Home | History | Annotate | Line # | Download | only in dist
print-lspping.c revision 1.5
      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  christos  * Original code by Hannes Gredler (hannes (at) juniper.net)
     14  1.1  christos  */
     15  1.1  christos 
     16  1.2  christos #include <sys/cdefs.h>
     17  1.1  christos #ifndef lint
     18  1.5  christos __RCSID("$NetBSD: print-lspping.c,v 1.5 2014/11/20 03:05:03 christos Exp $");
     19  1.1  christos #endif
     20  1.1  christos 
     21  1.5  christos #define NETDISSECT_REWORKED
     22  1.1  christos #ifdef HAVE_CONFIG_H
     23  1.1  christos #include "config.h"
     24  1.1  christos #endif
     25  1.1  christos 
     26  1.1  christos #include <tcpdump-stdinc.h>
     27  1.1  christos 
     28  1.1  christos #include "interface.h"
     29  1.1  christos #include "extract.h"
     30  1.1  christos #include "addrtoname.h"
     31  1.1  christos 
     32  1.1  christos #include "l2vpn.h"
     33  1.1  christos #include "oui.h"
     34  1.1  christos 
     35  1.1  christos /*
     36  1.1  christos  * LSPPING common header
     37  1.1  christos  *
     38  1.1  christos  *  0                   1                   2                   3
     39  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
     40  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     41  1.1  christos  * |         Version Number        |         Must Be Zero          |
     42  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     43  1.1  christos  * |  Message Type |   Reply mode  |  Return Code  | Return Subcode|
     44  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     45  1.1  christos  * |                        Sender's Handle                        |
     46  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     47  1.1  christos  * |                        Sequence Number                        |
     48  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     49  1.1  christos  * |                    TimeStamp Sent (seconds)                   |
     50  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     51  1.1  christos  * |                  TimeStamp Sent (microseconds)                |
     52  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     53  1.1  christos  * |                  TimeStamp Received (seconds)                 |
     54  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     55  1.1  christos  * |                TimeStamp Received (microseconds)              |
     56  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     57  1.1  christos  * |                            TLVs ...                           |
     58  1.1  christos  * .                                                               .
     59  1.1  christos  * .                                                               .
     60  1.1  christos  * .                                                               .
     61  1.1  christos  */
     62  1.1  christos 
     63  1.1  christos struct lspping_common_header {
     64  1.5  christos     uint8_t version[2];
     65  1.5  christos     uint8_t reserved[2];
     66  1.5  christos     uint8_t msg_type;
     67  1.5  christos     uint8_t reply_mode;
     68  1.5  christos     uint8_t return_code;
     69  1.5  christos     uint8_t return_subcode;
     70  1.5  christos     uint8_t sender_handle[4];
     71  1.5  christos     uint8_t seq_number[4];
     72  1.5  christos     uint8_t ts_sent_sec[4];
     73  1.5  christos     uint8_t ts_sent_usec[4];
     74  1.5  christos     uint8_t ts_rcvd_sec[4];
     75  1.5  christos     uint8_t ts_rcvd_usec[4];
     76  1.1  christos };
     77  1.1  christos 
     78  1.1  christos #define LSPPING_VERSION            1
     79  1.1  christos 
     80  1.1  christos static const struct tok lspping_msg_type_values[] = {
     81  1.1  christos     { 1, "MPLS Echo Request"},
     82  1.1  christos     { 2, "MPLS Echo Reply"},
     83  1.1  christos     { 0, NULL}
     84  1.1  christos };
     85  1.1  christos 
     86  1.1  christos static const struct tok lspping_reply_mode_values[] = {
     87  1.1  christos     { 1, "Do not reply"},
     88  1.1  christos     { 2, "Reply via an IPv4/IPv6 UDP packet"},
     89  1.1  christos     { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
     90  1.1  christos     { 4, "Reply via application level control channel"},
     91  1.1  christos     { 0, NULL}
     92  1.1  christos };
     93  1.1  christos 
     94  1.1  christos static const struct tok lspping_return_code_values[] = {
     95  1.1  christos     {  0, "No return code or return code contained in the Error Code TLV"},
     96  1.1  christos     {  1, "Malformed echo request received"},
     97  1.1  christos     {  2, "One or more of the TLVs was not understood"},
     98  1.1  christos     {  3, "Replying router is an egress for the FEC at stack depth"},
     99  1.1  christos     {  4, "Replying router has no mapping for the FEC at stack depth"},
    100  1.1  christos     {  5, "Reserved"},
    101  1.1  christos     {  6, "Reserved"},
    102  1.1  christos     {  7, "Reserved"},
    103  1.1  christos     {  8, "Label switched at stack-depth"},
    104  1.1  christos     {  9, "Label switched but no MPLS forwarding at stack-depth"},
    105  1.1  christos     { 10, "Mapping for this FEC is not the given label at stack depth"},
    106  1.1  christos     { 11, "No label entry at stack-depth"},
    107  1.1  christos     { 12, "Protocol not associated with interface at FEC stack depth"},
    108  1.1  christos };
    109  1.1  christos 
    110  1.1  christos 
    111  1.5  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.5  christos     uint8_t type[2];
    128  1.5  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  christos #define LSPPING_TLV_VENDOR_ENTERPRISE     5
    135  1.1  christos #define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
    136  1.1  christos #define LSPPING_TLV_INTERFACE_LABEL_STACK 7
    137  1.1  christos #define	LSPPING_TLV_ERROR_CODE            9
    138  1.1  christos #define LSPPING_TLV_REPLY_TOS_BYTE        10
    139  1.1  christos #define	LSPPING_TLV_BFD_DISCRIMINATOR     15 /* draft-ietf-bfd-mpls-02 */
    140  1.1  christos #define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
    141  1.1  christos #define	LSPPING_TLV_VENDOR_PRIVATE        0xfc00
    142  1.1  christos 
    143  1.1  christos static const struct tok lspping_tlv_values[] = {
    144  1.1  christos     { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
    145  1.1  christos     { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
    146  1.1  christos     { LSPPING_TLV_PAD, "Pad" },
    147  1.1  christos     { LSPPING_TLV_ERROR_CODE, "Error Code" },
    148  1.1  christos     { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
    149  1.1  christos     { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
    150  1.1  christos     { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
    151  1.1  christos     { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
    152  1.1  christos     { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
    153  1.1  christos     { 0, NULL}
    154  1.1  christos };
    155  1.1  christos 
    156  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4      1
    157  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6      2
    158  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4     3
    159  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6     4
    160  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4    6
    161  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6    7
    162  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT   8
    163  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
    164  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID   10
    165  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4     11
    166  1.1  christos #define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6     12
    167  1.1  christos 
    168  1.1  christos static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
    169  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
    170  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
    171  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
    172  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
    173  1.1  christos     { 5, "Reserved"},
    174  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
    175  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
    176  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
    177  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"},
    178  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},
    179  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
    180  1.1  christos     { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
    181  1.1  christos     { 0, NULL}
    182  1.1  christos };
    183  1.1  christos 
    184  1.1  christos /*
    185  1.1  christos  *  0                   1                   2                   3
    186  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
    187  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    188  1.1  christos  * |                          IPv4 prefix                          |
    189  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    190  1.1  christos  * | Prefix Length |         Must Be Zero                          |
    191  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    192  1.1  christos  */
    193  1.1  christos struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
    194  1.5  christos     uint8_t prefix [4];
    195  1.5  christos     uint8_t prefix_len;
    196  1.1  christos };
    197  1.1  christos 
    198  1.1  christos /*
    199  1.1  christos  *  0                   1                   2                   3
    200  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
    201  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    202  1.1  christos  * |                          IPv6 prefix                          |
    203  1.1  christos  * |                          (16 octets)                          |
    204  1.1  christos  * |                                                               |
    205  1.1  christos  * |                                                               |
    206  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    207  1.1  christos  * | Prefix Length |         Must Be Zero                          |
    208  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    209  1.1  christos  */
    210  1.1  christos struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
    211  1.5  christos     uint8_t prefix [16];
    212  1.5  christos     uint8_t prefix_len;
    213  1.1  christos };
    214  1.1  christos 
    215  1.1  christos /*
    216  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
    217  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    218  1.1  christos  * |                    Sender identifier                          |
    219  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    220  1.1  christos  * |                         IPv4 prefix                           |
    221  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    222  1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    223  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    224  1.1  christos  */
    225  1.1  christos struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
    226  1.5  christos     uint8_t sender_id [4];
    227  1.5  christos     uint8_t prefix [4];
    228  1.5  christos     uint8_t prefix_len;
    229  1.1  christos };
    230  1.1  christos 
    231  1.1  christos /*
    232  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
    233  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    234  1.1  christos  * |                    Sender identifier                          |
    235  1.1  christos  * |                          (16 octets)                          |
    236  1.1  christos  * |                                                               |
    237  1.1  christos  * |                                                               |
    238  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    239  1.1  christos  * |                          IPv6 prefix                          |
    240  1.1  christos  * |                          (16 octets)                          |
    241  1.1  christos  * |                                                               |
    242  1.1  christos  * |                                                               |
    243  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    244  1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    245  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    246  1.1  christos  */
    247  1.1  christos struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
    248  1.5  christos     uint8_t sender_id [16];
    249  1.5  christos     uint8_t prefix [16];
    250  1.5  christos     uint8_t prefix_len;
    251  1.1  christos };
    252  1.1  christos 
    253  1.1  christos /*
    254  1.1  christos  *  0                   1                   2                   3
    255  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
    256  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    257  1.1  christos  * |                 IPv4 tunnel end point address                 |
    258  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    259  1.1  christos  * |          Must Be Zero         |     Tunnel ID                 |
    260  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    261  1.1  christos  * |                       Extended Tunnel ID                      |
    262  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    263  1.1  christos  * |                   IPv4 tunnel sender address                  |
    264  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    265  1.1  christos  * |          Must Be Zero         |            LSP ID             |
    266  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    267  1.1  christos  */
    268  1.1  christos struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
    269  1.5  christos     uint8_t tunnel_endpoint [4];
    270  1.5  christos     uint8_t res[2];
    271  1.5  christos     uint8_t tunnel_id[2];
    272  1.5  christos     uint8_t extended_tunnel_id[4];
    273  1.5  christos     uint8_t tunnel_sender [4];
    274  1.5  christos     uint8_t res2[2];
    275  1.5  christos     uint8_t lsp_id [2];
    276  1.1  christos };
    277  1.1  christos 
    278  1.1  christos /*
    279  1.1  christos  *  0                   1                   2                   3
    280  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
    281  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    282  1.1  christos  * |                 IPv6 tunnel end point address                 |
    283  1.1  christos  * |                                                               |
    284  1.1  christos  * |                                                               |
    285  1.1  christos  * |                                                               |
    286  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    287  1.1  christos  * |          Must Be Zero         |          Tunnel ID            |
    288  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    289  1.1  christos  * |                       Extended Tunnel ID                      |
    290  1.1  christos  * |                                                               |
    291  1.1  christos  * |                                                               |
    292  1.1  christos  * |                                                               |
    293  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    294  1.1  christos  * |                   IPv6 tunnel sender address                  |
    295  1.1  christos  * |                                                               |
    296  1.1  christos  * |                                                               |
    297  1.1  christos  * |                                                               |
    298  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    299  1.1  christos  * |          Must Be Zero         |            LSP ID             |
    300  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    301  1.1  christos  */
    302  1.1  christos struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
    303  1.5  christos     uint8_t tunnel_endpoint [16];
    304  1.5  christos     uint8_t res[2];
    305  1.5  christos     uint8_t tunnel_id[2];
    306  1.5  christos     uint8_t extended_tunnel_id[16];
    307  1.5  christos     uint8_t tunnel_sender [16];
    308  1.5  christos     uint8_t res2[2];
    309  1.5  christos     uint8_t lsp_id [2];
    310  1.1  christos };
    311  1.1  christos 
    312  1.1  christos /*
    313  1.1  christos  *  0                   1                   2                   3
    314  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
    315  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    316  1.1  christos  * |                      Route Distinguisher                      |
    317  1.1  christos  * |                          (8 octets)                           |
    318  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    319  1.1  christos  * |                         IPv4 prefix                           |
    320  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    321  1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    322  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    323  1.1  christos  */
    324  1.1  christos struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
    325  1.5  christos     uint8_t rd [8];
    326  1.5  christos     uint8_t prefix [4];
    327  1.5  christos     uint8_t prefix_len;
    328  1.1  christos };
    329  1.1  christos 
    330  1.1  christos /*
    331  1.1  christos  *  0                   1                   2                   3
    332  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
    333  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    334  1.1  christos  * |                      Route Distinguisher                      |
    335  1.1  christos  * |                          (8 octets)                           |
    336  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    337  1.1  christos  * |                          IPv6 prefix                          |
    338  1.1  christos  * |                          (16 octets)                          |
    339  1.1  christos  * |                                                               |
    340  1.1  christos  * |                                                               |
    341  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    342  1.1  christos  * | Prefix Length |                 Must Be Zero                  |
    343  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    344  1.1  christos  */
    345  1.1  christos struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
    346  1.5  christos     uint8_t rd [8];
    347  1.5  christos     uint8_t prefix [16];
    348  1.5  christos     uint8_t prefix_len;
    349  1.1  christos };
    350  1.1  christos 
    351  1.1  christos /*
    352  1.1  christos  *  0                   1                   2                   3
    353  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
    354  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    355  1.1  christos  * |                      Route Distinguisher                      |
    356  1.1  christos  * |                          (8 octets)                           |
    357  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    358  1.1  christos  * |         Sender's CE ID        |       Receiver's CE ID        |
    359  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    360  1.1  christos  * |      Encapsulation Type       |         Must Be Zero          |
    361  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    362  1.1  christos  *  0                   1                   2                   3
    363  1.1  christos  */
    364  1.1  christos struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
    365  1.5  christos     uint8_t rd [8];
    366  1.5  christos     uint8_t sender_ce_id [2];
    367  1.5  christos     uint8_t receiver_ce_id [2];
    368  1.5  christos     uint8_t encapsulation[2];
    369  1.1  christos };
    370  1.1  christos 
    371  1.1  christos /*
    372  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
    373  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    374  1.1  christos  * |                      Remote PE Address                        |
    375  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    376  1.1  christos  * |                             VC ID                             |
    377  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    378  1.1  christos  * |      Encapsulation Type       |         Must Be Zero          |
    379  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    380  1.1  christos  */
    381  1.1  christos struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
    382  1.5  christos     uint8_t remote_pe_address [4];
    383  1.5  christos     uint8_t vc_id [4];
    384  1.5  christos     uint8_t encapsulation[2];
    385  1.1  christos };
    386  1.1  christos 
    387  1.1  christos /*
    388  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
    389  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    390  1.1  christos  * |                     Sender's PE Address                       |
    391  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    392  1.1  christos  * |                      Remote PE Address                        |
    393  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    394  1.1  christos  * |                             VC ID                             |
    395  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    396  1.1  christos  * |      Encapsulation Type       |         Must Be Zero          |
    397  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    398  1.1  christos  */
    399  1.1  christos struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
    400  1.5  christos     uint8_t sender_pe_address [4];
    401  1.5  christos     uint8_t remote_pe_address [4];
    402  1.5  christos     uint8_t vc_id [4];
    403  1.5  christos     uint8_t encapsulation[2];
    404  1.1  christos };
    405  1.1  christos 
    406  1.1  christos /*
    407  1.1  christos  *  0                   1                   2                   3
    408  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
    409  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    410  1.1  christos  * |               MTU             | Address Type  |  Resvd (SBZ)  |
    411  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    412  1.1  christos  * |             Downstream IP Address (4 or 16 octets)            |
    413  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    414  1.1  christos  * |         Downstream Interface Address (4 or 16 octets)         |
    415  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    416  1.1  christos  * | Hash Key Type | Depth Limit   |        Multipath Length       |
    417  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    418  1.1  christos  * .                                                               .
    419  1.1  christos  * .                     (Multipath Information)                   .
    420  1.1  christos  * .                                                               .
    421  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    422  1.1  christos  * |               Downstream Label                |    Protocol   |
    423  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    424  1.1  christos  * .                                                               .
    425  1.1  christos  * .                                                               .
    426  1.1  christos  * .                                                               .
    427  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    428  1.1  christos  * |               Downstream Label                |    Protocol   |
    429  1.1  christos  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    430  1.1  christos  */
    431  1.1  christos struct lspping_tlv_downstream_map_ipv4_t {
    432  1.5  christos     uint8_t mtu [2];
    433  1.5  christos     uint8_t address_type;
    434  1.5  christos     uint8_t res;
    435  1.5  christos     uint8_t downstream_ip[4];
    436  1.5  christos     uint8_t downstream_interface[4];
    437  1.1  christos };
    438  1.1  christos 
    439  1.1  christos struct lspping_tlv_downstream_map_ipv6_t {
    440  1.5  christos     uint8_t mtu [2];
    441  1.5  christos     uint8_t address_type;
    442  1.5  christos     uint8_t res;
    443  1.5  christos     uint8_t downstream_ip[16];
    444  1.5  christos     uint8_t downstream_interface[16];
    445  1.1  christos };
    446  1.1  christos 
    447  1.1  christos struct lspping_tlv_downstream_map_info_t {
    448  1.5  christos     uint8_t hash_key_type;
    449  1.5  christos     uint8_t depth_limit;
    450  1.5  christos     uint8_t multipath_length [2];
    451  1.1  christos };
    452  1.1  christos 
    453  1.1  christos #define LSPPING_AFI_IPV4 1
    454  1.1  christos #define LSPPING_AFI_UNMB 2
    455  1.1  christos #define LSPPING_AFI_IPV6 3
    456  1.1  christos 
    457  1.1  christos static const struct tok lspping_tlv_downstream_addr_values[] = {
    458  1.1  christos     { LSPPING_AFI_IPV4, "IPv4"},
    459  1.1  christos     { LSPPING_AFI_IPV6, "IPv6"},
    460  1.1  christos     { LSPPING_AFI_UNMB, "Unnumbered"},
    461  1.1  christos     { 0, NULL}
    462  1.1  christos };
    463  1.1  christos 
    464  1.1  christos void
    465  1.5  christos lspping_print(netdissect_options *ndo,
    466  1.5  christos               register const u_char *pptr, register u_int len) {
    467  1.1  christos 
    468  1.1  christos     const struct lspping_common_header *lspping_com_header;
    469  1.1  christos     const struct lspping_tlv_header *lspping_tlv_header;
    470  1.1  christos     const struct lspping_tlv_header *lspping_subtlv_header;
    471  1.1  christos     const u_char *tptr,*tlv_tptr,*subtlv_tptr;
    472  1.1  christos     int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
    473  1.1  christos     int tlv_hexdump,subtlv_hexdump;
    474  1.1  christos     int lspping_subtlv_len,lspping_subtlv_type;
    475  1.5  christos     struct timeval timestamp;
    476  1.1  christos 
    477  1.1  christos     union {
    478  1.1  christos         const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
    479  1.1  christos         const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6;
    480  1.1  christos         const struct lspping_tlv_downstream_map_info_t  *lspping_tlv_downstream_map_info;
    481  1.1  christos     } tlv_ptr;
    482  1.1  christos 
    483  1.1  christos     union {
    484  1.1  christos         const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *lspping_tlv_targetfec_subtlv_ldp_ipv4;
    485  1.1  christos         const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *lspping_tlv_targetfec_subtlv_ldp_ipv6;
    486  1.1  christos         const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *lspping_tlv_targetfec_subtlv_rsvp_ipv4;
    487  1.1  christos         const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *lspping_tlv_targetfec_subtlv_rsvp_ipv6;
    488  1.1  christos         const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
    489  1.1  christos         const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
    490  1.1  christos         const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt;
    491  1.1  christos         const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
    492  1.1  christos         const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
    493  1.1  christos         const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
    494  1.1  christos         const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
    495  1.1  christos     } subtlv_ptr;
    496  1.1  christos 
    497  1.1  christos     tptr=pptr;
    498  1.1  christos     lspping_com_header = (const struct lspping_common_header *)pptr;
    499  1.5  christos     ND_TCHECK(*lspping_com_header);
    500  1.1  christos 
    501  1.1  christos     /*
    502  1.1  christos      * Sanity checking of the header.
    503  1.1  christos      */
    504  1.1  christos     if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
    505  1.5  christos 	ND_PRINT((ndo, "LSP-PING version %u packet not supported",
    506  1.5  christos                EXTRACT_16BITS(&lspping_com_header->version[0])));
    507  1.1  christos 	return;
    508  1.1  christos     }
    509  1.1  christos 
    510  1.1  christos     /* in non-verbose mode just lets print the basic Message Type*/
    511  1.5  christos     if (ndo->ndo_vflag < 1) {
    512  1.5  christos         ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
    513  1.1  christos                EXTRACT_16BITS(&lspping_com_header->version[0]),
    514  1.1  christos                tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
    515  1.1  christos                EXTRACT_32BITS(lspping_com_header->seq_number),
    516  1.5  christos                len));
    517  1.1  christos         return;
    518  1.1  christos     }
    519  1.1  christos 
    520  1.1  christos     /* ok they seem to want to know everything - lets fully decode it */
    521  1.1  christos 
    522  1.1  christos     tlen=len;
    523  1.1  christos 
    524  1.5  christos     ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t  reply-mode: %s (%u)",
    525  1.1  christos            EXTRACT_16BITS(&lspping_com_header->version[0]),
    526  1.1  christos            tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
    527  1.1  christos            lspping_com_header->msg_type,
    528  1.1  christos            len,
    529  1.1  christos            tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
    530  1.5  christos            lspping_com_header->reply_mode));
    531  1.1  christos 
    532  1.1  christos     /*
    533  1.1  christos      *  the following return codes require that the subcode is attached
    534  1.1  christos      *  at the end of the translated token output
    535  1.1  christos      */
    536  1.1  christos     if (lspping_com_header->return_code == 3 ||
    537  1.1  christos         lspping_com_header->return_code == 4 ||
    538  1.1  christos         lspping_com_header->return_code == 8 ||
    539  1.1  christos         lspping_com_header->return_code == 10 ||
    540  1.1  christos         lspping_com_header->return_code == 11 ||
    541  1.1  christos         lspping_com_header->return_code == 12 )
    542  1.5  christos         ND_PRINT((ndo, "\n\t  Return Code: %s %u (%u)\n\t  Return Subcode: (%u)",
    543  1.1  christos                tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
    544  1.5  christos                lspping_com_header->return_subcode,
    545  1.1  christos                lspping_com_header->return_code,
    546  1.5  christos                lspping_com_header->return_subcode));
    547  1.1  christos     else
    548  1.5  christos         ND_PRINT((ndo, "\n\t  Return Code: %s (%u)\n\t  Return Subcode: (%u)",
    549  1.5  christos                tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
    550  1.1  christos                lspping_com_header->return_code,
    551  1.5  christos                lspping_com_header->return_subcode));
    552  1.5  christos 
    553  1.5  christos     ND_PRINT((ndo, "\n\t  Sender Handle: 0x%08x, Sequence: %u",
    554  1.1  christos            EXTRACT_32BITS(lspping_com_header->sender_handle),
    555  1.5  christos            EXTRACT_32BITS(lspping_com_header->seq_number)));
    556  1.1  christos 
    557  1.1  christos     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
    558  1.5  christos     timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
    559  1.5  christos     ND_PRINT((ndo, "\n\t  Sender Timestamp: "));
    560  1.5  christos     ts_print(ndo, &timestamp);
    561  1.1  christos 
    562  1.1  christos     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
    563  1.5  christos     timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
    564  1.5  christos     ND_PRINT((ndo, "Receiver Timestamp: "));
    565  1.1  christos     if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
    566  1.5  christos         ts_print(ndo, &timestamp);
    567  1.1  christos     else
    568  1.5  christos         ND_PRINT((ndo, "no timestamp"));
    569  1.1  christos 
    570  1.1  christos     tptr+=sizeof(const struct lspping_common_header);
    571  1.1  christos     tlen-=sizeof(const struct lspping_common_header);
    572  1.1  christos 
    573  1.1  christos     while(tlen>(int)sizeof(struct lspping_tlv_header)) {
    574  1.1  christos 
    575  1.1  christos         /* did we capture enough for fully decoding the tlv header ? */
    576  1.5  christos         ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
    577  1.1  christos 
    578  1.1  christos         lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
    579  1.1  christos         lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
    580  1.1  christos         lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length);
    581  1.1  christos 
    582  1.1  christos         /* some little sanity checking */
    583  1.1  christos         if (lspping_tlv_type == 0 || lspping_tlv_len == 0)
    584  1.1  christos             return;
    585  1.1  christos 
    586  1.1  christos         if(lspping_tlv_len < 4) {
    587  1.5  christos             ND_PRINT((ndo, "\n\t  ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
    588  1.1  christos             return;
    589  1.1  christos         }
    590  1.1  christos 
    591  1.5  christos         ND_PRINT((ndo, "\n\t  %s TLV (%u), length: %u",
    592  1.1  christos                tok2str(lspping_tlv_values,
    593  1.1  christos                        "Unknown",
    594  1.1  christos                        lspping_tlv_type),
    595  1.1  christos                lspping_tlv_type,
    596  1.5  christos                lspping_tlv_len));
    597  1.1  christos 
    598  1.1  christos         tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
    599  1.1  christos         tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
    600  1.1  christos 
    601  1.1  christos         /* did we capture enough for fully decoding the tlv ? */
    602  1.5  christos         ND_TCHECK2(*tptr, lspping_tlv_len);
    603  1.1  christos         tlv_hexdump=FALSE;
    604  1.1  christos 
    605  1.1  christos         switch(lspping_tlv_type) {
    606  1.1  christos         case LSPPING_TLV_TARGET_FEC_STACK:
    607  1.1  christos             while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
    608  1.1  christos 
    609  1.1  christos                 /* did we capture enough for fully decoding the subtlv header ? */
    610  1.5  christos                 ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
    611  1.1  christos                 subtlv_hexdump=FALSE;
    612  1.1  christos 
    613  1.1  christos                 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
    614  1.1  christos                 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
    615  1.1  christos                 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
    616  1.1  christos                 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
    617  1.5  christos 
    618  1.1  christos                 if (lspping_subtlv_len == 0)
    619  1.1  christos                     break;
    620  1.1  christos 
    621  1.5  christos                 ND_PRINT((ndo, "\n\t    %s subTLV (%u), length: %u",
    622  1.1  christos                        tok2str(lspping_tlvtargetfec_subtlv_values,
    623  1.1  christos                                "Unknown",
    624  1.1  christos                                lspping_subtlv_type),
    625  1.1  christos                        lspping_subtlv_type,
    626  1.5  christos                        lspping_subtlv_len));
    627  1.1  christos 
    628  1.1  christos                 switch(lspping_subtlv_type) {
    629  1.1  christos 
    630  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
    631  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
    632  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
    633  1.5  christos                     ND_PRINT((ndo, "\n\t      %s/%u",
    634  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
    635  1.5  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
    636  1.1  christos                     break;
    637  1.1  christos 
    638  1.1  christos #ifdef INET6
    639  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
    640  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
    641  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
    642  1.5  christos                     ND_PRINT((ndo, "\n\t      %s/%u",
    643  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
    644  1.5  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
    645  1.1  christos                     break;
    646  1.1  christos #endif
    647  1.1  christos 
    648  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
    649  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
    650  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
    651  1.5  christos                     ND_PRINT((ndo, "\n\t      %s/%u, sender-id %s",
    652  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
    653  1.1  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
    654  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
    655  1.1  christos                     break;
    656  1.1  christos 
    657  1.1  christos #ifdef INET6
    658  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
    659  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
    660  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
    661  1.5  christos                     ND_PRINT((ndo, "\n\t      %s/%u, sender-id %s",
    662  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
    663  1.1  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
    664  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
    665  1.1  christos                     break;
    666  1.1  christos #endif
    667  1.1  christos 
    668  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
    669  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
    670  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
    671  1.5  christos                     ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
    672  1.1  christos                            "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
    673  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
    674  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
    675  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
    676  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
    677  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
    678  1.1  christos                     break;
    679  1.1  christos 
    680  1.1  christos #ifdef INET6
    681  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
    682  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
    683  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
    684  1.5  christos                     ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
    685  1.1  christos                            "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
    686  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
    687  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
    688  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
    689  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
    690  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
    691  1.1  christos                     break;
    692  1.1  christos #endif
    693  1.1  christos 
    694  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
    695  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
    696  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
    697  1.5  christos                     ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
    698  1.5  christos                            bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
    699  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
    700  1.5  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
    701  1.1  christos                     break;
    702  1.1  christos 
    703  1.1  christos #ifdef INET6
    704  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
    705  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
    706  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
    707  1.5  christos                     ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
    708  1.5  christos                            bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
    709  1.5  christos                            ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
    710  1.5  christos                            subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
    711  1.1  christos                     break;
    712  1.1  christos #endif
    713  1.1  christos 
    714  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
    715  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
    716  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
    717  1.5  christos                     ND_PRINT((ndo, "\n\t      RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
    718  1.1  christos                            "\n\t      Encapsulation Type: %s (%u)",
    719  1.5  christos                            bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
    720  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
    721  1.1  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
    722  1.1  christos                            tok2str(l2vpn_encaps_values,
    723  1.1  christos                                    "unknown",
    724  1.1  christos                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
    725  1.5  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
    726  1.5  christos 
    727  1.1  christos                     break;
    728  1.1  christos 
    729  1.1  christos                     /* the old L2VPN VCID subTLV does not have support for the sender field */
    730  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
    731  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
    732  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
    733  1.5  christos                     ND_PRINT((ndo, "\n\t      Remote PE: %s" \
    734  1.1  christos                            "\n\t      VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
    735  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
    736  1.1  christos                            EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
    737  1.1  christos                            tok2str(l2vpn_encaps_values,
    738  1.1  christos                                    "unknown",
    739  1.1  christos                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
    740  1.5  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)));
    741  1.5  christos 
    742  1.1  christos                     break;
    743  1.1  christos 
    744  1.1  christos                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
    745  1.1  christos                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
    746  1.1  christos                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
    747  1.5  christos                     ND_PRINT((ndo, "\n\t      Sender PE: %s, Remote PE: %s" \
    748  1.1  christos                            "\n\t      VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
    749  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
    750  1.5  christos                            ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
    751  1.1  christos                            EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
    752  1.1  christos                            tok2str(l2vpn_encaps_values,
    753  1.1  christos                                    "unknown",
    754  1.1  christos                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
    755  1.5  christos                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)));
    756  1.5  christos 
    757  1.1  christos                     break;
    758  1.1  christos 
    759  1.1  christos                 default:
    760  1.1  christos                     subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
    761  1.1  christos                     break;
    762  1.1  christos                 }
    763  1.1  christos                 /* do we want to see an additionally subtlv hexdump ? */
    764  1.5  christos                 if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
    765  1.5  christos                     print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
    766  1.1  christos                                        "\n\t      ",
    767  1.1  christos                                        lspping_subtlv_len);
    768  1.1  christos 
    769  1.1  christos                 tlv_tptr+=lspping_subtlv_len;
    770  1.1  christos                 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
    771  1.1  christos             }
    772  1.1  christos             break;
    773  1.1  christos 
    774  1.1  christos         case LSPPING_TLV_DOWNSTREAM_MAPPING:
    775  1.1  christos             /* that strange thing with the downstream map TLV is that until now
    776  1.1  christos              * we do not know if its IPv4 or IPv6 , after we found the adress-type
    777  1.1  christos              * lets recast the tlv_tptr and move on */
    778  1.1  christos 
    779  1.1  christos             tlv_ptr.lspping_tlv_downstream_map_ipv4= \
    780  1.1  christos                 (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
    781  1.1  christos             tlv_ptr.lspping_tlv_downstream_map_ipv6= \
    782  1.1  christos                 (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
    783  1.5  christos             ND_PRINT((ndo, "\n\t    MTU: %u, Address-Type: %s (%u)",
    784  1.1  christos                    EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
    785  1.1  christos                    tok2str(lspping_tlv_downstream_addr_values,
    786  1.1  christos                            "unknown",
    787  1.1  christos                            tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
    788  1.5  christos                    tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type));
    789  1.1  christos 
    790  1.1  christos             switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
    791  1.1  christos 
    792  1.1  christos             case LSPPING_AFI_IPV4:
    793  1.5  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    794  1.1  christos                        "\n\t    Downstream Interface IP: %s",
    795  1.5  christos                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
    796  1.5  christos                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
    797  1.1  christos                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    798  1.1  christos                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    799  1.1  christos                 break;
    800  1.1  christos #ifdef INET6
    801  1.1  christos              case LSPPING_AFI_IPV6:
    802  1.5  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    803  1.1  christos                        "\n\t    Downstream Interface IP: %s",
    804  1.5  christos                        ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
    805  1.5  christos                        ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
    806  1.1  christos                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
    807  1.1  christos                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
    808  1.1  christos                 break;
    809  1.1  christos #endif
    810  1.1  christos             case LSPPING_AFI_UNMB:
    811  1.5  christos                 ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
    812  1.1  christos                        "\n\t    Downstream Interface Index: 0x%08x",
    813  1.5  christos                        ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
    814  1.5  christos                        EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
    815  1.1  christos                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    816  1.1  christos                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
    817  1.1  christos                 break;
    818  1.1  christos 
    819  1.1  christos             default:
    820  1.1  christos                 /* should not happen ! - no error message - tok2str() has barked already */
    821  1.1  christos                 break;
    822  1.1  christos             }
    823  1.1  christos 
    824  1.1  christos             tlv_ptr.lspping_tlv_downstream_map_info= \
    825  1.1  christos                 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
    826  1.5  christos 
    827  1.1  christos             /* FIXME add hash-key type, depth limit, multipath processing */
    828  1.1  christos 
    829  1.1  christos 
    830  1.1  christos             tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
    831  1.1  christos             tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
    832  1.1  christos 
    833  1.1  christos             /* FIXME print downstream labels */
    834  1.1  christos 
    835  1.1  christos 
    836  1.1  christos             tlv_hexdump=TRUE; /* dump the TLV until code complete */
    837  1.1  christos 
    838  1.1  christos             break;
    839  1.1  christos 
    840  1.1  christos         case LSPPING_TLV_BFD_DISCRIMINATOR:
    841  1.1  christos             tptr += sizeof(struct lspping_tlv_header);
    842  1.5  christos             ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
    843  1.5  christos             ND_PRINT((ndo, "\n\t    BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
    844  1.1  christos             break;
    845  1.1  christos 
    846  1.1  christos         case  LSPPING_TLV_VENDOR_ENTERPRISE:
    847  1.1  christos         {
    848  1.5  christos             uint32_t vendor_id;
    849  1.1  christos 
    850  1.5  christos             ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
    851  1.1  christos             vendor_id = EXTRACT_32BITS(tlv_tptr);
    852  1.5  christos             ND_PRINT((ndo, "\n\t    Vendor: %s (0x%04x)",
    853  1.1  christos                    tok2str(smi_values, "Unknown", vendor_id),
    854  1.5  christos                    vendor_id));
    855  1.1  christos         }
    856  1.1  christos             break;
    857  1.1  christos 
    858  1.1  christos             /*
    859  1.1  christos              *  FIXME those are the defined TLVs that lack a decoder
    860  1.1  christos              *  you are welcome to contribute code ;-)
    861  1.1  christos              */
    862  1.1  christos         case LSPPING_TLV_PAD:
    863  1.1  christos         case LSPPING_TLV_ERROR_CODE:
    864  1.1  christos         case LSPPING_TLV_VENDOR_PRIVATE:
    865  1.5  christos 
    866  1.1  christos         default:
    867  1.5  christos             if (ndo->ndo_vflag <= 1)
    868  1.5  christos                 print_unknown_data(ndo, tlv_tptr, "\n\t    ", tlv_tlen);
    869  1.1  christos             break;
    870  1.1  christos         }
    871  1.1  christos         /* do we want to see an additionally tlv hexdump ? */
    872  1.5  christos         if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
    873  1.5  christos             print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t    ",
    874  1.1  christos                                lspping_tlv_len);
    875  1.1  christos 
    876  1.1  christos 
    877  1.1  christos         /* All TLVs are aligned to four octet boundary */
    878  1.1  christos         if (lspping_tlv_len % 4) {
    879  1.1  christos             lspping_tlv_len += (4 - lspping_tlv_len % 4);
    880  1.1  christos         }
    881  1.1  christos 
    882  1.1  christos         tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
    883  1.1  christos         tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
    884  1.1  christos     }
    885  1.1  christos     return;
    886  1.1  christos trunc:
    887  1.5  christos     ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
    888  1.1  christos }
    889  1.5  christos /*
    890  1.5  christos  * Local Variables:
    891  1.5  christos  * c-style: whitesmith
    892  1.5  christos  * c-basic-offset: 8
    893  1.5  christos  * End:
    894  1.5  christos  */
    895