OpENer - Open Source EtherNet/IP(TM) I/O Target Stack
2.1
|
#include <string.h>
#include <stdio.h>
#include "cipcommon.h"
#include "opener_user_conf.h"
#include "opener_api.h"
#include "cipidentity.h"
#include "ciptcpipinterface.h"
#include "cipethernetlink.h"
#include "cipconnectionmanager.h"
#include "endianconv.h"
#include "encap.h"
#include "ciperror.h"
#include "cipassembly.h"
#include "cipmessagerouter.h"
#include "cipqos.h"
#include "cpf.h"
#include "trace.h"
#include "appcontype.h"
#include "cipepath.h"
#include "stdlib.h"
Go to the source code of this file.
Functions | |
CipInstance * | AddCIPInstance (CipClass *RESTRICT const class, const EipUint32 instance_id) |
Create one instance of a given class with a certain instance number. More... | |
CipInstance * | AddCipInstances (CipClass *RESTRICT const cip_class, const int number_of_instances) |
Add a number of CIP instances to a given CIP class. More... | |
void | AllocateAttributeMasks (CipClass *target_class) |
Allocates Attribute bitmasks. More... | |
size_t | CalculateIndex (EipUint16 attribute_number) |
Calculates Byte-Index of Attribute. More... | |
void | CipStackInit (const EipUint16 unique_connection_id) |
Initialize and setup the CIP-stack. More... | |
CipClass * | CreateCipClass (const EipUint32 class_id, const int number_of_class_attributes, const EipUint32 highest_class_attribute_number, const int number_of_class_services, const int number_of_instance_attributes, const EipUint32 highest_instance_attribute_number, const int number_of_instance_services, const int number_of_instances, char *name, const EipUint16 revision, void(*InitializeCipClass)(CipClass *)) |
int | DecodeData (const EipUint8 cip_data_type, void *const cip_data, const EipUint8 **const cip_message) |
Retrieve the given data according to CIP encoding from the message buffer. More... | |
int | DecodePaddedEPath (CipEpath *epath, const EipUint8 **message) |
Decodes padded EPath. More... | |
int | EncodeData (const EipUint8 cip_type, const void *const cip_data, EipUint8 **cip_message) |
Produce the data according to CIP encoding onto the message buffer. More... | |
int | EncodeEPath (CipEpath *epath, EipUint8 **message) |
EipStatus | GetAttributeAll (CipInstance *instance, CipMessageRouterRequest *message_router_request, CipMessageRouterResponse *message_router_response, struct sockaddr *originator_address, const int encapsulation_session) |
Generic implementation of the GetAttributeAll CIP service. More... | |
EipStatus | GetAttributeSingle (CipInstance *RESTRICT const instance, CipMessageRouterRequest *const message_router_request, CipMessageRouterResponse *const message_router_response, struct sockaddr *originator_address, const int encapsulation_session) |
Generic implementation of the GetAttributeSingle CIP service. More... | |
CipAttributeStruct * | GetCipAttribute (const CipInstance *const instance, const EipUint16 attribute_number) |
Get a pointer to an instance's attribute. More... | |
CipServiceStruct * | GetCipService (const CipInstance *const instance, CipUsint service_number) |
size_t | GetSizeOfAttribute (const CipAttributeStruct *const attribute_struct) |
void | InsertAttribute (CipInstance *const instance, const EipUint16 attribute_number, const EipUint8 cip_type, void *const data, const EipByte cip_flags) |
Insert an attribute in an instance of a CIP class. More... | |
void | InsertService (const CipClass *const class, const EipUint8 service_number, const CipServiceFunction service_function, char *const service_name) |
Insert a service in an instance of a CIP object. More... | |
EipStatus | NotifyClass (const CipClass *RESTRICT const cip_class, CipMessageRouterRequest *const message_router_request, CipMessageRouterResponse *const message_router_response, struct sockaddr *originator_address, const int encapsulation_session) |
Check if requested service present in class/instance and call appropriate service. More... | |
void | ShutdownCipStack (void) |
Shutdown of the CIP stack. More... | |
Variables | |
EipUint8 | g_message_data_reply_buffer [OPENER_MESSAGE_DATA_REPLY_BUFFER] |
CipClass* CreateCipClass | ( | const EipUint32 | class_id, |
const int | number_of_class_attributes, | ||
const EipUint32 | highest_class_attribute_number, | ||
const int | number_of_class_services, | ||
const int | number_of_instance_attributes, | ||
const EipUint32 | highest_instance_attribute_number, | ||
const int | number_of_instance_services, | ||
const int | number_of_instances, | ||
char * | name, | ||
const EipUint16 | revision, | ||
void(*)(CipClass *) | InitializeCipClass | ||
) |
Definition at line 189 of file cipcommon.c.
References AddCipInstances(), AllocateAttributeMasks(), CipCalloc(), cip_class::class_id, GetAttributeAll(), GetAttributeSingle(), GetCipClass(), InsertAttribute(), InsertService(), kCipUint, kEipStatusError, kGetableAll, kGetableSingle, kGetableSingleAndAll, kGetAttributeAll, kGetAttributeSingle, kNotSetOrGetable, OPENER_ASSERT, OPENER_TRACE_INFO, RegisterCipClass(), and cip_class::revision.
Referenced by CipEthernetLinkInit(), CipIdentityInit(), CipMessageRouterInit(), CipQoSInit(), CipTcpIpInterfaceInit(), ConnectionManagerInit(), and CreateAssemblyClass().
Decodes padded EPath.
epath | EPath object to the receiving element |
message | pointer to the message to decode |
Definition at line 804 of file cipcommon.c.
References CipEpath::attribute_number, CipEpath::class_id, GetIntFromMessage(), CipEpath::instance_number, kEipStatusError, kSegmentTypeReserved, LOGICAL_SEGMENT_FORMAT_EIGHT_BIT, LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT, LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID, LOGICAL_SEGMENT_TYPE_CLASS_ID, LOGICAL_SEGMENT_TYPE_INSTANCE_ID, LOGICAL_SEGMENT_TYPE_MEMBER_ID, OPENER_TRACE_ERR, CipEpath::path_size, and SEGMENT_TYPE_LOGICAL_SEGMENT.
Referenced by CreateMessageRouterRequestStructure().
Definition at line 747 of file cipcommon.c.
References AddIntToMessage(), CipEpath::attribute_number, CipEpath::class_id, CipEpath::instance_number, and CipEpath::path_size.
Referenced by EncodeData().
EipStatus GetAttributeAll | ( | CipInstance * | instance, |
CipMessageRouterRequest * | message_router_request, | ||
CipMessageRouterResponse * | message_router_response, | ||
struct sockaddr * | originator_address, | ||
const int | encapsulation_session | ||
) |
Generic implementation of the GetAttributeAll CIP service.
Copy all attributes from Object into the global message buffer.
instance | pointer to object instance with data. |
message_router_request | pointer to MR request. |
message_router_response | pointer for MR response. |
originator_address | address struct of the originator as received |
encapsulation_session | associated encapsulation session of the explicit message |
Definition at line 704 of file cipcommon.c.
References CipEpath::attribute_number, CipAttributeStruct::attribute_number, cip_instance::attributes, CalculateIndex(), cip_instance::cip_class, CipMessageRouterResponse::data, CipMessageRouterResponse::data_length, CipMessageRouterResponse::general_status, cip_class::get_all_bit_mask, GetCipService(), kCipErrorServiceNotSupported, kEipStatusError, kEipStatusOk, kEipStatusOkSend, kGetAttributeSingle, cip_class::number_of_attributes, CipMessageRouterResponse::reply_service, CipMessageRouterRequest::request_path, CipMessageRouterRequest::service, cip_service_struct::service_function, and CipMessageRouterResponse::size_of_additional_status.
Referenced by CipEthernetLinkInit(), CipIdentityInit(), ConnectionManagerInit(), and CreateCipClass().
EipStatus GetAttributeSingle | ( | CipInstance *RESTRICT const | instance, |
CipMessageRouterRequest *const | message_router_request, | ||
CipMessageRouterResponse *const | message_router_response, | ||
struct sockaddr * | originator_address, | ||
const int | encapsulation_session | ||
) |
Generic implementation of the GetAttributeSingle CIP service.
Check from classID which Object requests an attribute, search if object has the appropriate attribute implemented.
instance | pointer to instance. |
message_router_request | pointer to request. |
message_router_response | pointer to response. |
originator_address | address struct of the originator as received |
encapsulation_session | associated encapsulation session of the explicit message |
Definition at line 391 of file cipcommon.c.
References CipEpath::attribute_number, BeforeAssemblyDataSend(), CalculateIndex(), CipMessageRouterResponse::data, CipAttributeStruct::data, CipMessageRouterResponse::data_length, EncodeData(), CipMessageRouterResponse::general_status, GetCipAttribute(), kCipByteArray, kCipErrorAttributeNotSupported, kCipErrorSuccess, kEipStatusOkSend, kGetAttributeAll, OPENER_ASSERT, OPENER_TRACE_INFO, CipMessageRouterResponse::reply_service, CipMessageRouterRequest::request_path, CipMessageRouterRequest::service, CipMessageRouterResponse::size_of_additional_status, and CipAttributeStruct::type.
Referenced by CipIdentityInit(), CipMessageRouterInit(), ConnectionManagerInit(), CreateAssemblyClass(), CreateCipClass(), GetAttributeSingleEthernetLink(), and GetAttributeSingleQoS().
CipServiceStruct* GetCipService | ( | const CipInstance *const | instance, |
CipUsint | service_number | ||
) |
Definition at line 692 of file cipcommon.c.
References cip_instance::cip_class, cip_class::number_of_services, cip_service_struct::service_number, and cip_class::services.
Referenced by GetAttributeAll().
size_t GetSizeOfAttribute | ( | const CipAttributeStruct *const | attribute_struct | ) |
Definition at line 900 of file cipcommon.c.
References CipAttributeStruct::data, CipTcpIpNetworkInterfaceConfiguration::domain_name, kCip6Usint, kCipBool, kCipByte, kCipByteArray, kCipDate, kCipDateAndTime, kCipDint, kCipDword, kCipEngUnit, kCipEpath, kCipFtime, kCipInt, kCipItime, kCipLint, kCipLreal, kCipLtime, kCipLword, kCipMemberList, kCipReal, kCipShortString, kCipSint, kCipStime, kCipString, kCipString2, kCipStringN, kCipTime, kCipTimeOfDay, kCipUdint, kCipUdintUdintUdintUdintUdintString, kCipUint, kCipUlint, kCipUsint, kCipUsintUsint, kCipWord, kInternalUint6, CipByteArray::length, CipShortString::length, CipString::length, CipStringN::length, CipEpath::path_size, CipStringN::size, and CipAttributeStruct::type.
EipStatus NotifyClass | ( | const CipClass *const RESTRICT | cip_class, |
CipMessageRouterRequest *const | message_router_request, | ||
CipMessageRouterResponse *const | message_router_response, | ||
struct sockaddr * | originator_address, | ||
const int | encapsulation_session | ||
) |
Check if requested service present in class/instance and call appropriate service.
cip_class | class receiving the message |
message_router_request | request message |
message_router_response | reply message |
originator_address | address struct of the originator as received |
encapsulation_session | associated encapsulation session of the explicit message |
Definition at line 75 of file cipcommon.c.
References cip_instance::cip_class, CipMessageRouterResponse::data_length, CipMessageRouterResponse::general_status, GetCipInstance(), CipEpath::instance_number, kCipErrorPathDestinationUnknown, kCipErrorServiceNotSupported, kEipStatusOkSend, cip_service_struct::name, cip_class::number_of_services, OPENER_ASSERT, OPENER_TRACE_INFO, OPENER_TRACE_WARN, CipMessageRouterResponse::reply_service, CipMessageRouterRequest::request_path, CipMessageRouterRequest::service, cip_service_struct::service_function, cip_service_struct::service_number, cip_class::services, and CipMessageRouterResponse::size_of_additional_status.
Referenced by NotifyMessageRouter().
EipUint8 g_message_data_reply_buffer[OPENER_MESSAGE_DATA_REPLY_BUFFER] |
Reply buffer
Definition at line 30 of file cipcommon.c.
Referenced by CipMessageRouterInit(), and NotifyMessageRouter().