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

Fix platform includes for linting

Signed-off-by: Martin Melik Merkumians <martin.melik@gmail.com>
Martin Melik Merkumians 2 месяцев назад
Родитель
Сommit
63d215046b

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

@@ -18,7 +18,7 @@
 #include "cip/ciptcpipinterface.h"
 #include "enet_encap/encap.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
 #include "cip/cipdlr.h"
 #endif

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

@@ -25,7 +25,7 @@
 #include "enet_encap/cpf.h"
 #include "enet_encap/encap.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/generic_networkhandler.h"
 #include "utils/xorshiftrandom.h"
 

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

@@ -10,7 +10,7 @@
 #include "cip/cipconnectionobject.h"
 #include "cip/ciptypes.h"
 #include "core/typedefs.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 /**
  * @brief Connection Type constants of the Forward Open service request

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

@@ -12,7 +12,7 @@
 #include "cip/cipepath.h"
 #include "cip/ciptypes.h"
 #include "core/typedefs.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "utils/doublylinkedlist.h"
 
 #define CIP_CONNECTION_OBJECT_CODE 0x05

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

@@ -56,7 +56,7 @@
 #include "cip/cipcommon.h"
 #include "core/trace.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 #if OPENER_ETHLINK_INSTANCE_CNT > 1
 /* If we have more than 1 Ethernet Link instance then the interface label

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

@@ -36,10 +36,10 @@
 #include "cip/cipstring.h"
 #include "core/trace.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 /** @brief The device's configuration data for the Identity Object */
-#include "devicedata.h"
+#include "devicedata.h"  // NOLINT(build/include_subdir)
 
 /** @brief Definition of the global Identity Object */
 CipIdentityObject g_identity = {

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

@@ -13,7 +13,7 @@
 #include "cip/cipmessagerouter.h"
 #include "core/trace.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 #define DEFAULT_DSCP_EVENT 59U
 #define DEFAULT_DSCP_GENERAL 47U

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

@@ -17,7 +17,7 @@
 #include "cip/cipstring.h"
 #include "core/trace.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 /* Define constants to initialize the config_capability attribute (#2). These
  *   are needed as defines because we use them for static initialization. */

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

@@ -7,7 +7,7 @@
 #define CIP_CIPTYPES_H_
 
 #include "core/typedefs.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/networkhandler.h"
 #include "utils/enipmessage.h"
 

+ 1 - 1
source/src/core/trace.h

@@ -13,7 +13,7 @@
 #ifdef OPENER_WITH_TRACES
 
 #ifndef OPENER_INSTALL_AS_LIB
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #endif
 
 /** @def OPENER_TRACE_LEVEL_ERROR Enable tracing of error messages. This is the

+ 1 - 1
source/src/core/typedefs.h

@@ -10,7 +10,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 
-#include "platform_network_includes.h"
+#include "platform_network_includes.h"  // NOLINT(build/include_subdir)
 
 /** @file "core/typedefs.h"
    Do not use interface types for internal variables, such as "int i;", which is

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

@@ -18,7 +18,7 @@
 #include "core/trace.h"
 #include "enet_encap/cpf.h"
 #include "enet_encap/endianconv.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/generic_networkhandler.h"
 #include "ports/opener_error.h"
 #include "ports/socket_timer.h"

+ 1 - 1
source/src/ports/MINGW/networkconfig.c

@@ -6,7 +6,7 @@
 
 /* ---------- Include files ---------------------------- */
 #define WIN32_LEAN_AND_MEAN
-#include "ports/networkconfig.h"
+#include "networkconfig.h"  // NOLINT(build/include_subdir)
 
 #include <errno.h>
 #include <inttypes.h>

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

@@ -4,7 +4,7 @@
  *
  ******************************************************************************/
 #define WIN32_LEAN_AND_MEAN
-#include "networkhandler.h"
+#include "networkhandler.h"  // NOLINT(build/include_subdir)
 
 #include <stdlib.h>
 #include <string.h>
@@ -12,7 +12,7 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
-#include "generic_networkhandler.h"
+#include "ports/generic_networkhandler.h"
 
 MicroSeconds getMicroSeconds() {
   LARGE_INTEGER performance_counter;

+ 7 - 213
source/src/ports/MINGW/sample_application/opener_user_conf.h

@@ -7,11 +7,12 @@
 #define PORTS_MINGW_SAMPLE_APPLICATION_OPENER_USER_CONF_H_
 
 /** @file
- * @brief OpENer configuration setup
+ * @brief OpENer MinGW platform configuration setup
  *
- * This file contains the general application specific configuration for OpENer.
+ * This file contains MinGW-specific configuration.
+ * Common configuration is provided by opener_user_conf_common.h.
  *
- * Furthermore you have to specific platform specific network include files.
+ * Platform specific network include files are provided here.
  * OpENer needs definitions for the following data-types
  * and functions:
  *    - struct sockaddr_in
@@ -28,217 +29,10 @@
 #include "tests/test_assert.h"
 #endif /* OPENER_UNIT_TEST */
 
-// MinGW does not define POSIX in_port_t; must match WinSock's unsigned short
+/* MinGW does not define POSIX in_port_t; must match WinSock's unsigned short */
 typedef unsigned short in_port_t;  // NOLINT(runtime/int)
 
-/** @brief Set this define if you have a DLR capable device
- *
- * This define changes the OpENer device configuration in a way that
- *  the DLR object is initialized and the other configuration stuff
- *  that is mandatory for a DLR device is also enabled.
- *
- * This define should be set from the CMake command line using
- *  "-DOPENER_IS_DLR_DEVICE:BOOL=ON"
- */
-#ifndef OPENER_IS_DLR_DEVICE
-#define OPENER_IS_DLR_DEVICE 0
-#endif
-
-#if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-/* 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
-#define OPENER_ETHLINK_LABEL_ENABLE 1
-#define OPENER_ETHLINK_INSTANCE_CNT 3
-#endif
-
-/* Control some configuration of TCP/IP object */
-
-/** @brief Set this define if you want the Interface Configuration to be
- * settable
- *
- * This define makes the TCP/IP object's Interface Configuration (attribute #5)
- *  and the Host Name (attribute #6) settable. This is required as per ODVA
- *  publication 70 "Recommended Functionality for EIP Devices" Version
- *  10. This also enables the storage of these attributes in NV data
- *  storage area.
- */
-#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
-#define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
-#endif
-
-/* Control some configuration of Ethernet Link object */
-
-/** @brief Set this define to determine the number of instantiated Ethernet Link
- * objects
- *
- * A simple device has only a single Ethernet port. For this kind of device set
- * this define to 1. A DLR capable device has at least two Ethernet ports. For
- * this kind of device set this define to 2. If you want expose the internal
- * switch port of your capable DLR device also then set this define to 3.
- */
-#ifndef OPENER_ETHLINK_INSTANCE_CNT
-#define OPENER_ETHLINK_INSTANCE_CNT 1
-#endif
-
-/** @brief Set this define if you want a real interface label for the Ethernet
- * Link object
- *
- * This define adds a interface label to the Ethernet Link object that has a
- * string length greater than zero. It defaults to "PORT 1".
- */
-#ifndef OPENER_ETHLINK_LABEL_ENABLE
-#define OPENER_ETHLINK_LABEL_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Counters for Ethernet Link object
- *
- * This define enables the Media Counters (attribute #5) which are required
- *  for a DLR device. Also the Interface Counters (attribute #4) are enabled
- *  which become required because the Media Counters are implemented.
- */
-#ifndef OPENER_ETHLINK_CNTRS_ENABLE
-#define OPENER_ETHLINK_CNTRS_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Interface Control for Ethernet Link
- * object
- *
- * This define enables the Interface Control attribute (#6) as a settable
- *  attribute which is required for a DLR device. This also enables the storage
- *  of the attribute in NV data storage area.
- */
-#ifndef OPENER_ETHLINK_IFACE_CTRL_ENABLE
-#define OPENER_ETHLINK_IFACE_CTRL_ENABLE 0
-#endif
-
-/** @brief Define the number of objects that may be used in connections
- *
- *  This number needs only to consider additional objects. Connections to
- *  the connection manager object as well as to the assembly object are
- * supported in any case.
- */
-#define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
-
-/** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be equal or greater than 6.
- */
-#define OPENER_CIP_NUM_EXPLICIT_CONNS 6
-
-/** @brief Define the number of supported exclusive owner connections.
- *  Each of these connections has to be configured with the function
- *  void configureExclusiveOwnerConnectionPoint(unsigned int pa_unConnNum,
- * unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned
- * int pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
-
-/** @brief Define the number of supported input only connections.
- *  Each of these connections has to be configured with the function
- *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS 1
-
-/** @brief Define the number of supported input only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Define the number of supported listen only connections.
- *  Each of these connections has to be configured with the function
- *  void configureListenOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS 1
-
-/** @brief Define the number of supported Listen only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Number of sessions that can be handled at the same time
- */
-#define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
-
-/** @brief The time in ms of the timer used in this implementations, time base
- * for time-outs and production timers
- */
-static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
-
-#ifdef OPENER_WITH_TRACES
-/* If we have tracing enabled provide LOG_TRACE macro */
-#include <stdio.h>
-
-#define LOG_TRACE(...) fprintf(stderr, __VA_ARGS__)
-#endif /* ifdef OPENER_WITH_TRACES */
-
-/*
- * Omit assertion definitions when building unit tests. These will
- * be defined with versions suitable for the unit test environment.
- */
-#ifndef OPENER_UNIT_TEST
-
-#ifdef OPENER_WITH_TRACES
-
-#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.
- */
-#define OPENER_ASSERT(assertion)                                   \
-  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. */
-#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 */
-#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.
- */
-#define OPENER_ASSERT(assertion) (assertion)
-#elif 0
-/* 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)
-#elif 0
-/* 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. */
-#define OPENER_ASSERT(assertion) assert(assertion)
-#endif
-
-#endif /* ifdef OPENER_WITH_TRACES */
-
-#endif /* ifndef OPENER_UNIT_TEST */
+/* Include common configuration shared across all platforms */
+#include "ports/opener_user_conf_common.h"
 
 #endif  // PORTS_MINGW_SAMPLE_APPLICATION_OPENER_USER_CONF_H_

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

@@ -3,7 +3,7 @@
  * All rights reserved.
  *
  ******************************************************************************/
-#include "networkconfig.h"
+#include "networkconfig.h"  // NOLINT(build/include_subdir)
 
 #include <arpa/inet.h>
 #include <errno.h>

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

@@ -3,7 +3,7 @@
  * All rights reserved.
  *
  ******************************************************************************/
-#include "networkhandler.h"
+#include "networkhandler.h"  // NOLINT(build/include_subdir)
 
 #include <fcntl.h>
 #include <netinet/in.h>
@@ -16,7 +16,7 @@
 
 #include "core/trace.h"
 #include "enet_encap/encap.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/opener_error.h"
 
 MicroSeconds GetMicroSeconds(void) {

+ 6 - 236
source/src/ports/POSIX/sample_application/opener_user_conf.h

@@ -7,11 +7,12 @@
 #define PORTS_POSIX_SAMPLE_APPLICATION_OPENER_USER_CONF_H_
 
 /** @file POSIX/sample_application/opener_user_conf.h
- * @brief OpENer configuration setup
+ * @brief OpENer POSIX platform configuration setup
  *
- * This file contains the general application specific configuration for OpENer.
+ * This file contains POSIX-specific includes and configuration.
+ * Common configuration is provided by opener_user_conf_common.h.
  *
- * Furthermore you have to specific platform specific network include files.
+ * Platform specific network include files are provided here.
  * OpENer needs definitions for the following data-types
  * and functions:
  *    - struct sockaddr_in
@@ -29,242 +30,11 @@
 
 #include "core/typedefs.h"
 
-/** @brief Set this define if you have a CIP File capable device
- *
- *  This define changes the OpENer device configuration in a way that
- *  the File object is initialized.
- *
- *  This define should be set from the CMake command line using
- *  "-DCIP_FILE_OBJECT:BOOL=ON"
- */
-#ifndef CIP_FILE_OBJECT
-#define CIP_FILE_OBJECT 0
-#endif
-
-/** @brief Set this define if you have a CIP Security capable device
- *
- *  This define changes the OpENer device configuration in a way that
- *  the Security related objects are initialized.
- *
- *  This define should be set from the CMake command line using
- *  "-DCIP_SECURITY_OBJECTS:BOOL=ON"
- */
-#ifndef CIP_SECURITY_OBJECTS
-#define CIP_SECURITY_OBJECTS 0
-#endif
-
 #ifdef OPENER_UNIT_TEST
 #include "tests/test_assert.h"
 #endif /* OPENER_UNIT_TEST */
 
-/** @brief Set this define if you have a DLR capable device
- *
- * This define changes the OpENer device configuration in a way that
- *  the DLR object is initialized and the other configuration stuff
- *  that is mandatory for a DLR device is also enabled.
- *
- * This define should be set from the CMake command line using
- *  "-DOPENER_IS_DLR_DEVICE:BOOL=ON"
- */
-#ifndef OPENER_IS_DLR_DEVICE
-#define OPENER_IS_DLR_DEVICE 0
-#endif
-
-#if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-/* 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
-#define OPENER_ETHLINK_LABEL_ENABLE 1
-#define OPENER_ETHLINK_INSTANCE_CNT 3
-#endif
-
-/* Control some configuration of TCP/IP object */
-
-/** @brief Set this define if you want the Interface Configuration to be
- * settable
- *
- * This define makes the TCP/IP object's Interface Configuration (attribute #5)
- *  and the Host Name (attribute #6) settable. This is required as per ODVA
- *  publication 70 "Recommended Functionality for EIP Devices" Version
- *  10. This also enables the storage of these attributes in NV data
- *  storage area.
- */
-#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
-#define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
-#endif
-
-/* Control some configuration of Ethernet Link object */
-
-/** @brief Set this define to determine the number of instantiated Ethernet Link
- * objects
- *
- * A simple device has only a single Ethernet port. For this kind of device set
- * this define to 1. A DLR capable device has at least two Ethernet ports. For
- * this kind of device set this define to 2. If you want expose the internal
- * switch port of your capable DLR device also then set this define to 3.
- */
-#ifndef OPENER_ETHLINK_INSTANCE_CNT
-#define OPENER_ETHLINK_INSTANCE_CNT 1
-#endif
-
-/** @brief Set this define if you want a real interface label for the Ethernet
- * Link object
- *
- * This define adds a interface label to the Ethernet Link object that has a
- * string length greater than zero. It defaults to "PORT 1".
- */
-#ifndef OPENER_ETHLINK_LABEL_ENABLE
-#define OPENER_ETHLINK_LABEL_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Counters for Ethernet Link object
- *
- * This define enables the Media Counters (attribute #5) which are required
- *  for a DLR device. Also the Interface Counters (attribute #4) are enabled
- *  which become required because the Media Counters are implemented.
- */
-#ifndef OPENER_ETHLINK_CNTRS_ENABLE
-#define OPENER_ETHLINK_CNTRS_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Interface Control for Ethernet Link
- * object
- *
- * This define enables the Interface Control attribute (#6) as a settable
- *  attribute which is required for a DLR device. This also enables the storage
- *  of the attribute in NV data storage area.
- */
-#ifndef OPENER_ETHLINK_IFACE_CTRL_ENABLE
-#define OPENER_ETHLINK_IFACE_CTRL_ENABLE 0
-#endif
-
-/** @brief Define the number of objects that may be used in connections
- *
- *  This number needs only to consider additional objects. Connections to
- *  the connection manager object as well as to the assembly object are
- * supported in any case.
- */
-#define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
-
-/** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be equal or greater than 6.
- */
-#define OPENER_CIP_NUM_EXPLICIT_CONNS 6
-
-/** @brief Define the number of supported exclusive owner connections.
- *  Each of these connections has to be configured with the function
- *  void configureExclusiveOwnerConnectionPoint(unsigned int pa_unConnNum,
- * unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned
- * int pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
-
-/** @brief Define the number of supported input only connections.
- *  Each of these connections has to be configured with the function
- *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS 1
-
-/** @brief Define the number of supported input only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Define the number of supported listen only connections.
- *  Each of these connections has to be configured with the function
- *  void configureListenOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS 1
-
-/** @brief Define the number of supported Listen only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Number of sessions that can be handled at the same time
- */
-#define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
-
-/** @brief The time in ms of the timer used in this implementations, time base
- * for time-outs and production timers
- */
-static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
-
-#ifdef OPENER_WITH_TRACES
-/* If we have tracing enabled provide LOG_TRACE macro */
-#include <stdio.h>
-
-#define LOG_TRACE(...) fprintf(stderr, __VA_ARGS__)
-#endif /* ifdef OPENER_WITH_TRACES */
-
-/*
- * Omit assertion definitions when building unit tests. These will
- * be defined with versions suitable for the unit test environment.
- */
-#ifndef OPENER_UNIT_TEST
-
-#ifdef OPENER_WITH_TRACES
-
-#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.
- */
-#define OPENER_ASSERT(assertion)                                   \
-  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. */
-#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 */
-#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.
- */
-#define OPENER_ASSERT(assertion) (assertion)
-#elif 0
-/* 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)
-#elif 0
-/* 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. */
-#define OPENER_ASSERT(assertion) assert(assertion)
-#endif
-
-#endif /* ifdef OPENER_WITH_TRACES */
-
-#endif /* ifndef OPENER_UNIT_TEST */
+/* Include common configuration shared across all platforms */
+#include "ports/opener_user_conf_common.h"
 
 #endif  // PORTS_POSIX_SAMPLE_APPLICATION_OPENER_USER_CONF_H_

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

@@ -8,12 +8,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "api/opener_api.h"
 #include "cip/appcontype.h"
 #include "cip/cipidentity.h"
 #include "cip/cipqos.h"
 #include "cip/ciptcpipinterface.h"
 #include "core/trace.h"
-#include "opener_api.h"
 #include "ports/nvdata/nvdata.h"
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
 #include "cip/cipethernetlink.h"

+ 2 - 2
source/src/ports/STM32/networkconfig.c

@@ -3,19 +3,19 @@
  * All rights reserved.
  *
  ******************************************************************************/
-#include "ports/STM32/networkconfig.h"
+#include "networkconfig.h"  // NOLINT(build/include_subdir)
 
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include "api/opener_api.h"
 #include "cip/cipcommon.h"
 #include "cip/ciperror.h"
 #include "cip/cipstring.h"
 #include "core/trace.h"
 #include "lwip/netif.h"
-#include "opener_api.h"
 
 EipStatus IfaceGetMacAddress(TcpIpInterface* iface,
                              uint8_t* const physical_address) {

+ 1 - 1
source/src/ports/STM32/networkhandler.c

@@ -8,7 +8,7 @@
 
 #include "core/trace.h"
 #include "enet_encap/encap.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/opener_error.h"
 
 MilliSeconds GetMilliSeconds(void) {

+ 11 - 240
source/src/ports/STM32/sample_application/opener_user_conf.h

@@ -6,12 +6,13 @@
 #ifndef PORTS_STM32_SAMPLE_APPLICATION_OPENER_USER_CONF_H_
 #define PORTS_STM32_SAMPLE_APPLICATION_OPENER_USER_CONF_H_
 
-/** @file POSIX/sample_application/opener_user_conf.h
- * @brief OpENer configuration setup
+/** @file STM32/sample_application/opener_user_conf.h
+ * @brief OpENer STM32 platform configuration setup
  *
- * This file contains the general application specific configuration for OpENer.
+ * This file contains STM32-specific includes and configuration.
+ * Common configuration is provided by opener_user_conf_common.h.
  *
- * Furthermore you have to specific platform specific network include files.
+ * Platform specific network include files are provided here.
  * OpENer needs definitions for the following data-types
  * and functions:
  *    - struct sockaddr_in
@@ -23,7 +24,8 @@
  */
 #include <assert.h>
 
-/// in _default_fcntl.h defined as 0x4000, but lwip defines 1 in sockets.h
+/* Conflict resolution: in _default_fcntl.h defined as 0x4000,
+ * but lwip defines 1 in sockets.h */
 #undef O_NONBLOCK
 
 #include "FreeRTOS.h"
@@ -33,244 +35,13 @@
 #include "lwip/arch.h"
 #include "lwip/opt.h"
 #include "lwip/sockets.h"
-#include "task.h"
-
-/** @brief Set this define if you have a CIP File capable device
- *
- *  This define changes the OpENer device configuration in a way that
- *  the File object is initialized.
- *
- *  This define should be set from the CMake command line using
- *  "-DCIP_FILE_OBJECT:BOOL=ON"
- */
-#ifndef CIP_FILE_OBJECT
-#define CIP_FILE_OBJECT 0
-#endif
-
-/** @brief Set this define if you have a CIP Security capable device
- *
- *  This define changes the OpENer device configuration in a way that
- *  the Security related objects are initialized.
- *
- *  This define should be set from the CMake command line using
- *  "-DCIP_SECURITY_OBJECTS:BOOL=ON"
- */
-#ifndef CIP_SECURITY_OBJECTS
-#define CIP_SECURITY_OBJECTS 0
-#endif
+#include "task.h"  // NOLINT(build/include_subdir)
 
 #ifdef OPENER_UNIT_TEST
-#include "test_assert.h"
+#include "tests/test_assert.h"
 #endif /* OPENER_UNIT_TEST */
 
-/** @brief Set this define if you have a DLR capable device
- *
- * This define changes the OpENer device configuration in a way that
- *  the DLR object is initialized and the other configuration stuff
- *  that is mandatory for a DLR device is also enabled.
- *
- * This define should be set from the CMake command line using
- *  "-DOPENER_IS_DLR_DEVICE:BOOL=ON"
- */
-#ifndef OPENER_IS_DLR_DEVICE
-#define OPENER_IS_DLR_DEVICE 0
-#endif
-
-#if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-/* 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
-#define OPENER_ETHLINK_LABEL_ENABLE 1
-#define OPENER_ETHLINK_INSTANCE_CNT 3
-#endif
-
-/* Control some configuration of TCP/IP object */
-
-/** @brief Set this define if you want the Interface Configuration to be
- * settable
- *
- * This define makes the TCP/IP object's Interface Configuration (attribute #5)
- *  and the Host Name (attribute #6) settable. This is required as per ODVA
- *  publication 70 "Recommended Functionality for EIP Devices" Version
- *  10. This also enables the storage of these attributes in NV data
- *  storage area.
- */
-#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
-#define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
-#endif
-
-/* Control some configuration of Ethernet Link object */
-
-/** @brief Set this define to determine the number of instantiated Ethernet Link
- * objects
- *
- * A simple device has only a single Ethernet port. For this kind of device set
- * this define to 1. A DLR capable device has at least two Ethernet ports. For
- * this kind of device set this define to 2. If you want expose the internal
- * switch port of your capable DLR device also then set this define to 3.
- */
-#ifndef OPENER_ETHLINK_INSTANCE_CNT
-#define OPENER_ETHLINK_INSTANCE_CNT 1
-#endif
-
-/** @brief Set this define if you want a real interface label for the Ethernet
- * Link object
- *
- * This define adds a interface label to the Ethernet Link object that has a
- * string length greater than zero. It defaults to "PORT 1".
- */
-#ifndef OPENER_ETHLINK_LABEL_ENABLE
-#define OPENER_ETHLINK_LABEL_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Counters for Ethernet Link object
- *
- * This define enables the Media Counters (attribute #5) which are required
- *  for a DLR device. Also the Interface Counters (attribute #4) are enabled
- *  which become required because the Media Counters are implemented.
- */
-#ifndef OPENER_ETHLINK_CNTRS_ENABLE
-#define OPENER_ETHLINK_CNTRS_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Interface Control for Ethernet Link
- * object
- *
- * This define enables the Interface Control attribute (#6) as a settable
- *  attribute which is required for a DLR device. This also enables the storage
- *  of the attribute in NV data storage area.
- */
-#ifndef OPENER_ETHLINK_IFACE_CTRL_ENABLE
-#define OPENER_ETHLINK_IFACE_CTRL_ENABLE 0
-#endif
-
-/** @brief Define the number of objects that may be used in connections
- *
- *  This number needs only to consider additional objects. Connections to
- *  the connection manager object as well as to the assembly object are
- * supported in any case.
- */
-#define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
-
-/** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be equal or greater than 6.
- */
-#define OPENER_CIP_NUM_EXPLICIT_CONNS 6
-
-/** @brief Define the number of supported exclusive owner connections.
- *  Each of these connections has to be configured with the function
- *  void configureExclusiveOwnerConnectionPoint(unsigned int pa_unConnNum,
- * unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned
- * int pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
-
-/** @brief Define the number of supported input only connections.
- *  Each of these connections has to be configured with the function
- *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS 1
-
-/** @brief Define the number of supported input only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Define the number of supported listen only connections.
- *  Each of these connections has to be configured with the function
- *  void configureListenOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS 1
-
-/** @brief Define the number of supported Listen only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Number of sessions that can be handled at the same time
- */
-#define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
-
-/** @brief The time in ms of the timer used in this implementations, time base
- * for time-outs and production timers
- */
-static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
-
-#ifdef OPENER_WITH_TRACES
-/* If we have tracing enabled provide LOG_TRACE macro */
-#include <stdio.h>
-
-#define LOG_TRACE(...) fprintf(stderr, __VA_ARGS__)
-#endif /* ifdef OPENER_WITH_TRACES */
-
-/*
- * Omit assertion definitions when building unit tests. These will
- * be defined with versions suitable for the unit test environment.
- */
-#ifndef OPENER_UNIT_TEST
-
-#ifdef OPENER_WITH_TRACES
-
-#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.
- */
-#define OPENER_ASSERT(assertion)                                   \
-  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. */
-#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 */
-#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.
- */
-#define OPENER_ASSERT(assertion) (assertion)
-#elif 0
-/* 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)
-#elif 0
-/* 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. */
-#define OPENER_ASSERT(assertion) assert(assertion)
-#endif
-
-#endif /* ifdef OPENER_WITH_TRACES */
-
-#endif /* ifndef OPENER_UNIT_TEST */
+/* Include common configuration shared across all platforms */
+#include "ports/opener_user_conf_common.h"
 
 #endif  // PORTS_STM32_SAMPLE_APPLICATION_OPENER_USER_CONF_H_

+ 9 - 214
source/src/ports/WIN32/sample_application/opener_user_conf.h

@@ -7,11 +7,12 @@
 #define PORTS_WIN32_SAMPLE_APPLICATION_OPENER_USER_CONF_H_
 
 /** @file WIN32/sample_application/opener_user_conf.h
- * @brief OpENer configuration setup
+ * @brief OpENer WIN32 platform configuration setup
  *
- * This file contains the general application specific configuration for OpENer.
+ * This file contains WIN32-specific includes and configuration.
+ * Common configuration is provided by opener_user_conf_common.h.
  *
- * Furthermore you have to specific platform specific network include files.
+ * Platform specific network include files are provided here.
  * OpENer needs definitions for the following data-types
  * and functions:
  *    - struct sockaddr_in
@@ -24,223 +25,17 @@
 #include <windows.h>
 #include <winsock2.h>
 #include <ws2tcpip.h>
-// MSVC compatibility: in_port_t must match network stack's unsigned short
+
+/* MSVC compatibility: in_port_t must match network stack's unsigned short */
 typedef unsigned short in_port_t;  // NOLINT(runtime/int)
 
 #include "core/typedefs.h"
 
 #ifdef OPENER_UNIT_TEST
-#include "test_assert.h"
+#include "tests/test_assert.h"
 #endif /* OPENER_UNIT_TEST */
 
-/** @brief Set this define if you have a DLR capable device
- *
- * This define changes the OpENer device configuration in a way that
- *  the DLR object is initialized and the other configuration stuff
- *  that is mandatory for a DLR device is also enabled.
- *
- * This define should be set from the CMake command line using
- *  "-DOPENER_IS_DLR_DEVICE:BOOL=ON"
- */
-#ifndef OPENER_IS_DLR_DEVICE
-#define OPENER_IS_DLR_DEVICE 0
-#endif
-
-#if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
-/* 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
-#define OPENER_ETHLINK_LABEL_ENABLE 1
-#define OPENER_ETHLINK_INSTANCE_CNT 3
-#endif
-
-/* Control some configuration of TCP/IP object */
-
-/** @brief Set this define if you want the Interface Configuration to be
- * settable
- *
- * This define makes the TCP/IP object's Interface Configuration (attribute #5)
- *  and the Host Name (attribute #6) settable. This is required as per ODVA
- *  publication 70 "Recommended Functionality for EIP Devices" Version
- *  10. This also enables the storage of these attributes in NV data
- *  storage area.
- */
-#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
-#define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
-#endif
-
-/* Control some configuration of Ethernet Link object */
-
-/** @brief Set this define to determine the number of instantiated Ethernet Link
- * objects
- *
- * A simple device has only a single Ethernet port. For this kind of device set
- * this define to 1. A DLR capable device has at least two Ethernet ports. For
- * this kind of device set this define to 2. If you want expose the internal
- * switch port of your capable DLR device also then set this define to 3.
- */
-#ifndef OPENER_ETHLINK_INSTANCE_CNT
-#define OPENER_ETHLINK_INSTANCE_CNT 1
-#endif
-
-/** @brief Set this define if you want a real interface label for the Ethernet
- * Link object
- *
- * This define adds a interface label to the Ethernet Link object that has a
- * string length greater than zero. It defaults to "PORT 1".
- */
-#ifndef OPENER_ETHLINK_LABEL_ENABLE
-#define OPENER_ETHLINK_LABEL_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Counters for Ethernet Link object
- *
- * This define enables the Media Counters (attribute #5) which are required
- *  for a DLR device. Also the Interface Counters (attribute #4) are enabled
- *  which become required because the Media Counters are implemented.
- */
-#ifndef OPENER_ETHLINK_CNTRS_ENABLE
-#define OPENER_ETHLINK_CNTRS_ENABLE 0
-#endif
-
-/** @brief Set this define if you need Interface Control for Ethernet Link
- * object
- *
- * This define enables the Interface Control attribute (#6) as a settable
- *  attribute which is required for a DLR device. This also enables the storage
- *  of the attribute in NV data storage area.
- */
-#ifndef OPENER_ETHLINK_IFACE_CTRL_ENABLE
-#define OPENER_ETHLINK_IFACE_CTRL_ENABLE 0
-#endif
-
-/** @brief Define the number of objects that may be used in connections
- *
- *  This number needs only to consider additional objects. Connections to
- *  the connection manager object as well as to the assembly object are
- * supported in any case.
- */
-#define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
-
-/** @brief Define the number of supported explicit connections.
- *  According to ODVA's PUB 70 this number should be equal or greater than 6.
- */
-#define OPENER_CIP_NUM_EXPLICIT_CONNS 6
-
-/** @brief Define the number of supported exclusive owner connections.
- *  Each of these connections has to be configured with the function
- *  void configureExclusiveOwnerConnectionPoint(unsigned int pa_unConnNum,
- * unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned
- * int pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
-
-/** @brief Define the number of supported input only connections.
- *  Each of these connections has to be configured with the function
- *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS 1
-
-/** @brief Define the number of supported input only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Define the number of supported listen only connections.
- *  Each of these connections has to be configured with the function
- *  void configureListenOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
- * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
- * pa_unConfigAssembly)
- *
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS 1
-
-/** @brief Define the number of supported Listen only connections per connection
- * path
- */
-#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH 3
-
-/** @brief Number of sessions that can be handled at the same time
- */
-#define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
-
-/** @brief The time in ms of the timer used in this implementations, time base
- * for time-outs and production timers
- */
-static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
-
-#ifdef OPENER_WITH_TRACES
-/* If we have tracing enabled provide LOG_TRACE macro */
-#include <stdio.h>
-
-#define LOG_TRACE(...) fprintf(stderr, __VA_ARGS__)
-#endif /* ifdef OPENER_WITH_TRACES */
-
-/*
- * Omit assertion definitions when building unit tests. These will
- * be defined with versions suitable for the unit test environment.
- */
-#ifndef OPENER_UNIT_TEST
-
-#ifdef OPENER_WITH_TRACES
-
-#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.
- */
-#define OPENER_ASSERT(assertion)                                   \
-  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. */
-#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 */
-#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.
- */
-#define OPENER_ASSERT(assertion) (assertion)
-#elif 0
-/* 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)
-#elif 0
-/* 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. */
-#define OPENER_ASSERT(assertion) assert(assertion)
-#endif
-
-#endif /* ifdef OPENER_WITH_TRACES */
-
-#endif /* ifndef OPENER_UNIT_TEST */
+/* Include common configuration shared across all platforms */
+#include "ports/opener_user_conf_common.h"
 
 #endif  // PORTS_WIN32_SAMPLE_APPLICATION_OPENER_USER_CONF_H_

+ 1 - 1
source/src/ports/WIN32/sample_application/sampleapplication.c

@@ -7,11 +7,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "api/opener_api.h"
 #include "cip/appcontype.h"
 #include "cip/cipqos.h"
 #include "cip/ciptcpipinterface.h"
 #include "core/trace.h"
-#include "opener_api.h"
 #include "ports/nvdata/nvdata.h"
 #if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
 #include "cip/cipethernetlink.h"

+ 1 - 1
source/src/ports/generic_networkhandler.c

@@ -25,7 +25,7 @@
 #include "core/trace.h"
 #include "core/typedefs.h"
 #include "enet_encap/encap.h"
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 #include "ports/opener_error.h"
 
 #define MAX_NO_OF_TCP_SOCKETS 10

+ 251 - 0
source/src/ports/opener_user_conf_common.h

@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2009, Rockwell Automation, Inc.
+ * All rights reserved.
+ *
+ ******************************************************************************/
+#ifndef PORTS_OPENER_USER_CONF_COMMON_H_
+#define PORTS_OPENER_USER_CONF_COMMON_H_
+
+/** @file ports/opener_user_conf_common.h
+ * @brief OpENer common configuration setup shared across all platforms
+ *
+ * This file contains platform-independent application-specific configuration
+ * for OpENer. Platform-specific includes and typedefs should be defined in
+ * the platform-specific opener_user_conf.h file before including this header.
+ */
+
+/** @brief Set this define if you have a CIP File capable device
+ *
+ *  This define changes the OpENer device configuration in a way that
+ *  the File object is initialized.
+ *
+ *  This define should be set from the CMake command line using
+ *  "-DCIP_FILE_OBJECT:BOOL=ON"
+ */
+#ifndef CIP_FILE_OBJECT
+#define CIP_FILE_OBJECT 0
+#endif
+
+/** @brief Set this define if you have a CIP Security capable device
+ *
+ *  This define changes the OpENer device configuration in a way that
+ *  the Security related objects are initialized.
+ *
+ *  This define should be set from the CMake command line using
+ *  "-DCIP_SECURITY_OBJECTS:BOOL=ON"
+ */
+#ifndef CIP_SECURITY_OBJECTS
+#define CIP_SECURITY_OBJECTS 0
+#endif
+
+/** @brief Set this define if you have a DLR capable device
+ *
+ * This define changes the OpENer device configuration in a way that
+ *  the DLR object is initialized and the other configuration stuff
+ *  that is mandatory for a DLR device is also enabled.
+ *
+ * This define should be set from the CMake command line using
+ *  "-DOPENER_IS_DLR_DEVICE:BOOL=ON"
+ */
+#ifndef OPENER_IS_DLR_DEVICE
+#define OPENER_IS_DLR_DEVICE 0
+#endif
+
+#if defined(OPENER_IS_DLR_DEVICE) && 0 != OPENER_IS_DLR_DEVICE
+/* 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
+#define OPENER_ETHLINK_LABEL_ENABLE 1
+#define OPENER_ETHLINK_INSTANCE_CNT 3
+#endif
+
+/* Control some configuration of TCP/IP object */
+
+/** @brief Set this define if you want the Interface Configuration to be
+ * settable
+ *
+ * This define makes the TCP/IP object's Interface Configuration (attribute #5)
+ *  and the Host Name (attribute #6) settable. This is required as per ODVA
+ *  publication 70 "Recommended Functionality for EIP Devices" Version
+ *  10. This also enables the storage of these attributes in NV data
+ *  storage area.
+ */
+#ifndef OPENER_TCPIP_IFACE_CFG_SETTABLE
+#define OPENER_TCPIP_IFACE_CFG_SETTABLE 0
+#endif
+
+/* Control some configuration of Ethernet Link object */
+
+/** @brief Set this define to determine the number of instantiated Ethernet Link
+ * objects
+ *
+ * A simple device has only a single Ethernet port. For this kind of device set
+ * this define to 1. A DLR capable device has at least two Ethernet ports. For
+ * this kind of device set this define to 2. If you want expose the internal
+ * switch port of your capable DLR device also then set this define to 3.
+ */
+#ifndef OPENER_ETHLINK_INSTANCE_CNT
+#define OPENER_ETHLINK_INSTANCE_CNT 1
+#endif
+
+/** @brief Set this define if you want a real interface label for the Ethernet
+ * Link object
+ *
+ * This define adds a interface label to the Ethernet Link object that has a
+ * string length greater than zero. It defaults to "PORT 1".
+ */
+#ifndef OPENER_ETHLINK_LABEL_ENABLE
+#define OPENER_ETHLINK_LABEL_ENABLE 0
+#endif
+
+/** @brief Set this define if you need Counters for Ethernet Link object
+ *
+ * This define enables the Media Counters (attribute #5) which are required
+ *  for a DLR device. Also the Interface Counters (attribute #4) are enabled
+ *  which become required because the Media Counters are implemented.
+ */
+#ifndef OPENER_ETHLINK_CNTRS_ENABLE
+#define OPENER_ETHLINK_CNTRS_ENABLE 0
+#endif
+
+/** @brief Set this define if you need Interface Control for Ethernet Link
+ * object
+ *
+ * This define enables the Interface Control attribute (#6) as a settable
+ *  attribute which is required for a DLR device. This also enables the storage
+ *  of the attribute in NV data storage area.
+ */
+#ifndef OPENER_ETHLINK_IFACE_CTRL_ENABLE
+#define OPENER_ETHLINK_IFACE_CTRL_ENABLE 0
+#endif
+
+/** @brief Define the number of objects that may be used in connections
+ *
+ *  This number needs only to consider additional objects. Connections to
+ *  the connection manager object as well as to the assembly object are
+ * supported in any case.
+ */
+#define OPENER_CIP_NUM_APPLICATION_SPECIFIC_CONNECTABLE_OBJECTS 1
+
+/** @brief Define the number of supported explicit connections.
+ *  According to ODVA's PUB 70 this number should be equal or greater than 6.
+ */
+#define OPENER_CIP_NUM_EXPLICIT_CONNS 6
+
+/** @brief Define the number of supported exclusive owner connections.
+ *  Each of these connections has to be configured with the function
+ *  void configureExclusiveOwnerConnectionPoint(unsigned int pa_unConnNum,
+ * unsigned int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned
+ * int pa_unConfigAssembly)
+ *
+ */
+#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS 1
+
+/** @brief Define the number of supported input only connections.
+ *  Each of these connections has to be configured with the function
+ *  void configureInputOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
+ * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
+ * pa_unConfigAssembly)
+ *
+ */
+#define OPENER_CIP_NUM_INPUT_ONLY_CONNS 1
+
+/** @brief Define the number of supported input only connections per connection
+ * path
+ */
+#define OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH 3
+
+/** @brief Define the number of supported listen only connections.
+ *  Each of these connections has to be configured with the function
+ *  void configureListenOnlyConnectionPoint(unsigned int pa_unConnNum, unsigned
+ * int pa_unOutputAssembly, unsigned int pa_unInputAssembly, unsigned int
+ * pa_unConfigAssembly)
+ *
+ */
+#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS 1
+
+/** @brief Define the number of supported Listen only connections per connection
+ * path
+ */
+#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH 3
+
+/** @brief Number of sessions that can be handled at the same time
+ */
+#define OPENER_NUMBER_OF_SUPPORTED_SESSIONS 20
+
+/** @brief The time in ms of the timer used in this implementations, time base
+ * for time-outs and production timers
+ */
+static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;
+
+#ifdef OPENER_WITH_TRACES
+/* If we have tracing enabled provide LOG_TRACE macro */
+#include <stdio.h>
+
+#define LOG_TRACE(...) fprintf(stderr, __VA_ARGS__)
+#endif /* ifdef OPENER_WITH_TRACES */
+
+/*
+ * Omit assertion definitions when building unit tests. These will
+ * be defined with versions suitable for the unit test environment.
+ */
+#ifndef OPENER_UNIT_TEST
+
+#ifdef OPENER_WITH_TRACES
+
+#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.
+ */
+#define OPENER_ASSERT(assertion)                                   \
+  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. */
+#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 */
+#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.
+ */
+#define OPENER_ASSERT(assertion) (assertion)
+#elif 0
+/* 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)
+#elif 0
+/* 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. */
+#define OPENER_ASSERT(assertion) assert(assertion)
+#endif
+
+#endif /* ifdef OPENER_WITH_TRACES */
+
+#endif /* ifndef OPENER_UNIT_TEST */
+
+#endif  // PORTS_OPENER_USER_CONF_COMMON_H_

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

@@ -9,7 +9,7 @@
 #include <assert.h>
 #include <stdio.h>  // Needed to define NULL
 
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 void DoublyLinkedListInitialize(DoublyLinkedList* list,
                                 NodeMemoryAllocator allocator,

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

@@ -6,7 +6,7 @@
 #ifndef UTILS_ENIPMESSAGE_H_
 #define UTILS_ENIPMESSAGE_H_
 
-#include "opener_user_conf.h"
+#include "opener_user_conf.h"  // NOLINT(build/include_subdir)  // NOLINT(build/include_subdir)
 
 typedef struct enip_message {
   CipOctet message_buffer[PC_OPENER_ETHERNET_BUFFER_SIZE];