2 * Routines for ISO/OSI End System to Intermediate System
3 * Routeing Exchange Protocol ISO 9542.
5 * $Id: packet-esis.c,v 1.14 2001/03/30 10:51:50 guy Exp $
6 * Ralf Schneider <Ralf.Schneider@t-online.de>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@zing.org>
10 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
43 #include "packet-osi.h"
44 #include "packet-osi-options.h"
45 #include "packet-esis.h"
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;
59 static gint ett_esis = -1;
60 static gint ett_esis_area_addr = -1;
62 static const value_string esis_vals[] = {
63 { ESIS_ESH_PDU, "ES HELLO"},
64 { ESIS_ISH_PDU, "IS HELLO"},
65 { ESIS_RD_PDU, "RD REQUEST"},
68 /* internal prototypes */
70 static void esis_dissect_esh_pdu( u_char len, tvbuff_t *tvb,
71 packet_info *pinfo, proto_tree *treepd);
72 static void esis_dissect_ish_pdu( u_char len, tvbuff_t *tvb,
73 packet_info *pinfo, proto_tree *tree);
74 static void esis_dissect_redirect_pdu( u_char len, tvbuff_t *tvb,
75 packet_info *pinfo, proto_tree *tree);
77 /* ################## Descriptions ###########################################*/
78 /* Parameters for the ESH PDU
79 * Source Address Parameter:
81 * Octet: Length: Parameter Type:
82 * 10 1 Number of Source Adresses ( NSAPs served by this Network
83 * 11 1 Source Address Length Indicator ( SAL ) # Entity )
84 * 12-m-1 variable Source Address ( NSAP )
85 * m Options, dissected in osi.c
88 * Parameter for the ISH PDU:
89 * Network Entity Title Parameter:
91 * Octet: Length: Parameter Type:
92 * 10 1 Network Entity Title Length Indicator ( NETL )
93 * 11-m-1 variable Network Entity Title ( NET )
94 * m Options, dissected in osi.c
97 * Parameter for the RD PDU:
98 * When re-directed to an IS:
100 * Octet: Length: Parameter Type:
101 * 10 1 Destination Address Length Indicator ( DAL )
102 * 11>m-1 variable Destination Address ( DA )
103 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
104 * m+1>n-1 variable Subnetwork Address ( BSNPA )
105 * n 1 Network Entity Title Length Indicator ( NETL )
106 * n+1>p-1 variable Network Entity Title ( NET )
107 * p Options, dissected in osi.c
110 * Parameter for the RD PDU:
111 * When re-directed to an ES:
113 * Octet: Length: Parameter Type:
114 * 10 1 Destination Address Length Indicator ( DAL )
115 * 11>m-1 variable Destination Address ( DA )
116 * m 1 Subnetwork Address Length Indicator ( BSNPAL )
117 * m+1>n-1 variable Subnetwork Address ( BSNPA )
118 * n 1 Network Entity Title Length Indicator ( NETL ) == 0
119 * n+1 Options, dissected in osi.c
123 /* ############################ Tool Functions ############################## */
126 /* ############################## Dissection Functions ###################### */
128 * Name: dissect_esis_unknown()
131 * There was some error in the protocol and we are in unknown space
132 * here. Add a tree item to cover the error and go on. Note
133 * that we make sure we don't go off the end of the bleedin packet here!
135 * This is just a copy of isis.c and isis.h, so I keep the stuff also
136 * and adapt the names to cover possible protocol errors! Ive really no
137 * idea wether I need this or not.
140 * int offset : Current offset into packet data.
141 * int len : length of to dump.
142 * proto_tree * : tree of display data. May be NULL.
143 * frame_data * fd : frame data
144 * char * : format text
147 * void (may modify proto tree)
150 esis_dissect_unknown( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
155 proto_tree_add_text_valist(tree, tvb, 0, tvb_length(tvb), fmat, ap);
161 esis_dissect_esh_pdu( u_char len, tvbuff_t *tvb, packet_info *pinfo,
163 proto_tree *esis_area_tree;
171 offset += ESIS_HDR_FIXED_LENGTH;
173 no_sa = tvb_get_guint8(tvb, offset);
176 ti = proto_tree_add_text( tree, tvb, offset, tvb_length_remaining(tvb, offset),
177 "Number of Source Addresses (SA, Format: NSAP) : %u", no_sa );
180 esis_area_tree = proto_item_add_subtree( ti, ett_esis_area_addr );
181 while ( no_sa-- > 0 ) {
182 sal = (int) tvb_get_guint8(tvb, offset);
184 proto_tree_add_text(esis_area_tree, tvb, offset, 1, "SAL: %2u Octets", sal);
185 proto_tree_add_text(esis_area_tree, tvb, offset + 1, sal,
187 print_nsap_net( tvb_get_ptr(tvb, offset, sal), sal ) );
191 dissect_osi_options( PDU_TYPE_ESIS_ESH, len, tvb, offset, pinfo, tree );
193 } /* esis_dissect_esh_pdu */ ;
196 esis_dissect_ish_pdu( u_char len, tvbuff_t *tvb, packet_info *pinfo,
203 offset += ESIS_HDR_FIXED_LENGTH;
205 netl = (int) tvb_get_guint8(tvb, offset);
206 proto_tree_add_text( tree, tvb, offset, netl + 1,
207 "### Network Entity Titel Section ###");
208 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", netl);
209 proto_tree_add_text( tree, tvb, offset, netl,
211 print_nsap_net( tvb_get_ptr(tvb, offset, netl), netl ) );
215 dissect_osi_options( PDU_TYPE_ESIS_ISH, len, tvb, offset, pinfo, tree );
220 esis_dissect_redirect_pdu( u_char len, tvbuff_t *tvb, packet_info *pinfo,
227 offset += ESIS_HDR_FIXED_LENGTH;
229 tmpl = (int) tvb_get_guint8(tvb, offset);
230 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
231 "### Destination Address Section ###" );
232 proto_tree_add_text( tree, tvb, offset++, 1, "DAL: %2u Octets", tmpl);
233 proto_tree_add_text( tree, tvb, offset, tmpl,
235 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
238 tmpl = (int) tvb_get_guint8(tvb, offset);
240 proto_tree_add_text( tree, tvb, offset, tmpl + 1,
241 "### Subnetwork Address Section ###");
242 proto_tree_add_text( tree, tvb, offset++, 1, "BSNPAL: %2u Octets", tmpl);
243 proto_tree_add_text( tree, tvb, offset, tmpl,
245 print_system_id( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
248 tmpl = (int) tvb_get_guint8(tvb, offset);
251 proto_tree_add_text( tree, tvb, offset, 1,
252 "### No Network Entity Title Section ###" );
257 proto_tree_add_text( tree, tvb, offset, 1,
258 "### Network Entity Title Section ###" );
259 proto_tree_add_text( tree, tvb, offset++, 1, "NETL: %2u Octets", tmpl );
260 proto_tree_add_text( tree, tvb, offset, tmpl,
262 print_nsap_net( tvb_get_ptr(tvb, offset, tmpl), tmpl ) );
266 dissect_osi_options( PDU_TYPE_ESIS_RD, len, tvb, offset, pinfo, tree );
272 * Name: dissect_esis()
275 * Main entry area for esis de-mangling. This will build the
276 * main esis tree data and call the sub-protocols as needed.
279 * tvbuff * : tvbuff referring to packet data
280 * frame_data * : frame data (whole packet with extra info)
281 * proto_tree * : tree of display data. May be NULL.
284 * void, but we will add to the proto_tree if it is not NULL.
287 dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
288 char *pdu_type_string = NULL;
289 char *pdu_type_format_string = "PDU Type : %s (R:%s%s%s)";
292 proto_tree *esis_tree = NULL;
293 int variable_len = 0;
296 if (check_col(pinfo->fd, COL_PROTOCOL))
297 col_set_str(pinfo->fd, COL_PROTOCOL, "ESIS");
298 if (check_col(pinfo->fd, COL_INFO))
299 col_clear(pinfo->fd, COL_INFO);
301 tvb_memcpy(tvb, (guint8 *)&ehdr, 0, sizeof ehdr);
304 ti = proto_tree_add_item(tree, proto_esis, tvb, 0, tvb_length(tvb), FALSE);
305 esis_tree = proto_item_add_subtree(ti, ett_esis);
307 if (ehdr.esis_version != ESIS_REQUIRED_VERSION){
308 esis_dissect_unknown(tvb, pinfo, esis_tree,
309 "Unknown ESIS version (%u vs %u)",
310 ehdr.esis_version, ESIS_REQUIRED_VERSION );
314 proto_tree_add_uint( esis_tree, hf_esis_nlpi, tvb, 0, 1, ehdr.esis_nlpi );
315 proto_tree_add_uint( esis_tree, hf_esis_length, tvb,
316 1, 1, ehdr.esis_length );
317 proto_tree_add_uint( esis_tree, hf_esis_version, tvb, 2, 1,
319 proto_tree_add_uint( esis_tree, hf_esis_reserved, tvb, 3, 1,
320 ehdr.esis_reserved );
322 pdu_type_string = val_to_str(ehdr.esis_type&OSI_PDU_TYPE_MASK,
323 esis_vals, "Unknown (0x%x)");
325 proto_tree_add_uint_format( esis_tree, hf_esis_type, tvb, 4, 1,
327 pdu_type_format_string,
329 (ehdr.esis_type&BIT_8) ? "1" : "0",
330 (ehdr.esis_type&BIT_7) ? "1" : "0",
331 (ehdr.esis_type&BIT_6) ? "1" : "0");
333 tmp_uint = pntohs( ehdr.esis_holdtime );
334 proto_tree_add_uint_format(esis_tree, hf_esis_holdtime, tvb, 5, 2,
335 tmp_uint, "Holding Time : %u seconds",
338 tmp_uint = pntohs( ehdr.esis_checksum );
340 proto_tree_add_uint_format( esis_tree, hf_esis_checksum, tvb, 7, 2,
341 tmp_uint, "Checksum : 0x%x ( %s )",
342 tmp_uint, calc_checksum( tvb, 0,
349 * Let us make sure we use the same names for all our decodes
350 * here. First, dump the name into info column, and THEN
351 * dispatch the sub-type.
353 if (check_col(pinfo->fd, COL_INFO)) {
354 col_add_str(pinfo->fd, COL_INFO,
355 val_to_str( ehdr.esis_type&OSI_PDU_TYPE_MASK, esis_vals,
356 "Unknown (0x%x)" ) );
359 variable_len = ehdr.esis_length - ESIS_HDR_FIXED_LENGTH;
361 switch (ehdr.esis_type & OSI_PDU_TYPE_MASK) {
363 esis_dissect_esh_pdu( variable_len, tvb, pinfo, esis_tree);
366 esis_dissect_ish_pdu( variable_len, tvb, pinfo, esis_tree);
369 esis_dissect_redirect_pdu( variable_len, tvb, pinfo,
373 esis_dissect_unknown(tvb, pinfo, esis_tree,
374 "Unknown ESIS packet type 0x%x",
375 ehdr.esis_type & OSI_PDU_TYPE_MASK );
381 * Name: proto_register_esis()
384 * main register for esis protocol set. We register some display
385 * formats and the protocol module variables.
387 * NOTE: this procedure to autolinked by the makefile process that
397 proto_register_esis(void) {
398 static hf_register_info hf[] = {
400 { "Network Layer Protocol Identifier", "esis.nlpi",
401 FT_UINT8, BASE_HEX, VALS(nlpid_vals), 0x0, "" }},
403 { "PDU Length ", "esis.length", FT_UINT8, BASE_DEC, NULL, 0x0, "" }},
405 { "Version (==1) ", "esis.ver", FT_UINT8, BASE_DEC, NULL, 0x0, "" }},
407 { "Reserved(==0) ", "esis.res", FT_UINT8, BASE_DEC, NULL, 0x0, "" }},
409 { "PDU Type ", "esis.type", FT_UINT8, BASE_DEC, VALS(esis_vals),
412 { "Holding Time ", "esis.htime", FT_UINT16, BASE_DEC, NULL, 0x0, " s"}},
414 { "Checksum ", "esis.chksum", FT_UINT16, BASE_HEX, NULL, 0x0, "" }}
420 static gint *ett[] = {
425 proto_esis = proto_register_protocol( PROTO_STRING_ESIS, "ESIS", "esis");
426 proto_register_field_array(proto_esis, hf, array_length(hf));
427 proto_register_subtree_array(ett, array_length(ett));
431 proto_reg_handoff_esis(void)
433 dissector_add("osinl", NLPID_ISO9542_ESIS, dissect_esis, proto_esis);