2 * Routines for decoding isis hello packets and their CLVs
4 * $Id: packet-isis-hello.c,v 1.8 2000/05/31 05:07:12 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;
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, frame_data *fd, proto_tree *tree);
78 static void dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
79 guint length, frame_data *fd, proto_tree *tree);
80 static void dissect_hello_padding_clv(const u_char *pd, int offset,
81 guint length, frame_data *fd, proto_tree *tree);
82 static void dissect_hello_nlpid_clv(const u_char *pd, int offset,
83 guint 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, frame_data *fd, proto_tree *tree);
86 static void dissect_hello_auth_clv(const u_char *pd, int offset,
87 guint 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 * frame_data * : frame data
248 * proto_tree * : proto tree to build on (may be null)
251 * void, will modify proto_tree if not null.
254 dissect_hello_nlpid_clv(const u_char *pd, int offset,
255 guint length, frame_data *fd, proto_tree *tree) {
256 isis_dissect_nlpid_clv(pd, offset, length, fd, tree );
260 * Name: dissect_hello_ip_int_addr_clv()
263 * Decode for a hello packets ip interface addr clv. Calls into the
267 * u_char * : packet data
268 * int : current offset into packet data
269 * guint : length of this clv
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_ip_int_addr_clv(const u_char *pd, int offset,
278 guint length, frame_data *fd, proto_tree *tree) {
279 isis_dissect_ip_int_clv(pd, offset, length, fd, tree,
280 hf_isis_hello_clv_ipv4_int_addr );
284 * Name: dissect_hello_auth_clv()
287 * Decode for a hello packets authenticaion clv. Calls into the
288 * clv common one. An auth inside a hello packet is a perlink
292 * u_char * : packet data
293 * int : current offset into packet data
294 * guint : length of this clv
295 * frame_data * : frame data
296 * proto_tree * : proto tree to build on (may be null)
299 * void, will modify proto_tree if not null.
302 dissect_hello_auth_clv(const u_char *pd, int offset,
303 guint length, frame_data *fd, proto_tree *tree) {
304 isis_dissect_authentication_clv(pd, offset, length, fd, tree,
305 "Per Link authentication" );
309 * Name: dissect_hello_area_address_clv()
312 * Decode for a hello packets area address clv. Calls into the
316 * u_char * : packet data
317 * int : current offset into packet data
318 * guint : length of this clv
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_area_address_clv(const u_char *pd, int offset,
327 guint length, frame_data *fd, proto_tree *tree) {
328 isis_dissect_area_address_clv(pd, offset, length, fd, tree );
332 * Name: isis_dissect_is_neighbors_clv()
335 * Take apart a IS neighbor packet. A neighbor is n 6 byte packets.
336 * (they tend to be an 802.3 MAC address, but its not required).
339 * u_char * : packet data
340 * int : offset into packet data where we are.
341 * guint : length of clv we are decoding
342 * frame_data * : frame data (complete frame)
343 * proto_tree * : protocol display tree to fill out. May be NULL
344 * gint : tree id to use for proto tree.
347 * void, but we will add to proto tree if !NULL.
350 dissect_hello_is_neighbors_clv(const u_char *pd, int offset,
351 guint length, frame_data *fd, proto_tree *tree ) {
352 while ( length > 0 ) {
354 isis_dissect_unknown(offset, length, tree, fd,
355 "short is neighbor (%d vs 6)", length );
359 * Lets turn the area address into "standard" 0000.0000.etc
363 proto_tree_add_text ( tree, NullTVB, offset, 6,
364 "IS Neighbor: %s", print_system_id( pd + offset, 6 ) );
373 * Name: dissect_hello_padding_clv()
376 * Decode for a hello packet's padding clv. Padding does nothing,
380 * u_char * : packet data
381 * int : current offset into packet data
382 * guint : length of this clv
383 * frame_data * : frame data
384 * proto_tree * : proto tree to build on (may be null)
390 dissect_hello_padding_clv(const u_char *pd, int offset, guint length,
391 frame_data *fd, proto_tree *tree) {
392 /* nothing to do here! */
396 * Name: isis_dissect_isis_hello()
399 * This procedure rips apart the various types of ISIS hellos. L1H and
400 * L2H's are identicle for the most part, while the PTP hello has
404 * int : hello type, alla packet-isis.h ISIS_TYPE_* values
405 * int : header length of packet.
406 * u_char * : packet data
407 * int offset : our offset into packet data.
408 * frame_data * : frame data
409 * proto_tree * : protocol display tree to add to. May be NULL.
412 * void, will modify proto_tree if not NULL.
415 isis_dissect_isis_hello(int hello_type, int header_length,
416 const u_char *pd, int offset, frame_data *fd, proto_tree *tree){
419 proto_tree *hello_tree = NULL;
423 if (hello_type == ISIS_TYPE_PTP_HELLO) {
424 hlen = sizeof(*ihp) - 6; /* make length correct */
429 if (!BYTES_ARE_IN_FRAME(offset, hlen)) {
430 isis_dissect_unknown(offset, hlen, tree, fd,
431 "not enough capture data for header (%d vs %d)",
436 ihp = (isis_hello_t *) &pd[offset];
439 ti = proto_tree_add_item(tree, proto_isis_hello, NullTVB,
440 offset, END_OF_FRAME, FALSE);
441 hello_tree = proto_item_add_subtree(ti, ett_isis_hello);
442 proto_tree_add_uint_format(hello_tree,
443 hf_isis_hello_circuit_reserved,
444 NullTVB, offset, 1, ihp->isis_hello_circuit_reserved,
445 "Circuit type : %s, reserved(0x%02x == 0)",
446 val_to_str(ihp->isis_hello_circuit,
447 isis_hello_circuit_type_vals,
449 ihp->isis_hello_creserved
452 proto_tree_add_string_format(hello_tree, hf_isis_hello_lan_id, NullTVB,
453 offset + 1, 6, ihp->isis_hello_source_id,
454 "SystemID{ Sender of PDU } : %s",
455 print_system_id( pd + offset + 1, 6 ) );
456 proto_tree_add_uint(hello_tree, hf_isis_hello_holding_timer, NullTVB,
457 offset + 7, 2,pntohs(&ihp->isis_hello_holding_timer[0]));
458 proto_tree_add_uint(hello_tree, hf_isis_hello_pdu_length, NullTVB,
459 offset + 9, 2,pntohs(&ihp->isis_hello_pdu_length[0]));
460 proto_tree_add_uint_format(hello_tree, hf_isis_hello_priority_reserved, NullTVB,
461 offset + 11, 1, ihp->isis_hello_priority_reserved,
462 "Priority : %d, reserved(0x%02x == 0)",
463 ihp->isis_hello_priority, ihp->isis_hello_preserved );
464 if (hello_type == ISIS_TYPE_PTP_HELLO) {
465 proto_tree_add_uint(hello_tree, hf_isis_hello_local_circuit_id, NullTVB,
466 offset + 12, 1, ihp->isis_hello_lan_id[0] );
468 proto_tree_add_string_format(hello_tree, hf_isis_hello_lan_id, NullTVB,
469 offset + 12, 7, ihp->isis_hello_lan_id,
470 "SystemID{ Designated IS } : %s",
471 print_system_id( pd + offset + 12, 7 ) );
476 len = pntohs(&ihp->isis_hello_pdu_length[0]);
477 len -= header_length;
479 isis_dissect_unknown(offset, header_length, tree, fd,
480 "packet header length %d went beyond packet",
485 * Now, we need to decode our CLVs. We need to pass in
486 * our list of valid ones!
488 if (hello_type == ISIS_TYPE_L1_HELLO){
489 isis_dissect_clvs ( clv_l1_hello_opts, len, pd, offset, fd,
490 hello_tree, ett_isis_hello_clv_unknown );
491 } else if (hello_type == ISIS_TYPE_L2_HELLO) {
492 isis_dissect_clvs ( clv_l2_hello_opts, len, pd, offset, fd,
493 hello_tree, ett_isis_hello_clv_unknown );
495 isis_dissect_clvs ( clv_ptp_hello_opts, len, pd, offset, fd,
496 hello_tree, ett_isis_hello_clv_unknown );
501 * Name: proto_register_isis_hello()
504 * Register our protocol sub-sets with protocol manager.
505 * NOTE: this procedure is autolinked by the makefile process that
515 proto_register_isis_hello(void) {
516 static hf_register_info hf[] = {
517 { &hf_isis_hello_circuit_reserved,
518 { "Circuit type ", "isis_hello.circuite_type",
519 FT_UINT8, BASE_HEX, NULL, 0x0, "" }},
521 { &hf_isis_hello_source_id,
522 { "SystemID{ Sender of PDU } ", "isis_hello.source_id",
523 FT_ETHER, BASE_HEX, NULL, 0x0, "" }},
525 { &hf_isis_hello_holding_timer,
526 { "Holding timer ", "isis_hello.holding_timer",
527 FT_UINT16, BASE_DEC, NULL, 0x0, "" }},
529 { &hf_isis_hello_pdu_length,
530 { "PDU length ", "isis_hello.pdu_length",
531 FT_UINT16, BASE_DEC, NULL, 0x0, "" }},
533 { &hf_isis_hello_priority_reserved,
534 { "Priority ", "isis_hello.priority",FT_UINT8, BASE_DEC, NULL,
535 ISIS_HELLO_P_RESERVED_MASK, "" }},
537 { &hf_isis_hello_lan_id,
538 { "SystemID{ Designated IS } ", "isis_hello.lan_id", FT_STRING, BASE_DEC, NULL,
541 { &hf_isis_hello_local_circuit_id,
542 { "Local circuit ID ", "isis_hello.local_circuit_id", FT_UINT8,
543 BASE_DEC, NULL, 0x0, "" }},
545 { &hf_isis_hello_clv_ipv4_int_addr,
546 { "IPv4 interface address ", "isis_hello.clv_ipv4_int_addr", FT_IPv4,
547 BASE_NONE, NULL, 0x0, "" }},
550 static gint *ett[] = {
552 &ett_isis_hello_clv_area_addr,
553 &ett_isis_hello_clv_is_neighbors,
554 &ett_isis_hello_clv_padding,
555 &ett_isis_hello_clv_unknown,
556 &ett_isis_hello_clv_nlpid,
557 &ett_isis_hello_clv_auth,
558 &ett_isis_hello_clv_ipv4_int_addr,
561 proto_isis_hello = proto_register_protocol("ISIS HELLO", "isis_hello");
562 proto_register_field_array(proto_isis_hello, hf, array_length(hf));
563 proto_register_subtree_array(ett, array_length(ett));