HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-ppi.c
blob29e12a318c3e7c39c35733d7bdfbe668fbfaf470
1 /*
2 * packet-ppi.c
3 * Routines for PPI Packet Header dissection
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 2007 Gerald Combs
11 * Copyright (c) 2006 CACE Technologies, Davis (California)
12 * All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of the project nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
43 * Dustin Johnson - Dustin@Dustinj.us, Dustin.Johnson@cacetech.com
44 * May 7, 2008 - Added 'Aggregation Extension' and '802.3 Extension'
48 #include "config.h"
50 #include <glib.h>
52 #include <epan/packet.h>
53 #include <epan/exceptions.h>
54 #include <epan/ptvcursor.h>
55 #include <epan/prefs.h>
56 #include <epan/expert.h>
57 #include <epan/reassemble.h>
58 #include <epan/frequency-utils.h>
59 #include <epan/wmem/wmem.h>
60 #include <wsutil/pint.h>
62 /* Needed for wtap_pcap_encap_to_wtap_encap(). */
63 #include <wiretap/pcap-encap.h>
65 #include "packet-frame.h"
66 #include "packet-eth.h"
67 #include "packet-ieee80211.h"
68 #include "packet-ppi.h"
71 * Per-Packet Information (PPI) header.
72 * See the PPI Packet Header documentation at http://www.cacetech.com/documents
73 * for details.
77 * PPI headers have the following format:
79 * ,---------------------------------------------------------.
80 * | PPH | PFH 1 | Field data 1 | PFH 2 | Field data 2 | ... |
81 * `---------------------------------------------------------'
83 * The PPH struct has the following format:
85 * typedef struct ppi_packetheader {
86 * guint8 pph_version; // Version. Currently 0
87 * guint8 pph_flags; // Flags.
88 * guint16 pph_len; // Length of entire message, including this header and TLV payload.
89 * guint32 pph_dlt; // libpcap Data Link Type of the captured packet data.
90 * } ppi_packetheader_t;
92 * The PFH struct has the following format:
94 * typedef struct ppi_fieldheader {
95 * guint16 pfh_type; // Type
96 * guint16 pfh_datalen; // Length of data
97 * } ppi_fieldheader_t;
99 * Anyone looking to add their own PPI dissector would probably do well to imitate the GPS
100 * ones separation into a distinct file. Here is a step by step guide:
101 * 1) add the number you received to the enum ppi_field_type declaration.
102 * 2) Add a value string for your number into vs_ppi_field_type
103 * 3) declare a dissector handle by the ppi_gps_handle, and initialize it inside proto_reg_handoff
104 * 4) add case inside dissect_ppi to call your new handle.
105 * 5) Write your parser, and get it loaded.
106 * Following these steps will result in less churn inside the ppi proper parser, and avoid namespace issues.
110 #define PPI_PADDED (1 << 0)
112 #define PPI_V0_HEADER_LEN 8
113 #define PPI_80211_COMMON_LEN 20
114 #define PPI_80211N_MAC_LEN 12
115 #define PPI_80211N_MAC_PHY_OFF 9
116 #define PPI_80211N_MAC_PHY_LEN 48
117 #define PPI_AGGREGATION_EXTENSION_LEN 4
118 #define PPI_8023_EXTENSION_LEN 8
120 #define PPI_FLAG_ALIGN 0x01
121 #define IS_PPI_FLAG_ALIGN(x) ((x) & PPI_FLAG_ALIGN)
123 #define DOT11_FLAG_HAVE_FCS 0x0001
125 #define DOT11N_FLAG_IS_AGGREGATE 0x0010
126 #define DOT11N_FLAG_MORE_AGGREGATES 0x0020
127 #define DOT11N_FLAG_AGG_CRC_ERROR 0x0040
129 #define DOT11N_IS_AGGREGATE(flags) (flags & DOT11N_FLAG_IS_AGGREGATE)
130 #define DOT11N_MORE_AGGREGATES(flags) ( \
131 (flags & DOT11N_FLAG_MORE_AGGREGATES) && \
132 !(flags & DOT11N_FLAG_AGG_CRC_ERROR))
133 #define AGGREGATE_MAX 65535
134 #define AMPDU_MAX 16383
136 /* XXX - Start - Copied from packet-radiotap.c */
137 /* Channel flags. */
138 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
139 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
140 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
141 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
142 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
143 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
144 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
145 #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
148 * Useful combinations of channel characteristics.
150 #define IEEE80211_CHAN_FHSS \
151 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
152 #define IEEE80211_CHAN_A \
153 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
154 #define IEEE80211_CHAN_B \
155 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
156 #define IEEE80211_CHAN_PUREG \
157 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
158 #define IEEE80211_CHAN_G \
159 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
160 #define IEEE80211_CHAN_T \
161 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
162 #define IEEE80211_CHAN_108G \
163 (IEEE80211_CHAN_G | IEEE80211_CHAN_TURBO)
164 #define IEEE80211_CHAN_108PUREG \
165 (IEEE80211_CHAN_PUREG | IEEE80211_CHAN_TURBO)
166 /* XXX - End - Copied from packet-radiotap.c */
168 typedef enum {
169 /* 0 - 29999: Public types */
170 PPI_80211_COMMON = 2,
171 PPI_80211N_MAC = 3,
172 PPI_80211N_MAC_PHY = 4,
173 PPI_SPECTRUM_MAP = 5,
174 PPI_PROCESS_INFO = 6,
175 PPI_CAPTURE_INFO = 7,
176 PPI_AGGREGATION_EXTENSION = 8,
177 PPI_8023_EXTENSION = 9,
178 /* 11 - 29999: RESERVED */
180 /* 30000 - 65535: Private types */
181 INTEL_CORP_PRIVATE = 30000,
182 MOHAMED_THAGA_PRIVATE = 30001,
183 PPI_GPS_INFO = 30002, /* 30002 - 30005 described in PPI-GEOLOCATION specifcation */
184 PPI_VECTOR_INFO = 30003, /* currently available in draft from. jellch@harris.com */
185 PPI_SENSOR_INFO = 30004,
186 PPI_ANTENNA_INFO = 30005,
187 CACE_PRIVATE = 0xCACE
188 /* All others RESERVED. Contact the WinPcap team for an assignment */
189 } ppi_field_type;
191 /* Protocol */
192 static int proto_ppi = -1;
194 /* Packet header */
195 static int hf_ppi_head_version = -1;
196 static int hf_ppi_head_flags = -1;
197 static int hf_ppi_head_flag_alignment = -1;
198 static int hf_ppi_head_flag_reserved = -1;
199 static int hf_ppi_head_len = -1;
200 static int hf_ppi_head_dlt = -1;
202 /* Field header */
203 static int hf_ppi_field_type = -1;
204 static int hf_ppi_field_len = -1;
206 /* 802.11 Common */
207 static int hf_80211_common_tsft = -1;
208 static int hf_80211_common_flags = -1;
209 static int hf_80211_common_flags_fcs = -1;
210 static int hf_80211_common_flags_tsft = -1;
211 static int hf_80211_common_flags_fcs_valid = -1;
212 static int hf_80211_common_flags_phy_err = -1;
213 static int hf_80211_common_rate = -1;
214 static int hf_80211_common_chan_freq = -1;
215 static int hf_80211_common_chan_flags = -1;
217 static int hf_80211_common_chan_flags_turbo = -1;
218 static int hf_80211_common_chan_flags_cck = -1;
219 static int hf_80211_common_chan_flags_ofdm = -1;
220 static int hf_80211_common_chan_flags_2ghz = -1;
221 static int hf_80211_common_chan_flags_5ghz = -1;
222 static int hf_80211_common_chan_flags_passive = -1;
223 static int hf_80211_common_chan_flags_dynamic = -1;
224 static int hf_80211_common_chan_flags_gfsk = -1;
226 static int hf_80211_common_fhss_hopset = -1;
227 static int hf_80211_common_fhss_pattern = -1;
228 static int hf_80211_common_dbm_antsignal = -1;
229 static int hf_80211_common_dbm_antnoise = -1;
231 /* 802.11n MAC */
232 static int hf_80211n_mac_flags = -1;
233 static int hf_80211n_mac_flags_greenfield = -1;
234 static int hf_80211n_mac_flags_ht20_40 = -1;
235 static int hf_80211n_mac_flags_rx_guard_interval = -1;
236 static int hf_80211n_mac_flags_duplicate_rx = -1;
237 static int hf_80211n_mac_flags_more_aggregates = -1;
238 static int hf_80211n_mac_flags_aggregate = -1;
239 static int hf_80211n_mac_flags_delimiter_crc_after = -1;
240 static int hf_80211n_mac_ampdu_id = -1;
241 static int hf_80211n_mac_num_delimiters = -1;
242 static int hf_80211n_mac_reserved = -1;
244 /* 802.11n MAC+PHY */
245 static int hf_80211n_mac_phy_mcs = -1;
246 static int hf_80211n_mac_phy_num_streams = -1;
247 static int hf_80211n_mac_phy_rssi_combined = -1;
248 static int hf_80211n_mac_phy_rssi_ant0_ctl = -1;
249 static int hf_80211n_mac_phy_rssi_ant1_ctl = -1;
250 static int hf_80211n_mac_phy_rssi_ant2_ctl = -1;
251 static int hf_80211n_mac_phy_rssi_ant3_ctl = -1;
252 static int hf_80211n_mac_phy_rssi_ant0_ext = -1;
253 static int hf_80211n_mac_phy_rssi_ant1_ext = -1;
254 static int hf_80211n_mac_phy_rssi_ant2_ext = -1;
255 static int hf_80211n_mac_phy_rssi_ant3_ext = -1;
256 static int hf_80211n_mac_phy_ext_chan_freq = -1;
257 static int hf_80211n_mac_phy_ext_chan_flags = -1;
258 static int hf_80211n_mac_phy_ext_chan_flags_turbo = -1;
259 static int hf_80211n_mac_phy_ext_chan_flags_cck = -1;
260 static int hf_80211n_mac_phy_ext_chan_flags_ofdm = -1;
261 static int hf_80211n_mac_phy_ext_chan_flags_2ghz = -1;
262 static int hf_80211n_mac_phy_ext_chan_flags_5ghz = -1;
263 static int hf_80211n_mac_phy_ext_chan_flags_passive = -1;
264 static int hf_80211n_mac_phy_ext_chan_flags_dynamic = -1;
265 static int hf_80211n_mac_phy_ext_chan_flags_gfsk = -1;
266 static int hf_80211n_mac_phy_dbm_ant0signal = -1;
267 static int hf_80211n_mac_phy_dbm_ant0noise = -1;
268 static int hf_80211n_mac_phy_dbm_ant1signal = -1;
269 static int hf_80211n_mac_phy_dbm_ant1noise = -1;
270 static int hf_80211n_mac_phy_dbm_ant2signal = -1;
271 static int hf_80211n_mac_phy_dbm_ant2noise = -1;
272 static int hf_80211n_mac_phy_dbm_ant3signal = -1;
273 static int hf_80211n_mac_phy_dbm_ant3noise = -1;
274 static int hf_80211n_mac_phy_evm0 = -1;
275 static int hf_80211n_mac_phy_evm1 = -1;
276 static int hf_80211n_mac_phy_evm2 = -1;
277 static int hf_80211n_mac_phy_evm3 = -1;
279 /* 802.11n-Extensions A-MPDU fragments */
280 static int hf_ampdu_reassembled_in = -1;
281 /* static int hf_ampdu_segments = -1; */
282 static int hf_ampdu_segment = -1;
283 static int hf_ampdu_count = -1;
285 /* Spectrum-Map */
286 static int hf_spectrum_map = -1;
288 /* Process-Info */
289 static int hf_process_info = -1;
291 /* Capture-Info */
292 static int hf_capture_info = -1;
294 /* Aggregation Extension */
295 static int hf_aggregation_extension_interface_id = -1;
297 /* 802.3 Extension */
298 static int hf_8023_extension_flags = -1;
299 static int hf_8023_extension_flags_fcs_present = -1;
300 static int hf_8023_extension_errors = -1;
301 static int hf_8023_extension_errors_fcs = -1;
302 static int hf_8023_extension_errors_sequence = -1;
303 static int hf_8023_extension_errors_symbol = -1;
304 static int hf_8023_extension_errors_data = -1;
306 /* Generated from convert_proto_tree_add_text.pl */
307 static int hf_ppi_antenna = -1;
308 static int hf_ppi_harris = -1;
309 static int hf_ppi_reserved = -1;
310 static int hf_ppi_vector = -1;
311 static int hf_ppi_gps = -1;
313 static gint ett_ppi_pph = -1;
314 static gint ett_ppi_flags = -1;
315 static gint ett_dot11_common = -1;
316 static gint ett_dot11_common_flags = -1;
317 static gint ett_dot11_common_channel_flags = -1;
318 static gint ett_dot11n_mac = -1;
319 static gint ett_dot11n_mac_flags = -1;
320 static gint ett_dot11n_mac_phy = -1;
321 static gint ett_dot11n_mac_phy_ext_channel_flags = -1;
322 static gint ett_ampdu_segments = -1;
323 static gint ett_ampdu = -1;
324 static gint ett_ampdu_segment = -1;
325 static gint ett_aggregation_extension = -1;
326 static gint ett_8023_extension = -1;
327 static gint ett_8023_extension_flags = -1;
328 static gint ett_8023_extension_errors = -1;
330 /* Generated from convert_proto_tree_add_text.pl */
331 static expert_field ei_ppi_invalid_length = EI_INIT;
333 static dissector_handle_t ppi_handle;
335 static dissector_handle_t data_handle;
336 static dissector_handle_t ieee80211_ht_handle;
337 static dissector_handle_t ppi_gps_handle, ppi_vector_handle, ppi_sensor_handle, ppi_antenna_handle;
339 static const true_false_string tfs_ppi_head_flag_alignment = { "32-bit aligned", "Not aligned" };
340 static const true_false_string tfs_tsft_ms = { "milliseconds", "microseconds" };
341 static const true_false_string tfs_ht20_40 = { "HT40", "HT20" };
342 static const true_false_string tfs_invalid_valid = { "Invalid", "Valid" };
343 static const true_false_string tfs_phy_error = { "PHY error", "No errors"};
345 static const value_string vs_ppi_field_type[] = {
346 {PPI_80211_COMMON, "802.11-Common"},
347 {PPI_80211N_MAC, "802.11n MAC Extensions"},
348 {PPI_80211N_MAC_PHY, "802.11n MAC+PHY Extensions"},
349 {PPI_SPECTRUM_MAP, "Spectrum-Map"},
350 {PPI_PROCESS_INFO, "Process-Info"},
351 {PPI_CAPTURE_INFO, "Capture-Info"},
352 {PPI_AGGREGATION_EXTENSION, "Aggregation Extension"},
353 {PPI_8023_EXTENSION, "802.3 Extension"},
355 {INTEL_CORP_PRIVATE, "Intel Corporation (private)"},
356 {MOHAMED_THAGA_PRIVATE, "Mohamed Thaga (private)"},
357 {PPI_GPS_INFO, "GPS Tagging"},
358 {PPI_VECTOR_INFO, "Vector Tagging"},
359 {PPI_SENSOR_INFO, "Sensor tagging"},
360 {PPI_ANTENNA_INFO, "Antenna Tagging"},
361 {CACE_PRIVATE, "CACE Technologies (private)"},
362 {0, NULL}
365 /* XXX - Start - Copied from packet-radiotap.c */
366 static const value_string vs_80211_common_phy_type[] = {
367 { 0, "Unknown" },
368 { IEEE80211_CHAN_A, "802.11a" },
369 { IEEE80211_CHAN_B, "802.11b" },
370 { IEEE80211_CHAN_PUREG, "802.11g (pure-g)" },
371 { IEEE80211_CHAN_G, "802.11g" },
372 { IEEE80211_CHAN_T, "802.11a (turbo)" },
373 { IEEE80211_CHAN_108PUREG, "802.11g (pure-g, turbo)" },
374 { IEEE80211_CHAN_108G, "802.11g (turbo)" },
375 { IEEE80211_CHAN_FHSS, "FHSS" },
376 { 0, NULL },
378 /* XXX - End - Copied from packet-radiotap.c */
380 /* Table for A-MPDU reassembly */
381 static reassembly_table ampdu_reassembly_table;
383 /* Reassemble A-MPDUs? */
384 static gboolean ppi_ampdu_reassemble = TRUE;
387 void
388 capture_ppi(const guchar *pd, int len, packet_counts *ld)
390 guint32 dlt;
391 guint ppi_len, data_type, data_len;
392 guint offset = PPI_V0_HEADER_LEN;
393 gboolean is_htc = FALSE;
395 ppi_len = pletohs(pd+2);
396 if(ppi_len < PPI_V0_HEADER_LEN || !BYTES_ARE_IN_FRAME(0, len, ppi_len)) {
397 ld->other++;
398 return;
401 dlt = pletohl(pd+4);
403 /* Figure out if we're +HTC */
404 while (offset < ppi_len) {
405 data_type = pletohs(pd+offset);
406 data_len = pletohs(pd+offset+2) + 4;
407 offset += data_len;
409 if (data_type == PPI_80211N_MAC || data_type == PPI_80211N_MAC_PHY) {
410 is_htc = TRUE;
411 break;
415 /* XXX - We should probably combine this with capture_info.c:capture_info_packet() */
416 switch(dlt) {
417 case 1: /* DLT_EN10MB */
418 capture_eth(pd, ppi_len, len, ld);
419 return;
420 case 105: /* DLT_DLT_IEEE802_11 */
421 if (is_htc)
422 capture_ieee80211_ht(pd, ppi_len, len, ld);
423 else
424 capture_ieee80211(pd, ppi_len, len, ld);
425 return;
426 default:
427 break;
430 ld->other++;
433 static void
434 ptvcursor_add_invalid_check(ptvcursor_t *csr, int hf, gint len, guint64 invalid_val) {
435 proto_item *ti;
436 guint64 val = invalid_val;
438 switch (len) {
439 case 8:
440 val = tvb_get_letoh64(ptvcursor_tvbuff(csr),
441 ptvcursor_current_offset(csr));
442 break;
443 case 4:
444 val = tvb_get_letohl(ptvcursor_tvbuff(csr),
445 ptvcursor_current_offset(csr));
446 break;
447 case 2:
448 val = tvb_get_letohs(ptvcursor_tvbuff(csr),
449 ptvcursor_current_offset(csr));
450 break;
451 case 1:
452 val = tvb_get_guint8(ptvcursor_tvbuff(csr),
453 ptvcursor_current_offset(csr));
454 break;
455 default:
456 DISSECTOR_ASSERT_NOT_REACHED();
459 ti = ptvcursor_add(csr, hf, len, ENC_LITTLE_ENDIAN);
460 if (val == invalid_val)
461 proto_item_append_text(ti, " [invalid]");
464 static void
465 add_ppi_field_header(tvbuff_t *tvb, proto_tree *tree, int *offset)
467 ptvcursor_t *csr;
469 csr = ptvcursor_new(tree, tvb, *offset);
470 ptvcursor_add(csr, hf_ppi_field_type, 2, ENC_LITTLE_ENDIAN);
471 ptvcursor_add(csr, hf_ppi_field_len, 2, ENC_LITTLE_ENDIAN);
472 ptvcursor_free(csr);
473 *offset=ptvcursor_current_offset(csr);
476 /* XXX - The main dissection function in the 802.11 dissector has the same name. */
477 static void
478 dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len)
480 proto_tree *ftree = NULL;
481 proto_item *ti = NULL;
482 ptvcursor_t *csr;
483 gint rate_kbps;
484 guint32 common_flags;
485 guint16 common_frequency;
486 gchar *chan_str;
488 ti = proto_tree_add_text(tree, tvb, offset, data_len, "802.11-Common");
489 ftree = proto_item_add_subtree(ti, ett_dot11_common);
490 add_ppi_field_header(tvb, ftree, &offset);
491 data_len -= 4; /* Subtract field header length */
493 if (data_len != PPI_80211_COMMON_LEN) {
494 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
495 THROW(ReportedBoundsError);
498 common_flags = tvb_get_letohs(tvb, offset + 8);
499 if (common_flags & DOT11_FLAG_HAVE_FCS)
500 pinfo->pseudo_header->ieee_802_11.fcs_len = 4;
501 else
502 pinfo->pseudo_header->ieee_802_11.fcs_len = 0;
504 csr = ptvcursor_new(ftree, tvb, offset);
506 ptvcursor_add_invalid_check(csr, hf_80211_common_tsft, 8, 0);
508 ptvcursor_add_with_subtree(csr, hf_80211_common_flags, 2, ENC_LITTLE_ENDIAN,
509 ett_dot11_common_flags);
510 ptvcursor_add_no_advance(csr, hf_80211_common_flags_fcs, 2, ENC_LITTLE_ENDIAN);
511 ptvcursor_add_no_advance(csr, hf_80211_common_flags_tsft, 2, ENC_LITTLE_ENDIAN);
512 ptvcursor_add_no_advance(csr, hf_80211_common_flags_fcs_valid, 2, ENC_LITTLE_ENDIAN);
513 ptvcursor_add(csr, hf_80211_common_flags_phy_err, 2, ENC_LITTLE_ENDIAN);
514 ptvcursor_pop_subtree(csr);
516 rate_kbps = tvb_get_letohs(tvb, ptvcursor_current_offset(csr)) * 500;
517 ti = proto_tree_add_uint_format(ftree, hf_80211_common_rate, tvb,
518 ptvcursor_current_offset(csr), 2, rate_kbps, "Rate: %.1f Mbps",
519 rate_kbps / 1000.0);
520 if (rate_kbps == 0)
521 proto_item_append_text(ti, " [invalid]");
522 col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%.1f Mbps", rate_kbps / 1000.0);
523 ptvcursor_advance(csr, 2);
525 common_frequency = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
526 chan_str = ieee80211_mhz_to_str(common_frequency);
527 proto_tree_add_uint_format_value(ptvcursor_tree(csr), hf_80211_common_chan_freq, ptvcursor_tvbuff(csr),
528 ptvcursor_current_offset(csr), 2, common_frequency, "%s", chan_str);
529 col_add_fstr(pinfo->cinfo, COL_FREQ_CHAN, "%s", chan_str);
530 g_free(chan_str);
531 ptvcursor_advance(csr, 2);
533 ptvcursor_add_with_subtree(csr, hf_80211_common_chan_flags, 2, ENC_LITTLE_ENDIAN,
534 ett_dot11_common_channel_flags);
535 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_turbo, 2, ENC_LITTLE_ENDIAN);
536 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_cck, 2, ENC_LITTLE_ENDIAN);
537 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_ofdm, 2, ENC_LITTLE_ENDIAN);
538 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_2ghz, 2, ENC_LITTLE_ENDIAN);
539 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_5ghz, 2, ENC_LITTLE_ENDIAN);
540 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_passive, 2, ENC_LITTLE_ENDIAN);
541 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_dynamic, 2, ENC_LITTLE_ENDIAN);
542 ptvcursor_add(csr, hf_80211_common_chan_flags_gfsk, 2, ENC_LITTLE_ENDIAN);
543 ptvcursor_pop_subtree(csr);
546 ptvcursor_add(csr, hf_80211_common_fhss_hopset, 1, ENC_LITTLE_ENDIAN);
547 ptvcursor_add(csr, hf_80211_common_fhss_pattern, 1, ENC_LITTLE_ENDIAN);
549 col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm",
550 (gint8) tvb_get_guint8(tvb, ptvcursor_current_offset(csr)));
552 ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antsignal, 1, 0x80); /* -128 */
553 ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antnoise, 1, 0x80);
555 ptvcursor_free(csr);
558 static void
559 dissect_80211n_mac(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int data_len, gboolean add_subtree, guint32 *n_mac_flags, guint32 *ampdu_id)
561 proto_tree *ftree = tree;
562 proto_item *ti = NULL;
563 ptvcursor_t *csr;
564 int subtree_off = add_subtree ? 4 : 0;
566 *n_mac_flags = tvb_get_letohl(tvb, offset + subtree_off);
567 *ampdu_id = tvb_get_letohl(tvb, offset + 4 + subtree_off);
569 if (add_subtree) {
570 ti = proto_tree_add_text(tree, tvb, offset, data_len, "802.11n MAC");
571 ftree = proto_item_add_subtree(ti, ett_dot11n_mac);
572 add_ppi_field_header(tvb, ftree, &offset);
573 data_len -= 4; /* Subtract field header length */
576 if (data_len != PPI_80211N_MAC_LEN) {
577 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
578 THROW(ReportedBoundsError);
581 csr = ptvcursor_new(ftree, tvb, offset);
583 ptvcursor_add_with_subtree(csr, hf_80211n_mac_flags, 4, ENC_LITTLE_ENDIAN,
584 ett_dot11n_mac_flags);
585 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_greenfield, 4, ENC_LITTLE_ENDIAN);
586 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_ht20_40, 4, ENC_LITTLE_ENDIAN);
587 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_rx_guard_interval, 4, ENC_LITTLE_ENDIAN);
588 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_duplicate_rx, 4, ENC_LITTLE_ENDIAN);
589 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_aggregate, 4, ENC_LITTLE_ENDIAN);
590 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_more_aggregates, 4, ENC_LITTLE_ENDIAN);
591 ptvcursor_add(csr, hf_80211n_mac_flags_delimiter_crc_after, 4, ENC_LITTLE_ENDIAN); /* Last */
592 ptvcursor_pop_subtree(csr);
594 ptvcursor_add(csr, hf_80211n_mac_ampdu_id, 4, ENC_LITTLE_ENDIAN);
595 ptvcursor_add(csr, hf_80211n_mac_num_delimiters, 1, ENC_LITTLE_ENDIAN);
597 if (add_subtree) {
598 ptvcursor_add(csr, hf_80211n_mac_reserved, 3, ENC_LITTLE_ENDIAN);
601 ptvcursor_free(csr);
604 static void
605 dissect_80211n_mac_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len, guint32 *n_mac_flags, guint32 *ampdu_id)
607 proto_tree *ftree = NULL;
608 proto_item *ti = NULL;
609 ptvcursor_t *csr;
610 guint16 ext_frequency;
611 gchar *chan_str;
613 ti = proto_tree_add_text(tree, tvb, offset, data_len, "802.11n MAC+PHY");
614 ftree = proto_item_add_subtree(ti, ett_dot11n_mac_phy);
615 add_ppi_field_header(tvb, ftree, &offset);
616 data_len -= 4; /* Subtract field header length */
618 if (data_len != PPI_80211N_MAC_PHY_LEN) {
619 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
620 THROW(ReportedBoundsError);
623 dissect_80211n_mac(tvb, pinfo, ftree, offset, PPI_80211N_MAC_LEN,
624 FALSE, n_mac_flags, ampdu_id);
625 offset += PPI_80211N_MAC_PHY_OFF;
627 csr = ptvcursor_new(ftree, tvb, offset);
629 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_mcs, 1, 255);
630 ti = ptvcursor_add(csr, hf_80211n_mac_phy_num_streams, 1, ENC_LITTLE_ENDIAN);
631 if (tvb_get_guint8(tvb, ptvcursor_current_offset(csr) - 1) == 0)
632 proto_item_append_text(ti, " (unknown)");
633 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_combined, 1, 255);
634 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant0_ctl, 1, 255);
635 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant1_ctl, 1, 255);
636 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant2_ctl, 1, 255);
637 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant3_ctl, 1, 255);
638 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant0_ext, 1, 255);
639 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant1_ext, 1, 255);
640 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant2_ext, 1, 255);
641 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant3_ext, 1, 255);
643 ext_frequency = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
644 chan_str = ieee80211_mhz_to_str(ext_frequency);
645 proto_tree_add_uint_format(ptvcursor_tree(csr), hf_80211n_mac_phy_ext_chan_freq, ptvcursor_tvbuff(csr),
646 ptvcursor_current_offset(csr), 2, ext_frequency, "Ext. Channel frequency: %s", chan_str);
647 g_free(chan_str);
648 ptvcursor_advance(csr, 2);
650 ptvcursor_add_with_subtree(csr, hf_80211n_mac_phy_ext_chan_flags, 2, ENC_LITTLE_ENDIAN,
651 ett_dot11n_mac_phy_ext_channel_flags);
652 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_turbo, 2, ENC_LITTLE_ENDIAN);
653 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_cck, 2, ENC_LITTLE_ENDIAN);
654 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_ofdm, 2, ENC_LITTLE_ENDIAN);
655 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_2ghz, 2, ENC_LITTLE_ENDIAN);
656 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_5ghz, 2, ENC_LITTLE_ENDIAN);
657 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_passive, 2, ENC_LITTLE_ENDIAN);
658 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_dynamic, 2, ENC_LITTLE_ENDIAN);
659 ptvcursor_add(csr, hf_80211n_mac_phy_ext_chan_flags_gfsk, 2, ENC_LITTLE_ENDIAN);
660 ptvcursor_pop_subtree(csr);
662 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant0signal, 1, 0x80); /* -128 */
663 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant0noise, 1, 0x80);
664 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant1signal, 1, 0x80);
665 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant1noise, 1, 0x80);
666 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant2signal, 1, 0x80);
667 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant2noise, 1, 0x80);
668 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant3signal, 1, 0x80);
669 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant3noise, 1, 0x80);
670 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm0, 4, 0);
671 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm1, 4, 0);
672 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm2, 4, 0);
673 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm3, 4, 0);
675 ptvcursor_free(csr);
678 static void
679 dissect_aggregation_extension(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int data_len)
681 proto_tree *ftree = tree;
682 proto_item *ti = NULL;
683 ptvcursor_t *csr;
685 ti = proto_tree_add_text(tree, tvb, offset, data_len, "Aggregation Extension");
686 ftree = proto_item_add_subtree(ti, ett_aggregation_extension);
687 add_ppi_field_header(tvb, ftree, &offset);
688 data_len -= 4; /* Subtract field header length */
690 if (data_len != PPI_AGGREGATION_EXTENSION_LEN) {
691 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
692 THROW(ReportedBoundsError);
695 csr = ptvcursor_new(ftree, tvb, offset);
697 ptvcursor_add(csr, hf_aggregation_extension_interface_id, 4, ENC_LITTLE_ENDIAN); /* Last */
698 ptvcursor_free(csr);
701 static void
702 dissect_8023_extension(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, int data_len)
704 proto_tree *ftree = tree;
705 proto_item *ti = NULL;
706 ptvcursor_t *csr;
708 ti = proto_tree_add_text(tree, tvb, offset, data_len, "802.3 Extension");
709 ftree = proto_item_add_subtree(ti, ett_8023_extension);
710 add_ppi_field_header(tvb, ftree, &offset);
711 data_len -= 4; /* Subtract field header length */
713 if (data_len != PPI_8023_EXTENSION_LEN) {
714 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
715 THROW(ReportedBoundsError);
718 csr = ptvcursor_new(ftree, tvb, offset);
720 ptvcursor_add_with_subtree(csr, hf_8023_extension_flags, 4, ENC_LITTLE_ENDIAN, ett_8023_extension_flags);
721 ptvcursor_add(csr, hf_8023_extension_flags_fcs_present, 4, ENC_LITTLE_ENDIAN);
722 ptvcursor_pop_subtree(csr);
724 ptvcursor_add_with_subtree(csr, hf_8023_extension_errors, 4, ENC_LITTLE_ENDIAN, ett_8023_extension_errors);
725 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_fcs, 4, ENC_LITTLE_ENDIAN);
726 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_sequence, 4, ENC_LITTLE_ENDIAN);
727 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_symbol, 4, ENC_LITTLE_ENDIAN);
728 ptvcursor_add(csr, hf_8023_extension_errors_data, 4, ENC_LITTLE_ENDIAN);
729 ptvcursor_pop_subtree(csr);
731 ptvcursor_free(csr);
735 #define PADDING4(x) ((((x + 3) >> 2) << 2) - x)
736 #define ADD_BASIC_TAG(hf_tag) \
737 if (tree) \
738 proto_tree_add_item(ppi_tree, hf_tag, tvb, offset, data_len, ENC_NA)
740 static void
741 dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
743 proto_tree *ppi_tree = NULL, *ppi_flags_tree = NULL, *seg_tree = NULL, *ampdu_tree = NULL;
744 proto_tree *agg_tree = NULL;
745 proto_item *ti = NULL;
746 tvbuff_t *next_tvb;
747 int offset = 0;
748 guint version, flags;
749 gint tot_len, data_len;
750 guint data_type;
751 guint32 dlt;
752 guint32 n_ext_flags = 0;
753 guint32 ampdu_id = 0;
754 fragment_head *fd_head = NULL;
755 fragment_item *ft_fdh = NULL;
756 gint mpdu_count = 0;
757 gchar *mpdu_str;
758 gboolean first_mpdu = TRUE;
759 guint last_frame = 0;
760 gboolean is_ht = FALSE;
761 gint len_remain, /*pad_len = 0,*/ ampdu_len = 0;
763 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPI");
764 col_clear(pinfo->cinfo, COL_INFO);
766 version = tvb_get_guint8(tvb, offset);
767 flags = tvb_get_guint8(tvb, offset + 1);
769 tot_len = tvb_get_letohs(tvb, offset+2);
770 dlt = tvb_get_letohl(tvb, offset+4);
772 col_add_fstr(pinfo->cinfo, COL_INFO, "PPI version %u, %u bytes",
773 version, tot_len);
775 /* Dissect the packet */
776 if (tree) {
777 ti = proto_tree_add_protocol_format(tree, proto_ppi,
778 tvb, 0, tot_len, "PPI version %u, %u bytes", version, tot_len);
779 ppi_tree = proto_item_add_subtree(ti, ett_ppi_pph);
780 proto_tree_add_item(ppi_tree, hf_ppi_head_version,
781 tvb, offset, 1, ENC_LITTLE_ENDIAN);
783 ti = proto_tree_add_item(ppi_tree, hf_ppi_head_flags,
784 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
785 ppi_flags_tree = proto_item_add_subtree(ti, ett_ppi_flags);
786 proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_alignment,
787 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
788 proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_reserved,
789 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
791 proto_tree_add_item(ppi_tree, hf_ppi_head_len,
792 tvb, offset + 2, 2, ENC_LITTLE_ENDIAN);
793 proto_tree_add_item(ppi_tree, hf_ppi_head_dlt,
794 tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
797 tot_len -= PPI_V0_HEADER_LEN;
798 offset += 8;
800 while (tot_len > 0) {
801 data_type = tvb_get_letohs(tvb, offset);
802 data_len = tvb_get_letohs(tvb, offset + 2) + 4;
803 tot_len -= data_len;
805 switch (data_type) {
806 case PPI_80211_COMMON:
807 dissect_80211_common(tvb, pinfo, ppi_tree, offset, data_len);
808 break;
810 case PPI_80211N_MAC:
811 dissect_80211n_mac(tvb, pinfo, ppi_tree, offset, data_len,
812 TRUE, &n_ext_flags, &ampdu_id);
813 is_ht = TRUE;
814 break;
816 case PPI_80211N_MAC_PHY:
817 dissect_80211n_mac_phy(tvb, pinfo, ppi_tree, offset,
818 data_len, &n_ext_flags, &ampdu_id);
819 is_ht = TRUE;
820 break;
822 case PPI_SPECTRUM_MAP:
823 ADD_BASIC_TAG(hf_spectrum_map);
824 break;
826 case PPI_PROCESS_INFO:
827 ADD_BASIC_TAG(hf_process_info);
828 break;
830 case PPI_CAPTURE_INFO:
831 ADD_BASIC_TAG(hf_capture_info);
832 break;
834 case PPI_AGGREGATION_EXTENSION:
835 dissect_aggregation_extension(tvb, pinfo, ppi_tree, offset, data_len);
836 break;
838 case PPI_8023_EXTENSION:
839 dissect_8023_extension(tvb, pinfo, ppi_tree, offset, data_len);
840 break;
841 case PPI_GPS_INFO:
842 if (ppi_gps_handle == NULL)
844 proto_tree_add_item(ppi_tree, hf_ppi_gps, tvb, offset, data_len, ENC_NA);
846 else /* we found a suitable dissector */
848 /* skip over the ppi_fieldheader, and pass it off to the dedicated GPS dissetor */
849 next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1);
850 call_dissector(ppi_gps_handle, next_tvb, pinfo, ppi_tree);
852 break;
853 case PPI_VECTOR_INFO:
854 if (ppi_vector_handle == NULL)
856 proto_tree_add_item(ppi_tree, hf_ppi_vector, tvb, offset, data_len, ENC_NA);
858 else /* we found a suitable dissector */
860 /* skip over the ppi_fieldheader, and pass it off to the dedicated VECTOR dissetor */
861 next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1);
862 call_dissector(ppi_vector_handle, next_tvb, pinfo, ppi_tree);
864 break;
865 case PPI_SENSOR_INFO:
866 if (ppi_sensor_handle == NULL)
868 proto_tree_add_item(ppi_tree, hf_ppi_harris, tvb, offset, data_len, ENC_NA);
870 else /* we found a suitable dissector */
872 /* skip over the ppi_fieldheader, and pass it off to the dedicated SENSOR dissetor */
873 next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1);
874 call_dissector(ppi_sensor_handle, next_tvb, pinfo, ppi_tree);
876 break;
877 case PPI_ANTENNA_INFO:
878 if (ppi_antenna_handle == NULL)
880 proto_tree_add_item(ppi_tree, hf_ppi_antenna, tvb, offset, data_len, ENC_NA);
882 else /* we found a suitable dissector */
884 /* skip over the ppi_fieldheader, and pass it off to the dedicated ANTENNA dissetor */
885 next_tvb = tvb_new_subset(tvb, offset + 4, data_len - 4 , -1);
886 call_dissector(ppi_antenna_handle, next_tvb, pinfo, ppi_tree);
888 break;
890 default:
891 proto_tree_add_item(ppi_tree, hf_ppi_reserved, tvb, offset, data_len, ENC_NA);
894 offset += data_len;
895 if (IS_PPI_FLAG_ALIGN(flags)){
896 offset += PADDING4(offset);
900 if (ppi_ampdu_reassemble && DOT11N_IS_AGGREGATE(n_ext_flags)) {
901 len_remain = tvb_length_remaining(tvb, offset);
902 #if 0 /* XXX: pad_len never actually used ?? */
903 if (DOT11N_MORE_AGGREGATES(n_ext_flags)) {
904 pad_len = PADDING4(len_remain);
906 #endif
907 pinfo->fragmented = TRUE;
909 /* Make sure we aren't going to go past AGGREGATE_MAX
910 * and caclulate our full A-MPDU length */
911 fd_head = fragment_get(&ampdu_reassembly_table, pinfo, ampdu_id, NULL);
912 while (fd_head) {
913 ampdu_len += fd_head->len + PADDING4(fd_head->len) + 4;
914 fd_head = fd_head->next;
916 if (ampdu_len > AGGREGATE_MAX) {
917 if (tree) {
918 proto_tree_add_expert_format(ppi_tree, pinfo, &ei_ppi_invalid_length, tvb, offset, -1, "Aggregate length greater than maximum (%u)", AGGREGATE_MAX);
919 THROW(ReportedBoundsError);
920 } else {
921 return;
926 * Note that we never actually reassemble our A-MPDUs. Doing
927 * so would require prepending each MPDU with an A-MPDU delimiter
928 * and appending it with padding, only to hand it off to some
929 * routine which would un-do the work we just did. We're using
930 * the reassembly code to track MPDU sizes and frame numbers.
932 /*??fd_head = */fragment_add_seq_next(&ampdu_reassembly_table,
933 tvb, offset, pinfo, ampdu_id, NULL, len_remain, TRUE);
934 pinfo->fragmented = TRUE;
936 /* Do reassembly? */
937 fd_head = fragment_get(&ampdu_reassembly_table, pinfo, ampdu_id, NULL);
939 /* Show our fragments */
940 if (fd_head && tree) {
941 ft_fdh = fd_head;
942 /* List our fragments */
943 ti = proto_tree_add_text(ppi_tree, tvb, offset, -1, "A-MPDU (%u bytes w/hdrs):", ampdu_len);
944 PROTO_ITEM_SET_GENERATED(ti);
945 seg_tree = proto_item_add_subtree(ti, ett_ampdu_segments);
947 while (ft_fdh) {
948 if (ft_fdh->tvb_data && ft_fdh->len) {
949 last_frame = ft_fdh->frame;
950 if (!first_mpdu)
951 proto_item_append_text(ti, ",");
952 first_mpdu = FALSE;
953 proto_item_append_text(ti, " #%u(%u)",
954 ft_fdh->frame, ft_fdh->len);
955 proto_tree_add_uint_format(seg_tree, hf_ampdu_segment,
956 tvb, 0, 0, last_frame,
957 "Frame: %u (%u byte%s)",
958 last_frame,
959 ft_fdh->len,
960 plurality(ft_fdh->len, "", "s"));
962 ft_fdh = ft_fdh->next;
964 if (last_frame && last_frame != pinfo->fd->num)
965 proto_tree_add_uint(seg_tree, hf_ampdu_reassembled_in,
966 tvb, 0, 0, last_frame);
969 if (fd_head && !DOT11N_MORE_AGGREGATES(n_ext_flags)) {
970 if (tree) {
971 ti = proto_tree_add_protocol_format(tree,
972 proto_get_id_by_filter_name("wlan_aggregate"),
973 tvb, 0, tot_len, "IEEE 802.11 Aggregate MPDU");
974 agg_tree = proto_item_add_subtree(ti, ett_ampdu);
977 while (fd_head) {
978 if (fd_head->tvb_data && fd_head->len) {
979 mpdu_count++;
980 mpdu_str = wmem_strdup_printf(wmem_packet_scope(), "MPDU #%d", mpdu_count);
982 next_tvb = tvb_new_chain(tvb, fd_head->tvb_data);
983 add_new_data_source(pinfo, next_tvb, mpdu_str);
985 if (agg_tree) {
986 ti = proto_tree_add_text(agg_tree, next_tvb, 0, -1, "%s", mpdu_str);
987 ampdu_tree = proto_item_add_subtree(ti, ett_ampdu_segment);
989 call_dissector(ieee80211_ht_handle, next_tvb, pinfo, ampdu_tree);
991 fd_head = fd_head->next;
993 proto_tree_add_uint(seg_tree, hf_ampdu_count, tvb, 0, 0, mpdu_count);
994 pinfo->fragmented=FALSE;
995 } else {
996 next_tvb = tvb_new_subset_remaining(tvb, offset);
997 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IEEE 802.11n");
998 col_set_str(pinfo->cinfo, COL_INFO, "Unreassembled A-MPDU data");
999 call_dissector(data_handle, next_tvb, pinfo, tree);
1001 return;
1004 next_tvb = tvb_new_subset_remaining(tvb, offset);
1005 if (is_ht) { /* We didn't hit the reassembly code */
1006 call_dissector(ieee80211_ht_handle, next_tvb, pinfo, tree);
1007 } else {
1008 dissector_try_uint(wtap_encap_dissector_table,
1009 wtap_pcap_encap_to_wtap_encap(dlt), next_tvb, pinfo, tree);
1013 /* Establish our beachead */
1015 static void
1016 ampdu_reassemble_init(void)
1018 reassembly_table_init(&ampdu_reassembly_table,
1019 &addresses_reassembly_table_functions);
1022 void
1023 proto_register_ppi(void)
1025 static hf_register_info hf[] = {
1026 { &hf_ppi_head_version,
1027 { "Version", "ppi.version",
1028 FT_UINT8, BASE_DEC, NULL, 0x0,
1029 "PPI header format version", HFILL } },
1030 { &hf_ppi_head_flags,
1031 { "Flags", "ppi.flags",
1032 FT_UINT8, BASE_HEX, NULL, 0x0,
1033 "PPI header flags", HFILL } },
1034 { &hf_ppi_head_flag_alignment,
1035 { "Alignment", "ppi.flags.alignment",
1036 FT_BOOLEAN, 8, TFS(&tfs_ppi_head_flag_alignment), 0x01,
1037 "PPI header flags - 32bit Alignment", HFILL } },
1038 { &hf_ppi_head_flag_reserved,
1039 { "Reserved", "ppi.flags.reserved",
1040 FT_UINT8, BASE_HEX, NULL, 0xFE,
1041 "PPI header flags - Reserved Flags", HFILL } },
1042 { &hf_ppi_head_len,
1043 { "Header length", "ppi.length",
1044 FT_UINT16, BASE_DEC, NULL, 0x0,
1045 "Length of header including payload", HFILL } },
1046 { &hf_ppi_head_dlt,
1047 { "DLT", "ppi.dlt",
1048 FT_UINT32, BASE_DEC, NULL, 0x0, "libpcap Data Link Type (DLT) of the payload", HFILL } },
1050 { &hf_ppi_field_type,
1051 { "Field type", "ppi.field_type",
1052 FT_UINT16, BASE_DEC, VALS(vs_ppi_field_type), 0x0, "PPI data field type", HFILL } },
1053 { &hf_ppi_field_len,
1054 { "Field length", "ppi.field_len",
1055 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI data field length", HFILL } },
1057 { &hf_80211_common_tsft,
1058 { "TSFT", "ppi.80211-common.tsft",
1059 FT_UINT64, BASE_DEC, NULL, 0x0, "PPI 802.11-Common Timing Synchronization Function Timer (TSFT)", HFILL } },
1060 { &hf_80211_common_flags,
1061 { "Flags", "ppi.80211-common.flags",
1062 FT_UINT16, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Flags", HFILL } },
1063 { &hf_80211_common_flags_fcs,
1064 { "FCS present flag", "ppi.80211-common.flags.fcs",
1065 FT_BOOLEAN, 16, TFS(&tfs_present_absent), 0x0001, "PPI 802.11-Common Frame Check Sequence (FCS) Present Flag", HFILL } },
1066 { &hf_80211_common_flags_tsft,
1067 { "TSFT flag", "ppi.80211-common.flags.tsft",
1068 FT_BOOLEAN, 16, TFS(&tfs_tsft_ms), 0x0002, "PPI 802.11-Common Timing Synchronization Function Timer (TSFT) msec/usec flag", HFILL } },
1069 { &hf_80211_common_flags_fcs_valid,
1070 { "FCS validity", "ppi.80211-common.flags.fcs-invalid",
1071 FT_BOOLEAN, 16, TFS(&tfs_invalid_valid), 0x0004, "PPI 802.11-Common Frame Check Sequence (FCS) Validity flag", HFILL } },
1072 { &hf_80211_common_flags_phy_err,
1073 { "PHY error flag", "ppi.80211-common.flags.phy-err",
1074 FT_BOOLEAN, 16, TFS(&tfs_phy_error), 0x0008, "PPI 802.11-Common Physical level (PHY) Error", HFILL } },
1075 { &hf_80211_common_rate,
1076 { "Data rate", "ppi.80211-common.rate",
1077 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI 802.11-Common Data Rate (x 500 Kbps)", HFILL } },
1078 { &hf_80211_common_chan_freq,
1079 { "Channel frequency", "ppi.80211-common.chan.freq",
1080 FT_UINT16, BASE_DEC, NULL, 0x0,
1081 "PPI 802.11-Common Channel Frequency", HFILL } },
1082 { &hf_80211_common_chan_flags,
1083 { "Channel type", "ppi.80211-common.chan.type",
1084 FT_UINT16, BASE_HEX, VALS(vs_80211_common_phy_type), 0x0, "PPI 802.11-Common Channel Type", HFILL } },
1086 { &hf_80211_common_chan_flags_turbo,
1087 { "Turbo", "ppi.80211-common.chan.type.turbo",
1088 FT_BOOLEAN, 16, NULL, 0x0010, "PPI 802.11-Common Channel Type Turbo", HFILL } },
1089 { &hf_80211_common_chan_flags_cck,
1090 { "Complementary Code Keying (CCK)", "ppi.80211-common.chan.type.cck",
1091 FT_BOOLEAN, 16, NULL, 0x0020, "PPI 802.11-Common Channel Type Complementary Code Keying (CCK) Modulation", HFILL } },
1092 { &hf_80211_common_chan_flags_ofdm,
1093 { "Orthogonal Frequency-Division Multiplexing (OFDM)", "ppi.80211-common.chan.type.ofdm",
1094 FT_BOOLEAN, 16, NULL, 0x0040, "PPI 802.11-Common Channel Type Orthogonal Frequency-Division Multiplexing (OFDM)", HFILL } },
1095 { &hf_80211_common_chan_flags_2ghz,
1096 { "2 GHz spectrum", "ppi.80211-common.chan.type.2ghz",
1097 FT_BOOLEAN, 16, NULL, 0x0080, "PPI 802.11-Common Channel Type 2 GHz spectrum", HFILL } },
1098 { &hf_80211_common_chan_flags_5ghz,
1099 { "5 GHz spectrum", "ppi.80211-common.chan.type.5ghz",
1100 FT_BOOLEAN, 16, NULL, 0x0100, "PPI 802.11-Common Channel Type 5 GHz spectrum", HFILL } },
1101 { &hf_80211_common_chan_flags_passive,
1102 { "Passive", "ppi.80211-common.chan.type.passive",
1103 FT_BOOLEAN, 16, NULL, 0x0200, "PPI 802.11-Common Channel Type Passive", HFILL } },
1104 { &hf_80211_common_chan_flags_dynamic,
1105 { "Dynamic CCK-OFDM", "ppi.80211-common.chan.type.dynamic",
1106 FT_BOOLEAN, 16, NULL, 0x0400, "PPI 802.11-Common Channel Type Dynamic CCK-OFDM Channel", HFILL } },
1107 { &hf_80211_common_chan_flags_gfsk,
1108 { "Gaussian Frequency Shift Keying (GFSK)", "ppi.80211-common.chan.type.gfsk",
1109 FT_BOOLEAN, 16, NULL, 0x0800, "PPI 802.11-Common Channel Type Gaussian Frequency Shift Keying (GFSK) Modulation", HFILL } },
1111 { &hf_80211_common_fhss_hopset,
1112 { "FHSS hopset", "ppi.80211-common.fhss.hopset",
1113 FT_UINT8, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Frequency-Hopping Spread Spectrum (FHSS) Hopset", HFILL } },
1114 { &hf_80211_common_fhss_pattern,
1115 { "FHSS pattern", "ppi.80211-common.fhss.pattern",
1116 FT_UINT8, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Frequency-Hopping Spread Spectrum (FHSS) Pattern", HFILL } },
1117 { &hf_80211_common_dbm_antsignal,
1118 { "dBm antenna signal", "ppi.80211-common.dbm.antsignal",
1119 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11-Common dBm Antenna Signal", HFILL } },
1120 { &hf_80211_common_dbm_antnoise,
1121 { "dBm antenna noise", "ppi.80211-common.dbm.antnoise",
1122 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11-Common dBm Antenna Noise", HFILL } },
1124 /* 802.11n MAC */
1125 { &hf_80211n_mac_flags,
1126 { "MAC flags", "ppi.80211n-mac.flags",
1127 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC flags", HFILL } },
1128 { &hf_80211n_mac_flags_greenfield,
1129 { "Greenfield flag", "ppi.80211n-mac.flags.greenfield",
1130 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0001, "PPI 802.11n MAC Greenfield Flag", HFILL } },
1131 { &hf_80211n_mac_flags_ht20_40,
1132 { "HT20/HT40 flag", "ppi.80211n-mac.flags.ht20_40",
1133 FT_BOOLEAN, 32, TFS(&tfs_ht20_40), 0x0002, "PPI 802.11n MAC HT20/HT40 Flag", HFILL } },
1134 { &hf_80211n_mac_flags_rx_guard_interval,
1135 { "RX Short Guard Interval (SGI) flag", "ppi.80211n-mac.flags.rx.short_guard_interval",
1136 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0004, "PPI 802.11n MAC RX Short Guard Interval (SGI) Flag", HFILL } },
1137 { &hf_80211n_mac_flags_duplicate_rx,
1138 { "Duplicate RX flag", "ppi.80211n-mac.flags.rx.duplicate",
1139 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0008, "PPI 802.11n MAC Duplicate RX Flag", HFILL } },
1140 { &hf_80211n_mac_flags_aggregate,
1141 { "Aggregate flag", "ppi.80211n-mac.flags.agg",
1142 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0010, "PPI 802.11 MAC Aggregate Flag", HFILL } },
1143 { &hf_80211n_mac_flags_more_aggregates,
1144 { "More aggregates flag", "ppi.80211n-mac.flags.more_agg",
1145 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0020, "PPI 802.11n MAC More Aggregates Flag", HFILL } },
1146 { &hf_80211n_mac_flags_delimiter_crc_after,
1147 { "A-MPDU Delimiter CRC error after this frame flag", "ppi.80211n-mac.flags.delim_crc_error_after",
1148 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0040, "PPI 802.11n MAC A-MPDU Delimiter CRC Error After This Frame Flag", HFILL } },
1149 { &hf_80211n_mac_ampdu_id,
1150 { "AMPDU-ID", "ppi.80211n-mac.ampdu_id",
1151 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC AMPDU-ID", HFILL } },
1152 { &hf_80211n_mac_num_delimiters,
1153 { "Num-Delimiters", "ppi.80211n-mac.num_delimiters",
1154 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC number of zero-length pad delimiters", HFILL } },
1155 { &hf_80211n_mac_reserved,
1156 { "Reserved", "ppi.80211n-mac.reserved",
1157 FT_UINT24, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC Reserved", HFILL } },
1160 /* 802.11n MAC+PHY */
1161 { &hf_80211n_mac_phy_mcs,
1162 { "MCS", "ppi.80211n-mac-phy.mcs",
1163 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Modulation Coding Scheme (MCS)", HFILL } },
1164 { &hf_80211n_mac_phy_num_streams,
1165 { "Number of spatial streams", "ppi.80211n-mac-phy.num_streams",
1166 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY number of spatial streams", HFILL } },
1167 { &hf_80211n_mac_phy_rssi_combined,
1168 { "RSSI combined", "ppi.80211n-mac-phy.rssi.combined",
1169 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Received Signal Strength Indication (RSSI) Combined", HFILL } },
1170 { &hf_80211n_mac_phy_rssi_ant0_ctl,
1171 { "Antenna 0 control RSSI", "ppi.80211n-mac-phy.rssi.ant0ctl",
1172 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 0 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1173 { &hf_80211n_mac_phy_rssi_ant1_ctl,
1174 { "Antenna 1 control RSSI", "ppi.80211n-mac-phy.rssi.ant1ctl",
1175 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 1 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1176 { &hf_80211n_mac_phy_rssi_ant2_ctl,
1177 { "Antenna 2 control RSSI", "ppi.80211n-mac-phy.rssi.ant2ctl",
1178 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 2 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1179 { &hf_80211n_mac_phy_rssi_ant3_ctl,
1180 { "Antenna 3 control RSSI", "ppi.80211n-mac-phy.rssi.ant3ctl",
1181 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 3 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1182 { &hf_80211n_mac_phy_rssi_ant0_ext,
1183 { "Antenna 0 extension RSSI", "ppi.80211n-mac-phy.rssi.ant0ext",
1184 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 0 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1185 { &hf_80211n_mac_phy_rssi_ant1_ext,
1186 { "Antenna 1 extension RSSI", "ppi.80211n-mac-phy.rssi.ant1ext",
1187 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 1 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1188 { &hf_80211n_mac_phy_rssi_ant2_ext,
1189 { "Antenna 2 extension RSSI", "ppi.80211n-mac-phy.rssi.ant2ext",
1190 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 2 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1191 { &hf_80211n_mac_phy_rssi_ant3_ext,
1192 { "Antenna 3 extension RSSI", "ppi.80211n-mac-phy.rssi.ant3ext",
1193 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 3 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1194 { &hf_80211n_mac_phy_ext_chan_freq,
1195 { "Extended channel frequency", "ppi.80211-mac-phy.ext-chan.freq",
1196 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Extended Channel Frequency", HFILL } },
1197 { &hf_80211n_mac_phy_ext_chan_flags,
1198 { "Channel type", "ppi.80211-mac-phy.ext-chan.type",
1199 FT_UINT16, BASE_HEX, VALS(vs_80211_common_phy_type), 0x0, "PPI 802.11n MAC+PHY Channel Type", HFILL } },
1200 { &hf_80211n_mac_phy_ext_chan_flags_turbo,
1201 { "Turbo", "ppi.80211-mac-phy.ext-chan.type.turbo",
1202 FT_BOOLEAN, 16, NULL, 0x0010, "PPI 802.11n MAC+PHY Channel Type Turbo", HFILL } },
1203 { &hf_80211n_mac_phy_ext_chan_flags_cck,
1204 { "Complementary Code Keying (CCK)", "ppi.80211-mac-phy.ext-chan.type.cck",
1205 FT_BOOLEAN, 16, NULL, 0x0020, "PPI 802.11n MAC+PHY Channel Type Complementary Code Keying (CCK) Modulation", HFILL } },
1206 { &hf_80211n_mac_phy_ext_chan_flags_ofdm,
1207 { "Orthogonal Frequency-Division Multiplexing (OFDM)", "ppi.80211-mac-phy.ext-chan.type.ofdm",
1208 FT_BOOLEAN, 16, NULL, 0x0040, "PPI 802.11n MAC+PHY Channel Type Orthogonal Frequency-Division Multiplexing (OFDM)", HFILL } },
1209 { &hf_80211n_mac_phy_ext_chan_flags_2ghz,
1210 { "2 GHz spectrum", "ppi.80211-mac-phy.ext-chan.type.2ghz",
1211 FT_BOOLEAN, 16, NULL, 0x0080, "PPI 802.11n MAC+PHY Channel Type 2 GHz spectrum", HFILL } },
1212 { &hf_80211n_mac_phy_ext_chan_flags_5ghz,
1213 { "5 GHz spectrum", "ppi.80211-mac-phy.ext-chan.type.5ghz",
1214 FT_BOOLEAN, 16, NULL, 0x0100, "PPI 802.11n MAC+PHY Channel Type 5 GHz spectrum", HFILL } },
1215 { &hf_80211n_mac_phy_ext_chan_flags_passive,
1216 { "Passive", "ppi.80211-mac-phy.ext-chan.type.passive",
1217 FT_BOOLEAN, 16, NULL, 0x0200, "PPI 802.11n MAC+PHY Channel Type Passive", HFILL } },
1218 { &hf_80211n_mac_phy_ext_chan_flags_dynamic,
1219 { "Dynamic CCK-OFDM", "ppi.80211-mac-phy.ext-chan.type.dynamic",
1220 FT_BOOLEAN, 16, NULL, 0x0400, "PPI 802.11n MAC+PHY Channel Type Dynamic CCK-OFDM Channel", HFILL } },
1221 { &hf_80211n_mac_phy_ext_chan_flags_gfsk,
1222 { "Gaussian Frequency Shift Keying (GFSK)", "ppi.80211-mac-phy.ext-chan.type.gfsk",
1223 FT_BOOLEAN, 16, NULL, 0x0800, "PPI 802.11n MAC+PHY Channel Type Gaussian Frequency Shift Keying (GFSK) Modulation", HFILL } },
1224 { &hf_80211n_mac_phy_dbm_ant0signal,
1225 { "dBm antenna 0 signal", "ppi.80211n-mac-phy.dbmant0.signal",
1226 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 0 Signal", HFILL } },
1227 { &hf_80211n_mac_phy_dbm_ant0noise,
1228 { "dBm antenna 0 noise", "ppi.80211n-mac-phy.dbmant0.noise",
1229 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 0 Noise", HFILL } },
1230 { &hf_80211n_mac_phy_dbm_ant1signal,
1231 { "dBm antenna 1 signal", "ppi.80211n-mac-phy.dbmant1.signal",
1232 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 1 Signal", HFILL } },
1233 { &hf_80211n_mac_phy_dbm_ant1noise,
1234 { "dBm antenna 1 noise", "ppi.80211n-mac-phy.dbmant1.noise",
1235 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 1 Noise", HFILL } },
1236 { &hf_80211n_mac_phy_dbm_ant2signal,
1237 { "dBm antenna 2 signal", "ppi.80211n-mac-phy.dbmant2.signal",
1238 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 2 Signal", HFILL } },
1239 { &hf_80211n_mac_phy_dbm_ant2noise,
1240 { "dBm antenna 2 noise", "ppi.80211n-mac-phy.dbmant2.noise",
1241 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 2 Noise", HFILL } },
1242 { &hf_80211n_mac_phy_dbm_ant3signal,
1243 { "dBm antenna 3 signal", "ppi.80211n-mac-phy.dbmant3.signal",
1244 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 3 Signal", HFILL } },
1245 { &hf_80211n_mac_phy_dbm_ant3noise,
1246 { "dBm antenna 3 noise", "ppi.80211n-mac-phy.dbmant3.noise",
1247 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 3 Noise", HFILL } },
1248 { &hf_80211n_mac_phy_evm0,
1249 { "EVM-0", "ppi.80211n-mac-phy.evm0",
1250 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 0", HFILL } },
1251 { &hf_80211n_mac_phy_evm1,
1252 { "EVM-1", "ppi.80211n-mac-phy.evm1",
1253 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 1", HFILL } },
1254 { &hf_80211n_mac_phy_evm2,
1255 { "EVM-2", "ppi.80211n-mac-phy.evm2",
1256 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 2", HFILL } },
1257 { &hf_80211n_mac_phy_evm3,
1258 { "EVM-3", "ppi.80211n-mac-phy.evm3",
1259 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 3", HFILL } },
1261 { &hf_ampdu_segment,
1262 { "A-MPDU", "ppi.80211n-mac.ampdu",
1263 FT_FRAMENUM, BASE_NONE, NULL, 0x0, "802.11n Aggregated MAC Protocol Data Unit (A-MPDU)", HFILL }},
1264 #if 0
1265 { &hf_ampdu_segments,
1266 { "Reassembled A-MPDU", "ppi.80211n-mac.ampdu.reassembled",
1267 FT_NONE, BASE_NONE, NULL, 0x0, "Reassembled Aggregated MAC Protocol Data Unit (A-MPDU)", HFILL }},
1268 #endif
1269 { &hf_ampdu_reassembled_in,
1270 { "Reassembled A-MPDU in frame", "ppi.80211n-mac.ampdu.reassembled_in",
1271 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1272 "The A-MPDU that doesn't end in this segment is reassembled in this frame",
1273 HFILL }},
1274 { &hf_ampdu_count,
1275 { "MPDU count", "ppi.80211n-mac.ampdu.count",
1276 FT_UINT16, BASE_DEC, NULL, 0x0, "The number of aggregated MAC Protocol Data Units (MPDUs)", HFILL }},
1278 { &hf_spectrum_map,
1279 { "Radio spectrum map", "ppi.spectrum-map",
1280 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Radio spectrum map", HFILL } },
1281 { &hf_process_info,
1282 { "Process information", "ppi.proc-info",
1283 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Process information", HFILL } },
1284 { &hf_capture_info,
1285 { "Capture information", "ppi.cap-info",
1286 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Capture information", HFILL } },
1288 /* Aggregtion Extension */
1289 { &hf_aggregation_extension_interface_id,
1290 { "Interface ID", "ppi.aggregation_extension.interface_id",
1291 FT_UINT32, BASE_DEC, NULL, 0x0, "Zero-based index of the physical interface the packet was captured from", HFILL } },
1293 /* 802.3 Extension */
1294 { &hf_8023_extension_flags,
1295 { "Flags", "ppi.8023_extension.flags",
1296 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.3 Extension Flags", HFILL } },
1297 { &hf_8023_extension_flags_fcs_present,
1298 { "FCS Present Flag", "ppi.8023_extension.flags.fcs_present",
1299 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0001, "FCS (4 bytes) is present at the end of the packet", HFILL } },
1300 { &hf_8023_extension_errors,
1301 { "Errors", "ppi.8023_extension.errors",
1302 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.3 Extension Errors", HFILL } },
1303 { &hf_8023_extension_errors_fcs,
1304 { "FCS Error", "ppi.8023_extension.errors.fcs",
1305 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0001,
1306 "PPI 802.3 Extension FCS Error", HFILL } },
1307 { &hf_8023_extension_errors_sequence,
1308 { "Sequence Error", "ppi.8023_extension.errors.sequence",
1309 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0002,
1310 "PPI 802.3 Extension Sequence Error", HFILL } },
1311 { &hf_8023_extension_errors_symbol,
1312 { "Symbol Error", "ppi.8023_extension.errors.symbol",
1313 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0004,
1314 "PPI 802.3 Extension Symbol Error", HFILL } },
1315 { &hf_8023_extension_errors_data,
1316 { "Data Error", "ppi.8023_extension.errors.data",
1317 FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x0008,
1318 "PPI 802.3 Extension Data Error", HFILL } },
1320 /* Generated from convert_proto_tree_add_text.pl */
1321 { &hf_ppi_gps, { "GPS", "ppi.gps", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1322 { &hf_ppi_vector, { "VECTOR", "ppi.vector", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1323 { &hf_ppi_harris, { "HARRIS", "ppi.harris", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1324 { &hf_ppi_antenna, { "ANTENNA", "ppi.antenna", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1325 { &hf_ppi_reserved, { "Reserved", "ppi.reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1328 static gint *ett[] = {
1329 &ett_ppi_pph,
1330 &ett_ppi_flags,
1331 &ett_dot11_common,
1332 &ett_dot11_common_flags,
1333 &ett_dot11_common_channel_flags,
1334 &ett_dot11n_mac,
1335 &ett_dot11n_mac_flags,
1336 &ett_dot11n_mac_phy,
1337 &ett_dot11n_mac_phy_ext_channel_flags,
1338 &ett_ampdu_segments,
1339 &ett_ampdu,
1340 &ett_ampdu_segment,
1341 &ett_aggregation_extension,
1342 &ett_8023_extension,
1343 &ett_8023_extension_flags,
1344 &ett_8023_extension_errors
1347 static ei_register_info ei[] = {
1348 { &ei_ppi_invalid_length, { "ppi.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
1351 module_t *ppi_module;
1352 expert_module_t* expert_ppi;
1354 proto_ppi = proto_register_protocol("PPI Packet Header", "PPI", "ppi");
1355 proto_register_field_array(proto_ppi, hf, array_length(hf));
1356 proto_register_subtree_array(ett, array_length(ett));
1357 expert_ppi = expert_register_protocol(proto_ppi);
1358 expert_register_field_array(expert_ppi, ei, array_length(ei));
1360 ppi_handle = register_dissector("ppi", dissect_ppi, proto_ppi);
1362 register_init_routine(ampdu_reassemble_init);
1364 /* Configuration options */
1365 ppi_module = prefs_register_protocol(proto_ppi, NULL);
1366 prefs_register_bool_preference(ppi_module, "reassemble",
1367 "Reassemble fragmented 802.11 A-MPDUs",
1368 "Whether fragmented 802.11 aggregated MPDUs should be reassembled",
1369 &ppi_ampdu_reassemble);
1372 void
1373 proto_reg_handoff_ppi(void)
1375 data_handle = find_dissector("data");
1376 ieee80211_ht_handle = find_dissector("wlan_ht");
1377 ppi_gps_handle = find_dissector("ppi_gps");
1378 ppi_vector_handle = find_dissector("ppi_vector");
1379 ppi_sensor_handle = find_dissector("ppi_sensor");
1380 ppi_antenna_handle = find_dissector("ppi_antenna");
1382 dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_handle);
1386 * Editor modelines
1388 * Local Variables:
1389 * c-basic-offset: 4
1390 * tab-width: 8
1391 * indent-tabs-mode: nil
1392 * End:
1394 * ex: set shiftwidth=4 tabstop=8 expandtab:
1395 * :indentSize=4:tabSize=8:noTabs=true: