1146773Ssam/* 2146773Ssam * Redistribution and use in source and binary forms, with or without 3146773Ssam * modification, are permitted provided that: (1) source code 4146773Ssam * distributions retain the above copyright notice and this paragraph 5146773Ssam * in its entirety, and (2) distributions including binary code include 6146773Ssam * the above copyright notice and this paragraph in its entirety in 7146773Ssam * the documentation or other materials provided with the distribution. 8146773Ssam * THIS SOFTWARE IS PROVIDED ``AS IS'' AND 9146773Ssam * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 10146773Ssam * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11146773Ssam * FOR A PARTICULAR PURPOSE. 12146773Ssam * 13146773Ssam * Original code by Hannes Gredler (hannes@juniper.net) 14146773Ssam */ 15146773Ssam 16146773Ssam#ifndef lint 17146773Ssamstatic const char rcsid[] _U_ = 18214478Srpaulo "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp $"; 19146773Ssam#endif 20146773Ssam 21146773Ssam#ifdef HAVE_CONFIG_H 22146773Ssam#include "config.h" 23146773Ssam#endif 24146773Ssam 25146773Ssam#include <tcpdump-stdinc.h> 26146773Ssam 27146773Ssam#include <stdio.h> 28146773Ssam#include <stdlib.h> 29146773Ssam#include <string.h> 30146773Ssam 31146773Ssam#include "interface.h" 32146773Ssam#include "extract.h" 33146773Ssam#include "addrtoname.h" 34146773Ssam 35146773Ssam#include "bgp.h" 36146773Ssam#include "l2vpn.h" 37214478Srpaulo#include "oui.h" 38146773Ssam 39146773Ssam/* 40146773Ssam * LSPPING common header 41146773Ssam * 42146773Ssam * 0 1 2 3 43146773Ssam * 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 44146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45146773Ssam * | Version Number | Must Be Zero | 46146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47146773Ssam * | Message Type | Reply mode | Return Code | Return Subcode| 48146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 49146773Ssam * | Sender's Handle | 50146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51146773Ssam * | Sequence Number | 52146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 53146773Ssam * | TimeStamp Sent (seconds) | 54146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 55146773Ssam * | TimeStamp Sent (microseconds) | 56146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 57146773Ssam * | TimeStamp Received (seconds) | 58146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 59146773Ssam * | TimeStamp Received (microseconds) | 60146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 61146773Ssam * | TLVs ... | 62146773Ssam * . . 63146773Ssam * . . 64146773Ssam * . . 65146773Ssam */ 66146773Ssam 67146773Ssamstruct lspping_common_header { 68146773Ssam u_int8_t version[2]; 69146773Ssam u_int8_t reserved[2]; 70146773Ssam u_int8_t msg_type; 71146773Ssam u_int8_t reply_mode; 72146773Ssam u_int8_t return_code; 73146773Ssam u_int8_t return_subcode; 74146773Ssam u_int8_t sender_handle[4]; 75146773Ssam u_int8_t seq_number[4]; 76146773Ssam u_int8_t ts_sent_sec[4]; 77146773Ssam u_int8_t ts_sent_usec[4]; 78146773Ssam u_int8_t ts_rcvd_sec[4]; 79146773Ssam u_int8_t ts_rcvd_usec[4]; 80146773Ssam}; 81146773Ssam 82146773Ssam#define LSPPING_VERSION 1 83146773Ssam 84146773Ssamstatic const struct tok lspping_msg_type_values[] = { 85146773Ssam { 1, "MPLS Echo Request"}, 86146773Ssam { 2, "MPLS Echo Reply"}, 87146773Ssam { 0, NULL} 88146773Ssam}; 89146773Ssam 90146773Ssamstatic const struct tok lspping_reply_mode_values[] = { 91146773Ssam { 1, "Do not reply"}, 92146773Ssam { 2, "Reply via an IPv4/IPv6 UDP packet"}, 93146773Ssam { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"}, 94146773Ssam { 4, "Reply via application level control channel"}, 95146773Ssam { 0, NULL} 96146773Ssam}; 97146773Ssam 98146773Ssamstatic const struct tok lspping_return_code_values[] = { 99146773Ssam { 0, "No return code or return code contained in the Error Code TLV"}, 100146773Ssam { 1, "Malformed echo request received"}, 101146773Ssam { 2, "One or more of the TLVs was not understood"}, 102146773Ssam { 3, "Replying router is an egress for the FEC at stack depth"}, 103146773Ssam { 4, "Replying router has no mapping for the FEC at stack depth"}, 104146773Ssam { 5, "Reserved"}, 105146773Ssam { 6, "Reserved"}, 106146773Ssam { 7, "Reserved"}, 107146773Ssam { 8, "Label switched at stack-depth"}, 108146773Ssam { 9, "Label switched but no MPLS forwarding at stack-depth"}, 109146773Ssam { 10, "Mapping for this FEC is not the given label at stack depth"}, 110146773Ssam { 11, "No label entry at stack-depth"}, 111146773Ssam { 12, "Protocol not associated with interface at FEC stack depth"}, 112146773Ssam}; 113146773Ssam 114146773Ssam 115146773Ssam/* 116146773Ssam * LSPPING TLV header 117146773Ssam * 0 1 2 3 118146773Ssam * 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 119146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 120146773Ssam * | Type | Length | 121146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 122146773Ssam * | Value | 123146773Ssam * . . 124146773Ssam * . . 125146773Ssam * . . 126146773Ssam * | | 127146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 128146773Ssam */ 129146773Ssam 130146773Ssamstruct lspping_tlv_header { 131146773Ssam u_int8_t type[2]; 132146773Ssam u_int8_t length[2]; 133146773Ssam}; 134146773Ssam 135146773Ssam#define LSPPING_TLV_TARGET_FEC_STACK 1 136146773Ssam#define LSPPING_TLV_DOWNSTREAM_MAPPING 2 137146773Ssam#define LSPPING_TLV_PAD 3 138214478Srpaulo#define LSPPING_TLV_VENDOR_ENTERPRISE 5 139214478Srpaulo#define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4 140214478Srpaulo#define LSPPING_TLV_INTERFACE_LABEL_STACK 7 141214478Srpaulo#define LSPPING_TLV_ERROR_CODE 9 142214478Srpaulo#define LSPPING_TLV_REPLY_TOS_BYTE 10 143172683Smlaier#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */ 144172683Smlaier#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4 145147899Ssam#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00 146146773Ssam 147146773Ssamstatic const struct tok lspping_tlv_values[] = { 148146773Ssam { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" }, 149146773Ssam { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" }, 150146773Ssam { LSPPING_TLV_PAD, "Pad" }, 151146773Ssam { LSPPING_TLV_ERROR_CODE, "Error Code" }, 152214478Srpaulo { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" }, 153214478Srpaulo { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" }, 154214478Srpaulo { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" }, 155172683Smlaier { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" }, 156214478Srpaulo { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" }, 157146773Ssam { 0, NULL} 158146773Ssam}; 159146773Ssam 160146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1 161146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2 162146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3 163146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4 164146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6 165146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7 166146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8 167146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9 168146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10 169146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11 170146773Ssam#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12 171146773Ssam 172146773Ssamstatic const struct tok lspping_tlvtargetfec_subtlv_values[] = { 173146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"}, 174146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"}, 175146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"}, 176146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"}, 177146773Ssam { 5, "Reserved"}, 178146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"}, 179146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"}, 180146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"}, 181146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"}, 182146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"}, 183146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"}, 184146773Ssam { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"}, 185146773Ssam { 0, NULL} 186146773Ssam}; 187146773Ssam 188146773Ssam/* 189146773Ssam * 0 1 2 3 190146773Ssam * 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 191146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 192146773Ssam * | IPv4 prefix | 193146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 194146773Ssam * | Prefix Length | Must Be Zero | 195146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 196146773Ssam */ 197146773Ssamstruct lspping_tlv_targetfec_subtlv_ldp_ipv4_t { 198146773Ssam u_int8_t prefix [4]; 199146773Ssam u_int8_t prefix_len; 200146773Ssam}; 201146773Ssam 202146773Ssam/* 203146773Ssam * 0 1 2 3 204146773Ssam * 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 205146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 206146773Ssam * | IPv6 prefix | 207146773Ssam * | (16 octets) | 208146773Ssam * | | 209146773Ssam * | | 210146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 211146773Ssam * | Prefix Length | Must Be Zero | 212146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 213146773Ssam */ 214146773Ssamstruct lspping_tlv_targetfec_subtlv_ldp_ipv6_t { 215146773Ssam u_int8_t prefix [16]; 216146773Ssam u_int8_t prefix_len; 217146773Ssam}; 218146773Ssam 219146773Ssam/* 220146773Ssam * 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 221146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 222146773Ssam * | Sender identifier | 223146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 224146773Ssam * | IPv4 prefix | 225146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 226146773Ssam * | Prefix Length | Must Be Zero | 227146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 228146773Ssam */ 229146773Ssamstruct lspping_tlv_targetfec_subtlv_bgp_ipv4_t { 230146773Ssam u_int8_t sender_id [4]; 231146773Ssam u_int8_t prefix [4]; 232146773Ssam u_int8_t prefix_len; 233146773Ssam}; 234146773Ssam 235146773Ssam/* 236146773Ssam * 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 237146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 238146773Ssam * | Sender identifier | 239146773Ssam * | (16 octets) | 240146773Ssam * | | 241146773Ssam * | | 242146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 243146773Ssam * | IPv6 prefix | 244146773Ssam * | (16 octets) | 245146773Ssam * | | 246146773Ssam * | | 247146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 248146773Ssam * | Prefix Length | Must Be Zero | 249146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 250146773Ssam */ 251146773Ssamstruct lspping_tlv_targetfec_subtlv_bgp_ipv6_t { 252146773Ssam u_int8_t sender_id [16]; 253146773Ssam u_int8_t prefix [16]; 254146773Ssam u_int8_t prefix_len; 255146773Ssam}; 256146773Ssam 257146773Ssam/* 258146773Ssam * 0 1 2 3 259146773Ssam * 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 260146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 261146773Ssam * | IPv4 tunnel end point address | 262146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 263146773Ssam * | Must Be Zero | Tunnel ID | 264146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 265146773Ssam * | Extended Tunnel ID | 266146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 267146773Ssam * | IPv4 tunnel sender address | 268146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 269146773Ssam * | Must Be Zero | LSP ID | 270146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 271146773Ssam */ 272146773Ssamstruct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t { 273146773Ssam u_int8_t tunnel_endpoint [4]; 274146773Ssam u_int8_t res[2]; 275146773Ssam u_int8_t tunnel_id[2]; 276146773Ssam u_int8_t extended_tunnel_id[4]; 277146773Ssam u_int8_t tunnel_sender [4]; 278146773Ssam u_int8_t res2[2]; 279146773Ssam u_int8_t lsp_id [2]; 280146773Ssam}; 281146773Ssam 282146773Ssam/* 283146773Ssam * 0 1 2 3 284146773Ssam * 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 285146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 286146773Ssam * | IPv6 tunnel end point address | 287146773Ssam * | | 288146773Ssam * | | 289146773Ssam * | | 290146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 291146773Ssam * | Must Be Zero | Tunnel ID | 292146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 293146773Ssam * | Extended Tunnel ID | 294146773Ssam * | | 295146773Ssam * | | 296146773Ssam * | | 297146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 298146773Ssam * | IPv6 tunnel sender address | 299146773Ssam * | | 300146773Ssam * | | 301146773Ssam * | | 302146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 303146773Ssam * | Must Be Zero | LSP ID | 304146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 305146773Ssam */ 306146773Ssamstruct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t { 307146773Ssam u_int8_t tunnel_endpoint [16]; 308146773Ssam u_int8_t res[2]; 309146773Ssam u_int8_t tunnel_id[2]; 310146773Ssam u_int8_t extended_tunnel_id[16]; 311146773Ssam u_int8_t tunnel_sender [16]; 312146773Ssam u_int8_t res2[2]; 313146773Ssam u_int8_t lsp_id [2]; 314146773Ssam}; 315146773Ssam 316146773Ssam/* 317146773Ssam * 0 1 2 3 318146773Ssam * 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 319146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 320146773Ssam * | Route Distinguisher | 321146773Ssam * | (8 octets) | 322146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 323146773Ssam * | IPv4 prefix | 324146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 325146773Ssam * | Prefix Length | Must Be Zero | 326146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 327146773Ssam */ 328146773Ssamstruct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t { 329146773Ssam u_int8_t rd [8]; 330146773Ssam u_int8_t prefix [4]; 331146773Ssam u_int8_t prefix_len; 332146773Ssam}; 333146773Ssam 334146773Ssam/* 335146773Ssam * 0 1 2 3 336146773Ssam * 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 337146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 338146773Ssam * | Route Distinguisher | 339146773Ssam * | (8 octets) | 340146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 341146773Ssam * | IPv6 prefix | 342146773Ssam * | (16 octets) | 343146773Ssam * | | 344146773Ssam * | | 345146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 346146773Ssam * | Prefix Length | Must Be Zero | 347146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 348146773Ssam */ 349146773Ssamstruct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t { 350146773Ssam u_int8_t rd [8]; 351146773Ssam u_int8_t prefix [16]; 352146773Ssam u_int8_t prefix_len; 353146773Ssam}; 354146773Ssam 355146773Ssam/* 356146773Ssam * 0 1 2 3 357146773Ssam * 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 358146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 359146773Ssam * | Route Distinguisher | 360146773Ssam * | (8 octets) | 361146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 362146773Ssam * | Sender's CE ID | Receiver's CE ID | 363146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 364146773Ssam * | Encapsulation Type | Must Be Zero | 365146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 366146773Ssam * 0 1 2 3 367146773Ssam */ 368146773Ssamstruct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t { 369146773Ssam u_int8_t rd [8]; 370146773Ssam u_int8_t sender_ce_id [2]; 371146773Ssam u_int8_t receiver_ce_id [2]; 372146773Ssam u_int8_t encapsulation[2]; 373146773Ssam}; 374146773Ssam 375146773Ssam/* 376146773Ssam * 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 377146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 378146773Ssam * | Remote PE Address | 379146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 380146773Ssam * | VC ID | 381146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 382146773Ssam * | Encapsulation Type | Must Be Zero | 383146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 384146773Ssam */ 385146773Ssamstruct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t { 386146773Ssam u_int8_t remote_pe_address [4]; 387146773Ssam u_int8_t vc_id [4]; 388146773Ssam u_int8_t encapsulation[2]; 389146773Ssam}; 390146773Ssam 391146773Ssam/* 392146773Ssam * 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 393146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 394146773Ssam * | Sender's PE Address | 395146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 396146773Ssam * | Remote PE Address | 397146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 398146773Ssam * | VC ID | 399146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 400146773Ssam * | Encapsulation Type | Must Be Zero | 401146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 402146773Ssam */ 403146773Ssamstruct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t { 404146773Ssam u_int8_t sender_pe_address [4]; 405146773Ssam u_int8_t remote_pe_address [4]; 406146773Ssam u_int8_t vc_id [4]; 407146773Ssam u_int8_t encapsulation[2]; 408146773Ssam}; 409146773Ssam 410146773Ssam/* 411146773Ssam * 0 1 2 3 412146773Ssam * 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 413146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 414146773Ssam * | MTU | Address Type | Resvd (SBZ) | 415146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 416146773Ssam * | Downstream IP Address (4 or 16 octets) | 417146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 418146773Ssam * | Downstream Interface Address (4 or 16 octets) | 419146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 420146773Ssam * | Hash Key Type | Depth Limit | Multipath Length | 421146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 422146773Ssam * . . 423146773Ssam * . (Multipath Information) . 424146773Ssam * . . 425146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 426146773Ssam * | Downstream Label | Protocol | 427146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 428146773Ssam * . . 429146773Ssam * . . 430146773Ssam * . . 431146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 432146773Ssam * | Downstream Label | Protocol | 433146773Ssam * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 434146773Ssam */ 435146773Ssamstruct lspping_tlv_downstream_map_ipv4_t { 436146773Ssam u_int8_t mtu [2]; 437146773Ssam u_int8_t address_type; 438146773Ssam u_int8_t res; 439146773Ssam u_int8_t downstream_ip[4]; 440146773Ssam u_int8_t downstream_interface[4]; 441146773Ssam}; 442146773Ssam 443146773Ssamstruct lspping_tlv_downstream_map_ipv6_t { 444146773Ssam u_int8_t mtu [2]; 445146773Ssam u_int8_t address_type; 446146773Ssam u_int8_t res; 447146773Ssam u_int8_t downstream_ip[16]; 448146773Ssam u_int8_t downstream_interface[16]; 449146773Ssam}; 450146773Ssam 451146773Ssamstruct lspping_tlv_downstream_map_info_t { 452146773Ssam u_int8_t hash_key_type; 453146773Ssam u_int8_t depth_limit; 454146773Ssam u_int8_t multipath_length [2]; 455146773Ssam}; 456146773Ssam 457146773Ssam#define LSPPING_AFI_IPV4 1 458146773Ssam#define LSPPING_AFI_UNMB 2 459146773Ssam#define LSPPING_AFI_IPV6 3 460146773Ssam 461146773Ssamstatic const struct tok lspping_tlv_downstream_addr_values[] = { 462146773Ssam { LSPPING_AFI_IPV4, "IPv4"}, 463146773Ssam { LSPPING_AFI_IPV6, "IPv6"}, 464146773Ssam { LSPPING_AFI_UNMB, "Unnumbered"}, 465146773Ssam { 0, NULL} 466146773Ssam}; 467146773Ssam 468146773Ssamvoid 469146773Ssamlspping_print(register const u_char *pptr, register u_int len) { 470146773Ssam 471146773Ssam const struct lspping_common_header *lspping_com_header; 472146773Ssam const struct lspping_tlv_header *lspping_tlv_header; 473146773Ssam const struct lspping_tlv_header *lspping_subtlv_header; 474146773Ssam const u_char *tptr,*tlv_tptr,*subtlv_tptr; 475146773Ssam int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen; 476146773Ssam int tlv_hexdump,subtlv_hexdump; 477146773Ssam int lspping_subtlv_len,lspping_subtlv_type; 478146773Ssam struct timeval timestamp; 479146773Ssam 480146773Ssam union { 481146773Ssam const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4; 482146773Ssam const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6; 483146773Ssam const struct lspping_tlv_downstream_map_info_t *lspping_tlv_downstream_map_info; 484146773Ssam } tlv_ptr; 485146773Ssam 486146773Ssam union { 487146773Ssam const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4; 488146773Ssam const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6; 489146773Ssam const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4; 490146773Ssam const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6; 491146773Ssam const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4; 492146773Ssam const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6; 493146773Ssam const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt; 494146773Ssam const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old; 495146773Ssam const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid; 496146773Ssam const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4; 497146773Ssam const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6; 498146773Ssam } subtlv_ptr; 499146773Ssam 500146773Ssam tptr=pptr; 501146773Ssam lspping_com_header = (const struct lspping_common_header *)pptr; 502146773Ssam TCHECK(*lspping_com_header); 503146773Ssam 504146773Ssam /* 505146773Ssam * Sanity checking of the header. 506146773Ssam */ 507146773Ssam if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) { 508146773Ssam printf("LSP-PING version %u packet not supported", 509146773Ssam EXTRACT_16BITS(&lspping_com_header->version[0])); 510146773Ssam return; 511146773Ssam } 512146773Ssam 513146773Ssam /* in non-verbose mode just lets print the basic Message Type*/ 514146773Ssam if (vflag < 1) { 515146773Ssam printf("LSP-PINGv%u, %s, seq %u, length: %u", 516146773Ssam EXTRACT_16BITS(&lspping_com_header->version[0]), 517146773Ssam tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type), 518146773Ssam EXTRACT_32BITS(lspping_com_header->seq_number), 519146773Ssam len); 520146773Ssam return; 521146773Ssam } 522146773Ssam 523146773Ssam /* ok they seem to want to know everything - lets fully decode it */ 524146773Ssam 525146773Ssam tlen=len; 526146773Ssam 527147899Ssam printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)", 528146773Ssam EXTRACT_16BITS(&lspping_com_header->version[0]), 529146773Ssam tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type), 530146773Ssam lspping_com_header->msg_type, 531147899Ssam len, 532146773Ssam tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode), 533146773Ssam lspping_com_header->reply_mode); 534146773Ssam 535146773Ssam /* 536146773Ssam * the following return codes require that the subcode is attached 537146773Ssam * at the end of the translated token output 538146773Ssam */ 539146773Ssam if (lspping_com_header->return_code == 3 || 540146773Ssam lspping_com_header->return_code == 4 || 541146773Ssam lspping_com_header->return_code == 8 || 542146773Ssam lspping_com_header->return_code == 10 || 543146773Ssam lspping_com_header->return_code == 11 || 544146773Ssam lspping_com_header->return_code == 12 ) 545147899Ssam printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)", 546146773Ssam tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), 547146773Ssam lspping_com_header->return_subcode, 548146773Ssam lspping_com_header->return_code, 549146773Ssam lspping_com_header->return_subcode); 550146773Ssam else 551147899Ssam printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)", 552146773Ssam tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), 553146773Ssam lspping_com_header->return_code, 554146773Ssam lspping_com_header->return_subcode); 555146773Ssam 556146773Ssam printf("\n\t Sender Handle: 0x%08x, Sequence: %u", 557146773Ssam EXTRACT_32BITS(lspping_com_header->sender_handle), 558146773Ssam EXTRACT_32BITS(lspping_com_header->seq_number)); 559146773Ssam 560146773Ssam timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec); 561146773Ssam timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec); 562146773Ssam printf("\n\t Sender Timestamp: "); 563146773Ssam ts_print(×tamp); 564146773Ssam 565146773Ssam timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec); 566146773Ssam timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec); 567146773Ssam printf("Receiver Timestamp: "); 568146773Ssam if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0)) 569146773Ssam ts_print(×tamp); 570146773Ssam else 571146773Ssam printf("no timestamp"); 572146773Ssam 573146773Ssam tptr+=sizeof(const struct lspping_common_header); 574146773Ssam tlen-=sizeof(const struct lspping_common_header); 575146773Ssam 576146773Ssam while(tlen>(int)sizeof(struct lspping_tlv_header)) { 577214478Srpaulo 578146773Ssam /* did we capture enough for fully decoding the tlv header ? */ 579146773Ssam if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) 580146773Ssam goto trunc; 581146773Ssam 582146773Ssam lspping_tlv_header = (const struct lspping_tlv_header *)tptr; 583146773Ssam lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type); 584146773Ssam lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length); 585146773Ssam 586190207Srpaulo /* some little sanity checking */ 587190207Srpaulo if (lspping_tlv_type == 0 || lspping_tlv_len == 0) 588146773Ssam return; 589146773Ssam 590190207Srpaulo if(lspping_tlv_len < 4) { 591146773Ssam printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len); 592146773Ssam return; 593146773Ssam } 594146773Ssam 595146773Ssam printf("\n\t %s TLV (%u), length: %u", 596146773Ssam tok2str(lspping_tlv_values, 597146773Ssam "Unknown", 598146773Ssam lspping_tlv_type), 599146773Ssam lspping_tlv_type, 600146773Ssam lspping_tlv_len); 601146773Ssam 602146773Ssam tlv_tptr=tptr+sizeof(struct lspping_tlv_header); 603146773Ssam tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */ 604146773Ssam 605146773Ssam /* did we capture enough for fully decoding the tlv ? */ 606146773Ssam if (!TTEST2(*tptr, lspping_tlv_len)) 607146773Ssam goto trunc; 608146773Ssam tlv_hexdump=FALSE; 609146773Ssam 610146773Ssam switch(lspping_tlv_type) { 611146773Ssam case LSPPING_TLV_TARGET_FEC_STACK: 612146773Ssam while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) { 613146773Ssam 614146773Ssam /* did we capture enough for fully decoding the subtlv header ? */ 615146773Ssam if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) 616146773Ssam goto trunc; 617146773Ssam subtlv_hexdump=FALSE; 618146773Ssam 619146773Ssam lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr; 620146773Ssam lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type); 621146773Ssam lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length); 622146773Ssam subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header); 623146773Ssam 624146773Ssam if (lspping_subtlv_len == 0) 625146773Ssam break; 626146773Ssam 627146773Ssam printf("\n\t %s subTLV (%u), length: %u", 628146773Ssam tok2str(lspping_tlvtargetfec_subtlv_values, 629146773Ssam "Unknown", 630146773Ssam lspping_subtlv_type), 631146773Ssam lspping_subtlv_type, 632146773Ssam lspping_subtlv_len); 633146773Ssam 634146773Ssam switch(lspping_subtlv_type) { 635146773Ssam 636146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4: 637146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \ 638146773Ssam (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr; 639146773Ssam printf("\n\t %s/%u", 640146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix), 641146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len); 642146773Ssam break; 643146773Ssam 644146773Ssam#ifdef INET6 645146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6: 646146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \ 647146773Ssam (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr; 648146773Ssam printf("\n\t %s/%u", 649146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix), 650146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len); 651146773Ssam break; 652146773Ssam#endif 653146773Ssam 654146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4: 655146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \ 656146773Ssam (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr; 657146773Ssam printf("\n\t %s/%u, sender-id %s", 658146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix), 659146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len, 660146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)); 661146773Ssam break; 662146773Ssam 663146773Ssam#ifdef INET6 664146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6: 665146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \ 666146773Ssam (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr; 667146773Ssam printf("\n\t %s/%u, sender-id %s", 668146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix), 669146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len, 670146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)); 671146773Ssam break; 672146773Ssam#endif 673146773Ssam 674146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4: 675146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \ 676146773Ssam (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr; 677146773Ssam printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ 678146773Ssam "\n\t tunnel-id 0x%04x, extended tunnel-id %s", 679146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint), 680146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender), 681146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id), 682146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id), 683146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)); 684146773Ssam break; 685146773Ssam 686146773Ssam#ifdef INET6 687146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6: 688146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \ 689146773Ssam (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr; 690146773Ssam printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ 691146773Ssam "\n\t tunnel-id 0x%04x, extended tunnel-id %s", 692146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint), 693146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender), 694146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id), 695146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id), 696146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)); 697146773Ssam break; 698146773Ssam#endif 699146773Ssam 700146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4: 701146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \ 702146773Ssam (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr; 703146773Ssam printf("\n\t RD: %s, %s/%u", 704146773Ssam bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd), 705146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix), 706146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len); 707146773Ssam break; 708146773Ssam 709146773Ssam#ifdef INET6 710146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6: 711146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \ 712146773Ssam (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr; 713146773Ssam printf("\n\t RD: %s, %s/%u", 714146773Ssam bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd), 715146773Ssam ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix), 716146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len); 717146773Ssam break; 718146773Ssam#endif 719146773Ssam 720146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT: 721146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \ 722146773Ssam (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr; 723146773Ssam printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \ 724146773Ssam "\n\t Encapsulation Type: %s (%u)", 725146773Ssam bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd), 726146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id), 727146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id), 728146773Ssam tok2str(l2vpn_encaps_values, 729146773Ssam "unknown", 730146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)), 731146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)); 732146773Ssam 733146773Ssam break; 734146773Ssam 735146773Ssam /* the old L2VPN VCID subTLV does not have support for the sender field */ 736146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD: 737146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \ 738146773Ssam (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr; 739146773Ssam printf("\n\t Remote PE: %s" \ 740146773Ssam "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", 741146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address), 742146773Ssam EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id), 743146773Ssam tok2str(l2vpn_encaps_values, 744146773Ssam "unknown", 745146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)), 746146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)); 747146773Ssam 748146773Ssam break; 749146773Ssam 750146773Ssam case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID: 751146773Ssam subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \ 752146773Ssam (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr; 753146773Ssam printf("\n\t Sender PE: %s, Remote PE: %s" \ 754146773Ssam "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", 755146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address), 756146773Ssam ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address), 757146773Ssam EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id), 758146773Ssam tok2str(l2vpn_encaps_values, 759146773Ssam "unknown", 760146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)), 761146773Ssam EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)); 762146773Ssam 763146773Ssam break; 764146773Ssam 765146773Ssam default: 766146773Ssam subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */ 767146773Ssam break; 768146773Ssam } 769146773Ssam /* do we want to see an additionally subtlv hexdump ? */ 770146773Ssam if (vflag > 1 || subtlv_hexdump==TRUE) 771146773Ssam print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \ 772146773Ssam "\n\t ", 773146773Ssam lspping_subtlv_len); 774146773Ssam 775146773Ssam tlv_tptr+=lspping_subtlv_len; 776146773Ssam tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header); 777146773Ssam } 778146773Ssam break; 779146773Ssam 780146773Ssam case LSPPING_TLV_DOWNSTREAM_MAPPING: 781146773Ssam /* that strange thing with the downstream map TLV is that until now 782146773Ssam * we do not know if its IPv4 or IPv6 , after we found the adress-type 783146773Ssam * lets recast the tlv_tptr and move on */ 784146773Ssam 785146773Ssam tlv_ptr.lspping_tlv_downstream_map_ipv4= \ 786146773Ssam (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr; 787146773Ssam tlv_ptr.lspping_tlv_downstream_map_ipv6= \ 788146773Ssam (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr; 789146773Ssam printf("\n\t MTU: %u, Address-Type: %s (%u)", 790146773Ssam EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu), 791146773Ssam tok2str(lspping_tlv_downstream_addr_values, 792146773Ssam "unknown", 793146773Ssam tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type), 794146773Ssam tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type); 795146773Ssam 796146773Ssam switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) { 797146773Ssam 798146773Ssam case LSPPING_AFI_IPV4: 799146773Ssam printf("\n\t Downstream IP: %s" \ 800146773Ssam "\n\t Downstream Interface IP: %s", 801146773Ssam ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), 802146773Ssam ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); 803146773Ssam tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); 804146773Ssam tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); 805146773Ssam break; 806146773Ssam#ifdef INET6 807146773Ssam case LSPPING_AFI_IPV6: 808146773Ssam printf("\n\t Downstream IP: %s" \ 809146773Ssam "\n\t Downstream Interface IP: %s", 810146773Ssam ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip), 811146773Ssam ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)); 812146773Ssam tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t); 813146773Ssam tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t); 814146773Ssam break; 815146773Ssam#endif 816146773Ssam case LSPPING_AFI_UNMB: 817146773Ssam printf("\n\t Downstream IP: %s" \ 818146773Ssam "\n\t Downstream Interface Index: 0x%08x", 819146773Ssam ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), 820146773Ssam EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); 821146773Ssam tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); 822146773Ssam tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); 823146773Ssam break; 824146773Ssam 825146773Ssam default: 826146773Ssam /* should not happen ! - no error message - tok2str() has barked already */ 827146773Ssam break; 828146773Ssam } 829146773Ssam 830146773Ssam tlv_ptr.lspping_tlv_downstream_map_info= \ 831146773Ssam (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr; 832146773Ssam 833146773Ssam /* FIXME add hash-key type, depth limit, multipath processing */ 834146773Ssam 835146773Ssam 836146773Ssam tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t); 837146773Ssam tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t); 838146773Ssam 839146773Ssam /* FIXME print downstream labels */ 840146773Ssam 841146773Ssam 842146773Ssam tlv_hexdump=TRUE; /* dump the TLV until code complete */ 843146773Ssam 844146773Ssam break; 845146773Ssam 846172683Smlaier case LSPPING_TLV_BFD_DISCRIMINATOR: 847172683Smlaier tptr += sizeof(struct lspping_tlv_header); 848172683Smlaier if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN)) 849172683Smlaier goto trunc; 850172683Smlaier printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)); 851172683Smlaier break; 852214478Srpaulo 853214478Srpaulo case LSPPING_TLV_VENDOR_ENTERPRISE: 854214478Srpaulo { 855214478Srpaulo u_int32_t vendor_id; 856214478Srpaulo 857214478Srpaulo if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN)) 858214478Srpaulo goto trunc; 859214478Srpaulo vendor_id = EXTRACT_32BITS(tlv_tptr); 860214478Srpaulo printf("\n\t Vendor: %s (0x%04x)", 861214478Srpaulo tok2str(smi_values, "Unknown", vendor_id), 862214478Srpaulo vendor_id); 863214478Srpaulo } 864214478Srpaulo break; 865214478Srpaulo 866146773Ssam /* 867146773Ssam * FIXME those are the defined TLVs that lack a decoder 868146773Ssam * you are welcome to contribute code ;-) 869146773Ssam */ 870146773Ssam case LSPPING_TLV_PAD: 871146773Ssam case LSPPING_TLV_ERROR_CODE: 872146773Ssam case LSPPING_TLV_VENDOR_PRIVATE: 873146773Ssam 874146773Ssam default: 875146773Ssam if (vflag <= 1) 876146773Ssam print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen); 877146773Ssam break; 878146773Ssam } 879146773Ssam /* do we want to see an additionally tlv hexdump ? */ 880146773Ssam if (vflag > 1 || tlv_hexdump==TRUE) 881228926Skevlo print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t ", 882146773Ssam lspping_tlv_len); 883146773Ssam 884190207Srpaulo 885190207Srpaulo /* All TLVs are aligned to four octet boundary */ 886190207Srpaulo if (lspping_tlv_len % 4) { 887190207Srpaulo lspping_tlv_len += (4 - lspping_tlv_len % 4); 888190207Srpaulo } 889190207Srpaulo 890147899Ssam tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header); 891146773Ssam tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header); 892146773Ssam } 893146773Ssam return; 894146773Ssamtrunc: 895146773Ssam printf("\n\t\t packet exceeded snapshot"); 896146773Ssam} 897