OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
appcontype.c File Reference
#include <string.h>
#include "appcontype.h"
#include "cipconnectionmanager.h"
#include "cipconnectionobject.h"
#include "opener_api.h"
#include "assert.h"
#include "trace.h"
#include "cipepath.h"
Include dependency graph for appcontype.c:

Go to the source code of this file.

Data Structures

struct  ExclusiveOwnerConnection
 Exclusive Owner connection data. More...
 
struct  InputOnlyConnection
 Input Only connection data. More...
 
struct  ListenOnlyConnection
 Listen Only connection data. More...
 

Functions

void CloseAllConnections (void)
 
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). More...
 
void ConfigureExclusiveOwnerConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly, const unsigned int input_assembly, const unsigned int config_assembly)
 Configures the connection point for an exclusive owner connection. More...
 
void ConfigureInputOnlyConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly, const unsigned int input_assembly, const unsigned int config_assembly)
 Configures the connection point for an input only connection. More...
 
void ConfigureListenOnlyConnectionPoint (const unsigned int connection_number, const unsigned int output_assembly, const unsigned int input_assembly, const unsigned int config_assembly)
 Configures the connection point for a listen only connection. More...
 
bool ConnectionWithSameConfigPointExists (const EipUint32 config_point)
 Check if there is an established connection that uses the same config point. More...
 
CipConnectionObjectGetExclusiveOwnerConnection (const CipConnectionObject *const RESTRICT connection_object, EipUint16 *const extended_error)
 Takes an ConnectionObject and searches and returns an Exclusive Owner Connection based on the ConnectionObject, if there is non it returns NULL. More...
 
CipConnectionObjectGetExistingProducerMulticastConnection (const EipUint32 input_point)
 Check if there exists already an exclusive owner or listen only connection which produces the input assembly. More...
 
CipConnectionObjectGetInputOnlyConnection (const CipConnectionObject *const RESTRICT connection_object, EipUint16 *const extended_error)
 Takes an ConnectionObject and searches and returns an Input Only Connection based on the ConnectionObject, if there is non it returns NULL. More...
 
CipConnectionObjectGetIoConnectionForConnectionData (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 available. More...
 
CipConnectionObjectGetListenOnlyConnection (const CipConnectionObject *const RESTRICT connection_object, EipUint16 *const extended_error)
 Takes an ConnectionObject and searches and returns an Listen Only Connection based on the ConnectionObject, if there is non it returns NULL. More...
 
CipConnectionObjectGetNextNonControlMasterConnection (const EipUint32 input_point)
 check if there exists an producing multicast exclusive owner or listen only connection that should produce the same input but is not in charge of the connection. More...
 
void InitializeIoConnectionData (void)
 

Variables

ExclusiveOwnerConnection g_exlusive_owner_connections [OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS]
 
InputOnlyConnection g_input_only_connections [OPENER_CIP_NUM_INPUT_ONLY_CONNS]
 
ListenOnlyConnection g_listen_only_connections [OPENER_CIP_NUM_LISTEN_ONLY_CONNS]
 

Function Documentation

void CloseAllConnections ( void  )

@ brief close all open connections.

For I/O connections the sockets will be freed. The sockets for explicit connections are handled by the encapsulation layer, and freed there.

Definition at line 407 of file appcontype.c.

References cip_connection_object::connection_close_function, connection_list, doubly_linked_list_node::data, and DoublyLinkedList::first.

Referenced by ResetDevice(), and ShutdownCipStack().

Here is the caller graph for this function:

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).

Parameters
input_pointthe input point
instance_typethe connection application type

Definition at line 384 of file appcontype.c.

References CheckIoConnectionEvent(), cip_connection_object::connection_close_function, connection_list, ConnectionObjectGetInstanceType(), cip_connection_object::consumed_path, doubly_linked_list_node::data, DoublyLinkedList::first, connection_path_epath::instance_id, kIoConnectionEventClosed, doubly_linked_list_node::next, OPENER_TRACE_INFO, and cip_connection_object::produced_path.

