2 * Routines for EtherCAT packet disassembly
6 * Copyright (c) 2007 by Beckhoff Automation GmbH
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include <epan/packet.h>
37 #include "packet-ecatmb.h"
39 #define BIT2BYTE(x) ((x+7)/8)
40 #define ENDOF(p) ((p)+1) /* pointer to end of *p */
42 static dissector_handle_t eth_handle
;
43 static dissector_handle_t ams_handle
;
45 /* Define the EtherCAT mailbox proto */
46 int proto_ecat_mailbox
= -1;
48 static int ett_ecat_mailbox
= -1;
49 static int ett_ecat_mailbox_eoe
= -1;
50 static int ett_ecat_mailbox_eoe_init
= -1;
51 static int ett_ecat_mailbox_eoe_macfilter
= -1;
52 static int ett_ecat_mailbox_eoe_macfilter_filter
= -1;
53 static int ett_ecat_mailbox_eoe_macfilter_filtermask
= -1;
54 static int ett_ecat_mailbox_coe
= -1;
55 static int ett_ecat_mailbox_sdo
= -1;
56 static int ett_ecat_mailbox_coe_sdoccs
= -1;
57 static int ett_ecat_mailbox_coe_sdoscs
= -1;
58 static int ett_ecat_mailbox_foe
= -1;
59 static int ett_ecat_mailbox_foe_efw
= -1;
60 static int ett_ecat_mailbox_soeflag
= -1;
61 static int ett_ecat_mailbox_soe
= -1;
62 static int ett_ecat_mailbox_fraghead
= -1;
63 static int ett_ecat_mailbox_header
= -1;
65 static int hf_ecat_mailboxlength
= -1;
66 static int hf_ecat_mailboxaddress
= -1;
67 static int hf_ecat_mailbox_eoe
= -1;
68 static int hf_ecat_mailbox_eoe_fraghead
= -1;
69 static int hf_ecat_mailbox_eoe_type
= -1;
70 static int hf_ecat_mailbox_eoe_fragno
= -1;
71 static int hf_ecat_mailbox_eoe_offset
= -1;
72 static int hf_ecat_mailbox_eoe_frame
= -1;
73 static int hf_ecat_mailbox_eoe_last
= -1;
74 static int hf_ecat_mailbox_eoe_timestampreq
= -1;
75 static int hf_ecat_mailbox_eoe_timestampapp
= -1;
76 static int hf_ecat_mailbox_eoe_fragment
= -1;
77 static int hf_ecat_mailbox_eoe_init
= -1;
78 static int hf_ecat_mailbox_eoe_init_contains_macaddr
= -1;
79 static int hf_ecat_mailbox_eoe_init_contains_ipaddr
= -1;
80 static int hf_ecat_mailbox_eoe_init_contains_subnetmask
= -1;
81 static int hf_ecat_mailbox_eoe_init_contains_defaultgateway
= -1;
82 static int hf_ecat_mailbox_eoe_init_contains_dnsserver
= -1;
83 static int hf_ecat_mailbox_eoe_init_contains_dnsname
= -1;
84 static int hf_ecat_mailbox_eoe_init_append_timestamp
= -1;
85 static int hf_ecat_mailbox_eoe_init_macaddr
= -1;
86 static int hf_ecat_mailbox_eoe_init_ipaddr
= -1;
87 static int hf_ecat_mailbox_eoe_init_subnetmask
= -1;
88 static int hf_ecat_mailbox_eoe_init_defaultgateway
= -1;
89 static int hf_ecat_mailbox_eoe_init_dnsserver
= -1;
90 static int hf_ecat_mailbox_eoe_init_dnsname
= -1;
91 static int hf_ecat_mailbox_eoe_macfilter
= -1;
92 static int hf_ecat_mailbox_eoe_macfilter_macfiltercount
= -1;
93 static int hf_ecat_mailbox_eoe_macfilter_maskcount
= -1;
94 static int hf_ecat_mailbox_eoe_macfilter_nobroadcasts
= -1;
95 static int hf_ecat_mailbox_eoe_macfilter_filter
;
96 static int hf_ecat_mailbox_eoe_macfilter_filters
[16] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
97 static int hf_ecat_mailbox_eoe_macfilter_filtermask
= -1;
98 static int hf_ecat_mailbox_eoe_macfilter_filtermasks
[4] = {-1,-1,-1,-1};
99 static int hf_ecat_mailbox_eoe_timestamp
= -1;
100 static int hf_ecat_mailbox_coe
= -1;
101 static int hf_ecat_mailbox_coe_number
= -1;
102 static int hf_ecat_mailbox_coe_type
= -1;
103 static int hf_ecat_mailbox_coe_sdoreq
= -1;
104 static int hf_ecat_mailbox_coe_sdoccsid
= -1;
105 static int hf_ecat_mailbox_coe_sdoccsid_sizeind
= -1;
106 static int hf_ecat_mailbox_coe_sdoccsid_expedited
= -1;
107 static int hf_ecat_mailbox_coe_sdoccsid_size0
= -1;
108 static int hf_ecat_mailbox_coe_sdoccsid_size1
= -1;
109 static int hf_ecat_mailbox_coe_sdoccsid_complete
= -1;
110 static int hf_ecat_mailbox_coe_sdoccsds
= -1;
111 static int hf_ecat_mailbox_coe_sdoccsds_lastseg
= -1;
112 static int hf_ecat_mailbox_coe_sdoccsds_size
= -1;
113 static int hf_ecat_mailbox_coe_sdoccsds_toggle
= -1;
114 static int hf_ecat_mailbox_coe_sdoccsus
= -1;
115 static int hf_ecat_mailbox_coe_sdoccsus_toggle
= -1;
116 static int hf_ecat_mailbox_coe_sdoccsiu
= -1;
117 /* static int hf_ecat_mailbox_coe_sdoccsiu_complete = -1; */
118 static int hf_ecat_mailbox_coe_sdoidx
= -1;
119 static int hf_ecat_mailbox_coe_sdosub
= -1;
120 static int hf_ecat_mailbox_coe_sdodata
= -1;
121 static int hf_ecat_mailbox_coe_sdodata1
= -1;
122 static int hf_ecat_mailbox_coe_sdodata2
= -1;
123 static int hf_ecat_mailbox_coe_sdoldata
= -1;
124 static int hf_ecat_mailbox_coe_sdolength
= -1;
125 /* static int hf_ecat_mailbox_coe_sdoerror = -1; */
126 static int hf_ecat_mailbox_coe_sdores
= -1;
127 static int hf_ecat_mailbox_coe_sdoscsds
= -1;
128 static int hf_ecat_mailbox_coe_sdoscsds_toggle
= -1;
129 static int hf_ecat_mailbox_coe_sdoscsiu
= -1;
130 static int hf_ecat_mailbox_coe_sdoscsiu_sizeind
= -1;
131 static int hf_ecat_mailbox_coe_sdoscsiu_expedited
= -1;
132 static int hf_ecat_mailbox_coe_sdoscsiu_size0
= -1;
133 static int hf_ecat_mailbox_coe_sdoscsiu_size1
= -1;
134 static int hf_ecat_mailbox_coe_sdoscsiu_complete
= -1;
135 static int hf_ecat_mailbox_coe_sdoscsus
= -1;
136 static int hf_ecat_mailbox_coe_sdoscsus_lastseg
= -1;
137 static int hf_ecat_mailbox_coe_sdoscsus_bytes
= -1;
138 static int hf_ecat_mailbox_coe_sdoscsus_toggle
= -1;
139 static int hf_ecat_mailbox_coe_sdoinfoopcode
= -1;
140 static int hf_ecat_mailbox_coe_sdoinfofrag
= -1;
141 static int hf_ecat_mailbox_coe_sdoinfolisttype
= -1;
142 static int hf_ecat_mailbox_coe_sdoinfolist
= -1;
143 static int hf_ecat_mailbox_coe_sdoinfoindex
= -1;
144 static int hf_ecat_mailbox_coe_sdoinfosubindex
= -1;
145 static int hf_ecat_mailbox_coe_sdoinfovalueinfo
= -1;
146 static int hf_ecat_mailbox_coe_sdoinfoerrorcode
= -1;
147 static int hf_ecat_mailbox_coe_sdoinfodatatype
= -1;
148 static int hf_ecat_mailbox_coe_sdoinfomaxsub
= -1;
149 static int hf_ecat_mailbox_coe_sdoinfoobjcode
= -1;
150 static int hf_ecat_mailbox_coe_sdoinfoname
= -1;
151 static int hf_ecat_mailbox_coe_sdoinfobitlen
= -1;
152 static int hf_ecat_mailbox_coe_sdoinfoobjaccess
= -1;
153 static int hf_ecat_mailbox_coe_sdoinfounittype
= -1;
154 static int hf_ecat_mailbox_coe_sdoinfodefaultvalue
= -1;
155 static int hf_ecat_mailbox_coe_sdoinfominvalue
= -1;
156 static int hf_ecat_mailbox_coe_sdoinfomaxvalue
= -1;
157 static int hf_ecat_mailboxdata
= -1;
158 static int hf_ecat_mailbox_foe
= -1;
159 static int hf_ecat_mailbox_foe_opmode
= -1;
160 static int hf_ecat_mailbox_foe_filelength
= -1;
161 static int hf_ecat_mailbox_foe_filename
= -1;
162 static int hf_ecat_mailbox_foe_packetno
= -1;
163 static int hf_ecat_mailbox_foe_errcode
= -1;
164 static int hf_ecat_mailbox_foe_errtext
= -1;
165 static int hf_ecat_mailbox_foe_busydone
= -1;
166 static int hf_ecat_mailbox_foe_busyentire
= -1;
167 static int hf_ecat_mailbox_foe_data
= -1;
168 static int hf_ecat_mailbox_foe_efw
= -1;
169 static int hf_ecat_mailbox_foe_efw_cmd
= -1;
170 static int hf_ecat_mailbox_foe_efw_size
= -1;
171 static int hf_ecat_mailbox_foe_efw_addresslw
= -1;
172 static int hf_ecat_mailbox_foe_efw_addresshw
= -1;
173 static int hf_ecat_mailbox_foe_efw_data
= -1;
174 static int hf_ecat_mailbox_soe
= -1;
175 static int hf_ecat_mailbox_soe_header
= -1;
177 static int hf_ecat_mailbox_soe_header_opcode
= -1;
178 static int hf_ecat_mailbox_soe_header_incomplete
= -1;
179 static int hf_ecat_mailbox_soe_header_error
= -1;
180 static int hf_ecat_mailbox_soe_header_driveno
= -1;
181 static int hf_ecat_mailbox_soe_header_datastate
= -1;
182 static int hf_ecat_mailbox_soe_header_name
= -1;
183 static int hf_ecat_mailbox_soe_header_attribute
= -1;
184 static int hf_ecat_mailbox_soe_header_unit
= -1;
185 static int hf_ecat_mailbox_soe_header_min
= -1;
186 static int hf_ecat_mailbox_soe_header_max
= -1;
187 static int hf_ecat_mailbox_soe_header_value
= -1;
188 static int hf_ecat_mailbox_soe_header_reserved
= -1;
189 static int hf_ecat_mailbox_soe_idn
= -1;
190 static int hf_ecat_mailbox_soe_data
= -1;
191 static int hf_ecat_mailbox_soe_frag
= -1;
192 static int hf_ecat_mailbox_soe_error
= -1;
194 static const value_string EcMBoxType
[] =
197 { 1, "AoE (Vendor specific; Beckhoff ADS over EtherCAT)", },
198 { 2, "EoE (Ethernet over EtherCAT)", },
199 { 3, "CoE (CANopen over EtherCAT)", },
200 { 4, "FoE (File access over EtherCAT)", },
201 { 5, "SoE (Servo profile over EtherCAT)", },
202 { 15, "VoE (Vendor specific over EtherCAT)"},
203 { 0x80+1, "AoE - Err", },
204 { 0x80+2, "EoE - Err", },
205 { 0x80+3, "CoE - Err", },
206 { 0x80+4, "FoE - Err", },
207 { 0x80+5, "SoE - Err", },
211 static const value_string FoEOpMode
[] =
222 static const value_string FoEEfwCmd
[] =
224 { 1, "Memory Transfer", },
225 { 2, "Write Code", },
226 { 3, "Check device id", },
228 { 5, "Write code checksum", },
229 { 6, "Set device id", },
230 { 8, "Set code id", },
232 { 10, "Checksum checksum", },
233 { 11, "boot checksum", },
237 static const value_string SoeOpcode
[] =
244 { 5, "notification" },
249 static const true_false_string tfs_complete
=
254 void init_mbx_header(PETHERCAT_MBOX_HEADER pMbox
, tvbuff_t
*tvb
, gint offset
)
256 pMbox
->Length
= tvb_get_letohs(tvb
, offset
); offset
+=(int)sizeof(guint16
);
257 pMbox
->Address
= tvb_get_letohs(tvb
, offset
); offset
+=(int)sizeof(guint16
);
258 pMbox
->aControlUnion
.Control
= tvb_get_letohs(tvb
, offset
);
261 void init_eoe_header(PETHERCAT_EOE_HEADER pEoE
, tvbuff_t
*tvb
, gint offset
)
263 pEoE
->anEoeHeaderInfoUnion
.Info
= tvb_get_letohs(tvb
, offset
); offset
+=(int)sizeof(guint16
);
264 pEoE
->anEoeHeaderDataUnion
.Result
= tvb_get_letohs(tvb
, offset
);
267 void init_foe_header(PETHERCAT_FOE_HEADER pFoE
, tvbuff_t
*tvb
, gint offset
)
269 pFoE
->OpMode
= tvb_get_guint8(tvb
, offset
++);
270 pFoE
->Reserved1
= tvb_get_guint8(tvb
, offset
++);
271 pFoE
->aFoeHeaderDataUnion
.FileLength
= tvb_get_letohl(tvb
, offset
);
274 void init_soe_header(PETHERCAT_SOE_HEADER pSoE
, tvbuff_t
*tvb
, gint offset
)
276 pSoE
->anSoeHeaderControlUnion
.v2
.Control
= tvb_get_guint8(tvb
, offset
++);
277 pSoE
->anSoeHeaderControlUnion
.v2
.Element
= tvb_get_guint8(tvb
, offset
++);
278 pSoE
->anSoeHeaderDataUnion
.FragmentsLeft
= tvb_get_letohs(tvb
, offset
);
281 void init_coe_header(PETHERCAT_COE_HEADER pCoE
, tvbuff_t
*tvb
, gint offset
)
283 pCoE
->header
= tvb_get_letohs(tvb
, offset
);
286 void init_sdo_header(PETHERCAT_SDO_HEADER pSdo
, tvbuff_t
*tvb
, gint offset
)
288 pSdo
->anSdoHeaderUnion
.CS
= tvb_get_guint8(tvb
, offset
++);
289 pSdo
->Index
= tvb_get_letohs(tvb
, offset
);offset
+=(int)sizeof(guint16
);
290 pSdo
->SubIndex
= tvb_get_guint8(tvb
, offset
++);
291 pSdo
->Data
= tvb_get_letohl(tvb
, offset
);
294 void init_sdo_info_header(PETHERCAT_SDO_INFO_HEADER pInfo
, tvbuff_t
*tvb
, gint offset
)
296 pInfo
->anSdoControlUnion
.Control
= tvb_get_guint8(tvb
, offset
++);
297 pInfo
->Reserved
= tvb_get_guint8(tvb
, offset
);
298 pInfo
->FragmentsLeft
= (int)sizeof(guint16
);
302 static void MailboxTypeFormatter(PETHERCAT_MBOX_HEADER pMbx
, char *szText
, gint nMax
)
306 for(i
= 0; i
<sizeof(EcMBoxType
)/sizeof(value_string
); i
++ )
308 if( EcMBoxType
[i
].value
== pMbx
->aControlUnion
.v
.Type
)
310 g_snprintf(szText
, nMax
, "Type : %s (0x%x)", EcMBoxType
[i
].strptr
, pMbx
->aControlUnion
.v
.Type
);
314 g_snprintf ( szText
, nMax
,"Type : %d", pMbx
->aControlUnion
.v
.Type
);
317 static void EoETypeFormatter(PETHERCAT_EOE_HEADER pEoE
, char *szText
, gint nMax
)
319 switch (pEoE
->anEoeHeaderInfoUnion
.v
.Type
)
321 case EOE_TYPE_FRAME_FRAG
:
322 g_snprintf ( szText
, nMax
, "Type(%d) : Fragment", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
324 case EOE_TYPE_TIMESTAMP_RES
:
325 g_snprintf ( szText
, nMax
, "Type(%d) : TimeStamp", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
327 case EOE_TYPE_INIT_REQ
:
328 g_snprintf ( szText
, nMax
, "Type(%d) : Init Req", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
330 case EOE_TYPE_INIT_RES
:
331 g_snprintf ( szText
, nMax
, "Type(%d) : Init Res", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
333 case EOE_TYPE_MACFILTER_REQ
:
334 g_snprintf ( szText
, nMax
, "Type(%d) : MAC Req", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
336 case EOE_TYPE_MACFILTER_RES
:
337 g_snprintf ( szText
, nMax
, "Type(%d) : MAC Res", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
340 g_snprintf ( szText
, nMax
, "Type(%d) : Unknown", pEoE
->anEoeHeaderInfoUnion
.v
.Type
);
345 static void EoEFragNoFormatter(PETHERCAT_EOE_HEADER pEoE
, char *szText
, gint nMax
)
347 g_snprintf ( szText
, nMax
, "FragNo : %d", pEoE
->anEoeHeaderDataUnion
.v
.Fragment
);
350 static void EoEOffsetFormatter(PETHERCAT_EOE_HEADER pEoE
, char *szText
, gint nMax
)
352 if ( pEoE
->anEoeHeaderDataUnion
.v
.Fragment
== 0 )
353 g_snprintf ( szText
, nMax
, "BufferSize : %d", 32*pEoE
->anEoeHeaderDataUnion
.v
.OffsetBuffer
);
355 g_snprintf ( szText
, nMax
, "Offset : %d", 32*pEoE
->anEoeHeaderDataUnion
.v
.OffsetBuffer
);
358 static void EoEFrameFormatter(PETHERCAT_EOE_HEADER pEoE
, char *szText
, gint nMax
)
360 g_snprintf ( szText
, nMax
, "FrameNo : %d", pEoE
->anEoeHeaderDataUnion
.v
.FrameNo
);
363 static void EoELastFormatter(PETHERCAT_EOE_HEADER pEoE
, char *szText
, gint nMax
)
365 if ( pEoE
->anEoeHeaderInfoUnion
.v
.LastFragment
!= 0 )
366 g_snprintf ( szText
, nMax
, "Last Frag");
368 g_snprintf ( szText
, nMax
, "More Frags...");
371 static void CANopenNumberFormatter(PETHERCAT_COE_HEADER pCoE
, char *szText
, gint nMax
)
373 g_snprintf( szText
, nMax
, "Number : %d", pCoE
->v
.Number
);
376 static void CANopenTypeFormatter(PETHERCAT_COE_HEADER pCoE
, char *szText
, gint nMax
)
378 switch ( pCoE
->v
.Type
)
380 case ETHERCAT_COE_TYPE_EMERGENCY
:
381 g_snprintf ( szText
, nMax
, "Type : EMERGENCY(%d)", pCoE
->v
.Type
);
383 case ETHERCAT_COE_TYPE_SDOREQ
:
384 g_snprintf ( szText
, nMax
, "Type : SDO Req(%d)", pCoE
->v
.Type
);
386 case ETHERCAT_COE_TYPE_SDORES
:
387 g_snprintf ( szText
, nMax
, "Type : SDO Res(%d)", pCoE
->v
.Type
);
389 case ETHERCAT_COE_TYPE_TXPDO
:
390 g_snprintf ( szText
, nMax
, "Type : TxPDO(%d)", pCoE
->v
.Type
);
392 case ETHERCAT_COE_TYPE_RXPDO
:
393 g_snprintf ( szText
, nMax
, "Type : RxPDO(%d)", pCoE
->v
.Type
);
395 case ETHERCAT_COE_TYPE_TXPDO_RTR
:
396 g_snprintf ( szText
, nMax
, "Type : TxPDO_RTR(%d)", pCoE
->v
.Type
);
398 case ETHERCAT_COE_TYPE_RXPDO_RTR
:
399 g_snprintf ( szText
, nMax
, "Type : RxPDO_RTR(%d)", pCoE
->v
.Type
);
402 g_snprintf ( szText
, nMax
, "Type :%d", pCoE
->v
.Type
);
406 static void CANopenSdoReqFormatter(PETHERCAT_SDO_HEADER pSdo
, char *szText
, gint nMax
)
408 switch ( pSdo
->anSdoHeaderUnion
.Idq
.Ccs
)
410 case SDO_CCS_INITIATE_DOWNLOAD
:
411 g_snprintf ( szText
, nMax
, "SDO Req : 'Initiate Download' (%d) Idx=0x%x Sub=%d", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
, pSdo
->Index
, pSdo
->SubIndex
);
413 case SDO_CCS_INITIATE_UPLOAD
:
414 g_snprintf ( szText
, nMax
, "SDO Req : 'Initiate Upload' (%d) Idx=0x%x Sub=%d", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
, pSdo
->Index
, pSdo
->SubIndex
);
416 case SDO_CCS_DOWNLOAD_SEGMENT
:
417 g_snprintf ( szText
, nMax
, "SDO Req : 'Download Segment' (%d)", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
);
419 case SDO_CCS_UPLOAD_SEGMENT
:
420 g_snprintf ( szText
, nMax
, "SDO Req : 'Upload Segment' (%d)", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
);
422 case SDO_CCS_ABORT_TRANSFER
:
423 g_snprintf ( szText
, nMax
, "SDO Req : 'Abort Transfer' (%d)", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
);
426 g_snprintf ( szText
, nMax
, "SDO Req : Ccs %d", pSdo
->anSdoHeaderUnion
.Idq
.Ccs
);
430 static void CANopenSdoResFormatter(PETHERCAT_SDO_HEADER pSdo
, char *szText
, gint nMax
)
432 g_snprintf ( szText
, nMax
, "SDO Res : Scs %d", pSdo
->anSdoHeaderUnion
.Ids
.Scs
);
435 static void CANopenSdoInfoFormatter(PETHERCAT_SDO_INFO_HEADER pHead
, char *szText
, gint nMax
)
437 guint8 opCode
= pHead
->anSdoControlUnion
.v
.OpCode
& 0x7F;
438 const char* txt2
= "";
439 if ( (pHead
->anSdoControlUnion
.v
.OpCode
& 0x80) != 0 )
440 txt2
= " - More Follows";
443 case ECAT_COE_INFO_OPCODE_LIST_Q
:
444 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'List Req' %s", txt2
);
446 case ECAT_COE_INFO_OPCODE_LIST_S
:
447 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'List Res' %s", txt2
);
449 case ECAT_COE_INFO_OPCODE_OBJ_Q
:
450 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'Obj Req' %s", txt2
);
452 case ECAT_COE_INFO_OPCODE_OBJ_S
:
453 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'Obj Res' %s", txt2
);
455 case ECAT_COE_INFO_OPCODE_ENTRY_Q
:
456 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'Entry Req' %s", txt2
);
458 case ECAT_COE_INFO_OPCODE_ENTRY_S
:
459 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'Entry Res' %s", txt2
);
461 case ECAT_COE_INFO_OPCODE_ERROR_S
:
462 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: 'Error Res' %s", txt2
);
465 g_snprintf ( szText
, nMax
, "CoE SDO Info, OpCode: %d %s", opCode
, txt2
);
469 static void FoeFormatter(tvbuff_t
*tvb
, gint offset
, char *szText
, gint nMax
, guint foe_length
)
471 ETHERCAT_FOE_HEADER foe
;
473 memset(tmp
, 0, sizeof(tmp
));
475 init_foe_header(&foe
, tvb
, offset
);
477 switch ( foe
.OpMode
)
479 case ECAT_FOE_OPMODE_RRQ
:
480 case ECAT_FOE_OPMODE_WRQ
:
481 case ECAT_FOE_OPMODE_ERR
:
482 if ( foe_length
> ETHERCAT_FOE_HEADER_LEN
)
483 tvb_memcpy(tvb
, tmp
, offset
+ETHERCAT_FOE_HEADER_LEN
, MIN(foe_length
-ETHERCAT_FOE_HEADER_LEN
, sizeof(tmp
)-1));
487 switch ( foe
.OpMode
)
489 case ECAT_FOE_OPMODE_RRQ
:
490 g_snprintf ( szText
, nMax
, "FoE RRQ (%d) : '%s'", foe
.aFoeHeaderDataUnion
.FileLength
, tmp
);
492 case ECAT_FOE_OPMODE_WRQ
:
493 g_snprintf ( szText
, nMax
, "FoE WRQ (%d) : '%s'", foe
.aFoeHeaderDataUnion
.FileLength
, tmp
);
495 case ECAT_FOE_OPMODE_DATA
:
496 g_snprintf ( szText
, nMax
, "FoE DATA (%d) : %d Bytes", foe
.aFoeHeaderDataUnion
.v
.PacketNo
, foe_length
-ETHERCAT_FOE_HEADER_LEN
);
498 case ECAT_FOE_OPMODE_ACK
:
499 g_snprintf ( szText
, nMax
, "FoE ACK (%d)", foe
.aFoeHeaderDataUnion
.v
.PacketNo
);
501 case ECAT_FOE_OPMODE_ERR
:
502 g_snprintf ( szText
, nMax
, "FoE ERR (%d) : '%s'", foe
.aFoeHeaderDataUnion
.ErrorCode
, tmp
);
504 case ECAT_FOE_OPMODE_BUSY
:
505 if ( foe
.aFoeHeaderDataUnion
.v2
.Entire
> 0 )
506 g_snprintf ( szText
, nMax
, "FoE BUSY (%d%%)", ((guint32
)foe
.aFoeHeaderDataUnion
.v2
.Done
*100)/foe
.aFoeHeaderDataUnion
.v2
.Entire
);
508 g_snprintf ( szText
, nMax
, "FoE BUSY (%d/%d)", foe
.aFoeHeaderDataUnion
.v2
.Done
, foe
.aFoeHeaderDataUnion
.v2
.Entire
);
513 static void SoEIdToString( char* txt
, guint16 id
, int nMax
)
516 g_snprintf(txt
, nMax
, "P-%d-%04d", (id
>>12) & 0x0007, id
& 0x0FFF );
518 g_snprintf(txt
, nMax
, "S-%d-%04d", id
>>12, id
& 0x0FFF );
521 static void SoeFormatter(tvbuff_t
*tvb
, gint offset
, char *szText
, gint nMax
, guint soe_length
)
523 ETHERCAT_SOE_HEADER soe
;
526 memset(tmp
, 0, sizeof(tmp
));
528 init_soe_header(&soe
, tvb
, offset
);
529 offset
+=ETHERCAT_SOE_HEADER_LEN
;
531 if ( !soe
.anSoeHeaderControlUnion
.v
.Error
)
533 if ( !soe
.anSoeHeaderControlUnion
.v
.InComplete
)
535 SoEIdToString(tmp
, soe
.anSoeHeaderDataUnion
.IDN
, sizeof(tmp
)-1);
537 if ( soe
.anSoeHeaderControlUnion
.v
.DataState
)
538 g_strlcat(elm
, "D", 50);
539 if ( soe
.anSoeHeaderControlUnion
.v
.Name
)
540 g_strlcat(elm
, "N", 50);
541 if ( soe
.anSoeHeaderControlUnion
.v
.Attribute
)
542 g_strlcat(elm
, "A", 50);
543 if ( soe
.anSoeHeaderControlUnion
.v
.Unit
)
544 g_strlcat(elm
, "U", 50);
545 if ( soe
.anSoeHeaderControlUnion
.v
.Min
)
546 g_strlcat(elm
, "I", 50);
547 if ( soe
.anSoeHeaderControlUnion
.v
.Max
)
548 g_strlcat(elm
, "X", 50);
549 if ( soe
.anSoeHeaderControlUnion
.v
.Value
)
550 g_strlcat(elm
, "V", 50);
551 switch ( soe
.anSoeHeaderControlUnion
.v
.OpCode
)
553 case ECAT_SOE_OPCODE_RRQ
:
554 g_snprintf ( szText
, nMax
, "SoE: RRQ (%s, '%s')", tmp
, elm
);
556 case ECAT_SOE_OPCODE_RRS
:
557 g_snprintf ( szText
, nMax
, "SoE: RRS (%s, '%s') : %u Bytes", tmp
, elm
, (guint
)(soe_length
-ETHERCAT_SOE_HEADER_LEN
));
559 case ECAT_SOE_OPCODE_WRS
:
560 g_snprintf ( szText
, nMax
, "SoE: WRS (%s, '%s')", tmp
, elm
);
562 case ECAT_SOE_OPCODE_WRQ
:
563 g_snprintf ( szText
, nMax
, "SoE: WRQ (%s, '%s') : %u Bytes", tmp
, elm
, (guint
)(soe_length
-ETHERCAT_SOE_HEADER_LEN
));
565 case ECAT_SOE_OPCODE_NFC
:
566 g_snprintf ( szText
, nMax
, "SoE: NFC (%s, '%s') : %u Bytes", tmp
, elm
, (guint
)(soe_length
-ETHERCAT_SOE_HEADER_LEN
));
569 g_snprintf ( szText
, nMax
, "SoE: EMGCY");
572 g_snprintf ( szText
, nMax
, "SoE:");
576 g_snprintf ( szText
, nMax
, "SoE: FragmentsLeft %d", soe
.anSoeHeaderDataUnion
.FragmentsLeft
);
579 g_snprintf ( szText
, nMax
, "SoE: Error %04x", tvb_get_letohs(tvb
, offset
));
582 /* ethercat mailbox */
583 static void dissect_ecat_coe(tvbuff_t
*tvb
, gint offset
, packet_info
*pinfo
, proto_tree
*tree
)
585 proto_tree
*ecat_coe_tree
= NULL
, *ecat_sdo_tree
, *ecat_coe_sdoccs_tree
, *ecat_coe_sdoscs_tree
;
587 proto_item
*anItem
= NULL
, *aparent
= NULL
;
589 int nMax
= sizeof(szText
)-1;
591 guint coe_length
= tvb_reported_length(tvb
)-offset
;
596 anItem
= proto_tree_add_item(tree
, hf_ecat_mailbox_coe
, tvb
, offset
, coe_length
, ENC_NA
);
597 proto_item_set_text(anItem
,"CoE");
598 aparent
= proto_item_get_parent(anItem
);
599 proto_item_append_text(aparent
,":CoE ");
602 col_append_str(pinfo
->cinfo
, COL_INFO
, "CoE ");
604 if( coe_length
>= ETHERCAT_COE_HEADER_LEN
)
606 ETHERCAT_COE_HEADER coe
;
607 init_coe_header(&coe
, tvb
, offset
);
610 ecat_coe_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe
);
612 CANopenNumberFormatter(&coe
, szText
, nMax
);
613 anItem
= proto_tree_add_uint(ecat_coe_tree
, hf_ecat_mailbox_coe_number
, tvb
, offset
, ETHERCAT_COE_HEADER_LEN
, coe
.v
.Number
);
614 proto_item_set_text(anItem
, "%s", szText
);
616 CANopenTypeFormatter(&coe
, szText
, nMax
);
617 anItem
= proto_tree_add_uint(ecat_coe_tree
, hf_ecat_mailbox_coe_type
, tvb
, offset
, ETHERCAT_COE_HEADER_LEN
, coe
.v
.Type
);
618 proto_item_set_text(anItem
, "%s", szText
);
621 offset
+= ETHERCAT_COE_HEADER_LEN
;
625 case ETHERCAT_COE_TYPE_SDOREQ
:
627 ETHERCAT_SDO_HEADER sdo
;
629 if( coe_length
< ETHERCAT_COE_HEADER_LEN
+ ETHERCAT_SDO_HEADER_LEN
)
631 col_append_str(pinfo
->cinfo
, COL_INFO
, "Sdo Req - invalid length");
635 init_sdo_header(&sdo
, tvb
, offset
);
637 CANopenSdoReqFormatter(&sdo
, szText
, nMax
);
638 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
642 proto_item_append_text(aparent
, "%s", szText
);
644 anItem
= proto_tree_add_uint(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoreq
, tvb
, offset
, 1, sdo
.anSdoHeaderUnion
.Idq
.Ccs
);
645 proto_item_set_text(anItem
, "%s", szText
);
646 ecat_sdo_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_sdo
);
648 switch ( sdo
.anSdoHeaderUnion
.Idq
.Ccs
)
650 case SDO_CCS_INITIATE_DOWNLOAD
:
651 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoccsid
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
652 ecat_coe_sdoccs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoccs
);
653 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_sizeind
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
654 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_expedited
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
655 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_size0
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
656 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_size1
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
657 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_complete
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
659 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoidx
, tvb
, offset
+1, 2, ENC_LITTLE_ENDIAN
);
660 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdosub
, tvb
, offset
+3, 1, ENC_LITTLE_ENDIAN
);
661 if ( sdo
.anSdoHeaderUnion
.Idq
.SizeInd
&& !sdo
.anSdoHeaderUnion
.Idq
.Expedited
)
663 len
= coe_length
- ETHERCAT_COE_HEADER_LEN
- ETHERCAT_SDO_HEADER_LEN
;
664 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdolength
, tvb
, offset
+4, 4, ENC_LITTLE_ENDIAN
);
665 offset
+=ETHERCAT_SDO_HEADER_LEN
;
667 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoldata
, tvb
, offset
, len
, ENC_NA
);
671 if ( sdo
.anSdoHeaderUnion
.Idq
.Size
== 3 )
672 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata1
, tvb
, offset
+4, 1, ENC_LITTLE_ENDIAN
);
673 else if ( sdo
.anSdoHeaderUnion
.Idq
.Size
== 2 )
674 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata2
, tvb
, offset
+4, 2, ENC_LITTLE_ENDIAN
);
676 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata
, tvb
, offset
+4, 4, ENC_LITTLE_ENDIAN
);
679 case SDO_CCS_INITIATE_UPLOAD
:
680 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoccsiu
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
681 ecat_coe_sdoccs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoccs
);
682 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsid_complete
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
684 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoidx
, tvb
, offset
+1, 2, ENC_LITTLE_ENDIAN
);
685 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdosub
, tvb
, offset
+3, 1, ENC_LITTLE_ENDIAN
);
688 case SDO_CCS_DOWNLOAD_SEGMENT
:
689 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoccsds
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
690 ecat_coe_sdoccs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoccs
);
691 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsds_lastseg
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
692 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsds_size
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
693 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsds_toggle
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
696 if ( coe_length
-offset
> 0 )
698 anItem
= proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoldata
, tvb
, offset
, coe_length
-offset
, ENC_NA
);
699 proto_item_append_text(anItem
, "(len = %d)", coe_length
-offset
);
702 case SDO_CCS_UPLOAD_SEGMENT
:
703 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoccsus
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
704 ecat_coe_sdoccs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoccs
);
705 proto_tree_add_item(ecat_coe_sdoccs_tree
, hf_ecat_mailbox_coe_sdoccsus_toggle
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
707 case SDO_CCS_ABORT_TRANSFER
:
708 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoidx
, tvb
, offset
+4, 4, ENC_LITTLE_ENDIAN
);
715 case ETHERCAT_COE_TYPE_SDORES
:
717 ETHERCAT_SDO_HEADER sdo
;
718 if( coe_length
< ETHERCAT_COE_HEADER_LEN
+ ETHERCAT_SDO_HEADER_LEN
)
720 col_append_str(pinfo
->cinfo
, COL_INFO
, "Sdo Res - invalid length");
724 init_sdo_header(&sdo
, tvb
, offset
);
726 CANopenSdoResFormatter(&sdo
, szText
, nMax
);
727 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
731 anItem
= proto_tree_add_uint(ecat_coe_tree
, hf_ecat_mailbox_coe_sdores
, tvb
, offset
, 1, sdo
.anSdoHeaderUnion
.Ids
.Scs
);
732 proto_item_set_text(anItem
, "%s", szText
);
733 ecat_sdo_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_sdo
);
735 switch ( sdo
.anSdoHeaderUnion
.Ids
.Scs
)
737 case SDO_SCS_INITIATE_DOWNLOAD
:
738 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoidx
, tvb
, offset
+1, 2, ENC_LITTLE_ENDIAN
);
739 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdosub
, tvb
, offset
+3, 1, ENC_LITTLE_ENDIAN
);
741 case SDO_SCS_INITIATE_UPLOAD
:
742 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoscsiu
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
743 ecat_coe_sdoscs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoscs
);
744 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsiu_sizeind
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
745 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsiu_expedited
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
746 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsiu_size0
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
747 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsiu_size1
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
748 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsiu_complete
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
750 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoidx
, tvb
, offset
+1, 2, ENC_LITTLE_ENDIAN
);
751 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdosub
, tvb
, offset
+3, 1, ENC_LITTLE_ENDIAN
);
752 if ( sdo
.anSdoHeaderUnion
.Ius
.SizeInd
&& !sdo
.anSdoHeaderUnion
.Ius
.Expedited
)
754 len
= coe_length
- ETHERCAT_COE_HEADER_LEN
- ETHERCAT_SDO_HEADER_LEN
;
755 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdolength
, tvb
, offset
+4, 4, ENC_LITTLE_ENDIAN
);
756 offset
+=ETHERCAT_SDO_HEADER_LEN
;
758 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoldata
, tvb
, offset
, len
, ENC_NA
);
760 else if ( sdo
.anSdoHeaderUnion
.Ius
.SizeInd
&& sdo
.anSdoHeaderUnion
.Ius
.Expedited
&& sdo
.anSdoHeaderUnion
.Ius
.Size
== 3 )
761 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata1
, tvb
, offset
+4, 1, ENC_LITTLE_ENDIAN
);
762 else if ( sdo
.anSdoHeaderUnion
.Ius
.SizeInd
&& sdo
.anSdoHeaderUnion
.Ius
.Expedited
&& sdo
.anSdoHeaderUnion
.Ius
.Size
== 2 )
763 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata2
, tvb
, offset
+4, 2, ENC_LITTLE_ENDIAN
);
765 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdodata
, tvb
, offset
+4, 4, ENC_LITTLE_ENDIAN
);
767 case SDO_SCS_DOWNLOAD_SEGMENT
:
768 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoscsds
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
769 ecat_coe_sdoscs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoscs
);
770 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsds_toggle
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
772 case SDO_SCS_UPLOAD_SEGMENT
:
773 anItem
= proto_tree_add_item(ecat_sdo_tree
, hf_ecat_mailbox_coe_sdoscsus
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
774 ecat_coe_sdoscs_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_coe_sdoscs
);
775 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsus_lastseg
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
776 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsus_bytes
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
777 proto_tree_add_item(ecat_coe_sdoscs_tree
, hf_ecat_mailbox_coe_sdoscsus_toggle
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
780 if ( coe_length
-offset
> 0 )
782 anItem
= proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoldata
, tvb
, offset
, coe_length
-offset
, ENC_NA
);
783 proto_item_append_text(anItem
, "(len = %d)", coe_length
-offset
);
791 case ETHERCAT_COE_TYPE_SDOINFO
:
793 ETHERCAT_SDO_INFO_HEADER info
;
795 if( coe_length
< ETHERCAT_COE_HEADER_LEN
+ ETHERCAT_SDO_INFO_LISTREQ_LEN
)
797 col_append_str(pinfo
->cinfo
, COL_INFO
, "Sdo Info - invalid length");
801 init_sdo_info_header(&info
, tvb
, offset
);
803 CANopenSdoInfoFormatter(&info
, szText
, nMax
);
804 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
808 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoopcode
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
809 offset
++; /*Reserved*/
811 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfofrag
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
814 switch ( info
.anSdoControlUnion
.v
.OpCode
)
816 case ECAT_COE_INFO_OPCODE_LIST_Q
:
818 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfolisttype
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
821 case ECAT_COE_INFO_OPCODE_LIST_S
:
823 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfolisttype
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
826 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfolist
, tvb
, offset
, coe_length
-offset
, ENC_NA
);
829 case ECAT_COE_INFO_OPCODE_OBJ_Q
:
830 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoindex
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
832 case ECAT_COE_INFO_OPCODE_OBJ_S
:
834 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoindex
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
837 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfodatatype
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
840 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfomaxsub
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
841 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoobjcode
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
843 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoname
, tvb
, offset
, coe_length
-offset
, ENC_ASCII
|ENC_NA
);
846 case ECAT_COE_INFO_OPCODE_ENTRY_Q
:
848 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoindex
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
851 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfosubindex
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
852 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfovalueinfo
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
855 case ECAT_COE_INFO_OPCODE_ENTRY_S
:
859 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoindex
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
862 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfosubindex
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
863 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfovalueinfo
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
865 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfodatatype
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
868 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfobitlen
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
871 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoobjaccess
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
874 if ( (info
.anSdoInfoUnion
.Entry
.ValueInfo
& 0x08) != 0 )
876 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfounittype
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
879 if ( (info
.anSdoInfoUnion
.Entry
.ValueInfo
& 0x10) != 0 )
881 objlen
= BIT2BYTE(info
.anSdoInfoUnion
.Entry
.Res
.BitLen
);
882 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfodefaultvalue
, tvb
, offset
, objlen
, ENC_NA
);
885 if ( (info
.anSdoInfoUnion
.Entry
.ValueInfo
& 0x20) != 0 )
887 objlen
= BIT2BYTE(info
.anSdoInfoUnion
.Entry
.Res
.BitLen
);
888 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfominvalue
, tvb
, offset
, objlen
, ENC_NA
);
891 if ( (info
.anSdoInfoUnion
.Entry
.ValueInfo
& 0x40) != 0 )
893 objlen
= BIT2BYTE(info
.anSdoInfoUnion
.Entry
.Res
.BitLen
);
894 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfomaxvalue
, tvb
, offset
, objlen
, ENC_NA
);
897 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoname
, tvb
, offset
, coe_length
-offset
, ENC_ASCII
|ENC_NA
);
900 case ECAT_COE_INFO_OPCODE_ERROR_S
:
902 proto_tree_add_item(ecat_coe_tree
, hf_ecat_mailbox_coe_sdoinfoerrorcode
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
913 col_append_str(pinfo
->cinfo
, COL_INFO
, "- invalid length");
917 static void dissect_ecat_soe(tvbuff_t
*tvb
, gint offset
, packet_info
*pinfo
, proto_tree
*tree
)
919 proto_tree
*ecat_soeflag_tree
, *ecat_soe_tree
;
921 proto_item
*anItem
= NULL
,*aparent
= NULL
;
923 int nMax
= sizeof(szText
)-1;
925 guint soe_length
= tvb_reported_length(tvb
)-offset
;
929 anItem
= proto_tree_add_item(tree
, hf_ecat_mailbox_soe
, tvb
, offset
, soe_length
, ENC_NA
);
931 aparent
= proto_item_get_parent(anItem
);
932 proto_item_append_text(aparent
,":SoE ");
935 if( soe_length
>= ETHERCAT_SOE_HEADER_LEN
)
937 SoeFormatter(tvb
, offset
, szText
, nMax
, soe_length
);
938 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
942 ETHERCAT_SOE_HEADER soe
;
943 init_soe_header(&soe
, tvb
, offset
);
945 proto_item_append_text(aparent
, "%s", szText
);
946 proto_item_set_text(anItem
, "%s", szText
);
948 ecat_soe_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_soe
);
949 anItem
= proto_tree_add_item(ecat_soe_tree
, hf_ecat_mailbox_soe_header
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
951 ecat_soeflag_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_soeflag
);
952 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_opcode
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
953 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_incomplete
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
954 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_error
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
955 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_driveno
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
956 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_datastate
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
957 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_name
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
958 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_attribute
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
959 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_unit
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
960 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_min
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
961 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_max
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
962 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_value
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
963 proto_tree_add_item(ecat_soeflag_tree
, hf_ecat_mailbox_soe_header_reserved
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
966 if ( !soe
.anSoeHeaderControlUnion
.v
.Error
)
968 if ( !soe
.anSoeHeaderControlUnion
.v
.InComplete
)
970 switch (soe
.anSoeHeaderControlUnion
.v
.OpCode
)
972 case ECAT_SOE_OPCODE_RRQ
:
973 case ECAT_SOE_OPCODE_WRS
:
974 proto_tree_add_item(ecat_soe_tree
, hf_ecat_mailbox_soe_idn
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
976 case ECAT_SOE_OPCODE_RRS
:
977 case ECAT_SOE_OPCODE_WRQ
:
978 case ECAT_SOE_OPCODE_NFC
:
979 proto_tree_add_item(ecat_soe_tree
, hf_ecat_mailbox_soe_idn
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
981 proto_tree_add_item(tree
, hf_ecat_mailbox_soe_data
, tvb
, offset
, soe_length
-offset
, ENC_NA
);
987 proto_tree_add_item(ecat_soe_tree
, hf_ecat_mailbox_soe_frag
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
990 proto_tree_add_item(tree
, hf_ecat_mailbox_soe_data
, tvb
, offset
, soe_length
-offset
, ENC_NA
);
995 proto_tree_add_item(ecat_soe_tree
, hf_ecat_mailbox_soe_idn
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
996 proto_tree_add_item(tree
, hf_ecat_mailbox_soe_error
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1002 col_append_str(pinfo
->cinfo
, COL_INFO
, "SoE - invalid length");
1006 static void dissect_ecat_eoe(tvbuff_t
*tvb
, gint offset
, packet_info
*pinfo
, proto_tree
*tree
)
1008 proto_tree
*ecat_eoe_tree
= 0, *ecat_fraghead_tree
, *ecat_eoe_init_tree
, *ecat_eoe_macfilter_tree
,
1009 *ecat_eoe_macfilter_filter_tree
;
1011 proto_item
*anItem
= NULL
, *aparent
= NULL
;
1013 int nMax
= sizeof(szText
)-1;
1016 guint eoe_length
= tvb_reported_length(tvb
)-offset
;
1020 anItem
= proto_tree_add_item(tree
, hf_ecat_mailbox_eoe
, tvb
, offset
, eoe_length
, ENC_NA
);
1021 proto_item_set_text(anItem
, "EoE Fragment");
1023 aparent
= proto_item_get_parent(anItem
);
1024 proto_item_append_text(aparent
,":EoE ");
1027 if( eoe_length
>= ETHERCAT_EOE_HEADER_LEN
)
1029 ETHERCAT_EOE_HEADER eoe
;
1030 init_eoe_header(&eoe
, tvb
, offset
);
1031 if ( eoe
.anEoeHeaderInfoUnion
.v
.Type
== EOE_TYPE_FRAME_FRAG
)
1032 g_snprintf ( szText
, nMax
, "EoE-Frag %d", eoe
.anEoeHeaderDataUnion
.v
.Fragment
);
1034 g_snprintf ( szText
, nMax
, "EoE");
1035 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
1037 { /* Do the following even 'if (tree == NULL)' since a call_dissector() is done */
1038 ecat_eoe_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_eoe
);
1040 anItem
= proto_tree_add_item(ecat_eoe_tree
, hf_ecat_mailbox_eoe_fraghead
, tvb
, offset
, 4, ENC_NA
);
1041 proto_item_set_text(anItem
, "Header");
1042 ecat_fraghead_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_fraghead
);
1044 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_type
, tvb
, offset
, 4, eoe
.anEoeHeaderInfoUnion
.v
.Type
);
1045 EoETypeFormatter(&eoe
, szText
, nMax
);
1046 proto_item_set_text(anItem
, "%s", szText
);
1048 switch ( eoe
.anEoeHeaderInfoUnion
.v
.Type
)
1050 case EOE_TYPE_FRAME_FRAG
:
1051 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_fragno
, tvb
, offset
, 4, eoe
.anEoeHeaderDataUnion
.v
.Fragment
);
1052 EoEFragNoFormatter(&eoe
, szText
, nMax
);
1053 proto_item_set_text(anItem
, "%s", szText
);
1055 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_offset
, tvb
, offset
, 4, 32*eoe
.anEoeHeaderDataUnion
.v
.OffsetBuffer
);
1056 EoEOffsetFormatter(&eoe
, szText
, nMax
);
1057 proto_item_set_text(anItem
, "%s", szText
);
1059 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_frame
, tvb
, offset
, 4, eoe
.anEoeHeaderDataUnion
.v
.FrameNo
);
1060 EoEFrameFormatter(&eoe
, szText
, nMax
);
1061 proto_item_set_text(anItem
, "%s", szText
);
1063 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_last
, tvb
, offset
, 4, eoe
.anEoeHeaderInfoUnion
.v
.LastFragment
);
1064 EoELastFormatter(&eoe
, szText
, nMax
);
1065 proto_item_set_text(anItem
, "%s", szText
);
1067 if ( eoe
.anEoeHeaderInfoUnion
.v
.TimeStampRequested
)
1069 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_timestampreq
, tvb
, offset
, 4, eoe
.anEoeHeaderInfoUnion
.v
.TimeStampRequested
);
1070 proto_item_set_text(anItem
, "Time Stamp Requested");
1073 if ( eoe
.anEoeHeaderInfoUnion
.v
.TimeStampAppended
)
1075 anItem
= proto_tree_add_uint(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_timestampapp
, tvb
, offset
, 4, eoe
.anEoeHeaderInfoUnion
.v
.TimeStampAppended
);
1076 proto_item_set_text(anItem
, "Time Stamp Appended");
1079 offset
+=ETHERCAT_EOE_HEADER_LEN
;
1080 proto_tree_add_item(ecat_eoe_tree
, hf_ecat_mailbox_eoe_fragment
, tvb
, offset
, eoe_length
-offset
, ENC_NA
);
1082 if ( eoe
.anEoeHeaderDataUnion
.v
.Fragment
== 0 )
1084 next_tvb
= tvb_new_subset(tvb
, offset
, eoe_length
-offset
, eoe_length
-offset
);
1085 call_dissector( eth_handle
, next_tvb
, pinfo
, ecat_eoe_tree
);
1088 if ( eoe
.anEoeHeaderInfoUnion
.v
.TimeStampAppended
)
1090 proto_tree_add_item(ecat_eoe_tree
, hf_ecat_mailbox_eoe_timestamp
, tvb
, eoe_length
-ETHERCAT_EOE_TIMESTAMP_LEN
, ETHERCAT_EOE_TIMESTAMP_LEN
, ENC_LITTLE_ENDIAN
);
1094 case EOE_TYPE_TIMESTAMP_RES
:
1095 proto_tree_add_item(ecat_eoe_tree
, hf_ecat_mailbox_eoe_timestamp
, tvb
, offset
+ETHERCAT_EOE_HEADER_LEN
, ETHERCAT_EOE_TIMESTAMP_LEN
, ENC_LITTLE_ENDIAN
);
1098 case EOE_TYPE_INIT_REQ
:
1099 offset
+=ETHERCAT_EOE_HEADER_LEN
;
1100 anItem
= proto_tree_add_item(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_init
, tvb
, offset
, MIN(eoe_length
-offset
,ETHERCAT_EOE_INIT_LEN
), ENC_NA
);
1101 if( eoe_length
-offset
>= ETHERCAT_EOE_INIT_LEN
)
1103 ecat_eoe_init_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_eoe_init
);
1105 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_macaddr
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1106 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_ipaddr
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1107 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_subnetmask
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1108 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_defaultgateway
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1109 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_dnsserver
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1110 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_contains_dnsname
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1111 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_append_timestamp
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1114 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_macaddr
, tvb
, offset
, ETHERNET_ADDRESS_LEN
, ENC_NA
);
1115 offset
+=ETHERNET_ADDRESS_LEN
;
1117 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_ipaddr
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1120 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_subnetmask
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1123 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_defaultgateway
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1126 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_dnsserver
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1129 proto_tree_add_item(ecat_eoe_init_tree
, hf_ecat_mailbox_eoe_init_dnsname
, tvb
, offset
, 32, ENC_ASCII
|ENC_NA
);
1132 proto_item_append_text(anItem
, " - Invalid length!");
1135 case EOE_TYPE_MACFILTER_REQ
:
1137 EoeMacFilterOptionsUnion options
;
1138 offset
+=ETHERCAT_EOE_HEADER_LEN
;
1139 anItem
= proto_tree_add_item(ecat_fraghead_tree
, hf_ecat_mailbox_eoe_macfilter
, tvb
, offset
, MIN(eoe_length
-offset
, ETHERCAT_EOE_MACFILTER_LEN
), ENC_NA
);
1140 if( eoe_length
-offset
>= ETHERCAT_EOE_MACFILTER_LEN
)
1142 proto_tree
*ecat_eoe_macfilter_filtermask_tree
;
1144 ecat_eoe_macfilter_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_eoe_macfilter
);
1146 /* XXX: Is the field containing EoeMacFilterOptionsUnion 4 bytes or 2 bytes ? */
1147 /* sizeof EoeMacFilterOptionsUnion = 2 bytes but the code below */
1148 /* originally used a field width of 4 bytes. */
1149 /* Given the size of the union, the code below was changed to */
1150 /* use a field width of 2 bytes. */
1151 /* The hf[] entries were also changed to match the union struct */
1152 proto_tree_add_item(ecat_eoe_macfilter_tree
, hf_ecat_mailbox_eoe_macfilter_macfiltercount
, tvb
, offset
, /*4*/ 2, ENC_LITTLE_ENDIAN
);
1153 proto_tree_add_item(ecat_eoe_macfilter_tree
, hf_ecat_mailbox_eoe_macfilter_maskcount
, tvb
, offset
, /*4*/ 2, ENC_LITTLE_ENDIAN
);
1154 proto_tree_add_item(ecat_eoe_macfilter_tree
, hf_ecat_mailbox_eoe_macfilter_nobroadcasts
, tvb
, offset
, /*4*/ 2, ENC_LITTLE_ENDIAN
);
1155 options
.Options
= tvb_get_letohs(tvb
, offset
);
1158 anItem
= proto_tree_add_item(ecat_eoe_macfilter_tree
, hf_ecat_mailbox_eoe_macfilter_filter
, tvb
, offset
, 16*ETHERNET_ADDRESS_LEN
, ENC_NA
);
1159 ecat_eoe_macfilter_filter_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_eoe_macfilter_filter
);
1160 for( nCnt
=0; nCnt
<options
.v
.MacFilterCount
; nCnt
++)
1161 proto_tree_add_item(ecat_eoe_macfilter_filter_tree
, hf_ecat_mailbox_eoe_macfilter_filters
[nCnt
], tvb
, offset
+nCnt
*ETHERNET_ADDRESS_LEN
, ETHERNET_ADDRESS_LEN
, ENC_NA
);
1162 offset
+=16*ETHERNET_ADDRESS_LEN
;
1164 anItem
= proto_tree_add_item(ecat_eoe_macfilter_tree
, hf_ecat_mailbox_eoe_macfilter_filtermask
, tvb
, offset
, 4*(int)sizeof(guint32
), ENC_NA
);
1165 ecat_eoe_macfilter_filtermask_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_eoe_macfilter_filtermask
);
1166 for( nCnt
=0; nCnt
<options
.v
.MacFilterMaskCount
; nCnt
++)
1167 proto_tree_add_item(ecat_eoe_macfilter_filtermask_tree
, hf_ecat_mailbox_eoe_macfilter_filtermasks
[nCnt
], tvb
, offset
+nCnt
*(int)sizeof(guint32
), (int)sizeof(guint32
), ENC_NA
);
1170 proto_item_append_text(anItem
, " - Invalid length!");
1174 case EOE_TYPE_INIT_RES
:
1175 case EOE_TYPE_MACFILTER_RES
:
1180 col_prepend_fstr(pinfo
->cinfo
, COL_INFO
, "EoE(");
1182 col_prepend_fstr(pinfo
->cinfo
, COL_PROTOCOL
, "EoE-");
1186 col_append_str(pinfo
->cinfo
, COL_INFO
, "EoE - invalid length!");
1190 static void dissect_ecat_foe(tvbuff_t
*tvb
, gint offset
, packet_info
*pinfo
, proto_tree
*tree
)
1192 proto_tree
*ecat_foe_tree
,*ecat_foe_efw_tree
;
1194 proto_item
*anItem
= NULL
,*aparent
= NULL
;
1196 int nMax
= sizeof(szText
)-1;
1198 guint foe_length
= tvb_reported_length(tvb
)-offset
;
1202 anItem
= proto_tree_add_item(tree
, hf_ecat_mailbox_foe
, tvb
, offset
, foe_length
, ENC_NA
);
1203 proto_item_set_text(anItem
, ":Foe");
1205 aparent
= proto_item_get_parent(anItem
);
1206 proto_item_append_text(aparent
,"FoE ");
1209 if( foe_length
>= ETHERCAT_FOE_HEADER_LEN
)
1211 FoeFormatter(tvb
, offset
, szText
, nMax
, foe_length
);
1212 col_append_str(pinfo
->cinfo
, COL_INFO
, szText
);
1216 ETHERCAT_FOE_HEADER foe
;
1217 init_foe_header(&foe
, tvb
, offset
);
1219 ecat_foe_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_foe
);
1220 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_opmode
, tvb
, offset
++, 1, ENC_LITTLE_ENDIAN
);
1221 offset
++; /*Reserved1;*/
1225 case ECAT_FOE_OPMODE_RRQ
:
1226 case ECAT_FOE_OPMODE_WRQ
:
1227 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_filelength
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1230 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_filename
, tvb
, offset
, foe_length
-offset
, ENC_ASCII
|ENC_NA
);
1233 case ECAT_FOE_OPMODE_DATA
:
1235 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_packetno
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1236 offset
+=4; /*+2 for Reserved2*/
1238 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_data
, tvb
, offset
, foe_length
-offset
, ENC_NA
);
1240 if( foe_length
-offset
>= sizeof(TEFWUPDATE_HEADER
) )
1242 anItem
= proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_efw
, tvb
, offset
, foe_length
-offset
, ENC_NA
);
1243 ecat_foe_efw_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_foe_efw
);
1244 proto_tree_add_item(ecat_foe_efw_tree
, hf_ecat_mailbox_foe_efw_cmd
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1247 proto_tree_add_item(ecat_foe_efw_tree
, hf_ecat_mailbox_foe_efw_size
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1250 proto_tree_add_item(ecat_foe_efw_tree
, hf_ecat_mailbox_foe_efw_addresslw
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1253 proto_tree_add_item(ecat_foe_efw_tree
, hf_ecat_mailbox_foe_efw_addresshw
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1256 proto_tree_add_item(ecat_foe_efw_tree
, hf_ecat_mailbox_foe_efw_data
, tvb
, offset
, foe_length
-offset
, ENC_NA
);
1261 case ECAT_FOE_OPMODE_ACK
:
1262 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_packetno
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1265 case ECAT_FOE_OPMODE_ERR
:
1266 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_errcode
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
1269 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_errtext
, tvb
, offset
, foe_length
-offset
, ENC_ASCII
|ENC_NA
);
1272 case ECAT_FOE_OPMODE_BUSY
:
1273 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_busydone
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1276 proto_tree_add_item(ecat_foe_tree
, hf_ecat_mailbox_foe_busyentire
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
1283 col_append_str(pinfo
->cinfo
, COL_INFO
, "FoE - invalid length");
1287 static void dissect_ecat_mailbox(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
1289 proto_tree
*ecat_mailbox_tree
= NULL
;
1290 proto_tree
*ecat_mailbox_header_tree
= NULL
;
1295 int nMax
= sizeof(szText
)-1;
1297 gint mailbox_length
= tvb_reported_length(tvb
);
1299 if( mailbox_length
>= ETHERCAT_MBOX_HEADER_LEN
)
1301 ETHERCAT_MBOX_HEADER hdr
;
1303 init_mbx_header(&hdr
, tvb
, offset
);
1305 if( mailbox_length
>= ETHERCAT_MBOX_HEADER_LEN
+ hdr
.Length
)
1307 col_append_str(pinfo
->cinfo
, COL_INFO
, " Mbx(");
1311 /* Create the mailbox sub tree */
1312 anItem
= proto_tree_add_item(tree
, proto_ecat_mailbox
, tvb
, 0, ETHERCAT_MBOX_HEADER_LEN
+hdr
.Length
, ENC_NA
);
1313 ecat_mailbox_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox
);
1315 /* Create a mailbox header subtree */
1316 anItem
= proto_tree_add_text(ecat_mailbox_tree
, tvb
, offset
, ETHERCAT_MBOX_HEADER_LEN
, "Header");
1317 ecat_mailbox_header_tree
= proto_item_add_subtree(anItem
, ett_ecat_mailbox_header
);
1319 /* Add length information to the mailbox header */
1320 proto_tree_add_item(ecat_mailbox_header_tree
, hf_ecat_mailboxlength
, tvb
, offset
, sizeof(hdr
.Length
), ENC_LITTLE_ENDIAN
);
1321 offset
+=(int)sizeof(hdr
.Length
);
1323 /* Add address information to the mailbox header */
1324 proto_tree_add_item(ecat_mailbox_header_tree
, hf_ecat_mailboxaddress
, tvb
, offset
, sizeof(hdr
.Address
), ENC_LITTLE_ENDIAN
);
1325 offset
+=(int)sizeof(hdr
.Address
);
1327 /* Add priority information to the mailbox header */
1328 proto_tree_add_text(ecat_mailbox_header_tree
, tvb
, offset
, 1, "Priority: %d", tvb_get_guint8(tvb
, offset
) & 0x3);
1329 offset
+=(int)sizeof(guint8
);
1331 /* Add type information to the mailbox header */
1332 MailboxTypeFormatter(&hdr
, szText
, nMax
);
1333 proto_tree_add_text(ecat_mailbox_header_tree
, tvb
, offset
, 1, "%s", szText
);
1335 /* Add counter information to the mailbox header */
1336 proto_tree_add_text(ecat_mailbox_header_tree
, tvb
, offset
, 1, "Counter : %d",hdr
.aControlUnion
.v
.Counter
);
1340 offset
+=ETHERCAT_MBOX_HEADER_LEN
;
1342 next_tvb
= tvb_new_subset (tvb
, offset
, hdr
.Length
, hdr
.Length
);
1343 switch ( hdr
.aControlUnion
.v
.Type
)
1345 case ETHERCAT_MBOX_TYPE_ADS
:
1346 call_dissector(ams_handle
, next_tvb
, pinfo
, ecat_mailbox_tree
);
1349 case ETHERCAT_MBOX_TYPE_EOE
:
1350 dissect_ecat_eoe(next_tvb
, 0, pinfo
, ecat_mailbox_tree
);
1353 case ETHERCAT_MBOX_TYPE_COE
:
1354 dissect_ecat_coe(next_tvb
, 0, pinfo
, ecat_mailbox_tree
);
1357 case ETHERCAT_MBOX_TYPE_FOE
:
1358 dissect_ecat_foe(next_tvb
, 0, pinfo
, ecat_mailbox_tree
);
1361 case ETHERCAT_MBOX_TYPE_SOE
:
1362 dissect_ecat_soe(next_tvb
, 0, pinfo
, ecat_mailbox_tree
);
1366 proto_tree_add_item(ecat_mailbox_tree
, hf_ecat_mailboxdata
, tvb
, offset
, hdr
.Length
, ENC_NA
);
1369 col_append_str(pinfo
->cinfo
, COL_INFO
, ")");
1374 void proto_register_ecat_mailbox(void)
1376 static const true_false_string flags_set_truth
=
1382 static hf_register_info hf
[] =
1384 { &hf_ecat_mailboxlength
,
1385 { "Length", "ecat_mailbox.length",
1386 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1389 { &hf_ecat_mailboxaddress
,
1390 { "Address", "ecat_mailbox.address",
1391 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1394 { &hf_ecat_mailbox_eoe
,
1395 { "EoE Fragment", "ecat_mailbox.eoe",
1396 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1399 { &hf_ecat_mailbox_eoe_fraghead
,
1400 { "Eoe Frag Header", "ecat_mailbox.eoe.fraghead",
1401 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1404 { &hf_ecat_mailbox_eoe_type
,
1405 { "EoE"/*"Type*/, "ecat_mailbox.eoe.type",
1406 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1408 { &hf_ecat_mailbox_eoe_fragno
,
1409 { "EoE"/*"FragNo*/, "ecat_mailbox.eoe.fragno",
1410 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1412 { &hf_ecat_mailbox_eoe_offset
,
1413 { "EoE"/*"Offset"*/, "ecat_mailbox.eoe.offset",
1414 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1416 { &hf_ecat_mailbox_eoe_frame
,
1417 { "EoE"/*"FrameNo"*/, "ecat_mailbox.eoe.frame",
1418 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1420 { &hf_ecat_mailbox_eoe_last
,
1421 { "Last Fragment"/*"Last Fragment"*/, "ecat_mailbox.eoe.last",
1422 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1424 { &hf_ecat_mailbox_eoe_timestampapp
,
1425 { "Last Fragment"/*"Last Fragment"*/, "ecat_mailbox.eoe.timestampapp",
1426 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1428 { &hf_ecat_mailbox_eoe_timestampreq
,
1429 { "Last Fragment"/*"Last Fragment"*/, "ecat_mailbox.eoe.timestampreq",
1430 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1432 { &hf_ecat_mailbox_eoe_fragment
,
1433 { "EoE Frag Data", "ecat_mailbox.eoe.fragment",
1434 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1436 { &hf_ecat_mailbox_eoe_init
,
1437 { "Init", "ecat_mailbox.eoe.init",
1438 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1440 { &hf_ecat_mailbox_eoe_init_contains_macaddr
,
1441 { "MacAddr", "ecat_mailbox.eoe.init.contains_macaddr",
1442 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000001, NULL
, HFILL
}
1444 { &hf_ecat_mailbox_eoe_init_contains_ipaddr
,
1445 { "IpAddr", "ecat_mailbox.eoe.init.contains_ipaddr",
1446 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000002, NULL
, HFILL
}
1448 { &hf_ecat_mailbox_eoe_init_contains_subnetmask
,
1449 { "SubnetMask", "ecat_mailbox.eoe.init.contains_subnetmask",
1450 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000004, NULL
, HFILL
}
1452 { &hf_ecat_mailbox_eoe_init_contains_defaultgateway
,
1453 { "DefaultGateway", "ecat_mailbox.eoe.init.contains_defaultgateway",
1454 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000008, NULL
, HFILL
}
1456 { &hf_ecat_mailbox_eoe_init_contains_dnsserver
,
1457 { "DnsServer", "ecat_mailbox.eoe.init.contains_dnsserver",
1458 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000010, NULL
, HFILL
}
1460 { &hf_ecat_mailbox_eoe_init_contains_dnsname
,
1461 { "DnsName", "ecat_mailbox.eoe.init.contains_dnsname",
1462 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00000020, NULL
, HFILL
}
1464 { &hf_ecat_mailbox_eoe_init_append_timestamp
,
1465 { "AppendTimeStamp", "ecat_mailbox.eoe.init.append_timestamp",
1466 FT_BOOLEAN
, 32, TFS(&flags_set_truth
), 0x00010000, NULL
, HFILL
}
1468 { &hf_ecat_mailbox_eoe_init_macaddr
,
1469 { "Mac Addr", "ecat_mailbox.eoe.init.macaddr",
1470 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1472 { &hf_ecat_mailbox_eoe_init_ipaddr
,
1473 { "Ip Addr", "ecat_mailbox.eoe.init.ipaddr",
1474 FT_IPv4
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1476 { &hf_ecat_mailbox_eoe_init_subnetmask
,
1477 { "Subnet Mask", "ecat_mailbox.eoe.init.subnetmask",
1478 FT_IPv4
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1480 { &hf_ecat_mailbox_eoe_init_defaultgateway
,
1481 { "Default Gateway", "ecat_mailbox.eoe.init.defaultgateway",
1482 FT_IPv4
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1484 { &hf_ecat_mailbox_eoe_init_dnsserver
,
1485 { "Dns Server", "ecat_mailbox.eoe.init.dnsserver",
1486 FT_IPv4
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1488 { &hf_ecat_mailbox_eoe_init_dnsname
,
1489 { "Dns Name", "ecat_mailbox.eoe.init.dnsname",
1490 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1492 { &hf_ecat_mailbox_eoe_macfilter
,
1493 { "Mac Filter", "ecat_mailbox.eoe.macfilter",
1494 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1497 /* XXX: The following 3 fields may not be specified correctly */
1498 /* See related comment above */
1499 { &hf_ecat_mailbox_eoe_macfilter_macfiltercount
,
1500 { "Mac Filter Count", "ecat_mailbox.eoe.macfilter.macfiltercount",
1501 FT_UINT16
, BASE_DEC
, NULL
, 0xF000, NULL
, HFILL
}
1503 { &hf_ecat_mailbox_eoe_macfilter_maskcount
,
1504 { "Mac Filter Mask Count", "ecat_mailbox.eoe.macfilter.maskcount",
1505 FT_UINT16
, BASE_DEC
, NULL
, 0x0C00, NULL
, HFILL
}
1507 { &hf_ecat_mailbox_eoe_macfilter_nobroadcasts
,
1508 { "No Broadcasts", "ecat_mailbox.eoe.macfilter.nobroadcasts",
1509 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x0100, NULL
, HFILL
}
1513 { &hf_ecat_mailbox_eoe_macfilter_filter
,
1514 { "Filter", "ecat_mailbox.eoe.macfilter.filter",
1515 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1517 { &hf_ecat_mailbox_eoe_macfilter_filters
[0],
1518 { "Filter 0", "ecat_mailbox.eoe.macfilter.filter0",
1519 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1521 { &hf_ecat_mailbox_eoe_macfilter_filters
[1],
1522 { "Filter 1", "ecat_mailbox.eoe.macfilter.filter1",
1523 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1525 { &hf_ecat_mailbox_eoe_macfilter_filters
[2],
1526 { "Filter 2", "ecat_mailbox.eoe.macfilter.filter2",
1527 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1529 { &hf_ecat_mailbox_eoe_macfilter_filters
[3],
1530 { "Filter 3", "ecat_mailbox.eoe.macfilter.filter3",
1531 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1533 { &hf_ecat_mailbox_eoe_macfilter_filters
[4],
1534 { "Filter 4", "ecat_mailbox.eoe.macfilter.filter4",
1535 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1537 { &hf_ecat_mailbox_eoe_macfilter_filters
[5],
1538 { "Filter 5", "ecat_mailbox.eoe.macfilter.filter5",
1539 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1541 { &hf_ecat_mailbox_eoe_macfilter_filters
[6],
1542 { "Filter 6", "ecat_mailbox.eoe.macfilter.filter6",
1543 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1545 { &hf_ecat_mailbox_eoe_macfilter_filters
[7],
1546 { "Filter 7", "ecat_mailbox.eoe.macfilter.filter7",
1547 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1549 { &hf_ecat_mailbox_eoe_macfilter_filters
[8],
1550 { "Filter 8", "ecat_mailbox.eoe.macfilter.filter8",
1551 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1553 { &hf_ecat_mailbox_eoe_macfilter_filters
[9],
1554 { "Filter 9", "ecat_mailbox.eoe.macfilter.filter9",
1555 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1557 { &hf_ecat_mailbox_eoe_macfilter_filters
[10],
1558 { "Filter 10", "ecat_mailbox.eoe.macfilter.filter10",
1559 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1561 { &hf_ecat_mailbox_eoe_macfilter_filters
[11],
1562 { "Filter 11", "ecat_mailbox.eoe.macfilter.filter11",
1563 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1565 { &hf_ecat_mailbox_eoe_macfilter_filters
[12],
1566 { "Filter 12", "ecat_mailbox.eoe.macfilter.filter12",
1567 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1569 { &hf_ecat_mailbox_eoe_macfilter_filters
[13],
1570 { "Filter 13", "ecat_mailbox.eoe.macfilter.filter13",
1571 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1573 { &hf_ecat_mailbox_eoe_macfilter_filters
[14],
1574 { "Filter 14", "ecat_mailbox.eoe.macfilter.filter14",
1575 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1577 { &hf_ecat_mailbox_eoe_macfilter_filters
[15],
1578 { "Filter 15", "ecat_mailbox.eoe.macfilter.filter15",
1579 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1581 { &hf_ecat_mailbox_eoe_macfilter_filtermask
,
1582 { "Filter Mask", "ecat_mailbox.eoe.macfilter.filtermask",
1583 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1585 { &hf_ecat_mailbox_eoe_macfilter_filtermasks
[0],
1586 { "Mask 0", "ecat_mailbox.eoe.macfilter.filtermask0",
1587 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1589 { &hf_ecat_mailbox_eoe_macfilter_filtermasks
[1],
1590 { "Mask 1", "ecat_mailbox.eoe.macfilter.filtermask1",
1591 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1593 { &hf_ecat_mailbox_eoe_macfilter_filtermasks
[2],
1594 { "Mask 2", "ecat_mailbox.eoe.macfilter.filtermask2",
1595 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1597 { &hf_ecat_mailbox_eoe_macfilter_filtermasks
[3],
1598 { "Mask 3", "ecat_mailbox.eoe.macfilter.filtermask3",
1599 FT_ETHER
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1601 { &hf_ecat_mailbox_eoe_timestamp
,
1602 { "Time Stamp", "ecat_mailbox.eoe.timestamp",
1603 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1605 { &hf_ecat_mailbox_coe
,
1606 { "CoE", "ecat_mailbox.coe",
1607 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1609 { &hf_ecat_mailbox_coe_number
,
1610 { "Number", "ecat_mailbox.coe.number",
1611 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1613 { &hf_ecat_mailbox_coe_type
,
1614 { "Type", "ecat_mailbox.coe.type",
1615 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1617 { &hf_ecat_mailbox_coe_sdoreq
,
1618 { "SDO Req", "ecat_mailbox.coe.sdoreq",
1619 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1621 { &hf_ecat_mailbox_coe_sdoccsid
,
1622 { "Initiate Download", "ecat_mailbox.coe.sdoccsid",
1623 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1625 { &hf_ecat_mailbox_coe_sdoccsid_sizeind
,
1626 { "Size Ind.", "ecat_mailbox.coe.sdoccsid.sizeind",
1627 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000001,
1630 { &hf_ecat_mailbox_coe_sdoccsid_expedited
,
1631 { "Expedited", "ecat_mailbox.coe.sdoccsid.expedited",
1632 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000002,
1635 { &hf_ecat_mailbox_coe_sdoccsid_size0
,
1636 { "Bytes", "ecat_mailbox.coe.sdoccsid.size0",
1637 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000004,
1640 { &hf_ecat_mailbox_coe_sdoccsid_size1
,
1641 { "Bytes", "ecat_mailbox.coe.sdoccsid.size1",
1642 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000008,
1645 { &hf_ecat_mailbox_coe_sdoccsid_complete
,
1646 { "Access", "ecat_mailbox.coe.sdoccsid.complete",
1647 FT_BOOLEAN
, 8, TFS(&tfs_complete
), 0x00000010,
1650 { &hf_ecat_mailbox_coe_sdoccsds
,
1651 { "Download Segment", "ecat_mailbox.coe.sdoccsds",
1652 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1655 { &hf_ecat_mailbox_coe_sdoccsds_lastseg
,
1656 { "Last Segment", "ecat_mailbox.coe.sdoccsds.lastseg",
1657 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000001,
1660 { &hf_ecat_mailbox_coe_sdoccsds_size
,
1661 { "Size", "ecat_mailbox.coe.sdoccsds.size",
1662 FT_UINT8
, BASE_DEC
, NULL
, 0x0000000E,
1665 { &hf_ecat_mailbox_coe_sdoccsds_toggle
,
1666 { "Toggle Bit", "ecat_mailbox.coe.sdoccsds.toggle",
1667 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000010,
1670 { &hf_ecat_mailbox_coe_sdoccsiu
,
1671 { "Init Upload", "ecat_mailbox.coe.sdoccsiu",
1672 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1676 { &hf_ecat_mailbox_coe_sdoccsiu_complete
,
1677 { "Toggle Bit", "ecat_mailbox.coe.sdoccsiu_complete",
1678 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000010,
1682 { &hf_ecat_mailbox_coe_sdoccsus
,
1683 { "Upload Segment", "ecat_mailbox.coe.sdoccsus",
1684 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1687 { &hf_ecat_mailbox_coe_sdoccsus_toggle
,
1688 { "Toggle Bit", "ecat_mailbox.coe.sdoccsus_toggle",
1689 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000010,
1693 { &hf_ecat_mailbox_coe_sdoidx
,
1694 { "Index", "ecat_mailbox.coe.sdoidx",
1695 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1698 { &hf_ecat_mailbox_coe_sdosub
,
1699 { "SubIndex", "ecat_mailbox.coe.sdosub",
1700 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1703 { &hf_ecat_mailbox_coe_sdodata
,
1704 { "Data", "ecat_mailbox.coe.sdodata",
1705 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1708 { &hf_ecat_mailbox_coe_sdodata1
,
1709 { "Data", "ecat_mailbox.coe.sdodata",
1710 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1713 { &hf_ecat_mailbox_coe_sdodata2
,
1714 { "Data", "ecat_mailbox.coe.sdodata",
1715 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1718 { &hf_ecat_mailbox_coe_sdoldata
,
1719 { "Data", "ecat_mailbox.coe.dsoldata",
1720 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1723 { &hf_ecat_mailbox_coe_sdolength
,
1724 { "Length", "ecat_mailbox.coe.sdolength",
1725 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1729 { &hf_ecat_mailbox_coe_sdoerror
,
1730 { "SDO Error", "ecat_mailbox.coe.sdoerror",
1731 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1735 { &hf_ecat_mailbox_coe_sdores
,
1736 { "SDO Res", "ecat_mailbox.coe.sdores",
1737 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1740 { &hf_ecat_mailbox_coe_sdoscsiu
,
1741 { "Initiate Upload Response", "ecat_mailbox.coe.sdoscsiu",
1742 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1745 { &hf_ecat_mailbox_coe_sdoscsiu_sizeind
,
1746 { "Size Ind.", "ecat_mailbox.coe.sdoscsiu_sizeind",
1747 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000001,
1750 { &hf_ecat_mailbox_coe_sdoscsiu_expedited
,
1751 { "Expedited", "ecat_mailbox.coe.sdoscsiu_expedited",
1752 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000002,
1755 { &hf_ecat_mailbox_coe_sdoscsiu_size0
,
1756 { "Bytes", "ecat_mailbox.coe.sdoscsiu_size0",
1757 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000004,
1760 { &hf_ecat_mailbox_coe_sdoscsiu_size1
,
1761 { "Bytes", "ecat_mailbox.coe.sdoscsiu_size1",
1762 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000008,
1765 { &hf_ecat_mailbox_coe_sdoscsiu_complete
,
1766 { "Access", "ecat_mailbox.coe.sdoscsiu_complete",
1767 FT_BOOLEAN
, 8, TFS(&tfs_complete
), 0x00000010,
1770 { &hf_ecat_mailbox_coe_sdoscsds
,
1771 { "Download Segment Response", "ecat_mailbox.coe.sdoscsds",
1772 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1775 { &hf_ecat_mailbox_coe_sdoscsds_toggle
,
1776 { "Toggle Bit", "ecat_mailbox.coe.sdoscsds_toggle",
1777 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000010,
1780 { &hf_ecat_mailbox_coe_sdoscsus
,
1781 { "Upload Segment", "ecat_mailbox.coe.sdoscsus",
1782 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1785 { &hf_ecat_mailbox_coe_sdoscsus_lastseg
,
1786 { "Last Segment", "ecat_mailbox.coe.sdoscsus_lastseg",
1787 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000001,
1790 { &hf_ecat_mailbox_coe_sdoscsus_bytes
,
1791 { "Bytes", "ecat_mailbox.coe.sdoscsus_bytes",
1792 FT_UINT8
, BASE_DEC
, NULL
, 0x0000000E,
1795 { &hf_ecat_mailbox_coe_sdoscsus_toggle
,
1796 { "Toggle Bit", "ecat_mailbox.coe.sdoscsus_toggle",
1797 FT_BOOLEAN
, 8, TFS(&flags_set_truth
), 0x00000010,
1800 { &hf_ecat_mailbox_coe_sdoinfoopcode
,
1801 { "Info OpCode", "ecat_mailbox.coe.sdoinfoopcode",
1802 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
1805 { &hf_ecat_mailbox_coe_sdoinfofrag
,
1806 { "Info Frag Left", "ecat_mailbox.coe.sdoinfofrag",
1807 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1809 { &hf_ecat_mailbox_coe_sdoinfolisttype
,
1810 { "Info List Type", "ecat_mailbox.coe.sdoinfolisttype",
1811 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1813 { &hf_ecat_mailbox_coe_sdoinfolist
,
1814 { "Info List", "ecat_mailbox.coe.sdoinfolist",
1815 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
},
1817 { &hf_ecat_mailbox_coe_sdoinfoindex
,
1818 { "Info Obj Index", "ecat_mailbox.coe.sdoinfoindex",
1819 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1821 { &hf_ecat_mailbox_coe_sdoinfosubindex
,
1822 { "Info Obj SubIdx", "ecat_mailbox.coe.sdoinfosubindex",
1823 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1825 { &hf_ecat_mailbox_coe_sdoinfovalueinfo
,
1826 { "Info Obj SubIdx", "ecat_mailbox.coe.sdoinfovalueinfo",
1827 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1829 { &hf_ecat_mailbox_coe_sdoinfoerrorcode
,
1830 { "Info Error Code", "ecat_mailbox.coe.sdoinfoerrorcode",
1831 FT_UINT32
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1833 { &hf_ecat_mailbox_coe_sdoinfodatatype
,
1834 { "Info Data Type", "ecat_mailbox.coe.sdoinfodatatype",
1835 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1837 { &hf_ecat_mailbox_coe_sdoinfomaxsub
,
1838 { "Info Max SubIdx", "ecat_mailbox.coe.sdoinfomaxsub",
1839 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1841 { &hf_ecat_mailbox_coe_sdoinfoobjcode
,
1842 { "Info Obj Code", "ecat_mailbox.coe.sdoinfoobjcode",
1843 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1845 { &hf_ecat_mailbox_coe_sdoinfoname
,
1846 { "Info Name", "ecat_mailbox.coe.sdoinfoname",
1847 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
},
1849 { &hf_ecat_mailbox_coe_sdoinfobitlen
,
1850 { "Info Bit Len", "ecat_mailbox.coe.sdoinfobitlen",
1851 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1853 { &hf_ecat_mailbox_coe_sdoinfoobjaccess
,
1854 { "Info Obj Access", "ecat_mailbox.coe.sdoinfoobjaccess",
1855 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1857 { &hf_ecat_mailbox_coe_sdoinfounittype
,
1858 { "Info Data Type", "ecat_mailbox.coe.sdoinfounittype",
1859 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
},
1861 { &hf_ecat_mailbox_coe_sdoinfodefaultvalue
,
1862 { "Info Default Val", "ecat_mailbox.coe.sdoinfodefaultvalue",
1863 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
},
1865 { &hf_ecat_mailbox_coe_sdoinfominvalue
,
1866 { "Info Min Val", "ecat_mailbox.coe.sdoinfominvalue",
1867 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
},
1869 { &hf_ecat_mailbox_coe_sdoinfomaxvalue
,
1870 { "Info Max Val", "ecat_mailbox.coe.sdoinfomaxvalue",
1871 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
},
1873 { &hf_ecat_mailboxdata
,
1874 { "MB Data", "ecat_mailbox.data",
1875 FT_NONE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1877 { &hf_ecat_mailbox_foe
,
1878 { "Foe", "ecat_mailbox.foe",
1879 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1881 { &hf_ecat_mailbox_foe_opmode
,
1882 { "Foe OpMode", "ecat_mailbox.foe_opmode",
1883 FT_UINT8
, BASE_HEX
, VALS(FoEOpMode
), 0x0, "Op modes", HFILL
}
1885 { &hf_ecat_mailbox_foe_filelength
,
1886 { "Foe FileLength" , "ecat_mailbox.foe_filelength",
1887 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1889 { &hf_ecat_mailbox_foe_filename
,
1890 { "Foe FileName", "ecat_mailbox.foe_filename",
1891 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1893 { &hf_ecat_mailbox_foe_packetno
,
1894 { "Foe PacketNo", "ecat_mailbox.foe_packetno",
1895 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1897 { &hf_ecat_mailbox_foe_errcode
,
1898 { "Foe ErrorCode", "ecat_mailbox.foe_errcode",
1899 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1901 { &hf_ecat_mailbox_foe_errtext
,
1902 { "Foe ErrorString", "ecat_mailbox.foe_errtext",
1903 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1905 { &hf_ecat_mailbox_foe_busydone
,
1906 { "Foe BusyDone", "ecat_mailbox.foe_busydone",
1907 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1909 { &hf_ecat_mailbox_foe_busyentire
,
1910 { "Foe BusyEntire", "ecat_mailbox.foe_busyentire",
1911 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1913 { &hf_ecat_mailbox_foe_data
,
1914 { "Foe Data", "ecat_mailbox.foe_busydata",
1915 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1917 { &hf_ecat_mailbox_foe_efw
,
1918 { "Firmware", "ecat_mailbox.foe.efw",
1919 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1921 { &hf_ecat_mailbox_foe_efw_cmd
,
1922 { "Cmd", "ecat_mailbox.foe.efw.cmd",
1923 FT_UINT16
, BASE_HEX
, VALS(FoEEfwCmd
), 0x0, NULL
, HFILL
}
1925 { &hf_ecat_mailbox_foe_efw_size
,
1926 { "Size", "ecat_mailbox.foe.efw.size",
1927 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
1929 { &hf_ecat_mailbox_foe_efw_addresslw
,
1930 { "AddressLW", "ecat_mailbox.foe.efw.addresslw",
1931 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1933 { &hf_ecat_mailbox_foe_efw_addresshw
,
1934 { "AddressHW", "ecat_mailbox.foe.efw.addresshw",
1935 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1937 { &hf_ecat_mailbox_foe_efw_data
,
1938 { "Data", "ecat_mailbox.foe.efw.data",
1939 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1941 { &hf_ecat_mailbox_soe
,
1942 { "Soe", "ecat_mailbox.soe",
1943 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
1945 { &hf_ecat_mailbox_soe_header
,
1946 { "Soe Header", "ecat_mailbox.soe_header",
1947 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
1949 { &hf_ecat_mailbox_soe_header_opcode
,
1950 { "SoE OpCode", "ecat_mailbox.soe_opcode",
1951 FT_UINT16
, BASE_DEC
, VALS(SoeOpcode
), 0x00000007, NULL
, HFILL
}
1953 { &hf_ecat_mailbox_soe_header_incomplete
,
1954 { "More Follows...", "ecat_mailbox.soe_header_incomplete",
1955 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000008, NULL
, HFILL
}
1957 { &hf_ecat_mailbox_soe_header_error
,
1958 { "Error", "ecat_mailbox.soe_header_error",
1959 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000010,
1962 { &hf_ecat_mailbox_soe_header_driveno
,
1963 { "Drive No", "ecat_mailbox.soe_header_driveno",
1964 FT_UINT16
, BASE_DEC
, NULL
, 0x000000e0, NULL
, HFILL
}
1966 { &hf_ecat_mailbox_soe_header_datastate
,
1967 { "Datastate", "ecat_mailbox.soe_header_datastate",
1968 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000100,
1971 { &hf_ecat_mailbox_soe_header_name
,
1972 { "Name", "ecat_mailbox.soe_header_name",
1973 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000200,
1976 { &hf_ecat_mailbox_soe_header_attribute
,
1977 { "Attribute", "ecat_mailbox.soe_header_attribute",
1978 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000400,
1981 { &hf_ecat_mailbox_soe_header_unit
,
1982 { "Unit", "ecat_mailbox.soe_header_unit",
1983 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00000800,
1986 { &hf_ecat_mailbox_soe_header_min
,
1987 { "Min", "ecat_mailbox.soe_header_min",
1988 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00001000,
1991 { &hf_ecat_mailbox_soe_header_max
,
1992 { "Max", "ecat_mailbox.soe_header_max",
1993 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00002000,
1996 { &hf_ecat_mailbox_soe_header_value
,
1997 { "Value", "ecat_mailbox.soe_header_value",
1998 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00004000,
2001 { &hf_ecat_mailbox_soe_header_reserved
,
2002 { "Reserved", "ecat_mailbox.soe_header_reserved",
2003 FT_BOOLEAN
, 16, TFS(&flags_set_truth
), 0x00008000,
2006 { &hf_ecat_mailbox_soe_idn
,
2007 { "SoE IDN", "ecat_mailbox.soe_idn",
2008 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
2010 { &hf_ecat_mailbox_soe_data
,
2011 { "SoE Data", "ecat_mailbox.soe_data",
2012 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
2014 { &hf_ecat_mailbox_soe_frag
,
2015 { "SoE FragLeft", "ecat_mailbox.soe_frag",
2016 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
2018 { &hf_ecat_mailbox_soe_error
,
2019 { "SoE Error", "ecat_mailbox.soe_error",
2020 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}
2024 static gint
*ett
[] =
2027 &ett_ecat_mailbox_eoe
,
2028 &ett_ecat_mailbox_eoe_init
,
2029 &ett_ecat_mailbox_eoe_macfilter
,
2030 &ett_ecat_mailbox_eoe_macfilter_filter
,
2031 &ett_ecat_mailbox_eoe_macfilter_filtermask
,
2032 &ett_ecat_mailbox_coe
,
2033 &ett_ecat_mailbox_sdo
,
2034 &ett_ecat_mailbox_coe_sdoccs
,
2035 &ett_ecat_mailbox_coe_sdoscs
,
2036 &ett_ecat_mailbox_foe
,
2037 &ett_ecat_mailbox_foe_efw
,
2038 &ett_ecat_mailbox_soeflag
,
2039 &ett_ecat_mailbox_soe
,
2040 &ett_ecat_mailbox_fraghead
,
2041 &ett_ecat_mailbox_header
2044 proto_ecat_mailbox
= proto_register_protocol("EtherCAT Mailbox Protocol",
2045 "ECAT_MAILBOX", "ecat_mailbox");
2046 proto_register_field_array(proto_ecat_mailbox
, hf
,array_length(hf
));
2047 proto_register_subtree_array(ett
, array_length(ett
));
2049 register_dissector("ecat_mailbox", dissect_ecat_mailbox
, proto_ecat_mailbox
);
2052 void proto_reg_handoff_ecat_mailbox(void)
2054 dissector_handle_t ecat_mailbox_handle
;
2056 /* Register this dissector as a sub dissector to E88A4 based on ether type. */
2057 ecat_mailbox_handle
= find_dissector("ecat_mailbox");
2058 dissector_add_uint("ecatf.type", 5, ecat_mailbox_handle
);
2060 eth_handle
= find_dissector("eth_withoutfcs");
2061 ams_handle
= find_dissector("ams");