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.
15 * Original code by Hannes Gredler (hannes@juniper.net)
18 #include <sys/cdefs.h>
21 static const char rcsid
[] _U_
=
22 "@(#) Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.12.2.6 2006/06/23 02:07:27 hannes Exp";
24 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
32 #include <tcpdump-stdinc.h>
38 #include "interface.h"
40 #include "addrtoname.h"
46 * LSPPING common header
49 * 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
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | Version Number | Must Be Zero |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 * | Message Type | Reply mode | Return Code | Return Subcode|
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | TimeStamp Sent (seconds) |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * | TimeStamp Sent (microseconds) |
62 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 * | TimeStamp Received (seconds) |
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | TimeStamp Received (microseconds) |
66 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 struct lspping_common_header
{
79 u_int8_t return_subcode
;
80 u_int8_t sender_handle
[4];
81 u_int8_t seq_number
[4];
82 u_int8_t ts_sent_sec
[4];
83 u_int8_t ts_sent_usec
[4];
84 u_int8_t ts_rcvd_sec
[4];
85 u_int8_t ts_rcvd_usec
[4];
88 #define LSPPING_VERSION 1
90 static const struct tok lspping_msg_type_values
[] = {
91 { 1, "MPLS Echo Request"},
92 { 2, "MPLS Echo Reply"},
96 static const struct tok lspping_reply_mode_values
[] = {
98 { 2, "Reply via an IPv4/IPv6 UDP packet"},
99 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
100 { 4, "Reply via application level control channel"},
104 static const struct tok lspping_return_code_values
[] = {
105 { 0, "No return code or return code contained in the Error Code TLV"},
106 { 1, "Malformed echo request received"},
107 { 2, "One or more of the TLVs was not understood"},
108 { 3, "Replying router is an egress for the FEC at stack depth"},
109 { 4, "Replying router has no mapping for the FEC at stack depth"},
113 { 8, "Label switched at stack-depth"},
114 { 9, "Label switched but no MPLS forwarding at stack-depth"},
115 { 10, "Mapping for this FEC is not the given label at stack depth"},
116 { 11, "No label entry at stack-depth"},
117 { 12, "Protocol not associated with interface at FEC stack depth"},
124 * 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
125 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
133 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 struct lspping_tlv_header
{
141 #define LSPPING_TLV_TARGET_FEC_STACK 1
142 #define LSPPING_TLV_DOWNSTREAM_MAPPING 2
143 #define LSPPING_TLV_PAD 3
144 #define LSPPING_TLV_ERROR_CODE 4
145 #define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
146 #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
147 #define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
149 static const struct tok lspping_tlv_values
[] = {
150 { LSPPING_TLV_TARGET_FEC_STACK
, "Target FEC Stack" },
151 { LSPPING_TLV_DOWNSTREAM_MAPPING
, "Downstream Mapping" },
152 { LSPPING_TLV_PAD
, "Pad" },
153 { LSPPING_TLV_ERROR_CODE
, "Error Code" },
154 { LSPPING_TLV_BFD_DISCRIMINATOR
, "BFD Discriminator" },
155 { LSPPING_TLV_VENDOR_PRIVATE
, "Vendor Enterprise Code" },
159 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
160 #define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
161 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
162 #define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
163 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
164 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
165 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
166 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
167 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10
168 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11
169 #define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12
171 static const struct tok lspping_tlvtargetfec_subtlv_values
[] = {
172 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
, "LDP IPv4 prefix"},
173 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
, "LDP IPv6 prefix"},
174 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
, "RSVP IPv4 Session Query"},
175 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
, "RSVP IPv6 Session Query"},
177 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
, "VPN IPv4 prefix"},
178 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
, "VPN IPv6 prefix"},
179 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
, "L2 VPN endpoint"},
180 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD
, "L2 circuit ID (old)"},
181 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
, "L2 circuit ID"},
182 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
, "BGP labeled IPv4 prefix"},
183 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
, "BGP labeled IPv6 prefix"},
189 * 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
190 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
193 * | Prefix Length | Must Be Zero |
194 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
{
203 * 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
204 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
209 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 * | Prefix Length | Must Be Zero |
211 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
{
214 u_int8_t prefix
[16];
219 * 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
220 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
221 * | Sender identifier |
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 * | Prefix Length | Must Be Zero |
226 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
228 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
{
229 u_int8_t sender_id
[4];
235 * 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
236 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
237 * | Sender identifier |
241 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
246 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
247 * | Prefix Length | Must Be Zero |
248 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
250 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
{
251 u_int8_t sender_id
[16];
252 u_int8_t prefix
[16];
258 * 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
259 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
260 * | IPv4 tunnel end point address |
261 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
262 * | Must Be Zero | Tunnel ID |
263 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
264 * | Extended Tunnel ID |
265 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
266 * | IPv4 tunnel sender address |
267 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
268 * | Must Be Zero | LSP ID |
269 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
271 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
{
272 u_int8_t tunnel_endpoint
[4];
274 u_int8_t tunnel_id
[2];
275 u_int8_t extended_tunnel_id
[4];
276 u_int8_t tunnel_sender
[4];
283 * 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
284 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
285 * | IPv6 tunnel end point address |
289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
290 * | Must Be Zero | Tunnel ID |
291 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
292 * | Extended Tunnel ID |
296 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
297 * | IPv6 tunnel sender address |
301 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
302 * | Must Be Zero | LSP ID |
303 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
{
306 u_int8_t tunnel_endpoint
[16];
308 u_int8_t tunnel_id
[2];
309 u_int8_t extended_tunnel_id
[16];
310 u_int8_t tunnel_sender
[16];
317 * 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
318 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319 * | Route Distinguisher |
321 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
323 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
324 * | Prefix Length | Must Be Zero |
325 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
327 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
{
335 * 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
336 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
337 * | Route Distinguisher |
339 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
344 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
345 * | Prefix Length | Must Be Zero |
346 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
348 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
{
350 u_int8_t prefix
[16];
356 * 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
357 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
358 * | Route Distinguisher |
360 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361 * | Sender's CE ID | Receiver's CE ID |
362 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
363 * | Encapsulation Type | Must Be Zero |
364 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
{
369 u_int8_t sender_ce_id
[2];
370 u_int8_t receiver_ce_id
[2];
371 u_int8_t encapsulation
[2];
375 * 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
376 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
377 * | Remote PE Address |
378 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
380 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 * | Encapsulation Type | Must Be Zero |
382 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
{
385 u_int8_t remote_pe_address
[4];
387 u_int8_t encapsulation
[2];
391 * 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
392 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
393 * | Sender's PE Address |
394 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
395 * | Remote PE Address |
396 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
398 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
399 * | Encapsulation Type | Must Be Zero |
400 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
402 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
{
403 u_int8_t sender_pe_address
[4];
404 u_int8_t remote_pe_address
[4];
406 u_int8_t encapsulation
[2];
411 * 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
412 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
413 * | MTU | Address Type | Resvd (SBZ) |
414 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
415 * | Downstream IP Address (4 or 16 octets) |
416 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
417 * | Downstream Interface Address (4 or 16 octets) |
418 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
419 * | Hash Key Type | Depth Limit | Multipath Length |
420 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422 * . (Multipath Information) .
424 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
425 * | Downstream Label | Protocol |
426 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
430 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
431 * | Downstream Label | Protocol |
432 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
434 struct lspping_tlv_downstream_map_ipv4_t
{
436 u_int8_t address_type
;
438 u_int8_t downstream_ip
[4];
439 u_int8_t downstream_interface
[4];
442 struct lspping_tlv_downstream_map_ipv6_t
{
444 u_int8_t address_type
;
446 u_int8_t downstream_ip
[16];
447 u_int8_t downstream_interface
[16];
450 struct lspping_tlv_downstream_map_info_t
{
451 u_int8_t hash_key_type
;
452 u_int8_t depth_limit
;
453 u_int8_t multipath_length
[2];
456 #define LSPPING_AFI_IPV4 1
457 #define LSPPING_AFI_UNMB 2
458 #define LSPPING_AFI_IPV6 3
460 static const struct tok lspping_tlv_downstream_addr_values
[] = {
461 { LSPPING_AFI_IPV4
, "IPv4"},
462 { LSPPING_AFI_IPV6
, "IPv6"},
463 { LSPPING_AFI_UNMB
, "Unnumbered"},
468 lspping_print(register const u_char
*pptr
, register u_int len
) {
470 const struct lspping_common_header
*lspping_com_header
;
471 const struct lspping_tlv_header
*lspping_tlv_header
;
472 const struct lspping_tlv_header
*lspping_subtlv_header
;
473 const u_char
*tptr
,*tlv_tptr
,*subtlv_tptr
;
474 int tlen
,lspping_tlv_len
,lspping_tlv_type
,tlv_tlen
;
475 int tlv_hexdump
,subtlv_hexdump
;
476 int lspping_subtlv_len
,lspping_subtlv_type
;
477 struct timeval timestamp
;
480 const struct lspping_tlv_downstream_map_ipv4_t
*lspping_tlv_downstream_map_ipv4
;
481 const struct lspping_tlv_downstream_map_ipv6_t
*lspping_tlv_downstream_map_ipv6
;
482 const struct lspping_tlv_downstream_map_info_t
*lspping_tlv_downstream_map_info
;
486 const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*lspping_tlv_targetfec_subtlv_ldp_ipv4
;
487 const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*lspping_tlv_targetfec_subtlv_ldp_ipv6
;
488 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv4
;
489 const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*lspping_tlv_targetfec_subtlv_rsvp_ipv6
;
490 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv4
;
491 const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*lspping_tlv_targetfec_subtlv_l3vpn_ipv6
;
492 const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*lspping_tlv_targetfec_subtlv_l2vpn_endpt
;
493 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
*lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
;
494 const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*lspping_tlv_targetfec_subtlv_l2vpn_vcid
;
495 const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*lspping_tlv_targetfec_subtlv_bgp_ipv4
;
496 const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*lspping_tlv_targetfec_subtlv_bgp_ipv6
;
500 lspping_com_header
= (const struct lspping_common_header
*)pptr
;
501 TCHECK(*lspping_com_header
);
504 * Sanity checking of the header.
506 if (EXTRACT_16BITS(&lspping_com_header
->version
[0]) != LSPPING_VERSION
) {
507 printf("LSP-PING version %u packet not supported",
508 EXTRACT_16BITS(&lspping_com_header
->version
[0]));
512 /* in non-verbose mode just lets print the basic Message Type*/
514 printf("LSP-PINGv%u, %s, seq %u, length: %u",
515 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
516 tok2str(lspping_msg_type_values
, "unknown (%u)",lspping_com_header
->msg_type
),
517 EXTRACT_32BITS(lspping_com_header
->seq_number
),
522 /* ok they seem to want to know everything - lets fully decode it */
526 printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
527 EXTRACT_16BITS(&lspping_com_header
->version
[0]),
528 tok2str(lspping_msg_type_values
, "unknown",lspping_com_header
->msg_type
),
529 lspping_com_header
->msg_type
,
531 tok2str(lspping_reply_mode_values
, "unknown",lspping_com_header
->reply_mode
),
532 lspping_com_header
->reply_mode
);
535 * the following return codes require that the subcode is attached
536 * at the end of the translated token output
538 if (lspping_com_header
->return_code
== 3 ||
539 lspping_com_header
->return_code
== 4 ||
540 lspping_com_header
->return_code
== 8 ||
541 lspping_com_header
->return_code
== 10 ||
542 lspping_com_header
->return_code
== 11 ||
543 lspping_com_header
->return_code
== 12 )
544 printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
545 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
546 lspping_com_header
->return_subcode
,
547 lspping_com_header
->return_code
,
548 lspping_com_header
->return_subcode
);
550 printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
551 tok2str(lspping_return_code_values
, "unknown",lspping_com_header
->return_code
),
552 lspping_com_header
->return_code
,
553 lspping_com_header
->return_subcode
);
555 printf("\n\t Sender Handle: 0x%08x, Sequence: %u",
556 EXTRACT_32BITS(lspping_com_header
->sender_handle
),
557 EXTRACT_32BITS(lspping_com_header
->seq_number
));
559 timestamp
.tv_sec
=EXTRACT_32BITS(lspping_com_header
->ts_sent_sec
);
560 timestamp
.tv_usec
=EXTRACT_32BITS(lspping_com_header
->ts_sent_usec
);
561 printf("\n\t Sender Timestamp: ");
562 ts_print(×tamp
);
564 timestamp
.tv_sec
=EXTRACT_32BITS(lspping_com_header
->ts_rcvd_sec
);
565 timestamp
.tv_usec
=EXTRACT_32BITS(lspping_com_header
->ts_rcvd_usec
);
566 printf("Receiver Timestamp: ");
567 if ((timestamp
.tv_sec
!= 0) && (timestamp
.tv_usec
!= 0))
568 ts_print(×tamp
);
570 printf("no timestamp");
572 tptr
+=sizeof(const struct lspping_common_header
);
573 tlen
-=sizeof(const struct lspping_common_header
);
575 while(tlen
>(int)sizeof(struct lspping_tlv_header
)) {
576 /* did we capture enough for fully decoding the tlv header ? */
577 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
580 lspping_tlv_header
= (const struct lspping_tlv_header
*)tptr
;
581 lspping_tlv_type
=EXTRACT_16BITS(lspping_tlv_header
->type
);
582 lspping_tlv_len
=EXTRACT_16BITS(lspping_tlv_header
->length
);
584 if (lspping_tlv_len
== 0)
587 if(lspping_tlv_len
% 4 || lspping_tlv_len
< 4) { /* aligned to four octet boundary */
588 printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type
,lspping_tlv_len
);
592 printf("\n\t %s TLV (%u), length: %u",
593 tok2str(lspping_tlv_values
,
599 tlv_tptr
=tptr
+sizeof(struct lspping_tlv_header
);
600 tlv_tlen
=lspping_tlv_len
; /* header not included -> no adjustment */
602 /* did we capture enough for fully decoding the tlv ? */
603 if (!TTEST2(*tptr
, lspping_tlv_len
))
607 switch(lspping_tlv_type
) {
608 case LSPPING_TLV_TARGET_FEC_STACK
:
609 while(tlv_tlen
>(int)sizeof(struct lspping_tlv_header
)) {
611 /* did we capture enough for fully decoding the subtlv header ? */
612 if (!TTEST2(*tptr
, sizeof(struct lspping_tlv_header
)))
614 subtlv_hexdump
=FALSE
;
616 lspping_subtlv_header
= (const struct lspping_tlv_header
*)tlv_tptr
;
617 lspping_subtlv_type
=EXTRACT_16BITS(lspping_subtlv_header
->type
);
618 lspping_subtlv_len
=EXTRACT_16BITS(lspping_subtlv_header
->length
);
619 subtlv_tptr
=tlv_tptr
+sizeof(struct lspping_tlv_header
);
621 if (lspping_subtlv_len
== 0)
624 printf("\n\t %s subTLV (%u), length: %u",
625 tok2str(lspping_tlvtargetfec_subtlv_values
,
627 lspping_subtlv_type
),
631 switch(lspping_subtlv_type
) {
633 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4
:
634 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
= \
635 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t
*)subtlv_tptr
;
637 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix
),
638 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv4
->prefix_len
);
642 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6
:
643 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
= \
644 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t
*)subtlv_tptr
;
646 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix
),
647 subtlv_ptr
.lspping_tlv_targetfec_subtlv_ldp_ipv6
->prefix_len
);
651 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4
:
652 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
= \
653 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t
*)subtlv_tptr
;
654 printf("\n\t %s/%u, sender-id %s",
655 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix
),
656 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->prefix_len
,
657 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv4
->sender_id
));
661 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6
:
662 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
= \
663 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t
*)subtlv_tptr
;
664 printf("\n\t %s/%u, sender-id %s",
665 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix
),
666 subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->prefix_len
,
667 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_bgp_ipv6
->sender_id
));
671 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4
:
672 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
= \
673 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t
*)subtlv_tptr
;
674 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
675 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
676 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_endpoint
),
677 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_sender
),
678 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->lsp_id
),
679 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->tunnel_id
),
680 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv4
->extended_tunnel_id
));
684 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6
:
685 subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
= \
686 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t
*)subtlv_tptr
;
687 printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
688 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
689 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_endpoint
),
690 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_sender
),
691 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->lsp_id
),
692 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->tunnel_id
),
693 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_rsvp_ipv6
->extended_tunnel_id
));
697 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4
:
698 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
= \
699 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t
*)subtlv_tptr
;
700 printf("\n\t RD: %s, %s/%u",
701 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->rd
),
702 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix
),
703 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv4
->prefix_len
);
707 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6
:
708 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
= \
709 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t
*)subtlv_tptr
;
710 printf("\n\t RD: %s, %s/%u",
711 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->rd
),
712 ip6addr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix
),
713 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l3vpn_ipv6
->prefix_len
);
717 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT
:
718 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
= \
719 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t
*)subtlv_tptr
;
720 printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
721 "\n\t Encapsulation Type: %s (%u)",
722 bgp_vpn_rd_print(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->rd
),
723 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->sender_ce_id
),
724 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->receiver_ce_id
),
725 tok2str(l2vpn_encaps_values
,
727 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
)),
728 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_endpt
->encapsulation
));
732 /* the old L2VPN VCID subTLV does not have support for the sender field */
733 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD
:
734 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
= \
735 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t
*)subtlv_tptr
;
736 printf("\n\t Remote PE: %s" \
737 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
738 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->remote_pe_address
),
739 EXTRACT_32BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->vc_id
),
740 tok2str(l2vpn_encaps_values
,
742 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->encapsulation
)),
743 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old
->encapsulation
));
747 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID
:
748 subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
= \
749 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t
*)subtlv_tptr
;
750 printf("\n\t Sender PE: %s, Remote PE: %s" \
751 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
752 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->sender_pe_address
),
753 ipaddr_string(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->remote_pe_address
),
754 EXTRACT_32BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->vc_id
),
755 tok2str(l2vpn_encaps_values
,
757 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->encapsulation
)),
758 EXTRACT_16BITS(subtlv_ptr
.lspping_tlv_targetfec_subtlv_l2vpn_vcid
->encapsulation
));
763 subtlv_hexdump
=TRUE
; /* unknown subTLV just hexdump it */
766 /* do we want to see an additionally subtlv hexdump ? */
767 if (vflag
> 1 || subtlv_hexdump
==TRUE
)
768 print_unknown_data(tlv_tptr
+sizeof(struct lspping_tlv_header
), \
772 tlv_tptr
+=lspping_subtlv_len
;
773 tlv_tlen
-=lspping_subtlv_len
+sizeof(struct lspping_tlv_header
);
777 case LSPPING_TLV_DOWNSTREAM_MAPPING
:
778 /* that strange thing with the downstream map TLV is that until now
779 * we do not know if its IPv4 or IPv6 , after we found the adress-type
780 * lets recast the tlv_tptr and move on */
782 tlv_ptr
.lspping_tlv_downstream_map_ipv4
= \
783 (const struct lspping_tlv_downstream_map_ipv4_t
*)tlv_tptr
;
784 tlv_ptr
.lspping_tlv_downstream_map_ipv6
= \
785 (const struct lspping_tlv_downstream_map_ipv6_t
*)tlv_tptr
;
786 printf("\n\t MTU: %u, Address-Type: %s (%u)",
787 EXTRACT_16BITS(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->mtu
),
788 tok2str(lspping_tlv_downstream_addr_values
,
790 tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
),
791 tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
);
793 switch(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->address_type
) {
795 case LSPPING_AFI_IPV4
:
796 printf("\n\t Downstream IP: %s" \
797 "\n\t Downstream Interface IP: %s",
798 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_ip
),
799 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_interface
));
800 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
801 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
804 case LSPPING_AFI_IPV6
:
805 printf("\n\t Downstream IP: %s" \
806 "\n\t Downstream Interface IP: %s",
807 ip6addr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_ip
),
808 ip6addr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv6
->downstream_interface
));
809 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
810 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv6_t
);
813 case LSPPING_AFI_UNMB
:
814 printf("\n\t Downstream IP: %s" \
815 "\n\t Downstream Interface Index: 0x%08x",
816 ipaddr_string(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_ip
),
817 EXTRACT_32BITS(tlv_ptr
.lspping_tlv_downstream_map_ipv4
->downstream_interface
));
818 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
819 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_ipv4_t
);
823 /* should not happen ! - no error message - tok2str() has barked already */
827 tlv_ptr
.lspping_tlv_downstream_map_info
= \
828 (const struct lspping_tlv_downstream_map_info_t
*)tlv_tptr
;
830 /* FIXME add hash-key type, depth limit, multipath processing */
833 tlv_tptr
+=sizeof(struct lspping_tlv_downstream_map_info_t
);
834 tlv_tlen
-=sizeof(struct lspping_tlv_downstream_map_info_t
);
836 /* FIXME print downstream labels */
839 tlv_hexdump
=TRUE
; /* dump the TLV until code complete */
843 case LSPPING_TLV_BFD_DISCRIMINATOR
:
844 tptr
+= sizeof(struct lspping_tlv_header
);
845 if (!TTEST2(*tptr
, LSPPING_TLV_BFD_DISCRIMINATOR_LEN
))
847 printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr
));
850 * FIXME those are the defined TLVs that lack a decoder
851 * you are welcome to contribute code ;-)
854 case LSPPING_TLV_PAD
:
855 case LSPPING_TLV_ERROR_CODE
:
856 case LSPPING_TLV_VENDOR_PRIVATE
:
860 print_unknown_data(tlv_tptr
,"\n\t ",tlv_tlen
);
863 /* do we want to see an additionally tlv hexdump ? */
864 if (vflag
> 1 || tlv_hexdump
==TRUE
)
865 print_unknown_data(tptr
+sizeof(sizeof(struct lspping_tlv_header
)),"\n\t ",
868 tptr
+=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
869 tlen
-=lspping_tlv_len
+sizeof(struct lspping_tlv_header
);
873 printf("\n\t\t packet exceeded snapshot");