print-lspping.c

来自「TCPDUMP的C语言源代码,是在数据链路层的应用」· C语言 代码 · 共 875 行 · 第 1/3 页

C
875
字号
/* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code * distributions retain the above copyright notice and this paragraph * in its entirety, and (2) distributions including binary code include * the above copyright notice and this paragraph in its entirety in * the documentation or other materials provided with the distribution. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. * * Original code by Hannes Gredler (hannes@juniper.net) */#ifndef lintstatic const char rcsid[] _U_ =    "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.18.2.1 2008-01-28 13:48:16 hannes Exp $";#endif#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <tcpdump-stdinc.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "interface.h"#include "extract.h"#include "addrtoname.h"#include "bgp.h"#include "l2vpn.h"/* * LSPPING common header * *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |         Version Number        |         Must Be Zero          | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |  Message Type |   Reply mode  |  Return Code  | Return Subcode| * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                        Sender's Handle                        | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                        Sequence Number                        | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                    TimeStamp Sent (seconds)                   | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                  TimeStamp Sent (microseconds)                | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                  TimeStamp Received (seconds)                 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                TimeStamp Received (microseconds)              | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                            TLVs ...                           | * .                                                               . * .                                                               . * .                                                               . */struct lspping_common_header {    u_int8_t version[2];    u_int8_t reserved[2];    u_int8_t msg_type;    u_int8_t reply_mode;       u_int8_t return_code;       u_int8_t return_subcode;       u_int8_t sender_handle[4];    u_int8_t seq_number[4];    u_int8_t ts_sent_sec[4];    u_int8_t ts_sent_usec[4];    u_int8_t ts_rcvd_sec[4];    u_int8_t ts_rcvd_usec[4];};#define LSPPING_VERSION            1static const struct tok lspping_msg_type_values[] = {    { 1, "MPLS Echo Request"},    { 2, "MPLS Echo Reply"},    { 0, NULL}};static const struct tok lspping_reply_mode_values[] = {    { 1, "Do not reply"},    { 2, "Reply via an IPv4/IPv6 UDP packet"},    { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},    { 4, "Reply via application level control channel"},    { 0, NULL}};static const struct tok lspping_return_code_values[] = {    {  0, "No return code or return code contained in the Error Code TLV"},    {  1, "Malformed echo request received"},    {  2, "One or more of the TLVs was not understood"},    {  3, "Replying router is an egress for the FEC at stack depth"},    {  4, "Replying router has no mapping for the FEC at stack depth"},    {  5, "Reserved"},    {  6, "Reserved"},    {  7, "Reserved"},    {  8, "Label switched at stack-depth"},    {  9, "Label switched but no MPLS forwarding at stack-depth"},    { 10, "Mapping for this FEC is not the given label at stack depth"},    { 11, "No label entry at stack-depth"},    { 12, "Protocol not associated with interface at FEC stack depth"},};/*  * LSPPING TLV header *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |             Type              |            Length             | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                             Value                             | * .                                                               . * .                                                               . * .                                                               . * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_header {    u_int8_t type[2];    u_int8_t length[2];};#define	LSPPING_TLV_TARGET_FEC_STACK      1#define	LSPPING_TLV_DOWNSTREAM_MAPPING    2#define	LSPPING_TLV_PAD                   3#define	LSPPING_TLV_ERROR_CODE            4#define	LSPPING_TLV_BFD_DISCRIMINATOR     15 /* draft-ietf-bfd-mpls-02 */#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4#define	LSPPING_TLV_VENDOR_PRIVATE        0xfc00static const struct tok lspping_tlv_values[] = {    { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },    { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },    { LSPPING_TLV_PAD, "Pad" },    { LSPPING_TLV_ERROR_CODE, "Error Code" },    { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },    { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Enterprise Code" },    { 0, NULL}};#define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4      1#define	LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6      2#define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4     3#define	LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6     4#define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4    6#define	LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6    7#define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT   8#define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9#define	LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID   10#define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4     11#define	LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6     12static const struct tok lspping_tlvtargetfec_subtlv_values[] = {    { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},    { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},    { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},    { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},    { 5, "Reserved"},    { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},    { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},    { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},    { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"},    { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},    { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},    { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},    { 0, NULL}};/* *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                          IPv4 prefix                          | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Prefix Length |         Must Be Zero                          | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {    u_int8_t prefix [4];    u_int8_t prefix_len;};/* *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                          IPv6 prefix                          | * |                          (16 octets)                          | * |                                                               | * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Prefix Length |         Must Be Zero                          | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {    u_int8_t prefix [16];    u_int8_t prefix_len;};/* * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                    Sender identifier                          | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                         IPv4 prefix                           | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Prefix Length |                 Must Be Zero                  | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {    u_int8_t sender_id [4];    u_int8_t prefix [4];    u_int8_t prefix_len;};/* * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                    Sender identifier                          | * |                          (16 octets)                          | * |                                                               | * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                          IPv6 prefix                          | * |                          (16 octets)                          | * |                                                               | * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Prefix Length |                 Must Be Zero                  | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {    u_int8_t sender_id [16];    u_int8_t prefix [16];    u_int8_t prefix_len;};/* *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                 IPv4 tunnel end point address                 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |          Must Be Zero         |     Tunnel ID                 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                       Extended Tunnel ID                      | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                   IPv4 tunnel sender address                  | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |          Must Be Zero         |            LSP ID             | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {    u_int8_t tunnel_endpoint [4];    u_int8_t res[2];    u_int8_t tunnel_id[2];    u_int8_t extended_tunnel_id[4];    u_int8_t tunnel_sender [4];    u_int8_t res2[2];    u_int8_t lsp_id [2];};/* *  0                   1                   2                   3 *  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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                 IPv6 tunnel end point address                 | * |                                                               | * |                                                               | * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |          Must Be Zero         |          Tunnel ID            | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                       Extended Tunnel ID                      | * |                                                               | * |                                                               | * |                                                               | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |                   IPv6 tunnel sender address                  | * |                                                               | * |                                                               |

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?