Просмотр исходного кода

uncrustify

Signed-off-by: Martin Melik-Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik-Merkumians 2 лет назад
Родитель
Сommit
f6b2bc032d

+ 47 - 29
source/src/cip/cipcommon.c

@@ -1130,7 +1130,7 @@ EipStatus GetAttributeList(CipInstance *instance,
     CipAttributeStruct *attribute = NULL;
     CipAttributeStruct *attribute = NULL;
 
 
     CipOctet *attribute_count_responst_position =
     CipOctet *attribute_count_responst_position =
-        message_router_response->message.current_message_position;
+      message_router_response->message.current_message_position;
 
 
     MoveMessageNOctets(sizeof(CipInt), &message_router_response->message);  // move the message pointer to reserve memory
     MoveMessageNOctets(sizeof(CipInt), &message_router_response->message);  // move the message pointer to reserve memory
 
 
@@ -1139,20 +1139,28 @@ EipStatus GetAttributeList(CipInstance *instance,
       attribute = GetCipAttribute(instance, attribute_number);
       attribute = GetCipAttribute(instance, attribute_number);
 
 
       const int_fast64_t needed_message_space = NULL != attribute
       const int_fast64_t needed_message_space = NULL != attribute
-          ? (int_fast64_t) GetCipDataTypeLength(attribute->type, attribute->data) : (int_fast64_t) (2 * sizeof(CipSint));
-
-      const int_fast64_t remaining_message_space = (int_fast64_t) PC_OPENER_ETHERNET_BUFFER_SIZE - (int_fast64_t)  message_router_response->message.used_message_length - 33LL; //need 33 bytes extra space for the rest of the ENIP message
+          ? (int_fast64_t) GetCipDataTypeLength(attribute->type,
+                                                attribute->data) : (int_fast64_t) ( 
+                                                                                                   2
+                                                                                                   *
+                                                                                                   sizeof(
+                                                                                                     CipSint) );
+
+      const int_fast64_t remaining_message_space =
+        (int_fast64_t) PC_OPENER_ETHERNET_BUFFER_SIZE -
+        (int_fast64_t)  message_router_response->message.used_message_length -
+        33LL;                                                                                                                                                                   //need 33 bytes extra space for the rest of the ENIP message
       if (needed_message_space > remaining_message_space) {
       if (needed_message_space > remaining_message_space) {
         message_router_response->message.used_message_length -= 2;  // Correct count from Move above
         message_router_response->message.used_message_length -= 2;  // Correct count from Move above
         CipOctet *const save_current_position =
         CipOctet *const save_current_position =
-            message_router_response->message.current_message_position;
+          message_router_response->message.current_message_position;
         message_router_response->message.current_message_position =
         message_router_response->message.current_message_position =
-            attribute_count_responst_position;
+          attribute_count_responst_position;
         AddIntToMessage(attribute_count_request,
         AddIntToMessage(attribute_count_request,
                         &message_router_response
                         &message_router_response
-                             ->message);  // Add current amount of attributes
+                        ->message);       // Add current amount of attributes
         message_router_response->message.current_message_position =
         message_router_response->message.current_message_position =
-            save_current_position;
+          save_current_position;
         // If there was not alreay an attribute list error, resturn partial
         // If there was not alreay an attribute list error, resturn partial
         // transfer
         // transfer
         if (message_router_response->general_status !=
         if (message_router_response->general_status !=
@@ -1188,13 +1196,15 @@ EipStatus GetAttributeList(CipInstance *instance,
     }
     }
     // If we are there, we returned all elements
     // If we are there, we returned all elements
     message_router_response->message.used_message_length -= 2;  // Correct count from Move above
     message_router_response->message.used_message_length -= 2;  // Correct count from Move above
-    CipOctet *const save_current_position = message_router_response->message.current_message_position;
-    message_router_response->message.current_message_position = attribute_count_responst_position;
+    CipOctet *const save_current_position =
+      message_router_response->message.current_message_position;
+    message_router_response->message.current_message_position =
+      attribute_count_responst_position;
     AddIntToMessage(
     AddIntToMessage(
-        attribute_count_request,
-        &message_router_response->message);  // Add current amount of attributes
+      attribute_count_request,
+      &message_router_response->message);    // Add current amount of attributes
     message_router_response->message.current_message_position =
     message_router_response->message.current_message_position =
-        save_current_position;
+      save_current_position;
   } else {
   } else {
     message_router_response->general_status = kCipErrorAttributeListError;
     message_router_response->general_status = kCipErrorAttributeListError;
   }
   }
@@ -1226,7 +1236,7 @@ EipStatus SetAttributeList(CipInstance *instance,
     CipAttributeStruct *attribute = NULL;
     CipAttributeStruct *attribute = NULL;
 
 
     CipOctet *attribute_count_responst_position =
     CipOctet *attribute_count_responst_position =
-        message_router_response->message.current_message_position;
+      message_router_response->message.current_message_position;
 
 
     MoveMessageNOctets(sizeof(CipInt), &message_router_response->message);  // move the message pointer to reserve memory
     MoveMessageNOctets(sizeof(CipInt), &message_router_response->message);  // move the message pointer to reserve memory
 
 
@@ -1235,20 +1245,28 @@ EipStatus SetAttributeList(CipInstance *instance,
       attribute = GetCipAttribute(instance, attribute_number);
       attribute = GetCipAttribute(instance, attribute_number);
 
 
       const int_fast64_t needed_message_space = NULL != attribute
       const int_fast64_t needed_message_space = NULL != attribute
-          ? (int_fast64_t) GetCipDataTypeLength(attribute->type, attribute->data) : (int_fast64_t) (2 * sizeof(CipSint));
-
-      const int_fast64_t remaining_message_space = (int_fast64_t) PC_OPENER_ETHERNET_BUFFER_SIZE - (int_fast64_t)  message_router_response->message.used_message_length - 33LL; //need 33 bytes extra space for the rest of the ENIP message
+          ? (int_fast64_t) GetCipDataTypeLength(attribute->type,
+                                                attribute->data) : (int_fast64_t) ( 
+                                                                                                   2
+                                                                                                   *
+                                                                                                   sizeof(
+                                                                                                     CipSint) );
+
+      const int_fast64_t remaining_message_space =
+        (int_fast64_t) PC_OPENER_ETHERNET_BUFFER_SIZE -
+        (int_fast64_t)  message_router_response->message.used_message_length -
+        33LL;                                                                                                                                                                   //need 33 bytes extra space for the rest of the ENIP message
       if (needed_message_space > remaining_message_space) {
       if (needed_message_space > remaining_message_space) {
-         message_router_response->message.used_message_length -= 2;  // Correct count from Move above
+        message_router_response->message.used_message_length -= 2;   // Correct count from Move above
         CipOctet *const save_current_position =
         CipOctet *const save_current_position =
-            message_router_response->message.current_message_position;
+          message_router_response->message.current_message_position;
         message_router_response->message.current_message_position =
         message_router_response->message.current_message_position =
-            attribute_count_responst_position;
+          attribute_count_responst_position;
         AddIntToMessage(attribute_count_request,
         AddIntToMessage(attribute_count_request,
                         &message_router_response
                         &message_router_response
-                             ->message);  // Add current amount of attributes
+                        ->message);       // Add current amount of attributes
         message_router_response->message.current_message_position =
         message_router_response->message.current_message_position =
-            save_current_position;
+          save_current_position;
         // If there was not alreay an attribute list error, resturn partial
         // If there was not alreay an attribute list error, resturn partial
         // transfer
         // transfer
         if (message_router_response->general_status !=
         if (message_router_response->general_status !=
@@ -1257,7 +1275,7 @@ EipStatus SetAttributeList(CipInstance *instance,
         }
         }
         return kEipStatusOkSend;
         return kEipStatusOkSend;
       }
       }
-      
+
       AddIntToMessage(attribute_number, &message_router_response->message); // Attribute-ID
       AddIntToMessage(attribute_number, &message_router_response->message); // Attribute-ID
 
 
       if(NULL != attribute) {
       if(NULL != attribute) {
@@ -1296,16 +1314,16 @@ EipStatus SetAttributeList(CipInstance *instance,
     }
     }
     // If we are there, we returned all elements
     // If we are there, we returned all elements
     message_router_response->message.used_message_length -=
     message_router_response->message.used_message_length -=
-        2;  // Correct count from Move above
+      2;    // Correct count from Move above
     CipOctet *const save_current_position =
     CipOctet *const save_current_position =
-        message_router_response->message.current_message_position;
+      message_router_response->message.current_message_position;
     message_router_response->message.current_message_position =
     message_router_response->message.current_message_position =
-        attribute_count_responst_position;
+      attribute_count_responst_position;
     AddIntToMessage(
     AddIntToMessage(
-        attribute_count_request,
-        &message_router_response->message);  // Add current amount of attributes
+      attribute_count_request,
+      &message_router_response->message);    // Add current amount of attributes
     message_router_response->message.current_message_position =
     message_router_response->message.current_message_position =
-        save_current_position;
+      save_current_position;
   } else {
   } else {
     message_router_response->general_status = kCipErrorAttributeListError;
     message_router_response->general_status = kCipErrorAttributeListError;
   }
   }

+ 150 - 123
source/src/cip/cipioconnection.c

@@ -79,33 +79,30 @@ static EipUint8 s_produce_run_idle = 1;
 static EipUint8 s_produce_run_idle = 0;
 static EipUint8 s_produce_run_idle = 0;
 #endif
 #endif
 
 
-void CipRunIdleHeaderSetO2T(bool onoff)
-{
+void CipRunIdleHeaderSetO2T(bool onoff) {
   s_consume_run_idle = onoff;
   s_consume_run_idle = onoff;
 }
 }
 
 
-bool CipRunIdleHeaderGetO2T(void)
-{
+bool CipRunIdleHeaderGetO2T(void) {
   return s_consume_run_idle;
   return s_consume_run_idle;
 }
 }
 
 
-void CipRunIdleHeaderSetT2O(bool onoff)
-{
+void CipRunIdleHeaderSetT2O(bool onoff) {
   s_produce_run_idle = onoff;
   s_produce_run_idle = onoff;
 }
 }
 
 
-bool CipRunIdleHeaderGetT2O(void)
-{
+bool CipRunIdleHeaderGetT2O(void) {
   return s_produce_run_idle;
   return s_produce_run_idle;
 }
 }
 
 
-EipUint16 ProcessProductionInhibitTime(CipConnectionObject *io_connection_object)
-{
-  if(kConnectionObjectTransportClassTriggerProductionTriggerCyclic ==
-     ConnectionObjectGetTransportClassTriggerProductionTrigger(
-       io_connection_object) )
+EipUint16 ProcessProductionInhibitTime(
+  CipConnectionObject *io_connection_object) {
+  if( kConnectionObjectTransportClassTriggerProductionTriggerCyclic ==
+      ConnectionObjectGetTransportClassTriggerProductionTrigger(
+        io_connection_object) )
   {
   {
-    if(256 == ConnectionObjectGetProductionInhibitTime(io_connection_object) ) {
+    if( 256 ==
+        ConnectionObjectGetProductionInhibitTime(io_connection_object) ) {
       OPENER_TRACE_INFO("No PIT segment available\n");
       OPENER_TRACE_INFO("No PIT segment available\n");
       /* there was no PIT segment in the connection path; set PIT to one fourth of RPI */
       /* there was no PIT segment in the connection path; set PIT to one fourth of RPI */
       ConnectionObjectSetProductionInhibitTime(io_connection_object,
       ConnectionObjectSetProductionInhibitTime(io_connection_object,
@@ -113,9 +110,10 @@ EipUint16 ProcessProductionInhibitTime(CipConnectionObject *io_connection_object
                                                  io_connection_object) / 4000);
                                                  io_connection_object) / 4000);
     } else {
     } else {
       /* If a production inhibit time is provided, it needs to be smaller than the Requested Packet Interval */
       /* If a production inhibit time is provided, it needs to be smaller than the Requested Packet Interval */
-      if(ConnectionObjectGetProductionInhibitTime(io_connection_object) >
-         (ConnectionObjectGetTToORequestedPacketInterval(io_connection_object) /
-          1000) ) {
+      if( ConnectionObjectGetProductionInhibitTime(io_connection_object) >
+          (ConnectionObjectGetTToORequestedPacketInterval(io_connection_object)
+           /
+           1000) ) {
         /* see section C-1.4.3.3 */
         /* see section C-1.4.3.3 */
         return
         return
           kConnectionManagerExtendedStatusCodeProductionInhibitTimerGreaterThanRpi;
           kConnectionManagerExtendedStatusCodeProductionInhibitTimerGreaterThanRpi;
@@ -139,9 +137,9 @@ EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(
   CipClass *const assembly_class = GetCipClass(kCipAssemblyClassCode);
   CipClass *const assembly_class = GetCipClass(kCipAssemblyClassCode);
   CipInstance *instance = NULL;
   CipInstance *instance = NULL;
   if( NULL !=
   if( NULL !=
-      (instance =
-         GetCipInstance(assembly_class,
-                        io_connection_object->consumed_path.instance_id) ) ) {
+      ( instance =
+          GetCipInstance(assembly_class,
+                         io_connection_object->consumed_path.instance_id) ) ) {
     /* consuming Connection Point is present */
     /* consuming Connection Point is present */
     io_connection_object->consuming_instance = instance;
     io_connection_object->consuming_instance = instance;
     io_connection_object->consumed_connection_path_length = 6;
     io_connection_object->consumed_connection_path_length = 6;
@@ -160,9 +158,9 @@ EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(
                                                     kAssemblyObjectInstanceAttributeIdData);
                                                     kAssemblyObjectInstanceAttributeIdData);
     OPENER_ASSERT(attribute != NULL);
     OPENER_ASSERT(attribute != NULL);
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
-    if(kConnectionObjectTransportClassTriggerTransportClass1 ==
-       ConnectionObjectGetTransportClassTriggerTransportClass(
-         io_connection_object) )
+    if( kConnectionObjectTransportClassTriggerTransportClass1 ==
+        ConnectionObjectGetTransportClassTriggerTransportClass(
+          io_connection_object) )
     {
     {
       /* class 1 connection */
       /* class 1 connection */
       data_size -= 2; /* remove 16-bit sequence count length */
       data_size -= 2; /* remove 16-bit sequence count length */
@@ -191,44 +189,45 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
   CipConnectionObject *const io_connection_object,
   CipConnectionObject *const io_connection_object,
   CipConnectionObject *const RESTRICT connection_object) {
   CipConnectionObject *const RESTRICT connection_object) {
   DoublyLinkedListNode *node = connection_list.first;
   DoublyLinkedListNode *node = connection_list.first;
-  while(NULL != node &&
-        kConnectionObjectConnectionTypeMulticast ==
-        ConnectionObjectGetTToOConnectionType(io_connection_object) ) {
+  while( NULL != node &&
+         kConnectionObjectConnectionTypeMulticast ==
+         ConnectionObjectGetTToOConnectionType(io_connection_object) ) {
     CipConnectionObject *iterator = node->data;
     CipConnectionObject *iterator = node->data;
     if(io_connection_object->produced_path.instance_id ==
     if(io_connection_object->produced_path.instance_id ==
        iterator->produced_path.instance_id) {
        iterator->produced_path.instance_id) {
       //Check parameters
       //Check parameters
-      if(ConnectionObjectGetTToORequestedPacketInterval(io_connection_object) !=
-         ConnectionObjectGetTToORequestedPacketInterval(iterator) ) {
+      if( ConnectionObjectGetTToORequestedPacketInterval(io_connection_object)
+          !=
+          ConnectionObjectGetTToORequestedPacketInterval(iterator) ) {
         return kConnectionManagerExtendedStatusCodeErrorRpiValuesNotAcceptable;
         return kConnectionManagerExtendedStatusCodeErrorRpiValuesNotAcceptable;
       }
       }
-      if(ConnectionObjectGetTToOConnectionSizeType(io_connection_object) !=
-         ConnectionObjectGetTToOConnectionSizeType(iterator) ) {
+      if( ConnectionObjectGetTToOConnectionSizeType(io_connection_object) !=
+          ConnectionObjectGetTToOConnectionSizeType(iterator) ) {
         return
         return
           kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionFixVar;
           kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionFixVar;
       }
       }
-      if(ConnectionObjectGetTToOPriority(io_connection_object) !=
-         ConnectionObjectGetTToOPriority(iterator) ) {
+      if( ConnectionObjectGetTToOPriority(io_connection_object) !=
+          ConnectionObjectGetTToOPriority(iterator) ) {
         return
         return
           kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionPriority;
           kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionPriority;
       }
       }
 
 
-      if(ConnectionObjectGetTransportClassTriggerTransportClass(
-           io_connection_object) !=
-         ConnectionObjectGetTransportClassTriggerTransportClass(iterator) ) {
+      if( ConnectionObjectGetTransportClassTriggerTransportClass(
+            io_connection_object) !=
+          ConnectionObjectGetTransportClassTriggerTransportClass(iterator) ) {
         return kConnectionManagerExtendedStatusCodeMismatchedTransportClass;
         return kConnectionManagerExtendedStatusCodeMismatchedTransportClass;
       }
       }
 
 
-      if(ConnectionObjectGetTransportClassTriggerProductionTrigger(
-           io_connection_object)
-         != ConnectionObjectGetTransportClassTriggerProductionTrigger(iterator) )
+      if( ConnectionObjectGetTransportClassTriggerProductionTrigger(
+            io_connection_object)
+          != ConnectionObjectGetTransportClassTriggerProductionTrigger(iterator) )
       {
       {
         return
         return
           kConnectionManagerExtendedStatusCodeMismatchedTToOProductionTrigger;
           kConnectionManagerExtendedStatusCodeMismatchedTToOProductionTrigger;
       }
       }
 
 
-      if(ConnectionObjectGetProductionInhibitTime(io_connection_object) !=
-         ConnectionObjectGetProductionInhibitTime(iterator) ) {
+      if( ConnectionObjectGetProductionInhibitTime(io_connection_object) !=
+          ConnectionObjectGetProductionInhibitTime(iterator) ) {
         return
         return
           kConnectionManagerExtendedStatusCodeMismatchedTToOProductionInhibitTimeSegment;
           kConnectionManagerExtendedStatusCodeMismatchedTToOProductionInhibitTimeSegment;
       }
       }
@@ -242,9 +241,9 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
   CipClass *const assembly_class = GetCipClass(kCipAssemblyClassCode);
   CipClass *const assembly_class = GetCipClass(kCipAssemblyClassCode);
   CipInstance *instance = NULL;
   CipInstance *instance = NULL;
   if( NULL !=
   if( NULL !=
-      (instance =
-         GetCipInstance(assembly_class,
-                        io_connection_object->produced_path.instance_id) ) ) {
+      ( instance =
+          GetCipInstance(assembly_class,
+                         io_connection_object->produced_path.instance_id) ) ) {
 
 
     io_connection_object->producing_instance = instance;
     io_connection_object->producing_instance = instance;
     int data_size = ConnectionObjectGetTToOConnectionSize(io_connection_object);
     int data_size = ConnectionObjectGetTToOConnectionSize(io_connection_object);
@@ -256,9 +255,9 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
                                                     kAssemblyObjectInstanceAttributeIdData);
                                                     kAssemblyObjectInstanceAttributeIdData);
     OPENER_ASSERT(attribute != NULL);
     OPENER_ASSERT(attribute != NULL);
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
-    if(kConnectionObjectTransportClassTriggerTransportClass1 ==
-       ConnectionObjectGetTransportClassTriggerTransportClass(
-         io_connection_object) )
+    if( kConnectionObjectTransportClassTriggerTransportClass1 ==
+        ConnectionObjectGetTransportClassTriggerTransportClass(
+          io_connection_object) )
     {
     {
       /* class 1 connection */
       /* class 1 connection */
       data_size -= 2; /* remove 16-bit sequence count length */
       data_size -= 2; /* remove 16-bit sequence count length */
@@ -373,18 +372,17 @@ CipError EstablishIoConnection(
   return cip_error;
   return cip_error;
 }
 }
 
 
-static SocketAddressInfoItem* AllocateSocketAddressInfoItem(
+static SocketAddressInfoItem *AllocateSocketAddressInfoItem(
   CipCommonPacketFormatData *const common_packet_format_data,
   CipCommonPacketFormatData *const common_packet_format_data,
-  CipUint type)
-{
+  CipUint type) {
   const int address_info_item_size =
   const int address_info_item_size =
     sizeof(common_packet_format_data->address_info_item) /
     sizeof(common_packet_format_data->address_info_item) /
-      sizeof(common_packet_format_data->address_info_item[0]);
+    sizeof(common_packet_format_data->address_info_item[0]);
 
 
-  SocketAddressInfoItem* s = common_packet_format_data->address_info_item;
+  SocketAddressInfoItem *s = common_packet_format_data->address_info_item;
 
 
   for (int i = 0; i < address_info_item_size; i++) {
   for (int i = 0; i < address_info_item_size; i++) {
-    if((s->type_id == 0) || (s->type_id == type)) {
+    if( (s->type_id == 0) || (s->type_id == type) ) {
       return s;
       return s;
     }
     }
     s++;
     s++;
@@ -403,7 +401,7 @@ EipStatus OpenConsumingPointToPointConnection(
   CipConnectionObject *const connection_object,
   CipConnectionObject *const connection_object,
   CipCommonPacketFormatData *const common_packet_format_data) {
   CipCommonPacketFormatData *const common_packet_format_data) {
 
 
-  SocketAddressInfoItem* sock_addr_info =
+  SocketAddressInfoItem *sock_addr_info =
     AllocateSocketAddressInfoItem(common_packet_format_data,
     AllocateSocketAddressInfoItem(common_packet_format_data,
                                   kCipItemIdSocketAddressInfoOriginatorToTarget);
                                   kCipItemIdSocketAddressInfoOriginatorToTarget);
 
 
@@ -429,8 +427,8 @@ EipStatus OpenConsumingPointToPointConnection(
   connection_object->originator_address.sin_addr.s_addr = GetPeerAddress();
   connection_object->originator_address.sin_addr.s_addr = GetPeerAddress();
   connection_object->originator_address.sin_port = htons(kOpenerEipIoUdpPort);
   connection_object->originator_address.sin_port = htons(kOpenerEipIoUdpPort);
 
 
-  connection_object->socket[kUdpCommuncationDirectionConsuming] = 
-      g_network_status.udp_io_messaging;
+  connection_object->socket[kUdpCommuncationDirectionConsuming] =
+    g_network_status.udp_io_messaging;
 
 
   sock_addr_info->length = 16;
   sock_addr_info->length = 16;
   sock_addr_info->type_id = kCipItemIdSocketAddressInfoOriginatorToTarget;
   sock_addr_info->type_id = kCipItemIdSocketAddressInfoOriginatorToTarget;
@@ -445,10 +443,9 @@ EipStatus OpenConsumingPointToPointConnection(
 
 
 CipError OpenProducingPointToPointConnection(
 CipError OpenProducingPointToPointConnection(
   CipConnectionObject *connection_object,
   CipConnectionObject *connection_object,
-  CipCommonPacketFormatData *common_packet_format_data)
-{
+  CipCommonPacketFormatData *common_packet_format_data) {
   /* the default port to be used if no port information is part of the forward open request */
   /* the default port to be used if no port information is part of the forward open request */
-  in_port_t port = htons(kOpenerEipIoUdpPort); 
+  in_port_t port = htons(kOpenerEipIoUdpPort);
 
 
   if(kCipItemIdSocketAddressInfoTargetToOriginator ==
   if(kCipItemIdSocketAddressInfoTargetToOriginator ==
      common_packet_format_data->address_info_item[0].type_id) {
      common_packet_format_data->address_info_item[0].type_id) {
@@ -461,33 +458,32 @@ CipError OpenProducingPointToPointConnection(
   }
   }
 
 
   connection_object->remote_address.sin_family = AF_INET;
   connection_object->remote_address.sin_family = AF_INET;
-  connection_object->remote_address.sin_addr.s_addr = GetPeerAddress(); 
+  connection_object->remote_address.sin_addr.s_addr = GetPeerAddress();
   connection_object->remote_address.sin_port = port;
   connection_object->remote_address.sin_port = port;
 
 
   CipUsint qos_for_socket = ConnectionObjectGetTToOPriority(connection_object);
   CipUsint qos_for_socket = ConnectionObjectGetTToOPriority(connection_object);
   int error = SetQos(qos_for_socket);
   int error = SetQos(qos_for_socket);
   if (error != 0) {
   if (error != 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "cannot set QoS for UDP socket in OpenPointToPointConnection\n");
+      "cannot set QoS for UDP socket in OpenPointToPointConnection\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   connection_object->socket[kUdpCommuncationDirectionProducing] =
   connection_object->socket[kUdpCommuncationDirectionProducing] =
-      g_network_status.udp_io_messaging;
+    g_network_status.udp_io_messaging;
 
 
   return kCipErrorSuccess;
   return kCipErrorSuccess;
 }
 }
 
 
 EipStatus OpenProducingMulticastConnection(
 EipStatus OpenProducingMulticastConnection(
   CipConnectionObject *connection_object,
   CipConnectionObject *connection_object,
-  CipCommonPacketFormatData *common_packet_format_data)
-{
+  CipCommonPacketFormatData *common_packet_format_data) {
   /* Here we look for existing multi-cast IO connections only. */
   /* Here we look for existing multi-cast IO connections only. */
   CipConnectionObject *existing_connection_object =
   CipConnectionObject *existing_connection_object =
     GetExistingProducerIoConnection(true,
     GetExistingProducerIoConnection(true,
                                     connection_object->produced_path.instance_id);
                                     connection_object->produced_path.instance_id);
 
 
-  SocketAddressInfoItem* sock_addr_info =
+  SocketAddressInfoItem *sock_addr_info =
     AllocateSocketAddressInfoItem(common_packet_format_data,
     AllocateSocketAddressInfoItem(common_packet_format_data,
                                   kCipItemIdSocketAddressInfoTargetToOriginator);
                                   kCipItemIdSocketAddressInfoTargetToOriginator);
 
 
@@ -535,7 +531,7 @@ EipStatus OpenProducingMulticastConnection(
   connection_object->remote_address.sin_family = AF_INET;
   connection_object->remote_address.sin_family = AF_INET;
   connection_object->remote_address.sin_port = sock_addr_info->sin_port = port;
   connection_object->remote_address.sin_port = sock_addr_info->sin_port = port;
   connection_object->remote_address.sin_addr.s_addr = sock_addr_info->sin_addr =
   connection_object->remote_address.sin_addr.s_addr = sock_addr_info->sin_addr =
-      g_tcpip.mcast_config.starting_multicast_address;
+    g_tcpip.mcast_config.starting_multicast_address;
   memset(sock_addr_info->nasin_zero, 0, 8);
   memset(sock_addr_info->nasin_zero, 0, 8);
   sock_addr_info->sin_family = htons(AF_INET);
   sock_addr_info->sin_family = htons(AF_INET);
 
 
@@ -602,7 +598,8 @@ EipStatus OpenMulticastConnection(UdpCommuncationDirection direction,
      common_packet_format_data->address_info_item[j].type_id) {
      common_packet_format_data->address_info_item[j].type_id) {
     /* we are using an unused item initialize it with the default multicast address */
     /* we are using an unused item initialize it with the default multicast address */
     common_packet_format_data->address_info_item[j].sin_family = htons(AF_INET);
     common_packet_format_data->address_info_item[j].sin_family = htons(AF_INET);
-    common_packet_format_data->address_info_item[j].sin_port = htons(kOpenerEipIoUdpPort);
+    common_packet_format_data->address_info_item[j].sin_port = htons(
+      kOpenerEipIoUdpPort);
     common_packet_format_data->address_info_item[j].sin_addr =
     common_packet_format_data->address_info_item[j].sin_addr =
       g_tcpip.mcast_config.starting_multicast_address;
       g_tcpip.mcast_config.starting_multicast_address;
     memset(common_packet_format_data->address_info_item[j].nasin_zero, 0, 8);
     memset(common_packet_format_data->address_info_item[j].nasin_zero, 0, 8);
@@ -629,7 +626,7 @@ EipStatus OpenMulticastConnection(UdpCommuncationDirection direction,
   int error = SetQos(qos_for_socket);
   int error = SetQos(qos_for_socket);
   if (error != 0) {
   if (error != 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "cannot set QoS for UDP socket in OpenMulticastConnection\n");
+      "cannot set QoS for UDP socket in OpenMulticastConnection\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
   if (direction == kUdpCommuncationDirectionProducing) {
   if (direction == kUdpCommuncationDirectionProducing) {
@@ -662,8 +659,9 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
 
 
   if(0 != g_config_data_length) {
   if(0 != g_config_data_length) {
     OPENER_ASSERT(NULL != config_instance);
     OPENER_ASSERT(NULL != config_instance);
-    if(ConnectionWithSameConfigPointExists(connection_object->configuration_path
-                                           .instance_id) ) {
+    if( ConnectionWithSameConfigPointExists(connection_object->
+                                            configuration_path
+                                            .instance_id) ) {
       /* there is a connected connection with the same config point
       /* there is a connected connection with the same config point
        * we have to have the same data as already present in the config point*/
        * we have to have the same data as already present in the config point*/
       CipAttributeStruct *attribute_three = GetCipAttribute(config_instance, 3);
       CipAttributeStruct *attribute_three = GetCipAttribute(config_instance, 3);
@@ -678,8 +676,8 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
           "Hit an Ownership conflict in cipioconnection.c occurrence 1");
           "Hit an Ownership conflict in cipioconnection.c occurrence 1");
       } else {
       } else {
         /*FIXME check if this is correct */
         /*FIXME check if this is correct */
-        if(memcmp(attribute_three_data->data, g_config_data_buffer,
-                  g_config_data_length) ) {
+        if( memcmp(attribute_three_data->data, g_config_data_buffer,
+                   g_config_data_length) ) {
           connection_manager_status =
           connection_manager_status =
             kConnectionManagerExtendedStatusCodeErrorOwnershipConflict;
             kConnectionManagerExtendedStatusCodeErrorOwnershipConflict;
           OPENER_TRACE_INFO(
           OPENER_TRACE_INFO(
@@ -689,10 +687,10 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
     } else {
     } else {
       /* put the data on the configuration assembly object with the current
       /* put the data on the configuration assembly object with the current
          design this can be done rather efficiently */
          design this can be done rather efficiently */
-      if(kEipStatusOk !=
-         NotifyAssemblyConnectedDataReceived(config_instance,
-                                             g_config_data_buffer,
-                                             g_config_data_length) ) {
+      if( kEipStatusOk !=
+          NotifyAssemblyConnectedDataReceived(config_instance,
+                                              g_config_data_buffer,
+                                              g_config_data_length) ) {
         OPENER_TRACE_WARN("Configuration data was invalid\n");
         OPENER_TRACE_WARN("Configuration data was invalid\n");
         connection_manager_status =
         connection_manager_status =
           kConnectionManagerExtendedStatusCodeInvalidConfigurationApplicationPath;
           kConnectionManagerExtendedStatusCodeInvalidConfigurationApplicationPath;
@@ -709,43 +707,58 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
 static int transfer_master_connection(CipConnectionObject *connection_object) {
 static int transfer_master_connection(CipConnectionObject *connection_object) {
   CipConnectionObject *active;
   CipConnectionObject *active;
 
 
-  active = GetNextNonControlMasterConnection(connection_object->produced_path.instance_id);
-  if (!active)
+  active = GetNextNonControlMasterConnection(
+    connection_object->produced_path.instance_id);
+  if (!active) {
     return 1;
     return 1;
+  }
 
 
   OPENER_TRACE_INFO("Transferring socket ownership\n");
   OPENER_TRACE_INFO("Transferring socket ownership\n");
-  active->socket[kUdpCommuncationDirectionProducing] = connection_object->socket[kUdpCommuncationDirectionProducing];
-  connection_object->socket[kUdpCommuncationDirectionProducing] = kEipInvalidSocket;
+  active->socket[kUdpCommuncationDirectionProducing] =
+    connection_object->socket[kUdpCommuncationDirectionProducing];
+  connection_object->socket[kUdpCommuncationDirectionProducing] =
+    kEipInvalidSocket;
 
 
-  memcpy(&(active->remote_address), &(connection_object->remote_address), sizeof(active->remote_address));
-  active->eip_level_sequence_count_producing = connection_object->eip_level_sequence_count_producing;
-  active->sequence_count_producing = connection_object->sequence_count_producing;
-  active->transmission_trigger_timer = connection_object->transmission_trigger_timer;
+  memcpy( &(active->remote_address), &(connection_object->remote_address),
+          sizeof(active->remote_address) );
+  active->eip_level_sequence_count_producing =
+    connection_object->eip_level_sequence_count_producing;
+  active->sequence_count_producing =
+    connection_object->sequence_count_producing;
+  active->transmission_trigger_timer =
+    connection_object->transmission_trigger_timer;
 
 
   return 0;
   return 0;
 }
 }
 
 
 /* Always sync any changes with HandleIoConnectionTimeout() */
 /* Always sync any changes with HandleIoConnectionTimeout() */
 void CloseIoConnection(CipConnectionObject *RESTRICT connection_object) {
 void CloseIoConnection(CipConnectionObject *RESTRICT connection_object) {
-  ConnectionObjectInstanceType instance_type = ConnectionObjectGetInstanceType(connection_object);
-  ConnectionObjectConnectionType conn_type = ConnectionObjectGetTToOConnectionType(connection_object);
+  ConnectionObjectInstanceType instance_type = ConnectionObjectGetInstanceType(
+    connection_object);
+  ConnectionObjectConnectionType conn_type =
+    ConnectionObjectGetTToOConnectionType(connection_object);
 
 
   CheckIoConnectionEvent(connection_object->consumed_path.instance_id,
   CheckIoConnectionEvent(connection_object->consumed_path.instance_id,
                          connection_object->produced_path.instance_id,
                          connection_object->produced_path.instance_id,
                          kIoConnectionEventClosed);
                          kIoConnectionEventClosed);
-  ConnectionObjectSetState(connection_object, kConnectionObjectStateNonExistent);
+  ConnectionObjectSetState(connection_object,
+                           kConnectionObjectStateNonExistent);
 
 
   if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type ||
   if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type ||
      kConnectionObjectInstanceTypeIOInputOnly == instance_type) {
      kConnectionObjectInstanceTypeIOInputOnly == instance_type) {
     if(kConnectionObjectConnectionTypeMulticast == conn_type &&
     if(kConnectionObjectConnectionTypeMulticast == conn_type &&
-       kEipInvalidSocket != connection_object->socket[kUdpCommuncationDirectionProducing]) {
-      OPENER_TRACE_INFO("Exclusive Owner or Input Only connection closed - Instance type: %d\n", instance_type);
+       kEipInvalidSocket !=
+       connection_object->socket[kUdpCommuncationDirectionProducing]) {
+      OPENER_TRACE_INFO(
+        "Exclusive Owner or Input Only connection closed - Instance type: %d\n",
+        instance_type);
 
 
-      if(transfer_master_connection(connection_object)) {
+      if( transfer_master_connection(connection_object) ) {
         /* No transfer, this was the last master connection, close all
         /* No transfer, this was the last master connection, close all
          * listen only connections listening on the port */
          * listen only connections listening on the port */
-        CloseAllConnectionsForInputWithSameType(connection_object->produced_path.instance_id,
-                                                kConnectionObjectInstanceTypeIOListenOnly);
+        CloseAllConnectionsForInputWithSameType(
+          connection_object->produced_path.instance_id,
+          kConnectionObjectInstanceTypeIOListenOnly);
       }
       }
     }
     }
   }
   }
@@ -755,8 +768,10 @@ void CloseIoConnection(CipConnectionObject *RESTRICT connection_object) {
 
 
 /* Always sync any changes with CloseIoConnection() */
 /* Always sync any changes with CloseIoConnection() */
 void HandleIoConnectionTimeOut(CipConnectionObject *connection_object) {
 void HandleIoConnectionTimeOut(CipConnectionObject *connection_object) {
-  ConnectionObjectInstanceType instance_type = ConnectionObjectGetInstanceType(connection_object);
-  ConnectionObjectConnectionType conn_type = ConnectionObjectGetTToOConnectionType(connection_object);
+  ConnectionObjectInstanceType instance_type = ConnectionObjectGetInstanceType(
+    connection_object);
+  ConnectionObjectConnectionType conn_type =
+    ConnectionObjectGetTToOConnectionType(connection_object);
   int handover = 0;
   int handover = 0;
 
 
   CheckIoConnectionEvent(connection_object->consumed_path.instance_id,
   CheckIoConnectionEvent(connection_object->consumed_path.instance_id,
@@ -764,33 +779,42 @@ void HandleIoConnectionTimeOut(CipConnectionObject *connection_object) {
                          kIoConnectionEventTimedOut);
                          kIoConnectionEventTimedOut);
   ConnectionObjectSetState(connection_object, kConnectionObjectStateTimedOut);
   ConnectionObjectSetState(connection_object, kConnectionObjectStateTimedOut);
 
 
-  if(connection_object->last_package_watchdog_timer == connection_object->inactivity_watchdog_timer)
+  if(connection_object->last_package_watchdog_timer ==
+     connection_object->inactivity_watchdog_timer) {
     CheckForTimedOutConnectionsAndCloseTCPConnections(connection_object,
     CheckForTimedOutConnectionsAndCloseTCPConnections(connection_object,
                                                       CloseEncapsulationSessionBySockAddr);
                                                       CloseEncapsulationSessionBySockAddr);
+  }
 
 
   if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type ||
   if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type ||
      kConnectionObjectInstanceTypeIOInputOnly == instance_type) {
      kConnectionObjectInstanceTypeIOInputOnly == instance_type) {
     if(kConnectionObjectConnectionTypeMulticast == conn_type &&
     if(kConnectionObjectConnectionTypeMulticast == conn_type &&
-       kEipInvalidSocket != connection_object->socket[kUdpCommuncationDirectionProducing]) {
-      OPENER_TRACE_INFO("Exclusive Owner or Input Only connection timed out - Instance type: %d\n", instance_type);
+       kEipInvalidSocket !=
+       connection_object->socket[kUdpCommuncationDirectionProducing]) {
+      OPENER_TRACE_INFO(
+        "Exclusive Owner or Input Only connection timed out - Instance type: %d\n",
+        instance_type);
       /* we are the controlling input only connection find a new controller*/
       /* we are the controlling input only connection find a new controller*/
 
 
-      if(transfer_master_connection(connection_object)) {
+      if( transfer_master_connection(connection_object) ) {
         /* No transfer, this was the last master connection, close all
         /* No transfer, this was the last master connection, close all
          * listen only connections listening on the port */
          * listen only connections listening on the port */
-        CloseAllConnectionsForInputWithSameType(connection_object->produced_path.instance_id,
-                                                kConnectionObjectInstanceTypeIOListenOnly);
+        CloseAllConnectionsForInputWithSameType(
+          connection_object->produced_path.instance_id,
+          kConnectionObjectInstanceTypeIOListenOnly);
       } else {
       } else {
-	handover = 1;
+        handover = 1;
       }
       }
     }
     }
   }
   }
 
 
-  if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type && !handover) {
-    CloseAllConnectionsForInputWithSameType(connection_object->produced_path.instance_id,
-                                            kConnectionObjectInstanceTypeIOInputOnly);
-    CloseAllConnectionsForInputWithSameType(connection_object->produced_path.instance_id,
-                                            kConnectionObjectInstanceTypeIOListenOnly);
+  if(kConnectionObjectInstanceTypeIOExclusiveOwner == instance_type &&
+     !handover) {
+    CloseAllConnectionsForInputWithSameType(
+      connection_object->produced_path.instance_id,
+      kConnectionObjectInstanceTypeIOInputOnly);
+    CloseAllConnectionsForInputWithSameType(
+      connection_object->produced_path.instance_id,
+      kConnectionObjectInstanceTypeIOListenOnly);
   }
   }
 
 
   ConnectionObjectSetState(connection_object, kConnectionObjectStateTimedOut);
   ConnectionObjectSetState(connection_object, kConnectionObjectStateTimedOut);
@@ -808,10 +832,10 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
 
 
   /* assembleCPFData */
   /* assembleCPFData */
   common_packet_format_data->item_count = 2;
   common_packet_format_data->item_count = 2;
-  if(kConnectionObjectTransportClassTriggerTransportClass0 !=
-     ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
+  if( kConnectionObjectTransportClassTriggerTransportClass0 !=
+      ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
   /* use Sequenced Address Items if not Connection Class 0 */
   /* use Sequenced Address Items if not Connection Class 0 */
-  {                                          
+  {
     common_packet_format_data->address_item.type_id =
     common_packet_format_data->address_item.type_id =
       kCipItemIdSequencedAddressItem;
       kCipItemIdSequencedAddressItem;
     common_packet_format_data->address_item.length = 8;
     common_packet_format_data->address_item.length = 8;
@@ -833,7 +857,7 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
   common_packet_format_data->data_item.length = 0;
   common_packet_format_data->data_item.length = 0;
 
 
   /* notify the application that data will be sent immediately after the call */
   /* notify the application that data will be sent immediately after the call */
-  if(BeforeAssemblyDataSend(connection_object->producing_instance) ) {
+  if( BeforeAssemblyDataSend(connection_object->producing_instance) ) {
     /* the data has changed increase sequence counter */
     /* the data has changed increase sequence counter */
     connection_object->sequence_count_producing++;
     connection_object->sequence_count_producing++;
   }
   }
@@ -855,8 +879,8 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
     common_packet_format_data->data_item.length += 4;
     common_packet_format_data->data_item.length += 4;
   }
   }
 
 
-  if(kConnectionObjectTransportClassTriggerTransportClass1 ==
-     ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
+  if( kConnectionObjectTransportClassTriggerTransportClass1 ==
+      ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
   {
   {
     common_packet_format_data->data_item.length += 2;
     common_packet_format_data->data_item.length += 2;
     AddIntToMessage(common_packet_format_data->data_item.length,
     AddIntToMessage(common_packet_format_data->data_item.length,
@@ -892,12 +916,12 @@ EipStatus HandleReceivedIoConnectionData(CipConnectionObject *connection_object,
   OPENER_TRACE_INFO("Starting data length: %d\n", data_length);
   OPENER_TRACE_INFO("Starting data length: %d\n", data_length);
   bool no_new_data = false;
   bool no_new_data = false;
   /* check class 1 sequence number*/
   /* check class 1 sequence number*/
-  if(kConnectionObjectTransportClassTriggerTransportClass1 ==
-     ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
+  if( kConnectionObjectTransportClassTriggerTransportClass1 ==
+      ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
   {
   {
-    EipUint16 sequence_buffer = GetUintFromMessage(&(data) );
-    if(SEQ_LEQ16(sequence_buffer,
-                 connection_object->sequence_count_consuming) ) {
+    EipUint16 sequence_buffer = GetUintFromMessage( &(data) );
+    if( SEQ_LEQ16(sequence_buffer,
+                  connection_object->sequence_count_consuming) ) {
       no_new_data = true;
       no_new_data = true;
     }
     }
     connection_object->sequence_count_consuming = sequence_buffer;
     connection_object->sequence_count_consuming = sequence_buffer;
@@ -908,7 +932,7 @@ EipStatus HandleReceivedIoConnectionData(CipConnectionObject *connection_object,
   if(data_length > 0) {
   if(data_length > 0) {
     /* we have no heartbeat connection */
     /* we have no heartbeat connection */
     if(s_consume_run_idle) {
     if(s_consume_run_idle) {
-      EipUint32 nRunIdleBuf = GetUdintFromMessage(&(data) );
+      EipUint32 nRunIdleBuf = GetUdintFromMessage( &(data) );
       OPENER_TRACE_INFO("Run/Idle handler: 0x%x\n", nRunIdleBuf);
       OPENER_TRACE_INFO("Run/Idle handler: 0x%x\n", nRunIdleBuf);
       const uint32_t kRunBitMask = 0x0001;
       const uint32_t kRunBitMask = 0x0001;
       if( (kRunBitMask & nRunIdleBuf) == 1 ) {
       if( (kRunBitMask & nRunIdleBuf) == 1 ) {
@@ -940,7 +964,7 @@ CipError OpenCommunicationChannels(CipConnectionObject *connection_object) {
 
 
   CipError cip_error = kCipErrorSuccess;
   CipError cip_error = kCipErrorSuccess;
   CreateUdpSocket(); /* open UDP socket for IO messaging*/
   CreateUdpSocket(); /* open UDP socket for IO messaging*/
-  
+
 /*get pointer to the CPF data, currently we have just one global instance of the struct. This may change in the future*/
 /*get pointer to the CPF data, currently we have just one global instance of the struct. This may change in the future*/
   CipCommonPacketFormatData *common_packet_format_data =
   CipCommonPacketFormatData *common_packet_format_data =
     &g_common_packet_format_data_item;
     &g_common_packet_format_data_item;
@@ -975,7 +999,7 @@ CipError OpenCommunicationChannels(CipConnectionObject *connection_object) {
   }
   }
 
 
   if(target_to_originator_connection_type ==
   if(target_to_originator_connection_type ==
-     kConnectionObjectConnectionTypeMulticast)  
+     kConnectionObjectConnectionTypeMulticast)
   /* Multicast producing */
   /* Multicast producing */
   {
   {
     if(OpenProducingMulticastConnection(connection_object,
     if(OpenProducingMulticastConnection(connection_object,
@@ -985,7 +1009,7 @@ CipError OpenCommunicationChannels(CipConnectionObject *connection_object) {
       return kCipErrorConnectionFailure;
       return kCipErrorConnectionFailure;
     }
     }
   } else if(target_to_originator_connection_type ==
   } else if(target_to_originator_connection_type ==
-            kConnectionObjectConnectionTypePointToPoint)  
+            kConnectionObjectConnectionTypePointToPoint)
   /* Point to Point producing */
   /* Point to Point producing */
   {
   {
 
 
@@ -1002,14 +1026,17 @@ CipError OpenCommunicationChannels(CipConnectionObject *connection_object) {
 void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(
 void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(
   CipConnectionObject *connection_object) {
   CipConnectionObject *connection_object) {
   if(kEipInvalidSocket !=
   if(kEipInvalidSocket !=
-      connection_object->socket[kUdpCommuncationDirectionConsuming])
+     connection_object->socket[kUdpCommuncationDirectionConsuming]) {
     CloseUdpSocket(connection_object->socket[kUdpCommuncationDirectionConsuming]);
     CloseUdpSocket(connection_object->socket[kUdpCommuncationDirectionConsuming]);
+  }
 
 
   if(kEipInvalidSocket !=
   if(kEipInvalidSocket !=
-      connection_object->socket[kUdpCommuncationDirectionProducing])
+     connection_object->socket[kUdpCommuncationDirectionProducing]) {
     CloseUdpSocket(connection_object->socket[kUdpCommuncationDirectionProducing]);
     CloseUdpSocket(connection_object->socket[kUdpCommuncationDirectionProducing]);
+  }
 
 
   RemoveFromActiveConnections(connection_object);
   RemoveFromActiveConnections(connection_object);
   ConnectionObjectInitializeEmpty(connection_object);
   ConnectionObjectInitializeEmpty(connection_object);
-  OPENER_TRACE_INFO("cipioconnection: CloseCommunicationChannelsAndRemoveFromActiveConnectionsList\n");
+  OPENER_TRACE_INFO(
+    "cipioconnection: CloseCommunicationChannelsAndRemoveFromActiveConnectionsList\n");
 }
 }

+ 50 - 49
source/src/opener_api.h

@@ -78,7 +78,8 @@ void GetHostName(CipString *hostname);
  * @param major unsigned 8 bit major revision
  * @param major unsigned 8 bit major revision
  * @param minor unsigned 8 bit minor revision
  * @param minor unsigned 8 bit minor revision
  */
  */
-void SetDeviceRevision(EipUint8 major, EipUint8 minor);
+void SetDeviceRevision(EipUint8 major,
+                       EipUint8 minor);
 
 
 /** @ingroup CIP_API
 /** @ingroup CIP_API
  * @brief Set the serial number of the device's identity object.
  * @brief Set the serial number of the device's identity object.
@@ -316,7 +317,7 @@ void InsertAttribute(CipInstance *const instance,
                      const EipUint16 attribute_number,
                      const EipUint16 attribute_number,
                      const EipUint8 cip_type,
                      const EipUint8 cip_type,
                      CipAttributeEncodeInMessage encode_function,
                      CipAttributeEncodeInMessage encode_function,
-					 CipAttributeDecodeFromMessage decode_function,
+                     CipAttributeDecodeFromMessage decode_function,
                      void *const data,
                      void *const data,
                      const EipByte cip_flags);
                      const EipByte cip_flags);
 
 
@@ -470,76 +471,76 @@ void EncodeCipEthernetLinkPhyisicalAddress(const void *const data,
  *          -1 .. error
  *          -1 .. error
  */
  */
 int DecodeCipBool(CipBool *const data,
 int DecodeCipBool(CipBool *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipByte(CipByte *const data,
 int DecodeCipByte(CipByte *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipByteArray(CipByteArray *const data,
 int DecodeCipByteArray(CipByteArray *const data,
-			const CipMessageRouterRequest *const message_router_request,
-			CipMessageRouterResponse *const message_router_response);
+                       const CipMessageRouterRequest *const message_router_request,
+                       CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipWord(CipWord *const data,
 int DecodeCipWord(CipWord *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipDword(CipDword *const data,
 int DecodeCipDword(CipDword *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipLword(CipLword *const data,
 int DecodeCipLword(CipLword *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipUsint(CipUsint *const data,
 int DecodeCipUsint(CipUsint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipUint(CipUint *const data,
 int DecodeCipUint(CipUint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipUdint(CipUdint *const data,
 int DecodeCipUdint(CipUdint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipUlint(CipUlint *const data,
 int DecodeCipUlint(CipUlint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipSint(CipSint *const data,
 int DecodeCipSint(CipSint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipInt(CipInt *const data,
 int DecodeCipInt(CipInt *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                 const CipMessageRouterRequest *const message_router_request,
+                 CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipDint(CipDint *const data,
 int DecodeCipDint(CipDint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipLint(CipLint *const data,
 int DecodeCipLint(CipLint *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipReal(CipReal *const data,
 int DecodeCipReal(CipReal *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                  const CipMessageRouterRequest *const message_router_request,
+                  CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipLreal(CipLreal *const data,
 int DecodeCipLreal(CipLreal *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                   const CipMessageRouterRequest *const message_router_request,
+                   CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipString(CipString *const data,
 int DecodeCipString(CipString *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                    const CipMessageRouterRequest *const message_router_request,
+                    CipMessageRouterResponse *const message_router_response);
 
 
 int DecodeCipShortString(CipShortString *const data,
 int DecodeCipShortString(CipShortString *const data,
-		const CipMessageRouterRequest *const message_router_request,
-		CipMessageRouterResponse *const message_router_response);
+                         const CipMessageRouterRequest *const message_router_request,
+                         CipMessageRouterResponse *const message_router_response);
 
 
 /** @ingroup CIP_API
 /** @ingroup CIP_API
  * @brief Create an instance of an assembly object
  * @brief Create an instance of an assembly object
@@ -614,12 +615,12 @@ typedef EipStatus (*ConnectionSendDataFunction)(CipConnectionObject *
  * @return Stack status
  * @return Stack status
  */
  */
 typedef EipStatus (*ConnectionReceiveDataFunction)(CipConnectionObject *
 typedef EipStatus (*ConnectionReceiveDataFunction)(CipConnectionObject *
-                                                  connection_object,
-                                                  const EipUint8 *data,
-                                                  const EipUint16 data_length);
+                                                   connection_object,
+                                                   const EipUint8 *data,
+                                                   const EipUint16 data_length);
 
 
- /** @ingroup CIP_API
- * @brief Function pointer for timeout checker functions 
+/** @ingroup CIP_API
+ * @brief Function pointer for timeout checker functions
  *
  *
  * @param elapsed_time elapsed time since last check
  * @param elapsed_time elapsed time since last check
  */
  */
@@ -751,8 +752,8 @@ EipStatus HandleReceivedExplictUdpData(const int socket_handle,
  *  @return EIP_OK on success
  *  @return EIP_OK on success
  */
  */
 EipStatus HandleReceivedConnectedData(const EipUint8 *const received_data,
 EipStatus HandleReceivedConnectedData(const EipUint8 *const received_data,
-                            int received_data_length,
-                            struct sockaddr_in *from_address);
+                                      int received_data_length,
+                                      struct sockaddr_in *from_address);
 
 
 /** @ingroup CIP_API
 /** @ingroup CIP_API
  * @brief Check if any of the connection timers (TransmissionTrigger or
  * @brief Check if any of the connection timers (TransmissionTrigger or
@@ -789,7 +790,7 @@ EipStatus ManageConnections(MilliSeconds elapsed_time);
  * @return EIP_OK on success
  * @return EIP_OK on success
  */
  */
 EipStatus TriggerConnections(unsigned int output_assembly_id,
 EipStatus TriggerConnections(unsigned int output_assembly_id,
-                   unsigned int input_assembly_id);
+                             unsigned int input_assembly_id);
 
 
 /** @ingroup CIP_API
 /** @ingroup CIP_API
  * @brief Inform the encapsulation layer that the remote host has closed the
  * @brief Inform the encapsulation layer that the remote host has closed the
@@ -927,10 +928,10 @@ void CipFree(void *data);
 void RunIdleChanged(EipUint32 run_idle_value);
 void RunIdleChanged(EipUint32 run_idle_value);
 
 
 /** @ingroup CIP_CALLBACK_API
 /** @ingroup CIP_CALLBACK_API
- * @brief Create the UDP socket for the implicit IO messaging, 
+ * @brief Create the UDP socket for the implicit IO messaging,
  * one socket handles all connections
  * one socket handles all connections
  * @return the socket handle if successful, else kEipInvalidSocket
  * @return the socket handle if successful, else kEipInvalidSocket
-*/ 
+ */
 int CreateUdpSocket(void);
 int CreateUdpSocket(void);
 
 
 /** @ingroup CIP_CALLBACK_API
 /** @ingroup CIP_CALLBACK_API
@@ -940,7 +941,7 @@ int CreateUdpSocket(void);
  * @return kEipStatusOk on success
  * @return kEipStatusOk on success
  */
  */
 EipStatus SendUdpData(const struct sockaddr_in *const socket_data,
 EipStatus SendUdpData(const struct sockaddr_in *const socket_data,
-            const ENIPMessage *const outgoing_message);
+                      const ENIPMessage *const outgoing_message);
 
 
 /** @ingroup CIP_CALLBACK_API
 /** @ingroup CIP_CALLBACK_API
  * @brief Close the given socket and clean up the stack
  * @brief Close the given socket and clean up the stack

+ 163 - 142
source/src/ports/generic_networkhandler.c

@@ -52,7 +52,8 @@ const uint16_t kOpenerEthernetPort = 0xAF12;
 
 
 #ifndef MSG_NOSIGNAL
 #ifndef MSG_NOSIGNAL
 #define MSG_NOSIGNAL 0
 #define MSG_NOSIGNAL 0
-#define MSG_NOSIGNAL_PRAGMA_MESSAGE "MSG_NOSIGNAL not defined. Check if your system stops on SIGPIPE, as this can happen with the send() function"
+#define MSG_NOSIGNAL_PRAGMA_MESSAGE \
+  "MSG_NOSIGNAL not defined. Check if your system stops on SIGPIPE, as this can happen with the send() function"
 #if defined(_WIN32)
 #if defined(_WIN32)
 #pragma message(MSG_NOSIGNAL_PRAGMA_MESSAGE)
 #pragma message(MSG_NOSIGNAL_PRAGMA_MESSAGE)
 #else
 #else
@@ -67,7 +68,7 @@ SocketTimer g_timestamps[OPENER_NUMBER_OF_SUPPORTED_SESSIONS];
 fd_set master_socket;
 fd_set master_socket;
 fd_set read_socket;
 fd_set read_socket;
 
 
-int highest_socket_handle; 
+int highest_socket_handle;
 int g_current_active_tcp_socket;
 int g_current_active_tcp_socket;
 
 
 struct timeval g_time_value;
 struct timeval g_time_value;
@@ -78,7 +79,7 @@ NetworkStatus g_network_status;
 
 
 /** @brief Size of the timeout checker function pointer array
 /** @brief Size of the timeout checker function pointer array
  */
  */
-#define OPENER_TIMEOUT_CHECKER_ARRAY_SIZE 10 
+#define OPENER_TIMEOUT_CHECKER_ARRAY_SIZE 10
 
 
 /** @brief function pointer array for timer checker functions
 /** @brief function pointer array for timer checker functions
  */
  */
@@ -121,7 +122,7 @@ void RemoveSocketTimerFromList(const int socket_handle);
 
 
 EipStatus NetworkHandlerInitialize(void) {
 EipStatus NetworkHandlerInitialize(void) {
 
 
-  if(kEipStatusOk != NetworkHandlerInitializePlatform() ) {
+  if( kEipStatusOk != NetworkHandlerInitializePlatform() ) {
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
@@ -142,129 +143,138 @@ EipStatus NetworkHandlerInitialize(void) {
   FD_ZERO(&read_socket);
   FD_ZERO(&read_socket);
 
 
   /* create a new TCP socket */
   /* create a new TCP socket */
-  if( (g_network_status.tcp_listener =
-         socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) ) == -1 ) {
+  if( ( g_network_status.tcp_listener =
+          socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) ) == -1 ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler tcp_listener: error allocating socket, %d - %s\n",
-        error_code,
-        error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler tcp_listener: error allocating socket, %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   int set_socket_option_value = 1; //Represents true for used set socket options
   int set_socket_option_value = 1; //Represents true for used set socket options
   /* Activates address reuse */
   /* Activates address reuse */
-  if(setsockopt(g_network_status.tcp_listener, SOL_SOCKET, SO_REUSEADDR,
-                (char *) &set_socket_option_value,
-                sizeof(set_socket_option_value) ) == -1) {
+  if(setsockopt( g_network_status.tcp_listener, SOL_SOCKET, SO_REUSEADDR,
+                 (char *) &set_socket_option_value,
+                 sizeof(set_socket_option_value) ) == -1) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler tcp_listener: error setting socket option SO_REUSEADDR\n");
+      "networkhandler tcp_listener: error setting socket option SO_REUSEADDR\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   if(SetSocketToNonBlocking(g_network_status.tcp_listener) < 0) {
   if(SetSocketToNonBlocking(g_network_status.tcp_listener) < 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler tcp_listener: error setting socket to non-blocking on new socket\n");
+      "networkhandler tcp_listener: error setting socket to non-blocking on new socket\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* create a new UDP socket */
   /* create a new UDP socket */
-  if( (g_network_status.udp_global_broadcast_listener =
-         socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ) == kEipInvalidSocket ) {
+  if( ( g_network_status.udp_global_broadcast_listener =
+          socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ) == kEipInvalidSocket ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_global_broadcast_listener: error allocating socket, %d - %s\n",
-        error_code,
-        error_message);
+      "networkhandler udp_global_broadcast_listener: error allocating socket, %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* create a new UDP socket */
   /* create a new UDP socket */
-  if( (g_network_status.udp_unicast_listener =
-         socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ) == kEipInvalidSocket ) {
+  if( ( g_network_status.udp_unicast_listener =
+          socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ) == kEipInvalidSocket ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler udp_unicast_listener: error allocating socket, %d - %s\n",
-        error_code, error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler udp_unicast_listener: error allocating socket, %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* Activates address reuse */
   /* Activates address reuse */
   set_socket_option_value = 1;
   set_socket_option_value = 1;
-  if(setsockopt(g_network_status.udp_global_broadcast_listener, SOL_SOCKET,
-                SO_REUSEADDR, (char *) &set_socket_option_value,
-                sizeof(set_socket_option_value) )
+  if(setsockopt( g_network_status.udp_global_broadcast_listener, SOL_SOCKET,
+                 SO_REUSEADDR, (char *) &set_socket_option_value,
+                 sizeof(set_socket_option_value) )
      == -1) {
      == -1) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_global_broadcast_listener: error setting socket option SO_REUSEADDR\n");
+      "networkhandler udp_global_broadcast_listener: error setting socket option SO_REUSEADDR\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   if(SetSocketToNonBlocking(g_network_status.udp_global_broadcast_listener) <
   if(SetSocketToNonBlocking(g_network_status.udp_global_broadcast_listener) <
      0) {
      0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_global_broadcast_listener: error setting socket to non-blocking on new socket\n");
+      "networkhandler udp_global_broadcast_listener: error setting socket to non-blocking on new socket\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* Activates address reuse */
   /* Activates address reuse */
   set_socket_option_value = 1;
   set_socket_option_value = 1;
-  if(setsockopt(g_network_status.udp_unicast_listener, SOL_SOCKET, SO_REUSEADDR,
-                (char *) &set_socket_option_value,
-                sizeof(set_socket_option_value) ) == -1) {
+  if(setsockopt( g_network_status.udp_unicast_listener, SOL_SOCKET,
+                 SO_REUSEADDR,
+                 (char *) &set_socket_option_value,
+                 sizeof(set_socket_option_value) ) == -1) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_unicast_listener: error setting socket option SO_REUSEADDR\n");
+      "networkhandler udp_unicast_listener: error setting socket option SO_REUSEADDR\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   if(SetSocketToNonBlocking(g_network_status.udp_unicast_listener) < 0) {
   if(SetSocketToNonBlocking(g_network_status.udp_unicast_listener) < 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_unicast_listener: error setting socket to non-blocking\n");
+      "networkhandler udp_unicast_listener: error setting socket to non-blocking\n");
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   struct sockaddr_in my_address = {
   struct sockaddr_in my_address = {
     .sin_family = AF_INET,
     .sin_family = AF_INET,
     .sin_port = htons(kOpenerEthernetPort),
     .sin_port = htons(kOpenerEthernetPort),
-    .sin_addr.s_addr = g_network_status.ip_address};
+    .sin_addr.s_addr = g_network_status.ip_address
+  };
 
 
   /* bind the new socket to port 0xAF12 (CIP) */
   /* bind the new socket to port 0xAF12 (CIP) */
-  if( (bind(g_network_status.tcp_listener, (struct sockaddr *) &my_address,
-            sizeof(struct sockaddr) ) ) == -1 ) {
+  if( ( bind( g_network_status.tcp_listener, (struct sockaddr *) &my_address,
+              sizeof(struct sockaddr) ) ) == -1 ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler tcp_listener: error with TCP bind: %d - %s\n", error_code,
-        error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler tcp_listener: error with TCP bind: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
-  if( (bind(g_network_status.udp_unicast_listener,
-            (struct sockaddr *) &my_address,
-            sizeof(struct sockaddr) ) ) == -1 ) {
+  if( ( bind( g_network_status.udp_unicast_listener,
+              (struct sockaddr *) &my_address,
+              sizeof(struct sockaddr) ) ) == -1 ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR( "networkhandler udp_unicast_listener: error with UDP bind: %d - %s\n",
-        error_code, error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler udp_unicast_listener: error with UDP bind: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* have QoS DSCP explicit appear on UDP responses to unicast messages */
   /* have QoS DSCP explicit appear on UDP responses to unicast messages */
-  if(SetQosOnSocket(g_network_status.udp_unicast_listener,
-                    CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
+  if(SetQosOnSocket( g_network_status.udp_unicast_listener,
+                     CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
      != 0) {
      != 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_unicast_listener: error set QoS %d: %d - %s\n",
-        g_network_status.udp_unicast_listener,
-        error_code,
-        error_message);
+      "networkhandler udp_unicast_listener: error set QoS %d: %d - %s\n",
+      g_network_status.udp_unicast_listener,
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     /* print message but don't abort by intent */
     /* print message but don't abort by intent */
   }
   }
@@ -272,46 +282,49 @@ EipStatus NetworkHandlerInitialize(void) {
   struct sockaddr_in global_broadcast_address = {
   struct sockaddr_in global_broadcast_address = {
     .sin_family = AF_INET,
     .sin_family = AF_INET,
     .sin_port = htons(kOpenerEthernetPort),
     .sin_port = htons(kOpenerEthernetPort),
-    .sin_addr.s_addr = htonl(INADDR_ANY)};
+    .sin_addr.s_addr = htonl(INADDR_ANY)
+  };
 
 
   /* enable the UDP socket to receive broadcast messages */
   /* enable the UDP socket to receive broadcast messages */
   set_socket_option_value = 1;
   set_socket_option_value = 1;
-  if(0 >
-     setsockopt(g_network_status.udp_global_broadcast_listener, SOL_SOCKET,
-                SO_BROADCAST, (char *) &set_socket_option_value,
-                sizeof(int) ) ) {
+  if( 0 >
+      setsockopt( g_network_status.udp_global_broadcast_listener, SOL_SOCKET,
+                  SO_BROADCAST, (char *) &set_socket_option_value,
+                  sizeof(int) ) ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_global_broadcast_listener: error with setting broadcast receive: %d - %s\n",
-        error_code, error_message);
+      "networkhandler udp_global_broadcast_listener: error with setting broadcast receive: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
-  if( (bind(g_network_status.udp_global_broadcast_listener,
-            (struct sockaddr *) &global_broadcast_address,
-            sizeof(struct sockaddr) ) ) == -1 ) {
+  if( ( bind( g_network_status.udp_global_broadcast_listener,
+              (struct sockaddr *) &global_broadcast_address,
+              sizeof(struct sockaddr) ) ) == -1 ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler udp_global_broadcast_listener: error with UDP bind: %d - %s\n",
-        error_code,
-        error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler udp_global_broadcast_listener: error with UDP bind: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
 
 
   /* have QoS DSCP explicit appear on UDP responses to broadcast messages */
   /* have QoS DSCP explicit appear on UDP responses to broadcast messages */
-  if(SetQosOnSocket(g_network_status.udp_global_broadcast_listener,
-                    CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
+  if(SetQosOnSocket( g_network_status.udp_global_broadcast_listener,
+                     CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
      != 0) {
      != 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_global_broadcast_listener: error set QoS %d: %d - %s\n",
-        g_network_status.udp_global_broadcast_listener,
-        error_code,
-        error_message);
+      "networkhandler udp_global_broadcast_listener: error set QoS %d: %d - %s\n",
+      g_network_status.udp_global_broadcast_listener,
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     /* print message but don't abort by intent */
     /* print message but don't abort by intent */
   }
   }
@@ -319,28 +332,29 @@ EipStatus NetworkHandlerInitialize(void) {
   /* Make QoS DSCP explicit already appear on SYN connection establishment.
   /* Make QoS DSCP explicit already appear on SYN connection establishment.
    * A newly accept()ed TCP socket inherits the setting from this socket.
    * A newly accept()ed TCP socket inherits the setting from this socket.
    */
    */
-  if(SetQosOnSocket(g_network_status.tcp_listener,
-                    CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
+  if(SetQosOnSocket( g_network_status.tcp_listener,
+                     CipQosGetDscpPriority(kConnectionObjectPriorityExplicit) )
      != 0) {
      != 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler tcp_listener: error set QoS %d: %d - %s\n",
-        g_network_status.tcp_listener,
-        error_code,
-        error_message);
+      "networkhandler tcp_listener: error set QoS %d: %d - %s\n",
+      g_network_status.tcp_listener,
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     /* print message but don't abort by intent */
     /* print message but don't abort by intent */
   }
   }
 
 
   /* switch socket in listen mode */
   /* switch socket in listen mode */
-  if( (listen(g_network_status.tcp_listener,
-              MAX_NO_OF_TCP_SOCKETS) ) == -1 ) {
+  if( ( listen(g_network_status.tcp_listener,
+               MAX_NO_OF_TCP_SOCKETS) ) == -1 ) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler tcp_listener: error with listen: %d - %s\n",
-        error_code,
-        error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler tcp_listener: error with listen: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
@@ -376,9 +390,9 @@ void CloseTcpSocket(int socket_handle) {
 
 
 void RemoveSocketTimerFromList(const int socket_handle) {
 void RemoveSocketTimerFromList(const int socket_handle) {
   SocketTimer *socket_timer = NULL;
   SocketTimer *socket_timer = NULL;
-  while(NULL != (socket_timer = SocketTimerArrayGetSocketTimer(g_timestamps,
-                                                               OPENER_NUMBER_OF_SUPPORTED_SESSIONS,
-                                                               socket_handle) ) )
+  while( NULL != ( socket_timer = SocketTimerArrayGetSocketTimer(g_timestamps,
+                                                                 OPENER_NUMBER_OF_SUPPORTED_SESSIONS,
+                                                                 socket_handle) ) )
   {
   {
     SocketTimerClear(socket_timer);
     SocketTimerClear(socket_timer);
   }
   }
@@ -386,8 +400,8 @@ void RemoveSocketTimerFromList(const int socket_handle) {
 
 
 EipBool8 CheckSocketSet(int socket) {
 EipBool8 CheckSocketSet(int socket) {
   EipBool8 return_value = false;
   EipBool8 return_value = false;
-  if(FD_ISSET(socket, &read_socket) ) {
-    if(FD_ISSET(socket, &master_socket) ) {
+  if( FD_ISSET(socket, &read_socket) ) {
+    if( FD_ISSET(socket, &master_socket) ) {
       return_value = true;
       return_value = true;
     } else {
     } else {
       OPENER_TRACE_INFO("socket: %d closed with pending message\n", socket);
       OPENER_TRACE_INFO("socket: %d closed with pending message\n", socket);
@@ -401,7 +415,7 @@ EipBool8 CheckSocketSet(int socket) {
 void CheckAndHandleTcpListenerSocket(void) {
 void CheckAndHandleTcpListenerSocket(void) {
   int new_socket = kEipInvalidSocket;
   int new_socket = kEipInvalidSocket;
   /* see if this is a connection request to the TCP listener*/
   /* see if this is a connection request to the TCP listener*/
-  if(true == CheckSocketSet(g_network_status.tcp_listener) ) {
+  if( true == CheckSocketSet(g_network_status.tcp_listener) ) {
     OPENER_TRACE_INFO("networkhandler: new TCP connection\n");
     OPENER_TRACE_INFO("networkhandler: new TCP connection\n");
 
 
     new_socket = accept(g_network_status.tcp_listener, NULL, NULL);
     new_socket = accept(g_network_status.tcp_listener, NULL, NULL);
@@ -480,9 +494,9 @@ EipStatus NetworkHandlerProcessCyclic(void) {
     CheckAndHandleConsumingUdpSocket();
     CheckAndHandleConsumingUdpSocket();
 
 
     for(int socket = 0; socket <= highest_socket_handle; socket++) {
     for(int socket = 0; socket <= highest_socket_handle; socket++) {
-      if(true == CheckSocketSet(socket) ) {
+      if( true == CheckSocketSet(socket) ) {
         /* if it is still checked it is a TCP receive */
         /* if it is still checked it is a TCP receive */
-        if(kEipStatusError == HandleDataOnTcpSocket(socket) ) /* if error */
+        if( kEipStatusError == HandleDataOnTcpSocket(socket) ) /* if error */
         {
         {
           CloseTcpSocket(socket);
           CloseTcpSocket(socket);
           RemoveSession(socket); /* clean up session and close the socket */
           RemoveSession(socket); /* clean up session and close the socket */
@@ -531,7 +545,7 @@ EipStatus NetworkHandlerFinish(void) {
 
 
 void CheckAndHandleUdpGlobalBroadcastSocket(void) {
 void CheckAndHandleUdpGlobalBroadcastSocket(void) {
   /* see if this is an unsolicited inbound UDP message */
   /* see if this is an unsolicited inbound UDP message */
-  if(true == CheckSocketSet(g_network_status.udp_global_broadcast_listener) ) {
+  if( true == CheckSocketSet(g_network_status.udp_global_broadcast_listener) ) {
     struct sockaddr_in from_address = { 0 };
     struct sockaddr_in from_address = { 0 };
     socklen_t from_address_length = sizeof(from_address);
     socklen_t from_address_length = sizeof(from_address);
 
 
@@ -582,10 +596,10 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
         OPENER_TRACE_INFO("UDP broadcast reply sent:\n");
         OPENER_TRACE_INFO("UDP broadcast reply sent:\n");
 
 
         /* if the active socket matches a registered UDP callback, handle a UDP packet */
         /* 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) )
+        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) {
            != outgoing_message.used_message_length) {
           OPENER_TRACE_INFO(
           OPENER_TRACE_INFO(
             "networkhandler: UDP response was not fully sent\n");
             "networkhandler: UDP response was not fully sent\n");
@@ -597,7 +611,7 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
 
 
 void CheckAndHandleUdpUnicastSocket(void) {
 void CheckAndHandleUdpUnicastSocket(void) {
   /* see if this is an unsolicited inbound UDP message */
   /* see if this is an unsolicited inbound UDP message */
-  if(true == CheckSocketSet(g_network_status.udp_unicast_listener) ) {
+  if( true == CheckSocketSet(g_network_status.udp_unicast_listener) ) {
 
 
     struct sockaddr_in from_address = { 0 };
     struct sockaddr_in from_address = { 0 };
     socklen_t from_address_length = sizeof(from_address);
     socklen_t from_address_length = sizeof(from_address);
@@ -648,11 +662,11 @@ void CheckAndHandleUdpUnicastSocket(void) {
         OPENER_TRACE_INFO("UDP unicast reply sent:\n");
         OPENER_TRACE_INFO("UDP unicast reply sent:\n");
 
 
         /* if the active socket matches a registered UDP callback, handle a UDP packet */
         /* 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) ) !=
+        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) {
            outgoing_message.used_message_length) {
           OPENER_TRACE_INFO(
           OPENER_TRACE_INFO(
             "networkhandler: UDP unicast response was not fully sent\n");
             "networkhandler: UDP unicast response was not fully sent\n");
@@ -669,22 +683,22 @@ EipStatus SendUdpData(const struct sockaddr_in *const address,
 #if defined(OPENER_TRACE_ENABLED)
 #if defined(OPENER_TRACE_ENABLED)
   static char ip_str[INET_ADDRSTRLEN];
   static char ip_str[INET_ADDRSTRLEN];
   OPENER_TRACE_INFO(
   OPENER_TRACE_INFO(
-      "UDP packet to be sent to: %s:%d\n",
-      inet_ntop(AF_INET, &address->sin_addr, ip_str, sizeof ip_str),
-      ntohs(address->sin_port));
+    "UDP packet to be sent to: %s:%d\n",
+    inet_ntop(AF_INET, &address->sin_addr, ip_str, sizeof ip_str),
+    ntohs(address->sin_port) );
 #endif
 #endif
 
 
-  int sent_length = sendto(g_network_status.udp_io_messaging,
-                           (char *)outgoing_message->message_buffer,
+  int sent_length = sendto( g_network_status.udp_io_messaging,
+                            (char *)outgoing_message->message_buffer,
                             outgoing_message->used_message_length, 0,
                             outgoing_message->used_message_length, 0,
-                            (struct sockaddr*) address, sizeof(*address));
+                            (struct sockaddr *) address, sizeof(*address) );
   if(sent_length < 0) {
   if(sent_length < 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler: error with sendto in SendUDPData: %d - %s\n",
-        error_code,
-        error_message);
+      "networkhandler: error with sendto in SendUDPData: %d - %s\n",
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return kEipStatusError;
     return kEipStatusError;
   }
   }
@@ -720,7 +734,9 @@ EipStatus HandleDataOnTcpSocket(int socket) {
                                                                    OPENER_NUMBER_OF_SUPPORTED_SESSIONS,
                                                                    OPENER_NUMBER_OF_SUPPORTED_SESSIONS,
                                                                    socket);
                                                                    socket);
   if(number_of_read_bytes == 0) {
   if(number_of_read_bytes == 0) {
-    OPENER_TRACE_ERR("networkhandler: socket: %d - connection closed by client.\n", socket);
+    OPENER_TRACE_ERR(
+      "networkhandler: socket: %d - connection closed by client.\n",
+      socket);
     RemoveSocketTimerFromList(socket);
     RemoveSocketTimerFromList(socket);
     RemoveSession(socket);
     RemoveSession(socket);
     return kEipStatusError;
     return kEipStatusError;
@@ -829,7 +845,7 @@ EipStatus HandleDataOnTcpSocket(int socket) {
     g_current_active_tcp_socket = socket;
     g_current_active_tcp_socket = socket;
 
 
     struct sockaddr sender_address;
     struct sockaddr sender_address;
-    memset(&sender_address, 0, sizeof(sender_address) );
+    memset( &sender_address, 0, sizeof(sender_address) );
     socklen_t fromlen = sizeof(sender_address);
     socklen_t fromlen = sizeof(sender_address);
     if(getpeername(socket, (struct sockaddr *) &sender_address, &fromlen) < 0) {
     if(getpeername(socket, (struct sockaddr *) &sender_address, &fromlen) < 0) {
       int error_code = GetSocketErrorNumber();
       int error_code = GetSocketErrorNumber();
@@ -910,7 +926,7 @@ int CreateUdpSocket(void) {
 
 
   if (SetSocketToNonBlocking(g_network_status.udp_io_messaging) < 0) {
   if (SetSocketToNonBlocking(g_network_status.udp_io_messaging) < 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler udp_io_messaging: error setting socket to non-blocking on new socket\n");
+      "networkhandler udp_io_messaging: error setting socket to non-blocking on new socket\n");
     CloseUdpSocket(g_network_status.udp_io_messaging);
     CloseUdpSocket(g_network_status.udp_io_messaging);
     OPENER_ASSERT(false);/* This should never happen! */
     OPENER_ASSERT(false);/* This should never happen! */
     return kEipInvalidSocket;
     return kEipInvalidSocket;
@@ -920,10 +936,10 @@ int CreateUdpSocket(void) {
                     g_network_status.udp_io_messaging);
                     g_network_status.udp_io_messaging);
 
 
   int option_value = 1;
   int option_value = 1;
-  if (setsockopt(g_network_status.udp_io_messaging, SOL_SOCKET, SO_REUSEADDR,
-                 (char *)&option_value, sizeof(option_value)) < 0) {
+  if (setsockopt( g_network_status.udp_io_messaging, SOL_SOCKET, SO_REUSEADDR,
+                  (char *)&option_value, sizeof(option_value) ) < 0) {
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "error setting socket option SO_REUSEADDR on %s UDP socket\n");
+      "error setting socket option SO_REUSEADDR on %s UDP socket\n");
     CloseUdpSocket(g_network_status.udp_io_messaging);
     CloseUdpSocket(g_network_status.udp_io_messaging);
     return kEipInvalidSocket;
     return kEipInvalidSocket;
   }
   }
@@ -932,14 +948,16 @@ int CreateUdpSocket(void) {
   struct sockaddr_in source_addr = {
   struct sockaddr_in source_addr = {
     .sin_family = AF_INET,
     .sin_family = AF_INET,
     .sin_addr.s_addr = htonl(INADDR_ANY),
     .sin_addr.s_addr = htonl(INADDR_ANY),
-    .sin_port = htons(kOpenerEipIoUdpPort)};
-  
-  if (bind(g_network_status.udp_io_messaging, (struct sockaddr *)&source_addr,
-           sizeof(source_addr)) < 0) {
+    .sin_port = htons(kOpenerEipIoUdpPort)
+  };
+
+  if (bind( g_network_status.udp_io_messaging, (struct sockaddr *)&source_addr,
+            sizeof(source_addr) ) < 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error on bind UDP for producing messages: %d - %s\n", error_code,
-        error_message);
+    OPENER_TRACE_ERR("error on bind UDP for producing messages: %d - %s\n",
+                     error_code,
+                     error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     CloseUdpSocket(g_network_status.udp_io_messaging);
     CloseUdpSocket(g_network_status.udp_io_messaging);
     return kEipInvalidSocket;
     return kEipInvalidSocket;
@@ -947,7 +965,7 @@ int CreateUdpSocket(void) {
 
 
   /* add new socket to the master list */
   /* add new socket to the master list */
   FD_SET(g_network_status.udp_io_messaging, &master_socket);
   FD_SET(g_network_status.udp_io_messaging, &master_socket);
- 
+
   if (g_network_status.udp_io_messaging > highest_socket_handle) {
   if (g_network_status.udp_io_messaging > highest_socket_handle) {
     OPENER_TRACE_INFO("New highest socket: %d\n",
     OPENER_TRACE_INFO("New highest socket: %d\n",
                       g_network_status.udp_io_messaging);
                       g_network_status.udp_io_messaging);
@@ -960,8 +978,8 @@ int CreateUdpSocket(void) {
  *
  *
  * @return 0 if successful, else the error code */
  * @return 0 if successful, else the error code */
 int SetQos(CipUsint qos_for_socket) {
 int SetQos(CipUsint qos_for_socket) {
-  if (SetQosOnSocket(g_network_status.udp_io_messaging,
-                     CipQosGetDscpPriority(qos_for_socket)) !=
+  if (SetQosOnSocket( g_network_status.udp_io_messaging,
+                      CipQosGetDscpPriority(qos_for_socket) ) !=
       0) { /* got error */
       0) { /* got error */
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
@@ -976,31 +994,31 @@ int SetQos(CipUsint qos_for_socket) {
  *
  *
  * @return 0 if successful, else the error code */
  * @return 0 if successful, else the error code */
 int SetSocketOptionsMulticastProduce(void) {
 int SetSocketOptionsMulticastProduce(void) {
-  if (g_tcpip.mcast_ttl_value != 1) { 
+  if (g_tcpip.mcast_ttl_value != 1) {
     /* we need to set a TTL value for the socket */
     /* we need to set a TTL value for the socket */
-    if (setsockopt(g_network_status.udp_io_messaging, IPPROTO_IP,
-                   IP_MULTICAST_TTL, NWBUF_CAST & g_tcpip.mcast_ttl_value,
-                   sizeof(g_tcpip.mcast_ttl_value)) < 0) {
+    if (setsockopt( g_network_status.udp_io_messaging, IPPROTO_IP,
+                    IP_MULTICAST_TTL, NWBUF_CAST & g_tcpip.mcast_ttl_value,
+                    sizeof(g_tcpip.mcast_ttl_value) ) < 0) {
       int error_code = GetSocketErrorNumber();
       int error_code = GetSocketErrorNumber();
       char *error_message = GetErrorMessage(error_code);
       char *error_message = GetErrorMessage(error_code);
       OPENER_TRACE_ERR(
       OPENER_TRACE_ERR(
-          "networkhandler: could not set the TTL to: %d, error: %d - %s\n",
-          g_tcpip.mcast_ttl_value, error_code, error_message);
+        "networkhandler: could not set the TTL to: %d, error: %d - %s\n",
+        g_tcpip.mcast_ttl_value, error_code, error_message);
       FreeErrorMessage(error_message);
       FreeErrorMessage(error_message);
       return error_code;
       return error_code;
     }
     }
   }
   }
   /* Need to specify the interface for outgoing multicast packets on a
   /* Need to specify the interface for outgoing multicast packets on a
-   device with multiple interfaces. */
+     device with multiple interfaces. */
   struct in_addr my_addr = {.s_addr = g_network_status.ip_address};
   struct in_addr my_addr = {.s_addr = g_network_status.ip_address};
   if (setsockopt(g_network_status.udp_io_messaging, IPPROTO_IP, IP_MULTICAST_IF,
   if (setsockopt(g_network_status.udp_io_messaging, IPPROTO_IP, IP_MULTICAST_IF,
                  NWBUF_CAST & my_addr.s_addr, sizeof my_addr.s_addr) < 0) {
                  NWBUF_CAST & my_addr.s_addr, sizeof my_addr.s_addr) < 0) {
     int error_code = GetSocketErrorNumber();
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR(
     OPENER_TRACE_ERR(
-        "networkhandler: could not set the multicast interface, error: %d "
-        "- %s\n",
-        error_code, error_message);
+      "networkhandler: could not set the multicast interface, error: %d "
+      "- %s\n",
+      error_code, error_message);
     FreeErrorMessage(error_message);
     FreeErrorMessage(error_message);
     return error_code;
     return error_code;
   }
   }
@@ -1038,17 +1056,21 @@ void CheckAndHandleConsumingUdpSocket(void) {
 
 
     if( (kEipInvalidSocket !=
     if( (kEipInvalidSocket !=
          current_connection_object->socket[kUdpCommuncationDirectionConsuming])
          current_connection_object->socket[kUdpCommuncationDirectionConsuming])
-        && (true ==
-            CheckSocketSet(current_connection_object->socket[
-                             kUdpCommuncationDirectionConsuming
-                           ]) ) ) {
+        && ( true ==
+             CheckSocketSet(current_connection_object->socket[
+                              kUdpCommuncationDirectionConsuming
+                            ]) ) ) {
       OPENER_TRACE_INFO("Processing UDP consuming message\n");
       OPENER_TRACE_INFO("Processing UDP consuming message\n");
       struct sockaddr_in from_address = { 0 };
       struct sockaddr_in from_address = { 0 };
       socklen_t from_address_length = sizeof(from_address);
       socklen_t from_address_length = sizeof(from_address);
       CipOctet incoming_message[PC_OPENER_ETHERNET_BUFFER_SIZE] = { 0 };
       CipOctet incoming_message[PC_OPENER_ETHERNET_BUFFER_SIZE] = { 0 };
 
 
-      int received_size = recvfrom(g_network_status.udp_io_messaging, NWBUF_CAST incoming_message, sizeof(incoming_message),
-        0, (struct sockaddr*) &from_address, &from_address_length);
+      int received_size = recvfrom(g_network_status.udp_io_messaging,
+                                   NWBUF_CAST incoming_message,
+                                   sizeof(incoming_message),
+                                   0,
+                                   (struct sockaddr *) &from_address,
+                                   &from_address_length);
       if(0 == received_size) {
       if(0 == received_size) {
         int error_code = GetSocketErrorNumber();
         int error_code = GetSocketErrorNumber();
         char *error_message = GetErrorMessage(error_code);
         char *error_message = GetErrorMessage(error_code);
@@ -1127,8 +1149,8 @@ void CheckEncapsulationInactivity(int socket_handle) {
       MilliSeconds diff_milliseconds = g_actual_time - SocketTimerGetLastUpdate(
       MilliSeconds diff_milliseconds = g_actual_time - SocketTimerGetLastUpdate(
         socket_timer);
         socket_timer);
 
 
-      if(diff_milliseconds >=
-         (MilliSeconds) (1000UL * g_tcpip.encapsulation_inactivity_timeout) ) {
+      if( diff_milliseconds >=
+          (MilliSeconds) (1000UL * g_tcpip.encapsulation_inactivity_timeout) ) {
 
 
         size_t encapsulation_session_handle =
         size_t encapsulation_session_handle =
           GetSessionFromSocket(socket_handle);
           GetSessionFromSocket(socket_handle);
@@ -1142,8 +1164,7 @@ void CheckEncapsulationInactivity(int socket_handle) {
   }
   }
 }
 }
 
 
-void RegisterTimeoutChecker(TimeoutCheckerFunction timeout_checker_function)
-{
+void RegisterTimeoutChecker(TimeoutCheckerFunction timeout_checker_function) {
   for (size_t i = 0; i < OPENER_TIMEOUT_CHECKER_ARRAY_SIZE; i++) {
   for (size_t i = 0; i < OPENER_TIMEOUT_CHECKER_ARRAY_SIZE; i++) {
     if (NULL == timeout_checker_array[i]) { // find empty array element
     if (NULL == timeout_checker_array[i]) { // find empty array element
       timeout_checker_array[i] = timeout_checker_function; // add function pointer to array
       timeout_checker_array[i] = timeout_checker_function; // add function pointer to array

+ 4 - 4
source/src/ports/nvdata/nvdata.c

@@ -38,7 +38,7 @@ EipStatus NvdataLoad(void) {
   EipStatus eip_status = NvQosLoad(&g_qos);
   EipStatus eip_status = NvQosLoad(&g_qos);
   if (kEipStatusError != eip_status) {
   if (kEipStatusError != eip_status) {
     eip_status =
     eip_status =
-      (kEipStatusError == NvQosStore(&g_qos) ) ? kEipStatusError : eip_status;
+      ( kEipStatusError == NvQosStore(&g_qos) ) ? kEipStatusError : eip_status;
   }
   }
 
 
   return eip_status;
   return eip_status;
@@ -67,7 +67,7 @@ EipStatus NvQosSetCallback(CipInstance *const instance,
 
 
   EipStatus status = kEipStatusOk;
   EipStatus status = kEipStatusOk;
 
 
-  if (0 != (kNvDataFunc & attribute->attribute_flags) ) {
+  if ( 0 != (kNvDataFunc & attribute->attribute_flags) ) {
     OPENER_TRACE_INFO("NV data update: %s, i %" PRIu32 ", a %" PRIu16 "\n",
     OPENER_TRACE_INFO("NV data update: %s, i %" PRIu32 ", a %" PRIu16 "\n",
                       instance->cip_class->class_name,
                       instance->cip_class->class_name,
                       instance->instance_number,
                       instance->instance_number,
@@ -95,9 +95,9 @@ EipStatus NvTcpipSetCallback(CipInstance *const instance,
                              CipByte service) {
                              CipByte service) {
   EipStatus status = kEipStatusOk;
   EipStatus status = kEipStatusOk;
 
 
-  if (0 != (kNvDataFunc & attribute->attribute_flags) ) {
+  if ( 0 != (kNvDataFunc & attribute->attribute_flags) ) {
     /* Workaround: Update only if service is not flagged. */
     /* Workaround: Update only if service is not flagged. */
-    if (0 == (0x80 & service) ) {
+    if ( 0 == (0x80 & service) ) {
       OPENER_TRACE_INFO("NV data update: %s, i %" PRIu32 ", a %" PRIu16 "\n",
       OPENER_TRACE_INFO("NV data update: %s, i %" PRIu32 ", a %" PRIu16 "\n",
                         instance->cip_class->class_name,
                         instance->cip_class->class_name,
                         instance->instance_number,
                         instance->instance_number,

+ 6 - 6
source/tests/cip/cipcommontests.cpp

@@ -41,21 +41,21 @@ TEST(CipCommon, EncodeCipByte) {
 TEST(CipCommon, EncodeCipWord) {
 TEST(CipCommon, EncodeCipWord) {
   const CipWord value = 53678U;
   const CipWord value = 53678U;
   EncodeCipWord(&value, &message);
   EncodeCipWord(&value, &message);
-  CHECK_EQUAL(value, *(CipWord *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipWord *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 2, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 2, message.current_message_position);
 }
 }
 
 
 TEST(CipCommon, EncodeCipDword) {
 TEST(CipCommon, EncodeCipDword) {
   const CipDword value = 5357678U;
   const CipDword value = 5357678U;
   EncodeCipDword(&value, &message);
   EncodeCipDword(&value, &message);
-  CHECK_EQUAL(value, *(CipDword *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipDword *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 4, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 4, message.current_message_position);
 }
 }
 
 
 TEST(CipCommon, EncodeCipLword) {
 TEST(CipCommon, EncodeCipLword) {
   const CipLword value = 8353457678U;
   const CipLword value = 8353457678U;
   EncodeCipLword(&value, &message);
   EncodeCipLword(&value, &message);
-  CHECK_EQUAL(value, *(CipLword *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipLword *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 8, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 8, message.current_message_position);
 }
 }
 
 
@@ -70,20 +70,20 @@ TEST(CipCommon, EncodeCipUsint) {
 TEST(CipCommon, EncodeCipUint) {
 TEST(CipCommon, EncodeCipUint) {
   const CipUint value = 42568U;
   const CipUint value = 42568U;
   EncodeCipUint(&value, &message);
   EncodeCipUint(&value, &message);
-  CHECK_EQUAL(value, *(CipUint *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipUint *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 2, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 2, message.current_message_position);
 }
 }
 
 
 TEST(CipCommon, EncodeCipUdint) {
 TEST(CipCommon, EncodeCipUdint) {
   const CipUdint value = 1653245U;
   const CipUdint value = 1653245U;
   EncodeCipUdint(&value, &message);
   EncodeCipUdint(&value, &message);
-  CHECK_EQUAL(value, *(CipUdint *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipUdint *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 4, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 4, message.current_message_position);
 }
 }
 
 
 TEST(CipCommon, EncodeCipUlint) {
 TEST(CipCommon, EncodeCipUlint) {
   const CipUlint value = 5357678U;
   const CipUlint value = 5357678U;
   EncodeCipUlint(&value, &message);
   EncodeCipUlint(&value, &message);
-  CHECK_EQUAL(value, *(CipUlint *)(message.message_buffer) );
+  CHECK_EQUAL( value, *(CipUlint *)(message.message_buffer) );
   POINTERS_EQUAL(message.message_buffer + 8, message.current_message_position);
   POINTERS_EQUAL(message.message_buffer + 8, message.current_message_position);
 }
 }

+ 1 - 1
source/tests/utils/doublylinkedlistTests.cpp

@@ -230,7 +230,7 @@ TEST(DoublyLinkedList, RemoveFirstElementInList) {
   DoublyLinkedListNode *node_to_be_deleted = list.first;
   DoublyLinkedListNode *node_to_be_deleted = list.first;
   DoublyLinkedListRemoveNode(&list, &node_to_be_deleted);
   DoublyLinkedListRemoveNode(&list, &node_to_be_deleted);
   CHECK_EQUAL(2, test_data_1);
   CHECK_EQUAL(2, test_data_1);
-  CHECK_EQUAL(4, *( (int *)list.first->data ) );
+  CHECK_EQUAL( 4, *( (int *)list.first->data ) );
   DoublyLinkedListDestroy(&list);
   DoublyLinkedListDestroy(&list);
 }
 }