X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/0e2f16cc7ea02f9569d04acc01dc82b512086e7c..00c74e34be5c224ec7b18ae763d4db381fa3e7f0:/print-lspping.c diff --git a/print-lspping.c b/print-lspping.c index 631ae139..d78208c2 100644 --- a/print-lspping.c +++ b/print-lspping.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.5 2004-06-12 08:54:57 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.10 2004-06-16 10:35:29 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -31,7 +31,9 @@ static const char rcsid[] _U_ = #include "interface.h" #include "extract.h" #include "addrtoname.h" + #include "bgp.h" +#include "l2vpn.h" /* * LSPPING common header @@ -153,9 +155,10 @@ static const struct tok lspping_tlv_values[] = { #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6 #define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7 #define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8 -#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 9 -#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 10 -#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 11 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9 +#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10 +#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11 +#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12 static const struct tok lspping_tlvtargetfec_subtlv_values[] = { { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"}, @@ -166,6 +169,7 @@ static const struct tok lspping_tlvtargetfec_subtlv_values[] = { { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"}, { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"}, { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"}, + { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"}, { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"}, { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"}, { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"}, @@ -356,7 +360,23 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t { u_int8_t rd [8]; u_int8_t sender_ce_id [2]; u_int8_t receiver_ce_id [2]; - u_int8_t encapsulation; + u_int8_t encapsulation[2]; +}; + +/* + * 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 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Remote PE Address | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | VC ID | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Encapsulation Type | Must Be Zero | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t { + u_int8_t remote_pe_address [4]; + u_int8_t vc_id [4]; + u_int8_t encapsulation[2]; }; /* @@ -375,7 +395,7 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t { u_int8_t sender_pe_address [4]; u_int8_t remote_pe_address [4]; u_int8_t vc_id [4]; - u_int8_t encapsulation; + u_int8_t encapsulation[2]; }; void @@ -388,6 +408,7 @@ lspping_print(register const u_char *pptr, register u_int len) { int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen; int tlv_hexdump,subtlv_hexdump; int lspping_subtlv_len,lspping_subtlv_type; + struct timeval timestamp; union { const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4; @@ -397,6 +418,7 @@ lspping_print(register const u_char *pptr, register u_int len) { const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4; const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6; const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt; + const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old; const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid; const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4; const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6; @@ -457,19 +479,27 @@ lspping_print(register const u_char *pptr, register u_int len) { lspping_com_header->return_code, lspping_com_header->return_subcode); - printf("\n\t Sender Handle: 0x%08x, Sequence: %u" \ - "\n\t Sender Timestamp %u.%us, Receiver Timestamp %u.%us", + printf("\n\t Sender Handle: 0x%08x, Sequence: %u", EXTRACT_32BITS(lspping_com_header->sender_handle), - EXTRACT_32BITS(lspping_com_header->seq_number), - EXTRACT_32BITS(lspping_com_header->ts_sent_sec), /* FIXME: replace with ts_print() */ - EXTRACT_32BITS(lspping_com_header->ts_sent_usec), - EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec), /* FIXME: replace with ts_print() */ - EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec)); + EXTRACT_32BITS(lspping_com_header->seq_number)); + + timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec); + timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec); + printf("\n\t Sender Timestamp: "); + ts_print(×tamp); + + timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec); + timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec); + printf("Receiver Timestamp: "); + if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0)) + ts_print(×tamp); + else + printf("no timestamp"); tptr+=sizeof(const struct lspping_common_header); tlen-=sizeof(const struct lspping_common_header); - while(tlen>0) { + while(tlen>(int)sizeof(struct lspping_tlv_header)) { /* did we capture enough for fully decoding the tlv header ? */ if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) goto trunc; @@ -619,10 +649,25 @@ lspping_print(register const u_char *pptr, register u_int len) { bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id), - tok2str(bgp_l2vpn_encaps_values, + tok2str(l2vpn_encaps_values, + "unknown", + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)); + + break; + + /* the old L2VPN VCID subTLV does not have support for the sender field */ + case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD: + subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \ + (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr; + printf("\n\t Remote PE: %s" \ + "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address), + EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id), + tok2str(l2vpn_encaps_values, "unknown", - subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation), - subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation); + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)); break; @@ -634,10 +679,10 @@ lspping_print(register const u_char *pptr, register u_int len) { ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address), ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address), EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id), - tok2str(bgp_l2vpn_encaps_values, /* FIXME are the L2 encaps codepoints of BGP == LDP ??? */ + tok2str(l2vpn_encaps_values, "unknown", - subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation), - subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation); + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)), + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)); break; @@ -677,7 +722,7 @@ lspping_print(register const u_char *pptr, register u_int len) { lspping_tlv_len); tptr+=lspping_tlv_len; - tlen-=lspping_tlv_len; + tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header); } return; trunc: