iPXE
Functions
802.11 helper functions

Functions

static void net80211_add_channels (struct net80211_device *dev, int start, int len, int txpower)
 Add channels to 802.11 device. More...
 
static void net80211_filter_hw_channels (struct net80211_device *dev)
 Filter 802.11 device channels for hardware capabilities. More...
 
static void net80211_set_rtscts_rate (struct net80211_device *dev)
 Pick TX rate for RTS/CTS packets based on data rate. More...
 
static int net80211_process_capab (struct net80211_device *dev, u16 capab)
 Update 802.11 device state to reflect received capabilities field. More...
 
static int net80211_process_ie (struct net80211_device *dev, union ieee80211_ie *ie, void *ie_end)
 Update 802.11 device state to reflect received information elements. More...
 
static union ieee80211_ienet80211_marshal_request_info (struct net80211_device *dev, union ieee80211_ie *ie)
 Create information elements for outgoing probe or association packet. More...
 

Detailed Description

Function Documentation

◆ net80211_add_channels()

static void net80211_add_channels ( struct net80211_device dev,
int  start,
int  len,
int  txpower 
)
static

Add channels to 802.11 device.

Parameters
dev802.11 device
startFirst channel number to add
lenNumber of channels to add
txpowerTX power (dBm) to allow on added channels

To replace the current list of channels instead of adding to it, set the nr_channels field of the 802.11 device to 0 before calling this function.

Definition at line 918 of file net80211.c.

920 {
921  int i, chan = start;
922 
923  for ( i = dev->nr_channels; len-- && i < NET80211_MAX_CHANNELS; i++ ) {
924  dev->channels[i].channel_nr = chan;
925  dev->channels[i].maxpower = txpower;
926  dev->channels[i].hw_value = 0;
927 
928  if ( chan >= 1 && chan <= 14 ) {
929  dev->channels[i].band = NET80211_BAND_2GHZ;
930  if ( chan == 14 )
931  dev->channels[i].center_freq = 2484;
932  else
933  dev->channels[i].center_freq = 2407 + 5 * chan;
934  chan++;
935  } else {
936  dev->channels[i].band = NET80211_BAND_5GHZ;
937  dev->channels[i].center_freq = 5000 + 5 * chan;
938  chan += 4;
939  }
940  }
941 
942  dev->nr_channels = i;
943 }
uint32_t start
Starting offset.
Definition: netvsc.h:12
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition: net80211.h:45
u16 hw_value
Hardware channel value.
Definition: net80211.h:414
u8 maxpower
Maximum allowable transmit power, in dBm.
Definition: net80211.h:425
u8 nr_channels
The number of channels in the channels array.
Definition: net80211.h:809
ring len
Length.
Definition: dwmac.h:231
#define NET80211_MAX_CHANNELS
The maximum number of channels we allow to be configured simultaneously.
Definition: net80211.h:275
#define NET80211_BAND_5GHZ
The band from 4.9 GHz to 5.7 GHz, which tends to be more restricted.
Definition: net80211.h:47
u16 center_freq
The center frequency for this channel.
Definition: net80211.h:411
u8 band
The band with which this channel is associated.
Definition: net80211.h:388
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
u8 channel_nr
A channel number interpreted according to the band.
Definition: net80211.h:405

References net_device::dev, len, NET80211_BAND_2GHZ, NET80211_BAND_5GHZ, NET80211_MAX_CHANNELS, and start.

Referenced by net80211_prepare_probe(), and net80211_process_ie().

◆ net80211_filter_hw_channels()

static void net80211_filter_hw_channels ( struct net80211_device dev)
static

Filter 802.11 device channels for hardware capabilities.

Parameters
dev802.11 device

Hardware may support fewer channels than regulatory restrictions allow; this function filters out channels in dev->channels that are not supported by the hardware list in dev->hwinfo. It also copies over the net80211_channel::hw_value and limits maximum TX power appropriately.

Channels are matched based on center frequency, ignoring band and channel number.

If the driver specifies no supported channels, the effect will be as though all were supported.

Definition at line 962 of file net80211.c.

963 {
964  int delta = 0, i = 0;
965  int old_freq = dev->channels[dev->channel].center_freq;
966  struct net80211_channel *chan, *hwchan;
967 
968  if ( ! dev->hw->nr_channels )
969  return;
970 
971  dev->channel = 0;
972  for ( chan = dev->channels; chan < dev->channels + dev->nr_channels;
973  chan++, i++ ) {
974  int ok = 0;
975  for ( hwchan = dev->hw->channels;
976  hwchan < dev->hw->channels + dev->hw->nr_channels;
977  hwchan++ ) {
978  if ( hwchan->center_freq == chan->center_freq ) {
979  ok = 1;
980  break;
981  }
982  }
983 
984  if ( ! ok )
985  delta++;
986  else {
987  chan->hw_value = hwchan->hw_value;
988  if ( hwchan->maxpower != 0 &&
989  chan->maxpower > hwchan->maxpower )
990  chan->maxpower = hwchan->maxpower;
991  if ( old_freq == chan->center_freq )
992  dev->channel = i - delta;
993  if ( delta )
994  chan[-delta] = *chan;
995  }
996  }
997 
998  dev->nr_channels -= delta;
999 
1000  if ( dev->channels[dev->channel].center_freq != old_freq )
1001  dev->op->config ( dev, NET80211_CFG_CHANNEL );
1002 }
struct net80211_channel channels[NET80211_MAX_CHANNELS]
List of RF channels supported by the card.
Definition: net80211.h:498
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition: net80211.h:381
Definition: hw.c:16
u16 hw_value
Hardware channel value.
Definition: net80211.h:414
u8 maxpower
Maximum allowable transmit power, in dBm.
Definition: net80211.h:425
u8 nr_channels
The number of channels in the channels array.
Definition: net80211.h:809
u16 center_freq
The center frequency for this channel.
Definition: net80211.h:411
An 802.11 RF channel.
Definition: net80211.h:385
struct net80211_hw_info * hw
Information about the hardware, provided to net80211_register()
Definition: net80211.h:801
struct ieee80211_ie_channels_channel_band channels[0]
List of (start, length) channel bands we can use.
Definition: ieee80211.h:18
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
int nr_channels
Number of supported channels.
Definition: net80211.h:501
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
#define NET80211_CFG_CHANNEL
Channel choice (dev->channel) or regulatory parameters have changed.
Definition: net80211.h:81
#define ok(success)
Definition: test.h:46

References net80211_channel::center_freq, net80211_device::channel, channels, net80211_hw_info::channels, net80211_device::channels, net80211_device_operations::config, net_device::dev, net80211_device::hw, net80211_channel::hw_value, net80211_channel::maxpower, NET80211_CFG_CHANNEL, net80211_hw_info::nr_channels, net80211_device::nr_channels, ok, and net80211_device::op.

Referenced by net80211_prepare_probe(), and net80211_process_ie().

◆ net80211_set_rtscts_rate()

static void net80211_set_rtscts_rate ( struct net80211_device dev)
static

Pick TX rate for RTS/CTS packets based on data rate.

Parameters
dev802.11 device

The RTS/CTS rate is the fastest TX rate marked as "basic" that is not faster than the data rate.

Definition at line 1968 of file net80211.c.

1969 {
1970  u16 datarate = dev->rates[dev->rate];
1971  u16 rtsrate = 0;
1972  int rts_idx = -1;
1973  int i;
1974 
1975  for ( i = 0; i < dev->nr_rates; i++ ) {
1976  u16 rate = dev->rates[i];
1977 
1978  if ( ! ( dev->basic_rates & ( 1 << i ) ) || rate > datarate )
1979  continue;
1980 
1981  if ( rate > rtsrate ) {
1982  rtsrate = rate;
1983  rts_idx = i;
1984  }
1985  }
1986 
1987  /* If this is in initialization, we might not have any basic
1988  rates; just use the first data rate in that case. */
1989  if ( rts_idx < 0 )
1990  rts_idx = 0;
1991 
1992  dev->rtscts_rate = rts_idx;
1993 }
uint16_t u16
Definition: stdint.h:22
u32 basic_rates
Bitmask of basic rates.
Definition: net80211.h:843
u8 rtscts_rate
The rate to use for RTS/CTS transmissions.
Definition: net80211.h:831
u8 nr_rates
The number of transmission rates in the rates array.
Definition: net80211.h:821
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition: net80211.h:818
u8 rate
The rate currently in use, as an index into the rates array.
Definition: net80211.h:824

References net80211_device::basic_rates, net80211_device::nr_rates, net80211_device::rate, net80211_device::rates, and net80211_device::rtscts_rate.

Referenced by net80211_process_ie(), and net80211_set_rate_idx().

◆ net80211_process_capab()

static int net80211_process_capab ( struct net80211_device dev,
u16  capab 
)
static

Update 802.11 device state to reflect received capabilities field.

Parameters
dev802.11 device
capabCapabilities field in beacon, probe, or association frame
Return values
rcReturn status code

Definition at line 1011 of file net80211.c.

1013 {
1014  u16 old_phy = dev->phy_flags;
1015 
1016  if ( ( capab & ( IEEE80211_CAPAB_MANAGED | IEEE80211_CAPAB_ADHOC ) ) !=
1018  DBGC ( dev, "802.11 %p cannot handle IBSS network\n", dev );
1019  return -ENOSYS;
1020  }
1021 
1024 
1025  if ( capab & IEEE80211_CAPAB_SHORT_PMBL )
1027 
1028  if ( capab & IEEE80211_CAPAB_SHORT_SLOT )
1030 
1031  if ( old_phy != dev->phy_flags )
1032  dev->op->config ( dev, NET80211_CFG_PHY_PARAMS );
1033 
1034  return 0;
1035 }
uint16_t u16
Definition: stdint.h:22
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition: net80211.h:381
#define IEEE80211_CAPAB_SHORT_PMBL
Set if PHY supports short preambles on 802.11b.
Definition: ieee80211.h:404
#define DBGC(...)
Definition: compiler.h:505
#define NET80211_PHY_USE_SHORT_PREAMBLE
Whether to use 802.11b short preamble operation.
Definition: net80211.h:260
#define NET80211_CFG_PHY_PARAMS
Low-level link parameters (short preamble, protection, etc) have changed.
Definition: net80211.h:90
int phy_flags
Physical layer options.
Definition: net80211.h:983
#define IEEE80211_CAPAB_SHORT_SLOT
Set if PHY supports short slot time on 802.11g.
Definition: ieee80211.h:419
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
#define IEEE80211_CAPAB_MANAGED
Set if using an Access Point (managed mode)
Definition: ieee80211.h:389
#define ENOSYS
Function not implemented.
Definition: errno.h:565
#define NET80211_PHY_USE_SHORT_SLOT
Whether to use 802.11g short slot operation.
Definition: net80211.h:266
#define IEEE80211_CAPAB_ADHOC
Set if operating in IBSS (no-AP, "Ad-Hoc") mode.
Definition: ieee80211.h:392

References net80211_device_operations::config, DBGC, ENOSYS, IEEE80211_CAPAB_ADHOC, IEEE80211_CAPAB_MANAGED, IEEE80211_CAPAB_SHORT_PMBL, IEEE80211_CAPAB_SHORT_SLOT, NET80211_CFG_PHY_PARAMS, NET80211_PHY_USE_SHORT_PREAMBLE, NET80211_PHY_USE_SHORT_SLOT, net80211_device::op, and net80211_device::phy_flags.

Referenced by net80211_handle_assoc_reply(), and net80211_prepare_assoc().

◆ net80211_process_ie()

static int net80211_process_ie ( struct net80211_device dev,
union ieee80211_ie ie,
void *  ie_end 
)
static

Update 802.11 device state to reflect received information elements.

Parameters
dev802.11 device
iePointer to first information element
ie_endPointer to tail of packet I/O buffer
Return values
rcReturn status code

Definition at line 1045 of file net80211.c.

1047 {
1048  u16 old_rate = dev->rates[dev->rate];
1049  u16 old_phy = dev->phy_flags;
1050  int have_rates = 0, i;
1051  int ds_channel = 0;
1052  int changed = 0;
1053  int band = dev->channels[dev->channel].band;
1054 
1055  if ( ! ieee80211_ie_bound ( ie, ie_end ) )
1056  return 0;
1057 
1058  for ( ; ie; ie = ieee80211_next_ie ( ie, ie_end ) ) {
1059  switch ( ie->id ) {
1060  case IEEE80211_IE_SSID:
1061  if ( ie->len <= 32 ) {
1062  memcpy ( dev->essid, ie->ssid, ie->len );
1063  dev->essid[ie->len] = 0;
1064  }
1065  break;
1066 
1067  case IEEE80211_IE_RATES:
1069  if ( ! have_rates ) {
1070  dev->nr_rates = 0;
1071  dev->basic_rates = 0;
1072  have_rates = 1;
1073  }
1074  for ( i = 0; i < ie->len &&
1075  dev->nr_rates < NET80211_MAX_RATES; i++ ) {
1076  u8 rid = ie->rates[i];
1077  u16 rate = ( rid & 0x7f ) * 5;
1078 
1079  if ( rid & 0x80 )
1080  dev->basic_rates |=
1081  ( 1 << dev->nr_rates );
1082 
1083  dev->rates[dev->nr_rates++] = rate;
1084  }
1085 
1086  break;
1087 
1088  case IEEE80211_IE_DS_PARAM:
1089  if ( dev->channel < dev->nr_channels && ds_channel ==
1090  dev->channels[dev->channel].channel_nr )
1091  break;
1092  ds_channel = ie->ds_param.current_channel;
1093  net80211_change_channel ( dev, ds_channel );
1094  break;
1095 
1096  case IEEE80211_IE_COUNTRY:
1097  dev->nr_channels = 0;
1098 
1099  DBGC ( dev, "802.11 %p setting country regulations "
1100  "for %c%c\n", dev, ie->country.name[0],
1101  ie->country.name[1] );
1102  for ( i = 0; i < ( ie->len - 3 ) / 3; i++ ) {
1103  union ieee80211_ie_country_triplet *t =
1104  &ie->country.triplet[i];
1105  if ( t->first > 200 ) {
1106  DBGC ( dev, "802.11 %p ignoring regulatory "
1107  "extension information\n", dev );
1108  } else {
1109  net80211_add_channels ( dev,
1110  t->band.first_channel,
1111  t->band.nr_channels,
1112  t->band.max_txpower );
1113  }
1114  }
1116  break;
1117 
1118  case IEEE80211_IE_ERP_INFO:
1123  if ( ! ( ie->erp_info & IEEE80211_ERP_BARKER_LONG ) )
1125  break;
1126  }
1127  }
1128 
1129  if ( have_rates ) {
1130  /* Allow only those rates that are also supported by
1131  the hardware. */
1132  int delta = 0, j;
1133 
1134  dev->rate = 0;
1135  for ( i = 0; i < dev->nr_rates; i++ ) {
1136  int ok = 0;
1137  for ( j = 0; j < dev->hw->nr_rates[band]; j++ ) {
1138  if ( dev->hw->rates[band][j] == dev->rates[i] ){
1139  ok = 1;
1140  break;
1141  }
1142  }
1143 
1144  if ( ! ok )
1145  delta++;
1146  else {
1147  dev->rates[i - delta] = dev->rates[i];
1148  if ( old_rate == dev->rates[i] )
1149  dev->rate = i - delta;
1150  }
1151  }
1152 
1153  dev->nr_rates -= delta;
1154 
1155  /* Sort available rates - sorted subclumps tend to already
1156  exist, so insertion sort works well. */
1157  for ( i = 1; i < dev->nr_rates; i++ ) {
1158  u16 rate = dev->rates[i];
1159  u32 tmp, br, mask;
1160 
1161  for ( j = i - 1; j >= 0 && dev->rates[j] >= rate; j-- )
1162  dev->rates[j + 1] = dev->rates[j];
1163  dev->rates[j + 1] = rate;
1164 
1165  /* Adjust basic_rates to match by rotating the
1166  bits from bit j+1 to bit i left one position. */
1167  mask = ( ( 1 << i ) - 1 ) & ~( ( 1 << ( j + 1 ) ) - 1 );
1168  br = dev->basic_rates;
1169  tmp = br & ( 1 << i );
1170  br = ( br & ~( mask | tmp ) ) | ( ( br & mask ) << 1 );
1171  br |= ( tmp >> ( i - j - 1 ) );
1172  dev->basic_rates = br;
1173  }
1174 
1175  net80211_set_rtscts_rate ( dev );
1176 
1177  if ( dev->rates[dev->rate] != old_rate )
1178  changed |= NET80211_CFG_RATE;
1179  }
1180 
1181  if ( dev->hw->flags & NET80211_HW_NO_SHORT_PREAMBLE )
1183  if ( dev->hw->flags & NET80211_HW_NO_SHORT_SLOT )
1185 
1186  if ( old_phy != dev->phy_flags )
1187  changed |= NET80211_CFG_PHY_PARAMS;
1188 
1189  if ( changed )
1190  dev->op->config ( dev, changed );
1191 
1192  return 0;
1193 }
uint16_t u16
Definition: stdint.h:22
static union ieee80211_ie * ieee80211_next_ie(union ieee80211_ie *ie, void *end)
Advance to next 802.11 information element.
Definition: ieee80211.h:1028
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
#define IEEE80211_IE_COUNTRY
Information element ID for Country information element.
Definition: ieee80211.h:668
int(* config)(struct net80211_device *dev, int changed)
Update hardware state to match 802.11 layer state.
Definition: net80211.h:381
enum net80211_hw_info::@641 flags
A set of flags indicating peculiarities of this device.
u32 basic_rates
Bitmask of basic rates.
Definition: net80211.h:843
u8 first
Differentiator between band and ext triplets.
Definition: ieee80211.h:644
#define DBGC(...)
Definition: compiler.h:505
char name[2]
ISO Alpha2 country code.
Definition: ieee80211.h:660
static void net80211_filter_hw_channels(struct net80211_device *dev)
Filter 802.11 device channels for hardware capabilities.
Definition: net80211.c:962
char essid[IEEE80211_MAX_SSID_LEN+1]
SSID of the access point we are or will be associated with.
Definition: net80211.h:962
802.11 Country information element regulatory triplet
Definition: ieee80211.h:642
unsigned long tmp
Definition: linux_pci.h:65
u16 rates[NET80211_NR_BANDS][NET80211_MAX_RATES]
List of transmission rates supported by the card, indexed by band.
Definition: net80211.h:508
#define IEEE80211_IE_EXT_RATES
Information element ID for extended rates information element.
Definition: ieee80211.h:603
void * memcpy(void *dest, const void *src, size_t len) __nonnull
union ieee80211_ie_country_triplet triplet[0]
List of regulatory triplets.
Definition: ieee80211.h:664
struct ieee80211_ie_ds_param ds_param
DS parameter set.
Definition: ieee80211.h:991
u8 id
Information element ID.
Definition: ieee80211.h:976
u8 nr_channels
The number of channels in the channels array.
Definition: net80211.h:809
u8 nr_channels
Number of contiguous channels in band.
Definition: ieee80211.h:633
int nr_rates[NET80211_NR_BANDS]
Number of supported rates, indexed by band.
Definition: net80211.h:511
u8 rates[0]
Rates data.
Definition: ieee80211.h:980
#define NET80211_PHY_USE_SHORT_PREAMBLE
Whether to use 802.11b short preamble operation.
Definition: net80211.h:260
#define IEEE80211_IE_SSID
Information element ID for SSID information element.
Definition: ieee80211.h:582
u8 nr_rates
The number of transmission rates in the rates array.
Definition: net80211.h:821
#define NET80211_PHY_USE_PROTECTION
Whether to use RTS/CTS or CTS-to-self protection for transmissions.
Definition: net80211.h:251
u8 band
The band with which this channel is associated.
Definition: net80211.h:388
#define NET80211_CFG_PHY_PARAMS
Low-level link parameters (short preamble, protection, etc) have changed.
Definition: net80211.h:90
#define IEEE80211_IE_ERP_INFO
Information element ID for ERP Information information element.
Definition: ieee80211.h:768
static void net80211_set_rtscts_rate(struct net80211_device *dev)
Pick TX rate for RTS/CTS packets based on data rate.
Definition: net80211.c:1968
static int ieee80211_ie_bound(union ieee80211_ie *ie, void *end)
Check that 802.11 information element is bounded by buffer.
Definition: ieee80211.h:1012
u8 first_channel
Channel number for first channel in band.
Definition: ieee80211.h:632
struct net80211_hw_info * hw
Information about the hardware, provided to net80211_register()
Definition: net80211.h:801
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition: net80211.h:818
u8 len
Information element data length.
Definition: ieee80211.h:977
int phy_flags
Physical layer options.
Definition: net80211.h:983
struct ieee80211_ie_country country
Country information.
Definition: ieee80211.h:994
#define IEEE80211_ERP_USE_PROTECTION
ERP information element: Flag set if CTS protection must be used.
Definition: ieee80211.h:774
#define IEEE80211_ERP_BARKER_LONG
ERP information element: Flag set if long preambles must be used.
Definition: ieee80211.h:777
#define NET80211_MAX_RATES
The maximum number of TX rates we allow to be configured simultaneously.
Definition: net80211.h:272
#define IEEE80211_IE_DS_PARAM
Information element ID for Direct Spectrum parameter information element.
Definition: ieee80211.h:620
struct net80211_device_operations * op
802.11 device operations
Definition: net80211.h:795
u8 erp_info
ERP information flags.
Definition: ieee80211.h:984
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
struct ieee80211_ie_country_band_triplet band
Information about a band of channels.
Definition: ieee80211.h:647
#define NET80211_CFG_RATE
Requested transmission rate (dev->rate) has changed.
Definition: net80211.h:84
char ssid[0]
SSID text.
Definition: ieee80211.h:979
static void net80211_add_channels(struct net80211_device *dev, int start, int len, int txpower)
Add channels to 802.11 device.
Definition: net80211.c:918
#define IEEE80211_IE_RATES
Information element ID for rates information element.
Definition: ieee80211.h:600
u8 channel_nr
A channel number interpreted according to the band.
Definition: net80211.h:405
#define NET80211_PHY_USE_SHORT_SLOT
Whether to use 802.11g short slot operation.
Definition: net80211.h:266
#define ok(success)
Definition: test.h:46
int net80211_change_channel(struct net80211_device *dev, int channel)
Configure 802.11 device to transmit on a certain channel.
Definition: net80211.c:2022
u8 rate
The rate currently in use, as an index into the rates array.
Definition: net80211.h:824
uint8_t u8
Definition: stdint.h:20
uint32_t u32
Definition: stdint.h:24
u8 current_channel
Current channel number, 1-14.
Definition: ieee80211.h:616
u8 max_txpower
Maximum TX power in dBm.
Definition: ieee80211.h:634

