Преглед на файлове

Fix cpplint issues

Signed-off-by: Martin Melik Merkumians <martin.melik@gmail.com>
Martin Melik Merkumians преди 3 седмици
родител
ревизия
41e343a1c7

+ 44 - 49
source/src/cip/cipcommon.c

@@ -344,52 +344,48 @@ CipClass* CreateCipClass(const CipUdint class_code,
    */
   memcpy(cip_class->class_name, name, name_len + 1);
 
-  /* initialize the class-specific fields of the metaClass struct */
-  meta_class->class_code =
-      0xffffffff; /* set metaclass ID (this should never be referenced) */
-  meta_class->number_of_instances =
-      1; /* the class object is the only instance of the metaclass */
-  meta_class->instances = (CipInstance*)cip_class;
-  meta_class->number_of_attributes =
-      number_of_class_attributes +
-      7; /* the metaclass remembers how many class attributes exist*/
-  meta_class->highest_attribute_number =
-      highest_class_attribute_number; /* indicate which attributes are included
-                                         in class getAttributeAll*/
-  meta_class->number_of_services =
-      number_of_class_services; /* the metaclass manages the behavior of the
-                                   class itself */
-  meta_class->class_name = (char*)CipCalloc(
-      1, strlen(name) + 6); /* fabricate the name "meta<classname>"*/
+  // initialize the class-specific fields of the metaClass struct
+  // set metaclass ID (this should never be referenced)
+  meta_class->class_code = 0xffffffff;
+  // the class object is the only instance of the metaclass */
+  meta_class->number_of_instances = 1;
+  meta_class->instances           = (CipInstance*)cip_class;
+  // the metaclass remembers how many class attributes exist
+  meta_class->number_of_attributes = number_of_class_attributes + 7;
+  // indicate which attributes are included in class getAttributeAll
+  meta_class->highest_attribute_number = highest_class_attribute_number;
+  /* the metaclass manages the behavior of the class itself */
+  meta_class->number_of_services = number_of_class_services;
+  // fabricate the name "meta<classname>"
+  meta_class->class_name = (char*)CipCalloc(1, strlen(name) + 6);
   snprintf(meta_class->class_name, strlen(name) + 6, "meta-%s", name);
 
-  /* initialize the instance-specific fields of the Class struct*/
-  cip_class->class_instance.instance_number =
-      0; /* the class object is instance zero of the class it describes (weird,
-            but that's the spec)*/
-  cip_class->class_instance.attributes =
-      0; /* this will later point to the class attibutes*/
-  cip_class->class_instance.cip_class =
-      meta_class; /* the class's class is the metaclass (like SmallTalk)*/
-  cip_class->class_instance.next =
-      0; /* the next link will always be zero, since there is only one instance
-            of any particular class object */
-
-  meta_class->class_instance.instance_number =
-      0xffff; /*the metaclass object does not really have a valid instance
-                 number*/
-  meta_class->class_instance.attributes =
-      NULL; /* the metaclass has no attributes*/
-  meta_class->class_instance.cip_class = NULL; /* the metaclass has no class*/
-  meta_class->class_instance.next =
-      NULL; /* the next link will always be zero, since there is only one
-               instance of any particular metaclass object*/
-
-  /* further initialization of the class object*/
-
+  // initialize the instance-specific fields of the Class struct
+  // the class object is instance zero of the class it describes (weird, but
+  // that's the spec)
+  cip_class->class_instance.instance_number = 0;
+  // this will later point to the class attibutes
+  cip_class->class_instance.attributes = 0;
+  // the class's class is the metaclass (like SmallTalk)
+  cip_class->class_instance.cip_class = meta_class;
+  // the next link will always be zero, since there is only one instance of any
+  // particular class object
+  cip_class->class_instance.next = 0;
+
+  // the metaclass object does not really have a valid instance number
+  meta_class->class_instance.instance_number = 0xffff;
+  // the metaclass has no attributes
+  meta_class->class_instance.attributes = NULL;
+  // the metaclass has no class
+  meta_class->class_instance.cip_class = NULL;
+  // the next link will always be zero, since there is only one instance of any
+  // particular metaclass object
+  meta_class->class_instance.next = NULL;
+
+  // further initialization of the class object
   cip_class->class_instance.attributes = (CipAttributeStruct*)CipCalloc(
       meta_class->number_of_attributes, sizeof(CipAttributeStruct));
-  /* TODO -- check that we didn't run out of memory?*/
+  /* TODO(MartinMelikMerkumians) -- check that we didn't run out of memory?*/
 
   meta_class->services = (CipServiceStruct*)CipCalloc(
       meta_class->number_of_services, sizeof(CipServiceStruct));
@@ -550,9 +546,8 @@ void InsertService(const CipClass* const cip_class,
   /* adding a service to a class that was not declared to have services is not
    * allowed*/
   OPENER_ASSERT(service != NULL);
-  for (unsigned int i = 0; i < cip_class->number_of_services;
-       i++) /* Iterate over all service slots attached to the class */
-  {
+  // Iterate over all service slots attached to the class
+  for (unsigned int i = 0; i < cip_class->number_of_services; i++) {
     if (service->service_number == service_number ||
         service->service_function == NULL) {  // found undefined service slot
       service->service_number   = service_number;    // fill in service number
@@ -1634,12 +1629,12 @@ EipStatus CipDeleteService(
     // update pointers in instance list
     // pointer to first instance
     instances = class->instances;
-    if (instances->instance_number ==
-        instance->instance_number) {  // if instance to delete is head
+    // if instance to delete is head of list
+    if (instances->instance_number == instance->instance_number) {
       class->instances = instances->next;
     } else {
-      while (NULL != instances->next)  // as long as pointer in not NULL
-      {
+      // as long as pointer in not NULL
+      while (NULL != instances->next) {
         CipInstance* next_instance = instances->next;
         if (next_instance->instance_number == instance->instance_number) {
           instances->next = next_instance->next;

+ 164 - 172
source/src/cip/cipconnectionmanager.c

@@ -3,7 +3,7 @@
  * All rights reserved.
  *
  ******************************************************************************/
-#include "cipconnectionmanager.h"
+#include "cip/cipconnectionmanager.h"
 
 #include <stdbool.h>
 #include <string.h>
@@ -29,19 +29,22 @@
 #include "ports/generic_networkhandler.h"
 #include "utils/xorshiftrandom.h"
 
-const size_t g_kForwardOpenHeaderLength =
-    36; /**< the length in bytes of the forward open command specific data till
-           the start of the connection path (including con path size)*/
-const size_t g_kLargeForwardOpenHeaderLength =
-    40; /**< the length in bytes of the large forward open command specific data
-           till the start of the connection path (including con path size)*/
+/** the length in bytes of the forward open command specific data till the start
+ of the connection path (including con path size) */
+const size_t g_kForwardOpenHeaderLength = 36;
+/** the length in bytes of the large forward open command specific data till the
+ * start of the connection path (including con path size) */
+const size_t g_kLargeForwardOpenHeaderLength = 40;
 
 static const unsigned int g_kNumberOfConnectableObjects =
     2 + OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS;
 
+/** @brief Mapping class IDs to connection opening functions */
 typedef struct {
-  EipUint32 class_id;
-  OpenConnectionFunction open_connection_function;
+  EipUint32 class_id;  ///< Class ID of the connectable object
+  OpenConnectionFunction open_connection_function;  ///< Function pointer to
+                                                    ///< the connection opening
+                                                    ///< function
 } ConnectionManagementHandling;
 
 /* global variables private */
@@ -51,10 +54,10 @@ typedef struct {
 ConnectionManagementHandling g_connection_management_list
     [2 + OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS] = {{0}};
 
-/** buffer connection object needed for forward open */
+/// buffer connection object needed for forward open
 CipConnectionObject g_dummy_connection_object;
 
-/** @brief Holds the connection ID's "incarnation ID" in the upper 16 bits */
+/// Holds the connection ID's "incarnation ID" in the upper 16 bits
 EipUint32 g_incarnation_id;
 
 /* private functions */
@@ -156,7 +159,7 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
  *    - kEipStatusOk ... on success
  *    - On an error the general status code to be put into the response
  */
-EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
+CipError ParseConnectionPath(CipConnectionObject* connection_object,
                              CipMessageRouterRequest* message_router_request,
                              EipUint16* extended_error);
 
@@ -216,60 +219,66 @@ CipUdint GetConnectionId(void) {
 void InitializeConnectionManager(CipClass* class) {
   CipClass* meta_class = class->class_instance.cip_class;
 
+  // Add class attributes
+  // revision
   InsertAttribute((CipInstance*)class,
                   1,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&class->revision,
-                  kGetableSingleAndAll); /* revision */
+                  kGetableSingleAndAll);
+  // largest instance number
   InsertAttribute((CipInstance*)class,
                   2,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&class->number_of_instances,
-                  kGetableSingleAndAll); /* largest instance number */
+                  kGetableSingleAndAll);
+  // number of instances currently existing
   InsertAttribute((CipInstance*)class,
                   3,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&class->number_of_instances,
-                  kGetableSingle); /* number of instances currently existing*/
+                  kGetableSingle);
+  // optional attribute list - default = 0
   InsertAttribute((CipInstance*)class,
                   4,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&kCipUintZero,
-                  kNotSetOrGetable); /* optional attribute list - default = 0 */
+                  kNotSetOrGetable);
+  // optional service list - default = 0
   InsertAttribute((CipInstance*)class,
                   5,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&kCipUintZero,
-                  kNotSetOrGetable); /* optional service list - default = 0 */
+                  kNotSetOrGetable);
+  // max class attribute number
   InsertAttribute((CipInstance*)class,
                   6,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&meta_class->highest_attribute_number,
-                  kGetableSingleAndAll); /* max class attribute number*/
+                  kGetableSingleAndAll);
+  // max instance attribute number
   InsertAttribute((CipInstance*)class,
                   7,
                   kCipUint,
                   EncodeCipUint,
                   NULL,
                   (void*)&class->highest_attribute_number,
-                  kGetableSingleAndAll); /* max instance attribute number*/
-
-  InsertService(meta_class,
-                kGetAttributeAll,
-                &GetAttributeAll,
-                "GetAttributeAll"); /* bind instance services to the metaclass*/
+                  kGetableSingleAndAll);
+  // bind instance services to the metaclass (class services)
+  InsertService(
+      meta_class, kGetAttributeAll, &GetAttributeAll, "GetAttributeAll");
   InsertService(meta_class,
                 kGetAttributeSingle,
                 &GetAttributeSingle,
@@ -291,9 +300,12 @@ EipStatus ConnectionManagerInit(EipUint16 unique_connection_id) {
       "connection manager",           /* class name */
       1,                              /* revision */
       &InitializeConnectionManager);  /* # function pointer for initialization*/
+
+  // Check of initialization was successfull
   if (connection_manager == NULL) {
     return kEipStatusError;
   }
+  // Add instance services to class object
   InsertService(connection_manager,
                 kGetAttributeSingle,
                 &GetAttributeSingle,
@@ -343,13 +355,12 @@ EipStatus HandleReceivedConnectedData(const EipUint8* const data,
     if ((g_common_packet_format_data_item.address_item.type_id ==
          kCipItemIdConnectionAddress) ||
         (g_common_packet_format_data_item.address_item.type_id ==
-         kCipItemIdSequencedAddressItem)) { /* found connected address item or
-                                               found sequenced address item ->
-                                               for now the sequence number will
-                                               be ignored */
+         kCipItemIdSequencedAddressItem)) {
+      /* found connected address item or found sequenced address item -> for now
+       * the sequence number will be ignored */
       if (g_common_packet_format_data_item.data_item.type_id ==
-          kCipItemIdConnectedDataItem) { /* connected data item received */
-
+          kCipItemIdConnectedDataItem) {
+        // connected data item received
         CipConnectionObject* connection_object =
             GetConnectedObject(g_common_packet_format_data_item.address_item
                                    .data.connection_identifier);
@@ -357,7 +368,7 @@ EipStatus HandleReceivedConnectedData(const EipUint8* const data,
           return kEipStatusError;
         }
 
-        /* only handle the data if it is coming from the originator */
+        // only handle the data if it is coming from the originator
         if (connection_object->originator_address.sin_addr.s_addr ==
             from_address->sin_addr.s_addr) {
           ConnectionObjectResetLastPackageInactivityTimerValue(
@@ -367,7 +378,7 @@ EipStatus HandleReceivedConnectedData(const EipUint8* const data,
                            .sequence_number,
                        connection_object->eip_level_sequence_count_consuming) ||
               !connection_object->eip_first_level_sequence_count_received) {
-            /* reset the watchdog timer */
+            // reset the connection watchdog timer
             ConnectionObjectResetInactivityWatchdogTimerValue(
                 connection_object);
 
@@ -516,7 +527,7 @@ EipStatus HandleNonNullNonMatchingForwardOpenRequest(
 
   EipUint16 connection_status = kConnectionManagerExtendedStatusCodeSuccess;
 
-  /*check if the trigger type value is invalid or ok */
+  // check if the trigger type value is invalid or ok
   if (kConnectionObjectTransportClassTriggerProductionTriggerInvalid ==
       ConnectionObjectGetTransportClassTriggerProductionTrigger(
           &g_dummy_connection_object)) {
@@ -536,13 +547,12 @@ EipStatus HandleNonNullNonMatchingForwardOpenRequest(
                                        connection_status);
   }
 
-  /*parsing is now finished all data is available and check now establish the
-   * connection */
+  // parsing is now finished all data is available and check now establish the
+  // connection Call with dummy instance to get the correct open connection
+  // function for thr targeted object
   ConnectionManagementHandling* connection_management_entry =
-      GetConnectionManagementEntry(/* Gets correct open connection function for
-                                      the targeted object */
-                                   g_dummy_connection_object.configuration_path
-                                       .class_id);
+      GetConnectionManagementEntry(
+          g_dummy_connection_object.configuration_path.class_id);
   if (NULL != connection_management_entry) {
     if (NULL != connection_management_entry->open_connection_function) {
       temp = connection_management_entry->open_connection_function(
@@ -1023,15 +1033,12 @@ EipStatus ManageConnections(MilliSeconds elapsed_time) {
     CipConnectionObject* connection_object = node->data;
     if (kConnectionObjectStateEstablished ==
         ConnectionObjectGetState(connection_object)) {
-      if ((NULL !=
-           connection_object
-               ->consuming_instance) || /* we have a consuming connection check
-                                           inactivity watchdog timer */
+      if ((NULL != connection_object->consuming_instance) ||
           (kConnectionObjectTransportClassTriggerDirectionServer ==
            ConnectionObjectGetTransportClassTriggerDirection(
-               connection_object))) /* all server connections have to maintain
-                                       an inactivity watchdog timer */
-      {
+               connection_object))) {
+        // we have a consuming connection check inactivity watchdog timer
+        // all server connections have to maintain an inactivity watchdog timer
         if (elapsed_time >= connection_object->inactivity_watchdog_timer) {
           /* we have a timed out connection perform watchdog time out action*/
           OPENER_TRACE_INFO(">>>>>>>>>>Connection ConnNr: %u timed out\n",
@@ -1043,32 +1050,28 @@ EipStatus ManageConnections(MilliSeconds elapsed_time) {
           connection_object->last_package_watchdog_timer -= elapsed_time;
         }
       }
+
       /* only if the connection has not timed out check if data is to be send */
       if (kConnectionObjectStateEstablished ==
           ConnectionObjectGetState(connection_object)) {
         /* client connection */
         if ((0 != ConnectionObjectGetExpectedPacketRate(connection_object)) &&
             (kEipInvalidSocket !=
-             connection_object
-                 ->socket[kUdpCommuncationDirectionProducing])) /* only produce
-                                                                   for the
-                                                                   master
-                                                                   connection */
-        {
+             connection_object->socket[kUdpCommuncationDirectionProducing])) {
+          /* only produce for the master connection */
           if (kConnectionObjectTransportClassTriggerProductionTriggerCyclic !=
               ConnectionObjectGetTransportClassTriggerProductionTrigger(
                   connection_object)) {
-            /* non cyclic connections have to decrement production inhibit timer
-             */
-            if (elapsed_time <= connection_object->production_inhibit_timer) {
-              // The connection is allowed to send again
-            } else {
+            // non-cyclic connections have to decrement production inhibit timer
+            // if it still needs to wait for another (next) period
+            // if it expires in this period it will be reloaded after sending
+            if (elapsed_time > connection_object->production_inhibit_timer) {
               connection_object->production_inhibit_timer -= elapsed_time;
             }
           }
 
-          if (connection_object->transmission_trigger_timer <=
-              elapsed_time) { /* need to send package */
+          if (connection_object->transmission_trigger_timer <= elapsed_time) {
+            // need to send package
             OPENER_ASSERT(NULL !=
                           connection_object->connection_send_data_function);
             EipStatus eip_status =
@@ -1078,11 +1081,11 @@ EipStatus ManageConnections(MilliSeconds elapsed_time) {
               OPENER_TRACE_ERR(
                   "sending of UDP data in manage Connection failed\n");
             }
-            /* add the RPI to the timer value */
+            // add the RPI to the timer value
             connection_object->transmission_trigger_timer +=
                 ConnectionObjectGetRequestedPacketInterval(connection_object);
-            /* decrecment the elapsed time from timer value, if less than timer
-             * value */
+            // decrecment the elapsed time from timer value, if less than timer
+            // value
             if (connection_object->transmission_trigger_timer > elapsed_time) {
               connection_object->transmission_trigger_timer -= elapsed_time;
             } else { /* elapsed time was longer than RPI */
@@ -1146,14 +1149,14 @@ EipStatus AssembleForwardOpenResponse(
 
   if (kCipErrorSuccess == general_status) {
     OPENER_TRACE_INFO("assembleFWDOpenResponse: sending success response\n");
-    /* if there is no application specific data, total length should be 26 */
+    // if there is no application specific data, total length should be 26
     message_router_response->size_of_additional_status = 0;
 
     if (cip_common_packet_format_data->address_info_item[0].type_id != 0) {
       cip_common_packet_format_data->item_count = 3;
       if (cip_common_packet_format_data->address_info_item[1].type_id != 0) {
-        cip_common_packet_format_data->item_count =
-            4; /* there are two sockaddrinfo items to add */
+        // there are two sockaddrinfo items to add
+        cip_common_packet_format_data->item_count = 4;
       }
     }
 
@@ -1162,7 +1165,7 @@ EipStatus AssembleForwardOpenResponse(
     AddDintToMessage(connection_object->cip_produced_connection_id,
                      &message_router_response->message);
   } else {
-    /* we have an connection creation error */
+    // we have an connection creation error
     OPENER_TRACE_WARN(
         "AssembleForwardOpenResponse: sending error response, general/extended "
         "status=%d/%d\n",
@@ -1216,7 +1219,7 @@ EipStatus AssembleForwardOpenResponse(
                    &message_router_response->message);
 
   if (kCipErrorSuccess == general_status) {
-    /* set the actual packet rate to requested packet rate */
+    // set the actual packet rate to requested packet rate
     AddDintToMessage(connection_object->o_to_t_requested_packet_interval,
                      &message_router_response->message);
     AddDintToMessage(connection_object->t_to_o_requested_packet_interval,
@@ -1226,10 +1229,10 @@ EipStatus AssembleForwardOpenResponse(
   AddSintToMessage(
       0,
       &message_router_response
-           ->message); /* remaining path size - for routing devices relevant */
-  AddSintToMessage(0, &message_router_response->message); /* reserved */
+           ->message);  // remaining path size - for routing devices relevant
+  AddSintToMessage(0, &message_router_response->message);  // reserved
 
-  return kEipStatusOkSend; /* send reply */
+  return kEipStatusOkSend;  // send reply
 }
 
 /**
@@ -1247,22 +1250,16 @@ void AddNullAddressItem(
   common_data_packet_format_data->address_item.length  = 0;
 }
 
-/*   INT8 assembleFWDCloseResponse(UINT16 pa_ConnectionSerialNr, UINT16
- * pa_OriginatorVendorID, UINT32 pa_OriginatorSerialNr, S_CIP_MR_Request
- * *pa_MRRequest, S_CIP_MR_Response *pa_MRResponse, S_CIP_CPF_Data *pa_CPF_data,
- * INT8 pa_status, INT8 *pa_msg) create FWDClose response dependent on status.
- *      pa_ConnectionSerialNr	requested ConnectionSerialNr
- *      pa_OriginatorVendorID	requested OriginatorVendorID
- *      pa_OriginatorSerialNr	requested OriginalSerialNr
- *      pa_MRRequest		pointer to message router request
- *      pa_MRResponse		pointer to message router response
- *      pa_CPF_data		pointer to CPF Data Item
- *      pa_status		status of FWDClose
- *      pa_msg			pointer to memory where reply has to be stored
- *  return status
- *                      0 .. no reply need to ne sent back
- *                      1 .. need to send reply
- *                     -1 .. error
+/** @brief Assembles the Forward Close Response
+ * @param connection_serial_number	connection serial number.
+ * @param originatior_vendor_id	originator vendor ID.
+ * @param originator_serial_number	originator serial number
+ * @param message_router_request		pointer to message router
+ * request
+ * @param message_router_response		pointer to message router
+ * response
+ * @param extended_error_code		extended error code
+ * @return EipStatus indicating if a response should be sent
  */
 EipStatus AssembleForwardCloseResponse(
     EipUint16 connection_serial_number,
@@ -1286,17 +1283,16 @@ EipStatus AssembleForwardCloseResponse(
 
   message_router_response->reply_service =
       (0x80 | message_router_request->service);
-  /* Excepted length is 10 if there is no application specific data */
+  // Excepted length is 10 if there is no application specific data
 
   if (kConnectionManagerExtendedStatusCodeSuccess == extended_error_code) {
-    AddSintToMessage(
-        0, &message_router_response->message); /* no application data */
+    AddSintToMessage(0,
+                     &message_router_response->message);  // no application data
     message_router_response->general_status            = kCipErrorSuccess;
     message_router_response->size_of_additional_status = 0;
   } else {
-    AddSintToMessage(
-        *message_router_request->data,
-        &message_router_response->message); /* remaining path size */
+    AddSintToMessage(*message_router_request->data,
+                     &message_router_response->message);  // remaining path size
     if (kConnectionManagerExtendedStatusWrongCloser == extended_error_code) {
       message_router_response->general_status = kCipErrorPrivilegeViolation;
     } else {
@@ -1306,9 +1302,8 @@ EipStatus AssembleForwardCloseResponse(
     }
   }
 
-  AddSintToMessage(0, &message_router_response->message); /* reserved */
-
-  return kEipStatusOkSend;
+  AddSintToMessage(0, &message_router_response->message);  // reserved
+  return kEipStatusOkSend;                                 // send reply
 }
 
 CipConnectionObject* GetConnectedObject(const EipUint32 connection_id) {
@@ -1366,10 +1361,10 @@ CipConnectionObject* CheckForExistingConnection(
 EipStatus CheckElectronicKeyData(EipUint8 key_format,
                                  void* key_data,
                                  EipUint16* extended_status) {
-  /* Default return value */
+  // Default return value
   *extended_status = kConnectionManagerExtendedStatusCodeSuccess;
 
-  /* Check key format */
+  // Check key format
   if (4 != key_format) {
     *extended_status =
         kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath;
@@ -1379,7 +1374,7 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
   bool compatiblity_mode =
       ElectronicKeyFormat4GetMajorRevisionCompatibility(key_data);
 
-  /* Check VendorID and ProductCode, must match, or 0 */
+  // Check VendorID and ProductCode must match or be 0
   if (((ElectronicKeyFormat4GetVendorId(key_data) != g_identity.vendor_id) &&
        (ElectronicKeyFormat4GetVendorId(key_data) != 0)) ||
       ((ElectronicKeyFormat4GetProductCode(key_data) !=
@@ -1389,9 +1384,9 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
         kConnectionManagerExtendedStatusCodeErrorVendorIdOrProductcodeError;
     return kEipStatusError;
   } else {
-    /* VendorID and ProductCode are correct */
+    // VendorID and ProductCode are correct
 
-    /* Check DeviceType, must match or 0 */
+    // Check DeviceType, must match or be 0
     if ((ElectronicKeyFormat4GetDeviceType(key_data) !=
          g_identity.device_type) &&
         (ElectronicKeyFormat4GetDeviceType(key_data) != 0)) {
@@ -1399,15 +1394,16 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
           kConnectionManagerExtendedStatusCodeErrorDeviceTypeError;
       return kEipStatusError;
     } else {
-      /* VendorID, ProductCode and DeviceType are correct */
+      // VendorID, ProductCode and DeviceType are correct
 
       if (false == compatiblity_mode) {
-        /* Major = 0 is valid */
+        // Major = 0 is valid
         if (0 == ElectronicKeyFormat4GetMajorRevision(key_data)) {
           return kEipStatusOk;
         }
 
-        /* Check Major / Minor Revision, Major must match, Minor match or 0 */
+        // Check Major / Minor Revision, Major must match, Minor must match or
+        // be 0
         if ((ElectronicKeyFormat4GetMajorRevision(key_data) !=
              g_identity.revision.major_revision) ||
             ((ElectronicKeyFormat4GetMinorRevision(key_data) !=
@@ -1418,9 +1414,9 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
           return kEipStatusError;
         }
       } else {
-        /* Compatibility mode is set */
+        // Compatibility mode is set
 
-        /* Major must match, Minor != 0 and <= MinorRevision */
+        // Major must match, Minor != 0 and <= MinorRevision
         if ((ElectronicKeyFormat4GetMajorRevision(key_data) ==
              g_identity.revision.major_revision) &&
             (ElectronicKeyFormat4GetMinorRevision(key_data) > 0) &&
@@ -1432,7 +1428,7 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
               kConnectionManagerExtendedStatusCodeErrorRevisionMismatch;
           return kEipStatusError;
         }
-      } /* end if CompatiblityMode handling */
+      }  // end if CompatiblityMode handling
     }
   }
 
@@ -1441,12 +1437,12 @@ EipStatus CheckElectronicKeyData(EipUint8 key_format,
              : kEipStatusError;
 }
 
-EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
+CipError ParseConnectionPath(CipConnectionObject* connection_object,
                              CipMessageRouterRequest* message_router_request,
                              EipUint16* extended_error) {
   const EipUint8* message = message_router_request->data;
   const size_t connection_path_size =
-      GetUsintFromMessage(&message); /* length in words */
+      GetUsintFromMessage(&message);  // length in words
   if (0 == connection_path_size) {
     // A (large) forward open request needs to have a connection path size
     // larger than 0
@@ -1460,7 +1456,7 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
   CipDword class_id          = 0x0;
   CipInstanceNum instance_id = 0x0;
 
-  /* with 256 we mark that we haven't got a PIT segment */
+  // with 256 we mark that we haven't got a PIT segment
   ConnectionObjectSetProductionInhibitTime(connection_object, 256);
 
   size_t header_length = g_kForwardOpenHeaderLength;
@@ -1470,21 +1466,21 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
 
   if ((header_length + remaining_path * sizeof(CipWord)) <
       message_router_request->request_data_size) {
-    /* the received packet is larger than the data in the path */
+    // the received packet is larger than the data in the path
     *extended_error = 0;
     return kCipErrorTooMuchData;
   }
 
   if ((header_length + remaining_path * sizeof(CipWord)) >
       message_router_request->request_data_size) {
-    /*there is not enough data in received packet */
+    // there is not enough data in received packet for the path
     *extended_error = 0;
     OPENER_TRACE_INFO("Message not long enough for path\n");
     return kCipErrorNotEnoughData;
   }
 
   if (remaining_path > 0) {
-    /* first look if there is an electronic key */
+    // first look if there is an electronic key
     if (kSegmentTypeLogicalSegment == GetPathSegmentType(message)) {
       if (kLogicalSegmentLogicalTypeSpecial ==
           GetPathLogicalSegmentLogicalType(message)) {
@@ -1492,21 +1488,20 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
             GetPathLogicalSegmentSpecialTypeLogicalType(message)) {
           if (kElectronicKeySegmentFormatKeyFormat4 ==
               GetPathLogicalSegmentElectronicKeyFormat(message)) {
-            /* Check if there is enough data for holding the electronic key
-             * segment */
+            // Check if there is enough data to hold the electronic key segment
             if (remaining_path < 5) {
               *extended_error = 0;
               OPENER_TRACE_INFO("Message not long enough for electronic key\n");
               return kCipErrorNotEnoughData;
             }
-            /* Electronic key format 4 found */
+            // Electronic key format 4 found
             connection_object->electronic_key.key_format = 4;
             ElectronicKeyFormat4* electronic_key = ElectronicKeyFormat4New();
             GetElectronicKeyFormat4FromMessage(&message, electronic_key);
-            /* logical electronic key found */
+            // logical electronic key found
             connection_object->electronic_key.key_data = electronic_key;
 
-            remaining_path -= 5; /*length of the electronic key*/
+            remaining_path -= 5;  // length of the electronic key
             OPENER_TRACE_INFO(
                 "key: ven ID %d, dev type %d, prod code %d, major %d, minor "
                 "%d\n",
@@ -1537,11 +1532,11 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
       }
     }
 
-    // TODO: Refactor this afterwards
+    // TODO(MartinMelikMerkumians): Refactor this afterwards
     if (kConnectionObjectTransportClassTriggerProductionTriggerCyclic !=
         ConnectionObjectGetTransportClassTriggerProductionTrigger(
             connection_object)) {
-      /*non cyclic connections may have a production inhibit */
+      // non-cyclic connections may have a production inhibit
       if (kSegmentTypeNetworkSegment == GetPathSegmentType(message)) {
         NetworkSegmentSubtype network_segment_subtype =
             GetPathNetworkSegmentSubtype(message);
@@ -1563,7 +1558,7 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
       if (NULL == class) {
         OPENER_TRACE_ERR("classid %" PRIx32 " not found\n", class_id);
 
-        if (class_id >= 0xC8) { /*reserved range of class ids */
+        if (class_id >= 0xC8) {  // reserved range of class ids
           *extended_error =
               kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath;
         } else {
@@ -1580,29 +1575,31 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
           kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath;
       return kCipErrorConnectionFailure;
     }
-    remaining_path -= 1; /* 1 16Bit word for the class part of the path */
+    remaining_path -= 1;  // 1 16Bit word for the class part of the path
 
-    /* Get instance ID */
+    // Get instance ID
     if (kSegmentTypeLogicalSegment == GetPathSegmentType(message) &&
         kLogicalSegmentLogicalTypeInstanceId ==
-            GetPathLogicalSegmentLogicalType(
-                message)) { /* store the configuration ID for later checking in
-                               the application connection types */
+            GetPathLogicalSegmentLogicalType(message)) {
+      // store the configuration ID for later checking in the application
+      // connection types
       const CipDword temp_id = CipEpathGetLogicalValue(&message);
 
       OPENER_TRACE_INFO("Configuration instance id %" PRId32 "\n", temp_id);
       if ((temp_id > kCipInstanceNumMax) ||
           (NULL == GetCipInstance(class, (CipInstanceNum)temp_id))) {
-        /*according to the test tool we should respond with this extended error
-         * code */
+        // according to the test tool we should respond with this extended error
+        // code
         *extended_error =
             kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath;
         return kCipErrorConnectionFailure;
       }
       instance_id = (CipInstanceNum)temp_id;
-      /* 1 or 2 16Bit words for the configuration instance part of the path  */
+      // 1 or 2 16Bit words for the configuration instance part of the path
       remaining_path -=
-          (instance_id > 0xFF) ? 2 : 1;  // TODO: 32 bit case missing
+          (instance_id > 0xFF)
+              ? 2
+              : 1;  // TODO(MartinMelikMerkumians): 32 bit case missing
     } else {
       OPENER_TRACE_INFO("no config data\n");
     }
@@ -1610,7 +1607,7 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
     if (kConnectionObjectTransportClassTriggerTransportClass3 ==
         ConnectionObjectGetTransportClassTriggerTransportClass(
             connection_object)) {
-      /*we have Class 3 connection*/
+      // This is a Class 3 connection
       if (remaining_path > 0) {
         OPENER_TRACE_WARN(
             "Too much data in connection path for class 3 connection\n");
@@ -1619,13 +1616,13 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
         return kCipErrorConnectionFailure;
       }
 
-      /* connection end point has to be the message router instance 1 */
+      // connection end point has to be the message router instance 1
       if ((class_id != kCipMessageRouterClassCode) || (1 != instance_id)) {
         *extended_error =
             kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo;
         return kCipErrorConnectionFailure;
       }
-      /* Configuration connection point is producing connection point */
+      // Configuration connection point is producing connection point
       CipConnectionPathEpath connection_epath = {
           .class_id                         = class_id,
           .instance_id                      = instance_id,
@@ -1638,8 +1635,8 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
              &connection_epath,
              sizeof(connection_object->produced_path));
 
-      /* End class 3 connection handling */
-    } else { /* we have an IO connection */
+      // End class 3 connection handling
+    } else {  // we have an IO connection
       CipConnectionPathEpath connection_epath = {
           .class_id                         = class_id,
           .instance_id                      = instance_id,
@@ -1654,31 +1651,31 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
 
       connection_object->consumed_connection_path_length = 0;
       connection_object->consumed_connection_path        = NULL;
-      // connection_object->connection_path.connection_point[1] = 0; /* set not
-      // available path to Invalid */
+      // connection_object->connection_path.connection_point[1] = 0;
+      // set not available path to Invalid */
 
       size_t number_of_encoded_paths             = 0;
       CipConnectionPathEpath* paths_to_encode[2] = {0};
       if (kConnectionObjectConnectionTypeNull ==
           originator_to_target_connection_type) {
         if (kConnectionObjectConnectionTypeNull ==
-            target_to_originator_connection_type) { /* configuration only
-                                                       connection */
+            target_to_originator_connection_type) {
+          // configuration only connection
           number_of_encoded_paths = 0;
           OPENER_TRACE_WARN("assembly: type invalid\n");
-        } else { /* 1 path -> path is for production */
+        } else {  // 1 path -> path is for production
           OPENER_TRACE_INFO("assembly: type produce\n");
           number_of_encoded_paths = 1;
           paths_to_encode[0]      = &(connection_object->produced_path);
         }
       } else {
         if (kConnectionObjectConnectionTypeNull ==
-            target_to_originator_connection_type) { /* 1 path -> path is for
-                                                       consumption */
+            target_to_originator_connection_type) {
+          // 1 path -> path is for consumption
           OPENER_TRACE_INFO("assembly: type consume\n");
           number_of_encoded_paths = 1;
           paths_to_encode[0]      = &(connection_object->consumed_path);
-        } else { /* 2 paths -> 1st for production 2nd for consumption */
+        } else {  // 2 paths -> 1st for production 2nd for consumption
           OPENER_TRACE_INFO("assembly: type bidirectional\n");
           paths_to_encode[0]      = &(connection_object->consumed_path);
           paths_to_encode[1]      = &(connection_object->produced_path);
@@ -1686,19 +1683,18 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
         }
       }
 
-      for (size_t i = 0; i < number_of_encoded_paths;
-           i++) /* process up to 2 encoded paths */
-      {
+      for (size_t i = 0; i < number_of_encoded_paths; i++) {
+        /* process up to 2 encoded paths */
         if (kSegmentTypeLogicalSegment == GetPathSegmentType(message) &&
             (kLogicalSegmentLogicalTypeInstanceId ==
                  GetPathLogicalSegmentLogicalType(message) ||
              kLogicalSegmentLogicalTypeConnectionPoint ==
-                 GetPathLogicalSegmentLogicalType(
-                     message))) /* Connection Point interpreted as InstanceNr ->
-                                   only in Assembly Objects */
-        {                       /* Attribute Id or Connection Point */
+                 GetPathLogicalSegmentLogicalType(message))) {
+          // Connection Point interpreted as InstanceNr -> only in Assembly
+          // Objects
+          // Attribute Id or Connection Point
 
-          /* Validate encoded instance number. */
+          // Validate encoded instance number.
           const CipDword temp_instance_id = CipEpathGetLogicalValue(&message);
           if (temp_instance_id > kCipInstanceNumMax) {
             *extended_error =
@@ -1720,7 +1716,7 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
                 kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo;
             return kCipErrorConnectionFailure;
           }
-          /* 1 or 2 16Bit word for the connection point part of the path */
+          // 1 or 2 16Bit word for the connection point part of the path
           remaining_path -= (instance_id > 0xFF) ? 2 : 1;
         } else {
           *extended_error =
@@ -1732,9 +1728,9 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
       g_config_data_length = 0;
       g_config_data_buffer = NULL;
 
-      while (remaining_path > 0) { /* remaining_path_size something left in the
-                                      path should be configuration data */
-
+      while (remaining_path > 0) {
+        // remaining_path_size something left in the path should be
+        // configuration data
         SegmentType segment_type = GetPathSegmentType(message);
         switch (segment_type) {
           case kSegmentTypeDataSegment: {
@@ -1742,9 +1738,8 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
                 GetPathDataSegmentSubtype(message);
             switch (data_segment_type) {
               case kDataSegmentSubtypeSimpleData:
-                g_config_data_length =
-                    message[1] *
-                    2; /*data segments store length 16-bit word wise */
+                // data segments store length 16-bit word wise
+                g_config_data_length = message[1] * 2;
                 g_config_data_buffer = (EipUint8*)message + 2;
                 remaining_path -= (g_config_data_length + 2) / 2;
                 message += (g_config_data_length + 2);
@@ -1762,18 +1757,16 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
                 if (kConnectionObjectTransportClassTriggerProductionTriggerCyclic !=
                     ConnectionObjectGetTransportClassTriggerProductionTrigger(
                         connection_object)) {
-                  /* only non cyclic connections may have a production inhibit
-                   */
+                  // only non cyclic connections may have a production inhibit
                   connection_object->production_inhibit_time = message[1];
                   message += 2;
                   remaining_path -= 2;
                 } else {
-                  *extended_error =
-                      connection_path_size -
-                      remaining_path; /*offset in 16Bit words where within the
-                                         connection path the error happened*/
-                  return kCipErrorPathSegmentError; /*status code for invalid
-                                                       segment type*/
+                  // offset in 16Bit words where within the connection path the
+                  // error happened
+                  *extended_error = connection_path_size - remaining_path;
+                  // status code for invalid segment type
+                  return kCipErrorPathSegmentError;
                 }
                 break;
               default:
@@ -1786,10 +1779,9 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
             OPENER_TRACE_WARN(
                 "No data segment identifier found for the configuration "
                 "data\n");
-            *extended_error =
-                connection_path_size -
-                remaining_path; /*offset in 16Bit words where within the
-                                   connection path the error happened*/
+            // offset in 16Bit words where within the connection path the error
+            // happened
+            *extended_error = connection_path_size - remaining_path;
             return kConnectionManagerGeneralStatusPathSegmentErrorInUnconnectedSend;
         }
       }
@@ -1798,8 +1790,8 @@ EipUint8 ParseConnectionPath(CipConnectionObject* connection_object,
 
   OPENER_TRACE_INFO("Resulting PIT value: %u\n",
                     connection_object->production_inhibit_time);
-  /*save back the current position in the stream allowing followers to parse
-   * anything thats still there*/
+  // save back the current position in the stream allowing followers to parse
+  // anything thats still there
   message_router_request->data = message;
   return kEipStatusOk;
 }
@@ -1812,7 +1804,7 @@ void CloseConnection(CipConnectionObject* RESTRICT connection_object) {
   if (kConnectionObjectTransportClassTriggerTransportClass3 !=
       ConnectionObjectGetTransportClassTriggerTransportClass(
           connection_object)) {
-    /* only close the UDP connection for not class 3 connections */
+    // only close the UDP connection for not class 3 connections
     CloseUdpSocket(
         connection_object->socket[kUdpCommuncationDirectionConsuming]);
     connection_object->socket[kUdpCommuncationDirectionConsuming] =

+ 162 - 149
source/src/cip/cipconnectionmanager.h

@@ -22,202 +22,215 @@
 
 typedef enum {
   kConnectionManagerGeneralStatusSuccess =
-      0x00, /**< General Status - Everything is ok */
+      0x00U, /**< General Status - Everything is ok */
   kConnectionManagerGeneralStatusExtendedStatus =
-      0x01, /**< Indicates that extended status is set */
-  kConnectionManagerGeneralStatusResourceUnavailableForUnconnectedSend = 0x02,
-  kConnectionManagerGeneralStatusPathSegmentErrorInUnconnectedSend     = 0x04,
-  kConnectionManagerGeneralStatusErrorInDataSegment                    = 0x09,
-  kConnectionManagerGeneralStatusObjectStateError                      = 0x0C,
-  kConnectionManagerGeneralStatusDeviceStateError                      = 0x10,
-  kConnectionManagerGeneralStatusNotEnoughData                         = 0x13,
-  kConnectionManagerGeneralStatusTooMuchData                           = 0x15,
+      0x01U, /**< Indicates that extended status is set */
+  kConnectionManagerGeneralStatusResourceUnavailableForUnconnectedSend = 0x02U,
+  kConnectionManagerGeneralStatusPathSegmentErrorInUnconnectedSend     = 0x04U,
+  kConnectionManagerGeneralStatusErrorInDataSegment                    = 0x09U,
+  kConnectionManagerGeneralStatusObjectStateError                      = 0x0CU,
+  kConnectionManagerGeneralStatusDeviceStateError                      = 0x10U,
+  kConnectionManagerGeneralStatusNotEnoughData                         = 0x13U,
+  kConnectionManagerGeneralStatusTooMuchData                           = 0x15U,
 } ConnectionManagerGeneralStatus;
+
 /** @brief Connection Manager Error codes */
 typedef enum {
   kConnectionManagerExtendedStatusCodeSuccess =
-      0x00, /**< Obsolete code, should be General Status - Everything is ok */
+      0x00U, /**< Obsolete code, should be General Status - Everything is ok */
   kConnectionManagerExtendedStatusCodeErrorConnectionInUseOrDuplicateForwardOpen =
-      0x0100, /**< General Status has to be 0x01, Connection is already in use,
-                 or a duplicate Forward Open was received */
+      0x0100U,  ///< General Status has to be 0x01, Connection is already in
+                ///< use, or a duplicate Forward Open was received
   kConnectionManagerExtendedStatusCodeErrorTransportClassAndTriggerCombinationNotSupported =
-      0x0103, /**< General Status has to be 0x01, A Transport class and trigger
-                 combination has been specified, which is not supported by the
-                 target application */
+      0x0103U,  ///< General Status has to be 0x01, A Transport class and
+                ///< trigger combination has been specified, which is not
+                ///< supported by the target application
   kConnectionManagerExtendedStatusCodeErrorOwnershipConflict =
-      0x0106, /**< General Status has to be 0x01, Another connection has already
-                 reserved some needed resources */
+      0x0106U,  ///< General Status has to be 0x01, Another connection has
+                ///< already reserved some needed resources */
   kConnectionManagerExtendedStatusCodeErrorConnectionTargetConnectionNotFound =
-      0x0107, /**< General Status has to be 0x01, Forward Close error message,
-                 if connection to be closed is not found at the target */
+      0x0107U,  ///< General Status has to be 0x01, Forward Close error message,
+                ///< if connection to be closed is not found at the target */
   kConnectionManagerExtendedStatusCodeErrorTargetForConnectionNotConfigured =
-      0x0110, /**< General Status has to be 0x01, Target application not
-                 configured and connection request does not contain data segment
-                 for configuration */
-  kConnectionManagerExtendedStatusCodeRpiNotSupported = 0x0111,
+      0x0110U,  ///< General Status has to be 0x01, Target application not
+                ///< configured and connection request does not contain data
+                ///< segment for configuration
+  kConnectionManagerExtendedStatusCodeRpiNotSupported =
+      0x0111U,  ///< General Status has
+                ///< to be 0x01, Requested RPI not supported by target device
   kConnectionManagerExtendedStatusCodeErrorRpiValuesNotAcceptable =
-      0x0112, /**< General Status has to be 0x01, Requested RPI parameters
-                 outside of range, needs 6 16-bit extended status words, see
-                 Vol.1 Table 3-5.33 */
+      0x0112U,  ///< General Status has to be 0x01, Requested RPI parameters
+                ///< outside of range, needs 6 16-bit extended status words, see
+                ///< Vol.1 Table 3-5.33
   kConnectionManagerExtendedStatusCodeErrorNoMoreConnectionsAvailable =
-      0x0113, /**< General Status has to be 0x01, No free connection slots
-                 available */
+      0x0113U,  ///< General Status has to be 0x01, No free connection slots
+                ///< available
   kConnectionManagerExtendedStatusCodeErrorVendorIdOrProductcodeError =
-      0x0114, /**< General Status has to be 0x01, The Product Code or Vendor ID
-                 in the electronic key logical segment does not match the
-                 Product Code or Vendor ID of the device, or if the
-                 compatibility bit is set and one or both are zero, or cannot be
-                 emulated. */
+      0x0114U,  ///< General Status has to be 0x01, The Product Code or Vendor
+                ///< ID in the electronic key logical segment does not match the
+                ///< Product Code or Vendor ID of the device, or if the
+                ///< compatibility bit is set and one or both are zero, or
+                ///< cannot be emulated.
   kConnectionManagerExtendedStatusCodeErrorDeviceTypeError =
-      0x0115, /**< General Status has to be 0x01, Device Type specified in the
-                 electronic key logical segment does not match the Device Type,
-                 or if the compatibility bit is set and Device Type is zero, or
-                 cannot be emulated. */
+      0x0115U,  ///< General Status has to be 0x01, Device Type specified in the
+                ///< electronic key logical segment does not match the Device
+                ///< Type, or if the compatibility bit is set and Device Type is
+                ///< zero, or cannot be emulated.
   kConnectionManagerExtendedStatusCodeErrorRevisionMismatch =
-      0x0116, /**< General Status has to be 0x01, Major and minor revision
-                 specified in the electronic key logical segment is not a valid
-                 revision of the device, or if the compatibility bit is set and
-                 the requested Major Revision and/or Minor Revision is 0 or the
-                 device cannot emulate the specified revision. */
+      0x0116U,  ///< General Status has to be 0x01, Major and minor revision
+                ///< specified in the electronic key logical segment is not a
+                ///< valid revision of the device, or if the compatibility bit
+                ///< is set and the requested Major Revision and/or Minor
+                ///< Revision is 0 or the device cannot emulate the specified
+                ///< revision.
   kConnectionManagerExtendedStatusCodeNonListenOnlyConnectionNotOpened =
-      0x0119, /**< General Status has to be 0x01, listen-only connection cannot
-                 be established, if no non-listen only connections are
-                 established  */
+      0x0119U,  ///< General Status has to be 0x01, listen-only connection
+                ///< cannot be established, if no non-listen only connections
+                ///< are established
   kConnectionManagerExtendedStatusCodeTargetObjectOutOfConnections =
-      0x011A, /**< Maximum number of connections supported by the instance of
-                 the target object exceeded */
+      0x011AU,  ///< Maximum number of connections supported by the instance of
+                ///< the target object exceeded
   kConnectionManagerExtendedStatusCodeProductionInhibitTimerGreaterThanRpi =
-      0x011B, /**< The Production Inhibit Time is greater than the Target to
-                 Originator RPI */
+      0x011BU,  ///< The Production Inhibit Time is greater than the Target to
+                ///< Originator RPI
   kConnectionManagerExtendedStatusCodeTransportClassNotSupported =
-      0x011C, /**< The transport class requested in the Transport Type/Trigger
-                 parameter is not supported. */
+      0x011CU,  ///< The transport class requested in the Transport Type/Trigger
+                ///< parameter is not supported.
   kConnectionManagerExtendedStatusCodeProductionTriggerNotSuppoerted =
-      0x011D, /**< The production trigger requested in the Transport
-                 Type/Trigger parameter is not supported. */
+      0x011DU,  ///< The production trigger requested in the Transport
+                ///< Type/Trigger parameter is not supported.
   kConnectionManagerExtendedStatusCodeDirectionNotSupported =
-      0x011E, /**< The direction requested in the Transport Type/Trigger
-                 parameter is not supported */
+      0x011EU,  ///< The direction requested in the Transport Type/Trigger
+                ///< parameter is not supported
   kConnectionManagerExtendedStatusCodeInvalidOToTNetworkConnectionFixVar =
-      0x011F, /**< Shall be returned as the result of specifying an O->T fixed /
-                 variable flag that is not supported. */
+      0x011FU,  ///< Shall be returned as the result of specifying an O->T fixed
+                ///< / variable flag that is not supported.
   kConnectionManagerExtendedStatusCodeInvalidTToONetworkConnectionFixVar =
-      0x0120, /**< Shall be returned as the result of specifying an T->O fixed /
-                 variable flag that is not supported. */
+      0x0120U,  ///< Shall be returned as the result of specifying an T->O fixed
+                ///< / variable flag that is not supported.
   kConnectionManagerExtendedStatusCodeInvalidOToTNetworkConnectionPriority =
-      0x0121, /**< Shall be returned as the result of specifying an O->T
-                 priority code that is not supported. */
+      0x0121U,  ///< Shall be returned as the result of specifying an O->T
+                ///< priority code that is not supported.
   kConnectionManagerExtendedStatusCodeInvalidTToONetworkConnectionPriority =
-      0x0122, /**< Shall be returned as the result of specifying an T->O
-                 priority code that is not supported. */
+      0x0122U,  ///< Shall be returned as the result of specifying an T->O
+                ///< priority code that is not supported.
   kConnectionManagerExtendedStatusCodeErrorInvalidOToTConnectionType =
-      0x0123, /**< Shall be returned as the result of specifying an O->T
-                 connection type that is not supported */
+      0x0123U,  ///< Shall be returned as the result of specifying an O->T
+                ///< connection type that is not supported
   kConnectionManagerExtendedStatusCodeErrorInvalidTToOConnectionType =
-      0x0124, /**< Shall be returned as the result of specifying a T->O
-                 connection type that is not supported */
+      0x0124U,  ///< Shall be returned as the result of specifying a T->O
+                ///< connection type that is not supported
   kConnectionManagerExtendedStatusCodeInvalidOToTNetworkConnectionRedundantOwner =
-      0x0125, /**< Shall be returned as the result of specifying an O->T
-                 Redundant Owner flag that is not supported. */
+      0x0125U,  ///< Shall be returned as the result of specifying an O->T
+                ///< Redundant Owner flag that is not supported.
   kConnectionManagerExtendedStatusCodeInvalidConfigurationSize =
-      0x0126, /**< The data segment provided in the Connection_Path parameter
-                 did not contain an acceptable number of 16-bit words for the
-                 the configuration application path requested. Two additional
-                 status words shall follow, the error code plus the max size in
-                 words */
+      0x0126U,  ///< The data segment provided in the Connection_Path parameter
+                ///< did not contain an acceptable number of 16-bit words for
+                ///< the the configuration application path requested. Two
+                ///< additional status words shall follow, the error code plus
+                ///< the max size in words
   kConnectionManagerExtendedStatusCodeErrorInvalidOToTConnectionSize =
-      0x0127, /**< The size of the consuming object declared in the Forward_Open
-                 request and available on the target does not match the size
-                 declared in the O->T Network Connection Parameter. Two
-                 additional status words shall follow, the error code plus the
-                 max size in words */
+      0x0127U,  ///< The size of the consuming object declared in the
+                ///< Forward_Open request and available on the target does not
+                ///< match the size declared in the O->T Network Connection
+                ///< Parameter. Two additional status words shall follow, the
+                ///< error code plus the
+                ///<  max size in words
   kConnectionManagerExtendedStatusCodeErrorInvalidTToOConnectionSize =
-      0x0128, /**< The size of the consuming object declared in the Forward_Open
-                 request and available on the target does not match the size
-                 declared in the T->O Network Connection Parameter. Two
-                 additional status words shall follow, the error code plus the
-                 max size in words  */
+      0x0128U,  ///< The size of the consuming object declared in the
+                ///< Forward_Open request and available on the target does not
+                ///< match the size declared in the T->O Network Connection
+                ///< Parameter. Two additional status words shall follow, the
+                ///< error code plus the max size in words
   kConnectionManagerExtendedStatusCodeInvalidConfigurationApplicationPath =
-      0x0129, /**< Configuration application path specified does not correspond
-                 to a valid configuration application path within the target
-                 application. This error could also be returned if a
-                 configuration application path was required, but not provided
-                 by a connection request. */
+      0x0129U,  ///< Configuration application path specified does not
+                ///< correspond
+                ///<  to a valid configuration application path within the
+                ///<  target
+                ///< configuration application path was required, but not
+                ///< provided
+                ///<  application. This error could also be returned if a
+                ///<  by a connection request.
   kConnectionManagerExtendedStatusCodeInvalidConsumingApplicationPath =
-      0x012A, /**< Consumed application path specified does not correspond to a
-                 valid consumed application path within the target application.
-                 This error could also be returned if a consumed application
-                 path was required, but not provided by a connection request. */
+      0x012AU,  ///< Consumed application path specified does not correspond to
+                ///< a valid consumed application path within the target
+                ///< application. This error could also be returned if a
+                ///< consumed application path was required, but not provided by
+                ///< a connection request.
   kConnectionManagerExtendedStatusCodeInvalidProducingApplicationPath =
-      0x012B, /**< Produced application path specified does not correspond to a
-                 valid produced application path within the target application.
-                 This error could also be returned if a produced application
-                 path was required, but not provided by a connection request. */
-  kConnectionManagerExtendedStatusCodeConfigurationSymbolDoesNotExist = 0x012C,
-  kConnectionManagerExtendedStatusCodeConsumingSymbolDoesNotExist     = 0x012D,
-  kConnectionManagerExtendedStatusCodeProducingSymbolDoesNotExist     = 0x012E,
+      0x012BU,  ///< Produced application path specified does not correspond to
+                ///< a valid produced application path within the target
+                ///< application. This error could also be returned if a
+                ///< produced application path was required, but not provided by
+                ///< a connection request.
+  kConnectionManagerExtendedStatusCodeConfigurationSymbolDoesNotExist = 0x012CU,
+  kConnectionManagerExtendedStatusCodeConsumingSymbolDoesNotExist     = 0x012DU,
+  kConnectionManagerExtendedStatusCodeProducingSymbolDoesNotExist     = 0x012EU,
   kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo =
-      0x012F, /**<  */
-  kConnectionManagerExtendedStatusCodeInconsistentConsumeDataFormat = 0x0130,
-  kConnectionManagerExtendedStatusCodeInconsistentProduceDataFormat = 0x0131,
-  kConnectionManagerExtendedStatusCodeNullForwardOpenNotSupported   = 0x0132,
+      0x012FU,
+  kConnectionManagerExtendedStatusCodeInconsistentConsumeDataFormat = 0x0130U,
+  kConnectionManagerExtendedStatusCodeInconsistentProduceDataFormat = 0x0131U,
+  kConnectionManagerExtendedStatusCodeNullForwardOpenNotSupported   = 0x0132U,
   kConnectionManagerExtendedStatusCodeConnectionTimeoutMultiplierNotAcceptable =
-      0x0133,
+      0x0133U,
   kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionFixVar =
-      0x0135,
+      0x0135U,
   kConnectionManagerExtendedStatusCodeMismatchedTToONetworkConnectionPriority =
-      0x0136,
-  kConnectionManagerExtendedStatusCodeMismatchedTransportClass        = 0x0137,
-  kConnectionManagerExtendedStatusCodeMismatchedTToOProductionTrigger = 0x0138,
+      0x0136U,
+  kConnectionManagerExtendedStatusCodeMismatchedTransportClass        = 0x0137U,
+  kConnectionManagerExtendedStatusCodeMismatchedTToOProductionTrigger = 0x0138U,
   kConnectionManagerExtendedStatusCodeMismatchedTToOProductionInhibitTimeSegment =
-      0x0139,
-  kConnectionManagerExtendedStatusCodeConnectionTimedOut         = 0x0203,
-  kConnectionManagerExtendedStatusCodeUnconnectedRequestTimedOut = 0x0204,
+      0x0139U,
+  kConnectionManagerExtendedStatusCodeConnectionTimedOut         = 0x0203U,
+  kConnectionManagerExtendedStatusCodeUnconnectedRequestTimedOut = 0x0204U,
   kConnectionManagerExtendedStatusCodeErrorParameterErrorInUnconnectedSendService =
-      0x0205, /**<  */
+      0x0205U,
   kConnectionManagerExtendedStatusCodeMessageToLargeForUnconnectedSendService =
-      0x0206,
+      0x0206U,
   kConnectionManagerExtendedStatusCodeUnconnectedAcknowledgeWithoutReply =
-      0x0207,
-  kConnectionManagerExtendedStatusCodeNoBufferMemoryAvailable = 0x0301,
+      0x0207U,
+  kConnectionManagerExtendedStatusCodeNoBufferMemoryAvailable = 0x0301U,
   kConnectionManagerExtendedStatusCodeNetworkBandwithNotAvailableForData =
-      0x0302,
+      0x0302U,
   kConnectionManagerExtendedStatusCodeNoConsumedConnectionIdFilterAvailable =
-      0x0303,
+      0x0303U,
   kConnectionManagerExtendedStatusCodeNotConfiguredToSendScheduledPriorityData =
-      0x0304,
-  kConnectionManagerExtendedStatusCodeScheduleSignatureMismatch = 0x0305,
+      0x0304U,
+  kConnectionManagerExtendedStatusCodeScheduleSignatureMismatch = 0x0305U,
   kConnectionManagerExtendedStatusCodeScheduleSignatureValidationNotPossible =
-      0x0306,
-  kConnectionManagerExtendedStatusCodePortNotAvailable    = 0x0311,
-  kConnectionManagerExtendedStatusCodeLinkAddressNotValid = 0x0312,
-  kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath =
-      0x0315, /**<  */
+      0x0306U,
+  kConnectionManagerExtendedStatusCodePortNotAvailable              = 0x0311U,
+  kConnectionManagerExtendedStatusCodeLinkAddressNotValid           = 0x0312U,
+  kConnectionManagerExtendedStatusCodeErrorInvalidSegmentTypeInPath = 0x0315U,
   kConnectionManagerExtendedStatusCodeForwardCloseServiceConnectionPathMismatch =
-      0x0316,
-  kConnectionManagerExtendedStatusCodeSchedulingNotSpecified           = 0x0317,
-  kConnectionManagerExtendedStatusCodeLinkAddressToSelfInvalid         = 0x0318,
-  kConnectionManagerExtendedStatusCodeSecondaryResourcesUnavailable    = 0x0319,
-  kConnectionManagerExtendedStatusCodeRackConnectionAlreadyEstablished = 0x031A,
+      0x0316U,
+  kConnectionManagerExtendedStatusCodeSchedulingNotSpecified        = 0x0317U,
+  kConnectionManagerExtendedStatusCodeLinkAddressToSelfInvalid      = 0x0318U,
+  kConnectionManagerExtendedStatusCodeSecondaryResourcesUnavailable = 0x0319U,
+  kConnectionManagerExtendedStatusCodeRackConnectionAlreadyEstablished =
+      0x031AU,
   kConnectionManagerExtendedStatusCodeModuleConnectionAlreadyEstablished =
-      0x031B,
-  kConnectionManagerExtendedStatusCodeMiscellaneous               = 0x031C,
-  kConnectionManagerExtendedStatusCodeRedundantConnectionMismatch = 0x031D,
+      0x031BU,
+  kConnectionManagerExtendedStatusCodeMiscellaneous               = 0x031CU,
+  kConnectionManagerExtendedStatusCodeRedundantConnectionMismatch = 0x031DU,
   kConnectionManagerExtendedStatusCodeNoMoreUserConfigurableLinkConsumerResourcesAvailableInTheProducingModule =
-      0x031E,
+      0x031EU,
   kConnectionManagerExtendedStatusCodeNoUserConfigurableLinkConsumerResourcesConfiguredInTheProducingModule =
-      0x031F,
-  kConnectionManagerExtendedStatusCodeNetworkLinkOffline               = 0x0800,
-  kConnectionManagerExtendedStatusCodeNoTargetApplicationDataAvailable = 0x0810,
+      0x031FU,
+  kConnectionManagerExtendedStatusCodeNetworkLinkOffline = 0x0800U,
+  kConnectionManagerExtendedStatusCodeNoTargetApplicationDataAvailable =
+      0x0810U,
   kConnectionManagerExtendedStatusCodeNoOriginatorApplicationDataAvailable =
-      0x0811,
+      0x0811U,
   kConnectionManagerExtendedStatusCodeNodeAddressHasChangedSinceTheNetworkWasScheduled =
-      0x0812,
+      0x0812U,
   kConnectionManagerExtendedStatusCodeNotConfiguredForOffSubnetMulticast =
-      0x0813,
-  kConnectionManagerExtendedStatusCodeInvalidProduceConsumeDataFormat = 0x0814,
+      0x0813U,
+  kConnectionManagerExtendedStatusCodeInvalidProduceConsumeDataFormat = 0x0814U,
   kConnectionManagerExtendedStatusWrongCloser =
-      0xFFFF /* No a real extended error code, but needed for forward close */
+      0xFFFFU  ///< Not an official extended error code - used for Forward Close
+               ///< indicating that not the original originator is trying to
+               ///< close the connection
 } ConnectionManagerExtendedStatusCode;
 
 /** @brief macros for comparing sequence numbers according to CIP spec vol
@@ -227,17 +240,17 @@ typedef enum {
  *  b
  *  @def SEQ_GT32(a, b) Checks if sequence number a is greater than b
  */
-#define SEQ_LEQ32(a, b) ((int)((a) - (b)) <= 0)
-#define SEQ_GEQ32(a, b) ((int)((a) - (b)) >= 0)
-#define SEQ_GT32(a, b) ((int)((a) - (b)) > 0)
+#define SEQ_LEQ32(a, b) ((int32_fast_t)((a) - (b)) <= 0)
+#define SEQ_GEQ32(a, b) ((int32_fast_t)((a) - (b)) >= 0)
+#define SEQ_GT32(a, b) ((int32_fast_t)((a) - (b)) > 0)
 
 /** @brief similar macros for comparing 16 bit sequence numbers
  * @def SEQ_LEQ16(a, b) Checks if sequence number a is less or equal than b
  * @def SEQ_GEQ16(a, b) Checks if sequence number a is greater or equal than
  *  b
  */
-#define SEQ_LEQ16(a, b) ((short)((a) - (b)) <= 0)
-#define SEQ_GEQ16(a, b) ((short)((a) - (b)) >= 0)
+#define SEQ_LEQ16(a, b) ((int16_fast_t)((a) - (b)) <= 0)
+#define SEQ_GEQ16(a, b) ((int16_fast_t)((a) - (b)) >= 0)
 
 /** @brief Connection Manager class code */
 static const CipUint kCipConnectionManagerClassCode = 0x06U;
@@ -278,7 +291,7 @@ CipConnectionObject* GetConnectedOutputAssembly(
  */
 void CloseConnection(CipConnectionObject* RESTRICT connection_object);
 
-/* TODO: Missing documentation */
+/* TODO(MelikMerkumians): Missing documentation */
 EipBool8 IsConnectedOutputAssembly(const CipInstanceNum instance_number);
 
 /** @brief Insert the given connection object to the list of currently active
@@ -308,4 +321,4 @@ void CheckForTimedOutConnectionsAndCloseTCPConnections(
     const CipConnectionObject* const connection_object,
     CloseSessionFunction CloseSessions);
 
-#endif /* CIP_CIPCONNECTIONMANAGER_H_ */
+#endif  // CIP_CIPCONNECTIONMANAGER_H_

+ 134 - 140
source/src/cip/cipconnectionobject.h

@@ -18,92 +18,67 @@
 #define CIP_CONNECTION_OBJECT_CODE 0x05
 
 typedef enum {
-  kConnectionObjectStateNonExistent = 0, /**< Connection is non existent */
-  kConnectionObjectStateConfiguring, /**< Waiting for both to be configured and
-                                        to apply the configuration */
-  kConnectionObjectStateWaitingForConnectionID, /**< Only used for device net */
-  kConnectionObjectStateEstablished, /**< Connection is established */
-  kConnectionObjectStateTimedOut,    /**< Connection timed out - inactivity or
-                                        watchdog timer expired */
-  kConnectionObjectStateDeferredDelete, /**< Only used for device net */
-  kConnectionObjectStateClosing, /**< For CIP bridged connections - have to wait
-                                    for a successful forward close */
-  kConnectionObjectStateInvalid  /**< An invalid state, shall never occur! */
+  kConnectionObjectStateNonExistent = 0,  ///< Connection is non existent
+  kConnectionObjectStateConfiguring,  ///< Waiting for both to be configured and
+                                      ///< to apply the configuration
+  kConnectionObjectStateWaitingForConnectionID,  ///< Only used for device net
+  kConnectionObjectStateEstablished,             ///< Connection is established
+  kConnectionObjectStateTimedOut,  ///< Connection timed out - inactivity or
+                                   ///< watchdog timer expired
+  kConnectionObjectStateDeferredDelete,  ///< Only used for device net
+  kConnectionObjectStateClosing,  ///< For CIP bridged connections - have to
+                                  ///< wait for a successful forward close
+  kConnectionObjectStateInvalid   ///< The connection object is in an invalid
+                                  ///< state
 } ConnectionObjectState;
 
 typedef enum {
   kConnectionObjectInstanceTypeInvalid =
-      (CipUsint)(~0), /**< Invalid instance type - shall never occur! */
+      (CipUsint)(~0),  ///< Invalid instance type - shall never occur!
   kConnectionObjectInstanceTypeExplicitMessaging =
-      0, /**< Connection is an explicit messaging connection */
-  kConnectionObjectInstanceTypeIO, /**< Connection is an I/O connection */
-  kConnectionObjectInstanceTypeIOExclusiveOwner, /**< Also I/O connection, only
-                                                    for easy differentiation */
-  kConnectionObjectInstanceTypeIOInputOnly,  /**< Also I/O connection, only for
-                                                easy differentiation */
-  kConnectionObjectInstanceTypeIOListenOnly, /**< Also I/O connection, only for
-                                                easy differentiation */
-  kConnectionObjectInstanceTypeCipBridged    /**< Connection is a bridged
-                                                connection */
+      0,  ///< Connection is an explicit messaging connection
+  kConnectionObjectInstanceTypeIO,  ///< Connection is an I/O connection
+  kConnectionObjectInstanceTypeIOExclusiveOwner,  ///< Also I/O connection, only
+                                                  ///< for easy differentiation
+  kConnectionObjectInstanceTypeIOInputOnly,   ///< Also I/O connection, only for
+                                              ///< easy differentiation
+  kConnectionObjectInstanceTypeIOListenOnly,  ///< Also I/O connection, only for
+                                              ///< easy differentiation
+  kConnectionObjectInstanceTypeCipBridged     ///< Connection is a bridged
+                                              ///< connection
 } ConnectionObjectInstanceType;
 
 typedef enum {
-  kConnectionObjectTransportClassTriggerDirectionClient =
-      0, /**< Endpoint provides client behavior */
-  kConnectionObjectTransportClassTriggerDirectionServer /**< Endpoint provides
-                                                           server behavior -
-                                                           production trigger
-                                                           bits are to be
-                                                           ignored */
+  /// Endpoint provides client behavior
+  kConnectionObjectTransportClassTriggerDirectionClient = 0,
+  /// Endpoint provides server behavior - production trigger bits are to be
+  /// ignored
+  kConnectionObjectTransportClassTriggerDirectionServer
 } ConnectionObjectTransportClassTriggerDirection;
 
 typedef enum {
-  kConnectionObjectTransportClassTriggerProductionTriggerInvalid =
-      -1, /**< Invalid Production trigger - shall never occur! */
-  kConnectionObjectTransportClassTriggerProductionTriggerCyclic =
-      0, /**< Transmission Trigger Timer trigger data production */
-  kConnectionObjectTransportClassTriggerProductionTriggerChangeOfState,    /**<
-                                                                              Production
-                                                                              is
-                                                                              trigger
-                                                                              when
-                                                                              change-of-state
-                                                                              is
-                                                                              detected
-                                                                              by
-                                                                              the
-                                                                              Application
-                                                                              Object
-                                                                            */
-  kConnectionObjectTransportClassTriggerProductionTriggerApplicationObject /**<
-                                                                              The
-                                                                              Application
-                                                                              Object
-                                                                              decided
-                                                                              when
-                                                                              production
-                                                                              is
-                                                                              triggered
-                                                                            */
+  /// Invalid Production trigger - shall never occur!
+  kConnectionObjectTransportClassTriggerProductionTriggerInvalid = -1,
+  /// Transmission Trigger Timer trigger data production
+  kConnectionObjectTransportClassTriggerProductionTriggerCyclic = 0,
+  /// Production is trigger when change-of-state is detected by the Application
+  /// Object
+  kConnectionObjectTransportClassTriggerProductionTriggerChangeOfState,
+  /// The Application Object decided when production is triggered
+  kConnectionObjectTransportClassTriggerProductionTriggerApplicationObject
 } ConnectionObjectTransportClassTriggerProductionTrigger;
 
 typedef enum {
-  kConnectionObjectTransportClassTriggerTransportClassInvalid =
-      -1, /**< Invalid Transport Class - shall never occur! */
-  kConnectionObjectTransportClassTriggerTransportClass0 =
-      0, /**< Class 0 producing or consuming connection, based on Direction */
-  kConnectionObjectTransportClassTriggerTransportClass1, /**< Class 1 producing
-                                                            or consuming
-                                                            connection, based on
-                                                            Direction */
-  kConnectionObjectTransportClassTriggerTransportClass2, /**< Class 2 producing
-                                                            and consuming
-                                                            connection, Client
-                                                            starts producing */
-  kConnectionObjectTransportClassTriggerTransportClass3  /**< Class 3 producing
-                                                            and consuming
-                                                            connection, Client
-                                                            starts producing */
+  /// Invalid Transport Class - shall never occur!
+  kConnectionObjectTransportClassTriggerTransportClassInvalid = -1,
+  /// Class 0 producing or consuming connection, based on Direction
+  kConnectionObjectTransportClassTriggerTransportClass0 = 0,
+  /// Class 1 producing or consuming connection, based on Direction
+  kConnectionObjectTransportClassTriggerTransportClass1,
+  /// Class 2 producing and consuming connection, Client starts producing
+  kConnectionObjectTransportClassTriggerTransportClass2,
+  /// Class 3 producing and consuming connection, Client starts producing
+  kConnectionObjectTransportClassTriggerTransportClass3
   /* Higher transport classes not supported */
 } ConnectionObjectTransportClassTriggerTransportClass;
 
@@ -112,18 +87,16 @@ typedef enum {
  * Only positive values allowed
  */
 typedef enum {
-  kConnectionObjectWatchdogTimeoutActionTransitionToTimedOut =
-      0, /**< Default for I/O connections, invalid for Explicit Messaging */
-  kConnectionObjectWatchdogTimeoutActionAutoDelete, /**< Default for explicit
-                                                       connections */
-  kConnectionObjectWatchdogTimeoutActionAutoReset,  /**< Invalid for explicit
-                                                       connections */
-  kConnectionObjectWatchdogTimeoutActionDeferredDelete, /**< Only for Device
-                                                           Net, invalid for I/O
-                                                           connections */
-  kConnectionObjectWatchdogTimeoutActionInvalid /**< Invalid Watchdog Timeout
-                                                   Action - shall never occur!
-                                                 */
+  /// Default for I/O connections, invalid for Explicit Messaging
+  kConnectionObjectWatchdogTimeoutActionTransitionToTimedOut = 0,
+  /// Default for explicit connections
+  kConnectionObjectWatchdogTimeoutActionAutoDelete,
+  /// Invalid for explicit connections
+  kConnectionObjectWatchdogTimeoutActionAutoReset,
+  /// Only for Device Net, invalid for I/O  connections
+  kConnectionObjectWatchdogTimeoutActionDeferredDelete,
+  /// Invalid Watchdog Timeout Action - shall never occur!
+  kConnectionObjectWatchdogTimeoutActionInvalid
 } ConnectionObjectWatchdogTimeoutAction;
 
 typedef enum {
@@ -158,33 +131,36 @@ typedef EipStatus (*CipConnectionStateHandler)(
     ConnectionObjectState new_state);
 
 struct cip_connection_object {
-  CipUsint state;                  /*< Attribute 1 */
-  CipUsint instance_type;          /*< Attribute 2 */
-  CipByte transport_class_trigger; /*< Attribute 3 */
+  CipUsint state;                   ///< Attribute 1
+  CipUsint instance_type;           ///< Attribute 2
+  CipByte transport_class_trigger;  ///< Attribute 3
   /* Attribute 4-6 only for device net*/
-  CipUint produced_connection_size; /*< Attribute 7 - Limits produced connection
-                                       size - for explicit messaging 0xFFFF
-                                       means no predefined limit */
-  CipUint consumed_connection_size; /*< Attribute 8 - Limits produced connection
-                                       size - for explicit messaging 0xFFFF
-                                       means no predefined limit */
-  CipUint expected_packet_rate; /*< Attribute 9 - Resolution in Milliseconds */
-  CipUdint cip_produced_connection_id;     /*< Attribute 10 */
-  CipUdint cip_consumed_connection_id;     /*< Attribute 11 */
-  CipUsint watchdog_timeout_action;        /*< Attribute 12 */
-  CipUint produced_connection_path_length; /*< Attribute 13 */
-  CipOctet* produced_connection_path;      /*< Attribute 14 */
+  CipUint
+      produced_connection_size;  ///< Attribute 7 - Limits produced connection
+                                 ///< size - for explicit messaging 0xFFFF
+                                 ///< means no predefined limit
+  CipUint
+      consumed_connection_size;  ///< Attribute 8 - Limits produced connection
+                                 ///< ///< size - for explicit messaging 0xFFFF
+                                 ///< ///< means no predefined limit
+  CipUint expected_packet_rate;  ///< Attribute 9 - Resolution in Milliseconds
+  CipUdint cip_produced_connection_id;      ///< Attribute 10
+  CipUdint cip_consumed_connection_id;      ///< Attribute 11
+  CipUsint watchdog_timeout_action;         ///< Attribute 12
+  CipUint produced_connection_path_length;  ///< Attribute 13
+  CipOctet* produced_connection_path;       ///< Attribute 14
   CipConnectionPathEpath produced_path;
-  CipUint consumed_connection_path_length; /*< Attribute 15 */
-  CipOctet* consumed_connection_path;      /*< Attribute 16 */
+  CipUint consumed_connection_path_length;  ///< Attribute 15
+  CipOctet* consumed_connection_path;       ///< Attribute 16
   CipConnectionPathEpath consumed_path;
-  CipUint production_inhibit_time;        /*< Attribute 17 */
-  CipUsint connection_timeout_multiplier; /*< Attribute 18 */
+  CipUint production_inhibit_time;         ///< Attribute 17
+  CipUsint connection_timeout_multiplier;  ///< Attribute 18
   /* Attribute 19 not supported as Connection Bind service not supported */
 
   /* End of CIP attributes */
   /* Start of needed non-object variables */
-  CipElectronicKey electronic_key;  // TODO: Check if really needed
+  CipElectronicKey
+      electronic_key;  // TODO(MartinMelikMerkumians): Check if really needed
 
   CipConnectionPathEpath configuration_path;
 
@@ -211,46 +187,33 @@ struct cip_connection_object {
   CipUdint t_to_o_requested_packet_interval;
   CipDword t_to_o_network_connection_parameters;
 
-  CipUint sequence_count_producing; /**< sequence Count for Class 1 Producing
-                                         Connections */
-  CipUint sequence_count_consuming; /**< sequence Count for Class 1 Producing
-                                         Connections */
-
-  EipUint32
-      eip_level_sequence_count_producing; /**< the EIP level sequence Count
-                                             for Class 0/1
-                                             Producing Connections may have a
-                                             different
-                                             value than SequenceCountProducing
-                                           */
-  EipUint32
-      eip_level_sequence_count_consuming; /**< the EIP level sequence Count
-                                             for Class 0/1
-                                             Producing Connections may have a
-                                             different
-                                             value than SequenceCountProducing
-                                           */
-  CipBool
-      eip_first_level_sequence_count_received; /**< False if
-                                               eip_level_sequence_count_consuming
-                                               hasn't been initialized with a
-                                               sequence count yet, true
-                                               otherwise */
+  CipUint sequence_count_producing;  ///< sequence Count for Class 1 Producing
+                                     ///< Connections
+  CipUint sequence_count_consuming;  ///< sequence Count for Class 1 Producing
+                                     ///< Connections
+  /// the EIP level sequence Count for Class 0/1 Producing Connections
+  /// may have a different value than SequenceCountProducing
+  EipUint32 eip_level_sequence_count_producing;
+  /// the EIP level sequence Count for Class 0/1 Producing
+  /// Connections may have a different value than SequenceCountProducing
+  EipUint32 eip_level_sequence_count_consuming;
+  /// False if eip_level_sequence_count_consuming hasn't been initialized
+  /// with a sequence count yet, true otherwise
+  CipBool eip_first_level_sequence_count_received;
   CipInt correct_originator_to_target_size;
   CipInt correct_target_to_originator_size;
 
   /* Sockets for consuming and producing connection */
   int socket[2];
 
-  struct sockaddr_in remote_address;     /* socket address for produce */
-  struct sockaddr_in originator_address; /* the address of the originator that
-                                              established the connection. needed
-                                              for scanning if the right packet
-                                            is arriving */
+  struct sockaddr_in remote_address;  ///< socket address for produce
 
-  CipSessionHandle
-      associated_encapsulation_session; /* The session handle ID via which the
-                                           forward open was sent */
+  /// the address of the originator that established the connection. needed
+  /// for scanning if the right packet is arriving
+  struct sockaddr_in originator_address;
+
+  /// The session handle ID via which the forward open was sent
+  CipSessionHandle associated_encapsulation_session;
 
   /* pointers to connection handling functions */
   CipConnectionStateHandler current_state_handler;
@@ -270,12 +233,12 @@ extern DoublyLinkedList connection_list;
 DoublyLinkedListNode* CipConnectionObjectListArrayAllocator();
 void CipConnectionObjectListArrayFree(DoublyLinkedListNode** node);
 
-/** @brief Array allocator
+/** @brief CIP Connection Object constructor - NOT IMPLEMENTED
  *
  */
 CipConnectionObject* CipConnectionObjectCreate(const CipOctet* message);
 
-/** @brief Array deallocator
+/** @brief CIP Connection Object destructor - NOT IMPLEMENTED
  *
  */
 void CipConnectionObjectDelete(CipConnectionObject** connection_object);
@@ -341,20 +304,51 @@ CipUint ConnectionObjectGetRequestedPacketInterval(
  * As this function sets the expected packet rate according to the rules of the
  * CIP specification, it is not always the exact value entered, but rounded up
  * to the next serviceable increment, relative to the timer resolution
+ *
+ * @param connection_object The connection object for which the expected packet
+ * rate is set
  */
 void ConnectionObjectSetExpectedPacketRate(
     CipConnectionObject* const connection_object);
 
+/** @brief Gets the CIP Produced Connection ID
+ *
+ * Return the CIP Produced Connection ID of the given connection object
+ * @param connection_object The connection object from which the CIP Produced
+ * Connection ID is retrieved
+ * @return The CIP Produced Connection ID
+ */
 CipUdint ConnectionObjectGetCipProducedConnectionID(
     const CipConnectionObject* const connection_object);
 
+/** @brief Sets the CIP Produced Connection ID
+ *
+ * Sets the CIP Produced Connection ID for the given connection object
+ * @param connection_object The connection object from which the CIP Produced
+ * Connection ID is retrieved
+ * @param cip_produced_connection_id The CIP Produced Connection ID to set
+ */
 void ConnectionObjectSetCipProducedConnectionID(
     CipConnectionObject* const connection_object,
     const CipUdint cip_produced_connection_id);
 
+/** @brief Get the CIP Consumed Connection ID
+ *
+ * Return the CIP Consumed Connection ID of the given connection object
+ * @param connection_object The connection object from which the CIP Consumed
+ * Connection ID is retrieved
+ * @return The CIP Consumed Connection ID
+ */
 CipUdint ConnectionObjectGetCipConsumedConnectionID(
     const CipConnectionObject* const connection_object);
 
+/** @brief Sets the CIP Consumed Connection ID
+ *
+ * Sets the CIP Consumed Connection ID for the given connection object
+ * @param connection_object The connection object from which the CIP Consumed
+ * Connection ID is retrieved
+ * @param cip_consumed_connection_id The CIP Consumed Connection ID to set
+ */
 void ConnectionObjectSetCipConsumedConnectionID(
     CipConnectionObject* const connection_object,
     const CipUdint cip_consumed_connection_id);
@@ -516,4 +510,4 @@ bool CipConnectionObjectOriginatorHasSameIP(
     const CipConnectionObject* const connection_object,
     const struct sockaddr* const originator_address);
 
-#endif /* CIP_CIPCONNECTIONOBJECT_H_ */
+#endif  // CIP_CIPCONNECTIONOBJECT_H_

+ 1 - 2
source/src/cip/cipdlr.c

@@ -126,8 +126,7 @@ EipStatus CipDlrInit(void) {
                              1,     /* # instances */
                              "DLR", /* object class name */
                              DLR_CLASS_REVISION, /* # class revision */
-                             NULL /* function pointer for initialization */
-  );
+                             NULL); /* function pointer for initialization */
 
   if (NULL == dlr_class) {
     return kEipStatusError;

+ 1 - 1
source/src/cip/cipdlr.h

@@ -78,4 +78,4 @@ extern CipDlrObject g_dlr; /**< declaration of DLR object instance 1 data */
  */
 EipStatus CipDlrInit(void);
 
-#endif /* of CIP_CIPDLR_H_ */
+#endif  // CIP_CIPDLR_H_

+ 6 - 5
source/src/cip/cipelectronickey.h

@@ -15,10 +15,10 @@
  *
  */
 typedef struct {
-  CipUsint key_format; /**< Key Format 0-3 reserved, 4 = see Key Format Table,
-                          5-255 = Reserved */
-  void* key_data;      /**< Depends on key format used, usually Key Format 4 as
-                               specified in CIP Specification, Volume 1*/
+  CipUsint key_format;  ///< Key Format 0-3 reserved, 4 = see Key Format Table,
+                        ///< 5-255 = Reserved
+  void* key_data;       ///< Depends on key format used, usually Key Format 4 as
+                        ///< specified in CIP Specification, Volume 1
 } CipElectronicKey;
 
 void ElectronicKeySetSegmentType(CipElectronicKey* const electronic_key,
@@ -42,6 +42,7 @@ void* ElectronicKeyGetKeyData(const CipElectronicKey* const electronic_key);
  */
 typedef struct electronic_key_format_4 ElectronicKeyFormat4;
 
+/** @brief Size of the electronic key format 4 data structure */
 extern const size_t kElectronicKeyFormat4Size;
 
 /** @brief Constructor for the electroic key format 4 class
@@ -149,4 +150,4 @@ void ElectronicKeyFormat4SetMinorRevision(
 CipUsint ElectronicKeyFormat4GetMinorRevision(
     const ElectronicKeyFormat4* const electronic_key);
 
-#endif /* CIP_CIPELECTRONICKEY_H_ */
+#endif  // CIP_CIPELECTRONICKEY_H_

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

@@ -14,9 +14,9 @@
 #include "core/trace.h"
 #include "enet_encap/endianconv.h"
 
-const unsigned int kPortSegmentExtendedPort =
-    15; /**< Reserved port segment port value, indicating the use of the
-           extended port field */
+/// Reserved port segment port value, indicating the use of the extended port
+/// field
+const unsigned int kPortSegmentExtendedPort = 15;
 
 /*** Path Segment ***/
 SegmentType GetPathSegmentType(const CipOctet* const cip_path) {
@@ -643,8 +643,8 @@ LogicalSegmentLogicalFormat CipEpathGetNeededLogicalFormatForValue(
   return logical_format;
 }
 
-////TODO: Does not match the actual interface anymore, check how to fix
-// size_t CipEpathEncodeConnectionEpath(
+// TODO(MartinMelikMerkumians): Does not match the actual interface anymore,
+// check how to fix size_t CipEpathEncodeConnectionEpath(
 //   const CipConnectionPathEpath *const connection_epath,
 //   CipOctet **encoded_path) {
 //

+ 103 - 105
source/src/cip/cipepath.h

@@ -12,90 +12,83 @@
 #include "cip/cipelectronickey.h"
 #include "cip/ciptypes.h"
 
-#define SEGMENT_TYPE_PORT_SEGMENT             \
-  0x00 /**< Message value of the Port segment \
-        */
-#define SEGMENT_TYPE_LOGICAL_SEGMENT \
-  0x20 /**< Message value of the Logical segment */
-#define SEGMENT_TYPE_NETWORK_SEGMENT \
-  0x40 /**< Message value of the Network segment */
-#define SEGMENT_TYPE_SYMBOLIC_SEGMENT \
-  0x60 /**< Message value of the Symbolic segment */
-#define SEGMENT_TYPE_DATA_SEGMENT             \
-  0x80 /**< Message value of the Data segment \
-        */
-#define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED \
-  0xA0 /**< Message value of the Data type constructed */
-#define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY \
-  0xC0 /**< Message value of the Data type elementary */
-#define SEGMENT_TYPE_SEGMENT_RESERVED 0xE0 /**< Reserved value */
-
-#define LOGICAL_SEGMENT_TYPE_CLASS_ID \
-  0x00 /**< Message value of the logical segment/logical type Class ID */
-#define LOGICAL_SEGMENT_TYPE_INSTANCE_ID \
-  0x04 /**< Message value of the logical segment/logical type Instance ID */
-#define LOGICAL_SEGMENT_TYPE_MEMBER_ID \
-  0x08 /**< Message value of the logical segment/logical type Member ID */
-#define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT                                  \
-  0x0C /**< Message value of the logical segment/logical type Connection Point \
-        */
-#define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID \
-  0x10 /**< Message value of the logical segment/logical type Attribute ID */
-#define LOGICAL_SEGMENT_TYPE_SPECIAL \
-  0x14 /**< Message value of the logical segment/logical type Special */
-#define LOGICAL_SEGMENT_TYPE_SERVICE_ID \
-  0x18 /**< Message value of the logical segment/logical type Service ID */
-#define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL                                  \
-  0x1C /**< Message value of the logical segment/logical type Extended Logical \
-        */
-
-#define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT \
-  0x00 /**< Message value indicating an 8 bit value */
-#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT \
-  0x01 /**< Message value indicating an 16 bit value */
-#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT \
-  0x02 /**< Message value indicating an 32 bit value */
-
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED                           \
-  0x00 /**< Message value indicating an reserved/unused Extended Logical \
-          Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX                             \
-  0x01 /**< Message value indicating the Array Index Extended Logical Segment \
-          type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX                     \
-  0x02 /**< Message value indicating the Indirect Array Index Extended Logical \
-          Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX                             \
-  0x03 /**< Message value indicating the Bit Index Extended Logical Segment \
-          type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX                     \
-  0x04 /**< Message value indicating the Indirect Bit Index Extended Logical \
-          Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER              \
-  0x05 /**< Message value indicating the Structured Member Number Extended \
-          Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE               \
-  0x06 /**< Message value indicating the Structured Member Handler Extended \
-          Logical Segment type */
-
-#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY \
-  0x00 /**< Message value indicating an electronic key */
+/// Message value of the Port segment
+#define SEGMENT_TYPE_PORT_SEGMENT 0x00
+/// Message value of the Logical segment
+#define SEGMENT_TYPE_LOGICAL_SEGMENT 0x20
+/// Message value of the Network segment
+#define SEGMENT_TYPE_NETWORK_SEGMENT 0x40
+/// Message value of the Symbolic segment
+#define SEGMENT_TYPE_SYMBOLIC_SEGMENT 0x60
+/// Message value of the Data segment
+#define SEGMENT_TYPE_DATA_SEGMENT 0x80
+/// Message value of the Data type constructed
+#define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED 0xA0
+/// Message value of the Data type elementary
+#define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY 0xC0
+/// Reserved value
+#define SEGMENT_TYPE_SEGMENT_RESERVED 0xE0
+
+/// Message value of the logical segment/logical type Class ID
+#define LOGICAL_SEGMENT_TYPE_CLASS_ID 0x00
+/// Message value of the logical segment/logical type Instance ID
+#define LOGICAL_SEGMENT_TYPE_INSTANCE_ID 0x04
+/// Message value of the logical segment/logical type Member ID
+#define LOGICAL_SEGMENT_TYPE_MEMBER_ID 0x08
+/// Message value of the logical segment/logical type Connection Point
+#define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT 0x0C
+/// Message value of the logical segment/logical type Attribute ID
+#define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID 0x10
+/// Message value of the logical segment/logical type Special
+#define LOGICAL_SEGMENT_TYPE_SPECIAL 0x14
+/// Message value of the logical segment/logical type Service ID
+#define LOGICAL_SEGMENT_TYPE_SERVICE_ID 0x18
+/// Message value of the logical segment/logical type Extended Logical
+#define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL 0x1C
+
+/// Message value indicating an 8 bit value
+#define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT 0x00
+/// Message value indicating an 16 bit value
+#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT 0x01
+/// Message value indicating an 32 bit value
+#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT 0x02
+
+/// Message value indicating an reserved/unused Extended Logical Segment type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED 0x00
+/// Message value indicating the Array Index Extended Logical Segment type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX 0x01
+/// Message value indicating the Indirect Array Index Extended Logical Segment
+/// type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX 0x02
+/// Message value indicating the Bit Index Extended Logical Segment type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX 0x03
+/// Message value indicating the Indirect Bit Index Extended Logical Segment
+/// type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX 0x04
+/// Message value indicating the Structured Member Number Extended Logical
+/// Segment type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER 0x05
+/// Message value indicating the Structured Member Handler Extended Logical
+/// Segment type
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE 0x06
+
+/// Message value indicating an electronic key
+#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY 0x00
+/// Electronic key segment format 4
 #define ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4 0x04
 
-#define NETWORK_SEGMENT_SCHEDULE \
-  0x01 /**< Message value indicating a network segment schedule message */
-#define NETWORK_SEGMENT_FIXED_TAG \
-  0x02 /**< Message value indicating a network segment fixed tag message */
-#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS            \
-  0x03 /**< Message value indicating a network segment PIT in milliseconds \
-          message */
-#define NETWORK_SEGMENT_SAFETY \
-  0x04 /**< Message value indicating a network segment safety message */
-#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS            \
-  0x10 /**< Message value indicating a network segment PIT in microseconds \
-          message */
-#define NETWORK_SEGMENT_EXTENDED_NETWORK \
-  0x1F /**< Message indicating a network message extended network message */
+/// Message value indicating a network segment schedule message
+#define NETWORK_SEGMENT_SCHEDULE 0x01
+/// Message value indicating a network segment fixed tag message
+#define NETWORK_SEGMENT_FIXED_TAG 0x02
+/// Message value indicating a network segment PIT in milliseconds message
+#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS 0x03
+/// Message value indicating a network segment safety message
+#define NETWORK_SEGMENT_SAFETY 0x04
+/// Message value indicating a network segment PIT in microseconds message
+#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS 0x10
+/// Message indicating a network message extended network message
+#define NETWORK_SEGMENT_EXTENDED_NETWORK 0x1F
 
 #define SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING 0x00
 
@@ -186,19 +179,20 @@ typedef enum electronic_key_segment_format {
  * from the actual needed message values
  */
 typedef enum network_segment_subtype {
-  kNetworkSegmentSubtypeReserved,        /**< Reserverd */
-  kNetworkSegmentSubtypeScheduleSegment, /**< Schedule segment */
-  kNetworkSegmentSubtypeFixedTagSegment, /**< Fixed tag segment */
-  kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds, /**< Production
-                                                                Inhibit Time in
-                                                                milliseconds
-                                                                segment */
-  kNetworkSegmentSubtypeSafetySegment, /**< Safety segment */
-  kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds, /**< Production
-                                                                Inhibit Time in
-                                                                microseconds
-                                                                segment */
-  kNetworkSegmentSubtypeExtendedNetworkSegment /**< Extended network segment */
+  /// Reserverd
+  kNetworkSegmentSubtypeReserved,
+  /// Schedule segment
+  kNetworkSegmentSubtypeScheduleSegment,
+  /// Fixed tag segment
+  kNetworkSegmentSubtypeFixedTagSegment,
+  /// Production Inhibit Time in milliseconds segment
+  kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds,
+  /// Safety segment
+  kNetworkSegmentSubtypeSafetySegment,
+  /// Production Inhibit Time in microseconds segment
+  kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds,
+  /// Extended network segment
+  kNetworkSegmentSubtypeExtendedNetworkSegment
 } NetworkSegmentSubtype;
 
 /** @brief Data segment sub types
@@ -222,14 +216,18 @@ typedef enum symbolic_segment_format {
  *
  */
 typedef enum symbolic_segment_extended_format {
-  kSymbolicSegmentExtendedFormatDoubleByteChars,    /**< Double byte character
-                                                       encoding */
-  kSymbolicSegmentExtendedFormatTripleByteChars,    /**< Triple byte character
-                                                       encoding */
-  kSymbolicSegmentExtendedFormatNumericSymbolUSINT, /**< Numeric USINT symbol */
-  kSymbolicSegmentExtendedFormatNumericSymbolUINT,  /**< Numeric UINT symbol */
-  kSymbolicSegmentExtendedFormatNumericSymbolUDINT, /**< Numeric UDINT symbol */
-  kSymbolicSegmentExtendedFormatReserved            /**< Reserved */
+  //// Double byte character encoding
+  kSymbolicSegmentExtendedFormatDoubleByteChars,
+  /// Triple byte character encoding
+  kSymbolicSegmentExtendedFormatTripleByteChars,
+  /// Numeric USINT symbol
+  kSymbolicSegmentExtendedFormatNumericSymbolUSINT,
+  /// Numeric UINT symbol
+  kSymbolicSegmentExtendedFormatNumericSymbolUINT,
+  /// Numeric UDINT symbol
+  kSymbolicSegmentExtendedFormatNumericSymbolUDINT,
+  /// Reserved
+  kSymbolicSegmentExtendedFormatReserved
 } SymbolicSegmentExtendedFormat;
 
 /* Start - Often used types of EPaths */
@@ -442,7 +440,7 @@ SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(
     const unsigned char* const cip_path);
 
 /* Special purpose encoding and decoding functions */
-// TODO currently not fully implemented
+// TODO(MartinMelikMerkumians) currently not fully implemented
 // size_t CipEpathEncodeConnectionEpath(
 //   const CipConnectionPathEpath *const connection_epath,
 //   CipOctet **encoded_path);
@@ -452,4 +450,4 @@ bool CipEpathEqual(const CipOctet* const path1,
                    const CipOctet* const path2,
                    const CipUint path2_length);
 
-#endif /* CIP_CIPEPATH_H_ */
+#endif  // CIP_CIPEPATH_H_

+ 134 - 138
source/src/cip/ciperror.h

@@ -7,145 +7,141 @@
 #define CIP_CIPERROR_H_
 
 typedef enum {
-  kCipErrorSuccess =
-      0x00, /**< Service was successfully performed by the object specified. */
-  kCipErrorConnectionFailure = 0x01, /**< A connection related service failed
-                                        along the connection path. */
-  kCipErrorResourceUnavailable =
-      0x02, /**< Resources needed for the object to perform the requested
-               service were unavailable */
-  kCipErrorInvalidParameterValue =
-      0x03, /**< See Status Code 0x20, which is the preferred value to use for
-               this condition. */
-  kCipErrorPathSegmentError =
-      0x04, /**< The path segment identifier or the segment syntax was not
-               understood by the processing node. Path processing shall stop
-               when a path segment error is encountered. */
-  kCipErrorPathDestinationUnknown =
-      0x05, /**< The path is referencing an object class, instance or structure
-               element that is not known or is not contained in the processing
-               node. Path processing shall stop when a path destination unknown
-               error is encountered. */
-  kCipErrorPartialTransfer =
-      0x06, /**< Only part of the expected data was transferred. */
-  kCipErrorConnectionLost = 0x07, /**< The messaging connection was lost. */
-  kCipErrorServiceNotSupported =
-      0x08, /**< The requested service was not implemented or was not defined
-               for this Object Class/Instance. */
-  kCipErrorInvalidAttributeValue = 0x09, /**< Invalid attribute data detected */
-  kCipErrorAttributeListError =
-      0x0A, /**< An attribute in the Get_Attribute_List or Set_Attribute_List
-               response has a non-zero status. */
-  kCipErrorAlreadyInRequestedMode =
-      0x0B, /**< The object is already in the mode/state being requested by the
-               service */
-  kCipErrorObjectStateConflict =
-      0x0C, /**< The object cannot perform the requested service in its current
-               mode/state */
-  kCipErrorObjectAlreadyExists = 0x0D, /**< The requested instance of object to
-                                          be created already exists.*/
-  kCipErrorAttributeNotSetable =
-      0x0E, /**< A request to modify a non-modifiable attribute was received. */
-  kCipErrorPrivilegeViolation =
-      0x0F, /**< A permission/privilege check failed */
-  kCipErrorDeviceStateConflict =
-      0x10, /**< The device's current mode/state prohibits the execution of the
-               requested service. */
-  kCipErrorReplyDataTooLarge =
-      0x11, /**< The data to be transmitted in the response buffer is larger
-               than the allocated response buffer */
-  kCipErrorFragmentationOfAPrimitiveValue =
-      0x12, /**< The service specified an operation that is going to fragment a
-               primitive data value, i.e. half a REAL data type. */
-  kCipErrorNotEnoughData = 0x13, /**< The service did not supply enough data to
-                                    perform the specified operation. */
-  kCipErrorAttributeNotSupported =
-      0x14, /**< The attribute specified in the request is not supported */
-  kCipErrorTooMuchData =
-      0x15, /**< The service supplied more data than was expected */
-  kCipErrorObjectDoesNotExist =
-      0x16, /**< The object specified does not exist in the device. */
-  kCipErrorServiceFragmentationSequenceNotInProgress =
-      0x17, /**< The fragmentation sequence for this service is not currently
-               active for this data. */
-  kCipErrorNoStoredAttributeData =
-      0x18, /**< The attribute data of this object was not saved prior to the
-               requested service. */
-  kCipErrorStoreOperationFailure =
-      0x19, /**< The attribute data of this object was not saved due to a
-               failure during the attempt. */
-  kCipErrorRoutingFailureRequestPacketTooLarge =
-      0x1A, /**< The service request packet was too large for transmission on a
-               network in the path to the destination. The routing device was
-               forced to abort the service. */
-  kCipErrorRoutingFailureResponsePacketTooLarge =
-      0x1B, /**< The service response packet was too large for transmission on a
-               network in the path from the destination. The routing device was
-               forced to abort the service. */
-  kCipErrorMissingAttributeListEntry =
-      0x1C, /**< The service did not supply an attribute in a list of attributes
-               that was needed by the service to perform the requested behavior.
-             */
-  kCipErrorInvalidAttributeValueList =
-      0x1D, /**< The service is returning the list of attributes supplied with
-               status information for those attributes that were invalid. */
-  kCipErrorEmbeddedServiceError =
-      0x1E, /**< An embedded service resulted in an error. */
-  kCipErrorVendorSpecificError =
-      0x1F, /**< A vendor specific error has been encountered. The Additional
-               Code Field of the Error Response defines the particular error
-               encountered. Use of this General Error Code should only be
-               performed when none of the Error Codes presented in this table or
-               within an Object Class definition accurately reflect the error.
-             */
-  kCipErrorInvalidParameter =
-      0x20, /**< A parameter associated with the request was invalid. This code
-               is used when a parameter does not meet the requirements of this
-               specification and/or the requirements defined in an Application
-               Object Specification. */
-  kCipErrorWriteonceValueOrMediumAlreadyWritten =
-      0x21, /**< An attempt was made to write to a write-once medium (e.g. WORM
-               drive, PROM) that has already been written, or to modify a value
-               that cannot be changed once established. */
-  kCipErrorInvalidReplyReceived =
-      0x22, /**< An invalid reply is received (e.g. reply service code does not
-               match the request service code, or reply message is shorter than
-               the minimum expected reply size). This status code can serve for
-               other causes of invalid replies. */
+  /// Service was successfully performed by the object specified.
+  kCipErrorSuccess = 0x00U,
+  /// A connection related service failed along the connection path.
+  kCipErrorConnectionFailure = 0x01U,
+  /// Resources needed for the object to perform the requested service were
+  /// unavailable
+  kCipErrorResourceUnavailable = 0x02U,
+  /// See Status Code 0x20, which is the preferred value to use for this
+  /// condition.
+  kCipErrorInvalidParameterValue = 0x03U,
+  /// The path segment identifier or the segment syntax was not understood by
+  /// the processing node. Path processing shall stop when a path segment error
+  /// is encountered.
+  kCipErrorPathSegmentError = 0x04U,
+  /// The path is referencing an object class, instance or structure element
+  /// that is not known or is not contained in the processing node. Path
+  /// processing shall stop when a path destination unknown error is
+  /// encountered.
+  kCipErrorPathDestinationUnknown = 0x05U,
+  /// Only part of the expected data was transferred.
+  kCipErrorPartialTransfer = 0x06U,
+  /// The messaging connection was lost.
+  kCipErrorConnectionLost = 0x07U,
+  /// The requested service was not implemented or was not defined for this
+  /// Object Class/Instance.
+  kCipErrorServiceNotSupported = 0x08U,
+  /// Invalid attribute data detected
+  kCipErrorInvalidAttributeValue = 0x09U,
+  /// An attribute in the Get_Attribute_List or Set_Attribute_List response has
+  /// a non-zero status.
+  kCipErrorAttributeListError = 0x0AU,
+  /// The object is already in the mode/state being requested by the service
+  kCipErrorAlreadyInRequestedMode = 0x0BU,
+  /// The object cannot perform the requested service in its current mode/state
+  kCipErrorObjectStateConflict = 0x0CU,
+  /// The requested instance of object to be created already exists.
+  kCipErrorObjectAlreadyExists = 0x0DU,
+  /// A request to modify a non-modifiable attribute was received.
+  kCipErrorAttributeNotSetable = 0x0EU,
+  /// A permission/privilege check failed
+  kCipErrorPrivilegeViolation = 0x0FU,
+  /// The device's current mode/state prohibits the execution of the requested
+  /// service.
+  kCipErrorDeviceStateConflict = 0x10U,
+  /// The data to be transmitted in the response buffer is larger than the
+  /// allocated response buffer
+  kCipErrorReplyDataTooLarge = 0x11U,
+  /// The service specified an operation that is going to fragment a primitive
+  /// data value, i.e. half a REAL data type.
+  kCipErrorFragmentationOfAPrimitiveValue = 0x12U,
+  /// The service did not supply enough data to perform the specified operation.
+  kCipErrorNotEnoughData = 0x13U,
+  /// The attribute specified in the request is not supported
+  kCipErrorAttributeNotSupported = 0x14U,
+  /// The service supplied more data than was expected
+  kCipErrorTooMuchData = 0x15U,
+  /// The object specified does not exist in the device.
+  kCipErrorObjectDoesNotExist = 0x16U,
+  /// The fragmentation sequence for this service is not currently active for
+  /// this data.
+  kCipErrorServiceFragmentationSequenceNotInProgress = 0x17U,
+  /// The attribute data of this object was not saved prior to the requested
+  /// service.
+  kCipErrorNoStoredAttributeData = 0x18U,
+  /// The attribute data of this object was not saved due to a failure during
+  /// the attempt.
+  kCipErrorStoreOperationFailure = 0x19U,
+  /// The service request packet was too large for transmission on a network in
+  /// the path to the destination. The routing device was forced to abort the
+  /// service.
+  kCipErrorRoutingFailureRequestPacketTooLarge = 0x1AU,
+  /// The service response packet was too large for transmission on a network in
+  /// the path from the destination. The routing device was forced to abort the
+  /// service.
+  kCipErrorRoutingFailureResponsePacketTooLarge = 0x1BU,
+  /// The service did not supply an attribute in a list of attributes that was
+  /// needed by the service to perform the requested behavior.
+  kCipErrorMissingAttributeListEntry = 0x1CU,
+  /// The service is returning the list of attributes supplied with status
+  /// information for those attributes that were invalid.
+  kCipErrorInvalidAttributeValueList = 0x1DU,
+  /// An embedded service resulted in an error.
+  kCipErrorEmbeddedServiceError = 0x1EU,
+  /// A vendor specific error has been encountered. The Additional Code Field of
+  /// the Error Response defines the particular error encountered. Use of this
+  /// General Error Code should only be performed when none of the Error Codes
+  /// presented in this table or within an Object Class definition accurately
+  /// reflect the error.
+  kCipErrorVendorSpecificError = 0x1FU,
+  /// A parameter associated with the request was invalid. This code is used
+  /// when a parameter does not meet the requirements of this specification
+  /// and/or the requirements defined in an Application Object Specification.
+  kCipErrorInvalidParameter = 0x20U,
+  /// An attempt was made to write to a write-once medium (e.g. WORM drive,
+  /// PROM) that has already been written, or to modify a value that cannot be
+  /// changed once established.
+  kCipErrorWriteonceValueOrMediumAlreadyWritten = 0x21U,
+  /// An invalid reply is received (e.g. reply service code does not match the
+  /// request service code, or reply message is shorter than the minimum
+  /// expected reply size). This status code can serve for other causes of
+  /// invalid replies.
+  kCipErrorInvalidReplyReceived = 0x22U,
   /* 23-24 Reserved by CIP for future extensions */
-  kCipErrorKeyFailureInPath =
-      0x25, /**< The Key Segment that was included as the first segment in the
-               path does not match the destination module. The object specific
-               status shall indicate which part of the key check failed. */
-  kCipErrorPathSizeInvalid =
-      0x26, /**< The size of the path which was sent with the Service Request is
-               either not large enough to allow the Request to be routed to an
-               object or too much routing data was included. */
-  kCipErrorUnexpectedAttributeInList =
-      0x27, /**< An attempt was made to set an attribute that is not able to be
-               set at this time. */
-  kCipErrorInvalidMemberId =
-      0x28, /**< The Member ID specified in the request does not exist in the
-               specified Class/Instance/Attribute */
-  kCipErrorMemberNotSetable =
-      0x29, /**< A request to modify a non-modifiable member was received */
-  kCipErrorGroup2OnlyServerGeneralFailure =
-      0x2A, /**< This error code may only be reported by DeviceNet group 2 only
-               servers with 4K or less code space and only in place of Service
-               not supported, Attribute not supported and Attribute not setable.
-             */
-  kCipErrorUnknownModbusError = 0x2B, /**< A CIP to Modbus translator received
-                                         an unknown Modbus Exception Code. */
-  kCipErrorAttributeNotGettable =
-      0x2C, /**< A request to read a non-readable attribute was received. */
-  kCipErrorInstanceNotDeletable =
-      0x2D, /**< The requested object instance cannot be deleted. */
-  kCipErrorServiceNotSupportedForSpecifiedPath =
-      0x2E, /**< The object supports the service, but not for the designated
-               application path (e.g. attribute). NOTE: Not to be used when a
-               more specific General Status Code applies, e.g. 0x0E (Attribute
-               not settable) or 0x29 (Member not settable).*/
+  /// The Key Segment that was included as the first segment in the path does
+  /// not match the destination module. The object specific status shall
+  /// indicate which part of the key check failed.
+  kCipErrorKeyFailureInPath = 0x25U,
+  /// The size of the path which was sent with the Service Request is either not
+  /// large enough to allow the Request to be routed to an object or too much
+  /// routing data was included.
+  kCipErrorPathSizeInvalid = 0x26U,
+  /// An attempt was made to set an attribute that is not able to be set at this
+  /// time.
+  kCipErrorUnexpectedAttributeInList = 0x27U,
+  /// The Member ID specified in the request does not exist in the specified
+  /// Class/Instance/Attribute
+  kCipErrorInvalidMemberId = 0x28U,
+  /// A request to modify a non-modifiable member was received
+  kCipErrorMemberNotSetable = 0x29U,
+  /// This error code may only be reported by DeviceNet group 2 only servers
+  /// with 4K or less code space and only in place of Service not supported,
+  /// Attribute not supported and Attribute not setable.
+  kCipErrorGroup2OnlyServerGeneralFailure = 0x2AU,
+  /// A CIP to Modbus translator received an unknown Modbus Exception Code.
+  kCipErrorUnknownModbusError = 0x2BU,
+  /// A request to read a non-readable attribute was received.
+  kCipErrorAttributeNotGettable = 0x2CU,
+  /// The requested object instance cannot be deleted.
+  kCipErrorInstanceNotDeletable = 0x2DU,
+  /// The object supports the service, but not for the designated application
+  /// path (e.g. attribute). NOTE: Not to be used when a more specific General
+  /// Status Code applies, e.g. 0x0E (Attribute not settable) or 0x29 (Member
+  /// not settable).
+  kCipErrorServiceNotSupportedForSpecifiedPath = 0x2EU,
   /* 2F - CF Reserved by CIP for future extensions D0 - FF Reserved for Object
      Class and service errors*/
 } CipError;
-#endif /* CIP_CIPERROR_H_ */
+#endif  // CIP_CIPERROR_H_

+ 7 - 7
source/src/cip/cipethernetlink.c

@@ -86,10 +86,10 @@
 /** @brief Type definition of one entry in the speed / duplex array
  */
 typedef struct speed_duplex_array_entry {
-  CipUint interface_speed; /**< the interface speed in Mbit/s */
-  CipUsint
-      interface_duplex_mode; /**< the interface's duplex mode: 0 = half duplex,
-                                1 = full duplex, 2-255 = reserved */
+  CipUint interface_speed;         /**< the interface speed in Mbit/s */
+  CipUsint interface_duplex_mode;  ///< the interface's duplex mode:
+                                   ///< 0 = half duplex,
+                                   ///< 1 = full duplex, 2-255 = reserved
 } CipEthernetLinkSpeedDuplexArrayEntry;
 
 /* forward declaration of functions to encode certain attribute objects */
@@ -172,10 +172,10 @@ static const CipShortString iface_label_table[OPENER_ETHLINK_INSTANCE_CNT] = {
     {.length = sizeof IFACE_LABEL_2 - 1, .string = (EipByte*)IFACE_LABEL_2},
 #endif
 };
-#endif /* defined(OPENER_ETHLINK_LABEL_ENABLE) && 0 != \
-          OPENER_ETHLINK_LABEL_ENABLE */
+#endif  // defined(OPENER_ETHLINK_LABEL_ENABLE) &&
+        // 0 != OPENER_ETHLINK_LABEL_ENABLE
 
-/* Two dummy variables to provide fill data for the GetAttributeAll service. */
+// Two dummy variables to provide fill data for the GetAttributeAll service.
 static CipUsint dummy_attribute_usint = 0;
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
 #else

+ 12 - 12
source/src/cip/cipethernetlink.h

@@ -155,26 +155,26 @@ typedef struct {
 
 /** @brief Data of an CIP Ethernet Link object */
 typedef struct {
-  EipUint32 interface_speed;    /**< Attribute #1: 10/100/1000 Mbit/sec */
-  EipUint32 interface_flags;    /**< Attribute #2: Interface flags as defined in
-                                   the CIP specification */
-  EipUint8 physical_address[6]; /**< Attribute #3: MAC address of the Ethernet
-                                   link */
+  EipUint32 interface_speed;  ///< Attribute #1: 10/100/1000 Mbit/sec
+  EipUint32 interface_flags;  ///< Attribute #2: Interface flags as defined in
+                              ///< the CIP specification
+  EipUint8 physical_address[6];  ///< Attribute #3: MAC address of the Ethernet
+                                 ///< link
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
   CipEthernetLinkInterfaceCounters
-      interface_cntrs; /**< Attribute #4: Interface counters 32-bit wide */
+      interface_cntrs;  ///< Attribute #4: Interface counters 32-bit wide
   CipEthernetLinkMediaCounters
-      media_cntrs; /**< Attribute #5: Media counters 32-bit wide */
+      media_cntrs;  ///< Attribute #5: Media counters 32-bit wide
 #endif
 #if defined(OPENER_ETHLINK_IFACE_CTRL_ENABLE) && \
     0 != OPENER_ETHLINK_IFACE_CTRL_ENABLE
   CipEthernetLinkInterfaceControl
-      interface_control; /** Attribute #6: control link properties */
+      interface_control;  ///< Attribute #6: control link properties
 #endif
-  CipUsint interface_type;        /**< Attribute #7: Type of interface */
-  CipShortString interface_label; /**< Attribute #10: Interface label */
+  CipUsint interface_type;         ///< Attribute #7: Type of interface
+  CipShortString interface_label;  ///< Attribute #10: Interface label
   CipEthernetLinkMetaInterfaceCapability
-      interface_caps; /**< Attribute #11: Interface capabilities */
+      interface_caps;  ///< Attribute #11: Interface capabilities
 } CipEthernetLinkObject;
 
 /* public functions */
@@ -197,4 +197,4 @@ void CipEthernetLinkSetMac(EipUint8* p_physical_address);
 
 extern CipEthernetLinkObject g_ethernet_link[];
 
-#endif /* CIP_CIPETHERNETLINK_H_*/
+#endif  // CIP_CIPETHERNETLINK_H_

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

@@ -43,11 +43,11 @@
 
 /** @brief Definition of the global Identity Object */
 CipIdentityObject g_identity = {
-    .vendor_id    = OPENER_DEVICE_VENDOR_ID,    /* Attribute 1: Vendor ID */
-    .device_type  = OPENER_DEVICE_TYPE,         /* Attribute 2: Device Type */
-    .product_code = OPENER_DEVICE_PRODUCT_CODE, /* Attribute 3: Product Code */
+    .vendor_id    = OPENER_DEVICE_VENDOR_ID,     // Attribute 1: Vendor ID
+    .device_type  = OPENER_DEVICE_TYPE,          // Attribute 2: Device Type
+    .product_code = OPENER_DEVICE_PRODUCT_CODE,  // Attribute 3: Product Code
     .revision =
-        {/* Attribute 4: Revision / CipUsint Major, CipUsint Minor */
+        {// Attribute 4: Revision / CipUsint Major, CipUsint Minor
          OPENER_DEVICE_MAJOR_REVISION,
          OPENER_DEVICE_MINOR_REVISION},
     .status = 0, /* Attribute 5: Status */
@@ -284,17 +284,17 @@ void EncodeRevision(const void* const data,
 EipStatus CipIdentityInit() {
   CipClass* class = CreateCipClass(
       kCipIdentityClassCode,
-      0,          /* # of non-default class attributes */
-      7,          /* # highest class attribute number*/
-      2,          /* # of class services*/
-      7,          /* # of instance attributes*/
-      7,          /* # highest instance attribute number*/
-      5,          /* # of instance services*/
-      1,          /* # of instances*/
-      "identity", /* # class name (for debug)*/
-      1,
-      /* # class revision*/    // TODO: change revision to 2 - check
-      &InitializeCipIdentity); /* # function pointer for initialization*/
+      0,           // # of non-default class attributes
+      7,           // # highest class attribute number
+      2,           // # of class services
+      7,           // # of instance attributes
+      7,           // # highest instance attribute number
+      5,           // # of instance services
+      1,           // # of instances
+      "identity",  // class name (for debug)
+      1,           // class revision
+      // TODO(MartinMelikMerkumians): change revision to 2 - check
+      &InitializeCipIdentity); /* function pointer for initialization*/
 
   if (class == 0) {
     return kEipStatusError;

+ 32 - 33
source/src/cip/cipidentity.h

@@ -14,26 +14,25 @@ static const CipUint kCipIdentityClassCode = 0x01U;
 
 /** @brief Status of the CIP Identity object */
 typedef enum {
-  kOwned = 0x0001, /**< Indicates that the device has an owner */
-  kConfigured =
-      0x0004, /**< Indicates that the device is configured to do
-                 something different, than the out-of-the-box default. */
-  kMinorRecoverableFault =
-      0x0100, /**< Indicates that the device detected a
-                 fault with itself, which was thought to be recoverable. The
-                 device did not switch to a faulted state. */
-  kMinorUncoverableFault =
-      0x0200, /**< Indicates that the device detected a
-                 fault with itself, which was thought to be recoverable. The
-                 device did not switch to a faulted state. */
-  kMajorRecoverableFault =
-      0x0400, /**< Indicates that the device detected a
-                 fault with itself,which was thought to be recoverable. The
-                 device changed to the "Major Recoverable Fault" state */
-  kMajorUnrecoverableFault =
-      0x0800 /**< Indicates that the device detected a
-                fault with itself,which was thought to be recoverable. The
-                device changed to the "Major Unrecoverable Fault" state */
+  /// Indicates that the device has an owner
+  kOwned = 0x0001,
+  /// Indicates that the device is configured to do something different, than
+  /// the out-of-the-box default.
+  kConfigured = 0x0004,
+  /// Indicates that the device detected a fault with itself, which was thought
+  /// to be recoverable. The device did not switch to a faulted state.
+  kMinorRecoverableFault = 0x0100,
+  /// Indicates that the device detected a fault with itself, which was thought
+  /// to be recoverable. The device did not switch to a faulted state.
+  kMinorUncoverableFault = 0x0200,
+  /// Indicates that the device detected a fault with itself,which was thought
+  /// to be recoverable. The device changed to the "Major Recoverable Fault"
+  /// state
+  kMajorRecoverableFault = 0x0400,
+  /// Indicates that the device detected a fault with itself,which was thought
+  /// to be recoverable. The device changed to the "Major Unrecoverable Fault"
+  /// state
+  kMajorUnrecoverableFault = 0x0800
 } CipIdentityStatus;
 
 /** @brief Constants for the extended status field in the Status word */
@@ -63,19 +62,19 @@ typedef enum {
 /** @brief Declaration of the Identity object's structure type
  */
 typedef struct {
-  CipUint vendor_id;    /**< Attribute 1: Vendor ID */
-  CipUint device_type;  /**< Attribute 2: Device Type */
-  CipUint product_code; /**< Attribute 3: Product Code */
+  CipUint vendor_id;     ///< Attribute 1: Vendor ID
+  CipUint device_type;   ///< Attribute 2: Device Type
+  CipUint product_code;  ///< Attribute 3: Product Code
   CipRevision
-      revision;   /**< Attribute 4: Revision / CipUsint Major, CipUsint Minor */
-  CipWord status; /**< Attribute 5: Status */
-  CipWord ext_status;     /**< Attribute 5: last set extended status, needed for
-                             Status handling */
-  CipUdint serial_number; /**< Attribute 6: Serial Number, has to be set prior
-                             to OpENer's network initialization */
-  CipShortString product_name; /**< Attribute 7: Product Name */
-  CipUsint state; /** Attribute 8: state, this member could control the Module
-                     Status LED blink pattern */
+      revision;    ///< Attribute 4: Revision / CipUsint Major, CipUsint Minor
+  CipWord status;  ///< Attribute 5: Status
+  CipWord ext_status;  ///< Attribute 5: last set extended status, needed for
+                       ///< Status handling
+  CipUdint serial_number;  ///< Attribute 6: Serial Number, has to be set prior
+                           ///< to OpENer's network initialization
+  CipShortString product_name;  ///< Attribute 7: Product Name
+  CipUsint state;  ///< Attribute 8: state, this member could control the Module
+                   ///< Status LED blink pattern
 } CipIdentityObject;
 
 /* global public variables */
@@ -94,4 +93,4 @@ void CipIdentityClearStatusFlags(const CipWord status_flags);
 void CipIdentitySetExtendedDeviceStatus(
     CipIdentityExtendedStatus extended_status);
 
-#endif /* CIP_CIPIDENTITY_H_ */
+#endif  // CIP_CIPIDENTITY_H_

+ 32 - 37
source/src/cip/cipioconnection.c

@@ -63,13 +63,13 @@ EipStatus HandleReceivedIoConnectionData(CipConnectionObject* connection_object,
                                          EipUint16 data_length);
 
 /**** Global variables ****/
-EipUint8* g_config_data_buffer = NULL; /**< buffers for the config data coming
-                                          with a forward open request. */
-unsigned int g_config_data_length =
-    0; /**< length of g_config_data_buffer. Initialized with 0 */
+/// buffers for the config data coming with a forward open request.
+EipUint8* g_config_data_buffer = NULL;
+/// length of g_config_data_buffer. Initialized with 0
+unsigned int g_config_data_length = 0;
 
-EipUint32 g_run_idle_state =
-    0; /**< buffer for holding the run idle information. */
+/// buffer for holding the run idle information.
+EipUint32 g_run_idle_state = 0;
 
 /**** Local variables, set by API, with build-time defaults ****/
 #ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
@@ -344,8 +344,8 @@ CipError EstablishIoConnection(
     }
   }
 
-  if (NULL != g_config_data_buffer) { /* config data has been sent with this
-                                         forward open request */
+  if (NULL != g_config_data_buffer) {
+    // config data has been sent with this forward open request
     *extended_error = HandleConfigData(io_connection_object);
     if (kConnectionManagerExtendedStatusCodeSuccess != *extended_error) {
       return kCipErrorConnectionFailure;
@@ -493,19 +493,18 @@ EipStatus OpenProducingMulticastConnection(
 
   sock_addr_info->type_id = kCipItemIdSocketAddressInfoTargetToOriginator;
 
-  if (NULL ==
-      existing_connection_object) { /* we are the first connection producing for
-                                       the given Input Assembly */
+  if (NULL == existing_connection_object) {
+    // we are the first connection producing for the given Input Assembly
     return OpenMulticastConnection(kUdpCommuncationDirectionProducing,
                                    connection_object,
                                    common_packet_format_data);
   } else {
-    /* we need to inform our originator on the correct connection id */
+    // we need to inform our originator on the correct connection id
     connection_object->cip_produced_connection_id =
         existing_connection_object->cip_produced_connection_id;
   }
 
-  /* we have a connection reuse the data and the socket */
+  // we have a connection reuse the data and the socket
 
   if (kConnectionObjectInstanceTypeIOExclusiveOwner ==
       connection_object->instance_type) {
@@ -819,25 +818,25 @@ void HandleIoConnectionTimeOut(CipConnectionObject* connection_object) {
 }
 
 EipStatus SendConnectedData(CipConnectionObject* connection_object) {
-  /* TODO think of adding an own send buffer to each connection object in order
-   * to preset up the whole message on connection opening and just change the
-   * variable data items e.g., sequence number */
+  /* TODO(MartinMelikMerkumians) think of adding an own send buffer to each
+   * connection object in order to preset up the whole message on connection
+   * opening and just change the variable data items e.g., sequence number */
 
   CipCommonPacketFormatData* common_packet_format_data =
       &g_common_packet_format_data_item;
-  /* TODO think on adding a CPF data item to the S_CIP_ConnectionObject in order
-   * to remove the code here or even better allocate memory in the connection
-   * object for storing the message to send and just change the application
-   * data*/
+  /* TODO(MartinMelikMerkumians) think on adding a CPF data item to the
+   * S_CIP_ConnectionObject in order to remove the code here or even better
+   * allocate memory in the connection object for storing the message to send
+   * and just change the application data*/
 
   connection_object->eip_level_sequence_count_producing++;
 
   /* assembleCPFData */
   common_packet_format_data->item_count = 2;
   if (kConnectionObjectTransportClassTriggerTransportClass0 !=
-      ConnectionObjectGetTransportClassTriggerTransportClass(connection_object))
-  /* use Sequenced Address Items if not Connection Class 0 */
-  {
+      ConnectionObjectGetTransportClassTriggerTransportClass(
+          connection_object)) {
+    // use Sequenced Address Items if not Connection Class 0
     common_packet_format_data->address_item.type_id =
         kCipItemIdSequencedAddressItem;
     common_packet_format_data->address_item.length = 8;
@@ -857,9 +856,9 @@ EipStatus SendConnectedData(CipConnectionObject* connection_object) {
       (CipByteArray*)connection_object->producing_instance->attributes->data;
   common_packet_format_data->data_item.length = 0;
 
-  /* notify the application that data will be sent immediately after the call */
+  // notify the application that data will be sent immediately after the call
   if (BeforeAssemblyDataSend(connection_object->producing_instance)) {
-    /* the data has changed increase sequence counter */
+    // the data has changed increase sequence counter
     connection_object->sequence_count_producing++;
   }
 
@@ -977,9 +976,8 @@ CipError OpenCommunicationChannels(CipConnectionObject* connection_object) {
   /* open a connection "point to point" or "multicast" based on the
    * ConnectionParameter */
   if (originator_to_target_connection_type ==
-      kConnectionObjectConnectionTypeMulticast)
-  /* Multicast consuming */
-  {
+      kConnectionObjectConnectionTypeMulticast) {
+    // Multicast consuming
     if (OpenMulticastConnection(kUdpCommuncationDirectionConsuming,
                                 connection_object,
                                 common_packet_format_data) != kEipStatusError) {
@@ -987,9 +985,8 @@ CipError OpenCommunicationChannels(CipConnectionObject* connection_object) {
       return kCipErrorConnectionFailure;
     }
   } else if (originator_to_target_connection_type ==
-             kConnectionObjectConnectionTypePointToPoint)
-  /* Point to Point consuming */
-  {
+             kConnectionObjectConnectionTypePointToPoint) {
+    // Point to Point consuming
     if (OpenConsumingPointToPointConnection(
             connection_object, common_packet_format_data) == kEipStatusError) {
       OPENER_TRACE_ERR("error in PointToPoint consuming connection\n");
@@ -998,18 +995,16 @@ CipError OpenCommunicationChannels(CipConnectionObject* connection_object) {
   }
 
   if (target_to_originator_connection_type ==
-      kConnectionObjectConnectionTypeMulticast)
-  /* Multicast producing */
-  {
+      kConnectionObjectConnectionTypeMulticast) {
+    // Multicast producing
     if (OpenProducingMulticastConnection(
             connection_object, common_packet_format_data) == kEipStatusError) {
       OPENER_TRACE_ERR("error in OpenMulticast Connection\n");
       return kCipErrorConnectionFailure;
     }
   } else if (target_to_originator_connection_type ==
-             kConnectionObjectConnectionTypePointToPoint)
-  /* Point to Point producing */
-  {
+             kConnectionObjectConnectionTypePointToPoint) {
+    // Point to Point producing
     if (OpenProducingPointToPointConnection(
             connection_object, common_packet_format_data) != kCipErrorSuccess) {
       OPENER_TRACE_ERR("error in PointToPoint producing connection\n");

+ 34 - 39
source/src/cip/cipmessagerouter.c

@@ -115,19 +115,18 @@ void InitializeCipMessageRouterClass(CipClass* cip_class) {
 }
 
 EipStatus CipMessageRouterInit() {
-  CipClass* message_router =
-      CreateCipClass(kCipMessageRouterClassCode, /* class code */
-                     7,                          /* # of class attributes */
-                     7,                /* # highest class attribute number */
-                     2,                /* # of class services */
-                     0,                /* # of instance attributes */
-                     0,                /* # highest instance attribute number */
-                     1,                /* # of instance services */
-                     1,                /* # of instances */
-                     "message router", /* class name */
-                     1,                /* # class revision*/
-                     InitializeCipMessageRouterClass); /* # function pointer for
-                                                          initialization*/
+  CipClass* message_router = CreateCipClass(
+      kCipMessageRouterClassCode,        // class code
+      7,                                 // # of class attributes
+      7,                                 // # highest class attribute number
+      2,                                 // # of class services
+      0,                                 // # of instance attributes
+      0,                                 // # highest instance attribute number
+      1,                                 // # of instance services
+      1,                                 // # of instances
+      "message router",                  // class name
+      1,                                 // # class revision
+      InitializeCipMessageRouterClass);  // function pointer for initialization
   if (NULL == message_router) {
     return kEipStatusError;
   }
@@ -136,7 +135,7 @@ EipStatus CipMessageRouterInit() {
                 &GetAttributeSingle,
                 "GetAttributeSingle");
 
-  /* reserved for future use -> set to zero */
+  // reserved for future use -> set to zero
   return kEipStatusOk;
 }
 
@@ -151,11 +150,11 @@ CipMessageRouterObject* GetRegisteredObject(EipUint32 class_id) {
   CipMessageRouterObject* object =
       g_first_object; /* get pointer to head of class registration list */
 
-  while (NULL != object) /* for each entry in list*/
-  {
+  while (NULL != object) {
+    // for each entry in list
     OPENER_ASSERT(NULL != object->cip_class);
     if (object->cip_class->class_code == class_id) {
-      return object; /* return registration node if it matches class ID*/
+      return object;  // return registration node if it matches class ID
     }
     object = object->next;
   }
@@ -176,18 +175,17 @@ CipClass* GetCipClass(const CipUdint class_code) {
 CipInstance* GetCipInstance(const CipClass* RESTRICT const cip_class,
                             const CipInstanceNum instance_number) {
   if (instance_number == 0) {
-    return (CipInstance*)cip_class; /* if the instance number is zero, return
-                                       the class object itself*/
+    return (CipInstance*)cip_class;  // if the instance number is zero, return
+                                     // the class object itself
   }
-  /* pointer to linked list of instances from the class object*/
+  // pointer to linked list of instances from the class object
   for (CipInstance* instance = cip_class->instances; instance;
-       instance              = instance->next) /* follow the list*/
-  {
+       instance              = instance->next) {
+    // follow the list
     if (instance->instance_number == instance_number) {
-      return instance; /* if the number matches, return the instance*/
+      return instance;  // if the number matches, return the instance
     }
   }
-
   return NULL;
 }
 
@@ -195,13 +193,12 @@ EipStatus RegisterCipClass(CipClass* cip_class) {
   CipMessageRouterObject** message_router_object = &g_first_object;
 
   while (*message_router_object) {
-    message_router_object =
-        &(*message_router_object)->next; /* follow the list until p points to an
-                                            empty link (list end)*/
+    // follow the list until p points to an empty link (list end)
+    message_router_object = &(*message_router_object)->next;
   }
-  *message_router_object = (CipMessageRouterObject*)CipCalloc(
-      1, sizeof(CipMessageRouterObject)); /* create a new node at the end of the
-                                             list*/
+  // create a new node at the end of the list
+  *message_router_object =
+      (CipMessageRouterObject*)CipCalloc(1, sizeof(CipMessageRouterObject));
   if (*message_router_object == 0) {
     return kEipStatusError; /* check for memory error*/
   }
@@ -241,11 +238,9 @@ EipStatus NotifyMessageRouter(EipUint8* data,
           "NotifyMessageRouter: sending CIP_ERROR_OBJECT_DOES_NOT_EXIST reply, "
           "class id 0x%x is not registered\n",
           (unsigned)g_message_router_request.request_path.class_id);
-      message_router_response->general_status =
-          kCipErrorPathDestinationUnknown; /*according to the test tool this
-                                              should be the correct error flag
-                                              instead of
-                                              CIP_ERROR_OBJECT_DOES_NOT_EXIST;*/
+      // according to the test tool this should be the correct error flag
+      // instead of CIP_ERROR_OBJECT_DOES_NOT_EXIST;
+      message_router_response->general_status = kCipErrorPathDestinationUnknown;
       message_router_response->size_of_additional_status = 0;
       message_router_response->reserved                  = 0;
       message_router_response->reply_service =
@@ -325,15 +320,15 @@ void DeleteAllClasses(void) {
     while (NULL != instance) {
       instance_to_delete = instance;
       instance           = instance->next;
-      if (message_router_object_to_delete->cip_class
-              ->number_of_attributes) /* if the class has instance attributes */
-      { /* then free storage for the attribute array */
+      if (message_router_object_to_delete->cip_class->number_of_attributes) {
+        // if the class has instance attributes free storage for the attribute
+        // array
         CipFree(instance_to_delete->attributes);
       }
       CipFree(instance_to_delete);
     }
 
-    /* free meta class data*/
+    // free meta class data
     CipClass* meta_class =
         message_router_object_to_delete->cip_class->class_instance.cip_class;
     CipFree(meta_class->class_name);

+ 12 - 13
source/src/cip/cipqos.c

@@ -121,23 +121,22 @@ EipStatus CipQoSInit() {
 
   if ((qos_class =
            CreateCipClass(kCipQoSClassCode,
-                          7, /* # class attributes */
-                          7, /* # highest class attribute number */
-                          2, /* # class services */
-                          8, /* # instance attributes */
-                          8, /* # highest instance attribute number */
-                          2, /* # instance services */
-                          1, /* # instances */
+                          7,  // # class attributes
+                          7,  // # highest class attribute number
+                          2,  // # class services
+                          8,  // # instance attributes
+                          8,  // # highest instance attribute number
+                          2,  // # instance services
+                          1,  // # instances
                           "Quality of Service",
-                          1,   /* # class revision */
-                          NULL /* # function pointer for initialization */
-                          )) == 0) {
+                          1,      // # class revision
+                          NULL))  // # function pointer for initialization
+      == 0) {
     return kEipStatusError;
   }
 
-  CipInstance* instance = GetCipInstance(
-      qos_class,
-      1); /* bind attributes to the instance #1 that was created above */
+  // bind attributes to the instance #1 that was created above
+  CipInstance* instance = GetCipInstance(qos_class, 1);
 
   InsertAttribute(instance,
                   1,

+ 20 - 20
source/src/cip/cipqos.h

@@ -23,33 +23,33 @@ static const CipUint kCipQoSClassCode = 0x48U;
 
 /** This type represents the group of DSCP values of the QoS object. */
 typedef struct cip_qos_dscp_values {
-  CipUsint event;   /**< Attr. #2: DSCP value for event messages */
-  CipUsint general; /**< Attr. #3: DSCP value for general messages */
-  CipUsint urgent;  /**< Attr. #4: DSCP value for CIP transport class 0/1 Urgent
-                       priority messages */
-  CipUsint scheduled; /**< Attr. #5: DSCP value for CIP transport class 0/1
-                         Scheduled priority messages */
-  CipUsint high;      /**< Attr. #6: DSCP value for CIP transport class 0/1 High
-                         priority messages */
-  CipUsint low;       /**< Attr. #7: DSCP value for CIP transport class 0/1 low
-                         priority messages */
-  CipUsint explicit_msg; /**< Attr. #8: DSCP value for CIP explicit messages
-                            (transport class 2/3 and UCMM) and all other
-                            EtherNet/IP encapsulation messages */
+  CipUsint event;    ///< Attr. #2: DSCP value for event messages
+  CipUsint general;  ///< Attr. #3: DSCP value for general messages
+  CipUsint urgent;  ///< Attr. #4: DSCP value for CIP transport class 0/1 Urgent
+                    ///< priority messages
+  CipUsint scheduled;  ///< Attr. #5: DSCP value for CIP transport class 0/1
+                       ///< Scheduled priority messages
+  CipUsint high;  ///< Attr. #6: DSCP value for CIP transport class 0/1 High
+                  ///< priority messages
+  CipUsint low;   ///< Attr. #7: DSCP value for CIP transport class 0/1 low
+                  ///< priority messages
+  CipUsint explicit_msg;  ///< Attr. #8: DSCP value for CIP explicit messages
+                          ///< (transport class 2/3 and UCMM) and all other
+                          ///< EtherNet/IP encapsulation messages
 } CipQosDscpValues;
 
 /** This type represents the QoS object */
 typedef struct {
-  CipUsint q_frames_enable; /**< Attr. #1: Enables or disable sending 802.1Q
-                               frames on CIP and IEEE 1588 messages */
-  CipQosDscpValues dscp; /**< Attributes #2 ... #8 of DSCP values - beware! must
-                            not be the used set */
+  CipUsint q_frames_enable;  ///< Attr. #1: Enables or disable sending 802.1Q
+                             ///< frames on CIP and IEEE 1588 messages
+  CipQosDscpValues dscp;     ///< Attributes #2 ... #8 of DSCP values - beware!
+                             ///< must not be the used set
 } CipQosObject;
 
-/* public data */
+// public data
 extern CipQosObject g_qos;
 
-/* public functions */
+// public functions
 /** @brief Provide the matching DSCP value for a given connection object
  * priority level
  */
@@ -67,4 +67,4 @@ void CipQosUpdateUsedSetQosValues(void);
  */
 void CipQosResetAttributesToDefaultValues(void);
 
-#endif /* CIP_CIPQOS_H_*/
+#endif  // CIP_CIPQOS_H_

+ 1 - 1
source/src/cip/cipstring.h

@@ -189,4 +189,4 @@ int GetCstrFromCipShortString(CipShortString* const string,
                               char* buf,
                               size_t len);
 
-#endif /* of CIP_CIPSTRING_H_ */
+#endif  // CIP_CIPSTRING_H_

+ 2 - 1
source/src/cip/cipstringi.c

@@ -288,7 +288,8 @@ bool CipStringICompare(const CipStringI* const stringI_1,
         default:
           OPENER_TRACE_ERR("CIP File: No valid String type received!\n");
       }
-      /*compare strings*/  // TODO: compare works only for same data types
+      // compare strings
+      // TODO(MartinMelikMerkumians): compare works only for same data types
       if (len_1 == len_2 && string_1_data != NULL && string_2_data != NULL) {
         if (0 == memcmp(string_1_data, string_2_data, len_1)) {
           return true;

+ 5 - 0
source/src/cip/cipstringi.h

@@ -4,6 +4,9 @@
  *
  ******************************************************************************/
 
+#ifndef CIP_CIPSTRINGI_H_
+#define CIP_CIPSTRINGI_H_
+
 #include "cip/ciptypes.h"
 
 void CipStringIDelete(CipStringI* const string);
@@ -17,3 +20,5 @@ void CipStringIDecodeFromMessage(
 
 bool CipStringICompare(const CipStringI* const stringI_1,
                        const CipStringI* const stringI_2);
+
+#endif  // CIP_CIPSTRINGI_H_

+ 35 - 35
source/src/cip/ciptcpipinterface.h

@@ -32,58 +32,58 @@ static const CipDword kTcpipStatusAcdFault = 0x80U;
 
 /* Declare constants for config_control attribute (#3) */
 static const CipDword kTcpipCfgCtrlStaticIp =
-    0x00U; /**< IP configuration method is manual IP assignment */
+    0x00U;  ///< IP configuration method is manual IP assignment
 static const CipDword kTcpipCfgCtrlBootp =
-    0x01U; /**< IP configuration method is BOOTP */
+    0x01U;  ///< IP configuration method is BOOTP
 static const CipDword kTcpipCfgCtrlDhcp =
-    0x02U; /**< IP configuration method is DHCP */
+    0x02U;  ///< IP configuration method is DHCP
 static const CipDword kTcpipCfgCtrlMethodMask =
-    0x0FU; /**< bit mask for the method field */
+    0x0FU;  ///< bit mask for the method field
 static const CipDword kTcpipCfgCtrlDnsEnable =
-    0x10U; /**< enables DNS resolution on originator devices */
+    0x10U;  ///< enables DNS resolution on originator devices
 
 /** @brief Multicast Configuration struct, called Mcast config
  *
  */
 typedef struct multicast_address_configuration {
-  CipUsint alloc_control; /**< 0 for default multicast address generation
-                             algorithm; 1 for multicast addresses according to
-                             Num MCast and MCast Start Addr */
-  CipUsint reserved_shall_be_zero;                 /**< shall be zero */
-  CipUint number_of_allocated_multicast_addresses; /**< Number of IP multicast
-                                                      addresses allocated */
+  CipUsint alloc_control;  ///< 0 for default multicast address generation
+                           ///< algorithm; 1 for multicast addresses according
+                           ///< to Num MCast and MCast Start Addr
+  CipUsint reserved_shall_be_zero;                  ///< shall be zero
+  CipUint number_of_allocated_multicast_addresses;  ///< Number of IP multicast
+                                                    ///< addresses allocated
   CipUdint
-      starting_multicast_address; /**< Starting multicast address from which Num
-                                     Mcast addresses are allocated */
+      starting_multicast_address;  ///< Starting multicast address from which
+                                   ///< Num Mcast addresses are allocated Mcast
+                                   ///< addresses are allocated
 } MulticastAddressConfiguration;
 
-/** @brief Declaration of the TCP/IP object's structure type
- */
+/// @brief Declaration of the TCP/IP object's structure type
 typedef struct {
-  CipDword status;               /**< attribute #1  TCP status */
-  CipDword config_capability;    /**< attribute #2 bitmap of capability flags */
-  CipDword config_control;       /**< attribute #3 bitmap: control the interface
-                                    configuration method: static / BOOTP / DHCP */
-  CipEpath physical_link_object; /**< attribute #4 references the Ethernet Link
-                                    object for this  interface */
+  CipDword status;             ///< attribute #1  TCP status
+  CipDword config_capability;  ///< attribute #2 bitmap of capability flags
+  CipDword config_control;     ///< attribute #3 bitmap: control the interface
+                               ///< configuration method: static / BOOTP / DHCP
+  CipEpath physical_link_object;  ///< attribute #4 references the Ethernet Link
+                                  ///< object for this  interface
   CipTcpIpInterfaceConfiguration
-      interface_configuration; /**< attribute #5 IP, network mask, gateway, name
-                                  server 1 & 2, domain name*/
-  CipString hostname;          /**< #6 host name*/
-  CipUsint mcast_ttl_value;    /**< #8 the time to live value to be used for
-                                  multi-cast connections */
-
-  /** #9 The multicast configuration for this device */
-  MulticastAddressConfiguration mcast_config;
-  CipBool select_acd; /**< attribute #10 - Is ACD enabled? */
+      interface_configuration;  ///< attribute #5 IP, network mask, gateway,
+                                ///< name server 1 & 2, domain name
+  CipString hostname;           ///< #6 host name
+  CipUsint mcast_ttl_value;     ///< #8 the time to live value to be used for
+                                ///< multi-cast connections
 
-  /** #13 Number of seconds of inactivity before TCP connection is closed */
-  CipUint encapsulation_inactivity_timeout;
+  MulticastAddressConfiguration
+      mcast_config;    ///< #9 The multicast configuration for this device
+  CipBool select_acd;  ///< attribute #10 - Is ACD enabled?
+  CipUint
+      encapsulation_inactivity_timeout;  /// #13 Number of seconds of inactivity
+                                         /// before TCP connection is closed
 } CipTcpIpObject;
 
 /* global public variables */
-extern CipTcpIpObject
-    g_tcpip; /**< declaration of TCP/IP object instance 1 data */
+/// declaration of TCP/IP object instance 1 data
+extern CipTcpIpObject g_tcpip;
 
 /* public functions */
 /** @brief Initializing the data structures of the TCP/IP interface object
@@ -111,4 +111,4 @@ void CipTcpIpCalculateMulticastIp(CipTcpIpObject* const tcpip);
  */
 EipUint16 GetEncapsulationInactivityTimeout(CipInstance* instance);
 
-#endif /* CIP_CIPTCPIPINTERFACE_H_ */
+#endif  // CIP_CIPTCPIPINTERFACE_H_