2 * Routines for decoding isis hello packets and their CLVs
4 * $Id: packet-isis-hello.c,v 1.10 2000/08/13 14:08:19 deniel 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;
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;
66 static const value_string isis_hello_circuit_type_vals[] = {
67 { ISIS_HELLO_TYPE_RESERVED, "Reserved 0 (discard PDU)"},
68 { ISIS_HELLO_TYPE_LEVEL_1, "Level 1 only"},
69 { ISIS_HELLO_TYPE_LEVEL_2, "Level 2 only"},
70 { ISIS_HELLO_TYPE_LEVEL_12, "Level 1 and 2"},
74 * Predclare dissectors for use in clv dissection.
76 static void dissect_hello_area_address_clv(const u_char *pd, int offset,
77 guint length, int id_length, frame_data *fd, proto_tree *tree);
78 static void dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
79 guint length, int id_length, frame_data *fd, proto_tree *tree);
80 static void dissect_hello_padding_clv(const u_char *pd, int offset,
81 guint length, int id_length, frame_data *fd, proto_tree *tree);
82 static void dissect_hello_nlpid_clv(const u_char *pd, int offset,
83 guint length, int id_length, frame_data *fd, proto_tree *tree);
84 static void dissect_hello_ip_int_addr_clv(const u_char *pd, int offset,
85 guint length, int id_length, frame_data *fd, proto_tree *tree);
86 static void dissect_hello_auth_clv(const u_char *pd, int offset,
87 guint length, int id_length, frame_data *fd, proto_tree *tree);
89 static const isis_clv_handle_t clv_l1_hello_opts[] = {
91 ISIS_CLV_L1H_AREA_ADDRESS,
93 &ett_isis_hello_clv_area_addr,
94 dissect_hello_area_address_clv
97 ISIS_CLV_L1H_IS_NEIGHBORS,
99 &ett_isis_hello_clv_is_neighbors,
100 dissect_hello_is_neighbors_clv
103 ISIS_CLV_L1H_PADDING,
105 &ett_isis_hello_clv_padding,
106 dissect_hello_padding_clv
111 &ett_isis_hello_clv_nlpid,
112 dissect_hello_nlpid_clv
115 ISIS_CLV_L1H_IP_INTERFACE_ADDR,
116 "IP Interface address(es)",
117 &ett_isis_hello_clv_ipv4_int_addr,
118 dissect_hello_ip_int_addr_clv
121 ISIS_CLV_L1H_AUTHENTICATION_NS,
122 "Authentication(non spec)",
123 &ett_isis_hello_clv_auth,
124 dissect_hello_auth_clv
127 ISIS_CLV_L1H_AUTHENTICATION,
129 &ett_isis_hello_clv_auth,
130 dissect_hello_auth_clv
140 static const isis_clv_handle_t clv_l2_hello_opts[] = {
142 ISIS_CLV_L2H_AREA_ADDRESS,
144 &ett_isis_hello_clv_area_addr,
145 dissect_hello_area_address_clv
148 ISIS_CLV_L2H_IS_NEIGHBORS,
150 &ett_isis_hello_clv_is_neighbors,
151 dissect_hello_is_neighbors_clv
154 ISIS_CLV_L2H_PADDING,
156 &ett_isis_hello_clv_padding,
157 dissect_hello_padding_clv
162 &ett_isis_hello_clv_nlpid,
163 dissect_hello_nlpid_clv
166 ISIS_CLV_L2H_IP_INTERFACE_ADDR,
167 "IP Interface address(es)",
168 &ett_isis_hello_clv_ipv4_int_addr,
169 dissect_hello_ip_int_addr_clv
172 ISIS_CLV_L2H_AUTHENTICATION_NS,
173 "Authentication(non spec)",
174 &ett_isis_hello_clv_auth,
175 dissect_hello_auth_clv
178 ISIS_CLV_L2H_AUTHENTICATION,
180 &ett_isis_hello_clv_auth,
181 dissect_hello_auth_clv
191 static const isis_clv_handle_t clv_ptp_hello_opts[] = {
193 ISIS_CLV_PTP_AREA_ADDRESS,
195 &ett_isis_hello_clv_area_addr,
196 dissect_hello_area_address_clv
199 ISIS_CLV_PTP_PADDING,
201 &ett_isis_hello_clv_padding,
202 dissect_hello_padding_clv
207 &ett_isis_hello_clv_nlpid,
208 dissect_hello_nlpid_clv
211 ISIS_CLV_PTP_IP_INTERFACE_ADDR,
212 "IP Interface address(es)",
213 &ett_isis_hello_clv_ipv4_int_addr,
214 dissect_hello_ip_int_addr_clv
217 ISIS_CLV_PTP_AUTHENTICATION_NS,
218 "Authentication(non spec)",
219 &ett_isis_hello_clv_auth,
220 dissect_hello_auth_clv
223 ISIS_CLV_PTP_AUTHENTICATION,
225 &ett_isis_hello_clv_auth,
226 dissect_hello_auth_clv
237 * Name: dissect_hello_nlpid_clv()
240 * Decode for a hello packets NLPID clv. Calls into the
244 * u_char * : packet data
245 * int : current offset into packet data
246 * guint : length of this clv
247 * int : length of IDs in packet.
248 * frame_data * : frame data
249 * proto_tree * : proto tree to build on (may be null)
252 * void, will modify proto_tree if not null.
255 dissect_hello_nlpid_clv(const u_char *pd, int offset,
256 guint length, int id_length, frame_data *fd, proto_tree *tree) {
257 isis_dissect_nlpid_clv(pd, offset, length, fd, tree );
261 * Name: dissect_hello_ip_int_addr_clv()
264 * Decode for a hello packets ip interface addr clv. Calls into the
268 * u_char * : packet data
269 * int : current offset into packet data
270 * guint : length of this clv
271 * int : length of IDs in packet.
272 * frame_data * : frame data
273 * proto_tree * : proto tree to build on (may be null)
276 * void, will modify proto_tree if not null.
279 dissect_hello_ip_int_addr_clv(const u_char *pd, int offset,
280 guint length, int id_length, frame_data *fd, proto_tree *tree) {
281 isis_dissect_ip_int_clv(pd, offset, length, fd, tree,
282 hf_isis_hello_clv_ipv4_int_addr );
286 * Name: dissect_hello_auth_clv()
289 * Decode for a hello packets authenticaion clv. Calls into the
290 * clv common one. An auth inside a hello packet is a perlink
294 * u_char * : packet data
295 * int : current offset into packet data
296 * guint : length of this clv
297 * int : length of IDs in packet.
298 * frame_data * : frame data
299 * proto_tree * : proto tree to build on (may be null)
302 * void, will modify proto_tree if not null.
305 dissect_hello_auth_clv(const u_char *pd, int offset,
306 guint length, int id_length, frame_data *fd, proto_tree *tree) {
307 isis_dissect_authentication_clv(pd, offset, length, fd, tree,
308 "Per Link authentication" );
312 * Name: dissect_hello_area_address_clv()
315 * Decode for a hello packets area address clv. Calls into the
319 * u_char * : packet data
320 * int : current offset into packet data
321 * guint : length of this clv
322 * int : length of IDs in packet.
323 * frame_data * : frame data
324 * proto_tree * : proto tree to build on (may be null)
327 * void, will modify proto_tree if not null.
330 dissect_hello_area_address_clv(const u_char *pd, int offset,
331 guint length, int id_length, frame_data *fd, proto_tree *tree) {
332 isis_dissect_area_address_clv(pd, offset, length, fd, tree );
336 * Name: isis_dissect_is_neighbors_clv()
339 * Take apart a IS neighbor packet. A neighbor is n 6 byte packets.
340 * (they tend to be an 802.3 MAC address, but its not required).
343 * u_char * : packet data
344 * int : offset into packet data where we are.
345 * guint : length of clv we are decoding
346 * int : length of IDs in packet.
347 * frame_data * : frame data (complete frame)
348 * proto_tree * : protocol display tree to fill out. May be NULL
349 * gint : tree id to use for proto tree.
352 * void, but we will add to proto tree if !NULL.
355 dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
356 guint length, int id_length, frame_data *fd, proto_tree *tree ) {
357 while ( length > 0 ) {
359 isis_dissect_unknown(offset, length, tree, fd,
360 "short is neighbor (%d vs 6)", length );
364 * Lets turn the area address into "standard" 0000.0000.etc
368 proto_tree_add_text ( tree, NullTVB, offset, 6,
369 "IS Neighbor: %s", print_system_id( pd + offset, 6 ) );
378 * Name: dissect_hello_padding_clv()
381 * Decode for a hello packet's padding clv. Padding does nothing,
385 * u_char * : packet data
386 * int : current offset into packet data
387 * guint : length of this clv
388 * int : length of IDs in packet.
389 * frame_data * : frame data
390 * proto_tree * : proto tree to build on (may be null)
396 dissect_hello_padding_clv(const u_char *pd, int offset, guint length,
397 int id_length, frame_data *fd, proto_tree *tree) {
398 /* nothing to do here! */
402 * Name: isis_dissect_isis_hello()
405 * This procedure rips apart the various types of ISIS hellos. L1H and
406 * L2H's are identical for the most part, while the PTP hello has
410 * int : hello type, a la packet-isis.h ISIS_TYPE_* values
411 * int : header length of packet.
412 * int : length of IDs in packet.
413 * u_char * : packet data
414 * int offset : our offset into packet data.
415 * frame_data * : frame data
416 * proto_tree * : protocol display tree to add to. May be NULL.
419 * void, will modify proto_tree if not NULL.
422 isis_dissect_isis_hello(int hello_type, int header_length, int id_length,
423 const u_char *pd, int offset, frame_data *fd, proto_tree *tree){
425 proto_tree *hello_tree = NULL;
430 OLD_CHECK_DISPLAY_AS_DATA(proto_isis_hello, pd, offset, fd, tree);
432 if (hello_type == ISIS_TYPE_PTP_HELLO) {
433 hlen = 1+id_length+2+2+1;
435 hlen = 1+id_length+2+2+1+id_length+1;
438 if (!BYTES_ARE_IN_FRAME(offset, hlen)) {
439 isis_dissect_unknown(offset, hlen, tree, fd,
440 "not enough capture data for header (%d vs %d)",
446 ti = proto_tree_add_item(tree, proto_isis_hello, NullTVB,
447 offset, END_OF_FRAME, FALSE);
448 hello_tree = proto_item_add_subtree(ti, ett_isis_hello);
449 proto_tree_add_uint_format(hello_tree,
450 hf_isis_hello_circuit_reserved,
451 NullTVB, offset, 1, pd[offset],
452 "Circuit type : %s, reserved(0x%02x == 0)",
453 val_to_str(pd[offset]&ISIS_HELLO_CTYPE_MASK,
454 isis_hello_circuit_type_vals,
456 pd[offset]&ISIS_HELLO_CT_RESERVED_MASK
462 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, NullTVB,
463 offset, id_length, &pd[offset],
464 "SystemID{ Sender of PDU } : %s",
465 print_system_id( pd + offset, id_length ) );
470 proto_tree_add_uint(hello_tree, hf_isis_hello_holding_timer, NullTVB,
471 offset, 2, pntohs(&pd[offset]));
475 pdu_length = pntohs(&pd[offset]);
477 proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, NullTVB,
478 offset, 2, pdu_length);
483 proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, NullTVB,
484 offset, 1, pd[offset],
485 "Priority : %d, reserved(0x%02x == 0)",
486 pd[offset]&ISIS_HELLO_PRIORITY_MASK,
487 pd[offset]&ISIS_HELLO_P_RESERVED_MASK );
491 if (hello_type == ISIS_TYPE_PTP_HELLO) {
493 proto_tree_add_uint(hello_tree, hf_isis_hello_local_circuit_id, NullTVB,
494 offset, 1, pd[offset] );
499 proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, NullTVB,
500 offset, id_length + 1, &pd[offset],
501 "SystemID{ Designated IS } : %s",
502 print_system_id( pd + offset, id_length + 1 ) );
504 offset += id_length + 1;
508 len -= header_length;
510 isis_dissect_unknown(offset, header_length, tree, fd,
511 "packet header length %d went beyond packet",
516 * Now, we need to decode our CLVs. We need to pass in
517 * our list of valid ones!
519 if (hello_type == ISIS_TYPE_L1_HELLO){
520 isis_dissect_clvs ( clv_l1_hello_opts, len, id_length, pd,
521 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
522 } else if (hello_type == ISIS_TYPE_L2_HELLO) {
523 isis_dissect_clvs ( clv_l2_hello_opts, len, id_length, pd,
524 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
526 isis_dissect_clvs ( clv_ptp_hello_opts, len, id_length, pd,
527 offset, fd, hello_tree, ett_isis_hello_clv_unknown );
532 * Name: proto_register_isis_hello()
535 * Register our protocol sub-sets with protocol manager.
536 * NOTE: this procedure is autolinked by the makefile process that
546 proto_register_isis_hello(void) {
547 static hf_register_info hf[] = {
548 { &hf_isis_hello_circuit_reserved,
549 { "Circuit type ", "isis_hello.circuite_type",
550 FT_UINT8, BASE_HEX, NULL, 0x0, "" }},
552 { &hf_isis_hello_source_id,
553 { "SystemID{ Sender of PDU } ", "isis_hello.source_id",
554 FT_BYTES, BASE_HEX, NULL, 0x0, "" }},
556 { &hf_isis_hello_holding_timer,
557 { "Holding timer ", "isis_hello.holding_timer",
558 FT_UINT16, BASE_DEC, NULL, 0x0, "" }},
560 { &hf_isis_hello_pdu_length,
561 { "PDU length ", "isis_hello.pdu_length",
562 FT_UINT16, BASE_DEC, NULL, 0x0, "" }},
564 { &hf_isis_hello_priority_reserved,
565 { "Priority ", "isis_hello.priority",
566 FT_UINT8, BASE_DEC, NULL, ISIS_HELLO_P_RESERVED_MASK, "" }},
568 { &hf_isis_hello_lan_id,
569 { "SystemID{ Designated IS } ", "isis_hello.lan_id",
570 FT_BYTES, BASE_DEC, NULL, 0x0, "" }},
572 { &hf_isis_hello_local_circuit_id,
573 { "Local circuit ID ", "isis_hello.local_circuit_id",
574 FT_UINT8, BASE_DEC, NULL, 0x0, "" }},
576 { &hf_isis_hello_clv_ipv4_int_addr,
577 { "IPv4 interface address ", "isis_hello.clv_ipv4_int_addr",
578 FT_IPv4, BASE_NONE, NULL, 0x0, "" }},
581 static gint *ett[] = {
583 &ett_isis_hello_clv_area_addr,
584 &ett_isis_hello_clv_is_neighbors,
585 &ett_isis_hello_clv_padding,
586 &ett_isis_hello_clv_unknown,
587 &ett_isis_hello_clv_nlpid,
588 &ett_isis_hello_clv_auth,
589 &ett_isis_hello_clv_ipv4_int_addr,
592 proto_isis_hello = proto_register_protocol("ISIS HELLO", "isis_hello");
593 proto_register_field_array(proto_isis_hello, hf, array_length(hf));
594 proto_register_subtree_array(ett, array_length(ett));