瀏覽代碼

Merge branch 'master' of github.com:EIPStackGroup/OpENer

Martin Melik-Merkumians 2 年之前
父節點
當前提交
6d3cb51b7b

+ 59 - 54
source/src/ports/generic_networkhandler.c

@@ -578,34 +578,36 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
     int remaining_bytes = 0;
     ENIPMessage outgoing_message;
     InitializeENIPMessage(&outgoing_message);
-    do {
-      EipStatus need_to_send = HandleReceivedExplictUdpData(
-        g_network_status.udp_unicast_listener,
-        /* sending from unicast port, due to strange behavior of the broadcast port */
-        &from_address,
-        receive_buffer,
-        received_size,
-        &remaining_bytes,
-        false,
-        &outgoing_message);
-
-      receive_buffer += received_size - remaining_bytes;
-      received_size = remaining_bytes;
-
-      if(need_to_send > 0) {
-        OPENER_TRACE_INFO("UDP broadcast reply sent:\n");
-
-        /* if the active socket matches a registered UDP callback, handle a UDP packet */
-        if(sendto( g_network_status.udp_unicast_listener, /* sending from unicast port, due to strange behavior of the broadcast port */
-                   (char *) outgoing_message.message_buffer,
-                   outgoing_message.used_message_length, 0,
-                   (struct sockaddr *) &from_address, sizeof(from_address) )
-           != outgoing_message.used_message_length) {
-          OPENER_TRACE_INFO(
-            "networkhandler: UDP response was not fully sent\n");
-        }
+    EipStatus need_to_send = HandleReceivedExplictUdpData(
+      g_network_status.udp_unicast_listener,
+      /* sending from unicast port, due to strange behavior of the broadcast port */
+      &from_address,
+      receive_buffer,
+      received_size,
+      &remaining_bytes,
+      false,
+      &outgoing_message);
+
+    receive_buffer += received_size - remaining_bytes;
+    received_size = remaining_bytes;
+
+    if(need_to_send > 0) {
+      OPENER_TRACE_INFO("UDP broadcast reply sent:\n");
+
+      /* if the active socket matches a registered UDP callback, handle a UDP packet */
+      if(sendto( g_network_status.udp_unicast_listener,  /* sending from unicast port, due to strange behavior of the broadcast port */
+                 (char *) outgoing_message.message_buffer,
+                 outgoing_message.used_message_length, 0,
+                 (struct sockaddr *) &from_address, sizeof(from_address) )
+         != outgoing_message.used_message_length) {
+        OPENER_TRACE_INFO(
+          "networkhandler: UDP response was not fully sent\n");
       }
-    } while(remaining_bytes > 0);
+    }
+    if(remaining_bytes > 0) {
+      OPENER_TRACE_ERR("Request on broadcast UDP port had too many data (%d)",
+                       remaining_bytes);
+    }
   }
 }
 
@@ -645,34 +647,37 @@ void CheckAndHandleUdpUnicastSocket(void) {
     int remaining_bytes = 0;
     ENIPMessage outgoing_message;
     InitializeENIPMessage(&outgoing_message);
-    do {
-      EipStatus need_to_send = HandleReceivedExplictUdpData(
-        g_network_status.udp_unicast_listener,
-        &from_address,
-        receive_buffer,
-        received_size,
-        &remaining_bytes,
-        true,
-        &outgoing_message);
-
-      receive_buffer += received_size - remaining_bytes;
-      received_size = remaining_bytes;
-
-      if(need_to_send > 0) {
-        OPENER_TRACE_INFO("UDP unicast reply sent:\n");
-
-        /* if the active socket matches a registered UDP callback, handle a UDP packet */
-        if(sendto( g_network_status.udp_unicast_listener,
-                   (char *) outgoing_message.message_buffer,
-                   outgoing_message.used_message_length, 0,
-                   (struct sockaddr *) &from_address,
-                   sizeof(from_address) ) !=
-           outgoing_message.used_message_length) {
-          OPENER_TRACE_INFO(
-            "networkhandler: UDP unicast response was not fully sent\n");
-        }
+    EipStatus need_to_send = HandleReceivedExplictUdpData(
+      g_network_status.udp_unicast_listener,
+      &from_address,
+      receive_buffer,
+      received_size,
+      &remaining_bytes,
+      true,
+      &outgoing_message);
+
+    receive_buffer += received_size - remaining_bytes;
+    received_size = remaining_bytes;
+
+    if(need_to_send > 0) {
+      OPENER_TRACE_INFO("UDP unicast reply sent:\n");
+
+      /* if the active socket matches a registered UDP callback, handle a UDP packet */
+      if(sendto( g_network_status.udp_unicast_listener,
+                 (char *) outgoing_message.message_buffer,
+                 outgoing_message.used_message_length, 0,
+                 (struct sockaddr *) &from_address,
+                 sizeof(from_address) ) !=
+         outgoing_message.used_message_length) {
+        OPENER_TRACE_INFO(
+          "networkhandler: UDP unicast response was not fully sent\n");
       }
-    } while(remaining_bytes > 0);
+    }
+    if (remaining_bytes > 0) {
+      OPENER_TRACE_ERR(
+        "Request on broadcast UDP port had too many data (%d)",
+        remaining_bytes);
+    }
   }
 }
 

+ 11 - 0
source/src/ports/nvdata/conffile.c

@@ -83,7 +83,18 @@ static FILE *FopenMkdir(char *p_path,
     *sep = '/';
     VERBOSE(stdout, "%s", "\n");
   }
+
+/* Disable VS fopen depreciation warning. */
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif /* _MSC_VER */
+
   return fopen(p_path, mode);
+
+/* Restore default depreciation warning behavior. */
+#ifdef _MSC_VER
+#pragma warning(default : 4996)
+#endif /* _MSC_VER */
 }
 
 

+ 10 - 0
source/src/ports/nvdata/nvdata.c

@@ -65,6 +65,11 @@ EipStatus NvQosSetCallback(CipInstance *const instance,
   /* Suppress unused parameter compiler warning. */
   (void)service;
 
+  /* Suppress parameters used only for trace macros. */
+#ifndef OPENER_WITH_TRACES
+  (void)instance;
+#endif /* OPENER_WITH_TRACES */
+
   EipStatus status = kEipStatusOk;
 
   if ( 0 != (kNvDataFunc & attribute->attribute_flags) ) {
@@ -93,6 +98,11 @@ EipStatus NvQosSetCallback(CipInstance *const instance,
 EipStatus NvTcpipSetCallback(CipInstance *const instance,
                              CipAttributeStruct *const attribute,
                              CipByte service) {
+  /* Suppress parameters used only for trace macros. */
+#ifndef OPENER_WITH_TRACES
+  (void)instance;
+#endif /* OPENER_WITH_TRACES */
+
   EipStatus status = kEipStatusOk;
 
   if ( 0 != (kNvDataFunc & attribute->attribute_flags) ) {

+ 11 - 0
source/src/ports/nvdata/nvqos.c

@@ -40,6 +40,12 @@ int NvQosLoad(CipQosObject *p_qos) {
 
   FILE  *p_file = ConfFileOpen(false, QOS_CFG_NAME);
   if (NULL != p_file) {
+
+/* Disable VS fscanf depreciation warning. */
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif /* _MSC_VER */
+
     /* Read input data */
     rd_cnt = fscanf(p_file,
                     " %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 ", %" SCNu8 "\n",
@@ -49,6 +55,11 @@ int NvQosLoad(CipQosObject *p_qos) {
                     &dscp_low,
                     &dscp_explicit);
 
+/* Restore default depreciation warning behavior. */
+#ifdef _MSC_VER
+#pragma warning(default : 4996)
+#endif /* _MSC_VER */
+
     /* Need to try to close all stuff in any case. */
     eip_status = ConfFileClose(&p_file);
   }