Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-ecatmb.h
1/* packet-ecatmb.h
2 *
3 * Copyright (c) 2007 by Beckhoff Automation GmbH
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <[email protected]>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11#ifndef _PACKET_ECATMAILBOX_H_
12#define _PACKET_ECATMAILBOX_H_
13
14#include <ws_diag_control.h>
15DIAG_OFF_PEDANTIC
16
17/* Ensure the same data layout for all platforms */
18
19typedef struct TETHERNET_ADDRESS
20{
21 uint8_t b[6];
22} ETHERNET_ADDRESS, *PETHERNET_ADDRESS;
23#define ETHERNET_ADDRESS_LEN ((int) sizeof(ETHERNET_ADDRESS))
24
25/* Mailbox*/
26#define ETHERCAT_MBOX_TYPE_ADS 1 /* AMS/ADS header follows*/
27#define ETHERCAT_MBOX_TYPE_EOE 2 /* ETHERCAT_EOE_HEADER follows*/
28#define ETHERCAT_MBOX_TYPE_COE 3 /* ETHERCAT_COE_HEADER follows*/
29#define ETHERCAT_MBOX_TYPE_FOE 4 /* ETHERCAT_FOE_HEADER follows*/
30#define ETHERCAT_MBOX_TYPE_SOE 5 /* ETHERCAT_SOE_HEADER follows*/
31
33{
34 uint16_t Control;
35 struct
36 {
37 uint16_t Channel : 6; /* optional communication channels (default = 0)*/
38 uint16_t Priority : 2; /* optional communication priority (default = 0)*/
39 uint16_t Type : 4; /* TETHERCAT_MBOX_TYPE_xxx*/
40 uint16_t Counter : 3; /* 0 = counter not used (old version)*/
41 uint16_t Unsupported : 1; /* unsupported protocol detected*/
42 } v;
44
46{
47 uint16_t Length; /* following bytes*/
48 uint16_t Address; /* S->M: phys addr of destination; M->S: phys addr of source; 0 = master*/
49 MbxHeaderControlUnion aControlUnion;
51
52#define ETHERCAT_MBOX_HEADER_LEN ((int) sizeof(ETHERCAT_MBOX_HEADER))
53
54/* EoE*/
55#define ETHERNET_FRAMENO_MASK 0x0000000F
56
57#define EOE_TYPE_FRAME_FRAG 0 /* ETHERCAT_EOE_HEADER followed by frame fragment (ETHERCAT_EOE_TIMESTAMP may included) */
58#define EOE_TYPE_TIMESTAMP_RES 1 /* ETHERCAT_EOE_HEADER followed by ETHERCAT_EOE_TIMESTAMP */
59#define EOE_TYPE_INIT_REQ 2 /* ETHERCAT_EOE_HEADER followed by ETHERCAT_EOE_INIT */
60#define EOE_TYPE_INIT_RES 3 /* ETHERCAT_EOE_HEADER */
61#define EOE_TYPE_MACFILTER_REQ 4 /* ETHERCAT_EOE_HEADER followed by ETHERCAT_EOE_MACFILTER */
62#define EOE_TYPE_MACFILTER_RES 5 /* ETHERCAT_EOE_HEADER */
63
64#define EOE_RESULT_NOERROR 0x0000
65#define EOE_RESULT_UNSPECIFIED_ERROR 0x0001
66#define EOE_RESULT_UNSUPPORTED_TYPE 0x0002
67#define EOE_RESULT_NO_IP_SUPPORT 0x0201
68#define EOE_RESULT_NO_MACFILTERMASK_SUPPORT 0x0401
69
70
71/*typedef struct TETHERCAT_EOE_INIT
72{
73 uint32_t ContainsMacAddr :1;
74 uint32_t ContainsIpAddr :1;
75 uint32_t ContainsSubnetMask :1;
76 uint32_t ContainsDefaultGateway :1;
77 uint32_t ContainsDnsServer :1;
78 uint32_t ContainsDnsName :1;
79 uint32_t Reserved :26;
80 ETHERNET_ADDRESS MacAddr;
81 uint32_t IpAddr;
82 uint32_t SubnetMask;
83 uint32_t DefaultGateway;
84 uint32_t DnsServer;
85 char DnsName[32];
86} ETHERCAT_EOE_INIT, *PETHERCAT_EOE_INIT;*/
87#define ETHERCAT_EOE_INIT_LEN 58 /*sizeof(ETHERCAT_EOE_INIT)*/
88
90{
91 struct
92 {
93 uint16_t MacFilterCount :4;
94 uint16_t MacFilterMaskCount :2;
95 uint16_t Reserved1 :1;
96 uint16_t NoBroadcasts :1;
97 uint16_t Reserved2 :8;
98 } v;
99 uint16_t Options;
101
103{
104 EoeMacFilterOptionsUnion anEoeMacFilterOptionsUnion;
105 ETHERNET_ADDRESS MacFilter[16];
106 ETHERNET_ADDRESS MacFilterMask[4];
108#define ETHERCAT_EOE_MACFILTER_LEN ((int) sizeof(ETHERCAT_EOE_MACFILTER))
109
111{
112 uint32_t TimeStamp; /* 32 bit time stamp */
114#define ETHERCAT_EOE_TIMESTAMP_LEN ((int) sizeof(ETHERCAT_EOE_TIMESTAMP))
115
117{
118 struct
119 { /* EOE_TYPE_FRAME_FRAG and EOE_TYPE_TIMESTAMP_RES only */
120 uint16_t Fragment : 6; /* fragment number (EOE_TYPE_FRAME_FRAG only) */
121 uint16_t OffsetBuffer : 6; /* byte offset multiplied by 32 (if Fragment != 0) (EOE_TYPE_FRAME_FRAG only) */
122 /* buffer size multiplied by 32 (if Fragment == 0) (EOE_TYPE_FRAME_FRAG only) */
123 uint16_t FrameNo : 4; /* frame number (EOE_TYPE_FRAME_FRAG and EOE_TYPE_TIMESTAMP_RES only) */
124 } v;
125 uint16_t Result; /* EOE_TYPE_INIT_RES and EOE_TYPE_MACFILTER_RES only */
127
129{
130 struct
131 {
132 uint16_t Type : 4; /* specifies following data */
133 uint16_t PortAssign : 4; /* 0 = unspecified, 1 = port 1 */
134 uint16_t LastFragment : 1; /* true if last fragment (EOE_TYPE_FRAME_FRAG only) */
135 uint16_t TimeStampAppended : 1; /* 32 bit time stamp appended (EOE_TYPE_FRAME_FRAG with LastFragment=1 only) */
136 uint16_t TimeStampRequested : 1; /* time stamp response requested (EOE_TYPE_FRAME_FRAG only) */
137 uint16_t Reserved : 5;
138 } v;
139 uint16_t Info;
141
143{
144 EoeHeaderInfoUnion anEoeHeaderInfoUnion;
145 EoeHeaderDataUnion anEoeHeaderDataUnion;
147#define ETHERCAT_EOE_HEADER_LEN ((int) sizeof(ETHERCAT_EOE_HEADER))
148
149/* CANopen*/
150#define ETHERCAT_COE_TYPE_EMERGENCY 1
151#define ETHERCAT_COE_TYPE_SDOREQ 2
152#define ETHERCAT_COE_TYPE_SDORES 3
153#define ETHERCAT_COE_TYPE_TXPDO 4
154#define ETHERCAT_COE_TYPE_RXPDO 5
155#define ETHERCAT_COE_TYPE_TXPDO_RTR 6 /* Remote transmission request of TXPDO (master requested)*/
156#define ETHERCAT_COE_TYPE_RXPDO_RTR 7 /* Remote transmission request of RXPDO (slave requested) */
157#define ETHERCAT_COE_TYPE_SDOINFO 8
158
160{
161 struct
162 {
163 uint16_t Number : 9; /* e.g. PDO number*/
164 uint16_t Reserved : 3; /* = 0*/
165 uint16_t Type : 4; /* CANopen type*/
166 } v;
167 uint16_t header;
169#define ETHERCAT_COE_HEADER_LEN ((int) sizeof(ETHERCAT_COE_HEADER))
170
171
172typedef union tSdoHeaderUnion
173{
174 struct
175 { /* Initiate Download Request*/
176 uint8_t SizeInd : 1;
177 uint8_t Expedited : 1;
178 uint8_t Size : 2;
179 uint8_t Complete : 1;
180 uint8_t Ccs : 3; /* = 1*/
181 } Idq;
182 struct
183 { /* Initiate Download Response*/
184 uint8_t Reserved : 5;
185 uint8_t Scs : 3; /* = 3*/
186 } Ids;
187 struct
188 { /* Download Segment Request*/
189 uint8_t LastSeg : 1;
190 uint8_t Size : 3;
191 uint8_t Toggle : 1;
192 uint8_t Ccs : 3; /* = 0*/
193 } Dsq;
194 struct
195 { /* Download Segment Response*/
196 uint8_t Reserved : 4;
197 uint8_t Toggle : 1;
198 uint8_t Scs : 3; /* = 1*/
199 } Dss;
200 struct
201 { /* Initiate Upload Request*/
202 uint8_t Reserved : 4;
203 uint8_t Complete : 1;
204 uint8_t Ccs : 3; /* = 2*/
205 } Iuq;
206 struct
207 { /* Initiate Upload Response*/
208 uint8_t SizeInd : 1;
209 uint8_t Expedited : 1;
210 uint8_t Size : 2;
211 uint8_t Complete : 1;
212 uint8_t Scs : 3; /* = 2*/
213 } Ius;
214 struct
215 { /* Upload Segment Request*/
216 uint8_t Reserved : 4;
217 uint8_t Toggle : 1;
218 uint8_t Ccs : 3; /* = 3*/
219 } Usq;
220 struct
221 { /* Upload Segment Response*/
222 uint8_t LastSeg : 1;
223 uint8_t Bytes : 3;
224 uint8_t Toggle : 1;
225 uint8_t Scs : 3; /* = 0*/
226 } Uss;
227 struct
228 { /* Abort Transfer*/
229 uint8_t Reserved : 5;
230 uint8_t Ccs : 3; /* = 4*/
231 } Abt;
232 uint8_t CS;
234
236{
237 SdoHeaderUnion anSdoHeaderUnion;
238
239 uint16_t Index;
240 uint8_t SubIndex;
241 uint32_t Data;
243
244#define ETHERCAT_SDO_HEADER_LEN 8 /* sizeof(ETHERCAT_SDO_HEADER)*/
245
246#define SDO_CCS_DOWNLOAD_SEGMENT 0
247#define SDO_CCS_INITIATE_DOWNLOAD 1
248#define SDO_CCS_INITIATE_UPLOAD 2
249#define SDO_CCS_UPLOAD_SEGMENT 3
250#define SDO_CCS_ABORT_TRANSFER 4
251
252#define SDO_SCS_UPLOAD_SEGMENT 0
253#define SDO_SCS_DOWNLOAD_SEGMENT 1
254#define SDO_SCS_INITIATE_UPLOAD 2
255#define SDO_SCS_INITIATE_DOWNLOAD 3
256
257/* CoE SDO Information */
258#define ECAT_COE_INFO_OPCODE_LIST_Q 1
259#define ECAT_COE_INFO_OPCODE_LIST_S 2
260#define ECAT_COE_INFO_OPCODE_OBJ_Q 3
261#define ECAT_COE_INFO_OPCODE_OBJ_S 4
262#define ECAT_COE_INFO_OPCODE_ENTRY_Q 5
263#define ECAT_COE_INFO_OPCODE_ENTRY_S 6
264#define ECAT_COE_INFO_OPCODE_ERROR_S 7
265
266#define ECAT_COE_INFO_LIST_TYPE_LENGTH 0
267#define ECAT_COE_INFO_LIST_TYPE_ALL 1
268#define ECAT_COE_INFO_LIST_TYPE_PDOMAP 2
269#define ECAT_COE_INFO_LIST_TYPE_BACKUP 3
270
271#define ECAT_COE_INFO_OBJCODE_NULL 0
272#define ECAT_COE_INFO_OBJCODE_DOMAIN 2
273#define ECAT_COE_INFO_OBJCODE_DEFTYPE 5
274#define ECAT_COE_INFO_OBJCODE_DEFSTRUCT 6
275#define ECAT_COE_INFO_OBJCODE_VAR 7
276#define ECAT_COE_INFO_OBJCODE_ARRAY 8
277#define ECAT_COE_INFO_OBJCODE_RECORD 9
278
279#define ECAT_COE_INFO_OBJCAT_OPTIONAL 0
280#define ECAT_COE_INFO_OBJCAT_MANDATORY 1
281
282#define ECAT_COE_INFO_OBJACCESS_RO 0x07
283#define ECAT_COE_INFO_OBJACCESS_RW 0x3f
284
286{
287 uint16_t ListType; /* == SDO_INFO_LIST_TYPE_XXX */
288 struct
289 {
290 uint16_t Index[1];
291 } Res;
293
295{
296 uint16_t Index;
297 struct
298 {
299 uint16_t DataType; /* refer to data type index */
300 uint8_t MaxSubIndex; /* max subIndex */
301 uint8_t ObjCode; /* defined in DS 301 (Table 37)*/
302 char Name[1]; /* rest of mailbox data*/
303 } Res;
305
307{
308 uint16_t Index;
309 uint8_t SubIdx;
310 uint8_t ValueInfo; /* bit0 = ObjAccess, bit1 = ObjCategory, bit2 = PdoMapping, bit3 = UnitType
311 bit4 = DefaultValue, bit5 = MinValue, bit6 = MaxValue*/
312 struct
313 {
314 uint16_t DataType; /* refer to data type index */
315 uint16_t BitLen;
316 uint16_t ObjAccess; /* bit0 = read; bit1 = write; bit2 = const. bit3 = 'PRE-OP'; bit4 = 'SAFE-OP'; bit5 = 'OP'.*/
317 } Res;
319
321{
322 uint32_t ErrorCode;
323 char ErrorText[1]; /* rest of mailbox data */
325
326typedef union tSdoInfoUnion
327{
332 uint8_t Data[1];
334
335typedef union tSdoControlUnion
336{
337 struct
338 {
339 uint8_t OpCode : 7; /* == SDO_INFO_TYPE_XXX */
340 uint8_t InComplete : 1;
341 } v;
342 uint8_t Control;
344
346{
347 SdoControlUnion anSdoControlUnion;
348 uint8_t Reserved; /* == 0 */
349 uint16_t FragmentsLeft;
350 SdoInfoUnion anSdoInfoUnion;
352
353#define ETHERCAT_SDO_INFO_LISTREQ_LEN 6 /*offsetof(ETHERCAT_SDO_INFO_HEADER, anSdoInfoUnion.List.Res)*/
354
355/* FoE (File Access over EtherCAT)*/
356#define ECAT_FOE_OPMODE_RRQ 1
357#define ECAT_FOE_OPMODE_WRQ 2
358#define ECAT_FOE_OPMODE_DATA 3
359#define ECAT_FOE_OPMODE_ACK 4
360#define ECAT_FOE_OPMODE_ERR 5
361#define ECAT_FOE_OPMODE_BUSY 6
362
363#define ECAT_FOE_ERRCODE_NOTDEFINED 0
364#define ECAT_FOE_ERRCODE_NOTFOUND 1
365#define ECAT_FOE_ERRCODE_ACCESS 2
366#define ECAT_FOE_ERRCODE_DISKFULL 3
367#define ECAT_FOE_ERRCODE_ILLEAGAL 4
368#define ECAT_FOE_ERRCODE_PACKENO 5
369#define ECAT_FOE_ERRCODE_EXISTS 6
370#define ECAT_FOE_ERRCODE_NOUSER 7
371#define ECAT_FOE_ERRCODE_BOOTSTRAPONLY 8
372#define ECAT_FOE_ERRCODE_NOTINBOOTSTRAP 9
373
375{
376 uint32_t FileLength; /* (RRQ, WRQ) = 0 if unknown */
377 struct
378 {
379 uint16_t PacketNo; /* (DATA, ACK)*/
380 uint16_t Reserved2; /* (DATA, ACK)*/
381 } v;
382 uint32_t ErrorCode; /* (ERR)*/
383 struct
384 {
385 uint16_t Done; /* (BUSY)*/
386 uint16_t Entire; /* (BUSY)*/
387 } v2;
389
391{
392 uint8_t OpMode; /* = 1 (RRQ), = 2 (WRQ), = 3 (DATA), = 4 (ACK), = 5 (ERR), = 6 (BUSY) */
393 uint8_t Reserved1; /* = 0 */
394
395 FoeHeaderDataUnion aFoeHeaderDataUnion;
396 /* typedef union tMailBoxDataUnion
397 {
398 char Name[] (RRQ, WRQ) rest of mailbox data
399 uint8_t Data[] (DATA) rest of mailbox data (if OpMode = 3)
400 char ErrorText[] (ERR) rest of mailbox data
401 } MailBoxDataUnion;*/
403#define ETHERCAT_FOE_HEADER_LEN 6 /*sizeof(ETHERCAT_FOE_HEADER)*/
404
405typedef struct
406{
407 uint16_t Cmd;
408 uint16_t Size;
409 uint16_t AddressLW;
410 uint16_t AddressHW;
412
413
414/* SoE (SOE over EtherCAT)*/
415#define ECAT_SOE_OPCODE_RRQ 1
416#define ECAT_SOE_OPCODE_RRS 2
417#define ECAT_SOE_OPCODE_WRQ 3
418#define ECAT_SOE_OPCODE_WRS 4
419#define ECAT_SOE_OPCODE_NFC 5
420
421
423{
424 struct
425 {
426 uint8_t OpCode : 3; /* 0 = unused, 1 = readReq, 2 = readRes, 3 = writeReq, 4 = writeRes
427 5 = notification (command changed notification)*/
428 uint8_t InComplete : 1; /* more follows*/
429 uint8_t Error : 1; /* an error word follows */
430 uint8_t DriveNo : 3; /* drive number */
431
432 uint8_t DataState : 1; /* follows or requested */
433 uint8_t Name : 1; /* follows or requested */
434 uint8_t Attribute : 1; /* follows or requested */
435 uint8_t Unit : 1; /* follows or requested */
436 uint8_t Min : 1; /* follows or requested */
437 uint8_t Max : 1; /* follows or requested */
438 uint8_t Value : 1; /* follows or requested */
439 uint8_t Reserved : 1;
440 } v;
441 struct
442 {
443 uint8_t Control;
444 uint8_t Element;
445 } v2;
447
449{
450 uint16_t IDN; /* SOE IDN if (InComplete==0) */
451 uint16_t FragmentsLeft; /* Pending fragments if (InComplete==1) */
453
455{
456 SoeHeaderControlUnion anSoeHeaderControlUnion;
457 SoeHeaderDataUnion anSoeHeaderDataUnion;
458 /* typedef union tMailBoxDataUnion
459 {
460 uint8_t Data[] rest of mailbox data if (Error==0)
461 uint16_t ErrorCode if (Error==1)
462 } MailBoxDataUnion;*/
464#define ETHERCAT_SOE_HEADER_LEN ((int) sizeof(ETHERCAT_SOE_HEADER))
465
466extern void init_mbx_header(PETHERCAT_MBOX_HEADER pMbox, tvbuff_t *tvb, int offset);
467
468DIAG_ON_PEDANTIC
469#endif /* _PACKET_ECATMAILBOX_H_ */
Definition address.h:56
Definition packet-ecatmb.h:406
Definition packet-ecatmb.h:143
Definition packet-ecatmb.h:103
Definition packet-ecatmb.h:111
Definition packet-ecatmb.h:391
Definition packet-ecatmb.h:46
Definition packet-ecatmb.h:236
Definition packet-ecatmb.h:307
Definition packet-ecatmb.h:321
Definition packet-ecatmb.h:346
Definition packet-ecatmb.h:286
Definition packet-ecatmb.h:295
Definition packet-ecatmb.h:455
Definition packet-ecatmb.h:20
Definition tvbuff-int.h:35
Definition packet-ecatmb.h:160
Definition packet-ecatmb.h:117
Definition packet-ecatmb.h:129
Definition packet-ecatmb.h:90
Definition packet-ecatmb.h:375
Definition packet-ecatmb.h:33
Definition packet-ecatmb.h:336
Definition packet-ecatmb.h:173
Definition packet-ecatmb.h:327
Definition packet-ecatmb.h:423
Definition packet-ecatmb.h:449