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.12.2.4 2006-02-01 14:40:39 hannes Exp $";
25 #include <tcpdump-stdinc.h>
31 #include "interface.h"
33 #include "addrtoname.h"
39 * LSPPING common header
42 * 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
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | Version Number | Must Be Zero |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | Message Type | Reply mode | Return Code | Return Subcode|
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | TimeStamp Sent (seconds) |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * | TimeStamp Sent (microseconds) |
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * | TimeStamp Received (seconds) |
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * | TimeStamp Received (microseconds) |
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 struct lspping_common_header
{
72 u_int8_t return_subcode
;
73 u_int8_t sender_handle
[4];
74 u_int8_t seq_number
[4];
75 u_int8_t ts_sent_sec
[4];
76 u_int8_t ts_sent_usec
[4];
77 u_int8_t ts_rcvd_sec
[4];
78 u_int8_t ts_rcvd_usec
[4];
81 #define LSPPING_VERSION 1
85 static const struct tok lspping_msg_type_values
[] = {
86 { 1, "MPLS Echo Request"},
87 { 2, "MPLS Echo Reply"},
91 static const struct tok lspping_reply_mode_values
[] = {
93 { 2, "Reply via an IPv4/IPv6 UDP packet"},
94 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
95 { 4, "Reply via application level control channel"},
99 static const struct tok lspping_return_code_values
[] = {
100 { 0, "No return code or return code contained in the Error Code TLV"},
101 { 1, "Malformed echo request received"},
102 { 2, "One or more of the TLVs was not understood"},
103 { 3, "Replying router is an egress for the FEC at stack depth"},
104 { 4, "Replying router has no mapping for the FEC at stack depth"},
108 { 8, "Label switched at stack-depth"},
109 { 9, "Label switched but no MPLS forwarding at stack-depth"},
110 { 10, "Mapping for this FEC is not the given label at stack depth"},
111 { 11, "No label entry at stack-depth"},
112 { 12, "Protocol not associated with interface at FEC stack depth"},
119 * 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
120 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 struct lspping_tlv_header
{
136 #define LSPPING_TLV_TARGET_FEC_STACK 1
137 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
138 #define LSPPING_TLV_PAD 3
139 #define LSPPING_TLV_ERROR_CODE 4
140 #define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
141 #define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
143 static const struct tok lspping_tlv_values
[] = {
144 { LSPPING_TLV_TARGET_FEC_STACK
, "Target FEC Stack" },
145 { LSPPING_TLV_DOWNSTREAM_MAPPING
, "Downstream Mapping" },
146 { LSPPING_TLV_PAD
, "Pad" },
147 { LSPPING_TLV_ERROR_CODE
, "Error Code" },
148 { LSPPING_TLV_BFD_DISCRIMINATOR
, "BFD Discriminator" },
149 { LSPPING_TLV_VENDOR_PRIVATE
, "Vendor Enterprise Code" },
153 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
154 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
155 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
156 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
157 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
158 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
159 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
160 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
161 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10
162 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11
163 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12
165 static const struct tok lspping_tlvtargetfec_subtlv_values
[] = {
166 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
, "LDP IPv4 prefix"},
167 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
, "LDP IPv6 prefix"},
168 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
, "RSVP IPv4 Session Query"},
169 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
, "RSVP IPv6 Session Query"},
171 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
, "VPN IPv4 prefix"},
172 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
, "VPN IPv6 prefix"},
173 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
, "L2 VPN endpoint"},
174 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD
, "L2 circuit ID (old)"},
175 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
, "L2 circuit ID"},
176 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
, "BGP labeled IPv4 prefix"},
177 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
, "BGP labeled IPv6 prefix"},
183 * 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
184 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
186 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187 * | Prefix Length | Must Be Zero |
188 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
190 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
{
197 * 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
198 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
204 * | Prefix Length | Must Be Zero |
205 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
207 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
{
208 u_int8_t prefix
[16];
213 * 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
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 * | Sender identifier |
216 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219 * | Prefix Length | Must Be Zero |
220 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
222 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
{
223 u_int8_t sender_id
[4];
229 * 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
230 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
231 * | Sender identifier |
235 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
241 * | Prefix Length | Must Be Zero |
242 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
244 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
{
245 u_int8_t sender_id
[16];
246 u_int8_t prefix
[16];
252 * 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
253 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
254 * | IPv4 tunnel end point address |
255 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256 * | Must Be Zero | Tunnel ID |
257 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258 * | Extended Tunnel ID |
259 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
260 * | IPv4 tunnel sender address |
261 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
262 * | Must Be Zero | LSP ID |
263 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
{
266 u_int8_t tunnel_endpoint
[4];
268 u_int8_t tunnel_id
[2];
269 u_int8_t extended_tunnel_id
[4];
270 u_int8_t tunnel_sender
[4];
277 * 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
278 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
279 * | IPv6 tunnel end point address |
283 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
284 * | Must Be Zero | Tunnel ID |
285 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286 * | Extended Tunnel ID |
290 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
291 * | IPv6 tunnel sender address |
295 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
296 * | Must Be Zero | LSP ID |
297 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
299 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
{
300 u_int8_t tunnel_endpoint
[16];
302 u_int8_t tunnel_id
[2];
303 u_int8_t extended_tunnel_id
[16];
304 u_int8_t tunnel_sender
[16];
311 * 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
312 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
313 * | Route Distinguisher |
315 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
317 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318 * | Prefix Length | Must Be Zero |
319 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
321 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
{
329 * 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
330 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
331 * | Route Distinguisher |
333 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
338 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
339 * | Prefix Length | Must Be Zero |
340 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
342 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
{
344 u_int8_t prefix
[16];
350 * 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
351 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
352 * | Route Distinguisher |
354 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
355 * | Sender's CE ID | Receiver's CE ID |
356 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357 * | Encapsulation Type | Must Be Zero |
358 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
{
363 u_int8_t sender_ce_id
[2];
364 u_int8_t receiver_ce_id
[2];
365 u_int8_t encapsulation
[2];
369 * 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
370 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371 * | Remote PE Address |
372 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375 * | Encapsulation Type | Must Be Zero |
376 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
378 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
{
379 u_int8_t remote_pe_address
[4];
381 u_int8_t encapsulation
[2];
385 * 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
386 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
387 * | Sender's PE Address |
388 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
389 * | Remote PE Address |
390 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
392 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
393 * | Encapsulation Type | Must Be Zero |
394 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
396 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
{
397 u_int8_t sender_pe_address
[4];
398 u_int8_t remote_pe_address
[4];
400 u_int8_t encapsulation
[2];
405 * 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
406 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
407 * | MTU | Address Type | Resvd (SBZ) |
408 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
409 * | Downstream IP Address (4 or 16 octets) |
410 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
411 * | Downstream Interface Address (4 or 16 octets) |
412 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
413 * | Hash Key Type | Depth Limit | Multipath Length |
414 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
416 * . (Multipath Information) .
418 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
419 * | Downstream Label | Protocol |
420 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
425 * | Downstream Label | Protocol |
426 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
428 struct lspping_tlv_downstream_map_ipv4_t
{
430 u_int8_t address_type
;
432 u_int8_t downstream_ip
[4];
433 u_int8_t downstream_interface
[4];
436 struct lspping_tlv_downstream_map_ipv6_t
{
438 u_int8_t address_type
;
440 u_int8_t downstream_ip
[16];
441 u_int8_t downstream_interface
[16];
444 struct lspping_tlv_downstream_map_info_t
{
445 u_int8_t hash_key_type
;
446 u_int8_t depth_limit
;
447 u_int8_t multipath_length
[2];
450 #define LSPPING_AFI_IPV4 1
451 #define LSPPING_AFI_UNMB 2
452 #define LSPPING_AFI_IPV6 3
454 static const struct tok lspping_tlv_downstream_addr_values
[] = {
455 { LSPPING_AFI_IPV4
, "IPv4"},
456 { LSPPING_AFI_IPV6
, "IPv6"},
457 { LSPPING_AFI_UNMB
, "Unnumbered"},
462 lspping_print(register const u_char
*pptr
, register u_int len
) {
464 const struct lspping_common_header
*lspping_com_header
;
465 const struct lspping_tlv_header
*lspping_tlv_header
;
466 const struct lspping_tlv_header
*lspping_subtlv_header
;
467 const u_char
*tptr
,*tlv_tptr
,*subtlv_tptr
;
468 int tlen
,lspping_tlv_len
,lspping_tlv_type
,tlv_tlen
;
469 int tlv_hexdump
,subtlv_hexdump
;
470 int lspping_subtlv_len
,lspping_subtlv_type
;
471 struct timeval timestamp
;
474 const struct lspping_tlv_downstream_map_ipv4_t
*lspping_tlv_downstream_map_ipv4
;
475 const struct lspping_tlv_downstream_map_ipv6_t
*lspping_tlv_downstream_map_ipv6
;
476 const struct lspping_tlv_downstream_map_info_t
*lspping_tlv_downstream_map_info
;
480 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*lspping_tlv_targetfec_subtlv_ldp_ipv4
;
481 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*lspping_tlv_targetfec_subtlv_ldp_ipv6
;
482 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv4
;
483 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv6
;
484 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv4
;
485 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv6
;
486 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*lspping_tlv_targetfec_subtlv_l2vpn_endpt
;
487 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
*lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
;
488 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*lspping_tlv_targetfec_subtlv_l2vpn_vcid
;
489 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*lspping_tlv_targetfec_subtlv_bgp_ipv4
;
490 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*lspping_tlv_targetfec_subtlv_bgp_ipv6
;
494 lspping_com_header
= (const struct lspping_common_header
*)pptr
;
495 TCHECK(*lspping_com_header
);
498 * Sanity checking of the header.
500 if (EXTRACT_16BITS(&lspping_com_header
->version
[0]) != LSPPING_VERSION
) {
501 printf("LSP-PING version %u packet not supported",
502 EXTRACT_16BITS(&lspping_com_header
->version
[0]));
506 /* in non-verbose mode just lets print the basic Message Type*/
508 printf("LSP-PINGv%u, %s, seq %u, length: %u",
509 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
510 tok2str(lspping_msg_type_values
, "unknown (%u)",lspping_com_header
->msg_type
),
511 EXTRACT_32BITS(lspping_com_header
->seq_number
),
516 /* ok they seem to want to know everything - lets fully decode it */
520 printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
521 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
522 tok2str(lspping_msg_type_values
, "unknown",lspping_com_header
->msg_type
),
523 lspping_com_header
->msg_type
,
525 tok2str(lspping_reply_mode_values
, "unknown",lspping_com_header
->reply_mode
),
526 lspping_com_header
->reply_mode
);
529 * the following return codes require that the subcode is attached
530 * at the end of the translated token output
532 if (lspping_com_header
->return_code
== 3 ||
533 lspping_com_header
->return_code
== 4 ||
534 lspping_com_header
->return_code
== 8 ||
535 lspping_com_header
->return_code
== 10 ||
536 lspping_com_header
->return_code
== 11 ||
537 lspping_com_header
->return_code
== 12 )
538 printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
539 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
540 lspping_com_header
->return_subcode
,
541 lspping_com_header
->return_code
,
542 lspping_com_header
->return_subcode
);
544 printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
545 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
546 lspping_com_header
->return_code
,
547 lspping_com_header
->return_subcode
);
549 printf("\n\t Sender Handle: 0x%08x, Sequence: %u",
550 EXTRACT_32BITS(lspping_com_header
->sender_handle
),
551 EXTRACT_32BITS(lspping_com_header
->seq_number
));
553 timestamp
.tv_sec
=EXTRACT_32BITS(lspping_com_header
->ts_sent_sec
);
554 timestamp
.tv_usec
=EXTRACT_32BITS(lspping_com_header
->ts_sent_usec
);
555 printf("\n\t Sender Timestamp: ");
556 ts_print(×tamp
);
558 timestamp
.tv_sec
=EXTRACT_32BITS(lspping_com_header
->ts_rcvd_sec
);
559 timestamp
.tv_usec
=EXTRACT_32BITS(lspping_com_header
->ts_rcvd_usec
);
560 printf("Receiver Timestamp: ");
561 if ((timestamp
.tv_sec
!= 0) && (timestamp
.tv_usec
!= 0))
562 ts_print(×tamp
);
564 printf("no timestamp");
566 tptr
+=sizeof(const struct lspping_common_header
);
567 tlen
-=sizeof(const struct lspping_common_header
);
569 while(tlen
>(int)sizeof(struct lspping_tlv_header
)) {
570 /* did we capture enough for fully decoding the tlv header ? */
571 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
574 lspping_tlv_header
= (const struct lspping_tlv_header
*)tptr
;
575 lspping_tlv_type
=EXTRACT_16BITS(lspping_tlv_header
->type
);
576 lspping_tlv_len
=EXTRACT_16BITS(lspping_tlv_header
->length
);
578 if (lspping_tlv_len
== 0)
581 if(lspping_tlv_len
% 4 || lspping_tlv_len
< 4) { /* aligned to four octet boundary */
582 printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type
,lspping_tlv_len
);
586 printf("\n\t %s TLV (%u), length: %u",
587 tok2str(lspping_tlv_values
,
593 tlv_tptr
=tptr
+sizeof(struct lspping_tlv_header
);
594 tlv_tlen
=lspping_tlv_len
; /* header not included -> no adjustment */
596 /* did we capture enough for fully decoding the tlv ? */
597 if (!TTEST2(*tptr
, lspping_tlv_len
))
601 switch(lspping_tlv_type
) {
602 case LSPPING_TLV_TARGET_FEC_STACK
:
603 while(tlv_tlen
>(int)sizeof(struct lspping_tlv_header
)) {
605 /* did we capture enough for fully decoding the subtlv header ? */
606 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
608 subtlv_hexdump
=FALSE
;
610 lspping_subtlv_header
= (const struct lspping_tlv_header
*)tlv_tptr
;
611 lspping_subtlv_type
=EXTRACT_16BITS(lspping_subtlv_header
->type
);
612 lspping_subtlv_len
=EXTRACT_16BITS(lspping_subtlv_header
->length
);
613 subtlv_tptr
=tlv_tptr
+sizeof(struct lspping_tlv_header
);
615 if (lspping_subtlv_len
== 0)
618 printf("\n\t %s subTLV (%u), length: %u",
619 tok2str(lspping_tlvtargetfec_subtlv_values
,
621 lspping_subtlv_type
),
625 switch(lspping_subtlv_type
) {
627 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
:
628 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
= \
629 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*)subtlv_tptr
;
631 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix
),
632 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix_len
);
636 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
:
637 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
= \
638 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*)subtlv_tptr
;
640 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix
),
641 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix_len
);
645 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
:
646 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
= \
647 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*)subtlv_tptr
;
648 printf("\n\t %s/%u, sender-id %s",
649 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix
),
650 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix_len
,
651 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->sender_id
));
655 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
:
656 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
= \
657 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*)subtlv_tptr
;
658 printf("\n\t %s/%u, sender-id %s",
659 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix
),
660 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix_len
,
661 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->sender_id
));
665 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
:
666 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
= \
667 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*)subtlv_tptr
;
668 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
669 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
670 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_endpoint
),
671 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_sender
),
672 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->lsp_id
),
673 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_id
),
674 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->extended_tunnel_id
));
678 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
:
679 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
= \
680 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*)subtlv_tptr
;
681 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
682 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
683 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_endpoint
),
684 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_sender
),
685 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->lsp_id
),
686 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_id
),
687 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->extended_tunnel_id
));
691 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
:
692 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
= \
693 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*)subtlv_tptr
;
694 printf("\n\t RD: %s, %s/%u",
695 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->rd
),
696 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix
),
697 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix_len
);
701 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
:
702 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
= \
703 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*)subtlv_tptr
;
704 printf("\n\t RD: %s, %s/%u",
705 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->rd
),
706 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix
),
707 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix_len
);
711 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
:
712 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
= \
713 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*)subtlv_tptr
;
714 printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
715 "\n\t Encapsulation Type: %s (%u)",
716 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->rd
),
717 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->sender_ce_id
),
718 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->receiver_ce_id
),
719 tok2str(l2vpn_encaps_values
,
721 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
)),
722 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
));
726 /* the old L2VPN VCID subTLV does not have support for the sender field */
727 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD
:
728 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
= \
729 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
*)subtlv_tptr
;
730 printf("\n\t Remote PE: %s" \
731 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
732 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->remote_pe_address
),
733 EXTRACT_32BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->vc_id
),
734 tok2str(l2vpn_encaps_values
,
736 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->encapsulation
)),
737 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->encapsulation
));
741 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
:
742 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
= \
743 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*)subtlv_tptr
;
744 printf("\n\t Sender PE: %s, Remote PE: %s" \
745 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
746 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->sender_pe_address
),
747 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->remote_pe_address
),
748 EXTRACT_32BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->vc_id
),
749 tok2str(l2vpn_encaps_values
,
751 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->encapsulation
)),
752 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->encapsulation
));
757 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
760 /* do we want to see an additionally subtlv hexdump ? */
761 if (vflag
> 1 || subtlv_hexdump
==TRUE
)
762 print_unknown_data(tlv_tptr
+sizeof(struct lspping_tlv_header
), \
766 tlv_tptr
+=lspping_subtlv_len
;
767 tlv_tlen
-=lspping_subtlv_len
+sizeof(struct lspping_tlv_header
);
771 case LSPPING_TLV_DOWNSTREAM_MAPPING
:
772 /* that strange thing with the downstream map TLV is that until now
773 * we do not know if its IPv4 or IPv6 , after we found the adress-type
774 * lets recast the tlv_tptr and move on */
776 tlv_ptr
.lspping_tlv_downstream_map_ipv4
= \
777 (const struct lspping_tlv_downstream_map_ipv4_t
*)tlv_tptr
;
778 tlv_ptr
.lspping_tlv_downstream_map_ipv6
= \
779 (const struct lspping_tlv_downstream_map_ipv6_t
*)tlv_tptr
;
780 printf("\n\t MTU: %u, Address-Type: %s (%u)",
781 EXTRACT_16BITS(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->mtu
),
782 tok2str(lspping_tlv_downstream_addr_values
,
784 tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
),
785 tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
);
787 switch(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
) {
789 case LSPPING_AFI_IPV4
:
790 printf("\n\t Downstream IP: %s" \
791 "\n\t Downstream Interface IP: %s",
792 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_ip
),
793 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_interface
));
794 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
795 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
798 case LSPPING_AFI_IPV6
:
799 printf("\n\t Downstream IP: %s" \
800 "\n\t Downstream Interface IP: %s",
801 ip6addr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_ip
),
802 ip6addr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_interface
));
803 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
804 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
807 case LSPPING_AFI_UNMB
:
808 printf("\n\t Downstream IP: %s" \
809 "\n\t Downstream Interface Index: 0x%08x",
810 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_ip
),
811 EXTRACT_32BITS(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_interface
));
812 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
813 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
817 /* should not happen ! - no error message - tok2str() has barked already */
821 tlv_ptr
.lspping_tlv_downstream_map_info
= \
822 (const struct lspping_tlv_downstream_map_info_t
*)tlv_tptr
;
824 /* FIXME add hash-key type, depth limit, multipath processing */
827 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_info_t
);
828 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_info_t
);
830 /* FIXME print downstream labels */
833 tlv_hexdump
=TRUE
; /* dump the TLV until code complete */
837 case LSPPING_TLV_BFD_DISCRIMINATOR
:
838 tptr
+= sizeof(struct lspping_tlv_header
);
839 if (!TTEST2(*tptr
, 4))
841 printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr
));
844 * FIXME those are the defined TLVs that lack a decoder
845 * you are welcome to contribute code ;-)
848 case LSPPING_TLV_PAD
:
849 case LSPPING_TLV_ERROR_CODE
:
850 case LSPPING_TLV_VENDOR_PRIVATE
:
854 print_unknown_data(tlv_tptr
,"\n\t ",tlv_tlen
);
857 /* do we want to see an additionally tlv hexdump ? */
858 if (vflag
> 1 || tlv_hexdump
==TRUE
)
859 print_unknown_data(tptr
+sizeof(sizeof(struct lspping_tlv_header
)),"\n\t ",
862 tptr
+=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
863 tlen
-=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
867 printf("\n\t\t packet exceeded snapshot");