/src/wireshark/epan/dissectors/packet-juniper.c
Line | Count | Source |
1 | | /* packet-juniper.c |
2 | | * Routines for Juniper Networks, Inc. packet disassembly |
3 | | * Copyright 2005 Hannes Gredler <hannes@juniper.net> |
4 | | * |
5 | | * Wireshark - Network traffic analyzer |
6 | | * By Gerald Combs <gerald@wireshark.org> |
7 | | * Copyright 1998 Gerald Combs |
8 | | * |
9 | | * SPDX-License-Identifier: GPL-2.0-or-later |
10 | | */ |
11 | | |
12 | | #include "config.h" |
13 | | |
14 | | #include <epan/packet.h> |
15 | | #include <epan/expert.h> |
16 | | #include <epan/addr_resolv.h> |
17 | | #include <epan/etypes.h> |
18 | | #include <epan/tfs.h> |
19 | | #include <epan/iana-info.h> |
20 | | #include <wsutil/array.h> |
21 | | #include "packet-juniper.h" |
22 | | #include "packet-osi.h" |
23 | | #include "packet-ppp.h" |
24 | | |
25 | | |
26 | | void proto_register_juniper(void); |
27 | | void proto_reg_handoff_juniper(void); |
28 | | |
29 | | #define JUNIPER_FLAG_PKT_OUT 0x00 /* Outgoing packet */ |
30 | 0 | #define JUNIPER_FLAG_PKT_IN 0x01 /* Incoming packet */ |
31 | 2 | #define JUNIPER_FLAG_NO_L2 0x02 /* L2 header stripped */ |
32 | 0 | #define JUNIPER_FLAG_EXT 0x80 /* extensions present */ |
33 | 0 | #define EXT_TLV_HEADER_SIZE 2 |
34 | | #define JUNIPER_ATM2_PKT_TYPE_MASK 0x70 |
35 | 0 | #define JUNIPER_ATM2_GAP_COUNT_MASK 0x3F |
36 | 2 | #define JUNIPER_PCAP_MAGIC 0x4d4743 |
37 | | |
38 | 1 | #define JUNIPER_PIC_ATM1 1 |
39 | 2 | #define JUNIPER_PIC_ATM2 2 |
40 | 0 | #define JUNIPER_PIC_MLPPP 3 |
41 | 0 | #define JUNIPER_PIC_MLFR 4 |
42 | | |
43 | 0 | #define JUNIPER_HDR_SNAP 0xaaaa03 |
44 | 0 | #define JUNIPER_HDR_NLPID 0xfefe03 |
45 | 0 | #define JUNIPER_HDR_LLC_UI 0x03 |
46 | 0 | #define JUNIPER_HDR_PPP 0xff03 |
47 | | |
48 | 0 | #define ML_PIC_COOKIE_LEN 2 |
49 | 0 | #define LS_PIC_COOKIE_LEN 4 |
50 | 0 | #define AS_PIC_COOKIE_LEN 8 |
51 | | |
52 | 0 | #define GSP_SVC_REQ_APOLLO 0x40 |
53 | 0 | #define GSP_SVC_REQ_LSQ 0x47 |
54 | | |
55 | 0 | #define LSQ_COOKIE_RE 0x2 |
56 | 0 | #define LSQ_COOKIE_DIR 0x1 |
57 | 0 | #define LSQ_L3_PROTO_SHIFT 4 |
58 | 0 | #define LSQ_L3_PROTO_MASK 0xf0 |
59 | 0 | #define LSQ_L3_PROTO_IPV4 (0 << LSQ_L3_PROTO_SHIFT) |
60 | 0 | #define LSQ_L3_PROTO_IPV6 (1 << LSQ_L3_PROTO_SHIFT) |
61 | 0 | #define LSQ_L3_PROTO_MPLS (2 << LSQ_L3_PROTO_SHIFT) |
62 | 0 | #define LSQ_L3_PROTO_ISO (3 << LSQ_L3_PROTO_SHIFT) |
63 | | |
64 | 0 | #define EXT_TLV_IFD_IDX 1 |
65 | 0 | #define EXT_TLV_IFD_NAME 2 |
66 | 0 | #define EXT_TLV_IFD_MEDIATYPE 3 |
67 | 0 | #define EXT_TLV_IFL_IDX 4 |
68 | 0 | #define EXT_TLV_IFL_UNIT 5 |
69 | 0 | #define EXT_TLV_IFL_ENCAPS 6 |
70 | 0 | #define EXT_TLV_TTP_IFD_MEDIATYPE 7 |
71 | 0 | #define EXT_TLV_TTP_IFL_ENCAPS 8 |
72 | | |
73 | | /* VN related defines */ |
74 | 0 | #define VN_TLV_HDR_SIZE 2 |
75 | 14 | #define VN_FLAG_ALERT 0x00000002 |
76 | 14 | #define VN_FLAG_DROP 0x00000004 |
77 | 14 | #define VN_FLAG_DENY 0x00000008 |
78 | 14 | #define VN_FLAG_LOG 0x00000010 |
79 | 14 | #define VN_FLAG_PASS 0x00000020 |
80 | 14 | #define VN_FLAG_REJECT 0x00000040 |
81 | 14 | #define VN_FLAG_MIRROR 0x00000080 |
82 | 14 | #define VN_FLAG_DIRECTION 0x40000000 |
83 | 14 | #define VN_FLAG_MASK 0xFFFFFFFF |
84 | | enum { |
85 | | VN_TLV_HOST_IP = 1, |
86 | | VN_TLV_FLAGS = 2, |
87 | | VN_TLV_SRC_VN = 3, |
88 | | VN_TLV_DST_VN = 4, |
89 | | VN_TLV_LAST = 255 |
90 | | }; |
91 | | |
92 | | static const value_string ext_tlv_vals[] = { |
93 | | { EXT_TLV_IFD_IDX, "Device Interface Index" }, |
94 | | { EXT_TLV_IFD_NAME, "Device Interface Name" }, |
95 | | { EXT_TLV_IFD_MEDIATYPE, "Device Media Type" }, |
96 | | { EXT_TLV_IFL_IDX, "Logical Interface Index" }, |
97 | | { EXT_TLV_IFL_UNIT, "Logical Unit Number" }, |
98 | | { EXT_TLV_IFL_ENCAPS, "Logical Interface Encapsulation" }, |
99 | | { EXT_TLV_TTP_IFD_MEDIATYPE, "TTP derived Device Media Type" }, |
100 | | { EXT_TLV_TTP_IFL_ENCAPS, "TTP derived Logical Interface Encapsulation" }, |
101 | | { 0, NULL } |
102 | | }; |
103 | | |
104 | | static const value_string juniper_direction_vals[] = { |
105 | | {JUNIPER_FLAG_PKT_OUT, "Out"}, |
106 | | {JUNIPER_FLAG_PKT_IN, "In"}, |
107 | | {0, NULL} |
108 | | }; |
109 | | |
110 | | static const value_string juniper_l2hdr_presence_vals[] = { |
111 | | { 0, "Present"}, |
112 | | { 2, "none"}, |
113 | | {0, NULL} |
114 | | }; |
115 | | |
116 | | #define JUNIPER_IFML_ETHER 1 |
117 | | #define JUNIPER_IFML_FDDI 2 |
118 | | #define JUNIPER_IFML_TOKENRING 3 |
119 | | #define JUNIPER_IFML_PPP 4 |
120 | | #define JUNIPER_IFML_FRAMERELAY 5 |
121 | | #define JUNIPER_IFML_CISCOHDLC 6 |
122 | | #define JUNIPER_IFML_SMDSDXI 7 |
123 | | #define JUNIPER_IFML_ATMPVC 8 |
124 | | #define JUNIPER_IFML_PPP_CCC 9 |
125 | | #define JUNIPER_IFML_FRAMERELAY_CCC 10 |
126 | | #define JUNIPER_IFML_IPIP 11 |
127 | | #define JUNIPER_IFML_GRE 12 |
128 | | #define JUNIPER_IFML_PIM 13 |
129 | | #define JUNIPER_IFML_PIMD 14 |
130 | | #define JUNIPER_IFML_CISCOHDLC_CCC 15 |
131 | | #define JUNIPER_IFML_VLAN_CCC 16 |
132 | | #define JUNIPER_IFML_MLPPP 17 |
133 | | #define JUNIPER_IFML_MLFR 18 |
134 | | #define JUNIPER_IFML_ML 19 |
135 | | #define JUNIPER_IFML_LSI 20 |
136 | | #define JUNIPER_IFML_DFE 21 |
137 | | #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22 |
138 | | #define JUNIPER_IFML_CRYPTO 23 |
139 | | #define JUNIPER_IFML_GGSN 24 |
140 | | #define JUNIPER_IFML_LSI_PPP 25 |
141 | | #define JUNIPER_IFML_LSI_CISCOHDLC 26 |
142 | | #define JUNIPER_IFML_PPP_TCC 27 |
143 | | #define JUNIPER_IFML_FRAMERELAY_TCC 28 |
144 | | #define JUNIPER_IFML_CISCOHDLC_TCC 29 |
145 | | #define JUNIPER_IFML_ETHERNET_CCC 30 |
146 | | #define JUNIPER_IFML_VT 31 |
147 | | #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32 |
148 | | #define JUNIPER_IFML_ETHER_OVER_ATM 33 |
149 | | #define JUNIPER_IFML_MONITOR 34 |
150 | | #define JUNIPER_IFML_ETHERNET_TCC 35 |
151 | | #define JUNIPER_IFML_VLAN_TCC 36 |
152 | | #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37 |
153 | | #define JUNIPER_IFML_CONTROLLER 38 |
154 | | #define JUNIPER_IFML_MFR 39 |
155 | | #define JUNIPER_IFML_LS 40 |
156 | | #define JUNIPER_IFML_ETHERNET_VPLS 41 |
157 | | #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42 |
158 | | #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43 |
159 | | #define JUNIPER_IFML_LT 44 |
160 | | #define JUNIPER_IFML_SERVICES 45 |
161 | | #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46 |
162 | | #define JUNIPER_IFML_FR_PORT_CCC 47 |
163 | | #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48 |
164 | | #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49 |
165 | | #define JUNIPER_IFML_FRAMERELAY_FLEX 50 |
166 | | #define JUNIPER_IFML_GGSNI 51 |
167 | | #define JUNIPER_IFML_ETHERNET_FLEX 52 |
168 | | #define JUNIPER_IFML_COLLECTOR 53 |
169 | | #define JUNIPER_IFML_AGGREGATOR 54 |
170 | | #define JUNIPER_IFML_LAPD 55 |
171 | | #define JUNIPER_IFML_PPPOE 56 |
172 | | #define JUNIPER_IFML_PPP_SUBORDINATE 57 |
173 | | #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58 |
174 | | #define JUNIPER_IFML_DFC 59 |
175 | | #define JUNIPER_IFML_PICPEER 60 |
176 | | |
177 | | static const value_string juniper_ifmt_vals[] = { |
178 | | { JUNIPER_IFML_ETHER, "Ethernet" }, |
179 | | { JUNIPER_IFML_FDDI, "FDDI" }, |
180 | | { JUNIPER_IFML_TOKENRING, "Token-Ring" }, |
181 | | { JUNIPER_IFML_PPP, "PPP" }, |
182 | | { JUNIPER_IFML_PPP_SUBORDINATE, "PPP-Subordinate" }, |
183 | | { JUNIPER_IFML_FRAMERELAY, "Frame-Relay" }, |
184 | | { JUNIPER_IFML_CISCOHDLC, "Cisco-HDLC" }, |
185 | | { JUNIPER_IFML_SMDSDXI, "SMDS-DXI" }, |
186 | | { JUNIPER_IFML_ATMPVC, "ATM-PVC" }, |
187 | | { JUNIPER_IFML_PPP_CCC, "PPP-CCC" }, |
188 | | { JUNIPER_IFML_FRAMERELAY_CCC, "Frame-Relay-CCC" }, |
189 | | { JUNIPER_IFML_FRAMERELAY_EXT_CCC, "Extended FR-CCC" }, |
190 | | { JUNIPER_IFML_IPIP, "IP-over-IP" }, |
191 | | { JUNIPER_IFML_GRE, "GRE" }, |
192 | | { JUNIPER_IFML_PIM, "PIM-Encapsulator" }, |
193 | | { JUNIPER_IFML_PIMD, "PIM-Decapsulator" }, |
194 | | { JUNIPER_IFML_CISCOHDLC_CCC, "Cisco-HDLC-CCC" }, |
195 | | { JUNIPER_IFML_VLAN_CCC, "VLAN-CCC" }, |
196 | | { JUNIPER_IFML_EXTENDED_VLAN_CCC, "Extended-VLAN-CCC" }, |
197 | | { JUNIPER_IFML_MLPPP, "Multilink-PPP" }, |
198 | | { JUNIPER_IFML_MLFR, "Multilink-FR" }, |
199 | | { JUNIPER_IFML_MFR, "Multilink-FR-UNI-NNI" }, |
200 | | { JUNIPER_IFML_ML, "Multilink" }, |
201 | | { JUNIPER_IFML_LS, "LinkService" }, |
202 | | { JUNIPER_IFML_LSI, "LSI" }, |
203 | | { JUNIPER_IFML_ATM_CELLRELAY_CCC, "ATM-CCC-Cell-Relay" }, |
204 | | { JUNIPER_IFML_CRYPTO, "IPSEC-over-IP" }, |
205 | | { JUNIPER_IFML_GGSN, "GGSN" }, |
206 | | { JUNIPER_IFML_PPP_TCC, "PPP-TCC" }, |
207 | | { JUNIPER_IFML_FRAMERELAY_TCC, "Frame-Relay-TCC" }, |
208 | | { JUNIPER_IFML_FRAMERELAY_EXT_TCC, "Extended FR-TCC" }, |
209 | | { JUNIPER_IFML_CISCOHDLC_TCC, "Cisco-HDLC-TCC" }, |
210 | | { JUNIPER_IFML_ETHERNET_CCC, "Ethernet-CCC" }, |
211 | | { JUNIPER_IFML_VT, "VPN-Loopback-tunnel" }, |
212 | | { JUNIPER_IFML_ETHER_OVER_ATM, "Ethernet-over-ATM" }, |
213 | | { JUNIPER_IFML_ETHER_VPLS_OVER_ATM, "Ethernet-VPLS-over-ATM" }, |
214 | | { JUNIPER_IFML_MONITOR, "Monitor" }, |
215 | | { JUNIPER_IFML_ETHERNET_TCC, "Ethernet-TCC" }, |
216 | | { JUNIPER_IFML_VLAN_TCC, "VLAN-TCC" }, |
217 | | { JUNIPER_IFML_EXTENDED_VLAN_TCC, "Extended-VLAN-TCC" }, |
218 | | { JUNIPER_IFML_CONTROLLER, "Controller" }, |
219 | | { JUNIPER_IFML_ETHERNET_VPLS, "VPLS" }, |
220 | | { JUNIPER_IFML_ETHERNET_VLAN_VPLS, "VLAN-VPLS" }, |
221 | | { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS, "Extended-VLAN-VPLS" }, |
222 | | { JUNIPER_IFML_LT, "Logical-tunnel" }, |
223 | | { JUNIPER_IFML_SERVICES, "General-Services" }, |
224 | | { JUNIPER_IFML_PPPOE, "PPPoE" }, |
225 | | { JUNIPER_IFML_ETHERNET_FLEX, "Flexible-Ethernet-Services" }, |
226 | | { JUNIPER_IFML_FRAMERELAY_FLEX, "Flexible-FrameRelay" }, |
227 | | { JUNIPER_IFML_COLLECTOR, "Flow-collection" }, |
228 | | { JUNIPER_IFML_PICPEER, "PIC Peer" }, |
229 | | { JUNIPER_IFML_DFC, "Dynamic-Flow-Capture" }, |
230 | | {0, NULL} |
231 | | }; |
232 | | |
233 | | #define JUNIPER_IFLE_ATM_SNAP 2 |
234 | | #define JUNIPER_IFLE_ATM_NLPID 3 |
235 | | #define JUNIPER_IFLE_ATM_VCMUX 4 |
236 | | #define JUNIPER_IFLE_ATM_LLC 5 |
237 | | #define JUNIPER_IFLE_ATM_PPP_VCMUX 6 |
238 | | #define JUNIPER_IFLE_ATM_PPP_LLC 7 |
239 | | #define JUNIPER_IFLE_ATM_PPP_FUNI 8 |
240 | | #define JUNIPER_IFLE_ATM_CCC 9 |
241 | | #define JUNIPER_IFLE_FR_NLPID 10 |
242 | | #define JUNIPER_IFLE_FR_SNAP 11 |
243 | | #define JUNIPER_IFLE_FR_PPP 12 |
244 | | #define JUNIPER_IFLE_FR_CCC 13 |
245 | | #define JUNIPER_IFLE_ENET2 14 |
246 | | #define JUNIPER_IFLE_IEEE8023_SNAP 15 |
247 | | #define JUNIPER_IFLE_IEEE8023_LLC 16 |
248 | | #define JUNIPER_IFLE_PPP 17 |
249 | | #define JUNIPER_IFLE_CISCOHDLC 18 |
250 | | #define JUNIPER_IFLE_PPP_CCC 19 |
251 | | #define JUNIPER_IFLE_IPIP_NULL 20 |
252 | | #define JUNIPER_IFLE_PIM_NULL 21 |
253 | | #define JUNIPER_IFLE_GRE_NULL 22 |
254 | | #define JUNIPER_IFLE_GRE_PPP 23 |
255 | | #define JUNIPER_IFLE_PIMD_DECAPS 24 |
256 | | #define JUNIPER_IFLE_CISCOHDLC_CCC 25 |
257 | | #define JUNIPER_IFLE_ATM_CISCO_NLPID 26 |
258 | | #define JUNIPER_IFLE_VLAN_CCC 27 |
259 | | #define JUNIPER_IFLE_MLPPP 28 |
260 | | #define JUNIPER_IFLE_MLFR 29 |
261 | | #define JUNIPER_IFLE_LSI_NULL 30 |
262 | | #define JUNIPER_IFLE_AGGREGATE_UNUSED 31 |
263 | | #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32 |
264 | | #define JUNIPER_IFLE_CRYPTO 33 |
265 | | #define JUNIPER_IFLE_GGSN 34 |
266 | | #define JUNIPER_IFLE_ATM_TCC 35 |
267 | | #define JUNIPER_IFLE_FR_TCC 36 |
268 | | #define JUNIPER_IFLE_PPP_TCC 37 |
269 | | #define JUNIPER_IFLE_CISCOHDLC_TCC 38 |
270 | | #define JUNIPER_IFLE_ETHERNET_CCC 39 |
271 | | #define JUNIPER_IFLE_VT 40 |
272 | | #define JUNIPER_IFLE_ATM_EOA_LLC 41 |
273 | | #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42 |
274 | | #define JUNIPER_IFLE_ATM_SNAP_TCC 43 |
275 | | #define JUNIPER_IFLE_MONITOR 44 |
276 | | #define JUNIPER_IFLE_ETHERNET_TCC 45 |
277 | | #define JUNIPER_IFLE_VLAN_TCC 46 |
278 | | #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47 |
279 | | #define JUNIPER_IFLE_MFR 48 |
280 | | #define JUNIPER_IFLE_ETHERNET_VPLS 49 |
281 | | #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50 |
282 | | #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51 |
283 | | #define JUNIPER_IFLE_SERVICES 52 |
284 | | #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53 |
285 | | #define JUNIPER_IFLE_FR_PORT_CCC 54 |
286 | | #define JUNIPER_IFLE_ATM_MLPPP_LLC 55 |
287 | | #define JUNIPER_IFLE_ATM_EOA_CCC 56 |
288 | | #define JUNIPER_IFLE_LT_VLAN 57 |
289 | | #define JUNIPER_IFLE_COLLECTOR 58 |
290 | | #define JUNIPER_IFLE_AGGREGATOR 59 |
291 | | #define JUNIPER_IFLE_LAPD 60 |
292 | | #define JUNIPER_IFLE_ATM_PPPOE_LLC 61 |
293 | | #define JUNIPER_IFLE_ETHERNET_PPPOE 62 |
294 | | #define JUNIPER_IFLE_PPPOE 63 |
295 | | #define JUNIPER_IFLE_PPP_SUBORDINATE 64 |
296 | | #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65 |
297 | | #define JUNIPER_IFLE_DFC 66 |
298 | | #define JUNIPER_IFLE_PICPEER 67 |
299 | | |
300 | | static const value_string juniper_ifle_vals[] = { |
301 | | { JUNIPER_IFLE_AGGREGATOR, "Aggregator" }, |
302 | | { JUNIPER_IFLE_ATM_CCC, "CCC over ATM" }, |
303 | | { JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" }, |
304 | | { JUNIPER_IFLE_ATM_CISCO_NLPID, "CISCO compatible NLPID" }, |
305 | | { JUNIPER_IFLE_ATM_EOA_CCC, "Ethernet over ATM CCC" }, |
306 | | { JUNIPER_IFLE_ATM_EOA_LLC, "Ethernet over ATM LLC" }, |
307 | | { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC, "Ethernet VPLS over ATM LLC" }, |
308 | | { JUNIPER_IFLE_ATM_LLC, "ATM LLC" }, |
309 | | { JUNIPER_IFLE_ATM_MLPPP_LLC, "MLPPP over ATM LLC" }, |
310 | | { JUNIPER_IFLE_ATM_NLPID, "ATM NLPID" }, |
311 | | { JUNIPER_IFLE_ATM_PPPOE_LLC, "PPPoE over ATM LLC" }, |
312 | | { JUNIPER_IFLE_ATM_PPP_FUNI, "PPP over FUNI" }, |
313 | | { JUNIPER_IFLE_ATM_PPP_LLC, "PPP over ATM LLC" }, |
314 | | { JUNIPER_IFLE_ATM_PPP_VCMUX, "PPP over ATM VCMUX" }, |
315 | | { JUNIPER_IFLE_ATM_SNAP, "ATM SNAP" }, |
316 | | { JUNIPER_IFLE_ATM_SNAP_TCC, "ATM SNAP TCC" }, |
317 | | { JUNIPER_IFLE_ATM_TCC, "ATM VCMUX TCC" }, |
318 | | { JUNIPER_IFLE_ATM_VCMUX, "ATM VCMUX" }, |
319 | | { JUNIPER_IFLE_CISCOHDLC, "C-HDLC" }, |
320 | | { JUNIPER_IFLE_CISCOHDLC_CCC, "C-HDLC CCC" }, |
321 | | { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE, "C-HDLC via dialer" }, |
322 | | { JUNIPER_IFLE_CISCOHDLC_TCC, "C-HDLC TCC" }, |
323 | | { JUNIPER_IFLE_COLLECTOR, "Collector" }, |
324 | | { JUNIPER_IFLE_CRYPTO, "Crypto" }, |
325 | | { JUNIPER_IFLE_ENET2, "Ethernet" }, |
326 | | { JUNIPER_IFLE_ETHERNET_CCC, "Ethernet CCC" }, |
327 | | { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS, "Extended VLAN VPLS" }, |
328 | | { JUNIPER_IFLE_ETHERNET_PPPOE, "PPPoE over Ethernet" }, |
329 | | { JUNIPER_IFLE_ETHERNET_TCC, "Ethernet TCC" }, |
330 | | { JUNIPER_IFLE_ETHERNET_VLAN_VPLS, "VLAN VPLS" }, |
331 | | { JUNIPER_IFLE_ETHERNET_VPLS, "VPLS" }, |
332 | | { JUNIPER_IFLE_EXTENDED_VLAN_CCC, "Extended VLAN CCC" }, |
333 | | { JUNIPER_IFLE_EXTENDED_VLAN_TCC, "Extended VLAN TCC" }, |
334 | | { JUNIPER_IFLE_FR_CCC, "FR CCC" }, |
335 | | { JUNIPER_IFLE_FR_NLPID, "FR NLPID" }, |
336 | | { JUNIPER_IFLE_FR_PORT_CCC, "FR Port CCC" }, |
337 | | { JUNIPER_IFLE_FR_PPP, "FR PPP" }, |
338 | | { JUNIPER_IFLE_FR_SNAP, "FR SNAP" }, |
339 | | { JUNIPER_IFLE_FR_TCC, "FR TCC" }, |
340 | | { JUNIPER_IFLE_GGSN, "GGSN" }, |
341 | | { JUNIPER_IFLE_GRE_NULL, "GRE NULL" }, |
342 | | { JUNIPER_IFLE_GRE_PPP, "PPP over GRE" }, |
343 | | { JUNIPER_IFLE_IPIP_NULL, "IPIP" }, |
344 | | { JUNIPER_IFLE_LAPD, "LAPD" }, |
345 | | { JUNIPER_IFLE_LSI_NULL, "LSI Null" }, |
346 | | { JUNIPER_IFLE_LT_VLAN, "LT VLAN" }, |
347 | | { JUNIPER_IFLE_MFR, "MFR" }, |
348 | | { JUNIPER_IFLE_MLFR, "MLFR" }, |
349 | | { JUNIPER_IFLE_MLPPP, "MLPPP" }, |
350 | | { JUNIPER_IFLE_MONITOR, "Monitor" }, |
351 | | { JUNIPER_IFLE_PIMD_DECAPS, "PIMd" }, |
352 | | { JUNIPER_IFLE_PIM_NULL, "PIM Null" }, |
353 | | { JUNIPER_IFLE_PPP, "PPP" }, |
354 | | { JUNIPER_IFLE_PPPOE, "PPPoE" }, |
355 | | { JUNIPER_IFLE_PPP_CCC, "PPP CCC" }, |
356 | | { JUNIPER_IFLE_PPP_SUBORDINATE, "" }, |
357 | | { JUNIPER_IFLE_PPP_TCC, "PPP TCC" }, |
358 | | { JUNIPER_IFLE_SERVICES, "General Services" }, |
359 | | { JUNIPER_IFLE_VLAN_CCC, "VLAN CCC" }, |
360 | | { JUNIPER_IFLE_VLAN_TCC, "VLAN TCC" }, |
361 | | { JUNIPER_IFLE_VT, "VT" }, |
362 | | {0, NULL} |
363 | | }; |
364 | | |
365 | | |
366 | | static int proto_juniper; |
367 | | |
368 | | static int hf_juniper_magic; |
369 | | static int hf_juniper_direction; |
370 | | static int hf_juniper_l2hdr_presence; |
371 | | static int hf_juniper_ext_total_len; |
372 | | static int hf_juniper_cookie_len; |
373 | | static int hf_juniper_atm1_cookie; |
374 | | static int hf_juniper_atm2_cookie; |
375 | | static int hf_juniper_mlpic_cookie; |
376 | | static int hf_juniper_lspic_cookie; |
377 | | static int hf_juniper_aspic_cookie; |
378 | | static int hf_juniper_vlan; |
379 | | static int hf_juniper_proto; |
380 | | static int hf_juniper_payload_type; |
381 | | static int hf_juniper_encap_type; |
382 | | static int hf_juniper_ext_ifd; |
383 | | static int hf_juniper_ext_ifl; |
384 | | static int hf_juniper_ext_unit; |
385 | | static int hf_juniper_ext_ifmt; |
386 | | static int hf_juniper_ext_ifle; |
387 | | static int hf_juniper_ext_ttp_ifmt; |
388 | | static int hf_juniper_ext_ttp_ifle; |
389 | | static int hf_juniper_unknown_data; |
390 | | |
391 | | static expert_field ei_juniper_no_magic; |
392 | | static expert_field ei_juniper_vn_incorrect_format; |
393 | | |
394 | | static int hf_juniper_vn_host_ip; |
395 | | static int hf_juniper_vn_src; |
396 | | static int hf_juniper_vn_dst; |
397 | | static int hf_juniper_vn_flags; |
398 | | static int hf_juniper_vn_flag_alert; |
399 | | static int hf_juniper_vn_flag_drop; |
400 | | static int hf_juniper_vn_flag_deny; |
401 | | static int hf_juniper_vn_flag_log; |
402 | | static int hf_juniper_vn_flag_pass; |
403 | | static int hf_juniper_vn_flag_reject; |
404 | | static int hf_juniper_vn_flag_mirror; |
405 | | static int hf_juniper_vn_flag_direction; |
406 | | |
407 | | static int hf_juniper_st_eth_dst; |
408 | | static int hf_juniper_st_eth_src; |
409 | | static int hf_juniper_st_eth_type; |
410 | | static int hf_juniper_st_ip_len; |
411 | | static int hf_juniper_st_ip_proto; |
412 | | static int hf_juniper_st_esp_spi; |
413 | | static int hf_juniper_st_esp_seq; |
414 | | |
415 | | static int ett_juniper; |
416 | | static int ett_juniper_vn_flags; |
417 | | static int ett_juniper_st_eth; |
418 | | static int ett_juniper_st_ip; |
419 | | static int ett_juniper_st_esp; |
420 | | static int ett_juniper_st_unknown; |
421 | | |
422 | | static dissector_table_t payload_table; |
423 | | |
424 | | static int dissect_juniper_payload_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *juniper_subtree, unsigned proto, unsigned offset); |
425 | | static void dissect_juniper_atm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint16_t atm_pictype); |
426 | | static bool ppp_heuristic_guess(uint16_t proto); |
427 | | static unsigned ip_heuristic_guess(uint8_t ip_header_byte); |
428 | | static unsigned juniper_svc_cookie_len (uint64_t cookie); |
429 | | static unsigned juniper_svc_cookie_proto (uint64_t cookie, uint16_t pictype, uint8_t flags); |
430 | | |
431 | | static const value_string juniper_proto_vals[] = { |
432 | | {JUNIPER_PROTO_IP, "IPv4"}, |
433 | | {JUNIPER_PROTO_MPLS_IP, "MPLS->IPv4"}, |
434 | | {JUNIPER_PROTO_IP_MPLS, "IPv4->MPLS"}, |
435 | | {JUNIPER_PROTO_IP6, "IPv6"}, |
436 | | {JUNIPER_PROTO_MPLS_IP6, "MPLS->IPv6"}, |
437 | | {JUNIPER_PROTO_IP6_MPLS, "IPv6->MPLS"}, |
438 | | {JUNIPER_PROTO_PPP, "PPP"}, |
439 | | {JUNIPER_PROTO_CLNP, "CLNP"}, |
440 | | {JUNIPER_PROTO_MPLS_CLNP, "MPLS->CLNP"}, |
441 | | {JUNIPER_PROTO_CLNP_MPLS, "CLNP->MPLS"}, |
442 | | {JUNIPER_PROTO_ISO, "OSI"}, |
443 | | {JUNIPER_PROTO_MPLS, "MPLS"}, |
444 | | {JUNIPER_PROTO_LLC, "LLC"}, |
445 | | {JUNIPER_PROTO_LLC_SNAP, "LLC/SNAP"}, |
446 | | {JUNIPER_PROTO_ETHER, "Ethernet"}, |
447 | | {JUNIPER_PROTO_OAM, "ATM OAM Cell"}, |
448 | | {JUNIPER_PROTO_Q933, "Q.933"}, |
449 | | {JUNIPER_PROTO_FRELAY, "Frame-Relay"}, |
450 | | {JUNIPER_PROTO_CHDLC, "C-HDLC"}, |
451 | | {0, NULL} |
452 | | }; |
453 | | |
454 | | static int * const vn_flags[] = { |
455 | | &hf_juniper_vn_flag_direction, |
456 | | &hf_juniper_vn_flag_mirror, |
457 | | &hf_juniper_vn_flag_reject, |
458 | | &hf_juniper_vn_flag_pass, |
459 | | &hf_juniper_vn_flag_log, |
460 | | &hf_juniper_vn_flag_deny, |
461 | | &hf_juniper_vn_flag_drop, |
462 | | &hf_juniper_vn_flag_alert, |
463 | | NULL |
464 | | }; |
465 | | |
466 | | /* return a TLV value based on TLV length and TLV type (host/network order) */ |
467 | | static int |
468 | 0 | juniper_ext_get_tlv_value(tvbuff_t *tvb, unsigned tlv_type, unsigned tlv_len, unsigned offset) { |
469 | |
|
470 | 0 | int tlv_value; |
471 | |
|
472 | 0 | if (tlv_type < 128) { |
473 | | /* TLVs < 128 are little-endian / host order encoded */ |
474 | 0 | switch (tlv_len) { |
475 | 0 | case 1: |
476 | 0 | tlv_value = tvb_get_uint8(tvb, offset); |
477 | 0 | break; |
478 | 0 | case 2: |
479 | 0 | tlv_value = tvb_get_letohs(tvb, offset); |
480 | 0 | break; |
481 | 0 | case 3: |
482 | 0 | tlv_value = tvb_get_letoh24(tvb, offset); |
483 | 0 | break; |
484 | 0 | case 4: |
485 | 0 | tlv_value = tvb_get_letohl(tvb, offset); |
486 | 0 | break; |
487 | 0 | default: |
488 | 0 | tlv_value = -1; |
489 | 0 | break; |
490 | 0 | } |
491 | 0 | } else { |
492 | | /* TLVs >= 128 are big-endian / network order encoded */ |
493 | 0 | switch (tlv_len) { |
494 | 0 | case 1: |
495 | 0 | tlv_value = tvb_get_uint8(tvb, offset); |
496 | 0 | break; |
497 | 0 | case 2: |
498 | 0 | tlv_value = tvb_get_ntohs(tvb, offset); |
499 | 0 | break; |
500 | 0 | case 3: |
501 | 0 | tlv_value = tvb_get_ntoh24(tvb, offset); |
502 | 0 | break; |
503 | 0 | case 4: |
504 | 0 | tlv_value = tvb_get_ntohl(tvb, offset); |
505 | 0 | break; |
506 | 0 | default: |
507 | 0 | tlv_value = -1; |
508 | 0 | break; |
509 | 0 | } |
510 | 0 | } |
511 | 0 | return tlv_value; |
512 | 0 | } |
513 | | |
514 | | /* generic juniper header dissector */ |
515 | | static int |
516 | | dissect_juniper_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *juniper_subtree, uint8_t *flags) |
517 | 2 | { |
518 | 2 | proto_item *tisub, *magic_item; |
519 | 2 | uint8_t proto,ext_type,ext_len; |
520 | 2 | uint16_t ext_total_len,ext_offset=6,hdr_len; |
521 | 2 | uint32_t magic_number,ext_val; |
522 | | |
523 | 2 | proto_tree *juniper_ext_subtree = NULL, *juniper_ext_subtree_item = NULL; |
524 | | |
525 | 2 | magic_number = tvb_get_ntoh24(tvb, 0); |
526 | 2 | *flags = tvb_get_uint8(tvb, 3); |
527 | | |
528 | 2 | magic_item = proto_tree_add_item(juniper_subtree, hf_juniper_magic, tvb, 0, 3, ENC_BIG_ENDIAN); |
529 | | |
530 | | /* be liberal with magic-number detection - |
531 | | * some older JUNOS releases (e.g. 6.4), |
532 | | * which are still in the field do not generate magic-numbers */ |
533 | 2 | if (magic_number != JUNIPER_PCAP_MAGIC) { |
534 | 2 | expert_add_info(pinfo, magic_item, &ei_juniper_no_magic); |
535 | 2 | return 0; |
536 | 2 | } |
537 | | |
538 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_direction, tvb, 3, 1, ENC_NA); |
539 | |
|
540 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_l2hdr_presence, tvb, 3, 1, ENC_NA); |
541 | | |
542 | | /* calculate hdr_len before cookie, payload */ |
543 | | |
544 | | /* meta-info extensions (JUNOS >= 7.5) ? */ |
545 | 0 | if ((*flags & JUNIPER_FLAG_EXT) == JUNIPER_FLAG_EXT) { |
546 | 0 | ext_total_len = tvb_get_ntohs(tvb,4); |
547 | 0 | hdr_len = 6 + ext_total_len; /* MGC,flags,ext_total_len */ |
548 | |
|
549 | 0 | tisub = proto_tree_add_uint (juniper_subtree, hf_juniper_ext_total_len, tvb, 4, 2, ext_total_len); |
550 | 0 | juniper_ext_subtree = proto_item_add_subtree(tisub, ett_juniper); |
551 | |
|
552 | 0 | while (ext_total_len > EXT_TLV_HEADER_SIZE) { |
553 | 0 | ext_type = tvb_get_uint8(tvb, ext_offset); |
554 | 0 | ext_len = tvb_get_uint8(tvb, ext_offset+1); |
555 | |
|
556 | 0 | if (ext_len == 0 || ext_len > (ext_total_len - EXT_TLV_HEADER_SIZE)) /* a few sanity checks */ |
557 | 0 | break; |
558 | | |
559 | 0 | juniper_ext_subtree_item = proto_tree_add_subtree_format(juniper_ext_subtree, tvb, ext_offset, EXT_TLV_HEADER_SIZE + ext_len, |
560 | 0 | ett_juniper, &tisub, "%s Extension TLV #%u, length: %u", |
561 | 0 | val_to_str_const(ext_type, ext_tlv_vals, "Unknown"), |
562 | 0 | ext_type, |
563 | 0 | ext_len); |
564 | |
|
565 | 0 | ext_val = juniper_ext_get_tlv_value(tvb, ext_type, ext_len, ext_offset+EXT_TLV_HEADER_SIZE); |
566 | |
|
567 | 0 | switch (ext_type) { |
568 | 0 | case EXT_TLV_IFD_MEDIATYPE: |
569 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ifmt, |
570 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
571 | 0 | break; |
572 | 0 | case EXT_TLV_TTP_IFD_MEDIATYPE: |
573 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ttp_ifmt, |
574 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
575 | 0 | break; |
576 | 0 | case EXT_TLV_IFL_ENCAPS: |
577 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ifle, |
578 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
579 | 0 | break; |
580 | 0 | case EXT_TLV_TTP_IFL_ENCAPS: |
581 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ttp_ifle, |
582 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
583 | 0 | break; |
584 | | |
585 | 0 | case EXT_TLV_IFL_IDX: |
586 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ifl, |
587 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
588 | 0 | break; |
589 | | |
590 | 0 | case EXT_TLV_IFL_UNIT: |
591 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_unit, |
592 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
593 | 0 | break; |
594 | 0 | case EXT_TLV_IFD_IDX: |
595 | 0 | proto_tree_add_uint(juniper_ext_subtree_item, hf_juniper_ext_ifd, |
596 | 0 | tvb, ext_offset+EXT_TLV_HEADER_SIZE, ext_len, ext_val); |
597 | 0 | break; |
598 | 0 | case EXT_TLV_IFD_NAME: /* FIXME print ifname string - lets fall-through for now */ |
599 | 0 | default: |
600 | 0 | proto_item_append_text(tisub, "Unknown"); |
601 | 0 | break; |
602 | 0 | } |
603 | | |
604 | 0 | ext_offset += EXT_TLV_HEADER_SIZE + ext_len; |
605 | 0 | ext_total_len -= EXT_TLV_HEADER_SIZE + ext_len; |
606 | 0 | } |
607 | |
|
608 | 0 | } else |
609 | 0 | hdr_len = 4; /* MGC,flags */ |
610 | | |
611 | 0 | if ((*flags & JUNIPER_FLAG_NO_L2) == JUNIPER_FLAG_NO_L2) { /* no link header present ? */ |
612 | 0 | proto = tvb_get_letohl(tvb,hdr_len); /* proto is stored in host-order */ |
613 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, proto, hdr_len + 4); |
614 | 0 | return -1; |
615 | 0 | } |
616 | | |
617 | 0 | return hdr_len; /* bytes parsed */ |
618 | |
|
619 | 0 | } |
620 | | |
621 | | /* print the payload protocol */ |
622 | | static int |
623 | | dissect_juniper_payload_proto(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, |
624 | | proto_tree *juniper_subtree, unsigned proto, unsigned offset) |
625 | 2 | { |
626 | 2 | proto_item *ti; |
627 | 2 | tvbuff_t *next_tvb; |
628 | | |
629 | 2 | ti = proto_tree_add_uint(juniper_subtree, hf_juniper_payload_type, tvb, offset, 0, proto); |
630 | 2 | proto_item_set_generated(ti); |
631 | | |
632 | 2 | switch (proto) |
633 | 2 | { |
634 | | /* XXX - 0xa248 stands for ??? */ |
635 | 0 | case 0xa248: |
636 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_unknown_data, tvb, offset, 4, ENC_NA); |
637 | 0 | offset += 4; |
638 | 0 | proto = JUNIPER_PROTO_IP; |
639 | 0 | break; |
640 | | |
641 | 2 | default: |
642 | 2 | break; |
643 | 2 | } |
644 | | |
645 | 2 | proto_item_set_len(juniper_subtree, offset); |
646 | 2 | next_tvb = tvb_new_subset_remaining(tvb, offset); |
647 | | |
648 | 2 | if (!dissector_try_uint(payload_table, proto, next_tvb, pinfo, tree)) |
649 | 1 | { |
650 | | /* XXX - left in for posterity, dissection was never done */ |
651 | | /* case JUNIPER_PROTO_OAM: FIXME call OAM dissector without leading HEC byte */ |
652 | | |
653 | 1 | call_data_dissector(next_tvb, pinfo, tree); |
654 | 1 | } |
655 | | |
656 | 2 | return 0; |
657 | 2 | } |
658 | | |
659 | | /* MLFR dissector */ |
660 | | static int |
661 | | dissect_juniper_mlfr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
662 | 0 | { |
663 | 0 | proto_item *ti; |
664 | 0 | proto_tree* juniper_subtree; |
665 | 0 | unsigned offset; |
666 | 0 | int bytes_processed; |
667 | 0 | uint8_t flags; |
668 | 0 | uint64_t aspic_cookie; |
669 | 0 | uint32_t lspic_cookie; |
670 | 0 | uint16_t mlpic_cookie; |
671 | 0 | unsigned proto,cookie_len; |
672 | |
|
673 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper MLFR"); |
674 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
675 | |
|
676 | 0 | offset = 0; |
677 | |
|
678 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper Multi-Link Frame-Relay (FRF.15)"); |
679 | | |
680 | | /* parse header, match mgc, extract flags and build first tree */ |
681 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
682 | |
|
683 | 0 | if(bytes_processed == -1) |
684 | 0 | return 4; |
685 | 0 | else |
686 | 0 | offset+=bytes_processed; |
687 | | |
688 | 0 | aspic_cookie = tvb_get_ntoh64(tvb,offset); |
689 | 0 | proto = juniper_svc_cookie_proto(aspic_cookie, JUNIPER_PIC_MLFR, flags); |
690 | 0 | cookie_len = juniper_svc_cookie_len(aspic_cookie); |
691 | |
|
692 | 0 | if (cookie_len == AS_PIC_COOKIE_LEN) |
693 | 0 | proto_tree_add_uint64(juniper_subtree, hf_juniper_aspic_cookie, |
694 | 0 | tvb, offset, AS_PIC_COOKIE_LEN, aspic_cookie); |
695 | 0 | if (cookie_len == LS_PIC_COOKIE_LEN) { |
696 | 0 | lspic_cookie = tvb_get_ntohl(tvb,offset); |
697 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_lspic_cookie, |
698 | 0 | tvb, offset, LS_PIC_COOKIE_LEN, lspic_cookie); |
699 | 0 | } |
700 | |
|
701 | 0 | offset += cookie_len; |
702 | |
|
703 | 0 | mlpic_cookie = tvb_get_ntohs(tvb, offset); |
704 | | |
705 | | /* AS-PIC IS-IS */ |
706 | 0 | if (cookie_len == AS_PIC_COOKIE_LEN && |
707 | 0 | proto == JUNIPER_PROTO_UNKNOWN && |
708 | 0 | tvb_get_uint8(tvb,offset) == JUNIPER_HDR_LLC_UI) { |
709 | 0 | offset += 1; |
710 | 0 | proto = JUNIPER_PROTO_ISO; |
711 | 0 | } |
712 | | |
713 | | /* LS-PIC IS-IS */ |
714 | 0 | if (cookie_len == LS_PIC_COOKIE_LEN) { |
715 | 0 | if ( tvb_get_ntohs(tvb,offset) == JUNIPER_HDR_LLC_UI || |
716 | 0 | tvb_get_ntohs(tvb,offset) == (JUNIPER_HDR_LLC_UI<<8)) { |
717 | 0 | offset += 2; |
718 | 0 | } |
719 | 0 | } |
720 | | |
721 | | /* LS-PIC ? */ |
722 | 0 | if (cookie_len == LS_PIC_COOKIE_LEN && tvb_get_uint8(tvb,offset) == JUNIPER_HDR_LLC_UI) { |
723 | 0 | offset += 1; |
724 | 0 | } |
725 | | |
726 | | /* child link of an LS-PIC bundle ? */ |
727 | 0 | if (cookie_len == 0 && tvb_get_ntohs(tvb,offset+ML_PIC_COOKIE_LEN) == |
728 | 0 | (JUNIPER_HDR_LLC_UI<<8 | NLPID_Q_933)) { |
729 | 0 | cookie_len = ML_PIC_COOKIE_LEN; |
730 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_mlpic_cookie, |
731 | 0 | tvb, offset, ML_PIC_COOKIE_LEN, mlpic_cookie); |
732 | 0 | offset += 3; |
733 | 0 | proto = JUNIPER_PROTO_Q933; |
734 | 0 | } |
735 | | |
736 | | /* child link of an ML-, LS-, AS-PIC bundle / ML-PIC bundle ? */ |
737 | 0 | if (cookie_len == 0) { |
738 | 0 | if (tvb_get_ntohs(tvb,offset+ML_PIC_COOKIE_LEN) == JUNIPER_HDR_LLC_UI || |
739 | 0 | tvb_get_ntohs(tvb,offset+ML_PIC_COOKIE_LEN) == (JUNIPER_HDR_LLC_UI<<8)) { |
740 | 0 | cookie_len = ML_PIC_COOKIE_LEN; |
741 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_mlpic_cookie, |
742 | 0 | tvb, offset, ML_PIC_COOKIE_LEN, mlpic_cookie); |
743 | 0 | offset += 4; |
744 | 0 | proto = JUNIPER_PROTO_ISO; |
745 | 0 | } |
746 | 0 | } |
747 | | |
748 | | /* ML-PIC bundle ? */ |
749 | 0 | if (cookie_len == 0 && tvb_get_uint8(tvb,offset+ML_PIC_COOKIE_LEN) == JUNIPER_HDR_LLC_UI) { |
750 | 0 | cookie_len = ML_PIC_COOKIE_LEN; |
751 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_mlpic_cookie, |
752 | 0 | tvb, offset, ML_PIC_COOKIE_LEN, mlpic_cookie); |
753 | 0 | offset += 3; |
754 | 0 | proto = JUNIPER_PROTO_ISO; |
755 | 0 | } |
756 | |
|
757 | 0 | ti = proto_tree_add_uint(juniper_subtree, hf_juniper_cookie_len, tvb, offset, 0, cookie_len); |
758 | 0 | proto_item_set_generated(ti); |
759 | |
|
760 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, proto, offset); |
761 | |
|
762 | 0 | return tvb_captured_length(tvb); |
763 | 0 | } |
764 | | |
765 | | |
766 | | |
767 | | /* MLPPP dissector */ |
768 | | static int |
769 | | dissect_juniper_mlppp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
770 | 0 | { |
771 | 0 | proto_item *ti; |
772 | 0 | proto_tree* juniper_subtree; |
773 | 0 | unsigned offset; |
774 | 0 | int bytes_processed; |
775 | 0 | uint8_t flags; |
776 | 0 | uint64_t aspic_cookie; |
777 | 0 | uint32_t lspic_cookie; |
778 | 0 | uint16_t mlpic_cookie; |
779 | 0 | unsigned proto,cookie_len; |
780 | |
|
781 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper MLPPP"); |
782 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
783 | |
|
784 | 0 | offset = 0; |
785 | |
|
786 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper MLPPP"); |
787 | | |
788 | | /* parse header, match mgc, extract flags and build first tree */ |
789 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
790 | |
|
791 | 0 | if(bytes_processed == -1) |
792 | 0 | return 4; |
793 | 0 | else |
794 | 0 | offset+=bytes_processed; |
795 | | |
796 | 0 | aspic_cookie = tvb_get_ntoh64(tvb,offset); |
797 | 0 | proto = juniper_svc_cookie_proto(aspic_cookie, JUNIPER_PIC_MLPPP, flags); |
798 | 0 | cookie_len = juniper_svc_cookie_len(aspic_cookie); |
799 | |
|
800 | 0 | if (cookie_len == AS_PIC_COOKIE_LEN) |
801 | 0 | proto_tree_add_uint64(juniper_subtree, hf_juniper_aspic_cookie, |
802 | 0 | tvb, offset, AS_PIC_COOKIE_LEN, aspic_cookie); |
803 | 0 | if (cookie_len == LS_PIC_COOKIE_LEN) { |
804 | 0 | lspic_cookie = tvb_get_ntohl(tvb,offset); |
805 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_lspic_cookie, |
806 | 0 | tvb, offset, LS_PIC_COOKIE_LEN, lspic_cookie); |
807 | 0 | } |
808 | | |
809 | | /* no cookie pattern identified - lets guess from now on */ |
810 | | |
811 | | /* child link of an LS-PIC bundle ? */ |
812 | 0 | if (cookie_len == 0 && tvb_get_ntohs(tvb, offset) == JUNIPER_HDR_PPP) { |
813 | 0 | proto = JUNIPER_PROTO_PPP; |
814 | 0 | offset += 2; |
815 | 0 | } |
816 | | |
817 | | /* ML-PIC ? */ |
818 | 0 | if (cookie_len == 0 && ppp_heuristic_guess(tvb_get_ntohs(tvb, offset+2))) { |
819 | 0 | proto = JUNIPER_PROTO_PPP; |
820 | 0 | cookie_len = 2; |
821 | 0 | mlpic_cookie = tvb_get_ntohs(tvb, offset); |
822 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_mlpic_cookie, |
823 | 0 | tvb, offset, ML_PIC_COOKIE_LEN, mlpic_cookie); |
824 | 0 | } |
825 | | |
826 | | /* child link of an ML-PIC bundle ? */ |
827 | 0 | if (cookie_len == 0 && ppp_heuristic_guess(tvb_get_ntohs(tvb, offset))) { |
828 | 0 | proto = JUNIPER_PROTO_PPP; |
829 | 0 | } |
830 | |
|
831 | 0 | ti = proto_tree_add_uint(juniper_subtree, hf_juniper_cookie_len, tvb, offset, 0, cookie_len); |
832 | 0 | proto_item_set_generated(ti); |
833 | 0 | offset += cookie_len; |
834 | |
|
835 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, proto, offset); |
836 | |
|
837 | 0 | return tvb_captured_length(tvb); |
838 | 0 | } |
839 | | |
840 | | |
841 | | /* PPPoE dissector */ |
842 | | static int |
843 | | dissect_juniper_pppoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
844 | 0 | { |
845 | 0 | proto_tree* juniper_subtree; |
846 | 0 | unsigned offset; |
847 | 0 | int bytes_processed; |
848 | 0 | uint8_t flags; |
849 | |
|
850 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper PPPoE"); |
851 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
852 | |
|
853 | 0 | offset = 0; |
854 | |
|
855 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper PPPoE PIC"); |
856 | | |
857 | | /* parse header, match mgc, extract flags and build first tree */ |
858 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
859 | |
|
860 | 0 | if(bytes_processed == -1) |
861 | 0 | return 4; |
862 | 0 | else |
863 | 0 | offset+=bytes_processed; |
864 | | |
865 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_ETHER, offset); |
866 | |
|
867 | 0 | return tvb_captured_length(tvb); |
868 | 0 | } |
869 | | |
870 | | /* Ethernet dissector */ |
871 | | static int |
872 | | dissect_juniper_ether(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
873 | 0 | { |
874 | 0 | proto_tree* juniper_subtree; |
875 | 0 | unsigned offset; |
876 | 0 | int bytes_processed; |
877 | 0 | uint8_t flags; |
878 | |
|
879 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper Ethernet"); |
880 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
881 | |
|
882 | 0 | offset = 0; |
883 | |
|
884 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper Ethernet"); |
885 | | |
886 | | /* parse header, match mgc, extract flags and build first tree */ |
887 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
888 | |
|
889 | 0 | if(bytes_processed == -1) |
890 | 0 | return 4; |
891 | 0 | else |
892 | 0 | offset+=bytes_processed; |
893 | | |
894 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_ETHER, offset); |
895 | |
|
896 | 0 | return tvb_captured_length(tvb); |
897 | 0 | } |
898 | | |
899 | | /* PPP dissector */ |
900 | | static int |
901 | | dissect_juniper_ppp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
902 | 0 | { |
903 | 0 | proto_tree* juniper_subtree; |
904 | 0 | unsigned offset; |
905 | 0 | int bytes_processed; |
906 | 0 | uint8_t flags; |
907 | |
|
908 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper PPP"); |
909 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
910 | |
|
911 | 0 | offset = 0; |
912 | |
|
913 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper PPP"); |
914 | | |
915 | | /* parse header, match mgc, extract flags and build first tree */ |
916 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
917 | |
|
918 | 0 | if(bytes_processed == -1) |
919 | 0 | return 4; |
920 | 0 | else |
921 | 0 | offset+=bytes_processed; |
922 | | |
923 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_PPP, offset+2); |
924 | |
|
925 | 0 | return tvb_captured_length(tvb); |
926 | 0 | } |
927 | | |
928 | | /* Frame-Relay dissector */ |
929 | | static int |
930 | | dissect_juniper_frelay(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
931 | 0 | { |
932 | 0 | proto_tree* juniper_subtree; |
933 | 0 | unsigned offset; |
934 | 0 | int bytes_processed; |
935 | 0 | uint8_t flags; |
936 | |
|
937 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper Frame-Relay"); |
938 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
939 | |
|
940 | 0 | offset = 0; |
941 | |
|
942 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper Frame-Relay"); |
943 | | |
944 | | /* parse header, match mgc, extract flags and build first tree */ |
945 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
946 | |
|
947 | 0 | if(bytes_processed == -1) |
948 | 0 | return 4; |
949 | 0 | else |
950 | 0 | offset+=bytes_processed; |
951 | | |
952 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_FRELAY, offset); |
953 | |
|
954 | 0 | return tvb_captured_length(tvb); |
955 | 0 | } |
956 | | |
957 | | /* C-HDLC dissector */ |
958 | | static int |
959 | | dissect_juniper_chdlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
960 | 1 | { |
961 | 1 | proto_tree* juniper_subtree; |
962 | 1 | unsigned offset = 0; |
963 | 1 | int bytes_processed; |
964 | 1 | uint8_t flags; |
965 | | |
966 | 1 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper C-HDLC"); |
967 | 1 | col_clear(pinfo->cinfo, COL_INFO); |
968 | | |
969 | 1 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper C-HDLC"); |
970 | | |
971 | | /* parse header, match mgc, extract flags and build first tree */ |
972 | 1 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
973 | | |
974 | 1 | if(bytes_processed == -1) |
975 | 0 | return 4; |
976 | 1 | else |
977 | 1 | offset+=bytes_processed; |
978 | | |
979 | 1 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_CHDLC, offset); |
980 | | |
981 | 1 | return tvb_captured_length(tvb); |
982 | 1 | } |
983 | | |
984 | | |
985 | | |
986 | | /* wrapper for passing the PIC type to the generic ATM dissector */ |
987 | | static int |
988 | | dissect_juniper_atm1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
989 | 0 | { |
990 | 0 | dissect_juniper_atm(tvb,pinfo,tree, JUNIPER_PIC_ATM1); |
991 | 0 | return tvb_captured_length(tvb); |
992 | 0 | } |
993 | | |
994 | | /* wrapper for passing the PIC type to the generic ATM dissector */ |
995 | | static int |
996 | | dissect_juniper_atm2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
997 | 1 | { |
998 | 1 | dissect_juniper_atm(tvb,pinfo,tree, JUNIPER_PIC_ATM2); |
999 | 1 | return tvb_captured_length(tvb); |
1000 | 1 | } |
1001 | | |
1002 | | /* generic ATM dissector */ |
1003 | | static void |
1004 | | dissect_juniper_atm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint16_t atm_pictype) |
1005 | 1 | { |
1006 | 1 | proto_item *ti; |
1007 | 1 | proto_tree* juniper_subtree; |
1008 | 1 | uint8_t next_proto = JUNIPER_PROTO_UNKNOWN,atm1_header_len,atm2_header_len,flags; |
1009 | 1 | uint32_t cookie1, proto; |
1010 | 1 | uint64_t cookie2; |
1011 | 1 | unsigned offset = 0; |
1012 | 1 | int bytes_processed; |
1013 | 1 | tvbuff_t *next_tvb; |
1014 | | |
1015 | 1 | col_clear(pinfo->cinfo, COL_INFO); |
1016 | | |
1017 | 1 | switch (atm_pictype) { |
1018 | 0 | case JUNIPER_PIC_ATM1: |
1019 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper ATM1"); |
1020 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, 0, 0 , ett_juniper, NULL, "Juniper ATM1 PIC"); |
1021 | 0 | break; |
1022 | 1 | case JUNIPER_PIC_ATM2: |
1023 | 1 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper ATM2"); |
1024 | 1 | juniper_subtree = proto_tree_add_subtree(tree, tvb, 0, 0 , ett_juniper, NULL, "Juniper ATM2 PIC"); |
1025 | 1 | break; |
1026 | 0 | default: /* should not happen */ |
1027 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper ATM unknown"); |
1028 | 0 | proto_tree_add_subtree(tree, tvb, 0, 0 , ett_juniper, NULL, "Juniper unknown ATM PIC"); |
1029 | 0 | return; |
1030 | 1 | } |
1031 | | |
1032 | | /* parse header, match mgc, extract flags and build first tree */ |
1033 | 1 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
1034 | 1 | if(bytes_processed == -1) |
1035 | 0 | return; |
1036 | 1 | else |
1037 | 1 | offset+=bytes_processed; |
1038 | | |
1039 | 1 | if ((flags & JUNIPER_FLAG_NO_L2) == JUNIPER_FLAG_NO_L2) { |
1040 | 0 | atm1_header_len = 4; |
1041 | 0 | atm2_header_len = 4; |
1042 | 0 | } |
1043 | 1 | else { |
1044 | 1 | atm1_header_len = 4; |
1045 | 1 | atm2_header_len = 8; |
1046 | 1 | } |
1047 | | |
1048 | 1 | cookie1 = tvb_get_ntohl(tvb, offset); |
1049 | 1 | cookie2 = tvb_get_ntoh64(tvb, offset); |
1050 | | |
1051 | 1 | if (atm_pictype == JUNIPER_PIC_ATM1) { |
1052 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_atm1_cookie, tvb, offset, 4, cookie1); |
1053 | 0 | offset += atm1_header_len; |
1054 | 0 | if ((cookie1 >> 24) == 0x80) /* OAM cell ? */ |
1055 | 0 | next_proto = JUNIPER_PROTO_OAM; |
1056 | 0 | } |
1057 | 1 | else { /* JUNIPER_PIC_ATM2 */ |
1058 | 1 | proto_tree_add_uint64(juniper_subtree, hf_juniper_atm2_cookie, tvb, offset, 8, cookie2); |
1059 | 1 | offset += atm2_header_len; |
1060 | 1 | if (cookie2 & 0x70) /* OAM cell ? */ |
1061 | 1 | next_proto = JUNIPER_PROTO_OAM; |
1062 | 1 | } |
1063 | | |
1064 | 1 | next_tvb = tvb_new_subset_remaining(tvb, offset); |
1065 | | |
1066 | 1 | if (next_proto == JUNIPER_PROTO_OAM) { |
1067 | 1 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_OAM, offset); |
1068 | 1 | return; |
1069 | 1 | } |
1070 | | |
1071 | 0 | proto = tvb_get_ntoh24(tvb, offset); /* first try: 24-Bit guess */ |
1072 | |
|
1073 | 0 | if (proto == JUNIPER_HDR_NLPID) { |
1074 | | /* |
1075 | | * This begins with something that appears to be an LLC header for |
1076 | | * OSI; is this LLC-multiplexed traffic? |
1077 | | */ |
1078 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_LLC, offset); |
1079 | 0 | return; |
1080 | 0 | } |
1081 | | |
1082 | 0 | if (proto == JUNIPER_HDR_SNAP) { |
1083 | | /* |
1084 | | * This begins with something that appears to be an LLC header for |
1085 | | * SNAP; is this LLC-multiplexed traffic? |
1086 | | */ |
1087 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_LLC_SNAP, offset); |
1088 | 0 | return; |
1089 | 0 | } |
1090 | | |
1091 | 0 | if ((flags & JUNIPER_FLAG_PKT_IN) != JUNIPER_FLAG_PKT_IN && /* ether-over-1483 encaps ? */ |
1092 | 0 | (cookie1 & JUNIPER_ATM2_GAP_COUNT_MASK) && |
1093 | 0 | atm_pictype != JUNIPER_PIC_ATM1) { |
1094 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_ETHER, offset); |
1095 | 0 | return; |
1096 | 0 | } |
1097 | | |
1098 | 0 | proto = tvb_get_ntohs(tvb, offset); /* second try: 16-Bit guess */ |
1099 | |
|
1100 | 0 | if ( ppp_heuristic_guess( (uint16_t) proto) && |
1101 | 0 | atm_pictype != JUNIPER_PIC_ATM1) { |
1102 | | /* |
1103 | | * This begins with something that appears to be a PPP protocol |
1104 | | * type; is this VC-multiplexed PPPoA? |
1105 | | * That's not supported on ATM1 PICs. |
1106 | | */ |
1107 | 0 | proto_tree_add_uint_format_value(juniper_subtree, hf_juniper_encap_type, tvb, offset, 0, 0, "VC-MUX"); |
1108 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_PPP, offset); |
1109 | 0 | return; |
1110 | 0 | } |
1111 | | |
1112 | 0 | proto = tvb_get_uint8(tvb, offset); /* third try: 8-Bit guess */ |
1113 | |
|
1114 | 0 | if ( proto == JUNIPER_HDR_LLC_UI ) { |
1115 | | /* |
1116 | | * Cisco style NLPID encaps? |
1117 | | * Is the 0x03 an LLC UI control field? |
1118 | | */ |
1119 | 0 | proto_tree_add_uint_format_value(juniper_subtree, hf_juniper_encap_type, tvb, offset, 1, 1, "Cisco NLPID"); |
1120 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_ISO, offset+1); |
1121 | 0 | return; |
1122 | 0 | } |
1123 | | |
1124 | 0 | next_proto = ip_heuristic_guess( (uint8_t) proto); |
1125 | 0 | if (next_proto != JUNIPER_PROTO_UNKNOWN) { /* last resort: VC-MUX encaps ? */ |
1126 | | /* |
1127 | | * This begins with something that might be the first byte of |
1128 | | * an IPv4 or IPv6 packet; is this VC-multiplexed IP? |
1129 | | */ |
1130 | 0 | proto_tree_add_uint_format_value(juniper_subtree, hf_juniper_encap_type, tvb, offset, 0, 2, "VC-MUX"); |
1131 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, next_proto, offset); |
1132 | 0 | return; |
1133 | 0 | } |
1134 | | |
1135 | | /* could not figure what it is */ |
1136 | 0 | ti = proto_tree_add_uint_format_value(juniper_subtree, hf_juniper_payload_type, tvb, offset, 0, 0xFFFF, "Unknown"); |
1137 | 0 | proto_item_set_len(ti, tvb_reported_length_remaining(tvb, offset)); |
1138 | 0 | call_data_dissector(next_tvb, pinfo, tree); |
1139 | 0 | } |
1140 | | |
1141 | | |
1142 | 0 | static int dissect_juniper_ggsn(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) { |
1143 | |
|
1144 | 0 | proto_tree* juniper_subtree; |
1145 | 0 | unsigned offset = 0; |
1146 | 0 | int bytes_processed; |
1147 | 0 | uint8_t flags; |
1148 | 0 | uint16_t proto; |
1149 | |
|
1150 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper GGSN"); |
1151 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1152 | |
|
1153 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper GGSN"); |
1154 | | |
1155 | | /* parse header, match mgc, extract flags and build first tree */ |
1156 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
1157 | |
|
1158 | 0 | if(bytes_processed == -1) |
1159 | 0 | return 4; |
1160 | 0 | else |
1161 | 0 | offset+=bytes_processed; |
1162 | | |
1163 | 0 | proto = tvb_get_letohs(tvb, offset); /* fetch protocol */ |
1164 | |
|
1165 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_proto, tvb, offset, 2, proto); |
1166 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_vlan, tvb, offset+2, 2, ENC_LITTLE_ENDIAN); |
1167 | 0 | offset += 4; |
1168 | |
|
1169 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, proto, offset); |
1170 | |
|
1171 | 0 | return tvb_captured_length(tvb); |
1172 | 0 | } |
1173 | | |
1174 | 0 | static int dissect_juniper_vp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) { |
1175 | |
|
1176 | 0 | proto_tree* juniper_subtree; |
1177 | 0 | unsigned offset = 0; |
1178 | 0 | int bytes_processed; |
1179 | 0 | uint8_t flags; |
1180 | |
|
1181 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper Voice PIC"); |
1182 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1183 | |
|
1184 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper Voice PIC"); |
1185 | | |
1186 | | /* parse header, match mgc, extract flags and build first tree */ |
1187 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
1188 | |
|
1189 | 0 | if(bytes_processed == -1) |
1190 | 0 | return 4; |
1191 | 0 | else |
1192 | 0 | offset+=bytes_processed; |
1193 | | |
1194 | | /* |
1195 | | * Right know IPv4 is the only protocol we may encounter. |
1196 | | * For the future there should be sufficient space in the 18-byte |
1197 | | * empty header before payload starts. |
1198 | | */ |
1199 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_IP, offset+18); |
1200 | 0 | return tvb_captured_length(tvb); |
1201 | 0 | } |
1202 | | |
1203 | | /* Wrapper for Juniper service PIC cookie dissector */ |
1204 | | static int |
1205 | | dissect_juniper_svcs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
1206 | 0 | { |
1207 | 0 | proto_tree* juniper_subtree; |
1208 | 0 | unsigned offset = 0; |
1209 | 0 | int bytes_processed = 0; |
1210 | 0 | uint8_t flags; |
1211 | |
|
1212 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "Juniper Services"); |
1213 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1214 | |
|
1215 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 4, ett_juniper, NULL, "Juniper Services cookie"); |
1216 | | |
1217 | | /* parse header, match mgc, extract flags and build first tree */ |
1218 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
1219 | |
|
1220 | 0 | if (bytes_processed == -1) |
1221 | 0 | return 4; |
1222 | 0 | else |
1223 | 0 | offset+=bytes_processed; |
1224 | | |
1225 | 0 | if (flags & JUNIPER_FLAG_PKT_IN) { |
1226 | 0 | proto_tree_add_uint(juniper_subtree, hf_juniper_proto, tvb, offset, 2, JUNIPER_PROTO_IP); |
1227 | 0 | offset += 16; |
1228 | 0 | } else { |
1229 | 0 | offset += 12; |
1230 | 0 | } |
1231 | |
|
1232 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_IP, offset); |
1233 | 0 | return tvb_captured_length(tvb); |
1234 | 0 | } |
1235 | | |
1236 | | static int dissect_juniper_vn(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) |
1237 | 0 | { |
1238 | 0 | proto_tree* juniper_subtree; |
1239 | 0 | unsigned offset = 0; |
1240 | 0 | uint32_t tlv_type, tlv_len; |
1241 | |
|
1242 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, |
1243 | 0 | "Juniper Virtual Network Information"); |
1244 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1245 | |
|
1246 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 20, |
1247 | 0 | ett_juniper, NULL, "Juniper Virtual Network Information"); |
1248 | |
|
1249 | 0 | tlv_type = tvb_get_uint8(tvb, offset); |
1250 | 0 | tlv_len = tvb_get_uint8(tvb, (offset + 1)); |
1251 | 0 | offset += VN_TLV_HDR_SIZE; |
1252 | |
|
1253 | 0 | while (tlv_type != 255) { |
1254 | |
|
1255 | 0 | switch (tlv_type) { |
1256 | 0 | case VN_TLV_HOST_IP: |
1257 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_vn_host_ip, tvb, |
1258 | 0 | offset, 4, ENC_BIG_ENDIAN); |
1259 | 0 | break; |
1260 | 0 | case VN_TLV_FLAGS: |
1261 | 0 | proto_tree_add_bitmask(juniper_subtree, tvb, offset, hf_juniper_vn_flags, ett_juniper_vn_flags, vn_flags, ENC_BIG_ENDIAN); |
1262 | 0 | break; |
1263 | 0 | case VN_TLV_SRC_VN: |
1264 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_vn_src, tvb, offset, tlv_len, ENC_ASCII); |
1265 | 0 | break; |
1266 | 0 | case VN_TLV_DST_VN: |
1267 | 0 | proto_tree_add_item(juniper_subtree, hf_juniper_vn_dst, tvb, offset, tlv_len, ENC_ASCII); |
1268 | 0 | break; |
1269 | 0 | default: |
1270 | 0 | proto_tree_add_expert(juniper_subtree, pinfo, &ei_juniper_vn_incorrect_format, tvb, 0, 0); |
1271 | 0 | return offset; |
1272 | 0 | } |
1273 | | |
1274 | 0 | offset += tlv_len; |
1275 | 0 | tlv_type = tvb_get_uint8(tvb, offset); |
1276 | 0 | tlv_len = tvb_get_uint8(tvb, (offset + 1)); |
1277 | 0 | offset += VN_TLV_HDR_SIZE; |
1278 | 0 | } |
1279 | | |
1280 | 0 | offset+=tlv_len; |
1281 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, JUNIPER_PROTO_ETHER, offset); |
1282 | |
|
1283 | 0 | return tvb_captured_length(tvb); |
1284 | 0 | } |
1285 | | static int dissect_juniper_st(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) |
1286 | 0 | { |
1287 | 0 | proto_item *ti; |
1288 | 0 | proto_tree* juniper_subtree, *eth_tree, *ip_tree, *esp_tree; |
1289 | 0 | unsigned offset = 0; |
1290 | 0 | uint8_t flags; |
1291 | 0 | uint32_t type, len, ip_proto; |
1292 | 0 | int bytes_processed; |
1293 | |
|
1294 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, |
1295 | 0 | "Juniper Secure Tunnel Information"); |
1296 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
1297 | |
|
1298 | 0 | juniper_subtree = proto_tree_add_subtree(tree, tvb, offset, 70, |
1299 | 0 | ett_juniper, NULL, "Juniper Secure Tunnel Information"); |
1300 | |
|
1301 | 0 | bytes_processed = dissect_juniper_header(tvb, pinfo, tree, juniper_subtree, &flags); |
1302 | 0 | if (bytes_processed < 1) { |
1303 | 0 | return tvb_captured_length(tvb); |
1304 | 0 | } |
1305 | | |
1306 | 0 | offset += bytes_processed; |
1307 | | |
1308 | | /* Dissect lower layers */ |
1309 | 0 | eth_tree = proto_tree_add_subtree(juniper_subtree, tvb, offset, 14, ett_juniper_st_eth, NULL, "Tunnel Ethernet Header"); |
1310 | 0 | proto_tree_add_item(eth_tree, hf_juniper_st_eth_dst, tvb, offset, 6, ENC_NA); |
1311 | 0 | offset += 6; |
1312 | 0 | proto_tree_add_item(eth_tree, hf_juniper_st_eth_src, tvb, offset, 6, ENC_NA); |
1313 | 0 | offset += 6; |
1314 | 0 | proto_tree_add_item_ret_uint(eth_tree, hf_juniper_st_eth_type, tvb, offset, 2, ENC_BIG_ENDIAN, &type); |
1315 | 0 | offset += 2; |
1316 | | /* XXX can we have a VLAN header here ?*/ |
1317 | 0 | switch (type) { |
1318 | 0 | case ETHERTYPE_IP: |
1319 | 0 | ip_tree = proto_tree_add_subtree(juniper_subtree, tvb, offset, -1, ett_juniper_st_ip, &ti, "Tunnel IP Header"); |
1320 | 0 | proto_tree_add_item_ret_uint(ip_tree, hf_juniper_st_ip_len, tvb, offset, 1, ENC_BIG_ENDIAN, &len); |
1321 | 0 | len = len * 4; |
1322 | 0 | proto_item_set_len(ti, len); |
1323 | 0 | proto_tree_add_item_ret_uint(ip_tree, hf_juniper_st_ip_proto, tvb, offset+9, 1, ENC_BIG_ENDIAN, &ip_proto); |
1324 | 0 | offset += len; |
1325 | | /* ESP is expected */ |
1326 | 0 | if (ip_proto != IP_PROTO_ESP) { |
1327 | 0 | return tvb_captured_length(tvb); |
1328 | 0 | } |
1329 | 0 | esp_tree = proto_tree_add_subtree(juniper_subtree, tvb, offset, 8, ett_juniper_st_esp, NULL, "Tunnel ESP Header"); |
1330 | 0 | proto_tree_add_item(esp_tree, hf_juniper_st_esp_spi, tvb, offset, 4, ENC_BIG_ENDIAN); |
1331 | 0 | offset += 4; |
1332 | 0 | proto_tree_add_item(esp_tree, hf_juniper_st_esp_seq, tvb, offset, 4, ENC_BIG_ENDIAN); |
1333 | 0 | offset += 4; |
1334 | | /* 16 bytes unknown data remains in example trace */ |
1335 | 0 | proto_tree_add_subtree(juniper_subtree, tvb, offset, 16, ett_juniper_st_unknown, NULL, "Tunnel Unknown Data"); |
1336 | 0 | offset += 16; |
1337 | 0 | break; |
1338 | 0 | default: |
1339 | 0 | return tvb_captured_length(tvb); |
1340 | 0 | } |
1341 | | |
1342 | 0 | dissect_juniper_payload_proto(tvb, pinfo, tree, juniper_subtree, ip_heuristic_guess(tvb_get_uint8(tvb,offset)), offset); |
1343 | |
|
1344 | 0 | return tvb_captured_length(tvb); |
1345 | |
|
1346 | 0 | } |
1347 | | |
1348 | | |
1349 | | /* list of Juniper supported PPP proto IDs */ |
1350 | | static bool |
1351 | 0 | ppp_heuristic_guess(uint16_t proto) { |
1352 | |
|
1353 | 0 | switch(proto) { |
1354 | 0 | case PPP_IP : |
1355 | 0 | case PPP_OSI : |
1356 | 0 | case PPP_MPLS_UNI : |
1357 | 0 | case PPP_MPLS_MULTI : |
1358 | 0 | case PPP_IPCP : |
1359 | 0 | case PPP_OSINLCP : |
1360 | 0 | case PPP_MPLSCP : |
1361 | 0 | case PPP_LCP : |
1362 | 0 | case PPP_PAP : |
1363 | 0 | case PPP_CHAP : |
1364 | 0 | case PPP_MP : |
1365 | 0 | case PPP_IPV6 : |
1366 | 0 | case PPP_IPV6CP : |
1367 | 0 | return true; |
1368 | | |
1369 | 0 | default: |
1370 | 0 | return false; /* did not find a ppp header */ |
1371 | 0 | } |
1372 | 0 | } |
1373 | | |
1374 | | /* |
1375 | | * return the IP version number based on the first byte of the IP header |
1376 | | * returns 0 if it does not match a valid first IPv4/IPv6 header byte |
1377 | | */ |
1378 | | static unsigned |
1379 | 0 | ip_heuristic_guess(uint8_t ip_header_byte) { |
1380 | |
|
1381 | 0 | switch(ip_header_byte) { |
1382 | 0 | case 0x45: |
1383 | 0 | case 0x46: |
1384 | 0 | case 0x47: |
1385 | 0 | case 0x48: |
1386 | 0 | case 0x49: |
1387 | 0 | case 0x4a: |
1388 | 0 | case 0x4b: |
1389 | 0 | case 0x4c: |
1390 | 0 | case 0x4d: |
1391 | 0 | case 0x4e: |
1392 | 0 | case 0x4f: |
1393 | 0 | return JUNIPER_PROTO_IP; |
1394 | 0 | case 0x60: |
1395 | 0 | case 0x61: |
1396 | 0 | case 0x62: |
1397 | 0 | case 0x63: |
1398 | 0 | case 0x64: |
1399 | 0 | case 0x65: |
1400 | 0 | case 0x66: |
1401 | 0 | case 0x67: |
1402 | 0 | case 0x68: |
1403 | 0 | case 0x69: |
1404 | 0 | case 0x6a: |
1405 | 0 | case 0x6b: |
1406 | 0 | case 0x6c: |
1407 | 0 | case 0x6d: |
1408 | 0 | case 0x6e: |
1409 | 0 | case 0x6f: |
1410 | 0 | return JUNIPER_PROTO_IP6; |
1411 | 0 | default: |
1412 | 0 | return JUNIPER_PROTO_UNKNOWN; /* did not find a ip header */ |
1413 | 0 | } |
1414 | 0 | } |
1415 | | |
1416 | | /* return cookie length dep. on cookie SVC id */ |
1417 | | static |
1418 | 0 | unsigned juniper_svc_cookie_len (uint64_t cookie) { |
1419 | |
|
1420 | 0 | uint8_t svc_cookie_id; |
1421 | 0 | svc_cookie_id = (uint8_t)(cookie >> 56) & 0xff; |
1422 | |
|
1423 | 0 | switch(svc_cookie_id) { |
1424 | 0 | case 0x54: |
1425 | 0 | return LS_PIC_COOKIE_LEN; |
1426 | 0 | case GSP_SVC_REQ_APOLLO: |
1427 | 0 | case GSP_SVC_REQ_LSQ: |
1428 | 0 | return AS_PIC_COOKIE_LEN; |
1429 | 0 | default: |
1430 | 0 | return 0; |
1431 | 0 | } |
1432 | 0 | } |
1433 | | |
1434 | | /* return the next-level protocol based on cookie input */ |
1435 | | static unsigned |
1436 | 0 | juniper_svc_cookie_proto (uint64_t cookie, uint16_t pictype, uint8_t flags) { |
1437 | |
|
1438 | 0 | uint8_t svc_cookie_id; |
1439 | 0 | uint16_t lsq_proto; |
1440 | 0 | uint8_t lsq_dir; |
1441 | |
|
1442 | 0 | svc_cookie_id = (uint8_t)(cookie >> 56) & 0xff; |
1443 | 0 | lsq_proto = (uint16_t)((cookie >> 16) & LSQ_L3_PROTO_MASK); |
1444 | 0 | lsq_dir = (uint8_t)(cookie >> 24) & 0x3; |
1445 | | |
1446 | |
|
1447 | 0 | switch (svc_cookie_id) { |
1448 | 0 | case 0x54: |
1449 | 0 | switch (pictype) { |
1450 | 0 | case JUNIPER_PIC_MLPPP: |
1451 | 0 | return JUNIPER_PROTO_PPP; |
1452 | 0 | case JUNIPER_PIC_MLFR: |
1453 | 0 | return JUNIPER_PROTO_ISO; |
1454 | 0 | default: |
1455 | 0 | return JUNIPER_PROTO_UNKNOWN; |
1456 | 0 | } |
1457 | 0 | case GSP_SVC_REQ_APOLLO: |
1458 | 0 | case GSP_SVC_REQ_LSQ: |
1459 | 0 | switch(lsq_proto) { |
1460 | 0 | case LSQ_L3_PROTO_IPV4: |
1461 | 0 | switch(pictype) { |
1462 | 0 | case JUNIPER_PIC_MLPPP: |
1463 | | /* incoming traffic would have the direction bits set |
1464 | | * -> this must be IS-IS over PPP |
1465 | | */ |
1466 | 0 | if ((flags & JUNIPER_FLAG_PKT_IN) == JUNIPER_FLAG_PKT_IN && |
1467 | 0 | lsq_dir != (LSQ_COOKIE_RE|LSQ_COOKIE_DIR)) |
1468 | 0 | return JUNIPER_PROTO_PPP; |
1469 | 0 | else |
1470 | 0 | return JUNIPER_PROTO_IP; |
1471 | 0 | case JUNIPER_PIC_MLFR: |
1472 | 0 | if (lsq_dir == (LSQ_COOKIE_RE|LSQ_COOKIE_DIR)) |
1473 | 0 | return JUNIPER_PROTO_UNKNOWN; |
1474 | 0 | else |
1475 | 0 | return JUNIPER_PROTO_IP; |
1476 | 0 | default: |
1477 | 0 | return JUNIPER_PROTO_UNKNOWN; |
1478 | 0 | } |
1479 | 0 | case LSQ_L3_PROTO_IPV6: |
1480 | 0 | return JUNIPER_PROTO_IP6; |
1481 | 0 | case LSQ_L3_PROTO_MPLS: |
1482 | 0 | return JUNIPER_PROTO_MPLS; |
1483 | 0 | case LSQ_L3_PROTO_ISO: |
1484 | 0 | return JUNIPER_PROTO_ISO; |
1485 | 0 | default: |
1486 | 0 | return JUNIPER_PROTO_UNKNOWN; |
1487 | 0 | } |
1488 | 0 | default: |
1489 | 0 | return JUNIPER_PROTO_UNKNOWN; |
1490 | 0 | } |
1491 | 0 | } |
1492 | | |
1493 | | |
1494 | | void |
1495 | | proto_register_juniper(void) |
1496 | 14 | { |
1497 | 14 | static hf_register_info hf[] = { |
1498 | 14 | { &hf_juniper_magic, |
1499 | 14 | { "Magic Number", "juniper.magic-number", FT_UINT24, BASE_HEX, |
1500 | 14 | NULL, 0x0, NULL, HFILL }}, |
1501 | 14 | { &hf_juniper_direction, |
1502 | 14 | { "Direction", "juniper.direction", FT_UINT8, BASE_HEX, |
1503 | 14 | VALS(juniper_direction_vals), 0x01, NULL, HFILL }}, |
1504 | 14 | { &hf_juniper_l2hdr_presence, |
1505 | 14 | { "L2 header presence", "juniper.l2hdr", FT_UINT8, BASE_HEX, |
1506 | 14 | VALS(juniper_l2hdr_presence_vals), 0x02, NULL, HFILL }}, |
1507 | 14 | { &hf_juniper_ext_total_len, |
1508 | 14 | { "Extension(s) Total length", "juniper.ext_total_len", FT_UINT16, BASE_DEC, |
1509 | 14 | NULL, 0x0, NULL, HFILL }}, |
1510 | 14 | { &hf_juniper_cookie_len, |
1511 | 14 | { "Cookie length", "juniper.cookie_len", FT_UINT32, BASE_DEC, |
1512 | 14 | NULL, 0x0, NULL, HFILL }}, |
1513 | 14 | { &hf_juniper_atm2_cookie, |
1514 | 14 | { "Cookie", "juniper.atm2.cookie", FT_UINT64, BASE_HEX, |
1515 | 14 | NULL, 0x0, NULL, HFILL }}, |
1516 | 14 | { &hf_juniper_atm1_cookie, |
1517 | 14 | { "Cookie", "juniper.atm1.cookie", FT_UINT32, BASE_HEX, |
1518 | 14 | NULL, 0x0, NULL, HFILL }}, |
1519 | 14 | { &hf_juniper_mlpic_cookie, |
1520 | 14 | { "Cookie", "juniper.mlpic.cookie", FT_UINT16, BASE_HEX, |
1521 | 14 | NULL, 0x0, NULL, HFILL }}, |
1522 | 14 | { &hf_juniper_lspic_cookie, |
1523 | 14 | { "Cookie", "juniper.lspic.cookie", FT_UINT32, BASE_HEX, |
1524 | 14 | NULL, 0x0, NULL, HFILL }}, |
1525 | 14 | { &hf_juniper_aspic_cookie, |
1526 | 14 | { "Cookie", "juniper.aspic.cookie", FT_UINT64, BASE_HEX, |
1527 | 14 | NULL, 0x0, NULL, HFILL }}, |
1528 | 14 | { &hf_juniper_vlan, |
1529 | 14 | { "VLan ID", "juniper.vlan", FT_UINT16, BASE_DEC, |
1530 | 14 | NULL, 0x0, NULL, HFILL }}, |
1531 | 14 | { &hf_juniper_proto, |
1532 | 14 | { "Protocol", "juniper.proto", FT_UINT16, BASE_DEC, |
1533 | 14 | VALS(juniper_proto_vals), 0x0, NULL, HFILL }}, |
1534 | 14 | { &hf_juniper_payload_type, |
1535 | 14 | { "Payload Type", "juniper.payload_type", FT_UINT16, BASE_DEC, |
1536 | 14 | VALS(juniper_proto_vals), 0x0, NULL, HFILL }}, |
1537 | 14 | { &hf_juniper_encap_type, |
1538 | 14 | { "Encapsulation Type", "juniper.encap_type", FT_UINT8, BASE_DEC, |
1539 | 14 | NULL, 0x0, NULL, HFILL }}, |
1540 | 14 | { &hf_juniper_ext_ifd, |
1541 | | /* Juniper PCAP extensions */ |
1542 | 14 | { "Device Interface Index", "juniper.ext.ifd", FT_UINT32, BASE_DEC, |
1543 | 14 | NULL, 0x0, NULL, HFILL }}, |
1544 | 14 | { &hf_juniper_ext_ifl, |
1545 | 14 | { "Logical Interface Index", "juniper.ext.ifl", FT_UINT32, BASE_DEC, |
1546 | 14 | NULL, 0x0, NULL, HFILL }}, |
1547 | 14 | { &hf_juniper_ext_unit, |
1548 | 14 | { "Logical Unit Number", "juniper.ext.unit", FT_UINT32, BASE_DEC, |
1549 | 14 | NULL, 0x0, NULL, HFILL }}, |
1550 | 14 | { &hf_juniper_ext_ifmt, |
1551 | 14 | { "Device Media Type", "juniper.ext.ifmt", FT_UINT16, BASE_DEC, |
1552 | 14 | VALS(juniper_ifmt_vals), 0x0, NULL, HFILL }}, |
1553 | 14 | { &hf_juniper_ext_ifle, |
1554 | 14 | { "Logical Interface Encapsulation", "juniper.ext.ifle", FT_UINT16, BASE_DEC, |
1555 | 14 | VALS(juniper_ifle_vals), 0x0, NULL, HFILL }}, |
1556 | 14 | { &hf_juniper_ext_ttp_ifmt, |
1557 | 14 | { "TTP derived Device Media Type", "juniper.ext.ttp_ifmt", FT_UINT16, BASE_DEC, |
1558 | 14 | VALS(juniper_ifmt_vals), 0x0, NULL, HFILL }}, |
1559 | 14 | { &hf_juniper_ext_ttp_ifle, |
1560 | 14 | { "TTP derived Logical Interface Encapsulation", "juniper.ext.ttp_ifle", FT_UINT16, BASE_DEC, |
1561 | 14 | VALS(juniper_ifle_vals), 0x0, NULL, HFILL }}, |
1562 | 14 | { &hf_juniper_unknown_data, |
1563 | 14 | { "Unknown data", "juniper.unknown_data", FT_BYTES, BASE_NONE, |
1564 | 14 | NULL, 0x0, NULL, HFILL }}, |
1565 | 14 | { &hf_juniper_vn_host_ip, |
1566 | 14 | { "Host IP", "juniper.vn.host_ip", FT_IPv4, BASE_NONE, |
1567 | 14 | NULL, 0x0, NULL, HFILL }}, |
1568 | 14 | { &hf_juniper_vn_src, |
1569 | 14 | { "Src VN", "juniper.vn.src", FT_STRING, BASE_NONE, |
1570 | 14 | NULL, 0x0, NULL, HFILL }}, |
1571 | 14 | { &hf_juniper_vn_dst, |
1572 | 14 | { "Dst VN", "juniper.vn.dst", FT_STRING, BASE_NONE, |
1573 | 14 | NULL, 0x0, NULL, HFILL }}, |
1574 | 14 | { &hf_juniper_vn_flags, |
1575 | 14 | { "Flags", "juniper.vn.flags", FT_UINT32, BASE_HEX, NULL, VN_FLAG_MASK, |
1576 | 14 | NULL, HFILL }}, |
1577 | 14 | { &hf_juniper_vn_flag_alert, |
1578 | 14 | { "Action Alert", "juniper.vn.flags.alert", FT_BOOLEAN, 32, |
1579 | 14 | TFS(&tfs_set_notset), VN_FLAG_ALERT, NULL, HFILL }}, |
1580 | 14 | { &hf_juniper_vn_flag_drop, |
1581 | 14 | { "Action Drop", "juniper.vn.flags.drop", FT_BOOLEAN, 32, |
1582 | 14 | TFS(&tfs_set_notset), VN_FLAG_DROP, NULL, HFILL }}, |
1583 | 14 | { &hf_juniper_vn_flag_deny, |
1584 | 14 | { "Action Deny", "juniper.vn.flags.deny", FT_BOOLEAN, 32, |
1585 | 14 | TFS(&tfs_set_notset), VN_FLAG_DENY, NULL, HFILL }}, |
1586 | 14 | { &hf_juniper_vn_flag_log, |
1587 | 14 | { "Action Log", "juniper.vn.flags.log", FT_BOOLEAN, 32, |
1588 | 14 | TFS(&tfs_set_notset), VN_FLAG_LOG, NULL, HFILL }}, |
1589 | 14 | { &hf_juniper_vn_flag_pass, |
1590 | 14 | { "Action Pass", "juniper.vn.flags.pass", FT_BOOLEAN, 32, |
1591 | 14 | TFS(&tfs_set_notset), VN_FLAG_PASS, NULL, HFILL }}, |
1592 | 14 | { &hf_juniper_vn_flag_reject, |
1593 | 14 | { "Action Reject", "juniper.vn.flags.reject", FT_BOOLEAN, 32, |
1594 | 14 | TFS(&tfs_set_notset), VN_FLAG_REJECT, NULL, HFILL }}, |
1595 | 14 | { &hf_juniper_vn_flag_mirror, |
1596 | 14 | { "Action Mirror", "juniper.vn.flags.mirror", FT_BOOLEAN, 32, |
1597 | 14 | TFS(&tfs_set_notset), VN_FLAG_MIRROR, NULL, HFILL }}, |
1598 | 14 | { &hf_juniper_vn_flag_direction, |
1599 | 14 | { "Direction Ingress", "juniper.vn.flags.direction", FT_BOOLEAN, 32, |
1600 | 14 | TFS(&tfs_set_notset), VN_FLAG_DIRECTION, NULL, HFILL }}, |
1601 | 14 | { &hf_juniper_st_eth_dst, |
1602 | 14 | { "Destination", "juniper.st.eth.dst", FT_ETHER, BASE_NONE, |
1603 | 14 | NULL, 0x0, NULL, HFILL }}, |
1604 | 14 | { &hf_juniper_st_eth_src, |
1605 | 14 | { "Source", "juniper.st.eth.src", FT_ETHER, BASE_NONE, |
1606 | 14 | NULL, 0x0, NULL, HFILL }}, |
1607 | 14 | { &hf_juniper_st_eth_type, |
1608 | 14 | { "Type", "juniper.st.eth.type", FT_UINT16, BASE_HEX, |
1609 | 14 | VALS(etype_vals), 0x0, NULL, HFILL }}, |
1610 | 14 | { &hf_juniper_st_ip_len, |
1611 | 14 | { "Header Length", "juniper.st.ip.len", FT_UINT8, BASE_DEC, |
1612 | 14 | NULL, 0x0f, NULL, HFILL }}, |
1613 | 14 | { &hf_juniper_st_ip_proto, |
1614 | 14 | { "Protocol", "juniper.st.ip.proto", FT_UINT8, BASE_DEC | BASE_EXT_STRING, |
1615 | 14 | &ipproto_val_ext, 0x0, NULL, HFILL }}, |
1616 | 14 | { &hf_juniper_st_esp_spi, |
1617 | 14 | { "ESP SPI", "juniper.st.esp.spi", FT_UINT32, BASE_DEC, |
1618 | 14 | NULL, 0x0, NULL, HFILL }}, |
1619 | 14 | { &hf_juniper_st_esp_seq, |
1620 | 14 | { "ESP Sequence", "juniper.st.esp.seq", FT_UINT32, BASE_DEC, |
1621 | 14 | NULL, 0x0, NULL, HFILL }}, |
1622 | | |
1623 | 14 | }; |
1624 | | |
1625 | 14 | static int *ett[] = { |
1626 | 14 | &ett_juniper, |
1627 | 14 | &ett_juniper_vn_flags, |
1628 | 14 | &ett_juniper_st_eth, |
1629 | 14 | &ett_juniper_st_ip, |
1630 | 14 | &ett_juniper_st_esp, |
1631 | 14 | &ett_juniper_st_unknown, |
1632 | 14 | }; |
1633 | | |
1634 | 14 | static ei_register_info ei[] = { |
1635 | 14 | { &ei_juniper_no_magic, { "juniper.magic-number.none", PI_PROTOCOL, PI_WARN, "No Magic-Number found!", EXPFILL }}, |
1636 | 14 | { &ei_juniper_vn_incorrect_format, { "juniper.vn.incorrect_format", PI_PROTOCOL, PI_WARN, "Incorrect format", EXPFILL }}, |
1637 | 14 | }; |
1638 | | |
1639 | 14 | expert_module_t* expert_juniper; |
1640 | | |
1641 | 14 | proto_juniper = proto_register_protocol("Juniper", "Juniper", "juniper"); |
1642 | 14 | proto_register_field_array(proto_juniper, hf, array_length(hf)); |
1643 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
1644 | 14 | expert_juniper = expert_register_protocol(proto_juniper); |
1645 | 14 | expert_register_field_array(expert_juniper, ei, array_length(ei)); |
1646 | | |
1647 | 14 | payload_table = register_dissector_table("juniper.proto", "Juniper payload dissectors", proto_juniper, FT_UINT32, BASE_HEX); |
1648 | | |
1649 | 14 | } |
1650 | | |
1651 | | void |
1652 | | proto_reg_handoff_juniper(void) |
1653 | 14 | { |
1654 | 14 | dissector_handle_t juniper_atm1_handle; |
1655 | 14 | dissector_handle_t juniper_atm2_handle; |
1656 | 14 | dissector_handle_t juniper_pppoe_handle; |
1657 | 14 | dissector_handle_t juniper_mlppp_handle; |
1658 | 14 | dissector_handle_t juniper_mlfr_handle; |
1659 | 14 | dissector_handle_t juniper_ether_handle; |
1660 | 14 | dissector_handle_t juniper_ppp_handle; |
1661 | 14 | dissector_handle_t juniper_frelay_handle; |
1662 | 14 | dissector_handle_t juniper_chdlc_handle; |
1663 | 14 | dissector_handle_t juniper_ggsn_handle; |
1664 | 14 | dissector_handle_t juniper_vp_handle; |
1665 | 14 | dissector_handle_t juniper_svcs_handle; |
1666 | 14 | dissector_handle_t juniper_vn_handle; |
1667 | 14 | dissector_handle_t juniper_st_handle; |
1668 | | |
1669 | 14 | juniper_atm2_handle = create_dissector_handle(dissect_juniper_atm2, proto_juniper); |
1670 | 14 | juniper_atm1_handle = create_dissector_handle(dissect_juniper_atm1, proto_juniper); |
1671 | 14 | juniper_pppoe_handle = create_dissector_handle(dissect_juniper_pppoe, proto_juniper); |
1672 | 14 | juniper_mlppp_handle = create_dissector_handle(dissect_juniper_mlppp, proto_juniper); |
1673 | 14 | juniper_mlfr_handle = create_dissector_handle(dissect_juniper_mlfr, proto_juniper); |
1674 | 14 | juniper_ether_handle = create_dissector_handle(dissect_juniper_ether, proto_juniper); |
1675 | 14 | juniper_ppp_handle = create_dissector_handle(dissect_juniper_ppp, proto_juniper); |
1676 | 14 | juniper_frelay_handle = create_dissector_handle(dissect_juniper_frelay, proto_juniper); |
1677 | 14 | juniper_chdlc_handle = create_dissector_handle(dissect_juniper_chdlc, proto_juniper); |
1678 | 14 | juniper_ggsn_handle = create_dissector_handle(dissect_juniper_ggsn, proto_juniper); |
1679 | 14 | juniper_vp_handle = create_dissector_handle(dissect_juniper_vp, proto_juniper); |
1680 | 14 | juniper_svcs_handle = create_dissector_handle(dissect_juniper_svcs, proto_juniper); |
1681 | 14 | juniper_vn_handle = create_dissector_handle(dissect_juniper_vn, proto_juniper); |
1682 | 14 | juniper_st_handle = create_dissector_handle(dissect_juniper_st, proto_juniper); |
1683 | | |
1684 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ATM2, juniper_atm2_handle); |
1685 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ATM1, juniper_atm1_handle); |
1686 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_PPPOE, juniper_pppoe_handle); |
1687 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_MLPPP, juniper_mlppp_handle); |
1688 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_MLFR, juniper_mlfr_handle); |
1689 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ETHER, juniper_ether_handle); |
1690 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_PPP, juniper_ppp_handle); |
1691 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_FRELAY, juniper_frelay_handle); |
1692 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_CHDLC, juniper_chdlc_handle); |
1693 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_GGSN, juniper_ggsn_handle); |
1694 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_VP, juniper_vp_handle); |
1695 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_SVCS, juniper_svcs_handle); |
1696 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_VN, juniper_vn_handle); |
1697 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_JUNIPER_ST, juniper_st_handle); |
1698 | 14 | dissector_add_for_decode_as_with_preference("udp.port", juniper_vn_handle); |
1699 | 14 | } |
1700 | | |
1701 | | |
1702 | | /* |
1703 | | * Editor modelines |
1704 | | * |
1705 | | * Local Variables: |
1706 | | * c-basic-offset: 2 |
1707 | | * tab-width: 8 |
1708 | | * indent-tabs-mode: nil |
1709 | | * End: |
1710 | | * |
1711 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
1712 | | * :indentSize=2:tabSize=8:noTabs=true: |
1713 | | */ |