2 * Routines for ISO/OSI End System to Intermediate System
3 * Routing Exchange Protocol ISO 9542.
6 * Ralf Schneider <Ralf.Schneider@t-online.de>
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.
30 #include <epan/packet.h>
31 #include <epan/nlpid.h>
32 #include "packet-osi.h"
33 #include "packet-osi-options.h"
34 #include "packet-esis.h"
37 /* esis base header */
38 static int proto_esis = -1;
40 static int hf_esis_nlpi = -1;
41 static int hf_esis_length = -1;
42 static int hf_esis_version = -1;
43 static int hf_esis_reserved = -1;
44 static int hf_esis_type = -1;
45 static int hf_esis_holdtime = -1;
46 static int hf_esis_checksum = -1;
48 static gint ett_esis = -1;
49 static gint ett_esis_area_addr = -1;
51 static const value_string esis_vals[] = {
52 { ESIS_ESH_PDU, "ES HELLO"},
53 { ESIS_ISH_PDU, "IS HELLO"},
54 { ESIS_RD_PDU, "RD REQUEST"},
57 /* internal prototypes */
59 static void esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb,
61 static void esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb,
63 static void esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb,
66 /* ################## Descriptions ###########################################*/
67 /* Parameters for the ESH PDU
68 * Source Address Parameter:
70 * Octet: Length: Parameter Type:
71 * 10 1 Number of Source Addresses ( NSAPs served by this Network
72 * 11 1 Source Address Length Indicator ( SAL ) # Entity )
73 * 12-m-1 variable Source Address ( NSAP )
74 * m Options, dissected in osi.c
77 * Parameter for the ISH PDU:
78 * Network Entity Title Parameter:
80 * Octet: Length: Parameter Type:
81 * 10 1 Network Entity Title Length Indicator ( NETL )
82 * 11-m-1 variable Network Entity Title ( NET )
83 * m Options, dissected in osi.c
86 * Parameter for the RD PDU:
87 * When re-directed to an IS:
89 * Octet: Length: Parameter Type:
90 * 10 1 Destination Address Length Indicator ( DAL )
91 * 11>m-1 variable Destination Address ( DA )
92 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
93 * m+1>n-1 variable Subnetwork Address ( BSNPA )
94 * n 1 Network Entity Title Length Indicator ( NETL )
95 * n+1>p-1 variable Network Entity Title ( NET )
96 * p Options, dissected in osi.c
99 * Parameter for the RD PDU:
100 * When re-directed to an ES:
102 * Octet: Length: Parameter Type:
103 * 10 1 Destination Address Length Indicator ( DAL )
104 * 11>m-1 variable Destination Address ( DA )
105 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
106 * m+1>n-1 variable Subnetwork Address ( BSNPA )
107 * n 1 Network Entity Title Length Indicator ( NETL ) == 0
108 * n+1 Options, dissected in osi.c
112 /* ############################ Tool Functions ############################## */
115 /* ############################## Dissection Functions ###################### */
117 * Name: dissect_esis_unknown()
120 * There was some error in the protocol and we are in unknown space
121 * here. Add a tree item to cover the error and go on. Note
122 * that we make sure we don't go off the end of the bleedin packet here!
124 * This is just a copy of isis.c and isis.h, so I keep the stuff also
125 * and adapt the names to cover possible protocol errors! Ive really no
126 * idea whether I need this or not.
129 * tvbuff_t * : tvbuff with packet data.
130 * proto_tree * : tree of display data. May be NULL.
131 * char * : format text
132 * subsequent args : arguments to format
135 * void (may modify proto tree)
138 esis_dissect_unknown( tvbuff_t *tvb, proto_tree *tree, const char *fmat, ...){
142 proto_tree_add_text_valist(tree, tvb, 0, -1, fmat, ap);
148 esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
149 proto_tree *esis_area_tree;
157 offset += ESIS_HDR_FIXED_LENGTH;
159 no_sa = tvb_get_guint8(tvb, offset);
162 ti = proto_tree_add_text( tree, tvb, offset, -1,
163 "Number of Source Addresses (SA, Format: NSAP) : %u", no_sa );
166 esis_area_tree = proto_item_add_subtree( ti, ett_esis_area_addr );
167 while ( no_sa-- > 0 ) {
168 sal = (int) tvb_get_guint8(tvb, offset);
169 proto_tree_add_text(esis_area_tree, tvb, offset, 1, "SAL: %2u Octets", sal);
171 proto_tree_add_text(esis_area_tree, tvb, offset, sal,
173 print_nsap_net( tvb_get_ptr(tvb, offset, sal), sal ) );
177 dissect_osi_options( len, tvb, offset, tree );
179 } /* esis_dissect_esh_pdu */
182 esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
188 offset += ESIS_HDR_FIXED_LENGTH;
190 netl = (int) tvb_get_guint8(tvb, offset);
191 proto_tree_add_text( tree, tvb, offset, netl + 1,
192 "### Network Entity Title Section ###");
193 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", netl);
194 proto_tree_add_text( tree, tvb, offset, netl,
196 print_nsap_net( tvb_get_ptr(tvb, offset, netl), netl ) );
200 dissect_osi_options( len, tvb, offset, tree );
205 esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
211 offset += ESIS_HDR_FIXED_LENGTH;
213 tmpl = (int) tvb_get_guint8(tvb, offset);
214 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
215 "### Destination Address Section ###" );
216 proto_tree_add_text( tree, tvb, offset++, 1, "DAL: %2u Octets", tmpl);
217 proto_tree_add_text( tree, tvb, offset, tmpl,
219 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
222 tmpl = (int) tvb_get_guint8(tvb, offset);
224 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
225 "### Subnetwork Address Section ###");
226 proto_tree_add_text( tree, tvb, offset++, 1, "BSNPAL: %2u Octets", tmpl);
227 proto_tree_add_text( tree, tvb, offset, tmpl,
229 print_system_id( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
232 tmpl = (int) tvb_get_guint8(tvb, offset);
235 proto_tree_add_text( tree, tvb, offset, 1,
236 "### No Network Entity Title Section ###" );
241 proto_tree_add_text( tree, tvb, offset, 1,
242 "### Network Entity Title Section ###" );
243 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", tmpl );
244 proto_tree_add_text( tree, tvb, offset, tmpl,
246 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
250 dissect_osi_options( len, tvb, offset, tree );
256 * Name: dissect_esis()
259 * Main entry area for esis de-mangling. This will build the
260 * main esis tree data and call the sub-protocols as needed.
263 * tvbuff * : tvbuff referring to packet data
264 * packet_info * : info for current packet
265 * proto_tree * : tree of display data. May be NULL.
268 * void, but we will add to the proto_tree if it is not NULL.
271 dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
272 const char *pdu_type_string = NULL;
273 const char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)";
276 proto_tree *esis_tree = NULL;
279 const char *cksum_status;
281 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
282 col_clear(pinfo->cinfo, COL_INFO);
284 tvb_memcpy(tvb, (guint8 *)&ehdr, 0, sizeof ehdr);
287 ti = proto_tree_add_item(tree, proto_esis, tvb, 0, -1, ENC_NA);
288 esis_tree = proto_item_add_subtree(ti, ett_esis);
290 if (ehdr.esis_version != ESIS_REQUIRED_VERSION){
291 esis_dissect_unknown(tvb, esis_tree,
292 "Unknown ESIS version (%u vs %u)",
293 ehdr.esis_version, ESIS_REQUIRED_VERSION );
297 if (ehdr.esis_length < ESIS_HDR_FIXED_LENGTH) {
298 esis_dissect_unknown(tvb, esis_tree,
299 "Bogus ESIS length (%u, must be >= %u)",
300 ehdr.esis_length, ESIS_HDR_FIXED_LENGTH );
303 proto_tree_add_uint( esis_tree, hf_esis_nlpi, tvb, 0, 1, ehdr.esis_nlpi );
304 proto_tree_add_uint( esis_tree, hf_esis_length, tvb,
305 1, 1, ehdr.esis_length );
306 proto_tree_add_uint( esis_tree, hf_esis_version, tvb, 2, 1,
308 proto_tree_add_uint( esis_tree, hf_esis_reserved, tvb, 3, 1,
309 ehdr.esis_reserved );
311 pdu_type_string = val_to_str(ehdr.esis_type&OSI_PDU_TYPE_MASK,
312 esis_vals, "Unknown (0x%x)");
314 proto_tree_add_uint_format( esis_tree, hf_esis_type, tvb, 4, 1,
316 pdu_type_format_string,
318 (ehdr.esis_type&BIT_8) ? "1" : "0",
319 (ehdr.esis_type&BIT_7) ? "1" : "0",
320 (ehdr.esis_type&BIT_6) ? "1" : "0");
322 tmp_uint = pntohs( ehdr.esis_holdtime );
323 proto_tree_add_uint_format(esis_tree, hf_esis_holdtime, tvb, 5, 2,
324 tmp_uint, "Holding Time : %u seconds",
327 tmp_uint = pntohs( ehdr.esis_checksum );
329 switch (calc_checksum( tvb, 0, ehdr.esis_length, tmp_uint )) {
332 cksum_status = "Not Used";
336 cksum_status = "Not checkable - not all of packet was captured";
340 cksum_status = "Is good";
344 cksum_status = "Is wrong";
349 DISSECTOR_ASSERT_NOT_REACHED();
351 proto_tree_add_uint_format( esis_tree, hf_esis_checksum, tvb, 7, 2,
352 tmp_uint, "Checksum : 0x%x ( %s )",
353 tmp_uint, cksum_status );
358 * Let us make sure we use the same names for all our decodes
359 * here. First, dump the name into info column, and THEN
360 * dispatch the sub-type.
362 if (check_col(pinfo->cinfo, COL_INFO)) {
363 col_add_str(pinfo->cinfo, COL_INFO,
364 val_to_str( ehdr.esis_type&OSI_PDU_TYPE_MASK, esis_vals,
365 "Unknown (0x%x)" ) );
368 variable_len = ehdr.esis_length - ESIS_HDR_FIXED_LENGTH;
370 switch (ehdr.esis_type & OSI_PDU_TYPE_MASK) {
372 esis_dissect_esh_pdu( variable_len, tvb, esis_tree);
375 esis_dissect_ish_pdu( variable_len, tvb, esis_tree);
378 esis_dissect_redirect_pdu( variable_len, tvb, esis_tree);
381 esis_dissect_unknown(tvb, esis_tree,
382 "Unknown ESIS packet type 0x%x",
383 ehdr.esis_type & OSI_PDU_TYPE_MASK );
389 * Name: proto_register_esis()
392 * main register for esis protocol set. We register some display
393 * formats and the protocol module variables.
395 * NOTE: this procedure to autolinked by the makefile process that
405 proto_register_esis(void) {
406 static hf_register_info hf[] = {
408 { "Network Layer Protocol Identifier", "esis.nlpi",
409 FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, NULL, HFILL }},
412 { "PDU Length", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
415 { "Version (==1)", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
418 { "Reserved(==0)", "esis.res", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
421 { "PDU Type", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals), 0xff, NULL, HFILL }},
424 { "Holding Time", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, "s", HFILL }},
427 { "Checksum", "esis.chksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}
433 static gint *ett[] = {
438 proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
439 proto_register_field_array(proto_esis, hf, array_length(hf));
440 proto_register_subtree_array(ett, array_length(ett));
441 register_dissector("esis", dissect_esis, proto_esis);
445 proto_reg_handoff_esis(void)
447 dissector_handle_t esis_handle;
449 esis_handle = find_dissector("esis");
450 dissector_add_uint("osinl", NLPID_ISO9542_ESIS, esis_handle);