versadac  1
versadac - Scalable Recorder Firmware
eips_cpf.h
1 /*
2  * Copyright (c) 2002-2013 by Real Time Automation, Inc.
3  *
4  * This software is copyrighted by and is the sole property of
5  * Real Time Automation, Inc. (RTA). All rights, title, ownership,
6  * or other interests in the software remain the property of RTA.
7  * This software may only be used in accordance with the corresponding
8  * license agreement. Any unauthorized use, duplication, transmission,
9  * distribution, or disclosure of this software is expressly forbidden.
10  *
11  * This Copyright notice MAY NOT be removed or modified without prior
12  * written consent of RTA.
13  *
14  * RTA reserves the right to modify this software without notice.
15  *
16  * Real Time Automation
17  * 150 S. Sunny Slope Road USA 262.439.4999
18  * Suite 130 www.rtaautomation.com
19  * Brookfield, WI 53005 software@rtaautomation.com
20  *
21  *************************************************************************
22  *
23  * Version Date: 18APR2013
24  * Version: 2.33
25  * Conformed To: EtherNet/IP Protocol Conformance Test A-9 (16-NOV-2011)
26  * Module Name: eips_cpf.h
27  * Author: Jamin D. Wendorf (jwendorf@rtaautomation.com)
28  * Language: Ansi C
29  * Compile Options: N/A
30  * Compile defines: N/A
31  * Libraries: N/A
32  * Link Options: N/A
33  *
34  * Description.
35  * =======================================================================
36  * This file contains EtherNet/IP Server "Common Packet Format"
37  * definitions.
38  *
39  */
40 
41 #ifndef __EIPS_CPF_H__
42 #define __EIPS_CPF_H__
43 
44 #ifdef EIPS_PCCC_USED
45  #define PCCC_CMD 0x0F
46  #define PCCC_FNC_READ 0x68
47  #define PCCC_FNC_WRITE 0x67
48 
49  /* STS Error Codes */
50  #define STSERR_SUCCESS 0x00 /* SUCCESS */
51  #define STSERR_ILLCMD 0x10 /* Illegal command or format (only command is 0x0F) */
52  #define STSERR_EXTSTS 0xF0 /* Error code in the EXT STS byte */
53 
54  /* EXT STS Error Codes */
55  #define EXTSTS_NONE 0x00 /* No additional error */
56  #define EXTSTS_FIELDILLVAL 0x01 /* A field has an illegal value */
57  #define EXTSTS_TOOFEWLEVELS 0x02 /* Less levels specified in address than min for any address */
58  #define EXTSTS_TOOMANYLEVELS 0x03 /* More levels specified in address than system supports */
59  #define EXTSTS_SYMBOLNOTFOUND 0x04 /* Symbol not found */
60  #define EXTSTS_SYMBOLBADFORMAT 0x05 /* Symbol is of improper format */
61  #define EXTSTS_BADADDRESS 0x06 /* Address doesn't point to something useful */
62  #define EXTSTS_DATAFILETOOLRG 0x09 /* Data or file is too large */
63  #define EXTSTS_TRANSSIZETOOLRG 0x0A /* Transaction size plus word address is too large */
64  #define EXTSTS_REGISRO 0x0B /* Access denied, improper privilege (WR to RO Reg) */
65 #endif
66 
67 #define LINKOBJ_PROD 0x00
68 #define LINKOBJ_CONS 0x01
69 
70 #define LINKOBJSTATE_NONEXIST 0x00
71 #define LINKOBJSTATE_RUNNING 0x01
72 
73 #define CNXNST_UNCONNECTED 0x00
74 #define CNXNST_CONNECTED 0x01
75 
76 #ifdef EUROTHERM_VXWORKS
77 #define EIPS_CPF_MAX_MULTIPLE_REQ_LEN 500
78 #endif
79 #define EIPS_CPF_MAX_ITEM_DATA_LEN EIPS_USER_MSGRTR_DATA_SIZE /* EUROTHERM_VXWORKS - this was changed to 512 in the old V2.1 stack */
80 #define EIPS_CPF_MAX_RSP_SIZ EIPS_USER_MAX_ENCAP_BUFFER_SIZ
81 
82 #define LOGSEG_8BITCLASS 0x20
83 #define LOGSEG_16BITCLASS 0x21
84 #define LOGSEG_32BITCLASS 0x22
85 #define LOGSEG_RSVDCLASS 0x23
86 #define LOGSEG_8BITINST 0x24
87 #define LOGSEG_16BITINST 0x25
88 #define LOGSEG_32BITINST 0x26
89 #define LOGSEG_RSVDBITINST 0x27
90 #define LOGSEG_8BITMEMBER 0x28
91 #define LOGSEG_16BITMEMBER 0x29
92 #define LOGSEG_32BITMEMBER 0x2A
93 #define LOGSEG_RSVDBITMEMBER 0x2B
94 #define LOGSEG_8BITCNXNPT 0x2C
95 #define LOGSEG_16BITCNXNPT 0x2D
96 #define LOGSEG_32BITCNXNPT 0x2E
97 #define LOGSEG_RSVDBITCNXNPT 0x2F
98 #define LOGSEG_8BITATTR 0x30
99 #define LOGSEG_16BITATTR 0x31
100 #define LOGSEG_32BITATTR 0x32
101 #define LOGSEG_RSVDBITATTR 0x33
102 #define LOGSEG_ELECKEY 0x34
103 #define ELECKEY_FORMAT 0x04
104 #define NETSEG_PRODINHIBIT 0x43 /* Production Inhibit Time Network Segment (1 byte to follow in ms) */
105 #define DATASEG_SIMPLE 0x80 /* Simple Data Segment (1 byte to follow - len in words), then word data */
106 #define ANSIEXT_SYMSEG 0x91 /* ANSI Extended Symbol Segment (1 byte to follow - len if bytes), then ASCII string */
107 
108 /* ---------------------------- */
109 /* MISCELLANEOUS / MACROS */
110 /* ---------------------------- */
111 /*
112  * TCP sequence numbers are 32 bit integers operated
113  * on with modular arithmetric. These macros can be
114  * used to compare such integers.
115  */
116 
117 #define SEQ_LT (a,b) ((int)((a)-(b)) < 0)
118 #define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
119 #define SEQ_GT (a,b) ((int)((a)-(b)) > 0)
120 #define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0)
121 
122 #define SEQ32_LT(a,b) (((int32)((uint32)a - (uint32)b)) < 0)
123 #define SEQ32_LEQ(a,b) (((int32)((uint32)a - (uint32)b)) <= 0)
124 #define SEQ32_GT(a,b) (((int32)((uint32)a - (uint32)b)) > 0)
125 #define SEQ32_GEQ(a,b) (((int32)((uint32)a - (uint32)b)) >= 0)
126 
127 #define SEQ16_LT(a,b) (((int16)((uint16)a - (uint16)b)) < 0)
128 #define SEQ16_LEQ(a,b) (((int16)((uint16)a - (uint16)b)) <= 0)
129 #define SEQ16_GT(a,b) (((int16)((uint16)a - (uint16)b)) > 0)
130 #define SEQ16_GEQ(a,b) (((int16)((uint16)a - (uint16)b)) >= 0)
131 
132 /*
133  * The bulk of the information I found was in the ControlNet
134  * International Specification, Version 2.0, Errata 2,
135  * Part 4 "Network and Transport Layer", Section 8
136  * "TCP/IP Encapsulation".
137  *
138  * I Receive the C.P.F. part of the encapsulated Ethernet/IP
139  * message (Part 4, Section 8.9 "Common packet format").
140  *
141  * (Table 4-62: Common packet format)
142  * --------------------------------------------------------------------
143  * | FIELD NAME | TYPE | DESCRIPTION |
144  * |--------------------------------------------------------------------|
145  * | Item Count | uint16 | # of items to follow (>1) |
146  * |--------------------------------------------------------------------|
147  * | Address Item | Struct (see below) | Address info for encap. packet |
148  * |--------------------------------------------------------------------|
149  * | Data Item | Struct (see below) | The encap. data packet |
150  * |--------------------------------------------------------------------|
151  * | Optional additional items |
152  * --------------------------------------------------------------------
153  *
154  * (Table 4-63: Address and data item structure)
155  * -------------------------------------------------------------
156  * | FIELD NAME | TYPE | DESCRIPTION |
157  * |-------------------------------------------------------------|
158  * | Type ID | uint16 | Type of item encapsulated |
159  * |-------------------------------------------------------------|
160  * | Length | uint16 | Length in bytes of data to follow |
161  * |-------------------------------------------------------------|
162  * | Data | Variable | The data (if Length > 0) |
163  * -------------------------------------------------------------
164  */
165 
166 /* ***************************************************** */
167 /* ADDRESS TYPE IDS (From Table 4-64: Address type ID's) */
168 /* ***************************************************** */
169 #define ADDR_TYP_ID_NULL 0x0000 /* NULL (used for UCMM messages) */
170 /* 0x0001 - 0x00A0 -> Allocated for compatiblity with existing protocols) */
171 #define ADDR_TYP_ID_CNXNBASED 0x00A1 /* Connection-based (used for connected msgs) */
172 /* 0x00A2 - 0x7FFF -> Allocated for compatiblity with existing protocols) */
173 #define ADDR_TYP_ID_ENBT 0x0085 /* ENBT IP Address as String */
174 /* 0x8000 - 0x8001 -> Area for future expansion */
175 #define ADDR_TYP_ID_SEQADDRTYP 0x8002 /* Sequenced Address Type */
176 /* 0x8003 - 0xFFFF -> Area for future expansion */
177 
178 /* *********************************************** */
179 /* DATA TYPE IDS (From Table 4-65: Data type ID's) */
180 /* *********************************************** */
181 /* 0x0000 - 0x00B0 -> Allocated for compatiblity with existing protocols) */
182 #define DATA_TYP_ID_PDU 0x00B1 /* Connected Transport PDU */
183 #define DATA_TYP_ID_UCMM 0x00B2 /* Unconnected Message */
184 /* 0x00B3 - 0x7FFF -> Allocated for compatiblity with existing protocols) */
185 #define DATA_TYP_ID_ENBT 0x0091 /* ENBT DF1 String */
186 #define DATA_TYP_ID_SOCK_OT 0x8000 /* Sockaddr Info. originator-to-target */
187 #define DATA_TYP_ID_SOCK_TO 0x8001 /* Sockaddr Info. target-to-originator */
188 /* 0x8002 - 0xFFFF -> Area for future expansion */
189 
190 /* -------------- 8-Bit RANGE DEFINITIONS ------------------------------ */
191 /* Class (pass to user) */
192 #define CLASSRANGE8_VENDSPEC_MIN 0x64
193 #define CLASSRANGE8_VENDSPEC_MAX 0xC7
194 
195 /* Attribute (if class is supported, pass to user) */
196 #define ATTRRANGE8_VENDSPEC_MIN 0x64
197 #define ATTRRANGE8_VENDSPEC_MAX 0xC7
198 
199 /* Service Code (pass to user) */
200 #define SERVICERANGE8_VENDSPEC_MIN 0x32
201 #define SERVICERANGE8_VENDSPEC_MAX 0x4A
202 
203 /* -------------CLASS DEFINITIONS--------------------------------------- */
204 #define EIPS_IDENTITY_CLASS_REV 1
205 #define EIPS_ASSEMBLY_CLASS_REV 2
206 #define EIPS_TCP_CLASS_REV 2
207 #define EIPS_ENETLINK_CLASS_REV 3
208 
209 #ifdef EIPS_QOS_USED
210  #define EIPS_QOS_CLASS_REV 1
211 #endif
212 
213 #ifdef EIPS_TACL_OBJ_USED
214  #define EIPS_TACL_CLASS_REV 1
215 #endif
216 
217 /* -------------GENERIC OBJECT CLASSES--------------------------------- */
218 #define CLASS_IDENTITY 0x01
219 #define CLASS_MSGROUTER 0x02
220 #define CLASS_ASSEMBLY 0x04
221 #define CLASS_CONNECTMGR 0x06
222 #define CLASS_DIP 0x08
223 #define CLASS_DOP 0x09
224 #define CLASS_QOS 0x48
225 #define CLASS_TCPIP 0xF5
226 #define CLASS_ENETLINK 0xF6
227 
228 /* -------------COMMON SERVICE CODES----------------------------------- */
229 #define CIP_SC_GET_ATTR_ALL 0x01
230 #define CIP_SC_SET_ATTR_ALL 0x02
231 #define CIP_SC_RESET 0x05
232 #define CIP_SC_CREATE 0x08
233 #define CIP_SC_DELETE 0x09
234 #define CIP_SC_MULTI_SERV_PACKET 0x0A
235 #define CIP_SC_APPLY_ATTRIBS 0x0D
236 #define CIP_SC_GET_ATTR_SINGLE 0x0E
237 #define CIP_SC_SET_ATTR_SINGLE 0x10
238 #define CIP_SC_RESTORE 0x15
239 #define CIP_SC_ERROR_RESPONSE 0x94
240 
241 #ifdef EIPS_TACL_OBJ_USED
242  #define CLASS_TACL 0xA0 /* this may change */
243  #define CIP_SC_TACL_CNXN_READ 0x4C
244 #endif
245 
246 #ifdef EIPS_PCCC_USED
247  #define CLASS_PCCC 0x67
248  #define RA_SC_EXECUTE_PCCC 0x4B
249 #endif
250 
251 /* Connection Manager Services (PDU) */
252 #define CIP_SC_FWD_OPEN_REQ 0x54 /* Open a connection (0-511 bytes) */
253 #define CIP_SC_FWD_OPEN_RSP 0xD4 /* Open Response */
254 
255 #define CIP_SC_LRG_FWD_OPEN_REQ 0x5B /* Open a large connection (512-65535 bytes) */
256 #define CIP_SC_LRG_FWD_OPEN_RSP 0xDB /* Large Open Response */
257 
258 #define CIP_SC_FWD_CLOSE_REQ 0x4E /* Close a connection */
259 #define CIP_SC_FWD_CLOSE_RSP 0xCE /* Close Response */
260 
261 /* Unconnected Send */
262 #define CIP_SC_UNCON_SEND 0x52
263 
264 /* Rockwell Automation Tag Read/Write */
265 #define RA_SC_RD_TAG_REQ_REQ 0x4C
266 #define RA_SC_RD_FRAG_TAG_REQ_REQ 0x52
267 #define RA_SC_WR_TAG_REQ_REQ 0x4D
268 #define RA_SC_WR_FRAG_TAG_REQ_REQ 0x53
269 #define RA_SC_RD_MOD_WR_TAG_REQ_REQ 0x4E
270 
271 #define RA_SC_RD_TAG_REQ_RSP 0xCC
272 #define RA_SC_RD_FRAG_TAG_REQ_RSP 0xD2
273 #define RA_SC_WR_TAG_REQ_RSP 0xCD
274 #define RA_SC_WR_FRAG_TAG_REQ_RSP 0xD3
275 #define RA_SC_RD_MOD_WR_TAG_REQ_RSP 0xCE
276 
277 /* TCP Object Configuration Capabilities attribute */
278 #define EIPS_TCPCFG_BOOTPCLIENT_SUPPORTED 0x00000001L
279 #define EIPS_TCPCFG_DNSCLIENT_SUPPORTED 0x00000002L
280 #define EIPS_TCPCFG_DHCPCLIENT_SUPPORTED 0x00000004L
281 #define EIPS_TCPCFG_DHCPDNS_SUPPORTED 0x00000008L
282 #define EIPS_TCPCFG_CONFIGSETTABLE_SUPPORTED 0x00000010L
283 
284 /* -------------ERROR CODES-------------------------------------------- */
285 #define ERR_SUCCESS 0x00
286 #define ERR_CNXN_FAILURE 0x01
287 #define ERR_RESOURCE_UNAVAIL 0x02
288 #define ERR_INV_PARAMNAME 0x03
289 #define ERR_PATHSEGMENT 0x04
290 #define ERR_PATHDESTUNKNOWN 0x05
291 #define ERR_PARTIALXFER 0x06
292 #define ERR_CNXNLOST 0x07
293 #define ERR_SERV_UNSUPP 0x08
294 #define ERR_INV_ATTRIBVAL 0x09
295 #define ERR_ATTR_LIST_ERR 0x0A
296 #define ERR_IN_REQ_STATE 0x0B
297 #define ERR_OBJ_STATE_CONFLICT 0x0C
298 #define ERR_OBJ_ALREADY_EXISTS 0x0D
299 #define ERR_ATTR_READONLY 0x0E
300 #define ERR_PRIV_VIOLATION 0x0F
301 #define ERR_DEV_STATE_CONFLICT 0x10
302 #define ERR_REPLY_SIZE 0x11
303 #define ERR_FRAG_PRIM_VAL 0x12
304 #define ERR_INSUFF_DATA 0x13
305 #define ERR_ATTR_UNSUPP 0x14
306 #define ERR_TOOMUCH_DATA 0x15
307 #define ERR_UNEXISTANT_OBJ 0x16
308 #define ERR_SERV_FRAG_SEQ 0x17
309 #define ERR_NO_ATTR_DATA 0x18
310 #define ERR_STORE_FAILURE 0x19
311 #define ERR_ROUTE_REQ_TOO_LRG 0x1A
312 #define ERR_ROUTE_RSP_TOO_LRG 0x1B
313 #define ERR_MISSING_ATTR_LIST 0x1C
314 #define ERR_INV_ATTR_LIST 0x1D
315 #define ERR_EMBEDDED_SERV_ERR 0x1E
316 #define ERR_VENDOR_SPECIFIC 0x1F
317 #define ERR_INV_SERVICE_PARM 0x20
318 #define ERR_WO_VAL_ALREADY_W 0x21
319 #define ERR_INV_REP_RECV 0x22
320 #define ERR_BUFFER_OVERFLOW 0x23
321 #define ERR_MSG_FORMAT_ERR 0x24
322 #define ERR_KEY_ERR_IN_PATH 0x25
323 #define ERR_PATH_SIZE_INV 0x26
324 #define ERR_UNEXP_ATTR_IN_LIST 0x27
325 #define ERR_INV_MEMBER_ID 0x28
326 #define ERR_MEMBER_READONLY 0x29
327 #define ERR_G2ONLY_GEN_ERR 0x2A
328 #define ERR_UNKNOWN_MB_ERR 0x2B
329 #define ERR_ATTR_NOT_GETTABLE 0x2C
330 
331 #define ERR_NOADD_ERRCODE 0xFF
332 
333 /* -------------VENDOR ERROR CONDITIONS-------------------------------- */
334 #define ERRV_UNDEF_SERV 0x01
335 
336 /* -------------LED FLASH RATE----------------------------------------- */
337 #define LED_FLASH_RATE TICKS_PER_50MSEC /* (50 * 10msec) = 500msec */
338 
339 /* -------------MESSAGE CONTROL BITS----------------------------------- */
340 #define DNBIT_RR 0x80
341 #define DNBIT_FRAG 0x80
342 #define DNBIT_XID 0x40
343 #define DNBIT_XPORT_DIR 0x80
344 #define DNBITS_FRAGCNT 0x3F
345 
346 /* -------------FRAGMENT PROCESSING------------------------------------ */
347 #define FRAGTYP_1ST 0
348 #define FRAGTYP_MID 1
349 #define FRAGTYP_LAST 2
350 #define FRAGTYP_ACK 3
351 #define FRAGCNT_END 0x3F
352 
353 /* -------------CONNECTION STATES-------------------------------------- */
354 #define CXST_NONEXIST 0x00
355 #define CXST_CONFIGURING 0x01
356 #define CXST_WAIT4CID 0x02
357 #define CXST_ESTABLISHED 0x03
358 #define CXST_TIMEOUT 0x04
359 #define CXST_DEFERDELETE 0x05
360 
361 /* -------------INSTANCE TYPES----------------------------------------- */
362 #define INST_TYP_EM 0x00
363 #define INST_TYP_IO 0x01
364 
365 /* -------------MESSAGE BODY FORMAT------------------------------------ */
366 #define BDYFMT_C8I8 0x00 /* Class = 8, Instance = 8 */
367 #define BDYFMT_C8I6 0x01 /* Class = 8, Instance = 16 */
368 #define BDYFMT_C6I6 0x02 /* Class = 16, Instance = 16 */
369 #define BDYFMT_C6I8 0x03 /* Class = 16, Instance = 8 */
370 
371 /* -------------INIT PROD CHARS---------------------------------------- */
372 #define PRODGRP1 0x00
373 #define PRODGRP2DEST 0x01
374 #define PRODGRP2SRC 0x02
375 #define PRODGRP3 0x03
376 #define PRODDEFAULT 0x0F
377 
378 /* -------------INIT CONS CHARS---------------------------------------- */
379 #define CONSGRP1 0x00
380 #define CONSGRP2DEST 0x01
381 #define CONSGRP2SRC 0x02
382 #define CONSGRP3 0x03
383 #define CONSDEFAULT 0x0F
384 
385 /* -------------MAX PROD SIZE and MAX CONS SIZE------------------------ */
386 /*** The values for the Max Prod Size and Max Cons Size are listed in pw.h ***/
387 
388 /* -------------TRANSPORT DIRECTIONS----------------------------------- */
389 #define XPORTDIR_CLIENT 0x00
390 #define XPORTDIR_SERVER 0x80
391 
392 /* -------------TIMEOUT ACTION DEF------------------------------------- */
393 #define TMOACTION_TMO 0x00
394 #define TMOACTION_DELETE 0x01
395 #define TMOACTION_AUTORESET 0x02
396 #define TMOACTION_DEFERDELETE 0x03
397 
398 /* ************************************ */
399 /* IDENTITY STATUS WORD BIT DEFINITIONS */
400 /* ************************************ */
401 #define IDSTATWORD_OWNED 0x0001
402 #define IDSTATWORD_RSVD1 0x0002
403 #define IDSTATWORD_CONFIGURED 0x0004
404 #define IDSTATWORD_RSVD2 0x0008
405 #define IDSTATWORD_VENDOR1 0x0010
406 #define IDSTATWORD_VENDOR2 0x0020
407 #define IDSTATWORD_VENDOR3 0x0040
408 #define IDSTATWORD_VENDOR4 0x0080
409 #define IDSTATWORD_MINRFLT 0x0100
410 #define IDSTATWORD_MINNRFLT 0x0200
411 #define IDSTATWORD_MAJRFLT 0x0400
412 #define IDSTATWORD_MAJNRFLT 0x0800
413 #define IDSTATWORD_RSVD3 0x1000
414 #define IDSTATWORD_RSVD4 0x2000
415 #define IDSTATWORD_RSVD5 0x4000
416 #define IDSTATWORD_RSVD6 0x8000
417 
418 #endif /* __EIPS_CPF_H__ */