79 io_connection_object) ) {
140 io_connection_object) ) {
145 #ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
146 if ( (data_size > 0) && (!is_heartbeat) ) {
154 connection_object->correct_originator_to_target_size =
169 while (NULL != node &&
182 io_connection_object) !=
195 io_connection_object) !=
202 io_connection_object) !=
240 io_connection_object) ) {
245 #ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
246 if ( (data_size > 0) && (!is_heartbeat) ) {
254 connection_object->correct_target_to_originator_size =
284 if(NULL == io_connection_object) {
290 if(0 != *extended_error) {
306 target_to_originator_connection_type ==
317 if (originator_to_target_connection_type !=
320 io_connection_object,
328 if (target_to_originator_connection_type !=
331 io_connection_object,
379 struct sockaddr_in addr =
380 { .sin_family = AF_INET, .sin_addr.s_addr = INADDR_ANY, .sin_port = htons(
387 if (socket == kEipInvalidSocket) {
389 "cannot create UDP socket in OpenPointToPointConnection\n");
394 addr.sin_addr.s_addr = INADDR_ANY;
435 if (socket == kEipInvalidSocket) {
437 "cannot create UDP socket in OpenPointToPointConnection\n");
471 if (NULL == existing_connection_object) {
474 common_packet_format_data);
479 cip_produced_connection_id;
501 connection_object->
remote_address.sin_port = common_packet_format_data
504 connection_object->
remote_address.sin_addr.s_addr = common_packet_format_data
509 starting_multicast_address;
530 int address_info_item_which_contains_o_to_t = -1;
531 int address_info_item_which_contains_t_to_o = -1;
535 address_info_item_which_contains_o_to_t = 0;
538 address_info_item_which_contains_o_to_t = 1;
545 address_info_item_which_contains_t_to_o = 0;
548 address_info_item_which_contains_t_to_o = 1;
554 j = address_info_item_which_contains_o_to_t;
558 j = address_info_item_which_contains_t_to_o;
565 "no suitable addr info item available / O->T: %d, T->O: %d, Selector: %d, direction: %d\n",
566 address_info_item_which_contains_o_to_t,
567 address_info_item_which_contains_t_to_o,
588 "Sockaddr Info Item with wrong sin family value received\n");
593 struct sockaddr_in socket_address = {0};
594 socket_address.sin_family = ntohs(
596 socket_address.sin_addr.s_addr =
602 int socket =
CreateUdpSocket(direction, &socket_address, qos_for_socket);
603 if (socket == kEipInvalidSocket) {
607 connection_object->
socket[direction] = socket;
643 connection_manager_status =
646 "Hit an Ownership conflict in cipioconnection.c occurrence 1");
651 connection_manager_status =
654 "Hit an Ownership conflict in cipioconnection.c occurrence 2");
665 connection_manager_status =
670 return connection_manager_status;
686 && (kEipInvalidSocket
693 if (NULL != next_non_control_master_connection) {
696 next_non_control_master_connection->
socket[
750 if (kEipInvalidSocket
755 if (NULL != next_non_control_master_connection) {
756 next_non_control_master_connection->
socket[
830 common_packet_format_data->
data_item.
length = producing_instance_attributes
832 #ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
849 #ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
855 producing_instance_attributes->
data,
856 producing_instance_attributes->
length);
874 bool no_new_data =
false;
889 if (data_length > 0) {
891 #ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
894 const uint32_t kRunBitMask = 0x0001;
895 if((kRunBitMask & nRunIdleBuf) == 1) {
933 if (originator_to_target_connection_type ==
937 connection_object, common_packet_format_data)
942 }
else if (originator_to_target_connection_type ==
946 common_packet_format_data)
953 if (target_to_originator_connection_type ==
957 common_packet_format_data)
962 }
else if (target_to_originator_connection_type ==
967 common_packet_format_data)
ConnectionObjectConnectionType
EipStatus EstablishIoConnection(CipConnectionObject *RESTRICT const connection_object, EipUint16 *const extended_error)
Establishes a new IO Type 1 Connection.
CipInstance * producing_instance
Tracing infrastructure for OpENer.
void CloseCommunicationChannelsAndRemoveFromActiveConnectionsList(CipConnectionObject *connection_object)
close the communication channels of the given connection and remove it from the active connections li...
EipUint8 * g_config_data_buffer
struct sockaddr_in remote_address
EipStatus SendUdpData(struct sockaddr_in *socket_data, int socket_handle, EipUint8 *data, EipUint16 data_length)
Create a producing or consuming UDP socket.
CipAttributeStruct * attributes
ConnectionReceiveDataFunction connection_receive_data_function
DoublyLinkedListNode * first
void CloseEncapsulationSessionBySockAddr(const CipConnectionObject *const connection_object)
EipUint32 eip_level_sequence_count_producing
CipOctet message_buffer[PC_OPENER_ETHERNET_BUFFER_SIZE]
Class is a subclass of Instance.
#define OPENER_ASSERT(assertion)
EipStatus OpenProducingPointToPointConnection(CipConnectionObject *connection_object, CipCommonPacketFormatData *common_packet_format_data)
#define SEQ_LEQ16(a, b)
similar macros for comparing 16 bit sequence numbers
UdpCommuncationDirection
Communication direction of an UDP socket; consuming is receiver, producing is sender.
ConnectionObjectConnectionType ConnectionObjectGetTToOConnectionType(const CipConnectionObject *const connection_object)
EipUint32 GetDintFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT32 from *buffer and converts little endian to host.
CipOctet * current_message_position
void RemoveFromActiveConnections(CipConnectionObject *const connection_object)
Removes connection from the list of active connections.
void ConnectionObjectSetProductionInhibitTime(CipConnectionObject *const connection_object, const CipUint production_inhibit_time)
CipCommonPacketFormatData g_common_packet_format_data_item
Data storage for the any CPF data Currently we are single threaded and need only one CPF at the time...
CipConnectionObject * GetNextNonControlMasterConnection(const EipUint32 input_point)
check if there exists an producing multicast exclusive owner or listen only connection that should pr...
EipStatus OpenMulticastConnection(UdpCommuncationDirection direction, CipConnectionObject *connection_object, CipCommonPacketFormatData *common_packet_format_data)
Open a Multicast connection dependent on direction.
CipDword attribute_id_or_connection_point
Responsible for Endianess conversion.
#define OPENER_TRACE_ERR(...)
void InitializeENIPMessage(ENIPMessage *const message)
MulticastAddressConfiguration g_multicast_configuration
#9 The multicast configuration for this device
CipConnectionObject * GetExistingProducerMulticastConnection(const EipUint32 input_point)
Check if there exists already an exclusive owner or listen only connection which produces the input a...
EipStatus NotifyAssemblyConnectedDataReceived(CipInstance *const instance, const EipUint8 *const data, const EipUint16 data_length)
notify an Assembly object that data has been received for it.
EipStatus SendConnectedData(CipConnectionObject *connection_object)
Send the data from the produced CIP Object of the connection via the socket of the connection object ...
ConnectionCloseFunction connection_close_function
CipUdint ConnectionObjectGetTToORequestedPacketInterval(const CipConnectionObject *const connection_object)
void CheckIoConnectionEvent(unsigned int output_assembly_id, unsigned int input_assembly_id, IoConnectionEvent io_connection_event)
Inform the application on changes occurred for a connection.
int AssembleIOMessage(const CipCommonPacketFormatData *const common_packet_format_data_item, ENIPMessage *const outgoing_message)
EipStatus OpenCommunicationChannels(CipConnectionObject *connection_object)
Take the data given in the connection object structure and open the necessary communication channels...
void ConnectionObjectInitializeEmpty(CipConnectionObject *const connection_object)
void CloseAllConnectionsForInputWithSameType(const EipUint32 input_point, const ConnectionObjectInstanceType instance_type)
Close all connection producing the same input and have the same type (i.e., listen only or input only...
bool ConnectionWithSameConfigPointExists(const EipUint32 config_point)
Check if there is an established connection that uses the same config point.
DoublyLinkedListNode * next
ConnectionObjectPriority ConnectionObjectGetTToOPriority(const CipConnectionObject *const connection_object)
EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(CipConnectionObject *const io_connection_object, CipConnectionObject *const RESTRICT connection_object)
int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer)
converts UINT16 data from host to little endian an writes it to buffer.
EipStatus
EIP stack status enum.
CipUint sequence_count_producing
CipInstance * consuming_instance
int AddDintToMessage(const EipUint32 data, EipUint8 **const buffer)
Converts UINT32 data from host to little endian and writes it to buffer.
ConnectionObjectConnectionType ConnectionObjectGetOToTConnectionType(const CipConnectionObject *const connection_object)
#define OPENER_TRACE_INFO(...)
void CloseUdpSocket(int socket_handle)
CipConnectionPathEpath produced_path
EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(CipConnectionObject *const io_connection_object, CipConnectionObject *const RESTRICT connection_object)
void HandleIoConnectionTimeOut(CipConnectionObject *connection_object)
EipStatus OpenConsumingPointToPointConnection(CipConnectionObject *const connection_object, CipCommonPacketFormatData *const common_packet_format_data)
Open a Point2Point connection dependent on pa_direction.
CipUint ConnectionObjectGetProductionInhibitTime(const CipConnectionObject *const connection_object)
CipIdentitySetExtendedDeviceStatus(CipIdentityExtendedStatus extended_status)
CipInstance * GetCipInstance(const CipClass *RESTRICT const cip_class, EipUint32 instance_number)
Get a pointer to an instance.
EipUint32 sequence_number
CipClass * GetCipClass(const EipUint32 class_id)
Get a pointer to a CIP object with given class code.
CipConnectionPathEpath configuration_path
EipStatus HandleReceivedIoConnectionData(CipConnectionObject *connection_object, const EipUint8 *data, EipUint16 data_length)
CipAttributeStruct * GetCipAttribute(const CipInstance *const instance, const EipUint16 attribute_number)
Get a pointer to an instance's attribute.
Public interface of the TCP/IP Interface Object.
DoublyLinkedList connection_list
ConnectionTimeoutFunction connection_timeout_function
EipUint16 HandleConfigData(CipConnectionObject *connection_object)
uint64_t transmission_trigger_timer
#define OPENER_TRACE_WARN(...)
unsigned int g_config_data_length
void RunIdleChanged(EipUint32 run_idle_value)
Inform the application that the Run/Idle State has been changed by the originator.
int CreateUdpSocket(UdpCommuncationDirection communication_direction, struct sockaddr_in *socket_data, CipUsint qos_for_socket)
create a producing or consuming UDP socket
CipConnectionPathEpath consumed_path
CipUdint cip_produced_connection_id
CipUint consumed_connection_path_length
EipUint32 g_run_idle_state
CipUint produced_connection_path_length
size_t ConnectionObjectGetOToTConnectionSize(const CipConnectionObject *const connection_object)
const int kOpenerEipIoUdpPort
EipUint32 connection_identifier
CipConnectionObject * GetIoConnectionForConnectionData(CipConnectionObject *const RESTRICT connection_object, EipUint16 *const extended_error)
check if for the given connection data received in a forward_open request a suitable connection is av...
EipUint16 GetIntFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT16 from *buffer and converts little endian to host.
ConnectionSendDataFunction connection_send_data_function
void CloseIoConnection(CipConnectionObject *connection_object)
size_t used_message_length
ConnectionObjectTransportClassTriggerProductionTrigger ConnectionObjectGetTransportClassTriggerProductionTrigger(const CipConnectionObject *const connection_object)
void ConnectionObjectSetState(CipConnectionObject *const connection_object, const ConnectionObjectState state)
CipUint sequence_count_consuming
EipBool8 BeforeAssemblyDataSend(CipInstance *instance)
Inform the application that the data of an assembly object will be sent.
EipStatus OpenProducingMulticastConnection(CipConnectionObject *connection_object, CipCommonPacketFormatData *common_packet_format_data)
EipUint16 ProcessProductionInhibitTime(CipConnectionObject *io_connection_object)
ConnectionObjectInstanceType ConnectionObjectGetInstanceType(const CipConnectionObject *const connection_object)
struct sockaddr_in originator_address
size_t ConnectionObjectGetTToOConnectionSize(const CipConnectionObject *const connection_object)
uint64_t inactivity_watchdog_timer
void ConnectionObjectGeneralConfiguration(CipConnectionObject *const connection_object)
Generate the ConnectionIDs and set the general configuration parameter in the given connection object...
void SetIoConnectionCallbacks(CipConnectionObject *const io_connection_object)
uint64_t last_package_watchdog_timer
void CheckForTimedOutConnectionsAndCloseTCPConnections(const CipConnectionObject *const connection_object, CloseSessionFunction CloseSessions)
void AddNewActiveConnection(const CipConnectionObject *const connection_object)
Insert the given connection object to the list of currently active and managed connections.
ConnectionObjectTransportClassTriggerTransportClass ConnectionObjectGetTransportClassTriggerTransportClass(const CipConnectionObject *const connection_object)
CipUdint starting_multicast_address
ConnectionObjectConnectionSizeType ConnectionObjectGetTToOConnectionSizeType(const CipConnectionObject *const connection_object)