OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ciptypes.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, Rockwell Automation, Inc.
3  * All rights reserved.
4  *
5  ******************************************************************************/
6 #ifndef OPENER_CIPTYPES_H_
7 #define OPENER_CIPTYPES_H_
8 
9 #include "typedefs.h"
10 #include "networkhandler.h"
11 #include "enipmessage.h"
12 
13 #include "opener_user_conf.h"
14 
17 typedef enum cip_data_types {
18  kCipAny = 0x00,
19  kCipBool = 0xC1,
20  kCipSint = 0xC2,
21  kCipInt = 0xC3,
22  kCipDint = 0xC4,
23  kCipLint = 0xC5,
24  kCipUsint = 0xC6,
25  kCipUint = 0xC7,
26  kCipUdint = 0xC8,
27  kCipUlint = 0xC9,
28  kCipReal = 0xCA,
29  kCipLreal = 0xCB,
30  kCipStime = 0xCC,
31  kCipDate = 0xCD,
32  kCipTimeOfDay = 0xCE,
33  kCipDateAndTime = 0xCF,
34  kCipString = 0xD0,
35  kCipByte = 0xD1,
36  kCipWord = 0xD2,
37  kCipDword = 0xD3,
38  kCipLword = 0xD4,
39  kCipString2 = 0xD5,
40  kCipFtime = 0xD6,
41  kCipLtime = 0xD7,
42  kCipItime = 0xD8,
43  kCipStringN = 0xD9,
44  kCipShortString = 0xDA,
46  kCipTime = 0xDB,
47  kCipEpath = 0xDC,
48  kCipEngUnit = 0xDD,
49  /* definition of some CIP structs */
50  /* need to be validated in IEC 61131-3 subclause 2.3.3 */
51  /* TODO: Check these codes */
52  kCipUsintUsint = 0xA0,
55  kCip6Usint = 0xA2,
56  kCipMemberList = 0xA3,
57  kCipByteArray = 0xA4,
60 } CipDataType;
61 
68 typedef enum {
69  /* Start CIP common services */
74  kReset = 0x05,
75  kStart = 0x06,
76  kStop = 0x07,
77  kCreate = 0x08,
78  kDelete = 0x09,
84  kRestore = 0x15,
85  kSave = 0x16,
86  kNoOperation = 0x17,
87  kGetMember = 0x18,
88  kSetMember = 0x19,
89  kInsertMember = 0x1A,
90  kRemoveMember = 0x1B,
91  kGroupSync = 0x1C,
92  /* End CIP common services */
93 
94  /* Start CIP object-specific services */
95  kForwardOpen = 0x54,
96  kForwardClose = 0x4E,
99 /* End CIP object-specific services */
101 
103 typedef enum { /* TODO: Rework */
105  kGetableAll = 0x01,
106  kGetableSingle = 0x02,
107  kSetable = 0x04,
108  /* combined for convenience */
109  kSetAndGetAble = 0x07,
112 
113 typedef enum {
118 
122 typedef struct {
125 } CipByteArray;
126 
130 typedef struct {
134 
138 typedef struct {
141 } CipString;
142 
143 typedef struct {
147 } CipStringN;
148 
152 typedef struct {
157 } CipEpath;
158 
159 typedef enum connection_point_type {
165 
169 typedef struct {
176 
177 
179 typedef struct {
182 } CipRevision;
183 
187 typedef struct {
191  const CipOctet *data;
193 
194 #define MAX_SIZE_OF_ADD_STATUS 2 /* for now we support extended status codes up to 2 16bit values there is mostly only one 16bit value used */
195 
199 typedef struct {
207  EipUint16 additional_status[MAX_SIZE_OF_ADD_STATUS];
214 
215 typedef struct {
218  CIPAttributeFlag attribute_flags; /*< 0 => getable_all, 1 => getable_single; 2 =>
219  setable_single; 3 => get and setable; all other
220  values reserved */
221  void *data;
223 
224 /* type definition of CIP service structure */
225 
226 /* instances are stored in a linked list*/
227 typedef struct cip_instance {
232  struct cip_instance *next;
234 } CipInstance;
235 
237 typedef struct cip_class {
239  /* the rest of these are specific to the Class class only. */
249  uint8_t *set_bit_mask;
250  uint8_t *get_all_bit_mask;
257  char *class_name;
258 } CipClass;
259 
278  CipInstance *const instance,
279  CipMessageRouterRequest *const message_router_request,
280  CipMessageRouterResponse *const message_router_response,
281  struct sockaddr *originator_address,
282  const int encapsulation_session);
283 
285 typedef struct cip_service_struct {
288  char *name;
290 
294 typedef struct {
302 
303 typedef struct {
305  EipUint32 port; /* support up to 32 bit path*/
307 } CipRoutePath;
308 
309 typedef struct {
317  void *data;
319 
320 typedef struct {
324 
325 /* these are used for creating the getAttributeAll masks
326  TODO there might be a way simplifying this using __VARARGS__ in #define */
327 #define MASK1(a) ( 1 << (a) )
328 #define MASK2(a, b) ( 1 << (a) | 1 << (b) )
329 #define MASK3(a, b, c) ( 1 << (a) | 1 << (b) | 1 << (c) )
330 #define MASK4(a, b, c, d) ( 1 << (a) | 1 << (b) | 1 << (c) | 1 << (d) )
331 #define MASK5(a, b, c, d, e) \
332  ( 1 << (a) | 1 << (b) | 1 << (c) | 1 << (d) | 1 << (e) )
333 #define MASK6(a, b, c, d, e, f) \
334  ( 1 << (a) | 1 << (b) | 1 << (c) | 1 << (d) | 1 << (e) | 1 << (f) )
335 #define MASK7(a, b, c, d, e, f, g) \
336  ( 1 << (a) | 1 << (b) | 1 << (c) | 1 << (d) | 1 << (e) | 1 << (f) | 1 << (g) )
337 #define MASK8(a, b, c, d, e, f, g, h) \
338  ( 1 << (a) | 1 << (b) | 1 << (c) | 1 << (d) | 1 << (e) | 1 << (f) | \
339  1 << (g) | 1 << (h) )
340 
341 #endif /* OPENER_CIPTYPES_H_ */
struct cip_class CipClass
Class is a subclass of Instance.
CIP Short String.
Definition: ciptypes.h:130
Struct for padded EPATHs.
Definition: ciptypes.h:152
struct cip_service_struct * services
Definition: ciptypes.h:256
EipUint16 attribute_number
Definition: ciptypes.h:216
const CipOctet * data
Definition: ciptypes.h:191
EipUint16 number_of_instances
Definition: ciptypes.h:242
EipUint8 path_size
Definition: ciptypes.h:304
EipUint16 number_of_attributes
Definition: ciptypes.h:244
EipUint32 class_id
Definition: ciptypes.h:171
CipAttributeStruct * attributes
Definition: ciptypes.h:229
EipStatus(* CipServiceFunction)(CipInstance *const instance, CipMessageRouterRequest *const message_router_request, CipMessageRouterResponse *const message_router_response, struct sockaddr *originator_address, const int encapsulation_session)
Signature definition for the implementation of CIP services.
Definition: ciptypes.h:277
CIP Message Router Request.
Definition: ciptypes.h:187
EipUint32 class_id
Definition: ciptypes.h:240
char * class_name
Definition: ciptypes.h:257
Class is a subclass of Instance.
Definition: ciptypes.h:237
CipInstance * instances
Definition: ciptypes.h:255
CIP Byte Array.
Definition: ciptypes.h:122
EipUint16 length
Definition: ciptypes.h:123
CIP Connection Path.
Definition: ciptypes.h:169
CipServiceFunction service_function
Definition: ciptypes.h:287
EipUint32 get_attribute_all_mask
Definition: ciptypes.h:252
enum cip_data_types CipDataType
Enum containing the encoding values for CIP data types for CIP Messages.
EipUint8 service_number
Definition: ciptypes.h:286
CIP String.
Definition: ciptypes.h:138
uint8_t * get_single_bit_mask
Definition: ciptypes.h:248
#define MAX_SIZE_OF_ADD_STATUS
Definition: ciptypes.h:194
Definition: ciptypes.h:76
EipUint32 address
Definition: ciptypes.h:306
EipUint8 data_segment
Definition: ciptypes.h:173
CIPServiceCode
Definition of CIP service codes.
Definition: ciptypes.h:68
CIPAttributeFlag attribute_flags
Definition: ciptypes.h:218
EipUint8 path_size
Definition: ciptypes.h:153
uint8_t CipOctet
Data types as defined in the CIP Specification Vol 1 Appendix C.
Definition: typedefs.h:41
CIPAttributeFlag
Definition of Get and Set Flags for CIP Attributes.
Definition: ciptypes.h:103
EipUint16 length
Definition: ciptypes.h:139
EipStatus
EIP stack status enum.
Definition: typedefs.h:93
uint8_t EipUint8
Definition: typedefs.h:32
CipInstance class_instance
Definition: ciptypes.h:238
uint32_t EipUint32
Definition: typedefs.h:34
IoConnectionEvent
Definition: ciptypes.h:113
struct cip_instance * next
Definition: ciptypes.h:232
EipByte * string
Definition: ciptypes.h:146
struct cip_service_struct CipServiceStruct
Service descriptor. These are stored in an array.
uint8_t CipBool
Definition: typedefs.h:42
EipUint16 revision
Definition: ciptypes.h:241
EipByte * string
Definition: ciptypes.h:140
EipUint8 * segment_data
Definition: ciptypes.h:174
cip_data_types
Enum containing the encoding values for CIP data types for CIP Messages.
Definition: ciptypes.h:17
uint8_t CipUsint
Definition: typedefs.h:46
enum connection_point_type ConnectionPointType
connection_point_type
Definition: ciptypes.h:159
Service descriptor. These are stored in an array.
Definition: ciptypes.h:285
Struct for saving TCP/IP interface information.
Definition: ciptypes.h:294
EipUint16 class_id
Definition: ciptypes.h:154
EipUint16 length
Definition: ciptypes.h:145
EipUint16 instance_number
Definition: ciptypes.h:155
EipUint16 number_of_services
Definition: ciptypes.h:254
EipUint8 path_size
Definition: ciptypes.h:170
EipUint16 attribute_number
Definition: ciptypes.h:156
EipUint8 minor_revision
Definition: ciptypes.h:181
uint8_t EipByte
EIP Data type definitions.
Definition: typedefs.h:28
EipUint8 major_revision
Definition: ciptypes.h:180
Definition: ciptypes.h:85
int16_t EipInt16
Definition: typedefs.h:30
EipUint32 port
Definition: ciptypes.h:305
struct cip_instance CipInstance
uint32_t CipUdint
Definition: typedefs.h:48
uint16_t CipUint
Definition: typedefs.h:47
EipUint16 highest_attribute_number
Definition: ciptypes.h:245
uint8_t * set_bit_mask
Definition: ciptypes.h:249
Struct storing the CIP revision.
Definition: ciptypes.h:179
CIP Message Router Response.
Definition: ciptypes.h:199
EipUint16 message_request_size
Definition: ciptypes.h:312
struct cip_class * cip_class
Definition: ciptypes.h:231
CipMessageRouterRequest message_request
Definition: ciptypes.h:313
EipUint8 length
Definition: ciptypes.h:131
EipByte * string
Definition: ciptypes.h:132
CipMessageRouterResponse * message_response
Definition: ciptypes.h:314
EipUint32 instance_number
Definition: ciptypes.h:228
uint16_t EipUint16
Definition: typedefs.h:33
EipByte * data
Definition: ciptypes.h:124
EipInt16 request_path_size
Definition: ciptypes.h:190
uint8_t * get_all_bit_mask
Definition: ciptypes.h:250
CipUsint size_of_additional_status
Definition: ciptypes.h:205
EipUint16 size
Definition: ciptypes.h:144