]> The Tcpdump Group git mirrors - tcpdump/blob - print-juniper.c
CHANGES: Move change(s) backported to 4.99
[tcpdump] / print-juniper.c
1 /* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */
2
3 /*
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
14 *
15 * Original code by Hannes Gredler (hannes@gredler.at)
16 */
17
18 /* \summary: DLT_JUNIPER_* printers */
19
20 #ifndef lint
21 #else
22 __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
23 #endif
24
25 #include <config.h>
26
27 #include "netdissect-stdinc.h"
28
29 #include <string.h>
30
31 #define ND_LONGJMP_FROM_TCHECK
32 #include "netdissect.h"
33 #include "addrtoname.h"
34 #include "extract.h"
35 #include "ppp.h"
36 #include "llc.h"
37 #include "nlpid.h"
38 #include "ethertype.h"
39 #include "atm.h"
40
41 /*
42 * If none of the Juniper DLT_s are defined, there's nothing to do.
43 */
44 #if defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \
45 defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \
46 defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \
47 defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \
48 defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \
49 defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \
50 defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \
51 defined(DLT_JUNIPER_ATM2)
52 #define JUNIPER_BPF_OUT 0 /* Outgoing packet */
53 #define JUNIPER_BPF_IN 1 /* Incoming packet */
54 #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */
55 #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */
56 #define JUNIPER_BPF_IIF 0x4 /* IIF is valid */
57 #define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */
58 #define JUNIPER_BPF_EXT 0x80 /* extensions present */
59 #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */
60
61 #define JUNIPER_LSQ_COOKIE_RE (1 << 3)
62 #define JUNIPER_LSQ_COOKIE_DIR (1 << 2)
63 #define JUNIPER_LSQ_L3_PROTO_SHIFT 4
64 #define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT)
65 #define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT)
66 #define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT)
67 #define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT)
68 #define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT)
69 #define AS_PIC_COOKIE_LEN 8
70
71 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1
72 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2
73 #define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3
74 #define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
75 #define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
76
77 #ifdef DLT_JUNIPER_ES
78 static const struct tok juniper_ipsec_type_values[] = {
79 { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" },
80 { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" },
81 { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" },
82 { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE, "AH AUTH" },
83 { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE, "ESP ENCR" },
84 { 0, NULL}
85 };
86 #endif
87
88 static const struct tok juniper_direction_values[] = {
89 { JUNIPER_BPF_IN, "In"},
90 { JUNIPER_BPF_OUT, "Out"},
91 { 0, NULL}
92 };
93
94 /* codepoints for encoding extensions to a .pcap file */
95 enum {
96 JUNIPER_EXT_TLV_IFD_IDX = 1,
97 JUNIPER_EXT_TLV_IFD_NAME = 2,
98 JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3,
99 JUNIPER_EXT_TLV_IFL_IDX = 4,
100 JUNIPER_EXT_TLV_IFL_UNIT = 5,
101 JUNIPER_EXT_TLV_IFL_ENCAPS = 6,
102 JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7,
103 JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8
104 };
105
106 /* 1 byte type and 1-byte length */
107 #define JUNIPER_EXT_TLV_OVERHEAD 2U
108
109 static const struct tok jnx_ext_tlv_values[] = {
110 { JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" },
111 { JUNIPER_EXT_TLV_IFD_NAME,"Device Interface Name" },
112 { JUNIPER_EXT_TLV_IFD_MEDIATYPE, "Device Media Type" },
113 { JUNIPER_EXT_TLV_IFL_IDX, "Logical Interface Index" },
114 { JUNIPER_EXT_TLV_IFL_UNIT,"Logical Unit Number" },
115 { JUNIPER_EXT_TLV_IFL_ENCAPS, "Logical Interface Encapsulation" },
116 { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE, "TTP derived Device Media Type" },
117 { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS, "TTP derived Logical Interface Encapsulation" },
118 { 0, NULL }
119 };
120
121 static const struct tok jnx_flag_values[] = {
122 { JUNIPER_BPF_EXT, "Ext" },
123 { JUNIPER_BPF_FILTER, "Filter" },
124 { JUNIPER_BPF_IIF, "IIF" },
125 { JUNIPER_BPF_NO_L2, "no-L2" },
126 { JUNIPER_BPF_PKT_IN, "In" },
127 { 0, NULL }
128 };
129
130 #define JUNIPER_IFML_ETHER 1
131 #define JUNIPER_IFML_FDDI 2
132 #define JUNIPER_IFML_TOKENRING 3
133 #define JUNIPER_IFML_PPP 4
134 #define JUNIPER_IFML_FRAMERELAY 5
135 #define JUNIPER_IFML_CISCOHDLC 6
136 #define JUNIPER_IFML_SMDSDXI 7
137 #define JUNIPER_IFML_ATMPVC 8
138 #define JUNIPER_IFML_PPP_CCC 9
139 #define JUNIPER_IFML_FRAMERELAY_CCC 10
140 #define JUNIPER_IFML_IPIP 11
141 #define JUNIPER_IFML_GRE 12
142 #define JUNIPER_IFML_PIM 13
143 #define JUNIPER_IFML_PIMD 14
144 #define JUNIPER_IFML_CISCOHDLC_CCC 15
145 #define JUNIPER_IFML_VLAN_CCC 16
146 #define JUNIPER_IFML_MLPPP 17
147 #define JUNIPER_IFML_MLFR 18
148 #define JUNIPER_IFML_ML 19
149 #define JUNIPER_IFML_LSI 20
150 #define JUNIPER_IFML_DFE 21
151 #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22
152 #define JUNIPER_IFML_CRYPTO 23
153 #define JUNIPER_IFML_GGSN 24
154 #define JUNIPER_IFML_LSI_PPP 25
155 #define JUNIPER_IFML_LSI_CISCOHDLC 26
156 #define JUNIPER_IFML_PPP_TCC 27
157 #define JUNIPER_IFML_FRAMERELAY_TCC 28
158 #define JUNIPER_IFML_CISCOHDLC_TCC 29
159 #define JUNIPER_IFML_ETHERNET_CCC 30
160 #define JUNIPER_IFML_VT 31
161 #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32
162 #define JUNIPER_IFML_ETHER_OVER_ATM 33
163 #define JUNIPER_IFML_MONITOR 34
164 #define JUNIPER_IFML_ETHERNET_TCC 35
165 #define JUNIPER_IFML_VLAN_TCC 36
166 #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37
167 #define JUNIPER_IFML_CONTROLLER 38
168 #define JUNIPER_IFML_MFR 39
169 #define JUNIPER_IFML_LS 40
170 #define JUNIPER_IFML_ETHERNET_VPLS 41
171 #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42
172 #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43
173 #define JUNIPER_IFML_LT 44
174 #define JUNIPER_IFML_SERVICES 45
175 #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46
176 #define JUNIPER_IFML_FR_PORT_CCC 47
177 #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48
178 #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49
179 #define JUNIPER_IFML_FRAMERELAY_FLEX 50
180 #define JUNIPER_IFML_GGSNI 51
181 #define JUNIPER_IFML_ETHERNET_FLEX 52
182 #define JUNIPER_IFML_COLLECTOR 53
183 #define JUNIPER_IFML_AGGREGATOR 54
184 #define JUNIPER_IFML_LAPD 55
185 #define JUNIPER_IFML_PPPOE 56
186 #define JUNIPER_IFML_PPP_SUBORDINATE 57
187 #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58
188 #define JUNIPER_IFML_DFC 59
189 #define JUNIPER_IFML_PICPEER 60
190
191 static const struct tok juniper_ifmt_values[] = {
192 { JUNIPER_IFML_ETHER, "Ethernet" },
193 { JUNIPER_IFML_FDDI, "FDDI" },
194 { JUNIPER_IFML_TOKENRING, "Token-Ring" },
195 { JUNIPER_IFML_PPP, "PPP" },
196 { JUNIPER_IFML_PPP_SUBORDINATE, "PPP-Subordinate" },
197 { JUNIPER_IFML_FRAMERELAY, "Frame-Relay" },
198 { JUNIPER_IFML_CISCOHDLC, "Cisco-HDLC" },
199 { JUNIPER_IFML_SMDSDXI, "SMDS-DXI" },
200 { JUNIPER_IFML_ATMPVC, "ATM-PVC" },
201 { JUNIPER_IFML_PPP_CCC, "PPP-CCC" },
202 { JUNIPER_IFML_FRAMERELAY_CCC, "Frame-Relay-CCC" },
203 { JUNIPER_IFML_FRAMERELAY_EXT_CCC, "Extended FR-CCC" },
204 { JUNIPER_IFML_IPIP, "IP-over-IP" },
205 { JUNIPER_IFML_GRE, "GRE" },
206 { JUNIPER_IFML_PIM, "PIM-Encapsulator" },
207 { JUNIPER_IFML_PIMD, "PIM-Decapsulator" },
208 { JUNIPER_IFML_CISCOHDLC_CCC, "Cisco-HDLC-CCC" },
209 { JUNIPER_IFML_VLAN_CCC, "VLAN-CCC" },
210 { JUNIPER_IFML_EXTENDED_VLAN_CCC, "Extended-VLAN-CCC" },
211 { JUNIPER_IFML_MLPPP, "Multilink-PPP" },
212 { JUNIPER_IFML_MLFR, "Multilink-FR" },
213 { JUNIPER_IFML_MFR, "Multilink-FR-UNI-NNI" },
214 { JUNIPER_IFML_ML, "Multilink" },
215 { JUNIPER_IFML_LS, "LinkService" },
216 { JUNIPER_IFML_LSI, "LSI" },
217 { JUNIPER_IFML_ATM_CELLRELAY_CCC, "ATM-CCC-Cell-Relay" },
218 { JUNIPER_IFML_CRYPTO, "IPSEC-over-IP" },
219 { JUNIPER_IFML_GGSN, "GGSN" },
220 { JUNIPER_IFML_PPP_TCC, "PPP-TCC" },
221 { JUNIPER_IFML_FRAMERELAY_TCC, "Frame-Relay-TCC" },
222 { JUNIPER_IFML_FRAMERELAY_EXT_TCC, "Extended FR-TCC" },
223 { JUNIPER_IFML_CISCOHDLC_TCC, "Cisco-HDLC-TCC" },
224 { JUNIPER_IFML_ETHERNET_CCC, "Ethernet-CCC" },
225 { JUNIPER_IFML_VT, "VPN-Loopback-tunnel" },
226 { JUNIPER_IFML_ETHER_OVER_ATM, "Ethernet-over-ATM" },
227 { JUNIPER_IFML_ETHER_VPLS_OVER_ATM, "Ethernet-VPLS-over-ATM" },
228 { JUNIPER_IFML_MONITOR, "Monitor" },
229 { JUNIPER_IFML_ETHERNET_TCC, "Ethernet-TCC" },
230 { JUNIPER_IFML_VLAN_TCC, "VLAN-TCC" },
231 { JUNIPER_IFML_EXTENDED_VLAN_TCC, "Extended-VLAN-TCC" },
232 { JUNIPER_IFML_CONTROLLER, "Controller" },
233 { JUNIPER_IFML_ETHERNET_VPLS, "VPLS" },
234 { JUNIPER_IFML_ETHERNET_VLAN_VPLS, "VLAN-VPLS" },
235 { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS, "Extended-VLAN-VPLS" },
236 { JUNIPER_IFML_LT, "Logical-tunnel" },
237 { JUNIPER_IFML_SERVICES, "General-Services" },
238 { JUNIPER_IFML_PPPOE, "PPPoE" },
239 { JUNIPER_IFML_ETHERNET_FLEX, "Flexible-Ethernet-Services" },
240 { JUNIPER_IFML_FRAMERELAY_FLEX, "Flexible-FrameRelay" },
241 { JUNIPER_IFML_COLLECTOR, "Flow-collection" },
242 { JUNIPER_IFML_PICPEER, "PIC Peer" },
243 { JUNIPER_IFML_DFC, "Dynamic-Flow-Capture" },
244 {0, NULL}
245 };
246
247 #define JUNIPER_IFLE_ATM_SNAP 2
248 #define JUNIPER_IFLE_ATM_NLPID 3
249 #define JUNIPER_IFLE_ATM_VCMUX 4
250 #define JUNIPER_IFLE_ATM_LLC 5
251 #define JUNIPER_IFLE_ATM_PPP_VCMUX 6
252 #define JUNIPER_IFLE_ATM_PPP_LLC 7
253 #define JUNIPER_IFLE_ATM_PPP_FUNI 8
254 #define JUNIPER_IFLE_ATM_CCC 9
255 #define JUNIPER_IFLE_FR_NLPID 10
256 #define JUNIPER_IFLE_FR_SNAP 11
257 #define JUNIPER_IFLE_FR_PPP 12
258 #define JUNIPER_IFLE_FR_CCC 13
259 #define JUNIPER_IFLE_ENET2 14
260 #define JUNIPER_IFLE_IEEE8023_SNAP 15
261 #define JUNIPER_IFLE_IEEE8023_LLC 16
262 #define JUNIPER_IFLE_PPP 17
263 #define JUNIPER_IFLE_CISCOHDLC 18
264 #define JUNIPER_IFLE_PPP_CCC 19
265 #define JUNIPER_IFLE_IPIP_NULL 20
266 #define JUNIPER_IFLE_PIM_NULL 21
267 #define JUNIPER_IFLE_GRE_NULL 22
268 #define JUNIPER_IFLE_GRE_PPP 23
269 #define JUNIPER_IFLE_PIMD_DECAPS 24
270 #define JUNIPER_IFLE_CISCOHDLC_CCC 25
271 #define JUNIPER_IFLE_ATM_CISCO_NLPID 26
272 #define JUNIPER_IFLE_VLAN_CCC 27
273 #define JUNIPER_IFLE_MLPPP 28
274 #define JUNIPER_IFLE_MLFR 29
275 #define JUNIPER_IFLE_LSI_NULL 30
276 #define JUNIPER_IFLE_AGGREGATE_UNUSED 31
277 #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32
278 #define JUNIPER_IFLE_CRYPTO 33
279 #define JUNIPER_IFLE_GGSN 34
280 #define JUNIPER_IFLE_ATM_TCC 35
281 #define JUNIPER_IFLE_FR_TCC 36
282 #define JUNIPER_IFLE_PPP_TCC 37
283 #define JUNIPER_IFLE_CISCOHDLC_TCC 38
284 #define JUNIPER_IFLE_ETHERNET_CCC 39
285 #define JUNIPER_IFLE_VT 40
286 #define JUNIPER_IFLE_ATM_EOA_LLC 41
287 #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42
288 #define JUNIPER_IFLE_ATM_SNAP_TCC 43
289 #define JUNIPER_IFLE_MONITOR 44
290 #define JUNIPER_IFLE_ETHERNET_TCC 45
291 #define JUNIPER_IFLE_VLAN_TCC 46
292 #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47
293 #define JUNIPER_IFLE_MFR 48
294 #define JUNIPER_IFLE_ETHERNET_VPLS 49
295 #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50
296 #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51
297 #define JUNIPER_IFLE_SERVICES 52
298 #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53
299 #define JUNIPER_IFLE_FR_PORT_CCC 54
300 #define JUNIPER_IFLE_ATM_MLPPP_LLC 55
301 #define JUNIPER_IFLE_ATM_EOA_CCC 56
302 #define JUNIPER_IFLE_LT_VLAN 57
303 #define JUNIPER_IFLE_COLLECTOR 58
304 #define JUNIPER_IFLE_AGGREGATOR 59
305 #define JUNIPER_IFLE_LAPD 60
306 #define JUNIPER_IFLE_ATM_PPPOE_LLC 61
307 #define JUNIPER_IFLE_ETHERNET_PPPOE 62
308 #define JUNIPER_IFLE_PPPOE 63
309 #define JUNIPER_IFLE_PPP_SUBORDINATE 64
310 #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65
311 #define JUNIPER_IFLE_DFC 66
312 #define JUNIPER_IFLE_PICPEER 67
313
314 static const struct tok juniper_ifle_values[] = {
315 { JUNIPER_IFLE_AGGREGATOR, "Aggregator" },
316 { JUNIPER_IFLE_ATM_CCC, "CCC over ATM" },
317 { JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" },
318 { JUNIPER_IFLE_ATM_CISCO_NLPID, "CISCO compatible NLPID" },
319 { JUNIPER_IFLE_ATM_EOA_CCC, "Ethernet over ATM CCC" },
320 { JUNIPER_IFLE_ATM_EOA_LLC, "Ethernet over ATM LLC" },
321 { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC, "Ethernet VPLS over ATM LLC" },
322 { JUNIPER_IFLE_ATM_LLC, "ATM LLC" },
323 { JUNIPER_IFLE_ATM_MLPPP_LLC, "MLPPP over ATM LLC" },
324 { JUNIPER_IFLE_ATM_NLPID, "ATM NLPID" },
325 { JUNIPER_IFLE_ATM_PPPOE_LLC, "PPPoE over ATM LLC" },
326 { JUNIPER_IFLE_ATM_PPP_FUNI, "PPP over FUNI" },
327 { JUNIPER_IFLE_ATM_PPP_LLC, "PPP over ATM LLC" },
328 { JUNIPER_IFLE_ATM_PPP_VCMUX, "PPP over ATM VCMUX" },
329 { JUNIPER_IFLE_ATM_SNAP, "ATM SNAP" },
330 { JUNIPER_IFLE_ATM_SNAP_TCC, "ATM SNAP TCC" },
331 { JUNIPER_IFLE_ATM_TCC, "ATM VCMUX TCC" },
332 { JUNIPER_IFLE_ATM_VCMUX, "ATM VCMUX" },
333 { JUNIPER_IFLE_CISCOHDLC, "C-HDLC" },
334 { JUNIPER_IFLE_CISCOHDLC_CCC, "C-HDLC CCC" },
335 { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE, "C-HDLC via dialer" },
336 { JUNIPER_IFLE_CISCOHDLC_TCC, "C-HDLC TCC" },
337 { JUNIPER_IFLE_COLLECTOR, "Collector" },
338 { JUNIPER_IFLE_CRYPTO, "Crypto" },
339 { JUNIPER_IFLE_ENET2, "Ethernet" },
340 { JUNIPER_IFLE_ETHERNET_CCC, "Ethernet CCC" },
341 { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS, "Extended VLAN VPLS" },
342 { JUNIPER_IFLE_ETHERNET_PPPOE, "PPPoE over Ethernet" },
343 { JUNIPER_IFLE_ETHERNET_TCC, "Ethernet TCC" },
344 { JUNIPER_IFLE_ETHERNET_VLAN_VPLS, "VLAN VPLS" },
345 { JUNIPER_IFLE_ETHERNET_VPLS, "VPLS" },
346 { JUNIPER_IFLE_EXTENDED_VLAN_CCC, "Extended VLAN CCC" },
347 { JUNIPER_IFLE_EXTENDED_VLAN_TCC, "Extended VLAN TCC" },
348 { JUNIPER_IFLE_FR_CCC, "FR CCC" },
349 { JUNIPER_IFLE_FR_NLPID, "FR NLPID" },
350 { JUNIPER_IFLE_FR_PORT_CCC, "FR CCC" },
351 { JUNIPER_IFLE_FR_PPP, "FR PPP" },
352 { JUNIPER_IFLE_FR_SNAP, "FR SNAP" },
353 { JUNIPER_IFLE_FR_TCC, "FR TCC" },
354 { JUNIPER_IFLE_GGSN, "GGSN" },
355 { JUNIPER_IFLE_GRE_NULL, "GRE NULL" },
356 { JUNIPER_IFLE_GRE_PPP, "PPP over GRE" },
357 { JUNIPER_IFLE_IPIP_NULL, "IPIP" },
358 { JUNIPER_IFLE_LAPD, "LAPD" },
359 { JUNIPER_IFLE_LSI_NULL, "LSI Null" },
360 { JUNIPER_IFLE_LT_VLAN, "LT VLAN" },
361 { JUNIPER_IFLE_MFR, "MFR" },
362 { JUNIPER_IFLE_MLFR, "MLFR" },
363 { JUNIPER_IFLE_MLPPP, "MLPPP" },
364 { JUNIPER_IFLE_MONITOR, "Monitor" },
365 { JUNIPER_IFLE_PIMD_DECAPS, "PIMd" },
366 { JUNIPER_IFLE_PIM_NULL, "PIM Null" },
367 { JUNIPER_IFLE_PPP, "PPP" },
368 { JUNIPER_IFLE_PPPOE, "PPPoE" },
369 { JUNIPER_IFLE_PPP_CCC, "PPP CCC" },
370 { JUNIPER_IFLE_PPP_SUBORDINATE, "" },
371 { JUNIPER_IFLE_PPP_TCC, "PPP TCC" },
372 { JUNIPER_IFLE_SERVICES, "General Services" },
373 { JUNIPER_IFLE_VLAN_CCC, "VLAN CCC" },
374 { JUNIPER_IFLE_VLAN_TCC, "VLAN TCC" },
375 { JUNIPER_IFLE_VT, "VT" },
376 {0, NULL}
377 };
378
379 struct juniper_cookie_table_t {
380 uint32_t pictype; /* pic type */
381 uint8_t cookie_len; /* cookie len */
382 const char *s; /* pic name */
383 };
384
385 static const struct juniper_cookie_table_t juniper_cookie_table[] = {
386 #ifdef DLT_JUNIPER_ATM1
387 { DLT_JUNIPER_ATM1, 4, "ATM1"},
388 #endif
389 #ifdef DLT_JUNIPER_ATM2
390 { DLT_JUNIPER_ATM2, 8, "ATM2"},
391 #endif
392 #ifdef DLT_JUNIPER_MLPPP
393 { DLT_JUNIPER_MLPPP, 2, "MLPPP"},
394 #endif
395 #ifdef DLT_JUNIPER_MLFR
396 { DLT_JUNIPER_MLFR, 2, "MLFR"},
397 #endif
398 #ifdef DLT_JUNIPER_MFR
399 { DLT_JUNIPER_MFR, 4, "MFR"},
400 #endif
401 #ifdef DLT_JUNIPER_PPPOE
402 { DLT_JUNIPER_PPPOE, 0, "PPPoE"},
403 #endif
404 #ifdef DLT_JUNIPER_PPPOE_ATM
405 { DLT_JUNIPER_PPPOE_ATM, 0, "PPPoE ATM"},
406 #endif
407 #ifdef DLT_JUNIPER_GGSN
408 { DLT_JUNIPER_GGSN, 8, "GGSN"},
409 #endif
410 #ifdef DLT_JUNIPER_MONITOR
411 { DLT_JUNIPER_MONITOR, 8, "MONITOR"},
412 #endif
413 #ifdef DLT_JUNIPER_SERVICES
414 { DLT_JUNIPER_SERVICES, 8, "AS"},
415 #endif
416 #ifdef DLT_JUNIPER_ES
417 { DLT_JUNIPER_ES, 0, "ES"},
418 #endif
419 { 0, 0, NULL }
420 };
421
422 struct juniper_l2info_t {
423 uint32_t length;
424 uint32_t caplen;
425 uint32_t pictype;
426 uint8_t direction;
427 u_int header_len;
428 uint8_t cookie_len;
429 uint8_t cookie_type;
430 uint8_t cookie[8];
431 u_int bundle;
432 uint16_t proto;
433 uint8_t flags;
434 };
435
436 #define LS_COOKIE_ID 0x54
437 #define AS_COOKIE_ID 0x47
438 #define LS_MLFR_COOKIE_LEN 4
439 #define ML_MLFR_COOKIE_LEN 2
440 #define LS_MFR_COOKIE_LEN 6
441 #define ATM1_COOKIE_LEN 4
442 #define ATM2_COOKIE_LEN 8
443
444 #define ATM2_PKT_TYPE_MASK 0x70
445 #define ATM2_GAP_COUNT_MASK 0x3F
446
447 #define JUNIPER_PROTO_NULL 1
448 #define JUNIPER_PROTO_IPV4 2
449 #define JUNIPER_PROTO_IPV6 6
450
451 #define MFR_BE_MASK 0xc0
452
453 #ifdef DLT_JUNIPER_GGSN
454 static const struct tok juniper_protocol_values[] = {
455 { JUNIPER_PROTO_NULL, "Null" },
456 { JUNIPER_PROTO_IPV4, "IPv4" },
457 { JUNIPER_PROTO_IPV6, "IPv6" },
458 { 0, NULL}
459 };
460 #endif
461
462 static int ip_heuristic_guess(netdissect_options *, const u_char *, u_int);
463 #ifdef DLT_JUNIPER_ATM2
464 static int juniper_ppp_heuristic_guess(netdissect_options *, const u_char *, u_int);
465 #endif
466 static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
467
468 #ifdef DLT_JUNIPER_GGSN
469 void
470 juniper_ggsn_if_print(netdissect_options *ndo,
471 const struct pcap_pkthdr *h, const u_char *p)
472 {
473 struct juniper_l2info_t l2info;
474 struct juniper_ggsn_header {
475 nd_uint8_t svc_id;
476 nd_uint8_t flags_len;
477 nd_uint8_t proto;
478 nd_uint8_t flags;
479 nd_uint16_t vlan_id;
480 nd_byte res[2];
481 };
482 const struct juniper_ggsn_header *gh;
483 uint8_t proto;
484
485 ndo->ndo_protocol = "juniper_ggsn";
486 memset(&l2info, 0, sizeof(l2info));
487 l2info.pictype = DLT_JUNIPER_GGSN;
488 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
489 ndo->ndo_ll_hdr_len += l2info.header_len;
490 return;
491 }
492
493 p+=l2info.header_len;
494 gh = (struct juniper_ggsn_header *)&l2info.cookie;
495
496 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
497 proto = EXTRACT_U_1(gh->proto);
498 if (ndo->ndo_eflag) {
499 ND_PRINT("proto %s (%u), vlan %u: ",
500 tok2str(juniper_protocol_values,"Unknown",proto),
501 proto,
502 EXTRACT_BE_U_2(gh->vlan_id));
503 }
504
505 switch (proto) {
506 case JUNIPER_PROTO_IPV4:
507 ip_print(ndo, p, l2info.length);
508 break;
509 case JUNIPER_PROTO_IPV6:
510 ip6_print(ndo, p, l2info.length);
511 break;
512 default:
513 if (!ndo->ndo_eflag)
514 ND_PRINT("unknown GGSN proto (%u)", proto);
515 }
516
517 ndo->ndo_ll_hdr_len += l2info.header_len;
518 }
519 #endif
520
521 #ifdef DLT_JUNIPER_ES
522 void
523 juniper_es_if_print(netdissect_options *ndo,
524 const struct pcap_pkthdr *h, const u_char *p)
525 {
526 struct juniper_l2info_t l2info;
527 struct juniper_ipsec_header {
528 nd_uint16_t sa_index;
529 nd_uint8_t ttl;
530 nd_uint8_t type;
531 nd_uint32_t spi;
532 nd_ipv4 src_ip;
533 nd_ipv4 dst_ip;
534 };
535 u_int rewrite_len,es_type_bundle;
536 const struct juniper_ipsec_header *ih;
537
538 ndo->ndo_protocol = "juniper_es";
539 memset(&l2info, 0, sizeof(l2info));
540 l2info.pictype = DLT_JUNIPER_ES;
541 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
542 ndo->ndo_ll_hdr_len += l2info.header_len;
543 return;
544 }
545
546 p+=l2info.header_len;
547 ih = (const struct juniper_ipsec_header *)p;
548
549 ND_TCHECK_SIZE(ih);
550 switch (GET_U_1(ih->type)) {
551 case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE:
552 case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE:
553 rewrite_len = 0;
554 es_type_bundle = 1;
555 break;
556 case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE:
557 case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE:
558 case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE:
559 rewrite_len = 16;
560 es_type_bundle = 0;
561 break;
562 default:
563 ND_PRINT("ES Invalid type %u, length %u",
564 GET_U_1(ih->type),
565 l2info.length);
566 ndo->ndo_ll_hdr_len += l2info.header_len;
567 return;
568 }
569
570 l2info.length-=rewrite_len;
571 p+=rewrite_len;
572
573 if (ndo->ndo_eflag) {
574 if (!es_type_bundle) {
575 ND_PRINT("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
576 GET_BE_U_2(ih->sa_index),
577 GET_U_1(ih->ttl),
578 tok2str(juniper_ipsec_type_values,"Unknown",GET_U_1(ih->type)),
579 GET_U_1(ih->type),
580 GET_BE_U_4(ih->spi),
581 GET_IPADDR_STRING(ih->src_ip),
582 GET_IPADDR_STRING(ih->dst_ip),
583 l2info.length);
584 } else {
585 ND_PRINT("ES SA, index %u, ttl %u type %s (%u), length %u\n",
586 GET_BE_U_2(ih->sa_index),
587 GET_U_1(ih->ttl),
588 tok2str(juniper_ipsec_type_values,"Unknown",GET_U_1(ih->type)),
589 GET_U_1(ih->type),
590 l2info.length);
591 }
592 }
593
594 ip_print(ndo, p, l2info.length);
595 ndo->ndo_ll_hdr_len += l2info.header_len;
596 }
597 #endif
598
599 #ifdef DLT_JUNIPER_MONITOR
600 void
601 juniper_monitor_if_print(netdissect_options *ndo,
602 const struct pcap_pkthdr *h, const u_char *p)
603 {
604 struct juniper_l2info_t l2info;
605 struct juniper_monitor_header {
606 nd_uint8_t pkt_type;
607 nd_byte padding;
608 nd_uint16_t iif;
609 nd_uint32_t service_id;
610 };
611 const struct juniper_monitor_header *mh;
612
613 ndo->ndo_protocol = "juniper_monitor";
614 memset(&l2info, 0, sizeof(l2info));
615 l2info.pictype = DLT_JUNIPER_MONITOR;
616 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
617 ndo->ndo_ll_hdr_len += l2info.header_len;
618 return;
619 }
620
621 p+=l2info.header_len;
622 mh = (const struct juniper_monitor_header *)p;
623
624 ND_TCHECK_SIZE(mh);
625 if (ndo->ndo_eflag)
626 ND_PRINT("service-id %u, iif %u, pkt-type %u: ",
627 GET_BE_U_4(mh->service_id),
628 GET_BE_U_2(mh->iif),
629 GET_U_1(mh->pkt_type));
630
631 /* no proto field - lets guess by first byte of IP header*/
632 ip_heuristic_guess (ndo, p, l2info.length);
633
634 ndo->ndo_ll_hdr_len += l2info.header_len;
635 }
636 #endif
637
638 #ifdef DLT_JUNIPER_SERVICES
639 void
640 juniper_services_if_print(netdissect_options *ndo,
641 const struct pcap_pkthdr *h, const u_char *p)
642 {
643 struct juniper_l2info_t l2info;
644 struct juniper_services_header {
645 nd_uint8_t svc_id;
646 nd_uint8_t flags_len;
647 nd_uint16_t svc_set_id;
648 nd_byte pad;
649 nd_uint24_t dir_iif;
650 };
651 const struct juniper_services_header *sh;
652
653 ndo->ndo_protocol = "juniper_services";
654 memset(&l2info, 0, sizeof(l2info));
655 l2info.pictype = DLT_JUNIPER_SERVICES;
656 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
657 ndo->ndo_ll_hdr_len += l2info.header_len;
658 return;
659 }
660
661 p+=l2info.header_len;
662 sh = (const struct juniper_services_header *)p;
663
664 ND_TCHECK_SIZE(sh);
665 if (ndo->ndo_eflag)
666 ND_PRINT("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
667 GET_U_1(sh->svc_id),
668 GET_U_1(sh->flags_len),
669 GET_BE_U_2(sh->svc_set_id),
670 GET_BE_U_3(sh->dir_iif));
671
672 /* no proto field - lets guess by first byte of IP header*/
673 ip_heuristic_guess (ndo, p, l2info.length);
674
675 ndo->ndo_ll_hdr_len += l2info.header_len;
676 }
677 #endif
678
679 #ifdef DLT_JUNIPER_PPPOE
680 void
681 juniper_pppoe_if_print(netdissect_options *ndo,
682 const struct pcap_pkthdr *h, const u_char *p)
683 {
684 struct juniper_l2info_t l2info;
685
686 ndo->ndo_protocol = "juniper_pppoe";
687 memset(&l2info, 0, sizeof(l2info));
688 l2info.pictype = DLT_JUNIPER_PPPOE;
689 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
690 ndo->ndo_ll_hdr_len += l2info.header_len;
691 return;
692 }
693
694 p+=l2info.header_len;
695 /* this DLT contains nothing but raw ethernet frames */
696 ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
697 ndo->ndo_ll_hdr_len += l2info.header_len;
698 }
699 #endif
700
701 #ifdef DLT_JUNIPER_ETHER
702 void
703 juniper_ether_if_print(netdissect_options *ndo,
704 const struct pcap_pkthdr *h, const u_char *p)
705 {
706 struct juniper_l2info_t l2info;
707
708 ndo->ndo_protocol = "juniper_ether";
709 memset(&l2info, 0, sizeof(l2info));
710 l2info.pictype = DLT_JUNIPER_ETHER;
711 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
712 ndo->ndo_ll_hdr_len += l2info.header_len;
713 return;
714 }
715
716 p+=l2info.header_len;
717 /* this DLT contains nothing but raw Ethernet frames */
718 ndo->ndo_ll_hdr_len +=
719 l2info.header_len +
720 ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
721 }
722 #endif
723
724 #ifdef DLT_JUNIPER_PPP
725 void
726 juniper_ppp_if_print(netdissect_options *ndo,
727 const struct pcap_pkthdr *h, const u_char *p)
728 {
729 struct juniper_l2info_t l2info;
730
731 ndo->ndo_protocol = "juniper_ppp";
732 memset(&l2info, 0, sizeof(l2info));
733 l2info.pictype = DLT_JUNIPER_PPP;
734 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
735 ndo->ndo_ll_hdr_len += l2info.header_len;
736 return;
737 }
738
739 p+=l2info.header_len;
740 /* this DLT contains nothing but raw ppp frames */
741 ppp_print(ndo, p, l2info.length);
742 ndo->ndo_ll_hdr_len += l2info.header_len;
743 }
744 #endif
745
746 #ifdef DLT_JUNIPER_FRELAY
747 void
748 juniper_frelay_if_print(netdissect_options *ndo,
749 const struct pcap_pkthdr *h, const u_char *p)
750 {
751 struct juniper_l2info_t l2info;
752
753 ndo->ndo_protocol = "juniper_frelay";
754 memset(&l2info, 0, sizeof(l2info));
755 l2info.pictype = DLT_JUNIPER_FRELAY;
756 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
757 ndo->ndo_ll_hdr_len += l2info.header_len;
758 return;
759 }
760
761 p+=l2info.header_len;
762 /* this DLT contains nothing but raw frame-relay frames */
763 fr_print(ndo, p, l2info.length);
764 ndo->ndo_ll_hdr_len += l2info.header_len;
765 }
766 #endif
767
768 #ifdef DLT_JUNIPER_CHDLC
769 void
770 juniper_chdlc_if_print(netdissect_options *ndo,
771 const struct pcap_pkthdr *h, const u_char *p)
772 {
773 struct juniper_l2info_t l2info;
774
775 ndo->ndo_protocol = "juniper_chdlc";
776 memset(&l2info, 0, sizeof(l2info));
777 l2info.pictype = DLT_JUNIPER_CHDLC;
778 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
779 ndo->ndo_ll_hdr_len += l2info.header_len;
780 return;
781 }
782
783 p+=l2info.header_len;
784 /* this DLT contains nothing but raw c-hdlc frames */
785 chdlc_print(ndo, p, l2info.length);
786 ndo->ndo_ll_hdr_len += l2info.header_len;
787 }
788 #endif
789
790 #ifdef DLT_JUNIPER_PPPOE_ATM
791 void
792 juniper_pppoe_atm_if_print(netdissect_options *ndo,
793 const struct pcap_pkthdr *h, const u_char *p)
794 {
795 struct juniper_l2info_t l2info;
796 uint16_t extracted_ethertype;
797
798 ndo->ndo_protocol = "juniper_pppoe_atm";
799 memset(&l2info, 0, sizeof(l2info));
800 l2info.pictype = DLT_JUNIPER_PPPOE_ATM;
801 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
802 ndo->ndo_ll_hdr_len += l2info.header_len;
803 return;
804 }
805
806 p+=l2info.header_len;
807
808 extracted_ethertype = GET_BE_U_2(p);
809 /* this DLT contains nothing but raw PPPoE frames,
810 * prepended with a type field*/
811 if (ethertype_print(ndo, extracted_ethertype,
812 p+ETHERTYPE_LEN,
813 l2info.length-ETHERTYPE_LEN,
814 l2info.caplen-ETHERTYPE_LEN,
815 NULL, NULL) == 0)
816 /* ether_type not known, probably it wasn't one */
817 ND_PRINT("unknown ethertype 0x%04x", extracted_ethertype);
818
819 ndo->ndo_ll_hdr_len += l2info.header_len;
820 }
821 #endif
822
823 #ifdef DLT_JUNIPER_MLPPP
824 void
825 juniper_mlppp_if_print(netdissect_options *ndo,
826 const struct pcap_pkthdr *h, const u_char *p)
827 {
828 struct juniper_l2info_t l2info;
829
830 ndo->ndo_protocol = "juniper_mlppp";
831 memset(&l2info, 0, sizeof(l2info));
832 l2info.pictype = DLT_JUNIPER_MLPPP;
833 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
834 ndo->ndo_ll_hdr_len += l2info.header_len;
835 return;
836 }
837
838 /* suppress Bundle-ID if frame was captured on a child-link
839 * best indicator if the cookie looks like a proto */
840 if (ndo->ndo_eflag &&
841 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
842 EXTRACT_BE_U_2(&l2info.cookie) != PPP_OSI &&
843 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
844 EXTRACT_BE_U_2(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL))
845 ND_PRINT("Bundle-ID %u: ", l2info.bundle);
846
847 p+=l2info.header_len;
848
849 /* first try the LSQ protos */
850 switch(l2info.proto) {
851 case JUNIPER_LSQ_L3_PROTO_IPV4:
852 /* IP traffic going to the RE would not have a cookie
853 * -> this must be incoming IS-IS over PPP
854 */
855 if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR))
856 ppp_print(ndo, p, l2info.length);
857 else
858 ip_print(ndo, p, l2info.length);
859 ndo->ndo_ll_hdr_len += l2info.header_len;
860 return;
861 case JUNIPER_LSQ_L3_PROTO_IPV6:
862 ip6_print(ndo, p,l2info.length);
863 ndo->ndo_ll_hdr_len += l2info.header_len;
864 return;
865 case JUNIPER_LSQ_L3_PROTO_MPLS:
866 mpls_print(ndo, p, l2info.length);
867 ndo->ndo_ll_hdr_len += l2info.header_len;
868 return;
869 case JUNIPER_LSQ_L3_PROTO_ISO:
870 isoclns_print(ndo, p, l2info.length);
871 ndo->ndo_ll_hdr_len += l2info.header_len;
872 return;
873 default:
874 break;
875 }
876
877 /* zero length cookie ? */
878 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
879 switch (EXTRACT_BE_U_2(&l2info.cookie)) {
880 case PPP_OSI:
881 ppp_print(ndo, p - 2, l2info.length + 2);
882 break;
883 case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */
884 default:
885 ppp_print(ndo, p, l2info.length);
886 break;
887 }
888
889 ndo->ndo_ll_hdr_len += l2info.header_len;
890 }
891 #endif
892
893 #ifdef DLT_JUNIPER_MFR
894 void
895 juniper_mfr_if_print(netdissect_options *ndo,
896 const struct pcap_pkthdr *h, const u_char *p)
897 {
898 struct juniper_l2info_t l2info;
899
900 ndo->ndo_protocol = "juniper_mfr";
901 memset(&l2info, 0, sizeof(l2info));
902 l2info.pictype = DLT_JUNIPER_MFR;
903 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
904 ndo->ndo_ll_hdr_len += l2info.header_len;
905 return;
906 }
907
908 p+=l2info.header_len;
909
910 /* child-link ? */
911 if (l2info.cookie_len == 0) {
912 mfr_print(ndo, p, l2info.length);
913 ndo->ndo_ll_hdr_len += l2info.header_len;
914 return;
915 }
916
917 /* first try the LSQ protos */
918 if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {
919 switch(l2info.proto) {
920 case JUNIPER_LSQ_L3_PROTO_IPV4:
921 ip_print(ndo, p, l2info.length);
922 ndo->ndo_ll_hdr_len += l2info.header_len;
923 return;
924 case JUNIPER_LSQ_L3_PROTO_IPV6:
925 ip6_print(ndo, p,l2info.length);
926 ndo->ndo_ll_hdr_len += l2info.header_len;
927 return;
928 case JUNIPER_LSQ_L3_PROTO_MPLS:
929 mpls_print(ndo, p, l2info.length);
930 ndo->ndo_ll_hdr_len += l2info.header_len;
931 return;
932 case JUNIPER_LSQ_L3_PROTO_ISO:
933 isoclns_print(ndo, p, l2info.length);
934 ndo->ndo_ll_hdr_len += l2info.header_len;
935 return;
936 default:
937 break;
938 }
939 ndo->ndo_ll_hdr_len += l2info.header_len;
940 return;
941 }
942
943 /* suppress Bundle-ID if frame was captured on a child-link */
944 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
945 if (ndo->ndo_eflag && EXTRACT_BE_U_4(l2info.cookie) != 1)
946 ND_PRINT("Bundle-ID %u, ", l2info.bundle);
947 switch (l2info.proto) {
948 case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):
949 /* At least one byte is required */
950 ND_TCHECK_1(p);
951 isoclns_print(ndo, p + 1, l2info.length - 1);
952 break;
953 case (LLC_UI<<8 | NLPID_Q933):
954 case (LLC_UI<<8 | NLPID_IP):
955 case (LLC_UI<<8 | NLPID_IP6):
956 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
957 isoclns_print(ndo, p - 1, l2info.length + 1);
958 break;
959 default:
960 ND_PRINT("unknown protocol 0x%04x, length %u", l2info.proto, l2info.length);
961 }
962
963 ndo->ndo_ll_hdr_len += l2info.header_len;
964 }
965 #endif
966
967 #ifdef DLT_JUNIPER_MLFR
968 void
969 juniper_mlfr_if_print(netdissect_options *ndo,
970 const struct pcap_pkthdr *h, const u_char *p)
971 {
972 struct juniper_l2info_t l2info;
973
974 ndo->ndo_protocol = "juniper_mlfr";
975 memset(&l2info, 0, sizeof(l2info));
976 l2info.pictype = DLT_JUNIPER_MLFR;
977 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
978 ndo->ndo_ll_hdr_len += l2info.header_len;
979 return;
980 }
981
982 p+=l2info.header_len;
983
984 /* suppress Bundle-ID if frame was captured on a child-link */
985 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
986 if (ndo->ndo_eflag && EXTRACT_BE_U_4(l2info.cookie) != 1)
987 ND_PRINT("Bundle-ID %u, ", l2info.bundle);
988 switch (l2info.proto) {
989 case (LLC_UI):
990 case (LLC_UI<<8):
991 isoclns_print(ndo, p, l2info.length);
992 break;
993 case (LLC_UI<<8 | NLPID_Q933):
994 case (LLC_UI<<8 | NLPID_IP):
995 case (LLC_UI<<8 | NLPID_IP6):
996 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
997 isoclns_print(ndo, p - 1, l2info.length + 1);
998 break;
999 default:
1000 ND_PRINT("unknown protocol 0x%04x, length %u", l2info.proto, l2info.length);
1001 }
1002
1003 ndo->ndo_ll_hdr_len += l2info.header_len;
1004 }
1005 #endif
1006
1007 /*
1008 * ATM1 PIC cookie format
1009 *
1010 * +-----+-------------------------+-------------------------------+
1011 * |fmtid| vc index | channel ID |
1012 * +-----+-------------------------+-------------------------------+
1013 */
1014
1015 #ifdef DLT_JUNIPER_ATM1
1016 void
1017 juniper_atm1_if_print(netdissect_options *ndo,
1018 const struct pcap_pkthdr *h, const u_char *p)
1019 {
1020 int llc_hdrlen;
1021
1022 struct juniper_l2info_t l2info;
1023
1024 ndo->ndo_protocol = "juniper_atm1";
1025 memset(&l2info, 0, sizeof(l2info));
1026 l2info.pictype = DLT_JUNIPER_ATM1;
1027 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
1028 ndo->ndo_ll_hdr_len += l2info.header_len;
1029 return;
1030 }
1031
1032 p+=l2info.header_len;
1033
1034 if (l2info.cookie[0] == 0x80) { /* OAM cell ? */
1035 oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
1036 ndo->ndo_ll_hdr_len += l2info.header_len;
1037 return;
1038 }
1039
1040 if (GET_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */
1041 GET_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */
1042
1043 llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
1044 if (llc_hdrlen > 0) {
1045 ndo->ndo_ll_hdr_len += l2info.header_len;
1046 return;
1047 }
1048 }
1049
1050 if (GET_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */
1051 /* At least one byte is required */
1052 ND_TCHECK_1(p);
1053 isoclns_print(ndo, p + 1, l2info.length - 1);
1054 /* FIXME check if frame was recognized */
1055 ndo->ndo_ll_hdr_len += l2info.header_len;
1056 return;
1057 }
1058
1059 if (ip_heuristic_guess(ndo, p, l2info.length) != 0) { /* last try - vcmux encaps ? */
1060 ndo->ndo_ll_hdr_len += l2info.header_len;
1061 return;
1062 }
1063
1064 ndo->ndo_ll_hdr_len += l2info.header_len;
1065 }
1066 #endif
1067
1068 /*
1069 * ATM2 PIC cookie format
1070 *
1071 * +-------------------------------+---------+---+-----+-----------+
1072 * | channel ID |reserved |AAL| CCRQ| gap count |
1073 * +-------------------------------+---------+---+-----+-----------+
1074 */
1075
1076 #ifdef DLT_JUNIPER_ATM2
1077 void
1078 juniper_atm2_if_print(netdissect_options *ndo,
1079 const struct pcap_pkthdr *h, const u_char *p)
1080 {
1081 int llc_hdrlen;
1082
1083 struct juniper_l2info_t l2info;
1084
1085 ndo->ndo_protocol = "juniper_atm2";
1086 memset(&l2info, 0, sizeof(l2info));
1087 l2info.pictype = DLT_JUNIPER_ATM2;
1088 if (juniper_parse_header(ndo, p, h, &l2info) == 0) {
1089 ndo->ndo_ll_hdr_len += l2info.header_len;
1090 return;
1091 }
1092
1093 p+=l2info.header_len;
1094
1095 if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
1096 oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
1097 ndo->ndo_ll_hdr_len += l2info.header_len;
1098 return;
1099 }
1100
1101 if (GET_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */
1102 GET_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */
1103
1104 llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
1105 if (llc_hdrlen > 0) {
1106 ndo->ndo_ll_hdr_len += l2info.header_len;
1107 return;
1108 }
1109 }
1110
1111 if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
1112 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1113 (EXTRACT_BE_U_4(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
1114 ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
1115 ndo->ndo_ll_hdr_len += l2info.header_len;
1116 return;
1117 }
1118
1119 if (GET_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */
1120 /* At least one byte is required */
1121 ND_TCHECK_1(p);
1122 isoclns_print(ndo, p + 1, l2info.length - 1);
1123 /* FIXME check if frame was recognized */
1124 ndo->ndo_ll_hdr_len += l2info.header_len;
1125 return;
1126 }
1127
1128 if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) { /* PPPoA vcmux encaps ? */
1129 ndo->ndo_ll_hdr_len += l2info.header_len;
1130 return;
1131 }
1132
1133 if (ip_heuristic_guess(ndo, p, l2info.length) != 0) { /* last try - vcmux encaps ? */
1134 ndo->ndo_ll_hdr_len += l2info.header_len;
1135 return;
1136 }
1137
1138 ndo->ndo_ll_hdr_len += l2info.header_len;
1139 }
1140
1141 /* try to guess, based on all PPP protos that are supported in
1142 * a juniper router if the payload data is encapsulated using PPP */
1143 static int
1144 juniper_ppp_heuristic_guess(netdissect_options *ndo,
1145 const u_char *p, u_int length)
1146 {
1147 switch(GET_BE_U_2(p)) {
1148 case PPP_IP :
1149 case PPP_OSI :
1150 case PPP_MPLS_UCAST :
1151 case PPP_MPLS_MCAST :
1152 case PPP_IPCP :
1153 case PPP_OSICP :
1154 case PPP_MPLSCP :
1155 case PPP_LCP :
1156 case PPP_PAP :
1157 case PPP_CHAP :
1158 case PPP_ML :
1159 case PPP_IPV6 :
1160 case PPP_IPV6CP :
1161 ppp_print(ndo, p, length);
1162 break;
1163
1164 default:
1165 return 0; /* did not find a ppp header */
1166 }
1167 return 1; /* we printed a ppp packet */
1168 }
1169 #endif
1170
1171 static int
1172 ip_heuristic_guess(netdissect_options *ndo,
1173 const u_char *p, u_int length)
1174 {
1175 switch(GET_U_1(p)) {
1176 case 0x45:
1177 case 0x46:
1178 case 0x47:
1179 case 0x48:
1180 case 0x49:
1181 case 0x4a:
1182 case 0x4b:
1183 case 0x4c:
1184 case 0x4d:
1185 case 0x4e:
1186 case 0x4f:
1187 ip_print(ndo, p, length);
1188 break;
1189 case 0x60:
1190 case 0x61:
1191 case 0x62:
1192 case 0x63:
1193 case 0x64:
1194 case 0x65:
1195 case 0x66:
1196 case 0x67:
1197 case 0x68:
1198 case 0x69:
1199 case 0x6a:
1200 case 0x6b:
1201 case 0x6c:
1202 case 0x6d:
1203 case 0x6e:
1204 case 0x6f:
1205 ip6_print(ndo, p, length);
1206 break;
1207 default:
1208 return 0; /* did not find a ip header */
1209 }
1210 return 1; /* we printed an v4/v6 packet */
1211 }
1212
1213 static int
1214 juniper_read_tlv_value(netdissect_options *ndo,
1215 const u_char *p, u_int tlv_type, u_int tlv_len)
1216 {
1217 int tlv_value;
1218
1219 /* TLVs < 128 are little endian encoded */
1220 if (tlv_type < 128) {
1221 switch (tlv_len) {
1222 case 1:
1223 tlv_value = GET_U_1(p);
1224 break;
1225 case 2:
1226 tlv_value = GET_LE_U_2(p);
1227 break;
1228 case 3:
1229 tlv_value = GET_LE_U_3(p);
1230 break;
1231 case 4:
1232 tlv_value = GET_LE_U_4(p);
1233 break;
1234 default:
1235 tlv_value = -1;
1236 break;
1237 }
1238 } else {
1239 /* TLVs >= 128 are big endian encoded */
1240 switch (tlv_len) {
1241 case 1:
1242 tlv_value = GET_U_1(p);
1243 break;
1244 case 2:
1245 tlv_value = GET_BE_U_2(p);
1246 break;
1247 case 3:
1248 tlv_value = GET_BE_U_3(p);
1249 break;
1250 case 4:
1251 tlv_value = GET_BE_U_4(p);
1252 break;
1253 default:
1254 tlv_value = -1;
1255 break;
1256 }
1257 }
1258 return tlv_value;
1259 }
1260
1261 static int
1262 juniper_parse_header(netdissect_options *ndo,
1263 const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info)
1264 {
1265 const struct juniper_cookie_table_t *lp;
1266 u_int idx, extension_length, jnx_header_len = 0;
1267 uint8_t tlv_type,tlv_len;
1268 #ifdef DLT_JUNIPER_ATM2
1269 uint32_t control_word;
1270 #endif
1271 int tlv_value;
1272 const u_char *tptr;
1273
1274 l2info->header_len = 0;
1275 l2info->cookie_len = 0;
1276 l2info->proto = 0;
1277
1278 l2info->length = h->len;
1279 l2info->caplen = h->caplen;
1280 l2info->flags = GET_U_1(p + 3);
1281 l2info->direction = GET_U_1(p + 3) & JUNIPER_BPF_PKT_IN;
1282
1283 if (GET_BE_U_3(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
1284 ND_PRINT("no magic-number found!");
1285 return 0;
1286 }
1287
1288 if (ndo->ndo_eflag) /* print direction */
1289 ND_PRINT("%3s ", tok2str(juniper_direction_values, "---", l2info->direction));
1290
1291 /* magic number + flags */
1292 jnx_header_len = 4;
1293
1294 if (ndo->ndo_vflag > 1)
1295 ND_PRINT("\n\tJuniper PCAP Flags [%s]",
1296 bittok2str(jnx_flag_values, "none", l2info->flags));
1297
1298 /* extensions present ? - calculate how much bytes to skip */
1299 if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) {
1300
1301 tptr = p+jnx_header_len;
1302
1303 /* ok to read extension length ? */
1304 extension_length = GET_BE_U_2(tptr);
1305 jnx_header_len += 2;
1306 tptr +=2;
1307
1308 /* nail up the total length -
1309 * just in case something goes wrong
1310 * with TLV parsing */
1311 jnx_header_len += extension_length;
1312
1313 if (ndo->ndo_vflag > 1)
1314 ND_PRINT(", PCAP Extension(s) total length %u", extension_length);
1315
1316 ND_TCHECK_LEN(tptr, extension_length);
1317 while (extension_length > JUNIPER_EXT_TLV_OVERHEAD) {
1318 tlv_type = GET_U_1(tptr);
1319 tptr++;
1320 tlv_len = GET_U_1(tptr);
1321 tptr++;
1322 tlv_value = 0;
1323
1324 /* sanity checks */
1325 if (tlv_type == 0 || tlv_len == 0)
1326 break;
1327 ND_ICHECK_U(extension_length, <,
1328 tlv_len + JUNIPER_EXT_TLV_OVERHEAD);
1329
1330 if (ndo->ndo_vflag > 1)
1331 ND_PRINT("\n\t %s Extension TLV #%u, length %u, value ",
1332 tok2str(jnx_ext_tlv_values,"Unknown",tlv_type),
1333 tlv_type,
1334 tlv_len);
1335
1336 tlv_value = juniper_read_tlv_value(ndo, tptr, tlv_type, tlv_len);
1337 switch (tlv_type) {
1338 case JUNIPER_EXT_TLV_IFD_NAME:
1339 /* FIXME */
1340 break;
1341 case JUNIPER_EXT_TLV_IFD_MEDIATYPE:
1342 case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE:
1343 if (tlv_value != -1) {
1344 if (ndo->ndo_vflag > 1)
1345 ND_PRINT("%s (%u)",
1346 tok2str(juniper_ifmt_values, "Unknown", tlv_value),
1347 tlv_value);
1348 }
1349 break;
1350 case JUNIPER_EXT_TLV_IFL_ENCAPS:
1351 case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS:
1352 if (tlv_value != -1) {
1353 if (ndo->ndo_vflag > 1)
1354 ND_PRINT("%s (%u)",
1355 tok2str(juniper_ifle_values, "Unknown", tlv_value),
1356 tlv_value);
1357 }
1358 break;
1359 case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */
1360 case JUNIPER_EXT_TLV_IFL_UNIT:
1361 case JUNIPER_EXT_TLV_IFD_IDX:
1362 default:
1363 if (tlv_value != -1) {
1364 if (ndo->ndo_vflag > 1)
1365 ND_PRINT("%u", tlv_value);
1366 }
1367 break;
1368 }
1369
1370 tptr+=tlv_len;
1371 extension_length -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD;
1372 }
1373
1374 if (ndo->ndo_vflag > 1)
1375 ND_PRINT("\n\t-----original packet-----\n\t");
1376 }
1377
1378 if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
1379 if (ndo->ndo_eflag)
1380 ND_PRINT("no-L2-hdr, ");
1381
1382 /* there is no link-layer present -
1383 * perform the v4/v6 heuristics
1384 * to figure out what it is
1385 */
1386 ND_TCHECK_1(p + (jnx_header_len + 4));
1387 if (ip_heuristic_guess(ndo, p + jnx_header_len + 4,
1388 l2info->length - (jnx_header_len + 4)) == 0)
1389 ND_PRINT("no IP-hdr found!");
1390
1391 l2info->header_len=jnx_header_len+4;
1392 return 0; /* stop parsing the output further */
1393
1394 }
1395 l2info->header_len = jnx_header_len;
1396 p+=l2info->header_len;
1397 l2info->length -= l2info->header_len;
1398 l2info->caplen -= l2info->header_len;
1399
1400 /* search through the cookie table for one matching our PIC type */
1401 lp = NULL;
1402 for (const struct juniper_cookie_table_t *table_lp = juniper_cookie_table;
1403 table_lp->s != NULL; table_lp++) {
1404 if (table_lp->pictype == l2info->pictype) {
1405 lp = table_lp;
1406 break;
1407 }
1408 }
1409
1410 /* If we found one matching our PIC type, copy its values */
1411 if (lp != NULL) {
1412 l2info->cookie_len += lp->cookie_len;
1413
1414 switch (GET_U_1(p)) {
1415 case LS_COOKIE_ID:
1416 l2info->cookie_type = LS_COOKIE_ID;
1417 l2info->cookie_len += 2;
1418 break;
1419 case AS_COOKIE_ID:
1420 l2info->cookie_type = AS_COOKIE_ID;
1421 l2info->cookie_len = 8;
1422 break;
1423
1424 default:
1425 l2info->bundle = l2info->cookie[0];
1426 break;
1427 }
1428
1429 #ifdef DLT_JUNIPER_MFR
1430 /* MFR child links don't carry cookies */
1431 if (l2info->pictype == DLT_JUNIPER_MFR &&
1432 (GET_U_1(p) & MFR_BE_MASK) == MFR_BE_MASK) {
1433 l2info->cookie_len = 0;
1434 }
1435 #endif
1436
1437 l2info->header_len += l2info->cookie_len;
1438 l2info->length -= l2info->cookie_len;
1439 l2info->caplen -= l2info->cookie_len;
1440
1441 if (ndo->ndo_eflag)
1442 ND_PRINT("%s-PIC, cookie-len %u",
1443 lp->s,
1444 l2info->cookie_len);
1445
1446 ND_ICHECKMSG_U("cookie length", l2info->cookie_len, >, 8);
1447
1448 if (l2info->cookie_len > 0) {
1449 ND_TCHECK_LEN(p, l2info->cookie_len);
1450 if (ndo->ndo_eflag)
1451 ND_PRINT(", cookie 0x");
1452 for (idx = 0; idx < l2info->cookie_len; idx++) {
1453 l2info->cookie[idx] = GET_U_1(p + idx); /* copy cookie data */
1454 if (ndo->ndo_eflag) ND_PRINT("%02x", GET_U_1(p + idx));
1455 }
1456 }
1457
1458 if (ndo->ndo_eflag) ND_PRINT(": "); /* print demarc b/w L2/L3*/
1459
1460 l2info->proto = GET_BE_U_2(p + l2info->cookie_len);
1461 }
1462 p+=l2info->cookie_len;
1463
1464 /* DLT_ specific parsing */
1465 switch(l2info->pictype) {
1466 #ifdef DLT_JUNIPER_MLPPP
1467 case DLT_JUNIPER_MLPPP:
1468 switch (l2info->cookie_type) {
1469 case LS_COOKIE_ID:
1470 l2info->bundle = l2info->cookie[1];
1471 break;
1472 case AS_COOKIE_ID:
1473 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1474 l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff;
1475 l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
1476 break;
1477 default:
1478 l2info->bundle = l2info->cookie[0];
1479 break;
1480 }
1481 break;
1482 #endif
1483 #ifdef DLT_JUNIPER_MLFR
1484 case DLT_JUNIPER_MLFR:
1485 switch (l2info->cookie_type) {
1486 case LS_COOKIE_ID:
1487 l2info->bundle = l2info->cookie[1];
1488 l2info->proto = GET_BE_U_2(p);
1489 l2info->header_len += 2;
1490 l2info->length -= 2;
1491 l2info->caplen -= 2;
1492 break;
1493 case AS_COOKIE_ID:
1494 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1495 l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff;
1496 l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
1497 break;
1498 default:
1499 l2info->bundle = l2info->cookie[0];
1500 l2info->header_len += 2;
1501 l2info->length -= 2;
1502 l2info->caplen -= 2;
1503 break;
1504 }
1505 break;
1506 #endif
1507 #ifdef DLT_JUNIPER_MFR
1508 case DLT_JUNIPER_MFR:
1509 switch (l2info->cookie_type) {
1510 case LS_COOKIE_ID:
1511 l2info->bundle = l2info->cookie[1];
1512 l2info->proto = GET_BE_U_2(p);
1513 l2info->header_len += 2;
1514 l2info->length -= 2;
1515 l2info->caplen -= 2;
1516 break;
1517 case AS_COOKIE_ID:
1518 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
1519 l2info->bundle = (EXTRACT_BE_U_2(&l2info->cookie[6])>>3)&0xfff;
1520 l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
1521 break;
1522 default:
1523 l2info->bundle = l2info->cookie[0];
1524 break;
1525 }
1526 break;
1527 #endif
1528 #ifdef DLT_JUNIPER_ATM2
1529 case DLT_JUNIPER_ATM2:
1530 ND_TCHECK_4(p);
1531 /* ATM cell relay control word present ? */
1532 if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
1533 control_word = GET_BE_U_4(p);
1534 /* some control word heuristics */
1535 switch(control_word) {
1536 case 0: /* zero control word */
1537 case 0x08000000: /* < JUNOS 7.4 control-word */
1538 case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/
1539 l2info->header_len += 4;
1540 break;
1541 default:
1542 break;
1543 }
1544
1545 if (ndo->ndo_eflag)
1546 ND_PRINT("control-word 0x%08x ", control_word);
1547 }
1548 break;
1549 #endif
1550 #ifdef DLT_JUNIPER_ES
1551 case DLT_JUNIPER_ES:
1552 break;
1553 #endif
1554 #ifdef DLT_JUNIPER_GGSN
1555 case DLT_JUNIPER_GGSN:
1556 break;
1557 #endif
1558 #ifdef DLT_JUNIPER_SERVICES
1559 case DLT_JUNIPER_SERVICES:
1560 break;
1561 #endif
1562 #ifdef DLT_JUNIPER_ATM1
1563 case DLT_JUNIPER_ATM1:
1564 break;
1565 #endif
1566 #ifdef DLT_JUNIPER_PPP
1567 case DLT_JUNIPER_PPP:
1568 break;
1569 #endif
1570 #ifdef DLT_JUNIPER_CHDLC
1571 case DLT_JUNIPER_CHDLC:
1572 break;
1573 #endif
1574 #ifdef DLT_JUNIPER_ETHER
1575 case DLT_JUNIPER_ETHER:
1576 break;
1577 #endif
1578 #ifdef DLT_JUNIPER_FRELAY
1579 case DLT_JUNIPER_FRELAY:
1580 break;
1581 #endif
1582 #ifdef DLT_JUNIPER_MONITOR
1583 case DLT_JUNIPER_MONITOR:
1584 break;
1585 #endif
1586 #ifdef DLT_JUNIPER_PPPOE
1587 case DLT_JUNIPER_PPPOE:
1588 break;
1589 #endif
1590 #ifdef DLT_JUNIPER_PPPOE_ATM
1591 case DLT_JUNIPER_PPPOE_ATM:
1592 break;
1593 #endif
1594
1595 default:
1596 ND_PRINT("Unknown Juniper DLT_ type %u: ", l2info->pictype);
1597 break;
1598 }
1599
1600 if (ndo->ndo_eflag)
1601 ND_PRINT("hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto);
1602
1603 return 1; /* everything went ok so far. continue parsing */
1604 invalid:
1605 nd_print_invalid(ndo);
1606 return 0;
1607 }
1608 #endif /* defined(DLT_JUNIPER_GGSN) || defined(DLT_JUNIPER_ES) || \
1609 defined(DLT_JUNIPER_MONITOR) || defined(DLT_JUNIPER_SERVICES) || \
1610 defined(DLT_JUNIPER_PPPOE) || defined(DLT_JUNIPER_ETHER) || \
1611 defined(DLT_JUNIPER_PPP) || defined(DLT_JUNIPER_FRELAY) || \
1612 defined(DLT_JUNIPER_CHDLC) || defined(DLT_JUNIPER_PPPOE_ATM) || \
1613 defined(DLT_JUNIPER_MLPPP) || defined(DLT_JUNIPER_MFR) || \
1614 defined(DLT_JUNIPER_MLFR) || defined(DLT_JUNIPER_ATM1) || \
1615 defined(DLT_JUNIPER_ATM2) */