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