| OpENer - Open Source EtherNet/IP(TM)  I/O Target Stack
    2.1
    | 
This file contains the public interface of the encapsulation layer. More...
Go to the source code of this file.
| Data Structures | |
| struct | encapsulation_data | 
| struct | encapsulation_interface_information | 
| Macros | |
| #define | ENCAPSULATION_HEADER_LENGTH 24 | 
| Typedefs | |
| typedef struct encapsulation_data | EncapsulationData | 
| typedef struct encapsulation_interface_information | EncapsulationInterfaceInformation | 
| typedef struct enip_message | ENIPMessage | 
| Enumerations | |
| enum | EncapsulationProtocolErrorCode { kEncapsulationProtocolSuccess = 0x0000, kEncapsulationProtocolInvalidCommand = 0x0001, kEncapsulationProtocolInsufficientMemory = 0x0002, kEncapsulationProtocolIncorrectData = 0x0003, kEncapsulationProtocolInvalidSessionHandle = 0x0064, kEncapsulationProtocolInvalidLength = 0x0065, kEncapsulationProtocolUnsupportedProtocol = 0x0069 } | 
| definition of status codes in encapsulation protocol All other codes are either legacy codes, or reserved for future use  More... | |
| Functions | |
| void | CloseClass3ConnectionBasedOnSession (size_t encapsulation_session_handle) | 
| void | CloseEncapsulationSessionBySockAddr (const CipConnectionObject *const connection_object) | 
| void | CloseSessionBySessionHandle (const CipConnectionObject *const connection_object) | 
| EipInt16 | CreateEncapsulationStructure (const EipUint8 *receive_buffer, int receive_buffer_length, EncapsulationData *const encapsulation_data) | 
| copy data from pa_buf in little endian to host in structure.  More... | |
| void | EncapsulateListIdentityResponseMessage (const EncapsulationData *const receive_data, ENIPMessage *const outgoing_message) | 
| void | EncapsulationInit (void) | 
| Initialize the encapsulation layer.  More... | |
| void | EncapsulationShutDown (void) | 
| Shutdown the encapsulation layer.  More... | |
| void | GenerateEncapsulationHeader (const EncapsulationData *const receive_data, const size_t command_specific_data_length, const size_t session_handle, const EncapsulationProtocolErrorCode encapsulation_protocol_status, ENIPMessage *const outgoing_message) | 
| size_t | GetSessionFromSocket (const int socket_handle) | 
| void | HandleReceivedListInterfacesCommand (const EncapsulationData *const receive_data, ENIPMessage *const outgoing_message) | 
| void | HandleReceivedListServicesCommand (const EncapsulationData *const receive_data, ENIPMessage *const outgoing_message) | 
| generate reply with "Communications Services" + compatibility Flags.  More... | |
| void | HandleReceivedRegisterSessionCommand (int socket, const EncapsulationData *const receive_data, ENIPMessage *const outgoing_message) | 
| EipStatus | HandleReceivedSendRequestResponseDataCommand (const EncapsulationData *const receive_data, const struct sockaddr *const originator_address, ENIPMessage *const outgoing_message) | 
| Call UCMM or Message Router if UCMM not implemented.  More... | |
| void | ManageEncapsulationMessages (const MilliSeconds elapsed_time) | 
| Handle delayed encapsulation message responses.  More... | |
| void | RemoveSession (const int socket) | 
| void | SkipEncapsulationHeader (ENIPMessage *const outgoing_message) | 
This file contains the public interface of the encapsulation layer.
Definition in file encap.h.
| #define ENCAPSULATION_HEADER_LENGTH 24 | 
Definition at line 22 of file encap.h.
Referenced by CreateEncapsulationStructure(), HandleDataOnTcpSocket(), HandleReceivedListIdentityCommandUdp(), NotifyConnectedCommonPacketFormat(), and SkipEncapsulationHeader().
| typedef struct encapsulation_data EncapsulationData | 
| typedef struct enip_message ENIPMessage | 
definition of status codes in encapsulation protocol All other codes are either legacy codes, or reserved for future use
| void CloseClass3ConnectionBasedOnSession | ( | size_t | encapsulation_session_handle | ) | 
Definition at line 906 of file encap.c.
References cip_connection_object::associated_encapsulation_session, cip_connection_object::connection_close_function, connection_list, ConnectionObjectGetTransportClassTriggerTransportClass(), doubly_linked_list_node::data, DoublyLinkedList::first, kConnectionObjectTransportClassTriggerTransportClass3, and doubly_linked_list_node::next.
Referenced by CheckEncapsulationInactivity(), CloseSession(), HandleReceivedUnregisterSessionCommand(), and RemoveSession().
| void CloseEncapsulationSessionBySockAddr | ( | const CipConnectionObject *const | connection_object | ) | 
Definition at line 874 of file encap.c.
References CloseSession(), FreeErrorMessage(), g_registered_sessions, GetErrorMessage(), GetSocketErrorNumber(), OPENER_NUMBER_OF_SUPPORTED_SESSIONS, OPENER_TRACE_ERR, and cip_connection_object::originator_address.
Referenced by HandleIoConnectionTimeOut().
| void CloseSessionBySessionHandle | ( | const CipConnectionObject *const | connection_object | ) | 
Definition at line 813 of file encap.c.
References cip_connection_object::associated_encapsulation_session, CloseTcpSocket(), g_registered_sessions, and OPENER_TRACE_INFO.
Referenced by Class3ConnectionTimeoutHandler().
| EipInt16 CreateEncapsulationStructure | ( | const EipUint8 * | receive_buffer, | 
| int | receive_buffer_length, | ||
| EncapsulationData *const | encapsulation_data | ||
| ) | 
copy data from pa_buf in little endian to host in structure.
| receive_buffer | Received message | 
| receive_buffer_length | Length of the data in receive_buffer. Might be more than one message | 
| encapsulation_data | structure to which data shall be copied | 
Definition at line 774 of file encap.c.
References encapsulation_data::command_code, encapsulation_data::communication_buffer_start, encapsulation_data::current_communication_buffer_position, encapsulation_data::data_length, ENCAPSULATION_HEADER_LENGTH, GetDintFromMessage(), GetIntFromMessage(), kSenderContextSize, encapsulation_data::options, encapsulation_data::sender_context, encapsulation_data::session_handle, and encapsulation_data::status.
Referenced by HandleReceivedExplictTcpData(), and HandleReceivedExplictUdpData().
| void EncapsulateListIdentityResponseMessage | ( | const EncapsulationData *const | receive_data, | 
| ENIPMessage *const | outgoing_message | ||
| ) | 
Array of USINT - length 8 shall be set to zero
Definition at line 436 of file encap.c.
References AddDintToMessage(), AddIntToMessage(), enip_message::current_message_position, device_type_, EncapsulateIpAddress(), GenerateEncapsulationHeader(), CipTcpIpNetworkInterfaceConfiguration::ip_address, kEncapsulationProtocolSuccess, kSupportedProtocolVersion, CipShortString::length, CipRevision::major_revision, CipRevision::minor_revision, MoveMessageNOctets(), product_code_, serial_number_, status_, CipShortString::string, enip_message::used_message_length, and vendor_id_.
Referenced by HandleReceivedListIdentityCommandTcp(), and HandleReceivedListIdentityCommandUdp().
| void GenerateEncapsulationHeader | ( | const EncapsulationData *const | receive_data, | 
| const size_t | command_specific_data_length, | ||
| const size_t | session_handle, | ||
| const EncapsulationProtocolErrorCode | encapsulation_protocol_status, | ||
| ENIPMessage *const | outgoing_message | ||
| ) | 
Definition at line 317 of file encap.c.
References AddDintToMessage(), AddIntToMessage(), encapsulation_data::command_code, enip_message::current_message_position, kSenderContextSize, encapsulation_data::sender_context, and enip_message::used_message_length.
Referenced by EncapsulateListIdentityResponseMessage(), EncapsulateRegisterSessionCommandResponseMessage(), HandleReceivedInvalidCommand(), HandleReceivedListInterfacesCommand(), HandleReceivedListServicesCommand(), HandleReceivedSendRequestResponseDataCommand(), HandleReceivedSendUnitDataCommand(), HandleReceivedUnregisterSessionCommand(), NotifyCommonPacketFormat(), and NotifyConnectedCommonPacketFormat().
| size_t GetSessionFromSocket | ( | const int | socket_handle | ) | 
Definition at line 897 of file encap.c.
References g_registered_sessions, and OPENER_NUMBER_OF_SUPPORTED_SESSIONS.
Referenced by CheckEncapsulationInactivity().
| void HandleReceivedListInterfacesCommand | ( | const EncapsulationData *const | receive_data, | 
| ENIPMessage *const | outgoing_message | ||
| ) | 
Definition at line 381 of file encap.c.
References AddIntToMessage(), enip_message::current_message_position, GenerateEncapsulationHeader(), kEncapsulationProtocolSuccess, and enip_message::used_message_length.
Referenced by HandleReceivedExplictTcpData(), and HandleReceivedExplictUdpData().
| void HandleReceivedListServicesCommand | ( | const EncapsulationData *const | receive_data, | 
| ENIPMessage *const | outgoing_message | ||
| ) | 
generate reply with "Communications Services" + compatibility Flags.
| receive_data | pointer to structure with received data | 
| outgoing_message | The outgoing ENIP message | 
Definition at line 345 of file encap.c.
References AddIntToMessage(), encapsulation_interface_information::capability_flags, enip_message::current_message_position, encapsulation_interface_information::encapsulation_protocol_version, GenerateEncapsulationHeader(), kEncapsulationProtocolSuccess, encapsulation_interface_information::length, encapsulation_interface_information::name_of_service, encapsulation_interface_information::type_code, and enip_message::used_message_length.
Referenced by HandleReceivedExplictTcpData(), and HandleReceivedExplictUdpData().
| void HandleReceivedRegisterSessionCommand | ( | int | socket, | 
| const EncapsulationData *const | receive_data, | ||
| ENIPMessage *const | outgoing_message | ||
| ) | 
Definition at line 556 of file encap.c.
References encapsulation_data::current_communication_buffer_position, EncapsulateRegisterSessionCommandResponseMessage(), g_actual_time, g_registered_sessions, g_timestamps, GetFreeSessionIndex(), GetIntFromMessage(), kEncapsulationProtocolInsufficientMemory, kEncapsulationProtocolInvalidCommand, kEncapsulationProtocolSuccess, kEncapsulationProtocolUnsupportedProtocol, kSessionStatusInvalid, kSupportedProtocolVersion, OPENER_NUMBER_OF_SUPPORTED_SESSIONS, OPENER_TRACE_INFO, SocketTimerArrayGetEmptySocketTimer(), SocketTimerSetLastUpdate(), and SocketTimerSetSocket().
Referenced by HandleReceivedExplictTcpData().
| EipStatus HandleReceivedSendRequestResponseDataCommand | ( | const EncapsulationData *const | receive_data, | 
| const struct sockaddr *const | originator_address, | ||
| ENIPMessage *const | outgoing_message | ||
| ) | 
Call UCMM or Message Router if UCMM not implemented.
| receive_data | Pointer to structure with data and header information. | 
| originator_address | Address of the originator as received from socket | 
| outgoing_message | The outgoing ENIP message | 
Definition at line 698 of file encap.c.
References CheckRegisteredSessions(), encapsulation_data::current_communication_buffer_position, encapsulation_data::data_length, GenerateEncapsulationHeader(), GetDintFromMessage(), GetIntFromMessage(), InitializeENIPMessage(), kEipStatusError, kEipStatusOkSend, kEncapsulationProtocolInvalidSessionHandle, kSessionStatusValid, NotifyCommonPacketFormat(), and encapsulation_data::session_handle.
Referenced by HandleReceivedExplictTcpData().
| void RemoveSession | ( | const int | socket | ) | 
Definition at line 835 of file encap.c.
References CloseClass3ConnectionBasedOnSession(), g_registered_sessions, OPENER_NUMBER_OF_SUPPORTED_SESSIONS, and OPENER_TRACE_INFO.
Referenced by CheckEncapsulationInactivity(), HandleDataOnTcpSocket(), and NetworkHandlerProcessOnce().
| void SkipEncapsulationHeader | ( | ENIPMessage *const | outgoing_message | ) | 
Definition at line 312 of file encap.c.
References enip_message::current_message_position, ENCAPSULATION_HEADER_LENGTH, and MoveMessageNOctets().
Referenced by NotifyCommonPacketFormat(), and NotifyConnectedCommonPacketFormat().