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

Corrects doxygen entries and moves semicolon to OPENER_ASSERT macro

When OPENER_TRACES are deactivated, the static code checking tools will
report false positive empty line errors, as the OPENER_ASSERT will be
removed, but the semicolon will stay. With this change the semicolon for
OPENER_ASSERT is now part of the macro and is removed from the code,
resulting in complete empty lines, if OPENER_TRACES is deactivated.

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

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

@@ -437,7 +437,7 @@ bool ConnectionWithSameConfigPointExists(const EipUint32 config_point) {
 
   while (NULL != node) {
     CipConnectionObject *connection = node->data;
-    OPENER_ASSERT(NULL != connection);
+    OPENER_ASSERT(NULL != connection)
     if (config_point == connection->configuration_path.instance_id) {
       return true;
     }

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

@@ -36,25 +36,25 @@ void CipStackInit(const EipUint16 unique_connection_id) {
   EncapsulationInit();
   /* The message router is the first CIP object be initialized!!! */
   EipStatus eip_status = CipMessageRouterInit();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = CipIdentityInit();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = CipTcpIpInterfaceInit();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = CipEthernetLinkInit();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = ConnectionManagerInit(unique_connection_id);
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = CipAssemblyInitialize();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   eip_status = CipQoSInit();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
   /* the application has to be initialized at last */
   eip_status = ApplicationInitialization();
-  OPENER_ASSERT(kEipStatusOk == eip_status);
+  OPENER_ASSERT(kEipStatusOk == eip_status)
 
   /* Shut up compiler warning with traces disabled */
-  (void) eip_status;
+    (void) eip_status;
 }
 
 void ShutdownCipStack(void) {
@@ -96,7 +96,7 @@ EipStatus NotifyClass(const CipClass *RESTRICT const cip_class,
           /* call the service, and return what it returns */
           OPENER_TRACE_INFO("notify: calling %s service\n",
                             service->name);
-          OPENER_ASSERT(NULL != service->service_function);
+          OPENER_ASSERT(NULL != service->service_function)
           return service->service_function(instance,
                                            message_router_request,
                                            message_router_response,
@@ -146,7 +146,7 @@ CipInstance *AddCipInstances(CipClass *RESTRICT const cip_class,
     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);
+  OPENER_ASSERT(NULL != current_instance)
   /* fail if run out of memory */
 
   cip_class->number_of_instances += number_of_instances;       /* add the number of instances just created to the total recorded by the class */
@@ -199,7 +199,7 @@ CipClass *CreateCipClass(const EipUint32 class_id,
   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
@@ -208,7 +208,7 @@ CipClass *CreateCipClass(const EipUint32 class_id,
      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 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*/
@@ -309,7 +309,7 @@ void InsertAttribute(CipInstance *const instance,
   CipAttributeStruct *attribute = instance->attributes;
   CipClass *class = instance->cip_class;
 
-  OPENER_ASSERT(NULL != attribute);
+  OPENER_ASSERT(NULL != attribute)
   /* adding a attribute to a class that was not declared to have any attributes is not allowed */
   for (int i = 0; i < instance->cip_class->number_of_attributes; i++) {
     if (attribute->data == NULL) {             /* found non set attribute */
@@ -318,7 +318,7 @@ void InsertAttribute(CipInstance *const instance,
       attribute->attribute_flags = cip_flags;
       attribute->data = data;
 
-      OPENER_ASSERT(attribute_number <= class->highest_attribute_number);
+      OPENER_ASSERT(attribute_number <= class->highest_attribute_number)
 
       size_t index = CalculateIndex(attribute_number);
 
@@ -338,7 +338,7 @@ void InsertAttribute(CipInstance *const instance,
     "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);
+  OPENER_ASSERT(0)
   /* trying to insert too many attributes*/
 }
 
@@ -351,7 +351,7 @@ void InsertService(const CipClass *const class,
   OPENER_TRACE_INFO("%s, number of services:%d, service number:%d\n",
                     class->class_name, class->number_of_services,
                     service_number);
-  OPENER_ASSERT(service != 0);
+  OPENER_ASSERT(service != NULL)
   /* 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 */
   {
@@ -365,7 +365,7 @@ void InsertService(const CipClass *const class,
     }
     ++service;
   }
-  OPENER_ASSERT(0);
+  OPENER_ASSERT(0)
   /* adding more services than were declared is a no-no*/
 }
 
@@ -435,7 +435,7 @@ EipStatus GetAttributeSingle(CipInstance *RESTRICT const instance,
         BeforeAssemblyDataSend(instance);
       }
 
-      OPENER_ASSERT(NULL != attribute);
+      OPENER_ASSERT(NULL != attribute)
       message_router_response->data_length = EncodeData(attribute->type,
                                                         attribute->data,
                                                         &message);
@@ -612,27 +612,27 @@ int EncodeData(const EipUint8 cip_type,
   return counter;
 }
 
-int DecodeData(const EipUint8 cip_type,
-               void *const data,
-               const EipUint8 **const message) {
+int DecodeData(const EipUint8 cip_data_type,
+               void *const cip_data,
+               const EipUint8 **const cip_message) {
   int number_of_decoded_bytes = -1;
 
-  switch (cip_type)
+  switch (cip_data_type)
   /* check the data type of attribute */
   {
     case (kCipBool):
     case (kCipSint):
     case (kCipUsint):
     case (kCipByte):
-      *(EipUint8 *) (data) = **message;
-      ++(*message);
+      *(EipUint8 *) (cip_data) = **cip_message;
+      ++(*cip_message);
       number_of_decoded_bytes = 1;
       break;
 
     case (kCipInt):
     case (kCipUint):
     case (kCipWord):
-      (*(EipUint16 *) (data) ) = GetIntFromMessage(message);
+      (*(EipUint16 *) (cip_data) ) = GetIntFromMessage(cip_message);
       number_of_decoded_bytes = 2;
       break;
 
@@ -640,7 +640,7 @@ int DecodeData(const EipUint8 cip_type,
     case (kCipUdint):
     case (kCipDword):
     case (kCipReal):
-      (*(EipUint32 *) (data) ) = GetDintFromMessage(message);
+      (*(EipUint32 *) (cip_data) ) = GetDintFromMessage(cip_message);
       number_of_decoded_bytes = 4;
       break;
 
@@ -648,34 +648,34 @@ int DecodeData(const EipUint8 cip_type,
     case (kCipLint):
     case (kCipUlint):
     case (kCipLword): {
-      (*(EipUint64 *) (data) ) = GetLintFromMessage(message);
+      (*(EipUint64 *) (cip_data) ) = GetLintFromMessage(cip_message);
       number_of_decoded_bytes = 8;
     }
     break;
 #endif
 
     case (kCipString): {
-      CipString *string = (CipString *) data;
-      string->length = GetIntFromMessage(message);
-      memcpy(string->string, *message, string->length);
-      *message += string->length;
+      CipString *string = (CipString *) cip_data;
+      string->length = GetIntFromMessage(cip_message);
+      memcpy(string->string, *cip_message, string->length);
+      *cip_message += string->length;
 
       number_of_decoded_bytes = string->length + 2;           /* we have a two byte length field */
       if (number_of_decoded_bytes & 0x01) {
         /* we have an odd byte count */
-        ++(*message);
+        ++(*cip_message);
         number_of_decoded_bytes++;
       }
     }
     break;
     case (kCipShortString): {
-      CipShortString *short_string = (CipShortString *) data;
+      CipShortString *short_string = (CipShortString *) cip_data;
 
-      short_string->length = **message;
-      ++(*message);
+      short_string->length = **cip_message;
+      ++(*cip_message);
 
-      memcpy(short_string->string, *message, short_string->length);
-      *message += short_string->length;
+      memcpy(short_string->string, *cip_message, short_string->length);
+      *cip_message += short_string->length;
 
       number_of_decoded_bytes = short_string->length + 1;
       break;

+ 10 - 4
source/src/cip/cipcommon.h

@@ -25,9 +25,11 @@ static const EipUint16 kCipUintZero = 0; /**< Zero value for returning the UINT
 
 /** @brief Check if requested service present in class/instance and call appropriate service.
  *
- * @param class class receiving the message
+ * @param cip_class class receiving the message
  * @param message_router_request request message
  * @param message_router_response reply message
+ * @param originator_address address struct of the originator as received
+ * @param encapsulation_session associated encapsulation session of the explicit message
  * @return
  *     - kEipStatusOkSend ... success
  *     - kEipStatusOk ... no reply to send back
@@ -46,6 +48,8 @@ EipStatus NotifyClass(const CipClass *const RESTRICT cip_class,
  * @param instance pointer to instance.
  * @param message_router_request pointer to request.
  * @param message_router_response pointer to response.
+ * @param originator_address address struct of the originator as received
+ * @param encapsulation_session associated encapsulation session of the explicit message
  * @return status  >0 .. success
  *          -1 .. requested attribute not available
  */
@@ -64,6 +68,8 @@ EipStatus GetAttributeSingle(
  * @param instance pointer to object instance with data.
  * @param message_router_request pointer to MR request.
  * @param message_router_response pointer for MR response.
+ * @param originator_address address struct of the originator as received
+ * @param encapsulation_session associated encapsulation session of the explicit message
  * @return length of data stream >0 .. success
  *              0 .. no reply to send
  */
@@ -74,11 +80,11 @@ EipStatus GetAttributeAll(CipInstance *instance,
                           const int encapsulation_session);
 
 /** @brief Decodes padded EPath
- *  @param epath EPath to the receiving element
- *  @param message CIP Message to decode
+ *  @param epath EPath object to the receiving element
+ *  @param message pointer to the message to decode
  *  @return Number of decoded bytes
  */
 int DecodePaddedEPath(CipEpath *epath,
-                      const EipUint8 **data);
+                      const EipUint8 **message);
 size_t GetSizeOfAttribute(const CipAttributeStruct *const attribute_struct);
 #endif /* OPENER_CIPCOMMON_H_ */

+ 7 - 5
source/src/cip/cipconnectionmanager.c

@@ -129,9 +129,9 @@ EipStatus CheckElectronicKeyData(
  * @param connection_object pointer to the connection object structure for which the connection should
  *                      be established
  * @param message_router_request pointer to the received request structure. The position of the data stream pointer has to be at the connection length entry
- * @param extended_status the extended error code in case an error happened
+ * @param extended_error the extended error code in case an error happened
  * @return general status on the establishment
- *    - EIP_OK ... on success
+ *    - kEipStatusOk ... on success
  *    - On an error the general status code to be put into the response
  */
 EipUint8 ParseConnectionPath(
@@ -484,6 +484,8 @@ static const HandleForwardOpenRequestFunction
  *  @param instance	pointer to CIP object instance
  *  @param message_router_request		pointer to Message Router Request.
  *  @param message_router_response		pointer to Message Router Response.
+ *  @param originator_address address struct of the originator as received
+ *  @param encapsulation_session associated encapsulation session of the explicit message
  *      @return >0 .. success, 0 .. no reply to send back
  *              -1 .. error
  */
@@ -598,7 +600,7 @@ EipStatus ForwardClose(
            && (connection_object->originator_serial_number
                == originator_serial_number) ) {
         /* found the corresponding connection object -> close it */
-        OPENER_ASSERT(NULL != connection_object->connection_close_function);
+        OPENER_ASSERT(NULL != connection_object->connection_close_function)
         if ( ( (struct sockaddr_in *) originator_address )->sin_addr.s_addr
              == connection_object->originator_address.sin_addr.s_addr ) {
           connection_object->connection_close_function(connection_object);
@@ -666,7 +668,7 @@ EipStatus ManageConnections(MilliSeconds elapsed_time) {
           /* we have a timed out connection perform watchdog time out action*/
           OPENER_TRACE_INFO(">>>>>>>>>>Connection ConnNr: %u timed out\n",
                             connection_object->connection_serial_number);
-          OPENER_ASSERT(NULL != connection_object->connection_timeout_function);
+          OPENER_ASSERT(NULL != connection_object->connection_timeout_function)
           connection_object->connection_timeout_function(connection_object);
         } else {
           connection_object->inactivity_watchdog_timer -= elapsed_time;
@@ -696,7 +698,7 @@ EipStatus ManageConnections(MilliSeconds elapsed_time) {
 
           if (connection_object->transmission_trigger_timer <= elapsed_time) { /* need to send package */
             OPENER_ASSERT(
-              NULL != connection_object->connection_send_data_function);
+              NULL != connection_object->connection_send_data_function)
             EipStatus eip_status = connection_object
                                    ->connection_send_data_function(
               connection_object);

+ 8 - 8
source/src/cip/cipconnectionmanager.h

@@ -143,18 +143,18 @@ typedef enum {
 
 /** @brief macros for comparing sequence numbers according to CIP spec vol
  * 2 3-4.2 for int type variables
- * @define SEQ_LEQ32(a, b) Checks if sequence number a is less or equal than b
- * @define SEQ_GEQ32(a, b) Checks if sequence number a is greater or equal than
+ * @def SEQ_LEQ32(a, b) Checks if sequence number a is less or equal than b
+ * @def SEQ_GEQ32(a, b) Checks if sequence number a is greater or equal than
  *  b
- *  @define SEQ_GT32(a, b) Checks if sequence number a is greater than 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 )
 
 /** @brief similar macros for comparing 16 bit sequence numbers
- * @define SEQ_LEQ16(a, b) Checks if sequence number a is less or equal than b
- * @define SEQ_GEQ16(a, b) Checks if sequence number a is greater or equal than
+ * @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 )
@@ -167,16 +167,16 @@ static const int g_kCipConnectionManagerClassCode = 0x06;
 
 /** @brief Initialize the data of the connection manager object
  *
- *  @param A unique connection id
+ *  @param unique_connection_id A unique connection id
  *  @return kEipStatusOk if successful, otherwise kEipStatusError
  */
 EipStatus ConnectionManagerInit(EipUint16 unique_connection_id);
 
 /** @brief Get a connected object dependent on requested ConnectionID.
  *
- *   @param connection_id  requested @var connection_id of opened connection
+ *   @param connection_id Connection ID of the Connection Object to get
  *   @return pointer to connected Object
- *           0 .. connection not present in device
+ *           NULL .. connection not present in device
  */
 CipConnectionObject *GetConnectedObject(const EipUint32 connection_id);
 

+ 7 - 4
source/src/cip/cipconnectionobject.c

@@ -233,7 +233,8 @@ void ConnectionObjectSetState(CipConnectionObject *const connection_object,
         CIP_CONNECTION_OBJECT_STATE_CLOSING;
       break;
     default:
-      OPENER_ASSERT(false); /* Never get here */
+      OPENER_ASSERT(false) /* Never get here */
+      break;
   }
 }
 
@@ -277,9 +278,10 @@ CipUsint ConnectionObjectGetInstanceTypeForAttribute(
       return CIP_CONNECTION_OBJECT_INSTANCE_TYPE_CIP_BRIDGED;
       break;
     default:
-      assert(false);
+      OPENER_ASSERT(false)
+      break;
   }
-  assert(false);         //We should never come to this point
+  OPENER_ASSERT(false) //We should never come to this point
   return 255;
 }
 
@@ -685,7 +687,8 @@ ConnectionObjectPriority ConnectionObjectGetPriority(
       kConnectionObjectPriorityScheduled; break;
     case CIP_CONNECTION_OBJECT_PRIORITY_URGENT: result =
       kConnectionObjectPriorityUrgent; break;
-    default: OPENER_ASSERT(false); //Not possible to get here!
+    default: OPENER_ASSERT(false) /* Not possible to get here! */
+      break;
   }
   return result;
 }

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

@@ -59,9 +59,8 @@ ElectronicKeyFormat4 *ElectronicKeyFormat4New(
 void ElectronicKeyFormat4Delete(ElectronicKeyFormat4 **electronic_key);
 
 /** @brief Sets vendor ID in the electronic key
- *
+ *  @param electronic_key The electronic key to be set - will be modified
  *	@param vendor_id The vendor ID to be set into the electronic key
- *	@param electronic_key The electronic key to be set - will be modified
  */
 void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key,
                                      const CipUint vendor_id);
@@ -76,8 +75,8 @@ CipUint ElectronicKeyFormat4GetVendorId(
 
 /** @brief Sets the device type in the electronic key
  *
- *	@param device_type The device type which shall be inserted into the electronic key
  *	@param electronic_key A format 4 electronic key
+ *	@param device_type The device type which shall be inserted into the electronic key
  */
 void ElectronicKeyFormat4SetDeviceType(
   ElectronicKeyFormat4 *const electronic_key,
@@ -85,7 +84,7 @@ void ElectronicKeyFormat4SetDeviceType(
 
 /** @brief Gets the device type from a format 4 electronic key
  *
- *      @param The format 4 electronic key from which the device type will be extracted
+ *      @param electronic_key The format 4 electronic key from which the device type will be extracted
  *      @return The device type
  */
 CipUint ElectronicKeyFormat4GetDeviceType(
@@ -93,8 +92,8 @@ CipUint ElectronicKeyFormat4GetDeviceType(
 
 /** @brief Set product code in the electronic key
  *
- *      @param product_code The product code to be inserted
  *      @param electronic_key The electronic key to be modified
+ *      @param product_code The product code to be inserted
  */
 void ElectronicKeyFormat4SetProductCode(
   ElectronicKeyFormat4 *const electronic_key,

+ 57 - 55
source/src/cip/cipepath.c

@@ -103,7 +103,7 @@ SegmentType GetPathSegmentType(const CipOctet *const cip_path) {
       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;
@@ -138,7 +138,8 @@ void SetPathSegmentType(SegmentType segment_type,
       break;
     default:
       OPENER_ASSERT(
-        "Invalid Segment type chosen! We should never come here!\n");
+        "Invalid Segment type chosen! We should never come here!\n")
+      break;
   }
 }
 
@@ -157,36 +158,36 @@ 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(0 != port_identifier);
+/*  OPENER_ASSERT(0 != port_identifier, "Use of reserved port identifier 0\n"); */
+  OPENER_ASSERT( kSegmentTypePortSegment == GetPathSegmentType(cip_path) )
+  OPENER_ASSERT(0 != port_identifier)
   return port_identifier;
 }
 
 void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
                                       unsigned char *const cip_path) {
-//  OPENER_ASSERT(
-//      port_identifier < 16,
-//      "Port identifier too large for standard port identifier field\n");
-  OPENER_ASSERT(port_identifier < 16);
-  (*cip_path) |= port_identifier;
+/* OPENER_ASSERT(
+      port_identifier < 16,
+      "Port identifier too large for standard port identifier field\n"); */
+  OPENER_ASSERT(port_identifier < 16)
+    (*cip_path) |= port_identifier;
 }
 
 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(false == GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path),
+                "Call to non existent extended link address size\n") */
   OPENER_ASSERT( true ==
-                 GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) );
+                 GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) )
   return *(cip_path + 1);
 }
 
 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),
+                "There is no extended port available!\n") */
   OPENER_ASSERT( kPortSegmentExtendedPort ==
-                 GetPathPortSegmentPortIdentifier(cip_path) );
+                 GetPathPortSegmentPortIdentifier(cip_path) )
   const unsigned int kExtendedPortSegmentPosition =
     GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
   return cip_path[kExtendedPortSegmentPosition]
@@ -210,7 +211,7 @@ void SetPathPortSegmentExtendedPortIdentifier(
 
 LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
   const unsigned char *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) )
   const unsigned int kLogicalTypeMask = 0x1C;
   const unsigned int logical_type = (*cip_path) & kLogicalTypeMask;
   LogicalSegmentLogicalType result = kLogicalSegmentLogicalTypeExtendedLogical;
@@ -241,7 +242,7 @@ LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
       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;
@@ -249,7 +250,7 @@ LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
 
 void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type,
                                       CipOctet *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) )
   switch (logical_type) {
     case kLogicalSegmentLogicalTypeClassId:
       (*cip_path) |= LOGICAL_SEGMENT_TYPE_CLASS_ID;
@@ -284,7 +285,7 @@ void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type,
 
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   const unsigned char *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) )
   const unsigned int kLogicalFormatMask = 0x03;
   const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
   LogicalSegmentLogicalFormat result = kLogicalSegmentLogicalFormatEightBit;
@@ -300,7 +301,7 @@ LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
       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;
@@ -309,7 +310,7 @@ LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
 void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format,
                                         CipOctet *const cip_path) {
   OPENER_ASSERT( kSegmentTypeLogicalSegment ==
-                 GetPathSegmentType( (const CipOctet *)cip_path ) );
+                 GetPathSegmentType( (const CipOctet *)cip_path ) )
   switch (format) {
     case kLogicalSegmentLogicalFormatEightBit:
       (*cip_path) |= LOGICAL_SEGMENT_FORMAT_EIGHT_BIT;
@@ -322,7 +323,7 @@ void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format,
       break;
     default:
       OPENER_ASSERT(
-        "Logical segment/logical type: Invalid logical type detected!\n");
+        "Logical segment/logical type: Invalid logical type detected!\n")
       break;
   }
 }
@@ -345,7 +346,8 @@ const CipDword CipEpathGetLogicalValue(const EipUint8 **message) {
       data = GetDintFromMessage(message);
       break;
     default:
-      OPENER_ASSERT(false); //shall not happen!
+      OPENER_ASSERT(false) /* shall not happen! */
+      break;
   }
   return data;
 }
@@ -369,16 +371,16 @@ size_t CipEpathSetLogicalValue(const CipDword logical_value,
       AddDintToMessage(logical_value, message);
       return 5; break;
   }
-  OPENER_ASSERT(false); /* This should never happen! */
+  OPENER_ASSERT(false) /* This should never happen! */
   return 0;
 }
 
 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(LOGICAL_SEGMENT_TYPE_EXTENDED_kLogicalSegmentLogicalTypeExtendedLogicalMessageValue == GetPathLogicalSegmentLogicalType(cip_path),
+                "Trying to extract non-existent extended logical type") */
   OPENER_ASSERT( kLogicalSegmentLogicalTypeExtendedLogical == GetPathLogicalSegmentLogicalType(
-                   cip_path) );
+                   cip_path) )
   const unsigned int extended_logical_type = *(cip_path + 1);
   LogicalSegmentExtendedLogicalType result =
     kLogicalSegmentExtendedLogicalTypeReserved;
@@ -403,10 +405,10 @@ LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(
 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(kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path), "Not a logical segment!\n") */
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) )
   OPENER_ASSERT( kLogicalSegmentLogicalTypeSpecial == GetPathLogicalSegmentLogicalType(
-                   cip_path) );
+                   cip_path) )
   const unsigned int kLogicalFormatMask = 0x03;
   const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
 
@@ -423,10 +425,10 @@ GetPathLogicalSegmentSpecialTypeLogicalType(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), "Not an electronic key!\n") */
   OPENER_ASSERT( kLogicalSegmentSpecialTypeLogicalFormatElectronicKey ==
-                 GetPathLogicalSegmentSpecialTypeLogicalType(cip_path) );
+                 GetPathLogicalSegmentSpecialTypeLogicalType(cip_path) )
   ElectronicKeySegmentFormat result = kElectronicKeySegmentFormatReserved;
   switch( *(cip_path + 1) ) {
     case ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4: result =
@@ -440,7 +442,7 @@ void GetElectronicKeyFormat4FromMessage(
   const CipOctet **const message,
   ElectronicKeyFormat4 *key) {
   OPENER_ASSERT( kElectronicKeySegmentFormatKeyFormat4 ==
-                 GetPathLogicalSegmentElectronicKeyFormat(*message) );
+                 GetPathLogicalSegmentElectronicKeyFormat(*message) )
 
   MoveMessageNOctets(2, message);
   ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(message) );
