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