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