2 * Routines for Arbor Networks E100 packet encapsulation disassembly
4 * Copyright (c) 2009 by Bradley Higgins <bhiggins@arbor.net>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1999 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
17 void proto_register_e100(void);
18 void proto_reg_handoff_e100(void);
20 static int proto_e100
;
22 static dissector_handle_t eth_handle
;
24 /* Dissector tree globals */
25 static int hf_e100_header
;
26 static int hf_e100_port
;
27 static int hf_e100_seq
;
28 static int hf_e100_ip
;
29 static int hf_e100_mon_pkt_id
;
30 static int hf_e100_pkt_ts
;
31 static int hf_e100_bytes_cap
;
32 static int hf_e100_bytes_orig
;
36 /* E100 encapsulated packet offsets */
37 typedef struct _e100_encap
43 static e100_encap e100_header_ver
= {0, 1};
44 static e100_encap e100_port_recv
= {1, 1};
45 static e100_encap e100_seq
= {2, 2};
46 static e100_encap e100_ip
= {4, 4};
47 static e100_encap e100_mon_pkt_id
= {8, 4};
48 static e100_encap e100_ts
= {12, 8};
49 static e100_encap e100_bytes_cap
= {20, 4};
50 static e100_encap e100_bytes_orig
= {24, 4};
51 static unsigned e100_encap_len
= 28;
55 dissect_e100(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
58 uint32_t bytes_captured
;
59 uint32_t bytes_original
;
61 proto_tree
*e100_tree
;
64 * (1) tvb packet is larger than e100 packet
65 * (2) e100 header is 1
66 * (3) e100 capture size matches tvb packet size
68 if (tvb_captured_length(tvb
) < e100_encap_len
||
69 tvb_get_uint8(tvb
, e100_header_ver
.offset
) != 1 ||
70 tvb_get_ntohl(tvb
, e100_bytes_cap
.offset
) != tvb_reported_length(tvb
)-e100_encap_len
)
72 /* Not one of our packets. */
76 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "e100");
77 col_set_str(pinfo
->cinfo
, COL_INFO
, "E100 Encapsulated Packet");
79 ti
= proto_tree_add_item(tree
, proto_e100
, tvb
, 0, e100_encap_len
, ENC_NA
);
80 e100_tree
= proto_item_add_subtree(ti
, ett_e100
);
82 proto_tree_add_item(e100_tree
, hf_e100_header
, tvb
,
83 e100_header_ver
.offset
, e100_header_ver
.len
, ENC_BIG_ENDIAN
);
84 proto_tree_add_item(e100_tree
, hf_e100_port
, tvb
,
85 e100_port_recv
.offset
, e100_port_recv
.len
, ENC_BIG_ENDIAN
);
86 proto_tree_add_item(e100_tree
, hf_e100_seq
, tvb
,
87 e100_seq
.offset
, e100_seq
.len
, ENC_BIG_ENDIAN
);
88 proto_tree_add_item(e100_tree
, hf_e100_ip
, tvb
,
89 e100_ip
.offset
, e100_ip
.len
, ENC_BIG_ENDIAN
);
90 proto_tree_add_item(e100_tree
, hf_e100_mon_pkt_id
, tvb
,
91 e100_mon_pkt_id
.offset
, e100_mon_pkt_id
.len
, ENC_BIG_ENDIAN
);
92 proto_tree_add_item(e100_tree
, hf_e100_pkt_ts
, tvb
,
93 e100_ts
.offset
, e100_ts
.len
, ENC_TIME_SECS_USECS
|ENC_BIG_ENDIAN
);
94 proto_tree_add_item_ret_uint(e100_tree
, hf_e100_bytes_cap
, tvb
,
95 e100_bytes_cap
.offset
, e100_bytes_cap
.len
, ENC_BIG_ENDIAN
,
97 proto_tree_add_item_ret_uint(e100_tree
, hf_e100_bytes_orig
, tvb
,
98 e100_bytes_orig
.offset
, e100_bytes_orig
.len
, ENC_BIG_ENDIAN
,
101 next_tvb
= tvb_new_subset_length_caplen(tvb
, e100_encap_len
,
102 bytes_captured
, bytes_original
);
103 call_dissector(eth_handle
, next_tvb
, pinfo
, tree
);
105 return tvb_captured_length(tvb
);
109 dissect_e100_heur(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
111 return dissect_e100(tvb
, pinfo
, tree
, data
) > 0;
115 proto_register_e100(void)
117 static hf_register_info hf
[] =
124 NULL
, 0x0, NULL
, HFILL
128 { "E100 Port Received",
132 NULL
, 0x0, NULL
, HFILL
140 NULL
, 0x0, NULL
, HFILL
148 NULL
, 0x0, NULL
, HFILL
151 { &hf_e100_mon_pkt_id
,
152 { "Monitor Packet ID",
156 NULL
, 0x0, NULL
, HFILL
160 { "Packet Capture Timestamp",
164 NULL
, 0x0, NULL
, HFILL
167 { &hf_e100_bytes_cap
,
172 NULL
, 0x0, NULL
, HFILL
175 { &hf_e100_bytes_orig
,
176 { "Bytes in Original Packet",
180 NULL
, 0x0, NULL
, HFILL
185 /* Setup protocol subtree array */
191 proto_e100
= proto_register_protocol("E100 Encapsulation", "E100", "e100");
192 proto_register_field_array(proto_e100
, hf
, array_length(hf
));
193 proto_register_subtree_array(ett
, array_length(ett
));
197 proto_reg_handoff_e100(void)
199 /* Check all UDP traffic, as the specific UDP port is configurable */
200 heur_dissector_add("udp", dissect_e100_heur
, "E100 over UDP", "e100_udp", proto_e100
, HEURISTIC_ENABLE
);
201 /* e100 traffic encapsulates traffic from the ethernet frame on */
202 eth_handle
= find_dissector_add_dependency("eth_withoutfcs", proto_e100
);
206 * Editor modelines - https://www.wireshark.org/tools/modelines.html
211 * indent-tabs-mode: nil
214 * vi: set shiftwidth=4 tabstop=8 expandtab:
215 * :indentSize=4:tabSize=8:noTabs=true: