소스 검색

Shortens macro names for message constants

The additional code changes are due to automatic code formatting via
uncrustify
CapXilinx 9 년 전
부모
커밋
84407d10e2
3개의 변경된 파일491개의 추가작업 그리고 323개의 파일을 삭제
  1. 127 99
      source/src/cip/cipcommon.c
  2. 212 164
      source/src/cip/cipepath.c
  3. 152 60
      source/src/cip/cipepath.h

+ 127 - 99
source/src/cip/cipcommon.c

@@ -1,6 +1,6 @@
 /*******************************************************************************
  * Copyright (c) 2009, Rockwell Automation, Inc.
- * All rights reserved. 
+ * All rights reserved.
  *
  ******************************************************************************/
 #include <string.h>
@@ -29,7 +29,7 @@ EipUint8 g_message_data_reply_buffer[OPENER_MESSAGE_DATA_REPLY_BUFFER]; /**< Rep
 const EipUint16 kCipUintZero = 0; /**< Zero value for returning the UINT standard value */
 
 /* private functions*/
-int EncodeEPath(CipEpath *epath, EipUint8 **message);
+int EncodeEPath(CipEpath *epath, EipUint8 * *message);
 
 void CipStackInit(const EipUint16 unique_connection_id) {
   EncapsulationInit();
@@ -70,8 +70,9 @@ EipStatus NotifyClass(const CipClass *restrict const cip_class,
                       CipMessageRouterResponse *const message_router_response) {
 
   /* find the instance: if instNr==0, the class is addressed, else find the instance */
-  EipUint16 instance_number = message_router_request->request_path.instance_number; /* get the instance number */
-  CipInstance * instance = GetCipInstance(cip_class, instance_number); /* look up the instance (note that if inst==0 this will be the class itself) */
+  EipUint16 instance_number =
+    message_router_request->request_path.instance_number;                           /* get the instance number */
+  CipInstance *instance = GetCipInstance(cip_class, instance_number);  /* look up the instance (note that if inst==0 this will be the class itself) */
   if (instance) /* if instance is found */
   {
     OPENER_TRACE_INFO("notify: found instance %d%s\n", instance_number,
@@ -107,13 +108,14 @@ EipStatus NotifyClass(const CipClass *restrict const cip_class,
   message_router_response->size_of_additional_status = 0; /* fill in the rest of the reply with not much of anything*/
   message_router_response->data_length = 0;
   message_router_response->reply_service = (0x80
-      | message_router_request->service); /* except the reply code is an echo of the command + the reply flag */
+                                            | message_router_request->service); /* except the reply code is an echo of the command + the reply flag */
 
   return kEipStatusOkSend;
 }
 
-CipInstance *AddCipInstances(CipClass *restrict const cip_class, const int number_of_instances) {
-  CipInstance **next_instance = NULL;
+CipInstance *AddCipInstances(CipClass *restrict const cip_class,
+                             const int number_of_instances) {
+  CipInstance * *next_instance = NULL;
   EipUint32 instance_number = 1; /* the first instance is number 1 */
 
   OPENER_TRACE_INFO("adding %d instances to class %s\n", number_of_instances,
@@ -127,7 +129,7 @@ CipInstance *AddCipInstances(CipClass *restrict const cip_class, const int numbe
   }
 
   CipInstance *current_instance = current_instance = (CipInstance *) CipCalloc(
-        number_of_instances, sizeof(CipInstance)); /* allocate a block of memory for all created instances*/
+                                    number_of_instances, sizeof(CipInstance) ); /* allocate a block of memory for all created instances*/
   CipInstance *first_instance = current_instance; /* allocate a block of memory for all created instances*/
 
   OPENER_ASSERT(NULL != current_instance);
@@ -144,8 +146,8 @@ CipInstance *AddCipInstances(CipClass *restrict const cip_class, const int numbe
 
     if (cip_class->number_of_attributes) /* if the class calls for instance attributes */
     { /* then allocate storage for the attribute array */
-      current_instance->attributes = (CipAttributeStruct*) CipCalloc(
-          cip_class->number_of_attributes, sizeof(CipAttributeStruct));
+      current_instance->attributes = (CipAttributeStruct *) CipCalloc(
+        cip_class->number_of_attributes, sizeof(CipAttributeStruct) );
     }
 
     next_instance = &current_instance->next; /* update pp to point to the next link of the current node */
@@ -156,7 +158,8 @@ CipInstance *AddCipInstances(CipClass *restrict const cip_class, const int numbe
   return first_instance;
 }
 
-CipInstance *AddCIPInstance(CipClass *restrict const class, const EipUint32 instance_id) {
+CipInstance *AddCIPInstance(CipClass *restrict const class,
+                            const EipUint32 instance_id) {
   CipInstance *instance = GetCipInstance(class, instance_id);
 
   if (0 == instance) { /*we have no instance with given id*/
@@ -166,7 +169,8 @@ CipInstance *AddCIPInstance(CipClass *restrict const class, const EipUint32 inst
   return instance;
 }
 
-CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_attributes,
+CipClass *CreateCipClass(const EipUint32 class_id,
+                         const int number_of_class_attributes,
                          const EipUint32 get_all_class_attributes_mask,
                          const int number_of_class_services,
                          const int number_of_instance_attributes,
@@ -175,20 +179,20 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
                          const int number_of_instances, char *name,
                          const EipUint16 revision) {
 
-  OPENER_TRACE_INFO("creating class '%s' with id: 0x%"PRIX32"\n", name,
+  OPENER_TRACE_INFO("creating class '%s' with id: 0x%" PRIX32 "\n", name,
                     class_id);
 
-  OPENER_ASSERT(NULL == GetCipClass(class_id)); /* check if an class with the ClassID already exists */
+  OPENER_ASSERT( NULL == GetCipClass(class_id) ); /* check if an class with the ClassID already exists */
   /* should never try to redefine a class*/
 
   /* a metaClass is a class that holds the class attributes and services
-   CIP can talk to an instance, therefore an instance has a pointer to its class
-   CIP can talk to a class, therefore a class struct is a subclass of the instance struct,
-   and contains a pointer to a metaclass
-   CIP never explicitly addresses a metaclass*/
+     CIP can talk to an instance, therefore an instance has a pointer to its class
+     CIP can talk to a class, therefore a class struct is a subclass of the instance struct,
+     and contains a pointer to a metaclass
+     CIP never explicitly addresses a metaclass*/
 
-  CipClass *const class = (CipClass*) CipCalloc(1, sizeof(CipClass)); /* create the class object*/
-  CipClass *const meta_class = (CipClass*) CipCalloc(1, sizeof(CipClass)); /* create the metaclass object*/
+  CipClass *const class = (CipClass *) CipCalloc( 1, sizeof(CipClass) ); /* create the class object*/
+  CipClass *const meta_class = (CipClass *) CipCalloc( 1, sizeof(CipClass) ); /* create the metaclass object*/
 
   /* initialize the class-specific fields of the Class struct*/
   class->class_id = class_id; /* the class remembers the class ID */
@@ -198,7 +202,8 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
   class->number_of_attributes = number_of_instance_attributes; /* the class remembers the number of instances of that class */
   class->get_attribute_all_mask = get_all_instance_attributes_mask; /* indicate which attributes are included in instance getAttributeAll */
   class->number_of_services = number_of_instance_services
-      + ((0 == get_all_instance_attributes_mask) ? 1 : 2); /* the class manages the behavior of the instances */
+                              + ( (0 ==
+                                   get_all_instance_attributes_mask) ? 1 : 2 ); /* the class manages the behavior of the instances */
   class->services = 0;
   class->class_name = name; /* initialize the class-specific fields of the metaClass struct */
   meta_class->class_id = 0xffffffff; /* set metaclass ID (this should never be referenced) */
@@ -207,7 +212,8 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
   meta_class->number_of_attributes = number_of_class_attributes + 7; /* the metaclass remembers how many class attributes exist*/
   meta_class->get_attribute_all_mask = get_all_class_attributes_mask; /* indicate which attributes are included in class getAttributeAll*/
   meta_class->number_of_services = number_of_class_services
-      + ((0 == get_all_class_attributes_mask) ? 1 : 2); /* the metaclass manages the behavior of the class itself */
+                                   + ( (0 ==
+                                        get_all_class_attributes_mask) ? 1 : 2 ); /* the metaclass manages the behavior of the class itself */
   class->services = 0;
   meta_class->class_name = (char *) CipCalloc(1, strlen(name) + 6); /* fabricate the name "meta<classname>"*/
   strcpy(meta_class->class_name, "meta-");
@@ -227,40 +233,41 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
   /* further initialization of the class object*/
 
   class->class_instance.attributes = (CipAttributeStruct *) CipCalloc(
-      meta_class->number_of_attributes, sizeof(CipAttributeStruct));
+    meta_class->number_of_attributes, sizeof(CipAttributeStruct) );
   /* TODO -- check that we didn't run out of memory?*/
 
   meta_class->services = (CipServiceStruct *) CipCalloc(
-      meta_class->number_of_services, sizeof(CipServiceStruct));
+    meta_class->number_of_services, sizeof(CipServiceStruct) );
 
-  class->services = (CipServiceStruct *) CipCalloc(class->number_of_services,
-                                                   sizeof(CipServiceStruct));
+  class->services = (CipServiceStruct *) CipCalloc( class->number_of_services,
+                                                    sizeof(CipServiceStruct) );
 
   if (number_of_instances > 0) {
     AddCipInstances(class, number_of_instances); /*TODO handle return value and clean up if necessary*/
   }
 
-  if ((RegisterCipClass(class)) == kEipStatusError) { /* no memory to register class in Message Router */
+  if ( ( RegisterCipClass(class) ) == kEipStatusError ) { /* no memory to register class in Message Router */
     return 0; /*TODO handle return value and clean up if necessary*/
   }
 
   /* create the standard class attributes*/
-  InsertAttribute((CipInstance *) class, 1, kCipUint, (void *) &class->revision,
-                  kGetableSingleAndAll); /* revision */
-  InsertAttribute((CipInstance *) class, 2, kCipUint,
-                  (void *) &class->number_of_instances, kGetableSingleAndAll); /*  largest instance number */
-  InsertAttribute((CipInstance *) class, 3, kCipUint,
-                  (void *) &class->number_of_instances, kGetableSingleAndAll); /* number of instances currently existing*/
-  InsertAttribute((CipInstance *) class, 4, kCipUint, (void *) &kCipUintZero,
-                  kGetableAll); /* optional attribute list - default = 0 */
-  InsertAttribute((CipInstance *) class, 5, kCipUint, (void *) &kCipUintZero,
-                  kGetableAll); /* optional service list - default = 0 */
-  InsertAttribute((CipInstance *) class, 6, kCipUint,
-                  (void *) &meta_class->highest_attribute_number,
-                  kGetableSingleAndAll); /* max class attribute number*/
-  InsertAttribute((CipInstance *) class, 7, kCipUint,
-                  (void *) &class->highest_attribute_number,
-                  kGetableSingleAndAll); /* max instance attribute number*/
+  InsertAttribute( (CipInstance *) class, 1, kCipUint,
+                   (void *) &class->revision,
+                   kGetableSingleAndAll ); /* revision */
+  InsertAttribute( (CipInstance *) class, 2, kCipUint,
+                   (void *) &class->number_of_instances, kGetableSingleAndAll ); /*  largest instance number */
+  InsertAttribute( (CipInstance *) class, 3, kCipUint,
+                   (void *) &class->number_of_instances, kGetableSingleAndAll ); /* number of instances currently existing*/
+  InsertAttribute( (CipInstance *) class, 4, kCipUint, (void *) &kCipUintZero,
+                   kGetableAll ); /* optional attribute list - default = 0 */
+  InsertAttribute( (CipInstance *) class, 5, kCipUint, (void *) &kCipUintZero,
+                   kGetableAll ); /* optional service list - default = 0 */
+  InsertAttribute( (CipInstance *) class, 6, kCipUint,
+                   (void *) &meta_class->highest_attribute_number,
+                   kGetableSingleAndAll ); /* max class attribute number*/
+  InsertAttribute( (CipInstance *) class, 7, kCipUint,
+                   (void *) &class->highest_attribute_number,
+                   kGetableSingleAndAll ); /* max instance attribute number*/
 
   /* create the standard class services*/
   if (0 != get_all_class_attributes_mask) { /*only if the mask has values add the get_attribute_all service */
@@ -280,8 +287,10 @@ CipClass *CreateCipClass(const EipUint32 class_id, const int number_of_class_att
   return class;
 }
 
-void InsertAttribute(CipInstance *const instance, const EipUint16 attribute_number,
-                     const EipUint8 cip_type, void *const data, const EipByte cip_flags) {
+void InsertAttribute(CipInstance *const instance,
+                     const EipUint16 attribute_number,
+                     const EipUint8 cip_type, void *const data,
+                     const EipByte cip_flags) {
 
   CipAttributeStruct *attribute = instance->attributes;
   OPENER_ASSERT(NULL != attribute);
@@ -303,22 +312,24 @@ void InsertAttribute(CipInstance *const instance, const EipUint16 attribute_numb
   }
 
   OPENER_TRACE_ERR(
-      "Tried to insert to many attributes into class: %"PRIu32", instance %"PRIu32"\n",
-      instance->cip_class->class_instance.instance_number,
-      instance->instance_number);
+    "Tried to insert to many attributes into class: %" PRIu32 ", instance %" PRIu32 "\n",
+    instance->cip_class->class_instance.instance_number,
+    instance->instance_number);
   OPENER_ASSERT(0);
   /* trying to insert too many attributes*/
 }
 
 void InsertService(const CipClass *const class, const EipUint8 service_number,
-                   const CipServiceFunction service_function, char *const service_name) {
+                   const CipServiceFunction service_function,
+                   char *const service_name) {
 
   CipServiceStruct *service = class->services; /* get a pointer to the service array*/
   OPENER_ASSERT(service != 0);
   /* adding a service to a class that was not declared to have services is not allowed*/
   for (int i = 0; i < class->number_of_services; i++) /* Iterate over all service slots attached to the class */
   {
-    if (service->service_number == service_number || service->service_function == NULL) /* found undefined service slot*/
+    if (service->service_number == service_number ||
+        service->service_function == NULL)                                              /* found undefined service slot*/
     {
       service->service_number = service_number; /* fill in service number*/
       service->service_function = service_function; /* fill in function address*/
@@ -336,10 +347,12 @@ CipAttributeStruct *GetCipAttribute(const CipInstance *const instance,
 
   CipAttributeStruct *attribute = instance->attributes; /* init pointer to array of attributes*/
   for (int i = 0; i < instance->cip_class->number_of_attributes; i++) {
-    if (attribute_number == attribute->attribute_number)
+    if (attribute_number == attribute->attribute_number) {
       return attribute;
-    else
+    }
+    else{
       ++attribute;
+    }
   }
 
   OPENER_TRACE_WARN("attribute %d not defined\n", attribute_number);
@@ -350,17 +363,18 @@ CipAttributeStruct *GetCipAttribute(const CipInstance *const instance,
 /* TODO this needs to check for buffer overflow*/
 EipStatus GetAttributeSingle(CipInstance *restrict const instance,
                              CipMessageRouterRequest *const message_router_request,
-                             CipMessageRouterResponse *const message_router_response) {
+                             CipMessageRouterResponse *const message_router_response)
+{
   /* Mask for filtering get-ability */
   EipByte get_mask = kNotSetOrGetable;
 
   CipAttributeStruct *attribute = GetCipAttribute(
-      instance, message_router_request->request_path.attribute_number);
+    instance, message_router_request->request_path.attribute_number);
   EipByte *message = message_router_response->data;
 
   message_router_response->data_length = 0;
   message_router_response->reply_service = (0x80
-      | message_router_request->service);
+                                            | message_router_request->service);
   message_router_response->general_status = kCipErrorAttributeNotSupported;
   message_router_response->size_of_additional_status = 0;
 
@@ -372,7 +386,7 @@ EipStatus GetAttributeSingle(CipInstance *restrict const instance,
     get_mask = kGetableSingle;
   }
 
-  if ((attribute != 0) && (attribute->data != 0)) {
+  if ( (attribute != 0) && (attribute->data != 0) ) {
     if (attribute->attribute_flags & get_mask) {
       OPENER_TRACE_INFO("getAttribute %d\n",
                         message_router_request->request_path.attribute_number); /* create a reply message containing the data*/
@@ -399,7 +413,8 @@ EipStatus GetAttributeSingle(CipInstance *restrict const instance,
   return kEipStatusOkSend;
 }
 
-int EncodeData(const EipUint8 cip_type, const void *const cip_data, EipUint8 **cip_message) {
+int EncodeData(const EipUint8 cip_type, const void *const cip_data,
+               EipUint8 * *cip_message) {
   int counter = 0;
 
   switch (cip_type)
@@ -479,7 +494,7 @@ int EncodeData(const EipUint8 cip_type, const void *const cip_data, EipUint8 **c
       break;
 
     case (kCipEpath):
-      counter = EncodeEPath((CipEpath *) cip_data, cip_message);
+      counter = EncodeEPath( (CipEpath *) cip_data, cip_message );
       break;
 
     case (kCipEngUnit):
@@ -498,22 +513,26 @@ int EncodeData(const EipUint8 cip_type, const void *const cip_data, EipUint8 **c
 
     case (kCipUdintUdintUdintUdintUdintString): {
       /* TCP/IP attribute 5 */
-      CipTcpIpNetworkInterfaceConfiguration *tcp_ip_network_interface_configuration =
-          (CipTcpIpNetworkInterfaceConfiguration *) cip_data;
+      CipTcpIpNetworkInterfaceConfiguration *
+        tcp_ip_network_interface_configuration =
+        (CipTcpIpNetworkInterfaceConfiguration *) cip_data;
       counter += AddDintToMessage(
-          ntohl(tcp_ip_network_interface_configuration->ip_address), cip_message);
+        ntohl(tcp_ip_network_interface_configuration->ip_address), cip_message);
       counter += AddDintToMessage(
-          ntohl(tcp_ip_network_interface_configuration->network_mask), cip_message);
-      counter += AddDintToMessage(ntohl(tcp_ip_network_interface_configuration->gateway),
-                       cip_message);
+        ntohl(tcp_ip_network_interface_configuration->network_mask),
+        cip_message);
+      counter +=
+        AddDintToMessage(ntohl(tcp_ip_network_interface_configuration->gateway),
+                         cip_message);
       counter += AddDintToMessage(
-          ntohl(tcp_ip_network_interface_configuration->name_server), cip_message);
+        ntohl(tcp_ip_network_interface_configuration->name_server),
+        cip_message);
       counter += AddDintToMessage(
-          ntohl(tcp_ip_network_interface_configuration->name_server_2),
-          cip_message);
+        ntohl(tcp_ip_network_interface_configuration->name_server_2),
+        cip_message);
       counter += EncodeData(
-          kCipString, &(tcp_ip_network_interface_configuration->domain_name),
-          cip_message);
+        kCipString, &(tcp_ip_network_interface_configuration->domain_name),
+        cip_message);
       break;
     }
 
@@ -534,7 +553,7 @@ int EncodeData(const EipUint8 cip_type, const void *const cip_data, EipUint8 **c
       *cip_message += cip_byte_array->length;
       counter = cip_byte_array->length;
     }
-      break;
+    break;
 
     case (kInternalUint6): /* TODO for port class attribute 9, hopefully we can find a better way to do this*/
     {
@@ -557,7 +576,8 @@ int EncodeData(const EipUint8 cip_type, const void *const cip_data, EipUint8 **c
   return counter;
 }
 
-int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const message) {
+int DecodeData(const EipUint8 cip_type, void *const data,
+               const EipUint8 * *const message) {
   int number_of_decoded_bytes = -1;
 
   switch (cip_type)
@@ -575,14 +595,14 @@ int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const
     case (kCipInt):
     case (kCipUint):
     case (kCipWord):
-      (*(EipUint16 *) (data)) = GetIntFromMessage(message);
+      ( *(EipUint16 *) (data) ) = GetIntFromMessage(message);
       number_of_decoded_bytes = 2;
       break;
 
     case (kCipDint):
     case (kCipUdint):
     case (kCipDword):
-      (*(EipUint32 *) (data)) = GetDintFromMessage(message);
+      ( *(EipUint32 *) (data) ) = GetDintFromMessage(message);
       number_of_decoded_bytes = 4;
       break;
 
@@ -590,10 +610,10 @@ int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const
     case (kCipLint):
     case (kCipUlint):
     case (kCipLword): {
-      (*(EipUint64 *) (data)) = GetLintFromMessage(message);
+      ( *(EipUint64 *) (data) ) = GetLintFromMessage(message);
       number_of_decoded_bytes = 8;
     }
-      break;
+    break;
 #endif
 
     case (kCipString): {
@@ -609,7 +629,7 @@ int DecodeData(const EipUint8 cip_type, void *const data, const EipUint8 **const
         number_of_decoded_bytes++;
       }
     }
-      break;
+    break;
     case (kCipShortString): {
       CipShortString *short_string = (CipShortString *) data;
 
@@ -649,30 +669,31 @@ EipStatus GetAttributeAll(CipInstance *instance,
       if (0 == instance->cip_class->number_of_attributes) {
         message_router_response->data_length = 0; /*there are no attributes to be sent back*/
         message_router_response->reply_service = (0x80
-            | message_router_request->service);
+                                                  | message_router_request->
+                                                  service);
         message_router_response->general_status = kCipErrorServiceNotSupported;
         message_router_response->size_of_additional_status = 0;
       } else {
         for (int j = 0; j < instance->cip_class->number_of_attributes; j++) /* for each instance attribute of this class */
         {
           int attrNum = attribute->attribute_number;
-          if (attrNum < 32
-              && (instance->cip_class->get_attribute_all_mask & 1 << attrNum)) /* only return attributes that are flagged as being part of GetAttributeALl */
-              {
+          if ( attrNum < 32
+               && (instance->cip_class->get_attribute_all_mask & 1 << attrNum) ) /* only return attributes that are flagged as being part of GetAttributeALl */
+          {
             message_router_request->request_path.attribute_number = attrNum;
-            if (kEipStatusOkSend
-                != service->service_function(instance, message_router_request,
-                                             message_router_response)) {
+            if ( kEipStatusOkSend
+                 != service->service_function(instance, message_router_request,
+                                              message_router_response) ) {
               message_router_response->data = reply;
               return kEipStatusError;
             }
             message_router_response->data += message_router_response
-                ->data_length;
+                                             ->data_length;
           }
           attribute++;
         }
         message_router_response->data_length = message_router_response->data
-            - reply;
+                                               - reply;
         message_router_response->data = reply;
       }
       return kEipStatusOkSend;
@@ -682,7 +703,7 @@ EipStatus GetAttributeAll(CipInstance *instance,
   return kEipStatusOk; /* Return kEipStatusOk if cannot find GET_ATTRIBUTE_SINGLE service*/
 }
 
-int EncodeEPath(CipEpath *epath, EipUint8 **message) {
+int EncodeEPath(CipEpath *epath, EipUint8 * *message) {
   unsigned int length = epath->path_size;
   AddIntToMessage(epath->path_size, message);
 
@@ -738,7 +759,7 @@ int EncodeEPath(CipEpath *epath, EipUint8 **message) {
   return 2 + epath->path_size * 2; /* path size is in 16 bit chunks according to the specification */
 }
 
-int DecodePaddedEPath(CipEpath *epath, const EipUint8 **message) {
+int DecodePaddedEPath(CipEpath *epath, const EipUint8 * *message) {
   unsigned int number_of_decoded_elements = 0;
   const EipUint8 *message_runner = *message;
 
@@ -750,44 +771,51 @@ int DecodePaddedEPath(CipEpath *epath, const EipUint8 **message) {
   epath->attribute_number = 0;
 
   for (number_of_decoded_elements = 0;
-      number_of_decoded_elements < epath->path_size;
-      number_of_decoded_elements++) {
-    if (kSegmentTypeReserved == ((*message_runner) & kSegmentTypeReserved)) {
+       number_of_decoded_elements < epath->path_size;
+       number_of_decoded_elements++) {
+    if ( kSegmentTypeReserved ==
+         ( (*message_runner) & kSegmentTypeReserved ) ) {
       /* If invalid/reserved segment type, segment type greater than 0xE0 */
       return kEipStatusError;
     }
 
     switch (*message_runner) {
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_CLASS_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_CLASS_ID +
+        LOGICAL_SEGMENT_FORMAT_EIGHT_BIT:
         epath->class_id = *(EipUint8 *) (message_runner + 1);
         message_runner += 2;
         break;
 
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_CLASS_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_CLASS_ID +
+        LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT:
         message_runner += 2;
-        epath->class_id = GetIntFromMessage(&(message_runner));
+        epath->class_id = GetIntFromMessage( &(message_runner) );
         number_of_decoded_elements++;
         break;
 
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_INSTANCE_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_INSTANCE_ID +
+        LOGICAL_SEGMENT_FORMAT_EIGHT_BIT:
         epath->instance_number = *(EipUint8 *) (message_runner + 1);
         message_runner += 2;
         break;
 
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_INSTANCE_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_INSTANCE_ID +
+        LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT:
         message_runner += 2;
-        epath->instance_number = GetIntFromMessage(&(message_runner));
+        epath->instance_number = GetIntFromMessage( &(message_runner) );
         number_of_decoded_elements++;
         break;
 
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID +
+        LOGICAL_SEGMENT_FORMAT_EIGHT_BIT:
         epath->attribute_number = *(EipUint8 *) (message_runner + 1);
         message_runner += 2;
         break;
 
-      case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE + LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID_MESSAGE_VALUE + LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE:
+      case SEGMENT_TYPE_LOGICAL_SEGMENT + LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID +
+        LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT:
         message_runner += 2;
-        epath->attribute_number = GetIntFromMessage(&(message_runner));
+        epath->attribute_number = GetIntFromMessage( &(message_runner) );
         number_of_decoded_elements++;
         break;
 

+ 212 - 164
source/src/cip/cipepath.c

@@ -16,58 +16,58 @@
 const unsigned int kPortSegmentExtendedPort = 15; /**< Reserved port segment port value, indicating the use of the extended port field */
 
 /* Segments */
-#define SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE 0x00 /**< Message value of the Port segment */
-#define SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE 0x20 /**< Message value of the Logical segment */
-#define SEGMENT_TYPE_NETWORK_SEGMENT_MESSAGE_VALUE 0x40 /**< Message value of the Network segment */
-#define SEGMENT_TYPE_SYMBOLIC_SEGMENT_MESSAGE_VALUE 0x60 /**< Message value of the Symbolic segment */
-#define SEGMENT_TYPE_DATA_SEGMENT_MESSAGE_VALUE 0x80 /**< Message value of the Data segment */
-#define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED_MESSAGE_VALUE 0xA0 /**< Message value of the Data type constructed */
-#define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY_MESSAGE_VALUE 0xC0 /**< Message value of the Data type elementary */
-#define SEGMENT_TYPE_SEGMENT_RESERVED_MESSAGE_VALUE 0xE0 /**< Reserved value */
-
-#define LOGICAL_SEGMENT_TYPE_CLASS_ID_MESSAGE_VALUE 0x00 /**< Message value of the logical segment/logical type Class ID */
-#define LOGICAL_SEGMENT_TYPE_INSTANCE_ID_MESSAGE_VALUE 0x04 /**< Message value of the logical segment/logical type Instance ID */
-#define LOGICAL_SEGMENT_TYPE_MEMBER_ID_MESSAGE_VALUE 0x08 /**< Message value of the logical segment/logical type Member ID */
-#define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT_MESSAGE_VALUE 0x0C /**< Message value of the logical segment/logical type Connection Point */
-#define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID_MESSAGE_VALUE 0x10 /**< Message value of the logical segment/logical type Attribute ID */
-#define LOGICAL_SEGMENT_TYPE_SPECIAL_MESSAGE_VALUE 0x14 /**< Message value of the logical segment/logical type Special */
-#define LOGICAL_SEGMENT_TYPE_SERVICE_ID_MESSAGE_VALUE 0x18 /**< Message value of the logical segment/logical type Service ID */
-#define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL_MESSAGE_VALUE 0x1C /**< Message value of the logical segment/logical type Extended Logical */
-
-#define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE 0x00
-#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE 0x01
-#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT_MESSAGE_VALUE 0x02
-
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED_MESSAGE_VALUE 0x00
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX_MESSAGE_VALUE 0x01
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX_MESSAGE_VALUE 0x02
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX_MESSAGE_VALUE 0x03
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX_MESSAGE_VALUE 0x04
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER_MESSAGE_VALUE 0x05
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE_MESSAGE_VALUE 0x06
-
-#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY_MESSAGE_VALUE 0x00
-#define ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4_MESSAGE_VALUE 0x04
-
-#define NETWORK_SEGMENT_SUBTYPE_SCHEDULE_MESSAGE_VALUE 0x01
-#define NETWORK_SEGMENT_SUBTYPE_FIXED_TAG_MESSAGE_VALUE 0x02
-#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS_MESSAGE_VALUE 0x03
-#define NETWORK_SEGMENT_SUBTYPE_SAFETY_MESSAGE_VALUE 0x04
-#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS_MESSAGE_VALUE 0x10
-#define NETWORK_SEGMENT_SUBTYPE_EXTENDED_NETWORK_MESSAGE_VALUE 0x1F
-
-#define SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING_MESSAGE_VALUE 0x00
-
-#define EXTENDED_FORMAT_DOUBLE_CHAR_MESSAGE_VALUE 0x20
-#define EXTENDED_FORMAT_TRIPLE_CHAR_MESSAGE_VALUE 0x40
-#define EXTENDED_FORMAT_NUMERIC_MESSAGE_VALUE 0xC0
-
-#define EXTENDED_FORMAT_NUMERIC_USINT_TYPE 0x06
-#define EXTENDED_FORMAT_NUMERIC_UINT_TYPE 0x07
-#define EXTENDED_FORMAT_NUMERIC_UDINT_TYPE 0x08
-
-#define DATA_SEGMENT_SUBTYPE_SIMPLE_DATA_MESSAGE_VALUE 0x00
-#define DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL_MESSAGE_VALUE 0x11
+#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
+#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT 0x01
+#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT 0x02
+
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED 0x00
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX 0x01
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX 0x02
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX 0x03
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX 0x04
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER 0x05
+#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE 0x06
+
+#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY 0x00
+#define ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4 0x04
+
+#define NETWORK_SEGMENT_SCHEDULE 0x01
+#define NETWORK_SEGMENT_FIXED_TAG 0x02
+#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS 0x03
+#define NETWORK_SEGMENT_SAFETY 0x04
+#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS 0x10
+#define NETWORK_SEGMENT_EXTENDED_NETWORK 0x1F
+
+#define SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING 0x00
+
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_DOUBLE_CHAR 0x20
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_TRIPLE_CHAR 0x40
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC 0xC0
+
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_USINT_TYPE 0x06
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UINT_TYPE 0x07
+#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UDINT_TYPE 0x08
+
+#define DATA_SEGMENT_SUBTYPE_SIMPLE_DATA 0x00
+#define DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL 0x11
 
 
 
@@ -77,84 +77,88 @@ SegmentType GetPathSegmentType(const unsigned char *const cip_path) {
   const unsigned int segment_type = *cip_path & kSegmentTypeMask;
   SegmentType result = kSegmentTypeReserved;
   switch (segment_type) {
-    case SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE:
+    case SEGMENT_TYPE_PORT_SEGMENT:
       result = kSegmentTypePortSegment;
       break;
-    case SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE:
+    case SEGMENT_TYPE_LOGICAL_SEGMENT:
       result = kSegmentTypeLogicalSegment;
       break;
-    case SEGMENT_TYPE_NETWORK_SEGMENT_MESSAGE_VALUE:
+    case SEGMENT_TYPE_NETWORK_SEGMENT:
       result = kSegmentTypeNetworkSegment;
       break;
-    case SEGMENT_TYPE_SYMBOLIC_SEGMENT_MESSAGE_VALUE:
+    case SEGMENT_TYPE_SYMBOLIC_SEGMENT:
       result = kSegmentTypeSymbolicSegment;
       break;
-    case SEGMENT_TYPE_DATA_SEGMENT_MESSAGE_VALUE:
+    case SEGMENT_TYPE_DATA_SEGMENT:
       result = kSegmentTypeDataSegment;
       break;
-    case SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED_MESSAGE_VALUE:
+    case SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED:
       result = kSegmentTypeDataTypeConstructed;
       break;
-    case SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY_MESSAGE_VALUE:
+    case SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY:
       result = kSegmentTypeDataTypeElementary;
       break;
-    case SEGMENT_TYPE_SEGMENT_RESERVED_MESSAGE_VALUE:
+    case SEGMENT_TYPE_SEGMENT_RESERVED:
       result = kSegmentTypeReserved;
       break;
     default:
       OPENER_ASSERT(
-          "Invalid Segment type in the message! We should never come here!\n");
+        "Invalid Segment type in the message! We should never come here!\n");
       break;
   }
   return result;
 }
 
-void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path) {
+void SetPathSegmentType(SegmentType segment_type,
+                        unsigned char *const cip_path) {
   switch (segment_type) {
     case kSegmentTypePortSegment:
-      *cip_path |= SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_PORT_SEGMENT;
       break;
     case kSegmentTypeLogicalSegment:
-      *cip_path |= SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_LOGICAL_SEGMENT;
       break;
     case kSegmentTypeNetworkSegment:
-      *cip_path |= SEGMENT_TYPE_NETWORK_SEGMENT_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_NETWORK_SEGMENT;
       break;
     case kSegmentTypeSymbolicSegment:
-      *cip_path |= SEGMENT_TYPE_SYMBOLIC_SEGMENT_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_SYMBOLIC_SEGMENT;
       break;
     case kSegmentTypeDataSegment:
-      *cip_path |= SEGMENT_TYPE_DATA_SEGMENT_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_DATA_SEGMENT;
       break;
     case kSegmentTypeDataTypeConstructed:
-      *cip_path |= SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED;
       break;
     case kSegmentTypeDataTypeElementary:
-      *cip_path |= SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY;
       break;
     case kSegmentTypeReserved:
-      *cip_path |= SEGMENT_TYPE_SEGMENT_RESERVED_MESSAGE_VALUE;
+      *cip_path |= SEGMENT_TYPE_SEGMENT_RESERVED;
       break;
     default:
       OPENER_ASSERT(
-          "Invalid Segment type chosen! We should never come here!\n");
+        "Invalid Segment type chosen! We should never come here!\n");
   }
 }
 
 /*** Port Segment ***/
-bool GetPathPortSegmentExtendedLinkAddressSizeBit(const unsigned char *const cip_path) {
+bool GetPathPortSegmentExtendedLinkAddressSizeBit(
+  const unsigned char *const cip_path) {
   const unsigned int kExtendedLinkAddressSizeMask = 0x10;
-  if (kExtendedLinkAddressSizeMask == (*cip_path & kExtendedLinkAddressSizeMask) ) {
+  if ( kExtendedLinkAddressSizeMask ==
+       (*cip_path & kExtendedLinkAddressSizeMask) ) {
     return true;
   }
   return false;
 }
 
-unsigned int GetPathPortSegmentPortIdentifier(const unsigned char *const cip_path) {
+unsigned int GetPathPortSegmentPortIdentifier(
+  const unsigned char *const cip_path) {
   const unsigned int kPortIdentifierMask = 0x0F;
   unsigned int port_identifier = *cip_path & kPortIdentifierMask;
 //  OPENER_ASSERT(0 != port_identifier, "Use of reserved port identifier 0\n");
-  OPENER_ASSERT(kSegmentTypePortSegment == GetPathSegmentType(cip_path));
+  OPENER_ASSERT( kSegmentTypePortSegment == GetPathSegmentType(cip_path) );
   OPENER_ASSERT(0 != port_identifier);
   return port_identifier;
 }
@@ -168,128 +172,145 @@ void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
   (*cip_path) |= port_identifier;
 }
 
-unsigned int GetPathPortSegmentLinkAddressSize(const unsigned char *const cip_path) {
+unsigned int GetPathPortSegmentLinkAddressSize(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(false == GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path),
 //                "Call to non existent extended link address size\n");
-  OPENER_ASSERT(true == GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path));
+  OPENER_ASSERT( true ==
+                 GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) );
   return *(cip_path + 1);
 }
 
-unsigned int GetPathPortSegmentExtendedPortNumber(const unsigned char *const cip_path) {
+unsigned int GetPathPortSegmentExtendedPortNumber(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kPortSegmentExtendedPort == GetPathPortSegmentPortIdentifier(cip_path),
 //                "There is no extended port available!\n");
-  OPENER_ASSERT(kPortSegmentExtendedPort == GetPathPortSegmentPortIdentifier(cip_path));
+  OPENER_ASSERT( kPortSegmentExtendedPort ==
+                 GetPathPortSegmentPortIdentifier(cip_path) );
   const unsigned int kExtendedPortSegmentPosition =
-      GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
+    GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
   return cip_path[kExtendedPortSegmentPosition]
-      + (cip_path[kExtendedPortSegmentPosition + 1] << 8);
+         + (cip_path[kExtendedPortSegmentPosition + 1] << 8);
 }
 
 void SetPathPortSegmentExtendedPortIdentifier(
-    const unsigned int extended_port_identifier, unsigned char *const cip_path) {
+  const unsigned int extended_port_identifier, unsigned char *const cip_path) {
   SetPathPortSegmentPortIdentifier(kPortSegmentExtendedPort, cip_path);
   const unsigned int kExtendedPortSegmentPosition =
-      GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
+    GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
   cip_path[kExtendedPortSegmentPosition] = (char) (extended_port_identifier
-      & 0x00FF);
+                                                   & 0x00FF);
   cip_path[kExtendedPortSegmentPosition + 1] =
-      (char) ((extended_port_identifier & 0xFF00) >> 8);
+    (char) ( (extended_port_identifier & 0xFF00) >> 8 );
 }
 /*** Port Segment ***/
 
 /*** Logical Segment ***/
 
 LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
-    const unsigned char *const cip_path) {
-  OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
+  const unsigned char *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
   const unsigned int kLogicalTypeMask = 0x1C;
   const unsigned int logical_type = (*cip_path) & kLogicalTypeMask;
   LogicalSegmentLogicalType result = kLogicalSegmentLogicalTypeExtendedLogical;
   switch (logical_type) {
-    case LOGICAL_SEGMENT_TYPE_CLASS_ID_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_CLASS_ID:
       result = kLogicalSegmentLogicalTypeClassId;
       break;
-    case LOGICAL_SEGMENT_TYPE_INSTANCE_ID_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_INSTANCE_ID:
       result = kLogicalSegmentLogicalTypeInstanceId;
       break;
-    case LOGICAL_SEGMENT_TYPE_MEMBER_ID_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_MEMBER_ID:
       result = kLogicalSegmentLogicalTypeMemberId;
       break;
-    case LOGICAL_SEGMENT_TYPE_CONNECTION_POINT_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_CONNECTION_POINT:
       result = kLogicalSegmentLogicalTypeConnectionPoint;
       break;
-    case LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID:
       result = kLogicalSegmentLogicalTypeAttributeId;
       break;
-    case LOGICAL_SEGMENT_TYPE_SPECIAL_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_SPECIAL:
       result = kLogicalSegmentLogicalTypeSpecial;
       break;
-    case LOGICAL_SEGMENT_TYPE_SERVICE_ID_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_SERVICE_ID:
       result = kLogicalSegmentLogicalTypeServiceId;
       break;
-    case LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL:
       result = kLogicalSegmentLogicalTypeExtendedLogical;
       break;
     default:
       OPENER_ASSERT(
-          "Logical segment/logical type: It is not possible to reach this point!\n");
+        "Logical segment/logical type: It is not possible to reach this point!\n");
       break;
   }
   return result;
 }
 
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
-    const unsigned char *const cip_path) {
-  OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
+  const unsigned char *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
   const unsigned int kLogicalFormatMask = 0x03;
   const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
   LogicalSegmentLogicalFormat result = kLogicalSegmentLogicalFormatEightBit;
   switch (logical_format) {
-    case LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_FORMAT_EIGHT_BIT:
       result = kLogicalSegmentLogicalFormatEightBit;
       break;
-    case LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT:
       result = kLogicalSegmentLogicalFormatSixteenBit;
       break;
-    case LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT:
       result = kLogicalSegmentLogicalFormatThirtyTwoBit;
       break;
     default:
       OPENER_ASSERT(
-          "Logical segment/logical type: Invalid logical type detected!\n");
+        "Logical segment/logical type: Invalid logical type detected!\n");
       break;
   }
   return result;
 }
 
-LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const unsigned char *const cip_path) {
+LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(LOGICAL_SEGMENT_TYPE_EXTENDED_kLogicalSegmentLogicalTypeExtendedLogicalMessageValue == GetPathLogicalSegmentLogicalType(cip_path),
 //                "Trying to extract non-existent extended logical type");
-  OPENER_ASSERT(kLogicalSegmentLogicalTypeExtendedLogical == GetPathLogicalSegmentLogicalType(cip_path));
+  OPENER_ASSERT( kLogicalSegmentLogicalTypeExtendedLogical == GetPathLogicalSegmentLogicalType(
+                   cip_path) );
   const unsigned int extended_logical_type = *(cip_path + 1);
-  LogicalSegmentExtendedLogicalType result = kLogicalSegmentExtendedLogicalTypeReserved;
+  LogicalSegmentExtendedLogicalType result =
+    kLogicalSegmentExtendedLogicalTypeReserved;
   switch(extended_logical_type) {
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeArrayIndex; break;
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeIndirectArrayIndex; break;
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeBitIndex; break;
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeIndirectBitIndex; break;
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeStructureMemberNumber; break;
-    case LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE_MESSAGE_VALUE: result = kLogicalSegmentExtendedLogicalTypeStructureMemberHandle; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX: result =
+      kLogicalSegmentExtendedLogicalTypeArrayIndex; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX: result =
+      kLogicalSegmentExtendedLogicalTypeIndirectArrayIndex; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX: result =
+      kLogicalSegmentExtendedLogicalTypeBitIndex; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX: result =
+      kLogicalSegmentExtendedLogicalTypeIndirectBitIndex; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER: result =
+      kLogicalSegmentExtendedLogicalTypeStructureMemberNumber; break;
+    case LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE: result =
+      kLogicalSegmentExtendedLogicalTypeStructureMemberHandle; break;
     default: result = kLogicalSegmentExtendedLogicalTypeReserved;
   }
   return result;
 }
 
-LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path) {
+LogicalSegmentSpecialTypeLogicalFormat
+GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path)
+{
 //  OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path), "Not a logical segment!\n");
-  OPENER_ASSERT(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path));
-  OPENER_ASSERT(kLogicalSegmentLogicalTypeSpecial == GetPathLogicalSegmentLogicalType(cip_path));
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kLogicalSegmentLogicalTypeSpecial == GetPathLogicalSegmentLogicalType(
+                   cip_path) );
   const unsigned int kLogicalFormatMask = 0x03;
   const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
 
-  LogicalSegmentSpecialTypeLogicalFormat result = kLogicalSegmentSpecialTypeLogicalFormatReserved;
+  LogicalSegmentSpecialTypeLogicalFormat result =
+    kLogicalSegmentSpecialTypeLogicalFormatReserved;
   switch(logical_format) {
-    case LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY_MESSAGE_VALUE:
+    case LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY:
       result = kLogicalSegmentSpecialTypeLogicalFormatElectronicKey; break;
     default: result = kLogicalSegmentSpecialTypeLogicalFormatReserved; break;
   }
@@ -297,31 +318,37 @@ LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalTy
   return result;
 }
 
-ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const unsigned char *const cip_path) {
+ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
 //      GetPathLogicalSegmentSpecialTypeLogicalType(cip_path), "Not an electronic key!\n");
-  OPENER_ASSERT(kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
-        GetPathLogicalSegmentSpecialTypeLogicalType(cip_path));
+  OPENER_ASSERT( kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
+                 GetPathLogicalSegmentSpecialTypeLogicalType(cip_path) );
   ElectronicKeySegmentFormat result = kElectronicKeySegmentFormatReserved;
-  switch(*(cip_path + 1)) {
-    case ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4_MESSAGE_VALUE: result = kElectronicKeySegmentFormatKeyFormat4; break;
+  switch( *(cip_path + 1) ) {
+    case ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4: result =
+      kElectronicKeySegmentFormatKeyFormat4; break;
     default: result = kElectronicKeySegmentFormatReserved; break;
   }
   return result;
 }
 
-void GetPathLogicalSegmentElectronicKeyFormat4(const unsigned char *const cip_path, ElectronicKeyFormat4 *key) {
+void GetPathLogicalSegmentElectronicKeyFormat4(
+  const unsigned char *const cip_path, ElectronicKeyFormat4 *key) {
 //  OPENER_ASSERT(kElectronicKeySegmentFormatKeyFormat4 ==
 //      GetPathLogicalSegmentElectronicKeyFormat(cip_path), "Not electronic key format 4!\n");
-  OPENER_ASSERT(kElectronicKeySegmentFormatKeyFormat4 ==
-        GetPathLogicalSegmentElectronicKeyFormat(cip_path));
+  OPENER_ASSERT( kElectronicKeySegmentFormatKeyFormat4 ==
+                 GetPathLogicalSegmentElectronicKeyFormat(cip_path) );
 
   const char *message_runner = (const char *)(cip_path + 2);
   SetElectronicKeyFormat4VendorId(GetIntFromMessage(&message_runner), key);
   SetElectronicKeyFormat4DeviceType(GetIntFromMessage(&message_runner), key);
   SetElectronicKeyFormat4ProductCode(GetIntFromMessage(&message_runner), key);
-  SetElectronicKeyFormat4MajorRevisionCompatibility(GetSintFromMessage(&message_runner), key);
-  SetElectronicKeyFormat4MinorRevision(GetSintFromMessage(&message_runner), key);
+  SetElectronicKeyFormat4MajorRevisionCompatibility(GetSintFromMessage(&
+                                                                       message_runner),
+                                                    key);
+  SetElectronicKeyFormat4MinorRevision(GetSintFromMessage(&message_runner),
+                                       key);
 }
 
 /*** Logical Segment ***/
@@ -334,24 +361,25 @@ void GetPathLogicalSegmentElectronicKeyFormat4(const unsigned char *const cip_pa
  *  @param cip_path Pointer to the start of the EPath message
  *  @return The Network Segment subtype of the EPath
  */
-NetworkSegmentSubtype GetPathNetworkSegmentSubtype(const unsigned char *const cip_path) {
-  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path));
+NetworkSegmentSubtype GetPathNetworkSegmentSubtype(
+  const unsigned char *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) );
   const unsigned int kSubtypeMask = 0x1F;
   const unsigned int subtype = (*cip_path) & kSubtypeMask;
   NetworkSegmentSubtype result = kNetworkSegmentSubtypeReserved;
   switch(subtype) {
-    case NETWORK_SEGMENT_SUBTYPE_SCHEDULE_MESSAGE_VALUE:
+    case NETWORK_SEGMENT_SCHEDULE:
       result = kNetworkSegmentSubtypeScheduleSegment; break;
-    case NETWORK_SEGMENT_SUBTYPE_FIXED_TAG_MESSAGE_VALUE:
+    case NETWORK_SEGMENT_FIXED_TAG:
       result = kNetworkSegmentSubtypeFixedTagSegment; break;
-    case NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS_MESSAGE_VALUE:
+    case NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS:
       result = kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds; break;
-    case NETWORK_SEGMENT_SUBTYPE_SAFETY_MESSAGE_VALUE:
+    case NETWORK_SEGMENT_SAFETY:
       result = kNetworkSegmentSubtypeSafetySegment; break;
-    case NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS_MESSAGE_VALUE:
+    case NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS:
       result = kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds; break;
-    case NETWORK_SEGMENT_SUBTYPE_EXTENDED_NETWORK_MESSAGE_VALUE:
-          result = kNetworkSegmentSubtypeExtendedNetworkSegment; break;
+    case NETWORK_SEGMENT_EXTENDED_NETWORK:
+      result = kNetworkSegmentSubtypeExtendedNetworkSegment; break;
     default: result = kNetworkSegmentSubtypeReserved; break;
   }
 
@@ -364,12 +392,14 @@ NetworkSegmentSubtype GetPathNetworkSegmentSubtype(const unsigned char *const ci
  * @param cip_path Pointer to the start of the EPath message
  * @return the Production Inhibit Time in milliseconds ranging from 0 to 255
  */
-CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const unsigned char *const cip_path) {
+CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path),"Not a network segment!\n");
 //  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds == GetPathNetworkSegmentSubtype(cip_path),
 //                "Not a Production Inhibit Time milliseconds segment!\n");
-  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path));
-  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds == GetPathNetworkSegmentSubtype(cip_path));
+  OPENER_ASSERT( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kNetworkSegmentSubtypeProductionInhibitTimeInMilliseconds == GetPathNetworkSegmentSubtype(
+                   cip_path) );
   return *(cip_path + 1);
 }
 
@@ -379,15 +409,17 @@ CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const unsigned
  * @param cip_path Pointer to the start of the EPath message
  * @return the Production Inhibit Time in microseconds ranging from 0 to 4294967295
  */
-CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const unsigned char *const cip_path) {
+CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path),"Not a network segment!\n");
 //  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds == GetPathNetworkSegmentSubtype(cip_path),
 //                  "Not a Production Inhibit Time microseconds segment!\n");
 //  OPENER_ASSERT(2 == *(cip_path + 1), "Data Words length is incorrect! See CIP Spec Vol.1 C-1.4.3.3.2\n");
 
-  OPENER_ASSERT(kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path));
-  OPENER_ASSERT(kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds == GetPathNetworkSegmentSubtype(cip_path));
-  OPENER_ASSERT(2 == *(cip_path + 1));
+  OPENER_ASSERT( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds == GetPathNetworkSegmentSubtype(
+                   cip_path) );
+  OPENER_ASSERT( 2 == *(cip_path + 1) );
 
   const unsigned char *message_runner = cip_path + 2;
   return GetDintFromMessage(&message_runner);
@@ -397,44 +429,58 @@ CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const unsigned
 
 /*** Symbolic Segment ***/
 
-SymbolicSegmentFormat GetPathSymbolicSegmentFormat(const unsigned char *const cip_path) {
+SymbolicSegmentFormat GetPathSymbolicSegmentFormat(
+  const unsigned char *const cip_path) {
   const unsigned int kSymbolicSegmentFormatMask = 0x1F;
-  if( SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING_MESSAGE_VALUE == (*cip_path & kSymbolicSegmentFormatMask) ) {
+  if( SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING ==
+      (*cip_path & kSymbolicSegmentFormatMask) ) {
     return kSymbolicSegmentFormatExtendedString;
   }
   return kSymbolicSegmentFormatASCII;
 }
 
-unsigned int GetPathSymbolicSegmentASCIIFormatLength(const unsigned char *const cip_path) {
+unsigned int GetPathSymbolicSegmentASCIIFormatLength(
+  const unsigned char *const cip_path) {
   const unsigned int kSymbolicSegmentASCIIFormatLength = 0x1F;
   const unsigned int length = *cip_path & kSymbolicSegmentASCIIFormatLength;
   OPENER_ASSERT(0 != length);
   return length;
 }
 
-SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(const unsigned char *const cip_path) {
+SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(
+  const unsigned char *const cip_path) {
   const unsigned int kSymbolicSegmentExtendedFormatNumericTypeMask = 0x1F;
-  const unsigned int numeric_subtype = *(cip_path + 1) & kSymbolicSegmentExtendedFormatNumericTypeMask;
+  const unsigned int numeric_subtype = *(cip_path + 1) &
+                                       kSymbolicSegmentExtendedFormatNumericTypeMask;
   SymbolicSegmentExtendedFormat result = kSymbolicSegmentExtendedFormatReserved;
   switch(numeric_subtype) {
-    case EXTENDED_FORMAT_NUMERIC_USINT_TYPE: result = kSymbolicSegmentExtendedFormatNumericSymbolUSINT; break;
-    case EXTENDED_FORMAT_NUMERIC_UINT_TYPE: result = kSymbolicSegmentExtendedFormatNumericSymbolUINT; break;
-    case EXTENDED_FORMAT_NUMERIC_UDINT_TYPE: result = kSymbolicSegmentExtendedFormatNumericSymbolUDINT; break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_USINT_TYPE: result =
+      kSymbolicSegmentExtendedFormatNumericSymbolUSINT; break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UINT_TYPE: result =
+      kSymbolicSegmentExtendedFormatNumericSymbolUINT; break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UDINT_TYPE: result =
+      kSymbolicSegmentExtendedFormatNumericSymbolUDINT; break;
     default: result = kSymbolicSegmentExtendedFormatReserved; break;
   }
   return result;
 }
 
-SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(const unsigned char *const cip_path) {
-  OPENER_ASSERT(kSegmentTypeSymbolicSegment == GetPathSegmentType(cip_path));
-  OPENER_ASSERT(kSymbolicSegmentFormatExtendedString == GetPathSymbolicSegmentFormat(cip_path));
+SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(
+  const unsigned char *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeSymbolicSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSymbolicSegmentFormatExtendedString == GetPathSymbolicSegmentFormat(
+                   cip_path) );
   const unsigned int kSymbolicSegmentExtendedFormatMask = 0xE0;
-  const unsigned int extended_type = *(cip_path + 1) & kSymbolicSegmentExtendedFormatMask;
+  const unsigned int extended_type = *(cip_path + 1) &
+                                     kSymbolicSegmentExtendedFormatMask;
   SymbolicSegmentExtendedFormat result = kSymbolicSegmentExtendedFormatReserved;
   switch(extended_type) {
-    case EXTENDED_FORMAT_DOUBLE_CHAR_MESSAGE_VALUE: result = kSymbolicSegmentExtendedFormatDoubleByteChars; break;
-    case EXTENDED_FORMAT_TRIPLE_CHAR_MESSAGE_VALUE: result = kSymbolicSegmentExtendedFormatTripleByteChars; break;
-    case EXTENDED_FORMAT_NUMERIC_MESSAGE_VALUE: result = GetPathSymbolicSegmentNumericType(cip_path); break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_DOUBLE_CHAR: result =
+      kSymbolicSegmentExtendedFormatDoubleByteChars; break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_TRIPLE_CHAR: result =
+      kSymbolicSegmentExtendedFormatTripleByteChars; break;
+    case SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC: result =
+      GetPathSymbolicSegmentNumericType(cip_path); break;
     default: result = kSymbolicSegmentExtendedFormatReserved; break;
   }
   return result;
@@ -444,15 +490,16 @@ SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(const unsigne
 
 /*** Data Segment ***/
 
-DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path) {
+DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path)
+{
   const unsigned int kDataSegmentSubtypeMask = 0x1F;
   const unsigned int data_subtype = (*cip_path) & kDataSegmentSubtypeMask;
 
   DataSegmentSubtype result = kDataSegmentSubtypeReserved;
   switch(data_subtype) {
-    case DATA_SEGMENT_SUBTYPE_SIMPLE_DATA_MESSAGE_VALUE:
+    case DATA_SEGMENT_SUBTYPE_SIMPLE_DATA:
       result = kDataSegmentSubtypeSimpleData; break;
-    case DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL_MESSAGE_VALUE:
+    case DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL:
       result = kDataSegmentSubtypeANSIExtendedSymbol; break;
     default: result = kDataSegmentSubtypeReserved; break;
   }
@@ -464,12 +511,13 @@ DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path
  * @param cip_path Pointer to the start of the EPath message
  * @return The amount of 16-bit words of data in the EPath
  */
-CipUsint GetPathDataSegmentSimpleDataWordLength(const unsigned char *const cip_path) {
+CipUsint GetPathDataSegmentSimpleDataWordLength(
+  const unsigned char *const cip_path) {
 //  OPENER_ASSERT(kSegmentTypeDataSegment == GetPathSegmentType(cip_path),"Not a data segment!\n");
 //  OPENER_ASSERT(kDataSegmentSubtypeSimpleData == GetPathDataSegmentSubtype(cip_path), "Not a simple data segment!\n");
-  OPENER_ASSERT(kSegmentTypeDataSegment == GetPathSegmentType(cip_path));
-  OPENER_ASSERT(
-      kDataSegmentSubtypeSimpleData == GetPathDataSegmentSubtype(cip_path));
+  OPENER_ASSERT( kSegmentTypeDataSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kDataSegmentSubtypeSimpleData ==
+                 GetPathDataSegmentSubtype(cip_path) );
 
   const unsigned char *message_runner = cip_path + 1;
   return GetSintFromMessage(&message_runner);

+ 152 - 60
source/src/cip/cipepath.h

@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, Rockwell Automation, Inc.
+ * Copyright (c) 2016, Rockwell Automation, Inc.
  * All rights reserved.
  *
  ******************************************************************************/
@@ -12,44 +12,44 @@
 #include "ciptypes.h"
 #include "cipelectronickey.h"
 
-#define SEGMENT_TYPE_PORT_SEGMENT_MESSAGE_VALUE 0x00 /**< Message value of the Port segment */
-#define SEGMENT_TYPE_LOGICAL_SEGMENT_MESSAGE_VALUE 0x20 /**< Message value of the Logical segment */
-#define SEGMENT_TYPE_NETWORK_SEGMENT_MESSAGE_VALUE 0x40 /**< Message value of the Network segment */
-#define SEGMENT_TYPE_SYMBOLIC_SEGMENT_MESSAGE_VALUE 0x60 /**< Message value of the Symbolic segment */
-#define SEGMENT_TYPE_DATA_SEGMENT_MESSAGE_VALUE 0x80 /**< Message value of the Data segment */
-#define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED_MESSAGE_VALUE 0xA0 /**< Message value of the Data type constructed */
-#define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY_MESSAGE_VALUE 0xC0 /**< Message value of the Data type elementary */
-#define SEGMENT_TYPE_SEGMENT_RESERVED_MESSAGE_VALUE 0xE0 /**< Reserved value */
-
-#define LOGICAL_SEGMENT_TYPE_CLASS_ID_MESSAGE_VALUE 0x00 /**< Message value of the logical segment/logical type Class ID */
-#define LOGICAL_SEGMENT_TYPE_INSTANCE_ID_MESSAGE_VALUE 0x04 /**< Message value of the logical segment/logical type Instance ID */
-#define LOGICAL_SEGMENT_TYPE_MEMBER_ID_MESSAGE_VALUE 0x08 /**< Message value of the logical segment/logical type Member ID */
-#define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT_MESSAGE_VALUE 0x0C /**< Message value of the logical segment/logical type Connection Point */
-#define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID_MESSAGE_VALUE 0x10 /**< Message value of the logical segment/logical type Attribute ID */
-#define LOGICAL_SEGMENT_TYPE_SPECIAL_MESSAGE_VALUE 0x14 /**< Message value of the logical segment/logical type Special */
-#define LOGICAL_SEGMENT_TYPE_SERVICE_ID_MESSAGE_VALUE 0x18 /**< Message value of the logical segment/logical type Service ID */
-#define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL_MESSAGE_VALUE 0x1C /**< Message value of the logical segment/logical type Extended Logical */
-
-#define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT_MESSAGE_VALUE 0x00 /**< Message value indicating an 8 bit value */
-#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT_MESSAGE_VALUE 0x01 /**< Message value indicating an 16 bit value */
-#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT_MESSAGE_VALUE 0x02 /**< Message value indicating an 32 bit value */
-
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED_MESSAGE_VALUE 0x00 /**< Message value indicating an reserved/unused Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX_MESSAGE_VALUE 0x01 /**< Message value indicating the Array Index Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX_MESSAGE_VALUE 0x02 /**< Message value indicating the Indirect Array Index Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX_MESSAGE_VALUE 0x03 /**< Message value indicating the Bit Index Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX_MESSAGE_VALUE 0x04 /**< Message value indicating the Indirect Bit Index Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER_MESSAGE_VALUE 0x05 /**< Message value indicating the Structured Member Number Extended Logical Segment type */
-#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE_MESSAGE_VALUE 0x06 /**< Message value indicating the Structured Member Handler Extended Logical Segment type */
-
-#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY_MESSAGE_VALUE 0x00 /**< Message value indicating an electronic key */
-
-#define NETWORK_SEGMENT_SUBTYPE_SCHEDULE_MESSAGE_VALUE 0x01
-#define NETWORK_SEGMENT_SUBTYPE_FIXED_TAG_MESSAGE_VALUE 0x02
-#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS_MESSAGE_VALUE 0x03
-#define NETWORK_SEGMENT_SUBTYPE_SAFETY_MESSAGE_VALUE 0x04
-#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS_MESSAGE_VALUE 0x10
-#define NETWORK_SEGMENT_SUBTYPE_EXTENDED_NETWORK_MESSAGE_VALUE 0x1F
+#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 */
+
+#define NETWORK_SEGMENT_SUBTYPE_SCHEDULE 0x01
+#define NETWORK_SEGMENT_SUBTYPE_FIXED_TAG 0x02
+#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS 0x03
+#define NETWORK_SEGMENT_SUBTYPE_SAFETY 0x04
+#define NETWORK_SEGMENT_SUBTYPE_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS 0x10
+#define NETWORK_SEGMENT_SUBTYPE_EXTENDED_NETWORK 0x1F
 
 typedef enum network_segment_subtype {
   kNetworkSegmentSubtypeReserved,
@@ -98,25 +98,28 @@ SegmentType GetPathSegmentType(const unsigned char *const cip_path);
  * @param segment_type The segment type
  * @param cip_path A message buffer - Will be written on!
  */
-void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path);
+void SetPathSegmentType(SegmentType segment_type,
+                        unsigned char *const cip_path);
 
 /*********************************************************
- * Port Segment functions
- *********************************************************/
+* Port Segment functions
+*********************************************************/
 
 /** @brief Only to be used on Port Segments. Returns if the Port Segment has the extended link address size bit set
  *
  * @param cip_path The start of the EPath message
  * @return True if extended link addres size bit set, false otherwise
  */
-bool GetPathPortSegmentExtendedLinkAddressSizeBit(const unsigned char *const cip_path);
+bool GetPathPortSegmentExtendedLinkAddressSizeBit(
+  const unsigned char *const cip_path);
 
 /** @brief Only to be used on Port Segments. Returns the Port Identifier
  *
  * @param cip_path The start of the EPath message
  * @return The Port Identifier
  */
-unsigned int GetPathPortSegmentPortIdentifier(const unsigned char *const cip_path);
+unsigned int GetPathPortSegmentPortIdentifier(
+  const unsigned char *const cip_path);
 
 /** @brief Sets the Port Identifier form an Port Segment EPath to be sent.
  *
@@ -131,45 +134,134 @@ void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
  * @param cip_path The start of the EPath message
  * @return The Link Address Size
  */
-unsigned int GetPathPortSegmentLinkAddressSize(const unsigned char *const cip_path);
+unsigned int GetPathPortSegmentLinkAddressSize(
+  const unsigned char *const cip_path);
 
 /** @brief Only to be used on Port Segments with Extended Port Number. Gets the Extended Port Number
  *
  * @param cip_path The start of the EPath message
  * @return The Link Address Size
  */
-unsigned int GetPathPortSegmentExtendedPortNumber(const unsigned char *const cip_path);
+unsigned int GetPathPortSegmentExtendedPortNumber(
+  const unsigned char *const cip_path);
 
+/** @brief Sets the Extended Port Identifier in a EPath Port Segment message
+ *
+ * @param extended_port_identifier The extended port identifier to be encoded into the message
+ * @param cip_path The start for the EPatch message
+ */
 void SetPathPortSegmentExtendedPortIdentifier(
-    const unsigned int extended_port_identifier, unsigned char *const cip_path);
+  const unsigned int extended_port_identifier, unsigned char *const cip_path);
 
-LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(const unsigned char *const cip_path);
+/** @brief Gets the Logical Type of an EPath Logical Segment message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The logical type of the logical segment
+ */
+LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
+  const unsigned char *const cip_path);
 
+/** @brief Gets the Logical Format of a Logical Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The logical format of the logical format
+ */
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
-    const unsigned char *const cip_path);
+  const unsigned char *const cip_path);
 
-LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const unsigned char *const cip_path);
+/** @brief  Gets the Extended Logical Type of a Logical Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The extended logical type of the logical segment
+ */
+LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(
+  const unsigned char *const cip_path);
 
-LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path);
+/** @brief Gets the Special Type Logical Type of a Logical Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The Special Type Logical Format subtype of a Logical Segment EPath message
+ */
+LogicalSegmentSpecialTypeLogicalFormat
+GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path);
 
-ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const unsigned char *const cip_path);
+/** @brief Gets the Electronic Key format of a Logical Segment Special Type EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The Electronic Key Format used in the EPath
+ */
+ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
+  const unsigned char *const cip_path);
 
-void GetPathLogicalSegmentElectronicKeyFormat4(const unsigned char *const cip_path, ElectronicKeyFormat4 *key);
+/** @brief Gets the data for an Electronic Key of format 4 from the EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @param Writes the data on the user provided data electronic key struct
+ */
+void GetPathLogicalSegmentElectronicKeyFormat4(
+  const unsigned char *const cip_path, ElectronicKeyFormat4 *key);
 
-NetworkSegmentSubtype GetPathNetworkSegmentSubtype(const unsigned char *const cip_path);
+/** @brief Gets the Network Segment Subtype of a EPatch Network Segement EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return Network Segment subtype
+ */
+NetworkSegmentSubtype GetPathNetworkSegmentSubtype(
+  const unsigned char *const cip_path);
 
-CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const unsigned char *const cip_path);
+/** @brief Gets the Production Inhibit Time in Milliseconds
+ *
+ * @param cip_path The start of the EPath message
+ * @return The production Inhibit Time in Milliseconds
+ */
+CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(
+  const unsigned char *const cip_path);
 
-CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const unsigned char *const cip_path);
+/** @brief Gets the Production Inhibit Time in Microseconds
+ *
+ * @param cip_path The start of the EPath message
+ * @return The production Inhibit Time in Microseconds
+ */
+CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(
+  const unsigned char *const cip_path);
 
+/** @brief Gets the Data Segment subtype of a Data Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The Data Segment subtype
+ */
 DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path);
 
-CipUsint GetPathDataSegmentSimpleDataWordLength(const unsigned char *const cip_path);
+/** @brief Gets the data word length of a Simple Data segment
+ *
+ * @param cip_path The start of the EPath message
+ * @return The length in words of the Simple Data segment
+ */
+CipUsint GetPathDataSegmentSimpleDataWordLength(
+  const unsigned char *const cip_path);
 
-SymbolicSegmentFormat GetPathSymbolicSegmentFormat(const unsigned char *const cip_path);
+/** @brief Gets the Symbolic Segment Format of the Symbolic Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The Symbolic Segment Format
+ */
+SymbolicSegmentFormat GetPathSymbolicSegmentFormat(
+  const unsigned char *const cip_path);
 
-SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(const unsigned char *const cip_path);
+/** @brief Gets the Numeric subtype of a Symbolic Segment Extended Format EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return The Numeric Extended Format subtype
+ */
+SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(
+  const unsigned char *const cip_path);
 
-SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(const unsigned char *const cip_path);
+/** @brief Gets the Extended Format subtype of a Symbolic Segment EPath message
+ *
+ * @param cip_path The start of the EPath message
+ * @return Symbolic Segment Extended Format
+ */
+SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(
+  const unsigned char *const cip_path);
 
 #endif /* SRC_CIP_CIPEPATH_H_ */