OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OpENer User interface

This is the public interface of the OpENer. It provides all function needed to implement an EtherNet/IP enabled slave-device. More...

Collaboration diagram for OpENer User interface:

Modules

 Callback Functions Demanded by OpENer
 These functions have to implemented in order to give the OpENer a method to inform the application on certain state changes.
 

Typedefs

typedef EipStatus(* CipServiceFunction )(CipInstance *const instance, CipMessageRouterRequest *const message_router_request, CipMessageRouterResponse *const message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
 Signature definition for the implementation of CIP services. More...
 
typedef void(* ConnectionCloseFunction )(CipConnectionObject *connection_object)
 Function prototype for handling the closing of connections. More...
 
typedef EipStatus(* ConnectionReceiveDataFunction )(CipConnectionObject *connection_object, const EipUint8 *data, const EipUint16 data_length)
 Function prototype for receiving data via a connection. More...
 
typedef EipStatus(* ConnectionSendDataFunction )(CipConnectionObject *connection_object)
 Function prototype for sending data via a connection. More...
 
typedef void(* ConnectionTimeoutFunction )(CipConnectionObject *connection_object)
 Function prototype for handling the timeout of connections. More...
 
typedef EipStatus(* OpenConnectionFunction )(CipConnectionObject *RESTRICT const connection_object, EipUint16 *const extended_error_code)
 Function prototype for handling the opening of connections. More...
 

Functions

CipInstanceAddCIPInstance (CipClass *RESTRICT const cip_class_to_add_instance, const EipUint32 instance_id)
 Create one instance of a given class with a certain instance number. More...
 
CipInstanceAddCipInstances (CipClass *RESTRICT const cip_object_to_add_instances, const int number_of_instances)
 Add a number of CIP instances to a given CIP class. More...
 
EipStatus AddConnectableObject (const EipUint32 class_id, OpenConnectionFunction open_connection_function)
 register open functions for an specific object. More...
 
void AllocateAttributeMasks (CipClass *target_class)
 Allocates Attribute bitmasks. More...
 
size_t CalculateIndex (EipUint16 attribute_number)
 Calculates Byte-Index of Attribute. More...
 
void CipStackInit (const EipUint16 unique_connection_id)
 Initialize and setup the CIP-stack. More...
 
void CloseSession (int socket_handle)
 Inform the encapsulation layer that the remote host has closed the connection. More...
 
void ConfigureDomainName (void)
 Configure the domain name of the device. More...
 
void ConfigureExclusiveOwnerConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly_id, const unsigned int input_assembly_id, const unsigned int configuration_assembly_id)
 Configures the connection point for an exclusive owner connection. More...
 
void ConfigureHostName (void)
 Configure the host name of the device. More...
 
void ConfigureInputOnlyConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly_id, const unsigned int input_assembly_id, const unsigned int configuration_assembly_id)
 Configures the connection point for an input only connection. More...
 
void ConfigureListenOnlyConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly_id, const unsigned int input_assembly_id, const unsigned int configuration_assembly_id)
 Configures the connection point for a listen only connection. More...
 
void ConfigureMacAddress (const char *network_interface)
 Configure the MAC address of the device. More...
 
EipStatus ConfigureNetworkInterface (const char *const network_interface)
 Configure the data of the network interface of the device. More...
 
CipInstanceCreateAssemblyObject (const EipUint32 instance_number, EipByte *const data, const EipUint16 data_length)
 Create an instance of an assembly object. More...
 
CipClassCreateCipClass (const EipUint32 class_id, const int number_of_class_attributes, const EipUint32 highest_class_attribute_number, const int number_of_class_services, const int number_of_instance_attributes, const EipUint32 highest_instance_attribute_number, const int number_of_instance_services, const int number_of_instances, char *name, const EipUint16 revision, InitializeCipClass initializer)
 Allocate memory for new CIP Class and attributes. More...
 
int DecodeData (const EipUint8 cip_data_type, void *const cip_data, const EipUint8 **const cip_message)
 Retrieve the given data according to CIP encoding from the message buffer. More...
 
int EncodeData (const EipUint8 cip_data_type, const void *const cip_data, EipUint8 **cip_message)
 Produce the data according to CIP encoding onto the message buffer. More...
 
CipAttributeStructGetCipAttribute (const CipInstance *const cip_instance, const EipUint16 attribute_number)
 Get a pointer to an instance's attribute. More...
 
CipClassGetCipClass (const EipUint32 class_id)
 Get a pointer to a CIP object with given class code. More...
 
CipInstanceGetCipInstance (const CipClass *RESTRICT const cip_object, const EipUint32 instance_number)
 Get a pointer to an instance. More...
 
EipStatus HandleReceivedConnectedData (const EipUint8 *const received_data, int received_data_length, struct sockaddr_in *from_address)
 Notify the connection manager that data for a connection has been received. More...
 
int HandleReceivedExplictTcpData (int socket_handle, EipUint8 *buffer, size_t length, int *number_of_remaining_bytes, struct sockaddr *originator_address, ENIPMessage *const outgoing_message)
 Notify the encapsulation layer that an explicit message has been received via TCP. More...
 
int HandleReceivedExplictUdpData (const int socket_handle, const struct sockaddr_in *from_address, const EipUint8 *buffer, const size_t buffer_length, int *number_of_remaining_bytes, bool unicast, ENIPMessage *const outgoing_message)
 Notify the encapsulation layer that an explicit message has been received via UDP. More...
 
void InsertAttribute (CipInstance *const cip_instance, const EipUint16 attribute_number, const EipUint8 cip_data_type, void *const cip_data, const EipByte cip_flags)
 Insert an attribute in an instance of a CIP class. More...
 
void InsertService (const CipClass *const cip_class_to_add_service, const EipUint8 service_code, const CipServiceFunction service_function, char *const service_name)
 Insert a service in an instance of a CIP object. More...
 
EipStatus ManageConnections (MilliSeconds elapsed_time)
 Check if any of the connection timers (TransmissionTrigger or WatchdogTimeout) have timed out. More...
 
void SetDeviceSerialNumber (const EipUint32 serial_number)
 Set the serial number of the device's identity object. More...
 
void SetDeviceStatus (const EipUint16 device_status)
 Set the current status of the device. More...
 
void ShutdownCipStack (void)
 Shutdown of the CIP stack. More...
 
EipStatus TriggerConnections (unsigned int output_assembly_id, unsigned int input_assembly_id)
 Trigger the production of an application triggered connection. More...
 

Detailed Description

This is the public interface of the OpENer. It provides all function needed to implement an EtherNet/IP enabled slave-device.

Typedef Documentation

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

Signature definition for the implementation of CIP services.

CIP services have to follow this signature in order to be handled correctly by the stack.

Parameters
instancethe instance which was referenced in the service request
message_router_requestrequest data
message_router_responsestorage for the response data, including a buffer for extended data
Returns
kEipOkSend if service could be executed successfully and a response should be sent

Definition at line 277 of file ciptypes.h.

typedef void(* ConnectionCloseFunction)(CipConnectionObject *connection_object)

Function prototype for handling the closing of connections.

Parameters
connection_objectThe connection object which is closing the connection

Definition at line 320 of file opener_api.h.

typedef EipStatus(* ConnectionReceiveDataFunction)(CipConnectionObject *connection_object, const EipUint8 *data, const EipUint16 data_length)

Function prototype for receiving data via a connection.

Parameters
connection_objectThe connection object which connection timed out
dataThe payload of the CIP message
data_lengthLength of the payload
Returns
Stack status

Definition at line 349 of file opener_api.h.

typedef EipStatus(* ConnectionSendDataFunction)(CipConnectionObject *connection_object)

Function prototype for sending data via a connection.

Parameters
connection_objectThe connection object which connection timed out
Returns
EIP stack status

Definition at line 337 of file opener_api.h.

typedef void(* ConnectionTimeoutFunction)(CipConnectionObject *connection_object)

Function prototype for handling the timeout of connections.

Parameters
connection_objectThe connection object which connection timed out

Definition at line 327 of file opener_api.h.

typedef EipStatus(* OpenConnectionFunction)(CipConnectionObject *RESTRICT const connection_object, EipUint16 *const extended_error_code)

Function prototype for handling the opening of connections.

Parameters
connection_objectThe connection object which is opening the connection
extended_error_codeThe returned error code of the connection object
Returns
CIP error code

Definition at line 310 of file opener_api.h.

Function Documentation

CipInstance* AddCIPInstance ( CipClass *RESTRICT const  cip_class_to_add_instance,
const EipUint32  instance_id 
)

Create one instance of a given class with a certain instance number.

This function can be used for creating out of order instance numbers

Parameters
cip_class_to_add_instancethe class the instance should be created for
instance_idthe instance id of the created instance
Returns
pointer to the created instance, if an instance with the given id already exists the existing is returned an no new instance is created

Definition at line 178 of file cipcommon.c.

References AddCipInstances(), GetCipInstance(), and cip_instance::instance_number.

Referenced by CreateAssemblyObject().

Here is the call graph for this function:

