141
141
static int hf_radiotap_length = -1;
142
142
static int hf_radiotap_present = -1;
143
143
static int hf_radiotap_mactime = -1;
144
static int hf_radiotap_channel = -1;
144
145
static int hf_radiotap_channel_frequency = -1;
145
146
static int hf_radiotap_channel_flags = -1;
147
static int hf_radiotap_fhss_hopset = -1;
148
static int hf_radiotap_fhss_pattern = -1;
146
149
static int hf_radiotap_datarate = -1;
147
150
static int hf_radiotap_antenna = -1;
148
151
static int hf_radiotap_dbm_antsignal = -1;
149
152
static int hf_radiotap_db_antsignal = -1;
150
153
static int hf_radiotap_dbm_antnoise = -1;
151
154
static int hf_radiotap_db_antnoise = -1;
155
static int hf_radiotap_tx_attenuation = -1;
156
static int hf_radiotap_db_tx_attenuation = -1;
152
157
static int hf_radiotap_txpower = -1;
154
159
/* "Present" flags */
200
205
#define BIT(n) (1 << n)
203
* XXX - There are roundup macros defined in other dissectors. We should
204
* move them to a common location at some point.
207
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
208
* The NetBSD ieee80211_radiotap man page
209
* (http://netbsd.gw.com/cgi-bin/man-cgi?ieee80211_radiotap+9+NetBSD-current)
212
* Radiotap capture fields must be naturally aligned. That is, 16-, 32-,
213
* and 64-bit fields must begin on 16-, 32-, and 64-bit boundaries, respec-
214
* tively. In this way, drivers can avoid unaligned accesses to radiotap
215
* capture fields. radiotap-compliant drivers must insert padding before a
216
* capture field to ensure its natural alignment. radiotap-compliant packet
217
* dissectors, such as tcpdump(8), expect the padding.
221
* Returns the amount required to align "offset" with "width"
223
#define ALIGN_OFFSET(offset, width) \
224
( (((offset) + ((width) - 1)) & (~((width) - 1))) - offset )
211
228
capture_radiotap(const guchar *pd, int offset, int len, packet_counts *ld)
425
442
{ &hf_radiotap_fcs,
426
443
{ "802.11 FCS", "radiotap.fcs",
427
444
FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL } },
445
{ &hf_radiotap_channel,
446
{ "Channel", "radiotap.channel",
447
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
428
448
{ &hf_radiotap_channel_frequency,
429
449
{ "Channel frequency", "radiotap.channel.freq",
430
450
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
431
451
{ &hf_radiotap_channel_flags,
432
452
{ "Channel type", "radiotap.channel.flags",
433
453
FT_UINT16, BASE_HEX, VALS(phy_type), 0x0, "", HFILL } },
454
{ &hf_radiotap_fhss_hopset,
455
{ "FHSS Hop Set", "radiotap.fhss.hopset",
456
FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } },
457
{ &hf_radiotap_fhss_pattern,
458
{ "FHSS Pattern", "radiotap.fhss.pattern",
459
FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } },
434
460
{ &hf_radiotap_datarate,
435
461
{ "Data rate", "radiotap.datarate",
436
462
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
449
475
{ &hf_radiotap_db_antnoise,
450
476
{ "SSI Noise (dB)", "radiotap.db_antnoise",
451
477
FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } },
478
{ &hf_radiotap_tx_attenuation,
479
{ "Transmit attenuation", "radiotap.txattenuation",
480
FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } },
481
{ &hf_radiotap_db_tx_attenuation,
482
{ "Transmit attenuation (dB)", "radiotap.db_txattenuation",
483
FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } },
452
484
{ &hf_radiotap_txpower,
453
485
{ "Transmit power", "radiotap.txpower",
454
486
FT_INT32, BASE_DEC, NULL, 0x0, "", HFILL } },
745
777
length_remaining--;
747
779
case IEEE80211_RADIOTAP_CHANNEL:
748
if (length_remaining < 4)
780
align_offset = ALIGN_OFFSET(offset, 2);
781
offset += align_offset;
782
length_remaining -= align_offset;
783
if (length_remaining < 2)
751
786
freq = tvb_get_letohs(tvb, offset);
752
787
flags = tvb_get_letohs(tvb, offset+2);
753
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_channel_frequency,
754
tvb, offset, 2, freq,
755
"Channel: %u (chan %u)", freq, ieee80211_mhz2ieee(freq, flags));
756
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_flags,
788
channel = ieee80211_mhz2ieee(freq, flags);
790
proto_tree_add_uint_format(radiotap_tree, hf_radiotap_channel_frequency,
791
tvb, offset, 2, freq,
792
"Channel frequency: %u (invalid)", freq);
794
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel,
795
tvb, offset, 2, (guint32) channel);
796
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_frequency,
797
tvb, offset, 2, freq);
799
/* We're already 2-byte aligned. */
800
proto_tree_add_uint(radiotap_tree, hf_radiotap_channel_flags,
757
801
tvb, offset+2, 2, flags);
803
offset+=4 /* Channel + flags */;
760
804
length_remaining-=4;
762
806
case IEEE80211_RADIOTAP_FHSS:
807
align_offset = ALIGN_OFFSET(offset, 2);
808
offset += align_offset;
809
length_remaining -= align_offset;
810
if (length_remaining < 2)
812
proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_hopset,
813
tvb, offset, 1, FALSE);
814
proto_tree_add_item(radiotap_tree, hf_radiotap_fhss_pattern,
815
tvb, offset, 1, FALSE);
763
819
case IEEE80211_RADIOTAP_TX_ATTENUATION:
820
align_offset = ALIGN_OFFSET(offset, 2);
821
offset += align_offset;
822
length_remaining -= align_offset;
823
if (length_remaining < 2)
825
proto_tree_add_item(radiotap_tree, hf_radiotap_tx_attenuation,
826
tvb, offset, 2, FALSE);
764
830
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
831
align_offset = ALIGN_OFFSET(offset, 2);
832
offset += align_offset;
833
length_remaining -= align_offset;
765
834
if (length_remaining < 2)
768
tvb_get_letohs(tvb, offset);
836
proto_tree_add_item(radiotap_tree, hf_radiotap_db_tx_attenuation,
837
tvb, offset, 2, FALSE);
771
839
length_remaining-=2;
773
841
case IEEE80211_RADIOTAP_TSFT:
842
align_offset = ALIGN_OFFSET(offset, 8);
843
offset += align_offset;
844
length_remaining -= align_offset;
774
845
if (length_remaining < 8)