ソースを参照

Uncrustify

Signed-off-by: Martin Melik Merkumians <melik-merkumians@acin.tuwien.ac.at>
Martin Melik Merkumians 5 年 前
コミット
b653452272

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

@@ -295,7 +295,8 @@ CipConnectionObject *GetListenOnlyConnection(
 
       /* Here we look for both Point-to-Point and Multicast IO connections */
       if ( NULL == GetExistingProducerIoConnection(false,
-             connection_object->produced_path.instance_id) )
+                                                   connection_object->
+                                                   produced_path.instance_id) )
       {
         *extended_error =
           kConnectionManagerExtendedStatusCodeNonListenOnlyConnectionNotOpened;

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

@@ -174,7 +174,7 @@ void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier,
       port_identifier < 16,
       "Port identifier too large for standard port identifier field\n"); */
   OPENER_ASSERT(port_identifier < 16);
-    (*cip_path) |= port_identifier;
+  (*cip_path) |= port_identifier;
 }
 
 unsigned int GetPathPortSegmentLinkAddressSize(
@@ -449,7 +449,7 @@ void GetElectronicKeyFormat4FromMessage(
   OPENER_ASSERT( kElectronicKeySegmentFormatKeyFormat4 ==
                  GetPathLogicalSegmentElectronicKeyFormat(*message) );
 
-    (*message) += 2;
+  (*message) += 2;
   ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(message) );
   ElectronicKeyFormat4SetDeviceType(key, GetIntFromMessage(message) );
   ElectronicKeyFormat4SetProductCode(key, GetIntFromMessage(message) );

+ 30 - 28
source/src/cip/cipethernetlink.h

@@ -23,7 +23,7 @@ static const CipUint kCipEthernetLinkClassCode = CIP_ETHERNETLINK_CLASS_CODE;
 /** @brief Provide values for the Interface Flags (attribute #2) */
 typedef enum {
   /** Set this bit if your device needs a reset to take over new settings made via
-    * attribute #6. It is duplicates the meaning of kEthLinkCapManualReset */
+   * attribute #6. It is duplicates the meaning of kEthLinkCapManualReset */
   kEthLinkFlagsManualReset = 0x20,
 } CipEthLinkIfaceFlags;
 
@@ -35,7 +35,8 @@ typedef enum {
    *  Half-Duplex mode is forced. */
   kEthLinkIfCntrlForceDuplexFD = 0x02,
   /** For convenience declare the sum of valid bits as the maximum allowed value. */
-  kEthLinkIfCntrlMaxValid = kEthLinkIfCntrlAutonegotiate + kEthLinkIfCntrlForceDuplexFD,
+  kEthLinkIfCntrlMaxValid = kEthLinkIfCntrlAutonegotiate +
+                            kEthLinkIfCntrlForceDuplexFD,
 } CipEthLinkIfaceControl;
 
 /** @brief Provide values for the Interface Type (attribute #7) */
@@ -104,19 +105,19 @@ typedef struct {
  *  Media Counters attribute is required for DLR capable devices.
  */
 typedef union {
-  CipUdint  cntr32[11];
+  CipUdint cntr32[11];
   struct {
-    CipUdint  in_octets;
-    CipUdint  in_ucast;
-    CipUdint  in_nucast;
-    CipUdint  in_discards;
-    CipUdint  in_errors;
-    CipUdint  in_unknown_protos;
-    CipUdint  out_octets;
-    CipUdint  out_ucast;
-    CipUdint  out_nucast;
-    CipUdint  out_discards;
-    CipUdint  out_errors;
+    CipUdint in_octets;
+    CipUdint in_ucast;
+    CipUdint in_nucast;
+    CipUdint in_discards;
+    CipUdint in_errors;
+    CipUdint in_unknown_protos;
+    CipUdint out_octets;
+    CipUdint out_ucast;
+    CipUdint out_nucast;
+    CipUdint out_discards;
+    CipUdint out_errors;
   } ul;
 } CipEthernetLinkInterfaceCounters;
 
@@ -127,20 +128,20 @@ typedef union {
  *  HC Media Counters attribute is implemented, otherwise highly recommended.
  */
 typedef union {
-  CipUdint  cntr32[12];
+  CipUdint cntr32[12];
   struct {
-    CipUdint  align_errs;
-    CipUdint  fcs_errs;
-    CipUdint  single_coll;
-    CipUdint  multi_coll;
-    CipUdint  sqe_test_errs;
-    CipUdint  def_trans;
-    CipUdint  late_coll;
-    CipUdint  exc_coll;
-    CipUdint  mac_tx_errs;
-    CipUdint  crs_errs;
-    CipUdint  frame_too_long;
-    CipUdint  mac_rx_errs;
+    CipUdint align_errs;
+    CipUdint fcs_errs;
+    CipUdint single_coll;
+    CipUdint multi_coll;
+    CipUdint sqe_test_errs;
+    CipUdint def_trans;
+    CipUdint late_coll;
+    CipUdint exc_coll;
+    CipUdint mac_tx_errs;
+    CipUdint crs_errs;
+    CipUdint frame_too_long;
+    CipUdint mac_rx_errs;
   } ul;
 } CipEthernetLinkMediaCounters;
 #endif  /* ... && OPENER_ETHLINK_CNTRS_ENABLE != 0 */
@@ -162,7 +163,8 @@ typedef struct {
   CipEthernetLinkInterfaceCounters interface_cntrs; /**< Attribute #4: Interface counters 32-bit wide */
   CipEthernetLinkMediaCounters media_cntrs; /**< Attribute #5: Media counters 32-bit wide */
 #endif
-#if defined(OPENER_ETHLINK_IFACE_CTRL_ENABLE) && 0 != OPENER_ETHLINK_IFACE_CTRL_ENABLE
+#if defined(OPENER_ETHLINK_IFACE_CTRL_ENABLE) && \
+  0 != OPENER_ETHLINK_IFACE_CTRL_ENABLE
   CipEthernetLinkInterfaceControl interface_control;  /** Attribute #6: control link properties */
 #endif
   CipUsint interface_type;  /**< Attribute #7: Type of interface */

+ 11 - 7
source/src/cip/ciptcpipinterface.c

@@ -20,7 +20,7 @@
 #include "cipassembly.h"
 
 /* Define constants to initialize the config_capability attribute (#2). These
-*   are needed as defines because we use them for static initialization. */
+ *   are needed as defines because we use them for static initialization. */
 #define CFG_CAPS_BOOTP_CLIENT         0x01U /**< Device has BOOTP client */
 #define CFG_CAPS_DNS_CLIENT           0x02U /**< Device has DNS client */
 #define CFG_CAPS_DHCP_CLIENT          0x04U /**< Device has DHCP client */
@@ -295,7 +295,8 @@ static bool IsIOConnectionActive(void) {
   while (NULL != node) {
     CipConnectionObject *connection = node->data;
     if (ConnectionObjectIsTypeIOConnection(connection) &&
-        kConnectionObjectStateTimedOut != ConnectionObjectGetState(connection)) {
+        kConnectionObjectStateTimedOut !=
+        ConnectionObjectGetState(connection) ) {
       /* An IO connection is present but is only considered active
        *  if it is NOT in timeout state. */
       return true;
@@ -420,12 +421,15 @@ EipStatus SetAttributeSingleTcpIpInterface(
           CipTcpIpInterfaceConfiguration if_cfg;
           CipUdint tmp_ip;
 
-          if (IsIOConnectionActive()) {
-            message_router_response->general_status = kCipErrorDeviceStateConflict;
+          if (IsIOConnectionActive() ) {
+            message_router_response->general_status =
+              kCipErrorDeviceStateConflict;
             break;
           }
-          if (kTcpipCfgCtrlStaticIp != (g_tcpip.config_control & kTcpipCfgCtrlMethodMask)) {
-            message_router_response->general_status = kCipErrorObjectStateConflict;
+          if (kTcpipCfgCtrlStaticIp !=
+              (g_tcpip.config_control & kTcpipCfgCtrlMethodMask) ) {
+            message_router_response->general_status =
+              kCipErrorObjectStateConflict;
             break;
           }
           memset(&if_cfg, 0, sizeof if_cfg);
@@ -699,7 +703,7 @@ void CipTcpIpCalculateMulticastIp(CipTcpIpObject *const tcpip) {
 EipUint16 GetEncapsulationInactivityTimeout(CipInstance *instance) {
   CipAttributeStruct *attribute = GetCipAttribute(instance, 13);
   OPENER_ASSERT(NULL != attribute);
-  CipUint * data = (CipUint *) attribute->data;
+  CipUint *data = (CipUint *) attribute->data;
   EipUint16 encapsulation_inactivity_timeout = *data;
   return encapsulation_inactivity_timeout;
 }

+ 1 - 1
source/src/enet_encap/cpf.c

@@ -443,7 +443,7 @@ void EncodeSequenceNumber(
   const CipCommonPacketFormatData *const common_packet_format_data_item,
   ENIPMessage *const outgoing_message) {
   AddIntToMessage(
-     (EipUint16) common_packet_format_data_item->address_item.data.sequence_number,
+    (EipUint16) common_packet_format_data_item->address_item.data.sequence_number,
     outgoing_message );
 }
 

+ 7 - 2
source/src/ports/MINGW/networkhandler.c

@@ -38,7 +38,8 @@ EipStatus NetworkHandlerInitializePlatform(void) {
 }
 
 void ShutdownSocketPlatform(int socket_handle) {
-#warning "Untested. Is a shutdown() needed under Windows like for the POSIX port?"
+#warning \
+  "Untested. Is a shutdown() needed under Windows like for the POSIX port?"
 }
 
 void CloseSocketPlatform(int socket_handle) {
@@ -56,5 +57,9 @@ int SetQosOnSocket(int socket,
    *  Note that the DSCP value, if placed directly in the ToS field
    *  in the IP header, must be shifted left 2 bits. */
   DWORD set_tos = qos_value << 2;
-  return setsockopt(socket, IPPROTO_IP, IP_TOS, (char *)&set_tos, sizeof(set_tos) );
+  return setsockopt(socket,
+                    IPPROTO_IP,
+                    IP_TOS,
+                    (char *)&set_tos,
+                    sizeof(set_tos) );
 }

+ 26 - 26
source/src/ports/MINGW/sample_application/opener_user_conf.h

@@ -40,7 +40,7 @@ typedef unsigned short in_port_t;
 #endif
 
 #if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-  /* Enable all the stuff the DLR device depends on */
+/* Enable all the stuff the DLR device depends on */
   #define OPENER_TCPIP_IFACE_CFG_SETTABLE 1
   #define OPENER_ETHLINK_CNTRS_ENABLE     1
   #define OPENER_ETHLINK_IFACE_CTRL_ENABLE  1
@@ -160,50 +160,50 @@ typedef unsigned short in_port_t;
 static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
 
 #ifdef OPENER_WITH_TRACES
-    /* If we have tracing enabled provide LOG_TRACE macro */
+/* If we have tracing enabled provide LOG_TRACE macro */
     #include <stdio.h>
 
     #define LOG_TRACE(...)  fprintf(stderr,__VA_ARGS__)
 
      #ifdef IDLING_ASSERT
-        /** @brief A specialized assertion command enabled by IDLING_ASSERT that
-         *  will log the assertion and block further
-         *  execution in a while(1) loop.
-         */
+/** @brief A specialized assertion command enabled by IDLING_ASSERT that
+ *  will log the assertion and block further
+ *  execution in a while(1) loop.
+ */
         #define OPENER_ASSERT(assertion)                                    \
-          do {                                                              \
-            if( !(assertion) ) {                                            \
-              LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n",  \
-                        # assertion, __FILE__, __LINE__);                   \
-              while(1) {  }                                                 \
-            }                                                               \
-          } while(0)
+  do {                                                              \
+    if( !(assertion) ) {                                            \
+      LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n",  \
+                # assertion, __FILE__, __LINE__);                   \
+      while(1) {  }                                                 \
+    }                                                               \
+  } while(0)
 
     #else   /* ifdef IDLING_ASSERT */
-        /* Use standard assert() that vanishes only for release builds. */
+/* Use standard assert() that vanishes only for release builds. */
         #define OPENER_ASSERT(assertion) assert(assertion)
     #endif  /* ifdef IDLING_ASSERT */
 
 #else   /* ifdef OPENER_WITH_TRACES */
-    /* Select one of the OPENER_ASSERT() variants below if trace support is off */
+/* Select one of the OPENER_ASSERT() variants below if trace support is off */
     #if 0
-        /* If there are any strange timing issues, you can try the version below,
-         *  where the assertion is performed but the assert function is not used.
-         *  This may result in "statement with no effect" warnings.
-         */
+/* If there are any strange timing issues, you can try the version below,
+ *  where the assertion is performed but the assert function is not used.
+ *  This may result in "statement with no effect" warnings.
+ */
         #define OPENER_ASSERT(assertion) (assertion)
     #elif 0
-    /* If you still want assertions to stop execution but without tracing,
-     *  use the following */
+/* If you still want assertions to stop execution but without tracing,
+ *  use the following */
         #define OPENER_ASSERT(assertion)                    \
-          do { if(!(assertion)) { while(1) {} } } while (0)
+  do { if(!(assertion) ) { while(1) {} } } while (0)
     #elif 0
-        /* Even for debug builds remove assertion. May solicit unused variable
-         *  warnings. */
+/* Even for debug builds remove assertion. May solicit unused variable
+ *  warnings. */
         #define OPENER_ASSERT(assertion)
     #else
-        /* By default use standard assert() that vanishes only
-         *  for release builds. */
+/* By default use standard assert() that vanishes only
+ *  for release builds. */
         #define OPENER_ASSERT(assertion) assert(assertion)
     #endif
 

+ 104 - 82
source/src/ports/WIN32/networkconfig.c

@@ -49,21 +49,20 @@
  *  string if possible. On conversion success @p errno is set to zero.
  *  On failure @p errno is set to ERANGE or EINVAL.
  */
-static ULONG StrToIfaceIdx(const char *iface)
-{
-    ULONG iface_idx;
-    char  *end;
-    /* The input string is a decimal interface index number or an
-     *  interface name. */
-    errno = 0;  /* To distinguish success / failure later */
-    iface_idx = strtoul(iface, &end, 10);
-    /* overflow is signaled by (errno == ERANGE) */
-
-    if ((iface == end) ||   /* No digits were found */
-        ('\0' != *end)) {   /* More characters after number */
-        errno = EINVAL;     /* Signal conversion failure */
-    }
-    return iface_idx;
+static ULONG StrToIfaceIdx(const char *iface) {
+  ULONG iface_idx;
+  char  *end;
+  /* The input string is a decimal interface index number or an
+   *  interface name. */
+  errno = 0;    /* To distinguish success / failure later */
+  iface_idx = strtoul(iface, &end, 10);
+  /* overflow is signaled by (errno == ERANGE) */
+
+  if ( (iface == end) ||    /* No digits were found */
+       ('\0' != *end) ) {   /* More characters after number */
+    errno = EINVAL;         /* Signal conversion failure */
+  }
+  return iface_idx;
 }
 
 /** @brief Derive the interface index from a given interface alias name string
@@ -81,29 +80,29 @@ static ULONG StrToIfaceIdx(const char *iface)
  * The LUID can then be used to retrieve the interface index needed for the
  *  other functions by calling ConvertInterfaceLuidToIndex().
  */
-static DWORD ConvertToIndexFromFakeAlias(const char *iface, PNET_IFINDEX iface_idx)
-{
-    WCHAR       *p_if_alias;
-    NET_LUID    if_luid;
-
-    size_t mbtowc_rc = mbstowcs(NULL, iface, 0);
-    if ((size_t)-1 == mbtowc_rc) {  /* Invalid byte sequence encountered */
-        return ERROR_NO_UNICODE_TRANSLATION;
-    }
+static DWORD ConvertToIndexFromFakeAlias(const char *iface,
+                                         PNET_IFINDEX iface_idx) {
+  WCHAR       *p_if_alias;
+  NET_LUID if_luid;
 
-    size_t wc_cnt = mbtowc_rc+1U; /* +1U for nul character */
-    p_if_alias = MALLOC(sizeof(WCHAR) * wc_cnt);
-    if (NULL == p_if_alias) {
-        return ERROR_OUTOFMEMORY;
-    }
+  size_t mbtowc_rc = mbstowcs(NULL, iface, 0);
+  if ( (size_t)-1 == mbtowc_rc ) {  /* Invalid byte sequence encountered */
+    return ERROR_NO_UNICODE_TRANSLATION;
+  }
 
-    (void) mbstowcs(p_if_alias, iface, wc_cnt);
-    DWORD cnv_status = ConvertInterfaceAliasToLuid(p_if_alias, &if_luid);
-    if (NETIO_SUCCESS(cnv_status)) {
-        cnv_status = ConvertInterfaceLuidToIndex(&if_luid, iface_idx);
-    }
-    FREE(p_if_alias);
-    return cnv_status;
+  size_t wc_cnt = mbtowc_rc + 1U; /* +1U for nul character */
+  p_if_alias = MALLOC(sizeof(WCHAR) * wc_cnt);
+  if (NULL == p_if_alias) {
+    return ERROR_OUTOFMEMORY;
+  }
+
+  (void) mbstowcs(p_if_alias, iface, wc_cnt);
+  DWORD cnv_status = ConvertInterfaceAliasToLuid(p_if_alias, &if_luid);
+  if (NETIO_SUCCESS(cnv_status) ) {
+    cnv_status = ConvertInterfaceLuidToIndex(&if_luid, iface_idx);
+  }
+  FREE(p_if_alias);
+  return cnv_status;
 }
 
 /** @brief Determines the interface index number from string input
@@ -122,8 +121,8 @@ static DWORD ConvertToIndexFromFakeAlias(const char *iface, PNET_IFINDEX iface_i
  *  alias name. This function then in turn calls ConvertToIndexFromFakeAlias()
  *  to find an interface matching that alias.
  */
-static EipStatus DetermineIfaceIndexByString(const char *iface, PNET_IFINDEX iface_idx)
-{
+static EipStatus DetermineIfaceIndexByString(const char *iface,
+                                             PNET_IFINDEX iface_idx) {
   *iface_idx = StrToIfaceIdx(iface);
 
   BOOL arg_is_numerical = (0 == errno);
@@ -131,8 +130,10 @@ static EipStatus DetermineIfaceIndexByString(const char *iface, PNET_IFINDEX ifa
     DWORD cnv_status = ConvertToIndexFromFakeAlias(iface, iface_idx);
     if (NO_ERROR != cnv_status) {
       char *error_message = GetErrorMessage(cnv_status);
-      OPENER_TRACE_ERR("ConvertToIndexFromFakeAlias() failed: %" PRIDW " - %s\n",
-                       cnv_status, error_message);
+      OPENER_TRACE_ERR(
+        "ConvertToIndexFromFakeAlias() failed: %" PRIDW " - %s\n",
+        cnv_status,
+        error_message);
       FreeErrorMessage(error_message);
       return kEipStatusError;
     }
@@ -154,7 +155,8 @@ static EipStatus DetermineIfaceIndexByString(const char *iface, PNET_IFINDEX ifa
  *  which information to include and what information to exclude from the
  *  result.
  */
-EipStatus RetrieveAdapterAddressesTable(ULONG flags, PIP_ADAPTER_ADDRESSES *pp_addr_table) {
+EipStatus RetrieveAdapterAddressesTable(ULONG flags,
+                                        PIP_ADAPTER_ADDRESSES *pp_addr_table) {
   PIP_ADAPTER_ADDRESSES p_addr_table;
   ULONG ret_val;
   /* Start allocating with a guessed minimum size. */
@@ -162,10 +164,15 @@ EipStatus RetrieveAdapterAddressesTable(ULONG flags, PIP_ADAPTER_ADDRESSES *pp_a
   do {
     p_addr_table = (PIP_ADAPTER_ADDRESSES)MALLOC(outBufLen);
     if (NULL == p_addr_table) {
-      OPENER_TRACE_ERR("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
+      OPENER_TRACE_ERR(
+        "Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
       return kEipStatusError;
     }
-    ret_val = GetAdaptersAddresses(AF_INET, flags, NULL, p_addr_table, &outBufLen);
+    ret_val = GetAdaptersAddresses(AF_INET,
+                                   flags,
+                                   NULL,
+                                   p_addr_table,
+                                   &outBufLen);
 
     if (ERROR_BUFFER_OVERFLOW == ret_val) {
       FREE(p_addr_table);
@@ -212,7 +219,7 @@ static DWORD WideToCipString(const WCHAR *const src,
    *    the nul terminator.
    */
   const size_t num_chars = wcstombs(NULL, src, 0);
-  if ((size_t)-1 == num_chars) {
+  if ( (size_t)-1 == num_chars ) {
     return ERROR_NO_UNICODE_TRANSLATION;
   }
   if (num_chars >= UINT16_MAX) {
@@ -250,7 +257,7 @@ static DWORD WideToCipString(const WCHAR *const src,
  *  @return                 IPv4 address taken from @p socket_address
  */
 static CipUdint GetIpFromSocketAddress(const SOCKET_ADDRESS *socket_address) {
-  SOCKADDR_IN *sin = ((SOCKADDR_IN*)socket_address->lpSockaddr);
+  SOCKADDR_IN *sin = ( (SOCKADDR_IN *)socket_address->lpSockaddr );
   return sin->sin_addr.S_un.S_addr;
 }
 
@@ -258,10 +265,11 @@ static CipUdint GetIpFromSocketAddress(const SOCKET_ADDRESS *socket_address) {
 /* ---------- Public functions implementation ---------- */
 
 /* For Doxygen descriptions see opener_api.h. */
-EipStatus IfaceGetMacAddress(const char *iface, uint8_t *physical_address) {
-  ULONG  iface_idx;
+EipStatus IfaceGetMacAddress(const char *iface,
+                             uint8_t *physical_address) {
+  ULONG iface_idx;
 
-  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx)) {
+  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx) ) {
     return kEipStatusError;
   }
 
@@ -270,7 +278,7 @@ EipStatus IfaceGetMacAddress(const char *iface, uint8_t *physical_address) {
                       GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER |
                       GAA_FLAG_SKIP_FRIENDLY_NAME;
   PIP_ADAPTER_ADDRESSES p_addr_table = NULL;
-  if (kEipStatusOk != RetrieveAdapterAddressesTable(flags, &p_addr_table)) {
+  if (kEipStatusOk != RetrieveAdapterAddressesTable(flags, &p_addr_table) ) {
     return kEipStatusError;
   }
 
@@ -280,12 +288,17 @@ EipStatus IfaceGetMacAddress(const char *iface, uint8_t *physical_address) {
     if (iface_idx == p_addr_entry->IfIndex) {
       /* Get MAC address from matched interface */
       OPENER_TRACE_INFO("MAC address: %02" PRIX8 "-%02" PRIX8 "-%02" PRIX8
-                                    "-%02" PRIX8 "-%02" PRIX8 "-%02" PRIX8 "\n",
-        p_addr_entry->PhysicalAddress[0], p_addr_entry->PhysicalAddress[1],
-        p_addr_entry->PhysicalAddress[2], p_addr_entry->PhysicalAddress[3],
-        p_addr_entry->PhysicalAddress[4], p_addr_entry->PhysicalAddress[5]);
-        memcpy_s(physical_address, 6,
-                p_addr_entry->PhysicalAddress, p_addr_entry->PhysicalAddressLength);
+                        "-%02" PRIX8 "-%02" PRIX8 "-%02" PRIX8 "\n",
+                        p_addr_entry->PhysicalAddress[0],
+                        p_addr_entry->PhysicalAddress[1],
+                        p_addr_entry->PhysicalAddress[2],
+                        p_addr_entry->PhysicalAddress[3],
+                        p_addr_entry->PhysicalAddress[4],
+                        p_addr_entry->PhysicalAddress[5]);
+      memcpy_s(physical_address,
+               6,
+               p_addr_entry->PhysicalAddress,
+               p_addr_entry->PhysicalAddressLength);
       break;  /* leave search after iface_idx match */
     }
     p_addr_entry = p_addr_entry->Next;
@@ -298,11 +311,10 @@ EipStatus IfaceGetMacAddress(const char *iface, uint8_t *physical_address) {
 
 /* For Doxygen descriptions see opener_api.h. */
 EipStatus IfaceGetConfiguration(const char *iface,
-                                CipTcpIpInterfaceConfiguration *iface_cfg)
-{
-  ULONG  iface_idx;
+                                CipTcpIpInterfaceConfiguration *iface_cfg) {
+  ULONG iface_idx;
 
-  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx)) {
+  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx) ) {
     return kEipStatusError;
   }
 
@@ -310,7 +322,7 @@ EipStatus IfaceGetConfiguration(const char *iface,
   const ULONG flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
                       GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_PREFIX;
   PIP_ADAPTER_ADDRESSES p_addr_table = NULL;
-  if (kEipStatusOk != RetrieveAdapterAddressesTable(flags, &p_addr_table)) {
+  if (kEipStatusOk != RetrieveAdapterAddressesTable(flags, &p_addr_table) ) {
     return kEipStatusError;
   }
 
@@ -323,13 +335,15 @@ EipStatus IfaceGetConfiguration(const char *iface,
     if (iface_idx == p_addr_entry->IfIndex) {
 
       if (IfOperStatusUp != p_addr_entry->OperStatus) {
-        OPENER_TRACE_ERR("IfaceGetConfiguration(): Interface '%s' is not up.\n", iface);
+        OPENER_TRACE_ERR("IfaceGetConfiguration(): Interface '%s' is not up.\n",
+                         iface);
         FREE(p_addr_table);
         return kEipStatusError;
       }
       /* Extract ip_addr, netmask, gateway, nameserver, nameserver 2, domain ... */
       {
-        PIP_ADAPTER_UNICAST_ADDRESS pUnicast = p_addr_entry->FirstUnicastAddress;
+        PIP_ADAPTER_UNICAST_ADDRESS pUnicast =
+          p_addr_entry->FirstUnicastAddress;
         if (NULL != pUnicast) {
           local_cfg.ip_address = GetIpFromSocketAddress(&pUnicast->Address);
         }
@@ -337,22 +351,26 @@ EipStatus IfaceGetConfiguration(const char *iface,
       {
         PIP_ADAPTER_PREFIX pPrefix = p_addr_entry->FirstPrefix;
         if (NULL != pPrefix) {
-          local_cfg.network_mask = htonl(0xffffffff << (32U - pPrefix->PrefixLength));
+          local_cfg.network_mask =
+            htonl(0xffffffff << (32U - pPrefix->PrefixLength) );
         }
       }
       {
-        PIP_ADAPTER_GATEWAY_ADDRESS pGateway = p_addr_entry->FirstGatewayAddress;
+        PIP_ADAPTER_GATEWAY_ADDRESS pGateway =
+          p_addr_entry->FirstGatewayAddress;
         if (NULL != pGateway) {
           local_cfg.gateway = GetIpFromSocketAddress(&pGateway->Address);
         }
       }
       {
-        IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = p_addr_entry->FirstDnsServerAddress;
+        IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer =
+          p_addr_entry->FirstDnsServerAddress;
         if (NULL != pDnServer) {
           local_cfg.name_server = GetIpFromSocketAddress(&pDnServer->Address);
           pDnServer = pDnServer->Next;
           if (NULL != pDnServer) {
-            local_cfg.name_server_2= GetIpFromSocketAddress(&pDnServer->Address);
+            local_cfg.name_server_2 =
+              GetIpFromSocketAddress(&pDnServer->Address);
           }
         }
       }
@@ -384,21 +402,23 @@ EipStatus IfaceGetConfiguration(const char *iface,
 }
 
 /* For Doxygen descriptions see opener_api.h. */
-EipStatus IfaceWaitForIp(const char *iface, int timeout, volatile int *abort_wait) {
-  ULONG  iface_idx;
+EipStatus IfaceWaitForIp(const char *iface,
+                         int timeout,
+                         volatile int *abort_wait) {
+  ULONG iface_idx;
 
-  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx)) {
+  if(kEipStatusOk != DetermineIfaceIndexByString(iface, &iface_idx) ) {
     return kEipStatusError;
   }
 
   {
-    PMIB_IPADDRTABLE  pmib_ipaddr_table = NULL;
+    PMIB_IPADDRTABLE pmib_ipaddr_table = NULL;
     ULONG addr_table_sz = 0;
     uint32_t ipaddr;
 
 #define WAIT_CYCLE_MS 100
     /* Calculate cycles of SleepEx(WAIT_CYCLE_MS) needed. */
-    timeout *= (1000/WAIT_CYCLE_MS);
+    timeout *= (1000 / WAIT_CYCLE_MS);
     do {
       DWORD dw_ret;
       ipaddr = 0U;
@@ -426,10 +446,11 @@ EipStatus IfaceWaitForIp(const char *iface, int timeout, volatile int *abort_wai
       }
 
       /* Search entry matching the interface index and determine IP address. */
-      for (int i=0; i < (int) pmib_ipaddr_table->dwNumEntries; i++) {
+      for (int i = 0; i < (int) pmib_ipaddr_table->dwNumEntries; i++) {
         if (pmib_ipaddr_table->table[i].dwIndex == iface_idx) {
           if (0 == (pmib_ipaddr_table->table[i].wType &
-                    (MIB_IPADDR_DELETED | MIB_IPADDR_DISCONNECTED | MIB_IPADDR_TRANSIENT))) {
+                    (MIB_IPADDR_DELETED | MIB_IPADDR_DISCONNECTED |
+                     MIB_IPADDR_TRANSIENT) ) ) {
             ipaddr = pmib_ipaddr_table->table[i].dwAddr;
           }
         }
@@ -438,10 +459,12 @@ EipStatus IfaceWaitForIp(const char *iface, int timeout, volatile int *abort_wai
       if (timeout > 0) {
         --timeout;
       }
-    } while ((0 == ipaddr) && (0 != timeout) && (0 == *abort_wait) &&
-             (0 == SleepEx(WAIT_CYCLE_MS, FALSE)));
+    } while ( (0 == ipaddr) && (0 != timeout) && (0 == *abort_wait) &&
+              (0 == SleepEx(WAIT_CYCLE_MS, FALSE) ) );
 
-    OPENER_TRACE_INFO("IP=%08" PRIx32 ", timeout=%d\n", (uint32_t)ntohl(ipaddr), timeout);
+    OPENER_TRACE_INFO("IP=%08" PRIx32 ", timeout=%d\n",
+                      (uint32_t)ntohl(ipaddr),
+                      timeout);
     if (pmib_ipaddr_table) {
       FREE(pmib_ipaddr_table);
     }
@@ -450,8 +473,7 @@ EipStatus IfaceWaitForIp(const char *iface, int timeout, volatile int *abort_wai
 }
 
 #define HOST_NAME_MAX 256 /* Should be long enough according rfc1132. */
-void GetHostName(CipString *hostname)
-{
+void GetHostName(CipString *hostname) {
   CipWord wVersionRequested;
   WSADATA wsaData;
   int err;
@@ -464,19 +486,19 @@ void GetHostName(CipString *hostname)
     /* Tell the user that we could not find a usable Winsock DLL.  */
     char *error_message = GetErrorMessage(err);
     printf("WSAStartup failed with error: %d - %s\n",
-            err, error_message);
+           err, error_message);
     FreeErrorMessage(error_message);
     return;
   }
 
   char name_buf[HOST_NAME_MAX] = "";
-  err = gethostname(name_buf, sizeof(name_buf));
+  err = gethostname(name_buf, sizeof(name_buf) );
   if (0 != err) {
     int error_code = GetSocketErrorNumber();
     char *error_message = GetErrorMessage(error_code);
     printf("gethostname() failed, %d - %s\n",
-        error_code,
-        error_message);
+           error_code,
+           error_message);
     FreeErrorMessage(error_message);
     return;
   }

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

@@ -37,7 +37,8 @@ EipStatus NetworkHandlerInitializePlatform(void) {
 }
 
 void ShutdownSocketPlatform(int socket_handle) {
-#pragma message "Untested. Is a shutdown() needed under Windows like for the POSIX port?"
+#pragma \
+  message "Untested. Is a shutdown() needed under Windows like for the POSIX port?"
 }
 
 void CloseSocketPlatform(int socket_handle) {

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

@@ -43,7 +43,7 @@ typedef unsigned short in_port_t;
 #endif
 
 #if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-  /* Enable all the stuff the DLR device depends on */
+/* Enable all the stuff the DLR device depends on */
   #define OPENER_TCPIP_IFACE_CFG_SETTABLE 1
   #define OPENER_ETHLINK_CNTRS_ENABLE     1
   #define OPENER_ETHLINK_IFACE_CTRL_ENABLE  1
@@ -163,50 +163,50 @@ typedef unsigned short in_port_t;
 static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
 
 #ifdef OPENER_WITH_TRACES
-    /* If we have tracing enabled provide LOG_TRACE macro */
+/* If we have tracing enabled provide LOG_TRACE macro */
     #include <stdio.h>
 
     #define LOG_TRACE(...)  fprintf(stderr,__VA_ARGS__)
 
      #ifdef IDLING_ASSERT
-        /** @brief A specialized assertion command enabled by IDLING_ASSERT that
-         *  will log the assertion and block further
-         *  execution in a while(1) loop.
-         */
+/** @brief A specialized assertion command enabled by IDLING_ASSERT that
+ *  will log the assertion and block further
+ *  execution in a while(1) loop.
+ */
         #define OPENER_ASSERT(assertion)                                    \
-          do {                                                              \
-            if( !(assertion) ) {                                            \
-              LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n",  \
-                        # assertion, __FILE__, __LINE__);                   \
-              while(1) {  }                                                 \
-            }                                                               \
-          } while(0)
+  do {                                                              \
+    if( !(assertion) ) {                                            \
+      LOG_TRACE("Assertion \"%s\" failed: file \"%s\", line %d\n",  \
+                # assertion, __FILE__, __LINE__);                   \
+      while(1) {  }                                                 \
+    }                                                               \
+  } while(0)
 
     #else   /* ifdef IDLING_ASSERT */
-        /* Use standard assert() that vanishes only for release builds. */
+/* Use standard assert() that vanishes only for release builds. */
         #define OPENER_ASSERT(assertion) assert(assertion)
     #endif  /* ifdef IDLING_ASSERT */
 
 #else   /* ifdef OPENER_WITH_TRACES */
-    /* Select one of the OPENER_ASSERT() variants below if trace support is off */
+/* Select one of the OPENER_ASSERT() variants below if trace support is off */
     #if 0
-        /* If there are any strange timing issues, you can try the version below,
-         *  where the assertion is performed but the assert function is not used.
-         *  This may result in "statement with no effect" warnings.
-         */
+/* If there are any strange timing issues, you can try the version below,
+ *  where the assertion is performed but the assert function is not used.
+ *  This may result in "statement with no effect" warnings.
+ */
         #define OPENER_ASSERT(assertion) (assertion)
     #elif 0
-    /* If you still want assertions to stop execution but without tracing,
-     *  use the following */
+/* If you still want assertions to stop execution but without tracing,
+ *  use the following */
         #define OPENER_ASSERT(assertion)                    \
-          do { if(!(assertion)) { while(1) {} } } while (0)
+  do { if(!(assertion) ) { while(1) {} } } while (0)
     #elif 0
-        /* Even for debug builds remove assertion. May solicit unused variable
-         *  warnings. */
+/* Even for debug builds remove assertion. May solicit unused variable
+ *  warnings. */
         #define OPENER_ASSERT(assertion)
     #else
-        /* By default use standard assert() that vanishes only
-         *  for release builds. */
+/* By default use standard assert() that vanishes only
+ *  for release builds. */
         #define OPENER_ASSERT(assertion) assert(assertion)
     #endif
 

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

@@ -51,8 +51,8 @@ void DoublyLinkedListNodeDestroy(const DoublyLinkedList *const list,
 void DoublyLinkedListInsertAtHead(DoublyLinkedList *const list,
                                   void *data) {
   OPENER_ASSERT(list->allocator != NULL);
-  DoublyLinkedListNode * new_node = DoublyLinkedListNodeCreate(data,
-                                                               list->allocator);
+  DoublyLinkedListNode *new_node = DoublyLinkedListNodeCreate(data,
+                                                              list->allocator);
   if(NULL == list->first) {
     list->first = new_node;
     list->last = new_node;
@@ -66,8 +66,8 @@ 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);
+  DoublyLinkedListNode *new_node = DoublyLinkedListNodeCreate(data,
+                                                              list->allocator);
   if(NULL == list->last) {
     list->first = new_node;
     list->last = new_node;