OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ciptcpipinterface.c File Reference
#include <string.h>
#include "ciptcpipinterface.h"
#include "opener_user_conf.h"
#include "cipcommon.h"
#include "cipmessagerouter.h"
#include "ciperror.h"
#include "endianconv.h"
#include "cipethernetlink.h"
#include "opener_api.h"
#include "trace.h"
#include "cipassembly.h"
Include dependency graph for ciptcpipinterface.c:

Go to the source code of this file.

Functions

EipStatus CipTcpIpInterfaceInit ()
 Initializing the data structures of the TCP/IP interface object. More...
 
EipStatus GetAttributeAllTcpIpInterface (CipInstance *instance, CipMessageRouterRequest *message_router_request, CipMessageRouterResponse *message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
 
EipStatus GetAttributeSingleTcpIpInterface (CipInstance *instance, CipMessageRouterRequest *message_router_request, CipMessageRouterResponse *message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
 
EipStatus GetAttributeSingleTcpIpInterface (CipInstance *const RESTRICT instance, CipMessageRouterRequest *RESTRICT const message_router_request, CipMessageRouterResponse *RESTRICT const message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
 
EipUint16 GetEncapsulationInactivityTimeout (CipInstance *instance)
 Public Method to get Encapsulation Inactivity Timeout Value. More...
 
EipStatus SetAttributeSingleTcp (CipInstance *instance, CipMessageRouterRequest *message_router_request, CipMessageRouterResponse *message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
 
void ShutdownTcpIpInterface (void)
 Clean up the allocated data of the TCP/IP interface object. More...
 

Variables

CipDword configuration_capability_ = 0x04
 
CipDword configuration_control_ = 0x02
 
CipUint g_encapsulation_inactivity_timeout = 120
 #13 Number of seconds of inactivity before TCP connection is closed More...
 
MulticastAddressConfiguration g_multicast_configuration
 #9 The multicast configuration for this device More...
 
EipUint8 g_time_to_live_value = 1
 #8 the time to live value to be used for multi-cast connections More...
 
CipString hostname_
 
CipTcpIpNetworkInterfaceConfiguration interface_configuration_
 
CipEpath physical_link_object_
 
CipDword tcp_status_ = 0x1
 

Function Documentation

EipStatus CipTcpIpInterfaceInit ( void  )

Initializing the data structures of the TCP/IP interface object.

Returns
kEipStatusOk on success, otherwise kEipStatusError

Definition at line 165 of file ciptcpipinterface.c.

References configuration_capability_, configuration_control_, CreateCipClass(), g_encapsulation_inactivity_timeout, g_time_to_live_value, GetAttributeAllTcpIpInterface(), GetAttributeSingleTcpIpInterface(), GetCipInstance(), InsertAttribute(), InsertService(), kCipAny, kCipDword, kCipEpath, kCipString, kCipUdintUdintUdintUdintUdintString, kCipUint, kCipUsint, kEipStatusError, kEipStatusOk, kGetableSingleAndAll, kGetAttributeAll, kGetAttributeSingle, kSetAndGetAble, kSetAttributeSingle, SetAttributeSingleTcp(), and tcp_status_.

Referenced by CipStackInit().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus GetAttributeAllTcpIpInterface ( CipInstance instance,
CipMessageRouterRequest message_router_request,
CipMessageRouterResponse message_router_response,
struct sockaddr *  originator_address,
const int  encapsulation_session 
)

Definition at line 325 of file ciptcpipinterface.c.

References CipEpath::attribute_number, CipAttributeStruct::attribute_number, cip_instance::attributes, cip_instance::cip_class, CipMessageRouterResponse::data, CipMessageRouterResponse::data_length, GetAttributeSingleTcpIpInterface(), kEipStatusError, kEipStatusOkSend, cip_class::number_of_attributes, and CipMessageRouterRequest::request_path.

Referenced by CipTcpIpInterfaceInit().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus GetAttributeSingleTcpIpInterface ( CipInstance instance,
CipMessageRouterRequest message_router_request,
CipMessageRouterResponse message_router_response,
struct sockaddr *  originator_address,
const int  encapsulation_session 
)

Referenced by CipTcpIpInterfaceInit(), and GetAttributeAllTcpIpInterface().

Here is the caller graph for this function:

EipStatus GetAttributeSingleTcpIpInterface ( CipInstance *const RESTRICT  instance,
CipMessageRouterRequest *RESTRICT const  message_router_request,
CipMessageRouterResponse *RESTRICT const  message_router_response,
struct sockaddr *  originator_address,
const int  encapsulation_session 
)
EipUint16 GetEncapsulationInactivityTimeout ( CipInstance instance)

Public Method to get Encapsulation Inactivity Timeout Value.

Definition at line 384 of file ciptcpipinterface.c.

References CipAttributeStruct::data, GetCipAttribute(), and OPENER_ASSERT.

Here is the call graph for this function:

EipStatus SetAttributeSingleTcp ( CipInstance instance,
CipMessageRouterRequest message_router_request,
CipMessageRouterResponse message_router_response,
struct sockaddr *  originator_address,
const int  encapsulation_session 
)
void ShutdownTcpIpInterface ( void  )

Clean up the allocated data of the TCP/IP interface object.

Currently this is the host name string and the domain name string.

Definition at line 215 of file ciptcpipinterface.c.

References CipFree(), CipTcpIpNetworkInterfaceConfiguration::domain_name, and CipString::string.

Referenced by ShutdownCipStack().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

CipDword configuration_capability_ = 0x04

#2 This is a default value meaning that it is a DHCP client see 5-3.2.2.2 EIP specification

Definition at line 21 of file ciptcpipinterface.c.

Referenced by CipTcpIpInterfaceInit().

CipDword configuration_control_ = 0x02

#3 This is a TCP/IP object attribute. 0x02 means that the device shall obtain its interface configuration values via DHCP.

Definition at line 22 of file ciptcpipinterface.c.

Referenced by CipTcpIpInterfaceInit().

CipUint g_encapsulation_inactivity_timeout = 120

#13 Number of seconds of inactivity before TCP connection is closed

Currently we implemented with the default value of 120 seconds.

Definition at line 63 of file ciptcpipinterface.c.

Referenced by CheckEncapsulationInactivity(), CipTcpIpInterfaceInit(), and ResetDeviceToInitialConfiguration().

MulticastAddressConfiguration g_multicast_configuration
Initial value:
= { 0,
0,
1,
0
}

#9 The multicast configuration for this device

Currently we implement it non set-able and use the default allocation algorithm

Definition at line 53 of file ciptcpipinterface.c.

Referenced by ConfigureIpMacAddress(), ConfigureNetworkInterface(), CreateUdpSocket(), OpenMulticastConnection(), and OpenProducingMulticastConnection().

EipUint8 g_time_to_live_value = 1

#8 the time to live value to be used for multi-cast connections

Currently we implement it non set-able and with the default value of 1.

Definition at line 46 of file ciptcpipinterface.c.

Referenced by CipTcpIpInterfaceInit(), and CreateUdpSocket().

CipString hostname_
Initial value:
=
{ 0, NULL }

#6 Hostname

Definition at line 40 of file ciptcpipinterface.c.

Referenced by ConfigureHostName().

CipTcpIpNetworkInterfaceConfiguration interface_configuration_
Initial value:
=
{ 0,
0,
0,
0,
0,
{
0, NULL,
} }

#5 IP, network mask, gateway, name server 1 & 2, domain name

Definition at line 30 of file ciptcpipinterface.c.

Referenced by ConfigureDomainName(), ConfigureIpMacAddress(), and ConfigureNetworkInterface().

CipEpath physical_link_object_
Initial value:
=
{ 2,
1,
0
}

#4

Definition at line 23 of file ciptcpipinterface.c.

CipDword tcp_status_ = 0x1

#1 TCP status with 1 we indicate that we got a valid configuration from DHCP or BOOTP

Definition at line 20 of file ciptcpipinterface.c.

Referenced by CipTcpIpInterfaceInit().