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 917 of file net80211.c.

919 {
920  int i, chan = start;
921 
922  for ( i = dev->nr_channels; len-- && i < NET80211_MAX_CHANNELS; i++ ) {
923  dev->channels[i].channel_nr = chan;
924  dev->channels[i].maxpower = txpower;
925  dev->channels[i].hw_value = 0;
926 
927  if ( chan >= 1 && chan <= 14 ) {
928  dev->channels[i].band = NET80211_BAND_2GHZ;
929  if ( chan == 14 )
930  dev->channels[i].center_freq = 2484;
931  else
932  dev->channels[i].center_freq = 2407 + 5 * chan;
933  chan++;
934  } else {
935  dev->channels[i].band = NET80211_BAND_5GHZ;
936  dev->channels[i].center_freq = 5000 + 5 * chan;
937  chan += 4;
938  }
939  }
940 
941  dev->nr_channels = i;
942 }
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
#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
uint32_t len
Length.
Definition: ena.h:14
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 961 of file net80211.c.

962 {
963  int delta = 0, i = 0;
964  int old_freq = dev->channels[dev->channel].center_freq;
965  struct net80211_channel *chan, *hwchan;
966 
967  if ( ! dev->hw->nr_channels )
968  return;
969 
970  dev->channel = 0;
971  for ( chan = dev->channels; chan < dev->channels + dev->nr_channels;
972  chan++, i++ ) {
973  int ok = 0;
974  for ( hwchan = dev->hw->channels;
975  hwchan < dev->hw->channels + dev->hw->nr_channels;
976  hwchan++ ) {
977  if ( hwchan->center_freq == chan->center_freq ) {
978  ok = 1;
979  break;
980  }
981  }
982 
983  if ( ! ok )
984  delta++;
985  else {
986  chan->hw_value = hwchan->hw_value;
987  if ( hwchan->maxpower != 0 &&
988  chan->maxpower > hwchan->maxpower )
989  chan->maxpower = hwchan->maxpower;
990  if ( old_freq == chan->center_freq )
991  dev->channel = i - delta;
992  if ( delta )
993  chan[-delta] = *chan;
994  }
995  }
996 
997  dev->nr_channels -= delta;
998 
999  if ( dev->channels[dev->channel].center_freq != old_freq )
1000  dev->op->config ( dev, NET80211_CFG_CHANNEL );
1001 }
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 1967 of file net80211.c.

1968 {
1969  u16 datarate = dev->rates[dev->rate];
1970  u16 rtsrate = 0;
1971  int rts_idx = -1;
1972  int i;
1973 
1974  for ( i = 0; i < dev->nr_rates; i++ ) {
1975  u16 rate = dev->rates[i];
1976 
1977  if ( ! ( dev->basic_rates & ( 1 << i ) ) || rate > datarate )
1978  continue;
1979 
1980  if ( rate > rtsrate ) {
1981  rtsrate = rate;
1982  rts_idx = i;
1983  }
1984  }
1985 
1986  /* If this is in initialization, we might not have any basic
1987  rates; just use the first data rate in that case. */
1988  if ( rts_idx < 0 )
1989  rts_idx = 0;
1990 
1991  dev->rtscts_rate = rts_idx;
1992 }
uint16_t u16
Definition: stdint.h:21
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 1010 of file net80211.c.

1012 {
1013  u16 old_phy = dev->phy_flags;
1014 
1015  if ( ( capab & ( IEEE80211_CAPAB_MANAGED | IEEE80211_CAPAB_ADHOC ) ) !=
1017  DBGC ( dev, "802.11 %p cannot handle IBSS network\n", dev );
1018  return -ENOSYS;
1019  }
1020 
1023 
1024  if ( capab & IEEE80211_CAPAB_SHORT_PMBL )
1026 
1027  if ( capab & IEEE80211_CAPAB_SHORT_SLOT )
1029 
1030  if ( old_phy != dev->phy_flags )
1031  dev->op->config ( dev, NET80211_CFG_PHY_PARAMS );
1032 
1033  return 0;
1034 }
uint16_t u16
Definition: stdint.h:21
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:564
#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 1044 of file net80211.c.