@@ -463,7 +465,7 @@ void GetElectronicKeyFormat4FromMessage(
  */
 NetworkSegmentSubtype GetPathNetworkSegmentSubtype(
   const unsigned char *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) )
   const unsigned int kSubtypeMask = 0x1F;
   const unsigned int subtype = (*cip_path) & kSubtypeMask;
   NetworkSegmentSubtype result = kNetworkSegmentSubtypeReserved;
@@ -494,12 +496,12 @@ NetworkSegmentSubtype GetPathNetworkSegmentSubtype(
  */
 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(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) );
+                   cip_path) )
   return *(cip_path + 1);
 }
 
@@ -511,15 +513,15 @@ CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(
  */
 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),"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( kSegmentTypeNetworkSegment == GetPathSegmentType(cip_path) )
   OPENER_ASSERT( kNetworkSegmentSubtypeProductionInhibitTimeInMicroseconds == GetPathNetworkSegmentSubtype(
-                   cip_path) );
-  OPENER_ASSERT( 2 == *(cip_path + 1) );
+                   cip_path) )
+  OPENER_ASSERT( 2 == *(cip_path + 1) )
 
   const unsigned char *message_runner = cip_path + 2;
   return GetDintFromMessage(&message_runner);
@@ -543,7 +545,7 @@ 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);
+  OPENER_ASSERT(0 != length)
   return length;
 }
 
@@ -567,9 +569,9 @@ SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(
 
 SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(
   const unsigned char *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeSymbolicSegment == GetPathSegmentType(cip_path) );
+  OPENER_ASSERT( kSegmentTypeSymbolicSegment == GetPathSegmentType(cip_path) )
   OPENER_ASSERT( kSymbolicSegmentFormatExtendedString == GetPathSymbolicSegmentFormat(
-                   cip_path) );
+                   cip_path) )
   const unsigned int kSymbolicSegmentExtendedFormatMask = 0xE0;
   const unsigned int extended_type = *(cip_path + 1) &
                                      kSymbolicSegmentExtendedFormatMask;
@@ -613,11 +615,11 @@ DataSegmentSubtype GetPathDataSegmentSubtype(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(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) );
+                 GetPathDataSegmentSubtype(cip_path) )
 
   const unsigned char *message_runner = cip_path + 1;
   return GetSintFromMessage(&message_runner);

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

@@ -291,7 +291,7 @@ ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
 /** @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
+ * @param key Writes the data on the user provided data electronic key struct
  */
 void GetElectronicKeyFormat4FromMessage(
   const CipOctet **const cip_path,

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

@@ -41,7 +41,7 @@ EipStatus GetAttributeSingleEthernetLink(
   struct sockaddr *originator_address,
   const int encapsulation_session);
 
-/** @bried Configures the MAC address of the Ethernet Link object*
+/** @brief Configures the MAC address of the Ethernet Link object*
  *
  *  @param mac_address The MAC address of the Ethernet Link
  */

+ 10 - 12
source/src/cip/cipioconnection.c

@@ -132,7 +132,7 @@ EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(
     /* an assembly object should always have an attribute 3 */
     CipAttributeStruct *attribute = GetCipAttribute(instance,
                                                     io_connection_object->consumed_path.attribute_id_or_connection_point);
-    OPENER_ASSERT(attribute != NULL);
+    OPENER_ASSERT(attribute != NULL)
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
     if ( kConnectionObjectTransportClassTriggerTransportClass1
          == ConnectionObjectGetTransportClassTriggerTransportClass(
@@ -231,7 +231,7 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
     io_connection_object->produced_path.attribute_id_or_connection_point = 3;
     CipAttributeStruct *attribute = GetCipAttribute(instance,
                                                     io_connection_object->produced_path.attribute_id_or_connection_point);
-    OPENER_ASSERT(attribute != NULL);
+    OPENER_ASSERT(attribute != NULL)
     bool is_heartbeat = ( ( (CipByteArray *) attribute->data )->length == 0 );
     if ( kConnectionObjectTransportClassTriggerTransportClass1 ==
          ConnectionObjectGetTransportClassTriggerTransportClass(
@@ -301,7 +301,7 @@ EipStatus EstablishIoConnection(
   OPENER_ASSERT( !(originator_to_target_connection_type ==
                    kConnectionObjectConnectionTypeNull &&
                    target_to_originator_connection_type ==
-                   kConnectionObjectConnectionTypeNull) );
+                   kConnectionObjectConnectionTypeNull) )
 
   io_connection_object->consuming_instance = NULL;
   io_connection_object->consumed_connection_path_length = 0;
@@ -510,11 +510,11 @@ EipStatus OpenProducingMulticastConnection(
   return kEipStatusOk;
 }
 
-/** @brief Open a Multicast connection dependent on @var direction.
+/** @brief Open a Multicast connection dependent on @p direction.
  *
  * @param direction Flag to indicate if consuming or producing.
- * @param connection_object  pointer to registered Object in ConnectionManager.
- * @param common_packet_format_data     received CPF Data Item.
+ * @param connection_object Pointer to registered Object in ConnectionManager.
+ * @param common_packet_format_data Received CPF Data Item.
  * @return kEipStatusOk on success, otherwise kEipStatusError
  */
 EipStatus OpenMulticastConnection(
@@ -548,12 +548,10 @@ EipStatus OpenMulticastConnection(
   }
 
   if(kUdpCommuncationDirectionConsuming == direction) {
-    //OPENER_ASSERT(-1 != address_info_item_which_contains_o_to_t);
     j = address_info_item_which_contains_o_to_t;
   }
 
   if(kUdpCommuncationDirectionProducing == direction) {
-    //OPENER_ASSERT(-1 != address_info_item_which_contains_o_to_t);
     j = address_info_item_which_contains_t_to_o;
   }
 
@@ -626,7 +624,7 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
     assembly_class, connection_object->configuration_path.instance_id);
 
   if (0 != g_config_data_length) {
-    OPENER_ASSERT(NULL != config_instance);
+    OPENER_ASSERT(NULL != config_instance)
     if ( ConnectionWithSameConfigPointExists(
            connection_object->configuration_path.instance_id) ) {
       /* there is a connected connection with the same config point
@@ -634,10 +632,10 @@ EipUint16 HandleConfigData(CipConnectionObject *connection_object) {
       CipAttributeStruct *attribute_three = GetCipAttribute(
         config_instance,
         3);
-      OPENER_ASSERT(NULL != attribute_three);
-      CipByteArray *attribute_three_data =
+      OPENER_ASSERT(NULL != attribute_three)
+      CipByteArray * attribute_three_data =
         (CipByteArray *) attribute_three->data;
-      OPENER_ASSERT(NULL != attribute_three_data);
+      OPENER_ASSERT(NULL != attribute_three_data)
       if (attribute_three_data->length != g_config_data_length) {
         connection_manager_status =
           kConnectionManagerExtendedStatusCodeErrorOwnershipConflict;

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

@@ -21,17 +21,17 @@ CipMessageRouterResponse g_message_router_response;
  * memory. The size of the array could be a parameter in the platform config file.
  */
 typedef struct cip_message_router_object {
-  struct cip_message_router_object *next; /*< link */
-  CipClass *cip_class; /*< object */
+  struct cip_message_router_object *next; /**< link */
+  CipClass *cip_class; /**< object */
 } CipMessageRouterObject;
 
 /** @brief Pointer to first registered object in MessageRouter*/
 CipMessageRouterObject *g_first_object = NULL;
 
-/** @brief Register an Class to the message router
+/** @brief Register a CIP Class to the message router
  *  @param cip_class Pointer to a class object to be registered.
- *  @return status      0 .. success
- *                     -1 .. error no memory available to register more objects
+ *  @return kEipStatusOk on success
+ *          kEipStatusError on no memory available to register more objects
  */
 EipStatus RegisterCipClass(CipClass *cip_class);
 
@@ -113,7 +113,7 @@ CipMessageRouterObject *GetRegisteredObject(EipUint32 class_id) {
 
   while (NULL != object) /* for each entry in list*/
   {
-    OPENER_ASSERT(object->cip_class != NULL);
+    OPENER_ASSERT(NULL != object->cip_class)
     if (object->cip_class->class_id == class_id) {
       return object; /* return registration node if it matches class ID*/
     }
@@ -212,7 +212,7 @@ EipStatus NotifyMessageRouter(EipUint8 *data,
       /* call notify function from Object with ClassID (gMRRequest.RequestPath.ClassID)
          object will or will not make an reply into gMRResponse*/
       g_message_router_response.reserved = 0;
-      OPENER_ASSERT(NULL != registered_object->cip_class);
+      OPENER_ASSERT(NULL != registered_object->cip_class)
       OPENER_TRACE_INFO(
         "NotifyMessageRouter: calling notify function of class '%s'\n",
         registered_object->cip_class->class_name);

+ 7 - 5
source/src/cip/cipmessagerouter.h

@@ -35,8 +35,10 @@ void DeleteAllClasses(void);
  *  g_stCPFDataItem.
  *  @param data pointer to the data buffer of the message directly at the beginning of the CIP part.
  *  @param data_length number of bytes in the data buffer
- *  @return  EIP_ERROR on fault
- *           EIP_OK on success
+ *  @param originator_address The address of the originator as received
+ *  @param encapsulation_session The associated encapsulation session of the explicit message
+ *  @return  kEipStatusError on fault
+ *           kEipStatusOk on success
  */
 EipStatus NotifyMessageRouter(EipUint8 *data,
                               int data_length,
@@ -48,9 +50,9 @@ EipStatus NotifyMessageRouter(EipUint8 *data,
  *  explicit messages each class has to register.
  *  Will be automatically done when invoking create
  *  createCIPClass.
- *  @param object CIP class to be registered
- *  @return EIP_OK on success
+ *  @param cip_class CIP class to be registered
+ *  @return kEipStatusOk on success
  */
-EipStatus RegisterCipClass(CipClass *object);
+EipStatus RegisterCipClass(CipClass *cip_class);
 
 #endif /* OPENER_CIPMESSAGEROUTER_H_ */

+ 2 - 2
source/src/cip/ciptcpipinterface.c

@@ -383,8 +383,8 @@ EipStatus GetAttributeAllTcpIpInterface(
 
 EipUint16 GetEncapsulationInactivityTimeout(CipInstance *instance) {
   CipAttributeStruct *attribute = GetCipAttribute(instance, 13);
-  OPENER_ASSERT(NULL != attribute);
-  CipUint *data = (CipUint *) attribute->data;
+  OPENER_ASSERT(NULL != attribute)
+  CipUint * data = (CipUint *) attribute->data;
   EipUint16 encapsulation_inactivity_timeout = *data;
   return encapsulation_inactivity_timeout;
 }

+ 8 - 12
source/src/cip/ciptypes.h

@@ -258,18 +258,20 @@ typedef struct cip_class {
 } CipClass;
 
 /** @ingroup CIP_API
- *  @typedef  EIP_STATUS (*TCIPServiceFunc)(S_CIP_Instance *pa_pstInstance,
- *   S_CIP_MR_Request *pa_MRRequest, S_CIP_MR_Response *pa_MRResponse)
+ *  @typedef  EipStatus (*CipServiceFunction)(CipInstance *const instance,
+ *    CipMessageRouterRequest *const message_router_request,
+ *    CipMessageRouterResponse *const message_router_response,
+ *    struct sockaddr *originator_address, const int encapsulation_session)
  *  @brief Signature definition for the implementation of CIP services.
  *
  *  CIP services have to follow this signature in order to be handled correctly
  *   by the stack.
- *  @param pa_pstInstance the instance which was referenced in the service
+ *  @param instance the instance which was referenced in the service
  *   request
- *  @param pa_MRRequest request data
- *  @param pa_MRResponse storage for the response data, including a buffer for
+ *  @param message_router_request request data
+ *  @param message_router_response storage for the response data, including a buffer for
  *   extended data
- *  @return EIP_OK_SEND if service could be executed successfully and a response
+ *  @return kEipOkSend if service could be executed successfully and a response
  *   should be sent
  */
 typedef EipStatus (*CipServiceFunction)(
@@ -315,12 +317,6 @@ typedef struct {
   void *data;
 } CipUnconnectedSendParameter;
 
-/** @brief Data of an CIP Ethernet Link object */
-//typedef struct {
-//  EipUint32 interface_speed; /**< 10/100/1000 Mbit/sec */
-//  EipUint32 interface_flags; /**< Inferface flags as defined in the CIP specification */
-//  EipUint8 physical_address[6]; /**< MAC address of the Ethernet link */
-//} CipEthernetLinkObject;
 typedef struct {
   CipUint num_conn_entries;
   CipBool *conn_open_bits;

+ 33 - 61
source/src/enet_encap/cpf.c

@@ -23,14 +23,15 @@ const size_t sequenced_address_item_length = 8;
 
 CipCommonPacketFormatData g_common_packet_format_data_item; /**< CPF global data items */
 
-int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
+int NotifyCommonPacketFormat(EncapsulationData *const received_data,
                              const struct sockaddr *const originator_address,
                              ENIPMessage *const outgoing_message) {
   int return_value = kEipStatusError;
 
   if (kEipStatusError == ( return_value = CreateCommonPacketFormatStructure(
-                             receive_data->current_communication_buffer_position,
-                             receive_data->data_length,
+                             received_data->
+                             current_communication_buffer_position,
+                             received_data->data_length,
                              &g_common_packet_format_data_item) ) ) {
     OPENER_TRACE_ERR("notifyCPF: error from createCPFstructure\n");
   } else {
@@ -44,7 +45,7 @@ int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
           g_common_packet_format_data_item.data_item.data,
           g_common_packet_format_data_item.data_item.length,
           originator_address,
-          receive_data->session_handle);
+          received_data->session_handle);
         if (return_value != kEipStatusError) {
           SkipEncapsulationHeader(outgoing_message);
           return_value = AssembleLinearMessage(
@@ -54,9 +55,9 @@ int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
           CipOctet *buffer = outgoing_message->current_message_position;
           outgoing_message->current_message_position =
             outgoing_message->message_buffer;
-          GenerateEncapsulationHeader(receive_data,
+          GenerateEncapsulationHeader(received_data,
                                       return_value,
-                                      receive_data->session_handle,
+                                      received_data->session_handle,
                                       kEncapsulationProtocolSuccess,
                                       outgoing_message);
           outgoing_message->current_message_position = buffer;
@@ -66,9 +67,9 @@ int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
         /* wrong data item detected*/
         OPENER_TRACE_ERR(
           "notifyCPF: got something besides the expected CIP_ITEM_ID_UNCONNECTEDMESSAGE\n");
-        GenerateEncapsulationHeader(receive_data,
+        GenerateEncapsulationHeader(received_data,
                                     return_value,
-                                    receive_data->session_handle,
+                                    received_data->session_handle,
                                     kEncapsulationProtocolIncorrectData,
                                     outgoing_message);
         return_value = outgoing_message->used_message_length;
@@ -76,9 +77,9 @@ int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
     } else {
       OPENER_TRACE_ERR(
         "notifyCPF: got something besides the expected CIP_ITEM_ID_NULL\n");
-      GenerateEncapsulationHeader(receive_data,
+      GenerateEncapsulationHeader(received_data,
                                   return_value,
-                                  receive_data->session_handle,
+                                  received_data->session_handle,
                                   kEncapsulationProtocolIncorrectData,
                                   outgoing_message);
       return_value = outgoing_message->used_message_length;
@@ -210,7 +211,7 @@ EipStatus CreateCommonPacketFormatStructure(
 
   int length_count = 0;
   CipUint item_count = GetIntFromMessage(&data);
-  OPENER_ASSERT(4U >= item_count); /* Sanitizing data - probably needs to be changed for productive code */
+  OPENER_ASSERT(4U >= item_count) /* Sanitizing data - probably needs to be changed for productive code */
   common_packet_format_data->item_count = item_count;
   length_count += 2;
   if (common_packet_format_data->item_count >= 1U) {
@@ -289,8 +290,7 @@ EipStatus CreateCommonPacketFormatStructure(
 
 /**
  * @brief Encodes a Null Address Item into the message frame
- * @param message The message frame
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -306,9 +306,8 @@ int EncodeNullAddressItem(ENIPMessage *const outgoing_message) {
 
 /**
  * Encodes a Connected Address Item into the message frame
- * @param message The message frame
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -330,9 +329,8 @@ int EncodeConnectedAddressItem(
 /**
  * @brief Encodes a sequenced address item into the message
  *
- * @param message Pointer to the message memory start
  * @param common_packet_format_data_item Common Packet Format item which is used in the encoding
- * @param size Size of the message at the start of the function
+ * @param outgoing_message The outgoing message object
  *
  * @return New message size after encoding
  */
@@ -359,8 +357,7 @@ int EncodeSequencedAddressItem(
  * @brief Adds the item count to the message frame
  *
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message The message frame
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -377,8 +374,7 @@ int EncodeItemCount(
  * Adds the data item type to the message frame
  *
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message The message frame
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -395,8 +391,7 @@ int EncodeDataItemType(
  * Adds the data item section length to the message frame
  *
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message The message frame
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -413,8 +408,7 @@ int EncodeDataItemLength(
  * Adds the data items to the message frame
  *
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message Message frame to which the data is added
- * @param size The actual size of the message frame
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message frame after encoding
  */
@@ -434,8 +428,7 @@ int EncodeDataItemData(
  * @brief Encodes the Connected Data item length
  *
  * @param message_router_response The Router Response message which shall be answered
- * @param message Message frame to which the data is added
- * @param size Current size of the message buffer
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message buffer
  */
@@ -453,9 +446,8 @@ int EncodeConnectedDataItemLength(
 /**
  * @brief Encodes a sequence number into the message
  *
- * @param size The current size of the message buffer
  * @param common_packet_format_data_item
- * @param message Message frame to which the data is added
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message buffer
  *
@@ -473,9 +465,8 @@ int EncodeSequenceNumber(
 /**
  * @brief Encodes the reply service code for the requested service
  *
- * @param size The current size of the message buffer
- * @param message Message frame to which the data is added
- * @param message_rounter_response The router response message data structure to be processed
+ * @param message_router_response The router response message data structure to be processed
+ * @param outgoing_message The outgoing message object
  *
  * @return The new size of the message buffer
  */
@@ -491,9 +482,8 @@ int EncodeReplyService(
 /**
  * @brief Encodes the reserved byte in the message router response
  *
- * @param size Current size of the message buffer
- * @param message Message frame to which the data is added
  * @param message_router_response Router Response message to be processed
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -509,9 +499,8 @@ int EncodeReservedFieldOfLengthByte(
 /**
  * @brief Encodes the general status of a Router Response
  *
- * @param size Current size of the message buffer
- * @param message Message frame to which the data is added
  * @param message_router_response Router Response message to be processed
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -527,9 +516,8 @@ int EncodeGeneralStatus(
 /**
  * @brief Encodes the length of the extended status data part
  *
- * @param size Current size of the message buffer
- * @param message Message frame to which the data is added
  * @param message_router_response Router Response message to be processed
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -546,9 +534,8 @@ int EncodeExtendedStatusLength(
 /**
  * @brief Encodes the extended status data items
  *
- * @param size Current size of the message buffer
  * @param message_router_response Router Response message to be processed
- * @param message Message frame to which the data is added
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -571,9 +558,8 @@ int EncodeExtendedStatusDataItems(
  * This function uses EncodeExtendedStatusLength and EncodeExtendedStatusDataItems
  * to encode the complete extended status information into the message
  *
- * @param size Current size of the message buffer
- * @param message Message frame to which the data is added
  * @param message_router_response Router Response message to be processed
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -590,9 +576,8 @@ int EncodeExtendedStatus(
 /**
  * @brief Encode the data item length of the unconnected data segment
  *
- * @param size Current size of the message buffer
  * @param message_router_response Router Response message to be processed
- * @param message Message frame to which the data is added
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -609,9 +594,8 @@ int EncodeUnconnectedDataItemLength(
 /**
  * @brief Encodes the Message Router Response data
  *
- * @param size Current size of the message buffer
  * @param message_router_response Router Response message to be processed
- * @param message Message frame to which the data is added
+ * @param outgoing_message The outgoing message object
  */
 int EncodeMessageRouterResponseData(
   const CipMessageRouterResponse *const message_router_response,
@@ -627,10 +611,9 @@ int EncodeMessageRouterResponseData(
 /**
  * @brief Encodes the sockaddr info type id into the message
  *
- * @param size Current size of the message buffer
  * @param item_type
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message Message frame to which the encoded data is added
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -638,7 +621,7 @@ int EncodeSockaddrInfoItemTypeId(
   int item_type,
   const CipCommonPacketFormatData *const common_packet_format_data_item,
   ENIPMessage *const outgoing_message) {
-  OPENER_ASSERT(item_type == 0 || item_type == 1);
+  OPENER_ASSERT(item_type == 0 || item_type == 1)
   outgoing_message->used_message_length += AddIntToMessage(
     common_packet_format_data_item->address_info_item[item_type].type_id,
     &outgoing_message->current_message_position);
@@ -649,10 +632,9 @@ int EncodeSockaddrInfoItemTypeId(
 /**
  * @brief Encodes the sockaddr info length into the message
  *
- * @param size Current size of the message buffer
  * @param item_type
  * @param common_packet_format_data_item The Common Packet Format data structure from which the message is constructed
- * @param message Message frame to which the encoded data is added
+ * @param outgoing_message The outgoing message object
  *
  * @return New size of the message buffer
  */
@@ -666,15 +648,6 @@ int EncodeSockaddrInfoLength(
   return outgoing_message->used_message_length;
 }
 
-/** @brief Copy data from message_router_response struct and common_packet_format_data_item into linear memory in
- * pa_msg for transmission over in encapsulation.
- *
- * @param message_router_response	pointer to message router response which has to be aligned into linear memory.
- * @param common_packet_format_data_item pointer to CPF structure which has to be aligned into linear memory.
- * @param message		pointer to linear memory.
- *  @return length of reply in message in bytes
- *                      -1 .. error
- */
 int AssembleLinearMessage(
   const CipMessageRouterResponse *const message_router_response,
   const CipCommonPacketFormatData *const common_packet_format_data_item,
@@ -787,4 +760,3 @@ int AssembleIOMessage(
   return AssembleLinearMessage(0, common_packet_format_data_item,
                                outgoing_message);
 }
-

+ 20 - 17
source/src/enet_encap/cpf.h

@@ -12,12 +12,12 @@
 
 /** @ingroup ENCAP
  * @brief CPF is Common Packet Format
- * CPF packet := <number of items> {<items>}
- * item := <TypeID> <Length> <data>
- * <number of items> := two bytes
- * <TypeID> := two bytes
- * <Length> := two bytes
- * <data> := <the number of bytes specified by Length>
+ * CPF packet := \<number of items\> {\<items\>}
+ * item := \<TypeID\> \<Length\> \<data\>
+ * \<number of items\> := two bytes
+ * \<TypeID\> := two bytes
+ * \<Length\> := two bytes
+ * \<data\> := \<the number of bytes specified by Length\>
  */
 
 /** @brief Definition of Item ID numbers used for address and data items in CPF structures */
@@ -75,11 +75,12 @@ typedef struct {
  * Parse the CPF data from a received unconnected explicit message and
  * hand the data on to the message router
  *
- * @param  received_data pointer to the encapsulation structure with the received message
- * @param  reply_buffer reply buffer
+ * @param received_data pointer to the encapsulation structure with the received message
+ * @param originator_address Address struct of the originator
+ * @param outgoing_message The outgoing ENIP message struct
  * @return number of bytes to be sent back. < 0 if nothing should be sent
  */
-int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
+int NotifyCommonPacketFormat(EncapsulationData *const received_data,
                              const struct sockaddr *const originator_address,
                              ENIPMessage *const outgoing_message);
 
@@ -88,8 +89,9 @@ int NotifyCommonPacketFormat(EncapsulationData *const receive_data,
  * the connection status, update any timers, and hand the data on to
  * the message router
  *
- * @param  received_data pointer to the encapsulation structure with the received message
- * @param  reply_buffer reply buffer
+ * @param received_data pointer to the encapsulation structure with the received message
+ * @param originator_address Address struct of the originator
+ * @param outgoing_message The outgoing ENIP message struct
  * @return number of bytes to be sent back. < 0 if nothing should be sent
  */
 int NotifyConnectedCommonPacketFormat(
@@ -113,10 +115,9 @@ EipStatus CreateCommonPacketFormatStructure(
 
 /** @ingroup ENCAP
  * Copy data from CPFDataItem into linear memory in message for transmission over in encapsulation.
- * @param  message_router_response  pointer to message router response which has to be aligned into linear memory.
  * @param  common_packet_format_data_item pointer to CPF structure which has to be aligned into linear memory.
- * @param  message    pointer to linear memory.
- * @return length of reply in pa_msg in bytes
+ * @param  message Modified ENIP message struct
+ * @return length of modification in bytes
  *     EIP_ERROR .. error
  */
 int AssembleIOMessage(
@@ -125,11 +126,13 @@ int AssembleIOMessage(
 
 
 /** @ingroup ENCAP
- * Copy data from MRResponse struct and CPFDataItem into linear memory in message for transmission over in encapsulation.
+ * /** @brief Copy data from message_router_response struct and common_packet_format_data_item into
+ * ENIPMessage struct outgoing_message via encapsulation.
+ *
  * @param  message_router_response	pointer to message router response which has to be aligned into linear memory.
  * @param  common_packet_format_data_item	pointer to CPF structure which has to be aligned into linear memory.
- * @param  message		pointer to linear memory.
- * @return length of reply in pa_msg in bytes
+ * @param  outgoing_message Modified ENIP message struct
+ * @return length of modification in bytes
  *         EIP_ERROR .. error
  */
 int AssembleLinearMessage(

+ 17 - 11
source/src/enet_encap/encap.c

@@ -22,15 +22,15 @@
 #include "opener_error.h"
 
 /*Identity data from cipidentity.c*/
-extern EipUint16 vendor_id_;
-extern EipUint16 device_type_;
-extern EipUint16 product_code_;
+extern CipUint vendor_id_;
+extern CipUint device_type_;
+extern CipUint product_code_;
 extern CipRevision revision_;
-extern EipUint16 status_;
-extern EipUint32 serial_number_;
+extern CipWord status_;
+extern CipUdint serial_number_;
 extern CipShortString product_name_;
 
-/*ip address data taken from TCPIPInterfaceObject*/
+/* IP address data taken from TCPIPInterfaceObject*/
 extern CipTcpIpNetworkInterfaceConfiguration interface_configuration_;
 
 const int kSupportedProtocolVersion = 1; /**< Supported Encapsulation protocol version */
@@ -338,6 +338,7 @@ void GenerateEncapsulationHeader(const EncapsulationData *const receive_data,
 
 /** @brief generate reply with "Communications Services" + compatibility Flags.
  *  @param receive_data pointer to structure with received data
+ *  @param outgoing_message The outgoing ENIP message
  */
 void HandleReceivedListServicesCommand(
   const EncapsulationData *const receive_data,
@@ -611,7 +612,8 @@ void HandleReceivedRegisterSessionCommand(int socket,
 
 }
 
-/*   INT8 UnregisterSession(struct S_Encapsulation_Data *pa_S_ReceiveData)
+/*   TODO: Update and doxyfy
+ * INT8 UnregisterSession(struct S_Encapsulation_Data *pa_S_ReceiveData)
  *   close all corresponding TCP connections and delete session handle.
  *      pa_S_ReceiveData pointer to unregister session request with corresponding socket handle.
  */
@@ -642,6 +644,8 @@ EipStatus HandleReceivedUnregisterSessionCommand(
 
 /** @brief Call Connection Manager.
  *  @param receive_data Pointer to structure with data and header information.
+ *  @param originator_address Address of the originator as received from socket
+ *  @param outgoing_message The outgoing ENIP message
  */
 EipStatus HandleReceivedSendUnitDataCommand(
   const EncapsulationData *const receive_data,
@@ -684,8 +688,10 @@ EipStatus HandleReceivedSendUnitDataCommand(
 
 /** @brief Call UCMM or Message Router if UCMM not implemented.
  *  @param receive_data Pointer to structure with data and header information.
- *  @return status      0 .. success.
- *                                      -1 .. error
+ *  @param originator_address Address of the originator as received from socket
+ *  @param outgoing_message The outgoing ENIP message
+ *  @return status      kEipStatusOk .. success.
+ *                      kEipStatusError .. error
  */
 EipStatus HandleReceivedSendRequestResponseDataCommand(
   const EncapsulationData *const receive_data,
@@ -755,8 +761,8 @@ int GetFreeSessionIndex(void) {
 }
 
 /** @brief copy data from pa_buf in little endian to host in structure.
- * @param receive_buffer
- * @param length Length of the data in receive_buffer. Might be more than one message
+ * @param receive_buffer Received message
+ * @param receive_buffer_length Length of the data in receive_buffer. Might be more than one message
  * @param encapsulation_data	structure to which data shall be copied
  * @return return difference between bytes in pa_buf an data_length
  *              0 .. full package received

+ 1 - 1
source/src/enet_encap/endianconv.h

@@ -105,7 +105,7 @@ int AddLintToMessage(const EipUint64 pa_unData,
  *
  * @param port Port of the socket, has to be provided in big-endian
  * @param address IP address of the socket, has to be provided in big-endian
- * @param communcation_buffer The message buffer for sending the message
+ * @param communication_buffer The message buffer for sending the message
  */
 int EncapsulateIpAddress(EipUint16 port,
                          EipUint32 address,

+ 53 - 51
source/src/opener_api.h

@@ -44,14 +44,12 @@ void ConfigureMacAddress(const char *network_interface);
  * @brief Configure the domain name of the device
  * @param domain_name the domain name to be used
  */
-void ConfigureDomainName(
-  );
+void ConfigureDomainName(void);
 /** @ingroup CIP_API
  * @brief Configure the host name of the device
  * @param host_name the host name to be used
  */
-void ConfigureHostName(
-  );
+void ConfigureHostName(void);
 
 /** @ingroup CIP_API
  * @brief Set the serial number of the device's identity object.
@@ -121,6 +119,7 @@ CipInstance *GetCipInstance(const CipClass *RESTRICT const cip_object,
 CipAttributeStruct *GetCipAttribute(const CipInstance *const cip_instance,
                                     const EipUint16 attribute_number);
 
+typedef void (*InitializeCipClass)(CipClass *); /**< Initializer function for CIP class initialization */
 /** @ingroup CIP_API
  * @brief Allocate memory for new CIP Class and attributes
  *
@@ -129,21 +128,15 @@ CipAttributeStruct *GetCipAttribute(const CipInstance *const cip_instance,
  *
  *  @param class_id class ID of the new class
  *  @param number_of_class_attributes number of class attributes
- *  @param get_attribute_all_mask mask of which attributes are included in the
- *  class getAttributeAll.
- *  If the mask is 0 the getAttributeAll service will not be added as class
- *  service
+ *  @param highest_class_attribute_number Highest attribute number from the set of implemented class attributes
  *  @param number_of_class_services number of class services
- *  @param number_of_instance_attributes number of attributes of each instance
- *  @param instance_attributes_get_attributes_all_mask  mask of which attributes
- *  are included in the instance getAttributeAll
- *  If the mask is 0 the getAttributeAll service will not be added as class
- *  service
+ *  @param number_of_instance_attributes Number of implemented instance attributes
+ *  @param highest_instance_attribute_number Highest attribute number from the set of implemented instance attributes
  *  @param number_of_instance_services number of instance services
  *  @param number_of_instances number of initial instances to create
- *  @param class_name  class name (for debugging class structure)
- *  @param class_revision class revision
- *  @param (*InitializeCipClass)(CipClass*) For non-standard implementation of
+ *  @param name class name (for debugging class structure)
+ *  @param revision class revision
+ *  @param initializer For non-standard implementation of
  *  class attributes, function realizes specific implementation
  *  @return pointer to new class object
  *      0 on error
@@ -159,7 +152,8 @@ CipClass *CreateCipClass( const EipUint32 class_id,
                           const int number_of_instances,
                           char *name,
                           const EipUint16 revision,
-                          void (*InitializeCipClass)(CipClass *) );
+                          InitializeCipClass initializer );
+
 /** @ingroup CIP_API
  * @brief Add a number of CIP instances to a given CIP class
  *
@@ -186,8 +180,8 @@ CipInstance *AddCipInstances(
  * @brief Create one instance of a given class with a certain instance number
  *
  * This function can be used for creating out of order instance numbers
- * @param pa_pstCIPClass the class the instance should be created for
- * @param pa_nInstanceId the instance id of the created instance
+ * @param cip_class_to_add_instance the class the instance should be created for
+ * @param instance_id the instance id of the created instance
  * @return pointer to the created instance, if an instance with the given id
  *         already exists the existing is returned an no new instance is created
  *
@@ -202,11 +196,11 @@ CipInstance *AddCIPInstance(CipClass *RESTRICT const cip_class_to_add_instance,
  *  the attributes array is not expandable if you insert an attributes that has
  *  already been defined, the previous attributes will be replaced
  *
- *  @param pa_pInstance pointer to CIP class. (may be also instance 0)
- *  @param pa_nAttributeNr number of attribute to be inserted.
- *  @param cip_data_type type of attribute to be inserted.
- *  @param cip_data pointer to data of attribute.
- *  @param cip_flags flags to indicate set-ability and get-ability of attribute.
+ *  @param cip_instance Pointer to CIP class instance (Instance 0)
+ *  @param attribute_number Number of attribute to be inserted.
+ *  @param cip_data_type Type of attribute to be inserted.
+ *  @param cip_data Pointer to data of attribute.
+ *  @param cip_flags Flags to indicate set-ability and get-ability of attribute.
  */
 
 
@@ -277,9 +271,9 @@ int EncodeData(const EipUint8 cip_data_type,
  *  @return length of taken bytes
  *          -1 .. error
  */
-int DecodeData(const EipUint8 cip_type,
-               void *const data,
-               const EipUint8 **const message);
+int DecodeData(const EipUint8 cip_data_type,
+               void *const cip_data,
+               const EipUint8 **const cip_message);
 
 /** @ingroup CIP_API
  * @brief Create an instance of an assembly object
@@ -432,18 +426,20 @@ void ConfigureListenOnlyConnectionPoint(
  * @brief Notify the encapsulation layer that an explicit message has been
  * received via TCP.
  *
- * @param socket_handle socket handle from which data is received.
- * @param buffer buffer that contains the received data. This buffer will also
+ * @param socket_handle Socket handle from which data is received.
+ * @param buffer Buffer that contains the received data. This buffer will also
  * contain the response if one is to be sent.
- * @param buffer length of the data in buffer.
- * @param number_of_remaining_bytes return how many bytes of the input are left
+ * @param length Length of the data in buffer.
+ * @param number_of_remaining_bytes Return how many bytes of the input are left
  * over after we're done here
+ * @param originator_address Address struct of the message originator
+ * @param outgoing_message The outgoing ENIP message
  * @return length of reply that need to be sent back
  */
-int HandleReceivedExplictTcpData(int socket,
+int HandleReceivedExplictTcpData(int socket_handle,
                                  EipUint8 *buffer,
                                  size_t length,
-                                 int *remaining_bytes,
+                                 int *number_of_remaining_bytes,
                                  struct sockaddr *originator_address,
                                  ENIPMessage *const outgoing_message);
 
@@ -458,9 +454,11 @@ int HandleReceivedExplictTcpData(int socket,
  * @param buffer_length length of the data in buffer.
  * @param number_of_remaining_bytes return how many bytes of the input are left
  * over after we're done here
+ * @param unicast Was the data receieved from a multicast address
+ * @param outgoing_message Outgoing ENIP message
  * @return length of reply that need to be sent back
  */
-int HandleReceivedExplictUdpData(const int socket,
+int HandleReceivedExplictUdpData(const int socket_handle,
                                  const struct sockaddr_in *from_address,
                                  const EipUint8 *buffer,
                                  const size_t buffer_length,
@@ -490,8 +488,11 @@ HandleReceivedConnectedData(const EipUint8 *const received_data,
  * WatchdogTimeout) have timed out.
  *
  * If the a timeout occurs the function performs the necessary action. This
- * function should be called periodically once every OPENER_TIMER_TICK
- * milliseconds.
+ * function should be called periodically once every @ref kOpenerTimerTickInMilliSeconds
+ * milliseconds. In order to simplify the algorithm if more time was lapsed, the elapsed
+ * time since the last call of the function is given as a parameter.
+ *
+ * @param elapsed_time Elapsed time in milliseconds since the last call of ManageConnections
  *
  * @return EIP_OK on success
  */
@@ -529,7 +530,7 @@ TriggerConnections(unsigned int output_assembly_id,
  * the encapsulation layer.
  * @param socket_handle the handler to the socket of the closed connection
  */
-void CloseSession(int socket);
+void CloseSession(int socket_handle);
 
 /**  @defgroup CIP_CALLBACK_API Callback Functions Demanded by OpENer
  * @ingroup CIP_API
@@ -664,7 +665,7 @@ void RunIdleChanged(EipUint32 run_idle_value);
 /** @ingroup CIP_CALLBACK_API
  * @brief create a producing or consuming UDP socket
  *
- * @param communication_direction PRODCUER or CONSUMER
+ * @param communication_direction kUdpCommunicationDirectionProducing or kUdpCommunicationDirectionConsuming
  * @param socket_data pointer to the address holding structure
  *     Attention: For producing point-to-point connection the
  *     *pa_pstAddr->sin_addr.s_addr member is set to 0 by OpENer. The network
@@ -674,6 +675,7 @@ void RunIdleChanged(EipUint32 run_idle_value);
  * pa_pstAddr->sin_addr.s_addr to the correct address of the originator.
  * FIXME add an additional parameter that can be used by the CIP stack to
  * request the originators sockaddr_in data.
+ * @param qos_for_socket CIP QoS object parameter value
  * @return socket identifier on success
  *         -1 on error
  */
@@ -682,17 +684,17 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
                     CipUsint qos_for_socket);
 
 /** @ingroup CIP_CALLBACK_API
- * @brief create a producing or consuming UDP socket
+ * @brief Create a producing or consuming UDP socket
  *
- * @param socket_data pointer to the "send to" address
- * @param socket_handle socket descriptor to send on
- * @param data pointer to the data to send
- * @param data_length length of the data to send
- * @return  EIP_SUCCESS on success
+ * @param socket_data Pointer to the "send to" address
+ * @param socket_handle Socket descriptor to send on
+ * @param data Pointer to the data to send
+ * @param data_length Length of the data to send
+ * @return kEipStatusOk on success
  */
 EipStatus
 SendUdpData(struct sockaddr_in *socket_data,
-            int socket,
+            int socket_handle,
             EipUint8 *data,
             EipUint16 data_length);
 
@@ -701,7 +703,7 @@ SendUdpData(struct sockaddr_in *socket_data,
  *
  * @param socket_handle socket descriptor to close
  */
-void CloseSocket(const int socket);
+void CloseSocket(const int socket_handle);
 
 /** @mainpage OpENer - Open Source EtherNet/IP(TM) Communication Stack
  * Documentation
@@ -759,11 +761,11 @@ void CloseSocket(const int socket);
  * @section gen_config_section General Stack Configuration
  * The general stack properties have to be defined prior to building your
  * production. This is done by providing a file called opener_user_conf.h. An
- * example file can be found in the src/ports/platform-pc directory. The
- * documentation of the example file for the necessary configuration options:
+ * example file can be found in the src/ports/POSIX or src/ports/WIN32 directory.
+ * The documentation of the example file for the necessary configuration options:
  * opener_user_conf.h
  *
- * @copydoc opener_user_conf.h
+ * @copydoc ./ports/POSIX/sample_application/opener_user_conf.h
  *
  * @section startup_sec Startup Sequence
  * During startup of your EtherNet/IP(TM) device the following steps have to be
@@ -843,7 +845,7 @@ void CloseSocket(const int socket);
  *      .
  *   - Cyclically update the connection status:\n
  *     In order that OpENer can determine when to produce new data on
- *     connections or that a connection timed out every @ref OPENER_TIMER_TICK
+ *     connections or that a connection timed out every @ref kOpenerTimerTickInMilliSeconds
  * milliseconds the
  *     function EIP_STATUS ManageConnections(void) has to be called.
  *
@@ -880,7 +882,7 @@ void CloseSocket(const int socket);
  * guarding conditions for using OpENer in own products. For this please look
  * in license text as shown below:
  *
- * @include "license.txt"
+ * @include "../license.txt"
  *
  */
 

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

@@ -19,7 +19,7 @@ MicroSeconds GetMicroSeconds(void) {
   struct timespec now = { .tv_nsec = 0, .tv_sec = 0 };
 
   int error = clock_gettime( CLOCK_MONOTONIC, &now );
-  OPENER_ASSERT(-1 != error);
+  OPENER_ASSERT(-1 != error)
   MicroSeconds micro_seconds =  (MicroSeconds)now.tv_nsec / 1000ULL +
                                now.tv_sec * 1000000ULL;
   return micro_seconds;
@@ -55,7 +55,6 @@ int SetSocketToNonBlocking(int socket_handle) {
 
 int SetQosOnSocket(const int socket,
                    CipUsint qos_value) {
-
   int set_tos = qos_value;
   return setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos) );
 }

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

@@ -4,7 +4,7 @@
  *
  ******************************************************************************/
 
-/** @file opener_error.c
+/** @file POSIX/opener_error.c
  *  @author Martin Melik Merkumians
  *  @brief This file includes the prototypes for error resolution functions like strerror or WSAGetLastError
  *

+ 2 - 2
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -6,7 +6,7 @@
 #ifndef OPENER_USER_CONF_H_
 #define OPENER_USER_CONF_H_
 
-/** @file opener_user_conf.h
+/** @file POSIX/sample_application/opener_user_conf.h
  * @brief OpENer configuration setup
  *
  * This file contains the general application specific configuration for OpENer.
@@ -127,7 +127,7 @@ static const int kOpenerProducedDataHasRunIdleHeader = 0;
 //#include <stdio.h>
 //#define OPENER_ASSERT(assertion) assert(assertion)
 #else
-#define OPENER_ASSERT(assertion) assert(assertion)
+#define OPENER_ASSERT(assertion) assert(assertion);
 #endif
 #else
 

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

@@ -4,7 +4,7 @@
  *
  ******************************************************************************/
 
-/** @file opener_error.c
+/** @file WIN32/opener_error.c
  *  @author Martin Melik Merkumians
  *  @brief This file includes the prototypes for error resolution functions like strerror or WSAGetLastError
  *

+ 1 - 1
source/src/ports/WIN32/sample_application/opener_user_conf.h

@@ -6,7 +6,7 @@
 #ifndef OPENER_USER_CONF_H_
 #define OPENER_USER_CONF_H_
 
-/** @file
+/** @file WIN32/sample_application/opener_user_conf.h
  * @brief OpENer configuration setup
  *
  * This file contains the general application specific configuration for OpENer.

+ 20 - 11
source/src/ports/generic_networkhandler.c

@@ -330,7 +330,7 @@ void CheckAndHandleTcpListenerSocket(void) {
 //                        g_timestamps[i].last_update);
 //    }
 
-    OPENER_ASSERT(socket_timer != NULL);
+    OPENER_ASSERT(socket_timer != NULL)
 
     FD_SET(new_socket, &master_socket);
     /* add newfd to master set */
@@ -405,7 +405,7 @@ EipStatus NetworkHandlerProcessOnce(void) {
   g_last_time = g_actual_time;
   //OPENER_TRACE_INFO("Elapsed time: %u\n", g_network_status.elapsed_time);
 
-  /* check if we had been not able to update the connection manager for several OPENER_TIMER_TICK.
+  /* check if we had been not able to update the connection manager for several kOpenerTimerTickInMilliSeconds.
    * This should compensate the jitter of the windows timer
    */
   if (g_network_status.elapsed_time >= kOpenerTimerTickInMilliSeconds) {
@@ -550,7 +550,7 @@ void CheckAndHandleUdpUnicastSocket(void) {
 }
 
 EipStatus SendUdpData(struct sockaddr_in *address,
-                      int socket,
+                      int socket_handle,
                       EipUint8 *data,
                       EipUint16 data_length) {
 
@@ -566,12 +566,21 @@ EipStatus SendUdpData(struct sockaddr_in *address,
 
   char complete_message[data_length + kUpdHeaderLength];
   memcpy(complete_message + kUpdHeaderLength, data, data_length);
-  UDPHeaderGenerate(&header, (char*)complete_message);
-  UDPHeaderSetChecksum(&header, htons(UDPHeaderCalculateChecksum(complete_message, 8+data_length, interface_configuration_.ip_address, address->sin_addr.s_addr)));
-  UDPHeaderGenerate(&header, (char*)complete_message);
-
-  int sent_length = sendto( socket, (char *) complete_message, data_length + kUpdHeaderLength, 0,
-                            (struct sockaddr *) address, sizeof(*address) );
+  UDPHeaderGenerate(&header, (char *)complete_message);
+  UDPHeaderSetChecksum(&header,
+                       htons(UDPHeaderCalculateChecksum(complete_message,
+                                                        8 + data_length,
+                                                        interface_configuration_
+                                                        .ip_address,
+                                                        address->sin_addr.s_addr) ) );
+  UDPHeaderGenerate(&header, (char *)complete_message);
+
+  int sent_length = sendto( socket,
+                            (char *) complete_message,
+                            data_length + kUpdHeaderLength,
+                            0,
+                            (struct sockaddr *) address,
+                            sizeof(*address) );
 
   if (sent_length < 0) {
     int error_code = GetSocketErrorNumber();
@@ -792,7 +801,7 @@ EipStatus HandleDataOnTcpSocket(int socket) {
 
 /** @brief create a new UDP socket for the connection manager
  *
- * @param communciation_direction Consuming or producing port
+ * @param communication_direction Consuming or producing port
  * @param socket_data Data for socket creation
  *
  * @return the socket handle if successful, else kEipInvalidSocket */
@@ -826,7 +835,7 @@ int CreateUdpSocket(UdpCommuncationDirection communication_direction,
     OPENER_TRACE_ERR(
       "error setting socket to non-blocking on new socket\n");
     CloseSocket(new_socket);
-    OPENER_ASSERT(false); /* This should never happen! */
+    OPENER_ASSERT(false) /* This should never happen! */
     return kEipStatusError;
   }
 

+ 1 - 1
source/src/ports/socket_timer.h

@@ -22,7 +22,7 @@ typedef struct socket_timer {
  * Sets socket of a Socket Timer
  *
  * @param socket_timer Socket Timer to be set
- * @param Socket value
+ * @param socket Socket handle
  */
 void SocketTimerSetSocket(SocketTimer *const socket_timer,
                           const int socket);

+ 9 - 9
source/src/utils/doublylinkedlist.c

@@ -42,15 +42,15 @@ DoublyLinkedListNode *DoublyLinkedListNodeCreate(
 
 void DoublyLinkedListNodeDestroy(const DoublyLinkedList *const list,
                                  DoublyLinkedListNode **node) {
-  OPENER_ASSERT(list->deallocator != NULL);
+  OPENER_ASSERT(list->deallocator != NULL)
   list->deallocator(node);
 }
 
 void DoublyLinkedListInsertAtHead(DoublyLinkedList *const list,
                                   void *data) {
-  OPENER_ASSERT(list->allocator != NULL);
-  DoublyLinkedListNode *new_node = DoublyLinkedListNodeCreate(data,
-                                                              list->allocator);
+  OPENER_ASSERT(list->allocator != NULL)
+  DoublyLinkedListNode * new_node = DoublyLinkedListNodeCreate(data,
+                                                               list->allocator);
   if(NULL == list->first) {
     list->first = new_node;
     list->last = new_node;
@@ -63,9 +63,9 @@ void DoublyLinkedListInsertAtHead(DoublyLinkedList *const list,
 
 void DoublyLinkedListInsertAtTail(DoublyLinkedList *const list,
                                   const void *const data) {
-  OPENER_ASSERT(list->allocator != NULL);
-  DoublyLinkedListNode *new_node = DoublyLinkedListNodeCreate(data,
-                                                              list->allocator);
+  OPENER_ASSERT(list->allocator != NULL)
+  DoublyLinkedListNode * new_node = DoublyLinkedListNodeCreate(data,
+                                                               list->allocator);
   if(NULL == list->last) {
     list->first = new_node;
     list->last = new_node;
@@ -79,7 +79,7 @@ void DoublyLinkedListInsertAtTail(DoublyLinkedList *const list,
 void DoublyLinkedListInsertBeforeNode(DoublyLinkedList *const list,
                                       DoublyLinkedListNode *node,
                                       void *data) {
-  OPENER_ASSERT(list->allocator != NULL);
+  OPENER_ASSERT(list->allocator != NULL)
   if(list->first == node) {
     DoublyLinkedListInsertAtHead(list, data);
   } else {
@@ -95,7 +95,7 @@ void DoublyLinkedListInsertBeforeNode(DoublyLinkedList *const list,
 void DoublyLinkedListInsertAfterNode(DoublyLinkedList *const list,
                                      DoublyLinkedListNode *node,
                                      void *data) {
-  OPENER_ASSERT(list->allocator != NULL);
+  OPENER_ASSERT(list->allocator != NULL)
   if(list->last == node) {
     DoublyLinkedListInsertAtTail(list, data);
   } else {

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

@@ -8,7 +8,7 @@
 #define SRC_UTILS_DOUBLYLINKEDLIST_H_
 
 /**
- * @file doublelinkedlist.h
+ * @file doublylinkedlist.h
  *
  * The public interface for a reference type doubly linked list
  */