peektagged: guess the PHY for 11b/11g/11a.

FOr 11b and 11g, also set the metadata to provide the "short preamble"
indication.

Add some macros to wsutil/802_11-utils.h to help there, as I threatened
to do in the previous commit. :-)
This commit is contained in:
Guy Harris 2021-03-04 16:07:23 -08:00
parent 25d44cde11
commit 8f700ab1f3
2 changed files with 96 additions and 1 deletions

View File

@ -767,6 +767,60 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
/* It's a data rate. */
ieee_802_11.has_data_rate = TRUE;
ieee_802_11.data_rate = data_rate_or_mcs_index;
if (ieee_802_11.phy == PHDR_802_11_PHY_UNKNOWN) {
/*
* We don't know they PHY; try to guess it based
* on the data rate and channel/center frequency.
*/
if (RATE_IS_DSSS(ieee_802_11.data_rate)) {
/* 11b */
ieee_802_11.phy = PHDR_802_11_PHY_11B;
if (saw_flags_and_status) {
ieee_802_11.phy_info.info_11b.has_short_preamble = TRUE;
ieee_802_11.phy_info.info_11b.short_preamble =
(flags_and_status & STATUS_SHORT_PREAMBLE) ? TRUE : FALSE;;
} else
ieee_802_11.phy_info.info_11b.has_short_preamble = FALSE;
} else if (RATE_IS_OFDM(ieee_802_11.data_rate)) {
/* 11a or 11g, depending on the band. */
if (ieee_802_11.has_channel) {
if (CHAN_IS_BG(ieee_802_11.channel)) {
/* 11g */
ieee_802_11.phy = PHDR_802_11_PHY_11G;
} else {
/* 11a */
ieee_802_11.phy = PHDR_802_11_PHY_11A;
}
} else if (ieee_802_11.has_frequency) {
if (FREQ_IS_BG(ieee_802_11.frequency)) {
/* 11g */
ieee_802_11.phy = PHDR_802_11_PHY_11G;
} else {
/* 11a */
ieee_802_11.phy = PHDR_802_11_PHY_11A;
}
}
if (ieee_802_11.phy == PHDR_802_11_PHY_11G) {
/* Set 11g metadata */
if (saw_flags_and_status) {
/*
* XXX - is the short preamble only a
* "DSSS part of 11g" thing? If so, we
* should never get here.
*/
ieee_802_11.phy_info.info_11g.has_short_preamble = TRUE;
ieee_802_11.phy_info.info_11g.short_preamble =
(flags_and_status & STATUS_SHORT_PREAMBLE) ? TRUE : FALSE;;
} else
ieee_802_11.phy_info.info_11g.has_short_preamble = FALSE;
} else if (ieee_802_11.phy == PHDR_802_11_PHY_11G) {
/* 11a - set 11a metadata */
ieee_802_11.phy_info.info_11a.has_channel_type = FALSE;
ieee_802_11.phy_info.info_11a.has_turbo_type = FALSE;
}
/* Otherwise we don't know the PHY */
}
}
}
}
if (ieee_802_11.has_frequency && !ieee_802_11.has_channel) {

View File

@ -52,7 +52,48 @@ gchar*
ieee80211_mhz_to_str(guint freq);
/* Should this be "(freq < 4920)", or something else? */
#define FREQ_IS_BG(freq) (freq <= 2484)
#define FREQ_IS_BG(freq) ((freq) <= 2484)
#define CHAN_IS_BG(chan) ((chan) <= 14)
/*
* Test whether a data rate is an {HR}/DSSS (legacy DSSS/11b) data rate
* and whether it's an OFDM (11a/11g OFDM mode) data rate.
*
* rate is in units of 500 Kb/s.
*
* The 22 and 33 Mb/s rates for DSSS use Packet Binary Convolutional
* Coding (PBCC). That was provided by Texas Instruments as 11b+,
* and was in section 19.6 "ERP-PBCC operation specifications" of
* IEEE Std 802.11g-2003, and sections 18.4.6.6 "DSSS/PBCC data modulation
* and modulation rate (optional)" and 19.6 "ERP-PBCC operation
* specifications" of IEEE Std 802.11-2007, and sections 17.4.6.7 "DSSS/PBCC
* data modulation and modulation rate (optional)" and 19.6 "ERP-PBCC
* operation specifications" of IEEE Std 802.11-2012, marked as optional
* in both cases, but is not present in IEEE Std 802.11-2016.
*
* (Note: not to be confused with "peanut butter and chocolate chips":
*
* https://www.bigoven.com/recipe/peanut-butter-chocolate-chip-cookies-pbcc-cookies/186266
*
* :-))
*/
#define RATE_IS_DSSS(rate) \
((rate) == 2 /* 1 Mb/s */ || \
(rate) == 4 /* 2 Mb/s */ || \
(rate) == 11 /* 5.5 Mb/s */ || \
(rate) == 22 /* 11 Mb/s */ || \
(rate) == 44 /* 22 Mb/s */ || \
(rate) == 66 /* 33 Mb/s */)
#define RATE_IS_OFDM(rate) \
((rate) == 12 /* 6 Mb/s */ || \
(rate) == 18 /* 9 Mb/s */ || \
(rate) == 24 /* 12 Mb/s */ || \
(rate) == 36 /* 18 Mb/s */ || \
(rate) == 48 /* 24 Mb/s */ || \
(rate) == 72 /* 36 Mb/s */ || \
(rate) == 96 /* 48 Mb/s */ || \
(rate) == 108 /* 54 Mb/s */)
#ifdef __cplusplus
}