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

Fix possible inconsistency between TCP/IP object attributes 3 and 5

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 b) here.

Signed-off-by: Manuel Köppen <manuel.koeppen@esd.eu>
Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Stefan Mätje 6 лет назад
Родитель
Сommit
0c0d43590d
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      source/src/cip/ciptcpipinterface.c

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

@@ -415,6 +415,10 @@ 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;