Referenced by CloseIoConnection(), and HandleIoConnectionTimeOut().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ConnectionWithSameConfigPointExists ( const EipUint32  config_point)

Check if there is an established connection that uses the same config point.

Parameters
config_pointThe configuration point
Returns
true if connection was found, otherwise false

Definition at line 417 of file appcontype.c.

References cip_connection_object::configuration_path, connection_list, doubly_linked_list_node::data, DoublyLinkedList::first, connection_path_epath::instance_id, doubly_linked_list_node::next, and OPENER_ASSERT.

Referenced by HandleConfigData().

Here is the caller graph for this function:

CipConnectionObject * GetExclusiveOwnerConnection ( const CipConnectionObject *const RESTRICT  connection_object,
EipUint16 *const  extended_error 
)

Takes an ConnectionObject and searches and returns an Exclusive Owner Connection based on the ConnectionObject, if there is non it returns NULL.

Parameters
connection_objectConnection Object which will be searched for in the Exclusive Owner Connections
extended_errorPointer to the extended error variable, will be written if an error occurs
Returns
The corresponding Exclusive Owner Connection or NULL if there is non

Definition at line 177 of file appcontype.c.

References ExclusiveOwnerConnection::config_assembly, ExclusiveOwnerConnection::connection_data, ConnectionObjectEqualOriginator(), ConnectionObjectGetState(), GetConnectedOutputAssembly(), ExclusiveOwnerConnection::input_assembly, kConnectionManagerExtendedStatusCodeErrorOwnershipConflict, kConnectionObjectStateEstablished, kConnectionObjectStateTimedOut, OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS, and OPENER_TRACE_INFO.

Referenced by GetIoConnectionForConnectionData().

Here is the call graph for this function:

Here is the caller graph for this function:

CipConnectionObject* GetExistingProducerMulticastConnection ( const EipUint32  input_point)

Check if there exists already an exclusive owner or listen only connection which produces the input assembly.

Parameters
input_pointthe Input point to be produced
Returns
if a connection could be found a pointer to this connection if not NULL

Definition at line 335 of file appcontype.c.

References connection_list, ConnectionObjectGetTToOConnectionType(), ConnectionObjectIsTypeIOConnection(), doubly_linked_list_node::data, DoublyLinkedList::first, connection_path_epath::instance_id, kConnectionObjectConnectionTypeMulticast, kUdpCommuncationDirectionProducing, doubly_linked_list_node::next, cip_connection_object::produced_path, and cip_connection_object::socket.

Referenced by GetListenOnlyConnection(), and OpenProducingMulticastConnection().

Here is the call graph for this function:

Here is the caller graph for this function:

CipConnectionObject * GetInputOnlyConnection ( const CipConnectionObject *const RESTRICT  connection_object,
EipUint16 *const  extended_error 
)

Takes an ConnectionObject and searches and returns an Input Only Connection based on the ConnectionObject, if there is non it returns NULL.

Parameters
connection_objectConnection Object which will be searched for in the Input Only Connections
extended_errorPointer to the extended error variable, will be written if an error occurs
Returns
The corresponding Exclusive Owner Connection or NULL if there is non

Definition at line 223 of file appcontype.c.

References InputOnlyConnection::connection_data, ConnectionObjectEqualOriginator(), ConnectionObjectGetState(), kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo, kConnectionManagerExtendedStatusCodeInvalidProducingApplicationPath, kConnectionManagerExtendedStatusCodeTargetObjectOutOfConnections, kConnectionObjectStateNonExistent, kConnectionObjectStateTimedOut, OPENER_CIP_NUM_INPUT_ONLY_CONNS, and OPENER_CIP_NUM_INPUT_ONLY_CONNS_PER_CON_PATH.

Referenced by GetIoConnectionForConnectionData().

Here is the call graph for this function:

Here is the caller graph for this function:

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 available.