Here is the caller graph for this function:

CipInstance* AddCipInstances ( CipClass *RESTRICT const  cip_object_to_add_instances,
const int  number_of_instances 
)

Add a number of CIP instances to a given CIP class.

The required number of instances are created in a block, but are attached to the class as a linked list. The instances are numbered sequentially – i.e. the first node in the chain is instance 1, the second is 2, and so on. You can add new instances at any time (you do not have to create all the instances of a class at the same time) deleting instances once they have been created is not supported out-of-order instance numbers are not supported running out of memory while creating new instances causes an assert.

Parameters
cip_object_to_add_instancesCIP object the instances should be added
number_of_instancesnumber of instances to be generated.
Returns
pointer to the first of the new instances 0 on error

Definition at line 132 of file cipcommon.c.

References cip_instance::attributes, cip_instance::cip_class, CipCalloc(), cip_instance::instance_number, cip_instance::next, OPENER_ASSERT, and OPENER_TRACE_INFO.

Referenced by AddCIPInstance(), and CreateCipClass().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus AddConnectableObject ( const EipUint32  class_id,
OpenConnectionFunction  open_connection_function 
)

register open functions for an specific object.

With this function any object can be enabled to be a target for forward open/close request.

Parameters
class_idThe class ID
open_connection_functionPointer to the function handling the open process
Returns
EIP_OK on success

Definition at line 1443 of file cipconnectionmanager.c.

References ConnectionManagementHandling::class_id, kEipStatusError, kEipStatusOk, and ConnectionManagementHandling::open_connection_function.

Referenced by ConnectionManagerInit().

Here is the caller graph for this function:

void AllocateAttributeMasks ( CipClass target_class)

Allocates Attribute bitmasks.

Parameters
target_classClass, in which the bitmasks will be inserted.

Definition at line 885 of file cipcommon.c.

References CalculateIndex(), CipCalloc(), cip_class::class_name, cip_class::get_all_bit_mask, cip_class::get_single_bit_mask, cip_class::highest_attribute_number, OPENER_TRACE_INFO, and cip_class::set_bit_mask.

Referenced by CreateCipClass().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t CalculateIndex ( EipUint16  attribute_number)

Calculates Byte-Index of Attribute.

Parameters
attribute_numberAttribute number.

Definition at line 895 of file cipcommon.c.

Referenced by AllocateAttributeMasks(), GetAttributeAll(), GetAttributeSingle(), GetAttributeSingleEthernetLink(), GetAttributeSingleTcpIpInterface(), InsertAttribute(), SetAttributeSingleQoS(), and SetAttributeSingleTcp().

Here is the caller graph for this function:

void CipStackInit ( const EipUint16  unique_connection_id)

Initialize and setup the CIP-stack.

Parameters
unique_connection_idvalue passed to Connection_Manager_Init() to form a "per boot" unique connection ID.

Definition at line 36 of file cipcommon.c.

References ApplicationInitialization(), CipAssemblyInitialize(), CipEthernetLinkInit(), CipIdentityInit(), CipMessageRouterInit(), CipQoSInit(), CipTcpIpInterfaceInit(), ConnectionManagerInit(), EncapsulationInit(), kEipStatusOk, and OPENER_ASSERT.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void CloseSession ( int  socket_handle)

Inform the encapsulation layer that the remote host has closed the connection.

According to the specifications that will clean up and close the session in the encapsulation layer.

Parameters
socket_handlethe handler to the socket of the closed connection

Definition at line 822 of file encap.c.

References CloseClass3ConnectionBasedOnSession(), CloseTcpSocket(), g_registered_sessions, OPENER_NUMBER_OF_SUPPORTED_SESSIONS, and OPENER_TRACE_INFO.

Referenced by CloseEncapsulationSessionBySockAddr().

Here is the call graph for this function:

Here is the caller graph for this function:

void ConfigureDomainName ( void  )

Configure the domain name of the device.

Parameters
domain_namethe domain name to be used

Definition at line 87 of file networkconfig.c.

Referenced by main().

Here is the caller graph for this function:

void ConfigureExclusiveOwnerConnectionPoint ( const unsigned int  connection_number,
const unsigned int  output_assembly_id,
const unsigned int  input_assembly_id,
const unsigned int  configuration_assembly_id 
)

Configures the connection point for an exclusive owner connection.

Parameters
connection_numberThe number of the exclusive owner connection. The enumeration starts with 0. Has to be smaller than OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS.
output_assembly_idID of the O-to-T point to be used for this connection
input_assembly_idID of the T-to-O point to be used for this connection
configuration_assembly_idID of the configuration point to be used for this connection

Definition at line 85 of file appcontype.c.

References ExclusiveOwnerConnection::config_assembly, ExclusiveOwnerConnection::input_assembly, OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS, and ExclusiveOwnerConnection::output_assembly.

Referenced by ApplicationInitialization().

Here is the caller graph for this function:

void ConfigureHostName ( void  )

Configure the host name of the device.

Parameters
host_namethe host name to be used

Definition at line 218 of file networkconfig.c.

Referenced by main().

Here is the caller graph for this function:

void ConfigureInputOnlyConnectionPoint ( const unsigned int  connection_number,
const unsigned int  output_assembly_id,
const unsigned int  input_assembly_id,
const unsigned int  configuration_assembly_id 
)

Configures the connection point for an input only connection.

Parameters
connection_numberThe number of the input only connection. The enumeration starts with 0. Has to be smaller than OPENER_CIP_NUM_INPUT_ONLY_CONNS.
output_assembly_idID of the O-to-T point to be used for this connection
input_assembly_idID of the T-to-O point to be used for this connection
configuration_assembly_idID of the configuration point to be used for this connection

Definition at line 100 of file appcontype.c.

References InputOnlyConnection::config_assembly, InputOnlyConnection::input_assembly, OPENER_CIP_NUM_INPUT_ONLY_CONNS, and InputOnlyConnection::output_assembly.

Referenced by ApplicationInitialization().

Here is the caller graph for this function:

void ConfigureListenOnlyConnectionPoint ( const unsigned int  connection_number,
const unsigned int  output_assembly_id,
const unsigned int  input_assembly_id,
const unsigned int  configuration_assembly_id 
)

Configures the connection point for a listen only connection.

Parameters
connection_numberThe number of the input only connection. The enumeration starts with 0. Has to be smaller than OPENER_CIP_NUM_LISTEN_ONLY_CONNS.
output_assembly_idID of the O-to-T point to be used for this connection
input_assembly_idID of the T-to-O point to be used for this connection
configuration_assembly_idID of the configuration point to be used for this connection

Definition at line 113 of file appcontype.c.

References ListenOnlyConnection::config_assembly, ListenOnlyConnection::input_assembly, OPENER_CIP_NUM_LISTEN_ONLY_CONNS, and ListenOnlyConnection::output_assembly.

Referenced by ApplicationInitialization().

Here is the caller graph for this function:

void ConfigureMacAddress ( const char *  network_interface)

Configure the MAC address of the device.

Parameters
mac_addressthe hardware MAC address of the network interface

Definition at line 31 of file networkconfig.c.

References CloseSocket(), g_ethernet_link, OPENER_TRACE_INFO, and CipEthernetLinkObject::physical_address.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus ConfigureNetworkInterface ( const char *const  network_interface)

Configure the data of the network interface of the device.

This function setup the data of the network interface needed by OpENer. The multicast address is automatically calculated from he given data.

Parameters
ip_addressthe current IP address of the device
subnet_maskthe subnet mask to be used
gateway_addressthe gateway address
Returns
kEipStatusOk if the configuring worked otherwise kEipStatusError

Definition at line 27 of file networkconfig.c.

Referenced by main().

Here is the caller graph for this function:

CipInstance* CreateAssemblyObject ( const EipUint32  instance_number,
EipByte *const  data,
const EipUint16  data_length 
)

Create an instance of an assembly object.

Parameters
instance_numberinstance number of the assembly object to create
datapointer to the data the assembly object should contain
data_lengthlength of the assembly object's data
Returns
pointer to the instance of the created assembly object. NULL on error

Assembly Objects for Configuration Data:

The CIP stack treats configuration assembly objects the same way as any other assembly object. In order to support a configuration assembly object it has to be created with this function. The notification on received configuration data is handled with the AfterAssemblyDataReceived.

Definition at line 80 of file cipassembly.c.

References AddCIPInstance(), CipCalloc(), CreateAssemblyClass(), CipByteArray::data, GetCipClass(), InsertAttribute(), kCipByteArray, kCipUint, kGetableSingle, kSetAndGetAble, and CipByteArray::length.

Referenced by ApplicationInitialization().

Here is the call graph for this function:

Here is the caller graph for this function:

CipClass* CreateCipClass ( const EipUint32  class_id,
const int  number_of_class_attributes,
const EipUint32  highest_class_attribute_number,
const int  number_of_class_services,
const int  number_of_instance_attributes,
const EipUint32  highest_instance_attribute_number,
const int  number_of_instance_services,
const int  number_of_instances,
char *  name,
const EipUint16  revision,
InitializeCipClass  initializer 
)

