Home | History | Annotate | Line # | Download | only in dist
print-lspping.c revision 1.1.1.7
      1      1.1  christos /*
      2      1.1  christos  * Redistribution and use in source and binary forms, with or without
      3      1.1  christos  * modification, are permitted provided that: (1) source code
      4      1.1  christos  * distributions retain the above copyright notice and this paragraph
      5      1.1  christos  * in its entirety, and (2) distributions including binary code include
      6      1.1  christos  * the above copyright notice and this paragraph in its entirety in
      7      1.1  christos  * the documentation or other materials provided with the distribution.
      8      1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
      9      1.1  christos  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
     10      1.1  christos  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     11      1.1  christos  * FOR A PARTICULAR PURPOSE.
     12      1.1  christos  *
     13  1.1.1.7  christos  * Original code by Hannes Gredler (hannes (at) gredler.at)
     14      1.1  christos  */
     15      1.1  christos 
     16  1.1.1.6       spz /* \summary: MPLS LSP PING printer */
     17  1.1.1.6       spz 
     18      1.1  christos #ifdef HAVE_CONFIG_H
     19      1.1  christos #include "config.h"
     20      1.1  christos #endif
     21      1.1  christos 
     22  1.1.1.5  christos #include <netdissect-stdinc.h>
     23      1.1  christos 
     24  1.1.1.5  christos #include "netdissect.h"
     25      1.1  christos #include "extract.h"
     26      1.1  christos #include "addrtoname.h"
     27      1.1  christos 
     28      1.1  christos #include "l2vpn.h"
     29      1.1  christos #include "oui.h"
     30      1.1  christos 
     31  1.1.1.6       spz /* RFC 4349 */
     32  1.1.1.6       spz 
     33      1.1  christos /*
     34      1.1  christos  * LSPPING common header
     35      1.1  christos  *
     36      1.1  christos  *  0                   1                   2                   3
     37      1.1  christos  *  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
     38      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     39      1.1  christos  * |         Version Number        |         Must Be Zero          |
     40      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     41      1.1  christos  * |  Message Type |   Reply mode  |  Return Code  | Return Subcode|
     42      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     43      1.1  christos  * |                        Sender's Handle                        |
     44      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     45      1.1  christos  * |                        Sequence Number                        |
     46      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     47      1.1  christos  * |                    TimeStamp Sent (seconds)                   |
     48      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     49      1.1  christos  * |                  TimeStamp Sent (microseconds)                |
     50      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     51      1.1  christos  * |                  TimeStamp Received (seconds)                 |
     52      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     53      1.1  christos  * |                TimeStamp Received (microseconds)              |
     54      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     55      1.1  christos  * |                            TLVs ...                           |
     56      1.1  christos  * .                                                               .
     57      1.1  christos  * .                                                               .
     58      1.1  christos  * .                                                               .
     59      1.1  christos  */
     60      1.1  christos 
     61      1.1  christos struct lspping_common_header {
     62  1.1.1.3  christos     uint8_t version[2];
     63  1.1.1.6       spz     uint8_t global_flags[2];
     64  1.1.1.3  christos     uint8_t msg_type;
     65  1.1.1.3  christos     uint8_t reply_mode;
     66  1.1.1.3  christos     uint8_t return_code;
     67  1.1.1.3  christos     uint8_t return_subcode;
     68  1.1.1.3  christos     uint8_t sender_handle[4];
     69  1.1.1.3  christos     uint8_t seq_number[4];
     70  1.1.1.3  christos     uint8_t ts_sent_sec[4];
     71  1.1.1.3  christos     uint8_t ts_sent_usec[4];
     72  1.1.1.3  christos     uint8_t ts_rcvd_sec[4];
     73  1.1.1.3  christos     uint8_t ts_rcvd_usec[4];
     74      1.1  christos };
     75      1.1  christos 
     76      1.1  christos #define LSPPING_VERSION            1
     77      1.1  christos 
     78      1.1  christos static const struct tok lspping_msg_type_values[] = {
     79      1.1  christos     { 1, "MPLS Echo Request"},
     80      1.1  christos     { 2, "MPLS Echo Reply"},
     81      1.1  christos     { 0, NULL}
     82      1.1  christos };
     83      1.1  christos 
     84      1.1  christos static const struct tok lspping_reply_mode_values[] = {
     85      1.1  christos     { 1, "Do not reply"},
     86      1.1  christos     { 2, "Reply via an IPv4/IPv6 UDP packet"},
     87      1.1  christos     { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
     88      1.1  christos     { 4, "Reply via application level control channel"},
     89      1.1  christos     { 0, NULL}
     90      1.1  christos };
     91      1.1  christos 
     92      1.1  christos static const struct tok lspping_return_code_values[] = {
     93      1.1  christos     {  0, "No return code or return code contained in the Error Code TLV"},
     94      1.1  christos     {  1, "Malformed echo request received"},
     95      1.1  christos     {  2, "One or more of the TLVs was not understood"},
     96      1.1  christos     {  3, "Replying router is an egress for the FEC at stack depth"},
     97      1.1  christos     {  4, "Replying router has no mapping for the FEC at stack depth"},
     98      1.1  christos     {  5, "Reserved"},
     99      1.1  christos     {  6, "Reserved"},
    100      1.1  christos     {  7, "Reserved"},
    101      1.1  christos     {  8, "Label switched at stack-depth"},
    102      1.1  christos     {  9, "Label switched but no MPLS forwarding at stack-depth"},
    103      1.1  christos     { 10, "Mapping for this FEC is not the given label at stack depth"},
    104      1.1  christos     { 11, "No label entry at stack-depth"},
    105      1.1  christos     { 12, "Protocol not associated with interface at FEC stack depth"},
    106  1.1.1.6       spz     { 13, "Premature termination of ping due to label stack shrinking to a single label"},
    107  1.1.1.7  christos     { 0,  NULL},
    108      1.1  christos };
    109      1.1  christos 
    110      1.1  christos 
    111  1.1.1.3  christos /*
    112      1.1  christos  * LSPPING TLV header
    113      1.1  christos  *  0                   1                   2                   3
    114      1.1  christos  *  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
    115      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    116      1.1  christos  * |             Type              |            Length             |
    117      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    118      1.1  christos  * |                             Value                             |
    119      1.1  christos  * .                                                               .
    120      1.1  christos  * .                                                               .
    121      1.1  christos  * .                                                               .
    122      1.1  christos  * |                                                               |
    123      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    124      1.1  christos  */
    125      1.1  christos 
    126      1.1  christos struct lspping_tlv_header {
    127  1.1.1.3  christos     uint8_t type[2];
    128  1.1.1.3  christos     uint8_t length[2];
    129      1.1  christos };
    130      1.1  christos 
    131      1.1  christos #define	LSPPING_TLV_TARGET_FEC_STACK      1
    132      1.1  christos #define	LSPPING_TLV_DOWNSTREAM_MAPPING    2
    133      1.1  christos #define	LSPPING_TLV_PAD                   3
    134  1.1.1.6       spz /* not assigned                           4 */
    135      1.1  christos #define LSPPING_TLV_VENDOR_ENTERPRISE     5
    136      1.1  christos #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
    137  1.1.1.6       spz /* not assigned                           6 */
    138      1.1  christos #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
    139  1.1.1.6       spz /* not assigned                           8 */
    140      1.1  christos #define	LSPPING_TLV_ERROR_CODE            9
    141      1.1  christos #define LSPPING_TLV_REPLY_TOS_BYTE        10
    142      1.1  christos #define	LSPPING_TLV_BFD_DISCRIMINATOR     15 /* draft-ietf-bfd-mpls-02 */
    143      1.1  christos #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
    144      1.1  christos #define	LSPPING_TLV_VENDOR_PRIVATE        0xfc00
    145      1.1  christos 
    146      1.1  christos static const struct tok lspping_tlv_values[] = {
    147      1.1  christos     { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
    148      1.1  christos     { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
    149      1.1  christos     { LSPPING_TLV_PAD, "Pad" },
    150      1.1  christos     { LSPPING_TLV_ERROR_CODE, "Error Code" },
    151      1.1  christos     { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
    152      1.1  christos     { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
    153      1.1  christos     { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
    154      1.1  christos     { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
    155      1.1  christos     { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
    156      1.1  christos     { 0, NULL}
    157      1.1  christos };
    158      1.1  christos 
    159  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4       1
    160  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6       2
    161  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4      3
    162  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6      4
    163  1.1.1.6       spz /* not assigned                                     5 */
    164  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4     6
    165  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6     7
    166  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT    8
    167  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD 9
    168  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW     10
    169  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_FEC_129_PW     11
    170  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4       12
    171  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6       13
    172  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV4   14
    173  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV6   15
    174  1.1.1.6       spz #define	LSPPING_TLV_TARGETFEC_SUBTLV_NIL_FEC        16
    175      1.1  christos 
    176      1.1  christos static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
    177      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
    178      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
    179      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
    180      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
    181      1.1  christos     { 5, "Reserved"},
    182      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
    183      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
    184      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
    185  1.1.1.6       spz     { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD, "FEC 128 pseudowire (old)"},
    186  1.1.1.6       spz     { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW, "FEC 128 pseudowire"},
    187      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
    188      1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
    189      1.1  christos     { 0, NULL}
    190      1.1  christos };
    191      1.1  christos 
    192      1.1  christos /*
    193      1.1  christos  *  0                   1                   2                   3
    194      1.1  christos  *  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
    195      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    196      1.1  christos  * |                          IPv4 prefix                          |
    197      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    198      1.1  christos  * | Prefix Length |         Must Be Zero                          |
    199      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    200      1.1  christos  */
    201      1.1  christos struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
    202  1.1.1.3  christos     uint8_t prefix [4];
    203  1.1.1.3  christos     uint8_t prefix_len;
    204      1.1  christos };
    205      1.1  christos 
    206      1.1  christos /*
    207      1.1  christos  *  0                   1                   2                   3
    208      1.1  christos  *  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
    209      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    210      1.1  christos  * |                          IPv6 prefix                          |
    211      1.1  christos  * |                          (16 octets)                          |
    212      1.1  christos  * |                                                               |
    213      1.1  christos  * |                                                               |
    214      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    215      1.1  christos  * | Prefix Length |         Must Be Zero                          |
    216      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    217      1.1  christos  */
    218      1.1  christos struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
    219  1.1.1.3  christos     uint8_t prefix [16];
    220  1.1.1.3  christos     uint8_t prefix_len;
    221      1.1  christos };
    222      1.1  christos 
    223      1.1  christos /*
    224      1.1  christos  *  0                   1                   2                   3
    225      1.1  christos  *  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
    226      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    227      1.1  christos  * |                 IPv4 tunnel end point address                 |
    228      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    229      1.1  christos  * |          Must Be Zero         |     Tunnel ID                 |
    230      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    231      1.1  christos  * |                       Extended Tunnel ID                      |
    232      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    233      1.1  christos  * |                   IPv4 tunnel sender address                  |
    234      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    235      1.1  christos  * |          Must Be Zero         |            LSP ID             |
    236      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    237      1.1  christos  */
    238      1.1  christos struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
    239  1.1.1.3  christos     uint8_t tunnel_endpoint [4];
    240  1.1.1.3  christos     uint8_t res[2];
    241  1.1.1.3  christos     uint8_t tunnel_id[2];
    242  1.1.1.3  christos     uint8_t extended_tunnel_id[4];
    243  1.1.1.3  christos     uint8_t tunnel_sender [4];
    244  1.1.1.3  christos     uint8_t res2[2];
    245  1.1.1.3  christos     uint8_t lsp_id [2];
    246      1.1  christos };
    247      1.1  christos 
    248      1.1  christos /*
    249      1.1  christos  *  0                   1                   2                   3
    250      1.1  christos  *  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
    251      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    252      1.1  christos  * |                 IPv6 tunnel end point address                 |
    253      1.1  christos  * |                                                               |
    254      1.1  christos  * |                                                               |
    255      1.1  christos  * |                                                               |
    256      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    257      1.1  christos  * |          Must Be Zero         |          Tunnel ID            |
    258      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    259      1.1  christos  * |                       Extended Tunnel ID                      |
    260      1.1  christos  * |                                                               |
    261      1.1  christos  * |                                                               |
    262      1.1  christos  * |                                                               |
    263      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    264      1.1  christos  * |                   IPv6 tunnel sender address                  |
    265      1.1  christos  * |                                                               |
    266      1.1  christos  * |                                                               |
    267      1.1  christos  * |                                                               |
    268      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    269      1.1  christos  * |          Must Be Zero         |            LSP ID             |
    270      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    271      1.1  christos  */
    272      1.1  christos struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
    273  1.1.1.3  christos     uint8_t tunnel_endpoint [16];
    274  1.1.1.3  christos     uint8_t res[2];
    275  1.1.1.3  christos     uint8_t tunnel_id[2];
    276  1.1.1.3  christos     uint8_t extended_tunnel_id[16];
    277  1.1.1.3  christos     uint8_t tunnel_sender [16];
    278  1.1.1.3  christos     uint8_t res2[2];
    279  1.1.1.3  christos     uint8_t lsp_id [2];
    280      1.1  christos };
    281      1.1  christos 
    282      1.1  christos /*
    283      1.1  christos  *  0                   1                   2                   3
    284      1.1  christos  *  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
    285      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    286      1.1  christos  * |                      Route Distinguisher                      |
    287      1.1  christos  * |                          (8 octets)                           |
    288      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    289      1.1  christos  * |                         IPv4 prefix                           |
    290      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    291      1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    292      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    293      1.1  christos  */
    294      1.1  christos struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
    295  1.1.1.3  christos     uint8_t rd [8];
    296  1.1.1.3  christos     uint8_t prefix [4];
    297  1.1.1.3  christos     uint8_t prefix_len;
    298      1.1  christos };
    299      1.1  christos 
    300      1.1  christos /*
    301      1.1  christos  *  0                   1                   2                   3
    302      1.1  christos  *  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
    303      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    304      1.1  christos  * |                      Route Distinguisher                      |
    305      1.1  christos  * |                          (8 octets)                           |
    306      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    307      1.1  christos  * |                          IPv6 prefix                          |
    308      1.1  christos  * |                          (16 octets)                          |
    309      1.1  christos  * |                                                               |
    310      1.1  christos  * |                                                               |
    311      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    312      1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    313      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    314      1.1  christos  */
    315      1.1  christos struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
    316  1.1.1.3  christos     uint8_t rd [8];
    317  1.1.1.3  christos     uint8_t prefix [16];
    318  1.1.1.3  christos     uint8_t prefix_len;
    319      1.1  christos };
    320      1.1  christos 
    321      1.1  christos /*
    322      1.1  christos  *  0                   1                   2                   3
    323      1.1  christos  *  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
    324      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    325      1.1  christos  * |                      Route Distinguisher                      |
    326      1.1  christos  * |                          (8 octets)                           |
    327      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    328  1.1.1.6       spz  * |         Sender's VE ID        |       Receiver's VE ID        |
    329      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    330      1.1  christos  * |      Encapsulation Type       |         Must Be Zero          |
    331      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    332      1.1  christos  *  0                   1                   2                   3
    333      1.1  christos  */
    334      1.1  christos struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
    335  1.1.1.3  christos     uint8_t rd [8];
    336  1.1.1.6       spz     uint8_t sender_ve_id [2];
    337  1.1.1.6       spz     uint8_t receiver_ve_id [2];
    338  1.1.1.3  christos     uint8_t encapsulation[2];
    339      1.1  christos };
    340      1.1  christos 
    341      1.1  christos /*
    342      1.1  christos  *  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
    343      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    344      1.1  christos  * |                      Remote PE Address                        |
    345      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    346  1.1.1.6       spz  * |                             PW ID                             |
    347      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    348  1.1.1.6       spz  * |            PW Type            |          Must Be Zero         |
    349      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    350      1.1  christos  */
    351  1.1.1.6       spz struct lspping_tlv_targetfec_subtlv_fec_128_pw_old {
    352  1.1.1.3  christos     uint8_t remote_pe_address [4];
    353  1.1.1.6       spz     uint8_t pw_id [4];
    354  1.1.1.6       spz     uint8_t pw_type[2];
    355      1.1  christos };
    356      1.1  christos 
    357      1.1  christos /*
    358      1.1  christos  *  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
    359      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    360      1.1  christos  * |                     Sender's PE Address                       |
    361      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    362      1.1  christos  * |                      Remote PE Address                        |
    363      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    364  1.1.1.6       spz  * |                             PW ID                             |
    365      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    366  1.1.1.6       spz  * |            PW Type            |          Must Be Zero         |
    367      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    368      1.1  christos  */
    369  1.1.1.6       spz struct lspping_tlv_targetfec_subtlv_fec_128_pw {
    370  1.1.1.3  christos     uint8_t sender_pe_address [4];
    371  1.1.1.3  christos     uint8_t remote_pe_address [4];
    372  1.1.1.6       spz     uint8_t pw_id [4];
    373  1.1.1.6       spz     uint8_t pw_type[2];
    374  1.1.1.6       spz };
    375  1.1.1.6       spz 
    376  1.1.1.6       spz /*
    377  1.1.1.6       spz  * 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
    378  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    379  1.1.1.6       spz  * |                         IPv4 prefix                           |
    380  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    381  1.1.1.6       spz  * | Prefix Length |                 Must Be Zero                  |
    382  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    383  1.1.1.6       spz  */
    384  1.1.1.6       spz struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
    385  1.1.1.6       spz     uint8_t prefix [4];
    386  1.1.1.6       spz     uint8_t prefix_len;
    387  1.1.1.6       spz };
    388  1.1.1.6       spz 
    389  1.1.1.6       spz /*
    390  1.1.1.6       spz  * 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
    391  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    392  1.1.1.6       spz  * |                          IPv6 prefix                          |
    393  1.1.1.6       spz  * |                          (16 octets)                          |
    394  1.1.1.6       spz  * |                                                               |
    395  1.1.1.6       spz  * |                                                               |
    396  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    397  1.1.1.6       spz  * | Prefix Length |                 Must Be Zero                  |
    398  1.1.1.6       spz  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    399  1.1.1.6       spz  */
    400  1.1.1.6       spz struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
    401  1.1.1.6       spz     uint8_t prefix [16];
    402  1.1.1.6       spz     uint8_t prefix_len;
    403      1.1  christos };
    404      1.1  christos 
    405      1.1  christos /*
    406      1.1  christos  *  0                   1                   2                   3
    407      1.1  christos  *  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
    408      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    409      1.1  christos  * |               MTU             | Address Type  |  Resvd (SBZ)  |
    410      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    411      1.1  christos  * |             Downstream IP Address (4 or 16 octets)            |
    412      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    413      1.1  christos  * |         Downstream Interface Address (4 or 16 octets)         |
    414      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    415  1.1.1.6       spz  * | Multipath Type| Depth Limit   |        Multipath Length       |
    416      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    417      1.1  christos  * .                                                               .
    418      1.1  christos  * .                     (Multipath Information)                   .
    419      1.1  christos  * .                                                               .
    420      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    421      1.1  christos  * |               Downstream Label                |    Protocol   |
    422      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    423      1.1  christos  * .                                                               .
    424      1.1  christos  * .                                                               .
    425      1.1  christos  * .                                                               .
    426      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    427      1.1  christos  * |               Downstream Label                |    Protocol   |
    428      1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    429      1.1  christos  */
    430  1.1.1.6       spz /* Enough to get the address type */
    431  1.1.1.6       spz struct lspping_tlv_downstream_map_t {
    432  1.1.1.6       spz     uint8_t mtu [2];
    433  1.1.1.6       spz     uint8_t address_type;
    434  1.1.1.6       spz     uint8_t ds_flags;
    435  1.1.1.6       spz };
    436  1.1.1.6       spz 
    437      1.1  christos struct lspping_tlv_downstream_map_ipv4_t {
    438  1.1.1.3  christos     uint8_t mtu [2];
    439  1.1.1.3  christos     uint8_t address_type;
    440  1.1.1.6       spz     uint8_t ds_flags;
    441  1.1.1.6       spz     uint8_t downstream_ip[4];
    442  1.1.1.6       spz     uint8_t downstream_interface[4];
    443  1.1.1.6       spz };
    444  1.1.1.6       spz 
    445  1.1.1.6       spz struct lspping_tlv_downstream_map_ipv4_unmb_t {
    446  1.1.1.6       spz     uint8_t mtu [2];
    447  1.1.1.6       spz     uint8_t address_type;
    448  1.1.1.6       spz     uint8_t ds_flags;
    449  1.1.1.3  christos     uint8_t downstream_ip[4];
    450  1.1.1.3  christos     uint8_t downstream_interface[4];
    451      1.1  christos };
    452      1.1  christos 
    453      1.1  christos struct lspping_tlv_downstream_map_ipv6_t {
    454  1.1.1.3  christos     uint8_t mtu [2];
    455  1.1.1.3  christos     uint8_t address_type;
    456  1.1.1.6       spz     uint8_t ds_flags;
    457  1.1.1.3  christos     uint8_t downstream_ip[16];
    458  1.1.1.3  christos     uint8_t downstream_interface[16];
    459      1.1  christos };
    460      1.1  christos 
    461  1.1.1.6       spz struct lspping_tlv_downstream_map_ipv6_unmb_t {
    462  1.1.1.6       spz     uint8_t mtu [2];
    463  1.1.1.6       spz     uint8_t address_type;
    464  1.1.1.6       spz     uint8_t ds_flags;
    465  1.1.1.6       spz     uint8_t downstream_ip[16];
    466  1.1.1.6       spz     uint8_t downstream_interface[4];
    467  1.1.1.6       spz };
    468  1.1.1.6       spz 
    469      1.1  christos struct lspping_tlv_downstream_map_info_t {
    470  1.1.1.6       spz     uint8_t multipath_type;
    471  1.1.1.3  christos     uint8_t depth_limit;
    472  1.1.1.3  christos     uint8_t multipath_length [2];
    473      1.1  christos };
    474      1.1  christos 
    475  1.1.1.6       spz #define LSPPING_AFI_IPV4      1
    476  1.1.1.6       spz #define LSPPING_AFI_IPV4_UNMB 2
    477  1.1.1.6       spz #define LSPPING_AFI_IPV6      3
    478  1.1.1.6       spz #define LSPPING_AFI_IPV6_UNMB 4
    479      1.1  christos 
    480      1.1  christos static const struct tok lspping_tlv_downstream_addr_values[] = {
    481  1.1.1.6       spz     { LSPPING_AFI_IPV4,      "IPv4"},
    482  1.1.1.6       spz     { LSPPING_AFI_IPV4_UNMB, "Unnumbered IPv4"},
    483  1.1.1.6       spz     { LSPPING_AFI_IPV6,      "IPv6"},
    484  1.1.1.6       spz     { LSPPING_AFI_IPV6_UNMB, "IPv6"},
    485      1.1  christos     { 0, NULL}
    486      1.1  christos };
    487      1.1  christos 
    488      1.1  christos void
    489  1.1.1.3  christos lspping_print(netdissect_options *ndo,
    490  1.1.1.4  christos               register const u_char *pptr, register u_int len)
    491  1.1.1.4  christos {
    492      1.1  christos     const struct lspping_common_header *lspping_com_header;
    493      1.1  christos     const struct lspping_tlv_header *lspping_tlv_header;
    494      1.1  christos     const struct lspping_tlv_header *lspping_subtlv_header;
    495      1.1  christos     const u_char *tptr,*tlv_tptr,*subtlv_tptr;
    496  1.1.1.6       spz     u_int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
    497      1.1  christos     int tlv_hexdump,subtlv_hexdump;
    498  1.1.1.6       spz     u_int lspping_subtlv_len,lspping_subtlv_type;
    499  1.1.1.3  christos     struct timeval timestamp;
    500      1.1  christos 
    501      1.1  christos     union {
    502  1.1.1.6       spz         const struct lspping_tlv_downstream_map_t *lspping_tlv_downstream_map;
    503      1.1  christos         const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
    504  1.1.1.6       spz         const struct lspping_tlv_downstream_map_ipv4_unmb_t *lspping_tlv_downstream_map_ipv4_unmb;
    505      1.1  christos         const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6;
    506  1.1.1.6       spz         const struct lspping_tlv_downstream_map_ipv6_unmb_t *lspping_tlv_downstream_map_ipv6_unmb;
    507      1.1  christos         const struct lspping_tlv_downstream_map_info_t  *lspping_tlv_downstream_map_info;
    508      1.1  christos     } tlv_ptr;
    509      1.1  christos 
    510      1.1  christos     union {
    511      1.1  christos         const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4;
    512      1.1  christos         const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6;
    513      1.1  christos         const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4;
    514      1.1  christos         const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6;
    515      1.1  christos         const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
    516      1.1  christos         const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
    517      1.1  christos         const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt;
    518  1.1.1.6       spz         const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
    519  1.1.1.6       spz         const struct lspping_tlv_targetfec_subtlv_fec_128_pw *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
    520      1.1  christos         const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
    521      1.1  christos         const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
    522      1.1  christos     } subtlv_ptr;
    523      1.1  christos 
    524      1.1  christos     tptr=pptr;
    525      1.1  christos     lspping_com_header = (const struct lspping_common_header *)pptr;
    526  1.1.1.6       spz     if (len < sizeof(const struct lspping_common_header))
    527  1.1.1.6       spz         goto tooshort;
    528  1.1.1.3  christos     ND_TCHECK(*lspping_com_header);
    529      1.1  christos 
    530      1.1  christos     /*
    531      1.1  christos      * Sanity checking of the header.
    532      1.1  christos      */
    533      1.1  christos     if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
    534  1.1.1.3  christos 	ND_PRINT((ndo, "LSP-PING version %u packet not supported",
    535  1.1.1.3  christos                EXTRACT_16BITS(&lspping_com_header->version[0])));
    536      1.1  christos 	return;
    537      1.1  christos     }
    538      1.1  christos 
    539      1.1  christos     /* in non-verbose mode just lets print the basic Message Type*/
    540  1.1.1.3  christos     if (ndo->ndo_vflag < 1) {
    541  1.1.1.3  christos         ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
    542      1.1  christos                EXTRACT_16BITS(&lspping_com_header->version[0]),
    543      1.1  christos                tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
    544      1.1  christos                EXTRACT_32BITS(lspping_com_header->seq_number),
    545  1.1.1.3  christos                len));
    546      1.1  christos         return;
    547      1.1  christos     }
    548      1.1  christos 
    549      1.1  christos     /* ok they seem to want to know everything - lets fully decode it */
    550      1.1  christos 
    551      1.1  christos     tlen=len;
    552      1.1  christos 
    553  1.1.1.3  christos     ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t  reply-mode: %s (%u)",
    554      1.1  christos            EXTRACT_16BITS(&lspping_com_header->version[0]),
    555      1.1  christos            tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
    556      1.1  christos            lspping_com_header->msg_type,
    557      1.1  christos            len,
    558      1.1  christos            tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
    559  1.1.1.3  christos            lspping_com_header->reply_mode));
    560      1.1  christos 
    561      1.1  christos     /*
    562      1.1  christos      *  the following return codes require that the subcode is attached
    563      1.1  christos      *  at the end of the translated token output
    564      1.1  christos      */
    565      1.1  christos     if (lspping_com_header->return_code == 3 ||
    566      1.1  christos         lspping_com_header->return_code == 4 ||
    567      1.1  christos         lspping_com_header->return_code == 8 ||
    568      1.1  christos         lspping_com_header->return_code == 10 ||
    569      1.1  christos         lspping_com_header->return_code == 11 ||
    570      1.1  christos         lspping_com_header->return_code == 12 )
    571  1.1.1.3  christos         ND_PRINT((ndo, "\n\t  Return Code: %s %u (%u)\n\t  Return Subcode: (%u)",
    572      1.1  christos                tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
    573  1.1.1.3  christos                lspping_com_header->return_subcode,
    574      1.1  christos                lspping_com_header->return_code,
    575  1.1.1.3  christos                lspping_com_header->return_subcode));
    576      1.1  christos     else
    577  1.1.1.3  christos         ND_PRINT((ndo, "\n\t  Return Code: %s (%u)\n\t  Return Subcode: (%u)",
    578  1.1.1.3  christos                tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
    579      1.1  christos                lspping_com_header->return_code,
    580  1.1.1.3  christos                lspping_com_header->return_subcode));
    581  1.1.1.3  christos 
    582  1.1.1.3  christos     ND_PRINT((ndo, "\n\t  Sender Handle: 0x%08x, Sequence: %u",
    583      1.1  christos            EXTRACT_32BITS(lspping_com_header->sender_handle),
    584  1.1.1.3  christos            EXTRACT_32BITS(lspping_com_header->seq_number)));
    585      1.1  christos 
    586      1.1  christos     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
    587  1.1.1.3  christos     timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
    588  1.1.1.3  christos     ND_PRINT((ndo, "\n\t  Sender Timestamp: "));
    589  1.1.1.3  christos     ts_print(ndo, &timestamp);
    590      1.1  christos 
    591      1.1  christos     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
    592  1.1.1.3  christos     timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
    593  1.1.1.3  christos     ND_PRINT((ndo, "Receiver Timestamp: "));
    594      1.1  christos     if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
    595  1.1.1.3  christos         ts_print(ndo, &timestamp);
    596      1.1  christos     else
    597  1.1.1.3  christos         ND_PRINT((ndo, "no timestamp"));
    598      1.1  christos 
    599      1.1  christos     tptr+=sizeof(const struct lspping_common_header);
    600      1.1  christos     tlen-=sizeof(const struct lspping_common_header);
    601      1.1  christos 
    602  1.1.1.6       spz     while (tlen != 0) {
    603  1.1.1.6       spz         /* Does the TLV go past the end of the packet? */
    604  1.1.1.6       spz         if (tlen < sizeof(struct lspping_tlv_header))
    605  1.1.1.6       spz             goto tooshort;
    606      1.1  christos 
    607      1.1  christos         /* did we capture enough for fully decoding the tlv header ? */
    608  1.1.1.3  christos         ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
    609      1.1  christos 
    610      1.1  christos         lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
    611      1.1  christos         lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
    612      1.1  christos         lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length);
    613      1.1  christos 
    614  1.1.1.3  christos         ND_PRINT((ndo, "\n\t  %s TLV (%u), length: %u",
    615      1.1  christos                tok2str(lspping_tlv_values,
    616      1.1  christos                        "Unknown",
    617      1.1  christos                        lspping_tlv_type),
    618      1.1  christos                lspping_tlv_type,
    619  1.1.1.3  christos                lspping_tlv_len));
    620      1.1  christos 
    621  1.1.1.6       spz         /* some little sanity checking */
    622  1.1.1.6       spz         if (lspping_tlv_len == 0) {
    623  1.1.1.6       spz             tptr+=sizeof(struct lspping_tlv_header);
    624  1.1.1.6       spz             tlen-=sizeof(struct lspping_tlv_header);
    625  1.1.1.6       spz             continue;    /* no value to dissect */
    626  1.1.1.6       spz         }
    627  1.1.1.6       spz 
    628      1.1  christos         tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
    629      1.1  christos         tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
    630      1.1  christos 
    631  1.1.1.6       spz         /* Does the TLV go past the end of the packet? */
    632  1.1.1.6       spz         if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
    633  1.1.1.6       spz             goto tooshort;
    634      1.1  christos         /* did we capture enough for fully decoding the tlv ? */
    635  1.1.1.6       spz         ND_TCHECK2(*tlv_tptr, lspping_tlv_len);
    636      1.1  christos         tlv_hexdump=FALSE;
    637      1.1  christos 
    638      1.1  christos         switch(lspping_tlv_type) {
    639      1.1  christos         case LSPPING_TLV_TARGET_FEC_STACK:
    640  1.1.1.6       spz             while (tlv_tlen != 0) {
    641  1.1.1.6       spz                 /* Does the subTLV header go past the end of the TLV? */
    642  1.1.1.6       spz                 if (tlv_tlen < sizeof(struct lspping_tlv_header)) {
    643  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    644  1.1.1.6       spz                     tlv_hexdump = TRUE;
    645  1.1.1.6       spz                     goto tlv_tooshort;
    646  1.1.1.6       spz                 }
    647      1.1  christos                 /* did we capture enough for fully decoding the subtlv header ? */
    648  1.1.1.6       spz                 ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_header));
    649      1.1  christos                 subtlv_hexdump=FALSE;
    650      1.1  christos 
    651      1.1  christos                 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
    652      1.1  christos                 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
    653      1.1  christos                 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
    654      1.1  christos                 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
    655  1.1.1.3  christos 
    656  1.1.1.6       spz                 /* Does the subTLV go past the end of the TLV? */
    657  1.1.1.6       spz                 if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
    658  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    659  1.1.1.6       spz                     tlv_hexdump = TRUE;
    660  1.1.1.6       spz                     goto tlv_tooshort;
    661  1.1.1.6       spz                 }
    662  1.1.1.6       spz 
    663  1.1.1.6       spz                 /* Did we capture enough for fully decoding the subTLV? */
    664  1.1.1.6       spz                 ND_TCHECK2(*subtlv_tptr, lspping_subtlv_len);
    665      1.1  christos 
    666  1.1.1.3  christos                 ND_PRINT((ndo, "\n\t    %s subTLV (%u), length: %u",
    667      1.1  christos                        tok2str(lspping_tlvtargetfec_subtlv_values,
    668      1.1  christos                                "Unknown",
    669      1.1  christos                                lspping_subtlv_type),
    670      1.1  christos                        lspping_subtlv_type,
    671  1.1.1.3  christos                        lspping_subtlv_len));
    672      1.1  christos 
    673      1.1  christos                 switch(lspping_subtlv_type) {
    674      1.1  christos 
    675      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
    676  1.1.1.6       spz                     /* Is the subTLV length correct? */
    677  1.1.1.6       spz                     if (lspping_subtlv_len != 5) {
    678  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 5"));
    679  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    680  1.1.1.6       spz                     } else {
    681  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
    682  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
    683  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      %s/%u",
    684  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
    685  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
    686  1.1.1.6       spz                     }
    687      1.1  christos                     break;
    688      1.1  christos 
    689      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
    690  1.1.1.6       spz                     /* Is the subTLV length correct? */
    691  1.1.1.6       spz                     if (lspping_subtlv_len != 17) {
    692  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 17"));
    693  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    694  1.1.1.6       spz                     } else {
    695  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
    696  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
    697  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      %s/%u",
    698  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
    699  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
    700  1.1.1.6       spz                     }
    701      1.1  christos                     break;
    702      1.1  christos 
    703      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
    704  1.1.1.6       spz                     /* Is the subTLV length correct? */
    705  1.1.1.6       spz                     if (lspping_subtlv_len != 5) {
    706  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 5"));
    707  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    708  1.1.1.6       spz                     } else {
    709  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
    710  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
    711  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      %s/%u",
    712  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
    713  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len));
    714  1.1.1.6       spz                     }
    715      1.1  christos                     break;
    716      1.1  christos 
    717      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
    718  1.1.1.6       spz                     /* Is the subTLV length correct? */
    719  1.1.1.6       spz                     if (lspping_subtlv_len != 17) {
    720  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 17"));
    721  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    722  1.1.1.6       spz                     } else {
    723  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
    724  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
    725  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      %s/%u",
    726  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
    727  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len));
    728  1.1.1.6       spz                     }
    729      1.1  christos                     break;
    730      1.1  christos 
    731      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
    732  1.1.1.6       spz                     /* Is the subTLV length correct? */
    733  1.1.1.6       spz                     if (lspping_subtlv_len != 20) {
    734  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 20"));
    735  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    736  1.1.1.6       spz                     } else {
    737  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
    738  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
    739  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
    740  1.1.1.6       spz                                "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
    741  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
    742  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
    743  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
    744  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
    745  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
    746  1.1.1.6       spz                     }
    747      1.1  christos                     break;
    748      1.1  christos 
    749      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
    750  1.1.1.6       spz                     /* Is the subTLV length correct? */
    751  1.1.1.6       spz                     if (lspping_subtlv_len != 56) {
    752  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 56"));
    753  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    754  1.1.1.6       spz                     } else {
    755  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
    756  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
    757  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
    758  1.1.1.6       spz                                "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
    759  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
    760  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
    761  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
    762  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
    763  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
    764  1.1.1.6       spz                     }
    765      1.1  christos                     break;
    766      1.1  christos 
    767      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
    768  1.1.1.6       spz                     /* Is the subTLV length correct? */
    769  1.1.1.6       spz                     if (lspping_subtlv_len != 13) {
    770  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 13"));
    771  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    772  1.1.1.6       spz                     } else {
    773  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
    774  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
    775  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
    776  1.1.1.6       spz                                bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
    777  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
    778  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
    779  1.1.1.6       spz                     }
    780      1.1  christos                     break;
    781      1.1  christos 
    782      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
    783  1.1.1.6       spz                     /* Is the subTLV length correct? */
    784  1.1.1.6       spz                     if (lspping_subtlv_len != 25) {
    785  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 25"));
    786  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    787  1.1.1.6       spz                     } else {
    788  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
    789  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
    790  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
    791  1.1.1.6       spz                                bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
    792  1.1.1.6       spz                                ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
    793  1.1.1.6       spz                                subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
    794  1.1.1.6       spz                     }
    795      1.1  christos                     break;
    796      1.1  christos 
    797      1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
    798  1.1.1.6       spz                     /* Is the subTLV length correct? */
    799  1.1.1.6       spz                     if (lspping_subtlv_len != 14) {
    800  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 14"));
    801  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    802  1.1.1.6       spz                     } else {
    803  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
    804  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
    805  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      RD: %s, Sender VE ID: %u, Receiver VE ID: %u" \
    806  1.1.1.6       spz                                "\n\t      Encapsulation Type: %s (%u)",
    807  1.1.1.6       spz                                bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
    808  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ve_id),
    809  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ve_id),
    810  1.1.1.6       spz                                tok2str(mpls_pw_types_values,
    811  1.1.1.6       spz                                        "unknown",
    812  1.1.1.6       spz                                        EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
    813  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
    814  1.1.1.6       spz                     }
    815      1.1  christos                     break;
    816      1.1  christos 
    817      1.1  christos                     /* the old L2VPN VCID subTLV does not have support for the sender field */
    818  1.1.1.6       spz                 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD:
    819  1.1.1.6       spz                     /* Is the subTLV length correct? */
    820  1.1.1.6       spz                     if (lspping_subtlv_len != 10) {
    821  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 10"));
    822  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    823  1.1.1.6       spz                     } else {
    824  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
    825  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *)subtlv_tptr;
    826  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      Remote PE: %s" \
    827  1.1.1.6       spz                                "\n\t      PW ID: 0x%08x, PW Type: %s (%u)",
    828  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
    829  1.1.1.6       spz                                EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_id),
    830  1.1.1.6       spz                                tok2str(mpls_pw_types_values,
    831  1.1.1.6       spz                                        "unknown",
    832  1.1.1.6       spz                                        EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type)),
    833  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type)));
    834  1.1.1.6       spz                     }
    835      1.1  christos                     break;
    836      1.1  christos 
    837  1.1.1.6       spz                 case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW:
    838  1.1.1.6       spz                     /* Is the subTLV length correct? */
    839  1.1.1.6       spz                     if (lspping_subtlv_len != 14) {
    840  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      invalid subTLV length, should be 14"));
    841  1.1.1.6       spz                         subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    842  1.1.1.6       spz                     } else {
    843  1.1.1.6       spz                         subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
    844  1.1.1.6       spz                             (const struct lspping_tlv_targetfec_subtlv_fec_128_pw *)subtlv_tptr;
    845  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t      Sender PE: %s, Remote PE: %s" \
    846  1.1.1.6       spz                                "\n\t      PW ID: 0x%08x, PW Type: %s (%u)",
    847  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
    848  1.1.1.6       spz                                ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
    849  1.1.1.6       spz                                EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_id),
    850  1.1.1.6       spz                                tok2str(mpls_pw_types_values,
    851  1.1.1.6       spz                                        "unknown",
    852  1.1.1.6       spz                                        EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type)),
    853  1.1.1.6       spz                                EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type)));
    854  1.1.1.6       spz                     }
    855      1.1  christos                     break;
    856      1.1  christos 
    857      1.1  christos                 default:
    858      1.1  christos                     subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    859      1.1  christos                     break;
    860      1.1  christos                 }
    861      1.1  christos                 /* do we want to see an additionally subtlv hexdump ? */
    862  1.1.1.3  christos                 if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
    863  1.1.1.3  christos                     print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
    864      1.1  christos                                        "\n\t      ",
    865      1.1  christos                                        lspping_subtlv_len);
    866      1.1  christos 
    867  1.1.1.6       spz                 /* All subTLVs are aligned to four octet boundary */
    868  1.1.1.6       spz                 if (lspping_subtlv_len % 4) {
    869  1.1.1.6       spz                     lspping_subtlv_len += 4 - (lspping_subtlv_len % 4);
    870  1.1.1.6       spz                     /* Does the subTLV, including padding, go past the end of the TLV? */
    871  1.1.1.6       spz                     if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
    872  1.1.1.6       spz                         ND_PRINT((ndo, "\n\t\t TLV is too short"));
    873  1.1.1.6       spz                         return;
    874  1.1.1.6       spz                     }
    875  1.1.1.6       spz                 }
    876      1.1  christos                 tlv_tptr+=lspping_subtlv_len;
    877      1.1  christos                 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
    878      1.1  christos             }
    879      1.1  christos             break;
    880      1.1  christos 
    881      1.1  christos         case LSPPING_TLV_DOWNSTREAM_MAPPING:
    882  1.1.1.6       spz             /* Does the header go past the end of the TLV? */
    883  1.1.1.6       spz             if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_t)) {
    884  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t      TLV is too short"));
    885  1.1.1.6       spz                 tlv_hexdump = TRUE;
    886  1.1.1.6       spz                 goto tlv_tooshort;
    887  1.1.1.6       spz             }
    888  1.1.1.6       spz             /* Did we capture enough to get the address family? */
    889  1.1.1.6       spz             ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_t));
    890  1.1.1.6       spz 
    891  1.1.1.6       spz             tlv_ptr.lspping_tlv_downstream_map= \
    892  1.1.1.6       spz                 (const struct lspping_tlv_downstream_map_t *)tlv_tptr;
    893  1.1.1.6       spz 
    894      1.1  christos             /* that strange thing with the downstream map TLV is that until now
    895  1.1.1.6       spz              * we do not know if its IPv4 or IPv6 or is unnumbered; after
    896  1.1.1.6       spz              * we find the address-type, we recast the tlv_tptr and move on. */
    897      1.1  christos 
    898  1.1.1.3  christos             ND_PRINT((ndo, "\n\t    MTU: %u, Address-Type: %s (%u)",
    899  1.1.1.6       spz                    EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map->mtu),
    900      1.1  christos                    tok2str(lspping_tlv_downstream_addr_values,
    901      1.1  christos                            "unknown",
    902  1.1.1.6       spz                            tlv_ptr.lspping_tlv_downstream_map->address_type),
    903  1.1.1.6       spz                    tlv_ptr.lspping_tlv_downstream_map->address_type));
    904      1.1  christos 
    905  1.1.1.6       spz             switch(tlv_ptr.lspping_tlv_downstream_map->address_type) {
    906      1.1  christos 
    907      1.1  christos             case LSPPING_AFI_IPV4:
    908  1.1.1.6       spz                 /* Does the data go past the end of the TLV? */
    909  1.1.1.6       spz                 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_t)) {
    910  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    911  1.1.1.6       spz                     tlv_hexdump = TRUE;
    912  1.1.1.6       spz                     goto tlv_tooshort;
    913  1.1.1.6       spz                 }
    914  1.1.1.6       spz                 /* Did we capture enough for this part of the TLV? */
    915  1.1.1.6       spz                 ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv4_t));
    916  1.1.1.6       spz 
    917  1.1.1.6       spz                 tlv_ptr.lspping_tlv_downstream_map_ipv4= \
    918  1.1.1.6       spz                     (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
    919  1.1.1.3  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    920      1.1  christos                        "\n\t    Downstream Interface IP: %s",
    921  1.1.1.3  christos                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
    922  1.1.1.3  christos                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
    923      1.1  christos                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    924      1.1  christos                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    925      1.1  christos                 break;
    926  1.1.1.6       spz             case LSPPING_AFI_IPV4_UNMB:
    927  1.1.1.6       spz                 /* Does the data go past the end of the TLV? */
    928  1.1.1.6       spz                 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t)) {
    929  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    930  1.1.1.6       spz                     tlv_hexdump = TRUE;
    931  1.1.1.6       spz                     goto tlv_tooshort;
    932  1.1.1.6       spz                 }
    933  1.1.1.6       spz                 /* Did we capture enough for this part of the TLV? */
    934  1.1.1.6       spz                 ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t));
    935  1.1.1.6       spz 
    936  1.1.1.6       spz                 tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb= \
    937  1.1.1.6       spz                     (const struct lspping_tlv_downstream_map_ipv4_unmb_t *)tlv_tptr;
    938  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    939  1.1.1.6       spz                        "\n\t    Downstream Interface Index: 0x%08x",
    940  1.1.1.6       spz                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_ip),
    941  1.1.1.6       spz                        EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_interface)));
    942  1.1.1.6       spz                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
    943  1.1.1.6       spz                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
    944  1.1.1.6       spz                 break;
    945  1.1.1.6       spz             case LSPPING_AFI_IPV6:
    946  1.1.1.6       spz                 /* Does the data go past the end of the TLV? */
    947  1.1.1.6       spz                 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_t)) {
    948  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    949  1.1.1.6       spz                     tlv_hexdump = TRUE;
    950  1.1.1.6       spz                     goto tlv_tooshort;
    951  1.1.1.6       spz                 }
    952  1.1.1.6       spz                 /* Did we capture enough for this part of the TLV? */
    953  1.1.1.6       spz                 ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv6_t));
    954  1.1.1.6       spz 
    955  1.1.1.6       spz                 tlv_ptr.lspping_tlv_downstream_map_ipv6= \
    956  1.1.1.6       spz                     (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
    957  1.1.1.3  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    958      1.1  christos                        "\n\t    Downstream Interface IP: %s",
    959  1.1.1.3  christos                        ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
    960  1.1.1.3  christos                        ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
    961      1.1  christos                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
    962      1.1  christos                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
    963      1.1  christos                 break;
    964  1.1.1.6       spz              case LSPPING_AFI_IPV6_UNMB:
    965  1.1.1.6       spz                 /* Does the data go past the end of the TLV? */
    966  1.1.1.6       spz                 if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t)) {
    967  1.1.1.6       spz                     ND_PRINT((ndo, "\n\t      TLV is too short"));
    968  1.1.1.6       spz                     tlv_hexdump = TRUE;
    969  1.1.1.6       spz                     goto tlv_tooshort;
    970  1.1.1.6       spz                 }
    971  1.1.1.6       spz                 /* Did we capture enough for this part of the TLV? */
    972  1.1.1.6       spz                 ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t));
    973  1.1.1.6       spz 
    974  1.1.1.6       spz                 tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb= \
    975  1.1.1.6       spz                    (const struct lspping_tlv_downstream_map_ipv6_unmb_t *)tlv_tptr;
    976  1.1.1.3  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    977      1.1  christos                        "\n\t    Downstream Interface Index: 0x%08x",
    978  1.1.1.6       spz                        ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_ip),
    979  1.1.1.6       spz                        EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_interface)));
    980  1.1.1.6       spz                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
    981  1.1.1.6       spz                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
    982      1.1  christos                 break;
    983      1.1  christos 
    984      1.1  christos             default:
    985      1.1  christos                 /* should not happen ! - no error message - tok2str() has barked already */
    986      1.1  christos                 break;
    987      1.1  christos             }
    988      1.1  christos 
    989  1.1.1.6       spz             /* Does the data go past the end of the TLV? */
    990  1.1.1.6       spz             if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_info_t)) {
    991  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t      TLV is too short"));
    992  1.1.1.6       spz                 tlv_hexdump = TRUE;
    993  1.1.1.6       spz                 goto tlv_tooshort;
    994  1.1.1.6       spz             }
    995  1.1.1.6       spz             /* Did we capture enough for this part of the TLV? */
    996  1.1.1.6       spz             ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_info_t));
    997  1.1.1.6       spz 
    998      1.1  christos             tlv_ptr.lspping_tlv_downstream_map_info= \
    999      1.1  christos                 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
   1000  1.1.1.3  christos 
   1001      1.1  christos             /* FIXME add hash-key type, depth limit, multipath processing */
   1002      1.1  christos 
   1003      1.1  christos             tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
   1004      1.1  christos             tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
   1005      1.1  christos 
   1006      1.1  christos             /* FIXME print downstream labels */
   1007      1.1  christos 
   1008      1.1  christos             tlv_hexdump=TRUE; /* dump the TLV until code complete */
   1009      1.1  christos 
   1010      1.1  christos             break;
   1011      1.1  christos 
   1012      1.1  christos         case LSPPING_TLV_BFD_DISCRIMINATOR:
   1013  1.1.1.6       spz             if (tlv_tlen < LSPPING_TLV_BFD_DISCRIMINATOR_LEN) {
   1014  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t      TLV is too short"));
   1015  1.1.1.6       spz                 tlv_hexdump = TRUE;
   1016  1.1.1.6       spz                 goto tlv_tooshort;
   1017  1.1.1.6       spz             } else {
   1018  1.1.1.6       spz                 ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
   1019  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t    BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
   1020  1.1.1.6       spz             }
   1021      1.1  christos             break;
   1022      1.1  christos 
   1023      1.1  christos         case  LSPPING_TLV_VENDOR_ENTERPRISE:
   1024      1.1  christos         {
   1025  1.1.1.3  christos             uint32_t vendor_id;
   1026      1.1  christos 
   1027  1.1.1.6       spz             if (tlv_tlen < LSPPING_TLV_VENDOR_ENTERPRISE_LEN) {
   1028  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t      TLV is too short"));
   1029  1.1.1.6       spz                 tlv_hexdump = TRUE;
   1030  1.1.1.6       spz                 goto tlv_tooshort;
   1031  1.1.1.6       spz             } else {
   1032  1.1.1.6       spz                 ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
   1033  1.1.1.6       spz                 vendor_id = EXTRACT_32BITS(tlv_tptr);
   1034  1.1.1.6       spz                 ND_PRINT((ndo, "\n\t    Vendor: %s (0x%04x)",
   1035  1.1.1.6       spz                        tok2str(smi_values, "Unknown", vendor_id),
   1036  1.1.1.6       spz                        vendor_id));
   1037  1.1.1.6       spz             }
   1038      1.1  christos         }
   1039      1.1  christos             break;
   1040      1.1  christos 
   1041      1.1  christos             /*
   1042      1.1  christos              *  FIXME those are the defined TLVs that lack a decoder
   1043      1.1  christos              *  you are welcome to contribute code ;-)
   1044      1.1  christos              */
   1045      1.1  christos         case LSPPING_TLV_PAD:
   1046      1.1  christos         case LSPPING_TLV_ERROR_CODE:
   1047      1.1  christos         case LSPPING_TLV_VENDOR_PRIVATE:
   1048  1.1.1.3  christos 
   1049      1.1  christos         default:
   1050  1.1.1.3  christos             if (ndo->ndo_vflag <= 1)
   1051  1.1.1.3  christos                 print_unknown_data(ndo, tlv_tptr, "\n\t    ", tlv_tlen);
   1052      1.1  christos             break;
   1053      1.1  christos         }
   1054      1.1  christos         /* do we want to see an additionally tlv hexdump ? */
   1055  1.1.1.6       spz     tlv_tooshort:
   1056  1.1.1.3  christos         if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
   1057  1.1.1.3  christos             print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t    ",
   1058      1.1  christos                                lspping_tlv_len);
   1059      1.1  christos 
   1060      1.1  christos 
   1061      1.1  christos         /* All TLVs are aligned to four octet boundary */
   1062      1.1  christos         if (lspping_tlv_len % 4) {
   1063      1.1  christos             lspping_tlv_len += (4 - lspping_tlv_len % 4);
   1064  1.1.1.6       spz             /* Does the TLV, including padding, go past the end of the packet? */
   1065  1.1.1.6       spz             if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
   1066  1.1.1.6       spz                 goto tooshort;
   1067      1.1  christos         }
   1068      1.1  christos 
   1069      1.1  christos         tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
   1070      1.1  christos         tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
   1071      1.1  christos     }
   1072      1.1  christos     return;
   1073  1.1.1.6       spz tooshort:
   1074  1.1.1.6       spz     ND_PRINT((ndo, "\n\t\t packet is too short"));
   1075  1.1.1.6       spz     return;
   1076      1.1  christos trunc:
   1077  1.1.1.3  christos     ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
   1078  1.1.1.6       spz     return;
   1079      1.1  christos }
   1080  1.1.1.3  christos /*
   1081  1.1.1.3  christos  * Local Variables:
   1082  1.1.1.3  christos  * c-style: whitesmith
   1083  1.1.1.3  christos  * c-basic-offset: 8
   1084  1.1.1.3  christos  * End:
   1085  1.1.1.3  christos  */
   1086