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