/src/wireshark/epan/dissectors/packet-eth.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-eth.c |
2 | | * Routines for ethernet packet disassembly |
3 | | * |
4 | | * Wireshark - Network traffic analyzer |
5 | | * By Gerald Combs <gerald@wireshark.org> |
6 | | * Copyright 1998 Gerald Combs |
7 | | * |
8 | | * SPDX-License-Identifier: GPL-2.0-or-later |
9 | | */ |
10 | | |
11 | | #include "config.h" |
12 | | |
13 | | #include <epan/packet.h> |
14 | | #include <epan/exceptions.h> |
15 | | #include <epan/prefs.h> |
16 | | #include <epan/etypes.h> |
17 | | #include <epan/ipproto.h> |
18 | | #include <epan/addr_resolv.h> |
19 | | #include <epan/expert.h> |
20 | | #include <epan/conversation_table.h> |
21 | | #include <epan/conversation_filter.h> |
22 | | #include <epan/capture_dissectors.h> |
23 | | #include <epan/exported_pdu.h> |
24 | | #include <epan/tfs.h> |
25 | | #include <wsutil/pint.h> |
26 | | #include "packet-eth.h" |
27 | | #include "packet-gre.h" |
28 | | #include "packet-ieee8023.h" |
29 | | #include "packet-ipx.h" |
30 | | #include "packet-isl.h" |
31 | | #include "packet-llc.h" |
32 | | #include "packet-sll.h" |
33 | | #include "packet-juniper.h" |
34 | | #include "packet-sflow.h" |
35 | | #include "packet-l2tp.h" |
36 | | #include "packet-vxlan.h" |
37 | | #include "packet-nsh.h" |
38 | | #include "packet-acdr.h" |
39 | | #include "packet-mctp.h" |
40 | | #include <epan/crc32-tvb.h> |
41 | | #include <wiretap/erf_record.h> |
42 | | |
43 | | void proto_register_eth(void); |
44 | | void proto_reg_handoff_eth(void); |
45 | | |
46 | 17.3k | #define PADDING_NONE 0 |
47 | 844 | #define PADDING_ZEROS 1 |
48 | 9.20k | #define PADDING_ANY 2 |
49 | | |
50 | | static int eth_padding = PADDING_ZEROS; |
51 | | static unsigned eth_trailer_length; |
52 | | /* By default, try to autodetect FCS */ |
53 | | static int eth_fcs = -1; |
54 | | static bool eth_check_fcs; |
55 | | /* Interpret packets as FW1 monitor file packets if they look as if they are */ |
56 | | static bool eth_interpret_as_fw1_monitor; |
57 | | /* When capturing on a Cisco FEX some frames start with an extra destination mac */ |
58 | | static bool eth_deduplicate_dmac; |
59 | | /* Preference settings defining conditions for which the CCSDS dissector is called */ |
60 | | static bool ccsds_heuristic_length; |
61 | | static bool ccsds_heuristic_version; |
62 | | static bool ccsds_heuristic_header; |
63 | | static bool ccsds_heuristic_bit; |
64 | | |
65 | | /* protocols and header fields */ |
66 | | static int proto_eth; |
67 | | static int hf_eth_dst; |
68 | | static int hf_eth_dst_resolved; |
69 | | static int hf_eth_dst_oui; |
70 | | static int hf_eth_dst_oui_resolved; |
71 | | static int hf_eth_src; |
72 | | static int hf_eth_src_resolved; |
73 | | static int hf_eth_src_oui; |
74 | | static int hf_eth_src_oui_resolved; |
75 | | static int hf_eth_len; |
76 | | static int hf_eth_type; |
77 | | static int hf_eth_invalid_lentype; |
78 | | static int hf_eth_addr; |
79 | | static int hf_eth_addr_resolved; |
80 | | static int hf_eth_addr_oui; |
81 | | static int hf_eth_addr_oui_resolved; |
82 | | static int hf_eth_dst_lg; |
83 | | static int hf_eth_dst_ig; |
84 | | static int hf_eth_src_lg; |
85 | | static int hf_eth_src_ig; |
86 | | static int hf_eth_lg; |
87 | | static int hf_eth_ig; |
88 | | static int hf_eth_padding; |
89 | | static int hf_eth_trailer; |
90 | | static int hf_eth_fcs; |
91 | | static int hf_eth_fcs_status; |
92 | | static int hf_eth_stream; |
93 | | |
94 | | static int ett_ieee8023; |
95 | | static int ett_ether2; |
96 | | static int ett_ether; |
97 | | static int ett_addr; |
98 | | |
99 | | static expert_field ei_eth_invalid_lentype; |
100 | | static expert_field ei_eth_src_not_group; |
101 | | static expert_field ei_eth_fcs_bad; |
102 | | static expert_field ei_eth_len; |
103 | | static expert_field ei_eth_padding_bad; |
104 | | |
105 | | static dissector_handle_t fw1_handle; |
106 | | static dissector_handle_t ethertype_handle; |
107 | | static capture_dissector_handle_t isl_cap_handle; |
108 | | static capture_dissector_handle_t ipx_cap_handle; |
109 | | static capture_dissector_handle_t llc_cap_handle; |
110 | | static heur_dissector_list_t heur_subdissector_list; |
111 | | static heur_dissector_list_t eth_trailer_subdissector_list; |
112 | | static dissector_handle_t eth_withoutfcs_handle; |
113 | | static dissector_handle_t eth_maybefcs_handle; |
114 | | |
115 | | |
116 | | static int eth_tap; |
117 | | static uint32_t eth_stream_count; |
118 | | |
119 | | static int exported_pdu_tap = -1; |
120 | | |
121 | 51.6k | #define ETH_HEADER_SIZE 14 |
122 | | |
123 | | static const true_false_string ig_tfs = { |
124 | | "Group address (multicast/broadcast)", |
125 | | "Individual address (unicast)" |
126 | | }; |
127 | | static const true_false_string lg_tfs = { |
128 | | "Locally administered address (this is NOT the factory default)", |
129 | | "Globally unique address (factory default)" |
130 | | }; |
131 | | |
132 | | static const enum_val_t eth_padding_vals[] = { |
133 | | {"never", "Never", PADDING_NONE}, |
134 | | {"zeros", "Zeros", PADDING_ZEROS}, |
135 | | {"any", "Any", PADDING_ANY}, |
136 | | {NULL, NULL, 0} |
137 | | }; |
138 | | |
139 | | static const enum_val_t eth_fcs_vals[] = { |
140 | | {"heuristic", "According to heuristic", -1}, |
141 | | {"never", "Never", 0}, |
142 | | {"always", "Always", 4}, |
143 | | {NULL, NULL, 0} |
144 | | }; |
145 | | |
146 | | static const char* eth_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter) |
147 | 0 | { |
148 | 0 | if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_ETHER)) |
149 | 0 | return "eth.src"; |
150 | | |
151 | 0 | if ((filter == CONV_FT_DST_ADDRESS) && (conv->dst_address.type == AT_ETHER)) |
152 | 0 | return "eth.dst"; |
153 | | |
154 | 0 | if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == AT_ETHER)) |
155 | 0 | return "eth.addr"; |
156 | | |
157 | 0 | return CONV_FILTER_INVALID; |
158 | 0 | } |
159 | | |
160 | | static ct_dissector_info_t eth_ct_dissector_info = {ð_conv_get_filter_type}; |
161 | | |
162 | | static tap_packet_status |
163 | | eth_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags) |
164 | 0 | { |
165 | 0 | conv_hash_t *hash = (conv_hash_t*) pct; |
166 | 0 | hash->flags = flags; |
167 | 0 | const eth_hdr *ehdr=(const eth_hdr *)vip; |
168 | |
|
169 | 0 | add_conversation_table_data_with_conv_id(hash, &ehdr->src, &ehdr->dst, 0, 0, (conv_id_t)ehdr->stream, 1, pinfo->fd->pkt_len, |
170 | 0 | &pinfo->rel_ts, &pinfo->abs_ts, ð_ct_dissector_info, CONVERSATION_ETH); |
171 | |
|
172 | 0 | return TAP_PACKET_REDRAW; |
173 | 0 | } |
174 | | |
175 | | static const char* eth_endpoint_get_filter_type(endpoint_item_t* endpoint, conv_filter_type_e filter) |
176 | 0 | { |
177 | 0 | if ((filter == CONV_FT_ANY_ADDRESS) && (endpoint->myaddress.type == AT_ETHER)) |
178 | 0 | return "eth.addr"; |
179 | | |
180 | 0 | return CONV_FILTER_INVALID; |
181 | 0 | } |
182 | | |
183 | | static et_dissector_info_t eth_endpoint_dissector_info = {ð_endpoint_get_filter_type}; |
184 | | |
185 | | static tap_packet_status |
186 | | eth_endpoint_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags) |
187 | 0 | { |
188 | 0 | conv_hash_t *hash = (conv_hash_t*) pit; |
189 | 0 | hash->flags = flags; |
190 | 0 | const eth_hdr *ehdr=(const eth_hdr *)vip; |
191 | | |
192 | | /* Take two "add" passes per packet, adding for each direction, ensures that all |
193 | | packets are counted properly (even if address is sending to itself) |
194 | | XXX - this could probably be done more efficiently inside endpoint_table */ |
195 | 0 | add_endpoint_table_data(hash, &ehdr->src, 0, true, 1, pinfo->fd->pkt_len, ð_endpoint_dissector_info, ENDPOINT_NONE); |
196 | 0 | add_endpoint_table_data(hash, &ehdr->dst, 0, false, 1, pinfo->fd->pkt_len, ð_endpoint_dissector_info, ENDPOINT_NONE); |
197 | |
|
198 | 0 | return TAP_PACKET_REDRAW; |
199 | 0 | } |
200 | | |
201 | | static bool |
202 | | eth_filter_valid(packet_info *pinfo, void *user_data _U_) |
203 | 0 | { |
204 | 0 | return (pinfo->dl_src.type == AT_ETHER); |
205 | 0 | } |
206 | | |
207 | | static char* |
208 | | eth_build_filter(packet_info *pinfo, void *user_data _U_) |
209 | 0 | { |
210 | 0 | return ws_strdup_printf("eth.addr eq %s and eth.addr eq %s", |
211 | 0 | address_to_str(pinfo->pool, &pinfo->dl_src), |
212 | 0 | address_to_str(pinfo->pool, &pinfo->dl_dst)); |
213 | 0 | } |
214 | | |
215 | | |
216 | | /* These are the Netware-ish names for the different Ethernet frame types. |
217 | | EthernetII: The ethernet with a Type field instead of a length field |
218 | | Ethernet802.2: An 802.3 header followed by an 802.2 header |
219 | | Ethernet802.3: A raw 802.3 packet. IPX/SPX can be the only payload. |
220 | | There's no 802.2 hdr in this. |
221 | | EthernetSNAP: Basically 802.2, just with 802.2SNAP. For our purposes, |
222 | | there's no difference between 802.2 and 802.2SNAP, since we just |
223 | | pass it down to the LLC dissector. -- Gilbert |
224 | | */ |
225 | 0 | #define ETHERNET_II 0 |
226 | 0 | #define ETHERNET_802_2 1 |
227 | 0 | #define ETHERNET_802_3 2 |
228 | | #define ETHERNET_SNAP 3 |
229 | | |
230 | | static bool |
231 | | capture_eth(const unsigned char *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header) |
232 | 0 | { |
233 | 0 | uint16_t etype, length; |
234 | 0 | int ethhdr_type; /* the type of ethernet frame */ |
235 | |
|
236 | 0 | if (!BYTES_ARE_IN_FRAME(offset, len, ETH_HEADER_SIZE)) |
237 | 0 | return false; |
238 | | |
239 | 0 | etype = pntoh16(&pd[offset+12]); |
240 | |
|
241 | 0 | if (etype <= IEEE_802_3_MAX_LEN) { |
242 | | /* Oh, yuck. Cisco ISL frames require special interpretation of the |
243 | | destination address field; fortunately, they can be recognized by |
244 | | checking the first 5 octets of the destination address, which are |
245 | | 01-00-0C-00-00 or 0C-00-0C-00-00 for ISL frames. */ |
246 | 0 | if ((pd[offset] == 0x01 || pd[offset] == 0x0C) && pd[offset+1] == 0x00 |
247 | 0 | && pd[offset+2] == 0x0C && pd[offset+3] == 0x00 |
248 | 0 | && pd[offset+4] == 0x00) { |
249 | 0 | return call_capture_dissector(isl_cap_handle, pd, offset, len, cpinfo, pseudo_header); |
250 | 0 | } |
251 | 0 | } |
252 | | |
253 | | /* |
254 | | * If the type/length field is <= the maximum 802.3 length, |
255 | | * and is not zero, this is an 802.3 frame, and it's a length |
256 | | * field; it might be an Novell "raw 802.3" frame, with no |
257 | | * 802.2 LLC header, or it might be a frame with an 802.2 LLC |
258 | | * header. |
259 | | * |
260 | | * If the type/length field is >= the minimum Ethernet II length, |
261 | | * this is an Ethernet II frame, and it's a type field. |
262 | | * |
263 | | * If the type/length field is > maximum 802.3 length and < minimum |
264 | | * Ethernet II length, then this is an invalid packet. |
265 | | * |
266 | | * If the type/length field is zero (ETHERTYPE_UNK), this is |
267 | | * a frame used internally by the Cisco MDS switch to contain |
268 | | * Fibre Channel ("Vegas"). We treat that as an Ethernet II |
269 | | * frame; the dissector for those frames registers itself with |
270 | | * an ethernet type of ETHERTYPE_UNK. |
271 | | */ |
272 | 0 | if (etype > IEEE_802_3_MAX_LEN && etype < ETHERNET_II_MIN_LEN) |
273 | 0 | return false; |
274 | | |
275 | 0 | if (etype <= IEEE_802_3_MAX_LEN && etype != ETHERTYPE_UNK) { |
276 | 0 | length = etype; |
277 | | |
278 | | /* Is there an 802.2 layer? I can tell by looking at the first 2 |
279 | | bytes after the 802.3 header. If they are 0xffff, then what |
280 | | follows the 802.3 header is an IPX payload, meaning no 802.2. |
281 | | (IPX/SPX is they only thing that can be contained inside a |
282 | | straight 802.3 packet). A non-0xffff value means that there's an |
283 | | 802.2 layer inside the 802.3 layer */ |
284 | 0 | if (pd[offset+14] == 0xff && pd[offset+15] == 0xff) { |
285 | 0 | ethhdr_type = ETHERNET_802_3; |
286 | 0 | } |
287 | 0 | else { |
288 | 0 | ethhdr_type = ETHERNET_802_2; |
289 | 0 | } |
290 | | |
291 | | /* Convert the LLC length from the 802.3 header to a total |
292 | | frame length, by adding in the size of any data that preceded |
293 | | the Ethernet header, and adding in the Ethernet header size, |
294 | | and set the payload and captured-payload lengths to the minima |
295 | | of the total length and the frame lengths. */ |
296 | 0 | length += offset + ETH_HEADER_SIZE; |
297 | 0 | if (len > length) |
298 | 0 | len = length; |
299 | 0 | } else { |
300 | 0 | ethhdr_type = ETHERNET_II; |
301 | 0 | } |
302 | 0 | offset += ETH_HEADER_SIZE; |
303 | |
|
304 | 0 | switch (ethhdr_type) { |
305 | 0 | case ETHERNET_802_3: |
306 | 0 | return call_capture_dissector(ipx_cap_handle, pd, offset, len, cpinfo, pseudo_header); |
307 | 0 | case ETHERNET_802_2: |
308 | 0 | return call_capture_dissector(llc_cap_handle, pd, offset, len, cpinfo, pseudo_header); |
309 | 0 | case ETHERNET_II: |
310 | 0 | return try_capture_dissector("ethertype", etype, pd, offset, len, cpinfo, pseudo_header); |
311 | 0 | } |
312 | | |
313 | 0 | return false; |
314 | 0 | } |
315 | | |
316 | | static bool check_is_802_2(tvbuff_t *tvb, int fcs_len); |
317 | | |
318 | | static void |
319 | | dissect_address_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool check_group) |
320 | 25.7k | { |
321 | 25.7k | static const mac_hf_list_t eth_dst = { |
322 | 25.7k | &hf_eth_dst, |
323 | 25.7k | &hf_eth_dst_resolved, |
324 | 25.7k | &hf_eth_dst_oui, |
325 | 25.7k | &hf_eth_dst_oui_resolved, |
326 | 25.7k | &hf_eth_dst_lg, |
327 | 25.7k | &hf_eth_dst_ig, |
328 | 25.7k | }; |
329 | 25.7k | static const mac_hf_list_t eth_src = { |
330 | 25.7k | &hf_eth_src, |
331 | 25.7k | &hf_eth_src_resolved, |
332 | 25.7k | &hf_eth_src_oui, |
333 | 25.7k | &hf_eth_src_oui_resolved, |
334 | 25.7k | &hf_eth_src_lg, |
335 | 25.7k | &hf_eth_src_ig, |
336 | 25.7k | }; |
337 | 25.7k | static const mac_hf_list_t eth_addr = { |
338 | 25.7k | &hf_eth_addr, |
339 | 25.7k | &hf_eth_addr_resolved, |
340 | 25.7k | &hf_eth_addr_oui, |
341 | 25.7k | &hf_eth_addr_oui_resolved, |
342 | 25.7k | &hf_eth_lg, |
343 | 25.7k | &hf_eth_ig, |
344 | 25.7k | }; |
345 | 25.7k | proto_item *addr_item; |
346 | | |
347 | 25.7k | proto_tree_add_mac48_detail(ð_dst, ð_addr, ett_addr, tvb, tree, 0); |
348 | | |
349 | 25.7k | addr_item = proto_tree_add_mac48_detail(ð_src, ð_addr, ett_addr, tvb, tree, 6); |
350 | 25.7k | if (check_group) { |
351 | 18.0k | if (tvb_get_uint8(tvb, 6) & 0x01) { |
352 | 7.78k | expert_add_info(pinfo, addr_item, &ei_eth_src_not_group); |
353 | 7.78k | } |
354 | 18.0k | } |
355 | 25.7k | } |
356 | | |
357 | | static void |
358 | | export_pdu(tvbuff_t *tvb, packet_info *pinfo) |
359 | 25.9k | { |
360 | 25.9k | if (have_tap_listener(exported_pdu_tap)) { |
361 | 0 | exp_pdu_data_t *exp_pdu_data = wmem_new0(pinfo->pool, exp_pdu_data_t); |
362 | |
|
363 | 0 | exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb); |
364 | 0 | exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb); |
365 | 0 | exp_pdu_data->pdu_tvb = tvb; |
366 | 0 | tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data); |
367 | 0 | } |
368 | 25.9k | } |
369 | | |
370 | | static struct eth_analysis * |
371 | | init_eth_conversation_data(packet_info *pinfo) |
372 | 6.52k | { |
373 | 6.52k | struct eth_analysis *ethd; |
374 | | |
375 | | /* Initialize the eth protocol data structure to add to the ip conversation */ |
376 | 6.52k | ethd=wmem_new0(wmem_file_scope(), struct eth_analysis); |
377 | | |
378 | 6.52k | ethd->initial_frame = pinfo->num; |
379 | 6.52k | ethd->stream = 0; |
380 | 6.52k | ethd->stream = eth_stream_count++; |
381 | | |
382 | 6.52k | return ethd; |
383 | 6.52k | } |
384 | | |
385 | | struct eth_analysis * |
386 | | get_eth_conversation_data(conversation_t *conv, packet_info *pinfo) |
387 | 25.7k | { |
388 | 25.7k | struct eth_analysis *ethd; |
389 | | |
390 | | /* Did the caller supply the conversation pointer? */ |
391 | 25.7k | if( conv==NULL ) { |
392 | 0 | return NULL; |
393 | 0 | } |
394 | | |
395 | | /* Get the data for this conversation */ |
396 | 25.7k | ethd=(struct eth_analysis *)conversation_get_proto_data(conv, proto_eth); |
397 | | |
398 | 25.7k | if (!ethd) { |
399 | 6.52k | ethd = init_eth_conversation_data(pinfo); |
400 | 6.52k | conversation_add_proto_data(conv, proto_eth, ethd); |
401 | 6.52k | } |
402 | | |
403 | 25.7k | if (!ethd) { |
404 | 0 | return NULL; |
405 | 0 | } |
406 | | |
407 | 25.7k | return ethd; |
408 | 25.7k | } |
409 | | |
410 | | static proto_tree * |
411 | | dissect_eth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, |
412 | | int fcs_len) |
413 | 26.0k | { |
414 | 26.0k | proto_item *ti = NULL; |
415 | 26.0k | eth_hdr *ehdr; |
416 | 26.0k | bool is_802_2; |
417 | 26.0k | proto_tree *fh_tree = NULL; |
418 | 26.0k | static eth_hdr ehdrs[4]; |
419 | 26.0k | static int ehdr_num=0; |
420 | 26.0k | proto_tree *tree; |
421 | 26.0k | ethertype_data_t ethertype_data; |
422 | 26.0k | heur_dtbl_entry_t *hdtbl_entry = NULL; |
423 | 26.0k | struct eth_analysis *ethd=NULL; |
424 | | /* a facility for not duplicating long code */ |
425 | 26.0k | bool needs_dissector_with_data = false; |
426 | | |
427 | | /* Rotating buffer */ |
428 | 26.0k | ehdr_num++; |
429 | 26.0k | if(ehdr_num>=4){ |
430 | 6.50k | ehdr_num=0; |
431 | 6.50k | } |
432 | 26.0k | ehdr=&ehdrs[ehdr_num]; |
433 | | |
434 | 26.0k | tree=parent_tree; |
435 | | |
436 | 26.0k | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Ethernet"); |
437 | | |
438 | 26.0k | set_address_tvb(&pinfo->dl_dst, AT_ETHER, 6, tvb, 0); |
439 | 26.0k | copy_address_shallow(&pinfo->dst, &pinfo->dl_dst); |
440 | 26.0k | copy_address_shallow(&ehdr->dst, &pinfo->dl_dst); |
441 | | |
442 | 26.0k | set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, 6); |
443 | 26.0k | copy_address_shallow(&pinfo->src, &pinfo->dl_src); |
444 | 26.0k | copy_address_shallow(&ehdr->src, &pinfo->dl_src); |
445 | | |
446 | 26.0k | ehdr->type = tvb_get_ntohs(tvb, 12); |
447 | | |
448 | 26.0k | tap_queue_packet(eth_tap, pinfo, ehdr); |
449 | 26.0k | export_pdu(tvb, pinfo); |
450 | | |
451 | | /* |
452 | | * In case the packet is a non-Ethernet packet inside |
453 | | * Ethernet framing, allow heuristic dissectors to take |
454 | | * a first look before we assume that it's actually an |
455 | | * Ethernet packet. |
456 | | * |
457 | | * Tell the heuristic dissectors what FCS length was reported for |
458 | | * this packet - the non-Ethernet packet might or might not include |
459 | | * the FCS, or might have a different calculation. (Heuristic |
460 | | * dissectors also can't report a number of bytes consumed, so we |
461 | | * can't really handle the "maybefcs" case otherwise.) |
462 | | */ |
463 | 26.0k | struct eth_phdr phdr; |
464 | 26.0k | phdr.fcs_len = fcs_len; |
465 | 26.0k | if (dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, parent_tree, &hdtbl_entry, &phdr)) |
466 | 26 | return fh_tree; |
467 | | |
468 | 25.9k | if (ehdr->type <= IEEE_802_3_MAX_LEN) { |
469 | | /* Oh, yuck. Cisco ISL frames require special interpretation of the |
470 | | destination address field; fortunately, they can be recognized by |
471 | | checking the first 5 octets of the destination address, which are |
472 | | 01-00-0C-00-00 for ISL frames. */ |
473 | 8.26k | if ((tvb_get_uint8(tvb, 0) == 0x01 || |
474 | 8.26k | tvb_get_uint8(tvb, 0) == 0x0C) && |
475 | 8.26k | tvb_get_uint8(tvb, 1) == 0x00 && |
476 | 8.26k | tvb_get_uint8(tvb, 2) == 0x0C && |
477 | 8.26k | tvb_get_uint8(tvb, 3) == 0x00 && |
478 | 8.26k | tvb_get_uint8(tvb, 4) == 0x00) { |
479 | 101 | dissect_isl(tvb, pinfo, parent_tree, fcs_len); |
480 | 101 | return fh_tree; |
481 | 101 | } |
482 | 8.26k | } |
483 | | |
484 | | /* |
485 | | * If the type/length field is <= the maximum 802.3 length, |
486 | | * and is not zero, this is an 802.3 frame, and it's a length |
487 | | * field; it might be an Novell "raw 802.3" frame, with no |
488 | | * 802.2 LLC header, or it might be a frame with an 802.2 LLC |
489 | | * header. |
490 | | * |
491 | | * If the type/length field is >= the minimum Ethernet II length, |
492 | | * this is an Ethernet II frame, and it's a type field. |
493 | | * |
494 | | * If the type/length field is > maximum 802.3 length and < minimum |
495 | | * Ethernet II length, then this is an invalid packet. |
496 | | * |
497 | | * If the type/length field is zero (ETHERTYPE_UNK), this is |
498 | | * a frame used internally by the Cisco MDS switch to contain |
499 | | * Fibre Channel ("Vegas"). We treat that as an Ethernet II |
500 | | * frame; the dissector for those frames registers itself with |
501 | | * an ethernet type of ETHERTYPE_UNK. |
502 | | */ |
503 | 25.8k | if (ehdr->type > IEEE_802_3_MAX_LEN && ehdr->type < ETHERNET_II_MIN_LEN) { |
504 | 8 | tvbuff_t *next_tvb; |
505 | | |
506 | 8 | col_add_fstr(pinfo->cinfo, COL_INFO, |
507 | 8 | "Ethernet Unknown: Invalid length/type: 0x%04x (%d)", |
508 | 8 | ehdr->type, ehdr->type); |
509 | 8 | ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE, |
510 | 8 | "Ethernet Unknown, Src: %s, Dst: %s", |
511 | 8 | address_with_resolution_to_str(pinfo->pool, &pinfo->src), |
512 | 8 | address_with_resolution_to_str(pinfo->pool, &pinfo->dst)); |
513 | 8 | fh_tree = proto_item_add_subtree(ti, ett_ether); |
514 | | |
515 | 8 | dissect_address_data(tvb, pinfo, fh_tree, false); |
516 | | |
517 | 8 | ti = proto_tree_add_item(fh_tree, hf_eth_invalid_lentype, tvb, 12, 2, ENC_BIG_ENDIAN); |
518 | 8 | expert_add_info_format(pinfo, ti, &ei_eth_invalid_lentype, |
519 | 8 | "Invalid length/type: 0x%04x (%d)", ehdr->type, ehdr->type); |
520 | 8 | next_tvb = tvb_new_subset_remaining(tvb, 14); |
521 | 8 | call_data_dissector(next_tvb, pinfo, parent_tree); |
522 | 8 | return fh_tree; |
523 | 8 | } |
524 | | |
525 | 25.8k | if (ehdr->type <= IEEE_802_3_MAX_LEN && ehdr->type != ETHERTYPE_UNK) { |
526 | | |
527 | 7.69k | is_802_2 = check_is_802_2(tvb, fcs_len); |
528 | | |
529 | 7.69k | col_add_fstr(pinfo->cinfo, COL_INFO, "IEEE 802.3 Ethernet %s", |
530 | 7.69k | (is_802_2 ? "" : "Raw ")); |
531 | 7.69k | if (tree) { |
532 | 7.69k | ti = proto_tree_add_protocol_format(tree, proto_eth, tvb, 0, ETH_HEADER_SIZE, |
533 | 7.69k | "IEEE 802.3 Ethernet %s", (is_802_2 ? "" : "Raw ")); |
534 | | |
535 | 7.69k | fh_tree = proto_item_add_subtree(ti, ett_ieee8023); |
536 | 7.69k | } |
537 | | |
538 | | /* if IP is not referenced from any filters we don't need to worry about |
539 | | generating any tree items. We must do this after we created the actual |
540 | | protocol above so that proto hier stat still works though. |
541 | | */ |
542 | 7.69k | if(!proto_field_is_referenced(parent_tree, proto_eth)){ |
543 | 992 | tree=NULL; |
544 | 992 | fh_tree=NULL; |
545 | 992 | } |
546 | | |
547 | 7.69k | dissect_address_data(tvb, pinfo, fh_tree, false); |
548 | | |
549 | 7.69k | dissect_802_3(ehdr->type, is_802_2, tvb, ETH_HEADER_SIZE, pinfo, |
550 | 7.69k | parent_tree, fh_tree, hf_eth_len, hf_eth_trailer, &ei_eth_len, fcs_len); |
551 | 18.1k | } else { |
552 | 18.1k | if (eth_interpret_as_fw1_monitor) { |
553 | 0 | const uint8_t *dst_addr = (const uint8_t*)pinfo->dst.data; |
554 | |
|
555 | 0 | if ((dst_addr[0] == 'i') || (dst_addr[0] == 'I') || |
556 | 0 | (dst_addr[0] == 'o') || (dst_addr[0] == 'O') || |
557 | 0 | (dst_addr[0] == 'e') || (dst_addr[0] == 'E')) { |
558 | 0 | call_dissector(fw1_handle, tvb, pinfo, parent_tree); |
559 | 0 | return fh_tree; |
560 | 0 | } |
561 | 0 | } |
562 | | |
563 | 18.1k | col_set_str(pinfo->cinfo, COL_INFO, "Ethernet II"); |
564 | 18.1k | if (parent_tree) { |
565 | 18.0k | if (PTREE_DATA(parent_tree)->visible) { |
566 | 16.7k | ti = proto_tree_add_protocol_format(parent_tree, proto_eth, tvb, 0, ETH_HEADER_SIZE, |
567 | 16.7k | "Ethernet II, Src: %s, Dst: %s", |
568 | 16.7k | address_with_resolution_to_str(pinfo->pool, &pinfo->src), |
569 | 16.7k | address_with_resolution_to_str(pinfo->pool, &pinfo->dst)); |
570 | 16.7k | } |
571 | 1.31k | else { |
572 | 1.31k | ti = proto_tree_add_item(parent_tree, proto_eth, tvb, 0, ETH_HEADER_SIZE, ENC_NA); |
573 | 1.31k | } |
574 | 18.0k | fh_tree = proto_item_add_subtree(ti, ett_ether2); |
575 | 18.0k | } |
576 | | |
577 | 18.1k | dissect_address_data(tvb, pinfo, fh_tree, true); |
578 | | |
579 | 18.1k | proto_tree_add_uint(fh_tree, hf_eth_type, tvb, 12, 2, ehdr->type); |
580 | | |
581 | 18.1k | ethertype_data.etype = ehdr->type; |
582 | 18.1k | ethertype_data.payload_offset = ETH_HEADER_SIZE; |
583 | 18.1k | ethertype_data.fh_tree = fh_tree; |
584 | 18.1k | ethertype_data.trailer_id = hf_eth_trailer; |
585 | 18.1k | ethertype_data.fcs_len = fcs_len; |
586 | | |
587 | 18.1k | needs_dissector_with_data = true; |
588 | 18.1k | } |
589 | | |
590 | | /* if we still did not leave the dissection, try identifying any ETH conversation |
591 | | * When deinterlacing was asked and an interface is known, create an _IN conv, |
592 | | * otherwise create an ordinary _NN one. |
593 | | * |
594 | | */ |
595 | | |
596 | 25.8k | unsigned conv_type = CONVERSATION_ETH_NN; |
597 | | /* deinterlacing is requested */ |
598 | 25.8k | if(prefs.conversation_deinterlacing_key>0) { |
599 | 0 | uint32_t dtlc_iface = 0; |
600 | |
|
601 | 0 | if(prefs.conversation_deinterlacing_key&CONV_DEINT_KEY_INTERFACE && |
602 | 0 | pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID) { |
603 | |
|
604 | 0 | conv_type = CONVERSATION_ETH_IN; |
605 | 0 | dtlc_iface = pinfo->rec->rec_header.packet_header.interface_id; |
606 | 0 | } |
607 | 0 | else { |
608 | 0 | conv_type = CONVERSATION_ETH_NN; |
609 | 0 | } |
610 | | |
611 | | // identify an existing conversation or create a new one |
612 | 0 | conversation_t *conv_deint = find_conversation_deinterlacer(pinfo->num, &pinfo->src, &pinfo->dst, conv_type, |
613 | 0 | dtlc_iface, 0, 0); |
614 | 0 | if(!conv_deint) { |
615 | 0 | conversation_new_deinterlacer(pinfo->num, &pinfo->src, &pinfo->dst, |
616 | 0 | conv_type, dtlc_iface, 0, 0); |
617 | 0 | } |
618 | 0 | } |
619 | | |
620 | 25.8k | conversation_t *conv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst, conv_type, 0, 0, NO_PORT_X); |
621 | | |
622 | 25.8k | if(!conv) { |
623 | 6.52k | conv = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst, conv_type, 0, 0, NO_PORTS); |
624 | 6.52k | } |
625 | 19.3k | else { |
626 | | /* |
627 | | * while not strictly necessary because there is only 1 |
628 | | * conversation between 2 IPs, we still move the last frame |
629 | | * indicator as being a usual practice. |
630 | | */ |
631 | 19.3k | if (!(pinfo->fd->visited)) { |
632 | 19.2k | if (pinfo->num > conv->last_frame) { |
633 | 13.2k | conv->last_frame = pinfo->num; |
634 | 13.2k | } |
635 | 19.2k | } |
636 | 19.3k | } |
637 | | |
638 | 25.8k | ethd = get_eth_conversation_data(conv, pinfo); |
639 | 25.8k | if(ethd) { |
640 | 25.7k | ehdr->stream = ethd->stream; |
641 | 25.7k | if(tree) { |
642 | 24.7k | ti = proto_tree_add_uint(fh_tree, hf_eth_stream, tvb, 0, 0, ethd->stream); |
643 | 24.7k | proto_item_set_generated(ti); |
644 | 24.7k | } |
645 | 25.7k | } |
646 | | |
647 | 25.8k | if(needs_dissector_with_data) { |
648 | 18.0k | call_dissector_with_data(ethertype_handle, tvb, pinfo, parent_tree, ðertype_data); |
649 | 18.0k | } |
650 | | |
651 | 25.8k | return fh_tree; |
652 | 25.8k | } |
653 | | |
654 | | static void |
655 | | eth_init(void) |
656 | 14 | { |
657 | 14 | eth_stream_count = 0; |
658 | 14 | } |
659 | | |
660 | | /* -------------- */ |
661 | | static bool check_is_802_2(tvbuff_t *tvb, int fcs_len) |
662 | 7.69k | { |
663 | 7.69k | volatile bool is_802_2; |
664 | 7.69k | volatile int length; |
665 | 7.69k | int captured_length, reported_length; |
666 | | |
667 | 7.69k | is_802_2 = true; |
668 | | |
669 | | /* Is there an 802.2 layer? I can tell by looking at the first 2 |
670 | | bytes after the 802.3 header. If they are 0xffff, then what |
671 | | follows the 802.3 header is an IPX payload, meaning no 802.2. |
672 | | A non-0xffff value means that there's an 802.2 layer or CCSDS |
673 | | layer inside the 802.3 layer */ |
674 | | |
675 | 7.69k | TRY { |
676 | 7.69k | if (tvb_get_ntohs(tvb, 14) == 0xffff) { |
677 | 475 | is_802_2 = false; |
678 | 475 | } |
679 | | /* Is this a CCSDS payload instead of an 802.2 (LLC)? |
680 | | Check the conditions enabled by the user for CCSDS presence */ |
681 | 7.22k | else if (ccsds_heuristic_length || ccsds_heuristic_version || |
682 | 7.22k | ccsds_heuristic_header || ccsds_heuristic_bit) { |
683 | 0 | bool CCSDS_len = true; |
684 | 0 | bool CCSDS_ver = true; |
685 | 0 | bool CCSDS_head = true; |
686 | 0 | bool CCSDS_bit = true; |
687 | | /* See if the reported payload size matches the |
688 | | size contained in the CCSDS header. */ |
689 | 0 | if (ccsds_heuristic_length) { |
690 | | /* The following technique to account for FCS |
691 | | is copied from packet-ieee8023.c dissect_802_3() */ |
692 | 0 | length = tvb_get_ntohs(tvb, 12); |
693 | 0 | reported_length = tvb_reported_length_remaining(tvb, ETH_HEADER_SIZE); |
694 | 0 | if (fcs_len > 0) { |
695 | 0 | if (reported_length >= fcs_len) |
696 | 0 | reported_length -= fcs_len; |
697 | 0 | } |
698 | | /* Make sure the length in the 802.3 header doesn't go past the end of |
699 | | the payload. */ |
700 | 0 | if (length > reported_length) { |
701 | 0 | length = reported_length; |
702 | 0 | } |
703 | | /* Only allow inspection of 'length' number of bytes. */ |
704 | 0 | captured_length = tvb_captured_length_remaining(tvb, ETH_HEADER_SIZE); |
705 | 0 | if (captured_length > length) |
706 | 0 | captured_length = length; |
707 | | |
708 | | /* Check if payload is large enough to contain a CCSDS header */ |
709 | 0 | if (captured_length >= 6) { |
710 | | /* Compare length to packet length contained in CCSDS header. */ |
711 | 0 | if (length != 7 + tvb_get_ntohs(tvb, ETH_HEADER_SIZE + 4)) |
712 | 0 | CCSDS_len = false; |
713 | 0 | } |
714 | 0 | } |
715 | | /* Check if CCSDS Version number (first 3 bits of payload) is zero */ |
716 | 0 | if ((ccsds_heuristic_version) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE, 3)!=0)) |
717 | 0 | CCSDS_ver = false; |
718 | | /* Check if Secondary Header Flag (4th bit of payload) is set to one. */ |
719 | 0 | if ((ccsds_heuristic_header) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE + 4, 1)!=1)) |
720 | 0 | CCSDS_head = false; |
721 | | /* Check if spare bit (1st bit of 7th word of payload) is zero. */ |
722 | 0 | if ((ccsds_heuristic_bit) && (tvb_get_bits8(tvb, 8*ETH_HEADER_SIZE + 16*6, 1)!=0)) |
723 | 0 | CCSDS_bit = false; |
724 | | /* If all the conditions are true, don't interpret payload as an 802.2 (LLC). |
725 | | * Additional check in packet-802.3.c will distinguish between |
726 | | * IPX and CCSDS packets*/ |
727 | 0 | if (CCSDS_len && CCSDS_ver && CCSDS_head && CCSDS_bit) |
728 | 0 | is_802_2 = false; |
729 | 0 | } |
730 | 7.69k | } |
731 | 7.69k | CATCH_BOUNDS_ERRORS { |
732 | 78 | ; /* do nothing */ |
733 | | |
734 | 78 | } |
735 | 7.69k | ENDTRY; |
736 | 7.69k | return is_802_2; |
737 | 7.69k | } |
738 | | |
739 | | /* |
740 | | * Add an Ethernet trailer - which, for some captures, might be the FCS |
741 | | * rather than a pad-to-60-bytes trailer. |
742 | | * |
743 | | * If fcs_len is 0, we assume the frame has no FCS; if it's 4, we assume |
744 | | * it has an FCS; if it's anything else (such as -1, which means "maybe |
745 | | * it does, maybe it doesn't"), we try to infer whether it has an FCS. |
746 | | */ |
747 | | void |
748 | | add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree, |
749 | | int trailer_id, tvbuff_t *tvb, tvbuff_t *trailer_tvb, int fcs_len, |
750 | | int payload_offset) |
751 | 25.9k | { |
752 | | /* If there're some bytes left over, it could be a combination of: |
753 | | - padding to meet the minimum 64 byte frame length |
754 | | - an FCS, if present (if fcs_len is 0, we know it's not present; |
755 | | if fcs_len is 4, we know it's present; if fcs_len is -1, we |
756 | | need some heuristics to determine whether it's present) |
757 | | - information inserted by TAPs or other network monitoring equipment. |
758 | | |
759 | | If we don't know whether the FCS is present, then, if we don't have a |
760 | | network monitoring trailer, and if the Ethernet frame was claimed to |
761 | | have had 64 or more bytes - i.e., it was at least an FCS worth of data |
762 | | longer than the minimum payload size - we could assume the last 4 bytes |
763 | | of the trailer are an FCS. */ |
764 | 25.9k | heur_dtbl_entry_t *hdtbl_entry; |
765 | | |
766 | 25.9k | if (trailer_tvb) { |
767 | 8.66k | unsigned trailer_length, trailer_reported_length; |
768 | 8.66k | unsigned padding_length = 0; |
769 | 8.66k | bool has_fcs = false; |
770 | 8.66k | bool maybe_padded = false; |
771 | 8.66k | tvbuff_t *real_trailer_tvb; |
772 | | |
773 | 8.66k | trailer_length = tvb_captured_length(trailer_tvb); |
774 | 8.66k | trailer_reported_length = tvb_reported_length(trailer_tvb); |
775 | | |
776 | | /* Theoretically padding is added if the frame length without the FCS is |
777 | | * less than 60 bytes, starting from the addresses. In practice, frames |
778 | | * are often padded so that the length is 60 bytes not counting any tags |
779 | | * before the final Ethertype. (I.e., padding so that the payload portion |
780 | | * is 46.) |
781 | | * |
782 | | * Padding might be added to a frame at one point in a network, and then a |
783 | | * tag or trailer added later without removing the padding. Conversely, a |
784 | | * frame might have padding and a tag and trailer, and then the tag removed, |
785 | | * dropping the frame below 60 octets, leading to more padding at the end, |
786 | | * after the trailer. https://gitlab.com/wireshark/wireshark/-/wikis/PRP |
787 | | * has useful illustrations of both situations. The heuristic trailer |
788 | | * dissectors can try to deal with both situations (though looping through |
789 | | * the trailer bytes increases false positives.) |
790 | | * |
791 | | * By increasing the minimum frame size (padding payload to 46) the former |
792 | | * situation always occurs, and trailers appear at the end. IEEE Std |
793 | | * 802.1Q-2014 G.2.1 "Treatment of PAD fields in IEEE 802.3 frames" |
794 | | * and G.2.3 "Minimum PDU size" specifically state it is permissible for a |
795 | | * Bridge to to adopt a minimum tagged frame length of 68 bytes (64 without |
796 | | * FCS) when 802.1Q is used. Other specs don't directly address this, but |
797 | | * we often see padding on frames that are more than 60 octets without FCS. |
798 | | */ |
799 | 8.66k | int frame_len; |
800 | 8.66k | if (eth_padding == PADDING_ANY) { |
801 | | /* This is a size at which there definitely should be padding, |
802 | | * which we use with PADDING_ANY to be conservative so we don't |
803 | | * mark any possible trailer as padding. Fo certain cases (tags, |
804 | | * trailers, especially encapsulation like ISL, GSE Bridged Frames) |
805 | | * some padding will be classified as trailer. |
806 | | */ |
807 | 0 | frame_len = pinfo->fd->pkt_len; |
808 | 8.66k | } else { |
809 | | /* This is the size up to which there might be padding, if padding |
810 | | * was added before adding tags after the first ethertype. |
811 | | * Use this if we're testing PADDING_ZERO, which is strict. |
812 | | * Consecutive zeroes up to this point will be padding, |
813 | | * anything starting with the first non-zero will be trailer. |
814 | | */ |
815 | 8.66k | frame_len = tvb_reported_length(tvb) + (14 - payload_offset); |
816 | 8.66k | } |
817 | 8.66k | maybe_padded = (frame_len >= 60 && (frame_len - trailer_reported_length) < 60); |
818 | | |
819 | 8.66k | if (eth_padding != PADDING_NONE && maybe_padded) { |
820 | | /* XXX: There could be another 4 bytes of padding if a Bridge extends |
821 | | * the minimum frame size of 68 on untagged fraomes, see discussion |
822 | | * above of IEEE 802.1Q Annex G. If we require padding to be zeros, |
823 | | * we could possibly use 64 instead of 60. (Too many false positives |
824 | | * with PADDING_ANY.) |
825 | | */ |
826 | 302 | padding_length = 60 - (frame_len - trailer_reported_length); |
827 | | /* Require padding to be zeros */ |
828 | 302 | if (eth_padding == PADDING_ZEROS) { |
829 | 1.04k | for (unsigned i = 0; i < padding_length; i++) { |
830 | 974 | if (tvb_get_int8(trailer_tvb, i) != 0) { |
831 | 232 | padding_length = i; |
832 | 232 | break; |
833 | 232 | } |
834 | 974 | } |
835 | 302 | } |
836 | | /* If it was determined that we have padding, add it to the tree. */ |
837 | 302 | if (padding_length > 0) { |
838 | 147 | tvb_ensure_bytes_exist(tvb, 0, padding_length); |
839 | 147 | proto_tree_add_item(fh_tree, hf_eth_padding, trailer_tvb, 0, |
840 | 147 | padding_length, ENC_NA); |
841 | 147 | trailer_length -= padding_length; |
842 | 147 | trailer_reported_length -= padding_length; |
843 | 147 | } |
844 | 302 | } |
845 | | |
846 | 8.66k | int payload_length = tvb_reported_length(tvb) - payload_offset; |
847 | 8.66k | bool dissected = false; |
848 | | |
849 | 8.66k | if (fcs_len != 4) { |
850 | | /* Try trailer dissection without an FCS */ |
851 | 7.95k | real_trailer_tvb = tvb_new_subset_remaining(trailer_tvb, padding_length); |
852 | | /* Call all ethernet trailer dissectors to dissect the trailer if |
853 | | we actually have a trailer. The PRP trailer dissector wants |
854 | | to know about the payload (LSDU) length. */ |
855 | 7.95k | if (tvb_reported_length(real_trailer_tvb) != 0) { |
856 | 1.14k | dissected = dissector_try_heuristic(eth_trailer_subdissector_list, |
857 | 1.14k | real_trailer_tvb, pinfo, tree, |
858 | 1.14k | &hdtbl_entry, &payload_length); |
859 | 1.14k | } |
860 | 7.95k | } |
861 | | |
862 | 8.66k | if (fcs_len != 0) { |
863 | | /* If fcs_len is 4, we assume we definitely have an FCS. |
864 | | If fcs_len is -1, if the frame is big enough that, if we |
865 | | have a trailer, it probably includes an FCS, and we have |
866 | | enough space in the trailer for the FCS, and we didn't |
867 | | have a heuristic trailer dissector successfully dissect |
868 | | without an FCS, we assume we have an FCS. |
869 | | |
870 | | "Big enough" means 64 bytes or more; any frame that big |
871 | | needs no trailer, as there's no need to pad an Ethernet |
872 | | packet past 60 bytes. |
873 | | |
874 | | XXX: This is not quite true. See IEEE Std 802.1Q-2014 |
875 | | G.2.1 "Treatment of PAD fields in IEEE 802.3 frames" and |
876 | | G.2.3 "Minimum PDU size" and the discussion above. |
877 | | |
878 | | The trailer must be at least 4 bytes long to have enough |
879 | | space for an FCS. */ |
880 | | |
881 | 1.19k | if (fcs_len == 4 || (fcs_len == -1 && !dissected && |
882 | 817 | frame_len >= 64 && trailer_reported_length >= 4)) { |
883 | | /* Either we know we have an FCS, or we believe we have an FCS. */ |
884 | 817 | if (trailer_length < trailer_reported_length) { |
885 | | /* The packet is claimed to have enough data for a 4-byte FCS, |
886 | | but we didn't capture all of the packet. |
887 | | Slice off the 4-byte FCS from the reported length, and |
888 | | trim the captured length so it's no more than the reported |
889 | | length; that will slice off what of the FCS, if any, is |
890 | | in the captured packet. */ |
891 | 6 | trailer_reported_length -= 4; |
892 | 6 | if (trailer_length > trailer_reported_length) { |
893 | 2 | payload_length -= (trailer_length - trailer_reported_length); |
894 | 2 | trailer_length = trailer_reported_length; |
895 | 2 | } |
896 | 6 | has_fcs = true; |
897 | 811 | } else { |
898 | | /* We captured all of the packet, including what appears to |
899 | | be a 4-byte FCS. Slice it off. */ |
900 | 811 | trailer_length -= 4; |
901 | 811 | trailer_reported_length -= 4; |
902 | 811 | payload_length -= 4; |
903 | 811 | has_fcs = true; |
904 | 811 | } |
905 | | |
906 | 817 | real_trailer_tvb = tvb_new_subset_length_caplen(trailer_tvb, padding_length, |
907 | 817 | trailer_length, trailer_reported_length); |
908 | | |
909 | | /* Call all ethernet trailer dissectors to dissect the trailer if |
910 | | we actually have a trailer. */ |
911 | 817 | if (tvb_reported_length(real_trailer_tvb) != 0) { |
912 | 133 | dissected = dissector_try_heuristic(eth_trailer_subdissector_list, |
913 | 133 | real_trailer_tvb, pinfo, tree, |
914 | 133 | &hdtbl_entry, &payload_length); |
915 | 133 | } |
916 | 817 | } |
917 | 1.19k | } |
918 | | |
919 | 8.66k | if (!dissected) { |
920 | | /* No luck with the trailer dissectors, so just display the |
921 | | extra bytes as general trailer */ |
922 | 8.57k | if (trailer_length != 0) { |
923 | 1.08k | tvb_ensure_bytes_exist(real_trailer_tvb, 0, trailer_length); |
924 | 1.08k | proto_item *pi = proto_tree_add_item(fh_tree, trailer_id, real_trailer_tvb, 0, |
925 | 1.08k | trailer_length, ENC_NA); |
926 | 1.08k | if (maybe_padded) { |
927 | 271 | if (eth_padding == PADDING_ANY && padding_length > 0) { |
928 | 0 | expert_add_info_format(pinfo, pi, &ei_eth_padding_bad, |
929 | 0 | "Padding was assumed, and an undecoded trailer exists. Some of the trailer may have been consumed by padding."); |
930 | 0 | } |
931 | 271 | else if (eth_padding == PADDING_ZEROS && padding_length == 0) { |
932 | 127 | expert_add_info_format(pinfo, pi, &ei_eth_padding_bad, |
933 | 127 | "Didn't find padding of zeros, and an undecoded trailer exists. There may be padding of non-zeros."); |
934 | 127 | } |
935 | 271 | } |
936 | 1.08k | } |
937 | 8.57k | } |
938 | | |
939 | 8.66k | if (has_fcs) { |
940 | 813 | uint32_t sent_fcs = tvb_get_ntohl(trailer_tvb, padding_length+trailer_length); |
941 | | /* If we don't have the entire header, we can't actually check the FCS. |
942 | | * Dissectors that don't have the entire header (say, a tag) probably |
943 | | * should have set fcs_len to zero in the ethertype_data struct. |
944 | | * XXX: Maybe add an expert info saying why we aren't checking the FCS? */ |
945 | 813 | if (eth_check_fcs && payload_offset == ETH_HEADER_SIZE) { |
946 | 0 | uint32_t fcs = crc32_802_tvb(tvb, tvb_captured_length(tvb) - 4); |
947 | 0 | proto_tree_add_checksum(fh_tree, trailer_tvb, padding_length+trailer_length, hf_eth_fcs, hf_eth_fcs_status, &ei_eth_fcs_bad, pinfo, fcs, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY); |
948 | |
|
949 | 0 | if (fcs != sent_fcs) { |
950 | 0 | col_append_str(pinfo->cinfo, COL_INFO, " [ETHERNET FRAME CHECK SEQUENCE INCORRECT]"); |
951 | 0 | } |
952 | 813 | }else{ |
953 | 813 | proto_tree_add_checksum(fh_tree, trailer_tvb, padding_length+trailer_length, hf_eth_fcs, hf_eth_fcs_status, &ei_eth_fcs_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS); |
954 | 813 | } |
955 | 813 | trailer_length += 4; |
956 | 813 | } |
957 | 8.66k | proto_tree_set_appendix(fh_tree, tvb, tvb_captured_length(tvb) - padding_length - trailer_length, padding_length + trailer_length); |
958 | 8.66k | } |
959 | 25.9k | } |
960 | | |
961 | | /* Called for the Ethernet Wiretap encapsulation type; pass the FCS length |
962 | | reported to us, if known, otherwise falling back to the "fcs" preference. */ |
963 | | static int |
964 | | dissect_eth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
965 | 1 | { |
966 | 1 | struct eth_phdr *eth = (struct eth_phdr *)data; |
967 | 1 | proto_tree *fh_tree; |
968 | 1 | tvbuff_t *real_tvb; |
969 | 1 | int fcs_len; |
970 | | |
971 | 1 | if (eth && eth->fcs_len != -1) { |
972 | | /* Use the value reported from Wiretap, if known. */ |
973 | 0 | fcs_len = eth->fcs_len; |
974 | 1 | } else { |
975 | 1 | fcs_len = eth_fcs; |
976 | 1 | } |
977 | | |
978 | | /* When capturing on a Cisco FEX, some frames (most likely all frames |
979 | | captured without a vntag) have an extra destination mac prepended. */ |
980 | 1 | if (eth_deduplicate_dmac && tvb_captured_length(tvb) > 20 && |
981 | 1 | memcmp(tvb_get_ptr(tvb,0,6),tvb_get_ptr(tvb,6,6), 6) == 0) { |
982 | 0 | real_tvb = tvb_new_subset_length_caplen(tvb, 6, |
983 | 0 | tvb_captured_length(tvb) - 6, tvb_reported_length(tvb) - 6); |
984 | 1 | } else { |
985 | 1 | real_tvb = tvb; |
986 | 1 | } |
987 | | |
988 | | /* Some devices slice the packet and add their own trailer before |
989 | | putting the frame on the network. Make sure these packets get |
990 | | a proper trailer (even though the sliced frame might not |
991 | | properly dissect. */ |
992 | 1 | if ( (eth_trailer_length > 0) && (eth_trailer_length < tvb_captured_length(real_tvb)) ) { |
993 | 0 | tvbuff_t *next_tvb; |
994 | 0 | unsigned total_trailer_length = eth_trailer_length; |
995 | | |
996 | | /* If we have to guess if the trailer includes the FCS, assume not; the |
997 | | * user probably set the "eth_trailer_length" preference to the total |
998 | | * trailer length. The user has already set the preference, so should |
999 | | * have little difficulty changing it or the "fcs" preference if need be. |
1000 | | */ |
1001 | 0 | total_trailer_length += (fcs_len < 0 ? 0 : (unsigned)fcs_len); |
1002 | | |
1003 | | /* Dissect the tvb up to, but not including the trailer */ |
1004 | 0 | next_tvb = tvb_new_subset_length_caplen(real_tvb, 0, |
1005 | 0 | tvb_captured_length(real_tvb) - total_trailer_length, |
1006 | 0 | tvb_reported_length(real_tvb) - total_trailer_length); |
1007 | 0 | fh_tree = dissect_eth_common(next_tvb, pinfo, tree, 0); |
1008 | | |
1009 | | /* Now handle the ethernet trailer and optional FCS */ |
1010 | 0 | next_tvb = tvb_new_subset_remaining(real_tvb, tvb_captured_length(real_tvb) - total_trailer_length); |
1011 | 0 | add_ethernet_trailer(pinfo, tree, fh_tree, hf_eth_trailer, real_tvb, next_tvb, |
1012 | 0 | fcs_len, ETH_HEADER_SIZE); |
1013 | 1 | } else { |
1014 | 1 | dissect_eth_common(real_tvb, pinfo, tree, fcs_len); |
1015 | 1 | } |
1016 | 1 | return tvb_captured_length(tvb); |
1017 | 1 | } |
1018 | | |
1019 | | /* Called by other dissectors This one's for encapsulated Ethernet |
1020 | | packets that don't include an FCS. */ |
1021 | | static int |
1022 | | dissect_eth_withoutfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
1023 | 23.9k | { |
1024 | 23.9k | dissect_eth_common(tvb, pinfo, tree, 0); |
1025 | 23.9k | return tvb_captured_length(tvb); |
1026 | 23.9k | } |
1027 | | |
1028 | | /* ...and this one's for encapsulated packets that do. */ |
1029 | | static int |
1030 | | dissect_eth_withfcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
1031 | 768 | { |
1032 | 768 | dissect_eth_common(tvb, pinfo, tree, 4); |
1033 | 768 | return tvb_captured_length(tvb); |
1034 | 768 | } |
1035 | | |
1036 | | /* ...and this one's for encapsulated packets that might or might not. */ |
1037 | | static int |
1038 | | dissect_eth_maybefcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
1039 | 1.31k | { |
1040 | 1.31k | dissect_eth_common(tvb, pinfo, tree, eth_fcs); |
1041 | 1.31k | return tvb_captured_length(tvb); |
1042 | 1.31k | } |
1043 | | |
1044 | | void |
1045 | | proto_register_eth(void) |
1046 | 14 | { |
1047 | 14 | register_init_routine(eth_init); |
1048 | | |
1049 | 14 | static hf_register_info hf[] = { |
1050 | | |
1051 | 14 | { &hf_eth_dst, |
1052 | 14 | { "Destination", "eth.dst", FT_ETHER, BASE_NONE, NULL, 0x0, |
1053 | 14 | "Destination Hardware Address", HFILL }}, |
1054 | | |
1055 | 14 | { &hf_eth_dst_resolved, |
1056 | 14 | { "Destination (resolved)", "eth.dst_resolved", FT_STRING, BASE_NONE, |
1057 | 14 | NULL, 0x0, "Destination Hardware Address (resolved)", HFILL }}, |
1058 | | |
1059 | 14 | { &hf_eth_dst_oui, |
1060 | 14 | { "Destination OUI", "eth.dst.oui", FT_UINT24, BASE_OUI, |
1061 | 14 | NULL, 0x0, "Destination Organizationally Unique Identifier", HFILL } }, |
1062 | | |
1063 | 14 | { &hf_eth_dst_oui_resolved, |
1064 | 14 | { "Destination OUI (resolved)", "eth.dst.oui_resolved", FT_STRING, BASE_NONE, |
1065 | 14 | NULL, 0x0, "Destination Organizationally Unique Identifier (resolved)", HFILL } }, |
1066 | | |
1067 | 14 | { &hf_eth_src, |
1068 | 14 | { "Source", "eth.src", FT_ETHER, BASE_NONE, NULL, 0x0, |
1069 | 14 | "Source Hardware Address", HFILL }}, |
1070 | | |
1071 | 14 | { &hf_eth_src_resolved, |
1072 | 14 | { "Source (resolved)", "eth.src_resolved", FT_STRING, BASE_NONE, |
1073 | 14 | NULL, 0x0, "Source Hardware Address (resolved)", HFILL }}, |
1074 | | |
1075 | | |
1076 | 14 | { &hf_eth_src_oui, |
1077 | 14 | { "Source OUI", "eth.src.oui", FT_UINT24, BASE_OUI, |
1078 | 14 | NULL, 0x0, "Source Organizationally Unique Identifier", HFILL } }, |
1079 | | |
1080 | 14 | { &hf_eth_src_oui_resolved, |
1081 | 14 | { "Source OUI (resolved)", "eth.src.oui_resolved", FT_STRING, BASE_NONE, |
1082 | 14 | NULL, 0x0, "Source Organizationally Unique Identifier (resolved)", HFILL } }, |
1083 | | |
1084 | 14 | { &hf_eth_len, |
1085 | 14 | { "Length", "eth.len", FT_UINT16, BASE_DEC, NULL, 0x0, |
1086 | 14 | NULL, HFILL }}, |
1087 | | |
1088 | | /* registered here but handled in packet-ethertype.c */ |
1089 | 14 | { &hf_eth_type, |
1090 | 14 | { "Type", "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, |
1091 | 14 | NULL, HFILL }}, |
1092 | | |
1093 | 14 | { &hf_eth_invalid_lentype, |
1094 | 14 | { "Invalid length/type", "eth.invalid_lentype", FT_UINT16, BASE_HEX_DEC, |
1095 | 14 | NULL, 0x0, NULL, HFILL }}, |
1096 | | |
1097 | 14 | { &hf_eth_addr, |
1098 | 14 | { "Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0, |
1099 | 14 | "Source or Destination Hardware Address", HFILL }}, |
1100 | | |
1101 | 14 | { &hf_eth_addr_resolved, |
1102 | 14 | { "Address (resolved)", "eth.addr_resolved", FT_STRING, BASE_NONE, |
1103 | 14 | NULL, 0x0, "Source or Destination Hardware Address (resolved)", |
1104 | 14 | HFILL }}, |
1105 | | |
1106 | 14 | { &hf_eth_addr_oui, |
1107 | 14 | { "Address OUI", "eth.addr.oui", FT_UINT24, BASE_OUI, |
1108 | 14 | NULL, 0x0, "Address Organizationally Unique Identifier", HFILL } }, |
1109 | | |
1110 | 14 | { &hf_eth_addr_oui_resolved, |
1111 | 14 | { "Address OUI (resolved)", "eth.addr.oui_resolved", FT_STRING, BASE_NONE, |
1112 | 14 | NULL, 0x0, "Address Organizationally Unique Identifier (resolved)", HFILL } }, |
1113 | | |
1114 | 14 | { &hf_eth_padding, |
1115 | 14 | { "Padding", "eth.padding", FT_BYTES, BASE_NONE, NULL, 0x0, |
1116 | 14 | "Ethernet Padding", HFILL }}, |
1117 | | |
1118 | 14 | { &hf_eth_trailer, |
1119 | 14 | { "Trailer", "eth.trailer", FT_BYTES, BASE_NONE, NULL, 0x0, |
1120 | 14 | "Ethernet Trailer or Checksum", HFILL }}, |
1121 | | |
1122 | 14 | { &hf_eth_fcs, |
1123 | 14 | { "Frame check sequence", "eth.fcs", FT_UINT32, BASE_HEX, NULL, 0x0, |
1124 | 14 | "Ethernet checksum", HFILL }}, |
1125 | | |
1126 | 14 | { &hf_eth_fcs_status, |
1127 | 14 | { "FCS Status", "eth.fcs.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, |
1128 | 14 | NULL, HFILL }}, |
1129 | | |
1130 | 14 | { &hf_eth_dst_lg, |
1131 | 14 | { "LG bit", "eth.dst.lg", FT_BOOLEAN, 24, |
1132 | 14 | TFS(&lg_tfs), 0x020000, |
1133 | 14 | "Specifies if this is a locally administered or globally unique (IEEE assigned) address", HFILL }}, |
1134 | | |
1135 | 14 | { &hf_eth_dst_ig, |
1136 | 14 | { "IG bit", "eth.dst.ig", FT_BOOLEAN, 24, |
1137 | 14 | TFS(&ig_tfs), 0x010000, |
1138 | 14 | "Specifies if this is an individual (unicast) or group (broadcast/multicast) address", HFILL }}, |
1139 | | |
1140 | 14 | { &hf_eth_src_lg, |
1141 | 14 | { "LG bit", "eth.src.lg", FT_BOOLEAN, 24, |
1142 | 14 | TFS(&lg_tfs), 0x020000, |
1143 | 14 | "Specifies if this is a locally administered or globally unique (IEEE assigned) address", HFILL }}, |
1144 | | |
1145 | 14 | { &hf_eth_src_ig, |
1146 | 14 | { "IG bit", "eth.src.ig", FT_BOOLEAN, 24, |
1147 | 14 | TFS(&ig_tfs), 0x010000, |
1148 | 14 | "Specifies if this is an individual (unicast) or group (broadcast/multicast) address", HFILL }}, |
1149 | | |
1150 | 14 | { &hf_eth_lg, |
1151 | 14 | { "LG bit", "eth.lg", FT_BOOLEAN, 24, |
1152 | 14 | TFS(&lg_tfs), 0x020000, |
1153 | 14 | "Specifies if this is a locally administered or globally unique (IEEE assigned) address", HFILL }}, |
1154 | | |
1155 | 14 | { &hf_eth_ig, |
1156 | 14 | { "IG bit", "eth.ig", FT_BOOLEAN, 24, |
1157 | 14 | TFS(&ig_tfs), 0x010000, |
1158 | 14 | "Specifies if this is an individual (unicast) or group (broadcast/multicast) address", HFILL }}, |
1159 | | |
1160 | 14 | { &hf_eth_stream, |
1161 | 14 | { "Stream index", "eth.stream", FT_UINT32, BASE_DEC, NULL, 0x0, |
1162 | 14 | NULL, HFILL }} |
1163 | 14 | }; |
1164 | 14 | static int *ett[] = { |
1165 | 14 | &ett_ieee8023, |
1166 | 14 | &ett_ether2, |
1167 | 14 | &ett_ether, |
1168 | 14 | &ett_addr, |
1169 | 14 | }; |
1170 | | |
1171 | 14 | static ei_register_info ei[] = { |
1172 | 14 | { &ei_eth_invalid_lentype, { "eth.invalid_lentype.expert", PI_PROTOCOL, PI_WARN, "Invalid length/type", EXPFILL }}, |
1173 | 14 | { &ei_eth_src_not_group, { "eth.src_not_group", PI_PROTOCOL, PI_WARN, "Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)", EXPFILL }}, |
1174 | 14 | { &ei_eth_fcs_bad, { "eth.fcs_bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }}, |
1175 | 14 | { &ei_eth_len, { "eth.len.past_end", PI_MALFORMED, PI_ERROR, "Length field value goes past the end of the payload", EXPFILL }}, |
1176 | 14 | { &ei_eth_padding_bad, {"eth.padding_bad", PI_PROTOCOL, PI_NOTE, "Padding identification may be inaccurate and impact trailer dissector", EXPFILL }}, |
1177 | 14 | }; |
1178 | | |
1179 | 14 | module_t *eth_module; |
1180 | 14 | expert_module_t* expert_eth; |
1181 | | |
1182 | 14 | proto_eth = proto_register_protocol("Ethernet", "Ethernet", "eth"); |
1183 | 14 | proto_register_field_array(proto_eth, hf, array_length(hf)); |
1184 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1185 | 14 | expert_eth = expert_register_protocol(proto_eth); |
1186 | 14 | expert_register_field_array(expert_eth, ei, array_length(ei)); |
1187 | | |
1188 | | /* subdissector code */ |
1189 | 14 | heur_subdissector_list = register_heur_dissector_list_with_description("eth", "Ethernet framed non-Ethernet data", proto_eth); |
1190 | 14 | eth_trailer_subdissector_list = register_heur_dissector_list_with_description("eth.trailer", "Ethernet trailer", proto_eth); |
1191 | | |
1192 | | /* Register configuration preferences */ |
1193 | 14 | eth_module = prefs_register_protocol(proto_eth, NULL); |
1194 | | |
1195 | 14 | prefs_register_obsolete_preference(eth_module, "assume_padding"); |
1196 | 14 | prefs_register_enum_preference(eth_module, "padding", |
1197 | 14 | "Assume padding for short frames with trailer", |
1198 | 14 | "Some devices add trailing data to frames. Depending on where this " |
1199 | 14 | "device exists in the network, padding could be added to short " |
1200 | 14 | "frames before the additional trailer. This option determines how " |
1201 | 14 | "that padding will be detected.\n\n" |
1202 | 14 | "Never - Don't detect any padding. Any bytes after the ethernet " |
1203 | 14 | "payload will be considered trailer.\n" |
1204 | 14 | "Zeros (default) - Consecutive bytes of zeros up to the minimum " |
1205 | 14 | "ethernet frame size will be treated as padding. Additional bytes will " |
1206 | 14 | "be considered trailer.\n" |
1207 | 14 | "Any - Any bytes after the payload up to the minimum ethernet frame " |
1208 | 14 | "size will be treated as padding. Additional bytes will be considered " |
1209 | 14 | "trailer.", |
1210 | 14 | ð_padding, eth_padding_vals, false); |
1211 | | |
1212 | 14 | prefs_register_uint_preference(eth_module, "trailer_length", |
1213 | 14 | "Fixed ethernet trailer length", |
1214 | 14 | "Some TAPs add a fixed length ethernet trailer at the end " |
1215 | 14 | "of the frame, but before the (optional) FCS. Make sure it " |
1216 | 14 | "gets interpreted correctly.", |
1217 | 14 | 10, ð_trailer_length); |
1218 | | |
1219 | 14 | prefs_register_obsolete_preference(eth_module, "assume_fcs"); |
1220 | 14 | prefs_register_enum_preference(eth_module, "fcs", |
1221 | 14 | "Assume packets have FCS", |
1222 | 14 | "Some Ethernet adapters and drivers include the FCS at the end of a packet, others do not. " |
1223 | 14 | "Some capture file formats and protocols do not indicate whether or not the FCS is included. " |
1224 | 14 | "The Ethernet dissector then attempts to guess whether a captured packet has an FCS, " |
1225 | 14 | "but it cannot always guess correctly. This option can override that heuristic " |
1226 | 14 | "and assume that the FCS is either never or always present in such cases.", |
1227 | 14 | ð_fcs, eth_fcs_vals, false); |
1228 | | |
1229 | 14 | prefs_register_bool_preference(eth_module, "check_fcs", |
1230 | 14 | "Validate the Ethernet checksum if possible", |
1231 | 14 | "Whether to validate the Frame Check Sequence", |
1232 | 14 | ð_check_fcs); |
1233 | | |
1234 | 14 | prefs_register_bool_preference(eth_module, "interpret_as_fw1_monitor", |
1235 | 14 | "Attempt to interpret as FireWall-1 monitor file", |
1236 | 14 | "Whether packets should be interpreted as coming from CheckPoint FireWall-1 monitor file if they look as if they do", |
1237 | 14 | ð_interpret_as_fw1_monitor); |
1238 | | |
1239 | 14 | prefs_register_bool_preference(eth_module, "deduplicate_dmac", |
1240 | 14 | "Skip bytes 1-6 if identical to 7-12", |
1241 | 14 | "When capturing on a Cisco FEX some frames start with an extra destination mac", |
1242 | 14 | ð_deduplicate_dmac); |
1243 | | |
1244 | 14 | prefs_register_static_text_preference(eth_module, "ccsds_heuristic", |
1245 | 14 | "Dissect as CCSDS if", |
1246 | 14 | "These are the conditions to match a payload against in order to determine if this\n" |
1247 | 14 | "is a CCSDS (Consultative Committee for Space Data Systems) packet within\n" |
1248 | 14 | "an 802.3 packet. A packet is considered as a possible CCSDS packet only if\n" |
1249 | 14 | "one or more of the conditions are checked."); |
1250 | | |
1251 | 14 | prefs_register_bool_preference(eth_module, "ccsds_heuristic_length", |
1252 | 14 | "CCSDS Length in header matches payload size", |
1253 | 14 | "Set the condition that must be true for the CCSDS dissector to be called", |
1254 | 14 | &ccsds_heuristic_length); |
1255 | | |
1256 | 14 | prefs_register_bool_preference(eth_module, "ccsds_heuristic_version", |
1257 | 14 | "CCSDS Version # is zero", |
1258 | 14 | "Set the condition that must be true for the CCSDS dissector to be called", |
1259 | 14 | &ccsds_heuristic_version); |
1260 | | |
1261 | 14 | prefs_register_bool_preference(eth_module, "ccsds_heuristic_header", |
1262 | 14 | "CCSDS Secondary Header Flag is set", |
1263 | 14 | "Set the condition that must be true for the CCSDS dissector to be called", |
1264 | 14 | &ccsds_heuristic_header); |
1265 | | |
1266 | 14 | prefs_register_bool_preference(eth_module, "ccsds_heuristic_bit", |
1267 | 14 | "CCSDS Spare bit is cleared", |
1268 | 14 | "Set the condition that must be true for the CCSDS dissector to be called", |
1269 | 14 | &ccsds_heuristic_bit); |
1270 | | |
1271 | 14 | eth_withoutfcs_handle = register_dissector("eth_withoutfcs", dissect_eth_withoutfcs, proto_eth); |
1272 | 14 | register_dissector("eth_withfcs", dissect_eth_withfcs, proto_eth); |
1273 | 14 | eth_maybefcs_handle = register_dissector("eth_maybefcs", dissect_eth_maybefcs, proto_eth); |
1274 | 14 | eth_tap = register_tap("eth"); |
1275 | | |
1276 | 14 | register_conversation_table(proto_eth, true, eth_conversation_packet, eth_endpoint_packet); |
1277 | 14 | register_conversation_filter("eth", "Ethernet", eth_filter_valid, eth_build_filter, NULL); |
1278 | | |
1279 | 14 | register_capture_dissector("eth", capture_eth, proto_eth); |
1280 | 14 | } |
1281 | | |
1282 | | void |
1283 | | proto_reg_handoff_eth(void) |
1284 | 14 | { |
1285 | 14 | dissector_handle_t eth_handle; |
1286 | 14 | capture_dissector_handle_t eth_cap_handle; |
1287 | | |
1288 | | /* Get a handle for the Firewall-1 dissector. */ |
1289 | 14 | fw1_handle = find_dissector_add_dependency("fw1", proto_eth); |
1290 | | |
1291 | | /* Get a handle for the ethertype dissector. */ |
1292 | 14 | ethertype_handle = find_dissector_add_dependency("ethertype", proto_eth); |
1293 | | |
1294 | 14 | eth_handle = create_dissector_handle(dissect_eth, proto_eth); |
1295 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_handle); |
1296 | | /* This needs a different (& more user-friendly) name than the other tap */ |
1297 | 14 | exported_pdu_tap = register_export_pdu_tap_with_encap("Ethernet", WTAP_ENCAP_ETHERNET); |
1298 | | |
1299 | 14 | dissector_add_uint("ethertype", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle); |
1300 | | |
1301 | 14 | dissector_add_uint("erf.types.type", ERF_TYPE_ETH, eth_maybefcs_handle); |
1302 | 14 | dissector_add_uint("erf.types.type", ERF_TYPE_COLOR_ETH, eth_maybefcs_handle); |
1303 | 14 | dissector_add_uint("erf.types.type", ERF_TYPE_DSM_COLOR_ETH, eth_maybefcs_handle); |
1304 | 14 | dissector_add_uint("erf.types.type", ERF_TYPE_COLOR_HASH_ETH, eth_maybefcs_handle); |
1305 | 14 | dissector_add_uint("ip.proto", IP_PROTO_ETHERNET, eth_maybefcs_handle); |
1306 | | |
1307 | 14 | dissector_add_uint("chdlc.protocol", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle); |
1308 | 14 | dissector_add_for_decode_as("gre.subproto", eth_withoutfcs_handle); |
1309 | 14 | dissector_add_uint("gre.proto", ETHERTYPE_ETHBRIDGE, eth_withoutfcs_handle); |
1310 | 14 | dissector_add_uint("gre.proto", GRE_MIKROTIK_EOIP, eth_withoutfcs_handle); |
1311 | 14 | dissector_add_uint("juniper.proto", JUNIPER_PROTO_ETHER, eth_withoutfcs_handle); |
1312 | 14 | dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_ETHERNET, eth_withoutfcs_handle); |
1313 | 14 | dissector_add_uint("l2tp.pw_type", L2TPv3_PW_ETH, eth_withoutfcs_handle); |
1314 | 14 | dissector_add_uint("vxlan.next_proto", VXLAN_ETHERNET, eth_withoutfcs_handle); |
1315 | 14 | dissector_add_uint("sll.ltype", LINUX_SLL_P_ETHERNET, eth_withoutfcs_handle); |
1316 | 14 | dissector_add_uint("nsh.next_proto", NSH_ETHERNET, eth_withoutfcs_handle); |
1317 | | |
1318 | 14 | dissector_add_uint("acdr.media_type", ACDR_Control, eth_withoutfcs_handle); |
1319 | 14 | dissector_add_uint("acdr.media_type", ACDR_DSP_SNIFFER, eth_withoutfcs_handle); |
1320 | 14 | dissector_add_uint("mctp.encap-type", MCTP_TYPE_ETHERNET, eth_withoutfcs_handle); |
1321 | | |
1322 | | /* |
1323 | | * This is to handle the output for the Cisco CMTS "cable intercept" |
1324 | | * command - it encapsulates Ethernet frames in UDP packets, but |
1325 | | * the UDP port is user-defined. |
1326 | | */ |
1327 | 14 | dissector_add_for_decode_as_with_preference("udp.port", eth_withoutfcs_handle); |
1328 | | |
1329 | 14 | dissector_add_for_decode_as("pcli.payload", eth_withoutfcs_handle); |
1330 | | |
1331 | 14 | eth_cap_handle = find_capture_dissector("eth"); |
1332 | 14 | capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_ETHERNET, eth_cap_handle); |
1333 | 14 | capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_3, eth_cap_handle); |
1334 | 14 | capture_dissector_add_uint("atm_lane", TRAF_ST_LANE_802_3_MC, eth_cap_handle); |
1335 | 14 | capture_dissector_add_uint("ppi", 1 /* DLT_EN10MB */, eth_cap_handle); |
1336 | 14 | capture_dissector_add_uint("sll.ltype", LINUX_SLL_P_ETHERNET, eth_cap_handle); |
1337 | | |
1338 | 14 | isl_cap_handle = find_capture_dissector("isl"); |
1339 | 14 | ipx_cap_handle = find_capture_dissector("ipx"); |
1340 | 14 | llc_cap_handle = find_capture_dissector("llc"); |
1341 | 14 | } |
1342 | | |
1343 | | /* |
1344 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
1345 | | * |
1346 | | * Local Variables: |
1347 | | * c-basic-offset: 2 |
1348 | | * tab-width: 8 |
1349 | | * indent-tabs-mode: nil |
1350 | | * End: |
1351 | | * |
1352 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
1353 | | * :indentSize=2:tabSize=8:noTabs=true: |
1354 | | */ |