2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
13 * Original code by Hannes Gredler (hannes@juniper.net)
17 static const char rcsid
[] =
18 "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.4 2002-10-18 13:53:42 hannes Exp $";
25 #include <tcpdump-stdinc.h>
30 #include "interface.h"
32 #include "addrtoname.h"
33 #include "ethertype.h"
36 * RFC 2205 common header
39 * +-------------+-------------+-------------+-------------+
40 * | Vers | Flags| Msg Type | RSVP Checksum |
41 * +-------------+-------------+-------------+-------------+
42 * | Send_TTL | (Reserved) | RSVP Length |
43 * +-------------+-------------+-------------+-------------+
47 struct rsvp_common_header
{
57 * RFC2205 object header
61 * +-------------+-------------+-------------+-------------+
62 * | Length (bytes) | Class-Num | C-Type |
63 * +-------------+-------------+-------------+-------------+
65 * // (Object contents) //
67 * +-------------+-------------+-------------+-------------+
70 struct rsvp_object_header
{
76 #define RSVP_VERSION 1
77 #define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
79 #define RSVP_MSGTYPE_PATH 1
80 #define RSVP_MSGTYPE_RESV 2
81 #define RSVP_MSGTYPE_PATHERR 3
82 #define RSVP_MSGTYPE_RESVERR 4
83 #define RSVP_MSGTYPE_PATHTEAR 5
84 #define RSVP_MSGTYPE_RESVTEAR 6
85 #define RSVP_MSGTYPE_RESVCONF 7
86 #define RSVP_MSGTYPE_AGGREGATE 12
87 #define RSVP_MSGTYPE_ACK 13
88 #define RSVP_MSGTYPE_HELLO_OLD 14 /* ancient Hellos */
89 #define RSVP_MSGTYPE_SREFRESH 15
90 #define RSVP_MSGTYPE_HELLO 20
92 static const struct tok rsvp_msg_type_values
[] = {
93 { RSVP_MSGTYPE_PATH
, "Path" },
94 { RSVP_MSGTYPE_RESV
, "Resv" },
95 { RSVP_MSGTYPE_PATHERR
, "PathErr" },
96 { RSVP_MSGTYPE_RESVERR
, "ResvErr" },
97 { RSVP_MSGTYPE_PATHTEAR
, "PathTear" },
98 { RSVP_MSGTYPE_RESVTEAR
, "ResvTear" },
99 { RSVP_MSGTYPE_RESVCONF
, "ResvConf" },
100 { RSVP_MSGTYPE_AGGREGATE
, "Aggregate" },
101 { RSVP_MSGTYPE_ACK
, "Acknowledgement" },
102 { RSVP_MSGTYPE_HELLO_OLD
, "Hello (Old)" },
103 { RSVP_MSGTYPE_SREFRESH
, "Refresh" },
104 { RSVP_MSGTYPE_HELLO
, "Hello" },
108 #define RSVP_OBJ_SESSION 1
109 #define RSVP_OBJ_RSVP_HOP 3
110 #define RSVP_OBJ_INTEGRITY 4
111 #define RSVP_OBJ_TIME_VALUES 5
112 #define RSVP_OBJ_ERROR_SPEC 6
113 #define RSVP_OBJ_SCOPE 7
114 #define RSVP_OBJ_STYLE 8
115 #define RSVP_OBJ_FLOWSPEC 9
116 #define RSVP_OBJ_FILTERSPEC 10
117 #define RSVP_OBJ_SENDER_TEMPLATE 11
118 #define RSVP_OBJ_SENDER_TSPEC 12
119 #define RSVP_OBJ_ADSPEC 13
120 #define RSVP_OBJ_POLICY_DATA 14
121 #define RSVP_OBJ_CONFIRM 15
122 #define RSVP_OBJ_LABEL 16
123 #define RSVP_OBJ_LABEL_REQ 19
124 #define RSVP_OBJ_ERO 20
125 #define RSVP_OBJ_RRO 21
126 #define RSVP_OBJ_HELLO 22
127 #define RSVP_OBJ_MESSAGE_ID 23
128 #define RSVP_OBJ_MESSAGE_ID_ACK 24
129 #define RSVP_OBJ_MESSAGE_ID_LIST 25
130 #define RSVP_OBJ_RECOVERY_LABEL 34
131 #define RSVP_OBJ_UPSTREAM_LABEL 35
132 #define RSVP_OBJ_DETOUR 63
133 #define RSVP_OBJ_SUGGESTED_LABEL 129
134 #define RSVP_OBJ_PROPERTIES 204
135 #define RSVP_OBJ_FASTREROUTE 205
136 #define RSVP_OBJ_SESSION_ATTRIBUTE 207 /* rfc3209 */
137 #define RSVP_OBJ_RESTART_CAPABILITY 131 /* draft-pan-rsvp-te-restart */
139 static const struct tok rsvp_obj_values
[] = {
140 { RSVP_OBJ_SESSION
, "Session" },
141 { RSVP_OBJ_RSVP_HOP
, "RSVP Hop" },
142 { RSVP_OBJ_INTEGRITY
, "Integrity" },
143 { RSVP_OBJ_TIME_VALUES
, "Time Values" },
144 { RSVP_OBJ_ERROR_SPEC
, "Error Spec" },
145 { RSVP_OBJ_SCOPE
, "Scope" },
146 { RSVP_OBJ_STYLE
, "Style" },
147 { RSVP_OBJ_FLOWSPEC
, "Flowspec" },
148 { RSVP_OBJ_FILTERSPEC
, "FilterSpec" },
149 { RSVP_OBJ_SENDER_TEMPLATE
, "Sender Template" },
150 { RSVP_OBJ_SENDER_TSPEC
, "Sender TSpec" },
151 { RSVP_OBJ_ADSPEC
, "Adspec" },
152 { RSVP_OBJ_POLICY_DATA
, "Policy Data" },
153 { RSVP_OBJ_CONFIRM
, "Confirm" },
154 { RSVP_OBJ_LABEL
, "Label" },
155 { RSVP_OBJ_LABEL_REQ
, "Label Request" },
156 { RSVP_OBJ_ERO
, "ERO" },
157 { RSVP_OBJ_RRO
, "RRO" },
158 { RSVP_OBJ_HELLO
, "Hello" },
159 { RSVP_OBJ_MESSAGE_ID
, "Message ID" },
160 { RSVP_OBJ_MESSAGE_ID_ACK
, "Message ID Ack" },
161 { RSVP_OBJ_MESSAGE_ID_LIST
, "Message ID List" },
162 { RSVP_OBJ_RECOVERY_LABEL
, "Recovery Label" },
163 { RSVP_OBJ_UPSTREAM_LABEL
, "Upstream Label" },
164 { RSVP_OBJ_DETOUR
, "Detour" },
165 { RSVP_OBJ_SUGGESTED_LABEL
, "Suggested Label" },
166 { RSVP_OBJ_PROPERTIES
, "Properties" },
167 { RSVP_OBJ_FASTREROUTE
, "Fast Re-Route" },
168 { RSVP_OBJ_SESSION_ATTRIBUTE
, "Session Attribute" },
169 { RSVP_OBJ_RESTART_CAPABILITY
, "Restart Capability" },
173 #define RSVP_CTYPE_IPV4 1
174 #define RSVP_CTYPE_IPV6 2
175 #define RSVP_CTYPE_TUNNEL_IPV4 7
176 #define RSVP_CTYPE_TUNNEL_IPV6 8
177 #define RSVP_CTYPE_1 1
178 #define RSVP_CTYPE_2 2
179 #define RSVP_CTYPE_3 3
182 * the ctypes are not globally unique so for
183 * translating it to strings we build a table based
184 * on objects offsetted by the ctype
187 static const struct tok rsvp_ctype_values
[] = {
188 { 256*RSVP_OBJ_SESSION
+RSVP_CTYPE_IPV4
, "IPv4" },
189 { 256*RSVP_OBJ_SESSION
+RSVP_CTYPE_IPV6
, "IPv6" },
190 { 256*RSVP_OBJ_SESSION
+RSVP_CTYPE_TUNNEL_IPV4
, "Tunnel IPv4" },
191 { 256*RSVP_OBJ_SENDER_TEMPLATE
+RSVP_CTYPE_TUNNEL_IPV4
, "Tunnel IPv4" },
192 { 256*RSVP_OBJ_STYLE
+RSVP_CTYPE_1
, "1" },
193 { 256*RSVP_OBJ_HELLO
+RSVP_CTYPE_1
, "Hello Request" },
194 { 256*RSVP_OBJ_HELLO
+RSVP_CTYPE_2
, "Hello Ack" },
195 { 256*RSVP_OBJ_LABEL_REQ
+RSVP_CTYPE_1
, "without label range" },
196 { 256*RSVP_OBJ_LABEL_REQ
+RSVP_CTYPE_2
, "with ATM label range" },
197 { 256*RSVP_OBJ_LABEL_REQ
+RSVP_CTYPE_3
, "with FR label range" },
198 { 256*RSVP_OBJ_LABEL
+RSVP_CTYPE_1
, "1" },
199 { 256*RSVP_OBJ_ERO
+RSVP_CTYPE_IPV4
, "IPv4" },
200 { 256*RSVP_OBJ_RRO
+RSVP_CTYPE_IPV4
, "IPv4" },
201 { 256*RSVP_OBJ_RESTART_CAPABILITY
+RSVP_CTYPE_1
, "IPv4" },
202 { 256*RSVP_OBJ_SESSION_ATTRIBUTE
+RSVP_CTYPE_TUNNEL_IPV4
, "Tunnel IPv4" },
206 #define RSVP_OBJ_XRO_MASK_SUBOBJ(x) ((x)&0x7f)
207 #define RSVP_OBJ_XRO_MASK_LOOSE(x) ((x)&0x80)
209 #define RSVP_OBJ_XRO_RES 0
210 #define RSVP_OBJ_XRO_IPV4 1
211 #define RSVP_OBJ_XRO_IPV6 2
212 #define RSVP_OBJ_XRO_ASN 32
213 #define RSVP_OBJ_XRO_MPLS 64
215 static const struct tok rsvp_obj_xro_values
[] = {
216 { RSVP_OBJ_XRO_RES
, "Reserved" },
217 { RSVP_OBJ_XRO_IPV4
, "IPv4 prefix" },
218 { RSVP_OBJ_XRO_IPV6
, "IPv6 prefix" },
219 { RSVP_OBJ_XRO_ASN
, "Autonomous system number" },
220 { RSVP_OBJ_XRO_MPLS
, "MPLS label switched path termination" },
224 static const struct tok rsvp_resstyle_values
[] = {
225 { 17, "Wildcard Filter" },
226 { 10, "Fixed Filter" },
227 { 18, "Shared Explicit" },
231 static struct tok rsvp_session_attribute_flag_values
[] = {
232 { 1, "Local Protection desired" },
233 { 2, "Label Recording desired" },
234 { 4, "SE Style desired" },
242 rsvp_print(register const u_char
*pptr
, register u_int len
) {
244 const struct rsvp_common_header
*rsvp_com_header
;
245 const struct rsvp_object_header
*rsvp_obj_header
;
246 const u_char
*tptr
,*obj_tptr
;
247 u_short tlen
,rsvp_obj_len
,rsvp_obj_ctype
,obj_tlen
;
251 rsvp_com_header
= (const struct rsvp_common_header
*)pptr
;
252 TCHECK(*rsvp_com_header
);
255 * Sanity checking of the header.
257 if (RSVP_EXTRACT_VERSION(rsvp_com_header
->version_flags
) != RSVP_VERSION
) {
258 printf("RSVP version %u packet not supported",
259 RSVP_EXTRACT_VERSION(rsvp_com_header
->version_flags
));
263 /* in non-verbose mode just lets print the basic Message Type*/
265 printf("RSVP %s Message, length: %u",
266 tok2str(rsvp_msg_type_values
, "unknown (%u)",rsvp_com_header
->msg_type
),
271 /* ok they seem to want to know everything - lets fully decode it */
273 printf("RSVP, length: %u",len
);
275 tlen
=EXTRACT_16BITS(rsvp_com_header
->length
);
277 printf("\n\tv: %u, msg-type: %s, length: %u, ttl: %u, checksum: 0x%04x",
278 RSVP_EXTRACT_VERSION(rsvp_com_header
->version_flags
),
279 tok2str(rsvp_msg_type_values
, "unknown, type: %u",rsvp_com_header
->msg_type
),
281 rsvp_com_header
->ttl
,
282 EXTRACT_16BITS(rsvp_com_header
->checksum
));
284 tptr
+=sizeof(const struct rsvp_common_header
);
285 tlen
-=sizeof(const struct rsvp_common_header
);
288 /* did we capture enough for fully decoding the object header ? */
289 if (!TTEST2(*tptr
, sizeof(struct rsvp_object_header
)))
292 rsvp_obj_header
= (const struct rsvp_object_header
*)tptr
;
293 rsvp_obj_len
=EXTRACT_16BITS(rsvp_obj_header
->length
);
294 rsvp_obj_ctype
=rsvp_obj_header
->ctype
;
296 if(rsvp_obj_len
% 4 || rsvp_obj_len
< 4)
299 printf("\n\t %s Object (%u) flags: [%s",
300 tok2str(rsvp_obj_values
,
302 rsvp_obj_header
->class_num
),
303 rsvp_obj_header
->class_num
,
304 ((rsvp_obj_header
->class_num
)&0x80) ? "ignore" : "reject");
306 if (rsvp_obj_header
->class_num
> 128)
308 ((rsvp_obj_header
->class_num
)&0x40) ? "and forward" : "silently");
310 printf(" if unknown], Class-Type: %s (%u), length: %u",
311 tok2str(rsvp_ctype_values
,
313 ((rsvp_obj_header
->class_num
)<<8)+rsvp_obj_ctype
),
317 obj_tptr
=tptr
+sizeof(struct rsvp_object_header
);
318 obj_tlen
=rsvp_obj_len
-sizeof(struct rsvp_object_header
);
320 /* did we capture enough for fully decoding the object ? */
321 if (!TTEST2(*tptr
, rsvp_obj_len
))
325 switch(rsvp_obj_header
->class_num
) {
326 case RSVP_OBJ_SESSION
:
327 switch(rsvp_obj_ctype
) {
328 case RSVP_CTYPE_IPV4
:
329 printf("\n\t IPv4 DestAddress: %s, Protocol ID: 0x%02x",
330 ipaddr_string(obj_tptr
),
332 printf("\n\t Flags: 0x%02x, DestPort %u",
334 EXTRACT_16BITS(obj_tptr
+6));
339 case RSVP_CTYPE_IPV6
:
340 printf("\n\t IPv6 DestAddress: %s, Protocol ID: 0x%02x",
341 ip6addr_string(obj_tptr
),
343 printf("\n\t Flags: 0x%02x, DestPort %u",
345 EXTRACT_16BITS(obj_tptr
+18));
349 case RSVP_CTYPE_TUNNEL_IPV6
:
350 printf("\n\t IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
351 ip6addr_string(obj_tptr
),
352 EXTRACT_16BITS(obj_tptr
+18),
353 ip6addr_string(obj_tptr
+20));
358 case RSVP_CTYPE_TUNNEL_IPV4
:
359 printf("\n\t IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
360 ipaddr_string(obj_tptr
),
361 EXTRACT_16BITS(obj_tptr
+6),
362 ipaddr_string(obj_tptr
+8));
371 switch(rsvp_obj_ctype
) {
373 while(obj_tlen
>= 4 ) {
374 printf("\n\t Label: %u", EXTRACT_32BITS(obj_tptr
));
384 switch(rsvp_obj_ctype
) {
386 printf("\n\t Reservation Style: %s, Flags: 0x%02x",
387 tok2str(rsvp_resstyle_values
,
389 EXTRACT_24BITS(obj_tptr
+1)),
398 case RSVP_OBJ_SENDER_TEMPLATE
:
399 switch(rsvp_obj_ctype
) {
400 case RSVP_CTYPE_TUNNEL_IPV4
:
401 printf("\n\t IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
402 ipaddr_string(obj_tptr
),
403 EXTRACT_16BITS(obj_tptr
+6));
411 case RSVP_OBJ_LABEL_REQ
:
412 switch(rsvp_obj_ctype
) {
414 while(obj_tlen
>= 4 ) {
415 printf("\n\t L3 Protocol ID: %s",
416 tok2str(ethertype_values
,
417 "Unknown Protocol 0x%04x",
418 EXTRACT_16BITS(obj_tptr
+2)));
424 printf("\n\t L3 Protocol ID: %s",
425 tok2str(ethertype_values
,
426 "Unknown Protocol 0x%04x",
427 EXTRACT_16BITS(obj_tptr
+2)));
428 printf(",%s merge capability",((*(obj_tptr
+4))&0x80) ? "no" : "" );
429 printf("\n\t Minimum VPI/VCI %u/%u",
430 (EXTRACT_16BITS(obj_tptr
+4))&0xfff,
431 (EXTRACT_16BITS(obj_tptr
+6))&0xfff);
432 printf("\n\t Maximum VPI/VCI %u/%u",
433 (EXTRACT_16BITS(obj_tptr
+8))&0xfff,
434 (EXTRACT_16BITS(obj_tptr
+10))&0xfff);
439 printf("\n\t L3 Protocol ID: %s",
440 tok2str(ethertype_values
,
441 "Unknown Protocol 0x%04x",
442 EXTRACT_16BITS(obj_tptr
+2)));
443 printf("\n\t Minimum/Maximum DLCI %u/%u, %s%s bit DLCI",
444 (EXTRACT_32BITS(obj_tptr
+4))&0x7fffff,
445 (EXTRACT_32BITS(obj_tptr
+8))&0x7fffff,
446 (((EXTRACT_16BITS(obj_tptr
+4)>>7)&3) == 0 ) ? "10" : "",
447 (((EXTRACT_16BITS(obj_tptr
+4)>>7)&3) == 2 ) ? "23" : "");
457 switch(rsvp_obj_ctype
) {
458 case RSVP_CTYPE_IPV4
:
459 while(obj_tlen
>= 4 ) {
460 printf("\n\t Subobject Type: %s",
461 tok2str(rsvp_obj_xro_values
,
463 RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr
)));
464 switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr
)) {
465 case RSVP_OBJ_XRO_IPV4
:
466 printf(", %s, %s/%u",
467 RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr
) ? "Loose" : "Strict",
468 ipaddr_string(obj_tptr
+2),
471 obj_tlen
-=*(obj_tptr
+1);
472 obj_tptr
+=*(obj_tptr
+1);
480 switch(rsvp_obj_ctype
) {
483 printf("\n\t Source Instance 0x%08x, Destination Instance 0x%08x",
484 EXTRACT_32BITS(obj_tptr
),
485 EXTRACT_32BITS(obj_tptr
+4));
493 case RSVP_OBJ_RESTART_CAPABILITY
:
494 switch(rsvp_obj_ctype
) {
496 printf("\n\t Restart Time: %ums\n\t Recovery Time: %ums",
497 EXTRACT_16BITS(obj_tptr
),
498 EXTRACT_16BITS(obj_tptr
+4));
504 case RSVP_OBJ_SESSION_ATTRIBUTE
:
505 switch(rsvp_obj_ctype
) {
506 case RSVP_CTYPE_TUNNEL_IPV4
:
507 printf("\n\t Session Name: %s",(obj_tptr
+3));
508 printf("\n\t Setup Priority: %u, Holding Priority: %u, Flags: [%s]",
511 tok2str(rsvp_session_attribute_flag_values
,
515 obj_tptr
+=4+*(obj_tptr
+3);
522 * FIXME those are the defined objects that lack a decoder
523 * you are welcome to contribute code ;-)
525 case RSVP_OBJ_RSVP_HOP
:
526 case RSVP_OBJ_INTEGRITY
:
527 case RSVP_OBJ_TIME_VALUES
:
528 case RSVP_OBJ_ERROR_SPEC
:
530 case RSVP_OBJ_FILTERSPEC
:
531 case RSVP_OBJ_SENDER_TSPEC
:
532 case RSVP_OBJ_ADSPEC
:
533 case RSVP_OBJ_POLICY_DATA
:
534 case RSVP_OBJ_CONFIRM
:
535 case RSVP_OBJ_MESSAGE_ID
:
536 case RSVP_OBJ_MESSAGE_ID_ACK
:
537 case RSVP_OBJ_MESSAGE_ID_LIST
:
538 case RSVP_OBJ_RECOVERY_LABEL
:
539 case RSVP_OBJ_UPSTREAM_LABEL
:
540 case RSVP_OBJ_DETOUR
:
541 case RSVP_OBJ_SUGGESTED_LABEL
:
542 case RSVP_OBJ_PROPERTIES
:
543 case RSVP_OBJ_FASTREROUTE
:
546 print_unknown_data(obj_tptr
,"\n\t ",obj_tlen
);
549 /* do we want to see an additionally hexdump ? */
550 if (vflag
> 1 || hexdump
==TRUE
)
551 print_unknown_data(tptr
+sizeof(sizeof(struct rsvp_object_header
)),"\n\t ",
552 rsvp_obj_len
-sizeof(struct rsvp_object_header
));
559 printf("\n\t\t packet exceeded snapshot");