xref: /freebsd/contrib/tcpdump/print-rsvp.c (revision 6ae1554a5d9b318f8ad53ccc39fa5a961403da73)
1 /*
2  * Copyright (c) 1998-2007 The TCPDUMP project
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that: (1) source code
6  * distributions retain the above copyright notice and this paragraph
7  * in its entirety, and (2) distributions including binary code include
8  * the above copyright notice and this paragraph in its entirety in
9  * the documentation or other materials provided with the distribution.
10  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * Original code by Hannes Gredler (hannes@juniper.net)
16  */
17 
18 #define NETDISSECT_REWORKED
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22 
23 #include <tcpdump-stdinc.h>
24 
25 #include "interface.h"
26 #include "extract.h"
27 #include "addrtoname.h"
28 #include "ethertype.h"
29 #include "gmpls.h"
30 #include "af.h"
31 #include "signature.h"
32 
33 /*
34  * RFC 2205 common header
35  *
36  *               0             1              2             3
37  *        +-------------+-------------+-------------+-------------+
38  *        | Vers | Flags|  Msg Type   |       RSVP Checksum       |
39  *        +-------------+-------------+-------------+-------------+
40  *        |  Send_TTL   | (Reserved)  |        RSVP Length        |
41  *        +-------------+-------------+-------------+-------------+
42  *
43  */
44 
45 struct rsvp_common_header {
46     uint8_t version_flags;
47     uint8_t msg_type;
48     uint8_t checksum[2];
49     uint8_t ttl;
50     uint8_t reserved;
51     uint8_t length[2];
52 };
53 
54 /*
55  * RFC2205 object header
56  *
57  *
58  *               0             1              2             3
59  *        +-------------+-------------+-------------+-------------+
60  *        |       Length (bytes)      |  Class-Num  |   C-Type    |
61  *        +-------------+-------------+-------------+-------------+
62  *        |                                                       |
63  *        //                  (Object contents)                   //
64  *        |                                                       |
65  *        +-------------+-------------+-------------+-------------+
66  */
67 
68 struct rsvp_object_header {
69     uint8_t length[2];
70     uint8_t class_num;
71     uint8_t ctype;
72 };
73 
74 #define RSVP_VERSION            1
75 #define	RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
76 #define	RSVP_EXTRACT_FLAGS(x)   ((x)&0x0f)
77 
78 #define	RSVP_MSGTYPE_PATH       1
79 #define	RSVP_MSGTYPE_RESV       2
80 #define	RSVP_MSGTYPE_PATHERR    3
81 #define	RSVP_MSGTYPE_RESVERR    4
82 #define	RSVP_MSGTYPE_PATHTEAR   5
83 #define	RSVP_MSGTYPE_RESVTEAR   6
84 #define	RSVP_MSGTYPE_RESVCONF   7
85 #define RSVP_MSGTYPE_AGGREGATE  12
86 #define RSVP_MSGTYPE_ACK        13
87 #define RSVP_MSGTYPE_HELLO_OLD  14      /* ancient Hellos */
88 #define RSVP_MSGTYPE_SREFRESH   15
89 #define	RSVP_MSGTYPE_HELLO      20
90 
91 static const struct tok rsvp_msg_type_values[] = {
92     { RSVP_MSGTYPE_PATH,	"Path" },
93     { RSVP_MSGTYPE_RESV,	"Resv" },
94     { RSVP_MSGTYPE_PATHERR,	"PathErr" },
95     { RSVP_MSGTYPE_RESVERR,	"ResvErr" },
96     { RSVP_MSGTYPE_PATHTEAR,	"PathTear" },
97     { RSVP_MSGTYPE_RESVTEAR,	"ResvTear" },
98     { RSVP_MSGTYPE_RESVCONF,	"ResvConf" },
99     { RSVP_MSGTYPE_AGGREGATE,	"Aggregate" },
100     { RSVP_MSGTYPE_ACK,	        "Acknowledgement" },
101     { RSVP_MSGTYPE_HELLO_OLD,	"Hello (Old)" },
102     { RSVP_MSGTYPE_SREFRESH,	"Refresh" },
103     { RSVP_MSGTYPE_HELLO,	"Hello" },
104     { 0, NULL}
105 };
106 
107 static const struct tok rsvp_header_flag_values[] = {
108     { 0x01,	              "Refresh reduction capable" }, /* rfc2961 */
109     { 0, NULL}
110 };
111 
112 #define	RSVP_OBJ_SESSION            1   /* rfc2205 */
113 #define	RSVP_OBJ_RSVP_HOP           3   /* rfc2205, rfc3473 */
114 #define	RSVP_OBJ_INTEGRITY          4   /* rfc2747 */
115 #define	RSVP_OBJ_TIME_VALUES        5   /* rfc2205 */
116 #define	RSVP_OBJ_ERROR_SPEC         6
117 #define	RSVP_OBJ_SCOPE              7
118 #define	RSVP_OBJ_STYLE              8   /* rfc2205 */
119 #define	RSVP_OBJ_FLOWSPEC           9   /* rfc2215 */
120 #define	RSVP_OBJ_FILTERSPEC         10  /* rfc2215 */
121 #define	RSVP_OBJ_SENDER_TEMPLATE    11
122 #define	RSVP_OBJ_SENDER_TSPEC       12  /* rfc2215 */
123 #define	RSVP_OBJ_ADSPEC             13  /* rfc2215 */
124 #define	RSVP_OBJ_POLICY_DATA        14
125 #define	RSVP_OBJ_CONFIRM            15  /* rfc2205 */
126 #define	RSVP_OBJ_LABEL              16  /* rfc3209 */
127 #define	RSVP_OBJ_LABEL_REQ          19  /* rfc3209 */
128 #define	RSVP_OBJ_ERO                20  /* rfc3209 */
129 #define	RSVP_OBJ_RRO                21  /* rfc3209 */
130 #define	RSVP_OBJ_HELLO              22  /* rfc3209 */
131 #define	RSVP_OBJ_MESSAGE_ID         23  /* rfc2961 */
132 #define	RSVP_OBJ_MESSAGE_ID_ACK     24  /* rfc2961 */
133 #define	RSVP_OBJ_MESSAGE_ID_LIST    25  /* rfc2961 */
134 #define	RSVP_OBJ_RECOVERY_LABEL     34  /* rfc3473 */
135 #define	RSVP_OBJ_UPSTREAM_LABEL     35  /* rfc3473 */
136 #define	RSVP_OBJ_LABEL_SET          36  /* rfc3473 */
137 #define	RSVP_OBJ_PROTECTION         37  /* rfc3473 */
138 #define RSVP_OBJ_S2L                50  /* rfc4875 */
139 #define	RSVP_OBJ_DETOUR             63  /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */
140 #define	RSVP_OBJ_CLASSTYPE          66  /* rfc4124 */
141 #define RSVP_OBJ_CLASSTYPE_OLD      125 /* draft-ietf-tewg-diff-te-proto-07 */
142 #define	RSVP_OBJ_SUGGESTED_LABEL    129 /* rfc3473 */
143 #define	RSVP_OBJ_ACCEPT_LABEL_SET   130 /* rfc3473 */
144 #define	RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */
145 #define	RSVP_OBJ_NOTIFY_REQ         195 /* rfc3473 */
146 #define	RSVP_OBJ_ADMIN_STATUS       196 /* rfc3473 */
147 #define	RSVP_OBJ_PROPERTIES         204 /* juniper proprietary */
148 #define	RSVP_OBJ_FASTREROUTE        205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */
149 #define	RSVP_OBJ_SESSION_ATTRIBUTE  207 /* rfc3209 */
150 #define RSVP_OBJ_GENERALIZED_UNI    229 /* OIF RSVP extensions UNI 1.0 Signaling, Rel. 2 */
151 #define RSVP_OBJ_CALL_ID            230 /* rfc3474 */
152 #define RSVP_OBJ_CALL_OPS           236 /* rfc3474 */
153 
154 static const struct tok rsvp_obj_values[] = {
155     { RSVP_OBJ_SESSION,            "Session" },
156     { RSVP_OBJ_RSVP_HOP,           "RSVP Hop" },
157     { RSVP_OBJ_INTEGRITY,          "Integrity" },
158     { RSVP_OBJ_TIME_VALUES,        "Time Values" },
159     { RSVP_OBJ_ERROR_SPEC,         "Error Spec" },
160     { RSVP_OBJ_SCOPE,              "Scope" },
161     { RSVP_OBJ_STYLE,              "Style" },
162     { RSVP_OBJ_FLOWSPEC,           "Flowspec" },
163     { RSVP_OBJ_FILTERSPEC,         "FilterSpec" },
164     { RSVP_OBJ_SENDER_TEMPLATE,    "Sender Template" },
165     { RSVP_OBJ_SENDER_TSPEC,       "Sender TSpec" },
166     { RSVP_OBJ_ADSPEC,             "Adspec" },
167     { RSVP_OBJ_POLICY_DATA,        "Policy Data" },
168     { RSVP_OBJ_CONFIRM,            "Confirm" },
169     { RSVP_OBJ_LABEL,              "Label" },
170     { RSVP_OBJ_LABEL_REQ,          "Label Request" },
171     { RSVP_OBJ_ERO,                "ERO" },
172     { RSVP_OBJ_RRO,                "RRO" },
173     { RSVP_OBJ_HELLO,              "Hello" },
174     { RSVP_OBJ_MESSAGE_ID,         "Message ID" },
175     { RSVP_OBJ_MESSAGE_ID_ACK,     "Message ID Ack" },
176     { RSVP_OBJ_MESSAGE_ID_LIST,    "Message ID List" },
177     { RSVP_OBJ_RECOVERY_LABEL,     "Recovery Label" },
178     { RSVP_OBJ_UPSTREAM_LABEL,     "Upstream Label" },
179     { RSVP_OBJ_LABEL_SET,          "Label Set" },
180     { RSVP_OBJ_ACCEPT_LABEL_SET,   "Acceptable Label Set" },
181     { RSVP_OBJ_DETOUR,             "Detour" },
182     { RSVP_OBJ_CLASSTYPE,          "Class Type" },
183     { RSVP_OBJ_CLASSTYPE_OLD,      "Class Type (old)" },
184     { RSVP_OBJ_SUGGESTED_LABEL,    "Suggested Label" },
185     { RSVP_OBJ_PROPERTIES,         "Properties" },
186     { RSVP_OBJ_FASTREROUTE,        "Fast Re-Route" },
187     { RSVP_OBJ_SESSION_ATTRIBUTE,  "Session Attribute" },
188     { RSVP_OBJ_GENERALIZED_UNI,    "Generalized UNI" },
189     { RSVP_OBJ_CALL_ID,            "Call-ID" },
190     { RSVP_OBJ_CALL_OPS,           "Call Capability" },
191     { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" },
192     { RSVP_OBJ_NOTIFY_REQ,         "Notify Request" },
193     { RSVP_OBJ_PROTECTION,         "Protection" },
194     { RSVP_OBJ_ADMIN_STATUS,       "Administrative Status" },
195     { RSVP_OBJ_S2L,                "Sub-LSP to LSP" },
196     { 0, NULL}
197 };
198 
199 #define	RSVP_CTYPE_IPV4        1
200 #define	RSVP_CTYPE_IPV6        2
201 #define	RSVP_CTYPE_TUNNEL_IPV4 7
202 #define	RSVP_CTYPE_TUNNEL_IPV6 8
203 #define	RSVP_CTYPE_UNI_IPV4    11 /* OIF RSVP extensions UNI 1.0 Signaling Rel. 2 */
204 #define RSVP_CTYPE_1           1
205 #define RSVP_CTYPE_2           2
206 #define RSVP_CTYPE_3           3
207 #define RSVP_CTYPE_4           4
208 #define RSVP_CTYPE_12         12
209 #define RSVP_CTYPE_13         13
210 #define RSVP_CTYPE_14         14
211 
212 /*
213  * the ctypes are not globally unique so for
214  * translating it to strings we build a table based
215  * on objects offsetted by the ctype
216  */
217 
218 static const struct tok rsvp_ctype_values[] = {
219     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV4,	             "IPv4" },
220     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV6,	             "IPv6" },
221     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_3,	             "IPv4 plus opt. TLVs" },
222     { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_4,	             "IPv6 plus opt. TLVs" },
223     { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV4,	             "IPv4" },
224     { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV6,	             "IPv6" },
225     { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV4,	             "IPv4" },
226     { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV6,	             "IPv6" },
227     { 256*RSVP_OBJ_TIME_VALUES+RSVP_CTYPE_1,	             "1" },
228     { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_1,	             "obsolete" },
229     { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_2,	             "IntServ" },
230     { 256*RSVP_OBJ_SENDER_TSPEC+RSVP_CTYPE_2,	             "IntServ" },
231     { 256*RSVP_OBJ_ADSPEC+RSVP_CTYPE_2,	                     "IntServ" },
232     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV4,	             "IPv4" },
233     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV6,	             "IPv6" },
234     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_3,	             "IPv6 Flow-label" },
235     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_TUNNEL_IPV4,	     "Tunnel IPv4" },
236     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_12,                 "IPv4 P2MP LSP Tunnel" },
237     { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_13,                 "IPv6 P2MP LSP Tunnel" },
238     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4,	             "IPv4" },
239     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6,	             "IPv6" },
240     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4,           "Tunnel IPv4" },
241     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4,              "UNI IPv4" },
242     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_13,                    "IPv4 P2MP LSP Tunnel" },
243     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_14,                    "IPv6 P2MP LSP Tunnel" },
244     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4,          "IPv4" },
245     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6,          "IPv6" },
246     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4,   "Tunnel IPv4" },
247     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_12,            "IPv4 P2MP LSP Tunnel" },
248     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_13,            "IPv6 P2MP LSP Tunnel" },
249     { 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1,                  "1" },
250     { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1,              "Message id ack" },
251     { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_2,              "Message id nack" },
252     { 256*RSVP_OBJ_MESSAGE_ID_LIST+RSVP_CTYPE_1,             "1" },
253     { 256*RSVP_OBJ_STYLE+RSVP_CTYPE_1,                       "1" },
254     { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1,                       "Hello Request" },
255     { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_2,                       "Hello Ack" },
256     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_1,	             "without label range" },
257     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_2,	             "with ATM label range" },
258     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_3,                   "with FR label range" },
259     { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_4,                   "Generalized Label" },
260     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_1,                       "Label" },
261     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_2,                       "Generalized Label" },
262     { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_3,                       "Waveband Switching" },
263     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_1,             "Label" },
264     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_2,             "Generalized Label" },
265     { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_3,             "Waveband Switching" },
266     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_1,              "Label" },
267     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_2,              "Generalized Label" },
268     { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_3,              "Waveband Switching" },
269     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_1,              "Label" },
270     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_2,              "Generalized Label" },
271     { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_3,              "Waveband Switching" },
272     { 256*RSVP_OBJ_ERO+RSVP_CTYPE_IPV4,                      "IPv4" },
273     { 256*RSVP_OBJ_RRO+RSVP_CTYPE_IPV4,                      "IPv4" },
274     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV4,               "IPv4" },
275     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV6,               "IPv6" },
276     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_3,                  "IPv4 plus opt. TLVs" },
277     { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_4,                  "IPv6 plus opt. TLVs" },
278     { 256*RSVP_OBJ_RESTART_CAPABILITY+RSVP_CTYPE_1,          "IPv4" },
279     { 256*RSVP_OBJ_SESSION_ATTRIBUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
280     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4,       "Tunnel IPv4" }, /* old style*/
281     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_1,                 "1" }, /* new style */
282     { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4,            "Tunnel IPv4" },
283     { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1,                  "1" },
284     { 256*RSVP_OBJ_ADMIN_STATUS+RSVP_CTYPE_1,                "1" },
285     { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1,                   "1" },
286     { 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1,               "1" },
287     { 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1,                   "1" },
288     { 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1,             "1" },
289     { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV4,                      "IPv4 sub-LSP" },
290     { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV6,                      "IPv6 sub-LSP" },
291     { 0, NULL}
292 };
293 
294 struct rsvp_obj_integrity_t {
295     uint8_t flags;
296     uint8_t res;
297     uint8_t key_id[6];
298     uint8_t sequence[8];
299     uint8_t digest[16];
300 };
301 
302 static const struct tok rsvp_obj_integrity_flag_values[] = {
303     { 0x80, "Handshake" },
304     { 0, NULL}
305 };
306 
307 struct rsvp_obj_frr_t {
308     uint8_t setup_prio;
309     uint8_t hold_prio;
310     uint8_t hop_limit;
311     uint8_t flags;
312     uint8_t bandwidth[4];
313     uint8_t include_any[4];
314     uint8_t exclude_any[4];
315     uint8_t include_all[4];
316 };
317 
318 
319 #define RSVP_OBJ_XRO_MASK_SUBOBJ(x)   ((x)&0x7f)
320 #define RSVP_OBJ_XRO_MASK_LOOSE(x)    ((x)&0x80)
321 
322 #define	RSVP_OBJ_XRO_RES       0
323 #define	RSVP_OBJ_XRO_IPV4      1
324 #define	RSVP_OBJ_XRO_IPV6      2
325 #define	RSVP_OBJ_XRO_LABEL     3
326 #define	RSVP_OBJ_XRO_ASN       32
327 #define	RSVP_OBJ_XRO_MPLS      64
328 
329 static const struct tok rsvp_obj_xro_values[] = {
330     { RSVP_OBJ_XRO_RES,	      "Reserved" },
331     { RSVP_OBJ_XRO_IPV4,      "IPv4 prefix" },
332     { RSVP_OBJ_XRO_IPV6,      "IPv6 prefix" },
333     { RSVP_OBJ_XRO_LABEL,     "Label" },
334     { RSVP_OBJ_XRO_ASN,       "Autonomous system number" },
335     { RSVP_OBJ_XRO_MPLS,      "MPLS label switched path termination" },
336     { 0, NULL}
337 };
338 
339 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07.txt */
340 static const struct tok rsvp_obj_rro_flag_values[] = {
341     { 0x01,	              "Local protection available" },
342     { 0x02,                   "Local protection in use" },
343     { 0x04,                   "Bandwidth protection" },
344     { 0x08,                   "Node protection" },
345     { 0, NULL}
346 };
347 
348 /* RFC3209 */
349 static const struct tok rsvp_obj_rro_label_flag_values[] = {
350     { 0x01,                   "Global" },
351     { 0, NULL}
352 };
353 
354 static const struct tok rsvp_resstyle_values[] = {
355     { 17,	              "Wildcard Filter" },
356     { 10,                     "Fixed Filter" },
357     { 18,                     "Shared Explicit" },
358     { 0, NULL}
359 };
360 
361 #define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2
362 #define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5
363 
364 static const struct tok rsvp_intserv_service_type_values[] = {
365     { 1,                                "Default/Global Information" },
366     { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" },
367     { RSVP_OBJ_INTSERV_CONTROLLED_LOAD,	"Controlled Load" },
368     { 0, NULL}
369 };
370 
371 static const struct tok rsvp_intserv_parameter_id_values[] = {
372     { 4,                     "IS hop cnt" },
373     { 6,                     "Path b/w estimate" },
374     { 8,                     "Minimum path latency" },
375     { 10,                    "Composed MTU" },
376     { 127,                   "Token Bucket TSpec" },
377     { 130,                   "Guaranteed Service RSpec" },
378     { 133,                   "End-to-end composed value for C" },
379     { 134,                   "End-to-end composed value for D" },
380     { 135,                   "Since-last-reshaping point composed C" },
381     { 136,                   "Since-last-reshaping point composed D" },
382     { 0, NULL}
383 };
384 
385 static const struct tok rsvp_session_attribute_flag_values[] = {
386     { 0x01,	              "Local Protection" },
387     { 0x02,                   "Label Recording" },
388     { 0x04,                   "SE Style" },
389     { 0x08,                   "Bandwidth protection" }, /* RFC4090 */
390     { 0x10,                   "Node protection" },      /* RFC4090 */
391     { 0, NULL}
392 };
393 
394 static const struct tok rsvp_obj_prop_tlv_values[] = {
395     { 0x01,                   "Cos" },
396     { 0x02,                   "Metric 1" },
397     { 0x04,                   "Metric 2" },
398     { 0x08,                   "CCC Status" },
399     { 0x10,                   "Path Type" },
400     { 0, NULL}
401 };
402 
403 #define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24
404 #define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY  25
405 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28
406 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125
407 
408 static const struct tok rsvp_obj_error_code_values[] = {
409     { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
410     { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY,  "Notify Error" },
411     { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },
412     { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD, "Diffserv TE Error (Old)" },
413     { 0, NULL}
414 };
415 
416 static const struct tok rsvp_obj_error_code_routing_values[] = {
417     { 1,                      "Bad EXPLICIT_ROUTE object" },
418     { 2,                      "Bad strict node" },
419     { 3,                      "Bad loose node" },
420     { 4,                      "Bad initial subobject" },
421     { 5,                      "No route available toward destination" },
422     { 6,                      "Unacceptable label value" },
423     { 7,                      "RRO indicated routing loops" },
424     { 8,                      "non-RSVP-capable router in the path" },
425     { 9,                      "MPLS label allocation failure" },
426     { 10,                     "Unsupported L3PID" },
427     { 0, NULL}
428 };
429 
430 static const struct tok rsvp_obj_error_code_diffserv_te_values[] = {
431     { 1,                      "Unexpected CT object" },
432     { 2,                      "Unsupported CT" },
433     { 3,                      "Invalid CT value" },
434     { 4,                      "CT/setup priority do not form a configured TE-Class" },
435     { 5,                      "CT/holding priority do not form a configured TE-Class" },
436     { 6,                      "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
437     { 7,                      "Inconsistency between signaled PSC and signaled CT" },
438     { 8,                      "Inconsistency between signaled PHBs and signaled CT" },
439    { 0, NULL}
440 };
441 
442 /* rfc3473 / rfc 3471 */
443 static const struct tok rsvp_obj_admin_status_flag_values[] = {
444     { 0x80000000, "Reflect" },
445     { 0x00000004, "Testing" },
446     { 0x00000002, "Admin-down" },
447     { 0x00000001, "Delete-in-progress" },
448     { 0, NULL}
449 };
450 
451 /* label set actions - rfc3471 */
452 #define LABEL_SET_INCLUSIVE_LIST  0
453 #define LABEL_SET_EXCLUSIVE_LIST  1
454 #define LABEL_SET_INCLUSIVE_RANGE 2
455 #define LABEL_SET_EXCLUSIVE_RANGE 3
456 
457 static const struct tok rsvp_obj_label_set_action_values[] = {
458     { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" },
459     { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" },
460     { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" },
461     { LABEL_SET_EXCLUSIVE_RANGE, "Exclusive range" },
462     { 0, NULL}
463 };
464 
465 /* OIF RSVP extensions UNI 1.0 Signaling, release 2 */
466 #define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS	    1
467 #define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2
468 #define RSVP_GEN_UNI_SUBOBJ_DIVERSITY		    3
469 #define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL            4
470 #define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL           5
471 
472 static const struct tok rsvp_obj_generalized_uni_values[] = {
473     { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" },
474     { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" },
475     { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" },
476     { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" },
477     { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" },
478     { 0, NULL}
479 };
480 
481 /*
482  * this is a dissector for all the intserv defined
483  * specs as defined per rfc2215
484  * it is called from various rsvp objects;
485  * returns the amount of bytes being processed
486  */
487 static int
488 rsvp_intserv_print(netdissect_options *ndo,
489                    const u_char *tptr, u_short obj_tlen)
490 {
491     int parameter_id,parameter_length;
492     union {
493 	float f;
494 	uint32_t i;
495     } bw;
496 
497     if (obj_tlen < 4)
498         return 0;
499     parameter_id = *(tptr);
500     parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
501 
502     ND_PRINT((ndo, "\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
503            tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
504            parameter_id,
505            parameter_length,
506            *(tptr + 1)));
507 
508     if (obj_tlen < parameter_length+4)
509         return 0;
510     switch(parameter_id) { /* parameter_id */
511 
512     case 4:
513        /*
514         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
515         * |    4 (e)      |    (f)        |           1 (g)               |
516         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
517         * |        IS hop cnt (32-bit unsigned integer)                   |
518         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
519         */
520         if (parameter_length == 4)
521             ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr + 4)));
522         break;
523 
524     case 6:
525        /*
526         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
527         * |    6 (h)      |    (i)        |           1 (j)               |
528         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
529         * |  Path b/w estimate  (32-bit IEEE floating point number)       |
530         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
531         */
532         if (parameter_length == 4) {
533             bw.i = EXTRACT_32BITS(tptr+4);
534             ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
535         }
536         break;
537 
538     case 8:
539        /*
540         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
541         * |     8 (k)     |    (l)        |           1 (m)               |
542         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
543         * |        Minimum path latency (32-bit integer)                  |
544         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
545         */
546         if (parameter_length == 4) {
547             ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
548             if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
549                 ND_PRINT((ndo, "don't care"));
550             else
551                 ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr + 4)));
552         }
553         break;
554 
555     case 10:
556 
557        /*
558         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
559         * |     10 (n)    |      (o)      |           1 (p)               |
560         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
561         * |      Composed MTU (32-bit unsigned integer)                   |
562         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
563         */
564         if (parameter_length == 4)
565             ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr + 4)));
566         break;
567     case 127:
568        /*
569         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
570         * |   127 (e)     |    0 (f)      |             5 (g)             |
571         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
572         * |  Token Bucket Rate [r] (32-bit IEEE floating point number)    |
573         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
574         * |  Token Bucket Size [b] (32-bit IEEE floating point number)    |
575         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
576         * |  Peak Data Rate [p] (32-bit IEEE floating point number)       |
577         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
578         * |  Minimum Policed Unit [m] (32-bit integer)                    |
579         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
580         * |  Maximum Packet Size [M]  (32-bit integer)                    |
581         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
582         */
583 
584         if (parameter_length == 20) {
585             bw.i = EXTRACT_32BITS(tptr+4);
586             ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000));
587             bw.i = EXTRACT_32BITS(tptr+8);
588             ND_PRINT((ndo, "\n\t\tToken Bucket Size: %.10g bytes", bw.f));
589             bw.i = EXTRACT_32BITS(tptr+12);
590             ND_PRINT((ndo, "\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000));
591             ND_PRINT((ndo, "\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr + 16)));
592             ND_PRINT((ndo, "\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr + 20)));
593         }
594         break;
595 
596     case 130:
597        /*
598         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
599         * |     130 (h)   |    0 (i)      |            2 (j)              |
600         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
601         * |  Rate [R]  (32-bit IEEE floating point number)                |
602         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
603         * |  Slack Term [S]  (32-bit integer)                             |
604         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
605         */
606 
607         if (parameter_length == 8) {
608             bw.i = EXTRACT_32BITS(tptr+4);
609             ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
610             ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8)));
611         }
612         break;
613 
614     case 133:
615     case 134:
616     case 135:
617     case 136:
618         if (parameter_length == 4)
619             ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4)));
620         break;
621 
622     default:
623         if (ndo->ndo_vflag <= 1)
624             print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length);
625     }
626     return (parameter_length+4); /* header length 4 bytes */
627 }
628 
629 static int
630 rsvp_obj_print(netdissect_options *ndo,
631                 const u_char *pptr
632 #ifndef HAVE_LIBCRYPTO
633 _U_
634 #endif
635 , u_int plen
636 #ifndef HAVE_LIBCRYPTO
637 _U_
638 #endif
639 , const u_char *tptr,
640                 const char *ident, u_int tlen)
641 {
642     const struct rsvp_object_header *rsvp_obj_header;
643     const u_char *obj_tptr;
644     union {
645         const struct rsvp_obj_integrity_t *rsvp_obj_integrity;
646         const struct rsvp_obj_frr_t *rsvp_obj_frr;
647     } obj_ptr;
648 
649     u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen;
650     int hexdump,processed,padbytes,error_code,error_value,i,sigcheck;
651     union {
652 	float f;
653 	uint32_t i;
654     } bw;
655     uint8_t namelen;
656 
657     u_int action, subchannel;
658 
659     while(tlen>=sizeof(struct rsvp_object_header)) {
660         /* did we capture enough for fully decoding the object header ? */
661         ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header));
662 
663         rsvp_obj_header = (const struct rsvp_object_header *)tptr;
664         rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
665         rsvp_obj_ctype=rsvp_obj_header->ctype;
666 
667         if(rsvp_obj_len % 4) {
668             ND_PRINT((ndo, "%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len));
669             return -1;
670         }
671         if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
672             ND_PRINT((ndo, "%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
673                    (unsigned long)sizeof(const struct rsvp_object_header)));
674             return -1;
675         }
676 
677         ND_PRINT((ndo, "%s%s Object (%u) Flags: [%s",
678                ident,
679                tok2str(rsvp_obj_values,
680                        "Unknown",
681                        rsvp_obj_header->class_num),
682                rsvp_obj_header->class_num,
683                ((rsvp_obj_header->class_num) & 0x80) ? "ignore" : "reject"));
684 
685         if (rsvp_obj_header->class_num > 128)
686             ND_PRINT((ndo, " %s",
687                    ((rsvp_obj_header->class_num) & 0x40) ? "and forward" : "silently"));
688 
689         ND_PRINT((ndo, " if unknown], Class-Type: %s (%u), length: %u",
690                tok2str(rsvp_ctype_values,
691                        "Unknown",
692                        ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
693                rsvp_obj_ctype,
694                rsvp_obj_len));
695 
696         if(tlen < rsvp_obj_len) {
697             ND_PRINT((ndo, "%sERROR: object goes past end of objects TLV", ident));
698             return -1;
699         }
700 
701         obj_tptr=tptr+sizeof(struct rsvp_object_header);
702         obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
703 
704         /* did we capture enough for fully decoding the object ? */
705         if (!ND_TTEST2(*tptr, rsvp_obj_len))
706             return -1;
707         hexdump=FALSE;
708 
709         switch(rsvp_obj_header->class_num) {
710         case RSVP_OBJ_SESSION:
711             switch(rsvp_obj_ctype) {
712             case RSVP_CTYPE_IPV4:
713                 if (obj_tlen < 8)
714                     return -1;
715                 ND_PRINT((ndo, "%s  IPv4 DestAddress: %s, Protocol ID: 0x%02x",
716                        ident,
717                        ipaddr_string(ndo, obj_tptr),
718                        *(obj_tptr + sizeof(struct in_addr))));
719                 ND_PRINT((ndo, "%s  Flags: [0x%02x], DestPort %u",
720                        ident,
721                        *(obj_tptr+5),
722                        EXTRACT_16BITS(obj_tptr + 6)));
723                 obj_tlen-=8;
724                 obj_tptr+=8;
725                 break;
726 #ifdef INET6
727             case RSVP_CTYPE_IPV6:
728                 if (obj_tlen < 20)
729                     return -1;
730                 ND_PRINT((ndo, "%s  IPv6 DestAddress: %s, Protocol ID: 0x%02x",
731                        ident,
732                        ip6addr_string(ndo, obj_tptr),
733                        *(obj_tptr + sizeof(struct in6_addr))));
734                 ND_PRINT((ndo, "%s  Flags: [0x%02x], DestPort %u",
735                        ident,
736                        *(obj_tptr+sizeof(struct in6_addr)+1),
737                        EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2)));
738                 obj_tlen-=20;
739                 obj_tptr+=20;
740                 break;
741 
742             case RSVP_CTYPE_TUNNEL_IPV6:
743                 if (obj_tlen < 36)
744                     return -1;
745                 ND_PRINT((ndo, "%s  IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
746                        ident,
747                        ip6addr_string(ndo, obj_tptr),
748                        EXTRACT_16BITS(obj_tptr+18),
749                        ip6addr_string(ndo, obj_tptr + 20)));
750                 obj_tlen-=36;
751                 obj_tptr+=36;
752                 break;
753 
754             case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
755                 if (obj_tlen < 26)
756                     return -1;
757                 ND_PRINT((ndo, "%s  IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
758                        ident,
759                        EXTRACT_32BITS(obj_tptr),
760                        EXTRACT_16BITS(obj_tptr+6),
761                        ip6addr_string(ndo, obj_tptr + 8)));
762                 obj_tlen-=26;
763                 obj_tptr+=26;
764                 break;
765 #endif
766             case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
767                 if (obj_tlen < 12)
768                     return -1;
769                 ND_PRINT((ndo, "%s  IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
770                        ident,
771                        ipaddr_string(ndo, obj_tptr),
772                        EXTRACT_16BITS(obj_tptr+6),
773                        ipaddr_string(ndo, obj_tptr + 8)));
774                 obj_tlen-=12;
775                 obj_tptr+=12;
776                 break;
777             case RSVP_CTYPE_TUNNEL_IPV4:
778             case RSVP_CTYPE_UNI_IPV4:
779                 if (obj_tlen < 12)
780                     return -1;
781                 ND_PRINT((ndo, "%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
782                        ident,
783                        ipaddr_string(ndo, obj_tptr),
784                        EXTRACT_16BITS(obj_tptr+6),
785                        ipaddr_string(ndo, obj_tptr + 8)));
786                 obj_tlen-=12;
787                 obj_tptr+=12;
788                 break;
789             default:
790                 hexdump=TRUE;
791             }
792             break;
793 
794         case RSVP_OBJ_CONFIRM:
795             switch(rsvp_obj_ctype) {
796             case RSVP_CTYPE_IPV4:
797                 if (obj_tlen < sizeof(struct in_addr))
798                     return -1;
799                 ND_PRINT((ndo, "%s  IPv4 Receiver Address: %s",
800                        ident,
801                        ipaddr_string(ndo, obj_tptr)));
802                 obj_tlen-=sizeof(struct in_addr);
803                 obj_tptr+=sizeof(struct in_addr);
804                 break;
805 #ifdef INET6
806             case RSVP_CTYPE_IPV6:
807                 if (obj_tlen < sizeof(struct in6_addr))
808                     return -1;
809                 ND_PRINT((ndo, "%s  IPv6 Receiver Address: %s",
810                        ident,
811                        ip6addr_string(ndo, obj_tptr)));
812                 obj_tlen-=sizeof(struct in6_addr);
813                 obj_tptr+=sizeof(struct in6_addr);
814                 break;
815 #endif
816             default:
817                 hexdump=TRUE;
818             }
819             break;
820 
821         case RSVP_OBJ_NOTIFY_REQ:
822             switch(rsvp_obj_ctype) {
823             case RSVP_CTYPE_IPV4:
824                 if (obj_tlen < sizeof(struct in_addr))
825                     return -1;
826                 ND_PRINT((ndo, "%s  IPv4 Notify Node Address: %s",
827                        ident,
828                        ipaddr_string(ndo, obj_tptr)));
829                 obj_tlen-=sizeof(struct in_addr);
830                 obj_tptr+=sizeof(struct in_addr);
831                 break;
832 #ifdef INET6
833             case RSVP_CTYPE_IPV6:
834                 if (obj_tlen < sizeof(struct in6_addr))
835                     return-1;
836                 ND_PRINT((ndo, "%s  IPv6 Notify Node Address: %s",
837                        ident,
838                        ip6addr_string(ndo, obj_tptr)));
839                 obj_tlen-=sizeof(struct in6_addr);
840                 obj_tptr+=sizeof(struct in6_addr);
841                 break;
842 #endif
843             default:
844                 hexdump=TRUE;
845             }
846             break;
847 
848         case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */
849         case RSVP_OBJ_UPSTREAM_LABEL:  /* fall through */
850         case RSVP_OBJ_RECOVERY_LABEL:  /* fall through */
851         case RSVP_OBJ_LABEL:
852             switch(rsvp_obj_ctype) {
853             case RSVP_CTYPE_1:
854                 while(obj_tlen >= 4 ) {
855                     ND_PRINT((ndo, "%s  Label: %u", ident, EXTRACT_32BITS(obj_tptr)));
856                     obj_tlen-=4;
857                     obj_tptr+=4;
858                 }
859                 break;
860             case RSVP_CTYPE_2:
861                 if (obj_tlen < 4)
862                     return-1;
863                 ND_PRINT((ndo, "%s  Generalized Label: %u",
864                        ident,
865                        EXTRACT_32BITS(obj_tptr)));
866                 obj_tlen-=4;
867                 obj_tptr+=4;
868                 break;
869             case RSVP_CTYPE_3:
870                 if (obj_tlen < 12)
871                     return-1;
872                 ND_PRINT((ndo, "%s  Waveband ID: %u%s  Start Label: %u, Stop Label: %u",
873                        ident,
874                        EXTRACT_32BITS(obj_tptr),
875                        ident,
876                        EXTRACT_32BITS(obj_tptr+4),
877                        EXTRACT_32BITS(obj_tptr + 8)));
878                 obj_tlen-=12;
879                 obj_tptr+=12;
880                 break;
881             default:
882                 hexdump=TRUE;
883             }
884             break;
885 
886         case RSVP_OBJ_STYLE:
887             switch(rsvp_obj_ctype) {
888             case RSVP_CTYPE_1:
889                 if (obj_tlen < 4)
890                     return-1;
891                 ND_PRINT((ndo, "%s  Reservation Style: %s, Flags: [0x%02x]",
892                        ident,
893                        tok2str(rsvp_resstyle_values,
894                                "Unknown",
895                                EXTRACT_24BITS(obj_tptr+1)),
896                        *(obj_tptr)));
897                 obj_tlen-=4;
898                 obj_tptr+=4;
899                 break;
900             default:
901                 hexdump=TRUE;
902             }
903             break;
904 
905         case RSVP_OBJ_SENDER_TEMPLATE:
906             switch(rsvp_obj_ctype) {
907             case RSVP_CTYPE_IPV4:
908                 if (obj_tlen < 8)
909                     return-1;
910                 ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
911                        ident,
912                        ipaddr_string(ndo, obj_tptr),
913                        EXTRACT_16BITS(obj_tptr + 6)));
914                 obj_tlen-=8;
915                 obj_tptr+=8;
916                 break;
917 #ifdef INET6
918             case RSVP_CTYPE_IPV6:
919                 if (obj_tlen < 20)
920                     return-1;
921                 ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
922                        ident,
923                        ip6addr_string(ndo, obj_tptr),
924                        EXTRACT_16BITS(obj_tptr + 18)));
925                 obj_tlen-=20;
926                 obj_tptr+=20;
927                 break;
928             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
929                 if (obj_tlen < 40)
930                     return-1;
931                 ND_PRINT((ndo, "%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
932                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
933                        ident,
934                        ip6addr_string(ndo, obj_tptr),
935                        EXTRACT_16BITS(obj_tptr+18),
936                        ident,
937                        ip6addr_string(ndo, obj_tptr+20),
938                        EXTRACT_16BITS(obj_tptr + 38)));
939                 obj_tlen-=40;
940                 obj_tptr+=40;
941                 break;
942 #endif
943             case RSVP_CTYPE_TUNNEL_IPV4:
944                 if (obj_tlen < 8)
945                     return-1;
946                 ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
947                        ident,
948                        ipaddr_string(ndo, obj_tptr),
949                        EXTRACT_16BITS(obj_tptr + 6)));
950                 obj_tlen-=8;
951                 obj_tptr+=8;
952                 break;
953             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
954                 if (obj_tlen < 16)
955                     return-1;
956                 ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
957                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
958                        ident,
959                        ipaddr_string(ndo, obj_tptr),
960                        EXTRACT_16BITS(obj_tptr+6),
961                        ident,
962                        ipaddr_string(ndo, obj_tptr+8),
963                        EXTRACT_16BITS(obj_tptr + 12)));
964                 obj_tlen-=16;
965                 obj_tptr+=16;
966                 break;
967             default:
968                 hexdump=TRUE;
969             }
970             break;
971 
972         case RSVP_OBJ_LABEL_REQ:
973             switch(rsvp_obj_ctype) {
974             case RSVP_CTYPE_1:
975                 while(obj_tlen >= 4 ) {
976                     ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
977                            ident,
978                            tok2str(ethertype_values,
979                                    "Unknown Protocol (0x%04x)",
980                                    EXTRACT_16BITS(obj_tptr + 2))));
981                     obj_tlen-=4;
982                     obj_tptr+=4;
983                 }
984                 break;
985             case RSVP_CTYPE_2:
986                 if (obj_tlen < 12)
987                     return-1;
988                 ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
989                        ident,
990                        tok2str(ethertype_values,
991                                "Unknown Protocol (0x%04x)",
992                                EXTRACT_16BITS(obj_tptr + 2))));
993                 ND_PRINT((ndo, ",%s merge capability",((*(obj_tptr + 4)) & 0x80) ? "no" : "" ));
994                 ND_PRINT((ndo, "%s  Minimum VPI/VCI: %u/%u",
995                        ident,
996                        (EXTRACT_16BITS(obj_tptr+4))&0xfff,
997                        (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff));
998                 ND_PRINT((ndo, "%s  Maximum VPI/VCI: %u/%u",
999                        ident,
1000                        (EXTRACT_16BITS(obj_tptr+8))&0xfff,
1001                        (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff));
1002                 obj_tlen-=12;
1003                 obj_tptr+=12;
1004                 break;
1005             case RSVP_CTYPE_3:
1006                 if (obj_tlen < 12)
1007                     return-1;
1008                 ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
1009                        ident,
1010                        tok2str(ethertype_values,
1011                                "Unknown Protocol (0x%04x)",
1012                                EXTRACT_16BITS(obj_tptr + 2))));
1013                 ND_PRINT((ndo, "%s  Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
1014                        ident,
1015                        (EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
1016                        (EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
1017                        (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
1018                        (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : ""));
1019                 obj_tlen-=12;
1020                 obj_tptr+=12;
1021                 break;
1022             case RSVP_CTYPE_4:
1023                 if (obj_tlen < 4)
1024                     return-1;
1025                 ND_PRINT((ndo, "%s  LSP Encoding Type: %s (%u)",
1026                        ident,
1027                        tok2str(gmpls_encoding_values,
1028                                "Unknown",
1029                                *obj_tptr),
1030 		       *obj_tptr));
1031                 ND_PRINT((ndo, "%s  Switching Type: %s (%u), Payload ID: %s (0x%04x)",
1032                        ident,
1033                        tok2str(gmpls_switch_cap_values,
1034                                "Unknown",
1035                                *(obj_tptr+1)),
1036 		       *(obj_tptr+1),
1037                        tok2str(gmpls_payload_values,
1038                                "Unknown",
1039                                EXTRACT_16BITS(obj_tptr+2)),
1040 		       EXTRACT_16BITS(obj_tptr + 2)));
1041                 obj_tlen-=4;
1042                 obj_tptr+=4;
1043                 break;
1044             default:
1045                 hexdump=TRUE;
1046             }
1047             break;
1048 
1049         case RSVP_OBJ_RRO:
1050         case RSVP_OBJ_ERO:
1051             switch(rsvp_obj_ctype) {
1052             case RSVP_CTYPE_IPV4:
1053                 while(obj_tlen >= 4 ) {
1054                     ND_PRINT((ndo, "%s  Subobject Type: %s, length %u",
1055                            ident,
1056                            tok2str(rsvp_obj_xro_values,
1057                                    "Unknown %u",
1058                                    RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
1059                            *(obj_tptr + 1)));
1060 
1061                     if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
1062                         ND_PRINT((ndo, "%s  ERROR: zero length ERO subtype", ident));
1063                         break;
1064                     }
1065 
1066                     switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
1067                     case RSVP_OBJ_XRO_IPV4:
1068                         ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]",
1069                                RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
1070                                ipaddr_string(ndo, obj_tptr+2),
1071                                *(obj_tptr+6),
1072                                bittok2str(rsvp_obj_rro_flag_values,
1073                                    "none",
1074                                    *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
1075                     break;
1076                     case RSVP_OBJ_XRO_LABEL:
1077                         ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
1078                                bittok2str(rsvp_obj_rro_label_flag_values,
1079                                    "none",
1080                                    *(obj_tptr+2)),
1081                                *(obj_tptr+2),
1082                                tok2str(rsvp_ctype_values,
1083                                        "Unknown",
1084                                        *(obj_tptr+3) + 256*RSVP_OBJ_RRO),
1085                                *(obj_tptr+3),
1086                                EXTRACT_32BITS(obj_tptr + 4)));
1087                     }
1088                     obj_tlen-=*(obj_tptr+1);
1089                     obj_tptr+=*(obj_tptr+1);
1090                 }
1091                 break;
1092             default:
1093                 hexdump=TRUE;
1094             }
1095             break;
1096 
1097         case RSVP_OBJ_HELLO:
1098             switch(rsvp_obj_ctype) {
1099             case RSVP_CTYPE_1:
1100             case RSVP_CTYPE_2:
1101                 if (obj_tlen < 8)
1102                     return-1;
1103                 ND_PRINT((ndo, "%s  Source Instance: 0x%08x, Destination Instance: 0x%08x",
1104                        ident,
1105                        EXTRACT_32BITS(obj_tptr),
1106                        EXTRACT_32BITS(obj_tptr + 4)));
1107                 obj_tlen-=8;
1108                 obj_tptr+=8;
1109                 break;
1110             default:
1111                 hexdump=TRUE;
1112             }
1113             break;
1114 
1115         case RSVP_OBJ_RESTART_CAPABILITY:
1116             switch(rsvp_obj_ctype) {
1117             case RSVP_CTYPE_1:
1118                 if (obj_tlen < 8)
1119                     return-1;
1120                 ND_PRINT((ndo, "%s  Restart  Time: %ums, Recovery Time: %ums",
1121                        ident,
1122                        EXTRACT_32BITS(obj_tptr),
1123                        EXTRACT_32BITS(obj_tptr + 4)));
1124                 obj_tlen-=8;
1125                 obj_tptr+=8;
1126                 break;
1127             default:
1128                 hexdump=TRUE;
1129             }
1130             break;
1131 
1132         case RSVP_OBJ_SESSION_ATTRIBUTE:
1133             switch(rsvp_obj_ctype) {
1134             case RSVP_CTYPE_TUNNEL_IPV4:
1135                 if (obj_tlen < 4)
1136                     return-1;
1137                 namelen = *(obj_tptr+3);
1138                 if (obj_tlen < 4+namelen)
1139                     return-1;
1140                 ND_PRINT((ndo, "%s  Session Name: ", ident));
1141                 for (i = 0; i < namelen; i++)
1142                     safeputchar(ndo, *(obj_tptr + 4 + i));
1143                 ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
1144                        ident,
1145                        (int)*obj_tptr,
1146                        (int)*(obj_tptr+1),
1147                        bittok2str(rsvp_session_attribute_flag_values,
1148                                   "none",
1149                                   *(obj_tptr+2)),
1150                        *(obj_tptr + 2)));
1151                 obj_tlen-=4+*(obj_tptr+3);
1152                 obj_tptr+=4+*(obj_tptr+3);
1153                 break;
1154             default:
1155                 hexdump=TRUE;
1156             }
1157             break;
1158 
1159 	case RSVP_OBJ_GENERALIZED_UNI:
1160             switch(rsvp_obj_ctype) {
1161 		int subobj_type,af,subobj_len,total_subobj_len;
1162 
1163             case RSVP_CTYPE_1:
1164 
1165                 if (obj_tlen < 4)
1166                     return-1;
1167 
1168 		/* read variable length subobjects */
1169 		total_subobj_len = obj_tlen;
1170                 while(total_subobj_len > 0) {
1171                     subobj_len  = EXTRACT_16BITS(obj_tptr);
1172                     subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
1173                     af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
1174 
1175                     ND_PRINT((ndo, "%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
1176                            ident,
1177                            tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
1178                            subobj_type,
1179                            tok2str(af_values, "Unknown", af), af,
1180                            subobj_len));
1181 
1182                     switch(subobj_type) {
1183                     case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
1184                     case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS:
1185 
1186                         switch(af) {
1187                         case AFNUM_INET:
1188                             if (subobj_len < 8)
1189                                 return -1;
1190                             ND_PRINT((ndo, "%s    UNI IPv4 TNA address: %s",
1191                                    ident, ipaddr_string(ndo, obj_tptr + 4)));
1192                             break;
1193 #ifdef INET6
1194                         case AFNUM_INET6:
1195                             if (subobj_len < 20)
1196                                 return -1;
1197                             ND_PRINT((ndo, "%s    UNI IPv6 TNA address: %s",
1198                                    ident, ip6addr_string(ndo, obj_tptr + 4)));
1199                             break;
1200 #endif
1201                         case AFNUM_NSAP:
1202                             if (subobj_len) {
1203                                 /* unless we have a TLV parser lets just hexdump */
1204                                 hexdump=TRUE;
1205                             }
1206                             break;
1207                         }
1208                         break;
1209 
1210                     case RSVP_GEN_UNI_SUBOBJ_DIVERSITY:
1211                         if (subobj_len) {
1212                             /* unless we have a TLV parser lets just hexdump */
1213                             hexdump=TRUE;
1214                         }
1215                         break;
1216 
1217                     case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL:
1218                         if (subobj_len < 16) {
1219                             return -1;
1220                         }
1221 
1222                         ND_PRINT((ndo, "%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
1223                                ident,
1224                                ((EXTRACT_32BITS(obj_tptr+4))>>31),
1225                                ((EXTRACT_32BITS(obj_tptr+4))&0xFF),
1226                                EXTRACT_32BITS(obj_tptr+8),
1227                                EXTRACT_32BITS(obj_tptr + 12)));
1228                         break;
1229 
1230                     case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
1231                         if (subobj_len < 8) {
1232                             return -1;
1233                         }
1234 
1235                         ND_PRINT((ndo, "%s    Service level: %u",
1236                                ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24));
1237                         break;
1238 
1239                     default:
1240                         hexdump=TRUE;
1241                         break;
1242                     }
1243                     total_subobj_len-=subobj_len;
1244                     obj_tptr+=subobj_len;
1245                     obj_tlen+=subobj_len;
1246 		}
1247 
1248                 if (total_subobj_len) {
1249                     /* unless we have a TLV parser lets just hexdump */
1250                     hexdump=TRUE;
1251                 }
1252                 break;
1253 
1254             default:
1255                 hexdump=TRUE;
1256             }
1257             break;
1258 
1259         case RSVP_OBJ_RSVP_HOP:
1260             switch(rsvp_obj_ctype) {
1261             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
1262             case RSVP_CTYPE_IPV4:
1263                 if (obj_tlen < 8)
1264                     return-1;
1265                 ND_PRINT((ndo, "%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
1266                        ident,
1267                        ipaddr_string(ndo, obj_tptr),
1268                        EXTRACT_32BITS(obj_tptr + 4)));
1269                 obj_tlen-=8;
1270                 obj_tptr+=8;
1271                 if (obj_tlen)
1272                     hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
1273                 break;
1274 #ifdef INET6
1275             case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
1276             case RSVP_CTYPE_IPV6:
1277                 if (obj_tlen < 20)
1278                     return-1;
1279                 ND_PRINT((ndo, "%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
1280                        ident,
1281                        ip6addr_string(ndo, obj_tptr),
1282                        EXTRACT_32BITS(obj_tptr + 16)));
1283                 obj_tlen-=20;
1284                 obj_tptr+=20;
1285                 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
1286                 break;
1287 #endif
1288             default:
1289                 hexdump=TRUE;
1290             }
1291             break;
1292 
1293         case RSVP_OBJ_TIME_VALUES:
1294             switch(rsvp_obj_ctype) {
1295             case RSVP_CTYPE_1:
1296                 if (obj_tlen < 4)
1297                     return-1;
1298                 ND_PRINT((ndo, "%s  Refresh Period: %ums",
1299                        ident,
1300                        EXTRACT_32BITS(obj_tptr)));
1301                 obj_tlen-=4;
1302                 obj_tptr+=4;
1303                 break;
1304             default:
1305                 hexdump=TRUE;
1306             }
1307             break;
1308 
1309         /* those three objects do share the same semantics */
1310         case RSVP_OBJ_SENDER_TSPEC:
1311         case RSVP_OBJ_ADSPEC:
1312         case RSVP_OBJ_FLOWSPEC:
1313             switch(rsvp_obj_ctype) {
1314             case RSVP_CTYPE_2:
1315                 if (obj_tlen < 4)
1316                     return-1;
1317                 ND_PRINT((ndo, "%s  Msg-Version: %u, length: %u",
1318                        ident,
1319                        (*obj_tptr & 0xf0) >> 4,
1320                        EXTRACT_16BITS(obj_tptr + 2) << 2));
1321                 obj_tptr+=4; /* get to the start of the service header */
1322                 obj_tlen-=4;
1323 
1324                 while (obj_tlen >= 4) {
1325                     intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
1326                     ND_PRINT((ndo, "%s  Service Type: %s (%u), break bit %s set, Service length: %u",
1327                            ident,
1328                            tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
1329                            *(obj_tptr),
1330                            (*(obj_tptr+1)&0x80) ? "" : "not",
1331                            intserv_serv_tlen));
1332 
1333                     obj_tptr+=4; /* get to the start of the parameter list */
1334                     obj_tlen-=4;
1335 
1336                     while (intserv_serv_tlen>=4) {
1337                         processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen);
1338                         if (processed == 0)
1339                             break;
1340                         obj_tlen-=processed;
1341                         intserv_serv_tlen-=processed;
1342                         obj_tptr+=processed;
1343                     }
1344                 }
1345                 break;
1346             default:
1347                 hexdump=TRUE;
1348             }
1349             break;
1350 
1351         case RSVP_OBJ_FILTERSPEC:
1352             switch(rsvp_obj_ctype) {
1353             case RSVP_CTYPE_IPV4:
1354                 if (obj_tlen < 8)
1355                     return-1;
1356                 ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
1357                        ident,
1358                        ipaddr_string(ndo, obj_tptr),
1359                        EXTRACT_16BITS(obj_tptr + 6)));
1360                 obj_tlen-=8;
1361                 obj_tptr+=8;
1362                 break;
1363 #ifdef INET6
1364             case RSVP_CTYPE_IPV6:
1365                 if (obj_tlen < 20)
1366                     return-1;
1367                 ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
1368                        ident,
1369                        ip6addr_string(ndo, obj_tptr),
1370                        EXTRACT_16BITS(obj_tptr + 18)));
1371                 obj_tlen-=20;
1372                 obj_tptr+=20;
1373                 break;
1374             case RSVP_CTYPE_3:
1375                 if (obj_tlen < 20)
1376                     return-1;
1377                 ND_PRINT((ndo, "%s  Source Address: %s, Flow Label: %u",
1378                        ident,
1379                        ip6addr_string(ndo, obj_tptr),
1380                        EXTRACT_24BITS(obj_tptr + 17)));
1381                 obj_tlen-=20;
1382                 obj_tptr+=20;
1383                 break;
1384             case RSVP_CTYPE_TUNNEL_IPV6:
1385                 if (obj_tlen < 20)
1386                     return-1;
1387                 ND_PRINT((ndo, "%s  Source Address: %s, LSP-ID: 0x%04x",
1388                        ident,
1389                        ipaddr_string(ndo, obj_tptr),
1390                        EXTRACT_16BITS(obj_tptr + 18)));
1391                 obj_tlen-=20;
1392                 obj_tptr+=20;
1393                 break;
1394             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
1395                 if (obj_tlen < 40)
1396                     return-1;
1397                 ND_PRINT((ndo, "%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
1398                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
1399                        ident,
1400                        ip6addr_string(ndo, obj_tptr),
1401                        EXTRACT_16BITS(obj_tptr+18),
1402                        ident,
1403                        ip6addr_string(ndo, obj_tptr+20),
1404                        EXTRACT_16BITS(obj_tptr + 38)));
1405                 obj_tlen-=40;
1406                 obj_tptr+=40;
1407                 break;
1408 #endif
1409             case RSVP_CTYPE_TUNNEL_IPV4:
1410                 if (obj_tlen < 8)
1411                     return-1;
1412                 ND_PRINT((ndo, "%s  Source Address: %s, LSP-ID: 0x%04x",
1413                        ident,
1414                        ipaddr_string(ndo, obj_tptr),
1415                        EXTRACT_16BITS(obj_tptr + 6)));
1416                 obj_tlen-=8;
1417                 obj_tptr+=8;
1418                 break;
1419             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
1420                 if (obj_tlen < 16)
1421                     return-1;
1422                 ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
1423                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
1424                        ident,
1425                        ipaddr_string(ndo, obj_tptr),
1426                        EXTRACT_16BITS(obj_tptr+6),
1427                        ident,
1428                        ipaddr_string(ndo, obj_tptr+8),
1429                        EXTRACT_16BITS(obj_tptr + 12)));
1430                 obj_tlen-=16;
1431                 obj_tptr+=16;
1432                 break;
1433             default:
1434                 hexdump=TRUE;
1435             }
1436             break;
1437 
1438         case RSVP_OBJ_FASTREROUTE:
1439             /* the differences between c-type 1 and 7 are minor */
1440             obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr;
1441             bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth);
1442 
1443             switch(rsvp_obj_ctype) {
1444             case RSVP_CTYPE_1: /* new style */
1445                 if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
1446                     return-1;
1447                 ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
1448                        ident,
1449                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
1450                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
1451                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
1452                         bw.f * 8 / 1000000));
1453                 ND_PRINT((ndo, "%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
1454                        ident,
1455                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
1456                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any),
1457                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all)));
1458                 obj_tlen-=sizeof(struct rsvp_obj_frr_t);
1459                 obj_tptr+=sizeof(struct rsvp_obj_frr_t);
1460                 break;
1461 
1462             case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
1463                 if (obj_tlen < 16)
1464                     return-1;
1465                 ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
1466                        ident,
1467                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
1468                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
1469                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
1470                         bw.f * 8 / 1000000));
1471                 ND_PRINT((ndo, "%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
1472                        ident,
1473                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
1474                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any)));
1475                 obj_tlen-=16;
1476                 obj_tptr+=16;
1477                 break;
1478 
1479             default:
1480                 hexdump=TRUE;
1481             }
1482             break;
1483 
1484         case RSVP_OBJ_DETOUR:
1485             switch(rsvp_obj_ctype) {
1486             case RSVP_CTYPE_TUNNEL_IPV4:
1487                 while(obj_tlen >= 8) {
1488                     ND_PRINT((ndo, "%s  PLR-ID: %s, Avoid-Node-ID: %s",
1489                            ident,
1490                            ipaddr_string(ndo, obj_tptr),
1491                            ipaddr_string(ndo, obj_tptr + 4)));
1492                     obj_tlen-=8;
1493                     obj_tptr+=8;
1494                 }
1495                 break;
1496             default:
1497                 hexdump=TRUE;
1498             }
1499             break;
1500 
1501         case RSVP_OBJ_CLASSTYPE:
1502         case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
1503             switch(rsvp_obj_ctype) {
1504             case RSVP_CTYPE_1:
1505                 ND_PRINT((ndo, "%s  CT: %u",
1506                        ident,
1507                        EXTRACT_32BITS(obj_tptr) & 0x7));
1508                 obj_tlen-=4;
1509                 obj_tptr+=4;
1510                 break;
1511             default:
1512                 hexdump=TRUE;
1513             }
1514             break;
1515 
1516         case RSVP_OBJ_ERROR_SPEC:
1517             switch(rsvp_obj_ctype) {
1518             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
1519             case RSVP_CTYPE_IPV4:
1520                 if (obj_tlen < 8)
1521                     return-1;
1522                 error_code=*(obj_tptr+5);
1523                 error_value=EXTRACT_16BITS(obj_tptr+6);
1524                 ND_PRINT((ndo, "%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
1525                        ident,
1526                        ipaddr_string(ndo, obj_tptr),
1527                        *(obj_tptr+4),
1528                        ident,
1529                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1530                        error_code));
1531                 switch (error_code) {
1532                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1533                     ND_PRINT((ndo, ", Error Value: %s (%u)",
1534                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1535                            error_value));
1536                     break;
1537                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */
1538                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD:
1539                     ND_PRINT((ndo, ", Error Value: %s (%u)",
1540                            tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
1541                            error_value));
1542                     break;
1543                 default:
1544                     ND_PRINT((ndo, ", Unknown Error Value (%u)", error_value));
1545                     break;
1546                 }
1547                 obj_tlen-=8;
1548                 obj_tptr+=8;
1549                 break;
1550 #ifdef INET6
1551             case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
1552             case RSVP_CTYPE_IPV6:
1553                 if (obj_tlen < 20)
1554                     return-1;
1555                 error_code=*(obj_tptr+17);
1556                 error_value=EXTRACT_16BITS(obj_tptr+18);
1557                 ND_PRINT((ndo, "%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
1558                        ident,
1559                        ip6addr_string(ndo, obj_tptr),
1560                        *(obj_tptr+16),
1561                        ident,
1562                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1563                        error_code));
1564 
1565                 switch (error_code) {
1566                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1567                     ND_PRINT((ndo, ", Error Value: %s (%u)",
1568                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1569 			   error_value));
1570                     break;
1571                 default:
1572                     break;
1573                 }
1574                 obj_tlen-=20;
1575                 obj_tptr+=20;
1576                 break;
1577 #endif
1578             default:
1579                 hexdump=TRUE;
1580             }
1581             break;
1582 
1583         case RSVP_OBJ_PROPERTIES:
1584             switch(rsvp_obj_ctype) {
1585             case RSVP_CTYPE_1:
1586                 if (obj_tlen < 4)
1587                     return-1;
1588                 padbytes = EXTRACT_16BITS(obj_tptr+2);
1589                 ND_PRINT((ndo, "%s  TLV count: %u, padding bytes: %u",
1590                        ident,
1591                        EXTRACT_16BITS(obj_tptr),
1592                        padbytes));
1593                 obj_tlen-=4;
1594                 obj_tptr+=4;
1595                 /* loop through as long there is anything longer than the TLV header (2) */
1596                 while(obj_tlen >= 2 + padbytes) {
1597                     ND_PRINT((ndo, "%s    %s TLV (0x%02x), length: %u", /* length includes header */
1598                            ident,
1599                            tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
1600                            *obj_tptr,
1601                            *(obj_tptr + 1)));
1602                     if (obj_tlen < *(obj_tptr+1))
1603                         return-1;
1604                     if (*(obj_tptr+1) < 2)
1605                         return -1;
1606                     print_unknown_data(ndo, obj_tptr + 2, "\n\t\t", *(obj_tptr + 1) - 2);
1607                     obj_tlen-=*(obj_tptr+1);
1608                     obj_tptr+=*(obj_tptr+1);
1609                 }
1610                 break;
1611             default:
1612                 hexdump=TRUE;
1613             }
1614             break;
1615 
1616         case RSVP_OBJ_MESSAGE_ID:     /* fall through */
1617         case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */
1618         case RSVP_OBJ_MESSAGE_ID_LIST:
1619             switch(rsvp_obj_ctype) {
1620             case RSVP_CTYPE_1:
1621             case RSVP_CTYPE_2:
1622                 if (obj_tlen < 8)
1623                     return-1;
1624                 ND_PRINT((ndo, "%s  Flags [0x%02x], epoch: %u",
1625                        ident,
1626                        *obj_tptr,
1627                        EXTRACT_24BITS(obj_tptr + 1)));
1628                 obj_tlen-=4;
1629                 obj_tptr+=4;
1630                 /* loop through as long there are no messages left */
1631                 while(obj_tlen >= 4) {
1632                     ND_PRINT((ndo, "%s    Message-ID 0x%08x (%u)",
1633                            ident,
1634                            EXTRACT_32BITS(obj_tptr),
1635                            EXTRACT_32BITS(obj_tptr)));
1636                     obj_tlen-=4;
1637                     obj_tptr+=4;
1638                 }
1639                 break;
1640             default:
1641                 hexdump=TRUE;
1642             }
1643             break;
1644 
1645         case RSVP_OBJ_INTEGRITY:
1646             switch(rsvp_obj_ctype) {
1647             case RSVP_CTYPE_1:
1648                 if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
1649                     return-1;
1650                 obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
1651                 ND_PRINT((ndo, "%s  Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
1652                        ident,
1653                        EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id),
1654                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2),
1655                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence),
1656                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4),
1657                        bittok2str(rsvp_obj_integrity_flag_values,
1658                                   "none",
1659                                   obj_ptr.rsvp_obj_integrity->flags)));
1660                 ND_PRINT((ndo, "%s  MD5-sum 0x%08x%08x%08x%08x ",
1661                        ident,
1662                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
1663                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
1664                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
1665                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
1666 
1667 #ifdef HAVE_LIBCRYPTO
1668                 sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\
1669                                              rsvp_obj_integrity->digest);
1670 #else
1671                 sigcheck = CANT_CHECK_SIGNATURE;
1672 #endif
1673                 ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
1674 
1675                 obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
1676                 obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
1677                 break;
1678             default:
1679                 hexdump=TRUE;
1680             }
1681             break;
1682 
1683         case RSVP_OBJ_ADMIN_STATUS:
1684             switch(rsvp_obj_ctype) {
1685             case RSVP_CTYPE_1:
1686                 if (obj_tlen < 4)
1687                     return-1;
1688                 ND_PRINT((ndo, "%s  Flags [%s]", ident,
1689                        bittok2str(rsvp_obj_admin_status_flag_values, "none",
1690                                   EXTRACT_32BITS(obj_tptr))));
1691                 obj_tlen-=4;
1692                 obj_tptr+=4;
1693                 break;
1694             default:
1695                 hexdump=TRUE;
1696             }
1697             break;
1698 
1699         case RSVP_OBJ_LABEL_SET:
1700             switch(rsvp_obj_ctype) {
1701             case RSVP_CTYPE_1:
1702                 if (obj_tlen < 4)
1703                     return-1;
1704                 action = (EXTRACT_16BITS(obj_tptr)>>8);
1705 
1706                 ND_PRINT((ndo, "%s  Action: %s (%u), Label type: %u", ident,
1707                        tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
1708                        action, ((EXTRACT_32BITS(obj_tptr) & 0x7F))));
1709 
1710                 switch (action) {
1711                 case LABEL_SET_INCLUSIVE_RANGE:
1712                 case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */
1713 
1714 		    /* only a couple of subchannels are expected */
1715 		    if (obj_tlen < 12)
1716 			return -1;
1717 		    ND_PRINT((ndo, "%s  Start range: %u, End range: %u", ident,
1718                            EXTRACT_32BITS(obj_tptr+4),
1719                            EXTRACT_32BITS(obj_tptr + 8)));
1720 		    obj_tlen-=12;
1721 		    obj_tptr+=12;
1722                     break;
1723 
1724                 default:
1725                     obj_tlen-=4;
1726                     obj_tptr+=4;
1727                     subchannel = 1;
1728                     while(obj_tlen >= 4 ) {
1729                         ND_PRINT((ndo, "%s  Subchannel #%u: %u", ident, subchannel,
1730                                EXTRACT_32BITS(obj_tptr)));
1731                         obj_tptr+=4;
1732                         obj_tlen-=4;
1733                         subchannel++;
1734                     }
1735                     break;
1736                 }
1737                 break;
1738             default:
1739                 hexdump=TRUE;
1740             }
1741 
1742         case RSVP_OBJ_S2L:
1743             switch (rsvp_obj_ctype) {
1744             case RSVP_CTYPE_IPV4:
1745                 if (obj_tlen < 4)
1746                     return-1;
1747                 ND_PRINT((ndo, "%s  Sub-LSP destination address: %s",
1748                        ident, ipaddr_string(ndo, obj_tptr)));
1749 
1750                 obj_tlen-=4;
1751                 obj_tptr+=4;
1752                 break;
1753 #ifdef INET6
1754             case RSVP_CTYPE_IPV6:
1755                 if (obj_tlen < 16)
1756                     return-1;
1757                 ND_PRINT((ndo, "%s  Sub-LSP destination address: %s",
1758                        ident, ip6addr_string(ndo, obj_tptr)));
1759 
1760                 obj_tlen-=16;
1761                 obj_tptr+=16;
1762                 break;
1763 #endif
1764             default:
1765                 hexdump=TRUE;
1766             }
1767 
1768         /*
1769          *  FIXME those are the defined objects that lack a decoder
1770          *  you are welcome to contribute code ;-)
1771          */
1772 
1773         case RSVP_OBJ_SCOPE:
1774         case RSVP_OBJ_POLICY_DATA:
1775         case RSVP_OBJ_ACCEPT_LABEL_SET:
1776         case RSVP_OBJ_PROTECTION:
1777         default:
1778             if (ndo->ndo_vflag <= 1)
1779                 print_unknown_data(ndo, obj_tptr, "\n\t    ", obj_tlen); /* FIXME indentation */
1780             break;
1781         }
1782         /* do we also want to see a hex dump ? */
1783         if (ndo->ndo_vflag > 1 || hexdump == TRUE)
1784             print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t    ", /* FIXME indentation */
1785                                rsvp_obj_len - sizeof(struct rsvp_object_header));
1786 
1787         tptr+=rsvp_obj_len;
1788         tlen-=rsvp_obj_len;
1789     }
1790     return 0;
1791 trunc:
1792     ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
1793     return -1;
1794 }
1795 
1796 void
1797 rsvp_print(netdissect_options *ndo,
1798            register const u_char *pptr, register u_int len)
1799 {
1800     struct rsvp_common_header *rsvp_com_header;
1801     const u_char *tptr,*subtptr;
1802     u_short plen, tlen, subtlen;
1803 
1804     tptr=pptr;
1805 
1806     rsvp_com_header = (struct rsvp_common_header *)pptr;
1807     ND_TCHECK(*rsvp_com_header);
1808 
1809     /*
1810      * Sanity checking of the header.
1811      */
1812     if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1813 	ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
1814                RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
1815 	return;
1816     }
1817 
1818     /* in non-verbose mode just lets print the basic Message Type*/
1819     if (ndo->ndo_vflag < 1) {
1820         ND_PRINT((ndo, "RSVPv%u %s Message, length: %u",
1821                RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1822                tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
1823                len));
1824         return;
1825     }
1826 
1827     /* ok they seem to want to know everything - lets fully decode it */
1828 
1829     plen = tlen = EXTRACT_16BITS(rsvp_com_header->length);
1830 
1831     ND_PRINT((ndo, "\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1832            RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1833            tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1834            rsvp_com_header->msg_type,
1835            bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1836            tlen,
1837            rsvp_com_header->ttl,
1838            EXTRACT_16BITS(rsvp_com_header->checksum)));
1839 
1840     /*
1841      * Clear checksum prior to signature verification.
1842      */
1843     rsvp_com_header->checksum[0] = 0;
1844     rsvp_com_header->checksum[1] = 0;
1845 
1846     if (tlen < sizeof(const struct rsvp_common_header)) {
1847         ND_PRINT((ndo, "ERROR: common header too short %u < %lu", tlen,
1848                (unsigned long)sizeof(const struct rsvp_common_header)));
1849         return;
1850     }
1851 
1852     tptr+=sizeof(const struct rsvp_common_header);
1853     tlen-=sizeof(const struct rsvp_common_header);
1854 
1855     switch(rsvp_com_header->msg_type) {
1856 
1857     case RSVP_MSGTYPE_AGGREGATE:
1858         while(tlen > 0) {
1859             subtptr=tptr;
1860             rsvp_com_header = (struct rsvp_common_header *)subtptr;
1861             ND_TCHECK(*rsvp_com_header);
1862 
1863             /*
1864              * Sanity checking of the header.
1865              */
1866             if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1867                 ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
1868                        RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
1869                 return;
1870             }
1871             subtlen=EXTRACT_16BITS(rsvp_com_header->length);
1872 
1873             ND_PRINT((ndo, "\n\t  RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1874                    RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1875                    tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1876                    rsvp_com_header->msg_type,
1877                    bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1878                    subtlen,
1879                    rsvp_com_header->ttl,
1880                    EXTRACT_16BITS(rsvp_com_header->checksum)));
1881 
1882             /*
1883              * Clear checksum prior to signature verification.
1884              */
1885             rsvp_com_header->checksum[0] = 0;
1886             rsvp_com_header->checksum[1] = 0;
1887 
1888             if (subtlen < sizeof(const struct rsvp_common_header)) {
1889                 ND_PRINT((ndo, "ERROR: common header too short %u < %lu", subtlen,
1890                        (unsigned long)sizeof(const struct rsvp_common_header)));
1891                 return;
1892             }
1893 
1894             if (tlen < subtlen) {
1895                 ND_PRINT((ndo, "ERROR: common header too large %u > %u", subtlen,
1896                        tlen));
1897                 return;
1898             }
1899 
1900             subtptr+=sizeof(const struct rsvp_common_header);
1901             subtlen-=sizeof(const struct rsvp_common_header);
1902 
1903             if (rsvp_obj_print(ndo, pptr, plen, subtptr, "\n\t    ", subtlen) == -1)
1904                 return;
1905 
1906             tptr+=subtlen+sizeof(const struct rsvp_common_header);
1907             tlen-=subtlen+sizeof(const struct rsvp_common_header);
1908         }
1909 
1910         break;
1911 
1912     case RSVP_MSGTYPE_PATH:
1913     case RSVP_MSGTYPE_RESV:
1914     case RSVP_MSGTYPE_PATHERR:
1915     case RSVP_MSGTYPE_RESVERR:
1916     case RSVP_MSGTYPE_PATHTEAR:
1917     case RSVP_MSGTYPE_RESVTEAR:
1918     case RSVP_MSGTYPE_RESVCONF:
1919     case RSVP_MSGTYPE_HELLO_OLD:
1920     case RSVP_MSGTYPE_HELLO:
1921     case RSVP_MSGTYPE_ACK:
1922     case RSVP_MSGTYPE_SREFRESH:
1923         if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t  ", tlen) == -1)
1924             return;
1925         break;
1926 
1927     default:
1928         print_unknown_data(ndo, tptr, "\n\t    ", tlen);
1929         break;
1930     }
1931 
1932     return;
1933 trunc:
1934     ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
1935 }
1936