- fixed bug in sv_subscriber: missing initialization of allocated memory
This commit is contained in:
parent
bae3de6bc3
commit
daf876e4df
7 changed files with 88 additions and 84 deletions
|
@ -23,6 +23,8 @@
|
|||
#define DEBUG_MMS_SERVER 0
|
||||
#define DEBUG_GOOSE_SUBSCRIBER 0
|
||||
#define DEBUG_GOOSE_PUBLISHER 0
|
||||
#define DEBUG_SV_SUBSCRIBER 0
|
||||
#define DEBUG_HAL_ETHERNET 0
|
||||
|
||||
/* Maximum MMS PDU SIZE - default is 65000 */
|
||||
#define CONFIG_MMS_MAXIMUM_PDU_SIZE 65000
|
||||
|
|
|
@ -5,8 +5,6 @@ set(goose_subscriber_example_SRCS
|
|||
|
||||
IF(WIN32)
|
||||
|
||||
IF(WITH_WPCAP)
|
||||
|
||||
set_source_files_properties(${goose_subscriber_example_SRCS}
|
||||
PROPERTIES LANGUAGE CXX)
|
||||
add_executable(goose_subscriber_example
|
||||
|
@ -17,8 +15,6 @@ target_link_libraries(goose_subscriber_example
|
|||
iec61850
|
||||
)
|
||||
|
||||
ENDIF(WITH_WPCAP)
|
||||
|
||||
ELSE(WIN32)
|
||||
|
||||
add_executable(goose_subscriber_example
|
||||
|
|
|
@ -5,20 +5,16 @@ set(sv_subscriber_example_SRCS
|
|||
|
||||
IF(WIN32)
|
||||
|
||||
IF(WITH_WPCAP)
|
||||
|
||||
set_source_files_properties(${sv_subscriber_example_SRCS}
|
||||
PROPERTIES LANGUAGE CXX)
|
||||
add_executable(sv_subscriber_example
|
||||
${sv_subscriber_example_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(svsubscriber_example
|
||||
target_link_libraries(sv_subscriber_example
|
||||
iec61850
|
||||
)
|
||||
|
||||
ENDIF(WITH_WPCAP)
|
||||
|
||||
ELSE(WIN32)
|
||||
|
||||
add_executable(sv_subscriber_example
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
LIBIEC_HOME=../../../libiec61850
|
||||
LIBIEC_HOME=../..
|
||||
|
||||
PROJECT_BINARY_NAME = sv_subscriber
|
||||
PROJECT_SOURCES += sv_subscriber_example.c
|
||||
|
|
|
@ -55,8 +55,8 @@ main(int argc, char** argv)
|
|||
SVReceiver receiver = SVReceiver_create();
|
||||
|
||||
if (argc > 1) {
|
||||
printf("Set interface id: %s\n", argv[1]);
|
||||
SVReceiver_setInterfaceId(receiver, argv[1]);
|
||||
printf("Set interface id: %s\n", argv[1]);
|
||||
}
|
||||
else {
|
||||
printf("Using interface eth0\n");
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
#include "libiec61850_platform_includes.h"
|
||||
|
||||
#ifndef DEBUG_HAL_ETHERNET
|
||||
#define DEBUG_HAL_ETHERNET 1
|
||||
#endif
|
||||
|
||||
#if (CONFIG_INCLUDE_ETHERNET_WINDOWS == 1)
|
||||
|
||||
|
||||
|
@ -95,11 +99,11 @@ loadDLLs(void)
|
|||
HINSTANCE hDll = LoadLibrary("iphlpapi.dll");
|
||||
|
||||
if (hDll == NULL) {
|
||||
if (DEBUG_HAL_ETHERNET)
|
||||
printf("Error loading iphlpapi.dll!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GetAdaptersAddresses = (pgetadaptersaddresses) GetProcAddress(hDll,
|
||||
"GetAdaptersAddresses");
|
||||
|
||||
|
@ -111,7 +115,6 @@ loadDLLs(void)
|
|||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
static char*
|
||||
getInterfaceName(int interfaceIndex)
|
||||
{
|
||||
|
@ -137,6 +140,7 @@ getInterfaceName(int interfaceIndex)
|
|||
if (i == interfaceIndex) {
|
||||
interfaceName = (char*) malloc(strlen(device->name) + 1);
|
||||
strcpy(interfaceName, device->name);
|
||||
if (DEBUG_HAL_ETHERNET)
|
||||
printf("Use interface (%s)\n", interfaceName);
|
||||
ifaceFound = true;
|
||||
break;
|
||||
|
@ -147,6 +151,7 @@ getInterfaceName(int interfaceIndex)
|
|||
|
||||
if (!ifaceFound)
|
||||
{
|
||||
if (DEBUG_HAL_ETHERNET)
|
||||
printf("No ethernet interfaces found! Make sure WinPcap is installed.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -180,13 +185,16 @@ getAdapterMacAddress(char* pcapAdapterName, uint8_t* macAddress)
|
|||
|
||||
int i;
|
||||
|
||||
if (DEBUG_HAL_ETHERNET) {
|
||||
printf("Adapter %s: ", pAddress->AdapterName);
|
||||
|
||||
for (i = 0; i < (int) addressLength; i++) {
|
||||
printf("%02x ", pAddress->PhysicalAddress[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr(pcapAdapterName, pAddress->AdapterName) != 0) {
|
||||
if (DEBUG_HAL_ETHERNET)
|
||||
printf(" requested found!");
|
||||
|
||||
for (i = 0; i < (int) addressLength; i++) {
|
||||
|
|
|
@ -80,7 +80,7 @@ struct sSVClientASDU {
|
|||
SVReceiver
|
||||
SVReceiver_create(void)
|
||||
{
|
||||
SVReceiver self = (SVReceiver) GLOBAL_MALLOC(sizeof(struct sSVReceiver));
|
||||
SVReceiver self = (SVReceiver) GLOBAL_CALLOC(1, sizeof(struct sSVReceiver));
|
||||
|
||||
if (self != NULL) {
|
||||
self->subscriberList = LinkedList_create();
|
||||
|
@ -180,6 +180,8 @@ SVReceiver_destroy(SVReceiver self)
|
|||
void
|
||||
SVReceiver_startThreadless(SVReceiver self)
|
||||
{
|
||||
printf("SVReceiver_startThreadless\n");
|
||||
|
||||
if (self->interfaceId == NULL)
|
||||
self->ethSocket = Ethernet_createSocket(CONFIG_ETHERNET_INTERFACE_ID, NULL);
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue