Browse Source

Fix possible inconsistency between TCP/IP object attributes 3 and 5; option a)

The "Interface Configuration" attribute (#5) could be written even if the
"Configuration Control" attribute (#3) is not set for the "Static IP"
configuration method (its value is zero).

If such a SetAttributeSingle request for attribute #5 arrives the device
has two choices:

a) Reject the SetAttributeSingle request with the status codes 0x0C "Object
   state conflict" or 0x10 "Device state conflict".
b) Accept the SetAttributeSingle request but change the "Configuration
   Control" attribute (#3) to contain the configuration method value 0,
   i. e. "Static IP", on the fly.

We adopt the choice a) here and revert a previous patch that chose option
b) because the Conformance Test Tool will mark the behavior according b)
as an error. This is a flaw in the Conformance Test Tool and option b) is
allowed in PUB00049, Rev. 1.1, "EtherNet/IP Interoperability Conformance
Test Specification" in the sections 4.2.1.1.3 & 4.2.1.1.4.

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Stefan Mätje 6 years ago
parent
commit
8bc5690208
1 changed files with 4 additions and 4 deletions
  1. 4 4
      source/src/cip/ciptcpipinterface.c

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

@@ -381,6 +381,10 @@ EipStatus SetAttributeSingleTcpIpInterface(
             message_router_response->general_status = kCipErrorDeviceStateConflict;
             break;
           }
+          if (kTcpipCfgCtrlStaticIp != (g_tcpip.config_control & kTcpipCfgCtrlMethodMask)) {
+            message_router_response->general_status = kCipErrorObjectStateConflict;
+            break;
+          }
           memset(&if_cfg, 0, sizeof if_cfg);
           tmp_ip = GetUdintFromMessage(&(message_router_request->data));
           if_cfg.ip_address = htonl(tmp_ip);
@@ -415,10 +419,6 @@ EipStatus SetAttributeSingleTcpIpInterface(
            * because if_cfg goes out of scope now. */
           FreeCipString(&p_interface_configuration->domain_name);
           *p_interface_configuration = if_cfg;
-
-          /* Automatically set attribute 3 to static IP mode (kTcpipCfgCtrlStaticIp ^= 0),
-           * leaving only DnsEnable bit intact */
-          g_tcpip.config_control &= kTcpipCfgCtrlDnsEnable;
           /* Tell that this configuration change becomes active after a reset */
           g_tcpip.status |= kTcpipStatusIfaceCfgPend;
           message_router_response->general_status = kCipErrorSuccess;