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