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