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.
33 #include <epan/packet.h>
34 #include <epan/nlpid.h>
35 #include "packet-osi.h"
36 #include "packet-osi-options.h"
37 #include "packet-esis.h"
40 /* esis base header */
41 static int proto_esis = -1;
43 static int hf_esis_nlpi = -1;
44 static int hf_esis_length = -1;
45 static int hf_esis_version = -1;
46 static int hf_esis_reserved = -1;
47 static int hf_esis_type = -1;
48 static int hf_esis_holdtime = -1;
49 static int hf_esis_checksum = -1;
51 static gint ett_esis = -1;
52 static gint ett_esis_area_addr = -1;
54 static const value_string esis_vals[] = {
55 { ESIS_ESH_PDU, "ES HELLO"},
56 { ESIS_ISH_PDU, "IS HELLO"},
57 { ESIS_RD_PDU, "RD REQUEST"},
60 /* internal prototypes */
62 static void esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb,
64 static void esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb,
66 static void esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb,
69 /* ################## Descriptions ###########################################*/
70 /* Parameters for the ESH PDU
71 * Source Address Parameter:
73 * Octet: Length: Parameter Type:
74 * 10 1 Number of Source Adresses ( NSAPs served by this Network
75 * 11 1 Source Address Length Indicator ( SAL ) # Entity )
76 * 12-m-1 variable Source Address ( NSAP )
77 * m Options, dissected in osi.c
80 * Parameter for the ISH PDU:
81 * Network Entity Title Parameter:
83 * Octet: Length: Parameter Type:
84 * 10 1 Network Entity Title Length Indicator ( NETL )
85 * 11-m-1 variable Network Entity Title ( NET )
86 * m Options, dissected in osi.c
89 * Parameter for the RD PDU:
90 * When re-directed to an IS:
92 * Octet: Length: Parameter Type:
93 * 10 1 Destination Address Length Indicator ( DAL )
94 * 11>m-1 variable Destination Address ( DA )
95 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
96 * m+1>n-1 variable Subnetwork Address ( BSNPA )
97 * n 1 Network Entity Title Length Indicator ( NETL )
98 * n+1>p-1 variable Network Entity Title ( NET )
99 * p Options, dissected in osi.c
102 * Parameter for the RD PDU:
103 * When re-directed to an ES:
105 * Octet: Length: Parameter Type:
106 * 10 1 Destination Address Length Indicator ( DAL )
107 * 11>m-1 variable Destination Address ( DA )
108 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
109 * m+1>n-1 variable Subnetwork Address ( BSNPA )
110 * n 1 Network Entity Title Length Indicator ( NETL ) == 0
111 * n+1 Options, dissected in osi.c
115 /* ############################ Tool Functions ############################## */
118 /* ############################## Dissection Functions ###################### */
120 * Name: dissect_esis_unknown()
123 * There was some error in the protocol and we are in unknown space
124 * here. Add a tree item to cover the error and go on. Note
125 * that we make sure we don't go off the end of the bleedin packet here!
127 * This is just a copy of isis.c and isis.h, so I keep the stuff also
128 * and adapt the names to cover possible protocol errors! Ive really no
129 * idea whether I need this or not.
132 * tvbuff_t * : tvbuff with packet data.
133 * proto_tree * : tree of display data. May be NULL.
134 * char * : format text
135 * subsequent args : arguments to format
138 * void (may modify proto tree)
141 esis_dissect_unknown( tvbuff_t *tvb, proto_tree *tree, const char *fmat, ...){
145 proto_tree_add_text_valist(tree, tvb, 0, -1, fmat, ap);
151 esis_dissect_esh_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
152 proto_tree *esis_area_tree;
160 offset += ESIS_HDR_FIXED_LENGTH;
162 no_sa = tvb_get_guint8(tvb, offset);
165 ti = proto_tree_add_text( tree, tvb, offset, -1,
166 "Number of Source Addresses (SA, Format: NSAP) : %u", no_sa );
169 esis_area_tree = proto_item_add_subtree( ti, ett_esis_area_addr );
170 while ( no_sa-- > 0 ) {
171 sal = (int) tvb_get_guint8(tvb, offset);
172 proto_tree_add_text(esis_area_tree, tvb, offset, 1, "SAL: %2u Octets", sal);
174 proto_tree_add_text(esis_area_tree, tvb, offset, sal,
176 print_nsap_net( tvb_get_ptr(tvb, offset, sal), sal ) );
180 dissect_osi_options( len, tvb, offset, tree );
182 } /* esis_dissect_esh_pdu */
185 esis_dissect_ish_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
191 offset += ESIS_HDR_FIXED_LENGTH;
193 netl = (int) tvb_get_guint8(tvb, offset);
194 proto_tree_add_text( tree, tvb, offset, netl + 1,
195 "### Network Entity Title Section ###");
196 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", netl);
197 proto_tree_add_text( tree, tvb, offset, netl,
199 print_nsap_net( tvb_get_ptr(tvb, offset, netl), netl ) );
203 dissect_osi_options( len, tvb, offset, tree );
208 esis_dissect_redirect_pdu( guint8 len, tvbuff_t *tvb, proto_tree *tree) {
214 offset += ESIS_HDR_FIXED_LENGTH;
216 tmpl = (int) tvb_get_guint8(tvb, offset);
217 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
218 "### Destination Address Section ###" );
219 proto_tree_add_text( tree, tvb, offset++, 1, "DAL: %2u Octets", tmpl);
220 proto_tree_add_text( tree, tvb, offset, tmpl,
222 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
225 tmpl = (int) tvb_get_guint8(tvb, offset);
227 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
228 "### Subnetwork Address Section ###");
229 proto_tree_add_text( tree, tvb, offset++, 1, "BSNPAL: %2u Octets", tmpl);
230 proto_tree_add_text( tree, tvb, offset, tmpl,
232 print_system_id( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
235 tmpl = (int) tvb_get_guint8(tvb, offset);
238 proto_tree_add_text( tree, tvb, offset, 1,
239 "### No Network Entity Title Section ###" );
244 proto_tree_add_text( tree, tvb, offset, 1,
245 "### Network Entity Title Section ###" );
246 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", tmpl );
247 proto_tree_add_text( tree, tvb, offset, tmpl,
249 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
253 dissect_osi_options( len, tvb, offset, tree );
259 * Name: dissect_esis()
262 * Main entry area for esis de-mangling. This will build the
263 * main esis tree data and call the sub-protocols as needed.
266 * tvbuff * : tvbuff referring to packet data
267 * packet_info * : info for current packet
268 * proto_tree * : tree of display data. May be NULL.
271 * void, but we will add to the proto_tree if it is not NULL.
274 dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
275 const char *pdu_type_string = NULL;
276 const char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)";
279 proto_tree *esis_tree = NULL;
282 const char *cksum_status;
284 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
285 col_clear(pinfo->cinfo, COL_INFO);
287 tvb_memcpy(tvb, (guint8 *)&ehdr, 0, sizeof ehdr);
290 ti = proto_tree_add_item(tree, proto_esis, tvb, 0, -1, FALSE);
291 esis_tree = proto_item_add_subtree(ti, ett_esis);
293 if (ehdr.esis_version != ESIS_REQUIRED_VERSION){
294 esis_dissect_unknown(tvb, esis_tree,
295 "Unknown ESIS version (%u vs %u)",
296 ehdr.esis_version, ESIS_REQUIRED_VERSION );
300 if (ehdr.esis_length < ESIS_HDR_FIXED_LENGTH) {
301 esis_dissect_unknown(tvb, esis_tree,
302 "Bogus ESIS length (%u, must be >= %u)",
303 ehdr.esis_length, ESIS_HDR_FIXED_LENGTH );
306 proto_tree_add_uint( esis_tree, hf_esis_nlpi, tvb, 0, 1, ehdr.esis_nlpi );
307 proto_tree_add_uint( esis_tree, hf_esis_length, tvb,
308 1, 1, ehdr.esis_length );
309 proto_tree_add_uint( esis_tree, hf_esis_version, tvb, 2, 1,
311 proto_tree_add_uint( esis_tree, hf_esis_reserved, tvb, 3, 1,
312 ehdr.esis_reserved );
314 pdu_type_string = val_to_str(ehdr.esis_type&OSI_PDU_TYPE_MASK,
315 esis_vals, "Unknown (0x%x)");
317 proto_tree_add_uint_format( esis_tree, hf_esis_type, tvb, 4, 1,
319 pdu_type_format_string,
321 (ehdr.esis_type&BIT_8) ? "1" : "0",
322 (ehdr.esis_type&BIT_7) ? "1" : "0",
323 (ehdr.esis_type&BIT_6) ? "1" : "0");
325 tmp_uint = pntohs( ehdr.esis_holdtime );
326 proto_tree_add_uint_format(esis_tree, hf_esis_holdtime, tvb, 5, 2,
327 tmp_uint, "Holding Time : %u seconds",
330 tmp_uint = pntohs( ehdr.esis_checksum );
332 switch (calc_checksum( tvb, 0, ehdr.esis_length, tmp_uint )) {
335 cksum_status = "Not Used";
339 cksum_status = "Not checkable - not all of packet was captured";
343 cksum_status = "Is good";
347 cksum_status = "Is wrong";
352 DISSECTOR_ASSERT_NOT_REACHED();
354 proto_tree_add_uint_format( esis_tree, hf_esis_checksum, tvb, 7, 2,
355 tmp_uint, "Checksum : 0x%x ( %s )",
356 tmp_uint, cksum_status );
361 * Let us make sure we use the same names for all our decodes
362 * here. First, dump the name into info column, and THEN
363 * dispatch the sub-type.
365 if (check_col(pinfo->cinfo, COL_INFO)) {
366 col_add_str(pinfo->cinfo, COL_INFO,
367 val_to_str( ehdr.esis_type&OSI_PDU_TYPE_MASK, esis_vals,
368 "Unknown (0x%x)" ) );
371 variable_len = ehdr.esis_length - ESIS_HDR_FIXED_LENGTH;
373 switch (ehdr.esis_type & OSI_PDU_TYPE_MASK) {
375 esis_dissect_esh_pdu( variable_len, tvb, esis_tree);
378 esis_dissect_ish_pdu( variable_len, tvb, esis_tree);
381 esis_dissect_redirect_pdu( variable_len, tvb, esis_tree);
384 esis_dissect_unknown(tvb, esis_tree,
385 "Unknown ESIS packet type 0x%x",
386 ehdr.esis_type & OSI_PDU_TYPE_MASK );
392 * Name: proto_register_esis()
395 * main register for esis protocol set. We register some display
396 * formats and the protocol module variables.
398 * NOTE: this procedure to autolinked by the makefile process that
408 proto_register_esis(void) {
409 static hf_register_info hf[] = {
411 { "Network Layer Protocol Identifier", "esis.nlpi",
412 FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, NULL, HFILL }},
414 { "PDU Length", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
416 { "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 }},
420 { "PDU Type", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals),
421 0xff, NULL, HFILL }},
423 { "Holding Time", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, "s", HFILL }},
425 { "Checksum", "esis.chksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}
431 static gint *ett[] = {
436 proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
437 proto_register_field_array(proto_esis, hf, array_length(hf));
438 proto_register_subtree_array(ett, array_length(ett));
439 register_dissector("esis", dissect_esis, proto_esis);
443 proto_reg_handoff_esis(void)
445 dissector_handle_t esis_handle;
447 esis_handle = find_dissector("esis");
448 dissector_add("osinl", NLPID_ISO9542_ESIS, esis_handle);