2 * Routines for decoding isis hello packets and their CLVs
4 * $Id: packet-isis-hello.c,v 1.29 2002/04/07 23:39:00 guy Exp $
5 * Stuart Stanley <stuarts@mxmail.net>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
37 #include <epan/packet.h>
38 #include "packet-osi.h"
39 #include "packet-isis.h"
40 #include "packet-isis-clv.h"
41 #include "packet-isis-hello.h"
42 #include "epan/resolv.h"
45 static int hf_isis_hello_circuit_reserved = -1;
46 static int hf_isis_hello_source_id = -1;
47 static int hf_isis_hello_holding_timer = -1;
48 static int hf_isis_hello_pdu_length = -1;
49 static int hf_isis_hello_priority_reserved = -1;
50 static int hf_isis_hello_lan_id = -1;
51 static int hf_isis_hello_local_circuit_id = -1;
52 static int hf_isis_hello_clv_ipv4_int_addr = -1;
53 static int hf_isis_hello_clv_ipv6_int_addr = -1;
54 static int hf_isis_hello_clv_ptp_adj = -1;
55 static int hf_isis_hello_clv_mt = -1;
57 static gint ett_isis_hello = -1;
58 static gint ett_isis_hello_clv_area_addr = -1;
59 static gint ett_isis_hello_clv_is_neighbors = -1;
60 static gint ett_isis_hello_clv_padding = -1;
61 static gint ett_isis_hello_clv_unknown = -1;
62 static gint ett_isis_hello_clv_nlpid = -1;
63 static gint ett_isis_hello_clv_auth = -1;
64 static gint ett_isis_hello_clv_ipv4_int_addr = -1;
65 static gint ett_isis_hello_clv_ipv6_int_addr = -1;
66 static gint ett_isis_hello_clv_ptp_adj = -1;
67 static gint ett_isis_hello_clv_mt = -1;
68 static gint ett_isis_hello_clv_restart = -1;
70 static const value_string isis_hello_circuit_type_vals[] = {
71 { ISIS_HELLO_TYPE_RESERVED, "Reserved 0 (discard PDU)"},
72 { ISIS_HELLO_TYPE_LEVEL_1, "Level 1 only"},
73 { ISIS_HELLO_TYPE_LEVEL_2, "Level 2 only"},
74 { ISIS_HELLO_TYPE_LEVEL_12, "Level 1 and 2"},
78 * Predclare dissectors for use in clv dissection.
80 static void dissect_hello_padding_clv(tvbuff_t *tvb,
81 proto_tree *tree, int offset, int id_length, int length);
82 static void dissect_hello_is_neighbors_clv(tvbuff_t *tvb,
83 proto_tree *tree, int offset, int id_length, int length);
84 static void dissect_hello_ptp_adj_clv(tvbuff_t *tvb,
85 proto_tree *tree, int offset, int id_length, int length);
86 static void dissect_hello_area_address_clv(tvbuff_t *tvb,
87 proto_tree *tree, int offset, int id_length, int length);
88 static void dissect_hello_auth_clv(tvbuff_t *tvb,
89 proto_tree *tree, int offset, int id_length, int length);
90 static void dissect_hello_ipv6_int_addr_clv(tvbuff_t *tvb,
91 proto_tree *tree, int offset, int id_length, int length);
92 static void dissect_hello_ip_int_addr_clv(tvbuff_t *tvb,
93 proto_tree *tree, int offset, int id_length, int length);
94 static void dissect_hello_mt_clv(tvbuff_t *tvb,
95 proto_tree *tree, int offset, int id_length, int length);
96 static void dissect_hello_nlpid_clv(tvbuff_t *tvb,
97 proto_tree *tree, int offset, int id_length, int length);
98 static void dissect_hello_restart_clv(tvbuff_t *tvb,
99 proto_tree *tree, int offset, int id_length, int length);
102 static const isis_clv_handle_t clv_l1_hello_opts[] = {
104 ISIS_CLV_L1H_AREA_ADDRESS,
106 &ett_isis_hello_clv_area_addr,
107 dissect_hello_area_address_clv
110 ISIS_CLV_L1H_IS_NEIGHBORS,
112 &ett_isis_hello_clv_is_neighbors,
113 dissect_hello_is_neighbors_clv
116 ISIS_CLV_L1H_PADDING,
118 &ett_isis_hello_clv_padding,
119 dissect_hello_padding_clv
123 "Protocols Supported",
124 &ett_isis_hello_clv_nlpid,
125 dissect_hello_nlpid_clv
128 ISIS_CLV_L1H_IP_INTERFACE_ADDR,
129 "IP Interface address(es)",
130 &ett_isis_hello_clv_ipv4_int_addr,
131 dissect_hello_ip_int_addr_clv
134 ISIS_CLV_L1H_IPv6_INTERFACE_ADDR,
135 "IPv6 Interface address(es)",
136 &ett_isis_hello_clv_ipv6_int_addr,
137 dissect_hello_ipv6_int_addr_clv
140 ISIS_CLV_L1H_RESTART,
142 &ett_isis_hello_clv_restart,
143 dissect_hello_restart_clv
146 ISIS_CLV_L1H_AUTHENTICATION_NS,
147 "Authentication(non spec)",
148 &ett_isis_hello_clv_auth,
149 dissect_hello_auth_clv
152 ISIS_CLV_L1H_AUTHENTICATION,
154 &ett_isis_hello_clv_auth,
155 dissect_hello_auth_clv
160 &ett_isis_hello_clv_mt,
171 static const isis_clv_handle_t clv_l2_hello_opts[] = {
173 ISIS_CLV_L2H_AREA_ADDRESS,
175 &ett_isis_hello_clv_area_addr,
176 dissect_hello_area_address_clv
179 ISIS_CLV_L2H_IS_NEIGHBORS,
181 &ett_isis_hello_clv_is_neighbors,
182 dissect_hello_is_neighbors_clv
185 ISIS_CLV_L2H_PADDING,
187 &ett_isis_hello_clv_padding,
188 dissect_hello_padding_clv
192 "Protocols Supported",
193 &ett_isis_hello_clv_nlpid,
194 dissect_hello_nlpid_clv
197 ISIS_CLV_L2H_IP_INTERFACE_ADDR,
198 "IP Interface address(es)",
199 &ett_isis_hello_clv_ipv4_int_addr,
200 dissect_hello_ip_int_addr_clv
203 ISIS_CLV_L2H_IPv6_INTERFACE_ADDR,
204 "IPv6 Interface address(es)",
205 &ett_isis_hello_clv_ipv6_int_addr,
206 dissect_hello_ipv6_int_addr_clv
209 ISIS_CLV_L2H_AUTHENTICATION_NS,
210 "Authentication(non spec)",
211 &ett_isis_hello_clv_auth,
212 dissect_hello_auth_clv
215 ISIS_CLV_L2H_RESTART,
217 &ett_isis_hello_clv_restart,
218 dissect_hello_restart_clv
221 ISIS_CLV_L2H_AUTHENTICATION,
223 &ett_isis_hello_clv_auth,
224 dissect_hello_auth_clv
229 &ett_isis_hello_clv_mt,
240 static const isis_clv_handle_t clv_ptp_hello_opts[] = {
242 ISIS_CLV_PTP_AREA_ADDRESS,
244 &ett_isis_hello_clv_area_addr,
245 dissect_hello_area_address_clv
248 ISIS_CLV_PTP_PADDING,
250 &ett_isis_hello_clv_padding,
251 dissect_hello_padding_clv
255 "Protocols Supported",
256 &ett_isis_hello_clv_nlpid,
257 dissect_hello_nlpid_clv
260 ISIS_CLV_PTP_IP_INTERFACE_ADDR,
261 "IP Interface address(es)",
262 &ett_isis_hello_clv_ipv4_int_addr,
263 dissect_hello_ip_int_addr_clv
266 ISIS_CLV_PTP_IPv6_INTERFACE_ADDR,
267 "IPv6 Interface address(es)",
268 &ett_isis_hello_clv_ipv6_int_addr,
269 dissect_hello_ipv6_int_addr_clv
272 ISIS_CLV_PTP_AUTHENTICATION_NS,
273 "Authentication(non spec)",
274 &ett_isis_hello_clv_auth,
275 dissect_hello_auth_clv
278 ISIS_CLV_PTP_AUTHENTICATION,
280 &ett_isis_hello_clv_auth,
281 dissect_hello_auth_clv
284 ISIS_CLV_PTP_RESTART,
286 &ett_isis_hello_clv_restart,
287 dissect_hello_restart_clv
291 "Point-to-point Adjacency State",
292 &ett_isis_hello_clv_ptp_adj,
293 dissect_hello_ptp_adj_clv
298 &ett_isis_hello_clv_mt,
311 * Name: dissect_hello_restart_clv()
314 * Decode for a restart clv - only found in IIHs
315 * hence no call in the common clv dissector
320 dissect_hello_restart_clv(tvbuff_t *tvb,
321 proto_tree *tree, int offset, int id_length, int length)
325 restart_options = tvb_get_guint8(tvb, offset);
327 proto_tree_add_text ( tree, tvb, offset, 1,
328 "Restart Request bit %s, "
329 "Restart Acknowledgement bit %s",
330 ISIS_MASK_RESTART_RR(restart_options) ? "set" : "clear",
331 ISIS_MASK_RESTART_RA(restart_options) ? "set" : "clear");
332 proto_tree_add_text ( tree, tvb, offset+1, 2,
333 "Remaining holding time: %us",
334 tvb_get_ntohs(tvb, offset+1) );
338 * Name: dissect_hello_nlpid_clv()
341 * Decode for a hello packets NLPID clv. Calls into the
345 * tvbuff_t * : tvbuffer for packet data
346 * proto_tree * : proto tree to build on (may be null)
347 * int : current offset into packet data
348 * int : length of IDs in packet.
349 * int : length of this clv
352 * void, will modify proto_tree if not null.
355 dissect_hello_nlpid_clv(tvbuff_t *tvb,
356 proto_tree *tree, int offset, int id_length, int length)
358 isis_dissect_nlpid_clv(tvb, tree, offset, length);
362 * Name: dissect_hello_mt_clv()
365 * Decode for a hello packets Multi Topology clv. Calls into the
369 * tvbuff_t * : tvbuffer for packet data
370 * proto_tree * : proto tree to build on (may be null)
371 * int : current offset into packet data
372 * int : length of IDs in packet.
373 * int : length of this clv
376 * void, will modify proto_tree if not null.
380 dissect_hello_mt_clv(tvbuff_t *tvb,
381 proto_tree *tree, int offset, int id_length, int length)
383 isis_dissect_mt_clv(tvb, tree, offset, length,
384 hf_isis_hello_clv_mt );
388 * Name: dissect_hello_ip_int_addr_clv()
391 * Decode for a hello packets ip interface addr clv. Calls into the
395 * tvbuff_t * : tvbuffer for packet data
396 * proto_tree * : proto tree to build on (may be null)
397 * int : current offset into packet data
398 * int : length of IDs in packet.
399 * int : length of this clv
402 * void, will modify proto_tree if not null.
405 dissect_hello_ip_int_addr_clv(tvbuff_t *tvb,
406 proto_tree *tree, int offset, int id_length, int length)
408 isis_dissect_ip_int_clv(tvb, tree, offset, length,
409 hf_isis_hello_clv_ipv4_int_addr );
413 * Name: dissect_hello_ipv6_int_addr_clv()
416 * Decode for a hello packets ipv6 interface addr clv. Calls into the
420 * tvbuff_t * : tvbuffer for packet data
421 * proto_tree * : proto tree to build on (may be null)
422 * int : current offset into packet data
423 * int : length of IDs in packet.
424 * int : length of this clv
427 * void, will modify proto_tree if not null.
430 dissect_hello_ipv6_int_addr_clv(tvbuff_t *tvb,
431 proto_tree *tree, int offset, int id_length, int length)
433 isis_dissect_ipv6_int_clv(tvb, tree, offset, length,
434 hf_isis_hello_clv_ipv6_int_addr );
438 * Name: dissect_hello_auth_clv()
441 * Decode for a hello packets authenticaion clv. Calls into the
442 * clv common one. An auth inside a hello packet is a perlink
446 * tvbuff_t * : tvbuffer for packet data
447 * proto_tree * : proto tree to build on (may be null)
448 * int : current offset into packet data
449 * int : length of IDs in packet.
450 * int : length of this clv
453 * void, will modify proto_tree if not null.
456 dissect_hello_auth_clv(tvbuff_t *tvb,
457 proto_tree *tree, int offset, int id_length, int length)
459 isis_dissect_authentication_clv(tvb, tree, offset,
460 length, "authentication" );
464 * Name: dissect_hello_area_address_clv()
467 * Decode for a hello packets area address clv. Calls into the
471 * tvbuff_t * : tvbuffer for packet data
472 * proto_tree * : proto tree to build on (may be null)
473 * int : current offset into packet data
474 * int : length of IDs in packet.
475 * int : length of this clv
478 * void, will modify proto_tree if not null.
481 dissect_hello_area_address_clv(tvbuff_t *tvb,
482 proto_tree *tree, int offset, int id_length, int length)
484 isis_dissect_area_address_clv(tvb, tree, offset, length);
490 dissect_hello_ptp_adj_clv(tvbuff_t *tvb,
491 proto_tree *tree, int offset, int id_length, int length)
495 switch(tvb_get_guint8(tvb, offset)) {
497 strcpy(adj_state,"Up");
500 strcpy(adj_state,"Initializing");
503 strcpy(adj_state,"Down");
506 strcpy(adj_state,"<illegal value !!!>");
511 proto_tree_add_text ( tree, tvb, offset, 1,
512 "Adjacency State: %s", adj_state );
515 proto_tree_add_text ( tree, tvb, offset, 1,
516 "Adjacency State: %s", adj_state );
517 proto_tree_add_text ( tree, tvb, offset+1, 4,
518 "Extended Local circuit ID: 0x%08x", tvb_get_ntohl(tvb, offset+1) );
521 proto_tree_add_text ( tree, tvb, offset, 1,
522 "Adjacency State: %s", adj_state );
523 proto_tree_add_text ( tree, tvb, offset+1, 4,
524 "Extended Local circuit ID: 0x%08x", tvb_get_ntohl(tvb, offset+1) );
525 proto_tree_add_text ( tree, tvb, offset+5, 6,
526 "Neighbor SystemID: %s", print_system_id( tvb_get_ptr(tvb, offset+5, 6), 6 ) );
529 proto_tree_add_text ( tree, tvb, offset, 1,
530 "Adjacency State: %s", adj_state );
531 proto_tree_add_text ( tree, tvb, offset+1, 4,
532 "Extended Local circuit ID: 0x%08x", tvb_get_ntohl(tvb, offset+1) );
533 proto_tree_add_text ( tree, tvb, offset+5, 6,
534 "Neighbor SystemID: %s", print_system_id( tvb_get_ptr(tvb, offset+5, 6), 6 ) );
535 proto_tree_add_text ( tree, tvb, offset+11, 4,
536 "Neighbor Extended Local circuit ID: 0x%08x", tvb_get_ntohl(tvb, offset+11) );
539 isis_dissect_unknown(tvb, tree, offset,
540 "malformed TLV (%d vs 1,5,11,15)", length );
546 * Name: isis_dissect_is_neighbors_clv()
549 * Take apart a IS neighbor packet. A neighbor is n 6 byte packets.
550 * (they tend to be an 802.3 MAC address, but its not required).
553 * tvbuff_t * : tvbuffer for packet data
554 * proto_tree * : protocol display tree to fill out. May be NULL
555 * int : offset into packet data where we are.
556 * int : length of IDs in packet.
557 * int : length of clv we are decoding
560 * void, but we will add to proto tree if !NULL.
563 dissect_hello_is_neighbors_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
564 int id_length, int length)
566 while ( length > 0 ) {
568 isis_dissect_unknown(tvb, tree, offset,
569 "short is neighbor (%d vs 6)", length );
573 * Lets turn the area address into "standard" 0000.0000.etc
577 proto_tree_add_text ( tree, tvb, offset, 6,
578 "IS Neighbor: %s", get_ether_name( tvb_get_ptr(tvb, offset, 6)) );
586 * Name: dissect_hello_padding_clv()
589 * Decode for a hello packet's padding clv. Padding does nothing,
593 * tvbuff_t * : tvbuffer for packet data
594 * proto_tree * : proto tree to build on (may be null)
595 * int : current offset into packet data
596 * int : length of IDs in packet.
597 * int : length of this clv
603 dissect_hello_padding_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
604 int id_length, int length)
606 /* nothing to do here! */
611 * Name: isis_dissect_isis_hello()
614 * This procedure rips apart the various types of ISIS hellos. L1H and
615 * L2H's are identical for the most part, while the PTP hello has
619 * tvbuff_t * : tvbuffer for packet data
620 * proto_tree * : protocol display tree to add to. May be NULL.
621 * int offset : our offset into packet data.
622 * int : hello type, a la packet-isis.h ISIS_TYPE_* values
623 * int : header length of packet.
624 * int : length of IDs in packet.
627 * void, will modify proto_tree if not NULL.
630 isis_dissect_isis_hello(tvbuff_t *tvb, proto_tree *tree, int offset,
631 int hello_type, int header_length, int id_length)
634 proto_tree *hello_tree = NULL;
637 const guint8 *source_id;
639 const guint8 *lan_id;
642 ti = proto_tree_add_text(tree, tvb, offset, -1, "ISIS HELLO");
643 hello_tree = proto_item_add_subtree(ti, ett_isis_hello);
644 octet = tvb_get_guint8(tvb, offset);
645 proto_tree_add_uint_format(hello_tree,
646 hf_isis_hello_circuit_reserved,
647 tvb, offset, 1, octet,
648 "Circuit type : %s, reserved(0x%02x == 0)",
649 val_to_str(octet&ISIS_HELLO_CTYPE_MASK,
650 isis_hello_circuit_type_vals,
652 octet&ISIS_HELLO_CT_RESERVED_MASK
658 source_id = tvb_get_ptr(tvb, offset, id_length);
659 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, tvb,
660 offset, id_length, source_id,
661 "SystemID{ Sender of PDU } : %s",
662 print_system_id( source_id, id_length ) );
667 proto_tree_add_item(hello_tree, hf_isis_hello_holding_timer, tvb,
672 pdu_length = tvb_get_ntohs(tvb, offset);
674 proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, tvb,
675 offset, 2, pdu_length);
679 if (hello_type == ISIS_TYPE_PTP_HELLO) {
681 proto_tree_add_item(hello_tree, hf_isis_hello_local_circuit_id, tvb,
688 octet = tvb_get_guint8(tvb, offset);
689 proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, tvb,
691 "Priority : %d, reserved(0x%02x == 0)",
692 octet&ISIS_HELLO_PRIORITY_MASK,
693 octet&ISIS_HELLO_P_RESERVED_MASK );
698 lan_id = tvb_get_ptr(tvb, offset, id_length+1);
699 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, tvb,
700 offset, id_length + 1, lan_id,
701 "SystemID{ Designated IS } : %s",
702 print_system_id( lan_id, id_length + 1 ) );
704 offset += id_length + 1;
708 len -= header_length;
710 isis_dissect_unknown(tvb, tree, offset,
711 "Packet header length %d went beyond packet",
716 * Now, we need to decode our CLVs. We need to pass in
717 * our list of valid ones!
719 if (hello_type == ISIS_TYPE_L1_HELLO){
720 isis_dissect_clvs(tvb, hello_tree, offset,
721 clv_l1_hello_opts, len, id_length,
722 ett_isis_hello_clv_unknown);
723 } else if (hello_type == ISIS_TYPE_L2_HELLO) {
724 isis_dissect_clvs(tvb, hello_tree, offset,
725 clv_l2_hello_opts, len, id_length,
726 ett_isis_hello_clv_unknown);
728 isis_dissect_clvs(tvb, hello_tree, offset,
729 clv_ptp_hello_opts, len, id_length,
730 ett_isis_hello_clv_unknown);
735 * Name: isis_register_hello()
738 * Register our protocol sub-sets with protocol manager.
741 * int : protocol index for the ISIS protocol
747 isis_register_hello(int proto_isis) {
748 static hf_register_info hf[] = {
749 { &hf_isis_hello_circuit_reserved,
750 { "Circuit type ", "isis.hello.circuit_type",
751 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
753 { &hf_isis_hello_source_id,
754 { "SystemID{ Sender of PDU } ", "isis.hello.source_id",
755 FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
757 { &hf_isis_hello_holding_timer,
758 { "Holding timer ", "isis.hello.holding_timer",
759 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
761 { &hf_isis_hello_pdu_length,
762 { "PDU length ", "isis.hello.pdu_length",
763 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
765 { &hf_isis_hello_priority_reserved,
766 { "Priority ", "isis.hello.priority",
767 FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_P_RESERVED_MASK, "", HFILL }},
769 { &hf_isis_hello_lan_id,
770 { "SystemID{ Designated IS } ", "isis.hello.lan_id",
771 FT_BYTES, BASE_DEC, NULL, 0x0, "", HFILL }},
773 { &hf_isis_hello_local_circuit_id,
774 { "Local circuit ID ", "isis.hello.local_circuit_id",
775 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
777 { &hf_isis_hello_clv_ipv4_int_addr,
778 { "IPv4 interface address ", "isis.hello.clv_ipv4_int_addr",
779 FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
781 { &hf_isis_hello_clv_ipv6_int_addr,
782 { "IPv6 interface address ", "isis.hello.clv_ipv6_int_addr",
783 FT_IPv6, BASE_NONE, NULL, 0x0, "", HFILL }},
785 { &hf_isis_hello_clv_ptp_adj,
786 { "Point-to-point Adjacency ", "isis.hello.clv_ptp_adj",
787 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
789 { &hf_isis_hello_clv_mt,
790 { "MT-ID ", "isis.hello.clv_mt",
791 FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
793 static gint *ett[] = {
795 &ett_isis_hello_clv_area_addr,
796 &ett_isis_hello_clv_is_neighbors,
797 &ett_isis_hello_clv_padding,
798 &ett_isis_hello_clv_unknown,
799 &ett_isis_hello_clv_nlpid,
800 &ett_isis_hello_clv_auth,
801 &ett_isis_hello_clv_ipv4_int_addr,
802 &ett_isis_hello_clv_ipv6_int_addr,
803 &ett_isis_hello_clv_ptp_adj,
804 &ett_isis_hello_clv_mt,
805 &ett_isis_hello_clv_restart
808 proto_register_field_array(proto_isis, hf, array_length(hf));
809 proto_register_subtree_array(ett, array_length(ett));