If a suitable connection is found the connection data is transfered the application connection type is set (i.e., EConnType).

Parameters
connection_objectconnection data to be used
extended_errorpointer to the extended_error variable, if an error occurred this value has the according error code for the response
Returns
  • on success: A pointer to the connection object already containing the connection data given in connection_object.
  • on error: NULL

Definition at line 127 of file appcontype.c.

References ConnectionObjectDeepCopy(), ConnectionObjectSetInstanceType(), GetExclusiveOwnerConnection(), GetInputOnlyConnection(), GetListenOnlyConnection(), kCipErrorSuccess, kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo, kConnectionManagerExtendedStatusCodeSuccess, kConnectionObjectInstanceTypeIOExclusiveOwner, kConnectionObjectInstanceTypeIOInputOnly, kConnectionObjectInstanceTypeIOListenOnly, and OPENER_TRACE_INFO.

Referenced by EstablishIoConnection().

Here is the call graph for this function:

Here is the caller graph for this function:

CipConnectionObject * GetListenOnlyConnection ( const CipConnectionObject *const RESTRICT  connection_object,
EipUint16 *const  extended_error 
)

Takes an ConnectionObject and searches and returns an Listen Only Connection based on the ConnectionObject, if there is non it returns NULL.

Parameters
connection_objectConnection Object which will be searched for in the Listen Only Connections
extended_errorPointer to the extended error variable, will be written if an error occurs
Returns
The corresponding Exclusive Owner Connection or NULL if there is non

Definition at line 275 of file appcontype.c.

References ListenOnlyConnection::connection_data, ConnectionObjectEqualOriginator(), ConnectionObjectGetState(), GetExistingProducerMulticastConnection(), kConnectionManagerExtendedStatusCodeInconsistentApplicationPathCombo, kConnectionManagerExtendedStatusCodeInvalidProducingApplicationPath, kConnectionManagerExtendedStatusCodeNonListenOnlyConnectionNotOpened, kConnectionManagerExtendedStatusCodeTargetObjectOutOfConnections, kConnectionObjectStateNonExistent, kConnectionObjectStateTimedOut, OPENER_CIP_NUM_LISTEN_ONLY_CONNS, and OPENER_CIP_NUM_LISTEN_ONLY_CONNS_PER_CON_PATH.

Referenced by GetIoConnectionForConnectionData().

Here is the call graph for this function:

Here is the caller graph for this function:

CipConnectionObject* GetNextNonControlMasterConnection ( const EipUint32  input_point)

check if there exists an producing multicast exclusive owner or listen only connection that should produce the same input but is not in charge of the connection.

Parameters
input_pointthe produced input
Returns
if a connection could be found the pointer to this connection otherwise NULL.

Definition at line 362 of file appcontype.c.

References connection_list, ConnectionObjectGetState(), ConnectionObjectGetTToOConnectionType(), ConnectionObjectIsTypeNonLOIOConnection(), doubly_linked_list_node::data, DoublyLinkedList::first, connection_path_epath::instance_id, kConnectionObjectConnectionTypeMulticast, kConnectionObjectStateEstablished, kUdpCommuncationDirectionProducing, doubly_linked_list_node::next, cip_connection_object::produced_path, and cip_connection_object::socket.

Referenced by CloseIoConnection(), and HandleIoConnectionTimeOut().

Here is the call graph for this function:

Here is the caller graph for this function:

void InitializeIoConnectionData ( void  )

Definition at line 431 of file appcontype.c.

References OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS, OPENER_CIP_NUM_INPUT_ONLY_CONNS, and OPENER_CIP_NUM_LISTEN_ONLY_CONNS.

Referenced by InitializeConnectionManagerData().

Here is the caller graph for this function:

Variable Documentation

Exclusive Owner connections

Definition at line 46 of file appcontype.c.

Input Only connections

Definition at line 48 of file appcontype.c.

Listen Only connections

Definition at line 50 of file appcontype.c.