2 * Routines for decoding isis hello packets and their CLVs
4 * $Id: packet-isis-hello.c,v 1.16 2001/06/18 02:17:47 guy Exp $
5 * Stuart Stanley <stuarts@mxmail.net>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
9 * 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 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
41 #include "packet-osi.h"
42 #include "packet-isis.h"
43 #include "packet-isis-clv.h"
44 #include "packet-isis-hello.h"
47 static int proto_isis_hello = -1;
48 static int hf_isis_hello_circuit_reserved = -1;
49 static int hf_isis_hello_source_id = -1;
50 static int hf_isis_hello_holding_timer = -1;
51 static int hf_isis_hello_pdu_length = -1;
52 static int hf_isis_hello_priority_reserved = -1;
53 static int hf_isis_hello_lan_id = -1;
54 static int hf_isis_hello_local_circuit_id = -1;
55 static int hf_isis_hello_clv_ipv4_int_addr = -1;
56 static int hf_isis_hello_clv_ipv6_int_addr = -1;
58 static gint ett_isis_hello = -1;
59 static gint ett_isis_hello_clv_area_addr = -1;
60 static gint ett_isis_hello_clv_is_neighbors = -1;
61 static gint ett_isis_hello_clv_padding = -1;
62 static gint ett_isis_hello_clv_unknown = -1;
63 static gint ett_isis_hello_clv_nlpid = -1;
64 static gint ett_isis_hello_clv_auth = -1;
65 static gint ett_isis_hello_clv_ipv4_int_addr = -1;
66 static gint ett_isis_hello_clv_ipv6_int_addr = -1;
68 static const value_string isis_hello_circuit_type_vals[] = {
69 { ISIS_HELLO_TYPE_RESERVED, "Reserved 0 (discard PDU)"},
70 { ISIS_HELLO_TYPE_LEVEL_1, "Level 1 only"},
71 { ISIS_HELLO_TYPE_LEVEL_2, "Level 2 only"},
72 { ISIS_HELLO_TYPE_LEVEL_12, "Level 1 and 2"},
76 * Predclare dissectors for use in clv dissection.
78 static void dissect_hello_area_address_clv(const u_char *pd, int offset,
79 guint length, int id_length, frame_data *fd, proto_tree *tree);
80 static void dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
81 guint length, int id_length, frame_data *fd, proto_tree *tree);
82 static void dissect_hello_padding_clv(const u_char *pd, int offset,
83 guint length, int id_length, frame_data *fd, proto_tree *tree);
84 static void dissect_hello_nlpid_clv(const u_char *pd, int offset,
85 guint length, int id_length, frame_data *fd, proto_tree *tree);
86 static void dissect_hello_ip_int_addr_clv(const u_char *pd, int offset,
87 guint length, int id_length, frame_data *fd, proto_tree *tree);
88 static void dissect_hello_ipv6_int_addr_clv(const u_char *pd, int offset,
89 guint length, int id_length, frame_data *fd, proto_tree *tree);
90 static void dissect_hello_auth_clv(const u_char *pd, int offset,
91 guint length, int id_length, frame_data *fd, proto_tree *tree);
93 static const isis_clv_handle_t clv_l1_hello_opts[] = {
95 ISIS_CLV_L1H_AREA_ADDRESS,
97 &ett_isis_hello_clv_area_addr,
98 dissect_hello_area_address_clv
101 ISIS_CLV_L1H_IS_NEIGHBORS,
103 &ett_isis_hello_clv_is_neighbors,
104 dissect_hello_is_neighbors_clv
107 ISIS_CLV_L1H_PADDING,
109 &ett_isis_hello_clv_padding,
110 dissect_hello_padding_clv
114 "Protocols Supported",
115 &ett_isis_hello_clv_nlpid,
116 dissect_hello_nlpid_clv
119 ISIS_CLV_L1H_IP_INTERFACE_ADDR,
120 "IP Interface address(es)",
121 &ett_isis_hello_clv_ipv4_int_addr,
122 dissect_hello_ip_int_addr_clv
125 ISIS_CLV_L1H_IPv6_INTERFACE_ADDR,
126 "IPv6 Interface address(es)",
127 &ett_isis_hello_clv_ipv6_int_addr,
128 dissect_hello_ipv6_int_addr_clv
131 ISIS_CLV_L1H_AUTHENTICATION_NS,
132 "Authentication(non spec)",
133 &ett_isis_hello_clv_auth,
134 dissect_hello_auth_clv
137 ISIS_CLV_L1H_AUTHENTICATION,
139 &ett_isis_hello_clv_auth,
140 dissect_hello_auth_clv
150 static const isis_clv_handle_t clv_l2_hello_opts[] = {
152 ISIS_CLV_L2H_AREA_ADDRESS,
154 &ett_isis_hello_clv_area_addr,
155 dissect_hello_area_address_clv
158 ISIS_CLV_L2H_IS_NEIGHBORS,
160 &ett_isis_hello_clv_is_neighbors,
161 dissect_hello_is_neighbors_clv
164 ISIS_CLV_L2H_PADDING,
166 &ett_isis_hello_clv_padding,
167 dissect_hello_padding_clv
171 "Protocols Supported",
172 &ett_isis_hello_clv_nlpid,
173 dissect_hello_nlpid_clv
176 ISIS_CLV_L2H_IP_INTERFACE_ADDR,
177 "IP Interface address(es)",
178 &ett_isis_hello_clv_ipv4_int_addr,
179 dissect_hello_ip_int_addr_clv
182 ISIS_CLV_L2H_IPv6_INTERFACE_ADDR,
183 "IPv6 Interface address(es)",
184 &ett_isis_hello_clv_ipv6_int_addr,
185 dissect_hello_ipv6_int_addr_clv
188 ISIS_CLV_L2H_AUTHENTICATION_NS,
189 "Authentication(non spec)",
190 &ett_isis_hello_clv_auth,
191 dissect_hello_auth_clv
194 ISIS_CLV_L2H_AUTHENTICATION,
196 &ett_isis_hello_clv_auth,
197 dissect_hello_auth_clv
207 static const isis_clv_handle_t clv_ptp_hello_opts[] = {
209 ISIS_CLV_PTP_AREA_ADDRESS,
211 &ett_isis_hello_clv_area_addr,
212 dissect_hello_area_address_clv
215 ISIS_CLV_PTP_PADDING,
217 &ett_isis_hello_clv_padding,
218 dissect_hello_padding_clv
222 "Protocols Supported",
223 &ett_isis_hello_clv_nlpid,
224 dissect_hello_nlpid_clv
227 ISIS_CLV_PTP_IP_INTERFACE_ADDR,
228 "IP Interface address(es)",
229 &ett_isis_hello_clv_ipv4_int_addr,
230 dissect_hello_ip_int_addr_clv
233 ISIS_CLV_PTP_IPv6_INTERFACE_ADDR,
234 "IPv6 Interface address(es)",
235 &ett_isis_hello_clv_ipv6_int_addr,
236 dissect_hello_ipv6_int_addr_clv
239 ISIS_CLV_PTP_AUTHENTICATION_NS,
240 "Authentication(non spec)",
241 &ett_isis_hello_clv_auth,
242 dissect_hello_auth_clv
245 ISIS_CLV_PTP_AUTHENTICATION,
247 &ett_isis_hello_clv_auth,
248 dissect_hello_auth_clv
259 * Name: dissect_hello_nlpid_clv()
262 * Decode for a hello packets NLPID clv. Calls into the
266 * u_char * : packet data
267 * int : current offset into packet data
268 * guint : length of this clv
269 * int : length of IDs in packet.
270 * frame_data * : frame data
271 * proto_tree * : proto tree to build on (may be null)
274 * void, will modify proto_tree if not null.
277 dissect_hello_nlpid_clv(const u_char *pd, int offset,
278 guint length, int id_length, frame_data *fd, proto_tree *tree) {
279 isis_dissect_nlpid_clv(pd, offset, length, fd, tree );
283 * Name: dissect_hello_ip_int_addr_clv()
286 * Decode for a hello packets ip interface addr clv. Calls into the
290 * u_char * : packet data
291 * int : current offset into packet data
292 * guint : length of this clv
293 * int : length of IDs in packet.
294 * frame_data * : frame data
295 * proto_tree * : proto tree to build on (may be null)
298 * void, will modify proto_tree if not null.
301 dissect_hello_ip_int_addr_clv(const u_char *pd, int offset,
302 guint length, int id_length, frame_data *fd, proto_tree *tree) {
303 isis_dissect_ip_int_clv(pd, offset, length, fd, tree,
304 hf_isis_hello_clv_ipv4_int_addr );
308 * Name: dissect_hello_ipv6_int_addr_clv()
311 * Decode for a hello packets ipv6 interface addr clv. Calls into the
315 * u_char * : packet data
316 * int : current offset into packet data
317 * guint : length of this clv
318 * int : length of IDs in packet.
319 * frame_data * : frame data
320 * proto_tree * : proto tree to build on (may be null)
323 * void, will modify proto_tree if not null.
326 dissect_hello_ipv6_int_addr_clv(const u_char *pd, int offset,
327 guint length, int id_length, frame_data *fd, proto_tree *tree) {
328 isis_dissect_ipv6_int_clv(pd, offset, length, fd, tree,
329 hf_isis_hello_clv_ipv6_int_addr );
333 * Name: dissect_hello_auth_clv()
336 * Decode for a hello packets authenticaion clv. Calls into the
337 * clv common one. An auth inside a hello packet is a perlink
341 * u_char * : packet data
342 * int : current offset into packet data
343 * guint : length of this clv
344 * int : length of IDs in packet.
345 * frame_data * : frame data
346 * proto_tree * : proto tree to build on (may be null)
349 * void, will modify proto_tree if not null.
352 dissect_hello_auth_clv(const u_char *pd, int offset,
353 guint length, int id_length, frame_data *fd, proto_tree *tree) {
354 isis_dissect_authentication_clv(pd, offset, length, fd, tree,
359 * Name: dissect_hello_area_address_clv()
362 * Decode for a hello packets area address clv. Calls into the
366 * u_char * : packet data
367 * int : current offset into packet data
368 * guint : length of this clv
369 * int : length of IDs in packet.
370 * frame_data * : frame data
371 * proto_tree * : proto tree to build on (may be null)
374 * void, will modify proto_tree if not null.
377 dissect_hello_area_address_clv(const u_char *pd, int offset,
378 guint length, int id_length, frame_data *fd, proto_tree *tree) {
379 isis_dissect_area_address_clv(pd, offset, length, fd, tree );
383 * Name: isis_dissect_is_neighbors_clv()
386 * Take apart a IS neighbor packet. A neighbor is n 6 byte packets.
387 * (they tend to be an 802.3 MAC address, but its not required).
390 * u_char * : packet data
391 * int : offset into packet data where we are.
392 * guint : length of clv we are decoding
393 * int : length of IDs in packet.
394 * frame_data * : frame data (complete frame)
395 * proto_tree * : protocol display tree to fill out. May be NULL
396 * gint : tree id to use for proto tree.
399 * void, but we will add to proto tree if !NULL.
402 dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
403 guint length, int id_length, frame_data *fd, proto_tree *tree ) {
404 while ( length > 0 ) {
406 isis_dissect_unknown(offset, length, tree, fd,
407 "short is neighbor (%d vs 6)", length );
411 * Lets turn the area address into "standard" 0000.0000.etc
415 proto_tree_add_text ( tree, NullTVB, offset, 6,
416 "IS Neighbor: %s", print_system_id( pd + offset, 6 ) );
425 * Name: dissect_hello_padding_clv()
428 * Decode for a hello packet's padding clv. Padding does nothing,
432 * u_char * : packet data
433 * int : current offset into packet data
434 * guint : length of this clv
435 * int : length of IDs in packet.
436 * frame_data * : frame data
437 * proto_tree * : proto tree to build on (may be null)
443 dissect_hello_padding_clv(const u_char *pd, int offset, guint length,
444 int id_length, frame_data *fd, proto_tree *tree) {
445 /* nothing to do here! */
449 * Name: isis_dissect_isis_hello()
452 * This procedure rips apart the various types of ISIS hellos. L1H and
453 * L2H's are identical for the most part, while the PTP hello has
457 * int : hello type, a la packet-isis.h ISIS_TYPE_* values
458 * int : header length of packet.
459 * int : length of IDs in packet.
460 * u_char * : packet data
461 * int offset : our offset into packet data.
462 * frame_data * : frame data
463 * proto_tree * : protocol display tree to add to. May be NULL.
466 * void, will modify proto_tree if not NULL.
469 isis_dissect_isis_hello(int hello_type, int header_length, int id_length,
470 const u_char *pd, int offset, frame_data *fd, proto_tree *tree){
472 proto_tree *hello_tree = NULL;
477 OLD_CHECK_DISPLAY_AS_DATA(proto_isis_hello, pd, offset, fd, tree);
479 if (hello_type == ISIS_TYPE_PTP_HELLO) {
480 hlen = 1+id_length+2+2+1;
482 hlen = 1+id_length+2+2+1+id_length+1;
485 if (!BYTES_ARE_IN_FRAME(offset, hlen)) {
486 isis_dissect_unknown(offset, hlen, tree, fd,
487 "not enough capture data for header (%d vs %d)",
493 ti = proto_tree_add_item(tree, proto_isis_hello, NullTVB,
494 offset, END_OF_FRAME, FALSE);
495 hello_tree = proto_item_add_subtree(ti, ett_isis_hello);
496 proto_tree_add_uint_format(hello_tree,
497 hf_isis_hello_circuit_reserved,
498 NullTVB, offset, 1, pd[offset],
499 "Circuit type : %s, reserved(0x%02x == 0)",
500 val_to_str(pd[offset]&ISIS_HELLO_CTYPE_MASK,
501 isis_hello_circuit_type_vals,
503 pd[offset]&ISIS_HELLO_CT_RESERVED_MASK
509 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, NullTVB,
510 offset, id_length, &pd[offset],
511 "SystemID{ Sender of PDU } : %s",
512 print_system_id( pd + offset, id_length ) );
517 proto_tree_add_uint(hello_tree, hf_isis_hello_holding_timer, NullTVB,
518 offset, 2, pntohs(&pd[offset]));
522 pdu_length = pntohs(&pd[offset]);
524 proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, NullTVB,
525 offset, 2, pdu_length);
529 if (hello_type == ISIS_TYPE_PTP_HELLO) {
531 proto_tree_add_uint(hello_tree, hf_isis_hello_local_circuit_id, NullTVB,
532 offset, 1, pd[offset] );
538 proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, NullTVB,
539 offset, 1, pd[offset],
540 "Priority : %d, reserved(0x%02x == 0)",
541 pd[offset]&ISIS_HELLO_PRIORITY_MASK,
542 pd[offset]&ISIS_HELLO_P_RESERVED_MASK );
547 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, NullTVB,
548 offset, id_length + 1, &pd[offset],
549 "SystemID{ Designated IS } : %s",
550 print_system_id( pd + offset, id_length + 1 ) );
552 offset += id_length + 1;
556 len -= header_length;
558 isis_dissect_unknown(offset, header_length, tree, fd,
559 "packet header length %d went beyond packet",
564 * Now, we need to decode our CLVs. We need to pass in
565 * our list of valid ones!
567 if (hello_type == ISIS_TYPE_L1_HELLO){
568 isis_dissect_clvs ( clv_l1_hello_opts, len, id_length, pd,
569 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
570 } else if (hello_type == ISIS_TYPE_L2_HELLO) {
571 isis_dissect_clvs ( clv_l2_hello_opts, len, id_length, pd,
572 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
574 isis_dissect_clvs ( clv_ptp_hello_opts, len, id_length, pd,
575 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
580 * Name: proto_register_isis_hello()
583 * Register our protocol sub-sets with protocol manager.
584 * NOTE: this procedure is autolinked by the makefile process that
594 proto_register_isis_hello(void) {
595 static hf_register_info hf[] = {
596 { &hf_isis_hello_circuit_reserved,
597 { "Circuit type ", "isis_hello.circuite_type",
598 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
600 { &hf_isis_hello_source_id,
601 { "SystemID{ Sender of PDU } ", "isis_hello.source_id",
602 FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
604 { &hf_isis_hello_holding_timer,
605 { "Holding timer ", "isis_hello.holding_timer",
606 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
608 { &hf_isis_hello_pdu_length,
609 { "PDU length ", "isis_hello.pdu_length",
610 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
612 { &hf_isis_hello_priority_reserved,
613 { "Priority ", "isis_hello.priority",
614 FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_P_RESERVED_MASK, "", HFILL }},
616 { &hf_isis_hello_lan_id,
617 { "SystemID{ Designated IS } ", "isis_hello.lan_id",
618 FT_BYTES, BASE_DEC, NULL, 0x0, "", HFILL }},
620 { &hf_isis_hello_local_circuit_id,
621 { "Local circuit ID ", "isis_hello.local_circuit_id",
622 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
624 { &hf_isis_hello_clv_ipv4_int_addr,
625 { "IPv4 interface address ", "isis_hello.clv_ipv4_int_addr",
626 FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
628 { &hf_isis_hello_clv_ipv6_int_addr,
629 { "IPv6 interface address ", "isis_hello.clv_ipv6_int_addr",
630 FT_IPv6, BASE_NONE, NULL, 0x0, "", HFILL }},
633 static gint *ett[] = {
635 &ett_isis_hello_clv_area_addr,
636 &ett_isis_hello_clv_is_neighbors,
637 &ett_isis_hello_clv_padding,
638 &ett_isis_hello_clv_unknown,
639 &ett_isis_hello_clv_nlpid,
640 &ett_isis_hello_clv_auth,
641 &ett_isis_hello_clv_ipv4_int_addr,
642 &ett_isis_hello_clv_ipv6_int_addr
645 proto_isis_hello = proto_register_protocol("ISIS HELLO",
646 "ISIS HELLO", "isis_hello");
647 proto_register_field_array(proto_isis_hello, hf, array_length(hf));
648 proto_register_subtree_array(ett, array_length(ett));