1046 {
1047  u16 old_rate = dev->rates[dev->rate];
1048  u16 old_phy = dev->phy_flags;
1049  int have_rates = 0, i;
1050  int ds_channel = 0;
1051  int changed = 0;
1052  int band = dev->channels[dev->channel].band;
1053 
1054  if ( ! ieee80211_ie_bound ( ie, ie_end ) )
1055  return 0;
1056 
1057  for ( ; ie; ie = ieee80211_next_ie ( ie, ie_end ) ) {
1058  switch ( ie->id ) {
1059  case IEEE80211_IE_SSID:
1060  if ( ie->len <= 32 ) {
1061  memcpy ( dev->essid, ie->ssid, ie->len );
1062  dev->essid[ie->len] = 0;
1063  }
1064  break;
1065 
1066  case IEEE80211_IE_RATES:
1068  if ( ! have_rates ) {
1069  dev->nr_rates = 0;
1070  dev->basic_rates = 0;
1071  have_rates = 1;
1072  }
1073  for ( i = 0; i < ie->len &&
1074  dev->nr_rates < NET80211_MAX_RATES; i++ ) {
1075  u8 rid = ie->rates[i];
1076  u16 rate = ( rid & 0x7f ) * 5;
1077 
1078  if ( rid & 0x80 )
1079  dev->basic_rates |=
1080  ( 1 << dev->nr_rates );
1081 
1082  dev->rates[dev->nr_rates++] = rate;
1083  }
1084 
1085  break;
1086 
1087  case IEEE80211_IE_DS_PARAM:
1088  if ( dev->channel < dev->nr_channels && ds_channel ==
1089  dev->channels[dev->channel].channel_nr )
1090  break;
1091  ds_channel = ie->ds_param.current_channel;
1092  net80211_change_channel ( dev, ds_channel );
1093  break;
1094 
1095  case IEEE80211_IE_COUNTRY:
1096  dev->nr_channels = 0;
1097 
1098  DBGC ( dev, "802.11 %p setting country regulations "
1099  "for %c%c\n", dev, ie->country.name[0],
1100  ie->country.name[1] );
1101  for ( i = 0; i < ( ie->len - 3 ) / 3; i++ ) {
1102  union ieee80211_ie_country_triplet *t =
1103  &ie->country.triplet[i];
1104  if ( t->first > 200 ) {
1105  DBGC ( dev, "802.11 %p ignoring regulatory "
1106  "extension information\n", dev );
1107  } else {
1108  net80211_add_channels ( dev,
1109  t->band.first_channel,
1110  t->band.nr_channels,
1111  t->band.max_txpower );
1112  }
1113  }
1115  break;
1116 
1117  case IEEE80211_IE_ERP_INFO:
1122  if ( ! ( ie->erp_info & IEEE80211_ERP_BARKER_LONG ) )
1124  break;
1125  }
1126  }
1127 
1128  if ( have_rates ) {
1129  /* Allow only those rates that are also supported by
1130  the hardware. */
1131  int delta = 0, j;
1132 
1133  dev->rate = 0;
1134  for ( i = 0; i < dev->nr_rates; i++ ) {
1135  int ok = 0;
1136  for ( j = 0; j < dev->hw->nr_rates[band]; j++ ) {
1137  if ( dev->hw->rates[band][j] == dev->rates[i] ){
1138  ok = 1;
1139  break;
1140  }
1141  }
1142 
1143  if ( ! ok )
1144  delta++;
1145  else {
1146  dev->rates[i - delta] = dev->rates[i];
1147  if ( old_rate == dev->rates[i] )
1148  dev->rate = i - delta;
1149  }
1150  }
1151 
1152  dev->nr_rates -= delta;
1153 
1154  /* Sort available rates - sorted subclumps tend to already
1155  exist, so insertion sort works well. */
1156  for ( i = 1; i < dev->nr_rates; i++ ) {
1157  u16 rate = dev->rates[i];
1158  u32 tmp, br, mask;
1159 
1160  for ( j = i - 1; j >= 0 && dev->rates[j] >= rate; j-- )
1161  dev->rates[j + 1] = dev->rates[j];
1162  dev->rates[j + 1] = rate;
1163 
1164  /* Adjust basic_rates to match by rotating the
1165  bits from bit j+1 to bit i left one position. */
1166  mask = ( ( 1 << i ) - 1 ) & ~( ( 1 << ( j + 1 ) ) - 1 );
1167  br = dev->basic_rates;
1168  tmp = br & ( 1 << i );
1169  br = ( br & ~( mask | tmp ) ) | ( ( br & mask ) << 1 );
1170  br |= ( tmp >> ( i - j - 1 ) );
1171  dev->basic_rates = br;
1172  }
1173 
1174  net80211_set_rtscts_rate ( dev );
1175 
1176  if ( dev->rates[dev->rate] != old_rate )
1177  changed |= NET80211_CFG_RATE;
1178  }
1179 
1180  if ( dev->hw->flags & NET80211_HW_NO_SHORT_PREAMBLE )
1182  if ( dev->hw->flags & NET80211_HW_NO_SHORT_SLOT )
1184 
1185  if ( old_phy != dev->phy_flags )
1186  changed |= NET80211_CFG_PHY_PARAMS;
1187 
1188  if ( changed )
1189  dev->op->config ( dev, changed );
1190 
1191  return 0;
1192 }
uint16_t u16
Definition: stdint.h:21
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
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:961
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:53
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:1967
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
enum net80211_hw_info::@575 flags
A set of flags indicating peculiarities of this device.
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:917
#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:2021
u8 rate
The rate currently in use, as an index into the rates array.
Definition: net80211.h:824
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
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 1202 of file net80211.c.

