2 * Routines for Arbor Networks E100 packet encapsulation disassembly
6 * Copyright (c) 2009 by Bradley Higgins <bhiggins@arbor.net>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1999 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.
29 #include <epan/packet.h>
31 void proto_register_e100(void);
32 void proto_reg_handoff_e100(void);
34 static int proto_e100
= -1;
36 static dissector_handle_t eth_handle
;
38 /* Dissector tree globals */
39 static int hf_e100_header
= -1;
40 static int hf_e100_port
= -1;
41 static int hf_e100_seq
= -1;
42 static int hf_e100_ip
= -1;
43 static int hf_e100_mon_pkt_id
= -1;
44 static int hf_e100_pkt_ts
= -1;
45 static int hf_e100_bytes_cap
= -1;
46 static int hf_e100_bytes_orig
= -1;
48 static gint ett_e100
= -1;
50 /* E100 encapsulated packet offsets */
51 typedef struct _e100_encap
57 static e100_encap e100_header_ver
= {0, 1};
58 static e100_encap e100_port_recv
= {1, 1};
59 static e100_encap e100_seq
= {2, 2};
60 static e100_encap e100_ip
= {4, 4};
61 static e100_encap e100_mon_pkt_id
= {8, 4};
62 static e100_encap e100_ts
= {12, 8};
63 static e100_encap e100_bytes_cap
= {20, 4};
64 static e100_encap e100_bytes_orig
= {24, 4};
65 static guint e100_encap_len
= 28;
69 dissect_e100(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
72 tvbuff_t
*next_tvb
= NULL
;
75 * (1) tvb packet is larger than e100 packet
76 * (2) e100 header is 1
77 * (3) e100 capture size matches tvb packet size
79 if (tvb_length(tvb
) >= e100_encap_len
&&
80 tvb_get_guint8(tvb
, e100_header_ver
.offset
) == 1 &&
81 tvb_get_ntohl(tvb
, e100_bytes_cap
.offset
) == tvb_length(tvb
)-e100_encap_len
)
83 guint32 bytes_captured
=0;
84 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "e100");
85 col_set_str(pinfo
->cinfo
, COL_INFO
, "E100 Encapsulated Packet");
88 /* pick apart protocol for display */
89 proto_item
*ti
= NULL
;
90 proto_tree
*e100_tree
= NULL
;
92 ti
= proto_tree_add_item(tree
, proto_e100
, tvb
, 0, e100_encap_len
, ENC_NA
);
93 e100_tree
= proto_item_add_subtree(ti
, ett_e100
);
95 proto_tree_add_item(e100_tree
, hf_e100_header
, tvb
,
96 e100_header_ver
.offset
, e100_header_ver
.len
, ENC_BIG_ENDIAN
);
97 proto_tree_add_item(e100_tree
, hf_e100_port
, tvb
,
98 e100_port_recv
.offset
, e100_port_recv
.len
, ENC_BIG_ENDIAN
);
99 proto_tree_add_item(e100_tree
, hf_e100_seq
, tvb
,
100 e100_seq
.offset
, e100_seq
.len
, ENC_BIG_ENDIAN
);
101 proto_tree_add_item(e100_tree
, hf_e100_ip
, tvb
,
102 e100_ip
.offset
, e100_ip
.len
, ENC_BIG_ENDIAN
);
103 proto_tree_add_item(e100_tree
, hf_e100_mon_pkt_id
, tvb
,
104 e100_mon_pkt_id
.offset
, e100_mon_pkt_id
.len
, ENC_BIG_ENDIAN
);
107 ts
.secs
= tvb_get_ntohl(tvb
, e100_ts
.offset
);
108 ts
.nsecs
= tvb_get_ntohl(tvb
, e100_ts
.offset
+4)*1000;
109 proto_tree_add_time(e100_tree
, hf_e100_pkt_ts
, tvb
,
110 e100_ts
.offset
, e100_ts
.len
, &ts
);
112 proto_tree_add_item(e100_tree
, hf_e100_bytes_cap
, tvb
,
113 e100_bytes_cap
.offset
, e100_bytes_cap
.len
, ENC_BIG_ENDIAN
);
114 proto_tree_add_item(e100_tree
, hf_e100_bytes_orig
, tvb
,
115 e100_bytes_orig
.offset
, e100_bytes_orig
.len
, ENC_BIG_ENDIAN
);
118 bytes_captured
= tvb_get_ntohl(tvb
, e100_bytes_cap
.offset
);
119 next_tvb
= tvb_new_subset(tvb
, e100_encap_len
, -1, bytes_captured
);
120 call_dissector(eth_handle
, next_tvb
, pinfo
, tree
);
122 ret_val
= tvb_length(tvb
);
123 } /* heuristic testing */
129 proto_register_e100(void)
131 static hf_register_info hf
[] =
138 NULL
, 0x0, NULL
, HFILL
142 { "E100 Port Received",
146 NULL
, 0x0, NULL
, HFILL
154 NULL
, 0x0, NULL
, HFILL
162 NULL
, 0x0, NULL
, HFILL
165 { &hf_e100_mon_pkt_id
,
166 { "Monitor Packet ID",
170 NULL
, 0x0, NULL
, HFILL
174 { "Packet Capture Timestamp",
178 NULL
, 0x0, NULL
, HFILL
181 { &hf_e100_bytes_cap
,
186 NULL
, 0x0, NULL
, HFILL
189 { &hf_e100_bytes_orig
,
190 { "Bytes in Original Packet",
194 NULL
, 0x0, NULL
, HFILL
199 /* Setup protocol subtree array */
205 proto_e100
= proto_register_protocol("E100 Encapsulation", "E100", "e100");
206 proto_register_field_array(proto_e100
, hf
, array_length(hf
));
207 proto_register_subtree_array(ett
, array_length(ett
));
211 proto_reg_handoff_e100(void)
213 /* Check all UDP traffic, as the specific UDP port is configurable */
214 heur_dissector_add("udp", dissect_e100
, proto_e100
);
215 /* e100 traffic encapsulates traffic from the ethernet frame on */
216 eth_handle
= find_dissector("eth");