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