blob: 888adfafbcdc8bf17c517359de44eff242d15519 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
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
Elliott Hughes892a68b2015-10-19 14:43:53 -070016#define NETDISSECT_REWORKED
The Android Open Source Project2949f582009-03-03 19:30:46 -080017#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <tcpdump-stdinc.h>
22
The Android Open Source Project2949f582009-03-03 19:30:46 -080023#include "interface.h"
24#include "extract.h"
25#include "addrtoname.h"
26
The Android Open Source Project2949f582009-03-03 19:30:46 -080027#include "l2vpn.h"
JP Abgrall53f17a92014-02-12 14:02:41 -080028#include "oui.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080029
30/*
31 * LSPPING common header
32 *
33 * 0 1 2 3
34 * 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
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 * | Version Number | Must Be Zero |
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 * | Message Type | Reply mode | Return Code | Return Subcode|
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 * | Sender's Handle |
41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 * | Sequence Number |
43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * | TimeStamp Sent (seconds) |
45 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * | TimeStamp Sent (microseconds) |
47 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * | TimeStamp Received (seconds) |
49 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * | TimeStamp Received (microseconds) |
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | TLVs ... |
53 * . .
54 * . .
55 * . .
56 */
57
58struct lspping_common_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -070059 uint8_t version[2];
60 uint8_t reserved[2];
61 uint8_t msg_type;
62 uint8_t reply_mode;
63 uint8_t return_code;
64 uint8_t return_subcode;
65 uint8_t sender_handle[4];
66 uint8_t seq_number[4];
67 uint8_t ts_sent_sec[4];
68 uint8_t ts_sent_usec[4];
69 uint8_t ts_rcvd_sec[4];
70 uint8_t ts_rcvd_usec[4];
The Android Open Source Project2949f582009-03-03 19:30:46 -080071};
72
73#define LSPPING_VERSION 1
74
75static const struct tok lspping_msg_type_values[] = {
76 { 1, "MPLS Echo Request"},
77 { 2, "MPLS Echo Reply"},
78 { 0, NULL}
79};
80
81static const struct tok lspping_reply_mode_values[] = {
82 { 1, "Do not reply"},
83 { 2, "Reply via an IPv4/IPv6 UDP packet"},
84 { 3, "Reply via an IPv4/IPv6 UDP packet with Router Alert"},
85 { 4, "Reply via application level control channel"},
86 { 0, NULL}
87};
88
89static const struct tok lspping_return_code_values[] = {
90 { 0, "No return code or return code contained in the Error Code TLV"},
91 { 1, "Malformed echo request received"},
92 { 2, "One or more of the TLVs was not understood"},
93 { 3, "Replying router is an egress for the FEC at stack depth"},
94 { 4, "Replying router has no mapping for the FEC at stack depth"},
95 { 5, "Reserved"},
96 { 6, "Reserved"},
97 { 7, "Reserved"},
98 { 8, "Label switched at stack-depth"},
99 { 9, "Label switched but no MPLS forwarding at stack-depth"},
100 { 10, "Mapping for this FEC is not the given label at stack depth"},
101 { 11, "No label entry at stack-depth"},
102 { 12, "Protocol not associated with interface at FEC stack depth"},
103};
104
105
Elliott Hughes892a68b2015-10-19 14:43:53 -0700106/*
The Android Open Source Project2949f582009-03-03 19:30:46 -0800107 * LSPPING TLV header
108 * 0 1 2 3
109 * 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
110 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111 * | Type | Length |
112 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
113 * | Value |
114 * . .
115 * . .
116 * . .
117 * | |
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 */
120
121struct lspping_tlv_header {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700122 uint8_t type[2];
123 uint8_t length[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800124};
125
126#define LSPPING_TLV_TARGET_FEC_STACK 1
127#define LSPPING_TLV_DOWNSTREAM_MAPPING 2
128#define LSPPING_TLV_PAD 3
JP Abgrall53f17a92014-02-12 14:02:41 -0800129#define LSPPING_TLV_VENDOR_ENTERPRISE 5
130#define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
131#define LSPPING_TLV_INTERFACE_LABEL_STACK 7
132#define LSPPING_TLV_ERROR_CODE 9
133#define LSPPING_TLV_REPLY_TOS_BYTE 10
The Android Open Source Project2949f582009-03-03 19:30:46 -0800134#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
135#define LSPPING_TLV_BFD_DISCRIMINATOR_LEN 4
136#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00
137
138static const struct tok lspping_tlv_values[] = {
139 { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" },
140 { LSPPING_TLV_DOWNSTREAM_MAPPING, "Downstream Mapping" },
141 { LSPPING_TLV_PAD, "Pad" },
142 { LSPPING_TLV_ERROR_CODE, "Error Code" },
JP Abgrall53f17a92014-02-12 14:02:41 -0800143 { LSPPING_TLV_VENDOR_ENTERPRISE, "Vendor Enterprise Code" },
144 { LSPPING_TLV_INTERFACE_LABEL_STACK, "Interface Label Stack" },
145 { LSPPING_TLV_REPLY_TOS_BYTE, "Reply TOS Byte" },
The Android Open Source Project2949f582009-03-03 19:30:46 -0800146 { LSPPING_TLV_BFD_DISCRIMINATOR, "BFD Discriminator" },
JP Abgrall53f17a92014-02-12 14:02:41 -0800147 { LSPPING_TLV_VENDOR_PRIVATE, "Vendor Private Code" },
The Android Open Source Project2949f582009-03-03 19:30:46 -0800148 { 0, NULL}
149};
150
151#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
152#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
153#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
154#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
155#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
156#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
157#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
158#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
159#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10
160#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11
161#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12
162
163static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
164 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
165 { LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6, "LDP IPv6 prefix"},
166 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4, "RSVP IPv4 Session Query"},
167 { LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6, "RSVP IPv6 Session Query"},
168 { 5, "Reserved"},
169 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
170 { LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
171 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
172 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"},
173 { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},
174 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
175 { LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
176 { 0, NULL}
177};
178
179/*
180 * 0 1 2 3
181 * 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
182 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
183 * | IPv4 prefix |
184 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
185 * | Prefix Length | Must Be Zero |
186 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187 */
188struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700189 uint8_t prefix [4];
190 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800191};
192
193/*
194 * 0 1 2 3
195 * 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
196 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197 * | IPv6 prefix |
198 * | (16 octets) |
199 * | |
200 * | |
201 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
202 * | Prefix Length | Must Be Zero |
203 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
204 */
205struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700206 uint8_t prefix [16];
207 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800208};
209
210/*
211 * 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
212 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
213 * | Sender identifier |
214 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
215 * | IPv4 prefix |
216 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 * | Prefix Length | Must Be Zero |
218 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219 */
220struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700221 uint8_t sender_id [4];
222 uint8_t prefix [4];
223 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800224};
225
226/*
227 * 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
228 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
229 * | Sender identifier |
230 * | (16 octets) |
231 * | |
232 * | |
233 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
234 * | IPv6 prefix |
235 * | (16 octets) |
236 * | |
237 * | |
238 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
239 * | Prefix Length | Must Be Zero |
240 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
241 */
242struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700243 uint8_t sender_id [16];
244 uint8_t prefix [16];
245 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800246};
247
248/*
249 * 0 1 2 3
250 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
251 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252 * | IPv4 tunnel end point address |
253 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
254 * | Must Be Zero | Tunnel ID |
255 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256 * | Extended Tunnel ID |
257 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258 * | IPv4 tunnel sender address |
259 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
260 * | Must Be Zero | LSP ID |
261 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
262 */
263struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700264 uint8_t tunnel_endpoint [4];
265 uint8_t res[2];
266 uint8_t tunnel_id[2];
267 uint8_t extended_tunnel_id[4];
268 uint8_t tunnel_sender [4];
269 uint8_t res2[2];
270 uint8_t lsp_id [2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800271};
272
273/*
274 * 0 1 2 3
275 * 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
276 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
277 * | IPv6 tunnel end point address |
278 * | |
279 * | |
280 * | |
281 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
282 * | Must Be Zero | Tunnel ID |
283 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
284 * | Extended Tunnel ID |
285 * | |
286 * | |
287 * | |
288 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289 * | IPv6 tunnel sender address |
290 * | |
291 * | |
292 * | |
293 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
294 * | Must Be Zero | LSP ID |
295 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
296 */
297struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700298 uint8_t tunnel_endpoint [16];
299 uint8_t res[2];
300 uint8_t tunnel_id[2];
301 uint8_t extended_tunnel_id[16];
302 uint8_t tunnel_sender [16];
303 uint8_t res2[2];
304 uint8_t lsp_id [2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800305};
306
307/*
308 * 0 1 2 3
309 * 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
310 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311 * | Route Distinguisher |
312 * | (8 octets) |
313 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
314 * | IPv4 prefix |
315 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
316 * | Prefix Length | Must Be Zero |
317 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318 */
319struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700320 uint8_t rd [8];
321 uint8_t prefix [4];
322 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800323};
324
325/*
326 * 0 1 2 3
327 * 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
328 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
329 * | Route Distinguisher |
330 * | (8 octets) |
331 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
332 * | IPv6 prefix |
333 * | (16 octets) |
334 * | |
335 * | |
336 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
337 * | Prefix Length | Must Be Zero |
338 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
339 */
340struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700341 uint8_t rd [8];
342 uint8_t prefix [16];
343 uint8_t prefix_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800344};
345
346/*
347 * 0 1 2 3
348 * 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
349 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
350 * | Route Distinguisher |
351 * | (8 octets) |
352 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
353 * | Sender's CE ID | Receiver's CE ID |
354 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
355 * | Encapsulation Type | Must Be Zero |
356 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357 * 0 1 2 3
358 */
359struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700360 uint8_t rd [8];
361 uint8_t sender_ce_id [2];
362 uint8_t receiver_ce_id [2];
363 uint8_t encapsulation[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800364};
365
366/*
367 * 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
368 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 * | Remote PE Address |
370 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371 * | VC ID |
372 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
373 * | Encapsulation Type | Must Be Zero |
374 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375 */
376struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700377 uint8_t remote_pe_address [4];
378 uint8_t vc_id [4];
379 uint8_t encapsulation[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800380};
381
382/*
383 * 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
384 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
385 * | Sender's PE Address |
386 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
387 * | Remote PE Address |
388 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
389 * | VC ID |
390 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
391 * | Encapsulation Type | Must Be Zero |
392 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
393 */
394struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700395 uint8_t sender_pe_address [4];
396 uint8_t remote_pe_address [4];
397 uint8_t vc_id [4];
398 uint8_t encapsulation[2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800399};
400
401/*
402 * 0 1 2 3
403 * 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
404 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
405 * | MTU | Address Type | Resvd (SBZ) |
406 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
407 * | Downstream IP Address (4 or 16 octets) |
408 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
409 * | Downstream Interface Address (4 or 16 octets) |
410 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
411 * | Hash Key Type | Depth Limit | Multipath Length |
412 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
413 * . .
414 * . (Multipath Information) .
415 * . .
416 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
417 * | Downstream Label | Protocol |
418 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
419 * . .
420 * . .
421 * . .
422 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
423 * | Downstream Label | Protocol |
424 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
425 */
426struct lspping_tlv_downstream_map_ipv4_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700427 uint8_t mtu [2];
428 uint8_t address_type;
429 uint8_t res;
430 uint8_t downstream_ip[4];
431 uint8_t downstream_interface[4];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800432};
433
434struct lspping_tlv_downstream_map_ipv6_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700435 uint8_t mtu [2];
436 uint8_t address_type;
437 uint8_t res;
438 uint8_t downstream_ip[16];
439 uint8_t downstream_interface[16];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800440};
441
442struct lspping_tlv_downstream_map_info_t {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700443 uint8_t hash_key_type;
444 uint8_t depth_limit;
445 uint8_t multipath_length [2];
The Android Open Source Project2949f582009-03-03 19:30:46 -0800446};
447
448#define LSPPING_AFI_IPV4 1
449#define LSPPING_AFI_UNMB 2
450#define LSPPING_AFI_IPV6 3
451
452static const struct tok lspping_tlv_downstream_addr_values[] = {
453 { LSPPING_AFI_IPV4, "IPv4"},
454 { LSPPING_AFI_IPV6, "IPv6"},
455 { LSPPING_AFI_UNMB, "Unnumbered"},
456 { 0, NULL}
457};
458
459void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700460lspping_print(netdissect_options *ndo,
461 register const u_char *pptr, register u_int len)
462{
The Android Open Source Project2949f582009-03-03 19:30:46 -0800463 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;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700470 struct timeval timestamp;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800471
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;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700494 ND_TCHECK(*lspping_com_header);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800495
496 /*
497 * Sanity checking of the header.
498 */
499 if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700500 ND_PRINT((ndo, "LSP-PING version %u packet not supported",
501 EXTRACT_16BITS(&lspping_com_header->version[0])));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800502 return;
503 }
504
505 /* in non-verbose mode just lets print the basic Message Type*/
Elliott Hughes892a68b2015-10-19 14:43:53 -0700506 if (ndo->ndo_vflag < 1) {
507 ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800508 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),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700511 len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800512 return;
513 }
514
515 /* ok they seem to want to know everything - lets fully decode it */
516
517 tlen=len;
518
Elliott Hughes892a68b2015-10-19 14:43:53 -0700519 ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800520 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),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700525 lspping_com_header->reply_mode));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800526
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 )
Elliott Hughes892a68b2015-10-19 14:43:53 -0700537 ND_PRINT((ndo, "\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800538 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700539 lspping_com_header->return_subcode,
The Android Open Source Project2949f582009-03-03 19:30:46 -0800540 lspping_com_header->return_code,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700541 lspping_com_header->return_subcode));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800542 else
Elliott Hughes892a68b2015-10-19 14:43:53 -0700543 ND_PRINT((ndo, "\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
544 tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800545 lspping_com_header->return_code,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700546 lspping_com_header->return_subcode));
547
548 ND_PRINT((ndo, "\n\t Sender Handle: 0x%08x, Sequence: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800549 EXTRACT_32BITS(lspping_com_header->sender_handle),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700550 EXTRACT_32BITS(lspping_com_header->seq_number)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800551
552 timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700553 timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
554 ND_PRINT((ndo, "\n\t Sender Timestamp: "));
555 ts_print(ndo, &timestamp);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800556
557 timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700558 timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
559 ND_PRINT((ndo, "Receiver Timestamp: "));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800560 if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700561 ts_print(ndo, &timestamp);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800562 else
Elliott Hughes892a68b2015-10-19 14:43:53 -0700563 ND_PRINT((ndo, "no timestamp"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800564
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)) {
JP Abgrall53f17a92014-02-12 14:02:41 -0800569
The Android Open Source Project2949f582009-03-03 19:30:46 -0800570 /* did we capture enough for fully decoding the tlv header ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700571 ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800572
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
JP Abgrall53f17a92014-02-12 14:02:41 -0800577 /* some little sanity checking */
578 if (lspping_tlv_type == 0 || lspping_tlv_len == 0)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800579 return;
580
JP Abgrall53f17a92014-02-12 14:02:41 -0800581 if(lspping_tlv_len < 4) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700582 ND_PRINT((ndo, "\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800583 return;
584 }
585
Elliott Hughes892a68b2015-10-19 14:43:53 -0700586 ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800587 tok2str(lspping_tlv_values,
588 "Unknown",
589 lspping_tlv_type),
590 lspping_tlv_type,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700591 lspping_tlv_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800592
593 tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
594 tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
595
596 /* did we capture enough for fully decoding the tlv ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700597 ND_TCHECK2(*tptr, lspping_tlv_len);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800598 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 ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700605 ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800606 subtlv_hexdump=FALSE;
607
608 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
609 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
610 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
611 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700612
The Android Open Source Project2949f582009-03-03 19:30:46 -0800613 if (lspping_subtlv_len == 0)
614 break;
615
Elliott Hughes892a68b2015-10-19 14:43:53 -0700616 ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800617 tok2str(lspping_tlvtargetfec_subtlv_values,
618 "Unknown",
619 lspping_subtlv_type),
620 lspping_subtlv_type,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700621 lspping_subtlv_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800622
623 switch(lspping_subtlv_type) {
624
625 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
626 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
627 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700628 ND_PRINT((ndo, "\n\t %s/%u",
629 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
630 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800631 break;
632
633#ifdef INET6
634 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
635 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
636 (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700637 ND_PRINT((ndo, "\n\t %s/%u",
638 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
639 subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800640 break;
641#endif
642
643 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
644 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
645 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700646 ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
647 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800648 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700649 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800650 break;
651
652#ifdef INET6
653 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
654 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
655 (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700656 ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
657 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800658 subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700659 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800660 break;
661#endif
662
663 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
664 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
665 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700666 ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800667 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700668 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
669 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800670 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
671 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700672 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800673 break;
674
675#ifdef INET6
676 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
677 subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
678 (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700679 ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800680 "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700681 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
682 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800683 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
684 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700685 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800686 break;
687#endif
688
689 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
690 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
691 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700692 ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
693 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
694 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
695 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800696 break;
697
698#ifdef INET6
699 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
700 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
701 (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700702 ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
703 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
704 ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
705 subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800706 break;
707#endif
708
709 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
710 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
711 (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700712 ND_PRINT((ndo, "\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800713 "\n\t Encapsulation Type: %s (%u)",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700714 bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800715 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
716 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
717 tok2str(l2vpn_encaps_values,
718 "unknown",
719 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700720 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
721
The Android Open Source Project2949f582009-03-03 19:30:46 -0800722 break;
723
724 /* the old L2VPN VCID subTLV does not have support for the sender field */
725 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
726 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
727 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700728 ND_PRINT((ndo, "\n\t Remote PE: %s" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800729 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700730 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800731 EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
732 tok2str(l2vpn_encaps_values,
733 "unknown",
734 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700735 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)));
736
The Android Open Source Project2949f582009-03-03 19:30:46 -0800737 break;
738
739 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
740 subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
741 (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700742 ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800743 "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700744 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
745 ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800746 EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
747 tok2str(l2vpn_encaps_values,
748 "unknown",
749 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700750 EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)));
751
The Android Open Source Project2949f582009-03-03 19:30:46 -0800752 break;
753
754 default:
755 subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
756 break;
757 }
758 /* do we want to see an additionally subtlv hexdump ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700759 if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
760 print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800761 "\n\t ",
762 lspping_subtlv_len);
763
764 tlv_tptr+=lspping_subtlv_len;
765 tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
766 }
767 break;
768
769 case LSPPING_TLV_DOWNSTREAM_MAPPING:
770 /* that strange thing with the downstream map TLV is that until now
Elliott Hughes892a68b2015-10-19 14:43:53 -0700771 * we do not know if its IPv4 or IPv6 , after we found the address-type
The Android Open Source Project2949f582009-03-03 19:30:46 -0800772 * lets recast the tlv_tptr and move on */
773
774 tlv_ptr.lspping_tlv_downstream_map_ipv4= \
775 (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
776 tlv_ptr.lspping_tlv_downstream_map_ipv6= \
777 (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700778 ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800779 EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
780 tok2str(lspping_tlv_downstream_addr_values,
781 "unknown",
782 tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700783 tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800784
785 switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
786
787 case LSPPING_AFI_IPV4:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700788 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800789 "\n\t Downstream Interface IP: %s",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700790 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
791 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800792 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
793 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
794 break;
795#ifdef INET6
796 case LSPPING_AFI_IPV6:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700797 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800798 "\n\t Downstream Interface IP: %s",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700799 ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
800 ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800801 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
802 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
803 break;
804#endif
805 case LSPPING_AFI_UNMB:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700806 ND_PRINT((ndo, "\n\t Downstream IP: %s" \
The Android Open Source Project2949f582009-03-03 19:30:46 -0800807 "\n\t Downstream Interface Index: 0x%08x",
Elliott Hughes892a68b2015-10-19 14:43:53 -0700808 ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
809 EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800810 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
811 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
812 break;
813
814 default:
815 /* should not happen ! - no error message - tok2str() has barked already */
816 break;
817 }
818
819 tlv_ptr.lspping_tlv_downstream_map_info= \
820 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700821
The Android Open Source Project2949f582009-03-03 19:30:46 -0800822 /* FIXME add hash-key type, depth limit, multipath processing */
823
824
825 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
826 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
827
828 /* FIXME print downstream labels */
829
830
831 tlv_hexdump=TRUE; /* dump the TLV until code complete */
832
833 break;
834
835 case LSPPING_TLV_BFD_DISCRIMINATOR:
836 tptr += sizeof(struct lspping_tlv_header);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700837 ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
838 ND_PRINT((ndo, "\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800839 break;
JP Abgrall53f17a92014-02-12 14:02:41 -0800840
841 case LSPPING_TLV_VENDOR_ENTERPRISE:
842 {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700843 uint32_t vendor_id;
JP Abgrall53f17a92014-02-12 14:02:41 -0800844
Elliott Hughes892a68b2015-10-19 14:43:53 -0700845 ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
JP Abgrall53f17a92014-02-12 14:02:41 -0800846 vendor_id = EXTRACT_32BITS(tlv_tptr);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700847 ND_PRINT((ndo, "\n\t Vendor: %s (0x%04x)",
JP Abgrall53f17a92014-02-12 14:02:41 -0800848 tok2str(smi_values, "Unknown", vendor_id),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700849 vendor_id));
JP Abgrall53f17a92014-02-12 14:02:41 -0800850 }
851 break;
852
The Android Open Source Project2949f582009-03-03 19:30:46 -0800853 /*
854 * FIXME those are the defined TLVs that lack a decoder
855 * you are welcome to contribute code ;-)
856 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800857 case LSPPING_TLV_PAD:
858 case LSPPING_TLV_ERROR_CODE:
859 case LSPPING_TLV_VENDOR_PRIVATE:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700860
The Android Open Source Project2949f582009-03-03 19:30:46 -0800861 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700862 if (ndo->ndo_vflag <= 1)
863 print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800864 break;
865 }
866 /* do we want to see an additionally tlv hexdump ? */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700867 if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
868 print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800869 lspping_tlv_len);
870
JP Abgrall53f17a92014-02-12 14:02:41 -0800871
872 /* All TLVs are aligned to four octet boundary */
873 if (lspping_tlv_len % 4) {
874 lspping_tlv_len += (4 - lspping_tlv_len % 4);
875 }
876
The Android Open Source Project2949f582009-03-03 19:30:46 -0800877 tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
878 tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
879 }
880 return;
881trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700882 ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800883}
Elliott Hughes892a68b2015-10-19 14:43:53 -0700884/*
885 * Local Variables:
886 * c-style: whitesmith
887 * c-basic-offset: 8
888 * End:
889 */