X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b751376719cfe1924aa07ab8fd364ec1a55c04b3..refs/heads/master:/print-lspping.c diff --git a/print-lspping.c b/print-lspping.c index b51a3738..04a4b21a 100644 --- a/print-lspping.c +++ b/print-lspping.c @@ -15,17 +15,17 @@ /* \summary: MPLS LSP PING printer */ -/* specification: RFC 4349 */ +/* specification: RFC 4379 */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" #include "addrtoname.h" +#include "ntp.h" #include "l2vpn.h" #include "oui.h" @@ -68,10 +68,8 @@ struct lspping_common_header { nd_uint8_t return_subcode; nd_uint32_t sender_handle; nd_uint32_t seq_number; - nd_uint32_t ts_sent_sec; - nd_uint32_t ts_sent_usec; - nd_uint32_t ts_rcvd_sec; - nd_uint32_t ts_rcvd_usec; + struct l_fixedpt ts_sent; + struct l_fixedpt ts_rcvd; }; #define LSPPING_VERSION 1 @@ -498,7 +496,7 @@ lspping_print(netdissect_options *ndo, u_int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen; int tlv_hexdump,subtlv_hexdump; u_int lspping_subtlv_len,lspping_subtlv_type; - struct timeval timestamp; + uint32_t int_part, fraction; u_int address_type; union { @@ -589,16 +587,14 @@ lspping_print(netdissect_options *ndo, GET_BE_U_4(lspping_com_header->sender_handle), GET_BE_U_4(lspping_com_header->seq_number)); - timestamp.tv_sec=GET_BE_U_4(lspping_com_header->ts_sent_sec); - timestamp.tv_usec=GET_BE_U_4(lspping_com_header->ts_sent_usec); - ND_PRINT("\n\t Sender Timestamp: "); - ts_print(ndo, ×tamp); + ND_PRINT("\n\t TimeStamp Sent: "); + p_ntp_time(ndo, &lspping_com_header->ts_sent); - timestamp.tv_sec=GET_BE_U_4(lspping_com_header->ts_rcvd_sec); - timestamp.tv_usec=GET_BE_U_4(lspping_com_header->ts_rcvd_usec); - ND_PRINT("Receiver Timestamp: "); - if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0)) - ts_print(ndo, ×tamp); + int_part=GET_BE_U_4(lspping_com_header->ts_rcvd.int_part); + fraction=GET_BE_U_4(lspping_com_header->ts_rcvd.fraction); + ND_PRINT("\n\t TimeStamp Received: "); + if (! (int_part == 0 && fraction == 0)) + p_ntp_time(ndo, &lspping_com_header->ts_rcvd); else ND_PRINT("no timestamp"); @@ -610,9 +606,6 @@ lspping_print(netdissect_options *ndo, if (tlen < sizeof(struct lspping_tlv_header)) goto tooshort; - /* did we capture enough for fully decoding the tlv header ? */ - ND_TCHECK_LEN(tptr, sizeof(struct lspping_tlv_header)); - lspping_tlv_header = (const struct lspping_tlv_header *)tptr; lspping_tlv_type=GET_BE_U_2(lspping_tlv_header->type); lspping_tlv_len=GET_BE_U_2(lspping_tlv_header->length); @@ -650,8 +643,6 @@ lspping_print(netdissect_options *ndo, tlv_hexdump = TRUE; goto tlv_tooshort; } - /* did we capture enough for fully decoding the subtlv header ? */ - ND_TCHECK_LEN(tlv_tptr, sizeof(struct lspping_tlv_header)); subtlv_hexdump=FALSE; lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr; @@ -1013,9 +1004,6 @@ lspping_print(netdissect_options *ndo, /* FIXME add hash-key type, depth limit, multipath processing */ - tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t); - tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t); - /* FIXME print downstream labels */ tlv_hexdump=TRUE; /* dump the TLV until code complete */ @@ -1028,8 +1016,7 @@ lspping_print(netdissect_options *ndo, tlv_hexdump = TRUE; goto tlv_tooshort; } else { - ND_TCHECK_LEN(tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN); - ND_PRINT("\n\t BFD Discriminator 0x%08x", GET_BE_U_4(tptr)); + ND_PRINT("\n\t BFD Discriminator 0x%08x", GET_BE_U_4(tlv_tptr)); } break; @@ -1042,7 +1029,6 @@ lspping_print(netdissect_options *ndo, tlv_hexdump = TRUE; goto tlv_tooshort; } else { - ND_TCHECK_LEN(tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN); vendor_id = GET_BE_U_4(tlv_tptr); ND_PRINT("\n\t Vendor: %s (0x%04x)", tok2str(smi_values, "Unknown", vendor_id), @@ -1085,8 +1071,4 @@ lspping_print(netdissect_options *ndo, return; tooshort: ND_PRINT("\n\t\t packet is too short"); - return; -trunc: - nd_print_trunc(ndo); - return; }