Bladeren bron

Uncrustify format update

Signed-off-by: Martin Melik Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik Merkumians 8 jaren geleden
bovenliggende
commit
ffb603bb1a
33 gewijzigde bestanden met toevoegingen van 322 en 210 verwijderingen
  1. 2 2
      source/contrib/msinttypes/inttypes.h
  2. 2 1
      source/src/cip/appcontype.h
  3. 12 6
      source/src/cip/cipclass3connection.c
  4. 6 2
      source/src/cip/cipclass3connection.h
  5. 1 1
      source/src/cip/cipcommon.c
  6. 2 1
      source/src/cip/cipconnectionmanager.h
  7. 19 10
      source/src/cip/cipelectronickey.c
  8. 14 7
      source/src/cip/cipelectronickey.h
  9. 112 70
      source/src/cip/cipepath.c
  10. 25 12
      source/src/cip/cipepath.h
  11. 5 5
      source/src/cip/cipidentity.c
  12. 23 21
      source/src/cip/cipmessagerouter.c
  13. 2 4
      source/src/cip/cipqos.c
  14. 9 7
      source/src/enet_encap/encap.c
  15. 11 6
      source/src/enet_encap/endianconv.c
  16. 12 6
      source/src/enet_encap/endianconv.h
  17. 5 6
      source/src/opener_api.h
  18. 1 1
      source/src/ports/POSIX/networkhandler.c
  19. 2 1
      source/src/ports/POSIX/networkhandler.h
  20. 2 1
      source/src/ports/POSIX/sample_application/sampleapplication.c
  21. 2 1
      source/src/ports/WIN32/main.c
  22. 1 1
      source/src/ports/WIN32/networkhandler.c
  23. 2 1
      source/src/ports/WIN32/networkhandler.h
  24. 2 1
      source/src/ports/WIN32/sample_application/sampleapplication.c
  25. 22 18
      source/src/ports/generic_networkhandler.c
  26. 2 1
      source/src/ports/opener_error.h
  27. 4 2
      source/src/ports/socket_timer.c
  28. 4 2
      source/src/ports/socket_timer.h
  29. 4 3
      source/src/utils/doublylinkedlist.c
  30. 2 1
      source/src/utils/doublylinkedlist.h
  31. 2 1
      source/tests/OpENerTests.cpp
  32. 7 7
      source/tests/cip/cipelectronickeytest.cpp
  33. 1 1
      source/tests/cip/cipepathtest.cpp

+ 2 - 2
source/contrib/msinttypes/inttypes.h

@@ -277,8 +277,8 @@ static
 #else // STATIC_IMAXDIV ][
 __inline
 #endif // STATIC_IMAXDIV ]
-imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
-{
+imaxdiv_t __cdecl imaxdiv(intmax_t numer,
+                          intmax_t denom) {
   imaxdiv_t result;
 
   result.quot = numer / denom;

+ 2 - 1
source/src/cip/appcontype.h

@@ -46,7 +46,8 @@ CipConnectionObject *GetExistingProducerMulticastConnection(
  * @return if a connection could be found the pointer to this connection
  *      otherwise NULL.
  */
-CipConnectionObject *GetNextNonControlMasterConnection(const EipUint32 input_point);
+CipConnectionObject *GetNextNonControlMasterConnection(
+  const EipUint32 input_point);
 
 /** @brief Close all connection producing the same input and have the same type
  * (i.e., listen only or input only).

+ 12 - 6
source/src/cip/cipclass3connection.c

@@ -34,14 +34,15 @@ EipStatus EstablishClass3Connection(
 
     ConnectionObjectGeneralConfiguration(explicit_connection);
 
-    ConnectionObjectSetInstanceType(explicit_connection, kConnectionObjectInstanceTypeExplicitMessaging);
+    ConnectionObjectSetInstanceType(explicit_connection,
+                                    kConnectionObjectInstanceTypeExplicitMessaging);
 
     /* set the connection call backs */
     explicit_connection->connection_close_function =
-    		CloseConnection;
+      CloseConnection;
     /* explicit connection have to be closed on time out*/
     explicit_connection->connection_timeout_function =
-    		CloseConnection;
+      CloseConnection;
 
     AddNewActiveConnection(explicit_connection);
   }
@@ -54,7 +55,8 @@ EipStatus EstablishClass3Connection(
  */
 CipConnectionObject *GetFreeExplicitConnection(void) {
   for (size_t i = 0; i < OPENER_CIP_NUM_EXPLICIT_CONNS; ++i) {
-    if (ConnectionObjectGetState(&(explicit_connection_object_pool[i])) == kConnectionObjectStateNonExistent) {
+    if (ConnectionObjectGetState(&(explicit_connection_object_pool[i]) ) ==
+        kConnectionObjectStateNonExistent) {
       return &(explicit_connection_object_pool[i]);
     }
   }
@@ -66,7 +68,9 @@ void InitializeClass3ConnectionData(void) {
           OPENER_CIP_NUM_EXPLICIT_CONNS * sizeof(CipConnectionObject) );
 }
 
-EipStatus CipClass3ConnectionObjectStateEstablishedHandler(CipConnectionObject *RESTRICT const connection_object, ConnectionObjectState new_state) {
+EipStatus CipClass3ConnectionObjectStateEstablishedHandler(
+  CipConnectionObject *RESTRICT const connection_object,
+  ConnectionObjectState new_state) {
   switch(new_state) {
     case kConnectionObjectStateNonExistent:
       ConnectionObjectInitializeEmpty(connection_object);
@@ -76,7 +80,9 @@ EipStatus CipClass3ConnectionObjectStateEstablishedHandler(CipConnectionObject *
   }
 }
 
-EipStatus CipClass3ConnectionObjectStateNonExistentHandler(CipConnectionObject *RESTRICT const connection_object, ConnectionObjectState new_state) {
+EipStatus CipClass3ConnectionObjectStateNonExistentHandler(
+  CipConnectionObject *RESTRICT const connection_object,
+  ConnectionObjectState new_state) {
   switch(new_state) {
     case kConnectionObjectStateEstablished:
       ConnectionObjectSetState(connection_object, new_state);

+ 6 - 2
source/src/cip/cipclass3connection.h

@@ -32,9 +32,13 @@
 #include "cipconnectionmanager.h"
 #include "cipconnectionobject.h"
 
-typedef EipStatus (*CipConnectionStateHandler)(CipConnectionObject *RESTRICT const connection_object, ConnectionObjectState new_state);
+typedef EipStatus (*CipConnectionStateHandler)(CipConnectionObject *RESTRICT
+                                               const connection_object,
+                                               ConnectionObjectState new_state);
 
-EipStatus CipClass3ConnectionObjectStateEstablishedHandler(CipConnectionObject *RESTRICT const connection_object, ConnectionObjectState new_state);
+EipStatus CipClass3ConnectionObjectStateEstablishedHandler(
+  CipConnectionObject *RESTRICT const connection_object,
+  ConnectionObjectState new_state);
 
 /** @brief Check if Class3 connection is available and if yes setup all data.
  *

+ 1 - 1
source/src/cip/cipcommon.c

@@ -542,7 +542,7 @@ int EncodeData(const EipUint8 cip_type,
     case (kCipUdintUdintUdintUdintUdintString): {
       /* TCP/IP attribute 5 */
       CipTcpIpNetworkInterfaceConfiguration *
-      tcp_ip_network_interface_configuration =
+        tcp_ip_network_interface_configuration =
         (CipTcpIpNetworkInterfaceConfiguration *) cip_data;
       counter += AddDintToMessage(
         ntohl(tcp_ip_network_interface_configuration->ip_address),

+ 2 - 1
source/src/cip/cipconnectionmanager.h

@@ -187,7 +187,8 @@ CipConnectionObject *GetConnectedObject(const EipUint32 connection_id);
  *   @return pointer to connected Object
  *           0 .. connection not present in device
  */
-CipConnectionObject *GetConnectedOutputAssembly(const EipUint32 output_assembly_id);
+CipConnectionObject *GetConnectedOutputAssembly(
+  const EipUint32 output_assembly_id);
 
 /** @brief Close the given connection
  *

+ 19 - 10
source/src/cip/cipelectronickey.c

@@ -8,15 +8,18 @@
 
 #include "cipelectronickey.h"
 
-void ElectronicKeySetKeyFormat(CipElectronicKey *const electronic_key, const CipUsint key_format) {
+void ElectronicKeySetKeyFormat(CipElectronicKey *const electronic_key,
+                               const CipUsint key_format) {
   electronic_key->key_format = key_format;
 }
 
-CipUint ElectronicKeyGetKeyFormat(const CipElectronicKey *const electronic_key) {
+CipUint ElectronicKeyGetKeyFormat(const CipElectronicKey *const electronic_key)
+{
   return electronic_key->key_format;
 }
 
-void ElectronicKeySetKeyData(CipElectronicKey *const electronic_key, void *key_data) {
+void ElectronicKeySetKeyData(CipElectronicKey *const electronic_key,
+                             void *key_data) {
   electronic_key->key_data = key_data;
 }
 
@@ -43,7 +46,8 @@ void ElectronicKeyFormat4Delete(ElectronicKeyFormat4 **electronic_key) {
   *electronic_key = NULL;
 }
 
-void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key, const CipUint vendor_id) {
+void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key,
+                                     const CipUint vendor_id) {
   electronic_key->vendor_id = vendor_id;
 }
 
@@ -52,7 +56,9 @@ CipUint ElectronicKeyFormat4GetVendorId(
   return electronic_key->vendor_id;
 }
 
-void ElectronicKeyFormat4SetDeviceType(ElectronicKeyFormat4 *const electronic_key, const CipUint device_type) {
+void ElectronicKeyFormat4SetDeviceType(
+  ElectronicKeyFormat4 *const electronic_key,
+  const CipUint device_type) {
   electronic_key->device_type = device_type;
 }
 
@@ -61,8 +67,9 @@ CipUint ElectronicKeyFormat4GetDeviceType(
   return electronic_key->device_type;
 }
 
-void ElectronicKeyFormat4SetProductCode(ElectronicKeyFormat4 *const electronic_key, const CipUint product_code)
-{
+void ElectronicKeyFormat4SetProductCode(
+  ElectronicKeyFormat4 *const electronic_key,
+  const CipUint product_code) {
   electronic_key->product_code = product_code;
 }
 
@@ -72,8 +79,8 @@ CipUint ElectronicKeyFormat4GetProductCode(
 }
 
 void ElectronicKeyFormat4SetMajorRevisionCompatibility(
-    ElectronicKeyFormat4 *const electronic_key,
-    const CipByte major_revision_compatibility) {
+  ElectronicKeyFormat4 *const electronic_key,
+  const CipByte major_revision_compatibility) {
   electronic_key->major_revision_compatibility = major_revision_compatibility;
 }
 
@@ -93,7 +100,9 @@ bool ElectronicKeyFormat4GetMajorRevisionCompatibility(
   return false;
 }
 
-void ElectronicKeyFormat4SetMinorRevision(ElectronicKeyFormat4 *const electronic_key, const CipUsint minor_revision) {
+void ElectronicKeyFormat4SetMinorRevision(
+  ElectronicKeyFormat4 *const electronic_key,
+  const CipUsint minor_revision) {
   electronic_key->minor_revision = minor_revision;
 }
 

+ 14 - 7
source/src/cip/cipelectronickey.h

@@ -21,15 +21,19 @@ typedef struct {
                           specified in CIP Specification, Volume 1*/
 } CipElectronicKey;
 
-void ElectronicKeySetSegmentType(CipElectronicKey *const electronic_key, const CipUsint segment_type);
+void ElectronicKeySetSegmentType(CipElectronicKey *const electronic_key,
+                                 const CipUsint segment_type);
 
-CipUsint ElectronicKeyGetSegmentType(const CipElectronicKey *const electronic_key);
+CipUsint ElectronicKeyGetSegmentType(
+  const CipElectronicKey *const electronic_key);
 
-void ElectronicKeySetKeyFormat(CipElectronicKey *const electronic_key, const CipUsint key_format);
+void ElectronicKeySetKeyFormat(CipElectronicKey *const electronic_key,
+                               const CipUsint key_format);
 
 CipUint ElectronicKeyGetKeyFormat(const CipElectronicKey *const electronic_key);
 
-void ElectronicKeySetKeyData(CipElectronicKey *const electronic_key, void *key_data);
+void ElectronicKeySetKeyData(CipElectronicKey *const electronic_key,
+                             void *key_data);
 
 void *ElectronicKeyGetKeyData(const CipElectronicKey *const electronic_key);
 
@@ -44,7 +48,8 @@ extern const size_t kElectronicKeyFormat4Size;
  *
  *	@return A new unset electronic key
  */
-ElectronicKeyFormat4 *ElectronicKeyFormat4New();
+ElectronicKeyFormat4 *ElectronicKeyFormat4New(
+  );
 
 /** @brief Destructor for the electroic key format 4 class
  *
@@ -58,7 +63,8 @@ void ElectronicKeyFormat4Delete(ElectronicKeyFormat4 **electronic_key);
  *	@param vendor_id The vendor ID to be set into the electronic key
  *	@param electronic_key The electronic key to be set - will be modified
  */
-void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key, const CipUint vendor_id);
+void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key,
+                                     const CipUint vendor_id);
 
 /** @brief Gets the vendor ID form the electronic key
  *
@@ -74,7 +80,8 @@ CipUint ElectronicKeyFormat4GetVendorId(
  *	@param electronic_key A format 4 electronic key
  */
 void ElectronicKeyFormat4SetDeviceType(
-  ElectronicKeyFormat4 *const electronic_key, const CipUint device_type);
+  ElectronicKeyFormat4 *const electronic_key,
+  const CipUint device_type);
 
 /** @brief Gets the device type from a format 4 electronic key
  *

+ 112 - 70
source/src/cip/cipepath.c

@@ -194,7 +194,8 @@ unsigned int GetPathPortSegmentExtendedPortNumber(
 }
 
 void SetPathPortSegmentExtendedPortIdentifier(
-  const unsigned int extended_port_identifier, CipOctet *const cip_path) {
+  const unsigned int extended_port_identifier,
+  CipOctet *const cip_path) {
   SetPathPortSegmentPortIdentifier(kPortSegmentExtendedPort, cip_path);
   const unsigned int kExtendedPortSegmentPosition =
     GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
@@ -246,38 +247,39 @@ LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
   return result;
 }
 
-void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, CipOctet *const cip_path) {
+void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type,
+                                      CipOctet *const cip_path) {
   OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
   switch (logical_type) {
-      case kLogicalSegmentLogicalTypeClassId:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_CLASS_ID;
-        break;
-      case kLogicalSegmentLogicalTypeInstanceId:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_INSTANCE_ID;
-        break;
-      case kLogicalSegmentLogicalTypeMemberId:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_MEMBER_ID;
-        break;
-      case kLogicalSegmentLogicalTypeConnectionPoint:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_CONNECTION_POINT;
-        break;
-      case kLogicalSegmentLogicalTypeAttributeId:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID;
-        break;
-      case kLogicalSegmentLogicalTypeSpecial:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_SPECIAL;
-        break;
-      case kLogicalSegmentLogicalTypeServiceId:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_SERVICE_ID;
-        break;
-      case kLogicalSegmentLogicalTypeExtendedLogical:
-        (*cip_path) |= LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL;
-        break;
-      default:
-        OPENER_ASSERT(
-          "Logical segment/logical type: It is not possible to reach this point!\n");
-        break;
-    }
+    case kLogicalSegmentLogicalTypeClassId:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_CLASS_ID;
+      break;
+    case kLogicalSegmentLogicalTypeInstanceId:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_INSTANCE_ID;
+      break;
+    case kLogicalSegmentLogicalTypeMemberId:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_MEMBER_ID;
+      break;
+    case kLogicalSegmentLogicalTypeConnectionPoint:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_CONNECTION_POINT;
+      break;
+    case kLogicalSegmentLogicalTypeAttributeId:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID;
+      break;
+    case kLogicalSegmentLogicalTypeSpecial:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_SPECIAL;
+      break;
+    case kLogicalSegmentLogicalTypeServiceId:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_SERVICE_ID;
+      break;
+    case kLogicalSegmentLogicalTypeExtendedLogical:
+      (*cip_path) |= LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL;
+      break;
+    default:
+      OPENER_ASSERT(
+        "Logical segment/logical type: It is not possible to reach this point!\n");
+      break;
+  }
 }
 
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
@@ -304,8 +306,10 @@ LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   return result;
 }
 
-void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipOctet *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType((const CipOctet *)cip_path) );
+void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format,
+                                        CipOctet *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeLogicalSegment ==
+                 GetPathSegmentType( (const CipOctet *)cip_path ) );
   switch (format) {
     case kLogicalSegmentLogicalFormatEightBit:
       (*cip_path) |= LOGICAL_SEGMENT_FORMAT_EIGHT_BIT;
@@ -324,12 +328,13 @@ void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipO
 }
 
 const CipDword CipEpathGetLogicalValue(const EipUint8 **message) {
-  LogicalSegmentLogicalFormat logical_format = GetPathLogicalSegmentLogicalFormat(*message);
+  LogicalSegmentLogicalFormat logical_format =
+    GetPathLogicalSegmentLogicalFormat(*message);
   CipDword data = 0;
   MoveMessageNOctets(1, message); /* Move to logical value */
-  switch (logical_format){
+  switch (logical_format) {
     case kLogicalSegmentLogicalFormatEightBit:
-    	data = GetSintFromMessage(message);
+      data = GetSintFromMessage(message);
       break;
     case kLogicalSegmentLogicalFormatSixteenBit:
       MoveMessageNOctets(1, message); /* Pad byte needs to be skipped */
@@ -345,11 +350,24 @@ const CipDword CipEpathGetLogicalValue(const EipUint8 **message) {
   return data;
 }
 
-size_t CipEpathSetLogicalValue(const CipDword logical_value, const LogicalSegmentLogicalFormat logical_format, CipOctet **message) {
+size_t CipEpathSetLogicalValue(const CipDword logical_value,
+                               const LogicalSegmentLogicalFormat logical_format,
+                               CipOctet **message) {
   switch(logical_value) {
-    case kLogicalSegmentLogicalFormatEightBit: AddSintToMessage(logical_value, message); return 1; break;
-    case kLogicalSegmentLogicalFormatSixteenBit: MoveMessageNOctets(1, (const CipOctet**)message); AddIntToMessage(logical_value, message); return 3; break;
-    case kLogicalSegmentLogicalFormatThirtyTwoBit: MoveMessageNOctets(1, (const CipOctet**)message); AddDintToMessage(logical_value, message); return 5; break;
+    case kLogicalSegmentLogicalFormatEightBit: AddSintToMessage(logical_value,
+                                                                message);
+      return 1; break;
+    case kLogicalSegmentLogicalFormatSixteenBit: MoveMessageNOctets(1,
+                                                                    (const
+                                                                     CipOctet **)message);
+      AddIntToMessage(logical_value, message);
+      return 3; break;
+    case kLogicalSegmentLogicalFormatThirtyTwoBit: MoveMessageNOctets(1,
+                                                                      (const
+                                                                       CipOctet
+                                                                       **)message);
+      AddDintToMessage(logical_value, message);
+      return 5; break;
   }
   OPENER_ASSERT(false); /* This should never happen! */
   return 0;
@@ -419,16 +437,18 @@ ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
 }
 
 void GetElectronicKeyFormat4FromMessage(
-  const CipOctet **const message, ElectronicKeyFormat4 *key) {
+  const CipOctet **const message,
+  ElectronicKeyFormat4 *key) {
   OPENER_ASSERT( kElectronicKeySegmentFormatKeyFormat4 ==
                  GetPathLogicalSegmentElectronicKeyFormat(*message) );
 
   MoveMessageNOctets(2, message);
-  ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(message));
-  ElectronicKeyFormat4SetDeviceType(key, GetIntFromMessage(message));
-  ElectronicKeyFormat4SetProductCode(key, GetIntFromMessage(message));
-  ElectronicKeyFormat4SetMajorRevisionCompatibility(key, GetSintFromMessage(message));
-  ElectronicKeyFormat4SetMinorRevision(key, GetSintFromMessage(message));
+  ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(message) );
+  ElectronicKeyFormat4SetDeviceType(key, GetIntFromMessage(message) );
+  ElectronicKeyFormat4SetProductCode(key, GetIntFromMessage(message) );
+  ElectronicKeyFormat4SetMajorRevisionCompatibility(key,
+                                                    GetSintFromMessage(message) );
+  ElectronicKeyFormat4SetMinorRevision(key, GetSintFromMessage(message) );
 }
 
 /*** Logical Segment ***/
@@ -607,8 +627,10 @@ CipUsint GetPathDataSegmentSimpleDataWordLength(
 
 /* Special purpose functions */
 
-LogicalSegmentLogicalFormat CipEpathGetNeededLogicalFormatForValue(CipDword value) {
-  LogicalSegmentLogicalFormat logical_format = kLogicalSegmentLogicalFormatEightBit;
+LogicalSegmentLogicalFormat CipEpathGetNeededLogicalFormatForValue(
+  CipDword value) {
+  LogicalSegmentLogicalFormat logical_format =
+    kLogicalSegmentLogicalFormatEightBit;
   if(0xFF < value) {
     logical_format = kLogicalSegmentLogicalFormatSixteenBit;
   }
@@ -618,42 +640,62 @@ LogicalSegmentLogicalFormat CipEpathGetNeededLogicalFormatForValue(CipDword valu
   return logical_format;
 }
 
-size_t CipEpathEncodeConnectionEpath(const CipConnectionPathEpath *const connection_epath, CipOctet **encoded_path) {
+size_t CipEpathEncodeConnectionEpath(
+  const CipConnectionPathEpath *const connection_epath,
+  CipOctet **encoded_path) {
 
-	size_t encoded_path_length = 0;
+  size_t encoded_path_length = 0;
   {
-  SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
-  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
-  LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->class_id);
-  SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
-  encoded_path_length += 1;
-  MoveMessageNOctets(1, (const CipOctet**)encoded_path);
-  encoded_path_length += CipEpathSetLogicalValue(connection_epath->class_id, logical_value, encoded_path);
+    SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
+    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId,
+                                     *encoded_path);
+    LogicalSegmentLogicalFormat logical_value =
+      CipEpathGetNeededLogicalFormatForValue(connection_epath->class_id);
+    SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
+    encoded_path_length += 1;
+    MoveMessageNOctets(1, (const CipOctet **)encoded_path);
+    encoded_path_length += CipEpathSetLogicalValue(connection_epath->class_id,
+                                                   logical_value,
+                                                   encoded_path);
   }
 
   {
-  SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
-  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
-  LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->instance_id);
-  SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
-  encoded_path_length += 1;
-  MoveMessageNOctets(1, (const CipOctet**)encoded_path);
-  encoded_path_length += CipEpathSetLogicalValue(connection_epath->instance_id, logical_value, encoded_path);
+    SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
+    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId,
+                                     *encoded_path);
+    LogicalSegmentLogicalFormat logical_value =
+      CipEpathGetNeededLogicalFormatForValue(connection_epath->instance_id);
+    SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
+    encoded_path_length += 1;
+    MoveMessageNOctets(1, (const CipOctet **)encoded_path);
+    encoded_path_length += CipEpathSetLogicalValue(
+      connection_epath->instance_id,
+      logical_value,
+      encoded_path);
   }
 
-  if(0 != connection_epath->attribute_id_or_connection_point){
+  if(0 != connection_epath->attribute_id_or_connection_point) {
     SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
-    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
-    LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->attribute_id_or_connection_point);
+    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId,
+                                     *encoded_path);
+    LogicalSegmentLogicalFormat logical_value =
+      CipEpathGetNeededLogicalFormatForValue(
+        connection_epath->attribute_id_or_connection_point);
     SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
     encoded_path_length += 1;
-    MoveMessageNOctets(1, (const CipOctet**)encoded_path);
-    encoded_path_length += CipEpathSetLogicalValue(connection_epath->attribute_id_or_connection_point, logical_value, encoded_path);
+    MoveMessageNOctets(1, (const CipOctet **)encoded_path);
+    encoded_path_length += CipEpathSetLogicalValue(
+      connection_epath->attribute_id_or_connection_point,
+      logical_value,
+      encoded_path);
   }
   return encoded_path_length += 1;
 }
 
-bool CipEpathEqual(const CipOctet *const path1, const CipUint path1_length, const CipOctet *const path2, const CipUint path2_length) {
+bool CipEpathEqual(const CipOctet *const path1,
+                   const CipUint path1_length,
+                   const CipOctet *const path2,
+                   const CipUint path2_length) {
   if(path1_length != path2_length) {
     return false;
   }

+ 25 - 12
source/src/cip/cipepath.h

@@ -161,9 +161,9 @@ typedef enum symbolic_segment_extended_format {
 
 /* Start - Often used types of EPaths */
 typedef struct connection_path_epath {
-    CipDword class_id;
-    CipDword instance_id;
-    CipDword attribute_id_or_connection_point;
+  CipDword class_id;
+  CipDword instance_id;
+  CipDword attribute_id_or_connection_point;
 } CipConnectionPathEpath;
 /* End - Often used types of EPaths */
 
@@ -179,7 +179,8 @@ SegmentType GetPathSegmentType(const CipOctet *const cip_path);
  * @param segment_type The segment type
  * @param cip_path A message buffer - Will be written on!
  */
-void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path);
+void SetPathSegmentType(SegmentType segment_type,
+                        unsigned char *const cip_path);
 
 /*********************************************************
 * Port Segment functions
@@ -231,7 +232,8 @@ unsigned int GetPathPortSegmentExtendedPortNumber(
  * @param cip_path The start for the EPatch message
  */
 void SetPathPortSegmentExtendedPortIdentifier(
-  const unsigned int extended_port_identifier, CipOctet *const cip_path);
+  const unsigned int extended_port_identifier,
+  CipOctet *const cip_path);
 
 /** @brief Gets the Logical Type of an EPath Logical Segment message
  *
@@ -241,7 +243,8 @@ void SetPathPortSegmentExtendedPortIdentifier(
 LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
   const unsigned char *const cip_path);
 
-void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, CipOctet *const cip_path);
+void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type,
+                                      CipOctet *const cip_path);
 
 /** @brief Gets the Logical Format of a Logical Segment EPath message
  *
@@ -251,11 +254,14 @@ void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, Ci
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   const unsigned char *const cip_path);
 
-void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipOctet *const cip_path);
+void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format,
+                                        CipOctet *const cip_path);
 
 const CipDword CipEpathGetLogicalValue(const EipUint8 **message);
 
-size_t CipEpathSetLogicalValue(const CipDword logical_value, const LogicalSegmentLogicalFormat logical_format, CipOctet **message);
+size_t CipEpathSetLogicalValue(const CipDword logical_value,
+                               const LogicalSegmentLogicalFormat logical_format,
+                               CipOctet **message);
 
 /** @brief  Gets the Extended Logical Type of a Logical Segment EPath message
  *
@@ -271,7 +277,8 @@ LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(
  * @return The Special Type Logical Format subtype of a Logical Segment EPath message
  */
 LogicalSegmentSpecialTypeLogicalFormat
-GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path);
+GetPathLogicalSegmentSpecialTypeLogicalType(
+  const unsigned char *const cip_path);
 
 /** @brief Gets the Electronic Key format of a Logical Segment Special Type EPath message
  *
@@ -287,7 +294,8 @@ ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
  * @param Writes the data on the user provided data electronic key struct
  */
 void GetElectronicKeyFormat4FromMessage(
-  const CipOctet **const cip_path, ElectronicKeyFormat4 *key);
+  const CipOctet **const cip_path,
+  ElectronicKeyFormat4 *key);
 
 /** @brief Gets the Network Segment Subtype of a EPatch Network Segement EPath message
  *
@@ -355,8 +363,13 @@ SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(
 
 /* Special purpose encoding and decoding functions */
 
-size_t CipEpathEncodeConnectionEpath(const CipConnectionPathEpath *const connection_epath, CipOctet **encoded_path);
+size_t CipEpathEncodeConnectionEpath(
+  const CipConnectionPathEpath *const connection_epath,
+  CipOctet **encoded_path);
 
-bool CipEpathEqual(const CipOctet *const path1, const CipUint path1_length, const CipOctet *const path2, const CipUint path2_length);
+bool CipEpathEqual(const CipOctet *const path1,
+                   const CipUint path1_length,
+                   const CipOctet *const path2,
+                   const CipUint path2_length);
 
 #endif /* SRC_CIP_CIPEPATH_H_ */

+ 5 - 5
source/src/cip/cipidentity.c

@@ -125,21 +125,21 @@ void InitializeCipIdentiy(CipClass *class) {
 
   InsertAttribute( (CipInstance *) class, 1, kCipUint,
                    (void *) &class->revision,
-				   kGetableSingleAndAll ); /* revision */
+                   kGetableSingleAndAll );                 /* revision */
   InsertAttribute( (CipInstance *) class, 2, kCipUint,
                    (void *) &class->number_of_instances, kGetableSingleAndAll ); /*  largest instance number */
   InsertAttribute( (CipInstance *) class, 3, kCipUint,
                    (void *) &class->number_of_instances, kGetAttributeSingle ); /* number of instances currently existing*/
   InsertAttribute( (CipInstance *) class, 4, kCipUint, (void *) &kCipUintZero,
-		  kNotSetOrGetable ); /* optional attribute list - default = 0 */
+                   kNotSetOrGetable ); /* optional attribute list - default = 0 */
   InsertAttribute( (CipInstance *) class, 5, kCipUint, (void *) &kCipUintZero,
-		  kNotSetOrGetable ); /* optional service list - default = 0 */
+                   kNotSetOrGetable ); /* optional service list - default = 0 */
   InsertAttribute( (CipInstance *) class, 6, kCipUint,
                    (void *) &meta_class->highest_attribute_number,
-				   kGetableSingleAndAll ); /* max class attribute number*/
+                   kGetableSingleAndAll );                 /* max class attribute number*/
   InsertAttribute( (CipInstance *) class, 7, kCipUint,
                    (void *) &class->highest_attribute_number,
-				   kGetableSingleAndAll ); /* max instance attribute number*/
+                   kGetableSingleAndAll );                 /* max instance attribute number*/
 
 }
 

+ 23 - 21
source/src/cip/cipmessagerouter.c

@@ -51,26 +51,28 @@ CipError CreateMessageRouterRequestStructure(
 
 void InitializeCipMessageRouterClass(CipClass *cip_class) {
 
-	CipClass *meta_class = cip_class->class_instance.cip_class;
-
-    InsertAttribute( (CipInstance *) cip_class, 1, kCipUint,
-                     (void *) &cip_class->revision, kGetableSingleAndAll ); /* revision */
-    InsertAttribute( (CipInstance *) cip_class, 2, kCipUint,
-                     (void *) &cip_class->number_of_instances,
-                     kGetableSingle );                                     /*  largest instance number */
-    InsertAttribute( (CipInstance *) cip_class, 3, kCipUint,
-                     (void *) &cip_class->number_of_instances,
-					 kGetableSingle );                                     /* number of instances currently existing*/
-    InsertAttribute( (CipInstance *) cip_class, 4, kCipUint, (void *) &kCipUintZero,
-                     kGetableAll ); /* optional attribute list - default = 0 */
-    InsertAttribute( (CipInstance *) cip_class, 5, kCipUint, (void *) &kCipUintZero,
-    		kGetableAll ); /* optional service list - default = 0 */
-    InsertAttribute( (CipInstance *) cip_class, 6, kCipUint,
-                     (void *) &meta_class->highest_attribute_number,
-					 kGetableSingleAndAll ); /* max class attribute number*/
-    InsertAttribute( (CipInstance *) cip_class, 7, kCipUint,
-                     (void *) &cip_class->highest_attribute_number,
-					 kGetableSingleAndAll ); /* max instance attribute number*/
+  CipClass *meta_class = cip_class->class_instance.cip_class;
+
+  InsertAttribute( (CipInstance *) cip_class, 1, kCipUint,
+                   (void *) &cip_class->revision, kGetableSingleAndAll );   /* revision */
+  InsertAttribute( (CipInstance *) cip_class, 2, kCipUint,
+                   (void *) &cip_class->number_of_instances,
+                   kGetableSingle );                                       /*  largest instance number */
+  InsertAttribute( (CipInstance *) cip_class, 3, kCipUint,
+                   (void *) &cip_class->number_of_instances,
+                   kGetableSingle );                                                           /* number of instances currently existing*/
+  InsertAttribute( (CipInstance *) cip_class, 4, kCipUint,
+                   (void *) &kCipUintZero,
+                   kGetableAll );   /* optional attribute list - default = 0 */
+  InsertAttribute( (CipInstance *) cip_class, 5, kCipUint,
+                   (void *) &kCipUintZero,
+                   kGetableAll ); /* optional service list - default = 0 */
+  InsertAttribute( (CipInstance *) cip_class, 6, kCipUint,
+                   (void *) &meta_class->highest_attribute_number,
+                   kGetableSingleAndAll );                       /* max class attribute number*/
+  InsertAttribute( (CipInstance *) cip_class, 7, kCipUint,
+                   (void *) &cip_class->highest_attribute_number,
+                   kGetableSingleAndAll );                       /* max instance attribute number*/
 }
 
 EipStatus CipMessageRouterInit() {
@@ -85,7 +87,7 @@ EipStatus CipMessageRouterInit() {
                                             1, /* # of instances*/
                                             "message router", /* class name*/
                                             1, /* # class revision*/
-											InitializeCipMessageRouterClass); /* # function pointer for initialization*/
+                                            InitializeCipMessageRouterClass);                                             /* # function pointer for initialization*/
   if (NULL == message_router) {
     return kEipStatusError;
   }

+ 2 - 4
source/src/cip/cipqos.c

@@ -30,8 +30,7 @@ EipStatus GetAttributeSingleQoS(
   CipInstance *const RESTRICT instance,
   CipMessageRouterRequest *RESTRICT const message_router_request,
   CipMessageRouterResponse *RESTRICT const message_router_response,
-  struct sockaddr *originator_address)
-{
+  struct sockaddr *originator_address) {
 
   return GetAttributeSingle(instance, message_router_request,
                             message_router_response, originator_address);
@@ -41,8 +40,7 @@ EipStatus SetAttributeSingleQoS(
   CipInstance *instance,
   CipMessageRouterRequest *message_router_request,
   CipMessageRouterResponse *message_router_response,
-  struct sockaddr *originator_address)
-{
+  struct sockaddr *originator_address) {
 
   CipAttributeStruct *attribute = GetCipAttribute(
     instance, message_router_request->request_path.attribute_number);

+ 9 - 7
source/src/enet_encap/encap.c

@@ -314,7 +314,7 @@ int EncapsulateData(const EncapsulationData *const send_data) {
   CipOctet *communcation_buffer = send_data->communication_buffer_start + 2;
   AddIntToMessage(send_data->data_length, &communcation_buffer);
   /*the CommBuf should already contain the correct session handle*/
-  MoveMessageNOctets(4, (const CipOctet**)&communcation_buffer);
+  MoveMessageNOctets(4, (const CipOctet **)&communcation_buffer);
   AddDintToMessage(send_data->status, &communcation_buffer);
   /*the CommBuf should already contain the correct sender context*/
   /*the CommBuf should already contain the correct  options value*/
@@ -399,7 +399,7 @@ ptrdiff_t EncapsulateListIdentyResponseMessage(
   AddIntToMessage(kCipItemIdListIdentityResponse, &communication_buffer_runner);
 
   EipByte *id_length_buffer = communication_buffer_runner;
-  MoveMessageNOctets(2, (const CipOctet**)&communication_buffer_runner); /*at this place the real length will be inserted below*/
+  MoveMessageNOctets(2, (const CipOctet **)&communication_buffer_runner); /*at this place the real length will be inserted below*/
 
   AddIntToMessage(kSupportedProtocolVersion, &communication_buffer_runner);
 
@@ -408,7 +408,7 @@ ptrdiff_t EncapsulateListIdentyResponseMessage(
                        &communication_buffer_runner);
 
   memset(communication_buffer_runner, 0, 8);
-  MoveMessageNOctets(8, (const CipOctet**)&communication_buffer_runner);
+  MoveMessageNOctets(8, (const CipOctet **)&communication_buffer_runner);
 
   AddIntToMessage(vendor_id_, &communication_buffer_runner);
   AddIntToMessage(device_type_, &communication_buffer_runner);
@@ -432,7 +432,7 @@ ptrdiff_t EncapsulateListIdentyResponseMessage(
 void DetermineDelayTime(EipByte *buffer_start,
                         DelayedEncapsulationMessage *delayed_message_buffer) {
 
-  MoveMessageNOctets(12, (const CipOctet**)&buffer_start); /* start of the sender context */
+  MoveMessageNOctets(12, (const CipOctet **)&buffer_start); /* start of the sender context */
   EipUint16 maximum_delay_time = GetIntFromMessage(
     (const EipUint8 **const)&buffer_start );
 
@@ -466,7 +466,9 @@ void HandleReceivedRegisterSessionCommand(int socket,
     for (int i = 0; i < OPENER_NUMBER_OF_SUPPORTED_SESSIONS; ++i) {
       if (g_registered_sessions[i] == socket) {
         /* the socket has already registered a session this is not allowed*/
-    	  OPENER_TRACE_INFO("Error: A session is already registered at socket %d\n", socket);
+        OPENER_TRACE_INFO(
+          "Error: A session is already registered at socket %d\n",
+          socket);
         receive_data->session_handle = i + 1; /*return the already assigned session back, the cip spec is not clear about this needs to be tested*/
         receive_data->status = kEncapsulationProtocolInvalidCommand;
         session_index = kSessionStatusInvalid;
@@ -511,8 +513,8 @@ void HandleReceivedRegisterSessionCommand(int socket,
  *   close all corresponding TCP connections and delete session handle.
  *      pa_S_ReceiveData pointer to unregister session request with corresponding socket handle.
  */
-EipStatus HandleReceivedUnregisterSessionCommand(
-  EncapsulationData *receive_data) {
+EipStatus HandleReceivedUnregisterSessionCommand(EncapsulationData *receive_data)
+{
 
   OPENER_TRACE_INFO("encap.c: Unregister Session Command\n");
 

+ 11 - 6
source/src/enet_encap/endianconv.c

@@ -100,7 +100,8 @@ CipUdint GetUdintFromMessage(const CipOctet **const buffer_address) {
  * @param data value to be written
  * @param buffer pointer where data should be written.
  */
-int AddSintToMessage(const EipUint8 data, EipUint8 **const buffer) {
+int AddSintToMessage(const EipUint8 data,
+                     EipUint8 **const buffer) {
   unsigned char *p = (unsigned char *) *buffer;
 
   p[0] = (unsigned char) data;
@@ -113,7 +114,8 @@ int AddSintToMessage(const EipUint8 data, EipUint8 **const buffer) {
  * @param data value to be written
  * @param buffer pointer where data should be written.
  */
-int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer) {
+int AddIntToMessage(const EipUint16 data,
+                    EipUint8 **const buffer) {
   unsigned char *p = (unsigned char *) *buffer;
 
   p[0] = (unsigned char) data;
@@ -127,7 +129,8 @@ int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer) {
  * @param data value to be written
  * @param buffer pointer where data should be written.
  */
-int AddDintToMessage(const EipUint32 data, EipUint8 **const buffer) {
+int AddDintToMessage(const EipUint32 data,
+                     EipUint8 **const buffer) {
   unsigned char *p = (unsigned char *) *buffer;
 
   p[0] = (unsigned char) data;
@@ -172,7 +175,8 @@ EipUint64 GetLintFromMessage(const EipUint8 **const buffer) {
  * @param data value to be written
  * @param buffer pointer where data should be written.
  */
-int AddLintToMessage(const EipUint64 data, EipUint8 **const buffer) {
+int AddLintToMessage(const EipUint64 data,
+                     EipUint8 **const buffer) {
   EipUint8 *buffer_address = *buffer;
   buffer_address[0] = (EipUint8) (data >> 56) & 0xFF;
   buffer_address[1] = (EipUint8) (data >> 48) & 0xFF;
@@ -251,7 +255,8 @@ int GetEndianess() {
   return g_opener_platform_endianess;
 }
 
-void MoveMessageNOctets(int amount_of_bytes_moved, const CipOctet **message_runner) {
+void MoveMessageNOctets(int amount_of_bytes_moved,
+                        const CipOctet **message_runner) {
   (*message_runner) += amount_of_bytes_moved;
 }
 
@@ -266,7 +271,7 @@ int FillNextNMessageOctetsWithValueAndMoveToNextPosition(CipOctet value,
                                                          unsigned int amount_of_filled_bytes,
                                                          CipOctet **message) {
   FillNextNMessageOctetsWith(value, amount_of_filled_bytes, message);
-  MoveMessageNOctets(amount_of_filled_bytes, (const CipOctet**)message);
+  MoveMessageNOctets(amount_of_filled_bytes, (const CipOctet **)message);
   return amount_of_filled_bytes;
 }
 

+ 12 - 6
source/src/enet_encap/endianconv.h

@@ -57,7 +57,8 @@ CipUdint GetUdintFromMessage(const CipOctet **const buffer_address);
  * @param data value to be written
  * @param buffer pointer where data should be written.
  */
-int AddSintToMessage(const EipUint8 data, EipUint8 **const buffer);
+int AddSintToMessage(const EipUint8 data,
+                     EipUint8 **const buffer);
 
 /** @ingroup ENCAP
  *
@@ -67,7 +68,8 @@ int AddSintToMessage(const EipUint8 data, EipUint8 **const buffer);
  *
  * @return Length in bytes of the encoded message
  */
-int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer);
+int AddIntToMessage(const EipUint16 data,
+                    EipUint8 **const buffer);
 
 /** @ingroup ENCAP
  *
@@ -77,7 +79,8 @@ int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer);
  *
  * @return Length in bytes of the encoded message
  */
-int AddDintToMessage(const EipUint32 data, EipUint8 **const buffer);
+int AddDintToMessage(const EipUint32 data,
+                     EipUint8 **const buffer);
 
 #ifdef OPENER_SUPPORT_64BIT_DATATYPES
 
@@ -91,7 +94,8 @@ EipUint64 GetLintFromMessage(const EipUint8 **const buffer);
  *
  * @return Length in bytes of the encoded message
  */
-int AddLintToMessage(const EipUint64 pa_unData, EipUint8 **const buffer);
+int AddLintToMessage(const EipUint64 pa_unData,
+                     EipUint8 **const buffer);
 
 #endif
 
@@ -120,9 +124,11 @@ void DetermineEndianess(void);
  */
 int GetEndianess(void);
 
-void MoveMessageNOctets(int n, const CipOctet **message_runner);
+void MoveMessageNOctets(int n,
+                        const CipOctet **message_runner);
 
-int FillNextNMessageOctetsWith(CipOctet value,unsigned int n,
+int FillNextNMessageOctetsWith(CipOctet value,
+                               unsigned int n,
                                CipOctet **message);
 
 int FillNextNMessageOctetsWithValueAndMoveToNextPosition(CipOctet value,

+ 5 - 6
source/src/opener_api.h

@@ -315,7 +315,7 @@ typedef struct cip_connection_object CipConnectionObject;
  * @return CIP error code
  */
 typedef EipStatus (*OpenConnectionFunction)(
-    CipConnectionObject *RESTRICT const connection_object,
+  CipConnectionObject *RESTRICT const connection_object,
   EipUint16 *const extended_error_code);
 
 /** @ingroup CIP_API
@@ -324,8 +324,7 @@ typedef EipStatus (*OpenConnectionFunction)(
  * @param connection_object The connection object which is closing the
  * connection
  */
-typedef void (*ConnectionCloseFunction)(
-    CipConnectionObject *connection_object);
+typedef void (*ConnectionCloseFunction)(CipConnectionObject *connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for handling the timeout of connections
@@ -333,7 +332,7 @@ typedef void (*ConnectionCloseFunction)(
  * @param connection_object The connection object which connection timed out
  */
 typedef void (*ConnectionTimeoutFunction)(
-    CipConnectionObject *connection_object);
+  CipConnectionObject *connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for sending data via a connection
@@ -342,8 +341,8 @@ typedef void (*ConnectionTimeoutFunction)(
  *
  * @return EIP stack status
  */
-typedef EipStatus (*ConnectionSendDataFunction)(
-    CipConnectionObject *connection_object);
+typedef EipStatus (*ConnectionSendDataFunction)(CipConnectionObject *
+                                                connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for receiving data via a connection

+ 1 - 1
source/src/ports/POSIX/networkhandler.c

@@ -47,5 +47,5 @@ void SetQosOnSocket(int socket,
                     CipUsint qos_value) {
 
   int set_tos = qos_value;
-  setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos));
+  setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos) );
 }

+ 2 - 1
source/src/ports/POSIX/networkhandler.h

@@ -41,6 +41,7 @@ MicroSeconds GetMicroSeconds(void);
  */
 MilliSeconds GetMilliSeconds(void);
 
-void SetQosOnSocket(int socket, CipUsint qos_value);
+void SetQosOnSocket(int socket,
+                    CipUsint qos_value);
 
 #endif /* OPENER_NETWORKHANDLER_H_ */

+ 2 - 1
source/src/ports/POSIX/sample_application/sampleapplication.c

@@ -136,7 +136,8 @@ EipStatus ResetDeviceToInitialConfiguration(void) {
 }
 
 void *
-CipCalloc(size_t number_of_elements, size_t size_of_element) {
+CipCalloc(size_t number_of_elements,
+          size_t size_of_element) {
   return calloc(number_of_elements, size_of_element);
 }
 

+ 2 - 1
source/src/ports/WIN32/main.c

@@ -28,7 +28,8 @@ LeaveStack(int pa_nSig);
 int g_end_stack = 0;
 
 /******************************************************************************/
-int main(int argc, char *arg[]) {
+int main(int argc,
+         char *arg[]) {
   EipUint8 acMyMACAddress[6];
   EipUint16 nUniqueConnectionID;
 

+ 1 - 1
source/src/ports/WIN32/networkhandler.c

@@ -48,5 +48,5 @@ int SetSocketToNonBlocking(int socket_handle) {
 void SetQosOnSocket(int socket,
                     CipUsint qos_value) {
   CipUsint set_tos = qos_value;
-  setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos));
+  setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos) );
 }

+ 2 - 1
source/src/ports/WIN32/networkhandler.h

@@ -34,6 +34,7 @@ MicroSeconds GetMicroSeconds(void);
  */
 MilliSeconds GetMilliSeconds(void);
 
-void SetQosOnSocket(int socket, CipUsint qos_value);
+void SetQosOnSocket(int socket,
+                    CipUsint qos_value);
 
 #endif /*NETWORKHANDLER_H_*/

+ 2 - 1
source/src/ports/WIN32/sample_application/sampleapplication.c

@@ -133,7 +133,8 @@ EipStatus ResetDeviceToInitialConfiguration(void) {
 }
 
 void *
-CipCalloc(unsigned pa_nNumberOfElements, unsigned pa_nSizeOfElement) {
+CipCalloc(unsigned pa_nNumberOfElements,
+          unsigned pa_nSizeOfElement) {
   return calloc(pa_nNumberOfElements, pa_nSizeOfElement);
 }
 

+ 22 - 18
source/src/ports/generic_networkhandler.c

@@ -561,10 +561,11 @@ EipStatus HandleDataOnTcpSocket(int socket) {
   if (number_of_read_bytes == 0) {
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler: socket: %d - connection closed by client: %d - %s\n",
-    		socket,
-                     error_code,
-                     error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler: socket: %d - connection closed by client: %d - %s\n",
+      socket,
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     RemoveSocketTimerFromList(socket);
     RemoveSession(socket);
@@ -605,7 +606,7 @@ EipStatus HandleDataOnTcpSocket(int socket) {
         char *error_message = GetErrorMessage(error_code);
         OPENER_TRACE_ERR(
           "networkhandler: socket: %d - connection closed by client: %d - %s\n",
-		  socket,
+          socket,
           error_code,
           error_message);
         FreeErrorMessage(error_message);
@@ -641,10 +642,11 @@ EipStatus HandleDataOnTcpSocket(int socket) {
   {
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler: socket: %d - connection closed by client: %d - %s\n",
-    		socket,
-                     error_code,
-                     error_message);
+    OPENER_TRACE_ERR(
+      "networkhandler: socket: %d - connection closed by client: %d - %s\n",
+      socket,
+      error_code,
+      error_message);
     FreeErrorMessage(error_message);
     RemoveSocketTimerFromList(socket);
     RemoveSession(socket);
@@ -747,7 +749,7 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
   }
 
   SetSocketToNonBlocking(new_socket);
-  SetQosOnSocket(new_socket, GetPriorityForSocket(qos_for_socket));
+  SetQosOnSocket(new_socket, GetPriorityForSocket(qos_for_socket) );
 
   OPENER_TRACE_INFO("networkhandler: UDP socket %d\n", new_socket);
 
@@ -828,7 +830,7 @@ void CheckAndHandleConsumingUdpSockets(void) {
 
   /* see a message on one of the registered UDP sockets has been received     */
   while (NULL != iterator) {
-    current_connection_object = (CipConnectionObject*)iterator->data;
+    current_connection_object = (CipConnectionObject *)iterator->data;
     iterator = iterator->next; /* do this at the beginning as the close function may can make the entry invalid */
 
     if ( (-1
@@ -845,13 +847,15 @@ void CheckAndHandleConsumingUdpSockets(void) {
         g_ethernet_communication_buffer, PC_OPENER_ETHERNET_BUFFER_SIZE, 0,
         (struct sockaddr *) &from_address, &from_address_length);
       if (0 == received_size) {
-    	  int error_code = GetSocketErrorNumber();
-    	           char *error_message = GetErrorMessage(error_code);
-    	           OPENER_TRACE_ERR("networkhandler: socket: %d - connection closed by client: %d - %s\n",
-    	        		   current_connection_object->socket[kUdpCommuncationDirectionConsuming],
-    	                            error_code,
-    	                            error_message);
-    	           FreeErrorMessage(error_message);
+        int error_code = GetSocketErrorNumber();
+        char *error_message = GetErrorMessage(error_code);
+        OPENER_TRACE_ERR(
+          "networkhandler: socket: %d - connection closed by client: %d - %s\n",
+          current_connection_object->socket[
+            kUdpCommuncationDirectionConsuming],
+          error_code,
+          error_message);
+        FreeErrorMessage(error_message);
         current_connection_object->connection_close_function(
           current_connection_object);
         continue;

+ 2 - 1
source/src/ports/opener_error.h

@@ -17,7 +17,8 @@
  *
  * @return Error number
  */
-int GetSocketErrorNumber();
+int GetSocketErrorNumber(
+  );
 
 
 /**

+ 4 - 2
source/src/ports/socket_timer.c

@@ -8,7 +8,8 @@
 
 #include "trace.h"
 
-void SocketTimerSetSocket(SocketTimer *const socket_timer, const int socket) {
+void SocketTimerSetSocket(SocketTimer *const socket_timer,
+                          const int socket) {
   socket_timer->socket = socket;
   OPENER_TRACE_INFO("Adds socket %d to socket timers\n", socket);
 }
@@ -50,7 +51,8 @@ SocketTimer *SocketTimerArrayGetSocketTimer(
 }
 
 SocketTimer *SocketTimerArrayGetEmptySocketTimer(
-  SocketTimer *const array_of_socket_timers,const size_t array_length) {
+  SocketTimer *const array_of_socket_timers,
+  const size_t array_length) {
   return SocketTimerArrayGetSocketTimer(array_of_socket_timers, array_length,
                                         kEipInvalidSocket);
 }

+ 4 - 2
source/src/ports/socket_timer.h

@@ -24,7 +24,8 @@ typedef struct socket_timer {
  * @param socket_timer Socket Timer to be set
  * @param Socket value
  */
-void SocketTimerSetSocket(SocketTimer *const socket_timer, const int socket);
+void SocketTimerSetSocket(SocketTimer *const socket_timer,
+                          const int socket);
 
 /** @brief
  * Sets time stamp entry of the Socket Timer
@@ -82,6 +83,7 @@ SocketTimer *SocketTimerArrayGetSocketTimer(
  * @return An empty Socket Timer entry, or NULL if non is available
  */
 SocketTimer *SocketTimerArrayGetEmptySocketTimer(
-  SocketTimer *const array_of_socket_timers,const size_t array_length);
+  SocketTimer *const array_of_socket_timers,
+  const size_t array_length);
 
 #endif /* SRC_PORTS_SOCKET_TIMER_H_ */

+ 4 - 3
source/src/utils/doublylinkedlist.c

@@ -109,7 +109,8 @@ void DoublyLinkedListInsertAfterNode(DoublyLinkedList *const list,
 }
 
 void DoublyLinkedListRemoveNode(DoublyLinkedList *const list,
-                                DoublyLinkedListNode **pointer_to_node_pointer) {
+                                DoublyLinkedListNode **pointer_to_node_pointer)
+{
   DoublyLinkedListNode *node = *pointer_to_node_pointer;
   if(node == list->first) {
     list->first = node->next;
@@ -121,10 +122,10 @@ void DoublyLinkedListRemoveNode(DoublyLinkedList *const list,
   DoublyLinkedListNode *next = node->next;
 
   if(NULL != previous) {
-  previous->next = next;
+    previous->next = next;
   }
   if(NULL != next) {
-  next->previous = previous;
+    next->previous = previous;
   }
 
   DoublyLinkedListNodeDestroy(list, pointer_to_node_pointer);

+ 2 - 1
source/src/utils/doublylinkedlist.h

@@ -15,7 +15,8 @@
 
 typedef struct doubly_linked_list_node DoublyLinkedListNode;
 
-typedef DoublyLinkedListNode * (*NodeMemoryAllocator)();
+typedef DoublyLinkedListNode * (*NodeMemoryAllocator)(
+  );
 
 typedef void (*NodeMemoryDeallocator)(DoublyLinkedListNode **node);
 

+ 2 - 1
source/tests/OpENerTests.cpp

@@ -1,6 +1,7 @@
 #include "OpENerTests.h"
 
-int main(int argc, char **argv) {
+int main(int argc,
+         char **argv) {
   /* These checks are here to make sure assertions outside test runs don't crash */
   CHECK(true);
   LONGS_EQUAL(1, 1);

+ 7 - 7
source/tests/cip/cipelectronickeytest.cpp

@@ -30,7 +30,7 @@ TEST_GROUP(CipElectronicKey) {
 
 TEST(CipElectronicKey, CreateElectronicKey) {
   char dummyArea[kElectronicKeyFormat4Size];
-  memset(dummyArea, 0, sizeof(dummyArea));
+  memset(dummyArea, 0, sizeof(dummyArea) );
   MEMCMP_EQUAL(dummyArea, key, kElectronicKeyFormat4Size);
 };
 
@@ -41,7 +41,7 @@ TEST(CipElectronicKey, DeleteElectronicKey) {
 
 TEST(CipElectronicKey, SetVendorID) {
   char demoArea[kElectronicKeyFormat4Size];
-  memset(demoArea, 0, sizeof(demoArea));
+  memset(demoArea, 0, sizeof(demoArea) );
   CipUint *vendor_id = (CipUint *)demoArea;
   *vendor_id = 1;
   ElectronicKeyFormat4SetVendorId(key, 1);
@@ -61,7 +61,7 @@ TEST(CipElectronicKey, GetVendorID) {
 
 TEST(CipElectronicKey, SetDeviceType) {
   char demoArea[kElectronicKeyFormat4Size];
-  memset(demoArea, 0, sizeof(demoArea));
+  memset(demoArea, 0, sizeof(demoArea) );
   CipUint *device_type = (CipUint *)demoArea + 1;
   *device_type = 1;
 
@@ -81,7 +81,7 @@ TEST(CipElectronicKey, GetDeviceType) {
 
 TEST(CipElectronicKey, SetProductCode) {
   char demoArea[kElectronicKeyFormat4Size];
-  memset(demoArea, 0, sizeof(demoArea));
+  memset(demoArea, 0, sizeof(demoArea) );
   CipUint *product_code = (CipUint *)demoArea + 2;
   *product_code = 1;
 
@@ -101,7 +101,7 @@ TEST(CipElectronicKey, GetProductCode) {
 
 TEST(CipElectronicKey, SetMajorRevisionCompatibility) {
   char demoArea[kElectronicKeyFormat4Size];
-  memset(demoArea, 0, sizeof(demoArea));
+  memset(demoArea, 0, sizeof(demoArea) );
   CipByte *major_revision_compatiblitiy = (CipByte *)demoArea + 6;
   *major_revision_compatiblitiy = 0x81;
 
@@ -132,7 +132,7 @@ TEST(CipElectronicKey, GetMajorRevisionCompatibility) {
 
 TEST(CipElectronicKey, SetMinorRevision) {
   char demoArea[kElectronicKeyFormat4Size];
-  memset(demoArea, 0, sizeof(demoArea));
+  memset(demoArea, 0, sizeof(demoArea) );
   CipByte *minor_revision_compatiblitiy = (CipByte *)demoArea + 7;
   *minor_revision_compatiblitiy = 0x81;
 
@@ -155,7 +155,7 @@ TEST(CipElectronicKey, ParseElectronicKeyTest) {
   const CipOctet message[] =
   {0x34, 0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x84, 0x05};
   const CipOctet *message_buffer = message;
-  GetElectronicKeyFormat4FromMessage((const CipOctet**)&message_buffer, key);
+  GetElectronicKeyFormat4FromMessage( (const CipOctet **)&message_buffer, key );
 
   message_buffer = message;
   CHECK_EQUAL( 256, ElectronicKeyFormat4GetVendorId(key) );

+ 1 - 1
source/tests/cip/cipepathtest.cpp

@@ -288,7 +288,7 @@ TEST(CipEpath, GetLogicalSegmentElectronicKeyFormat4) {
   /* Size of an electronic key is 1 + 1 + 8 (Segment, Key format, Key) */
   const CipOctet message[] =
   {0x34, 0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x04, 0x05};
-  const CipOctet *message_pp = (const CipOctet*)message;
+  const CipOctet *message_pp = (const CipOctet *)message;
   const CipOctet *message_buffer = message;
   ElectronicKeyFormat4 *electronic_key = ElectronicKeyFormat4New();
   GetElectronicKeyFormat4FromMessage(&message_pp, electronic_key);