1204 {
1205  int i;
1206 
1207  ie->id = IEEE80211_IE_SSID;
1208  ie->len = strlen ( dev->essid );
1209  memcpy ( ie->ssid, dev->essid, ie->len );
1210 
1211  ie = ieee80211_next_ie ( ie, NULL );
1212 
1213  ie->id = IEEE80211_IE_RATES;
1214  ie->len = dev->nr_rates;
1215  if ( ie->len > 8 )
1216  ie->len = 8;
1217 
1218  for ( i = 0; i < ie->len; i++ ) {
1219  ie->rates[i] = dev->rates[i] / 5;
1220  if ( dev->basic_rates & ( 1 << i ) )
1221  ie->rates[i] |= 0x80;
1222  }
1223 
1224  ie = ieee80211_next_ie ( ie, NULL );
1225 
1226  if ( dev->rsn_ie && dev->rsn_ie->id == IEEE80211_IE_RSN ) {
1227  memcpy ( ie, dev->rsn_ie, dev->rsn_ie->len + 2 );
1228  ie = ieee80211_next_ie ( ie, NULL );
1229  }
1230 
1231  if ( dev->nr_rates > 8 ) {
1232  /* 802.11 requires we use an Extended Basic Rates IE
1233  for the rates beyond the eighth. */
1234 
1235  ie->id = IEEE80211_IE_EXT_RATES;
1236  ie->len = dev->nr_rates - 8;
1237 
1238  for ( ; i < dev->nr_rates; i++ ) {
1239  ie->rates[i - 8] = dev->rates[i] / 5;
1240  if ( dev->basic_rates & ( 1 << i ) )
1241  ie->rates[i - 8] |= 0x80;
1242  }
1243 
1244  ie = ieee80211_next_ie ( ie, NULL );
1245  }
1246 
1247  if ( dev->rsn_ie && dev->rsn_ie->id == IEEE80211_IE_VENDOR ) {
1248  memcpy ( ie, dev->rsn_ie, dev->rsn_ie->len + 2 );
1249  ie = ieee80211_next_ie ( ie, NULL );
1250  }
1251 
1252  return ie;
1253 }
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:243
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:321

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().