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
[] _U_
=
18 "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.7 2004-06-15 08:17:19 hannes Exp $";
25 #include <tcpdump-stdinc.h>
31 #include "interface.h"
33 #include "addrtoname.h"
37 * LSPPING common header
40 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Version Number | Must Be Zero |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Message Type | Reply mode | Return Code | Return Subcode|
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | TimeStamp Sent (seconds) |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | TimeStamp Sent (microseconds) |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * | TimeStamp Received (seconds) |
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * | TimeStamp Received (microseconds) |
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 struct lspping_common_header
{
70 u_int8_t return_subcode
;
71 u_int8_t sender_handle
[4];
72 u_int8_t seq_number
[4];
73 u_int8_t ts_sent_sec
[4];
74 u_int8_t ts_sent_usec
[4];
75 u_int8_t ts_rcvd_sec
[4];
76 u_int8_t ts_rcvd_usec
[4];
79 #define LSPPING_VERSION 1
83 static const struct tok lspping_msg_type_values
[] = {
84 { 1, "MPLS Echo Request"},
85 { 2, "MPLS Echo Reply"},
89 static const struct tok lspping_reply_mode_values
[] = {
91 { 2, "Reply via an IPv4/IPv6 UDP packet"},
92 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
93 { 4, "Reply via application level control channel"},
97 static const struct tok lspping_return_code_values
[] = {
98 { 0, "No return code or return code contained in the Error Code TLV"},
99 { 1, "Malformed echo request received"},
100 { 2, "One or more of the TLVs was not understood"},
101 { 3, "Replying router is an egress for the FEC at stack depth"},
102 { 4, "Replying router has no mapping for the FEC at stack depth"},
106 { 8, "Label switched at stack-depth"},
107 { 9, "Label switched but no MPLS forwarding at stack-depth"},
108 { 10, "Mapping for this FEC is not the given label at stack depth"},
109 { 11, "No label entry at stack-depth"},
110 { 12, "Protocol not associated with interface at FEC stack depth"},
117 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 struct lspping_tlv_header
{
134 #define LSPPING_TLV_TARGET_FEC_STACK 1
135 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
136 #define LSPPING_TLV_PAD 3
137 #define LSPPING_TLV_ERROR_CODE 4
138 #define LSPPING_TLV_VENDOR_PRIVATE 5
140 static const struct tok lspping_tlv_values
[] = {
141 { LSPPING_TLV_TARGET_FEC_STACK
, "Target FEC Stack" },
142 { LSPPING_TLV_DOWNSTREAM_MAPPING
, "Downstream Mapping" },
143 { LSPPING_TLV_PAD
, "Pad" },
144 { LSPPING_TLV_ERROR_CODE
, "Error Code" },
145 { LSPPING_TLV_VENDOR_PRIVATE
, "Vendor Enterprise Code" },
149 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
150 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
151 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
152 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
153 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
154 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
155 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
156 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 9
157 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 10
158 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 11
160 static const struct tok lspping_tlvtargetfec_subtlv_values
[] = {
161 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
, "LDP IPv4 prefix"},
162 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
, "LDP IPv6 prefix"},
163 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
, "RSVP IPv4 Session Query"},
164 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
, "RSVP IPv6 Session Query"},
166 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
, "VPN IPv4 prefix"},
167 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
, "VPN IPv6 prefix"},
168 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
, "L2 VPN endpoint"},
169 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
, "L2 circuit ID"},
170 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
, "BGP labeled IPv4 prefix"},
171 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
, "BGP labeled IPv6 prefix"},
177 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
178 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
180 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
181 * | Prefix Length | Must Be Zero |
182 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
184 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
{
191 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 * | Prefix Length | Must Be Zero |
199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
{
202 u_int8_t prefix
[16];
207 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
208 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
209 * | Sender identifier |
210 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213 * | Prefix Length | Must Be Zero |
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
{
217 u_int8_t sender_id
[4];
223 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 * | Sender identifier |
229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
234 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
235 * | Prefix Length | Must Be Zero |
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
{
239 u_int8_t sender_id
[16];
240 u_int8_t prefix
[16];
246 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
247 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
248 * | IPv4 tunnel end point address |
249 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
250 * | Must Be Zero | Tunnel ID |
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252 * | Extended Tunnel ID |
253 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
254 * | IPv4 tunnel sender address |
255 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256 * | Must Be Zero | LSP ID |
257 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
{
260 u_int8_t tunnel_endpoint
[4];
262 u_int8_t tunnel_id
[2];
263 u_int8_t extended_tunnel_id
[4];
264 u_int8_t tunnel_sender
[4];
271 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
272 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273 * | IPv6 tunnel end point address |
277 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
278 * | Must Be Zero | Tunnel ID |
279 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
280 * | Extended Tunnel ID |
284 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
285 * | IPv6 tunnel sender address |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | Must Be Zero | LSP ID |
291 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
{
294 u_int8_t tunnel_endpoint
[16];
296 u_int8_t tunnel_id
[2];
297 u_int8_t extended_tunnel_id
[16];
298 u_int8_t tunnel_sender
[16];
305 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
306 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307 * | Route Distinguisher |
309 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
312 * | Prefix Length | Must Be Zero |
313 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
315 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
{
323 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
324 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
325 * | Route Distinguisher |
327 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
332 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
333 * | Prefix Length | Must Be Zero |
334 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
336 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
{
338 u_int8_t prefix
[16];
344 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
345 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
346 * | Route Distinguisher |
348 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
349 * | Sender's CE ID | Receiver's CE ID |
350 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351 * | Encapsulation Type | Must Be Zero |
352 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
355 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
{
357 u_int8_t sender_ce_id
[2];
358 u_int8_t receiver_ce_id
[2];
359 u_int8_t encapsulation
[2];
363 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
364 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365 * | Sender's PE Address |
366 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367 * | Remote PE Address |
368 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371 * | Encapsulation Type | Must Be Zero |
372 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
{
375 u_int8_t sender_pe_address
[4];
376 u_int8_t remote_pe_address
[4];
378 u_int8_t encapsulation
[2];
382 lspping_print(register const u_char
*pptr
, register u_int len
) {
384 const struct lspping_common_header
*lspping_com_header
;
385 const struct lspping_tlv_header
*lspping_tlv_header
;
386 const struct lspping_tlv_header
*lspping_subtlv_header
;
387 const u_char
*tptr
,*tlv_tptr
,*subtlv_tptr
;
388 int tlen
,lspping_tlv_len
,lspping_tlv_type
,tlv_tlen
;
389 int tlv_hexdump
,subtlv_hexdump
;
390 int lspping_subtlv_len
,lspping_subtlv_type
;
393 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*lspping_tlv_targetfec_subtlv_ldp_ipv4
;
394 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*lspping_tlv_targetfec_subtlv_ldp_ipv6
;
395 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv4
;
396 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv6
;
397 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv4
;
398 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv6
;
399 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*lspping_tlv_targetfec_subtlv_l2vpn_endpt
;
400 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*lspping_tlv_targetfec_subtlv_l2vpn_vcid
;
401 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*lspping_tlv_targetfec_subtlv_bgp_ipv4
;
402 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*lspping_tlv_targetfec_subtlv_bgp_ipv6
;
406 lspping_com_header
= (const struct lspping_common_header
*)pptr
;
407 TCHECK(*lspping_com_header
);
410 * Sanity checking of the header.
412 if (EXTRACT_16BITS(&lspping_com_header
->version
[0]) != LSPPING_VERSION
) {
413 printf("LSP-PING version %u packet not supported",
414 EXTRACT_16BITS(&lspping_com_header
->version
[0]));
418 /* in non-verbose mode just lets print the basic Message Type*/
420 printf("LSP-PINGv%u, %s, seq %u, length: %u",
421 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
422 tok2str(lspping_msg_type_values
, "unknown (%u)",lspping_com_header
->msg_type
),
423 EXTRACT_32BITS(lspping_com_header
->seq_number
),
428 /* ok they seem to want to know everything - lets fully decode it */
432 printf("\n\tLSP-PINGv%u, msg-type: %s (%u), reply-mode: %s (%u)",
433 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
434 tok2str(lspping_msg_type_values
, "unknown",lspping_com_header
->msg_type
),
435 lspping_com_header
->msg_type
,
436 tok2str(lspping_reply_mode_values
, "unknown",lspping_com_header
->reply_mode
),
437 lspping_com_header
->reply_mode
);
440 * the following return codes require that the subcode is attached
441 * at the end of the translated token output
443 if (lspping_com_header
->return_code
== 3 ||
444 lspping_com_header
->return_code
== 4 ||
445 lspping_com_header
->return_code
== 8 ||
446 lspping_com_header
->return_code
== 10 ||
447 lspping_com_header
->return_code
== 11 ||
448 lspping_com_header
->return_code
== 12 )
449 printf("\n\t Return Code: %s %u (%u), Return Subcode: (%u)",
450 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
451 lspping_com_header
->return_subcode
,
452 lspping_com_header
->return_code
,
453 lspping_com_header
->return_subcode
);
455 printf("\n\t Return Code: %s (%u), Return Subcode: (%u)",
456 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
457 lspping_com_header
->return_code
,
458 lspping_com_header
->return_subcode
);
460 printf("\n\t Sender Handle: 0x%08x, Sequence: %u" \
461 "\n\t Sender Timestamp %u.%us, Receiver Timestamp %u.%us",
462 EXTRACT_32BITS(lspping_com_header
->sender_handle
),
463 EXTRACT_32BITS(lspping_com_header
->seq_number
),
464 EXTRACT_32BITS(lspping_com_header
->ts_sent_sec
), /* FIXME: replace with ts_print() */
465 EXTRACT_32BITS(lspping_com_header
->ts_sent_usec
),
466 EXTRACT_32BITS(lspping_com_header
->ts_rcvd_sec
), /* FIXME: replace with ts_print() */
467 EXTRACT_32BITS(lspping_com_header
->ts_rcvd_usec
));
469 tptr
+=sizeof(const struct lspping_common_header
);
470 tlen
-=sizeof(const struct lspping_common_header
);
472 while(tlen
>(int)sizeof(struct lspping_tlv_header
)) {
473 /* did we capture enough for fully decoding the tlv header ? */
474 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
477 lspping_tlv_header
= (const struct lspping_tlv_header
*)tptr
;
478 lspping_tlv_type
=EXTRACT_16BITS(lspping_tlv_header
->type
);
479 lspping_tlv_len
=EXTRACT_16BITS(lspping_tlv_header
->length
);
481 if (lspping_tlv_len
== 0)
484 if(lspping_tlv_len
% 4 || lspping_tlv_len
< 4) { /* aligned to four octet boundary */
485 printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type
,lspping_tlv_len
);
489 printf("\n\t %s TLV (%u), length: %u",
490 tok2str(lspping_tlv_values
,
496 tlv_tptr
=tptr
+sizeof(struct lspping_tlv_header
);
497 tlv_tlen
=lspping_tlv_len
; /* header not included -> no adjustment */
499 /* did we capture enough for fully decoding the tlv ? */
500 if (!TTEST2(*tptr
, lspping_tlv_len
))
504 switch(lspping_tlv_type
) {
505 case LSPPING_TLV_TARGET_FEC_STACK
:
506 while(tlv_tlen
>(int)sizeof(struct lspping_tlv_header
)) {
508 /* did we capture enough for fully decoding the subtlv header ? */
509 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
511 subtlv_hexdump
=FALSE
;
513 lspping_subtlv_header
= (const struct lspping_tlv_header
*)tlv_tptr
;
514 lspping_subtlv_type
=EXTRACT_16BITS(lspping_subtlv_header
->type
);
515 lspping_subtlv_len
=EXTRACT_16BITS(lspping_subtlv_header
->length
);
516 subtlv_tptr
=tlv_tptr
+sizeof(struct lspping_tlv_header
);
518 if (lspping_subtlv_len
== 0)
521 printf("\n\t %s subTLV (%u), length: %u",
522 tok2str(lspping_tlvtargetfec_subtlv_values
,
524 lspping_subtlv_type
),
528 switch(lspping_subtlv_type
) {
530 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
:
531 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
= \
532 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*)subtlv_tptr
;
534 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix
),
535 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix_len
);
539 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
:
540 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
= \
541 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*)subtlv_tptr
;
543 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix
),
544 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix_len
);
548 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
:
549 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
= \
550 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*)subtlv_tptr
;
551 printf("\n\t %s/%u, sender-id %s",
552 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix
),
553 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix_len
,
554 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->sender_id
));
558 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
:
559 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
= \
560 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*)subtlv_tptr
;
561 printf("\n\t %s/%u, sender-id %s",
562 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix
),
563 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix_len
,
564 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->sender_id
));
568 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
:
569 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
= \
570 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*)subtlv_tptr
;
571 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
572 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
573 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_endpoint
),
574 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_sender
),
575 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->lsp_id
),
576 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_id
),
577 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->extended_tunnel_id
));
581 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
:
582 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
= \
583 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*)subtlv_tptr
;
584 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
585 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
586 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_endpoint
),
587 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_sender
),
588 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->lsp_id
),
589 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_id
),
590 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->extended_tunnel_id
));
594 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
:
595 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
= \
596 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*)subtlv_tptr
;
597 printf("\n\t RD: %s, %s/%u",
598 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->rd
),
599 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix
),
600 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix_len
);
604 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
:
605 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
= \
606 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*)subtlv_tptr
;
607 printf("\n\t RD: %s, %s/%u",
608 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->rd
),
609 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix
),
610 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix_len
);
614 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
:
615 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
= \
616 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*)subtlv_tptr
;
617 printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
618 "\n\t Encapsulation Type: %s (%u)",
619 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->rd
),
620 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->sender_ce_id
),
621 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->receiver_ce_id
),
622 tok2str(bgp_l2vpn_encaps_values
,
624 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
)),
625 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
));
629 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
:
630 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
= \
631 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*)subtlv_tptr
;
632 printf("\n\t Sender PE: %s, Remote PE: %s" \
633 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
634 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->sender_pe_address
),
635 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->remote_pe_address
),
636 EXTRACT_32BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->vc_id
),
637 tok2str(bgp_l2vpn_encaps_values
, /* FIXME are the L2 encaps codepoints of BGP == LDP ??? */
639 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
)),
640 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
));
645 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
648 /* do we want to see an additionally subtlv hexdump ? */
649 if (vflag
> 1 || subtlv_hexdump
==TRUE
)
650 print_unknown_data(tlv_tptr
+sizeof(struct lspping_tlv_header
), \
654 tlv_tptr
+=lspping_subtlv_len
;
655 tlv_tlen
-=lspping_subtlv_len
+sizeof(struct lspping_tlv_header
);
660 * FIXME those are the defined TLVs that lack a decoder
661 * you are welcome to contribute code ;-)
664 case LSPPING_TLV_DOWNSTREAM_MAPPING
:
665 case LSPPING_TLV_PAD
:
666 case LSPPING_TLV_ERROR_CODE
:
667 case LSPPING_TLV_VENDOR_PRIVATE
:
671 print_unknown_data(tlv_tptr
,"\n\t ",tlv_tlen
);
674 /* do we want to see an additionally tlv hexdump ? */
675 if (vflag
> 1 || tlv_hexdump
==TRUE
)
676 print_unknown_data(tptr
+sizeof(sizeof(struct lspping_tlv_header
)),"\n\t ",
679 tptr
+=lspping_tlv_len
;
680 tlen
-=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
684 printf("\n\t\t packet exceeded snapshot");