]> The Tcpdump Group git mirrors - tcpdump/blob - print-rsvp.c
Fix up some compiler warnings on platforms where "sizeof" generates an
[tcpdump] / print-rsvp.c
1 /*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
12 *
13 * Original code by Hannes Gredler (hannes@juniper.net)
14 */
15
16 #ifndef lint
17 static const char rcsid[] _U_ =
18 "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.29 2004-07-21 21:43:26 guy Exp $";
19 #endif
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <tcpdump-stdinc.h>
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "interface.h"
32 #include "extract.h"
33 #include "addrtoname.h"
34 #include "ethertype.h"
35 #include "gmpls.h"
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 u_int8_t version_flags;
51 u_int8_t msg_type;
52 u_int8_t checksum[2];
53 u_int8_t ttl;
54 u_int8_t reserved;
55 u_int8_t length[2];
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 u_int8_t length[2];
74 u_int8_t class_num;
75 u_int8_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_AGGREGATE 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_AGGREGATE, "Aggregate" },
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
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
136 #define RSVP_OBJ_MESSAGE_ID_ACK 24
137 #define RSVP_OBJ_MESSAGE_ID_LIST 25
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_DETOUR 63 /* draft-ietf-mpls-rsvp-lsp-fastreroute-01 */
143 #define RSVP_OBJ_SUGGESTED_LABEL 129 /* rfc3473 */
144 #define RSVP_OBJ_ACCEPT_LABEL_SET 130 /* rfc3473 */
145 #define RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */
146 #define RSVP_OBJ_NOTIFY_REQ 195 /* rfc3473 */
147 #define RSVP_OBJ_ADMIN_STATUS 196 /* rfc3473 */
148 #define RSVP_OBJ_PROPERTIES 204 /* juniper proprietary */
149 #define RSVP_OBJ_FASTREROUTE 205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-01 */
150 #define RSVP_OBJ_SESSION_ATTRIBUTE 207 /* rfc3209 */
151 #define RSVP_OBJ_CALL_ID 230 /* rfc3474 */
152 #define RSVP_OBJ_CALL_OPS 236 /* rfc3474 */
153
154 static const struct tok rsvp_obj_values[] = {
155 { RSVP_OBJ_SESSION, "Session" },
156 { RSVP_OBJ_RSVP_HOP, "RSVP Hop" },
157 { RSVP_OBJ_INTEGRITY, "Integrity" },
158 { RSVP_OBJ_TIME_VALUES, "Time Values" },
159 { RSVP_OBJ_ERROR_SPEC, "Error Spec" },
160 { RSVP_OBJ_SCOPE, "Scope" },
161 { RSVP_OBJ_STYLE, "Style" },
162 { RSVP_OBJ_FLOWSPEC, "Flowspec" },
163 { RSVP_OBJ_FILTERSPEC, "FilterSpec" },
164 { RSVP_OBJ_SENDER_TEMPLATE, "Sender Template" },
165 { RSVP_OBJ_SENDER_TSPEC, "Sender TSpec" },
166 { RSVP_OBJ_ADSPEC, "Adspec" },
167 { RSVP_OBJ_POLICY_DATA, "Policy Data" },
168 { RSVP_OBJ_CONFIRM, "Confirm" },
169 { RSVP_OBJ_LABEL, "Label" },
170 { RSVP_OBJ_LABEL_REQ, "Label Request" },
171 { RSVP_OBJ_ERO, "ERO" },
172 { RSVP_OBJ_RRO, "RRO" },
173 { RSVP_OBJ_HELLO, "Hello" },
174 { RSVP_OBJ_MESSAGE_ID, "Message ID" },
175 { RSVP_OBJ_MESSAGE_ID_ACK, "Message ID Ack" },
176 { RSVP_OBJ_MESSAGE_ID_LIST, "Message ID List" },
177 { RSVP_OBJ_RECOVERY_LABEL, "Recovery Label" },
178 { RSVP_OBJ_UPSTREAM_LABEL, "Upstream Label" },
179 { RSVP_OBJ_LABEL_SET, "Label Set" },
180 { RSVP_OBJ_ACCEPT_LABEL_SET, "Acceptable Label Set" },
181 { RSVP_OBJ_DETOUR, "Detour" },
182 { RSVP_OBJ_SUGGESTED_LABEL, "Suggested Label" },
183 { RSVP_OBJ_PROPERTIES, "Properties" },
184 { RSVP_OBJ_FASTREROUTE, "Fast Re-Route" },
185 { RSVP_OBJ_SESSION_ATTRIBUTE, "Session Attribute" },
186 { RSVP_OBJ_CALL_ID, "Call-ID" },
187 { RSVP_OBJ_CALL_OPS, "Call Capability" },
188 { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" },
189 { RSVP_OBJ_NOTIFY_REQ, "Notify Request" },
190 { RSVP_OBJ_PROTECTION, "Protection" },
191 { RSVP_OBJ_ADMIN_STATUS, "Administrative Status" },
192 { 0, NULL}
193 };
194
195 #define RSVP_CTYPE_IPV4 1
196 #define RSVP_CTYPE_IPV6 2
197 #define RSVP_CTYPE_TUNNEL_IPV4 7
198 #define RSVP_CTYPE_TUNNEL_IPV6 8
199 #define RSVP_CTYPE_1 1
200 #define RSVP_CTYPE_2 2
201 #define RSVP_CTYPE_3 3
202 #define RSVP_CTYPE_4 4
203
204 /*
205 * the ctypes are not globally unique so for
206 * translating it to strings we build a table based
207 * on objects offsetted by the ctype
208 */
209
210 static const struct tok rsvp_ctype_values[] = {
211 { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV4, "IPv4" },
212 { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV6, "IPv6" },
213 { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" },
214 { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" },
215 { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV4, "IPv4" },
216 { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV6, "IPv6" },
217 { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV4, "IPv4" },
218 { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV6, "IPv6" },
219 { 256*RSVP_OBJ_TIME_VALUES+RSVP_CTYPE_1, "1" },
220 { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_1, "obsolete" },
221 { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_2, "IntServ" },
222 { 256*RSVP_OBJ_SENDER_TSPEC+RSVP_CTYPE_2, "IntServ" },
223 { 256*RSVP_OBJ_ADSPEC+RSVP_CTYPE_2, "IntServ" },
224 { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV4, "IPv4" },
225 { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV6, "IPv6" },
226 { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_3, "IPv6 Flow-label" },
227 { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
228 { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4, "IPv4" },
229 { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6, "IPv6" },
230 { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
231 { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4, "IPv4" },
232 { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6, "IPv6" },
233 { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
234 { 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1, "1" },
235 { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1, "1" },
236 { 256*RSVP_OBJ_MESSAGE_ID_LIST+RSVP_CTYPE_1, "1" },
237 { 256*RSVP_OBJ_STYLE+RSVP_CTYPE_1, "1" },
238 { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1, "Hello Request" },
239 { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_2, "Hello Ack" },
240 { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_1, "without label range" },
241 { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_2, "with ATM label range" },
242 { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_3, "with FR label range" },
243 { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_4, "Generalized Label" },
244 { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_1, "Label" },
245 { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_2, "Generalized Label" },
246 { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_3, "Waveband Switching" },
247 { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_1, "Label" },
248 { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_2, "Generalized Label" },
249 { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_3, "Waveband Switching" },
250 { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_1, "Label" },
251 { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_2, "Generalized Label" },
252 { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_3, "Waveband Switching" },
253 { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_1, "Label" },
254 { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_2, "Generalized Label" },
255 { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_3, "Waveband Switching" },
256 { 256*RSVP_OBJ_ERO+RSVP_CTYPE_IPV4, "IPv4" },
257 { 256*RSVP_OBJ_RRO+RSVP_CTYPE_IPV4, "IPv4" },
258 { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV4, "IPv4" },
259 { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV6, "IPv6" },
260 { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" },
261 { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" },
262 { 256*RSVP_OBJ_RESTART_CAPABILITY+RSVP_CTYPE_1, "IPv4" },
263 { 256*RSVP_OBJ_SESSION_ATTRIBUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
264 { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
265 { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" },
266 { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1, "1" },
267 { 0, NULL}
268 };
269
270 #define RSVP_OBJ_XRO_MASK_SUBOBJ(x) ((x)&0x7f)
271 #define RSVP_OBJ_XRO_MASK_LOOSE(x) ((x)&0x80)
272
273 #define RSVP_OBJ_XRO_RES 0
274 #define RSVP_OBJ_XRO_IPV4 1
275 #define RSVP_OBJ_XRO_IPV6 2
276 #define RSVP_OBJ_XRO_ASN 32
277 #define RSVP_OBJ_XRO_MPLS 64
278
279 static const struct tok rsvp_obj_xro_values[] = {
280 { RSVP_OBJ_XRO_RES, "Reserved" },
281 { RSVP_OBJ_XRO_IPV4, "IPv4 prefix" },
282 { RSVP_OBJ_XRO_IPV6, "IPv6 prefix" },
283 { RSVP_OBJ_XRO_ASN, "Autonomous system number" },
284 { RSVP_OBJ_XRO_MPLS, "MPLS label switched path termination" },
285 { 0, NULL}
286 };
287
288 /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
289 static const struct tok rsvp_obj_rro_flag_values[] = {
290 { 0x01, "Local protection available" },
291 { 0x02, "Local protection in use" },
292 { 0x04, "Bandwidth protection" },
293 { 0x08, "Node protection" },
294 { 0, NULL}
295 };
296
297 static const struct tok rsvp_resstyle_values[] = {
298 { 17, "Wildcard Filter" },
299 { 10, "Fixed Filter" },
300 { 18, "Shared Explicit" },
301 { 0, NULL}
302 };
303
304 #define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2
305 #define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5
306
307 static const struct tok rsvp_intserv_service_type_values[] = {
308 { 1, "Default/Global Information" },
309 { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" },
310 { RSVP_OBJ_INTSERV_CONTROLLED_LOAD, "Controlled Load" },
311 { 0, NULL}
312 };
313
314 static const struct tok rsvp_intserv_parameter_id_values[] = {
315 { 4, "IS hop cnt" },
316 { 6, "Path b/w estimate" },
317 { 8, "Minimum path latency" },
318 { 10, "Composed MTU" },
319 { 127, "Token Bucket TSpec" },
320 { 130, "Guaranteed Service RSpec" },
321 { 133, "End-to-end composed value for C" },
322 { 134, "End-to-end composed value for D" },
323 { 135, "Since-last-reshaping point composed C" },
324 { 136, "Since-last-reshaping point composed D" },
325 { 0, NULL}
326 };
327
328 static struct tok rsvp_session_attribute_flag_values[] = {
329 { 0x01, "Local Protection desired" },
330 { 0x02, "Label Recording desired" },
331 { 0x04, "SE Style desired" },
332 { 0x08, "Bandwidth protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
333 { 0x10, "Node protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */
334 { 0, NULL}
335 };
336
337 static struct tok rsvp_obj_prop_tlv_values[] = {
338 { 0x01, "Cos" },
339 { 0x02, "Metric 1" },
340 { 0x04, "Metric 2" },
341 { 0x08, "CCC Status" },
342 { 0x10, "Path Type" },
343 { 0, NULL}
344 };
345
346 #define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24
347 #define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY 25
348
349 static struct tok rsvp_obj_error_code_values[] = {
350 { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
351 { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY, "Notify Error" },
352 { 0, NULL}
353 };
354
355 static struct tok rsvp_obj_error_code_routing_values[] = {
356 { 1, "Bad EXPLICIT_ROUTE object" },
357 { 2, "Bad strict node" },
358 { 3, "Bad loose node" },
359 { 4, "Bad initial subobject" },
360 { 5, "No route available toward destination" },
361 { 6, "Unacceptable label value" },
362 { 7, "RRO indicated routing loops" },
363 { 8, "non-RSVP-capable router in the path" },
364 { 9, "MPLS label allocation failure" },
365 { 10, "Unsupported L3PID" },
366 { 0, NULL}
367 };
368
369 #define FALSE 0
370 #define TRUE 1
371
372
373 static int rsvp_intserv_print(const u_char *, u_short);
374
375 /*
376 * this is a dissector for all the intserv defined
377 * specs as defined per rfc2215
378 * it is called from various rsvp objects;
379 * returns the amount of bytes being processed
380 */
381 static int
382 rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
383
384 int parameter_id,parameter_length;
385 union {
386 float f;
387 u_int32_t i;
388 } bw;
389
390 if (obj_tlen < 4)
391 return 0;
392 parameter_id = *(tptr);
393 parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
394
395 printf("\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
396 tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
397 parameter_id,
398 parameter_length,
399 *(tptr+1));
400
401 if (obj_tlen < parameter_length+4)
402 return 0;
403 switch(parameter_id) { /* parameter_id */
404
405 case 4:
406 /*
407 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
408 * | 4 (e) | (f) | 1 (g) |
409 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
410 * | IS hop cnt (32-bit unsigned integer) |
411 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
412 */
413 if (parameter_length == 4)
414 printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));
415 break;
416
417 case 6:
418 /*
419 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
420 * | 6 (h) | (i) | 1 (j) |
421 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422 * | Path b/w estimate (32-bit IEEE floating point number) |
423 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424 */
425 if (parameter_length == 4) {
426 bw.i = EXTRACT_32BITS(tptr+4);
427 printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);
428 }
429 break;
430
431 case 8:
432 /*
433 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
434 * | 8 (k) | (l) | 1 (m) |
435 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
436 * | Minimum path latency (32-bit integer) |
437 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
438 */
439 if (parameter_length == 4) {
440 printf("\n\t\tMinimum path latency: ");
441 if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
442 printf("don't care");
443 else
444 printf("%u", EXTRACT_32BITS(tptr+4));
445 }
446 break;
447
448 case 10:
449
450 /*
451 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
452 * | 10 (n) | (o) | 1 (p) |
453 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
454 * | Composed MTU (32-bit unsigned integer) |
455 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
456 */
457 if (parameter_length == 4)
458 printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
459 break;
460 case 127:
461 /*
462 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
463 * | 127 (e) | 0 (f) | 5 (g) |
464 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
465 * | Token Bucket Rate [r] (32-bit IEEE floating point number) |
466 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
467 * | Token Bucket Size [b] (32-bit IEEE floating point number) |
468 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
469 * | Peak Data Rate [p] (32-bit IEEE floating point number) |
470 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
471 * | Minimum Policed Unit [m] (32-bit integer) |
472 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
473 * | Maximum Packet Size [M] (32-bit integer) |
474 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
475 */
476
477 if (parameter_length == 20) {
478 bw.i = EXTRACT_32BITS(tptr+4);
479 printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);
480 bw.i = EXTRACT_32BITS(tptr+8);
481 printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
482 bw.i = EXTRACT_32BITS(tptr+12);
483 printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);
484 printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));
485 printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));
486 }
487 break;
488
489 case 130:
490 /*
491 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
492 * | 130 (h) | 0 (i) | 2 (j) |
493 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
494 * | Rate [R] (32-bit IEEE floating point number) |
495 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
496 * | Slack Term [S] (32-bit integer) |
497 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
498 */
499
500 if (parameter_length == 8) {
501 bw.i = EXTRACT_32BITS(tptr+4);
502 printf("\n\t\tRate: %.10g Mbps", bw.f/125000);
503 printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));
504 }
505 break;
506
507 case 133:
508 case 134:
509 case 135:
510 case 136:
511 if (parameter_length == 4)
512 printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));
513 break;
514
515 default:
516 if (vflag <= 1)
517 print_unknown_data(tptr+4,"\n\t\t",parameter_length);
518 }
519 return (parameter_length+4); /* header length 4 bytes */
520 }
521
522 static int
523 rsvp_obj_print (const u_char *tptr, const u_char *ident, u_int tlen) {
524
525 const struct rsvp_object_header *rsvp_obj_header;
526 const u_char *obj_tptr;
527 u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen;
528 int hexdump,processed,padbytes,error_code,error_value,i;
529 union {
530 float f;
531 u_int32_t i;
532 } bw;
533 u_int8_t namelen;
534
535 while(tlen>0) {
536 /* did we capture enough for fully decoding the object header ? */
537 if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))
538 goto trunc;
539
540 rsvp_obj_header = (const struct rsvp_object_header *)tptr;
541 rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
542 rsvp_obj_ctype=rsvp_obj_header->ctype;
543
544 if(rsvp_obj_len % 4 || rsvp_obj_len < sizeof(struct rsvp_object_header)) {
545 printf("ERROR: object header too short %u < %lu", rsvp_obj_len,
546 (unsigned long)sizeof(const struct rsvp_object_header));
547 return -1;
548 }
549
550 printf("%s%s Object (%u) Flags: [%s",
551 ident,
552 tok2str(rsvp_obj_values,
553 "Unknown",
554 rsvp_obj_header->class_num),
555 rsvp_obj_header->class_num,
556 ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");
557
558 if (rsvp_obj_header->class_num > 128)
559 printf(" %s",
560 ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently");
561
562 printf(" if unknown], Class-Type: %s (%u), length: %u",
563 tok2str(rsvp_ctype_values,
564 "Unknown",
565 ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
566 rsvp_obj_ctype,
567 rsvp_obj_len);
568
569 obj_tptr=tptr+sizeof(struct rsvp_object_header);
570 obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
571
572 /* did we capture enough for fully decoding the object ? */
573 if (!TTEST2(*tptr, rsvp_obj_len))
574 return -1;
575 hexdump=FALSE;
576
577 switch(rsvp_obj_header->class_num) {
578 case RSVP_OBJ_SESSION:
579 switch(rsvp_obj_ctype) {
580 case RSVP_CTYPE_IPV4:
581 if (obj_tlen < 8)
582 return -1;
583 printf("%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
584 ident,
585 ipaddr_string(obj_tptr),
586 *(obj_tptr+4));
587 printf("%s Flags: [0x%02x], DestPort %u",
588 ident,
589 *(obj_tptr+5),
590 EXTRACT_16BITS(obj_tptr+6));
591 obj_tlen-=8;
592 obj_tptr+=8;
593 break;
594 #ifdef INET6
595 case RSVP_CTYPE_IPV6:
596 if (obj_tlen < 20)
597 return -1;
598 printf("%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
599 ident,
600 ip6addr_string(obj_tptr),
601 *(obj_tptr+16));
602 printf("%s Flags: [0x%02x], DestPort %u",
603 ident,
604 *(obj_tptr+17),
605 EXTRACT_16BITS(obj_tptr+18));
606 obj_tlen-=20;
607 obj_tptr+=20;
608 break;
609
610 case RSVP_CTYPE_TUNNEL_IPV6:
611 if (obj_tlen < 36)
612 return -1;
613 printf("%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
614 ident,
615 ip6addr_string(obj_tptr),
616 EXTRACT_16BITS(obj_tptr+18),
617 ip6addr_string(obj_tptr+20));
618 obj_tlen-=36;
619 obj_tptr+=36;
620 break;
621 #endif
622 case RSVP_CTYPE_TUNNEL_IPV4:
623 if (obj_tlen < 12)
624 return -1;
625 printf("%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
626 ident,
627 ipaddr_string(obj_tptr),
628 EXTRACT_16BITS(obj_tptr+6),
629 ipaddr_string(obj_tptr+8));
630 obj_tlen-=12;
631 obj_tptr+=12;
632 break;
633 default:
634 hexdump=TRUE;
635 }
636 break;
637
638 case RSVP_OBJ_CONFIRM:
639 switch(rsvp_obj_ctype) {
640 case RSVP_CTYPE_IPV4:
641 if (obj_tlen < 4)
642 return -1;
643 printf("%s IPv4 Receiver Address: %s",
644 ident,
645 ipaddr_string(obj_tptr));
646 obj_tlen-=4;
647 obj_tptr+=4;
648 break;
649 #ifdef INET6
650 case RSVP_CTYPE_IPV6:
651 if (obj_tlen < 16)
652 return -1;
653 printf("%s IPv6 Receiver Address: %s",
654 ident,
655 ip6addr_string(obj_tptr));
656 obj_tlen-=16;
657 obj_tptr+=16;
658 break;
659 #endif
660 default:
661 hexdump=TRUE;
662 }
663 break;
664
665 case RSVP_OBJ_NOTIFY_REQ:
666 switch(rsvp_obj_ctype) {
667 case RSVP_CTYPE_IPV4:
668 if (obj_tlen < 4)
669 return -1;
670 printf("%s IPv4 Notify Node Address: %s",
671 ident,
672 ipaddr_string(obj_tptr));
673 obj_tlen-=4;
674 obj_tptr+=4;
675 break;
676 #ifdef INET6
677 case RSVP_CTYPE_IPV6:
678 if (obj_tlen < 16)
679 return-1;
680 printf("%s IPv6 Notify Node Address: %s",
681 ident,
682 ip6addr_string(obj_tptr));
683 obj_tlen-=16;
684 obj_tptr+=16;
685 break;
686 #endif
687 default:
688 hexdump=TRUE;
689 }
690 break;
691
692 case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */
693 case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */
694 case RSVP_OBJ_RECOVERY_LABEL: /* fall through */
695 case RSVP_OBJ_LABEL:
696 switch(rsvp_obj_ctype) {
697 case RSVP_CTYPE_1:
698 while(obj_tlen >= 4 ) {
699 printf("%s Label: %u", ident, EXTRACT_32BITS(obj_tptr));
700 obj_tlen-=4;
701 obj_tptr+=4;
702 }
703 break;
704 case RSVP_CTYPE_2:
705 if (obj_tlen < 4)
706 return-1;
707 printf("%s Generalized Label: %u",
708 ident,
709 EXTRACT_32BITS(obj_tptr));
710 obj_tlen-=4;
711 obj_tptr+=4;
712 break;
713 case RSVP_CTYPE_3:
714 if (obj_tlen < 12)
715 return-1;
716 printf("%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
717 ident,
718 EXTRACT_32BITS(obj_tptr),
719 ident,
720 EXTRACT_32BITS(obj_tptr+4),
721 EXTRACT_32BITS(obj_tptr+8));
722 obj_tlen-=12;
723 obj_tptr+=12;
724 break;
725 default:
726 hexdump=TRUE;
727 }
728 break;
729
730 case RSVP_OBJ_STYLE:
731 switch(rsvp_obj_ctype) {
732 case RSVP_CTYPE_1:
733 if (obj_tlen < 4)
734 return-1;
735 printf("%s Reservation Style: %s, Flags: [0x%02x]",
736 ident,
737 tok2str(rsvp_resstyle_values,
738 "Unknown",
739 EXTRACT_24BITS(obj_tptr+1)),
740 *(obj_tptr));
741 obj_tlen-=4;
742 obj_tptr+=4;
743 break;
744 default:
745 hexdump=TRUE;
746 }
747 break;
748
749 case RSVP_OBJ_SENDER_TEMPLATE:
750 switch(rsvp_obj_ctype) {
751 case RSVP_CTYPE_IPV4:
752 if (obj_tlen < 8)
753 return-1;
754 printf("%s Source Address: %s, Source Port: %u",
755 ident,
756 ipaddr_string(obj_tptr),
757 EXTRACT_16BITS(obj_tptr+6));
758 obj_tlen-=8;
759 obj_tptr+=8;
760 break;
761 #ifdef INET6
762 case RSVP_CTYPE_IPV6:
763 if (obj_tlen < 20)
764 return-1;
765 printf("%s Source Address: %s, Source Port: %u",
766 ident,
767 ip6addr_string(obj_tptr),
768 EXTRACT_16BITS(obj_tptr+18));
769 obj_tlen-=20;
770 obj_tptr+=20;
771 break;
772 #endif
773 case RSVP_CTYPE_TUNNEL_IPV4:
774 if (obj_tlen < 8)
775 return-1;
776 printf("%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
777 ident,
778 ipaddr_string(obj_tptr),
779 EXTRACT_16BITS(obj_tptr+6));
780 obj_tlen-=8;
781 obj_tptr+=8;
782 break;
783 default:
784 hexdump=TRUE;
785 }
786 break;
787
788 case RSVP_OBJ_LABEL_REQ:
789 switch(rsvp_obj_ctype) {
790 case RSVP_CTYPE_1:
791 while(obj_tlen >= 4 ) {
792 printf("%s L3 Protocol ID: %s",
793 ident,
794 tok2str(ethertype_values,
795 "Unknown Protocol (0x%04x)",
796 EXTRACT_16BITS(obj_tptr+2)));
797 obj_tlen-=4;
798 obj_tptr+=4;
799 }
800 break;
801 case RSVP_CTYPE_2:
802 if (obj_tlen < 12)
803 return-1;
804 printf("%s L3 Protocol ID: %s",
805 ident,
806 tok2str(ethertype_values,
807 "Unknown Protocol (0x%04x)",
808 EXTRACT_16BITS(obj_tptr+2)));
809 printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" );
810 printf("%s Minimum VPI/VCI: %u/%u",
811 ident,
812 (EXTRACT_16BITS(obj_tptr+4))&0xfff,
813 (EXTRACT_16BITS(obj_tptr+6))&0xfff);
814 printf("%s Maximum VPI/VCI: %u/%u",
815 ident,
816 (EXTRACT_16BITS(obj_tptr+8))&0xfff,
817 (EXTRACT_16BITS(obj_tptr+10))&0xfff);
818 obj_tlen-=12;
819 obj_tptr+=12;
820 break;
821 case RSVP_CTYPE_3:
822 if (obj_tlen < 12)
823 return-1;
824 printf("%s L3 Protocol ID: %s",
825 ident,
826 tok2str(ethertype_values,
827 "Unknown Protocol (0x%04x)",
828 EXTRACT_16BITS(obj_tptr+2)));
829 printf("%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
830 ident,
831 (EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
832 (EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
833 (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
834 (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : "");
835 obj_tlen-=12;
836 obj_tptr+=12;
837 break;
838 case RSVP_CTYPE_4:
839 if (obj_tlen < 8)
840 return-1;
841 printf("%s LSP Encoding Type: %s (%u)",
842 ident,
843 tok2str(gmpls_encoding_values,
844 "Unknown",
845 *obj_tptr),
846 *obj_tptr);
847 printf("%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
848 ident,
849 tok2str(gmpls_switch_cap_values,
850 "Unknown",
851 *(obj_tptr+1)),
852 *(obj_tptr+1),
853 tok2str(gmpls_payload_values,
854 "Unknown",
855 EXTRACT_16BITS(obj_tptr+2)),
856 EXTRACT_16BITS(obj_tptr+2));
857 obj_tlen-=8;
858 obj_tptr+=8;
859 break;
860 default:
861 hexdump=TRUE;
862 }
863 break;
864
865 case RSVP_OBJ_RRO:
866 case RSVP_OBJ_ERO:
867 switch(rsvp_obj_ctype) {
868 case RSVP_CTYPE_IPV4:
869 while(obj_tlen >= 4 ) {
870 printf("%s Subobject Type: %s",
871 ident,
872 tok2str(rsvp_obj_xro_values,
873 "Unknown %u",
874 RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)));
875 switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
876 case RSVP_OBJ_XRO_IPV4:
877 printf(", %s, %s/%u, Flags: [%s]",
878 RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
879 ipaddr_string(obj_tptr+2),
880 *(obj_tptr+6),
881 bittok2str(rsvp_obj_rro_flag_values,
882 "none",
883 *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
884 }
885 obj_tlen-=*(obj_tptr+1);
886 obj_tptr+=*(obj_tptr+1);
887 }
888 break;
889 default:
890 hexdump=TRUE;
891 }
892 break;
893
894 case RSVP_OBJ_HELLO:
895 switch(rsvp_obj_ctype) {
896 case RSVP_CTYPE_1:
897 case RSVP_CTYPE_2:
898 if (obj_tlen < 8)
899 return-1;
900 printf("%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
901 ident,
902 EXTRACT_32BITS(obj_tptr),
903 EXTRACT_32BITS(obj_tptr+4));
904 obj_tlen-=8;
905 obj_tptr+=8;
906 break;
907 default:
908 hexdump=TRUE;
909 }
910 break;
911
912 case RSVP_OBJ_RESTART_CAPABILITY:
913 switch(rsvp_obj_ctype) {
914 case RSVP_CTYPE_1:
915 if (obj_tlen < 8)
916 return-1;
917 printf("%s Restart Time: %ums, Recovery Time: %ums",
918 ident,
919 EXTRACT_16BITS(obj_tptr),
920 EXTRACT_16BITS(obj_tptr+4));
921 obj_tlen-=8;
922 obj_tptr+=8;
923 break;
924 default:
925 hexdump=TRUE;
926 }
927 break;
928
929 case RSVP_OBJ_SESSION_ATTRIBUTE:
930 switch(rsvp_obj_ctype) {
931 case RSVP_CTYPE_TUNNEL_IPV4:
932 if (obj_tlen < 4)
933 return-1;
934 namelen = *(obj_tptr+3);
935 if (obj_tlen < 4+namelen)
936 return-1;
937 printf("%s Session Name: ", ident);
938 for (i = 0; i < namelen; i++)
939 safeputchar(*(obj_tptr+4+i));
940 printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s]",
941 ident,
942 (int)*obj_tptr,
943 (int)*(obj_tptr+1),
944 tok2str(rsvp_session_attribute_flag_values,
945 "none",
946 *(obj_tptr+2)));
947
948 obj_tlen-=4+*(obj_tptr+3);
949 obj_tptr+=4+*(obj_tptr+3);
950 break;
951 default:
952 hexdump=TRUE;
953 }
954 break;
955
956 case RSVP_OBJ_RSVP_HOP:
957 switch(rsvp_obj_ctype) {
958 case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
959 case RSVP_CTYPE_IPV4:
960 if (obj_tlen < 8)
961 return-1;
962 printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
963 ident,
964 ipaddr_string(obj_tptr),
965 EXTRACT_32BITS(obj_tptr+4));
966 obj_tlen-=8;
967 obj_tptr+=8;
968 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
969 break;
970 #ifdef INET6
971 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
972 case RSVP_CTYPE_IPV6:
973 if (obj_tlen < 20)
974 return-1;
975 printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
976 ident,
977 ip6addr_string(obj_tptr),
978 EXTRACT_32BITS(obj_tptr+16));
979 obj_tlen-=20;
980 obj_tptr+=20;
981 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
982 break;
983 #endif
984 default:
985 hexdump=TRUE;
986 }
987 break;
988
989 case RSVP_OBJ_TIME_VALUES:
990 switch(rsvp_obj_ctype) {
991 case RSVP_CTYPE_1:
992 if (obj_tlen < 4)
993 return-1;
994 printf("%s Refresh Period: %ums",
995 ident,
996 EXTRACT_32BITS(obj_tptr));
997 obj_tlen-=4;
998 obj_tptr+=4;
999 break;
1000 default:
1001 hexdump=TRUE;
1002 }
1003 break;
1004
1005 /* those three objects do share the same semantics */
1006 case RSVP_OBJ_SENDER_TSPEC:
1007 case RSVP_OBJ_ADSPEC:
1008 case RSVP_OBJ_FLOWSPEC:
1009 switch(rsvp_obj_ctype) {
1010 case RSVP_CTYPE_2:
1011 if (obj_tlen < 4)
1012 return-1;
1013 printf("%s Msg-Version: %u, length: %u",
1014 ident,
1015 (*obj_tptr & 0xf0) >> 4,
1016 EXTRACT_16BITS(obj_tptr+2)<<2);
1017 obj_tptr+=4; /* get to the start of the service header */
1018 obj_tlen-=4;
1019
1020 while (obj_tlen >= 4) {
1021 intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
1022 printf("%s Service Type: %s (%u), break bit %s set, Service length: %u",
1023 ident,
1024 tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
1025 *(obj_tptr),
1026 (*(obj_tptr+1)&0x80) ? "" : "not",
1027 intserv_serv_tlen);
1028
1029 obj_tptr+=4; /* get to the start of the parameter list */
1030 obj_tlen-=4;
1031
1032 while (intserv_serv_tlen>=4) {
1033 processed = rsvp_intserv_print(obj_tptr, obj_tlen);
1034 if (processed == 0)
1035 break;
1036 obj_tlen-=processed;
1037 intserv_serv_tlen-=processed;
1038 obj_tptr+=processed;
1039 }
1040 }
1041 break;
1042 default:
1043 hexdump=TRUE;
1044 }
1045 break;
1046
1047 case RSVP_OBJ_FILTERSPEC:
1048 switch(rsvp_obj_ctype) {
1049 case RSVP_CTYPE_IPV4:
1050 if (obj_tlen < 8)
1051 return-1;
1052 printf("%s Source Address: %s, Source Port: %u",
1053 ident,
1054 ipaddr_string(obj_tptr),
1055 EXTRACT_16BITS(obj_tptr+6));
1056 obj_tlen-=8;
1057 obj_tptr+=8;
1058 break;
1059 #ifdef INET6
1060 case RSVP_CTYPE_IPV6:
1061 if (obj_tlen < 20)
1062 return-1;
1063 printf("%s Source Address: %s, Source Port: %u",
1064 ident,
1065 ip6addr_string(obj_tptr),
1066 EXTRACT_16BITS(obj_tptr+18));
1067 obj_tlen-=20;
1068 obj_tptr+=20;
1069 break;
1070 case RSVP_CTYPE_3:
1071 if (obj_tlen < 20)
1072 return-1;
1073 printf("%s Source Address: %s, Flow Label: %u",
1074 ident,
1075 ip6addr_string(obj_tptr),
1076 EXTRACT_24BITS(obj_tptr+17));
1077 obj_tlen-=20;
1078 obj_tptr+=20;
1079 break;
1080 case RSVP_CTYPE_TUNNEL_IPV6:
1081 if (obj_tlen < 20)
1082 return-1;
1083 printf("%s Source Address: %s, LSP-ID: 0x%04x",
1084 ident,
1085 ipaddr_string(obj_tptr),
1086 EXTRACT_16BITS(obj_tptr+18));
1087 obj_tlen-=20;
1088 obj_tptr+=20;
1089 break;
1090 #endif
1091 case RSVP_CTYPE_TUNNEL_IPV4:
1092 if (obj_tlen < 8)
1093 return-1;
1094 printf("%s Source Address: %s, LSP-ID: 0x%04x",
1095 ident,
1096 ipaddr_string(obj_tptr),
1097 EXTRACT_16BITS(obj_tptr+6));
1098 obj_tlen-=8;
1099 obj_tptr+=8;
1100 break;
1101 default:
1102 hexdump=TRUE;
1103 }
1104 break;
1105
1106 case RSVP_OBJ_FASTREROUTE:
1107 switch(rsvp_obj_ctype) {
1108 case RSVP_CTYPE_TUNNEL_IPV4:
1109 if (obj_tlen < 16)
1110 return-1;
1111 bw.i = EXTRACT_32BITS(obj_tptr+4);
1112 printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
1113 ident,
1114 (int)*obj_tptr,
1115 (int)*(obj_tptr+1),
1116 (int)*(obj_tptr+2),
1117 bw.f*8/1000000);
1118 printf("%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
1119 ident,
1120 EXTRACT_32BITS(obj_tptr+8),
1121 EXTRACT_32BITS(obj_tptr+12));
1122 obj_tlen-=16;
1123 obj_tptr+=16;
1124 break;
1125 default:
1126 hexdump=TRUE;
1127 }
1128 break;
1129
1130 case RSVP_OBJ_DETOUR:
1131 switch(rsvp_obj_ctype) {
1132 case RSVP_CTYPE_TUNNEL_IPV4:
1133 while(obj_tlen >= 8) {
1134 printf("%s PLR-ID: %s, Avoid-Node-ID: %s",
1135 ident,
1136 ipaddr_string(obj_tptr),
1137 ipaddr_string(obj_tptr+4));
1138 obj_tlen-=8;
1139 obj_tptr+=8;
1140 }
1141 break;
1142 default:
1143 hexdump=TRUE;
1144 }
1145 break;
1146
1147 case RSVP_OBJ_ERROR_SPEC:
1148 switch(rsvp_obj_ctype) {
1149 case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
1150 case RSVP_CTYPE_IPV4:
1151 if (obj_tlen < 8)
1152 return-1;
1153 error_code=*(obj_tptr+5);
1154 error_value=EXTRACT_16BITS(obj_tptr+6);
1155 printf("%s Error Node Adress: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
1156 ident,
1157 ipaddr_string(obj_tptr),
1158 *(obj_tptr+4),
1159 ident,
1160 tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1161 error_code);
1162 switch (error_code) {
1163 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1164 printf(", Error Value: %s (%u)",
1165 tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1166 error_value);
1167 break;
1168 default:
1169 printf(", Unknown Error Value (%u)", error_value);
1170 break;
1171 }
1172 obj_tlen-=8;
1173 obj_tptr+=8;
1174 break;
1175 #ifdef INET6
1176 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
1177 case RSVP_CTYPE_IPV6:
1178 if (obj_tlen < 20)
1179 return-1;
1180 error_code=*(obj_tptr+17);
1181 error_value=EXTRACT_16BITS(obj_tptr+18);
1182 printf("%s Error Node Adress: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
1183 ident,
1184 ip6addr_string(obj_tptr),
1185 *(obj_tptr+16),
1186 ident,
1187 tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1188 error_code);
1189
1190 switch (error_code) {
1191 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1192 printf(", Error Value: %s (%u)",
1193 tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1194 error_value);
1195 break;
1196 default:
1197 break;
1198 }
1199 obj_tlen-=20;
1200 obj_tptr+=20;
1201 break;
1202 #endif
1203 default:
1204 hexdump=TRUE;
1205 }
1206 break;
1207
1208 case RSVP_OBJ_PROPERTIES:
1209 switch(rsvp_obj_ctype) {
1210 case RSVP_CTYPE_1:
1211 if (obj_tlen < 4)
1212 return-1;
1213 padbytes = EXTRACT_16BITS(obj_tptr+2);
1214 printf("%s TLV count: %u, padding bytes: %u",
1215 ident,
1216 EXTRACT_16BITS(obj_tptr),
1217 padbytes);
1218 obj_tlen-=4;
1219 obj_tptr+=4;
1220 /* loop through as long there is anything longer than the TLV header (2) */
1221 while(obj_tlen >= 2 + padbytes) {
1222 printf("%s %s TLV (0x%02x), length: %u", /* length includes header */
1223 ident,
1224 tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
1225 *obj_tptr,
1226 *(obj_tptr+1));
1227 if (obj_tlen < *(obj_tptr+1))
1228 return-1;
1229 print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
1230 obj_tlen-=*(obj_tptr+1);
1231 obj_tptr+=*(obj_tptr+1);
1232 }
1233 break;
1234 default:
1235 hexdump=TRUE;
1236 }
1237 break;
1238
1239 case RSVP_OBJ_MESSAGE_ID: /* fall through */
1240 case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */
1241 case RSVP_OBJ_MESSAGE_ID_LIST:
1242 switch(rsvp_obj_ctype) {
1243 case RSVP_CTYPE_1:
1244 if (obj_tlen < 8)
1245 return-1;
1246 printf("%s Flags [0x%02x], epoch: %u",
1247 ident,
1248 *obj_tptr,
1249 EXTRACT_24BITS(obj_tptr+1));
1250 obj_tlen-=4;
1251 obj_tptr+=4;
1252 /* loop through as long there are no messages left */
1253 while(obj_tlen >= 4) {
1254 printf("%s Message-ID 0x%08x (%u)",
1255 ident,
1256 EXTRACT_32BITS(obj_tptr),
1257 EXTRACT_32BITS(obj_tptr));
1258 obj_tlen-=4;
1259 obj_tptr+=4;
1260 }
1261 break;
1262 default:
1263 hexdump=TRUE;
1264 }
1265 break;
1266
1267 /*
1268 * FIXME those are the defined objects that lack a decoder
1269 * you are welcome to contribute code ;-)
1270 */
1271
1272 case RSVP_OBJ_INTEGRITY:
1273 case RSVP_OBJ_SCOPE:
1274 case RSVP_OBJ_POLICY_DATA:
1275 case RSVP_OBJ_LABEL_SET:
1276 case RSVP_OBJ_ACCEPT_LABEL_SET:
1277 case RSVP_OBJ_PROTECTION:
1278 default:
1279 if (vflag <= 1)
1280 print_unknown_data(obj_tptr,"\n\t ",obj_tlen); /* FIXME identation */
1281 break;
1282 }
1283 /* do we want to see an additionally hexdump ? */
1284 if (vflag > 1 || hexdump==TRUE)
1285 print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t ", /* FIXME identation */
1286 rsvp_obj_len-sizeof(struct rsvp_object_header));
1287
1288 tptr+=rsvp_obj_len;
1289 tlen-=rsvp_obj_len;
1290 }
1291 return 0;
1292 trunc:
1293 printf("\n\t\t packet exceeded snapshot");
1294 return -1;
1295 }
1296
1297
1298 void
1299 rsvp_print(register const u_char *pptr, register u_int len) {
1300
1301 const struct rsvp_common_header *rsvp_com_header;
1302 const u_char *tptr,*subtptr;
1303 u_short tlen,subtlen;
1304
1305 tptr=pptr;
1306
1307 rsvp_com_header = (const struct rsvp_common_header *)pptr;
1308 TCHECK(*rsvp_com_header);
1309
1310 /*
1311 * Sanity checking of the header.
1312 */
1313 if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1314 printf("ERROR: RSVP version %u packet not supported",
1315 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
1316 return;
1317 }
1318
1319 /* in non-verbose mode just lets print the basic Message Type*/
1320 if (vflag < 1) {
1321 printf("RSVPv%u %s Message, length: %u",
1322 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1323 tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
1324 len);
1325 return;
1326 }
1327
1328 /* ok they seem to want to know everything - lets fully decode it */
1329
1330 tlen=EXTRACT_16BITS(rsvp_com_header->length);
1331
1332 printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1333 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1334 tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1335 rsvp_com_header->msg_type,
1336 bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1337 tlen,
1338 rsvp_com_header->ttl,
1339 EXTRACT_16BITS(rsvp_com_header->checksum));
1340
1341 if (tlen < sizeof(const struct rsvp_common_header)) {
1342 printf("ERROR: common header too short %u < %lu", tlen,
1343 (unsigned long)sizeof(const struct rsvp_common_header));
1344 return;
1345 }
1346
1347 tptr+=sizeof(const struct rsvp_common_header);
1348 tlen-=sizeof(const struct rsvp_common_header);
1349
1350 switch(rsvp_com_header->msg_type) {
1351
1352 case RSVP_MSGTYPE_AGGREGATE:
1353 while(tlen > 0) {
1354 subtptr=tptr;
1355 rsvp_com_header = (const struct rsvp_common_header *)subtptr;
1356 TCHECK(*rsvp_com_header);
1357
1358 /*
1359 * Sanity checking of the header.
1360 */
1361 if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1362 printf("ERROR: RSVP version %u packet not supported",
1363 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
1364 return;
1365 }
1366 subtlen=EXTRACT_16BITS(rsvp_com_header->length);
1367
1368 printf("\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1369 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1370 tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1371 rsvp_com_header->msg_type,
1372 bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1373 subtlen,
1374 rsvp_com_header->ttl,
1375 EXTRACT_16BITS(rsvp_com_header->checksum));
1376
1377 if (subtlen < sizeof(const struct rsvp_common_header)) {
1378 printf("ERROR: common header too short %u < %lu", subtlen,
1379 (unsigned long)sizeof(const struct rsvp_common_header));
1380 return;
1381 }
1382
1383 subtptr+=sizeof(const struct rsvp_common_header);
1384 subtlen-=sizeof(const struct rsvp_common_header);
1385
1386 if (rsvp_obj_print(subtptr,"\n\t ", subtlen) == -1)
1387 return;
1388
1389 tptr+=subtlen+sizeof(const struct rsvp_common_header);
1390 tlen-=subtlen+sizeof(const struct rsvp_common_header);
1391 }
1392
1393 break;
1394
1395 case RSVP_MSGTYPE_PATH:
1396 case RSVP_MSGTYPE_RESV:
1397 case RSVP_MSGTYPE_PATHERR:
1398 case RSVP_MSGTYPE_RESVERR:
1399 case RSVP_MSGTYPE_PATHTEAR:
1400 case RSVP_MSGTYPE_RESVTEAR:
1401 case RSVP_MSGTYPE_RESVCONF:
1402 case RSVP_MSGTYPE_HELLO_OLD:
1403 case RSVP_MSGTYPE_HELLO:
1404 case RSVP_MSGTYPE_ACK:
1405 case RSVP_MSGTYPE_SREFRESH:
1406 if (rsvp_obj_print(tptr,"\n\t ", tlen) == -1)
1407 return;
1408 break;
1409
1410 default:
1411 print_unknown_data(tptr,"\n\t ",tlen);
1412 break;
1413 }
1414
1415 return;
1416 trunc:
1417 printf("\n\t\t packet exceeded snapshot");
1418 }