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