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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
35 #include <epan/emem.h>
36 #include <epan/nlpid.h>
37 #include "packet-osi.h"
38 #include "packet-osi-options.h"
39 #include "packet-esis.h"
42 /* esis base header */
43 static int proto_esis = -1;
45 static int hf_esis_nlpi = -1;
46 static int hf_esis_length = -1;
47 static int hf_esis_version = -1;
48 static int hf_esis_reserved = -1;
49 static int hf_esis_type = -1;
50 static int hf_esis_holdtime = -1;
51 static int hf_esis_checksum = -1;
53 static gint ett_esis = -1;
54 static gint ett_esis_area_addr = -1;
56 static const value_string esis_vals[] = {
57 { ESIS_ESH_PDU, "ES HELLO"},
58 { ESIS_ISH_PDU, "IS HELLO"},
59 { ESIS_RD_PDU, "RD REQUEST"},
62 /* internal prototypes */
64 static void esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb,
66 static void esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb,
68 static void esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb,
71 /* ################## Descriptions ###########################################*/
72 /* Parameters for the ESH PDU
73 * Source Address Parameter:
75 * Octet: Length: Parameter Type:
76 * 10 1 Number of Source Adresses ( NSAPs served by this Network
77 * 11 1 Source Address Length Indicator ( SAL ) # Entity )
78 * 12-m-1 variable Source Address ( NSAP )
79 * m Options, dissected in osi.c
82 * Parameter for the ISH PDU:
83 * Network Entity Title Parameter:
85 * Octet: Length: Parameter Type:
86 * 10 1 Network Entity Title Length Indicator ( NETL )
87 * 11-m-1 variable Network Entity Title ( NET )
88 * m Options, dissected in osi.c
91 * Parameter for the RD PDU:
92 * When re-directed to an IS:
94 * Octet: Length: Parameter Type:
95 * 10 1 Destination Address Length Indicator ( DAL )
96 * 11>m-1 variable Destination Address ( DA )
97 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
98 * m+1>n-1 variable Subnetwork Address ( BSNPA )
99 * n 1 Network Entity Title Length Indicator ( NETL )
100 * n+1>p-1 variable Network Entity Title ( NET )
101 * p Options, dissected in osi.c
104 * Parameter for the RD PDU:
105 * When re-directed to an ES:
107 * Octet: Length: Parameter Type:
108 * 10 1 Destination Address Length Indicator ( DAL )
109 * 11>m-1 variable Destination Address ( DA )
110 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
111 * m+1>n-1 variable Subnetwork Address ( BSNPA )
112 * n 1 Network Entity Title Length Indicator ( NETL ) == 0
113 * n+1 Options, dissected in osi.c
117 /* ############################ Tool Functions ############################## */
120 /* ############################## Dissection Functions ###################### */
122 * Name: dissect_esis_unknown()
125 * There was some error in the protocol and we are in unknown space
126 * here. Add a tree item to cover the error and go on. Note
127 * that we make sure we don't go off the end of the bleedin packet here!
129 * This is just a copy of isis.c and isis.h, so I keep the stuff also
130 * and adapt the names to cover possible protocol errors! Ive really no
131 * idea wether I need this or not.
134 * tvbuff_t * : tvbuff with packet data.
135 * proto_tree * : tree of display data. May be NULL.
136 * char * : format text
137 * subsequent args : arguments to format
140 * void (may modify proto tree)
143 esis_dissect_unknown( tvbuff_t *tvb, proto_tree *tree, const char *fmat, ...){
147 proto_tree_add_text_valist(tree, tvb, 0, -1, fmat, ap);
153 esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
154 proto_tree *esis_area_tree;
162 offset += ESIS_HDR_FIXED_LENGTH;
164 no_sa = tvb_get_guint8(tvb, offset);
167 ti = proto_tree_add_text( tree, tvb, offset, -1,
168 "Number of Source Addresses (SA, Format: NSAP) : %u", no_sa );
171 esis_area_tree = proto_item_add_subtree( ti, ett_esis_area_addr );
172 while ( no_sa-- > 0 ) {
173 sal = (int) tvb_get_guint8(tvb, offset);
174 proto_tree_add_text(esis_area_tree, tvb, offset, 1, "SAL: %2u Octets", sal);
176 proto_tree_add_text(esis_area_tree, tvb, offset, sal,
178 print_nsap_net( tvb_get_ptr(tvb, offset, sal), sal ) );
182 dissect_osi_options( len, tvb, offset, tree );
184 } /* esis_dissect_esh_pdu */
187 esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
193 offset += ESIS_HDR_FIXED_LENGTH;
195 netl = (int) tvb_get_guint8(tvb, offset);
196 proto_tree_add_text( tree, tvb, offset, netl + 1,
197 "### Network Entity Title Section ###");
198 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", netl);
199 proto_tree_add_text( tree, tvb, offset, netl,
201 print_nsap_net( tvb_get_ptr(tvb, offset, netl), netl ) );
205 dissect_osi_options( len, tvb, offset, tree );
210 esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
216 offset += ESIS_HDR_FIXED_LENGTH;
218 tmpl = (int) tvb_get_guint8(tvb, offset);
219 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
220 "### Destination Address Section ###" );
221 proto_tree_add_text( tree, tvb, offset++, 1, "DAL: %2u Octets", tmpl);
222 proto_tree_add_text( tree, tvb, offset, tmpl,
224 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
227 tmpl = (int) tvb_get_guint8(tvb, offset);
229 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
230 "### Subnetwork Address Section ###");
231 proto_tree_add_text( tree, tvb, offset++, 1, "BSNPAL: %2u Octets", tmpl);
232 proto_tree_add_text( tree, tvb, offset, tmpl,
234 print_system_id( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
237 tmpl = (int) tvb_get_guint8(tvb, offset);
240 proto_tree_add_text( tree, tvb, offset, 1,
241 "### No Network Entity Title Section ###" );
246 proto_tree_add_text( tree, tvb, offset, 1,
247 "### Network Entity Title Section ###" );
248 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", tmpl );
249 proto_tree_add_text( tree, tvb, offset, tmpl,
251 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
255 dissect_osi_options( len, tvb, offset, tree );
261 * Name: dissect_esis()
264 * Main entry area for esis de-mangling. This will build the
265 * main esis tree data and call the sub-protocols as needed.
268 * tvbuff * : tvbuff referring to packet data
269 * packet_info * : info for current packet
270 * proto_tree * : tree of display data. May be NULL.
273 * void, but we will add to the proto_tree if it is not NULL.
276 dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
277 const char *pdu_type_string = NULL;
278 const char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)";
281 proto_tree *esis_tree = NULL;
284 const char *cksum_status;
286 if (check_col(pinfo->cinfo, COL_PROTOCOL))
287 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
288 if (check_col(pinfo->cinfo, COL_INFO))
289 col_clear(pinfo->cinfo, COL_INFO);
291 tvb_memcpy(tvb, (guint8 *)&ehdr, 0, sizeof ehdr);
294 ti = proto_tree_add_item(tree, proto_esis, tvb, 0, -1, FALSE);
295 esis_tree = proto_item_add_subtree(ti, ett_esis);
297 if (ehdr.esis_version != ESIS_REQUIRED_VERSION){
298 esis_dissect_unknown(tvb, esis_tree,
299 "Unknown ESIS version (%u vs %u)",
300 ehdr.esis_version, ESIS_REQUIRED_VERSION );
304 if (ehdr.esis_length < ESIS_HDR_FIXED_LENGTH) {
305 esis_dissect_unknown(tvb, esis_tree,
306 "Bogus ESIS length (%u, must be >= %u)",
307 ehdr.esis_length, ESIS_HDR_FIXED_LENGTH );
310 proto_tree_add_uint( esis_tree, hf_esis_nlpi, tvb, 0, 1, ehdr.esis_nlpi );
311 proto_tree_add_uint( esis_tree, hf_esis_length, tvb,
312 1, 1, ehdr.esis_length );
313 proto_tree_add_uint( esis_tree, hf_esis_version, tvb, 2, 1,
315 proto_tree_add_uint( esis_tree, hf_esis_reserved, tvb, 3, 1,
316 ehdr.esis_reserved );
318 pdu_type_string = val_to_str(ehdr.esis_type&OSI_PDU_TYPE_MASK,
319 esis_vals, "Unknown (0x%x)");
321 proto_tree_add_uint_format( esis_tree, hf_esis_type, tvb, 4, 1,
323 pdu_type_format_string,
325 (ehdr.esis_type&BIT_8) ? "1" : "0",
326 (ehdr.esis_type&BIT_7) ? "1" : "0",
327 (ehdr.esis_type&BIT_6) ? "1" : "0");
329 tmp_uint = pntohs( ehdr.esis_holdtime );
330 proto_tree_add_uint_format(esis_tree, hf_esis_holdtime, tvb, 5, 2,
331 tmp_uint, "Holding Time : %u seconds",
334 tmp_uint = pntohs( ehdr.esis_checksum );
336 switch (calc_checksum( tvb, 0, ehdr.esis_length, tmp_uint )) {
339 cksum_status = "Not Used";
343 cksum_status = "Not checkable - not all of packet was captured";
347 cksum_status = "Is good";
351 cksum_status = "Is wrong";
356 DISSECTOR_ASSERT_NOT_REACHED();
358 proto_tree_add_uint_format( esis_tree, hf_esis_checksum, tvb, 7, 2,
359 tmp_uint, "Checksum : 0x%x ( %s )",
360 tmp_uint, cksum_status );
365 * Let us make sure we use the same names for all our decodes
366 * here. First, dump the name into info column, and THEN
367 * dispatch the sub-type.
369 if (check_col(pinfo->cinfo, COL_INFO)) {
370 col_add_str(pinfo->cinfo, COL_INFO,
371 val_to_str( ehdr.esis_type&OSI_PDU_TYPE_MASK, esis_vals,
372 "Unknown (0x%x)" ) );
375 variable_len = ehdr.esis_length - ESIS_HDR_FIXED_LENGTH;
377 switch (ehdr.esis_type & OSI_PDU_TYPE_MASK) {
379 esis_dissect_esh_pdu( variable_len, tvb, esis_tree);
382 esis_dissect_ish_pdu( variable_len, tvb, esis_tree);
385 esis_dissect_redirect_pdu( variable_len, tvb, esis_tree);
388 esis_dissect_unknown(tvb, esis_tree,
389 "Unknown ESIS packet type 0x%x",
390 ehdr.esis_type & OSI_PDU_TYPE_MASK );
396 * Name: proto_register_esis()
399 * main register for esis protocol set. We register some display
400 * formats and the protocol module variables.
402 * NOTE: this procedure to autolinked by the makefile process that
412 proto_register_esis(void) {
413 static hf_register_info hf[] = {
415 { "Network Layer Protocol Identifier", "esis.nlpi",
416 FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, "", HFILL }},
418 { "PDU Length ", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
420 { "Version (==1) ", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
422 { "Reserved(==0) ", "esis.res", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
424 { "PDU Type ", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals),
427 { "Holding Time ", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, " s", HFILL }},
429 { "Checksum ", "esis.chksum", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }}
435 static gint *ett[] = {
440 proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
441 proto_register_field_array(proto_esis, hf, array_length(hf));
442 proto_register_subtree_array(ett, array_length(ett));
446 proto_reg_handoff_esis(void)
448 dissector_handle_t esis_handle;
450 esis_handle = create_dissector_handle(dissect_esis, proto_esis);
451 register_dissector("esis", dissect_esis, proto_esis);
452 dissector_add("osinl", NLPID_ISO9542_ESIS, esis_handle);