Allocate memory for new CIP Class and attributes.

The new CIP class will be registered at the stack to be able for receiving explicit messages.

Parameters
class_idclass ID of the new class
number_of_class_attributesnumber of class attributes
highest_class_attribute_numberHighest attribute number from the set of implemented class attributes
number_of_class_servicesnumber of class services
number_of_instance_attributesNumber of implemented instance attributes
highest_instance_attribute_numberHighest attribute number from the set of implemented instance attributes
number_of_instance_servicesnumber of instance services
number_of_instancesnumber of initial instances to create
nameclass name (for debugging class structure)
revisionclass revision
initializerFor non-standard implementation of class attributes, function realizes specific implementation
Returns
pointer to new class object 0 on error
int DecodeData ( const EipUint8  cip_data_type,
void *const  cip_data,
const EipUint8 **const  cip_message 
)

Retrieve the given data according to CIP encoding from the message buffer.

This function may be used in in own services for handling data from the requester (e.g., setAttributeSingle).

Parameters
cip_data_typethe CIP type to decode
cip_datapointer to data value to written.
cip_messagepointer to memory where the data should be taken from
Returns
length of taken bytes -1 .. error

Definition at line 616 of file cipcommon.c.

References GetDintFromMessage(), GetIntFromMessage(), kCipBool, kCipByte, kCipDint, kCipDword, kCipInt, kCipLint, kCipLword, kCipReal, kCipShortString, kCipSint, kCipString, kCipUdint, kCipUint, kCipUlint, kCipUsint, kCipWord, CipShortString::length, CipString::length, CipShortString::string, and CipString::string.

Here is the call graph for this function:

int EncodeData ( const EipUint8  cip_data_type,
const void *const  cip_data,
EipUint8 **  cip_message 
)

Produce the data according to CIP encoding onto the message buffer.

This function may be used in own services for sending data back to the requester (e.g., getAttributeSingle for special structs).

Parameters
cip_data_typethe cip type to encode
cip_datapointer to data value.
cip_messagepointer to memory where response should be written
Returns
length of attribute in bytes -1 .. error

Definition at line 450 of file cipcommon.c.

References AddDintToMessage(), AddIntToMessage(), AddSintToMessage(), CipByteArray::data, EncodeData(), EncodeEPath(), CipTcpIpNetworkInterfaceConfiguration::gateway, CipTcpIpNetworkInterfaceConfiguration::ip_address, kCip6Usint, kCipBool, kCipByte, kCipByteArray, kCipDate, kCipDateAndTime, kCipDint, kCipDword, kCipEngUnit, kCipEpath, kCipFtime, kCipInt, kCipItime, kCipLint, kCipLreal, kCipLtime, kCipLword, kCipMemberList, kCipReal, kCipShortString, kCipSint, kCipStime, kCipString, kCipString2, kCipStringN, kCipTime, kCipTimeOfDay, kCipUdint, kCipUdintUdintUdintUdintUdintString, kCipUint, kCipUlint, kCipUsint, kCipUsintUsint, kCipWord, kInternalUint6, CipByteArray::length, CipShortString::length, CipString::length, CipRevision::major_revision, CipRevision::minor_revision, CipTcpIpNetworkInterfaceConfiguration::name_server, CipTcpIpNetworkInterfaceConfiguration::name_server_2, CipTcpIpNetworkInterfaceConfiguration::network_mask, OPENER_TRACE_INFO, CipShortString::string, and CipString::string.

Referenced by EncodeData(), EncodeInterfaceCapability(), EncodeInterfaceControl(), EncodeInterfaceCounters(), EncodeMediaCounters(), GetAttributeSingle(), and GetAttributeSingleTcpIpInterface().

Here is the call graph for this function:

Here is the caller graph for this function:

CipAttributeStruct* GetCipAttribute ( const CipInstance *const  cip_instance,
const EipUint16  attribute_number 
)

Get a pointer to an instance's attribute.

As instances and objects are selfsimilar this function can also be used to retrieve the attribute of an object.

Parameters
cip_instancepointer to the instance the attribute belongs to
attribute_numbernumber of the attribute to retrieve
Returns
pointer to attribute 0 if instance is not in the object

Definition at line 373 of file cipcommon.c.

References CipAttributeStruct::attribute_number, cip_instance::attributes, cip_instance::cip_class, cip_class::number_of_attributes, and OPENER_TRACE_WARN.

Referenced by GetAttributeSingle(), GetAttributeSingleEthernetLink(), GetAttributeSingleTcpIpInterface(), GetEncapsulationInactivityTimeout(), HandleConfigData(), SetAssemblyAttributeSingle(), SetAttributeSingleQoS(), SetAttributeSingleTcp(), SetupIoConnectionOriginatorToTargetConnectionPoint(), SetupIoConnectionTargetToOriginatorConnectionPoint(), and ShutdownAssemblies().

Here is the caller graph for this function:

CipClass* GetCipClass ( const EipUint32  class_id)

Get a pointer to a CIP object with given class code.

Parameters
class_idclass ID of the object to retrieve
Returns
pointer to CIP Object 0 if object is not present in the stack

Definition at line 125 of file cipmessagerouter.c.

References cip_message_router_object::cip_class, and GetRegisteredObject().

Referenced by CreateAssemblyObject(), CreateCipClass(), HandleConfigData(), SetupIoConnectionOriginatorToTargetConnectionPoint(), SetupIoConnectionTargetToOriginatorConnectionPoint(), and ShutdownAssemblies().

Here is the call graph for this function:

Here is the caller graph for this function:

CipInstance* GetCipInstance ( const CipClass *RESTRICT const  cip_object,
const EipUint32  instance_number 
)

Get a pointer to an instance.

Parameters
cip_objectpointer to the object the instance belongs to
instance_numbernumber of the instance to retrieve
Returns
pointer to CIP Instance 0 if instance is not in the object

Definition at line 135 of file cipmessagerouter.c.

References cip_message_router_object::cip_class, and cip_instance::next.

Referenced by AddCIPInstance(), CipEthernetLinkInit(), CipIdentityInit(), CipQoSInit(), CipTcpIpInterfaceInit(), HandleConfigData(), NotifyClass(), ParseConnectionPath(), SetupIoConnectionOriginatorToTargetConnectionPoint(), and SetupIoConnectionTargetToOriginatorConnectionPoint().

Here is the caller graph for this function:

EipStatus HandleReceivedConnectedData ( const EipUint8 *const  received_data,
int  received_data_length,
struct sockaddr_in *  from_address 
)

Notify the connection manager that data for a connection has been received.

This function should be invoked by the network layer.

Parameters
received_datapointer to the buffer of data that has been received
received_data_lengthnumber of bytes in the data buffer
from_addressaddress from which the data has been received. Only data from the connections originator may be accepted. Avoids connection hijacking
Returns
EIP_OK on success

Definition at line 243 of file cipconnectionmanager.c.

References CipCommonPacketFormatData::address_item, AddressData::connection_identifier, cip_connection_object::connection_receive_data_function, ConnectionObjectResetInactivityWatchdogTimerValue(), ConnectionObjectResetLastPackageInactivityTimerValue(), CreateCommonPacketFormatStructure(), AddressItem::data, DataItem::data, CipCommonPacketFormatData::data_item, cip_connection_object::eip_level_sequence_count_consuming, g_common_packet_format_data_item, GetConnectedObject(), kCipItemIdConnectedDataItem, kCipItemIdConnectionAddress, kCipItemIdSequencedAddressItem, kEipStatusError, kEipStatusOk, DataItem::length, OPENER_TRACE_WARN, cip_connection_object::originator_address, SEQ_GT32, AddressData::sequence_number, AddressItem::type_id, and DataItem::type_id.

Referenced by CheckAndHandleConsumingUdpSockets().

Here is the call graph for this function:

Here is the caller graph for this function:

int HandleReceivedExplictTcpData ( int  socket_handle,
EipUint8 buffer,
size_t  length,
int *  number_of_remaining_bytes,
struct sockaddr *  originator_address,
ENIPMessage *const  outgoing_message 
)

Notify the encapsulation layer that an explicit message has been received via TCP.

Parameters
socket_handleSocket handle from which data is received.
bufferBuffer that contains the received data. This buffer will also contain the response if one is to be sent.
lengthLength of the data in buffer.
number_of_remaining_bytesReturn how many bytes of the input are left over after we're done here
originator_addressAddress struct of the message originator
outgoing_messageThe outgoing ENIP message
Returns
length of reply that need to be sent back

Definition at line 153 of file encap.c.

References encapsulation_data::command_code, CreateEncapsulationStructure(), HandleReceivedInvalidCommand(), HandleReceivedListIdentityCommandTcp(), HandleReceivedListInterfacesCommand(), HandleReceivedListServicesCommand(), HandleReceivedRegisterSessionCommand(), HandleReceivedSendRequestResponseDataCommand(), HandleReceivedSendUnitDataCommand(), HandleReceivedUnregisterSessionCommand(), kEipStatusOk, kEipStatusOkSend, kEncapsulationCommandListIdentity, kEncapsulationCommandListInterfaces, kEncapsulationCommandListServices, kEncapsulationCommandNoOperation, kEncapsulationCommandRegisterSession, kEncapsulationCommandSendRequestReplyData, kEncapsulationCommandSendUnitData, kEncapsulationCommandUnregisterSession, kEncapsulationHeaderOptionsFlag, kEncapsulationProtocolSuccess, OPENER_TRACE_INFO, encapsulation_data::options, and encapsulation_data::status.

