2 * Routines for NetWare Link Services Protocol
4 * $Id: packet-nlsp.c,v 1.7 2003/10/06 08:35:30 guy Exp $
6 * Based on ISIS dissector by Stuart Stanley <stuarts@mxmail.net>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * 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.
34 #include <epan/packet.h>
35 #include "packet-ipx.h"
37 /* NLSP base header */
38 static int proto_nlsp = -1;
40 static int hf_nlsp_irpd = -1;
41 static int hf_nlsp_header_length = -1;
42 static int hf_nlsp_minor_version = -1;
43 static int hf_nlsp_nr = -1;
44 static int hf_nlsp_type = -1;
45 static int hf_nlsp_major_version = -1;
46 static int hf_nlsp_packet_length = -1;
47 static int hf_nlsp_hello_state = -1;
48 static int hf_nlsp_hello_multicast = -1;
49 static int hf_nlsp_hello_circuit_type = -1;
50 static int hf_nlsp_hello_holding_timer = -1;
51 static int hf_nlsp_hello_priority = -1;
52 static int hf_nlsp_lsp_sequence_number = -1;
53 static int hf_nlsp_lsp_checksum = -1;
54 static int hf_nlsp_lsp_p = -1;
55 static int hf_nlsp_lsp_attached_flag = -1;
56 static int hf_nlsp_lsp_lspdbol = -1;
57 static int hf_nlsp_lsp_router_type = -1;
59 static gint ett_nlsp = -1;
60 static gint ett_nlsp_hello_clv_area_addr = -1;
61 static gint ett_nlsp_hello_clv_neighbors = -1;
62 static gint ett_nlsp_hello_local_mtu = -1;
63 static gint ett_nlsp_hello_clv_unknown = -1;
64 static gint ett_nlsp_lsp_info = -1;
65 static gint ett_nlsp_lsp_clv_area_addr = -1;
66 static gint ett_nlsp_lsp_clv_mgt_info = -1;
67 static gint ett_nlsp_lsp_clv_link_info = -1;
68 static gint ett_nlsp_lsp_clv_svcs_info = -1;
69 static gint ett_nlsp_lsp_clv_ext_routes = -1;
70 static gint ett_nlsp_lsp_clv_unknown = -1;
71 static gint ett_nlsp_csnp_lsp_entries = -1;
72 static gint ett_nlsp_csnp_lsp_entry = -1;
73 static gint ett_nlsp_csnp_clv_unknown = -1;
74 static gint ett_nlsp_psnp_lsp_entries = -1;
75 static gint ett_nlsp_psnp_lsp_entry = -1;
76 static gint ett_nlsp_psnp_clv_unknown = -1;
78 #define PACKET_TYPE_MASK 0x1f
83 * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/nlsp.htm
85 * for some information about Hello packets.
88 #define NLSP_TYPE_L1_HELLO 15
89 #define NLSP_TYPE_WAN_HELLO 17
90 #define NLSP_TYPE_L1_LSP 18
91 #define NLSP_TYPE_L1_CSNP 24
92 #define NLSP_TYPE_L1_PSNP 26
94 static const value_string nlsp_packet_type_vals[] = {
95 { NLSP_TYPE_L1_HELLO, "L1 Hello"},
96 { NLSP_TYPE_WAN_HELLO, "WAN Hello"},
97 { NLSP_TYPE_L1_LSP, "L1 LSP"},
98 { NLSP_TYPE_L1_CSNP, "L1 CSNP"},
99 { NLSP_TYPE_L1_PSNP, "L1 PSNP"},
103 static const value_string nlsp_attached_flag_vals[] = {
104 { 0, "Other routing areas cannot be reached through this router"},
105 { 1, "Other routing areas can be reached through this router"},
109 static const value_string nlsp_router_type_vals[] = {
110 { 1, "Level 1 Router"},
111 { 3, "Level 1 and Level 2 Router"},
115 static const true_false_string supported_string = {
121 * Our sub-packet dismantle structure for CLV's
124 int optcode; /* code for option */
125 char *tree_text; /* text for fold out */
126 gint *tree_id; /* id for add_item */
127 void (*dissect)(tvbuff_t *tvb, proto_tree *tree,
128 int offset, int length);
132 * Name: nlsp_dissect_unknown()
135 * There was some error in the protocol and we are in unknown space
136 * here. Add a tree item to cover the error and go on. Note
137 * that we make sure we don't go off the end of the bleedin packet here!
140 * tvbuff_t * : tvbuffer for packet data
141 * proto_tree * : tree of display data. May be NULL.
142 * int : current offset into packet data
143 * char * : format text
144 * subsequent args : arguments to format
147 * void (may modify proto tree)
150 nlsp_dissect_unknown(tvbuff_t *tvb, proto_tree *tree, int offset,
156 proto_tree_add_text_valist(tree, tvb, offset, -1, fmat, ap);
161 * Name: nlsp_dissect_clvs()
164 * Dispatch routine to shred all the CLVs in a packet. We just
165 * walk through the clv entries in the packet. For each one, we
166 * search the passed in valid clv's for this protocol (opts) for
167 * a matching code. If found, we add to the display tree and
168 * then call the dissector. If it is not, we just post an
169 * "unknown" clv entry using the passed in unknown clv tree id.
172 * tvbuff_t * : tvbuffer for packet data
173 * proto_tree * : protocol display tree to fill out. May be NULL
174 * int : offset into packet data where we are.
175 * nlsp_clv_handle_t * : NULL dissector terminated array of codes
176 * and handlers (along with tree text and tree id's).
177 * int : length of CLV area.
178 * int : unknown clv tree id
181 * void, but we will add to proto tree if !NULL.
184 nlsp_dissect_clvs(tvbuff_t *tvb, proto_tree *tree, int offset,
185 const nlsp_clv_handle_t *opts, int len, int unknown_tree_id)
191 proto_tree *clv_tree;
195 code = tvb_get_guint8(tvb, offset);
198 length = tvb_get_guint8(tvb, offset);
201 adj = (sizeof(code) + sizeof(length) + length);
204 nlsp_dissect_unknown(tvb, tree, offset,
205 "Short CLV header (%d vs %d)",
210 while ((opts[q].dissect != NULL )&&( opts[q].optcode != code )){
213 if ( opts[q].dissect ) {
215 /* adjust by 2 for code/len octets */
216 ti = proto_tree_add_text(tree, tvb, offset - 2,
217 length + 2, "%s (%u)",
218 opts[q].tree_text, length );
219 clv_tree = proto_item_add_subtree(ti,
224 opts[q].dissect(tvb, clv_tree, offset,
228 ti = proto_tree_add_text(tree, tvb, offset - 2,
229 length + 2, "Unknown code %u (%u)",
231 clv_tree = proto_item_add_subtree(ti,
242 * Name: dissect_area_address_clv()
245 * Decode an area address clv.
248 * tvbuff_t * : tvbuffer for packet data
249 * proto_tree * : protocol display tree to fill out. May be NULL
250 * int : offset into packet data where we are.
251 * int : length of clv we are decoding
254 * void, but we will add to proto tree if !NULL.
257 dissect_area_address_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
262 nlsp_dissect_unknown(tvb, tree, offset,
263 "Short area address entry");
267 proto_tree_add_text(tree, tvb, offset, 4,
268 "Area address network number: 0x%08x",
269 tvb_get_ntohl(tvb, offset));
275 nlsp_dissect_unknown(tvb, tree, offset,
276 "Short area address entry");
280 proto_tree_add_text(tree, tvb, offset, 4,
281 "Area address mask: 0x%08x",
282 tvb_get_ntohl(tvb, offset));
290 * Name: dissect_neighbor_clv()
293 * Decode an neighbor clv.
296 * tvbuff_t * : tvbuffer for packet data
297 * proto_tree * : protocol display tree to fill out. May be NULL
298 * int : offset into packet data where we are.
299 * int : length of clv we are decoding
302 * void, but we will add to proto tree if !NULL.
305 dissect_neighbor_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
310 nlsp_dissect_unknown(tvb, tree, offset,
311 "Short neighbor entry");
315 proto_tree_add_text(tree, tvb, offset, 6,
317 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
325 * Name: dissect_hello_local_mtu_clv()
328 * Decode for a hello packet's local MTU clv.
331 * tvbuff_t * : tvbuffer for packet data
332 * proto_tree * : protocol display tree to fill out. May be NULL
333 * int : offset into packet data where we are.
334 * int : length of clv we are decoding
337 * void, but we will add to proto tree if !NULL.
340 dissect_hello_local_mtu_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
344 nlsp_dissect_unknown(tvb, tree, offset,
345 "Short link info entry");
349 proto_tree_add_text(tree, tvb, offset, 4,
351 tvb_get_ntohl(tvb, offset));
357 static const nlsp_clv_handle_t clv_hello_opts[] = {
361 &ett_nlsp_hello_clv_area_addr,
362 dissect_area_address_clv
367 &ett_nlsp_hello_clv_neighbors,
373 &ett_nlsp_hello_local_mtu,
374 dissect_hello_local_mtu_clv
386 * Name: nlsp_dissect_nlsp_hello()
389 * This procedure rips apart NLSP hellos.
392 * tvbuff_t * : tvbuffer for packet data
393 * proto_tree * : protocol display tree to add to. May be NULL.
394 * int offset : our offset into packet data.
395 * int : hello type, a la NLSP_TYPE_* values
396 * int : header length of packet.
399 * void, will modify proto_tree if not NULL.
401 #define NLSP_HELLO_CTYPE_MASK 0x03
402 #define NLSP_HELLO_STATE_MASK 0xC0
403 #define NLSP_HELLO_MULTICAST_MASK 0x10
405 static const value_string nlsp_hello_state_vals[] = {
407 { 1, "Initializing" },
412 #define NLSP_HELLO_TYPE_RESERVED 0
413 #define NLSP_HELLO_TYPE_LEVEL_1 1
414 #define NLSP_HELLO_TYPE_LEVEL_2 2
415 #define NLSP_HELLO_TYPE_LEVEL_12 3
417 static const value_string nlsp_hello_circuit_type_vals[] = {
418 { NLSP_HELLO_TYPE_RESERVED, "Reserved 0 (discard PDU)"},
419 { NLSP_HELLO_TYPE_LEVEL_1, "Level 1 only"},
420 { NLSP_HELLO_TYPE_LEVEL_2, "Level 2 only"},
421 { NLSP_HELLO_TYPE_LEVEL_12, "Level 1 and 2"},
425 #define NLSP_HELLO_PRIORITY_MASK 0x7f
428 nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
429 int offset, int hello_type, int header_length)
431 guint16 packet_length;
433 guint16 holding_timer;
436 if (hello_type == NLSP_TYPE_WAN_HELLO) {
437 proto_tree_add_item(tree, hf_nlsp_hello_state, tvb,
440 proto_tree_add_item(tree, hf_nlsp_hello_multicast, tvb,
443 proto_tree_add_item(tree, hf_nlsp_hello_circuit_type, tvb,
449 proto_tree_add_text(tree, tvb, offset, 6,
450 "Sending Router System ID: %s",
451 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
453 if (check_col(pinfo->cinfo, COL_INFO)) {
454 col_append_fstr(pinfo->cinfo, COL_INFO, ", System ID: %s",
455 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
460 holding_timer = tvb_get_ntohs(tvb, offset);
461 proto_tree_add_uint_format(tree, hf_nlsp_hello_holding_timer,
462 tvb, offset, 2, holding_timer,
463 "Holding Timer: %us", holding_timer);
467 packet_length = tvb_get_ntohs(tvb, offset);
469 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
470 offset, 2, packet_length);
475 proto_tree_add_item(tree, hf_nlsp_hello_priority, tvb,
480 if (hello_type == NLSP_TYPE_WAN_HELLO) {
482 proto_tree_add_text(tree, tvb, offset, 1,
483 "Local WAN Circuit ID: %u",
484 tvb_get_guint8(tvb, offset));
489 proto_tree_add_text(tree, tvb, offset, 6,
490 "Designated Router System ID: %s",
491 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
492 proto_tree_add_text(tree, tvb, offset+6, 1,
493 "Designated Router Pseudonode ID: %u",
494 tvb_get_guint8(tvb, offset+6));
499 len = packet_length - header_length;
501 nlsp_dissect_unknown(tvb, tree, offset,
502 "packet header length %d went beyond packet",
508 * Now, we need to decode our CLVs. We need to pass in
509 * our list of valid ones!
511 nlsp_dissect_clvs(tvb, tree, offset,
512 clv_hello_opts, len, ett_nlsp_hello_clv_unknown);
516 * Name: dissect_lsp_mgt_info_clv()
519 * Decode for a lsp packet's management information clv.
522 * tvbuff_t * : tvbuffer for packet data
523 * proto_tree * : protocol display tree to fill out. May be NULL
524 * int : offset into packet data where we are.
525 * int : length of clv we are decoding
528 * void, but we will add to proto tree if !NULL.
531 dissect_lsp_mgt_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
537 nlsp_dissect_unknown(tvb, tree, offset,
538 "Short management info entry");
542 proto_tree_add_text(tree, tvb, offset, 4,
543 "Network number: 0x%08x",
544 tvb_get_ntohl(tvb, offset));
550 nlsp_dissect_unknown(tvb, tree, offset,
551 "Short management info entry");
555 proto_tree_add_text(tree, tvb, offset, 6,
557 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
563 nlsp_dissect_unknown(tvb, tree, offset,
564 "Short management info entry");
568 proto_tree_add_text(tree, tvb, offset, 1,
569 "IPX version number: %u",
570 tvb_get_guint8(tvb, offset));
576 nlsp_dissect_unknown(tvb, tree, offset,
577 "Short management info entry");
580 name_length = tvb_get_guint8(tvb, offset);
582 proto_tree_add_text(tree, tvb, offset, 1,
583 "Name length: %u", name_length);
588 if (name_length != 0) {
589 if (length < name_length) {
590 nlsp_dissect_unknown(tvb, tree, offset,
591 "Short management info entry");
595 proto_tree_add_text(tree, tvb, offset, name_length,
597 tvb_format_text(tvb, offset, name_length));
599 offset += name_length;
600 length -= name_length;
605 * Name: dissect_lsp_link_info_clv()
608 * Decode for a lsp packet's link information clv.
611 * tvbuff_t * : tvbuffer for packet data
612 * proto_tree * : protocol display tree to fill out. May be NULL
613 * int : offset into packet data where we are.
614 * int : length of clv we are decoding
617 * void, but we will add to proto tree if !NULL.
619 static const value_string media_type_vals[] = {
620 { 0x0000, "Generic LAN" },
621 { 0x8000, "Generic WAN" },
622 { 0x0001, "Localtalk" },
623 { 0x0002, "Ethernet II" },
624 { 0x0003, "IEEE 802.3 with IEEE 802.2 without SNAP" },
625 { 0x0005, "IEEE 802.3 with IPX header and no 802.2 header" },
626 { 0x000A, "IEEE 802.3 with IEEE 802.2 and SNAP" },
627 { 0x0004, "IEEE 802.5 with IEEE 802.2 without SNAP" },
628 { 0x000B, "IEEE 802.5 with IEEE 802.2 and SNAP" },
629 { 0x0006, "IEEE 802.4" },
630 { 0x0007, "IBM PC Network II" },
631 { 0x0008, "Gateway G/Net" },
632 { 0x0009, "Proteon ProNET" },
633 { 0x000C, "Racore LANPAC" },
635 { 0x000E, "ARCnet" },
636 { 0x000F, "IBM PC Network II with 802.2 without SNAP" },
637 { 0x0010, "IBM PC Network II with 802.2 and SNAP" },
638 { 0x0011, "Corvus OmniNet at 4 Mbps" },
639 { 0x0012, "Harris Adacom" },
640 { 0x0013, "IP tunnel" },
641 { 0x8013, "IP Relay" },
642 { 0x0014, "FDDI with 802.2 without SNAP" },
643 { 0x0015, "Commtex IVDLAN" },
644 { 0x0016, "Dataco OSI" },
645 { 0x0017, "FDDI with 802.2 and SNAP" },
646 { 0x0018, "IBM SDLC tunnel" },
647 { 0x0019, "PC Office frame" },
648 { 0x001A, "Hypercommunications WAIDNET" },
650 { 0x801D, "Proxim RangeLAN" },
652 { 0x801F, "Frame Relay" },
653 { 0x0020, "Integrated Workstations BUS-NET" },
654 { 0x8021, "Novell SNA Links" },
659 dissect_lsp_link_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
665 nlsp_dissect_unknown(tvb, tree, offset,
666 "Short link info entry");
670 flags_cost = tvb_get_guint8(tvb, offset);
671 proto_tree_add_text(tree, tvb, offset, 1,
672 decode_boolean_bitfield(flags_cost, 0x80, 1*8,
673 "Cost not present", "Cost present"));
674 if (!(flags_cost & 0x80)) {
676 * 0x80 clear => cost present.
678 proto_tree_add_text(tree, tvb, offset, 1,
679 decode_boolean_bitfield(flags_cost, 0x40, 1*8,
680 "Cost is internal metric",
681 "Cost is external metric"));
682 proto_tree_add_text(tree, tvb, offset, 1,
683 decode_numeric_bitfield(flags_cost, 0x3F, 1*8,
691 nlsp_dissect_unknown(tvb, tree, offset,
692 "Short link info entry");
695 offset += 3; /* Reserved */
699 nlsp_dissect_unknown(tvb, tree, offset,
700 "Short link info entry");
704 proto_tree_add_text(tree, tvb, offset, 6,
705 "Router System ID: %s",
706 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
707 proto_tree_add_text(tree, tvb, offset+6, 1,
708 "Router Pseudonode ID: %u",
709 tvb_get_guint8(tvb, offset+6));
715 nlsp_dissect_unknown(tvb, tree, offset,
716 "Short link info entry");
720 proto_tree_add_text(tree, tvb, offset, 4,
722 tvb_get_ntohl(tvb, offset));
728 nlsp_dissect_unknown(tvb, tree, offset,
729 "Short link info entry");
733 proto_tree_add_text(tree, tvb, offset, 4,
735 tvb_get_ntohl(tvb, offset));
741 nlsp_dissect_unknown(tvb, tree, offset,
742 "Short link info entry");
746 proto_tree_add_text(tree, tvb, offset, 4,
747 "Throughput: %u bits/s",
748 tvb_get_ntohl(tvb, offset));
754 nlsp_dissect_unknown(tvb, tree, offset,
755 "Short link info entry");
759 proto_tree_add_text(tree, tvb, offset, 2,
761 val_to_str(tvb_get_ntohs(tvb, offset), media_type_vals,
762 "Unknown (0x%04x)"));
769 * Name: dissect_lsp_svcs_info_clv()
772 * Decode for a lsp packet's services information clv.
775 * tvbuff_t * : tvbuffer for packet data
776 * proto_tree * : protocol display tree to fill out. May be NULL
777 * int : offset into packet data where we are.
778 * int : length of clv we are decoding
781 * void, but we will add to proto tree if !NULL.
784 dissect_lsp_svcs_info_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
788 nlsp_dissect_unknown(tvb, tree, offset,
789 "Short services info entry");
793 proto_tree_add_text(tree, tvb, offset, 1,
794 "Hops to reach the service: %u",
795 tvb_get_guint8(tvb, offset));
801 nlsp_dissect_unknown(tvb, tree, offset,
802 "Short services info entry");
806 proto_tree_add_text(tree, tvb, offset, 4,
807 "Network number: 0x%08x",
808 tvb_get_ntohl(tvb, offset));
814 nlsp_dissect_unknown(tvb, tree, offset,
815 "Short services info entry");
819 proto_tree_add_text(tree, tvb, offset, 6,
821 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
827 nlsp_dissect_unknown(tvb, tree, offset,
828 "Short services info entry");
832 proto_tree_add_text(tree, tvb, offset, 2,
834 val_to_str(tvb_get_ntohs(tvb, offset), ipx_socket_vals,
835 "Unknown (0x%04x)"));
841 nlsp_dissect_unknown(tvb, tree, offset,
842 "Short services info entry");
846 proto_tree_add_text(tree, tvb, offset, 2,
848 val_to_str(tvb_get_ntohs(tvb, offset), server_vals,
849 "Unknown (0x%04x)"));
856 proto_tree_add_text(tree, tvb, offset, length,
858 tvb_format_text(tvb, offset, length));
865 * Name: dissect_lsp_ext_routes_clv()
868 * Decode for a lsp packet's external routes clv.
871 * tvbuff_t * : tvbuffer for packet data
872 * proto_tree * : protocol display tree to fill out. May be NULL
873 * int : offset into packet data where we are.
874 * int : length of clv we are decoding
877 * void, but we will add to proto tree if !NULL.
880 dissect_lsp_ext_routes_clv(tvbuff_t *tvb, proto_tree *tree, int offset,
885 nlsp_dissect_unknown(tvb, tree, offset,
886 "Short external routes entry");
890 proto_tree_add_text(tree, tvb, offset, 1,
892 tvb_get_guint8(tvb, offset));
898 nlsp_dissect_unknown(tvb, tree, offset,
899 "Short external routes entry");
903 proto_tree_add_text(tree, tvb, offset, 4,
904 "Network number: 0x%08x",
905 tvb_get_ntohl(tvb, offset));
911 nlsp_dissect_unknown(tvb, tree, offset,
912 "Short external routes entry");
916 proto_tree_add_text(tree, tvb, offset, 2,
917 "RIP delay: %u ticks",
918 tvb_get_ntohs(tvb, offset));
925 static const nlsp_clv_handle_t clv_l1_lsp_opts[] = {
929 &ett_nlsp_lsp_clv_area_addr,
930 dissect_area_address_clv
934 "Management information",
935 &ett_nlsp_lsp_clv_mgt_info,
936 dissect_lsp_mgt_info_clv
941 &ett_nlsp_lsp_clv_link_info,
942 dissect_lsp_link_info_clv
946 "Services information",
947 &ett_nlsp_lsp_clv_svcs_info,
948 dissect_lsp_svcs_info_clv
953 &ett_nlsp_lsp_clv_ext_routes,
954 dissect_lsp_ext_routes_clv
966 * Name: nlsp_dissect_nlsp_lsp()
969 * Print out the LSP part of the main header and then call the CLV
970 * de-mangler with the right list of valid CLVs.
973 * tvbuff_t * : tvbuffer for packet data
974 * proto_tree * : protocol display tree to add to. May be NULL.
975 * int offset : our offset into packet data.
976 * int : header length of packet.
979 * void, but we will add to proto tree if !NULL.
981 /* P | ATT | OVERFLOW | ROUTER TYPE FIELD description */
982 #define NLSP_LSP_PARTITION_MASK 0x80
983 #define NLSP_LSP_PARTITION_SHIFT 7
984 #define NLSP_LSP_PARTITION(info) (((info) & NLSP_LSP_PARTITION_MASK) >> NLSP_LSP_PARTITION_SHIFT)
986 #define NLSP_LSP_ATT_MASK 0x78
987 #define NLSP_LSP_ATT_SHIFT 3
988 #define NLSP_LSP_ATT(info) (((info) & NLSP_LSP_ATT_MASK) >> NLSP_LSP_ATT_SHIFT)
990 #define NLSP_LSP_OVERFLOW_MASK 0x04
991 #define NLSP_LSP_OVERFLOW_SHIFT 2
992 #define NLSP_LSP_OVERFLOW(info) (((info) & NLSP_LSP_OVERFLOW_MASK) >> NLSP_LSP_OVERFLOW_SHIFT)
994 #define NLSP_LSP_ROUTER_TYPE_MASK 0x03
995 #define NLSP_LSP_ROUTER_TYPE(info) ((info) & NLSP_LSP_ROUTER_TYPE_MASK)
998 nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
999 int offset, int header_length)
1001 guint16 packet_length;
1002 guint16 remaining_lifetime;
1003 guint32 sequence_number;
1006 packet_length = tvb_get_ntohs(tvb, offset);
1008 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
1009 offset, 2, packet_length);
1013 remaining_lifetime = tvb_get_ntohs(tvb, offset);
1015 proto_tree_add_text(tree, tvb, offset, 2,
1016 "Remaining Lifetime: %us",
1017 remaining_lifetime);
1021 if (check_col(pinfo->cinfo, COL_INFO)) {
1022 col_append_fstr(pinfo->cinfo, COL_INFO, ", LSP ID: %s",
1023 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1026 proto_tree_add_text(tree, tvb, offset, 6,
1027 "LSP ID system ID: %s",
1028 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1031 /* XXX - append the pseudonode ID */
1033 proto_tree_add_text(tree, tvb, offset, 1,
1034 "LSP ID pseudonode ID: %u",
1035 tvb_get_guint8(tvb, offset));
1039 proto_tree_add_text(tree, tvb, offset, 1,
1040 "LSP ID LSP number: %u",
1041 tvb_get_guint8(tvb, offset));
1045 sequence_number = tvb_get_ntohl(tvb, offset);
1046 if (check_col(pinfo->cinfo, COL_INFO)) {
1047 col_append_fstr(pinfo->cinfo, COL_INFO,
1048 ", Sequence: 0x%08x, Lifetime: %us",
1049 sequence_number, remaining_lifetime);
1052 proto_tree_add_uint(tree, hf_nlsp_lsp_sequence_number, tvb,
1053 offset, 4, sequence_number);
1058 /* XXX -> we could validate the cksum here! */
1059 proto_tree_add_item(tree, hf_nlsp_lsp_checksum, tvb,
1065 proto_tree_add_item(tree, hf_nlsp_lsp_p, tvb,
1067 proto_tree_add_item(tree, hf_nlsp_lsp_attached_flag, tvb,
1069 proto_tree_add_item(tree, hf_nlsp_lsp_lspdbol, tvb,
1071 proto_tree_add_item(tree, hf_nlsp_lsp_router_type, tvb,
1076 len = packet_length - header_length;
1078 nlsp_dissect_unknown(tvb, tree, offset,
1079 "packet header length %d went beyond packet",
1085 * Now, we need to decode our CLVs. We need to pass in
1086 * our list of valid ones!
1088 nlsp_dissect_clvs(tvb, tree, offset,
1089 clv_l1_lsp_opts, len, ett_nlsp_lsp_clv_unknown);
1093 * Name: dissect_snp_lsp_entries()
1096 * All the snp packets use a common payload format. We have up
1097 * to n entries (based on length), which are made of:
1098 * 2 : remaining life time
1100 * 4 : sequence number
1104 * tvbuff_t * : tvbuffer for packet data
1105 * proto_tree * : protocol display tree to fill out. May be NULL
1106 * int : offset into packet data where we are.
1107 * int : length of payload to decode.
1110 * void, but we will add to proto tree if !NULL.
1113 dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
1116 proto_tree *subtree,*ti;
1118 while (length > 0) {
1120 nlsp_dissect_unknown(tvb, tree, offset,
1121 "Short CSNP header entry");
1125 ti = proto_tree_add_text(tree, tvb, offset, 16,
1126 "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
1127 ether_to_str(tvb_get_ptr(tvb, offset+2, 6)), /* XXX - rest of system ID */
1128 tvb_get_ntohl(tvb, offset+10),
1129 tvb_get_ntohs(tvb, offset),
1130 tvb_get_ntohs(tvb, offset+14));
1132 subtree = proto_item_add_subtree(ti, ett_nlsp_csnp_lsp_entry);
1134 proto_tree_add_text(subtree, tvb, offset+2, 6,
1135 "LSP ID source ID: %s",
1136 ether_to_str(tvb_get_ptr(tvb, offset+2, 6)));
1137 proto_tree_add_text(subtree, tvb, offset+8, 1,
1138 "LSP ID pseudonode ID: %u",
1139 tvb_get_guint8(tvb, offset+8));
1140 proto_tree_add_text(subtree, tvb, offset+9, 1,
1141 "LSP ID LSP number: %u",
1142 tvb_get_guint8(tvb, offset+9));
1144 proto_tree_add_text(subtree, tvb, offset+10, 4,
1145 "LSP Sequence Number: 0x%08x",
1146 tvb_get_ntohl(tvb, offset+10));
1148 proto_tree_add_text(subtree, tvb, offset, 2,
1149 "Remaining Lifetime: %us",
1150 tvb_get_ntohs(tvb, offset));
1152 proto_tree_add_text(subtree, tvb, offset+14, 2,
1153 "LSP checksum: 0x%04x",
1154 tvb_get_ntohs(tvb, offset+14));
1162 dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
1165 proto_tree *subtree,*ti;
1167 while (length > 0) {
1169 nlsp_dissect_unknown(tvb, tree, offset,
1170 "Short PSNP header entry");
1174 ti = proto_tree_add_text(tree, tvb, offset, 16,
1175 "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
1176 ether_to_str(tvb_get_ptr(tvb, offset+2, 6)), /* XXX - rest of system ID */
1177 tvb_get_ntohl(tvb, offset+10),
1178 tvb_get_ntohs(tvb, offset),
1179 tvb_get_ntohs(tvb, offset+14));
1181 subtree = proto_item_add_subtree(ti, ett_nlsp_psnp_lsp_entry);
1183 proto_tree_add_text(subtree, tvb, offset+2, 6,
1184 "LSP ID source ID: %s",
1185 ether_to_str(tvb_get_ptr(tvb, offset+2, 6)));
1186 proto_tree_add_text(subtree, tvb, offset+8, 1,
1187 "LSP ID pseudonode ID: %u",
1188 tvb_get_guint8(tvb, offset+8));
1189 proto_tree_add_text(subtree, tvb, offset+9, 1,
1190 "LSP ID LSP number: %u",
1191 tvb_get_guint8(tvb, offset+9));
1193 proto_tree_add_text(subtree, tvb, offset+10, 4,
1194 "LSP Sequence Number: 0x%08x",
1195 tvb_get_ntohl(tvb, offset+10));
1197 proto_tree_add_text(subtree, tvb, offset, 2,
1198 "Remaining Lifetime: %us",
1199 tvb_get_ntohs(tvb, offset));
1201 proto_tree_add_text(subtree, tvb, offset+14, 2,
1202 "LSP checksum: 0x%04x",
1203 tvb_get_ntohs(tvb, offset+14));
1210 static const nlsp_clv_handle_t clv_l1_csnp_opts[] = {
1214 &ett_nlsp_csnp_lsp_entries,
1215 dissect_csnp_lsp_entries
1227 * Name: nlsp_dissect_nlsp_csnp()
1230 * Tear apart a L1 CSNP header and then call into payload dissect
1231 * to pull apart the lsp id payload.
1234 * tvbuff_t * : tvbuffer for packet data
1235 * proto_tree * : protocol display tree to add to. May be NULL.
1236 * int offset : our offset into packet data.
1237 * int : header length of packet.
1240 * void, but we will add to proto tree if !NULL.
1243 nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1244 int offset, int header_length)
1246 guint16 packet_length;
1249 packet_length = tvb_get_ntohs(tvb, offset);
1251 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
1252 offset, 2, packet_length);
1256 if (check_col(pinfo->cinfo, COL_INFO)) {
1257 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
1258 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1261 proto_tree_add_text(tree, tvb, offset, 6,
1262 "Source ID system ID: %s",
1263 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1266 /* XXX - add the pseudonode ID */
1268 proto_tree_add_text(tree, tvb, offset, 1,
1269 "Source ID pseudonode ID: %u",
1270 tvb_get_guint8(tvb, offset));
1274 if (check_col(pinfo->cinfo, COL_INFO)) {
1275 col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP ID: %s",
1276 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1279 proto_tree_add_text(tree, tvb, offset, 6,
1280 "Start LSP ID source ID: %s",
1281 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1284 /* XXX - append the pseudonode ID */
1286 proto_tree_add_text(tree, tvb, offset, 1,
1287 "Start LSP ID pseudonode ID: %u",
1288 tvb_get_guint8(tvb, offset));
1292 proto_tree_add_text(tree, tvb, offset, 1,
1293 "Start LSP ID LSP number: %u",
1294 tvb_get_guint8(tvb, offset));
1298 if (check_col(pinfo->cinfo, COL_INFO)) {
1299 col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP ID: %s",
1300 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1303 proto_tree_add_text(tree, tvb, offset, 6,
1304 "End LSP ID source ID: %s",
1305 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1308 /* XXX - append the pseudonode ID */
1310 proto_tree_add_text(tree, tvb, offset, 1,
1311 "End LSP ID pseudonode ID: %u",
1312 tvb_get_guint8(tvb, offset));
1316 proto_tree_add_text(tree, tvb, offset, 1,
1317 "End LSP ID LSP number: %u",
1318 tvb_get_guint8(tvb, offset));
1322 len = packet_length - header_length;
1326 /* Call into payload dissector */
1327 nlsp_dissect_clvs(tvb, tree, offset,
1328 clv_l1_csnp_opts, len, ett_nlsp_csnp_clv_unknown);
1331 static const nlsp_clv_handle_t clv_l1_psnp_opts[] = {
1335 &ett_nlsp_psnp_lsp_entries,
1336 dissect_psnp_lsp_entries
1348 * Name: nlsp_dissect_nlsp_psnp()
1351 * Tear apart a L1 PSNP header and then call into payload dissect
1352 * to pull apart the lsp id payload.
1355 * tvbuff_t * : tvbuffer for packet data
1356 * proto_tree * : protocol display tree to add to. May be NULL.
1357 * int offset : our offset into packet data.
1358 * int : header length of packet.
1361 * void, but we will add to proto tree if !NULL.
1364 nlsp_dissect_nlsp_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1365 int offset, int header_length)
1367 guint16 packet_length;
1370 packet_length = tvb_get_ntohs(tvb, offset);
1372 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
1373 offset, 2, packet_length);
1377 if (check_col(pinfo->cinfo, COL_INFO)) {
1378 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
1379 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1382 proto_tree_add_text(tree, tvb, offset, 6,
1383 "Source ID system ID: %s",
1384 ether_to_str(tvb_get_ptr(tvb, offset, 6)));
1387 /* XXX - add the pseudonode ID */
1389 proto_tree_add_text(tree, tvb, offset, 1,
1390 "Source ID pseudonode ID: %u",
1391 tvb_get_guint8(tvb, offset));
1395 len = packet_length - header_length;
1399 /* Call into payload dissector */
1400 nlsp_dissect_clvs(tvb, tree, offset,
1401 clv_l1_psnp_opts, len, ett_nlsp_psnp_clv_unknown);
1405 * Name: dissect_nlsp()
1408 * Main entry area for nlsp de-mangling. This will build the
1409 * main nlsp tree data and call the sub-protocols as needed.
1412 * tvbuff_t * : tvbuffer for packet data
1413 * packet_info * : info for current packet
1414 * proto_tree * : tree of display data. May be NULL.
1417 * void, but we will add to the proto_tree if it is not NULL.
1420 dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1423 proto_tree *nlsp_tree = NULL;
1425 guint8 nlsp_major_version;
1426 guint8 nlsp_header_length;
1427 guint8 packet_type_flags;
1430 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1431 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NLSP");
1432 if (check_col(pinfo->cinfo, COL_INFO))
1433 col_clear(pinfo->cinfo, COL_INFO);
1435 nlsp_major_version = tvb_get_guint8(tvb, 5);
1436 if (nlsp_major_version != 1){
1437 if (check_col(pinfo->cinfo, COL_INFO)) {
1438 col_add_fstr(pinfo->cinfo, COL_INFO,
1439 "Unknown NLSP version (%u vs 1)",
1440 nlsp_major_version);
1442 nlsp_dissect_unknown(tvb, tree, 0,
1443 "Unknown NLSP version (%d vs 1)",
1444 nlsp_major_version, 1);
1449 ti = proto_tree_add_item(tree, proto_nlsp, tvb, 0, -1, FALSE);
1450 nlsp_tree = proto_item_add_subtree(ti, ett_nlsp);
1454 proto_tree_add_item(nlsp_tree, hf_nlsp_irpd, tvb, offset, 1,
1459 nlsp_header_length = tvb_get_guint8(tvb, 1);
1461 proto_tree_add_uint(nlsp_tree, hf_nlsp_header_length, tvb,
1462 offset, 1, nlsp_header_length );
1467 proto_tree_add_item(nlsp_tree, hf_nlsp_minor_version, tvb,
1472 offset += 1; /* Reserved */
1474 packet_type_flags = tvb_get_guint8(tvb, offset);
1475 packet_type = packet_type_flags & PACKET_TYPE_MASK;
1476 if (check_col(pinfo->cinfo, COL_INFO)) {
1477 col_add_str(pinfo->cinfo, COL_INFO,
1478 val_to_str(packet_type, nlsp_packet_type_vals, "Unknown (%u)"));
1481 if (packet_type == NLSP_TYPE_L1_LSP) {
1482 proto_tree_add_boolean(nlsp_tree, hf_nlsp_nr, tvb, offset, 1,
1483 packet_type_flags );
1485 proto_tree_add_uint(nlsp_tree, hf_nlsp_type, tvb, offset, 1,
1486 packet_type_flags );
1491 proto_tree_add_item(nlsp_tree, hf_nlsp_major_version, tvb,
1496 offset += 2; /* Reserved */
1498 switch (packet_type) {
1500 case NLSP_TYPE_L1_HELLO:
1501 case NLSP_TYPE_WAN_HELLO:
1502 nlsp_dissect_nlsp_hello(tvb, pinfo, nlsp_tree, offset,
1503 packet_type, nlsp_header_length);
1506 case NLSP_TYPE_L1_LSP:
1507 nlsp_dissect_nlsp_lsp(tvb, pinfo, nlsp_tree, offset,
1508 nlsp_header_length);
1511 case NLSP_TYPE_L1_CSNP:
1512 nlsp_dissect_nlsp_csnp(tvb, pinfo, nlsp_tree, offset,
1513 nlsp_header_length);
1516 case NLSP_TYPE_L1_PSNP:
1517 nlsp_dissect_nlsp_psnp(tvb, pinfo, nlsp_tree, offset,
1518 nlsp_header_length);
1522 nlsp_dissect_unknown(tvb, tree, offset,
1523 "Unknown NLSP packet type");
1528 * Name: proto_register_nlsp()
1531 * main register for NLSP protocol set. We register some display
1532 * formats and the protocol module variables.
1534 * NOTE: this procedure to autolinked by the makefile process that
1544 proto_register_nlsp(void)
1546 static hf_register_info hf[] = {
1548 { "NetWare Link Services Protocol Discriminator", "nlsp.irpd",
1549 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
1551 { &hf_nlsp_header_length,
1552 { "PDU Header Length", "nlsp.header_length",
1553 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
1555 { &hf_nlsp_minor_version,
1556 { "Minor Version", "nlsp.minor_version", FT_UINT8,
1557 BASE_DEC, NULL, 0x0, "", HFILL }},
1560 { "Multi-homed Non-routing Server", "nlsp.nr", FT_BOOLEAN, 8,
1561 NULL, 0x80, "", HFILL }},
1564 { "Packet Type", "nlsp.type", FT_UINT8, BASE_DEC,
1565 VALS(nlsp_packet_type_vals), PACKET_TYPE_MASK, "", HFILL }},
1567 { &hf_nlsp_major_version,
1568 { "Major Version", "nlsp.major_version", FT_UINT8,
1569 BASE_DEC, NULL, 0x0, "", HFILL }},
1571 { &hf_nlsp_packet_length,
1572 { "Packet Length", "nlsp.packet_length",
1573 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
1575 { &hf_nlsp_hello_state,
1576 { "State", "nlsp.hello.state", FT_UINT8, BASE_DEC,
1577 VALS(nlsp_hello_state_vals), NLSP_HELLO_STATE_MASK,
1580 { &hf_nlsp_hello_multicast,
1581 { "Multicast Routing", "nlsp.hello.multicast", FT_BOOLEAN, 8,
1582 TFS(&supported_string), NLSP_HELLO_MULTICAST_MASK,
1583 "If set, this router supports multicast routing", HFILL }},
1585 { &hf_nlsp_hello_circuit_type,
1586 { "Circuit Type", "nlsp.hello.circuit_type", FT_UINT8, BASE_DEC,
1587 VALS(nlsp_hello_circuit_type_vals), NLSP_HELLO_CTYPE_MASK,
1590 { &hf_nlsp_hello_holding_timer,
1591 { "Holding Timer", "nlsp.hello.holding_timer", FT_UINT8, BASE_DEC,
1592 NULL, 0x0, "", HFILL }},
1594 { &hf_nlsp_hello_priority,
1595 { "Priority", "nlsp.hello.priority", FT_UINT8, BASE_DEC,
1596 NULL, NLSP_HELLO_PRIORITY_MASK,
1599 { &hf_nlsp_lsp_sequence_number,
1600 { "Sequence Number", "nlsp.sequence_number",
1601 FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
1603 { &hf_nlsp_lsp_checksum,
1604 { "Checksum", "nlsp.lsp.checksum",
1605 FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
1608 { "Partition Repair", "nlsp.lsp.partition_repair", FT_BOOLEAN, 8,
1609 TFS(&supported_string), NLSP_LSP_PARTITION_MASK,
1610 "If set, this router supports the optional Partition Repair function", HFILL }},
1612 { &hf_nlsp_lsp_attached_flag,
1613 { "Attached Flag", "nlsp.lsp.attached_flag", FT_UINT8, BASE_DEC,
1614 VALS(nlsp_attached_flag_vals), NLSP_LSP_ATT_MASK, "", HFILL }},
1616 { &hf_nlsp_lsp_lspdbol,
1617 { "LSP Database Overloaded", "nlsp.lsp.lspdbol", FT_BOOLEAN, 8,
1618 NULL, NLSP_LSP_OVERFLOW_MASK, "", HFILL }},
1620 { &hf_nlsp_lsp_router_type,
1621 { "Router Type", "nlsp.lsp.router_type", FT_UINT8, BASE_DEC,
1622 VALS(nlsp_router_type_vals), NLSP_LSP_ROUTER_TYPE_MASK,
1625 static gint *ett[] = {
1627 &ett_nlsp_hello_clv_area_addr,
1628 &ett_nlsp_hello_clv_neighbors,
1629 &ett_nlsp_hello_local_mtu,
1630 &ett_nlsp_hello_clv_unknown,
1632 &ett_nlsp_lsp_clv_area_addr,
1633 &ett_nlsp_lsp_clv_mgt_info,
1634 &ett_nlsp_lsp_clv_link_info,
1635 &ett_nlsp_lsp_clv_svcs_info,
1636 &ett_nlsp_lsp_clv_ext_routes,
1637 &ett_nlsp_lsp_clv_unknown,
1638 &ett_nlsp_csnp_lsp_entries,
1639 &ett_nlsp_csnp_lsp_entry,
1640 &ett_nlsp_csnp_clv_unknown,
1641 &ett_nlsp_psnp_lsp_entries,
1642 &ett_nlsp_psnp_lsp_entry,
1643 &ett_nlsp_psnp_clv_unknown,
1646 proto_nlsp = proto_register_protocol("NetWare Link Services Protocol",
1648 proto_register_field_array(proto_nlsp, hf, array_length(hf));
1649 proto_register_subtree_array(ett, array_length(ett));
1653 proto_reg_handoff_nlsp(void)
1655 dissector_handle_t nlsp_handle;
1657 nlsp_handle = create_dissector_handle(dissect_nlsp, proto_nlsp);
1658 dissector_add("ipx.socket", IPX_SOCKET_NLSP, nlsp_handle);