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

Updates code indention according to uncrustify.cfg

CapXilinx 9 лет назад
Родитель
Сommit
9b000f703f

+ 16 - 11
source/src/cip/cipcommon.c

@@ -29,7 +29,7 @@ EipUint8 g_message_data_reply_buffer[OPENER_MESSAGE_DATA_REPLY_BUFFER]; /**< Rep
 const EipUint16 kCipUintZero = 0; /**< Zero value for returning the UINT standard value */
 
 /* private functions*/
-int EncodeEPath(CipEpath *epath, EipUint8 * *message);
+int EncodeEPath(CipEpath *epath, EipUint8 **message);
 
 void CipStackInit(const EipUint16 unique_connection_id) {
   EncapsulationInit();
@@ -115,7 +115,7 @@ EipStatus NotifyClass(const CipClass *restrict const cip_class,
 
 CipInstance *AddCipInstances(CipClass *restrict const cip_class,
                              const int number_of_instances) {
-  CipInstance * *next_instance = NULL;
+  CipInstance **next_instance = NULL;
   EipUint32 instance_number = 1; /* the first instance is number 1 */
 
   OPENER_TRACE_INFO("adding %d instances to class %s\n", number_of_instances,
@@ -176,7 +176,8 @@ CipClass *CreateCipClass(const EipUint32 class_id,
                          const int number_of_instance_attributes,
                          const EipUint32 get_all_instance_attributes_mask,
                          const int number_of_instance_services,
-                         const int number_of_instances, char *name,
+                         const int number_of_instances,
+                         char *name,
                          const EipUint16 revision) {
 
   OPENER_TRACE_INFO("creating class '%s' with id: 0x%" PRIX32 "\n", name,
@@ -289,7 +290,8 @@ CipClass *CreateCipClass(const EipUint32 class_id,
 
 void InsertAttribute(CipInstance *const instance,
                      const EipUint16 attribute_number,
-                     const EipUint8 cip_type, void *const data,
+                     const EipUint8 cip_type,
+                     void *const data,
                      const EipByte cip_flags) {
 
   CipAttributeStruct *attribute = instance->attributes;
@@ -319,7 +321,8 @@ void InsertAttribute(CipInstance *const instance,
   /* trying to insert too many attributes*/
 }
 
-void InsertService(const CipClass *const class, const EipUint8 service_number,
+void InsertService(const CipClass *const class,
+                   const EipUint8 service_number,
                    const CipServiceFunction service_function,
                    char *const service_name) {
 
@@ -413,8 +416,9 @@ EipStatus GetAttributeSingle(CipInstance *restrict const instance,
   return kEipStatusOkSend;
 }
 
-int EncodeData(const EipUint8 cip_type, const void *const cip_data,
-               EipUint8 * *cip_message) {
+int EncodeData(const EipUint8 cip_type,
+               const void *const cip_data,
+               EipUint8 **cip_message) {
   int counter = 0;
 
   switch (cip_type)
@@ -576,8 +580,9 @@ int EncodeData(const EipUint8 cip_type, const void *const cip_data,
   return counter;
 }
 
-int DecodeData(const EipUint8 cip_type, void *const data,
-               const EipUint8 * *const message) {
+int DecodeData(const EipUint8 cip_type,
+               void *const data,
+               const EipUint8 **const message) {
   int number_of_decoded_bytes = -1;
 
   switch (cip_type)
@@ -703,7 +708,7 @@ EipStatus GetAttributeAll(CipInstance *instance,
   return kEipStatusOk; /* Return kEipStatusOk if cannot find GET_ATTRIBUTE_SINGLE service*/
 }
 
-int EncodeEPath(CipEpath *epath, EipUint8 * *message) {
+int EncodeEPath(CipEpath *epath, EipUint8 **message) {
   unsigned int length = epath->path_size;
   AddIntToMessage(epath->path_size, message);
 
@@ -759,7 +764,7 @@ int EncodeEPath(CipEpath *epath, EipUint8 * *message) {
   return 2 + epath->path_size * 2; /* path size is in 16 bit chunks according to the specification */
 }
 
-int DecodePaddedEPath(CipEpath *epath, const EipUint8 * *message) {
+int DecodePaddedEPath(CipEpath *epath, const EipUint8 **message) {
   unsigned int number_of_decoded_elements = 0;
   const EipUint8 *message_runner = *message;
 

+ 57 - 32
source/src/opener_api.h

@@ -30,7 +30,8 @@
  *  @return EIP_OK if the configuring worked otherwise EIP_ERROR
  */
 EipStatus
-ConfigureNetworkInterface(const char *const ip_address, const char *const subnet_mask,
+ConfigureNetworkInterface(const char *const ip_address,
+                          const char *const subnet_mask,
                           const char *const gateway_address);
 
 /** @ingroup CIP_API
@@ -104,7 +105,8 @@ CipClass *GetCipClass(const EipUint32 class_id);
  * @return pointer to CIP Instance
  *          0 if instance is not in the object
  */
-CipInstance *GetCipInstance(const CipClass *restrict const cip_object, const EipUint32 instance_number);
+CipInstance *GetCipInstance(const CipClass *restrict const cip_object,
+                            const EipUint32 instance_number);
 
 /** @ingroup CIP_API
  * @brief Get a pointer to an instance's attribute
@@ -144,13 +146,15 @@ CipAttributeStruct *GetCipAttribute(const CipInstance *const cip_instance,
  *  @return pointer to new class object
  *      0 on error
  */
-CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_attributes,
+CipClass *CreateCipClass(const EipUint32 class_id,
+                         const int number_of_class_attributes,
                          const EipUint32 class_attributes_get_attribute_all_mask,
                          const int number_of_class_services,
                          const int number_of_instance_attributes,
                          const EipUint32 instance_attributes_get_attributes_all_mask,
                          const int number_of_instance_services,
-                         const int number_of_instances, char *class_name,
+                         const int number_of_instances,
+                         char *class_name,
                          const EipUint16 class_revision);
 
 /** @ingroup CIP_API
@@ -171,8 +175,9 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
  * @return pointer to the first of the new instances
  *              0 on error
  */
-CipInstance *AddCipInstances(CipClass *restrict const cip_object_to_add_instances,
-                             const int number_of_instances);
+CipInstance *AddCipInstances(
+  CipClass *restrict const cip_object_to_add_instances,
+  const int number_of_instances);
 
 /** @ingroup CIP_API
  * @brief Create one instance of a given class with a certain instance number
@@ -200,8 +205,11 @@ CipInstance *AddCIPInstance(CipClass *restrict const cip_class_to_add_instance,
  *  @param cip_data pointer to data of attribute.
  *  @param cip_flags flags to indicate set-ability and get-ability of attribute.
  */
-void InsertAttribute(CipInstance *const cip_instance, const EipUint16 attribute_number,
-                     const EipUint8 cip_data_type, void *const cip_data, const EipByte cip_flags);
+void InsertAttribute(CipInstance *const cip_instance,
+                     const EipUint16 attribute_number,
+                     const EipUint8 cip_data_type,
+                     void *const cip_data,
+                     const EipByte cip_flags);
 
 /** @ingroup CIP_API
  * @brief Insert a service in an instance of a CIP object
@@ -216,8 +224,10 @@ void InsertAttribute(CipInstance *const cip_instance, const EipUint16 attribute_
  * @param service_function pointer to function which represents the service.
  * @param service_name name of the service
  */
-void InsertService(const CipClass *const cip_class_to_add_service, const EipUint8 service_code,
-                   const CipServiceFunction service_function, char *const service_name);
+void InsertService(const CipClass *const cip_class_to_add_service,
+                   const EipUint8 service_code,
+                   const CipServiceFunction service_function,
+                   char *const service_name);
 
 /** @ingroup CIP_API
  * @brief Produce the data according to CIP encoding onto the message buffer.
@@ -230,7 +240,9 @@ void InsertService(const CipClass *const cip_class_to_add_service, const EipUint
  *  @return length of attribute in bytes
  *          -1 .. error
  */
-int EncodeData(const EipUint8 cip_data_type, const void *const cip_data, EipUint8 **cip_message);
+int EncodeData(const EipUint8 cip_data_type,
+               const void *const cip_data,
+               EipUint8 **cip_message);
 
 /** @ingroup CIP_API
  * @brief Retrieve the given data according to CIP encoding from the message
@@ -244,7 +256,9 @@ int EncodeData(const EipUint8 cip_data_type, const void *const cip_data, EipUint
  *  @return length of taken bytes
  *          -1 .. error
  */
-int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const message);
+int DecodeData(const EipUint8 cip_type,
+               void *const data,
+               const EipUint8 **const message);
 
 /** @ingroup CIP_API
  * @brief Create an instance of an assembly object
@@ -263,7 +277,8 @@ int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const
  * The notification on received configuration data is handled with the
  * IApp_after_receive function.
  */
-CipInstance *CreateAssemblyObject(const EipUint32 instance_number, EipByte *const data,
+CipInstance *CreateAssemblyObject(const EipUint32 instance_number,
+                                  EipByte *const data,
                                   const EipUint16 data_length);
 
 typedef struct connection_object ConnectionObject;
@@ -278,7 +293,8 @@ typedef struct connection_object ConnectionObject;
  * @return CIP error code
  */
 typedef EipStatus (*OpenConnectionFunction)(
-    ConnectionObject *restrict const connection_object, EipUint16 *const extended_error_code);
+  ConnectionObject *restrict const connection_object,
+  EipUint16 *const extended_error_code);
 
 /** @ingroup CIP_API
  * @brief Function prototype for handling the closing of connections
@@ -287,7 +303,7 @@ typedef EipStatus (*OpenConnectionFunction)(
  * connection
  */
 typedef void (*ConnectionCloseFunction)(
-    struct connection_object *connection_object);
+  struct connection_object *connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for handling the timeout of connections
@@ -295,7 +311,7 @@ typedef void (*ConnectionCloseFunction)(
  * @param connection_object The connection object which connection timed out
  */
 typedef void (*ConnectionTimeoutFunction)(
-    struct connection_object *connection_object);
+  struct connection_object *connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for sending data via a connection
@@ -305,7 +321,7 @@ typedef void (*ConnectionTimeoutFunction)(
  * @return EIP stack status
  */
 typedef EipStatus (*ConnectionSendDataFunction)(
-    struct connection_object *connection_object);
+  struct connection_object *connection_object);
 
 /** @ingroup CIP_API
  * @brief Function prototype for receiving data via a connection
@@ -317,8 +333,8 @@ typedef EipStatus (*ConnectionSendDataFunction)(
  * @return Stack status
  */
 typedef EipStatus (*ConnectionReceiveDataFunction)(
-    struct connection_object *connection_object, const EipUint8 *data,
-    const EipUint16 data_length);
+  struct connection_object *connection_object, const EipUint8 *data,
+  const EipUint16 data_length);
 
 /** @ingroup CIP_API
  * @brief register open functions for an specific object.
@@ -348,8 +364,10 @@ AddConnectableObject(EipUint32 class_id,
  * this connection
  */
 void ConfigureExclusiveOwnerConnectionPoint(
-    const unsigned int connection_number, const unsigned int output_assembly_id,
-    const unsigned int input_assembly_id, const unsigned int configuration_assembly_id);
+  const unsigned int connection_number,
+  const unsigned int output_assembly_id,
+  const unsigned int input_assembly_id,
+  const unsigned int configuration_assembly_id);
 
 /** @ingroup CIP_API
  * @brief Configures the connection point for an input only connection.
@@ -362,7 +380,7 @@ void ConfigureExclusiveOwnerConnectionPoint(
  * @param input_assembly_id ID of the T-to-O point to be used for this
  * connection
  * @param configuration_assembly_id ID of the configuration point to be used for
- *this connection
+ * this connection
  */
 void ConfigureInputOnlyConnectionPoint(const unsigned int connection_number,
                                        const unsigned int output_assembly_id,
@@ -399,7 +417,8 @@ void ConfigureListenOnlyConnectionPoint(const unsigned int connection_number,
  * over after we're done here
  * @return length of reply that need to be sent back
  */
-int HandleReceivedExplictTcpData(int socket, EipUint8 *buffer,
+int HandleReceivedExplictTcpData(int socket,
+                                 EipUint8 *buffer,
                                  unsigned int buffer_length,
                                  int *number_of_remaining_bytes);
 
@@ -416,9 +435,12 @@ int HandleReceivedExplictTcpData(int socket, EipUint8 *buffer,
  * over after we're done here
  * @return length of reply that need to be sent back
  */
-int HandleReceivedExplictUdpData(int socket, struct sockaddr_in *from_address,
-                                 EipUint8 *buffer, unsigned int buffer_length,
-                                 int *number_of_remaining_bytes, int unicast);
+int HandleReceivedExplictUdpData(int socket,
+                                 struct sockaddr_in *from_address,
+                                 EipUint8 *buffer,
+                                 unsigned int buffer_length,
+                                 int *number_of_remaining_bytes,
+                                 int unicast);
 
 /** @ingroup CIP_API
  *  @brief Notify the connection manager that data for a connection has been
@@ -433,7 +455,8 @@ int HandleReceivedExplictUdpData(int socket, struct sockaddr_in *from_address,
  *  @return EIP_OK on success
  */
 EipStatus
-HandleReceivedConnectedData(EipUint8 *received_data, int received_data_length,
+HandleReceivedConnectedData(EipUint8 *received_data,
+                            int received_data_length,
                             struct sockaddr_in *from_address);
 
 /** @ingroup CIP_API
@@ -525,8 +548,8 @@ void HandleApplication(void);
  * @param io_connection_event information on the change occurred
  */
 void CheckIoConnectionEvent(unsigned int output_assembly_id,
-                       unsigned int input_assembly_id,
-                       IoConnectionEvent io_connection_event);
+                            unsigned int input_assembly_id,
+                            IoConnectionEvent io_connection_event);
 
 /** @ingroup CIP_CALLBACK_API
  * @brief Call back function to inform application on received data for an
@@ -640,7 +663,9 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
  * @return  EIP_SUCCESS on success
  */
 EipStatus
-SendUdpData(struct sockaddr_in *socket_data, int socket, EipUint8 *data,
+SendUdpData(struct sockaddr_in *socket_data,
+            int socket,
+            EipUint8 *data,
             EipUint16 data_length);
 
 /** @ingroup CIP_CALLBACK_API
@@ -651,7 +676,7 @@ SendUdpData(struct sockaddr_in *socket_data, int socket, EipUint8 *data,
 void CloseSocket(int socket);
 
 /** @mainpage OpENer - Open Source EtherNet/IP(TM) Communication Stack
- *Documentation
+ * Documentation
  *
  * EtherNet/IP stack for adapter devices (connection target); supports multiple
  * I/O and explicit connections; includes features and objects required by the
@@ -785,7 +810,7 @@ void CloseSocket(int socket);
  * CloseSocket(int socket_handle)
  *      -# For TCP connection when the peer closed the connection OpENer needs
  *         to be informed to clean up internal data structures. This is done
- *with
+ * with
  *         the function void CloseSession(int socket_handle).
  *      .
  *   - Cyclically update the connection status:\n

+ 12 - 9
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -1,6 +1,6 @@
 /*******************************************************************************
  * Copyright (c) 2009, Rockwell Automation, Inc.
- * All rights reserved. 
+ * All rights reserved.
  *
  ******************************************************************************/
 #ifndef OPENER_USER_CONF_H_
@@ -8,9 +8,9 @@
 
 /** @file opener_user_conf.h
  * @brief OpENer configuration setup
- * 
+ *
  * This file contains the general application specific configuration for OpENer.
- * 
+ *
  * Furthermore you have to specific platform specific network include files.
  * OpENer needs definitions for the following data-types
  * and functions:
@@ -119,12 +119,15 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
  */
 #ifdef IDLING_ASSERT
 #define OPENER_ASSERT(assertion) \
-    do { \
-      if(!(assertion)) { \
-        LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n", #assertion, __FILE__, __LINE__); \
-        while(1){;} \
-      } \
-    } while(0)
+  do { \
+    if( !(assertion) ) { \
+      LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n", \
+                # assertion, \
+                __FILE__, \
+                __LINE__); \
+      while(1) {; } \
+    } \
+  } while(0)
 
 /* else use standard assert() */
 //#include <assert.h>

+ 15 - 15
source/src/ports/POSIX/sample_application/sampleapplication.c

@@ -27,16 +27,16 @@ EipUint8 g_assembly_data09A[32]; /* Explicit */
 EipStatus ApplicationInitialization(void) {
   /* create 3 assembly object instances*/
   /*INPUT*/
-  CreateAssemblyObject(DEMO_APP_INPUT_ASSEMBLY_NUM, g_assembly_data064,
-                       sizeof(g_assembly_data064));
+  CreateAssemblyObject( DEMO_APP_INPUT_ASSEMBLY_NUM, g_assembly_data064,
+                        sizeof(g_assembly_data064) );
 
   /*OUTPUT*/
-  CreateAssemblyObject(DEMO_APP_OUTPUT_ASSEMBLY_NUM, g_assembly_data096,
-                       sizeof(g_assembly_data096));
+  CreateAssemblyObject( DEMO_APP_OUTPUT_ASSEMBLY_NUM, g_assembly_data096,
+                        sizeof(g_assembly_data096) );
 
   /*CONFIG*/
-  CreateAssemblyObject(DEMO_APP_CONFIG_ASSEMBLY_NUM, g_assembly_data097,
-                       sizeof(g_assembly_data097));
+  CreateAssemblyObject( DEMO_APP_CONFIG_ASSEMBLY_NUM, g_assembly_data097,
+                        sizeof(g_assembly_data097) );
 
   /*Heart-beat output assembly for Input only connections */
   CreateAssemblyObject(DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM, NULL, 0);
@@ -45,18 +45,18 @@ EipStatus ApplicationInitialization(void) {
   CreateAssemblyObject(DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM, NULL, 0);
 
   /* assembly for explicit messaging */
-  CreateAssemblyObject(DEMO_APP_EXPLICT_ASSEMBLY_NUM, g_assembly_data09A,
-                       sizeof(g_assembly_data09A));
+  CreateAssemblyObject( DEMO_APP_EXPLICT_ASSEMBLY_NUM, g_assembly_data09A,
+                        sizeof(g_assembly_data09A) );
 
   ConfigureExclusiveOwnerConnectionPoint(0, DEMO_APP_OUTPUT_ASSEMBLY_NUM,
-  DEMO_APP_INPUT_ASSEMBLY_NUM,
+                                         DEMO_APP_INPUT_ASSEMBLY_NUM,
                                          DEMO_APP_CONFIG_ASSEMBLY_NUM);
   ConfigureInputOnlyConnectionPoint(0,
-  DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
+                                    DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
                                     DEMO_APP_INPUT_ASSEMBLY_NUM,
                                     DEMO_APP_CONFIG_ASSEMBLY_NUM);
   ConfigureListenOnlyConnectionPoint(0,
-  DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM,
+                                     DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM,
                                      DEMO_APP_INPUT_ASSEMBLY_NUM,
                                      DEMO_APP_CONFIG_ASSEMBLY_NUM);
 
@@ -68,8 +68,8 @@ void HandleApplication(void) {
 }
 
 void CheckIoConnectionEvent(unsigned int output_assembly_id,
-                       unsigned int input_assembly_id,
-                       IoConnectionEvent io_connection_event) {
+                            unsigned int input_assembly_id,
+                            IoConnectionEvent io_connection_event) {
   /* maintain a correct output state according to the connection state*/
 
   (void) output_assembly_id; /* suppress compiler warning */
@@ -85,8 +85,8 @@ EipStatus AfterAssemblyDataReceived(CipInstance *instance) {
     case DEMO_APP_OUTPUT_ASSEMBLY_NUM:
       /* Data for the output assembly has been received.
        * Mirror it to the inputs */
-      memcpy(&g_assembly_data064[0], &g_assembly_data096[0],
-             sizeof(g_assembly_data064));
+      memcpy( &g_assembly_data064[0], &g_assembly_data096[0],
+              sizeof(g_assembly_data064) );
       break;
     case DEMO_APP_EXPLICT_ASSEMBLY_NUM:
       /* do something interesting with the new data from

+ 12 - 6
source/src/ports/WIN32/opener_error.c

@@ -15,12 +15,18 @@
  #include "opener_error.h"
 
 int GetSocketErrorNumber() {
-	return WSAGetLastError();
+  return WSAGetLastError();
 }
 
 char *GetErrorMessage(int error_number) {
-  	char *error_message = NULL;
-  	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error_number, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-               &error_message, 0, NULL);
-  	return error_message;
-  }
+  char *error_message = NULL;
+  FormatMessage(
+    FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+    NULL,
+    error_number,
+    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+    &error_message,
+    0,
+    NULL);
+  return error_message;
+}

+ 269 - 211
source/src/ports/generic_networkhandler.c

@@ -50,12 +50,12 @@ void CheckAndHandleConsumingUdpSockets(void);
 EipStatus HandleDataOnTcpSocket(int socket);
 
 /*************************************************
- * Function implementations from now on
- *************************************************/
+* Function implementations from now on
+*************************************************/
 
 EipStatus NetworkHandlerInitialize(void) {
 
-  if(kEipStatusOk != NetworkHandlerInitializePlatform()) {
+  if( kEipStatusOk != NetworkHandlerInitializePlatform() ) {
     return kEipStatusError;
   }
 
@@ -64,122 +64,141 @@ EipStatus NetworkHandlerInitialize(void) {
   FD_ZERO(&read_socket);
 
   /* create a new TCP socket */
-  if ((g_network_status.tcp_listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))
-      == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error allocating socket stream listener, %d - %s\n", error_code, error_message);
-	free(error_message);
+  if ( ( g_network_status.tcp_listener =
+           socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) )
+       == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("error allocating socket stream listener, %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   int set_socket_option_value = 1;  //Represents true for used set socket options
   /* 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(
-        "error setting socket option SO_REUSEADDR on tcp_listener\n");
+      "error setting socket option SO_REUSEADDR on tcp_listener\n");
     return kEipStatusError;
   }
 
   /* create a new UDP socket */
-  if ((g_network_status.udp_global_broadcast_listener = socket(AF_INET,
-                                                               SOCK_DGRAM,
-                                                               IPPROTO_UDP))
-      == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error allocating UDP global broadcast listener socket, %d - %s\n",
-                     error_code, error_message);
-	free(error_message);
+  if ( ( g_network_status.udp_global_broadcast_listener = socket(AF_INET,
+                                                                 SOCK_DGRAM,
+                                                                 IPPROTO_UDP) )
+       == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR(
+      "error allocating UDP global broadcast listener socket, %d - %s\n",
+      error_code,
+      error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   /* create a new UDP socket */
-  if ((g_network_status.udp_unicast_listener = socket(AF_INET, SOCK_DGRAM,
-                                                      IPPROTO_UDP)) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
+  if ( ( g_network_status.udp_unicast_listener = socket(AF_INET, SOCK_DGRAM,
+                                                        IPPROTO_UDP) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
     OPENER_TRACE_ERR("error allocating UDP unicast listener socket, %d - %s\n",
-		error_code, error_message);
-	free(error_message);
+                     error_code, error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   /* Activates address reuse */
-  if (setsockopt(g_network_status.udp_global_broadcast_listener, SOL_SOCKET,
-                 SO_REUSEADDR, (char *) &set_socket_option_value,
-                 sizeof(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) ) == -1) {
     OPENER_TRACE_ERR(
-        "error setting socket option SO_REUSEADDR on udp_broadcast_listener\n");
+      "error setting socket option SO_REUSEADDR on udp_broadcast_listener\n");
     return kEipStatusError;
   }
 
   /* Activates address reuse */
-  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(
-        "error setting socket option SO_REUSEADDR on udp_unicast_listener\n");
+      "error setting socket option SO_REUSEADDR on udp_unicast_listener\n");
     return kEipStatusError;
   }
 
   struct sockaddr_in my_address = { .sin_family = AF_INET, .sin_port = htons(
-      kOpenerEthernetPort), .sin_addr.s_addr = interface_configuration_
-      .ip_address };
+                                      kOpenerEthernetPort),
+                                    .sin_addr.s_addr = interface_configuration_
+                                                       .
+                                                       ip_address };
 
   /* bind the new socket to port 0xAF12 (CIP) */
-  if ((bind(g_network_status.tcp_listener, (struct sockaddr *) &my_address,
-            sizeof(struct sockaddr))) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error with TCP bind: %d - %s\n", error_code, error_message);
-	free(error_message);
+  if ( ( bind( g_network_status.tcp_listener, (struct sockaddr *) &my_address,
+               sizeof(struct sockaddr) ) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("error with TCP bind: %d - %s\n", error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
-  if ((bind(g_network_status.udp_unicast_listener,
-            (struct sockaddr *) &my_address, sizeof(struct sockaddr))) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error with UDP unicast bind: %d - %s\n", error_code, GetErrorMessage(error_code));
-	free(error_message);
+  if ( ( bind( g_network_status.udp_unicast_listener,
+               (struct sockaddr *) &my_address,
+               sizeof(struct sockaddr) ) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR( "error with UDP unicast bind: %d - %s\n", error_code, GetErrorMessage(
+                        error_code) );
+    free(error_message);
     return kEipStatusError;
   }
 
   struct sockaddr_in global_broadcast_address = { .sin_family = AF_INET,
-      .sin_port = htons(kOpenerEthernetPort), .sin_addr.s_addr= htonl(INADDR_ANY) };
+                                                  .sin_port = htons(
+                                                    kOpenerEthernetPort),
+                                                  .sin_addr.s_addr = htonl(
+                                                    INADDR_ANY) };
 
   /* enable the UDP socket to receive broadcast messages */
-   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();
-	 char* error_message = GetErrorMessage(error_code);
-     OPENER_TRACE_ERR(
-         "error with setting broadcast receive for UDP socket: %d - %s\n",
-         error_code, error_message);
-	 free(error_message);
-     return kEipStatusError;
-   }
-
-  if ((bind(g_network_status.udp_global_broadcast_listener,
-            (struct sockaddr *) &global_broadcast_address,
-            sizeof(struct sockaddr))) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("error with global broadcast UDP bind: %d - %s\n", error_code, error_message);
-	free(error_message);
+  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();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR(
+      "error with setting broadcast receive for UDP socket: %d - %s\n",
+      error_code, error_message);
+    free(error_message);
+    return kEipStatusError;
+  }
+
+  if ( ( bind( g_network_status.udp_global_broadcast_listener,
+               (struct sockaddr *) &global_broadcast_address,
+               sizeof(struct sockaddr) ) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("error with global broadcast UDP bind: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   /* switch socket in listen mode */
-  if ((listen(g_network_status.tcp_listener, MAX_NO_OF_TCP_SOCKETS)) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler: error with listen: %d - %s\n", error_code, error_message);
-	free(error_message);
+  if ( ( listen(g_network_status.tcp_listener,
+                MAX_NO_OF_TCP_SOCKETS) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: error with listen: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
@@ -190,10 +209,10 @@ EipStatus NetworkHandlerInitialize(void) {
 
   /* keep track of the biggest file descriptor */
   highest_socket_handle = GetMaxSocket(
-      g_network_status.tcp_listener,
-      g_network_status.udp_global_broadcast_listener,
-      0,
-      g_network_status.udp_unicast_listener);
+    g_network_status.tcp_listener,
+    g_network_status.udp_global_broadcast_listener,
+    0,
+    g_network_status.udp_unicast_listener);
 
   g_last_time = GetMilliSeconds(); /* initialize time keeping */
   g_network_status.elapsed_time = 0;
@@ -211,8 +230,8 @@ void IApp_CloseSocket_tcp(int socket_handle) {
 
 EipBool8 CheckSocketSet(int socket) {
   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;
     } else {
       OPENER_TRACE_INFO("socket: %d closed with pending message\n", socket);
@@ -226,16 +245,16 @@ EipBool8 CheckSocketSet(int socket) {
 void CheckAndHandleTcpListenerSocket(void) {
   int new_socket;
   /* 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");
 
     new_socket = accept(g_network_status.tcp_listener, NULL, NULL);
     if (new_socket == -1) {
-	  int error_code = GetSocketErrorNumber();
-	  char* error_message = GetErrorMessage(error_code);
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
       OPENER_TRACE_ERR("networkhandler: error on accept: %d - %s\n",
                        error_code, error_message);
-	  free(error_message);
+      free(error_message);
       return;
     }
 
@@ -256,9 +275,9 @@ EipStatus NetworkHandlerProcessOnce(void) {
 
   g_time_value.tv_sec = 0;
   g_time_value.tv_usec = (
-      g_network_status.elapsed_time < kOpenerTimerTickInMilliSeconds ?
-          kOpenerTimerTickInMilliSeconds - g_network_status.elapsed_time : 0)
-      * 1000; /* 10 ms */
+    g_network_status.elapsed_time < kOpenerTimerTickInMilliSeconds ?
+    kOpenerTimerTickInMilliSeconds - g_network_status.elapsed_time : 0)
+                         * 1000; /* 10 ms */
 
   int ready_socket = select(highest_socket_handle + 1, &read_socket, 0, 0,
                             &g_time_value);
@@ -268,10 +287,12 @@ EipStatus NetworkHandlerProcessOnce(void) {
     {
       return kEipStatusOk;
     } else {
-	  int error_code = GetSocketErrorNumber();
-	  char* error_message = GetErrorMessage(error_code);
-      OPENER_TRACE_ERR("networkhandler: error with select: %d - %s\n", error_code, error_message);
-	  free(error_message);
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
+      OPENER_TRACE_ERR("networkhandler: error with select: %d - %s\n",
+                       error_code,
+                       error_message);
+      free(error_message);
       return kEipStatusError;
     }
   }
@@ -284,9 +305,9 @@ EipStatus NetworkHandlerProcessOnce(void) {
     CheckAndHandleConsumingUdpSockets();
 
     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 (kEipStatusError == HandleDataOnTcpSocket(socket)) /* if error */
+        if ( kEipStatusError == HandleDataOnTcpSocket(socket) ) /* if error */
         {
           CloseSocket(socket);
           CloseSession(socket); /* clean up session and close the socket */
@@ -323,12 +344,13 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
   socklen_t from_address_length;
 
   /* 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) ) {
 
     from_address_length = sizeof(from_address);
 
     OPENER_TRACE_STATE(
-        "networkhandler: unsolicited UDP message on EIP global broadcast socket\n");
+      "networkhandler: unsolicited UDP message on EIP global broadcast socket\n");
 
     /* Handle UDP broadcast messages */
     int received_size = recvfrom(g_network_status.udp_global_broadcast_listener,
@@ -338,11 +360,13 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
                                  &from_address_length);
 
     if (received_size <= 0) { /* got error */
-	  int error_code = GetSocketErrorNumber();
-	  char* error_message = GetErrorMessage(error_code);
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
       OPENER_TRACE_ERR(
-          "networkhandler: error on recvfrom UDP global broadcast port: %d - %s\n", error_code, error_message);
-	  free(error_message);
+        "networkhandler: error on recvfrom UDP global broadcast port: %d - %s\n",
+        error_code,
+        error_message);
+      free(error_message);
       return;
     }
 
@@ -352,8 +376,8 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
     int remaining_bytes = 0;
     do {
       int reply_length = HandleReceivedExplictUdpData(
-          g_network_status.udp_global_broadcast_listener, &from_address,
-          receive_buffer, received_size, &remaining_bytes, false);
+        g_network_status.udp_global_broadcast_listener, &from_address,
+        receive_buffer, received_size, &remaining_bytes, false);
 
       receive_buffer += received_size - remaining_bytes;
       received_size = remaining_bytes;
@@ -362,12 +386,12 @@ void CheckAndHandleUdpGlobalBroadcastSocket(void) {
         OPENER_TRACE_INFO("reply sent:\n");
 
         /* if the active socket matches a registered UDP callback, handle a UDP packet */
-        if (sendto(g_network_status.udp_global_broadcast_listener,
-                   (char *) g_ethernet_communication_buffer, reply_length, 0,
-                   (struct sockaddr *) &from_address, sizeof(from_address))
+        if (sendto( g_network_status.udp_global_broadcast_listener,
+                    (char *) g_ethernet_communication_buffer, reply_length, 0,
+                    (struct sockaddr *) &from_address, sizeof(from_address) )
             != reply_length) {
           OPENER_TRACE_INFO(
-              "networkhandler: UDP response was not fully sent\n");
+            "networkhandler: UDP response was not fully sent\n");
         }
       }
     } while (remaining_bytes > 0);
@@ -380,12 +404,12 @@ void CheckAndHandleUdpUnicastSocket(void) {
   socklen_t from_address_length;
 
   /* 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) ) {
 
     from_address_length = sizeof(from_address);
 
     OPENER_TRACE_STATE(
-        "networkhandler: unsolicited UDP message on EIP unicast socket\n");
+      "networkhandler: unsolicited UDP message on EIP unicast socket\n");
 
     /* Handle UDP broadcast messages */
     int received_size = recvfrom(g_network_status.udp_unicast_listener,
@@ -395,11 +419,13 @@ void CheckAndHandleUdpUnicastSocket(void) {
                                  &from_address_length);
 
     if (received_size <= 0) { /* got error */
-	  int error_code = GetSocketErrorNumber();
-	  char* error_message = GetErrorMessage(error_code);
-	  OPENER_TRACE_ERR(
-		  "networkhandler: error on recvfrom UDP unicast port: %d - %s\n", error_code, error_message);
-	  free(error_message);
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
+      OPENER_TRACE_ERR(
+        "networkhandler: error on recvfrom UDP unicast port: %d - %s\n",
+        error_code,
+        error_message);
+      free(error_message);
       return;
     }
 
@@ -409,8 +435,8 @@ void CheckAndHandleUdpUnicastSocket(void) {
     int remaining_bytes = 0;
     do {
       int reply_length = HandleReceivedExplictUdpData(
-          g_network_status.udp_unicast_listener, &from_address, receive_buffer,
-          received_size, &remaining_bytes, true);
+        g_network_status.udp_unicast_listener, &from_address, receive_buffer,
+        received_size, &remaining_bytes, true);
 
       receive_buffer += received_size - remaining_bytes;
       received_size = remaining_bytes;
@@ -419,36 +445,42 @@ void CheckAndHandleUdpUnicastSocket(void) {
         OPENER_TRACE_INFO("reply sent:\n");
 
         /* if the active socket matches a registered UDP callback, handle a UDP packet */
-        if (sendto(g_network_status.udp_unicast_listener,
-                   (char *) g_ethernet_communication_buffer, reply_length, 0,
-                   (struct sockaddr *) &from_address, sizeof(from_address))
+        if (sendto( g_network_status.udp_unicast_listener,
+                    (char *) g_ethernet_communication_buffer, reply_length, 0,
+                    (struct sockaddr *) &from_address, sizeof(from_address) )
             != reply_length) {
           OPENER_TRACE_INFO(
-              "networkhandler: UDP unicast response was not fully sent\n");
+            "networkhandler: UDP unicast response was not fully sent\n");
         }
       }
     } while (remaining_bytes > 0);
   }
 }
 
-EipStatus SendUdpData(struct sockaddr_in *address, int socket, EipUint8 *data,
+EipStatus SendUdpData(struct sockaddr_in *address,
+                      int socket,
+                      EipUint8 *data,
                       EipUint16 data_length) {
 
-  int sent_length = sendto(socket, (char *) data, data_length, 0,
-                           (struct sockaddr *) address, sizeof(*address));
+  int sent_length = sendto( socket, (char *) data, data_length, 0,
+                            (struct sockaddr *) address, sizeof(*address) );
 
   if (sent_length < 0) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-	OPENER_TRACE_ERR("networkhandler: error with sendto in sendUDPData: %d - %s\n", error_code, error_message);
-	free(error_message);
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR(
+      "networkhandler: error with sendto in sendUDPData: %d - %s\n",
+      error_code,
+      error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   if (sent_length != data_length) {
     OPENER_TRACE_WARN(
-        "data length sent_length mismatch; probably not all data was sent in SendUdpData, sent %d of %d\n",
-        sent_length, data_length);
+      "data length sent_length mismatch; probably not all data was sent in SendUdpData, sent %d of %d\n",
+      sent_length,
+      data_length);
     return kEipStatusError;
   }
 
@@ -461,36 +493,40 @@ EipStatus HandleDataOnTcpSocket(int socket) {
 
   /* We will handle just one EIP packet here the rest is done by the select
    * method which will inform us if more data is available in the socket
-   because of the current implementation of the main loop this may not be
-   the fastest way and a loop here with a non blocking socket would better
-   fit*/
+     because of the current implementation of the main loop this may not be
+     the fastest way and a loop here with a non blocking socket would better
+     fit*/
 
   /*Check how many data is here -- read the first four bytes from the connection */
   long number_of_read_bytes = recv(socket, g_ethernet_communication_buffer, 4,
                                    0); /*TODO we may have to set the socket to a non blocking socket */
 
   if (number_of_read_bytes == 0) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-	OPENER_TRACE_ERR("networkhandler: connection closed by client: %d - %s\n", error_code, error_message);
-	free(error_message);
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: connection closed by client: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
   if (number_of_read_bytes < 0) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-    OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n", error_code, error_message);
-	free(error_message);
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
   const EipUint8 *read_buffer = &g_ethernet_communication_buffer[2]; /* at this place EIP stores the data length */
   size_t data_size = GetIntFromMessage(&read_buffer)
-      + ENCAPSULATION_HEADER_LENGTH - 4; /* -4 is for the 4 bytes we have already read*/
+                     + ENCAPSULATION_HEADER_LENGTH - 4; /* -4 is for the 4 bytes we have already read*/
   /* (NOTE this advances the buffer pointer) */
-  if ((PC_OPENER_ETHERNET_BUFFER_SIZE - 4) < data_size) { /*TODO can this be handled in a better way?*/
+  if ( (PC_OPENER_ETHERNET_BUFFER_SIZE - 4) < data_size ) { /*TODO can this be handled in a better way?*/
     OPENER_TRACE_ERR(
-        "too large packet received will be ignored, will drop the data\n");
+      "too large packet received will be ignored, will drop the data\n");
     /* Currently we will drop the whole packet */
 
     do {
@@ -499,21 +535,26 @@ EipStatus HandleDataOnTcpSocket(int socket) {
 
       if (number_of_read_bytes == 0) /* got error or connection closed by client */
       {
-		int error_code = GetSocketErrorNumber();
-		char* error_message = GetErrorMessage(error_code);
-		OPENER_TRACE_ERR("networkhandler: connection closed by client: %d - %s\n", error_code, error_message);
-		free(error_message);
+        int error_code = GetSocketErrorNumber();
+        char *error_message = GetErrorMessage(error_code);
+        OPENER_TRACE_ERR(
+          "networkhandler: connection closed by client: %d - %s\n",
+          error_code,
+          error_message);
+        free(error_message);
         return kEipStatusError;
       }
       if (number_of_read_bytes < 0) {
-		int error_code = GetSocketErrorNumber();
-		char* error_message = GetErrorMessage(error_code);
-		OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n", error_code, error_message);
-		free(error_message);
+        int error_code = GetSocketErrorNumber();
+        char *error_message = GetErrorMessage(error_code);
+        OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n",
+                         error_code,
+                         error_message);
+        free(error_message);
         return kEipStatusError;
       }
       data_size -= number_of_read_bytes;
-      if ((data_size < PC_OPENER_ETHERNET_BUFFER_SIZE) && (data_size != 0)) {
+      if ( (data_size < PC_OPENER_ETHERNET_BUFFER_SIZE) && (data_size != 0) ) {
         data_sent = data_size;
       }
     } while (0 < data_size);
@@ -526,21 +567,25 @@ EipStatus HandleDataOnTcpSocket(int socket) {
 
   if (number_of_read_bytes == 0) /* got error or connection closed by client */
   {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-	OPENER_TRACE_ERR("networkhandler: connection closed by client: %d - %s\n", error_code, error_message);
-	free(error_message);
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: connection closed by client: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
   if (number_of_read_bytes < 0) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-	OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n", error_code, error_message);
-	free(error_message);
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipStatusError;
   }
 
-  if ((unsigned) number_of_read_bytes == data_size) {
+  if ( (unsigned) number_of_read_bytes == data_size ) {
     /*we got the right amount of data */
     data_size += 4;
     /*TODO handle partial packets*/
@@ -549,14 +594,14 @@ EipStatus HandleDataOnTcpSocket(int socket) {
     g_current_active_tcp_socket = socket;
 
     number_of_read_bytes = HandleReceivedExplictTcpData(
-        socket, g_ethernet_communication_buffer, data_size, &remaining_bytes);
+      socket, g_ethernet_communication_buffer, data_size, &remaining_bytes);
 
     g_current_active_tcp_socket = -1;
 
     if (remaining_bytes != 0) {
       OPENER_TRACE_WARN(
-          "Warning: received packet was to long: %d Bytes left!\n",
-          remaining_bytes);
+        "Warning: received packet was to long: %d Bytes left!\n",
+        remaining_bytes);
     }
 
     if (number_of_read_bytes > 0) {
@@ -596,11 +641,13 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
 
   peer_address_length = sizeof(struct sockaddr_in);
   /* create a new UDP socket */
-  if ((new_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
-	int error_code = GetSocketErrorNumber();
-	char* error_message = GetErrorMessage(error_code);
-	OPENER_TRACE_ERR("networkhandler: cannot create UDP socket: %d- %s\n", error_code, error_message);
-	free(error_message);
+  if ( ( new_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) ) == -1 ) {
+    int error_code = GetSocketErrorNumber();
+    char *error_message = GetErrorMessage(error_code);
+    OPENER_TRACE_ERR("networkhandler: cannot create UDP socket: %d- %s\n",
+                     error_code,
+                     error_message);
+    free(error_message);
     return kEipInvalidSocket;
   }
 
@@ -609,20 +656,22 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
   /* check if it is sending or receiving */
   if (communication_direction == kUdpCommuncationDirectionConsuming) {
     int option_value = 1;
-    if (setsockopt(new_socket, SOL_SOCKET, SO_REUSEADDR, (char *) &option_value,
-                   sizeof(option_value)) == -1) {
+    if (setsockopt( new_socket, SOL_SOCKET, SO_REUSEADDR,
+                    (char *) &option_value,
+                    sizeof(option_value) ) == -1) {
       OPENER_TRACE_ERR(
-          "error setting socket option SO_REUSEADDR on consuming udp socket\n");
+        "error setting socket option SO_REUSEADDR on consuming udp socket\n");
       return kEipStatusError;
     }
 
     /* bind is only for consuming necessary */
-    if ((bind(new_socket, (struct sockaddr *) socket_data,
-              sizeof(struct sockaddr))) == -1) {
-		int error_code = GetSocketErrorNumber();
-		char* error_message = GetErrorMessage(error_code);
-		OPENER_TRACE_ERR("error on bind udp: %d - %s\n", error_code, error_message);
-		free(error_message);
+    if ( ( bind( new_socket, (struct sockaddr *) socket_data,
+                 sizeof(struct sockaddr) ) ) == -1 ) {
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
+      OPENER_TRACE_ERR("error on bind udp: %d - %s\n", error_code,
+                       error_message);
+      free(error_message);
       return kEipInvalidSocket;
     }
 
@@ -632,31 +681,33 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
     if (socket_data->sin_addr.s_addr
         == g_multicast_configuration.starting_multicast_address) {
       if (1 != g_time_to_live_value) { /* we need to set a TTL value for the socket */
-        if (setsockopt(new_socket, IPPROTO_IP, IP_MULTICAST_TTL,
-                       &g_time_to_live_value,
-                       sizeof(g_time_to_live_value) < 0)) {
-			int error_code = GetSocketErrorNumber();
-			char* error_message = GetErrorMessage(error_code);
-			OPENER_TRACE_ERR(
-				"networkhandler: could not set the TTL to: %d, error: %d - %s\n",
-				g_time_to_live_value, error_code, error_message);
-			free(error_message);
+        if ( setsockopt(new_socket, IPPROTO_IP, IP_MULTICAST_TTL,
+                        &g_time_to_live_value,
+                        sizeof(g_time_to_live_value) < 0) ) {
+          int error_code = GetSocketErrorNumber();
+          char *error_message = GetErrorMessage(error_code);
+          OPENER_TRACE_ERR(
+            "networkhandler: could not set the TTL to: %d, error: %d - %s\n",
+            g_time_to_live_value, error_code, error_message);
+          free(error_message);
           return kEipInvalidSocket;
         }
       }
     }
   }
 
-  if ((communication_direction == kUdpCommuncationDirectionConsuming)
-      || (0 == socket_data->sin_addr.s_addr)) {
+  if ( (communication_direction == kUdpCommuncationDirectionConsuming)
+       || (0 == socket_data->sin_addr.s_addr) ) {
     /* we have a peer to peer producer or a consuming connection*/
     if (getpeername(g_current_active_tcp_socket,
                     (struct sockaddr *) &peer_address, &peer_address_length)
         < 0) {
-		int error_code = GetSocketErrorNumber();
-		char* error_message = GetErrorMessage(error_code);
-		OPENER_TRACE_ERR("networkhandler: could not get peername: %d - %s\n", error_code, error_message);
-		free(error_message);
+      int error_code = GetSocketErrorNumber();
+      char *error_message = GetErrorMessage(error_code);
+      OPENER_TRACE_ERR("networkhandler: could not get peername: %d - %s\n",
+                       error_code,
+                       error_message);
+      free(error_message);
       return kEipInvalidSocket;
     }
     /* store the originators address */
@@ -682,32 +733,36 @@ void CheckAndHandleConsumingUdpSockets(void) {
   while (NULL != connection_object_iterator) {
     current_connection_object = connection_object_iterator;
     connection_object_iterator = connection_object_iterator
-        ->next_connection_object; /* do this at the beginning as the close function may can make the entry invalid */
-
-    if ((-1
-        != current_connection_object->socket[kUdpCommuncationDirectionConsuming])
-        && (true
-            == CheckSocketSet(
-                current_connection_object->socket[kUdpCommuncationDirectionConsuming]))) {
+                                 ->next_connection_object; /* do this at the beginning as the close function may can make the entry invalid */
+
+    if ( (-1
+          != current_connection_object->socket[
+            kUdpCommuncationDirectionConsuming])
+         && ( true
+              == CheckSocketSet(
+                current_connection_object->socket[
+                  kUdpCommuncationDirectionConsuming]) ) ) {
       from_address_length = sizeof(from_address);
       int received_size = recvfrom(
-          current_connection_object->socket[kUdpCommuncationDirectionConsuming],
-          g_ethernet_communication_buffer, PC_OPENER_ETHERNET_BUFFER_SIZE, 0,
-          (struct sockaddr *) &from_address, &from_address_length);
+        current_connection_object->socket[kUdpCommuncationDirectionConsuming],
+        g_ethernet_communication_buffer, PC_OPENER_ETHERNET_BUFFER_SIZE, 0,
+        (struct sockaddr *) &from_address, &from_address_length);
       if (0 == received_size) {
         OPENER_TRACE_STATE("connection closed by client\n");
         current_connection_object->connection_close_function(
-            current_connection_object);
+          current_connection_object);
         continue;
       }
 
       if (0 > received_size) {
-		int error_code = GetSocketErrorNumber();
-		char* error_message = GetErrorMessage(error_code);
-		OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n", error_code, error_message);
-		free(error_message);
+        int error_code = GetSocketErrorNumber();
+        char *error_message = GetErrorMessage(error_code);
+        OPENER_TRACE_ERR("networkhandler: error on recv: %d - %s\n",
+                         error_code,
+                         error_message);
+        free(error_message);
         current_connection_object->connection_close_function(
-            current_connection_object);
+          current_connection_object);
         continue;
       }
 
@@ -729,14 +784,17 @@ void CloseSocket(int socket_handle) {
 }
 
 int GetMaxSocket(int socket1, int socket2, int socket3, int socket4) {
-  if ((socket1 > socket2) && (socket1 > socket3) && (socket1 > socket4))
+  if ( (socket1 > socket2) && (socket1 > socket3) && (socket1 > socket4) ) {
     return socket1;
+  }
 
-  if ((socket2 > socket1) && (socket2 > socket3) && (socket2 > socket4))
+  if ( (socket2 > socket1) && (socket2 > socket3) && (socket2 > socket4) ) {
     return socket2;
+  }
 
-  if ((socket3 > socket1) && (socket3 > socket2) && (socket3 > socket4))
+  if ( (socket3 > socket1) && (socket3 > socket2) && (socket3 > socket4) ) {
     return socket3;
+  }
 
   return socket4;
 }

+ 18 - 18
source/src/typedefs.h

@@ -10,16 +10,16 @@
 #include <stddef.h>
 
 /** @file typedefs.h
- Do not use interface types for internal variables, such as "int i;", which is
- commonly used for loop counters or counting things.
+   Do not use interface types for internal variables, such as "int i;", which is
+   commonly used for loop counters or counting things.
 
- Do not over-constrain data types. Prefer the use of the native "int" and
- "unsigned" types.
+   Do not over-constrain data types. Prefer the use of the native "int" and
+   "unsigned" types.
 
- Use char for native character strings.
+   Use char for native character strings.
 
- Do not use "char" for data buffers - use "unsigned char" instead. Using char
- for data buffers can occasionally blow up in your face rather nastily.
+   Do not use "char" for data buffers - use "unsigned char" instead. Using char
+   for data buffers can occasionally blow up in your face rather nastily.
  */
 
 /** @brief EIP Data type definitions
@@ -69,20 +69,20 @@ typedef unsigned long long MicroSeconds;
 
 /**
 
- The following are generally true regarding return status:
- -1 ... an error occurred
- 0 ... success
+   The following are generally true regarding return status:
+   -1 ... an error occurred
+   0 ... success
 
- Occasionally there is a variation on this:
- -1 ... an error occurred
- 0 ..  success and there is no reply to send
- 1 ... success and there is a reply to send
+   Occasionally there is a variation on this:
+   -1 ... an error occurred
+   0 ..  success and there is no reply to send
+   1 ... success and there is a reply to send
 
- For both of these cases EIP_STATUS is the return type.
+   For both of these cases EIP_STATUS is the return type.
 
- Other return type are:
- -- return pointer to thing, 0 if error (return type is "pointer to thing")
- -- return count of something, -1 if error, (return type is int)
+   Other return type are:
+   -- return pointer to thing, 0 if error (return type is "pointer to thing")
+   -- return count of something, -1 if error, (return type is int)
 
  */
 

+ 3 - 2
source/src/utils/random.c

@@ -10,8 +10,9 @@
 #include <stdlib.h>
 
 Random *RandomNew(SetSeed set_seed, GetNextUInt32 get_next_uint32) {
-  Random *random = malloc(sizeof(Random));
-  *random = (Random ) { .set_seed = set_seed, .get_next_uint32 = get_next_uint32 };
+  Random *random = malloc( sizeof(Random) );
+  *random =
+    (Random ) { .set_seed = set_seed, .get_next_uint32 = get_next_uint32 };
   return random;
 }
 

+ 93 - 48
source/tests/cip/cipepathtest.cpp

@@ -90,7 +90,7 @@ TEST(CipEpath, GetPortSegmentPortIdentifier) {
 TEST(CipEpath, SetPortSegmentPortIdentifier) {
   unsigned char message[] = {0x00};
   SetPathPortSegmentPortIdentifier(15, message);
-  CHECK_EQUAL(15, (unsigned int)(message[0]));
+  CHECK_EQUAL( 15, (unsigned int)(message[0]) );
 }
 
 TEST(CipEpath, GetPortSegmentLinkAddressSize) {
@@ -114,151 +114,179 @@ TEST(CipEpath, GetPortSegmentExtendedPortNumberWithExtendedAddress) {
 TEST(CipEpath, SetPortSegmentExtendedPortNoExtendedAddress) {
   unsigned char message[] = {0x00, 0x00, 0x00};
   const char expected_message[] = {0x0F, 0x22, 0x64};
-  SetPathPortSegmentExtendedPortIdentifier((unsigned int)25634, message);
+  SetPathPortSegmentExtendedPortIdentifier( (unsigned int)25634, message );
   MEMCMP_EQUAL(expected_message, message, 3);
 }
 
 TEST(CipEpath, SetPortSegmentExtendedPortWithExtendedAddress) {
   unsigned char message[] = {0x10, 0x00, 0x00, 0x00};
   const char expected_message[] = {0x1F, 0x00, 0x22, 0x64};
-  SetPathPortSegmentExtendedPortIdentifier((unsigned int)25634, message);
+  SetPathPortSegmentExtendedPortIdentifier( (unsigned int)25634, message );
   MEMCMP_EQUAL(expected_message, message, 4);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeClassId) {
   const unsigned char message[] = {0x20};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeClassId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeInstanceId) {
   const unsigned char message[] = {0x24};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeInstanceId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeMemberId) {
   const unsigned char message[] = {0x28};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeMemberId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeConnectionPoint) {
   const unsigned char message[] = {0x2C};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeConnectionPoint, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeAttributeId) {
   const unsigned char message[] = {0x30};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeAttributeId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeSpecial) {
   const unsigned char message[] = {0x34};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeSpecial, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeServiceId) {
   const unsigned char message[] = {0x38};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeServiceId, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalTypeExtendedLogical) {
   const unsigned char message[] = {0x3C};
-  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(message);
+  const LogicalSegmentLogicalType type = GetPathLogicalSegmentLogicalType(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalTypeExtendedLogical, type);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatEightBits) {
   const unsigned char message[] = {0x20};
-  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
+  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatEightBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatSixteenBits) {
   const unsigned char message[] = {0x21};
-  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
+  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatSixteenBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentLogicalFormatThirtyTwoBits) {
   const unsigned char message[] = {0x22};
-  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(message);
+  const LogicalSegmentLogicalFormat format = GetPathLogicalSegmentLogicalFormat(
+    message);
   CHECK_EQUAL(kLogicalSegmentLogicalFormatThirtyTwoBit, format);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeReserved) {
   const unsigned char message[] = {0x3C, 0x00};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeReserved, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeArrayIndex) {
   const unsigned char message[] = {0x3C, 0x01};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeArrayIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeIndirectArrayIndex) {
   const unsigned char message[] = {0x3C, 0x02};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
-  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectArrayIndex, extended_type);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
+  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectArrayIndex,
+              extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeBitIndex) {
   const unsigned char message[] = {0x3C, 0x03};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeBitIndex, extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeIndirectBitIndex) {
   const unsigned char message[] = {0x3C, 0x04};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
-  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectBitIndex, extended_type);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
+  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeIndirectBitIndex,
+              extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeStructureMemberNumber) {
   const unsigned char message[] = {0x3C, 0x05};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
-  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberNumber, extended_type);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
+  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberNumber,
+              extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentExtendedLogicalTypeStructureMemberHandle) {
   const unsigned char message[] = {0x3C, 0x06};
-  const LogicalSegmentExtendedLogicalType extended_type = GetPathLogicalSegmentExtendedLogicalType(message);
-  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberHandle, extended_type);
+  const LogicalSegmentExtendedLogicalType extended_type =
+    GetPathLogicalSegmentExtendedLogicalType(message);
+  CHECK_EQUAL(kLogicalSegmentExtendedLogicalTypeStructureMemberHandle,
+              extended_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentSpecialTypeLogicalTypeReserved) {
   const unsigned char message[] = {0x35};
-  LogicalSegmentSpecialTypeLogicalFormat special_type = GetPathLogicalSegmentSpecialTypeLogicalType(message);
+  LogicalSegmentSpecialTypeLogicalFormat special_type =
+    GetPathLogicalSegmentSpecialTypeLogicalType(message);
   CHECK_EQUAL(kLogicalSegmentSpecialTypeLogicalFormatReserved, special_type);
 }
 
 TEST(CipEpath, GetLogicalSegmentSpecialTypeLogicalTypeElectronicKey) {
   const unsigned char message[] = {0x34};
-  LogicalSegmentSpecialTypeLogicalFormat special_type = GetPathLogicalSegmentSpecialTypeLogicalType(message);
-  CHECK_EQUAL(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey, special_type);
+  LogicalSegmentSpecialTypeLogicalFormat special_type =
+    GetPathLogicalSegmentSpecialTypeLogicalType(message);
+  CHECK_EQUAL(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey,
+              special_type);
 }
 
 TEST(CipEpath, GetPathLogicalSegmentElectronicKeyFormatReserved) {
   const unsigned char message[] = {0x34, 0x00};
-  ElectronicKeySegmentFormat key_format = GetPathLogicalSegmentElectronicKeyFormat(message);
+  ElectronicKeySegmentFormat key_format =
+    GetPathLogicalSegmentElectronicKeyFormat(message);
   CHECK_EQUAL(kElectronicKeySegmentFormatReserved, key_format);
 }
 
 TEST(CipEpath, GetPathLogicalSegmentElectronicKeyFormat4) {
   const unsigned char message[] = {0x34, 0x04};
-  ElectronicKeySegmentFormat key_format = GetPathLogicalSegmentElectronicKeyFormat(message);
+  ElectronicKeySegmentFormat key_format =
+    GetPathLogicalSegmentElectronicKeyFormat(message);
   CHECK_EQUAL(kElectronicKeySegmentFormatKeyFormat4, key_format);
 }
 
 TEST(CipEpath, GetLogicalSegmentElectronicKeyFormat4) {
-  const unsigned char message[] = {0x34,0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
+  const unsigned char message[] =
+  {0x34,0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
   ElectronicKeyFormat4 *electronic_key = ElectronicKeyFormat4New();
   GetPathLogicalSegmentElectronicKeyFormat4(message, electronic_key);
 
@@ -285,10 +313,12 @@ TEST(CipEpath, GetPathNetworkSegmentSubtypeFixedTag) {
   CHECK_EQUAL(kNetworkSegmentSubtypeFixedTagSegment, sub_type);
 }
 
-TEST(CipEpath, GetPathNetworkSegmentSubtypeProductionInhibitTimerInMilliseconds) {
+TEST(CipEpath,
+     GetPathNetworkSegmentSubtypeProductionInhibitTimerInMilliseconds) {
   const unsigned char message[] = {0x43};
   NetworkSegmentSubtype sub_type = GetPathNetworkSegmentSubtype(message);
-  CHECK_EQUAL(kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds, sub_type);
+  CHECK_EQUAL(kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds,
+              sub_type);
 }
 
 TEST(CipEpath, GetPathNetworkSegmentSubtypeSafety) {
@@ -297,10 +327,12 @@ TEST(CipEpath, GetPathNetworkSegmentSubtypeSafety) {
   CHECK_EQUAL(kNetworkSegmentSubtypeSafetySegment, sub_type);
 }
 
-TEST(CipEpath, GetPathNetworkSegmentSubtypeProductionInhibitTimerInMicroseconds) {
+TEST(CipEpath,
+     GetPathNetworkSegmentSubtypeProductionInhibitTimerInMicroseconds) {
   const unsigned char message[] = {0x50};
   NetworkSegmentSubtype sub_type = GetPathNetworkSegmentSubtype(message);
-  CHECK_EQUAL(kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds, sub_type);
+  CHECK_EQUAL(kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds,
+              sub_type);
 }
 
 TEST(CipEpath, GetPathNetworkSegmentSubtypeExtendedNetwork) {
@@ -311,13 +343,15 @@ TEST(CipEpath, GetPathNetworkSegmentSubtypeExtendedNetwork) {
 
 TEST(CipEpath, GetPathNetworkSegmentProductionInhibitTimeInMilliseconds) {
   const unsigned char message[] = {0x43, 0xFF};
-  CipUsint time_im_milliseconds = GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(message);
+  CipUsint time_im_milliseconds =
+    GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(message);
   CHECK_EQUAL(255, time_im_milliseconds);
 }
 
 TEST(CipEpath, GetPathNetworkSegmentProductionInhibitTimeInMicroseconds) {
   const unsigned char message[] = {0x50, 0x02, 0x00, 0x00, 0x00, 0xFF};
-  CipUdint time_in_microseconds = GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(message);
+  CipUdint time_in_microseconds =
+    GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(message);
   CHECK_EQUAL(4278190080, time_in_microseconds);
 }
 
@@ -366,66 +400,77 @@ TEST(CipEpath, GetPathSymbolicSegmentASCIIFormatLength) {
 
 TEST(CipEpath, GetPathSymbolicSegmentNumericTypeReserved) {
   const unsigned char message[] = {0x60, 0xC0};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatReserved, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentNumericTypeUSINT) {
   const unsigned char message[] = {0x60, 0xC6};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUSINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentNumericTypeUINT) {
   const unsigned char message[] = {0x60, 0xC7};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentNumericTypeUDINT) {
   const unsigned char message[] = {0x60, 0xC8};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentNumericType(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUDINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatReserverd) {
   const unsigned char message[] = {0x60, 0x00};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatReserved, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatDoubleChars) {
   const unsigned char message[] = {0x60, 0x20};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatDoubleByteChars, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatTripleChars) {
   const unsigned char message[] = {0x60, 0x40};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatTripleByteChars, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatUSINT) {
   const unsigned char message[] = {0x60, 0xC6};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUSINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatUINT) {
   const unsigned char message[] = {0x60, 0xC7};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatUDINT) {
   const unsigned char message[] = {0x60, 0xC8};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatNumericSymbolUDINT, format);
 }
 
 TEST(CipEpath, GetPathSymbolicSegmentExtendedFormatNumericReserved) {
   const unsigned char message[] = {0x60, 0xC9};
-  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(message);
+  SymbolicSegmentExtendedFormat format = GetPathSymbolicSegmentExtendedFormat(
+    message);
   CHECK_EQUAL(kSymbolicSegmentExtendedFormatReserved, format);
 }

+ 6 - 6
source/tests/utils/randomTests.cpp

@@ -20,10 +20,10 @@ TEST_GROUP(RandomClass)
 
 TEST(RandomClass, CreateXOrShiftObject)
 {
-	Random* pRandom = NULL;
-	uint32_t nResult = 0;
-	pRandom = RandomNew(SetXorShiftSeed, NextXorShiftUint32);
-	POINTERS_EQUAL(SetXorShiftSeed, pRandom->set_seed);
-	POINTERS_EQUAL(NextXorShiftUint32, pRandom->get_next_uint32);
-	RandomDelete(&pRandom);
+  Random *pRandom = NULL;
+  uint32_t nResult = 0;
+  pRandom = RandomNew(SetXorShiftSeed, NextXorShiftUint32);
+  POINTERS_EQUAL(SetXorShiftSeed, pRandom->set_seed);
+  POINTERS_EQUAL(NextXorShiftUint32, pRandom->get_next_uint32);
+  RandomDelete(&pRandom);
 }