Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ppi.c
blobc8eab155b2bd54cd1aeea2c1c8fb269549fd11f1
1 /*
2 * packet-ppi.c
3 * Routines for PPI Packet Header dissection
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 2007 Gerald Combs
9 * Copyright (c) 2006 CACE Technologies, Davis (California)
10 * All rights reserved.
12 * SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
15 * Dustin Johnson - Dustin@Dustinj.us, Dustin.Johnson@cacetech.com
16 * May 7, 2008 - Added 'Aggregation Extension' and '802.3 Extension'
20 #include "config.h"
22 #include <epan/packet.h>
23 #include <epan/capture_dissectors.h>
24 #include <epan/tfs.h>
25 #include <epan/ptvcursor.h>
26 #include <epan/prefs.h>
27 #include <epan/expert.h>
28 #include <epan/reassemble.h>
29 #include <wsutil/802_11-utils.h>
30 #include <wsutil/pint.h>
31 #include <wsutil/str_util.h>
32 #include <wsutil/array.h>
35 * Per-Packet Information (PPI) header.
36 * See the PPI Packet Header documentation at
38 * https://wayback.archive.org/web/20120525190041/https://www.cacetech.com/documents/PPI%20Header%20format%201.0.10.pdf
40 * for details.
44 * PPI headers have the following format:
46 * ,---------------------------------------------------------.
47 * | PPH | PFH 1 | Field data 1 | PFH 2 | Field data 2 | ... |
48 * `---------------------------------------------------------'
50 * The PPH struct has the following format:
52 * typedef struct ppi_packetheader {
53 * uint8_t pph_version; // Version. Currently 0
54 * uint8_t pph_flags; // Flags.
55 * uint16_t pph_len; // Length of entire message, including this header and TLV payload.
56 * uint32_t pph_dlt; // libpcap Data Link Type of the captured packet data.
57 * } ppi_packetheader_t;
59 * The PFH struct has the following format:
61 * typedef struct ppi_fieldheader {
62 * uint16_t pfh_type; // Type
63 * uint16_t pfh_datalen; // Length of data
64 * } ppi_fieldheader_t;
66 * Anyone looking to add their own PPI dissector would probably do well to imitate the GPS
67 * ones separation into a distinct file. Here is a step by step guide:
68 * 1) add the number you received to the enum ppi_field_type declaration.
69 * 2) Add a value string for your number into vs_ppi_field_type
70 * 3) declare a dissector handle by the ppi_gps_handle, and initialize it inside proto_reg_handoff
71 * 4) add case inside dissect_ppi to call your new handle.
72 * 5) Write your parser, and get it loaded.
73 * Following these steps will result in less churn inside the ppi proper parser, and avoid namespace issues.
77 #define PPI_PADDED (1 << 0)
79 #define PPI_V0_HEADER_LEN 8
80 #define PPI_80211_COMMON_LEN 20
81 #define PPI_80211N_MAC_LEN 12
82 #define PPI_80211N_MAC_PHY_OFF 9
83 #define PPI_80211N_MAC_PHY_LEN 48
84 #define PPI_AGGREGATION_EXTENSION_LEN 4
85 #define PPI_8023_EXTENSION_LEN 8
87 #define PPI_FLAG_ALIGN 0x01
88 #define IS_PPI_FLAG_ALIGN(x) ((x) & PPI_FLAG_ALIGN)
90 #define DOT11_FLAG_HAVE_FCS 0x0001
91 #define DOT11_FLAG_TSF_TIMER_MS 0x0002
92 #define DOT11_FLAG_FCS_INVALID 0x0004
93 #define DOT11_FLAG_PHY_ERROR 0x0008
95 #define DOT11N_FLAG_GREENFIELD 0x00000001
96 #define DOT11N_FLAG_HT40 0x00000002
97 #define DOT11N_FLAG_SHORT_GI 0x00000004
98 #define DOT11N_FLAG_DUPLICATE_RX 0x00000008
99 #define DOT11N_FLAG_IS_AGGREGATE 0x00000010
100 #define DOT11N_FLAG_MORE_AGGREGATES 0x00000020
101 #define DOT11N_FLAG_AGG_CRC_ERROR 0x00000040
103 #define DOT11N_IS_AGGREGATE(flags) (flags & DOT11N_FLAG_IS_AGGREGATE)
104 #define DOT11N_MORE_AGGREGATES(flags) ( \
105 (flags & DOT11N_FLAG_MORE_AGGREGATES) && \
106 !(flags & DOT11N_FLAG_AGG_CRC_ERROR))
107 #define AGGREGATE_MAX 65535
108 #define AMPDU_MAX 16383
110 /* XXX - Start - Copied from packet-radiotap.c */
111 /* Channel flags. */
112 #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
113 #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
114 #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
115 #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
116 #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
117 #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
118 #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
119 #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
121 #define IEEE80211_CHAN_ALL \
122 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_GFSK | \
123 IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_DYN)
124 #define IEEE80211_CHAN_ALLTURBO \
125 (IEEE80211_CHAN_ALL | IEEE80211_CHAN_TURBO)
128 * Useful combinations of channel characteristics.
130 #define IEEE80211_CHAN_FHSS \
131 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
132 #define IEEE80211_CHAN_DSSS \
133 (IEEE80211_CHAN_2GHZ)
134 #define IEEE80211_CHAN_A \
135 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
136 #define IEEE80211_CHAN_B \
137 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
138 #define IEEE80211_CHAN_PUREG \
139 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
140 #define IEEE80211_CHAN_G \
141 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
142 #define IEEE80211_CHAN_108A \
143 (IEEE80211_CHAN_A | IEEE80211_CHAN_TURBO)
144 #define IEEE80211_CHAN_108G \
145 (IEEE80211_CHAN_G | IEEE80211_CHAN_TURBO)
146 #define IEEE80211_CHAN_108PUREG \
147 (IEEE80211_CHAN_PUREG | IEEE80211_CHAN_TURBO)
148 /* XXX - End - Copied from packet-radiotap.c */
150 void proto_register_ppi(void);
151 void proto_reg_handoff_ppi(void);
153 typedef enum {
154 /* 0 - 29999: Public types */
155 PPI_80211_COMMON = 2,
156 PPI_80211N_MAC = 3,
157 PPI_80211N_MAC_PHY = 4,
158 PPI_SPECTRUM_MAP = 5,
159 PPI_PROCESS_INFO = 6,
160 PPI_CAPTURE_INFO = 7,
161 PPI_AGGREGATION_EXTENSION = 8,
162 PPI_8023_EXTENSION = 9,
163 /* 11 - 29999: RESERVED */
165 /* 30000 - 65535: Private types */
166 INTEL_CORP_PRIVATE = 30000,
167 MOHAMED_THAGA_PRIVATE = 30001,
168 PPI_GPS_INFO = 30002, /* 30002 - 30005 described in PPI-GEOLOCATION specification */
169 PPI_VECTOR_INFO = 30003, /* currently available in draft from. jellch@harris.com */
170 PPI_SENSOR_INFO = 30004,
171 PPI_ANTENNA_INFO = 30005,
172 FNET_PRIVATE = 0xC017,
173 CACE_PRIVATE = 0xCACE
174 /* All others RESERVED. Contact the WinPcap team for an assignment */
175 } ppi_field_type;
177 /* Protocol */
178 static int proto_ppi;
180 /* Packet header */
181 static int hf_ppi_head_version;
182 static int hf_ppi_head_flags;
183 static int hf_ppi_head_flag_alignment;
184 static int hf_ppi_head_flag_reserved;
185 static int hf_ppi_head_len;
186 static int hf_ppi_head_dlt;
188 /* Field header */
189 static int hf_ppi_field_type;
190 static int hf_ppi_field_len;
192 /* 802.11 Common */
193 static int hf_80211_common_tsft;
194 static int hf_80211_common_flags;
195 static int hf_80211_common_flags_fcs;
196 static int hf_80211_common_flags_tsft;
197 static int hf_80211_common_flags_fcs_valid;
198 static int hf_80211_common_flags_phy_err;
199 static int hf_80211_common_rate;
200 static int hf_80211_common_chan_freq;
201 static int hf_80211_common_chan_flags;
203 static int hf_80211_common_chan_flags_turbo;
204 static int hf_80211_common_chan_flags_cck;
205 static int hf_80211_common_chan_flags_ofdm;
206 static int hf_80211_common_chan_flags_2ghz;
207 static int hf_80211_common_chan_flags_5ghz;
208 static int hf_80211_common_chan_flags_passive;
209 static int hf_80211_common_chan_flags_dynamic;
210 static int hf_80211_common_chan_flags_gfsk;
212 static int hf_80211_common_fhss_hopset;
213 static int hf_80211_common_fhss_pattern;
214 static int hf_80211_common_dbm_antsignal;
215 static int hf_80211_common_dbm_antnoise;
217 /* 802.11n MAC */
218 static int hf_80211n_mac_flags;
219 static int hf_80211n_mac_flags_greenfield;
220 static int hf_80211n_mac_flags_ht20_40;
221 static int hf_80211n_mac_flags_rx_guard_interval;
222 static int hf_80211n_mac_flags_duplicate_rx;
223 static int hf_80211n_mac_flags_more_aggregates;
224 static int hf_80211n_mac_flags_aggregate;
225 static int hf_80211n_mac_flags_delimiter_crc_after;
226 static int hf_80211n_mac_ampdu_id;
227 static int hf_80211n_mac_num_delimiters;
228 static int hf_80211n_mac_reserved;
230 /* 802.11n MAC+PHY */
231 static int hf_80211n_mac_phy_mcs;
232 static int hf_80211n_mac_phy_num_streams;
233 static int hf_80211n_mac_phy_rssi_combined;
234 static int hf_80211n_mac_phy_rssi_ant0_ctl;
235 static int hf_80211n_mac_phy_rssi_ant1_ctl;
236 static int hf_80211n_mac_phy_rssi_ant2_ctl;
237 static int hf_80211n_mac_phy_rssi_ant3_ctl;
238 static int hf_80211n_mac_phy_rssi_ant0_ext;
239 static int hf_80211n_mac_phy_rssi_ant1_ext;
240 static int hf_80211n_mac_phy_rssi_ant2_ext;
241 static int hf_80211n_mac_phy_rssi_ant3_ext;
242 static int hf_80211n_mac_phy_ext_chan_freq;
243 static int hf_80211n_mac_phy_ext_chan_flags;
244 static int hf_80211n_mac_phy_ext_chan_flags_turbo;
245 static int hf_80211n_mac_phy_ext_chan_flags_cck;
246 static int hf_80211n_mac_phy_ext_chan_flags_ofdm;
247 static int hf_80211n_mac_phy_ext_chan_flags_2ghz;
248 static int hf_80211n_mac_phy_ext_chan_flags_5ghz;
249 static int hf_80211n_mac_phy_ext_chan_flags_passive;
250 static int hf_80211n_mac_phy_ext_chan_flags_dynamic;
251 static int hf_80211n_mac_phy_ext_chan_flags_gfsk;
252 static int hf_80211n_mac_phy_dbm_ant0signal;
253 static int hf_80211n_mac_phy_dbm_ant0noise;
254 static int hf_80211n_mac_phy_dbm_ant1signal;
255 static int hf_80211n_mac_phy_dbm_ant1noise;
256 static int hf_80211n_mac_phy_dbm_ant2signal;
257 static int hf_80211n_mac_phy_dbm_ant2noise;
258 static int hf_80211n_mac_phy_dbm_ant3signal;
259 static int hf_80211n_mac_phy_dbm_ant3noise;
260 static int hf_80211n_mac_phy_evm0;
261 static int hf_80211n_mac_phy_evm1;
262 static int hf_80211n_mac_phy_evm2;
263 static int hf_80211n_mac_phy_evm3;
265 /* 802.11n-Extensions A-MPDU fragments */
266 static int hf_ampdu_reassembled_in;
267 /* static int hf_ampdu_segments; */
268 static int hf_ampdu_segment;
269 static int hf_ampdu_count;
271 /* Spectrum-Map */
272 static int hf_spectrum_map;
274 /* Process-Info */
275 static int hf_process_info;
277 /* Capture-Info */
278 static int hf_capture_info;
280 /* Aggregation Extension */
281 static int hf_aggregation_extension_interface_id;
283 /* 802.3 Extension */
284 static int hf_8023_extension_flags;
285 static int hf_8023_extension_flags_fcs_present;
286 static int hf_8023_extension_errors;
287 static int hf_8023_extension_errors_fcs;
288 static int hf_8023_extension_errors_sequence;
289 static int hf_8023_extension_errors_symbol;
290 static int hf_8023_extension_errors_data;
292 /* Generated from convert_proto_tree_add_text.pl */
293 static int hf_ppi_antenna;
294 static int hf_ppi_harris;
295 static int hf_ppi_reserved;
296 static int hf_ppi_vector;
297 static int hf_ppi_fnet;
298 static int hf_ppi_gps;
300 static int ett_ppi_pph;
301 static int ett_ppi_flags;
302 static int ett_dot11_common;
303 static int ett_dot11_common_flags;
304 static int ett_dot11_common_channel_flags;
305 static int ett_dot11n_mac;
306 static int ett_dot11n_mac_flags;
307 static int ett_dot11n_mac_phy;
308 static int ett_dot11n_mac_phy_ext_channel_flags;
309 static int ett_ampdu_segments;
310 static int ett_ampdu;
311 static int ett_ampdu_segment;
312 static int ett_aggregation_extension;
313 static int ett_8023_extension;
314 static int ett_8023_extension_flags;
315 static int ett_8023_extension_errors;
317 /* Generated from convert_proto_tree_add_text.pl */
318 static expert_field ei_ppi_invalid_length;
320 static dissector_handle_t ppi_handle;
322 static dissector_handle_t ieee80211_radio_handle;
323 static dissector_handle_t pcap_pktdata_handle;
324 static dissector_handle_t ppi_gps_handle, ppi_vector_handle, ppi_sensor_handle, ppi_antenna_handle;
325 static dissector_handle_t ppi_fnet_handle;
327 static const true_false_string tfs_ppi_head_flag_alignment = { "32-bit aligned", "Not aligned" };
328 static const true_false_string tfs_tsft_ms = { "milliseconds", "microseconds" };
329 static const true_false_string tfs_ht20_40 = { "HT40", "HT20" };
330 static const true_false_string tfs_phy_error = { "PHY error", "No errors"};
332 static const value_string vs_ppi_field_type[] = {
333 {PPI_80211_COMMON, "802.11-Common"},
334 {PPI_80211N_MAC, "802.11n MAC Extensions"},
335 {PPI_80211N_MAC_PHY, "802.11n MAC+PHY Extensions"},
336 {PPI_SPECTRUM_MAP, "Spectrum-Map"},
337 {PPI_PROCESS_INFO, "Process-Info"},
338 {PPI_CAPTURE_INFO, "Capture-Info"},
339 {PPI_AGGREGATION_EXTENSION, "Aggregation Extension"},
340 {PPI_8023_EXTENSION, "802.3 Extension"},
342 {INTEL_CORP_PRIVATE, "Intel Corporation (private)"},
343 {MOHAMED_THAGA_PRIVATE, "Mohamed Thaga (private)"},
344 {PPI_GPS_INFO, "GPS Tagging"},
345 {PPI_VECTOR_INFO, "Vector Tagging"},
346 {PPI_SENSOR_INFO, "Sensor tagging"},
347 {PPI_ANTENNA_INFO, "Antenna Tagging"},
348 {FNET_PRIVATE, "FlukeNetworks (private)"},
349 {CACE_PRIVATE, "CACE Technologies (private)"},
350 {0, NULL}
353 /* Table for A-MPDU reassembly */
354 static reassembly_table ampdu_reassembly_table;
356 /* Reassemble A-MPDUs? */
357 static bool ppi_ampdu_reassemble = true;
360 static bool
361 capture_ppi(const unsigned char *pd, int offset _U_, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
363 uint32_t dlt;
364 unsigned ppi_len;
366 ppi_len = pletoh16(pd+2);
367 if(ppi_len < PPI_V0_HEADER_LEN || !BYTES_ARE_IN_FRAME(0, len, ppi_len))
368 return false;
370 dlt = pletoh32(pd+4);
372 return try_capture_dissector("ppi", dlt, pd, ppi_len, len, cpinfo, pseudo_header);
375 static void
376 ptvcursor_add_invalid_check(ptvcursor_t *csr, int hf, int len, uint64_t invalid_val) {
377 proto_item *ti;
378 uint64_t val = invalid_val;
380 switch (len) {
381 case 8:
382 val = tvb_get_letoh64(ptvcursor_tvbuff(csr),
383 ptvcursor_current_offset(csr));
384 break;
385 case 4:
386 val = tvb_get_letohl(ptvcursor_tvbuff(csr),
387 ptvcursor_current_offset(csr));
388 break;
389 case 2:
390 val = tvb_get_letohs(ptvcursor_tvbuff(csr),
391 ptvcursor_current_offset(csr));
392 break;
393 case 1:
394 val = tvb_get_uint8(ptvcursor_tvbuff(csr),
395 ptvcursor_current_offset(csr));
396 break;
397 default:
398 DISSECTOR_ASSERT_NOT_REACHED();
401 ti = ptvcursor_add(csr, hf, len, ENC_LITTLE_ENDIAN);
402 if (val == invalid_val)
403 proto_item_append_text(ti, " [invalid]");
406 static void
407 add_ppi_field_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset)
409 ptvcursor_t *csr;
411 csr = ptvcursor_new(pinfo->pool, tree, tvb, *offset);
412 ptvcursor_add(csr, hf_ppi_field_type, 2, ENC_LITTLE_ENDIAN);
413 ptvcursor_add(csr, hf_ppi_field_len, 2, ENC_LITTLE_ENDIAN);
414 ptvcursor_free(csr);
415 *offset=ptvcursor_current_offset(csr);
418 /* XXX - The main dissection function in the 802.11 dissector has the same name. */
419 static void
420 dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len, struct ieee_802_11_phdr *phdr)
422 proto_tree *ftree;
423 proto_item *ti;
424 ptvcursor_t *csr;
425 uint64_t tsft_raw;
426 unsigned rate_raw;
427 unsigned rate_kbps;
428 uint32_t common_flags;
429 uint16_t common_frequency;
430 uint16_t chan_flags;
431 int8_t dbm_value;
432 char *chan_str;
434 ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_dot11_common, NULL, "802.11-Common");
435 add_ppi_field_header(tvb, pinfo, ftree, &offset);
436 data_len -= 4; /* Subtract field header length */
438 if (data_len != PPI_80211_COMMON_LEN) {
439 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
440 return;
443 common_flags = tvb_get_letohs(tvb, offset + 8);
444 if (common_flags & DOT11_FLAG_HAVE_FCS)
445 phdr->fcs_len = 4;
446 else
447 phdr->fcs_len = 0;
449 csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
451 tsft_raw = tvb_get_letoh64(tvb, offset);
452 if (tsft_raw != 0) {
453 phdr->has_tsf_timestamp = true;
454 if (common_flags & DOT11_FLAG_TSF_TIMER_MS)
455 phdr->tsf_timestamp = tsft_raw * 1000;
456 else
457 phdr->tsf_timestamp = tsft_raw;
460 ptvcursor_add_invalid_check(csr, hf_80211_common_tsft, 8, 0);
462 ptvcursor_add_with_subtree(csr, hf_80211_common_flags, 2, ENC_LITTLE_ENDIAN,
463 ett_dot11_common_flags);
464 ptvcursor_add_no_advance(csr, hf_80211_common_flags_fcs, 2, ENC_LITTLE_ENDIAN);
465 ptvcursor_add_no_advance(csr, hf_80211_common_flags_tsft, 2, ENC_LITTLE_ENDIAN);
466 ptvcursor_add_no_advance(csr, hf_80211_common_flags_fcs_valid, 2, ENC_LITTLE_ENDIAN);
467 ptvcursor_add(csr, hf_80211_common_flags_phy_err, 2, ENC_LITTLE_ENDIAN);
468 ptvcursor_pop_subtree(csr);
470 rate_raw = tvb_get_letohs(tvb, ptvcursor_current_offset(csr));
471 if (rate_raw != 0) {
472 phdr->has_data_rate = true;
473 phdr->data_rate = rate_raw;
475 rate_kbps = rate_raw * 500;
476 ti = proto_tree_add_uint_format(ftree, hf_80211_common_rate, tvb,
477 ptvcursor_current_offset(csr), 2, rate_kbps, "Rate: %.1f Mbps",
478 rate_kbps / 1000.0);
479 if (rate_kbps == 0)
480 proto_item_append_text(ti, " [invalid]");
481 col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%.1f Mbps", rate_kbps / 1000.0);
482 ptvcursor_advance(csr, 2);
484 common_frequency = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
485 if (common_frequency != 0) {
486 int calc_channel;
488 phdr->has_frequency = true;
489 phdr->frequency = common_frequency;
490 calc_channel = ieee80211_mhz_to_chan(common_frequency);
491 if (calc_channel != -1) {
492 phdr->has_channel = true;
493 phdr->channel = calc_channel;
496 chan_str = ieee80211_mhz_to_str(common_frequency);
497 proto_tree_add_uint_format_value(ptvcursor_tree(csr), hf_80211_common_chan_freq, ptvcursor_tvbuff(csr),
498 ptvcursor_current_offset(csr), 2, common_frequency, "%s", chan_str);
499 col_add_str(pinfo->cinfo, COL_FREQ_CHAN, chan_str);
500 g_free(chan_str);
501 ptvcursor_advance(csr, 2);
503 memset(&phdr->phy_info, 0, sizeof(phdr->phy_info));
504 chan_flags = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
505 switch (chan_flags & IEEE80211_CHAN_ALLTURBO) {
507 case IEEE80211_CHAN_FHSS:
508 phdr->phy = PHDR_802_11_PHY_11_FHSS;
509 break;
511 case IEEE80211_CHAN_DSSS:
512 phdr->phy = PHDR_802_11_PHY_11_DSSS;
513 break;
515 case IEEE80211_CHAN_A:
516 phdr->phy = PHDR_802_11_PHY_11A;
517 phdr->phy_info.info_11a.has_turbo_type = true;
518 phdr->phy_info.info_11a.turbo_type = PHDR_802_11A_TURBO_TYPE_NORMAL;
519 break;
521 case IEEE80211_CHAN_B:
522 phdr->phy = PHDR_802_11_PHY_11B;
523 break;
525 case IEEE80211_CHAN_PUREG:
526 phdr->phy = PHDR_802_11_PHY_11G;
527 phdr->phy_info.info_11g.has_mode = true;
528 phdr->phy_info.info_11g.mode = PHDR_802_11G_MODE_NORMAL;
529 break;
531 case IEEE80211_CHAN_G:
532 phdr->phy = PHDR_802_11_PHY_11G;
533 phdr->phy_info.info_11g.has_mode = true;
534 phdr->phy_info.info_11g.mode = PHDR_802_11G_MODE_NORMAL;
535 break;
537 case IEEE80211_CHAN_108A:
538 phdr->phy = PHDR_802_11_PHY_11A;
539 phdr->phy_info.info_11a.has_turbo_type = true;
540 /* We assume non-STURBO is dynamic turbo */
541 phdr->phy_info.info_11a.turbo_type = PHDR_802_11A_TURBO_TYPE_DYNAMIC_TURBO;
542 break;
544 case IEEE80211_CHAN_108PUREG:
545 phdr->phy = PHDR_802_11_PHY_11G;
546 phdr->phy_info.info_11g.has_mode = true;
547 phdr->phy_info.info_11g.mode = PHDR_802_11G_MODE_SUPER_G;
548 break;
550 ptvcursor_add_with_subtree(csr, hf_80211_common_chan_flags, 2, ENC_LITTLE_ENDIAN,
551 ett_dot11_common_channel_flags);
552 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_turbo, 2, ENC_LITTLE_ENDIAN);
553 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_cck, 2, ENC_LITTLE_ENDIAN);
554 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_ofdm, 2, ENC_LITTLE_ENDIAN);
555 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_2ghz, 2, ENC_LITTLE_ENDIAN);
556 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_5ghz, 2, ENC_LITTLE_ENDIAN);
557 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_passive, 2, ENC_LITTLE_ENDIAN);
558 ptvcursor_add_no_advance(csr, hf_80211_common_chan_flags_dynamic, 2, ENC_LITTLE_ENDIAN);
559 ptvcursor_add(csr, hf_80211_common_chan_flags_gfsk, 2, ENC_LITTLE_ENDIAN);
560 ptvcursor_pop_subtree(csr);
563 if (phdr->phy == PHDR_802_11_PHY_11_FHSS) {
564 phdr->phy_info.info_11_fhss.has_hop_set = true;
565 phdr->phy_info.info_11_fhss.hop_set = tvb_get_uint8(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
567 ptvcursor_add(csr, hf_80211_common_fhss_hopset, 1, ENC_LITTLE_ENDIAN);
568 if (phdr->phy == PHDR_802_11_PHY_11_FHSS) {
569 phdr->phy_info.info_11_fhss.has_hop_pattern = true;
570 phdr->phy_info.info_11_fhss.hop_pattern = tvb_get_uint8(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
572 ptvcursor_add(csr, hf_80211_common_fhss_pattern, 1, ENC_LITTLE_ENDIAN);
574 dbm_value = tvb_get_int8(tvb, ptvcursor_current_offset(csr));
575 if (dbm_value != -128 && dbm_value != 0) {
577 * XXX - the spec says -128 is invalid, presumably meaning "use
578 * -128 if you don't have the signal strength", but some captures
579 * have 0 for noise, presumably meaning it's incorrectly being
580 * used for "don't have it", so we check for it as well.
582 col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", dbm_value);
583 phdr->has_signal_dbm = true;
584 phdr->signal_dbm = dbm_value;
586 ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antsignal, 1, 0x80); /* -128 */
588 dbm_value = tvb_get_int8(tvb, ptvcursor_current_offset(csr));
589 if (dbm_value != -128 && dbm_value != 0) {
591 * XXX - the spec says -128 is invalid, presumably meaning "use
592 * -128 if you don't have the noise level", but some captures
593 * have 0, presumably meaning it's incorrectly being used for
594 * "don't have it", so we check for it as well.
596 phdr->has_noise_dbm = true;
597 phdr->noise_dbm = dbm_value;
599 ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antnoise, 1, 0x80);
601 ptvcursor_free(csr);
604 static void
605 dissect_80211n_mac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len, bool add_subtree, uint32_t *n_mac_flags, uint32_t *ampdu_id, struct ieee_802_11_phdr *phdr)
607 proto_tree *ftree = tree;
608 ptvcursor_t *csr;
609 uint32_t flags;
611 phdr->phy = PHDR_802_11_PHY_11N;
613 if (add_subtree) {
614 ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_dot11n_mac, NULL, "802.11n MAC");
615 add_ppi_field_header(tvb, pinfo, ftree, &offset);
616 data_len -= 4; /* Subtract field header length */
619 if (data_len != PPI_80211N_MAC_LEN) {
620 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
621 return;
624 csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
626 flags = tvb_get_letohl(tvb, ptvcursor_current_offset(csr));
627 *n_mac_flags = flags;
628 phdr->phy_info.info_11n.has_bandwidth = true;
629 phdr->phy_info.info_11n.has_short_gi = true;
630 phdr->phy_info.info_11n.has_greenfield = true;
631 phdr->phy_info.info_11n.bandwidth = ((flags & DOT11N_FLAG_HT40) != 0);
632 phdr->phy_info.info_11n.short_gi = ((flags & DOT11N_FLAG_SHORT_GI) != 0);
633 phdr->phy_info.info_11n.greenfield = ((flags & DOT11N_FLAG_GREENFIELD) != 0);
634 if (DOT11N_IS_AGGREGATE(flags)) {
635 phdr->has_aggregate_info = 1;
636 phdr->aggregate_flags = 0;
637 if (!(flags & DOT11N_FLAG_MORE_AGGREGATES))
638 phdr->aggregate_flags |= PHDR_802_11_LAST_PART_OF_A_MPDU;
639 if (flags & DOT11N_FLAG_AGG_CRC_ERROR)
640 phdr->aggregate_flags |= PHDR_802_11_A_MPDU_DELIM_CRC_ERROR;
642 ptvcursor_add_with_subtree(csr, hf_80211n_mac_flags, 4, ENC_LITTLE_ENDIAN,
643 ett_dot11n_mac_flags);
644 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_greenfield, 4, ENC_LITTLE_ENDIAN);
645 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_ht20_40, 4, ENC_LITTLE_ENDIAN);
646 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_rx_guard_interval, 4, ENC_LITTLE_ENDIAN);
647 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_duplicate_rx, 4, ENC_LITTLE_ENDIAN);
648 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_aggregate, 4, ENC_LITTLE_ENDIAN);
649 ptvcursor_add_no_advance(csr, hf_80211n_mac_flags_more_aggregates, 4, ENC_LITTLE_ENDIAN);
650 ptvcursor_add(csr, hf_80211n_mac_flags_delimiter_crc_after, 4, ENC_LITTLE_ENDIAN); /* Last */
651 ptvcursor_pop_subtree(csr);
653 if (DOT11N_IS_AGGREGATE(flags)) {
654 *ampdu_id = tvb_get_letohl(tvb, ptvcursor_current_offset(csr));
655 phdr->aggregate_id = *ampdu_id;
657 ptvcursor_add(csr, hf_80211n_mac_ampdu_id, 4, ENC_LITTLE_ENDIAN);
658 ptvcursor_add(csr, hf_80211n_mac_num_delimiters, 1, ENC_LITTLE_ENDIAN);
660 if (add_subtree) {
661 ptvcursor_add(csr, hf_80211n_mac_reserved, 3, ENC_LITTLE_ENDIAN);
664 ptvcursor_free(csr);
667 static void
668 dissect_80211n_mac_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len, uint32_t *n_mac_flags, uint32_t *ampdu_id, struct ieee_802_11_phdr *phdr)
670 proto_tree *ftree;
671 proto_item *ti;
672 ptvcursor_t *csr;
673 uint8_t mcs;
674 uint8_t ness;
675 uint16_t ext_frequency;
676 char *chan_str;
678 ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_dot11n_mac_phy, NULL, "802.11n MAC+PHY");
679 add_ppi_field_header(tvb, pinfo, ftree, &offset);
680 data_len -= 4; /* Subtract field header length */
682 if (data_len != PPI_80211N_MAC_PHY_LEN) {
683 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
684 return;
687 dissect_80211n_mac(tvb, pinfo, ftree, offset, PPI_80211N_MAC_LEN,
688 false, n_mac_flags, ampdu_id, phdr);
689 offset += PPI_80211N_MAC_PHY_OFF;
691 csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
693 mcs = tvb_get_uint8(tvb, ptvcursor_current_offset(csr));
694 if (mcs != 255) {
695 phdr->phy_info.info_11n.has_mcs_index = true;
696 phdr->phy_info.info_11n.mcs_index = mcs;
698 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_mcs, 1, 255);
700 ness = tvb_get_uint8(tvb, ptvcursor_current_offset(csr));
701 phdr->phy_info.info_11n.has_ness = true;
702 phdr->phy_info.info_11n.ness = ness;
703 ti = ptvcursor_add(csr, hf_80211n_mac_phy_num_streams, 1, ENC_LITTLE_ENDIAN);
704 if (tvb_get_uint8(tvb, ptvcursor_current_offset(csr) - 1) == 0)
705 proto_item_append_text(ti, " (unknown)");
706 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_combined, 1, 255);
707 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant0_ctl, 1, 255);
708 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant1_ctl, 1, 255);
709 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant2_ctl, 1, 255);
710 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant3_ctl, 1, 255);
711 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant0_ext, 1, 255);
712 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant1_ext, 1, 255);
713 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant2_ext, 1, 255);
714 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant3_ext, 1, 255);
716 ext_frequency = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
717 chan_str = ieee80211_mhz_to_str(ext_frequency);
718 proto_tree_add_uint_format(ptvcursor_tree(csr), hf_80211n_mac_phy_ext_chan_freq, ptvcursor_tvbuff(csr),
719 ptvcursor_current_offset(csr), 2, ext_frequency, "Ext. Channel frequency: %s", chan_str);
720 g_free(chan_str);
721 ptvcursor_advance(csr, 2);
723 ptvcursor_add_with_subtree(csr, hf_80211n_mac_phy_ext_chan_flags, 2, ENC_LITTLE_ENDIAN,
724 ett_dot11n_mac_phy_ext_channel_flags);
725 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_turbo, 2, ENC_LITTLE_ENDIAN);
726 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_cck, 2, ENC_LITTLE_ENDIAN);
727 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_ofdm, 2, ENC_LITTLE_ENDIAN);
728 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_2ghz, 2, ENC_LITTLE_ENDIAN);
729 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_5ghz, 2, ENC_LITTLE_ENDIAN);
730 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_passive, 2, ENC_LITTLE_ENDIAN);
731 ptvcursor_add_no_advance(csr, hf_80211n_mac_phy_ext_chan_flags_dynamic, 2, ENC_LITTLE_ENDIAN);
732 ptvcursor_add(csr, hf_80211n_mac_phy_ext_chan_flags_gfsk, 2, ENC_LITTLE_ENDIAN);
733 ptvcursor_pop_subtree(csr);
735 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant0signal, 1, 0x80); /* -128 */
736 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant0noise, 1, 0x80);
737 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant1signal, 1, 0x80);
738 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant1noise, 1, 0x80);
739 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant2signal, 1, 0x80);
740 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant2noise, 1, 0x80);
741 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant3signal, 1, 0x80);
742 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_dbm_ant3noise, 1, 0x80);
743 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm0, 4, 0);
744 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm1, 4, 0);
745 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm2, 4, 0);
746 ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_evm3, 4, 0);
748 ptvcursor_free(csr);
751 static void
752 dissect_aggregation_extension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len)
754 proto_tree *ftree;
755 ptvcursor_t *csr;
757 ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_aggregation_extension, NULL, "Aggregation Extension");
758 add_ppi_field_header(tvb, pinfo, ftree, &offset);
759 data_len -= 4; /* Subtract field header length */
761 if (data_len != PPI_AGGREGATION_EXTENSION_LEN) {
762 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
763 return;
766 csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
768 ptvcursor_add(csr, hf_aggregation_extension_interface_id, 4, ENC_LITTLE_ENDIAN); /* Last */
769 ptvcursor_free(csr);
772 static void
773 dissect_8023_extension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int data_len)
775 proto_tree *ftree;
776 ptvcursor_t *csr;
778 ftree = proto_tree_add_subtree(tree, tvb, offset, data_len, ett_8023_extension, NULL, "802.3 Extension");
779 add_ppi_field_header(tvb, pinfo, ftree, &offset);
780 data_len -= 4; /* Subtract field header length */
782 if (data_len != PPI_8023_EXTENSION_LEN) {
783 proto_tree_add_expert_format(ftree, pinfo, &ei_ppi_invalid_length, tvb, offset, data_len, "Invalid length: %u", data_len);
784 return;
787 csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
789 ptvcursor_add_with_subtree(csr, hf_8023_extension_flags, 4, ENC_LITTLE_ENDIAN, ett_8023_extension_flags);
790 ptvcursor_add(csr, hf_8023_extension_flags_fcs_present, 4, ENC_LITTLE_ENDIAN);
791 ptvcursor_pop_subtree(csr);
793 ptvcursor_add_with_subtree(csr, hf_8023_extension_errors, 4, ENC_LITTLE_ENDIAN, ett_8023_extension_errors);
794 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_fcs, 4, ENC_LITTLE_ENDIAN);
795 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_sequence, 4, ENC_LITTLE_ENDIAN);
796 ptvcursor_add_no_advance(csr, hf_8023_extension_errors_symbol, 4, ENC_LITTLE_ENDIAN);
797 ptvcursor_add(csr, hf_8023_extension_errors_data, 4, ENC_LITTLE_ENDIAN);
798 ptvcursor_pop_subtree(csr);
800 ptvcursor_free(csr);
804 #define PADDING4(x) ((((x + 3) >> 2) << 2) - x)
805 #define ADD_BASIC_TAG(hf_tag) \
806 if (tree) \
807 proto_tree_add_item(ppi_tree, hf_tag, tvb, offset, data_len, ENC_NA)
809 static int
810 dissect_ppi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
812 proto_tree *ppi_tree = NULL, *ppi_flags_tree = NULL, *seg_tree = NULL, *ampdu_tree = NULL;
813 proto_tree *agg_tree = NULL;
814 proto_item *ti = NULL;
815 tvbuff_t *next_tvb;
816 int offset = 0;
817 unsigned version, flags;
818 int tot_len, data_len;
819 unsigned data_type;
820 uint32_t dlt;
821 uint32_t n_ext_flags = 0;
822 uint32_t ampdu_id = 0;
823 fragment_head *fd_head = NULL;
824 fragment_item *ft_fdh = NULL;
825 int mpdu_count = 0;
826 char *mpdu_str;
827 bool first_mpdu = true;
828 unsigned last_frame = 0;
829 int len_remain, /*pad_len = 0,*/ ampdu_len = 0;
830 struct ieee_802_11_phdr phdr;
832 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPI");
833 col_clear(pinfo->cinfo, COL_INFO);
835 version = tvb_get_uint8(tvb, offset);
836 flags = tvb_get_uint8(tvb, offset + 1);
838 tot_len = tvb_get_letohs(tvb, offset+2);
839 dlt = tvb_get_letohl(tvb, offset+4);
841 col_add_fstr(pinfo->cinfo, COL_INFO, "PPI version %u, %u bytes",
842 version, tot_len);
844 /* Dissect the packet */
845 if (tree) {
846 ti = proto_tree_add_protocol_format(tree, proto_ppi,
847 tvb, 0, tot_len, "PPI version %u, %u bytes", version, tot_len);
848 ppi_tree = proto_item_add_subtree(ti, ett_ppi_pph);
849 proto_tree_add_item(ppi_tree, hf_ppi_head_version,
850 tvb, offset, 1, ENC_LITTLE_ENDIAN);
852 ti = proto_tree_add_item(ppi_tree, hf_ppi_head_flags,
853 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
854 ppi_flags_tree = proto_item_add_subtree(ti, ett_ppi_flags);
855 proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_alignment,
856 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
857 proto_tree_add_item(ppi_flags_tree, hf_ppi_head_flag_reserved,
858 tvb, offset + 1, 1, ENC_LITTLE_ENDIAN);
860 proto_tree_add_item(ppi_tree, hf_ppi_head_len,
861 tvb, offset + 2, 2, ENC_LITTLE_ENDIAN);
862 proto_tree_add_item(ppi_tree, hf_ppi_head_dlt,
863 tvb, offset + 4, 4, ENC_LITTLE_ENDIAN);
866 tot_len -= PPI_V0_HEADER_LEN;
867 offset += 8;
869 /* We don't have any 802.11 metadata yet. */
870 memset(&phdr, 0, sizeof(phdr));
871 phdr.fcs_len = -1;
872 phdr.decrypted = false;
873 phdr.datapad = false;
874 phdr.phy = PHDR_802_11_PHY_UNKNOWN;
876 while (tot_len > 0) {
877 data_type = tvb_get_letohs(tvb, offset);
878 data_len = tvb_get_letohs(tvb, offset + 2) + 4;
879 tot_len -= data_len;
881 switch (data_type) {
883 case PPI_80211_COMMON:
884 dissect_80211_common(tvb, pinfo, ppi_tree, offset, data_len, &phdr);
885 break;
887 case PPI_80211N_MAC:
888 dissect_80211n_mac(tvb, pinfo, ppi_tree, offset, data_len,
889 true, &n_ext_flags, &ampdu_id, &phdr);
890 break;
892 case PPI_80211N_MAC_PHY:
893 dissect_80211n_mac_phy(tvb, pinfo, ppi_tree, offset,
894 data_len, &n_ext_flags, &ampdu_id, &phdr);
895 break;
897 case PPI_SPECTRUM_MAP:
898 ADD_BASIC_TAG(hf_spectrum_map);
899 break;
901 case PPI_PROCESS_INFO:
902 ADD_BASIC_TAG(hf_process_info);
903 break;
905 case PPI_CAPTURE_INFO:
906 ADD_BASIC_TAG(hf_capture_info);
907 break;
909 case PPI_AGGREGATION_EXTENSION:
910 dissect_aggregation_extension(tvb, pinfo, ppi_tree, offset, data_len);
911 break;
913 case PPI_8023_EXTENSION:
914 dissect_8023_extension(tvb, pinfo, ppi_tree, offset, data_len);
915 break;
917 case PPI_GPS_INFO:
918 if (ppi_gps_handle == NULL)
920 proto_tree_add_item(ppi_tree, hf_ppi_gps, tvb, offset, data_len, ENC_NA);
922 else /* we found a suitable dissector */
924 /* skip over the ppi_fieldheader, and pass it off to the dedicated GPS dissector */
925 next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1);
926 call_dissector(ppi_gps_handle, next_tvb, pinfo, ppi_tree);
928 break;
930 case PPI_VECTOR_INFO:
931 if (ppi_vector_handle == NULL)
933 proto_tree_add_item(ppi_tree, hf_ppi_vector, tvb, offset, data_len, ENC_NA);
935 else /* we found a suitable dissector */
937 /* skip over the ppi_fieldheader, and pass it off to the dedicated VECTOR dissector */
938 next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1);
939 call_dissector(ppi_vector_handle, next_tvb, pinfo, ppi_tree);
941 break;
943 case PPI_SENSOR_INFO:
944 if (ppi_sensor_handle == NULL)
946 proto_tree_add_item(ppi_tree, hf_ppi_harris, tvb, offset, data_len, ENC_NA);
948 else /* we found a suitable dissector */
950 /* skip over the ppi_fieldheader, and pass it off to the dedicated SENSOR dissector */
951 next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1);
952 call_dissector(ppi_sensor_handle, next_tvb, pinfo, ppi_tree);
954 break;
956 case PPI_ANTENNA_INFO:
957 if (ppi_antenna_handle == NULL)
959 proto_tree_add_item(ppi_tree, hf_ppi_antenna, tvb, offset, data_len, ENC_NA);
961 else /* we found a suitable dissector */
963 /* skip over the ppi_fieldheader, and pass it off to the dedicated ANTENNA dissector */
964 next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1);
965 call_dissector(ppi_antenna_handle, next_tvb, pinfo, ppi_tree);
967 break;
969 case FNET_PRIVATE:
970 if (ppi_fnet_handle == NULL)
972 proto_tree_add_item(ppi_tree, hf_ppi_fnet, tvb, offset, data_len, ENC_NA);
974 else /* we found a suitable dissector */
976 /* skip over the ppi_fieldheader, and pass it off to the dedicated FNET dissector */
977 next_tvb = tvb_new_subset_length_caplen(tvb, offset + 4, data_len - 4 , -1);
978 call_dissector(ppi_fnet_handle, next_tvb, pinfo, ppi_tree);
980 break;
982 default:
983 proto_tree_add_item(ppi_tree, hf_ppi_reserved, tvb, offset, data_len, ENC_NA);
986 offset += data_len;
987 if (IS_PPI_FLAG_ALIGN(flags)){
988 offset += PADDING4(offset);
993 * The Channel-Flags field is described as "Radiotap-formatted
994 * channel flags". The comment in the radiotap.org page about
995 * the suggested xchannel field says:
997 * As used, this field conflates channel properties (which
998 * need not be stored per packet but are more or less fixed)
999 * with packet properties (like the modulation).
1001 * The radiotap channel field, in practice, seems to be used,
1002 * in some cases, to indicate channel properties (from which
1003 * the packet modulation cannot be inferred) and, in other
1004 * cases, to indicate the packet's modulation.
1006 * The same applies to the Channel-Flags field. There is a capture
1007 * in which the Channel-Flags field indicates that the channel is
1008 * an OFDM-only channel with a center frequency of 2422 MHz, and
1009 * the data rate field indicates a 2 Mb/s rate, which means you can't
1010 * rely on the CCK/OFDM/dynamic CCK/OFDM bits in the channel field
1011 * to indicate anything.
1013 * That makes the Channel-Flags field unusable either for determining
1014 * the channel type or for determining the packet modulation,
1015 * as it cannot be determined how it's being used.
1017 * Fortunately, there are other ways to determine the packet
1018 * modulation:
1020 * if there's an FHSS flag, the packet was transmitted
1021 * using the 802.11 legacy FHSS modulation;
1023 * otherwise:
1025 * if there's an 802.11n MAC Extension header or an 802.11n
1026 * MAC+PHY Extension header, the packet was transmitted using
1027 * one of the 11n HT PHY's specified modulations;
1029 * otherwise:
1031 * if the data rate is 1 Mb/s or 2 Mb/s, the packet was
1032 * transmitted using the 802.11 legacy DSSS modulation
1033 * (we ignore the IR PHY - was it ever implemented?);
1035 * if the data rate is 5 Mb/s or 11 Mb/s, the packet
1036 * was transmitted using the 802.11b DSSS/CCK modulation
1037 * (or the now-obsolete DSSS/PBCC modulation; *if* we can
1038 * rely on the channel/xchannel field's "CCK channel" and
1039 * "Dynamic CCK-OFDM channel" flags, the absence of either
1040 * flag would presumably indicate DSSS/PBCC);
1042 * if the data rate is 22 Mb/s or 33 Mb/s, the packet was
1043 * transmitted using the 802.11b DSSS/PBCC modulation (as
1044 * those speeds aren't supported by DSSS/CCK);
1046 * if the data rate is one of the OFDM rates for the 11a
1047 * OFDM PHY and the OFDM part of the 11g ERP PHY, the
1048 * packet was transmitted with the 11g/11a OFDM modulation.
1050 * We've already handled the 11n headers, and may have attempted
1051 * to use the Channel-Flags field to guess the modulation. That
1052 * guess might get the wrong answer for 11g "Dynamic CCK-OFDM"
1053 * channels.
1055 * If we have the data rate, we use it to:
1057 * fix up the 11g channels;
1059 * determine the modulation if we haven't been able to
1060 * determine it any other way.
1062 if (phdr.has_data_rate) {
1063 if (phdr.phy == PHDR_802_11_PHY_UNKNOWN) {
1065 * We don't know they PHY, but we do have the
1066 * data rate; try to guess it based on the
1067 * data rate and channel/center frequency.
1069 if (RATE_IS_DSSS(phdr.data_rate)) {
1070 /* 11b */
1071 phdr.phy = PHDR_802_11_PHY_11B;
1072 } else if (RATE_IS_OFDM(phdr.data_rate)) {
1073 /* 11a or 11g, depending on the band. */
1074 if (phdr.has_frequency) {
1075 if (FREQ_IS_BG(phdr.frequency)) {
1076 /* 11g */
1077 phdr.phy = PHDR_802_11_PHY_11G;
1078 } else {
1079 /* 11a */
1080 phdr.phy = PHDR_802_11_PHY_11A;
1084 } else if (phdr.phy == PHDR_802_11_PHY_11G) {
1085 if (RATE_IS_DSSS(phdr.data_rate)) {
1086 /* DSSS, so 11b. */
1087 phdr.phy = PHDR_802_11_PHY_11B;
1093 * There is no indication, for HR/DSSS (11b/11g), whether
1094 * the packet had a long or short preamble.
1096 if (phdr.phy == PHDR_802_11_PHY_11B)
1097 phdr.phy_info.info_11b.has_short_preamble = false;
1099 if (ppi_ampdu_reassemble && DOT11N_IS_AGGREGATE(n_ext_flags)) {
1100 len_remain = tvb_captured_length_remaining(tvb, offset);
1101 #if 0 /* XXX: pad_len never actually used ?? */
1102 if (DOT11N_MORE_AGGREGATES(n_ext_flags)) {
1103 pad_len = PADDING4(len_remain);
1105 #endif
1106 pinfo->fragmented = true;
1108 /* Make sure we aren't going to go past AGGREGATE_MAX
1109 * and caclulate our full A-MPDU length */
1110 fd_head = fragment_get(&ampdu_reassembly_table, pinfo, ampdu_id, NULL);
1111 if (fd_head) {
1112 for (ft_fdh = fd_head->next; ft_fdh; ft_fdh = ft_fdh->next) {
1113 ampdu_len += ft_fdh->len + PADDING4(ft_fdh->len) + 4;
1116 if (ampdu_len > AGGREGATE_MAX) {
1117 proto_tree_add_expert_format(ppi_tree, pinfo, &ei_ppi_invalid_length, tvb, offset, -1, "Aggregate length greater than maximum (%u)", AGGREGATE_MAX);
1118 return offset;
1122 * Note that we never actually reassemble our A-MPDUs. Doing
1123 * so would require prepending each MPDU with an A-MPDU delimiter
1124 * and appending it with padding, only to hand it off to some
1125 * routine which would un-do the work we just did. We're using
1126 * the reassembly code to track MPDU sizes and frame numbers.
1128 /*??fd_head = */fragment_add_seq_next(&ampdu_reassembly_table,
1129 tvb, offset, pinfo, ampdu_id, NULL, len_remain, true);
1130 pinfo->fragmented = true;
1132 /* Do reassembly? */
1133 fd_head = fragment_get(&ampdu_reassembly_table, pinfo, ampdu_id, NULL);
1135 /* Show our fragments */
1136 if (fd_head && tree) {
1137 ft_fdh = fd_head->next;
1138 /* List our fragments */
1139 seg_tree = proto_tree_add_subtree_format(ppi_tree, tvb, offset, -1,
1140 ett_ampdu_segments, &ti, "A-MPDU (%u bytes w/hdrs):", ampdu_len);
1141 proto_item_set_generated(ti);
1143 while (ft_fdh) {
1144 if (ft_fdh->tvb_data && ft_fdh->len) {
1145 last_frame = ft_fdh->frame;
1146 if (!first_mpdu)
1147 proto_item_append_text(ti, ",");
1148 first_mpdu = false;
1149 proto_item_append_text(ti, " #%u(%u)",
1150 ft_fdh->frame, ft_fdh->len);
1151 proto_tree_add_uint_format(seg_tree, hf_ampdu_segment,
1152 tvb, 0, 0, last_frame,
1153 "Frame: %u (%u byte%s)",
1154 last_frame,
1155 ft_fdh->len,
1156 plurality(ft_fdh->len, "", "s"));
1158 ft_fdh = ft_fdh->next;
1160 if (last_frame && last_frame != pinfo->num)
1161 proto_tree_add_uint(seg_tree, hf_ampdu_reassembled_in,
1162 tvb, 0, 0, last_frame);
1165 if (fd_head && !DOT11N_MORE_AGGREGATES(n_ext_flags)) {
1166 if (tree) {
1167 ti = proto_tree_add_protocol_format(tree,
1168 proto_get_id_by_filter_name("wlan_aggregate"),
1169 tvb, 0, tot_len, "IEEE 802.11 Aggregate MPDU");
1170 agg_tree = proto_item_add_subtree(ti, ett_ampdu);
1173 for (ft_fdh = fd_head->next; ft_fdh; ft_fdh = ft_fdh->next) {
1174 if (ft_fdh->tvb_data && ft_fdh->len) {
1175 mpdu_count++;
1176 mpdu_str = wmem_strdup_printf(pinfo->pool, "MPDU #%d", mpdu_count);
1178 next_tvb = tvb_new_chain(tvb, ft_fdh->tvb_data);
1179 add_new_data_source(pinfo, next_tvb, mpdu_str);
1181 ampdu_tree = proto_tree_add_subtree(agg_tree, next_tvb, 0, -1, ett_ampdu_segment, NULL, mpdu_str);
1182 call_dissector_with_data(ieee80211_radio_handle, next_tvb, pinfo, ampdu_tree, &phdr);
1185 proto_tree_add_uint(seg_tree, hf_ampdu_count, tvb, 0, 0, mpdu_count);
1186 pinfo->fragmented=false;
1187 } else {
1188 next_tvb = tvb_new_subset_remaining(tvb, offset);
1189 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IEEE 802.11n");
1190 col_set_str(pinfo->cinfo, COL_INFO, "Unreassembled A-MPDU data");
1191 call_data_dissector(next_tvb, pinfo, tree);
1193 return tvb_captured_length(tvb);
1196 next_tvb = tvb_new_subset_remaining(tvb, offset);
1198 * Handle LINKTYPE_IEEE802_11, which is 105, specially; call the
1199 * "802.11 with radio information" dissector, and pass it a pointer
1200 * to the struct ieee_802_11_phdr we've constructed from the PPI data,
1201 * so that it can display that information.
1203 * Handle everything else with the pcap_pktdata dissector, letting
1204 * it do whatever needs to be done about pseudo-headers.
1206 if (dlt == 105) {
1207 /* LINKTYPE_IEEE802_11 */
1208 call_dissector_with_data(ieee80211_radio_handle, next_tvb, pinfo, tree, &phdr);
1209 } else {
1210 /* Everything else. */
1211 call_dissector_with_data(pcap_pktdata_handle, next_tvb, pinfo, tree, &dlt);
1213 return tvb_captured_length(tvb);
1216 /* Establish our beachhead */
1218 void
1219 proto_register_ppi(void)
1221 static hf_register_info hf[] = {
1222 { &hf_ppi_head_version,
1223 { "Version", "ppi.version",
1224 FT_UINT8, BASE_DEC, NULL, 0x0,
1225 "PPI header format version", HFILL } },
1226 { &hf_ppi_head_flags,
1227 { "Flags", "ppi.flags",
1228 FT_UINT8, BASE_HEX, NULL, 0x0,
1229 "PPI header flags", HFILL } },
1230 { &hf_ppi_head_flag_alignment,
1231 { "Alignment", "ppi.flags.alignment",
1232 FT_BOOLEAN, 8, TFS(&tfs_ppi_head_flag_alignment), 0x01,
1233 "PPI header flags - 32bit Alignment", HFILL } },
1234 { &hf_ppi_head_flag_reserved,
1235 { "Reserved", "ppi.flags.reserved",
1236 FT_UINT8, BASE_HEX, NULL, 0xFE,
1237 "PPI header flags - Reserved Flags", HFILL } },
1238 { &hf_ppi_head_len,
1239 { "Header length", "ppi.length",
1240 FT_UINT16, BASE_DEC, NULL, 0x0,
1241 "Length of header including payload", HFILL } },
1242 { &hf_ppi_head_dlt,
1243 { "DLT", "ppi.dlt",
1244 FT_UINT32, BASE_DEC, NULL, 0x0, "libpcap Data Link Type (DLT) of the payload", HFILL } },
1246 { &hf_ppi_field_type,
1247 { "Field type", "ppi.field_type",
1248 FT_UINT16, BASE_DEC, VALS(vs_ppi_field_type), 0x0, "PPI data field type", HFILL } },
1249 { &hf_ppi_field_len,
1250 { "Field length", "ppi.field_len",
1251 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI data field length", HFILL } },
1253 { &hf_80211_common_tsft,
1254 { "TSFT", "ppi.80211-common.tsft",
1255 FT_UINT64, BASE_DEC, NULL, 0x0, "PPI 802.11-Common Timing Synchronization Function Timer (TSFT)", HFILL } },
1256 { &hf_80211_common_flags,
1257 { "Flags", "ppi.80211-common.flags",
1258 FT_UINT16, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Flags", HFILL } },
1259 { &hf_80211_common_flags_fcs,
1260 { "FCS present flag", "ppi.80211-common.flags.fcs",
1261 FT_BOOLEAN, 16, TFS(&tfs_present_absent), DOT11_FLAG_HAVE_FCS, "PPI 802.11-Common Frame Check Sequence (FCS) Present Flag", HFILL } },
1262 { &hf_80211_common_flags_tsft,
1263 { "TSFT flag", "ppi.80211-common.flags.tsft",
1264 FT_BOOLEAN, 16, TFS(&tfs_tsft_ms), DOT11_FLAG_TSF_TIMER_MS, "PPI 802.11-Common Timing Synchronization Function Timer (TSFT) msec/usec flag", HFILL } },
1265 { &hf_80211_common_flags_fcs_valid,
1266 { "FCS validity", "ppi.80211-common.flags.fcs-invalid",
1267 FT_BOOLEAN, 16, TFS(&tfs_invalid_valid), DOT11_FLAG_FCS_INVALID, "PPI 802.11-Common Frame Check Sequence (FCS) Validity flag", HFILL } },
1268 { &hf_80211_common_flags_phy_err,
1269 { "PHY error flag", "ppi.80211-common.flags.phy-err",
1270 FT_BOOLEAN, 16, TFS(&tfs_phy_error), DOT11_FLAG_PHY_ERROR, "PPI 802.11-Common Physical level (PHY) Error", HFILL } },
1271 { &hf_80211_common_rate,
1272 { "Data rate", "ppi.80211-common.rate",
1273 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI 802.11-Common Data Rate (x 500 Kbps)", HFILL } },
1274 { &hf_80211_common_chan_freq,
1275 { "Channel frequency", "ppi.80211-common.chan.freq",
1276 FT_UINT16, BASE_DEC, NULL, 0x0,
1277 "PPI 802.11-Common Channel Frequency", HFILL } },
1278 { &hf_80211_common_chan_flags,
1279 { "Channel flags", "ppi.80211-common.chan.flags",
1280 FT_UINT16, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Channel Flags", HFILL } },
1282 { &hf_80211_common_chan_flags_turbo,
1283 { "Turbo", "ppi.80211-common.chan.flags.turbo",
1284 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_TURBO, "PPI 802.11-Common Channel Flags Turbo", HFILL } },
1285 { &hf_80211_common_chan_flags_cck,
1286 { "Complementary Code Keying (CCK)", "ppi.80211-common.chan.flags.cck",
1287 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_CCK, "PPI 802.11-Common Channel Flags Complementary Code Keying (CCK) Modulation", HFILL } },
1288 { &hf_80211_common_chan_flags_ofdm,
1289 { "Orthogonal Frequency-Division Multiplexing (OFDM)", "ppi.80211-common.chan.flags.ofdm",
1290 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_OFDM, "PPI 802.11-Common Channel Flags Orthogonal Frequency-Division Multiplexing (OFDM)", HFILL } },
1291 { &hf_80211_common_chan_flags_2ghz,
1292 { "2 GHz spectrum", "ppi.80211-common.chan.flags.2ghz",
1293 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_2GHZ, "PPI 802.11-Common Channel Flags 2 GHz spectrum", HFILL } },
1294 { &hf_80211_common_chan_flags_5ghz,
1295 { "5 GHz spectrum", "ppi.80211-common.chan.flags.5ghz",
1296 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_5GHZ, "PPI 802.11-Common Channel Flags 5 GHz spectrum", HFILL } },
1297 { &hf_80211_common_chan_flags_passive,
1298 { "Passive", "ppi.80211-common.chan.flags.passive",
1299 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_PASSIVE, "PPI 802.11-Common Channel Flags Passive", HFILL } },
1300 { &hf_80211_common_chan_flags_dynamic,
1301 { "Dynamic CCK-OFDM", "ppi.80211-common.chan.flags.dynamic",
1302 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_DYN, "PPI 802.11-Common Channel Flags Dynamic CCK-OFDM Channel", HFILL } },
1303 { &hf_80211_common_chan_flags_gfsk,
1304 { "Gaussian Frequency Shift Keying (GFSK)", "ppi.80211-common.chan.flags.gfsk",
1305 FT_BOOLEAN, 16, NULL, IEEE80211_CHAN_GFSK, "PPI 802.11-Common Channel Flags Gaussian Frequency Shift Keying (GFSK) Modulation", HFILL } },
1307 { &hf_80211_common_fhss_hopset,
1308 { "FHSS hopset", "ppi.80211-common.fhss.hopset",
1309 FT_UINT8, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Frequency-Hopping Spread Spectrum (FHSS) Hopset", HFILL } },
1310 { &hf_80211_common_fhss_pattern,
1311 { "FHSS pattern", "ppi.80211-common.fhss.pattern",
1312 FT_UINT8, BASE_HEX, NULL, 0x0, "PPI 802.11-Common Frequency-Hopping Spread Spectrum (FHSS) Pattern", HFILL } },
1313 { &hf_80211_common_dbm_antsignal,
1314 { "dBm antenna signal", "ppi.80211-common.dbm.antsignal",
1315 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11-Common dBm Antenna Signal", HFILL } },
1316 { &hf_80211_common_dbm_antnoise,
1317 { "dBm antenna noise", "ppi.80211-common.dbm.antnoise",
1318 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11-Common dBm Antenna Noise", HFILL } },
1320 /* 802.11n MAC */
1321 { &hf_80211n_mac_flags,
1322 { "MAC flags", "ppi.80211n-mac.flags",
1323 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC flags", HFILL } },
1324 { &hf_80211n_mac_flags_greenfield,
1325 { "Greenfield flag", "ppi.80211n-mac.flags.greenfield",
1326 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_GREENFIELD, "PPI 802.11n MAC Greenfield Flag", HFILL } },
1327 { &hf_80211n_mac_flags_ht20_40,
1328 { "HT20/HT40 flag", "ppi.80211n-mac.flags.ht20_40",
1329 FT_BOOLEAN, 32, TFS(&tfs_ht20_40), DOT11N_FLAG_HT40, "PPI 802.11n MAC HT20/HT40 Flag", HFILL } },
1330 { &hf_80211n_mac_flags_rx_guard_interval,
1331 { "RX Short Guard Interval (SGI) flag", "ppi.80211n-mac.flags.rx.short_guard_interval",
1332 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_SHORT_GI, "PPI 802.11n MAC RX Short Guard Interval (SGI) Flag", HFILL } },
1333 { &hf_80211n_mac_flags_duplicate_rx,
1334 { "Duplicate RX flag", "ppi.80211n-mac.flags.rx.duplicate",
1335 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_DUPLICATE_RX, "PPI 802.11n MAC Duplicate RX Flag", HFILL } },
1336 { &hf_80211n_mac_flags_aggregate,
1337 { "Aggregate flag", "ppi.80211n-mac.flags.agg",
1338 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_IS_AGGREGATE, "PPI 802.11 MAC Aggregate Flag", HFILL } },
1339 { &hf_80211n_mac_flags_more_aggregates,
1340 { "More aggregates flag", "ppi.80211n-mac.flags.more_agg",
1341 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_MORE_AGGREGATES, "PPI 802.11n MAC More Aggregates Flag", HFILL } },
1342 { &hf_80211n_mac_flags_delimiter_crc_after,
1343 { "A-MPDU Delimiter CRC error after this frame flag", "ppi.80211n-mac.flags.delim_crc_error_after",
1344 FT_BOOLEAN, 32, NULL, DOT11N_FLAG_AGG_CRC_ERROR, "PPI 802.11n MAC A-MPDU Delimiter CRC Error After This Frame Flag", HFILL } },
1345 { &hf_80211n_mac_ampdu_id,
1346 { "AMPDU-ID", "ppi.80211n-mac.ampdu_id",
1347 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC AMPDU-ID", HFILL } },
1348 { &hf_80211n_mac_num_delimiters,
1349 { "Num-Delimiters", "ppi.80211n-mac.num_delimiters",
1350 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC number of zero-length pad delimiters", HFILL } },
1351 { &hf_80211n_mac_reserved,
1352 { "Reserved", "ppi.80211n-mac.reserved",
1353 FT_UINT24, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC Reserved", HFILL } },
1356 /* 802.11n MAC+PHY */
1357 { &hf_80211n_mac_phy_mcs,
1358 { "MCS", "ppi.80211n-mac-phy.mcs",
1359 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Modulation Coding Scheme (MCS)", HFILL } },
1360 { &hf_80211n_mac_phy_num_streams,
1361 { "Number of spatial streams", "ppi.80211n-mac-phy.num_streams",
1362 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY number of spatial streams", HFILL } },
1363 { &hf_80211n_mac_phy_rssi_combined,
1364 { "RSSI combined", "ppi.80211n-mac-phy.rssi.combined",
1365 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Received Signal Strength Indication (RSSI) Combined", HFILL } },
1366 { &hf_80211n_mac_phy_rssi_ant0_ctl,
1367 { "Antenna 0 control RSSI", "ppi.80211n-mac-phy.rssi.ant0ctl",
1368 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 0 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1369 { &hf_80211n_mac_phy_rssi_ant1_ctl,
1370 { "Antenna 1 control RSSI", "ppi.80211n-mac-phy.rssi.ant1ctl",
1371 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 1 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1372 { &hf_80211n_mac_phy_rssi_ant2_ctl,
1373 { "Antenna 2 control RSSI", "ppi.80211n-mac-phy.rssi.ant2ctl",
1374 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 2 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1375 { &hf_80211n_mac_phy_rssi_ant3_ctl,
1376 { "Antenna 3 control RSSI", "ppi.80211n-mac-phy.rssi.ant3ctl",
1377 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 3 Control Channel Received Signal Strength Indication (RSSI)", HFILL } },
1378 { &hf_80211n_mac_phy_rssi_ant0_ext,
1379 { "Antenna 0 extension RSSI", "ppi.80211n-mac-phy.rssi.ant0ext",
1380 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 0 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1381 { &hf_80211n_mac_phy_rssi_ant1_ext,
1382 { "Antenna 1 extension RSSI", "ppi.80211n-mac-phy.rssi.ant1ext",
1383 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 1 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1384 { &hf_80211n_mac_phy_rssi_ant2_ext,
1385 { "Antenna 2 extension RSSI", "ppi.80211n-mac-phy.rssi.ant2ext",
1386 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 2 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1387 { &hf_80211n_mac_phy_rssi_ant3_ext,
1388 { "Antenna 3 extension RSSI", "ppi.80211n-mac-phy.rssi.ant3ext",
1389 FT_UINT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Antenna 3 Extension Channel Received Signal Strength Indication (RSSI)", HFILL } },
1390 { &hf_80211n_mac_phy_ext_chan_freq,
1391 { "Extended channel frequency", "ppi.80211-mac-phy.ext-chan.freq",
1392 FT_UINT16, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Extended Channel Frequency", HFILL } },
1393 { &hf_80211n_mac_phy_ext_chan_flags,
1394 { "Channel flags", "ppi.80211-mac-phy.ext-chan.flags",
1395 FT_UINT16, BASE_HEX, NULL, 0x0, "PPI 802.11n MAC+PHY Channel Flags", HFILL } },
1396 { &hf_80211n_mac_phy_ext_chan_flags_turbo,
1397 { "Turbo", "ppi.80211-mac-phy.ext-chan.flags.turbo",
1398 FT_BOOLEAN, 16, NULL, 0x0010, "PPI 802.11n MAC+PHY Channel Flags Turbo", HFILL } },
1399 { &hf_80211n_mac_phy_ext_chan_flags_cck,
1400 { "Complementary Code Keying (CCK)", "ppi.80211-mac-phy.ext-chan.flags.cck",
1401 FT_BOOLEAN, 16, NULL, 0x0020, "PPI 802.11n MAC+PHY Channel Flags Complementary Code Keying (CCK) Modulation", HFILL } },
1402 { &hf_80211n_mac_phy_ext_chan_flags_ofdm,
1403 { "Orthogonal Frequency-Division Multiplexing (OFDM)", "ppi.80211-mac-phy.ext-chan.flags.ofdm",
1404 FT_BOOLEAN, 16, NULL, 0x0040, "PPI 802.11n MAC+PHY Channel Flags Orthogonal Frequency-Division Multiplexing (OFDM)", HFILL } },
1405 { &hf_80211n_mac_phy_ext_chan_flags_2ghz,
1406 { "2 GHz spectrum", "ppi.80211-mac-phy.ext-chan.flags.2ghz",
1407 FT_BOOLEAN, 16, NULL, 0x0080, "PPI 802.11n MAC+PHY Channel Flags 2 GHz spectrum", HFILL } },
1408 { &hf_80211n_mac_phy_ext_chan_flags_5ghz,
1409 { "5 GHz spectrum", "ppi.80211-mac-phy.ext-chan.flags.5ghz",
1410 FT_BOOLEAN, 16, NULL, 0x0100, "PPI 802.11n MAC+PHY Channel Flags 5 GHz spectrum", HFILL } },
1411 { &hf_80211n_mac_phy_ext_chan_flags_passive,
1412 { "Passive", "ppi.80211-mac-phy.ext-chan.flags.passive",
1413 FT_BOOLEAN, 16, NULL, 0x0200, "PPI 802.11n MAC+PHY Channel Flags Passive", HFILL } },
1414 { &hf_80211n_mac_phy_ext_chan_flags_dynamic,
1415 { "Dynamic CCK-OFDM", "ppi.80211-mac-phy.ext-chan.flags.dynamic",
1416 FT_BOOLEAN, 16, NULL, 0x0400, "PPI 802.11n MAC+PHY Channel Flags Dynamic CCK-OFDM Channel", HFILL } },
1417 { &hf_80211n_mac_phy_ext_chan_flags_gfsk,
1418 { "Gaussian Frequency Shift Keying (GFSK)", "ppi.80211-mac-phy.ext-chan.flags.gfsk",
1419 FT_BOOLEAN, 16, NULL, 0x0800, "PPI 802.11n MAC+PHY Channel Flags Gaussian Frequency Shift Keying (GFSK) Modulation", HFILL } },
1420 { &hf_80211n_mac_phy_dbm_ant0signal,
1421 { "dBm antenna 0 signal", "ppi.80211n-mac-phy.dbmant0.signal",
1422 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 0 Signal", HFILL } },
1423 { &hf_80211n_mac_phy_dbm_ant0noise,
1424 { "dBm antenna 0 noise", "ppi.80211n-mac-phy.dbmant0.noise",
1425 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 0 Noise", HFILL } },
1426 { &hf_80211n_mac_phy_dbm_ant1signal,
1427 { "dBm antenna 1 signal", "ppi.80211n-mac-phy.dbmant1.signal",
1428 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 1 Signal", HFILL } },
1429 { &hf_80211n_mac_phy_dbm_ant1noise,
1430 { "dBm antenna 1 noise", "ppi.80211n-mac-phy.dbmant1.noise",
1431 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 1 Noise", HFILL } },
1432 { &hf_80211n_mac_phy_dbm_ant2signal,
1433 { "dBm antenna 2 signal", "ppi.80211n-mac-phy.dbmant2.signal",
1434 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 2 Signal", HFILL } },
1435 { &hf_80211n_mac_phy_dbm_ant2noise,
1436 { "dBm antenna 2 noise", "ppi.80211n-mac-phy.dbmant2.noise",
1437 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 2 Noise", HFILL } },
1438 { &hf_80211n_mac_phy_dbm_ant3signal,
1439 { "dBm antenna 3 signal", "ppi.80211n-mac-phy.dbmant3.signal",
1440 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 3 Signal", HFILL } },
1441 { &hf_80211n_mac_phy_dbm_ant3noise,
1442 { "dBm antenna 3 noise", "ppi.80211n-mac-phy.dbmant3.noise",
1443 FT_INT8, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY dBm Antenna 3 Noise", HFILL } },
1444 { &hf_80211n_mac_phy_evm0,
1445 { "EVM-0", "ppi.80211n-mac-phy.evm0",
1446 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 0", HFILL } },
1447 { &hf_80211n_mac_phy_evm1,
1448 { "EVM-1", "ppi.80211n-mac-phy.evm1",
1449 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 1", HFILL } },
1450 { &hf_80211n_mac_phy_evm2,
1451 { "EVM-2", "ppi.80211n-mac-phy.evm2",
1452 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 2", HFILL } },
1453 { &hf_80211n_mac_phy_evm3,
1454 { "EVM-3", "ppi.80211n-mac-phy.evm3",
1455 FT_UINT32, BASE_DEC, NULL, 0x0, "PPI 802.11n MAC+PHY Error Vector Magnitude (EVM) for chain 3", HFILL } },
1457 { &hf_ampdu_segment,
1458 { "A-MPDU", "ppi.80211n-mac.ampdu",
1459 FT_FRAMENUM, BASE_NONE, NULL, 0x0, "802.11n Aggregated MAC Protocol Data Unit (A-MPDU)", HFILL }},
1460 #if 0
1461 { &hf_ampdu_segments,
1462 { "Reassembled A-MPDU", "ppi.80211n-mac.ampdu.reassembled",
1463 FT_NONE, BASE_NONE, NULL, 0x0, "Reassembled Aggregated MAC Protocol Data Unit (A-MPDU)", HFILL }},
1464 #endif
1465 { &hf_ampdu_reassembled_in,
1466 { "Reassembled A-MPDU in frame", "ppi.80211n-mac.ampdu.reassembled_in",
1467 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1468 "The A-MPDU that doesn't end in this segment is reassembled in this frame",
1469 HFILL }},
1470 { &hf_ampdu_count,
1471 { "MPDU count", "ppi.80211n-mac.ampdu.count",
1472 FT_UINT16, BASE_DEC, NULL, 0x0, "The number of aggregated MAC Protocol Data Units (MPDUs)", HFILL }},
1474 { &hf_spectrum_map,
1475 { "Radio spectrum map", "ppi.spectrum-map",
1476 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Radio spectrum map", HFILL } },
1477 { &hf_process_info,
1478 { "Process information", "ppi.proc-info",
1479 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Process information", HFILL } },
1480 { &hf_capture_info,
1481 { "Capture information", "ppi.cap-info",
1482 FT_BYTES, BASE_NONE, NULL, 0x0, "PPI Capture information", HFILL } },
1484 /* Aggregation Extension */
1485 { &hf_aggregation_extension_interface_id,
1486 { "Interface ID", "ppi.aggregation_extension.interface_id",
1487 FT_UINT32, BASE_DEC, NULL, 0x0, "Zero-based index of the physical interface the packet was captured from", HFILL } },
1489 /* 802.3 Extension */
1490 { &hf_8023_extension_flags,
1491 { "Flags", "ppi.8023_extension.flags",
1492 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.3 Extension Flags", HFILL } },
1493 { &hf_8023_extension_flags_fcs_present,
1494 { "FCS Present Flag", "ppi.8023_extension.flags.fcs_present",
1495 FT_BOOLEAN, 32, NULL, 0x00000001, "FCS (4 bytes) is present at the end of the packet", HFILL } },
1496 { &hf_8023_extension_errors,
1497 { "Errors", "ppi.8023_extension.errors",
1498 FT_UINT32, BASE_HEX, NULL, 0x0, "PPI 802.3 Extension Errors", HFILL } },
1499 { &hf_8023_extension_errors_fcs,
1500 { "FCS Error", "ppi.8023_extension.errors.fcs",
1501 FT_BOOLEAN, 32, NULL, 0x00000001,
1502 "PPI 802.3 Extension FCS Error", HFILL } },
1503 { &hf_8023_extension_errors_sequence,
1504 { "Sequence Error", "ppi.8023_extension.errors.sequence",
1505 FT_BOOLEAN, 32, NULL, 0x00000002,
1506 "PPI 802.3 Extension Sequence Error", HFILL } },
1507 { &hf_8023_extension_errors_symbol,
1508 { "Symbol Error", "ppi.8023_extension.errors.symbol",
1509 FT_BOOLEAN, 32, NULL, 0x00000004,
1510 "PPI 802.3 Extension Symbol Error", HFILL } },
1511 { &hf_8023_extension_errors_data,
1512 { "Data Error", "ppi.8023_extension.errors.data",
1513 FT_BOOLEAN, 32, NULL, 0x00000008,
1514 "PPI 802.3 Extension Data Error", HFILL } },
1516 /* Generated from convert_proto_tree_add_text.pl */
1517 { &hf_ppi_gps, { "GPS", "ppi.gps", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1518 { &hf_ppi_vector, { "VECTOR", "ppi.vector", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1519 { &hf_ppi_harris, { "HARRIS", "ppi.harris", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1520 { &hf_ppi_antenna, { "ANTENNA", "ppi.antenna", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1521 { &hf_ppi_fnet, { "FNET", "ppi.fnet", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1522 { &hf_ppi_reserved, { "Reserved", "ppi.reserved", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1525 static int *ett[] = {
1526 &ett_ppi_pph,
1527 &ett_ppi_flags,
1528 &ett_dot11_common,
1529 &ett_dot11_common_flags,
1530 &ett_dot11_common_channel_flags,
1531 &ett_dot11n_mac,
1532 &ett_dot11n_mac_flags,
1533 &ett_dot11n_mac_phy,
1534 &ett_dot11n_mac_phy_ext_channel_flags,
1535 &ett_ampdu_segments,
1536 &ett_ampdu,
1537 &ett_ampdu_segment,
1538 &ett_aggregation_extension,
1539 &ett_8023_extension,
1540 &ett_8023_extension_flags,
1541 &ett_8023_extension_errors
1544 static ei_register_info ei[] = {
1545 { &ei_ppi_invalid_length, { "ppi.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
1548 module_t *ppi_module;
1549 expert_module_t* expert_ppi;
1551 proto_ppi = proto_register_protocol("PPI Packet Header", "PPI", "ppi");
1552 proto_register_field_array(proto_ppi, hf, array_length(hf));
1553 proto_register_subtree_array(ett, array_length(ett));
1554 expert_ppi = expert_register_protocol(proto_ppi);
1555 expert_register_field_array(expert_ppi, ei, array_length(ei));
1557 ppi_handle = register_dissector("ppi", dissect_ppi, proto_ppi);
1558 register_capture_dissector_table("ppi", "PPI");
1560 reassembly_table_register(&ampdu_reassembly_table,
1561 &addresses_reassembly_table_functions);
1563 /* Configuration options */
1564 ppi_module = prefs_register_protocol(proto_ppi, NULL);
1565 prefs_register_bool_preference(ppi_module, "reassemble",
1566 "Reassemble fragmented 802.11 A-MPDUs",
1567 "Whether fragmented 802.11 aggregated MPDUs should be reassembled",
1568 &ppi_ampdu_reassemble);
1571 void
1572 proto_reg_handoff_ppi(void)
1574 capture_dissector_handle_t ppi_cap_handle;
1576 ieee80211_radio_handle = find_dissector_add_dependency("wlan_radio", proto_ppi);
1577 pcap_pktdata_handle = find_dissector_add_dependency("pcap_pktdata", proto_ppi);
1578 ppi_gps_handle = find_dissector_add_dependency("ppi_gps", proto_ppi);
1579 ppi_vector_handle = find_dissector_add_dependency("ppi_vector", proto_ppi);
1580 ppi_sensor_handle = find_dissector_add_dependency("ppi_sensor", proto_ppi);
1581 ppi_antenna_handle = find_dissector_add_dependency("ppi_antenna", proto_ppi);
1582 ppi_fnet_handle = find_dissector_add_dependency("ppi_fnet", proto_ppi);
1584 dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_handle);
1585 ppi_cap_handle = create_capture_dissector_handle(capture_ppi, proto_ppi);
1586 capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_PPI, ppi_cap_handle);
1590 * Editor modelines
1592 * Local Variables:
1593 * c-basic-offset: 4
1594 * tab-width: 8
1595 * indent-tabs-mode: nil
1596 * End:
1598 * ex: set shiftwidth=4 tabstop=8 expandtab:
1599 * :indentSize=4:tabSize=8:noTabs=true: