1 /* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */
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.
15 * Original code by Hannes Gredler (hannes@gredler.at)
18 /* \summary: DLT_JUNIPER_* printers */
22 __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
27 #include "netdissect-stdinc.h"
31 #define ND_LONGJMP_FROM_TCHECK
32 #include "netdissect.h"
33 #include "addrtoname.h"
38 #include "ethertype.h"
42 * If none of the Juniper DLT_s are defined, there's nothing to do.
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" */
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
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
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" },
88 static const struct tok juniper_direction_values
[] = {
89 { JUNIPER_BPF_IN
, "In"},
90 { JUNIPER_BPF_OUT
, "Out"},
94 /* codepoints for encoding extensions to a .pcap file */
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
106 /* 1 byte type and 1-byte length */
107 #define JUNIPER_EXT_TLV_OVERHEAD 2U
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" },
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" },
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
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" },
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
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" },
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 */
385 static const struct juniper_cookie_table_t juniper_cookie_table
[] = {
386 #ifdef DLT_JUNIPER_ATM1
387 { DLT_JUNIPER_ATM1
, 4, "ATM1"},
389 #ifdef DLT_JUNIPER_ATM2
390 { DLT_JUNIPER_ATM2
, 8, "ATM2"},
392 #ifdef DLT_JUNIPER_MLPPP
393 { DLT_JUNIPER_MLPPP
, 2, "MLPPP"},
395 #ifdef DLT_JUNIPER_MLFR
396 { DLT_JUNIPER_MLFR
, 2, "MLFR"},
398 #ifdef DLT_JUNIPER_MFR
399 { DLT_JUNIPER_MFR
, 4, "MFR"},
401 #ifdef DLT_JUNIPER_PPPOE
402 { DLT_JUNIPER_PPPOE
, 0, "PPPoE"},
404 #ifdef DLT_JUNIPER_PPPOE_ATM
405 { DLT_JUNIPER_PPPOE_ATM
, 0, "PPPoE ATM"},
407 #ifdef DLT_JUNIPER_GGSN
408 { DLT_JUNIPER_GGSN
, 8, "GGSN"},
410 #ifdef DLT_JUNIPER_MONITOR
411 { DLT_JUNIPER_MONITOR
, 8, "MONITOR"},
413 #ifdef DLT_JUNIPER_SERVICES
414 { DLT_JUNIPER_SERVICES
, 8, "AS"},
416 #ifdef DLT_JUNIPER_ES
417 { DLT_JUNIPER_ES
, 0, "ES"},
422 struct juniper_l2info_t
{
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
444 #define ATM2_PKT_TYPE_MASK 0x70
445 #define ATM2_GAP_COUNT_MASK 0x3F
447 #define JUNIPER_PROTO_NULL 1
448 #define JUNIPER_PROTO_IPV4 2
449 #define JUNIPER_PROTO_IPV6 6
451 #define MFR_BE_MASK 0xc0
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" },
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
);
466 static int juniper_parse_header(netdissect_options
*, const u_char
*, const struct pcap_pkthdr
*, struct juniper_l2info_t
*);
468 #ifdef DLT_JUNIPER_GGSN
470 juniper_ggsn_if_print(netdissect_options
*ndo
,
471 const struct pcap_pkthdr
*h
, const u_char
*p
)
473 struct juniper_l2info_t l2info
;
474 struct juniper_ggsn_header
{
476 nd_uint8_t flags_len
;
482 const struct juniper_ggsn_header
*gh
;
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
;
493 p
+=l2info
.header_len
;
494 gh
= (struct juniper_ggsn_header
*)&l2info
.cookie
;
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
),
502 EXTRACT_BE_U_2(gh
->vlan_id
));
506 case JUNIPER_PROTO_IPV4
:
507 ip_print(ndo
, p
, l2info
.length
);
509 case JUNIPER_PROTO_IPV6
:
510 ip6_print(ndo
, p
, l2info
.length
);
514 ND_PRINT("unknown GGSN proto (%u)", proto
);
517 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
521 #ifdef DLT_JUNIPER_ES
523 juniper_es_if_print(netdissect_options
*ndo
,
524 const struct pcap_pkthdr
*h
, const u_char
*p
)
526 struct juniper_l2info_t l2info
;
527 struct juniper_ipsec_header
{
528 nd_uint16_t sa_index
;
535 u_int rewrite_len
,es_type_bundle
;
536 const struct juniper_ipsec_header
*ih
;
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
;
546 p
+=l2info
.header_len
;
547 ih
= (const struct juniper_ipsec_header
*)p
;
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
:
556 case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
:
557 case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
:
558 case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
:
563 ND_PRINT("ES Invalid type %u, length %u",
566 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
570 l2info
.length
-=rewrite_len
;
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
),
578 tok2str(juniper_ipsec_type_values
,"Unknown",GET_U_1(ih
->type
)),
581 GET_IPADDR_STRING(ih
->src_ip
),
582 GET_IPADDR_STRING(ih
->dst_ip
),
585 ND_PRINT("ES SA, index %u, ttl %u type %s (%u), length %u\n",
586 GET_BE_U_2(ih
->sa_index
),
588 tok2str(juniper_ipsec_type_values
,"Unknown",GET_U_1(ih
->type
)),
594 ip_print(ndo
, p
, l2info
.length
);
595 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
599 #ifdef DLT_JUNIPER_MONITOR
601 juniper_monitor_if_print(netdissect_options
*ndo
,
602 const struct pcap_pkthdr
*h
, const u_char
*p
)
604 struct juniper_l2info_t l2info
;
605 struct juniper_monitor_header
{
609 nd_uint32_t service_id
;
611 const struct juniper_monitor_header
*mh
;
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
;
621 p
+=l2info
.header_len
;
622 mh
= (const struct juniper_monitor_header
*)p
;
626 ND_PRINT("service-id %u, iif %u, pkt-type %u: ",
627 GET_BE_U_4(mh
->service_id
),
629 GET_U_1(mh
->pkt_type
));
631 /* no proto field - lets guess by first byte of IP header*/
632 ip_heuristic_guess (ndo
, p
, l2info
.length
);
634 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
638 #ifdef DLT_JUNIPER_SERVICES
640 juniper_services_if_print(netdissect_options
*ndo
,
641 const struct pcap_pkthdr
*h
, const u_char
*p
)
643 struct juniper_l2info_t l2info
;
644 struct juniper_services_header
{
646 nd_uint8_t flags_len
;
647 nd_uint16_t svc_set_id
;
651 const struct juniper_services_header
*sh
;
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
;
661 p
+=l2info
.header_len
;
662 sh
= (const struct juniper_services_header
*)p
;
666 ND_PRINT("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
668 GET_U_1(sh
->flags_len
),
669 GET_BE_U_2(sh
->svc_set_id
),
670 GET_BE_U_3(sh
->dir_iif
));
672 /* no proto field - lets guess by first byte of IP header*/
673 ip_heuristic_guess (ndo
, p
, l2info
.length
);
675 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
679 #ifdef DLT_JUNIPER_PPPOE
681 juniper_pppoe_if_print(netdissect_options
*ndo
,
682 const struct pcap_pkthdr
*h
, const u_char
*p
)
684 struct juniper_l2info_t l2info
;
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
;
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
;
701 #ifdef DLT_JUNIPER_ETHER
703 juniper_ether_if_print(netdissect_options
*ndo
,
704 const struct pcap_pkthdr
*h
, const u_char
*p
)
706 struct juniper_l2info_t l2info
;
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
;
716 p
+=l2info
.header_len
;
717 /* this DLT contains nothing but raw Ethernet frames */
718 ndo
->ndo_ll_hdr_len
+=
720 ether_print(ndo
, p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
);
724 #ifdef DLT_JUNIPER_PPP
726 juniper_ppp_if_print(netdissect_options
*ndo
,
727 const struct pcap_pkthdr
*h
, const u_char
*p
)
729 struct juniper_l2info_t l2info
;
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
;
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
;
746 #ifdef DLT_JUNIPER_FRELAY
748 juniper_frelay_if_print(netdissect_options
*ndo
,
749 const struct pcap_pkthdr
*h
, const u_char
*p
)
751 struct juniper_l2info_t l2info
;
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
;
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
;
768 #ifdef DLT_JUNIPER_CHDLC
770 juniper_chdlc_if_print(netdissect_options
*ndo
,
771 const struct pcap_pkthdr
*h
, const u_char
*p
)
773 struct juniper_l2info_t l2info
;
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
;
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
;
790 #ifdef DLT_JUNIPER_PPPOE_ATM
792 juniper_pppoe_atm_if_print(netdissect_options
*ndo
,
793 const struct pcap_pkthdr
*h
, const u_char
*p
)
795 struct juniper_l2info_t l2info
;
796 uint16_t extracted_ethertype
;
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
;
806 p
+=l2info
.header_len
;
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
,
813 l2info
.length
-ETHERTYPE_LEN
,
814 l2info
.caplen
-ETHERTYPE_LEN
,
816 /* ether_type not known, probably it wasn't one */
817 ND_PRINT("unknown ethertype 0x%04x", extracted_ethertype
);
819 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
823 #ifdef DLT_JUNIPER_MLPPP
825 juniper_mlppp_if_print(netdissect_options
*ndo
,
826 const struct pcap_pkthdr
*h
, const u_char
*p
)
828 struct juniper_l2info_t l2info
;
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
;
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
);
847 p
+=l2info
.header_len
;
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
855 if (l2info
.cookie
[4] == (JUNIPER_LSQ_COOKIE_RE
|JUNIPER_LSQ_COOKIE_DIR
))
856 ppp_print(ndo
, p
, l2info
.length
);
858 ip_print(ndo
, p
, l2info
.length
);
859 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
861 case JUNIPER_LSQ_L3_PROTO_IPV6
:
862 ip6_print(ndo
, p
,l2info
.length
);
863 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
865 case JUNIPER_LSQ_L3_PROTO_MPLS
:
866 mpls_print(ndo
, p
, l2info
.length
);
867 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
869 case JUNIPER_LSQ_L3_PROTO_ISO
:
870 isoclns_print(ndo
, p
, l2info
.length
);
871 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
877 /* zero length cookie ? */
878 /* use EXTRACT_, not GET_ (not packet buffer pointer) */
879 switch (EXTRACT_BE_U_2(&l2info
.cookie
)) {
881 ppp_print(ndo
, p
- 2, l2info
.length
+ 2);
883 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* fall through */
885 ppp_print(ndo
, p
, l2info
.length
);
889 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
893 #ifdef DLT_JUNIPER_MFR
895 juniper_mfr_if_print(netdissect_options
*ndo
,
896 const struct pcap_pkthdr
*h
, const u_char
*p
)
898 struct juniper_l2info_t l2info
;
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
;
908 p
+=l2info
.header_len
;
911 if (l2info
.cookie_len
== 0) {
912 mfr_print(ndo
, p
, l2info
.length
);
913 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
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
;
924 case JUNIPER_LSQ_L3_PROTO_IPV6
:
925 ip6_print(ndo
, p
,l2info
.length
);
926 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
928 case JUNIPER_LSQ_L3_PROTO_MPLS
:
929 mpls_print(ndo
, p
, l2info
.length
);
930 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
932 case JUNIPER_LSQ_L3_PROTO_ISO
:
933 isoclns_print(ndo
, p
, l2info
.length
);
934 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
939 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
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 */
951 isoclns_print(ndo
, p
+ 1, l2info
.length
- 1);
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);
960 ND_PRINT("unknown protocol 0x%04x, length %u", l2info
.proto
, l2info
.length
);
963 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
967 #ifdef DLT_JUNIPER_MLFR
969 juniper_mlfr_if_print(netdissect_options
*ndo
,
970 const struct pcap_pkthdr
*h
, const u_char
*p
)
972 struct juniper_l2info_t l2info
;
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
;
982 p
+=l2info
.header_len
;
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
) {
991 isoclns_print(ndo
, p
, l2info
.length
);
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);
1000 ND_PRINT("unknown protocol 0x%04x, length %u", l2info
.proto
, l2info
.length
);
1003 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1008 * ATM1 PIC cookie format
1010 * +-----+-------------------------+-------------------------------+
1011 * |fmtid| vc index | channel ID |
1012 * +-----+-------------------------+-------------------------------+
1015 #ifdef DLT_JUNIPER_ATM1
1017 juniper_atm1_if_print(netdissect_options
*ndo
,
1018 const struct pcap_pkthdr
*h
, const u_char
*p
)
1022 struct juniper_l2info_t l2info
;
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
;
1032 p
+=l2info
.header_len
;
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
;
1040 if (GET_BE_U_3(p
) == 0xfefe03 || /* NLPID encaps ? */
1041 GET_BE_U_3(p
) == 0xaaaa03) { /* SNAP encaps ? */
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
;
1050 if (GET_U_1(p
) == 0x03) { /* Cisco style NLPID encaps ? */
1051 /* At least one byte is required */
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
;
1059 if (ip_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* last try - vcmux encaps ? */
1060 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1064 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1069 * ATM2 PIC cookie format
1071 * +-------------------------------+---------+---+-----+-----------+
1072 * | channel ID |reserved |AAL| CCRQ| gap count |
1073 * +-------------------------------+---------+---+-----+-----------+
1076 #ifdef DLT_JUNIPER_ATM2
1078 juniper_atm2_if_print(netdissect_options
*ndo
,
1079 const struct pcap_pkthdr
*h
, const u_char
*p
)
1083 struct juniper_l2info_t l2info
;
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
;
1093 p
+=l2info
.header_len
;
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
;
1101 if (GET_BE_U_3(p
) == 0xfefe03 || /* NLPID encaps ? */
1102 GET_BE_U_3(p
) == 0xaaaa03) { /* SNAP encaps ? */
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
;
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
;
1119 if (GET_U_1(p
) == 0x03) { /* Cisco style NLPID encaps ? */
1120 /* At least one byte is required */
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
;
1128 if(juniper_ppp_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* PPPoA vcmux encaps ? */
1129 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1133 if (ip_heuristic_guess(ndo
, p
, l2info
.length
) != 0) { /* last try - vcmux encaps ? */
1134 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
1138 ndo
->ndo_ll_hdr_len
+= l2info
.header_len
;
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 */
1144 juniper_ppp_heuristic_guess(netdissect_options
*ndo
,
1145 const u_char
*p
, u_int length
)
1147 switch(GET_BE_U_2(p
)) {
1150 case PPP_MPLS_UCAST
:
1151 case PPP_MPLS_MCAST
:
1161 ppp_print(ndo
, p
, length
);
1165 return 0; /* did not find a ppp header */
1167 return 1; /* we printed a ppp packet */
1172 ip_heuristic_guess(netdissect_options
*ndo
,
1173 const u_char
*p
, u_int length
)
1175 switch(GET_U_1(p
)) {
1187 ip_print(ndo
, p
, length
);
1205 ip6_print(ndo
, p
, length
);
1208 return 0; /* did not find a ip header */
1210 return 1; /* we printed an v4/v6 packet */
1214 juniper_read_tlv_value(netdissect_options
*ndo
,
1215 const u_char
*p
, u_int tlv_type
, u_int tlv_len
)
1219 /* TLVs < 128 are little endian encoded */
1220 if (tlv_type
< 128) {
1223 tlv_value
= GET_U_1(p
);
1226 tlv_value
= GET_LE_U_2(p
);
1229 tlv_value
= GET_LE_U_3(p
);
1232 tlv_value
= GET_LE_U_4(p
);
1239 /* TLVs >= 128 are big endian encoded */
1242 tlv_value
= GET_U_1(p
);
1245 tlv_value
= GET_BE_U_2(p
);
1248 tlv_value
= GET_BE_U_3(p
);
1251 tlv_value
= GET_BE_U_4(p
);
1262 juniper_parse_header(netdissect_options
*ndo
,
1263 const u_char
*p
, const struct pcap_pkthdr
*h
, struct juniper_l2info_t
*l2info
)
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
;
1274 l2info
->header_len
= 0;
1275 l2info
->cookie_len
= 0;
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
;
1283 if (GET_BE_U_3(p
) != JUNIPER_MGC_NUMBER
) { /* magic number found ? */
1284 ND_PRINT("no magic-number found!");
1288 if (ndo
->ndo_eflag
) /* print direction */
1289 ND_PRINT("%3s ", tok2str(juniper_direction_values
, "---", l2info
->direction
));
1291 /* magic number + flags */
1294 if (ndo
->ndo_vflag
> 1)
1295 ND_PRINT("\n\tJuniper PCAP Flags [%s]",
1296 bittok2str(jnx_flag_values
, "none", l2info
->flags
));
1298 /* extensions present ? - calculate how much bytes to skip */
1299 if ((l2info
->flags
& JUNIPER_BPF_EXT
) == JUNIPER_BPF_EXT
) {
1301 tptr
= p
+jnx_header_len
;
1303 /* ok to read extension length ? */
1304 extension_length
= GET_BE_U_2(tptr
);
1305 jnx_header_len
+= 2;
1308 /* nail up the total length -
1309 * just in case something goes wrong
1310 * with TLV parsing */
1311 jnx_header_len
+= extension_length
;
1313 if (ndo
->ndo_vflag
> 1)
1314 ND_PRINT(", PCAP Extension(s) total length %u", extension_length
);
1316 ND_TCHECK_LEN(tptr
, extension_length
);
1317 while (extension_length
> JUNIPER_EXT_TLV_OVERHEAD
) {
1318 tlv_type
= GET_U_1(tptr
);
1320 tlv_len
= GET_U_1(tptr
);
1325 if (tlv_type
== 0 || tlv_len
== 0)
1327 ND_ICHECK_U(extension_length
, <,
1328 tlv_len
+ JUNIPER_EXT_TLV_OVERHEAD
);
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
),
1336 tlv_value
= juniper_read_tlv_value(ndo
, tptr
, tlv_type
, tlv_len
);
1338 case JUNIPER_EXT_TLV_IFD_NAME
:
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)
1346 tok2str(juniper_ifmt_values
, "Unknown", tlv_value
),
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)
1355 tok2str(juniper_ifle_values
, "Unknown", tlv_value
),
1359 case JUNIPER_EXT_TLV_IFL_IDX
: /* fall through */
1360 case JUNIPER_EXT_TLV_IFL_UNIT
:
1361 case JUNIPER_EXT_TLV_IFD_IDX
:
1363 if (tlv_value
!= -1) {
1364 if (ndo
->ndo_vflag
> 1)
1365 ND_PRINT("%u", tlv_value
);
1371 extension_length
-= tlv_len
+JUNIPER_EXT_TLV_OVERHEAD
;
1374 if (ndo
->ndo_vflag
> 1)
1375 ND_PRINT("\n\t-----original packet-----\n\t");
1378 if ((l2info
->flags
& JUNIPER_BPF_NO_L2
) == JUNIPER_BPF_NO_L2
) {
1380 ND_PRINT("no-L2-hdr, ");
1382 /* there is no link-layer present -
1383 * perform the v4/v6 heuristics
1384 * to figure out what it is
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!");
1391 l2info
->header_len
=jnx_header_len
+4;
1392 return 0; /* stop parsing the output further */
1395 l2info
->header_len
= jnx_header_len
;
1396 p
+=l2info
->header_len
;
1397 l2info
->length
-= l2info
->header_len
;
1398 l2info
->caplen
-= l2info
->header_len
;
1400 /* search through the cookie table for one matching our PIC type */
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
) {
1410 /* If we found one matching our PIC type, copy its values */
1412 l2info
->cookie_len
+= lp
->cookie_len
;
1414 switch (GET_U_1(p
)) {
1416 l2info
->cookie_type
= LS_COOKIE_ID
;
1417 l2info
->cookie_len
+= 2;
1420 l2info
->cookie_type
= AS_COOKIE_ID
;
1421 l2info
->cookie_len
= 8;
1425 l2info
->bundle
= l2info
->cookie
[0];
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;
1437 l2info
->header_len
+= l2info
->cookie_len
;
1438 l2info
->length
-= l2info
->cookie_len
;
1439 l2info
->caplen
-= l2info
->cookie_len
;
1442 ND_PRINT("%s-PIC, cookie-len %u",
1444 l2info
->cookie_len
);
1446 ND_ICHECKMSG_U("cookie length", l2info
->cookie_len
, >, 8);
1448 if (l2info
->cookie_len
> 0) {
1449 ND_TCHECK_LEN(p
, l2info
->cookie_len
);
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
));
1458 if (ndo
->ndo_eflag
) ND_PRINT(": "); /* print demarc b/w L2/L3*/
1460 l2info
->proto
= GET_BE_U_2(p
+ l2info
->cookie_len
);
1462 p
+=l2info
->cookie_len
;
1464 /* DLT_ specific parsing */
1465 switch(l2info
->pictype
) {
1466 #ifdef DLT_JUNIPER_MLPPP
1467 case DLT_JUNIPER_MLPPP
:
1468 switch (l2info
->cookie_type
) {
1470 l2info
->bundle
= l2info
->cookie
[1];
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
;
1478 l2info
->bundle
= l2info
->cookie
[0];
1483 #ifdef DLT_JUNIPER_MLFR
1484 case DLT_JUNIPER_MLFR
:
1485 switch (l2info
->cookie_type
) {
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;
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
;
1499 l2info
->bundle
= l2info
->cookie
[0];
1500 l2info
->header_len
+= 2;
1501 l2info
->length
-= 2;
1502 l2info
->caplen
-= 2;
1507 #ifdef DLT_JUNIPER_MFR
1508 case DLT_JUNIPER_MFR
:
1509 switch (l2info
->cookie_type
) {
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;
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
;
1523 l2info
->bundle
= l2info
->cookie
[0];
1528 #ifdef DLT_JUNIPER_ATM2
1529 case DLT_JUNIPER_ATM2
:
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;
1546 ND_PRINT("control-word 0x%08x ", control_word
);
1550 #ifdef DLT_JUNIPER_ES
1551 case DLT_JUNIPER_ES
:
1554 #ifdef DLT_JUNIPER_GGSN
1555 case DLT_JUNIPER_GGSN
:
1558 #ifdef DLT_JUNIPER_SERVICES
1559 case DLT_JUNIPER_SERVICES
:
1562 #ifdef DLT_JUNIPER_ATM1
1563 case DLT_JUNIPER_ATM1
:
1566 #ifdef DLT_JUNIPER_PPP
1567 case DLT_JUNIPER_PPP
:
1570 #ifdef DLT_JUNIPER_CHDLC
1571 case DLT_JUNIPER_CHDLC
:
1574 #ifdef DLT_JUNIPER_ETHER
1575 case DLT_JUNIPER_ETHER
:
1578 #ifdef DLT_JUNIPER_FRELAY
1579 case DLT_JUNIPER_FRELAY
:
1582 #ifdef DLT_JUNIPER_MONITOR
1583 case DLT_JUNIPER_MONITOR
:
1586 #ifdef DLT_JUNIPER_PPPOE
1587 case DLT_JUNIPER_PPPOE
:
1590 #ifdef DLT_JUNIPER_PPPOE_ATM
1591 case DLT_JUNIPER_PPPOE_ATM
:
1596 ND_PRINT("Unknown Juniper DLT_ type %u: ", l2info
->pictype
);
1601 ND_PRINT("hlen %u, proto 0x%04x, ", l2info
->header_len
, l2info
->proto
);
1603 return 1; /* everything went ok so far. continue parsing */
1605 nd_print_invalid(ndo
);
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) */