20 #define SEGMENT_TYPE_PORT_SEGMENT 0x00
21 #define SEGMENT_TYPE_LOGICAL_SEGMENT 0x20
22 #define SEGMENT_TYPE_NETWORK_SEGMENT 0x40
23 #define SEGMENT_TYPE_SYMBOLIC_SEGMENT 0x60
24 #define SEGMENT_TYPE_DATA_SEGMENT 0x80
25 #define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED 0xA0
26 #define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY 0xC0
27 #define SEGMENT_TYPE_SEGMENT_RESERVED 0xE0
29 #define LOGICAL_SEGMENT_TYPE_CLASS_ID 0x00
30 #define LOGICAL_SEGMENT_TYPE_INSTANCE_ID 0x04
31 #define LOGICAL_SEGMENT_TYPE_MEMBER_ID 0x08
32 #define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT 0x0C
33 #define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID 0x10
34 #define LOGICAL_SEGMENT_TYPE_SPECIAL 0x14
35 #define LOGICAL_SEGMENT_TYPE_SERVICE_ID 0x18
36 #define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL 0x1C
38 #define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT 0x00
39 #define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT 0x01
40 #define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT 0x02
42 #define LOGICAL_SEGMENT_EXTENDED_TYPE_RESERVED 0x00
43 #define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX 0x01
44 #define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX 0x02
45 #define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX 0x03
46 #define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX 0x04
47 #define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER 0x05
48 #define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE 0x06
50 #define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY 0x00
51 #define ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4 0x04
53 #define NETWORK_SEGMENT_SCHEDULE 0x01
54 #define NETWORK_SEGMENT_FIXED_TAG 0x02
55 #define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS 0x03
56 #define NETWORK_SEGMENT_SAFETY 0x04
57 #define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS 0x10
58 #define NETWORK_SEGMENT_EXTENDED_NETWORK 0x1F
60 #define SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING 0x00
62 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_DOUBLE_CHAR 0x20
63 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_TRIPLE_CHAR 0x40
64 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC 0xC0
66 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_USINT_TYPE 0x06
67 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UINT_TYPE 0x07
68 #define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UDINT_TYPE 0x08
70 #define DATA_SEGMENT_SUBTYPE_SIMPLE_DATA 0x00
71 #define DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL 0x11
77 const unsigned int kSegmentTypeMask = 0xE0;
78 const unsigned int segment_type = *cip_path & kSegmentTypeMask;
80 switch (segment_type) {
107 "Invalid Segment type in the message! We should never come here!\n")
114 unsigned char *
const cip_path) {
115 switch (segment_type) {
142 "Invalid Segment type chosen! We should never come here!\n")
149 const unsigned char *
const cip_path) {
150 const unsigned int kExtendedLinkAddressSizeMask = 0x10;
151 if ( kExtendedLinkAddressSizeMask ==
152 (*cip_path & kExtendedLinkAddressSizeMask) ) {
159 const unsigned char *
const cip_path) {
160 const unsigned int kPortIdentifierMask = 0x0F;
161 unsigned int port_identifier = *cip_path & kPortIdentifierMask;
165 return port_identifier;
169 unsigned char *
const cip_path) {
174 (*cip_path) |= port_identifier;
178 const unsigned char *
const cip_path) {
183 return *(cip_path + 1);
187 const unsigned char *
const cip_path) {
192 const unsigned int kExtendedPortSegmentPosition =
194 return cip_path[kExtendedPortSegmentPosition]
195 + (cip_path[kExtendedPortSegmentPosition + 1] << 8);
199 const unsigned int extended_port_identifier,
202 const unsigned int kExtendedPortSegmentPosition =
204 cip_path[kExtendedPortSegmentPosition] = (char) (extended_port_identifier
206 cip_path[kExtendedPortSegmentPosition + 1] =
207 (char) ( (extended_port_identifier & 0xFF00) >> 8 );
214 const unsigned char *
const cip_path) {
216 const unsigned int kLogicalTypeMask = 0x1C;
217 const unsigned int logical_type = (*cip_path) & kLogicalTypeMask;
219 switch (logical_type) {
246 "Logical segment/logical type: It is not possible to reach this point!\n")
255 switch (logical_type) {
282 "Logical segment/logical type: It is not possible to reach this point!\n");
288 const unsigned char *
const cip_path) {
290 const unsigned int kLogicalFormatMask = 0x03;
291 const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
293 switch (logical_format) {
305 "Logical segment/logical type: Invalid logical type detected!\n")
327 "Logical segment/logical type: Invalid logical type detected!\n")
337 switch (logical_format) {
359 size_t written_bytes = 0;
360 switch(logical_value) {
376 return written_bytes;
380 const unsigned char *
const cip_path) {
385 const unsigned int extended_logical_type = *(cip_path + 1);
388 switch(extended_logical_type) {
413 const unsigned int kLogicalFormatMask = 0x03;
414 const unsigned int logical_format = (*cip_path) & kLogicalFormatMask;
418 switch(logical_format) {
427 const unsigned char *
const cip_path) {
433 switch( *(cip_path + 1) ) {
467 const unsigned char *
const cip_path) {
469 const unsigned int kSubtypeMask = 0x1F;
470 const unsigned int subtype = (*cip_path) & kSubtypeMask;
498 const unsigned char *
const cip_path) {
505 return *(cip_path + 1);
515 const unsigned char *
const cip_path) {
526 const unsigned char *message_runner = cip_path + 2;
535 const unsigned char *
const cip_path) {
536 const unsigned int kSymbolicSegmentFormatMask = 0x1F;
538 (*cip_path & kSymbolicSegmentFormatMask) ) {
545 const unsigned char *
const cip_path) {
546 const unsigned int kSymbolicSegmentASCIIFormatLength = 0x1F;
547 const unsigned int length = *cip_path & kSymbolicSegmentASCIIFormatLength;
553 const unsigned char *
const cip_path) {
554 const unsigned int kSymbolicSegmentExtendedFormatNumericTypeMask = 0x1F;
555 const unsigned int numeric_subtype = *(cip_path + 1) &
556 kSymbolicSegmentExtendedFormatNumericTypeMask;
558 switch(numeric_subtype) {
571 const unsigned char *
const cip_path) {
575 const unsigned int kSymbolicSegmentExtendedFormatMask = 0xE0;
576 const unsigned int extended_type = *(cip_path + 1) &
577 kSymbolicSegmentExtendedFormatMask;
579 switch(extended_type) {
597 const unsigned int kDataSegmentSubtypeMask = 0x1F;
598 const unsigned int data_subtype = (*cip_path) & kDataSegmentSubtypeMask;
601 switch(data_subtype) {
617 const unsigned char *
const cip_path) {
624 const unsigned char *message_runner = cip_path + 1;
642 return logical_format;
649 size_t encoded_path_length = 0;
657 encoded_path_length += 1;
671 encoded_path_length += 1;
687 encoded_path_length += 1;
694 return encoded_path_length += 1;
701 if(path1_length != path2_length) {
704 for(
size_t i = 0; i < path1_length; ++i) {
705 if(path1[i] != path2[i]) {
#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MICROSECONDS
LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(const unsigned char *const cip_path)
Gets the Logical Format of a Logical Segment EPath message.
unsigned int GetPathPortSegmentPortIdentifier(const unsigned char *const cip_path)
Only to be used on Port Segments. Returns the Port Identifier.
#define SEGMENT_TYPE_DATA_TYPE_ELEMENTARTY
#define NETWORK_SEGMENT_FIXED_TAG
Tracing infrastructure for OpENer.
void SetPathPortSegmentExtendedPortIdentifier(const unsigned int extended_port_identifier, CipOctet *const cip_path)
Sets the Extended Port Identifier in a EPath Port Segment message.
#define LOGICAL_SEGMENT_TYPE_INSTANCE_ID
#define LOGICAL_SEGMENT_TYPE_CONNECTION_POINT
CipUsint GetPathDataSegmentSimpleDataWordLength(const unsigned char *const cip_path)
Returns the amount of 16-bit data words in the Simple Data EPath.
void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipOctet *const cip_path)
#define NETWORK_SEGMENT_SCHEDULE
#define LOGICAL_SEGMENT_FORMAT_THIRTY_TWO_BIT
#define DATA_SEGMENT_SUBTYPE_SIMPLE_DATA
void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, CipOctet *const cip_path)
unsigned int GetPathPortSegmentExtendedPortNumber(const unsigned char *const cip_path)
Only to be used on Port Segments with Extended Port Number. Gets the Extended Port Number...
#define OPENER_ASSERT(assertion)
#define SEGMENT_TYPE_DATA_SEGMENT
#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_ARRAY_INDEX
void ElectronicKeyFormat4SetVendorId(ElectronicKeyFormat4 *const electronic_key, const CipUint vendor_id)
Sets vendor ID in the electronic key.
EipUint32 GetDintFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT32 from *buffer and converts little endian to host.
CipDword attribute_id_or_connection_point
Responsible for Endianess conversion.
EipUint8 GetSintFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT8 from *buffer and converts little endian to host.
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_DOUBLE_CHAR
SymbolicSegmentExtendedFormat GetPathSymbolicSegmentExtendedFormat(const unsigned char *const cip_path)
Gets the Extended Format subtype of a Symbolic Segment EPath message.
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC
enum data_segment_subtype DataSegmentSubtype
Data segment sub types.
#define SEGMENT_TYPE_LOGICAL_SEGMENT
void ElectronicKeyFormat4SetDeviceType(ElectronicKeyFormat4 *const electronic_key, const CipUint device_type)
Sets the device type in the electronic key.
#define SEGMENT_TYPE_NETWORK_SEGMENT
enum logical_segment_extended_logical_type LogicalSegmentExtendedLogicalType
SymbolicSegmentFormat GetPathSymbolicSegmentFormat(const unsigned char *const cip_path)
Gets the Symbolic Segment Format of the Symbolic Segment EPath message.
#define LOGICAL_SEGMENT_SPECIAL_TYPE_FORMAT_ELECTRONIC_KEY
#define LOGICAL_SEGMENT_EXTENDED_TYPE_BIT_INDEX
DataSegmentSubtype GetPathDataSegmentSubtype(const unsigned char *const cip_path)
Gets the Data Segment subtype of a Data Segment EPath message.
#define SEGMENT_TYPE_SEGMENT_RESERVED
#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_NUMBER
#define LOGICAL_SEGMENT_EXTENDED_TYPE_ARRAY_INDEX
bool CipEpathEqual(const CipOctet *const path1, const CipUint path1_length, const CipOctet *const path2, const CipUint path2_length)
uint8_t CipOctet
Data types as defined in the CIP Specification Vol 1 Appendix C.
LogicalSegmentSpecialTypeLogicalFormat GetPathLogicalSegmentSpecialTypeLogicalType(const unsigned char *const cip_path)
Gets the Special Type Logical Type of a Logical Segment EPath message.
#define LOGICAL_SEGMENT_TYPE_SERVICE_ID
#define LOGICAL_SEGMENT_TYPE_CLASS_ID
ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(const unsigned char *const cip_path)
Gets the Electronic Key format of a Logical Segment Special Type EPath message.
int AddIntToMessage(const EipUint16 data, EipUint8 **const buffer)
converts UINT16 data from host to little endian an writes it to buffer.
unsigned int GetPathPortSegmentLinkAddressSize(const unsigned char *const cip_path)
Only to be used on Port Segments. Gets the Link Address Size.
#define LOGICAL_SEGMENT_FORMAT_SIXTEEN_BIT
enum network_segment_subtype NetworkSegmentSubtype
All types of network segment types for the use in all code.
int AddDintToMessage(const EipUint32 data, EipUint8 **const buffer)
Converts UINT32 data from host to little endian and writes it to buffer.
#define SEGMENT_TYPE_SYMBOLIC_SEGMENT
#define LOGICAL_SEGMENT_EXTENDED_TYPE_INDIRECT_BIT_INDEX
enum logical_segment_logical_format LogicalSegmentLogicalFormat
Enum containing values how long the encoded value will be (8, 16, or 32 bit)
void SetPathSegmentType(SegmentType segment_type, unsigned char *const cip_path)
Sets the basic segment type of an CIP EPath to be sent.
enum segment_type SegmentType
Segment type Enum.
#define SEGMENT_TYPE_PORT_SEGMENT
int AddSintToMessage(const EipUint8 data, EipUint8 **const buffer)
converts UINT8 data from host to little endian an writes it to buffer.
void ElectronicKeyFormat4SetMajorRevisionCompatibility(ElectronicKeyFormat4 *const electronic_key, const CipByte major_revision_compatibility)
Sets the major revision byte including the compatibility flag.
int MoveMessageNOctets(const int amount_of_bytes_moved, const CipOctet **message_runner)
size_t CipEpathSetLogicalValue(const CipDword logical_value, const LogicalSegmentLogicalFormat logical_format, CipOctet **message)
#define DATA_SEGMENT_SUBTYPE_ANSI_EXTENDED_SYMBOL
LogicalSegmentLogicalFormat CipEpathGetNeededLogicalFormatForValue(CipDword value)
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UDINT_TYPE
NetworkSegmentSubtype GetPathNetworkSegmentSubtype(const unsigned char *const cip_path)
Return the Network Segment subtype.
#define LOGICAL_SEGMENT_TYPE_ATTRIBUTE_ID
LogicalSegmentExtendedLogicalType GetPathLogicalSegmentExtendedLogicalType(const unsigned char *const cip_path)
Gets the Extended Logical Type of a Logical Segment EPath message.
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_USINT_TYPE
#define LOGICAL_SEGMENT_TYPE_SPECIAL
#define LOGICAL_SEGMENT_EXTENDED_TYPE_STRUCTURE_MEMBER_HANDLE
LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(const unsigned char *const cip_path)
Gets the Logical Type of an EPath Logical Segment message.
enum symbolic_segment_format SymbolicSegmentFormat
Symbolic segment formats.
enum electronic_key_segment_format ElectronicKeySegmentFormat
Electronic key formats.
const unsigned int kPortSegmentExtendedPort
#define NETWORK_SEGMENT_SAFETY
CipUdint GetPathNetworkSegmentProductionInhibitTimeInMicroseconds(const unsigned char *const cip_path)
Return the Production Inhibit Time in microseconds from an EPath.
#define NETWORK_SEGMENT_EXTENDED_NETWORK
SymbolicSegmentExtendedFormat GetPathSymbolicSegmentNumericType(const unsigned char *const cip_path)
Gets the Numeric subtype of a Symbolic Segment Extended Format EPath message.
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_TRIPLE_CHAR
#define LOGICAL_SEGMENT_TYPE_EXTENDED_LOGICAL
void ElectronicKeyFormat4SetMinorRevision(ElectronicKeyFormat4 *const electronic_key, const CipUsint minor_revision)
Sets the devices minor revision in an format 4 electronic key.
#define SEGMENT_TYPE_DATA_TYPE_CONSTRUCTED
const CipDword CipEpathGetLogicalValue(const EipUint8 **message)
#define SYMBOLIC_SEGMENT_EXTENDED_FORMAT_NUMERIC_UINT_TYPE
#define SYMBOLIC_SEGMENT_FORMAT_EXTENDED_STRING
EipUint16 GetIntFromMessage(const EipUint8 **const buffer)
Reads EIP_UINT16 from *buffer and converts little endian to host.
#define ELECTRONIC_KEY_SEGMENT_KEY_FORMAT_4
void GetElectronicKeyFormat4FromMessage(const CipOctet **const message, ElectronicKeyFormat4 *key)
Gets the data for an Electronic Key of format 4 from the EPath message.
size_t CipEpathEncodeConnectionEpath(const CipConnectionPathEpath *const connection_epath, CipOctet **encoded_path)
CipUsint GetPathNetworkSegmentProductionInhibitTimeInMilliseconds(const unsigned char *const cip_path)
Return the Production Inhibit Time in milliseconds from an EPath.
segment_type
Segment type Enum.
unsigned int GetPathSymbolicSegmentASCIIFormatLength(const unsigned char *const cip_path)
enum symbolic_segment_extended_format SymbolicSegmentExtendedFormat
Extended symbolic symbol formats.
void SetPathPortSegmentPortIdentifier(const unsigned int port_identifier, unsigned char *const cip_path)
Sets the Port Identifier form an Port Segment EPath to be sent.
bool GetPathPortSegmentExtendedLinkAddressSizeBit(const unsigned char *const cip_path)
Only to be used on Port Segments. Returns if the Port Segment has the extended link address size bit ...
SegmentType GetPathSegmentType(const CipOctet *const cip_path)
Gets the basic segment type of a CIP EPath.
enum logical_segment_type LogicalSegmentLogicalType
Enum containing values which kind of logical segment is encoded.
#define LOGICAL_SEGMENT_TYPE_MEMBER_ID
#define LOGICAL_SEGMENT_FORMAT_EIGHT_BIT
void ElectronicKeyFormat4SetProductCode(ElectronicKeyFormat4 *const electronic_key, const CipUint product_code)
Set product code in the electronic key.
#define NETWORK_SEGMENT_PRODUCTION_INHIBIT_TIME_IN_MILLISECONDS
enum logical_segment_special_type_logical_format LogicalSegmentSpecialTypeLogicalFormat