Referenced by HandleDataOnTcpSocket().

Here is the call graph for this function:

Here is the caller graph for this function:

int HandleReceivedExplictUdpData ( const int  socket_handle,
const struct sockaddr_in *  from_address,
const EipUint8 buffer,
const size_t  buffer_length,
int *  number_of_remaining_bytes,
bool  unicast,
ENIPMessage *const  outgoing_message 
)

Notify the encapsulation layer that an explicit message has been received via UDP.

Parameters
socket_handlesocket handle from which data is received.
from_addressremote address from which the data is received.
bufferbuffer that contains the received data. This buffer will also contain the response if one is to be sent.
buffer_lengthlength of the data in buffer.
number_of_remaining_bytesreturn how many bytes of the input are left over after we're done here
unicastWas the data receieved from a multicast address
outgoing_messageOutgoing ENIP message
Returns
length of reply that need to be sent back

Definition at line 237 of file encap.c.

References encapsulation_data::command_code, CreateEncapsulationStructure(), encapsulation_data::data_length, HandleReceivedListIdentityCommandTcp(), HandleReceivedListIdentityCommandUdp(), HandleReceivedListInterfacesCommand(), HandleReceivedListServicesCommand(), kEipStatusOk, kEipStatusOkSend, kEncapsulationCommandListIdentity, kEncapsulationCommandListInterfaces, kEncapsulationCommandListServices, kEncapsulationCommandNoOperation, kEncapsulationCommandRegisterSession, kEncapsulationCommandSendRequestReplyData, kEncapsulationCommandSendUnitData, kEncapsulationCommandUnregisterSession, kEncapsulationHeaderOptionsFlag, kEncapsulationProtocolInvalidCommand, kEncapsulationProtocolSuccess, OPENER_TRACE_INFO, encapsulation_data::options, encapsulation_data::status, and enip_message::used_message_length.

Referenced by CheckAndHandleUdpGlobalBroadcastSocket(), and CheckAndHandleUdpUnicastSocket().

Here is the call graph for this function:

Here is the caller graph for this function:

void InsertAttribute ( CipInstance *const  cip_instance,
const EipUint16  attribute_number,
const EipUint8  cip_data_type,
void *const  cip_data,
const EipByte  cip_flags 
)

Insert an attribute in an instance of a CIP class.

Note that attributes are stored in an array pointer in the instance the attributes array is not expandable if you insert an attributes that has already been defined, the previous attributes will be replaced

Parameters
cip_instancePointer to CIP class instance (Instance 0)
attribute_numberNumber of attribute to be inserted.
cip_data_typeType of attribute to be inserted.
cip_dataPointer to data of attribute.
cip_flagsFlags to indicate set-ability and get-ability of attribute.

Definition at line 304 of file cipcommon.c.

References CipAttributeStruct::attribute_flags, CipAttributeStruct::attribute_number, cip_instance::attributes, CalculateIndex(), cip_instance::cip_class, cip_class::class_instance, CipAttributeStruct::data, cip_instance::instance_number, kGetableAll, kGetableSingle, kSetable, cip_class::number_of_attributes, OPENER_ASSERT, OPENER_TRACE_ERR, and CipAttributeStruct::type.

Referenced by CipEthernetLinkInit(), CipIdentityInit(), CipQoSInit(), CipTcpIpInterfaceInit(), CreateAssemblyObject(), CreateCipClass(), InitializeCipIdentiy(), InitializeCipMessageRouterClass(), and InitializeConnectionManager().

Here is the call graph for this function:

Here is the caller graph for this function:

void InsertService ( const CipClass *const  cip_class_to_add_service,
const EipUint8  service_code,
const CipServiceFunction  service_function,
char *const  service_name 
)

Insert a service in an instance of a CIP object.

Note that services are stored in an array pointer in the class object the service array is not expandable if you insert a service that has already been defined, the previous service will be replaced

Parameters
cip_class_to_add_servicepointer to CIP object. (may be also instance# 0)
service_codeservice code of service to be inserted.
service_functionpointer to function which represents the service.
service_namename of the service

Definition at line 346 of file cipcommon.c.

References cip_service_struct::name, OPENER_ASSERT, OPENER_TRACE_INFO, cip_service_struct::service_function, and cip_service_struct::service_number.

Referenced by CipEthernetLinkInit(), CipIdentityInit(), CipMessageRouterInit(), CipQoSInit(), CipTcpIpInterfaceInit(), ConnectionManagerInit(), CreateAssemblyClass(), and CreateCipClass().

Here is the caller graph for this function:

EipStatus ManageConnections ( MilliSeconds  elapsed_time)

Check if any of the connection timers (TransmissionTrigger or WatchdogTimeout) have timed out.

If the a timeout occurs the function performs the necessary action. This function should be called periodically once every kOpenerTimerTickInMilliSeconds milliseconds. In order to simplify the algorithm if more time was lapsed, the elapsed time since the last call of the function is given as a parameter.

Parameters
elapsed_timeElapsed time in milliseconds since the last call of ManageConnections
Returns
EIP_OK on success

Definition at line 650 of file cipconnectionmanager.c.

References cip_connection_object::connection_send_data_function, cip_connection_object::connection_serial_number, cip_connection_object::connection_timeout_function, ConnectionObjectGetExpectedPacketRate(), ConnectionObjectGetRequestedPacketInterval(), ConnectionObjectGetState(), ConnectionObjectGetTransportClassTriggerDirection(), ConnectionObjectGetTransportClassTriggerProductionTrigger(), ConnectionObjectResetProductionInhibitTimer(), cip_connection_object::consuming_instance, doubly_linked_list_node::data, DoublyLinkedList::first, HandleApplication(), cip_connection_object::inactivity_watchdog_timer, kConnectionObjectStateEstablished, kConnectionObjectTransportClassTriggerDirectionServer, kConnectionObjectTransportClassTriggerProductionTriggerCyclic, kEipStatusError, kEipStatusOk, kUdpCommuncationDirectionProducing, cip_connection_object::last_package_watchdog_timer, ManageEncapsulationMessages(), doubly_linked_list_node::next, OPENER_ASSERT, OPENER_TRACE_ERR, OPENER_TRACE_INFO, cip_connection_object::production_inhibit_timer, cip_connection_object::socket, and cip_connection_object::transmission_trigger_timer.

Referenced by NetworkHandlerProcessOnce().

Here is the call graph for this function:

Here is the caller graph for this function:

void SetDeviceSerialNumber ( const EipUint32  serial_number)

Set the serial number of the device's identity object.

Parameters
serial_numberunique 32 bit number identifying the device

Private functions, sets the devices serial number

Parameters
serial_numberThe serial number of the device

Definition at line 54 of file cipidentity.c.

References serial_number_.

Referenced by main().

Here is the caller graph for this function:

void SetDeviceStatus ( const EipUint16  status)

Set the current status of the device.

Parameters
device_statusthe new status value

Set the current status of the device.

Parameters
statusThe serial number of the device

Definition at line 61 of file cipidentity.c.

References status_.

void ShutdownCipStack ( void  )

Shutdown of the CIP stack.

This will

  • close all open I/O connections,
  • close all open explicit connections, and
  • free all memory allocated by the stack.

Memory allocated by the application will not be freed. This has to be done by the application!

Definition at line 61 of file cipcommon.c.

References CloseAllConnections(), DeleteAllClasses(), EncapsulationShutDown(), ShutdownAssemblies(), and ShutdownTcpIpInterface().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus TriggerConnections ( unsigned int  output_assembly_id,
unsigned int  input_assembly_id 
)

Trigger the production of an application triggered connection.

This will issue the production of the specified connection at the next possible occasion. Depending on the values for the RPI and the production inhibit timer. The application is informed via the EIP_BOOL8 BeforeAssemblyDataSend(S_CIP_Instance *pa_pstInstance) callback function when the production will happen. This function should only be invoked from void HandleApplication(void).

The connection can only be triggered if the application is established and it is of application application triggered type.

Parameters
output_assembly_idthe output assembly connection point of the connection
input_assembly_idthe input assembly connection point of the connection
Returns
EIP_OK on success

Definition at line 1478 of file cipconnectionmanager.c.

References ConnectionObjectGetTransportClassTriggerProductionTrigger(), cip_connection_object::consumed_path, doubly_linked_list_node::data, DoublyLinkedList::first, connection_path_epath::instance_id, kConnectionObjectTransportClassTriggerProductionTriggerApplicationObject, kEipStatusError, kEipStatusOk, cip_connection_object::produced_path, and cip_connection_object::transmission_trigger_timer.

Here is the call graph for this function: