OpENer - Open Source EtherNet/IP(TM) I/O Target Stack
2.1
|
#include "opener_api.h"
#include "cipcommon.h"
#include "cipmessagerouter.h"
#include "endianconv.h"
#include "ciperror.h"
#include "trace.h"
Go to the source code of this file.
Data Structures | |
struct | cip_message_router_object |
A class registry list node. More... | |
Typedefs | |
typedef struct cip_message_router_object | CipMessageRouterObject |
A class registry list node. More... | |
Functions | |
EipStatus | CipMessageRouterInit () |
Initialize the data structures of the message router. More... | |
CipError | CreateMessageRouterRequestStructure (const EipUint8 *data, EipInt16 data_length, CipMessageRouterRequest *message_router_request) |
Create Message Router Request structure out of the received data. More... | |
void | DeleteAllClasses (void) |
Free all data allocated by the classes created in the CIP stack. More... | |
CipClass * | GetCipClass (const EipUint32 class_id) |
Get a pointer to a CIP object with given class code. More... | |
CipInstance * | GetCipInstance (const CipClass *RESTRICT const cip_class, EipUint32 instance_number) |
Get a pointer to an instance. More... | |
CipMessageRouterObject * | GetRegisteredObject (EipUint32 class_id) |
Get the registered MessageRouter object corresponding to ClassID. given a class ID, return a pointer to the registration node for that object. More... | |
void | InitializeCipMessageRouterClass (CipClass *cip_class) |
EipStatus | NotifyMessageRouter (EipUint8 *data, int data_length, const struct sockaddr *const originator_address, const int encapsulation_session) |
Notify the MessageRouter that an explicit message (connected or unconnected) has been received. This function will be called from the encapsulation layer. The CPF structure is already parsed an can be accessed via the global variable: g_stCPFDataItem. More... | |
EipStatus | RegisterCipClass (CipClass *cip_class) |
Register a CIP Class to the message router. More... | |
Variables | |
CipMessageRouterObject * | g_first_object = NULL |
Pointer to first registered object in MessageRouter. More... | |
CipMessageRouterRequest | g_message_router_request |
CipMessageRouterResponse | g_message_router_response |
Structure for storing the Response generated by an explict message. More... | |
typedef struct cip_message_router_object CipMessageRouterObject |
A class registry list node.
A linked list of this object is the registry of classes known to the message router for small devices with very limited memory it could make sense to change this list into an array with a given max size for removing the need for having to dynamically allocate memory. The size of the array could be a parameter in the platform config file.
EipStatus CipMessageRouterInit | ( | void | ) |
Initialize the data structures of the message router.
Definition at line 78 of file cipmessagerouter.c.
References CreateCipClass(), CipMessageRouterResponse::data, g_message_data_reply_buffer, GetAttributeSingle(), InitializeCipMessageRouterClass(), InsertService(), kEipStatusError, kEipStatusOk, kGetAttributeSingle, and CipMessageRouterResponse::reserved.
Referenced by CipStackInit().
CipError CreateMessageRouterRequestStructure | ( | const EipUint8 * | data, |
EipInt16 | data_length, | ||
CipMessageRouterRequest * | message_router_request | ||
) |
Create Message Router Request structure out of the received data.
Parses the UCMM header consisting of: service, IOI size, IOI, data into a request structure
data | pointer to the message data received |
data_length | number of bytes in the message |
message_router_request | pointer to structure of MRRequest data item. |
Definition at line 245 of file cipmessagerouter.c.
References CipMessageRouterRequest::data, DecodePaddedEPath(), kCipErrorPathSegmentError, kCipErrorPathSizeInvalid, kCipErrorSuccess, CipMessageRouterRequest::request_path, CipMessageRouterRequest::request_path_size, and CipMessageRouterRequest::service.
Referenced by NotifyMessageRouter().
void DeleteAllClasses | ( | void | ) |
Free all data allocated by the classes created in the CIP stack.
Definition at line 271 of file cipmessagerouter.c.
References cip_instance::attributes, cip_message_router_object::cip_class, cip_instance::cip_class, CipFree(), cip_class::class_instance, cip_class::class_name, g_first_object, cip_class::instances, cip_message_router_object::next, cip_instance::next, cip_class::number_of_attributes, and cip_class::services.
Referenced by ShutdownCipStack().
CipMessageRouterObject* GetRegisteredObject | ( | EipUint32 | class_id | ) |
Get the registered MessageRouter object corresponding to ClassID. given a class ID, return a pointer to the registration node for that object.
class_id | Class code to be searched for. |
Definition at line 111 of file cipmessagerouter.c.
References cip_message_router_object::cip_class, cip_class::class_id, g_first_object, cip_message_router_object::next, and OPENER_ASSERT.
Referenced by GetCipClass(), and NotifyMessageRouter().
void InitializeCipMessageRouterClass | ( | CipClass * | cip_class | ) |
Definition at line 52 of file cipmessagerouter.c.
References cip_instance::cip_class, cip_class::class_instance, cip_class::highest_attribute_number, InsertAttribute(), kCipUint, kGetableAll, kGetableSingle, kGetableSingleAndAll, cip_class::number_of_instances, and cip_class::revision.
Referenced by CipMessageRouterInit().
EipStatus NotifyMessageRouter | ( | EipUint8 * | data, |
int | data_length, | ||
const struct sockaddr *const | originator_address, | ||
const int | encapsulation_session | ||
) |
Notify the MessageRouter that an explicit message (connected or unconnected) has been received. This function will be called from the encapsulation layer. The CPF structure is already parsed an can be accessed via the global variable: g_stCPFDataItem.
data | pointer to the data buffer of the message directly at the beginning of the CIP part. |
data_length | number of bytes in the data buffer |
originator_address | The address of the originator as received |
encapsulation_session | The associated encapsulation session of the explicit message |
Definition at line 173 of file cipmessagerouter.c.
References cip_message_router_object::cip_class, CipEpath::class_id, cip_class::class_name, CreateMessageRouterRequestStructure(), CipMessageRouterResponse::data, CipMessageRouterResponse::data_length, g_message_data_reply_buffer, CipMessageRouterResponse::general_status, GetRegisteredObject(), kCipErrorPathDestinationUnknown, kCipErrorSuccess, kEipStatusError, kEipStatusOk, kEipStatusOkSend, NotifyClass(), OPENER_ASSERT, OPENER_TRACE_ERR, OPENER_TRACE_INFO, CipMessageRouterResponse::reply_service, CipMessageRouterRequest::request_path, CipMessageRouterResponse::reserved, and CipMessageRouterResponse::size_of_additional_status.
Referenced by NotifyCommonPacketFormat(), and NotifyConnectedCommonPacketFormat().
Register a CIP Class to the message router.
cip_class | Pointer to a class object to be registered. |
Definition at line 154 of file cipmessagerouter.c.
References cip_message_router_object::cip_class, CipCalloc(), g_first_object, kEipStatusError, kEipStatusOk, and cip_message_router_object::next.
Referenced by CreateCipClass().
CipMessageRouterObject* g_first_object = NULL |
Pointer to first registered object in MessageRouter.
Definition at line 29 of file cipmessagerouter.c.
Referenced by DeleteAllClasses(), GetRegisteredObject(), and RegisterCipClass().
CipMessageRouterRequest g_message_router_request |
Definition at line 13 of file cipmessagerouter.c.
CipMessageRouterResponse g_message_router_response |
Structure for storing the Response generated by an explict message.
This buffer will be used for storing the result. The response message will be generated by assembleLinearMsg.
Definition at line 14 of file cipmessagerouter.c.
Referenced by NotifyCommonPacketFormat(), and NotifyConnectedCommonPacketFormat().