Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-nlsp.c
blob309130f939bcd56ecab6729b58fd29a042529262
1 /* packet-nlsp.c
2 * Routines for NetWare Link Services Protocol
4 * Based on ISIS dissector by Stuart Stanley <stuarts@mxmail.net>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
16 #include <epan/expert.h>
17 #include <epan/to_str.h>
18 #include <epan/tfs.h>
19 #include <epan/unit_strings.h>
21 #include <wsutil/array.h>
22 #include "packet-ipx.h"
24 void proto_register_nlsp(void);
25 void proto_reg_handoff_nlsp(void);
27 static dissector_handle_t nlsp_handle;
29 /* NLSP base header */
30 static int proto_nlsp;
32 static int hf_nlsp_irpd;
33 static int hf_nlsp_header_length;
34 static int hf_nlsp_minor_version;
35 static int hf_nlsp_nr;
36 static int hf_nlsp_type;
37 static int hf_nlsp_major_version;
38 static int hf_nlsp_packet_length;
39 static int hf_nlsp_hello_state;
40 static int hf_nlsp_hello_multicast;
41 static int hf_nlsp_hello_circuit_type;
42 static int hf_nlsp_hello_holding_timer;
43 static int hf_nlsp_hello_priority;
44 static int hf_nlsp_lsp_sequence_number;
45 static int hf_nlsp_lsp_checksum;
46 static int hf_nlsp_lsp_p;
47 static int hf_nlsp_lsp_attached_flag;
48 static int hf_nlsp_lsp_lspdbol;
49 static int hf_nlsp_lsp_router_type;
50 static int hf_nlsp_lsp_link_info_clv_flags_cost_present;
51 static int hf_nlsp_lsp_link_info_clv_flags_cost_metric;
52 static int hf_nlsp_lsp_link_info_clv_flags_cost;
54 /* Generated from convert_proto_tree_add_text.pl */
55 static int hf_nlsp_psnp_lsp_checksum;
56 static int hf_nlsp_csnp_start_lsp_id_source_id;
57 static int hf_nlsp_svcs_info_node_number;
58 static int hf_nlsp_ext_routes_rip_delay;
59 static int hf_nlsp_psnp_source_id_system_id;
60 static int hf_nlsp_svcs_info_socket;
61 static int hf_nlsp_hello_sending_router_system_id;
62 static int hf_nlsp_csnp_start_lsp_id_lsp_number;
63 static int hf_nlsp_lsp_id_system_id;
64 static int hf_nlsp_psnp_lsp_id_pseudonode_id;
65 static int hf_nlsp_csnp_end_lsp_id_lsp_number;
66 static int hf_nlsp_remaining_lifetime;
67 static int hf_nlsp_csnp_remaining_lifetime;
68 static int hf_nlsp_psnp_lsp_id_source_id;
69 static int hf_nlsp_ext_routes_hops;
70 static int hf_nlsp_hello_local_mtu_mtu_size;
71 static int hf_nlsp_link_info_throughput;
72 static int hf_nlsp_link_info_media_type;
73 static int hf_nlsp_mgt_info_name;
74 static int hf_nlsp_mgt_info_node_number;
75 static int hf_nlsp_csnp_end_lsp_id_source_id;
76 static int hf_nlsp_csnp_lsp_id_pseudonode_id;
77 static int hf_nlsp_psnp_lsp_sequence_number;
78 static int hf_nlsp_link_info_mtu_size;
79 static int hf_nlsp_lsp_id_lsp_number;
80 static int hf_nlsp_unknown_code;
81 static int hf_nlsp_mgt_info_ipx_version_number;
82 static int hf_nlsp_link_info_router_pseudonode_id;
83 static int hf_nlsp_psnp_source_id_pseudonode_id;
84 static int hf_nlsp_csnp_lsp_id_lsp_number;
85 static int hf_nlsp_csnp_source_id_pseudonode_id;
86 static int hf_nlsp_csnp_end_lsp_id_pseudonode_id;
87 static int hf_nlsp_csnp_lsp_sequence_number;
88 static int hf_nlsp_link_info_router_system_id;
89 static int hf_nlsp_svcs_info_type;
90 static int hf_nlsp_csnp_lsp_checksum;
91 static int hf_nlsp_hello_local_wan_circuit_id;
92 static int hf_nlsp_svcs_info_service_name;
93 static int hf_nlsp_mgt_info_name_length;
94 static int hf_nlsp_neighbor;
95 static int hf_nlsp_area_address_network_number;
96 static int hf_nlsp_link_info_delay;
97 static int hf_nlsp_csnp_start_lsp_id_pseudonode_id;
98 static int hf_nlsp_svcs_info_network_number;
99 static int hf_nlsp_csnp_source_id_system_id;
100 static int hf_nlsp_mgt_info_network_number;
101 static int hf_nlsp_hello_designated_router_pseudonode_id;
102 static int hf_nlsp_lsp_id_pseudonode_id;
103 static int hf_nlsp_csnp_lsp_id_source_id;
104 static int hf_nlsp_psnp_remaining_lifetime;
105 static int hf_nlsp_area_address_mask;
106 static int hf_nlsp_hello_designated_router_system_id;
107 static int hf_nlsp_svcs_info_hops_to_reach_the_service;
108 static int hf_nlsp_psnp_lsp_id_lsp_number;
109 static int hf_nlsp_ext_routes_network_number;
111 static expert_field ei_nlsp_short_packet;
112 static expert_field ei_nlsp_long_packet;
113 static expert_field ei_nlsp_major_version;
114 static expert_field ei_nlsp_type;
116 static int ett_nlsp;
117 static int ett_nlsp_hello_clv_area_addr;
118 static int ett_nlsp_hello_clv_neighbors;
119 static int ett_nlsp_hello_local_mtu;
120 static int ett_nlsp_hello_clv_unknown;
121 static int ett_nlsp_lsp_info;
122 static int ett_nlsp_lsp_clv_area_addr;
123 static int ett_nlsp_lsp_clv_mgt_info;
124 static int ett_nlsp_lsp_clv_link_info;
125 static int ett_nlsp_lsp_clv_svcs_info;
126 static int ett_nlsp_lsp_clv_ext_routes;
127 static int ett_nlsp_lsp_clv_unknown;
128 static int ett_nlsp_csnp_lsp_entries;
129 static int ett_nlsp_csnp_lsp_entry;
130 static int ett_nlsp_csnp_clv_unknown;
131 static int ett_nlsp_psnp_lsp_entries;
132 static int ett_nlsp_psnp_lsp_entry;
133 static int ett_nlsp_psnp_clv_unknown;
135 #define PACKET_TYPE_MASK 0x1f
138 * See
140 * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/nlsp.htm
142 * for some information about Hello packets.
145 #define NLSP_TYPE_L1_HELLO 15
146 #define NLSP_TYPE_WAN_HELLO 17
147 #define NLSP_TYPE_L1_LSP 18
148 #define NLSP_TYPE_L1_CSNP 24
149 #define NLSP_TYPE_L1_PSNP 26
151 static const value_string nlsp_packet_type_vals[] = {
152 { NLSP_TYPE_L1_HELLO, "L1 Hello"},
153 { NLSP_TYPE_WAN_HELLO, "WAN Hello"},
154 { NLSP_TYPE_L1_LSP, "L1 LSP"},
155 { NLSP_TYPE_L1_CSNP, "L1 CSNP"},
156 { NLSP_TYPE_L1_PSNP, "L1 PSNP"},
157 { 0, NULL}
160 static const value_string nlsp_attached_flag_vals[] = {
161 { 0, "Other routing areas cannot be reached through this router"},
162 { 1, "Other routing areas can be reached through this router"},
163 { 0, NULL}
166 static const value_string nlsp_router_type_vals[] = {
167 { 1, "Level 1 Router"},
168 { 3, "Level 1 and Level 2 Router"},
169 { 0, NULL}
172 static const true_false_string tfs_internal_external = { "Internal", "External" };
175 * Our sub-packet dismantle structure for CLV's
177 typedef struct {
178 int optcode; /* code for option */
179 const char *tree_text; /* text for fold out */
180 int *tree_id; /* id for add_item */
181 void (*dissect)(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree,
182 int offset, int length);
183 } nlsp_clv_handle_t;
186 * Name: nlsp_dissect_clvs()
188 * Description:
189 * Dispatch routine to shred all the CLVs in a packet. We just
190 * walk through the clv entries in the packet. For each one, we
191 * search the passed in valid clv's for this protocol (opts) for
192 * a matching code. If found, we add to the display tree and
193 * then call the dissector. If it is not, we just post an
194 * "unknown" clv entry using the passed in unknown clv tree id.
195 * XXX: The "unknown tree id" is an 'ett' index for use
196 * when creating a subtree;
197 * Since the 'unknown' subtree was not actually used in the
198 * code below, what was the intention for this ?
199 * For now: code related to creating an 'unknown' subtrree
200 * disabled.
202 * Input:
203 * tvbuff_t * : tvbuffer for packet data
204 * proto_tree * : protocol display tree to fill out. May be NULL
205 * int : offset into packet data where we are.
206 * nlsp_clv_handle_t * : NULL dissector terminated array of codes
207 * and handlers (along with tree text and tree id's).
208 * int : length of CLV area.
209 * int : unknown clv tree id
211 * Output:
212 * void, but we will add to proto tree if !NULL.
214 static void
215 nlsp_dissect_clvs(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
216 const nlsp_clv_handle_t *opts, int len, int unknown_tree_id _U_)
218 uint8_t code;
219 uint8_t length;
220 int q;
221 proto_tree *clv_tree;
223 while ( len > 0 ) {
224 code = tvb_get_uint8(tvb, offset);
225 offset += 1;
226 len -= 1;
227 if (len == 0)
228 break;
230 length = tvb_get_uint8(tvb, offset);
231 offset += 1;
232 len -= 1;
233 if (len == 0)
234 break;
236 if ( len < length ) {
237 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
238 "Short CLV header (%d vs %d)", length, len );
239 return;
241 q = 0;
242 while ((opts[q].dissect != NULL )&&( opts[q].optcode != code )){
243 q++;
245 if ( opts[q].dissect ) {
246 /* adjust by 2 for code/len octets */
247 clv_tree = proto_tree_add_subtree_format(tree, tvb, offset - 2,
248 length + 2, *opts[q].tree_id, NULL, "%s (%u)",
249 opts[q].tree_text, length );
250 opts[q].dissect(tvb, pinfo, clv_tree, offset,
251 length);
252 } else {
253 proto_item* ti;
254 ti = proto_tree_add_uint_format_value(tree, hf_nlsp_unknown_code, tvb, offset - 2,
255 1, code, "%u (%u)", code, length);
256 proto_item_set_len(ti, length + 2);
258 offset += length;
259 len -= length;
264 * Name: dissect_area_address_clv()
266 * Description:
267 * Decode an area address clv.
269 * Input:
270 * tvbuff_t * : tvbuffer for packet data
271 * proto_tree * : protocol display tree to fill out. May be NULL
272 * int : offset into packet data where we are.
273 * int : length of clv we are decoding
275 * Output:
276 * void, but we will add to proto tree if !NULL.
278 static void
279 dissect_area_address_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
280 int length)
282 while (length > 0) {
283 if (length < 4) {
284 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
285 "Short area address entry");
286 return;
288 proto_tree_add_item(tree, hf_nlsp_area_address_network_number, tvb, offset, 4, ENC_BIG_ENDIAN);
290 offset += 4;
291 length -= 4;
293 if (length < 4) {
294 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
295 "Short area address entry");
296 return;
298 proto_tree_add_item(tree, hf_nlsp_area_address_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
300 offset += 4;
301 length -= 4;
306 * Name: dissect_neighbor_clv()
308 * Description:
309 * Decode an neighbor clv.
311 * Input:
312 * tvbuff_t * : tvbuffer for packet data
313 * proto_tree * : protocol display tree to fill out. May be NULL
314 * int : offset into packet data where we are.
315 * int : length of clv we are decoding
317 * Output:
318 * void, but we will add to proto tree if !NULL.
320 static void
321 dissect_neighbor_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
322 int length)
324 while (length > 0) {
325 if (length < 6) {
326 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet,
327 tvb, offset, -1, "Short neighbor entry");
328 return;
330 proto_tree_add_item(tree, hf_nlsp_neighbor, tvb, offset, 6, ENC_NA);
331 offset += 6;
332 length -= 6;
337 * Name: dissect_hello_local_mtu_clv()
339 * Description:
340 * Decode for a hello packet's local MTU clv.
342 * Input:
343 * tvbuff_t * : tvbuffer for packet data
344 * proto_tree * : protocol display tree to fill out. May be NULL
345 * int : offset into packet data where we are.
346 * int : length of clv we are decoding
348 * Output:
349 * void, but we will add to proto tree if !NULL.
351 static void
352 dissect_hello_local_mtu_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
353 int length)
355 if (length < 4) {
356 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
357 "Short link info entry");
358 return;
360 proto_tree_add_item(tree, hf_nlsp_hello_local_mtu_mtu_size, tvb, offset, 4, ENC_BIG_ENDIAN);
363 static const nlsp_clv_handle_t clv_hello_opts[] = {
365 0xC0,
366 "Area address(es)",
367 &ett_nlsp_hello_clv_area_addr,
368 dissect_area_address_clv
372 "Neighbors",
373 &ett_nlsp_hello_clv_neighbors,
374 dissect_neighbor_clv
377 0xC5,
378 "Local MTU",
379 &ett_nlsp_hello_local_mtu,
380 dissect_hello_local_mtu_clv
386 NULL,
387 NULL
392 * Name: nlsp_dissect_nlsp_hello()
394 * Description:
395 * This procedure rips apart NLSP hellos.
397 * Input:
398 * tvbuff_t * : tvbuffer for packet data
399 * proto_tree * : protocol display tree to add to. May be NULL.
400 * int offset : our offset into packet data.
401 * int : hello type, a la NLSP_TYPE_* values
402 * int : header length of packet.
404 * Output:
405 * void, will modify proto_tree if not NULL.
407 #define NLSP_HELLO_CTYPE_MASK 0x03
408 #define NLSP_HELLO_STATE_MASK 0xC0
409 #define NLSP_HELLO_MULTICAST_MASK 0x10
411 static const value_string nlsp_hello_state_vals[] = {
412 { 0, "Up" },
413 { 1, "Initializing" },
414 { 2, "Down" },
415 { 0, NULL }
418 #define NLSP_HELLO_TYPE_RESERVED 0
419 #define NLSP_HELLO_TYPE_LEVEL_1 1
420 #define NLSP_HELLO_TYPE_LEVEL_2 2
421 #define NLSP_HELLO_TYPE_LEVEL_12 3
423 static const value_string nlsp_hello_circuit_type_vals[] = {
424 { NLSP_HELLO_TYPE_RESERVED, "Reserved 0 (discard PDU)"},
425 { NLSP_HELLO_TYPE_LEVEL_1, "Level 1 only"},
426 { NLSP_HELLO_TYPE_LEVEL_2, "Level 2 only"},
427 { NLSP_HELLO_TYPE_LEVEL_12, "Level 1 and 2"},
428 { 0, NULL}
431 #define NLSP_HELLO_PRIORITY_MASK 0x7f
433 static void
434 nlsp_dissect_nlsp_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
435 int offset, int hello_type, int header_length)
437 uint16_t packet_length;
438 int len;
440 if (hello_type == NLSP_TYPE_WAN_HELLO) {
441 proto_tree_add_item(tree, hf_nlsp_hello_state, tvb,
442 offset, 1, ENC_BIG_ENDIAN);
443 } else {
444 proto_tree_add_item(tree, hf_nlsp_hello_multicast, tvb,
445 offset, 1, ENC_BIG_ENDIAN);
447 proto_tree_add_item(tree, hf_nlsp_hello_circuit_type, tvb,
448 offset, 1, ENC_BIG_ENDIAN);
449 offset += 1;
451 proto_tree_add_item(tree, hf_nlsp_hello_sending_router_system_id, tvb, offset, 6, ENC_NA);
453 col_append_fstr(pinfo->cinfo, COL_INFO, ", System ID: %s",
454 tvb_ether_to_str(pinfo->pool, tvb, offset));
456 offset += 6;
458 proto_tree_add_item(tree, hf_nlsp_hello_holding_timer, tvb, offset, 2, ENC_BIG_ENDIAN);
459 offset += 2;
461 packet_length = tvb_get_ntohs(tvb, offset);
462 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb, offset, 2, packet_length);
463 offset += 2;
465 proto_tree_add_item(tree, hf_nlsp_hello_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
466 offset += 1;
468 if (hello_type == NLSP_TYPE_WAN_HELLO) {
469 proto_tree_add_item(tree, hf_nlsp_hello_local_wan_circuit_id, tvb, offset, 1, ENC_BIG_ENDIAN);
470 offset += 1;
471 } else {
472 proto_tree_add_item(tree, hf_nlsp_hello_designated_router_system_id, tvb, offset, 6, ENC_NA);
473 proto_tree_add_item(tree, hf_nlsp_hello_designated_router_pseudonode_id, tvb, offset+6, 1, ENC_BIG_ENDIAN);
474 offset += 7;
477 len = packet_length - header_length;
478 if (len < 0) {
479 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_long_packet, tvb, offset, -1,
480 "packet header length %d went beyond packet",
481 header_length);
482 return;
486 * Now, we need to decode our CLVs. We need to pass in
487 * our list of valid ones!
489 nlsp_dissect_clvs(tvb, pinfo, tree, offset,
490 clv_hello_opts, len, ett_nlsp_hello_clv_unknown);
494 * Name: dissect_lsp_mgt_info_clv()
496 * Description:
497 * Decode for a lsp packet's management information clv.
499 * Input:
500 * tvbuff_t * : tvbuffer for packet data
501 * proto_tree * : protocol display tree to fill out. May be NULL
502 * int : offset into packet data where we are.
503 * int : length of clv we are decoding
505 * Output:
506 * void, but we will add to proto tree if !NULL.
508 static void
509 dissect_lsp_mgt_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
510 int length)
512 uint8_t name_length;
514 if (length < 4) {
515 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
516 "Short management info entry");
517 return;
519 proto_tree_add_item(tree, hf_nlsp_mgt_info_network_number, tvb, offset, 4, ENC_BIG_ENDIAN);
520 offset += 4;
521 length -= 4;
523 if (length < 6) {
524 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
525 "Short management info entry");
526 return;
528 proto_tree_add_item(tree, hf_nlsp_mgt_info_node_number, tvb, offset, 6, ENC_NA);
529 offset += 6;
530 length -= 6;
532 if (length < 1) {
533 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
534 "Short management info entry");
535 return;
538 proto_tree_add_item(tree, hf_nlsp_mgt_info_ipx_version_number, tvb, offset, 1, ENC_BIG_ENDIAN);
539 offset += 1;
540 length -= 1;
542 if (length < 1) {
543 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
544 "Short management info entry");
545 return;
547 name_length = tvb_get_uint8(tvb, offset);
548 proto_tree_add_item(tree, hf_nlsp_mgt_info_name_length, tvb, offset, 1, ENC_BIG_ENDIAN);
549 offset += 1;
550 length -= 1;
552 if (name_length != 0) {
553 if (length < name_length) {
554 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
555 "Short management info entry");
556 return;
558 proto_tree_add_item(tree, hf_nlsp_mgt_info_name, tvb, offset, name_length, ENC_NA|ENC_ASCII);
563 * Name: dissect_lsp_link_info_clv()
565 * Description:
566 * Decode for a lsp packet's link information clv.
568 * Input:
569 * tvbuff_t * : tvbuffer for packet data
570 * proto_tree * : protocol display tree to fill out. May be NULL
571 * int : offset into packet data where we are.
572 * int : length of clv we are decoding
574 * Output:
575 * void, but we will add to proto tree if !NULL.
577 static const value_string media_type_vals[] = {
578 { 0x0000, "Generic LAN" },
579 { 0x8000, "Generic WAN" },
580 { 0x0001, "Localtalk" },
581 { 0x0002, "Ethernet II" },
582 { 0x0003, "IEEE 802.3 with IEEE 802.2 without SNAP" },
583 { 0x0005, "IEEE 802.3 with IPX header and no 802.2 header" },
584 { 0x000A, "IEEE 802.3 with IEEE 802.2 and SNAP" },
585 { 0x0004, "IEEE 802.5 with IEEE 802.2 without SNAP" },
586 { 0x000B, "IEEE 802.5 with IEEE 802.2 and SNAP" },
587 { 0x0006, "IEEE 802.4" },
588 { 0x0007, "IBM PC Network II" },
589 { 0x0008, "Gateway G/Net" },
590 { 0x0009, "Proteon ProNET" },
591 { 0x000C, "Racore LANPAC" },
592 { 0x800D, "ISDN" },
593 { 0x000E, "ARCnet" },
594 { 0x000F, "IBM PC Network II with 802.2 without SNAP" },
595 { 0x0010, "IBM PC Network II with 802.2 and SNAP" },
596 { 0x0011, "Corvus OmniNet at 4 Mbps" },
597 { 0x0012, "Harris Adacom" },
598 { 0x0013, "IP tunnel" },
599 { 0x8013, "IP Relay" },
600 { 0x0014, "FDDI with 802.2 without SNAP" },
601 { 0x0015, "Commtex IVDLAN" },
602 { 0x0016, "Dataco OSI" },
603 { 0x0017, "FDDI with 802.2 and SNAP" },
604 { 0x0018, "IBM SDLC tunnel" },
605 { 0x0019, "PC Office frame" },
606 { 0x001A, "Hypercommunications WAIDNET" },
607 { 0x801C, "PPP" },
608 { 0x801D, "Proxim RangeLAN" },
609 { 0x801E, "X.25" },
610 { 0x801F, "Frame Relay" },
611 { 0x0020, "Integrated Workstations BUS-NET" },
612 { 0x8021, "Novell SNA Links" },
613 { 0, NULL }
616 static void
617 dissect_lsp_link_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
618 int length)
620 uint8_t flags_cost;
622 if (length < 1) {
623 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
624 "Short link info entry");
625 return;
627 if (tree) {
628 flags_cost = tvb_get_uint8(tvb, offset);
629 proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost_present, tvb, offset, 1, ENC_BIG_ENDIAN);
630 if (!(flags_cost & 0x80)) {
632 * 0x80 clear => cost present.
634 proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost_metric, tvb, offset, 1, ENC_BIG_ENDIAN);
635 proto_tree_add_item(tree, hf_nlsp_lsp_link_info_clv_flags_cost, tvb, offset, 1, ENC_BIG_ENDIAN);
638 offset += 1;
639 length -= 1;
641 if (length < 3) {
642 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
643 "Short link info entry");
644 return;
646 offset += 3; /* Reserved */
647 length -= 3;
649 if (length < 7) {
650 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
651 "Short link info entry");
652 return;
655 proto_tree_add_item(tree, hf_nlsp_link_info_router_system_id, tvb, offset, 6, ENC_NA);
656 proto_tree_add_item(tree, hf_nlsp_link_info_router_pseudonode_id, tvb, offset+6, 1, ENC_BIG_ENDIAN);
657 offset += 7;
658 length -= 7;
660 if (length < 4) {
661 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
662 "Short link info entry");
663 return;
665 proto_tree_add_item(tree, hf_nlsp_link_info_mtu_size, tvb, offset, 4, ENC_BIG_ENDIAN);
666 offset += 4;
667 length -= 4;
669 if (length < 4) {
670 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
671 "Short link info entry");
672 return;
674 proto_tree_add_item(tree, hf_nlsp_link_info_delay, tvb, offset, 4, ENC_BIG_ENDIAN);
675 offset += 4;
676 length -= 4;
678 if (length < 4) {
679 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
680 "Short link info entry");
681 return;
683 proto_tree_add_item(tree, hf_nlsp_link_info_throughput, tvb, offset, 4, ENC_BIG_ENDIAN);
684 offset += 4;
685 length -= 4;
687 if (length < 2) {
688 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
689 "Short link info entry");
690 return;
692 proto_tree_add_item(tree, hf_nlsp_link_info_media_type, tvb, offset, 2, ENC_BIG_ENDIAN);
696 * Name: dissect_lsp_svcs_info_clv()
698 * Description:
699 * Decode for a lsp packet's services information clv.
701 * Input:
702 * tvbuff_t * : tvbuffer for packet data
703 * proto_tree * : protocol display tree to fill out. May be NULL
704 * int : offset into packet data where we are.
705 * int : length of clv we are decoding
707 * Output:
708 * void, but we will add to proto tree if !NULL.
710 static void
711 dissect_lsp_svcs_info_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
712 int length)
714 if (length < 1) {
715 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
716 "Short services info entry");
717 return;
720 proto_tree_add_item(tree, hf_nlsp_svcs_info_hops_to_reach_the_service, tvb, offset, 1, ENC_BIG_ENDIAN);
721 offset += 1;
722 length -= 1;
724 if (length < 4) {
725 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
726 "Short services info entry");
727 return;
730 proto_tree_add_item(tree, hf_nlsp_svcs_info_network_number, tvb, offset, 4, ENC_BIG_ENDIAN);
731 offset += 4;
732 length -= 4;
734 if (length < 6) {
735 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
736 "Short services info entry");
737 return;
740 proto_tree_add_item(tree, hf_nlsp_svcs_info_node_number, tvb, offset, 6, ENC_NA);
741 offset += 6;
742 length -= 6;
744 if (length < 2) {
745 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
746 "Short services info entry");
747 return;
750 proto_tree_add_item(tree, hf_nlsp_svcs_info_socket, tvb, offset, 2, ENC_BIG_ENDIAN);
751 offset += 2;
752 length -= 2;
754 if (length < 2) {
755 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
756 "Short services info entry");
757 return;
760 proto_tree_add_item(tree, hf_nlsp_svcs_info_type, tvb, offset, 2, ENC_BIG_ENDIAN);
761 offset += 2;
762 length -= 2;
764 if (length > 0) {
765 proto_tree_add_item(tree, hf_nlsp_svcs_info_service_name, tvb, offset, length, ENC_NA|ENC_ASCII);
771 * Name: dissect_lsp_ext_routes_clv()
773 * Description:
774 * Decode for a lsp packet's external routes clv.
776 * Input:
777 * tvbuff_t * : tvbuffer for packet data
778 * proto_tree * : protocol display tree to fill out. May be NULL
779 * int : offset into packet data where we are.
780 * int : length of clv we are decoding
782 * Output:
783 * void, but we will add to proto tree if !NULL.
785 static void
786 dissect_lsp_ext_routes_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
787 int length)
789 while (length > 0) {
790 proto_tree_add_item(tree, hf_nlsp_ext_routes_hops, tvb, offset, 1, ENC_BIG_ENDIAN);
791 offset += 1;
792 length -= 1;
794 if (length < 4) {
795 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
796 "Short external routes entry");
797 return;
800 proto_tree_add_item(tree, hf_nlsp_ext_routes_network_number, tvb, offset, 4, ENC_BIG_ENDIAN);
801 offset += 4;
802 length -= 4;
804 if (length < 2) {
805 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
806 "Short external routes entry");
807 return;
810 proto_tree_add_item(tree, hf_nlsp_ext_routes_rip_delay, tvb, offset, 2, ENC_BIG_ENDIAN);
811 offset += 2;
812 length -= 2;
816 static const nlsp_clv_handle_t clv_l1_lsp_opts[] = {
818 0xC0,
819 "Area address(es)",
820 &ett_nlsp_lsp_clv_area_addr,
821 dissect_area_address_clv
824 0xC1,
825 "Management information",
826 &ett_nlsp_lsp_clv_mgt_info,
827 dissect_lsp_mgt_info_clv
830 0xC2,
831 "Link information",
832 &ett_nlsp_lsp_clv_link_info,
833 dissect_lsp_link_info_clv
836 0xC3,
837 "Services information",
838 &ett_nlsp_lsp_clv_svcs_info,
839 dissect_lsp_svcs_info_clv
842 0xC4,
843 "External routes",
844 &ett_nlsp_lsp_clv_ext_routes,
845 dissect_lsp_ext_routes_clv
851 NULL,
852 NULL
857 * Name: nlsp_dissect_nlsp_lsp()
859 * Description:
860 * Print out the LSP part of the main header and then call the CLV
861 * de-mangler with the right list of valid CLVs.
863 * Input:
864 * tvbuff_t * : tvbuffer for packet data
865 * proto_tree * : protocol display tree to add to. May be NULL.
866 * int offset : our offset into packet data.
867 * int : header length of packet.
869 * Output:
870 * void, but we will add to proto tree if !NULL.
872 /* P | ATT | OVERFLOW | ROUTER TYPE FIELD description */
873 #define NLSP_LSP_PARTITION_MASK 0x80
874 #define NLSP_LSP_PARTITION_SHIFT 7
875 #define NLSP_LSP_PARTITION(info) (((info) & NLSP_LSP_PARTITION_MASK) >> NLSP_LSP_PARTITION_SHIFT)
877 #define NLSP_LSP_ATT_MASK 0x78
878 #define NLSP_LSP_ATT_SHIFT 3
879 #define NLSP_LSP_ATT(info) (((info) & NLSP_LSP_ATT_MASK) >> NLSP_LSP_ATT_SHIFT)
881 #define NLSP_LSP_OVERFLOW_MASK 0x04
882 #define NLSP_LSP_OVERFLOW_SHIFT 2
883 #define NLSP_LSP_OVERFLOW(info) (((info) & NLSP_LSP_OVERFLOW_MASK) >> NLSP_LSP_OVERFLOW_SHIFT)
885 #define NLSP_LSP_ROUTER_TYPE_MASK 0x03
886 #define NLSP_LSP_ROUTER_TYPE(info) ((info) & NLSP_LSP_ROUTER_TYPE_MASK)
888 static void
889 nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
890 int offset, int header_length)
892 uint16_t packet_length;
893 uint16_t remaining_lifetime;
894 uint32_t sequence_number;
895 int len;
897 packet_length = tvb_get_ntohs(tvb, offset);
898 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
899 offset, 2, packet_length);
900 offset += 2;
902 remaining_lifetime = tvb_get_ntohs(tvb, offset);
903 proto_tree_add_uint(tree, hf_nlsp_remaining_lifetime, tvb, offset, 2, remaining_lifetime);
904 offset += 2;
906 col_append_fstr(pinfo->cinfo, COL_INFO, ", LSP ID: %s",
907 tvb_ether_to_str(pinfo->pool, tvb, offset));
909 proto_tree_add_item(tree, hf_nlsp_lsp_id_system_id, tvb, offset, 6, ENC_NA);
911 offset += 6;
912 /* XXX - append the pseudonode ID */
913 proto_tree_add_item(tree, hf_nlsp_lsp_id_pseudonode_id, tvb, offset, 1, ENC_BIG_ENDIAN);
915 offset += 1;
916 proto_tree_add_item(tree, hf_nlsp_lsp_id_lsp_number, tvb, offset, 1, ENC_BIG_ENDIAN);
917 offset += 1;
919 sequence_number = tvb_get_ntohl(tvb, offset);
920 col_append_fstr(pinfo->cinfo, COL_INFO,
921 ", Sequence: 0x%08x, Lifetime: %us",
922 sequence_number, remaining_lifetime);
924 proto_tree_add_uint(tree, hf_nlsp_lsp_sequence_number, tvb,
925 offset, 4, sequence_number);
926 offset += 4;
928 /* XXX -> we could validate the cksum here! */
929 proto_tree_add_checksum(tree, tvb, offset, hf_nlsp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
930 offset += 2;
932 if (tree) {
933 proto_tree_add_item(tree, hf_nlsp_lsp_p, tvb,
934 offset, 1, ENC_BIG_ENDIAN);
935 proto_tree_add_item(tree, hf_nlsp_lsp_attached_flag, tvb,
936 offset, 1, ENC_BIG_ENDIAN);
937 proto_tree_add_item(tree, hf_nlsp_lsp_lspdbol, tvb,
938 offset, 1, ENC_BIG_ENDIAN);
939 proto_tree_add_item(tree, hf_nlsp_lsp_router_type, tvb,
940 offset, 1, ENC_BIG_ENDIAN);
942 offset += 1;
944 len = packet_length - header_length;
945 if (len < 0) {
946 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_long_packet, tvb, offset, -1,
947 "packet header length %d went beyond packet",
948 header_length);
949 return;
953 * Now, we need to decode our CLVs. We need to pass in
954 * our list of valid ones!
956 nlsp_dissect_clvs(tvb, pinfo, tree, offset,
957 clv_l1_lsp_opts, len, ett_nlsp_lsp_clv_unknown);
961 * Name: dissect_snp_lsp_entries()
963 * Description:
964 * All the snp packets use a common payload format. We have up
965 * to n entries (based on length), which are made of:
966 * 2 : remaining life time
967 * 8 : lsp id
968 * 4 : sequence number
969 * 2 : checksum
971 * Input:
972 * tvbuff_t * : tvbuffer for packet data
973 * proto_tree * : protocol display tree to fill out. May be NULL
974 * int : offset into packet data where we are.
975 * int : length of payload to decode.
977 * Output:
978 * void, but we will add to proto tree if !NULL.
980 static void
981 dissect_csnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
982 int length)
984 proto_tree *subtree;
986 while (length > 0) {
987 if (length < 16) {
988 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
989 "Short CSNP header entry");
990 return;
993 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 16,
994 ett_nlsp_csnp_lsp_entry, NULL, "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
995 tvb_ether_to_str(pinfo->pool, tvb, offset+2), /* XXX - rest of system ID */
996 tvb_get_ntohl(tvb, offset+10),
997 tvb_get_ntohs(tvb, offset),
998 tvb_get_ntohs(tvb, offset+14));
1000 proto_tree_add_item(subtree, hf_nlsp_csnp_lsp_id_source_id, tvb, offset+2, 6, ENC_NA);
1001 proto_tree_add_item(subtree, hf_nlsp_csnp_lsp_id_pseudonode_id, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1002 proto_tree_add_item(subtree, hf_nlsp_csnp_lsp_id_lsp_number, tvb, offset+9, 1, ENC_BIG_ENDIAN);
1004 proto_tree_add_item(subtree, hf_nlsp_csnp_lsp_sequence_number, tvb, offset+10, 4, ENC_BIG_ENDIAN);
1006 proto_tree_add_item(subtree, hf_nlsp_csnp_remaining_lifetime, tvb, offset, 2, ENC_BIG_ENDIAN);
1008 proto_tree_add_checksum(subtree, tvb, offset+14, hf_nlsp_csnp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1010 length -= 16;
1011 offset += 16;
1015 static void
1016 dissect_psnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset,
1017 int length)
1019 proto_tree *subtree;
1021 while (length > 0) {
1022 if (length < 16) {
1023 proto_tree_add_expert_format(tree, pinfo, &ei_nlsp_short_packet, tvb, offset, -1,
1024 "Short PSNP header entry");
1025 return;
1028 subtree = proto_tree_add_subtree_format(tree, tvb, offset, 16,
1029 ett_nlsp_psnp_lsp_entry, NULL, "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, Checksum: 0x%04x",
1030 tvb_ether_to_str(pinfo->pool, tvb, offset+2), /* XXX - rest of system ID */
1031 tvb_get_ntohl(tvb, offset+10),
1032 tvb_get_ntohs(tvb, offset),
1033 tvb_get_ntohs(tvb, offset+14));
1035 proto_tree_add_item(subtree, hf_nlsp_psnp_lsp_id_source_id, tvb, offset+2, 6, ENC_NA);
1036 proto_tree_add_item(subtree, hf_nlsp_psnp_lsp_id_pseudonode_id, tvb, offset+8, 1, ENC_BIG_ENDIAN);
1037 proto_tree_add_item(subtree, hf_nlsp_psnp_lsp_id_lsp_number, tvb, offset+9, 1, ENC_BIG_ENDIAN);
1039 proto_tree_add_item(subtree, hf_nlsp_psnp_lsp_sequence_number, tvb, offset+10, 4, ENC_BIG_ENDIAN);
1041 proto_tree_add_item(subtree, hf_nlsp_psnp_remaining_lifetime, tvb, offset, 2, ENC_BIG_ENDIAN);
1043 proto_tree_add_checksum(subtree, tvb, offset+14, hf_nlsp_psnp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1045 length -= 16;
1046 offset += 16;
1050 static const nlsp_clv_handle_t clv_l1_csnp_opts[] = {
1053 "LSP entries",
1054 &ett_nlsp_csnp_lsp_entries,
1055 dissect_csnp_lsp_entries
1061 NULL,
1062 NULL
1067 * Name: nlsp_dissect_nlsp_csnp()
1069 * Description:
1070 * Tear apart a L1 CSNP header and then call into payload dissect
1071 * to pull apart the lsp id payload.
1073 * Input:
1074 * tvbuff_t * : tvbuffer for packet data
1075 * proto_tree * : protocol display tree to add to. May be NULL.
1076 * int offset : our offset into packet data.
1077 * int : header length of packet.
1079 * Output:
1080 * void, but we will add to proto tree if !NULL.
1082 static void
1083 nlsp_dissect_nlsp_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1084 int offset, int header_length)
1086 uint16_t packet_length;
1087 int len;
1089 packet_length = tvb_get_ntohs(tvb, offset);
1090 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb, offset, 2, packet_length);
1091 offset += 2;
1093 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
1094 tvb_ether_to_str(pinfo->pool, tvb, offset));
1095 proto_tree_add_item(tree, hf_nlsp_csnp_source_id_system_id, tvb, offset, 6, ENC_NA);
1096 offset += 6;
1097 proto_tree_add_item(tree, hf_nlsp_csnp_source_id_pseudonode_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1098 offset += 1;
1100 col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP ID: %s",
1101 tvb_ether_to_str(pinfo->pool, tvb, offset));
1102 proto_tree_add_item(tree, hf_nlsp_csnp_start_lsp_id_source_id, tvb, offset, 6, ENC_NA);
1103 offset += 6;
1104 /* XXX - append the pseudonode ID */
1105 proto_tree_add_item(tree, hf_nlsp_csnp_start_lsp_id_pseudonode_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1106 offset += 1;
1108 proto_tree_add_item(tree, hf_nlsp_csnp_start_lsp_id_lsp_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1109 offset += 1;
1111 col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP ID: %s",
1112 tvb_ether_to_str(pinfo->pool, tvb, offset));
1113 proto_tree_add_item(tree, hf_nlsp_csnp_end_lsp_id_source_id, tvb, offset, 6, ENC_NA);
1114 offset += 6;
1115 /* XXX - append the pseudonode ID */
1116 proto_tree_add_item(tree, hf_nlsp_csnp_end_lsp_id_pseudonode_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1117 offset += 1;
1118 proto_tree_add_item(tree, hf_nlsp_csnp_end_lsp_id_lsp_number, tvb, offset, 1, ENC_BIG_ENDIAN);
1119 offset += 1;
1121 len = packet_length - header_length;
1122 if (len < 0) {
1123 return;
1125 /* Call into payload dissector */
1126 nlsp_dissect_clvs(tvb, pinfo, tree, offset,
1127 clv_l1_csnp_opts, len, ett_nlsp_csnp_clv_unknown);
1130 static const nlsp_clv_handle_t clv_l1_psnp_opts[] = {
1133 "LSP entries",
1134 &ett_nlsp_psnp_lsp_entries,
1135 dissect_psnp_lsp_entries
1141 NULL,
1142 NULL
1147 * Name: nlsp_dissect_nlsp_psnp()
1149 * Description:
1150 * Tear apart a L1 PSNP header and then call into payload dissect
1151 * to pull apart the lsp id payload.
1153 * Input:
1154 * tvbuff_t * : tvbuffer for packet data
1155 * proto_tree * : protocol display tree to add to. May be NULL.
1156 * int offset : our offset into packet data.
1157 * int : header length of packet.
1159 * Output:
1160 * void, but we will add to proto tree if !NULL.
1162 static void
1163 nlsp_dissect_nlsp_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1164 int offset, int header_length)
1166 uint16_t packet_length;
1167 int len;
1169 packet_length = tvb_get_ntohs(tvb, offset);
1170 proto_tree_add_uint(tree, hf_nlsp_packet_length, tvb,
1171 offset, 2, packet_length);
1172 offset += 2;
1174 col_append_fstr(pinfo->cinfo, COL_INFO, ", Source ID: %s",
1175 tvb_ether_to_str(pinfo->pool, tvb, offset));
1176 proto_tree_add_item(tree, hf_nlsp_psnp_source_id_system_id, tvb, offset, 6, ENC_NA);
1177 offset += 6;
1178 /* XXX - add the pseudonode ID */
1179 proto_tree_add_item(tree, hf_nlsp_psnp_source_id_pseudonode_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1180 offset += 1;
1182 len = packet_length - header_length;
1183 if (len < 0) {
1184 return;
1186 /* Call into payload dissector */
1187 nlsp_dissect_clvs(tvb, pinfo, tree, offset,
1188 clv_l1_psnp_opts, len, ett_nlsp_psnp_clv_unknown);
1192 * Name: dissect_nlsp()
1194 * Description:
1195 * Main entry area for nlsp de-mangling. This will build the
1196 * main nlsp tree data and call the sub-protocols as needed.
1198 * Input:
1199 * tvbuff_t * : tvbuffer for packet data
1200 * packet_info * : info for current packet
1201 * proto_tree * : tree of display data. May be NULL.
1203 * Output:
1204 * void, but we will add to the proto_tree if it is not NULL.
1206 static int
1207 dissect_nlsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
1209 proto_item *ti, *type_item;
1210 proto_tree *nlsp_tree;
1211 int offset = 0;
1212 uint8_t nlsp_major_version;
1213 uint8_t nlsp_header_length;
1214 uint8_t packet_type_flags;
1215 uint8_t packet_type;
1217 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NLSP");
1218 col_clear(pinfo->cinfo, COL_INFO);
1220 ti = proto_tree_add_item(tree, proto_nlsp, tvb, 0, -1, ENC_NA);
1221 nlsp_tree = proto_item_add_subtree(ti, ett_nlsp);
1223 proto_tree_add_item(nlsp_tree, hf_nlsp_irpd, tvb, offset, 1,
1224 ENC_BIG_ENDIAN );
1225 offset += 1;
1227 nlsp_header_length = tvb_get_uint8(tvb, 1);
1228 proto_tree_add_uint(nlsp_tree, hf_nlsp_header_length, tvb,
1229 offset, 1, nlsp_header_length );
1230 offset += 1;
1232 proto_tree_add_item(nlsp_tree, hf_nlsp_minor_version, tvb,
1233 offset, 1, ENC_BIG_ENDIAN );
1234 offset += 1;
1236 offset += 1; /* Reserved */
1238 packet_type_flags = tvb_get_uint8(tvb, offset);
1239 packet_type = packet_type_flags & PACKET_TYPE_MASK;
1240 col_add_str(pinfo->cinfo, COL_INFO,
1241 val_to_str(packet_type, nlsp_packet_type_vals, "Unknown (%u)"));
1242 if (packet_type == NLSP_TYPE_L1_LSP) {
1243 proto_tree_add_boolean(nlsp_tree, hf_nlsp_nr, tvb, offset, 1, packet_type_flags );
1245 type_item = proto_tree_add_uint(nlsp_tree, hf_nlsp_type, tvb, offset, 1, packet_type_flags );
1246 offset += 1;
1248 nlsp_major_version = tvb_get_uint8(tvb, offset);
1249 ti = proto_tree_add_item(nlsp_tree, hf_nlsp_major_version, tvb,
1250 offset, 1, ENC_BIG_ENDIAN );
1251 if (nlsp_major_version != 1){
1252 expert_add_info_format(pinfo, ti, &ei_nlsp_major_version,
1253 "Unknown NLSP version (%d vs 1)",
1254 nlsp_major_version);
1256 offset += 1;
1258 offset += 2; /* Reserved */
1260 switch (packet_type) {
1262 case NLSP_TYPE_L1_HELLO:
1263 case NLSP_TYPE_WAN_HELLO:
1264 nlsp_dissect_nlsp_hello(tvb, pinfo, nlsp_tree, offset,
1265 packet_type, nlsp_header_length);
1266 break;
1268 case NLSP_TYPE_L1_LSP:
1269 nlsp_dissect_nlsp_lsp(tvb, pinfo, nlsp_tree, offset,
1270 nlsp_header_length);
1271 break;
1273 case NLSP_TYPE_L1_CSNP:
1274 nlsp_dissect_nlsp_csnp(tvb, pinfo, nlsp_tree, offset,
1275 nlsp_header_length);
1276 break;
1278 case NLSP_TYPE_L1_PSNP:
1279 nlsp_dissect_nlsp_psnp(tvb, pinfo, nlsp_tree, offset,
1280 nlsp_header_length);
1281 break;
1283 default:
1284 expert_add_info(pinfo, type_item, &ei_nlsp_type);
1286 return tvb_captured_length(tvb);
1290 * Name: proto_register_nlsp()
1292 * Description:
1293 * main register for NLSP protocol set. We register some display
1294 * formats and the protocol module variables.
1296 * NOTE: this procedure to autolinked by the makefile process that
1297 * builds register.c
1299 * Input:
1300 * void
1302 * Output:
1303 * void
1305 void
1306 proto_register_nlsp(void)
1308 static hf_register_info hf[] = {
1309 { &hf_nlsp_irpd,
1310 { "NetWare Link Services Protocol Discriminator", "nlsp.irpd",
1311 FT_UINT8, BASE_HEX, NULL, 0x0,
1312 NULL, HFILL }
1315 { &hf_nlsp_header_length,
1316 { "PDU Header Length", "nlsp.header_length",
1317 FT_UINT8, BASE_DEC, NULL, 0x0,
1318 NULL, HFILL }
1321 { &hf_nlsp_minor_version,
1322 { "Minor Version", "nlsp.minor_version",
1323 FT_UINT8, BASE_DEC, NULL, 0x0,
1324 NULL, HFILL }
1327 { &hf_nlsp_nr,
1328 { "Multi-homed Non-routing Server", "nlsp.nr",
1329 FT_BOOLEAN, 8, NULL, 0x80,
1330 NULL, HFILL }
1333 { &hf_nlsp_type,
1334 { "Packet Type", "nlsp.type",
1335 FT_UINT8, BASE_DEC, VALS(nlsp_packet_type_vals), PACKET_TYPE_MASK,
1336 NULL, HFILL }
1339 { &hf_nlsp_major_version,
1340 { "Major Version", "nlsp.major_version",
1341 FT_UINT8, BASE_DEC, NULL, 0x0,
1342 NULL, HFILL }
1345 { &hf_nlsp_packet_length,
1346 { "Packet Length", "nlsp.packet_length",
1347 FT_UINT16, BASE_DEC, NULL, 0x0,
1348 NULL, HFILL }
1351 { &hf_nlsp_hello_state,
1352 { "State", "nlsp.hello.state",
1353 FT_UINT8, BASE_DEC, VALS(nlsp_hello_state_vals), NLSP_HELLO_STATE_MASK,
1354 NULL, HFILL }
1357 { &hf_nlsp_hello_multicast,
1358 { "Multicast Routing", "nlsp.hello.multicast",
1359 FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), NLSP_HELLO_MULTICAST_MASK,
1360 "If set, this router supports multicast routing", HFILL }
1363 { &hf_nlsp_hello_circuit_type,
1364 { "Circuit Type", "nlsp.hello.circuit_type",
1365 FT_UINT8, BASE_DEC, VALS(nlsp_hello_circuit_type_vals), NLSP_HELLO_CTYPE_MASK,
1366 NULL, HFILL }
1369 { &hf_nlsp_hello_holding_timer,
1370 { "Holding Timer", "nlsp.hello.holding_timer",
1371 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_seconds), 0x0,
1372 NULL, HFILL }
1375 { &hf_nlsp_hello_priority,
1376 { "Priority", "nlsp.hello.priority",
1377 FT_UINT8, BASE_DEC, NULL, NLSP_HELLO_PRIORITY_MASK,
1378 NULL, HFILL }
1381 { &hf_nlsp_lsp_sequence_number,
1382 { "Sequence Number", "nlsp.sequence_number",
1383 FT_UINT32, BASE_HEX, NULL, 0x0,
1384 NULL, HFILL }
1387 { &hf_nlsp_lsp_checksum,
1388 { "Checksum", "nlsp.lsp.checksum",
1389 FT_UINT16, BASE_HEX, NULL, 0x0,
1390 NULL, HFILL }
1393 { &hf_nlsp_lsp_p,
1394 { "Partition Repair", "nlsp.lsp.partition_repair",
1395 FT_BOOLEAN, 8, TFS(&tfs_supported_not_supported), NLSP_LSP_PARTITION_MASK,
1396 "If set, this router supports the optional Partition Repair function", HFILL }
1399 { &hf_nlsp_lsp_attached_flag,
1400 { "Attached Flag", "nlsp.lsp.attached_flag",
1401 FT_UINT8, BASE_DEC, VALS(nlsp_attached_flag_vals), NLSP_LSP_ATT_MASK,
1402 NULL, HFILL }
1405 { &hf_nlsp_lsp_lspdbol,
1406 { "LSP Database Overloaded", "nlsp.lsp.lspdbol",
1407 FT_BOOLEAN, 8, NULL, NLSP_LSP_OVERFLOW_MASK,
1408 NULL, HFILL }
1411 { &hf_nlsp_lsp_router_type,
1412 { "Router Type", "nlsp.lsp.router_type",
1413 FT_UINT8, BASE_DEC, VALS(nlsp_router_type_vals), NLSP_LSP_ROUTER_TYPE_MASK,
1414 NULL, HFILL }
1417 { &hf_nlsp_lsp_link_info_clv_flags_cost_present,
1418 { "Cost present", "nlsp.lsp.link_info_clv.flags.cost_present",
1419 FT_BOOLEAN, 8, TFS(&tfs_no_yes), 0x80,
1420 NULL, HFILL }
1423 { &hf_nlsp_lsp_link_info_clv_flags_cost_metric,
1424 { "Cost metric", "nlsp.lsp.link_info_clv.flags.cost_metric",
1425 FT_BOOLEAN, 8, TFS(&tfs_internal_external), 0x40,
1426 NULL, HFILL }
1429 { &hf_nlsp_lsp_link_info_clv_flags_cost,
1430 { "Cost", "nlsp.lsp.link_info_clv.flags.cost",
1431 FT_UINT8, BASE_DEC, NULL, 0x3F,
1432 NULL, HFILL }
1435 /* Generated from convert_proto_tree_add_text.pl */
1436 { &hf_nlsp_unknown_code,
1437 { "Unknown code", "nlsp.unknown_code",
1438 FT_UINT8, BASE_DEC, NULL, 0x0,
1439 NULL, HFILL }
1441 { &hf_nlsp_area_address_network_number,
1442 { "Area address network number", "nlsp.area_address.network_number",
1443 FT_UINT32, BASE_HEX, NULL, 0x0,
1444 NULL, HFILL }
1446 { &hf_nlsp_area_address_mask,
1447 { "Area address mask", "nlsp.area_address.mask",
1448 FT_UINT32, BASE_HEX, NULL, 0x0,
1449 NULL, HFILL }
1451 { &hf_nlsp_neighbor,
1452 { "Neighbor", "nlsp.neighbor",
1453 FT_ETHER, BASE_NONE, NULL, 0x0,
1454 NULL, HFILL }
1456 { &hf_nlsp_hello_local_mtu_mtu_size,
1457 { "MTU Size", "nlsp.hello_local_mtu.mtu_size",
1458 FT_UINT32, BASE_DEC, NULL, 0x0,
1459 NULL, HFILL }
1461 { &hf_nlsp_hello_sending_router_system_id,
1462 { "Sending Router System ID", "nlsp.hello.sending_router_system_id",
1463 FT_ETHER, BASE_NONE, NULL, 0x0,
1464 NULL, HFILL }
1466 { &hf_nlsp_hello_local_wan_circuit_id,
1467 { "Local WAN Circuit ID", "nlsp.hello.local_wan_circuit_id",
1468 FT_UINT8, BASE_DEC, NULL, 0x0,
1469 NULL, HFILL }
1471 { &hf_nlsp_hello_designated_router_system_id,
1472 { "Designated Router System ID", "nlsp.hello.designated_router_system_id",
1473 FT_ETHER, BASE_NONE, NULL, 0x0,
1474 NULL, HFILL }
1476 { &hf_nlsp_hello_designated_router_pseudonode_id,
1477 { "Designated Router Pseudonode ID", "nlsp.hello.designated_router_pseudonode_id",
1478 FT_UINT8, BASE_DEC, NULL, 0x0,
1479 NULL, HFILL }
1481 { &hf_nlsp_mgt_info_network_number,
1482 { "Network number", "nlsp.mgt_info.network_number",
1483 FT_UINT32, BASE_HEX, NULL, 0x0,
1484 NULL, HFILL }
1486 { &hf_nlsp_mgt_info_node_number,
1487 { "Node number", "nlsp.mgt_info.node_number",
1488 FT_ETHER, BASE_NONE, NULL, 0x0,
1489 NULL, HFILL }
1491 { &hf_nlsp_mgt_info_ipx_version_number,
1492 { "IPX version number", "nlsp.mgt_info.ipx_version_number",
1493 FT_UINT8, BASE_DEC, NULL, 0x0,
1494 NULL, HFILL }
1496 { &hf_nlsp_mgt_info_name_length,
1497 { "Name length", "nlsp.mgt_info.name_length",
1498 FT_UINT8, BASE_DEC, NULL, 0x0,
1499 NULL, HFILL }
1501 { &hf_nlsp_mgt_info_name,
1502 { "Name", "nlsp.mgt_info.name",
1503 FT_STRING, BASE_NONE, NULL, 0x0,
1504 NULL, HFILL }
1506 { &hf_nlsp_link_info_router_system_id,
1507 { "Router System ID", "nlsp.link_info.router_system_id",
1508 FT_ETHER, BASE_NONE, NULL, 0x0,
1509 NULL, HFILL }
1511 { &hf_nlsp_link_info_router_pseudonode_id,
1512 { "Router Pseudonode ID", "nlsp.link_info.router_pseudonode_id",
1513 FT_UINT8, BASE_DEC, NULL, 0x0,
1514 NULL, HFILL }
1516 { &hf_nlsp_link_info_mtu_size,
1517 { "MTU Size", "nlsp.link_info.mtu_size",
1518 FT_UINT32, BASE_DEC, NULL, 0x0,
1519 NULL, HFILL }
1521 { &hf_nlsp_link_info_delay,
1522 { "Delay", "nlsp.link_info.delay",
1523 FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_microseconds), 0x0,
1524 NULL, HFILL }
1526 { &hf_nlsp_link_info_throughput,
1527 { "Throughput", "nlsp.link_info.throughput",
1528 FT_UINT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_bit_sec), 0x0,
1529 NULL, HFILL }
1531 { &hf_nlsp_link_info_media_type,
1532 { "Media type", "nlsp.link_info.media_type",
1533 FT_UINT16, BASE_DEC, VALS(media_type_vals), 0x0,
1534 NULL, HFILL }
1536 { &hf_nlsp_svcs_info_hops_to_reach_the_service,
1537 { "Hops to reach the service", "nlsp.svcs_info.hops_to_reach_the_service",
1538 FT_UINT8, BASE_DEC, NULL, 0x0,
1539 NULL, HFILL }
1541 { &hf_nlsp_svcs_info_network_number,
1542 { "Network number", "nlsp.svcs_info.network_number",
1543 FT_UINT32, BASE_HEX, NULL, 0x0,
1544 NULL, HFILL }
1546 { &hf_nlsp_svcs_info_node_number,
1547 { "Node number", "nlsp.svcs_info.node_number",
1548 FT_ETHER, BASE_NONE, NULL, 0x0,
1549 NULL, HFILL }
1551 { &hf_nlsp_svcs_info_socket,
1552 { "Socket", "nlsp.svcs_info.socket",
1553 FT_UINT16, BASE_DEC|BASE_EXT_STRING, &ipx_socket_vals_ext, 0x0,
1554 NULL, HFILL }
1556 { &hf_nlsp_svcs_info_type,
1557 { "Type", "nlsp.svcs_info.type",
1558 FT_UINT16, BASE_DEC|BASE_EXT_STRING, &novell_server_vals_ext, 0x0,
1559 NULL, HFILL }
1561 { &hf_nlsp_svcs_info_service_name,
1562 { "Service Name", "nlsp.svcs_info.service_name",
1563 FT_STRING, BASE_NONE, NULL, 0x0,
1564 NULL, HFILL }
1566 { &hf_nlsp_ext_routes_hops,
1567 { "Hops", "nlsp.ext_routes.hops",
1568 FT_UINT8, BASE_DEC, NULL, 0x0,
1569 NULL, HFILL }
1571 { &hf_nlsp_ext_routes_network_number,
1572 { "Network number", "nlsp.ext_routes.network_number",
1573 FT_UINT32, BASE_HEX, NULL, 0x0,
1574 NULL, HFILL }
1576 { &hf_nlsp_ext_routes_rip_delay,
1577 { "RIP delay", "nlsp.ext_routes.rip_delay",
1578 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_tick_ticks), 0x0,
1579 NULL, HFILL }
1581 { &hf_nlsp_remaining_lifetime,
1582 { "Remaining Lifetime", "nlsp.remaining_lifetime",
1583 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_seconds), 0x0,
1584 NULL, HFILL }
1586 { &hf_nlsp_lsp_id_system_id,
1587 { "LSP ID system ID", "nlsp.lsp_id_system_id",
1588 FT_ETHER, BASE_NONE, NULL, 0x0,
1589 NULL, HFILL }
1591 { &hf_nlsp_lsp_id_pseudonode_id,
1592 { "LSP ID pseudonode ID", "nlsp.lsp_id_pseudonode_id",
1593 FT_UINT8, BASE_DEC, NULL, 0x0,
1594 NULL, HFILL }
1596 { &hf_nlsp_lsp_id_lsp_number,
1597 { "LSP ID LSP number", "nlsp.lsp_id_lsp_number",
1598 FT_UINT8, BASE_DEC, NULL, 0x0,
1599 NULL, HFILL }
1601 { &hf_nlsp_csnp_lsp_id_source_id,
1602 { "LSP ID source ID", "nlsp.csnp.lsp_id_source_id",
1603 FT_ETHER, BASE_NONE, NULL, 0x0,
1604 NULL, HFILL }
1606 { &hf_nlsp_csnp_lsp_id_pseudonode_id,
1607 { "LSP ID pseudonode ID", "nlsp.csnp.lsp_id_pseudonode_id",
1608 FT_UINT8, BASE_DEC, NULL, 0x0,
1609 NULL, HFILL }
1611 { &hf_nlsp_csnp_lsp_id_lsp_number,
1612 { "LSP ID LSP number", "nlsp.csnp.lsp_id_lsp_number",
1613 FT_UINT8, BASE_DEC, NULL, 0x0,
1614 NULL, HFILL }
1616 { &hf_nlsp_csnp_lsp_sequence_number,
1617 { "LSP Sequence Number", "nlsp.csnp.lsp_sequence_number",
1618 FT_UINT32, BASE_HEX, NULL, 0x0,
1619 NULL, HFILL }
1621 { &hf_nlsp_csnp_remaining_lifetime,
1622 { "Remaining Lifetime", "nlsp.csnp.remaining_lifetime",
1623 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_seconds), 0x0,
1624 NULL, HFILL }
1626 { &hf_nlsp_csnp_lsp_checksum,
1627 { "LSP checksum", "nlsp.csnp.lsp_checksum",
1628 FT_UINT16, BASE_HEX, NULL, 0x0,
1629 NULL, HFILL }
1631 { &hf_nlsp_psnp_lsp_id_source_id,
1632 { "LSP ID source ID", "nlsp.psnp.lsp_id_source_id",
1633 FT_ETHER, BASE_NONE, NULL, 0x0,
1634 NULL, HFILL }
1636 { &hf_nlsp_psnp_lsp_id_pseudonode_id,
1637 { "LSP ID pseudonode ID", "nlsp.psnp.lsp_id_pseudonode_id",
1638 FT_UINT8, BASE_DEC, NULL, 0x0,
1639 NULL, HFILL }
1641 { &hf_nlsp_psnp_lsp_id_lsp_number,
1642 { "LSP ID LSP number", "nlsp.psnp.lsp_id_lsp_number",
1643 FT_UINT8, BASE_DEC, NULL, 0x0,
1644 NULL, HFILL }
1646 { &hf_nlsp_psnp_lsp_sequence_number,
1647 { "LSP Sequence Number", "nlsp.psnp.lsp_sequence_number",
1648 FT_UINT32, BASE_HEX, NULL, 0x0,
1649 NULL, HFILL }
1651 { &hf_nlsp_psnp_remaining_lifetime,
1652 { "Remaining Lifetime", "nlsp.psnp.remaining_lifetime",
1653 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, UNS(&units_seconds), 0x0,
1654 NULL, HFILL }
1656 { &hf_nlsp_psnp_lsp_checksum,
1657 { "LSP checksum", "nlsp.psnp.lsp_checksum",
1658 FT_UINT16, BASE_HEX, NULL, 0x0,
1659 NULL, HFILL }
1661 { &hf_nlsp_csnp_source_id_system_id,
1662 { "Source ID system ID", "nlsp.csnp.source_id_system_id",
1663 FT_ETHER, BASE_NONE, NULL, 0x0,
1664 NULL, HFILL }
1666 { &hf_nlsp_csnp_source_id_pseudonode_id,
1667 { "Source ID pseudonode ID", "nlsp.csnp.source_id_pseudonode_id",
1668 FT_UINT8, BASE_DEC, NULL, 0x0,
1669 NULL, HFILL }
1671 { &hf_nlsp_csnp_start_lsp_id_source_id,
1672 { "Start LSP ID source ID", "nlsp.csnp.start_lsp_id_source_id",
1673 FT_ETHER, BASE_NONE, NULL, 0x0,
1674 NULL, HFILL }
1676 { &hf_nlsp_csnp_start_lsp_id_pseudonode_id,
1677 { "Start LSP ID pseudonode ID", "nlsp.csnp.start_lsp_id_pseudonode_id",
1678 FT_UINT8, BASE_DEC, NULL, 0x0,
1679 NULL, HFILL }
1681 { &hf_nlsp_csnp_start_lsp_id_lsp_number,
1682 { "Start LSP ID LSP number", "nlsp.csnp.start_lsp_id_lsp_number",
1683 FT_UINT8, BASE_DEC, NULL, 0x0,
1684 NULL, HFILL }
1686 { &hf_nlsp_csnp_end_lsp_id_source_id,
1687 { "End LSP ID source ID", "nlsp.csnp.end_lsp_id_source_id",
1688 FT_ETHER, BASE_NONE, NULL, 0x0,
1689 NULL, HFILL }
1691 { &hf_nlsp_csnp_end_lsp_id_pseudonode_id,
1692 { "End LSP ID pseudonode ID", "nlsp.csnp.end_lsp_id_pseudonode_id",
1693 FT_UINT8, BASE_DEC, NULL, 0x0,
1694 NULL, HFILL }
1696 { &hf_nlsp_csnp_end_lsp_id_lsp_number,
1697 { "End LSP ID LSP number", "nlsp.csnp.end_lsp_id_lsp_number",
1698 FT_UINT8, BASE_DEC, NULL, 0x0,
1699 NULL, HFILL }
1701 { &hf_nlsp_psnp_source_id_system_id,
1702 { "Source ID system ID", "nlsp.psnp.source_id_system_id",
1703 FT_ETHER, BASE_NONE, NULL, 0x0,
1704 NULL, HFILL }
1706 { &hf_nlsp_psnp_source_id_pseudonode_id,
1707 { "Source ID pseudonode ID", "nlsp.psnp.source_id_pseudonode_id",
1708 FT_UINT8, BASE_DEC, NULL, 0x0,
1709 NULL, HFILL }
1712 static int *ett[] = {
1713 &ett_nlsp,
1714 &ett_nlsp_hello_clv_area_addr,
1715 &ett_nlsp_hello_clv_neighbors,
1716 &ett_nlsp_hello_local_mtu,
1717 &ett_nlsp_hello_clv_unknown,
1718 &ett_nlsp_lsp_info,
1719 &ett_nlsp_lsp_clv_area_addr,
1720 &ett_nlsp_lsp_clv_mgt_info,
1721 &ett_nlsp_lsp_clv_link_info,
1722 &ett_nlsp_lsp_clv_svcs_info,
1723 &ett_nlsp_lsp_clv_ext_routes,
1724 &ett_nlsp_lsp_clv_unknown,
1725 &ett_nlsp_csnp_lsp_entries,
1726 &ett_nlsp_csnp_lsp_entry,
1727 &ett_nlsp_csnp_clv_unknown,
1728 &ett_nlsp_psnp_lsp_entries,
1729 &ett_nlsp_psnp_lsp_entry,
1730 &ett_nlsp_psnp_clv_unknown,
1733 static ei_register_info ei[] = {
1734 { &ei_nlsp_short_packet, { "nlsp.short_packet", PI_MALFORMED, PI_ERROR, "Short packet", EXPFILL }},
1735 { &ei_nlsp_long_packet, { "nlsp.long_packet", PI_MALFORMED, PI_ERROR, "Long packet", EXPFILL }},
1736 { &ei_nlsp_major_version, { "nlsp.major_version.unknown", PI_PROTOCOL, PI_WARN, "Unknown NLSP version", EXPFILL }},
1737 { &ei_nlsp_type, { "nlsp.type.unknown", PI_PROTOCOL, PI_WARN, "Unknown NLSP packet type", EXPFILL }},
1740 expert_module_t* expert_nlsp;
1742 proto_nlsp = proto_register_protocol("NetWare Link Services Protocol",
1743 "NLSP", "nlsp");
1744 proto_register_field_array(proto_nlsp, hf, array_length(hf));
1745 proto_register_subtree_array(ett, array_length(ett));
1746 expert_nlsp = expert_register_protocol(proto_nlsp);
1747 expert_register_field_array(expert_nlsp, ei, array_length(ei));
1749 nlsp_handle = register_dissector("nlsp", dissect_nlsp, proto_nlsp);
1752 void
1753 proto_reg_handoff_nlsp(void)
1755 dissector_add_uint("ipx.socket", IPX_SOCKET_NLSP, nlsp_handle);
1759 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1761 * Local variables:
1762 * c-basic-offset: 8
1763 * tab-width: 8
1764 * indent-tabs-mode: t
1765 * End:
1767 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1768 * :indentSize=8:tabSize=8:noTabs=false: