]> The Tcpdump Group git mirrors - tcpdump/blob - print-rsvp.c
update diffserv-TE codepoints as per rfc4124, code cosmetics: add a few TLV_MINLEN...
[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.33.2.6 2005-08-23 11:16:30 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 66 /* rfc4124 */
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 CT object" },
404 { 2, "Unsupported CT" },
405 { 3, "Invalid CT value" },
406 { 4, "CT/setup priority do not form a configured TE-Class" },
407 { 5, "CT/holding priority do not form a configured TE-Class" },
408 { 6, "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
409 { 7, "Inconsistency between signaled PSC and signaled CT" },
410 { 8, "Inconsistency between signaled PHBs and signaled CT" },
411 { 0, NULL}
412 };
413
414 #define FALSE 0
415 #define TRUE 1
416
417
418 static int rsvp_intserv_print(const u_char *, u_short);
419
420 /*
421 * this is a dissector for all the intserv defined
422 * specs as defined per rfc2215
423 * it is called from various rsvp objects;
424 * returns the amount of bytes being processed
425 */
426 static int
427 rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
428
429 int parameter_id,parameter_length;
430 union {
431 float f;
432 u_int32_t i;
433 } bw;
434
435 if (obj_tlen < 4)
436 return 0;
437 parameter_id = *(tptr);
438 parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
439
440 printf("\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
441 tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
442 parameter_id,
443 parameter_length,
444 *(tptr+1));
445
446 if (obj_tlen < parameter_length+4)
447 return 0;
448 switch(parameter_id) { /* parameter_id */
449
450 case 4:
451 /*
452 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
453 * | 4 (e) | (f) | 1 (g) |
454 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
455 * | IS hop cnt (32-bit unsigned integer) |
456 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
457 */
458 if (parameter_length == 4)
459 printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));
460 break;
461
462 case 6:
463 /*
464 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
465 * | 6 (h) | (i) | 1 (j) |
466 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
467 * | Path b/w estimate (32-bit IEEE floating point number) |
468 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
469 */
470 if (parameter_length == 4) {
471 bw.i = EXTRACT_32BITS(tptr+4);
472 printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);
473 }
474 break;
475
476 case 8:
477 /*
478 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
479 * | 8 (k) | (l) | 1 (m) |
480 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
481 * | Minimum path latency (32-bit integer) |
482 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
483 */
484 if (parameter_length == 4) {
485 printf("\n\t\tMinimum path latency: ");
486 if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
487 printf("don't care");
488 else
489 printf("%u", EXTRACT_32BITS(tptr+4));
490 }
491 break;
492
493 case 10:
494
495 /*
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
497 * | 10 (n) | (o) | 1 (p) |
498 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
499 * | Composed MTU (32-bit unsigned integer) |
500 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501 */
502 if (parameter_length == 4)
503 printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
504 break;
505 case 127:
506 /*
507 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
508 * | 127 (e) | 0 (f) | 5 (g) |
509 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
510 * | Token Bucket Rate [r] (32-bit IEEE floating point number) |
511 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
512 * | Token Bucket Size [b] (32-bit IEEE floating point number) |
513 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
514 * | Peak Data Rate [p] (32-bit IEEE floating point number) |
515 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
516 * | Minimum Policed Unit [m] (32-bit integer) |
517 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
518 * | Maximum Packet Size [M] (32-bit integer) |
519 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
520 */
521
522 if (parameter_length == 20) {
523 bw.i = EXTRACT_32BITS(tptr+4);
524 printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);
525 bw.i = EXTRACT_32BITS(tptr+8);
526 printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
527 bw.i = EXTRACT_32BITS(tptr+12);
528 printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);
529 printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));
530 printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));
531 }
532 break;
533
534 case 130:
535 /*
536 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
537 * | 130 (h) | 0 (i) | 2 (j) |
538 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
539 * | Rate [R] (32-bit IEEE floating point number) |
540 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
541 * | Slack Term [S] (32-bit integer) |
542 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
543 */
544
545 if (parameter_length == 8) {
546 bw.i = EXTRACT_32BITS(tptr+4);
547 printf("\n\t\tRate: %.10g Mbps", bw.f/125000);
548 printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));
549 }
550 break;
551
552 case 133:
553 case 134:
554 case 135:
555 case 136:
556 if (parameter_length == 4)
557 printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));
558 break;
559
560 default:
561 if (vflag <= 1)
562 print_unknown_data(tptr+4,"\n\t\t",parameter_length);
563 }
564 return (parameter_length+4); /* header length 4 bytes */
565 }
566
567 static int
568 rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
569
570 const struct rsvp_object_header *rsvp_obj_header;
571 const u_char *obj_tptr;
572 union {
573 const struct rsvp_obj_integrity_t *rsvp_obj_integrity;
574 const struct rsvp_obj_frr_t *rsvp_obj_frr;
575 } obj_ptr;
576
577 u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen;
578 int hexdump,processed,padbytes,error_code,error_value,i;
579 union {
580 float f;
581 u_int32_t i;
582 } bw;
583 u_int8_t namelen;
584
585 while(tlen>=sizeof(struct rsvp_object_header)) {
586 /* did we capture enough for fully decoding the object header ? */
587 if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))
588 goto trunc;
589
590 rsvp_obj_header = (const struct rsvp_object_header *)tptr;
591 rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
592 rsvp_obj_ctype=rsvp_obj_header->ctype;
593
594 if(rsvp_obj_len % 4) {
595 printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len);
596 return -1;
597 }
598 if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
599 printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
600 (unsigned long)sizeof(const struct rsvp_object_header));
601 return -1;
602 }
603
604 printf("%s%s Object (%u) Flags: [%s",
605 ident,
606 tok2str(rsvp_obj_values,
607 "Unknown",
608 rsvp_obj_header->class_num),
609 rsvp_obj_header->class_num,
610 ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");
611
612 if (rsvp_obj_header->class_num > 128)
613 printf(" %s",
614 ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently");
615
616 printf(" if unknown], Class-Type: %s (%u), length: %u",
617 tok2str(rsvp_ctype_values,
618 "Unknown",
619 ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
620 rsvp_obj_ctype,
621 rsvp_obj_len);
622
623 if(tlen < rsvp_obj_len) {
624 printf("%sERROR: object goes past end of objects TLV", ident);
625 return -1;
626 }
627
628 obj_tptr=tptr+sizeof(struct rsvp_object_header);
629 obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
630
631 /* did we capture enough for fully decoding the object ? */
632 if (!TTEST2(*tptr, rsvp_obj_len))
633 return -1;
634 hexdump=FALSE;
635
636 switch(rsvp_obj_header->class_num) {
637 case RSVP_OBJ_SESSION:
638 switch(rsvp_obj_ctype) {
639 case RSVP_CTYPE_IPV4:
640 if (obj_tlen < 8)
641 return -1;
642 printf("%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
643 ident,
644 ipaddr_string(obj_tptr),
645 *(obj_tptr+sizeof(struct in_addr)));
646 printf("%s Flags: [0x%02x], DestPort %u",
647 ident,
648 *(obj_tptr+5),
649 EXTRACT_16BITS(obj_tptr+6));
650 obj_tlen-=8;
651 obj_tptr+=8;
652 break;
653 #ifdef INET6
654 case RSVP_CTYPE_IPV6:
655 if (obj_tlen < 20)
656 return -1;
657 printf("%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
658 ident,
659 ip6addr_string(obj_tptr),
660 *(obj_tptr+sizeof(struct in6_addr)));
661 printf("%s Flags: [0x%02x], DestPort %u",
662 ident,
663 *(obj_tptr+sizeof(struct in6_addr)+1),
664 EXTRACT_16BITS(obj_tptr+sizeof(struct in6_addr)+2));
665 obj_tlen-=20;
666 obj_tptr+=20;
667 break;
668
669 case RSVP_CTYPE_TUNNEL_IPV6:
670 if (obj_tlen < 36)
671 return -1;
672 printf("%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
673 ident,
674 ip6addr_string(obj_tptr),
675 EXTRACT_16BITS(obj_tptr+18),
676 ip6addr_string(obj_tptr+20));
677 obj_tlen-=36;
678 obj_tptr+=36;
679 break;
680 #endif
681 case RSVP_CTYPE_TUNNEL_IPV4:
682 if (obj_tlen < 12)
683 return -1;
684 printf("%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
685 ident,
686 ipaddr_string(obj_tptr),
687 EXTRACT_16BITS(obj_tptr+6),
688 ipaddr_string(obj_tptr+8));
689 obj_tlen-=12;
690 obj_tptr+=12;
691 break;
692 default:
693 hexdump=TRUE;
694 }
695 break;
696
697 case RSVP_OBJ_CONFIRM:
698 switch(rsvp_obj_ctype) {
699 case RSVP_CTYPE_IPV4:
700 if (obj_tlen < sizeof(struct in_addr))
701 return -1;
702 printf("%s IPv4 Receiver Address: %s",
703 ident,
704 ipaddr_string(obj_tptr));
705 obj_tlen-=sizeof(struct in_addr);
706 obj_tptr+=sizeof(struct in_addr);
707 break;
708 #ifdef INET6
709 case RSVP_CTYPE_IPV6:
710 if (obj_tlen < sizeof(struct in6_addr))
711 return -1;
712 printf("%s IPv6 Receiver Address: %s",
713 ident,
714 ip6addr_string(obj_tptr));
715 obj_tlen-=sizeof(struct in6_addr);
716 obj_tptr+=sizeof(struct in6_addr);
717 break;
718 #endif
719 default:
720 hexdump=TRUE;
721 }
722 break;
723
724 case RSVP_OBJ_NOTIFY_REQ:
725 switch(rsvp_obj_ctype) {
726 case RSVP_CTYPE_IPV4:
727 if (obj_tlen < sizeof(struct in_addr))
728 return -1;
729 printf("%s IPv4 Notify Node Address: %s",
730 ident,
731 ipaddr_string(obj_tptr));
732 obj_tlen-=sizeof(struct in_addr);
733 obj_tptr+=sizeof(struct in_addr);
734 break;
735 #ifdef INET6
736 case RSVP_CTYPE_IPV6:
737 if (obj_tlen < sizeof(struct in6_addr))
738 return-1;
739 printf("%s IPv6 Notify Node Address: %s",
740 ident,
741 ip6addr_string(obj_tptr));
742 obj_tlen-=sizeof(struct in6_addr);
743 obj_tptr+=sizeof(struct in6_addr);
744 break;
745 #endif
746 default:
747 hexdump=TRUE;
748 }
749 break;
750
751 case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */
752 case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */
753 case RSVP_OBJ_RECOVERY_LABEL: /* fall through */
754 case RSVP_OBJ_LABEL:
755 switch(rsvp_obj_ctype) {
756 case RSVP_CTYPE_1:
757 while(obj_tlen >= 4 ) {
758 printf("%s Label: %u", ident, EXTRACT_32BITS(obj_tptr));
759 obj_tlen-=4;
760 obj_tptr+=4;
761 }
762 break;
763 case RSVP_CTYPE_2:
764 if (obj_tlen < 4)
765 return-1;
766 printf("%s Generalized Label: %u",
767 ident,
768 EXTRACT_32BITS(obj_tptr));
769 obj_tlen-=4;
770 obj_tptr+=4;
771 break;
772 case RSVP_CTYPE_3:
773 if (obj_tlen < 12)
774 return-1;
775 printf("%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
776 ident,
777 EXTRACT_32BITS(obj_tptr),
778 ident,
779 EXTRACT_32BITS(obj_tptr+4),
780 EXTRACT_32BITS(obj_tptr+8));
781 obj_tlen-=12;
782 obj_tptr+=12;
783 break;
784 default:
785 hexdump=TRUE;
786 }
787 break;
788
789 case RSVP_OBJ_STYLE:
790 switch(rsvp_obj_ctype) {
791 case RSVP_CTYPE_1:
792 if (obj_tlen < 4)
793 return-1;
794 printf("%s Reservation Style: %s, Flags: [0x%02x]",
795 ident,
796 tok2str(rsvp_resstyle_values,
797 "Unknown",
798 EXTRACT_24BITS(obj_tptr+1)),
799 *(obj_tptr));
800 obj_tlen-=4;
801 obj_tptr+=4;
802 break;
803 default:
804 hexdump=TRUE;
805 }
806 break;
807
808 case RSVP_OBJ_SENDER_TEMPLATE:
809 switch(rsvp_obj_ctype) {
810 case RSVP_CTYPE_IPV4:
811 if (obj_tlen < 8)
812 return-1;
813 printf("%s Source Address: %s, Source Port: %u",
814 ident,
815 ipaddr_string(obj_tptr),
816 EXTRACT_16BITS(obj_tptr+6));
817 obj_tlen-=8;
818 obj_tptr+=8;
819 break;
820 #ifdef INET6
821 case RSVP_CTYPE_IPV6:
822 if (obj_tlen < 20)
823 return-1;
824 printf("%s Source Address: %s, Source Port: %u",
825 ident,
826 ip6addr_string(obj_tptr),
827 EXTRACT_16BITS(obj_tptr+18));
828 obj_tlen-=20;
829 obj_tptr+=20;
830 break;
831 #endif
832 case RSVP_CTYPE_TUNNEL_IPV4:
833 if (obj_tlen < 8)
834 return-1;
835 printf("%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
836 ident,
837 ipaddr_string(obj_tptr),
838 EXTRACT_16BITS(obj_tptr+6));
839 obj_tlen-=8;
840 obj_tptr+=8;
841 break;
842 default:
843 hexdump=TRUE;
844 }
845 break;
846
847 case RSVP_OBJ_LABEL_REQ:
848 switch(rsvp_obj_ctype) {
849 case RSVP_CTYPE_1:
850 while(obj_tlen >= 4 ) {
851 printf("%s L3 Protocol ID: %s",
852 ident,
853 tok2str(ethertype_values,
854 "Unknown Protocol (0x%04x)",
855 EXTRACT_16BITS(obj_tptr+2)));
856 obj_tlen-=4;
857 obj_tptr+=4;
858 }
859 break;
860 case RSVP_CTYPE_2:
861 if (obj_tlen < 12)
862 return-1;
863 printf("%s L3 Protocol ID: %s",
864 ident,
865 tok2str(ethertype_values,
866 "Unknown Protocol (0x%04x)",
867 EXTRACT_16BITS(obj_tptr+2)));
868 printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" );
869 printf("%s Minimum VPI/VCI: %u/%u",
870 ident,
871 (EXTRACT_16BITS(obj_tptr+4))&0xfff,
872 (EXTRACT_16BITS(obj_tptr+6))&0xfff);
873 printf("%s Maximum VPI/VCI: %u/%u",
874 ident,
875 (EXTRACT_16BITS(obj_tptr+8))&0xfff,
876 (EXTRACT_16BITS(obj_tptr+10))&0xfff);
877 obj_tlen-=12;
878 obj_tptr+=12;
879 break;
880 case RSVP_CTYPE_3:
881 if (obj_tlen < 12)
882 return-1;
883 printf("%s L3 Protocol ID: %s",
884 ident,
885 tok2str(ethertype_values,
886 "Unknown Protocol (0x%04x)",
887 EXTRACT_16BITS(obj_tptr+2)));
888 printf("%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
889 ident,
890 (EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
891 (EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
892 (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
893 (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : "");
894 obj_tlen-=12;
895 obj_tptr+=12;
896 break;
897 case RSVP_CTYPE_4:
898 if (obj_tlen < 8)
899 return-1;
900 printf("%s LSP Encoding Type: %s (%u)",
901 ident,
902 tok2str(gmpls_encoding_values,
903 "Unknown",
904 *obj_tptr),
905 *obj_tptr);
906 printf("%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
907 ident,
908 tok2str(gmpls_switch_cap_values,
909 "Unknown",
910 *(obj_tptr+1)),
911 *(obj_tptr+1),
912 tok2str(gmpls_payload_values,
913 "Unknown",
914 EXTRACT_16BITS(obj_tptr+2)),
915 EXTRACT_16BITS(obj_tptr+2));
916 obj_tlen-=8;
917 obj_tptr+=8;
918 break;
919 default:
920 hexdump=TRUE;
921 }
922 break;
923
924 case RSVP_OBJ_RRO:
925 case RSVP_OBJ_ERO:
926 switch(rsvp_obj_ctype) {
927 case RSVP_CTYPE_IPV4:
928 while(obj_tlen >= 4 ) {
929 printf("%s Subobject Type: %s, length %u",
930 ident,
931 tok2str(rsvp_obj_xro_values,
932 "Unknown %u",
933 RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
934 *(obj_tptr+1));
935
936 if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
937 printf("%s ERROR: zero length ERO subtype",ident);
938 break;
939 }
940
941 switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
942 case RSVP_OBJ_XRO_IPV4:
943 printf(", %s, %s/%u, Flags: [%s]",
944 RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
945 ipaddr_string(obj_tptr+2),
946 *(obj_tptr+6),
947 bittok2str(rsvp_obj_rro_flag_values,
948 "none",
949 *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
950 }
951 obj_tlen-=*(obj_tptr+1);
952 obj_tptr+=*(obj_tptr+1);
953 }
954 break;
955 default:
956 hexdump=TRUE;
957 }
958 break;
959
960 case RSVP_OBJ_HELLO:
961 switch(rsvp_obj_ctype) {
962 case RSVP_CTYPE_1:
963 case RSVP_CTYPE_2:
964 if (obj_tlen < 8)
965 return-1;
966 printf("%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
967 ident,
968 EXTRACT_32BITS(obj_tptr),
969 EXTRACT_32BITS(obj_tptr+4));
970 obj_tlen-=8;
971 obj_tptr+=8;
972 break;
973 default:
974 hexdump=TRUE;
975 }
976 break;
977
978 case RSVP_OBJ_RESTART_CAPABILITY:
979 switch(rsvp_obj_ctype) {
980 case RSVP_CTYPE_1:
981 if (obj_tlen < 8)
982 return-1;
983 printf("%s Restart Time: %ums, Recovery Time: %ums",
984 ident,
985 EXTRACT_32BITS(obj_tptr),
986 EXTRACT_32BITS(obj_tptr+4));
987 obj_tlen-=8;
988 obj_tptr+=8;
989 break;
990 default:
991 hexdump=TRUE;
992 }
993 break;
994
995 case RSVP_OBJ_SESSION_ATTRIBUTE:
996 switch(rsvp_obj_ctype) {
997 case RSVP_CTYPE_TUNNEL_IPV4:
998 if (obj_tlen < 4)
999 return-1;
1000 namelen = *(obj_tptr+3);
1001 if (obj_tlen < 4+namelen)
1002 return-1;
1003 printf("%s Session Name: ", ident);
1004 for (i = 0; i < namelen; i++)
1005 safeputchar(*(obj_tptr+4+i));
1006 printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s]",
1007 ident,
1008 (int)*obj_tptr,
1009 (int)*(obj_tptr+1),
1010 tok2str(rsvp_session_attribute_flag_values,
1011 "none",
1012 *(obj_tptr+2)));
1013
1014 obj_tlen-=4+*(obj_tptr+3);
1015 obj_tptr+=4+*(obj_tptr+3);
1016 break;
1017 default:
1018 hexdump=TRUE;
1019 }
1020 break;
1021
1022 case RSVP_OBJ_RSVP_HOP:
1023 switch(rsvp_obj_ctype) {
1024 case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
1025 case RSVP_CTYPE_IPV4:
1026 if (obj_tlen < 8)
1027 return-1;
1028 printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
1029 ident,
1030 ipaddr_string(obj_tptr),
1031 EXTRACT_32BITS(obj_tptr+4));
1032 obj_tlen-=8;
1033 obj_tptr+=8;
1034 if (obj_tlen)
1035 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
1036 break;
1037 #ifdef INET6
1038 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
1039 case RSVP_CTYPE_IPV6:
1040 if (obj_tlen < 20)
1041 return-1;
1042 printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
1043 ident,
1044 ip6addr_string(obj_tptr),
1045 EXTRACT_32BITS(obj_tptr+16));
1046 obj_tlen-=20;
1047 obj_tptr+=20;
1048 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
1049 break;
1050 #endif
1051 default:
1052 hexdump=TRUE;
1053 }
1054 break;
1055
1056 case RSVP_OBJ_TIME_VALUES:
1057 switch(rsvp_obj_ctype) {
1058 case RSVP_CTYPE_1:
1059 if (obj_tlen < 4)
1060 return-1;
1061 printf("%s Refresh Period: %ums",
1062 ident,
1063 EXTRACT_32BITS(obj_tptr));
1064 obj_tlen-=4;
1065 obj_tptr+=4;
1066 break;
1067 default:
1068 hexdump=TRUE;
1069 }
1070 break;
1071
1072 /* those three objects do share the same semantics */
1073 case RSVP_OBJ_SENDER_TSPEC:
1074 case RSVP_OBJ_ADSPEC:
1075 case RSVP_OBJ_FLOWSPEC:
1076 switch(rsvp_obj_ctype) {
1077 case RSVP_CTYPE_2:
1078 if (obj_tlen < 4)
1079 return-1;
1080 printf("%s Msg-Version: %u, length: %u",
1081 ident,
1082 (*obj_tptr & 0xf0) >> 4,
1083 EXTRACT_16BITS(obj_tptr+2)<<2);
1084 obj_tptr+=4; /* get to the start of the service header */
1085 obj_tlen-=4;
1086
1087 while (obj_tlen >= 4) {
1088 intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
1089 printf("%s Service Type: %s (%u), break bit %s set, Service length: %u",
1090 ident,
1091 tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
1092 *(obj_tptr),
1093 (*(obj_tptr+1)&0x80) ? "" : "not",
1094 intserv_serv_tlen);
1095
1096 obj_tptr+=4; /* get to the start of the parameter list */
1097 obj_tlen-=4;
1098
1099 while (intserv_serv_tlen>=4) {
1100 processed = rsvp_intserv_print(obj_tptr, obj_tlen);
1101 if (processed == 0)
1102 break;
1103 obj_tlen-=processed;
1104 intserv_serv_tlen-=processed;
1105 obj_tptr+=processed;
1106 }
1107 }
1108 break;
1109 default:
1110 hexdump=TRUE;
1111 }
1112 break;
1113
1114 case RSVP_OBJ_FILTERSPEC:
1115 switch(rsvp_obj_ctype) {
1116 case RSVP_CTYPE_IPV4:
1117 if (obj_tlen < 8)
1118 return-1;
1119 printf("%s Source Address: %s, Source Port: %u",
1120 ident,
1121 ipaddr_string(obj_tptr),
1122 EXTRACT_16BITS(obj_tptr+6));
1123 obj_tlen-=8;
1124 obj_tptr+=8;
1125 break;
1126 #ifdef INET6
1127 case RSVP_CTYPE_IPV6:
1128 if (obj_tlen < 20)
1129 return-1;
1130 printf("%s Source Address: %s, Source Port: %u",
1131 ident,
1132 ip6addr_string(obj_tptr),
1133 EXTRACT_16BITS(obj_tptr+18));
1134 obj_tlen-=20;
1135 obj_tptr+=20;
1136 break;
1137 case RSVP_CTYPE_3:
1138 if (obj_tlen < 20)
1139 return-1;
1140 printf("%s Source Address: %s, Flow Label: %u",
1141 ident,
1142 ip6addr_string(obj_tptr),
1143 EXTRACT_24BITS(obj_tptr+17));
1144 obj_tlen-=20;
1145 obj_tptr+=20;
1146 break;
1147 case RSVP_CTYPE_TUNNEL_IPV6:
1148 if (obj_tlen < 20)
1149 return-1;
1150 printf("%s Source Address: %s, LSP-ID: 0x%04x",
1151 ident,
1152 ipaddr_string(obj_tptr),
1153 EXTRACT_16BITS(obj_tptr+18));
1154 obj_tlen-=20;
1155 obj_tptr+=20;
1156 break;
1157 #endif
1158 case RSVP_CTYPE_TUNNEL_IPV4:
1159 if (obj_tlen < 8)
1160 return-1;
1161 printf("%s Source Address: %s, LSP-ID: 0x%04x",
1162 ident,
1163 ipaddr_string(obj_tptr),
1164 EXTRACT_16BITS(obj_tptr+6));
1165 obj_tlen-=8;
1166 obj_tptr+=8;
1167 break;
1168 default:
1169 hexdump=TRUE;
1170 }
1171 break;
1172
1173 case RSVP_OBJ_FASTREROUTE:
1174 /* the differences between c-type 1 and 7 are minor */
1175 obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr;
1176 bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth);
1177
1178 switch(rsvp_obj_ctype) {
1179 case RSVP_CTYPE_1: /* new style */
1180 if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
1181 return-1;
1182 printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
1183 ident,
1184 (int)obj_ptr.rsvp_obj_frr->setup_prio,
1185 (int)obj_ptr.rsvp_obj_frr->hold_prio,
1186 (int)obj_ptr.rsvp_obj_frr->hop_limit,
1187 bw.f*8/1000000);
1188 printf("%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
1189 ident,
1190 EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
1191 EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any),
1192 EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all));
1193 obj_tlen-=sizeof(struct rsvp_obj_frr_t);
1194 obj_tptr+=sizeof(struct rsvp_obj_frr_t);
1195 break;
1196
1197 case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
1198 if (obj_tlen < 16)
1199 return-1;
1200 printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
1201 ident,
1202 (int)obj_ptr.rsvp_obj_frr->setup_prio,
1203 (int)obj_ptr.rsvp_obj_frr->hold_prio,
1204 (int)obj_ptr.rsvp_obj_frr->hop_limit,
1205 bw.f*8/1000000);
1206 printf("%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
1207 ident,
1208 EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
1209 EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any));
1210 obj_tlen-=16;
1211 obj_tptr+=16;
1212 break;
1213
1214 default:
1215 hexdump=TRUE;
1216 }
1217 break;
1218
1219 case RSVP_OBJ_DETOUR:
1220 switch(rsvp_obj_ctype) {
1221 case RSVP_CTYPE_TUNNEL_IPV4:
1222 while(obj_tlen >= 8) {
1223 printf("%s PLR-ID: %s, Avoid-Node-ID: %s",
1224 ident,
1225 ipaddr_string(obj_tptr),
1226 ipaddr_string(obj_tptr+4));
1227 obj_tlen-=8;
1228 obj_tptr+=8;
1229 }
1230 break;
1231 default:
1232 hexdump=TRUE;
1233 }
1234 break;
1235
1236 case RSVP_OBJ_CLASSTYPE:
1237 switch(rsvp_obj_ctype) {
1238 case RSVP_CTYPE_1:
1239 printf("%s CT: %u",
1240 ident,
1241 EXTRACT_32BITS(obj_tptr)&0x7);
1242 obj_tlen-=4;
1243 obj_tptr+=4;
1244 break;
1245 default:
1246 hexdump=TRUE;
1247 }
1248 break;
1249
1250 case RSVP_OBJ_ERROR_SPEC:
1251 switch(rsvp_obj_ctype) {
1252 case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
1253 case RSVP_CTYPE_IPV4:
1254 if (obj_tlen < 8)
1255 return-1;
1256 error_code=*(obj_tptr+5);
1257 error_value=EXTRACT_16BITS(obj_tptr+6);
1258 printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
1259 ident,
1260 ipaddr_string(obj_tptr),
1261 *(obj_tptr+4),
1262 ident,
1263 tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1264 error_code);
1265 switch (error_code) {
1266 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1267 printf(", Error Value: %s (%u)",
1268 tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1269 error_value);
1270 break;
1271 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE:
1272 printf(", Error Value: %s (%u)",
1273 tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
1274 error_value);
1275 break;
1276 default:
1277 printf(", Unknown Error Value (%u)", error_value);
1278 break;
1279 }
1280 obj_tlen-=8;
1281 obj_tptr+=8;
1282 break;
1283 #ifdef INET6
1284 case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
1285 case RSVP_CTYPE_IPV6:
1286 if (obj_tlen < 20)
1287 return-1;
1288 error_code=*(obj_tptr+17);
1289 error_value=EXTRACT_16BITS(obj_tptr+18);
1290 printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
1291 ident,
1292 ip6addr_string(obj_tptr),
1293 *(obj_tptr+16),
1294 ident,
1295 tok2str(rsvp_obj_error_code_values,"unknown",error_code),
1296 error_code);
1297
1298 switch (error_code) {
1299 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
1300 printf(", Error Value: %s (%u)",
1301 tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
1302 error_value);
1303 break;
1304 default:
1305 break;
1306 }
1307 obj_tlen-=20;
1308 obj_tptr+=20;
1309 break;
1310 #endif
1311 default:
1312 hexdump=TRUE;
1313 }
1314 break;
1315
1316 case RSVP_OBJ_PROPERTIES:
1317 switch(rsvp_obj_ctype) {
1318 case RSVP_CTYPE_1:
1319 if (obj_tlen < 4)
1320 return-1;
1321 padbytes = EXTRACT_16BITS(obj_tptr+2);
1322 printf("%s TLV count: %u, padding bytes: %u",
1323 ident,
1324 EXTRACT_16BITS(obj_tptr),
1325 padbytes);
1326 obj_tlen-=4;
1327 obj_tptr+=4;
1328 /* loop through as long there is anything longer than the TLV header (2) */
1329 while(obj_tlen >= 2 + padbytes) {
1330 printf("%s %s TLV (0x%02x), length: %u", /* length includes header */
1331 ident,
1332 tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
1333 *obj_tptr,
1334 *(obj_tptr+1));
1335 if (obj_tlen < *(obj_tptr+1))
1336 return-1;
1337 if (*(obj_tptr+1) < 2)
1338 return -1;
1339 print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
1340 obj_tlen-=*(obj_tptr+1);
1341 obj_tptr+=*(obj_tptr+1);
1342 }
1343 break;
1344 default:
1345 hexdump=TRUE;
1346 }
1347 break;
1348
1349 case RSVP_OBJ_MESSAGE_ID: /* fall through */
1350 case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */
1351 case RSVP_OBJ_MESSAGE_ID_LIST:
1352 switch(rsvp_obj_ctype) {
1353 case RSVP_CTYPE_1:
1354 if (obj_tlen < 8)
1355 return-1;
1356 printf("%s Flags [0x%02x], epoch: %u",
1357 ident,
1358 *obj_tptr,
1359 EXTRACT_24BITS(obj_tptr+1));
1360 obj_tlen-=4;
1361 obj_tptr+=4;
1362 /* loop through as long there are no messages left */
1363 while(obj_tlen >= 4) {
1364 printf("%s Message-ID 0x%08x (%u)",
1365 ident,
1366 EXTRACT_32BITS(obj_tptr),
1367 EXTRACT_32BITS(obj_tptr));
1368 obj_tlen-=4;
1369 obj_tptr+=4;
1370 }
1371 break;
1372 default:
1373 hexdump=TRUE;
1374 }
1375 break;
1376
1377 case RSVP_OBJ_INTEGRITY:
1378 switch(rsvp_obj_ctype) {
1379 case RSVP_CTYPE_1:
1380 if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
1381 return-1;
1382 obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
1383 printf("%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
1384 ident,
1385 EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id),
1386 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2),
1387 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence),
1388 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4),
1389 bittok2str(rsvp_obj_integrity_flag_values,
1390 "none",
1391 obj_ptr.rsvp_obj_integrity->flags));
1392 printf("%s MD5-sum 0x%08x%08x%08x%08x (unverified)",
1393 ident,
1394 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
1395 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
1396 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
1397 EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+12));
1398 obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
1399 obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
1400 break;
1401 default:
1402 hexdump=TRUE;
1403 }
1404 break;
1405
1406 /*
1407 * FIXME those are the defined objects that lack a decoder
1408 * you are welcome to contribute code ;-)
1409 */
1410
1411 case RSVP_OBJ_SCOPE:
1412 case RSVP_OBJ_POLICY_DATA:
1413 case RSVP_OBJ_LABEL_SET:
1414 case RSVP_OBJ_ACCEPT_LABEL_SET:
1415 case RSVP_OBJ_PROTECTION:
1416 default:
1417 if (vflag <= 1)
1418 print_unknown_data(obj_tptr,"\n\t ",obj_tlen); /* FIXME indentation */
1419 break;
1420 }
1421 /* do we also want to see a hex dump ? */
1422 if (vflag > 1 || hexdump==TRUE)
1423 print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t ", /* FIXME indentation */
1424 rsvp_obj_len-sizeof(struct rsvp_object_header));
1425
1426 tptr+=rsvp_obj_len;
1427 tlen-=rsvp_obj_len;
1428 }
1429 return 0;
1430 trunc:
1431 printf("\n\t\t packet exceeded snapshot");
1432 return -1;
1433 }
1434
1435
1436 void
1437 rsvp_print(register const u_char *pptr, register u_int len) {
1438
1439 const struct rsvp_common_header *rsvp_com_header;
1440 const u_char *tptr,*subtptr;
1441 u_short tlen,subtlen;
1442
1443 tptr=pptr;
1444
1445 rsvp_com_header = (const struct rsvp_common_header *)pptr;
1446 TCHECK(*rsvp_com_header);
1447
1448 /*
1449 * Sanity checking of the header.
1450 */
1451 if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1452 printf("ERROR: RSVP version %u packet not supported",
1453 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
1454 return;
1455 }
1456
1457 /* in non-verbose mode just lets print the basic Message Type*/
1458 if (vflag < 1) {
1459 printf("RSVPv%u %s Message, length: %u",
1460 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1461 tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
1462 len);
1463 return;
1464 }
1465
1466 /* ok they seem to want to know everything - lets fully decode it */
1467
1468 tlen=EXTRACT_16BITS(rsvp_com_header->length);
1469
1470 printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1471 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1472 tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1473 rsvp_com_header->msg_type,
1474 bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1475 tlen,
1476 rsvp_com_header->ttl,
1477 EXTRACT_16BITS(rsvp_com_header->checksum));
1478
1479 if (tlen < sizeof(const struct rsvp_common_header)) {
1480 printf("ERROR: common header too short %u < %lu", tlen,
1481 (unsigned long)sizeof(const struct rsvp_common_header));
1482 return;
1483 }
1484
1485 tptr+=sizeof(const struct rsvp_common_header);
1486 tlen-=sizeof(const struct rsvp_common_header);
1487
1488 switch(rsvp_com_header->msg_type) {
1489
1490 case RSVP_MSGTYPE_AGGREGATE:
1491 while(tlen > 0) {
1492 subtptr=tptr;
1493 rsvp_com_header = (const struct rsvp_common_header *)subtptr;
1494 TCHECK(*rsvp_com_header);
1495
1496 /*
1497 * Sanity checking of the header.
1498 */
1499 if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
1500 printf("ERROR: RSVP version %u packet not supported",
1501 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
1502 return;
1503 }
1504 subtlen=EXTRACT_16BITS(rsvp_com_header->length);
1505
1506 printf("\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
1507 RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
1508 tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
1509 rsvp_com_header->msg_type,
1510 bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
1511 subtlen,
1512 rsvp_com_header->ttl,
1513 EXTRACT_16BITS(rsvp_com_header->checksum));
1514
1515 if (subtlen < sizeof(const struct rsvp_common_header)) {
1516 printf("ERROR: common header too short %u < %lu", subtlen,
1517 (unsigned long)sizeof(const struct rsvp_common_header));
1518 return;
1519 }
1520
1521 if (tlen < subtlen) {
1522 printf("ERROR: common header too large %u > %u", subtlen,
1523 tlen);
1524 return;
1525 }
1526
1527 subtptr+=sizeof(const struct rsvp_common_header);
1528 subtlen-=sizeof(const struct rsvp_common_header);
1529
1530 if (rsvp_obj_print(subtptr,"\n\t ", subtlen) == -1)
1531 return;
1532
1533 tptr+=subtlen+sizeof(const struct rsvp_common_header);
1534 tlen-=subtlen+sizeof(const struct rsvp_common_header);
1535 }
1536
1537 break;
1538
1539 case RSVP_MSGTYPE_PATH:
1540 case RSVP_MSGTYPE_RESV:
1541 case RSVP_MSGTYPE_PATHERR:
1542 case RSVP_MSGTYPE_RESVERR:
1543 case RSVP_MSGTYPE_PATHTEAR:
1544 case RSVP_MSGTYPE_RESVTEAR:
1545 case RSVP_MSGTYPE_RESVCONF:
1546 case RSVP_MSGTYPE_HELLO_OLD:
1547 case RSVP_MSGTYPE_HELLO:
1548 case RSVP_MSGTYPE_ACK:
1549 case RSVP_MSGTYPE_SREFRESH:
1550 if (rsvp_obj_print(tptr,"\n\t ", tlen) == -1)
1551 return;
1552 break;
1553
1554 default:
1555 print_unknown_data(tptr,"\n\t ",tlen);
1556 break;
1557 }
1558
1559 return;
1560 trunc:
1561 printf("\n\t\t packet exceeded snapshot");
1562 }