13 #define CIP_CONNECTION_OBJECT_STATE_NON_EXISTENT 0U
14 #define CIP_CONNECTION_OBJECT_STATE_CONFIGURING 1U
15 #define CIP_CONNECTION_OBJECT_STATE_WAITING_FOR_CONNECTION_ID 2U
16 #define CIP_CONNECTION_OBJECT_STATE_ESTABLISHED 3U
17 #define CIP_CONNECTION_OBJECT_STATE_TIMEOUT 4U
18 #define CIP_CONNECTION_OBJECT_STATE_DEFERRED_DELETE 5U
19 #define CIP_CONNECTION_OBJECT_STATE_CLOSING 6U
21 #define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_EXPLICIT_MESSAGING 0
22 #define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_IO 1
23 #define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_CIP_BRIDGED 2
25 #define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_CYCLIC ( \
28 CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_CHANGE_OF_STATE ( \
31 CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_APPLICATION_OBJECT ( \
34 #define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_0 0
35 #define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_1 1
36 #define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_2 2
37 #define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_3 3
39 #define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_TRANSITION_TO_TIMED_OUT 0
40 #define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_AUTO_DELETE 1
41 #define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_AUTO_RESET 2
42 #define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_DEFERRED_DELETE 3
44 #define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_NULL 0
45 #define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_MULTICAST (1 << 13)
46 #define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_POINT_TO_POINT (1 << 14)
48 #define CIP_CONNECTION_OBJECT_PRIORITY_LOW 0
49 #define CIP_CONNECTION_OBJECT_PRIORITY_HIGH (1 << 10)
50 #define CIP_CONNECTION_OBJECT_PRIORITY_SCHEDULED (1 << 11)
51 #define CIP_CONNECTION_OBJECT_PRIORITY_URGENT (3 << 10)
65 for(
size_t i = 0; i < kNodesAmount; ++i) {
66 if(nodes[i].previous == NULL && nodes[i].next == NULL && nodes[i].data ==
99 memset( connection_object, 0,
sizeof(*connection_object) );
102 connection_object->
socket[0] = kEipInvalidSocket;
103 connection_object->
socket[1] = kEipInvalidSocket;
148 "ForwardOpen: ConConnID %" PRIu32
", ProdConnID %" PRIu32
178 switch (connection_object->
state) {
211 connection_object->
state =
215 connection_object->
state =
219 connection_object->
state =
223 connection_object->
state =
227 connection_object->
state =
231 connection_object->
state =
235 connection_object->
state =
289 return instance_type;
299 default:
return false;
312 default:
return false;
320 const CipByte TransportClassTriggerDirectionMask = 0x80;
322 TransportClassTriggerDirectionMask) ==
323 TransportClassTriggerDirectionMask ?
331 const CipByte kTransportClassTriggerProductionTriggerMask = 0x70;
335 kTransportClassTriggerProductionTriggerMask ) {
352 return production_trigger;
358 const CipByte kTransportClassTriggerTransportClassMask = 0x0F;
362 kTransportClassTriggerTransportClassMask ) {
378 return transport_class_trigger;
389 produced_connection_size) {
400 const CipUint consumed_connection_size) {
413 (kOpenerTimerTickInMilliSeconds * 1000);
414 if( 0 == remainder_to_resolution ) {
420 1000 - remainder_to_resolution / 1000);
428 (kOpenerTimerTickInMilliSeconds * 1000);
429 if( 0 == remainder_to_resolution ) {
437 kOpenerTimerTickInMilliSeconds - remainder_to_resolution / 1000 );
449 cip_produced_connection_id) {
461 cip_consumed_connection_id) {
485 return timeout_action;
491 watchdog_timeout_action) {
492 switch (watchdog_timeout_action) {
524 produced_connection_path_length) {
526 produced_connection_path_length;
537 consumed_connection_path_length) {
539 consumed_connection_path_length;
550 production_inhibit_time) {
557 const uint64_t kMinimumInitialTimeoutValue = 10000;
558 const uint64_t calculated_timeout_value =
562 (calculated_timeout_value >
563 kMinimumInitialTimeoutValue) ? calculated_timeout_value :
564 kMinimumInitialTimeoutValue;
597 const CipUint connection_serial_number) {
619 CipUdint originator_serial_number) {
630 CipUsint connection_timeout_multiplier) {
632 connection_timeout_multiplier;
642 const CipUdint requested_packet_interval) {
644 requested_packet_interval;
654 const CipUdint requested_packet_interval) {
656 requested_packet_interval;
661 const CipWord kOwnerMask = 0x80;
667 const CipWord kOwnerMask = 0x80;
672 const CipWord connection_parameters) {
673 const CipWord kConnectionTypeMask = 3 << 13;
674 switch(connection_parameters & kConnectionTypeMask) {
698 const CipWord connection_parameters) {
699 const CipWord kPriorityMask = 3 << 10;
701 switch(connection_parameters & kPriorityMask) {
731 const CipWord connection_parameters) {
732 const CipWord kConnectionSizeTypeMask = 1 << 9;
733 if(connection_parameters & kConnectionSizeTypeMask) {
753 const CipWord kConnectionSizeMask = 0x01FF;
754 return connection_parameters & kConnectionSizeMask;
793 connection_object->
socket[0] = kEipInvalidSocket;
794 connection_object->
socket[1] = kEipInvalidSocket;
850 const struct sockaddr *
const originator_address) {
851 return ( (
struct sockaddr_in *) originator_address )->sin_addr.s_addr ==
ConnectionObjectTransportClassTriggerDirection ConnectionObjectGetTransportClassTriggerDirection(const CipConnectionObject *const connection_object)
ConnectionObjectConnectionType
CipUint ConnectionObjectGetConnectionSerialNumber(const CipConnectionObject *const connection_object)
bool ConnectionObjectIsTypeNonLOIOConnection(const CipConnectionObject *const connection_object)
CipConnectionObject explicit_connection_object_pool[OPENER_CIP_NUM_EXPLICIT_CONNS]
Array of the available explicit connections.
CipUint ConnectionObjectGetConsumedConnectionPathLength(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_STATE_WAITING_FOR_CONNECTION_ID
void CipConnectionObjectListArrayFree(DoublyLinkedListNode **node)
CipUint consumed_connection_size
bool ConnectionObjectIsTypeIOConnection(const CipConnectionObject *const connection_object)
Tracing infrastructure for OpENer.
size_t ConnectionObjectGetConnectionSize(const CipWord connection_parameters)
#define CIP_CONNECTION_OBJECT_PRIORITY_SCHEDULED
CipUint ConnectionObjectGetProducedConnectionSize(const CipConnectionObject *const connection_object)
CipUint expected_packet_rate
bool ConnectionObjectIsTToORedundantOwner(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_0
#define OPENER_CIP_NUM_LISTEN_ONLY_CONNS
Define the number of supported listen only connections. Each of these connections has to be configure...
void ConnectionObjectSetCipProducedConnectionID(CipConnectionObject *const connection_object, const CipUdint cip_produced_connection_id)
CipUint ConnectionObjectGetExpectedPacketRate(const CipConnectionObject *const connection_object)
void ConnectionObjectSetWatchdogTimeoutAction(CipConnectionObject *const connection_object, const CipUsint watchdog_timeout_action)
EipUint32 eip_level_sequence_count_producing
void ConnectionObjectResetProductionInhibitTimer(CipConnectionObject *const connection_object)
bool CipConnectionObjectOriginatorHasSameIP(const CipConnectionObject *const connection_object, const struct sockaddr *const originator_address)
void ConnectionObjectSetInitialInactivityWatchdogTimerValue(CipConnectionObject *const connection_object)
#define OPENER_ASSERT(assertion)
CipUdint ConnectionObjectGetCipProducedConnectionID(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_STATE_CONFIGURING
CipUdint ConnectionObjectGetCipConsumedConnectionID(const CipConnectionObject *const connection_object)
void ConnectionObjectSetConsumedConnectionPathLength(CipConnectionObject *const connection_object, const CipUint consumed_connection_path_length)
ConnectionObjectConnectionType ConnectionObjectGetTToOConnectionType(const CipConnectionObject *const connection_object)
EipUint32 GetDintFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT32 from *buffer and converts little endian to host.
ConnectionObjectConnectionSizeType ConnectionObjectGetConnectionSizeType(const CipWord connection_parameters)
void ConnectionObjectSetProductionInhibitTime(CipConnectionObject *const connection_object, const CipUint production_inhibit_time)
ConnectionObjectWatchdogTimeoutAction
Possible values for the watch dog time out action of a connection.
void ConnectionObjectResetInactivityWatchdogTimerValue(CipConnectionObject *const connection_object)
CipUsint ConnectionObjectGetConnectionTimeoutMultiplier(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_CYCLIC
Responsible for Endianess conversion.
#define OPENER_TRACE_ERR(...)
CipByte transport_class_trigger
EipUint8 GetSintFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT8 from *buffer and converts little endian to host.
#define CIP_CONNECTION_OBJECT_STATE_NON_EXISTENT
#define OPENER_CIP_NUM_INPUT_ONLY_CONNS
Define the number of supported input only connections. Each of these connections has to be configured...
void ConnectionObjectResetLastPackageInactivityTimerValue(CipConnectionObject *const connection_object)
ConnectionObjectConnectionSizeType
void ConnectionObjectSetInstanceType(CipConnectionObject *const connection_object, const ConnectionObjectInstanceType instance_type)
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_CHANGE_OF_STATE
CipUint produced_connection_size
CipUint ConnectionObjectGetProducedConnectionPathLength(const CipConnectionObject *const connection_object)
CipUdint ConnectionObjectGetTToORequestedPacketInterval(const CipConnectionObject *const connection_object)
CipConnectionObject * CipConnectionObjectCreate(const CipOctet *message)
Array allocator.
#define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_IO
void ConnectionObjectInitializeEmpty(CipConnectionObject *const connection_object)
void ConnectionObjectDeepCopy(CipConnectionObject *RESTRICT destination, const CipConnectionObject *RESTRICT const source)
Copy the given connection data from source to destination.
void ConnectionObjectSetCipConsumedConnectionID(CipConnectionObject *const connection_object, const CipUdint cip_consumed_connection_id)
CipUdint t_to_o_requested_packet_interval
ConnectionObjectWatchdogTimeoutAction ConnectionObjectGetWatchdogTimeoutAction(const CipConnectionObject *const connection_object)
uint8_t CipOctet
Data types as defined in the CIP Specification Vol 1 Appendix C.
ConnectionObjectPriority ConnectionObjectGetTToOPriority(const CipConnectionObject *const connection_object)
void ConnectionObjectSetTToORequestedPacketInterval(CipConnectionObject *connection_object, const CipUdint requested_packet_interval)
void ConnectionObjectSetConsumedConnectionSize(CipConnectionObject *const connection_object, const CipUint consumed_connection_size)
bool ConnectionObjectEqualOriginator(const CipConnectionObject *const object1, const CipConnectionObject *const object2)
CipUsint ConnectionObjectGetInstanceTypeForAttribute(const CipConnectionObject *const connection_object)
ConnectionObjectInstanceType
CipUint sequence_count_producing
#define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_EXPLICIT_MESSAGING
ConnectionObjectTransportClassTriggerTransportClass
#define CIP_CONNECTION_OBJECT_INSTANCE_TYPE_CIP_BRIDGED
ConnectionObjectConnectionType ConnectionObjectGetOToTConnectionType(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_STATE_TIMEOUT
void ConnectionObjectResetSequenceCounts(CipConnectionObject *const connection_object)
void ConnectionObjectInitializeFromMessage(const CipOctet **message, CipConnectionObject *const connection_object)
#define OPENER_TRACE_INFO(...)
int MoveMessageNOctets(const int amount_of_bytes_moved, const CipOctet **message_runner)
CipUint connection_serial_number
ConnectionObjectConnectionType ConnectionObjectGetConnectionType(const CipWord connection_parameters)
ConnectionObjectConnectionSizeType ConnectionObjectGetOToTConnectionSizeType(const CipConnectionObject *const connection_object)
CipUdint originator_serial_number
CipUint ConnectionObjectGetProductionInhibitTime(const CipConnectionObject *const connection_object)
CipUint ConnectionObjectGetOriginatorVendorId(const CipConnectionObject *const connection_object)
void ConnectionObjectSetOToTRequestedPacketInterval(CipConnectionObject *connection_object, const CipUdint requested_packet_interval)
CipUdint ConnectionObjectGetOriginatorSerialNumber(const CipConnectionObject *const connection_object)
void ConnectionObjectSetExpectedPacketRate(CipConnectionObject *const connection_object)
Sets the expected packet rate according to the rules of the CIP specification.
#define OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS
Define the number of supported exclusive owner connections. Each of these connections has to be confi...
CipUdint cip_consumed_connection_id
ConnectionObjectState ConnectionObjectGetState(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_PRIORITY_URGENT
CipUint ConnectionObjectGetConsumedConnectionSize(const CipConnectionObject *const connection_object)
#define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_POINT_TO_POINT
CipUsint watchdog_timeout_action
#define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_NULL
#define CIP_CONNECTION_OBJECT_CONNECTION_TYPE_MULTICAST
CipUdint o_to_t_requested_packet_interval
#define OPENER_CIP_NUM_EXPLICIT_CONNS
Define the number of supported explicit connections. According to ODVA's PUB 70 this number should be...
void ConnectionObjectSetProducedConnectionPathLength(CipConnectionObject *const connection_object, const CipUint produced_connection_path_length)
ConnectionObjectPriority ConnectionObjectGetPriority(const CipWord connection_parameters)
CipUdint ConnectionObjectGetOToTRequestedPacketInterval(const CipConnectionObject *const connection_object)
uint64_t transmission_trigger_timer
#define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_AUTO_DELETE
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_1
#define CIP_CONNECTION_OBJECT_PRIORITY_HIGH
#define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_DEFERRED_DELETE
CipWord o_to_t_network_connection_parameters
CipUint originator_vendor_id
ConnectionObjectTransportClassTriggerDirection
ConnectionObjectPriority ConnectionObjectGetOToTPriority(const CipConnectionObject *const connection_object)
bool ConnectionObjectIsOToTRedundantOwner(const CipConnectionObject *const connection_object)
void ConnectionObjectSetConnectionTimeoutMultiplier(CipConnectionObject *connection_object, CipUsint connection_timeout_multiplier)
#define CIP_CONNECTION_OBJECT_STATE_CLOSING
CipUdint cip_produced_connection_id
uint64_t ConnectionObjectCalculateRegularInactivityWatchdogTimerValue(const CipConnectionObject *const connection_object)
CipUint consumed_connection_path_length
void ConnectionObjectSetOriginatorVendorId(CipConnectionObject *connection_object, const CipUint vendor_id)
uint64_t production_inhibit_timer
CipUint produced_connection_path_length
EipUint32 eip_level_sequence_count_consuming
#define CIP_CONNECTION_OBJECT_PRIORITY_LOW
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_PRODUCTION_TRIGGER_APPLICATION_OBJECT
size_t ConnectionObjectGetOToTConnectionSize(const CipConnectionObject *const connection_object)
DoublyLinkedList connection_list
ConnectionObjectTransportClassTriggerProductionTrigger
CipUint GetConnectionId(void)
Generate a new connection Id utilizing the Incarnation Id as described in the EIP specs...
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_3
EipUint16 GetIntFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT16 from *buffer and converts little endian to host.
CipUsint connection_timeout_multiplier
ConnectionObjectTransportClassTriggerProductionTrigger ConnectionObjectGetTransportClassTriggerProductionTrigger(const CipConnectionObject *const connection_object)
void ConnectionObjectSetState(CipConnectionObject *const connection_object, const ConnectionObjectState state)
CipUint ConnectionObjectGetRequestedPacketInterval(const CipConnectionObject *const connection_object)
DoublyLinkedListNode * CipConnectionObjectListArrayAllocator()
#define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_AUTO_RESET
#define CIP_CONNECTION_OBJECT_STATE_DEFERRED_DELETE
CipUint sequence_count_consuming
CipWord t_to_o_network_connection_parameters
void ConnectionObjectSetProducedConnectionSize(CipConnectionObject *const connection_object, const CipUint produced_connection_size)
#define CIP_CONNECTION_OBJECT_STATE_ESTABLISHED
CipUint production_inhibit_time
#define CIP_CONNECTION_OBJECT_WATCHDOG_TIMEOUT_ACTION_TRANSITION_TO_TIMED_OUT
#define CIP_CONNECTION_OBJECT_TRANSPORT_CLASS_TRIGGER_TRANSPORT_CLASS_2
void ConnectionObjectSetConnectionSerialNumber(CipConnectionObject *connection_object, const CipUint connection_serial_number)
ConnectionObjectInstanceType ConnectionObjectGetInstanceType(const CipConnectionObject *const connection_object)
struct sockaddr_in originator_address
void ConnectionObjectSetOriginatorSerialNumber(CipConnectionObject *connection_object, CipUdint originator_serial_number)
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...
uint64_t last_package_watchdog_timer
ConnectionObjectTransportClassTriggerTransportClass ConnectionObjectGetTransportClassTriggerTransportClass(const CipConnectionObject *const connection_object)
bool EqualConnectionTriad(const CipConnectionObject *const object1, const CipConnectionObject *const object2)
ConnectionObjectConnectionSizeType ConnectionObjectGetTToOConnectionSizeType(const CipConnectionObject *const connection_object)