References net80211_channel::band, ieee80211_ie_country_triplet::band, net80211_device::basic_rates, net80211_device::channel, net80211_channel::channel_nr, net80211_device::channels, net80211_device_operations::config, ieee80211_ie::country, ieee80211_ie_ds_param::current_channel, DBGC, ieee80211_ie::ds_param, ieee80211_ie::erp_info, net80211_device::essid, ieee80211_ie_country_triplet::first, ieee80211_ie_country_band_triplet::first_channel, net80211_hw_info::flags, net80211_device::hw, ieee80211_ie::id, IEEE80211_ERP_BARKER_LONG, IEEE80211_ERP_USE_PROTECTION, ieee80211_ie_bound(), IEEE80211_IE_COUNTRY, IEEE80211_IE_DS_PARAM, IEEE80211_IE_ERP_INFO, IEEE80211_IE_EXT_RATES, IEEE80211_IE_RATES, IEEE80211_IE_SSID, ieee80211_next_ie(), ieee80211_ie::len, ieee80211_ie_country_band_triplet::max_txpower, memcpy(), ieee80211_ie_country::name, net80211_add_channels(), NET80211_CFG_PHY_PARAMS, NET80211_CFG_RATE, net80211_change_channel(), net80211_filter_hw_channels(), NET80211_MAX_RATES, NET80211_PHY_USE_PROTECTION, NET80211_PHY_USE_SHORT_PREAMBLE, NET80211_PHY_USE_SHORT_SLOT, net80211_set_rtscts_rate(), ieee80211_ie_country_band_triplet::nr_channels, net80211_device::nr_channels, net80211_hw_info::nr_rates, net80211_device::nr_rates, ok, net80211_device::op, net80211_device::phy_flags, net80211_device::rate, net80211_hw_info::rates, net80211_device::rates, ieee80211_ie::rates, ieee80211_ie::ssid, tmp, and ieee80211_ie_country::triplet.

Referenced by net80211_handle_assoc_reply(), and net80211_prepare_assoc().

◆ net80211_marshal_request_info()

static union ieee80211_ie * net80211_marshal_request_info ( struct net80211_device dev,
union ieee80211_ie ie 
)
static

Create information elements for outgoing probe or association packet.

Parameters
dev802.11 device
iePointer to start of information element area
Return values
next_iePointer to first byte after added information elements

Definition at line 1203 of file net80211.c.

1205 {
1206  int i;
1207 
1208  ie->id = IEEE80211_IE_SSID;
1209  ie->len = strlen ( dev->essid );
1210  memcpy ( ie->ssid, dev->essid, ie->len );
1211 
1212  ie = ieee80211_next_ie ( ie, NULL );
1213 
1214  ie->id = IEEE80211_IE_RATES;
1215  ie->len = dev->nr_rates;
1216  if ( ie->len > 8 )
1217  ie->len = 8;
1218 
1219  for ( i = 0; i < ie->len; i++ ) {
1220  ie->rates[i] = dev->rates[i] / 5;
1221  if ( dev->basic_rates & ( 1 << i ) )
1222  ie->rates[i] |= 0x80;
1223  }
1224 
1225  ie = ieee80211_next_ie ( ie, NULL );
1226 
1227  if ( dev->rsn_ie && dev->rsn_ie->id == IEEE80211_IE_RSN ) {
1228  memcpy ( ie, dev->rsn_ie, dev->rsn_ie->len + 2 );
1229  ie = ieee80211_next_ie ( ie, NULL );
1230  }
1231 
1232  if ( dev->nr_rates > 8 ) {
1233  /* 802.11 requires we use an Extended Basic Rates IE
1234  for the rates beyond the eighth. */
1235 
1236  ie->id = IEEE80211_IE_EXT_RATES;
1237  ie->len = dev->nr_rates - 8;
1238 
1239  for ( ; i < dev->nr_rates; i++ ) {
1240  ie->rates[i - 8] = dev->rates[i] / 5;
1241  if ( dev->basic_rates & ( 1 << i ) )
1242  ie->rates[i - 8] |= 0x80;
1243  }
1244 
1245  ie = ieee80211_next_ie ( ie, NULL );
1246  }
1247 
1248  if ( dev->rsn_ie && dev->rsn_ie->id == IEEE80211_IE_VENDOR ) {
1249  memcpy ( ie, dev->rsn_ie, dev->rsn_ie->len + 2 );
1250  ie = ieee80211_next_ie ( ie, NULL );
1251  }
1252 
1253  return ie;
1254 }
static union ieee80211_ie * ieee80211_next_ie(union ieee80211_ie *ie, void *end)
Advance to next 802.11 information element.
Definition: ieee80211.h:1028
u32 basic_rates
Bitmask of basic rates.
Definition: net80211.h:843
union ieee80211_ie * rsn_ie
RSN or WPA information element to include with association.
Definition: net80211.h:932
char essid[IEEE80211_MAX_SSID_LEN+1]
SSID of the access point we are or will be associated with.
Definition: net80211.h:962
#define IEEE80211_IE_EXT_RATES
Information element ID for extended rates information element.
Definition: ieee80211.h:603
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 id
Information element ID.
Definition: ieee80211.h:976
u8 rates[0]
Rates data.
Definition: ieee80211.h:980
#define IEEE80211_IE_SSID
Information element ID for SSID information element.
Definition: ieee80211.h:582
u8 nr_rates
The number of transmission rates in the rates array.
Definition: net80211.h:821
#define IEEE80211_IE_VENDOR
Information element ID for Vendor Specific information element.
Definition: ieee80211.h:960
#define IEEE80211_IE_RSN
Information element ID for Robust Security Network information element.
Definition: ieee80211.h:834
size_t strlen(const char *src)
Get length of string.
Definition: string.c:244
u16 rates[NET80211_MAX_RATES]
A list of all possible TX rates we might use.
Definition: net80211.h:818
u8 len
Information element data length.
Definition: ieee80211.h:977
char ssid[0]
SSID text.
Definition: ieee80211.h:979
#define IEEE80211_IE_RATES
Information element ID for rates information element.
Definition: ieee80211.h:600
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References net80211_device::basic_rates, net80211_device::essid, ieee80211_ie::id, IEEE80211_IE_EXT_RATES, IEEE80211_IE_RATES, IEEE80211_IE_RSN, IEEE80211_IE_SSID, IEEE80211_IE_VENDOR, ieee80211_next_ie(), ieee80211_ie::len, memcpy(), net80211_device::nr_rates, NULL, net80211_device::rates, ieee80211_ie::rates, net80211_device::rsn_ie, ieee80211_ie::ssid, and strlen().

Referenced by net80211_probe_start(), and net80211_send_assoc().