2 * Routines for ISO/OSI End System to Intermediate System
3 * Routing Exchange Protocol ISO 9542.
5 * Ralf Schneider <Ralf.Schneider@t-online.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/expert.h>
30 #include <epan/nlpid.h>
31 #include "packet-osi.h"
32 #include "packet-osi-options.h"
34 /* The version we support is 1 */
35 #define ESIS_REQUIRED_VERSION 1
38 #define ESIS_ESH_PDU 02
39 #define ESIS_ISH_PDU 04
40 #define ESIS_RD_PDU 06
42 /* The length of the fixed part */
43 #define ESIS_HDR_FIXED_LENGTH 9
45 void proto_register_esis(void);
46 void proto_reg_handoff_esis(void);
48 /* esis base header */
49 static int proto_esis = -1;
51 static int hf_esis_nlpi = -1;
52 static int hf_esis_length = -1;
53 static int hf_esis_version = -1;
54 static int hf_esis_reserved = -1;
55 static int hf_esis_type = -1;
56 static int hf_esis_holdtime = -1;
57 static int hf_esis_checksum = -1;
58 static int hf_esis_checksum_status = -1;
59 /* Generated from convert_proto_tree_add_text.pl */
60 static int hf_esis_dal = -1;
61 static int hf_esis_number_of_source_addresses = -1;
62 static int hf_esis_netl = -1;
63 static int hf_esis_sal = -1;
64 static int hf_esis_sa = -1;
65 static int hf_esis_bsnpal = -1;
66 static int hf_esis_net = -1;
67 static int hf_esis_da = -1;
68 static int hf_esis_bsnpa = -1;
70 static gint ett_esis = -1;
71 static gint ett_esis_area_addr = -1;
72 static gint ett_esis_network = -1;
73 static gint ett_esis_dest_addr = -1;
74 static gint ett_esis_subnetwork = -1;
77 static expert_field ei_esis_version = EI_INIT;
78 static expert_field ei_esis_length = EI_INIT;
79 static expert_field ei_esis_type = EI_INIT;
80 static expert_field ei_esis_checksum = EI_INIT;
82 static const value_string esis_vals[] = {
83 { ESIS_ESH_PDU, "ES HELLO"},
84 { ESIS_ISH_PDU, "IS HELLO"},
85 { ESIS_RD_PDU, "RD REQUEST"},
88 /* ################## Descriptions ###########################################*/
89 /* Parameters for the ESH PDU
90 * Source Address Parameter:
92 * Octet: Length: Parameter Type:
93 * 10 1 Number of Source Addresses ( NSAPs served by this Network
94 * 11 1 Source Address Length Indicator ( SAL ) # Entity )
95 * 12-m-1 variable Source Address ( NSAP )
96 * m Options, dissected in osi.c
99 * Parameter for the ISH PDU:
100 * Network Entity Title Parameter:
102 * Octet: Length: Parameter Type:
103 * 10 1 Network Entity Title Length Indicator ( NETL )
104 * 11-m-1 variable Network Entity Title ( NET )
105 * m Options, dissected in osi.c
108 * Parameter for the RD PDU:
109 * When re-directed to an IS:
111 * Octet: Length: Parameter Type:
112 * 10 1 Destination Address Length Indicator ( DAL )
113 * 11>m-1 variable Destination Address ( DA )
114 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
115 * m+1>n-1 variable Subnetwork Address ( BSNPA )
116 * n 1 Network Entity Title Length Indicator ( NETL )
117 * n+1>p-1 variable Network Entity Title ( NET )
118 * p Options, dissected in osi.c
121 * Parameter for the RD PDU:
122 * When re-directed to an ES:
124 * Octet: Length: Parameter Type:
125 * 10 1 Destination Address Length Indicator ( DAL )
126 * 11>m-1 variable Destination Address ( DA )
127 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
128 * m+1>n-1 variable Subnetwork Address ( BSNPA )
129 * n 1 Network Entity Title Length Indicator ( NETL ) == 0
130 * n+1 Options, dissected in osi.c
134 /* ############################ Tool Functions ############################## */
138 esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo) {
139 proto_tree *esis_area_tree;
146 offset += ESIS_HDR_FIXED_LENGTH;
148 no_sa = tvb_get_guint8(tvb, offset);
151 ti = proto_tree_add_uint( tree, hf_esis_number_of_source_addresses, tvb, offset, 1, no_sa);
154 esis_area_tree = proto_item_add_subtree( ti, ett_esis_area_addr );
155 while ( no_sa-- > 0 ) {
156 sal = (int) tvb_get_guint8(tvb, offset);
157 proto_tree_add_uint_format_value(esis_area_tree, hf_esis_sal, tvb, offset, 1, sal, "%2u Octets", sal);
159 proto_tree_add_string(esis_area_tree, hf_esis_sa, tvb, offset, sal, print_nsap_net(tvb, offset, sal ) );
163 dissect_osi_options( len, tvb, offset, tree, pinfo );
165 } /* esis_dissect_esh_pdu */
168 esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo) {
172 proto_tree* network_tree;
174 offset += ESIS_HDR_FIXED_LENGTH;
176 netl = (int) tvb_get_guint8(tvb, offset);
177 network_tree = proto_tree_add_subtree( tree, tvb, offset, netl + 1, ett_esis_network, NULL,
178 "### Network Entity Title Section ###");
179 proto_tree_add_uint_format_value(network_tree, hf_esis_netl, tvb, offset++, 1, netl, "%2u Octets", netl);
180 proto_tree_add_string(network_tree, hf_esis_net, tvb, offset, netl, print_nsap_net( tvb, offset, netl ) );
184 dissect_osi_options( len, tvb, offset, network_tree, pinfo );
188 esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo) {
192 proto_tree *dest_tree, *subnet_tree, *network_tree;
194 offset += ESIS_HDR_FIXED_LENGTH;
196 tmpl = (int) tvb_get_guint8(tvb, offset);
197 dest_tree = proto_tree_add_subtree( tree, tvb, offset, tmpl + 1, ett_esis_dest_addr, NULL,
198 "### Destination Address Section ###" );
199 proto_tree_add_uint_format_value(dest_tree, hf_esis_dal, tvb, offset++, 1, tmpl, "%2u Octets", tmpl);
200 proto_tree_add_string( dest_tree, hf_esis_da, tvb, offset, tmpl,
201 print_nsap_net( tvb, offset, tmpl ) );
204 tmpl = (int) tvb_get_guint8(tvb, offset);
206 subnet_tree = proto_tree_add_subtree( tree, tvb, offset, tmpl + 1, ett_esis_subnetwork, NULL,
207 "### Subnetwork Address Section ###");
208 proto_tree_add_uint_format_value(subnet_tree, hf_esis_bsnpal, tvb, offset++, 1, tmpl, "%2u Octets", tmpl);
209 proto_tree_add_item(subnet_tree, hf_esis_bsnpa, tvb, offset, tmpl, ENC_NA);
212 tmpl = (int) tvb_get_guint8(tvb, offset);
215 network_tree = proto_tree_add_subtree( tree, tvb, offset, 1, ett_esis_network, NULL,
216 "### No Network Entity Title Section ###" );
221 network_tree = proto_tree_add_subtree( tree, tvb, offset, 1, ett_esis_network, NULL,
222 "### Network Entity Title Section ###" );
223 proto_tree_add_uint_format_value(network_tree, hf_esis_netl, tvb, offset++, 1, tmpl, "%2u Octets", tmpl );
224 proto_tree_add_string( network_tree, hf_esis_net, tvb, offset, tmpl,
225 print_nsap_net( tvb, offset, tmpl ) );
229 dissect_osi_options( len, tvb, offset, network_tree, pinfo );
234 * Name: dissect_esis()
237 * Main entry area for esis de-mangling. This will build the
238 * main esis tree data and call the sub-protocols as needed.
241 * tvbuff * : tvbuff referring to packet data
242 * packet_info * : info for current packet
243 * proto_tree * : tree of display data. May be NULL.
246 * void, but we will add to the proto_tree if it is not NULL.
249 dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
250 guint8 version, length;
251 proto_item *ti, *type_item;
252 proto_tree *esis_tree = NULL;
253 guint8 variable_len, type;
254 guint16 holdtime, checksum;
256 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
257 col_clear(pinfo->cinfo, COL_INFO);
259 ti = proto_tree_add_item(tree, proto_esis, tvb, 0, -1, ENC_NA);
260 esis_tree = proto_item_add_subtree(ti, ett_esis);
262 proto_tree_add_item( esis_tree, hf_esis_nlpi, tvb, 0, 1, ENC_BIG_ENDIAN);
263 ti = proto_tree_add_item( esis_tree, hf_esis_length, tvb, 1, 1, ENC_BIG_ENDIAN );
264 length = tvb_get_guint8(tvb, 1);
265 if (length < ESIS_HDR_FIXED_LENGTH) {
266 expert_add_info_format(pinfo, ti, &ei_esis_length,
267 "Bogus ESIS length (%u, must be >= %u)",
268 length, ESIS_HDR_FIXED_LENGTH );
271 version = tvb_get_guint8(tvb, 2);
272 ti = proto_tree_add_item( esis_tree, hf_esis_version, tvb, 2, 1, ENC_BIG_ENDIAN);
273 if (version != ESIS_REQUIRED_VERSION){
274 expert_add_info_format(pinfo, ti, &ei_esis_version,
275 "Unknown ESIS version (%u vs %u)",
276 version, ESIS_REQUIRED_VERSION );
279 proto_tree_add_item( esis_tree, hf_esis_reserved, tvb, 3, 1, ENC_BIG_ENDIAN);
281 type_item = proto_tree_add_item( esis_tree, hf_esis_type, tvb, 4, 1, ENC_BIG_ENDIAN);
282 type = tvb_get_guint8(tvb, 4) & OSI_PDU_TYPE_MASK;
284 holdtime = tvb_get_ntohs(tvb, 5);
285 proto_tree_add_uint_format_value(esis_tree, hf_esis_holdtime, tvb, 5, 2,
286 holdtime, "%u seconds", holdtime);
288 checksum = tvb_get_ntohs(tvb, 7);
290 /* No checksum present */
291 proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
293 guint32 c0 = 0, c1 = 0;
295 if (osi_calc_checksum(tvb, 0, length, &c0, &c1)) {
296 /* Successfully processed checksum, verify it */
297 proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, hf_esis_checksum_status, &ei_esis_checksum, pinfo, c0 | c1, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
299 proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, hf_esis_checksum_status, &ei_esis_checksum, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
304 * Let us make sure we use the same names for all our decodes
305 * here. First, dump the name into info column, and THEN
306 * dispatch the sub-type.
308 col_add_str(pinfo->cinfo, COL_INFO,
309 val_to_str( type, esis_vals,
310 "Unknown (0x%x)" ) );
312 variable_len = length - ESIS_HDR_FIXED_LENGTH;
316 esis_dissect_esh_pdu( variable_len, tvb, esis_tree, pinfo);
319 esis_dissect_ish_pdu( variable_len, tvb, esis_tree, pinfo);
322 esis_dissect_redirect_pdu( variable_len, tvb, esis_tree, pinfo);
325 expert_add_info(pinfo, type_item, &ei_esis_type);
327 return tvb_captured_length(tvb);
332 * Name: proto_register_esis()
335 * main register for esis protocol set. We register some display
336 * formats and the protocol module variables.
338 * NOTE: this procedure to autolinked by the makefile process that
348 proto_register_esis(void) {
349 static hf_register_info hf[] = {
351 { "Network Layer Protocol Identifier", "esis.nlpi",
352 FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, NULL, HFILL }},
355 { "PDU Length", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
358 { "Version", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
361 { "Reserved(==0)", "esis.res", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
364 { "PDU Type", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals), OSI_PDU_TYPE_MASK, NULL, HFILL }},
367 { "Holding Time", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, "s", HFILL }},
370 { "Checksum", "esis.chksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
372 { &hf_esis_checksum_status,
373 { "Checksum Status", "esis.chksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
375 /* Generated from convert_proto_tree_add_text.pl */
376 { &hf_esis_number_of_source_addresses, { "Number of Source Addresses (SA, Format: NSAP)", "esis.number_of_source_addresses", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
377 { &hf_esis_sal, { "SAL", "esis.sal", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
378 { &hf_esis_sa, { "SA", "esis.sa", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
379 { &hf_esis_netl, { "NETL", "esis.netl", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
380 { &hf_esis_dal, { "DAL", "esis.dal", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
381 { &hf_esis_bsnpal, { "BSNPAL", "esis.bsnpal", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
382 { &hf_esis_net, { "NET", "esis.net", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
383 { &hf_esis_da, { "DA", "esis.da", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
384 { &hf_esis_bsnpa, { "BSNPA", "esis.bsnpa", FT_SYSTEM_ID, BASE_NONE, NULL, 0x0, NULL, HFILL }},
387 static gint *ett[] = {
395 static ei_register_info ei[] = {
396 { &ei_esis_version, { "esis.ver.unknown", PI_PROTOCOL, PI_WARN, "Unknown ESIS version", EXPFILL }},
397 { &ei_esis_length, { "esis.length.invalid", PI_MALFORMED, PI_ERROR, "Bogus ESIS length", EXPFILL }},
398 { &ei_esis_type, { "esis.type.unknown", PI_PROTOCOL, PI_WARN, "Unknown ESIS packet type", EXPFILL }},
399 { &ei_esis_checksum, { "esis.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
402 expert_module_t* expert_esis;
404 proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
405 proto_register_field_array(proto_esis, hf, array_length(hf));
406 proto_register_subtree_array(ett, array_length(ett));
407 expert_esis = expert_register_protocol(proto_esis);
408 expert_register_field_array(expert_esis, ei, array_length(ei));
409 register_dissector("esis", dissect_esis, proto_esis);
413 proto_reg_handoff_esis(void)
415 dissector_handle_t esis_handle;
417 esis_handle = find_dissector("esis");
418 dissector_add_uint("osinl.incl", NLPID_ISO9542_ESIS, esis_handle);
422 * Editor modelines - http://www.wireshark.org/tools/modelines.html
427 * indent-tabs-mode: nil
430 * ex: set shiftwidth=2 tabstop=8 expandtab:
431 * :indentSize=2:tabSize=8:noTabs=true: