|
|
@@ -372,9 +372,9 @@ void EncodeCipLastConflictDetected(const void *const data,
|
|
|
|
|
|
|
|
|
int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
|
|
|
- CipDword *const data,
|
|
|
- CipMessageRouterRequest *const message_router_request,
|
|
|
- CipMessageRouterResponse *const message_router_response) {
|
|
|
+ CipDword *const data,
|
|
|
+ CipMessageRouterRequest *const message_router_request,
|
|
|
+ CipMessageRouterResponse *const message_router_response) {
|
|
|
|
|
|
int number_of_decoded_bytes = -1;
|
|
|
|
|
|
@@ -403,115 +403,115 @@ int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
|
|
|
0 != OPENER_TCPIP_IFACE_CFG_SETTABLE
|
|
|
|
|
|
int DecodeCipTcpIpInterfaceConfiguration( /* Attribute 5 */
|
|
|
- CipTcpIpInterfaceConfiguration *const data, //kCipUdintUdintUdintUdintUdintString
|
|
|
- CipMessageRouterRequest *const message_router_request,
|
|
|
- CipMessageRouterResponse *const message_router_response) {
|
|
|
-
|
|
|
- int number_of_decoded_bytes = -1;
|
|
|
-
|
|
|
- CipTcpIpInterfaceConfiguration if_cfg;
|
|
|
- CipUdint tmp_ip;
|
|
|
-
|
|
|
- if (IsIOConnectionActive()) {
|
|
|
- message_router_response->general_status = kCipErrorDeviceStateConflict;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
- if (kTcpipCfgCtrlStaticIp
|
|
|
- != (g_tcpip.config_control & kTcpipCfgCtrlMethodMask)) {
|
|
|
- message_router_response->general_status = kCipErrorObjectStateConflict;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
- memset(&if_cfg, 0, sizeof if_cfg);
|
|
|
- tmp_ip = GetUdintFromMessage(&(message_router_request->data));
|
|
|
- if_cfg.ip_address = htonl(tmp_ip);
|
|
|
- tmp_ip = GetUdintFromMessage(&(message_router_request->data));
|
|
|
- if_cfg.network_mask = htonl(tmp_ip);
|
|
|
- tmp_ip = GetUdintFromMessage(&(message_router_request->data));
|
|
|
- if_cfg.gateway = htonl(tmp_ip);
|
|
|
- tmp_ip = GetUdintFromMessage(&(message_router_request->data));
|
|
|
- if_cfg.name_server = htonl(tmp_ip);
|
|
|
- tmp_ip = GetUdintFromMessage(&(message_router_request->data));
|
|
|
- if_cfg.name_server_2 = htonl(tmp_ip);
|
|
|
-
|
|
|
- CipUint domain_name_length = GetUintFromMessage(
|
|
|
- &(message_router_request->data));
|
|
|
- if (domain_name_length > 48) { /* see Vol. 2, Table 5-4.3 Instance Attributes */
|
|
|
- message_router_response->general_status = kCipErrorTooMuchData;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
- SetCipStringByData(&if_cfg.domain_name, domain_name_length,
|
|
|
- message_router_request->data);
|
|
|
- domain_name_length = (domain_name_length + 1) & (~0x0001u); /* Align for possible pad byte */
|
|
|
- OPENER_TRACE_INFO("Domain: ds %hu '%s'\n",
|
|
|
- domain_name_length,
|
|
|
- if_cfg.domain_name.string);
|
|
|
-
|
|
|
- if (!IsValidNetworkConfig(&if_cfg)
|
|
|
- || (domain_name_length > 0
|
|
|
- && !IsValidDomain(if_cfg.domain_name.string))) {
|
|
|
- message_router_response->general_status =
|
|
|
- kCipErrorInvalidAttributeValue;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
-
|
|
|
- *data = if_cfg; //write data to attribute
|
|
|
- number_of_decoded_bytes = 20 + domain_name_length;
|
|
|
-
|
|
|
- /* Tell that this configuration change becomes active after a reset */
|
|
|
- g_tcpip.status |= kTcpipStatusIfaceCfgPend;
|
|
|
- message_router_response->general_status = kCipErrorSuccess;
|
|
|
-
|
|
|
- return number_of_decoded_bytes;
|
|
|
+ CipTcpIpInterfaceConfiguration *const data, //kCipUdintUdintUdintUdintUdintString
|
|
|
+ CipMessageRouterRequest *const message_router_request,
|
|
|
+ CipMessageRouterResponse *const message_router_response) {
|
|
|
+
|
|
|
+ int number_of_decoded_bytes = -1;
|
|
|
+
|
|
|
+ CipTcpIpInterfaceConfiguration if_cfg;
|
|
|
+ CipUdint tmp_ip;
|
|
|
+
|
|
|
+ if ( IsIOConnectionActive() ) {
|
|
|
+ message_router_response->general_status = kCipErrorDeviceStateConflict;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+ if ( kTcpipCfgCtrlStaticIp
|
|
|
+ != (g_tcpip.config_control & kTcpipCfgCtrlMethodMask) ) {
|
|
|
+ message_router_response->general_status = kCipErrorObjectStateConflict;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+ memset(&if_cfg, 0, sizeof if_cfg);
|
|
|
+ tmp_ip = GetUdintFromMessage( &(message_router_request->data) );
|
|
|
+ if_cfg.ip_address = htonl(tmp_ip);
|
|
|
+ tmp_ip = GetUdintFromMessage( &(message_router_request->data) );
|
|
|
+ if_cfg.network_mask = htonl(tmp_ip);
|
|
|
+ tmp_ip = GetUdintFromMessage( &(message_router_request->data) );
|
|
|
+ if_cfg.gateway = htonl(tmp_ip);
|
|
|
+ tmp_ip = GetUdintFromMessage( &(message_router_request->data) );
|
|
|
+ if_cfg.name_server = htonl(tmp_ip);
|
|
|
+ tmp_ip = GetUdintFromMessage( &(message_router_request->data) );
|
|
|
+ if_cfg.name_server_2 = htonl(tmp_ip);
|
|
|
+
|
|
|
+ CipUint domain_name_length = GetUintFromMessage(
|
|
|
+ &(message_router_request->data) );
|
|
|
+ if (domain_name_length > 48) { /* see Vol. 2, Table 5-4.3 Instance Attributes */
|
|
|
+ message_router_response->general_status = kCipErrorTooMuchData;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+ SetCipStringByData(&if_cfg.domain_name, domain_name_length,
|
|
|
+ message_router_request->data);
|
|
|
+ domain_name_length = (domain_name_length + 1) & (~0x0001u); /* Align for possible pad byte */
|
|
|
+ OPENER_TRACE_INFO("Domain: ds %hu '%s'\n",
|
|
|
+ domain_name_length,
|
|
|
+ if_cfg.domain_name.string);
|
|
|
+
|
|
|
+ if ( !IsValidNetworkConfig(&if_cfg)
|
|
|
+ || ( domain_name_length > 0
|
|
|
+ && !IsValidDomain(if_cfg.domain_name.string) ) ) {
|
|
|
+ message_router_response->general_status =
|
|
|
+ kCipErrorInvalidAttributeValue;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ *data = if_cfg; //write data to attribute
|
|
|
+ number_of_decoded_bytes = 20 + domain_name_length;
|
|
|
+
|
|
|
+ /* Tell that this configuration change becomes active after a reset */
|
|
|
+ g_tcpip.status |= kTcpipStatusIfaceCfgPend;
|
|
|
+ message_router_response->general_status = kCipErrorSuccess;
|
|
|
+
|
|
|
+ return number_of_decoded_bytes;
|
|
|
|
|
|
}
|
|
|
|
|
|
int DecodeCipTcpIpInterfaceHostName( /* Attribute 6 */
|
|
|
- CipString *const data,
|
|
|
- CipMessageRouterRequest *const message_router_request,
|
|
|
- CipMessageRouterResponse *const message_router_response) {
|
|
|
-
|
|
|
- int number_of_decoded_bytes = -1;
|
|
|
-
|
|
|
- CipString tmp_host_name = {
|
|
|
- .length = 0u,
|
|
|
- .string = NULL
|
|
|
- };
|
|
|
- CipUint host_name_length =
|
|
|
- GetUintFromMessage(&(message_router_request->data) );
|
|
|
- if (host_name_length > 64) { /* see RFC 1123 on more details */
|
|
|
- message_router_response->general_status = kCipErrorTooMuchData;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
- SetCipStringByData(&tmp_host_name,
|
|
|
- host_name_length,
|
|
|
- message_router_request->data);
|
|
|
- host_name_length = (host_name_length + 1) & (~0x0001u); /* Align for possible pad byte */
|
|
|
- OPENER_TRACE_INFO("Host Name: ds %hu '%s'\n",
|
|
|
- host_name_length,
|
|
|
- tmp_host_name.string);
|
|
|
-
|
|
|
- if (!IsValidNameLabel(tmp_host_name.string) ) {
|
|
|
- message_router_response->general_status =
|
|
|
- kCipErrorInvalidAttributeValue;
|
|
|
- return number_of_decoded_bytes;
|
|
|
- }
|
|
|
-
|
|
|
- *data = tmp_host_name; //write data to attribute
|
|
|
-
|
|
|
- /* Tell that this configuration change becomes active after a reset */
|
|
|
- g_tcpip.status |= kTcpipStatusIfaceCfgPend;
|
|
|
- message_router_response->general_status = kCipErrorSuccess;
|
|
|
-
|
|
|
- return number_of_decoded_bytes;
|
|
|
+ CipString *const data,
|
|
|
+ CipMessageRouterRequest *const message_router_request,
|
|
|
+ CipMessageRouterResponse *const message_router_response) {
|
|
|
+
|
|
|
+ int number_of_decoded_bytes = -1;
|
|
|
+
|
|
|
+ CipString tmp_host_name = {
|
|
|
+ .length = 0u,
|
|
|
+ .string = NULL
|
|
|
+ };
|
|
|
+ CipUint host_name_length =
|
|
|
+ GetUintFromMessage( &(message_router_request->data) );
|
|
|
+ if (host_name_length > 64) { /* see RFC 1123 on more details */
|
|
|
+ message_router_response->general_status = kCipErrorTooMuchData;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+ SetCipStringByData(&tmp_host_name,
|
|
|
+ host_name_length,
|
|
|
+ message_router_request->data);
|
|
|
+ host_name_length = (host_name_length + 1) & (~0x0001u); /* Align for possible pad byte */
|
|
|
+ OPENER_TRACE_INFO("Host Name: ds %hu '%s'\n",
|
|
|
+ host_name_length,
|
|
|
+ tmp_host_name.string);
|
|
|
+
|
|
|
+ if ( !IsValidNameLabel(tmp_host_name.string) ) {
|
|
|
+ message_router_response->general_status =
|
|
|
+ kCipErrorInvalidAttributeValue;
|
|
|
+ return number_of_decoded_bytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ *data = tmp_host_name; //write data to attribute
|
|
|
+
|
|
|
+ /* Tell that this configuration change becomes active after a reset */
|
|
|
+ g_tcpip.status |= kTcpipStatusIfaceCfgPend;
|
|
|
+ message_router_response->general_status = kCipErrorSuccess;
|
|
|
+
|
|
|
+ return number_of_decoded_bytes;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif /* defined (OPENER_TCPIP_IFACE_CFG_SETTABLE) && 0 != OPENER_TCPIP_IFACE_CFG_SETTABLE*/
|
|
|
|
|
|
int DecodeCipTcpIpInterfaceEncapsulationInactivityTimeout( /* Attribute 13 */
|
|
|
- CipUint *const data,
|
|
|
- CipMessageRouterRequest *const message_router_request,
|
|
|
- CipMessageRouterResponse *const message_router_response) {
|
|
|
+ CipUint *const data,
|
|
|
+ CipMessageRouterRequest *const message_router_request,
|
|
|
+ CipMessageRouterResponse *const message_router_response) {
|
|
|
|
|
|
int number_of_decoded_bytes = -1;
|
|
|
|