cfg80211.h 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  1. #ifndef __NET_CFG80211_H
  2. #define __NET_CFG80211_H
  3. /*
  4. * 802.11 device and configuration interface
  5. *
  6. * Copyright 2006-2009 Johannes Berg <johannes@sipsolutions.net>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/netdevice.h>
  13. #include <linux/debugfs.h>
  14. #include <linux/list.h>
  15. #include <linux/netlink.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/nl80211.h>
  18. #include <linux/if_ether.h>
  19. #include <linux/ieee80211.h>
  20. #include <net/regulatory.h>
  21. /* remove once we remove the wext stuff */
  22. #include <net/iw_handler.h>
  23. #include <linux/wireless.h>
  24. /*
  25. * wireless hardware capability structures
  26. */
  27. /**
  28. * enum ieee80211_band - supported frequency bands
  29. *
  30. * The bands are assigned this way because the supported
  31. * bitrates differ in these bands.
  32. *
  33. * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
  34. * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
  35. */
  36. enum ieee80211_band {
  37. IEEE80211_BAND_2GHZ,
  38. IEEE80211_BAND_5GHZ,
  39. /* keep last */
  40. IEEE80211_NUM_BANDS
  41. };
  42. /**
  43. * enum ieee80211_channel_flags - channel flags
  44. *
  45. * Channel flags set by the regulatory control code.
  46. *
  47. * @IEEE80211_CHAN_DISABLED: This channel is disabled.
  48. * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
  49. * on this channel.
  50. * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
  51. * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  52. * @IEEE80211_CHAN_NO_FAT_ABOVE: extension channel above this channel
  53. * is not permitted.
  54. * @IEEE80211_CHAN_NO_FAT_BELOW: extension channel below this channel
  55. * is not permitted.
  56. */
  57. enum ieee80211_channel_flags {
  58. IEEE80211_CHAN_DISABLED = 1<<0,
  59. IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
  60. IEEE80211_CHAN_NO_IBSS = 1<<2,
  61. IEEE80211_CHAN_RADAR = 1<<3,
  62. IEEE80211_CHAN_NO_FAT_ABOVE = 1<<4,
  63. IEEE80211_CHAN_NO_FAT_BELOW = 1<<5,
  64. };
  65. /**
  66. * struct ieee80211_channel - channel definition
  67. *
  68. * This structure describes a single channel for use
  69. * with cfg80211.
  70. *
  71. * @center_freq: center frequency in MHz
  72. * @max_bandwidth: maximum allowed bandwidth for this channel, in MHz
  73. * @hw_value: hardware-specific value for the channel
  74. * @flags: channel flags from &enum ieee80211_channel_flags.
  75. * @orig_flags: channel flags at registration time, used by regulatory
  76. * code to support devices with additional restrictions
  77. * @band: band this channel belongs to.
  78. * @max_antenna_gain: maximum antenna gain in dBi
  79. * @max_power: maximum transmission power (in dBm)
  80. * @beacon_found: helper to regulatory code to indicate when a beacon
  81. * has been found on this channel. Use regulatory_hint_found_beacon()
  82. * to enable this, this is is useful only on 5 GHz band.
  83. * @orig_mag: internal use
  84. * @orig_mpwr: internal use
  85. */
  86. struct ieee80211_channel {
  87. enum ieee80211_band band;
  88. u16 center_freq;
  89. u8 max_bandwidth;
  90. u16 hw_value;
  91. u32 flags;
  92. int max_antenna_gain;
  93. int max_power;
  94. bool beacon_found;
  95. u32 orig_flags;
  96. int orig_mag, orig_mpwr;
  97. };
  98. /**
  99. * enum ieee80211_rate_flags - rate flags
  100. *
  101. * Hardware/specification flags for rates. These are structured
  102. * in a way that allows using the same bitrate structure for
  103. * different bands/PHY modes.
  104. *
  105. * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
  106. * preamble on this bitrate; only relevant in 2.4GHz band and
  107. * with CCK rates.
  108. * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
  109. * when used with 802.11a (on the 5 GHz band); filled by the
  110. * core code when registering the wiphy.
  111. * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
  112. * when used with 802.11b (on the 2.4 GHz band); filled by the
  113. * core code when registering the wiphy.
  114. * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
  115. * when used with 802.11g (on the 2.4 GHz band); filled by the
  116. * core code when registering the wiphy.
  117. * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
  118. */
  119. enum ieee80211_rate_flags {
  120. IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
  121. IEEE80211_RATE_MANDATORY_A = 1<<1,
  122. IEEE80211_RATE_MANDATORY_B = 1<<2,
  123. IEEE80211_RATE_MANDATORY_G = 1<<3,
  124. IEEE80211_RATE_ERP_G = 1<<4,
  125. };
  126. /**
  127. * struct ieee80211_rate - bitrate definition
  128. *
  129. * This structure describes a bitrate that an 802.11 PHY can
  130. * operate with. The two values @hw_value and @hw_value_short
  131. * are only for driver use when pointers to this structure are
  132. * passed around.
  133. *
  134. * @flags: rate-specific flags
  135. * @bitrate: bitrate in units of 100 Kbps
  136. * @hw_value: driver/hardware value for this rate
  137. * @hw_value_short: driver/hardware value for this rate when
  138. * short preamble is used
  139. */
  140. struct ieee80211_rate {
  141. u32 flags;
  142. u16 bitrate;
  143. u16 hw_value, hw_value_short;
  144. };
  145. /**
  146. * struct ieee80211_sta_ht_cap - STA's HT capabilities
  147. *
  148. * This structure describes most essential parameters needed
  149. * to describe 802.11n HT capabilities for an STA.
  150. *
  151. * @ht_supported: is HT supported by the STA
  152. * @cap: HT capabilities map as described in 802.11n spec
  153. * @ampdu_factor: Maximum A-MPDU length factor
  154. * @ampdu_density: Minimum A-MPDU spacing
  155. * @mcs: Supported MCS rates
  156. */
  157. struct ieee80211_sta_ht_cap {
  158. u16 cap; /* use IEEE80211_HT_CAP_ */
  159. bool ht_supported;
  160. u8 ampdu_factor;
  161. u8 ampdu_density;
  162. struct ieee80211_mcs_info mcs;
  163. };
  164. /**
  165. * struct ieee80211_supported_band - frequency band definition
  166. *
  167. * This structure describes a frequency band a wiphy
  168. * is able to operate in.
  169. *
  170. * @channels: Array of channels the hardware can operate in
  171. * in this band.
  172. * @band: the band this structure represents
  173. * @n_channels: Number of channels in @channels
  174. * @bitrates: Array of bitrates the hardware can operate with
  175. * in this band. Must be sorted to give a valid "supported
  176. * rates" IE, i.e. CCK rates first, then OFDM.
  177. * @n_bitrates: Number of bitrates in @bitrates
  178. */
  179. struct ieee80211_supported_band {
  180. struct ieee80211_channel *channels;
  181. struct ieee80211_rate *bitrates;
  182. enum ieee80211_band band;
  183. int n_channels;
  184. int n_bitrates;
  185. struct ieee80211_sta_ht_cap ht_cap;
  186. };
  187. /*
  188. * Wireless hardware/device configuration structures and methods
  189. */
  190. /**
  191. * struct vif_params - describes virtual interface parameters
  192. * @mesh_id: mesh ID to use
  193. * @mesh_id_len: length of the mesh ID
  194. */
  195. struct vif_params {
  196. u8 *mesh_id;
  197. int mesh_id_len;
  198. };
  199. /**
  200. * struct key_params - key information
  201. *
  202. * Information about a key
  203. *
  204. * @key: key material
  205. * @key_len: length of key material
  206. * @cipher: cipher suite selector
  207. * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
  208. * with the get_key() callback, must be in little endian,
  209. * length given by @seq_len.
  210. */
  211. struct key_params {
  212. u8 *key;
  213. u8 *seq;
  214. int key_len;
  215. int seq_len;
  216. u32 cipher;
  217. };
  218. /**
  219. * struct beacon_parameters - beacon parameters
  220. *
  221. * Used to configure the beacon for an interface.
  222. *
  223. * @head: head portion of beacon (before TIM IE)
  224. * or %NULL if not changed
  225. * @tail: tail portion of beacon (after TIM IE)
  226. * or %NULL if not changed
  227. * @interval: beacon interval or zero if not changed
  228. * @dtim_period: DTIM period or zero if not changed
  229. * @head_len: length of @head
  230. * @tail_len: length of @tail
  231. */
  232. struct beacon_parameters {
  233. u8 *head, *tail;
  234. int interval, dtim_period;
  235. int head_len, tail_len;
  236. };
  237. /**
  238. * enum plink_action - actions to perform in mesh peers
  239. *
  240. * @PLINK_ACTION_INVALID: action 0 is reserved
  241. * @PLINK_ACTION_OPEN: start mesh peer link establishment
  242. * @PLINK_ACTION_BLOCL: block traffic from this mesh peer
  243. */
  244. enum plink_actions {
  245. PLINK_ACTION_INVALID,
  246. PLINK_ACTION_OPEN,
  247. PLINK_ACTION_BLOCK,
  248. };
  249. /**
  250. * struct station_parameters - station parameters
  251. *
  252. * Used to change and create a new station.
  253. *
  254. * @vlan: vlan interface station should belong to
  255. * @supported_rates: supported rates in IEEE 802.11 format
  256. * (or NULL for no change)
  257. * @supported_rates_len: number of supported rates
  258. * @sta_flags_mask: station flags that changed
  259. * (bitmask of BIT(NL80211_STA_FLAG_...))
  260. * @sta_flags_set: station flags values
  261. * (bitmask of BIT(NL80211_STA_FLAG_...))
  262. * @listen_interval: listen interval or -1 for no change
  263. * @aid: AID or zero for no change
  264. */
  265. struct station_parameters {
  266. u8 *supported_rates;
  267. struct net_device *vlan;
  268. u32 sta_flags_mask, sta_flags_set;
  269. int listen_interval;
  270. u16 aid;
  271. u8 supported_rates_len;
  272. u8 plink_action;
  273. struct ieee80211_ht_cap *ht_capa;
  274. };
  275. /**
  276. * enum station_info_flags - station information flags
  277. *
  278. * Used by the driver to indicate which info in &struct station_info
  279. * it has filled in during get_station() or dump_station().
  280. *
  281. * @STATION_INFO_INACTIVE_TIME: @inactive_time filled
  282. * @STATION_INFO_RX_BYTES: @rx_bytes filled
  283. * @STATION_INFO_TX_BYTES: @tx_bytes filled
  284. * @STATION_INFO_LLID: @llid filled
  285. * @STATION_INFO_PLID: @plid filled
  286. * @STATION_INFO_PLINK_STATE: @plink_state filled
  287. * @STATION_INFO_SIGNAL: @signal filled
  288. * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled
  289. * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs)
  290. * @STATION_INFO_RX_PACKETS: @rx_packets filled
  291. * @STATION_INFO_TX_PACKETS: @tx_packets filled
  292. */
  293. enum station_info_flags {
  294. STATION_INFO_INACTIVE_TIME = 1<<0,
  295. STATION_INFO_RX_BYTES = 1<<1,
  296. STATION_INFO_TX_BYTES = 1<<2,
  297. STATION_INFO_LLID = 1<<3,
  298. STATION_INFO_PLID = 1<<4,
  299. STATION_INFO_PLINK_STATE = 1<<5,
  300. STATION_INFO_SIGNAL = 1<<6,
  301. STATION_INFO_TX_BITRATE = 1<<7,
  302. STATION_INFO_RX_PACKETS = 1<<8,
  303. STATION_INFO_TX_PACKETS = 1<<9,
  304. };
  305. /**
  306. * enum station_info_rate_flags - bitrate info flags
  307. *
  308. * Used by the driver to indicate the specific rate transmission
  309. * type for 802.11n transmissions.
  310. *
  311. * @RATE_INFO_FLAGS_MCS: @tx_bitrate_mcs filled
  312. * @RATE_INFO_FLAGS_40_MHZ_WIDTH: 40 Mhz width transmission
  313. * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
  314. */
  315. enum rate_info_flags {
  316. RATE_INFO_FLAGS_MCS = 1<<0,
  317. RATE_INFO_FLAGS_40_MHZ_WIDTH = 1<<1,
  318. RATE_INFO_FLAGS_SHORT_GI = 1<<2,
  319. };
  320. /**
  321. * struct rate_info - bitrate information
  322. *
  323. * Information about a receiving or transmitting bitrate
  324. *
  325. * @flags: bitflag of flags from &enum rate_info_flags
  326. * @mcs: mcs index if struct describes a 802.11n bitrate
  327. * @legacy: bitrate in 100kbit/s for 802.11abg
  328. */
  329. struct rate_info {
  330. u8 flags;
  331. u8 mcs;
  332. u16 legacy;
  333. };
  334. /**
  335. * struct station_info - station information
  336. *
  337. * Station information filled by driver for get_station() and dump_station.
  338. *
  339. * @filled: bitflag of flags from &enum station_info_flags
  340. * @inactive_time: time since last station activity (tx/rx) in milliseconds
  341. * @rx_bytes: bytes received from this station
  342. * @tx_bytes: bytes transmitted to this station
  343. * @llid: mesh local link id
  344. * @plid: mesh peer link id
  345. * @plink_state: mesh peer link state
  346. * @signal: signal strength of last received packet in dBm
  347. * @txrate: current unicast bitrate to this station
  348. * @rx_packets: packets received from this station
  349. * @tx_packets: packets transmitted to this station
  350. */
  351. struct station_info {
  352. u32 filled;
  353. u32 inactive_time;
  354. u32 rx_bytes;
  355. u32 tx_bytes;
  356. u16 llid;
  357. u16 plid;
  358. u8 plink_state;
  359. s8 signal;
  360. struct rate_info txrate;
  361. u32 rx_packets;
  362. u32 tx_packets;
  363. };
  364. /**
  365. * enum monitor_flags - monitor flags
  366. *
  367. * Monitor interface configuration flags. Note that these must be the bits
  368. * according to the nl80211 flags.
  369. *
  370. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  371. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  372. * @MONITOR_FLAG_CONTROL: pass control frames
  373. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  374. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  375. */
  376. enum monitor_flags {
  377. MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
  378. MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
  379. MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
  380. MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
  381. MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
  382. };
  383. /**
  384. * enum mpath_info_flags - mesh path information flags
  385. *
  386. * Used by the driver to indicate which info in &struct mpath_info it has filled
  387. * in during get_station() or dump_station().
  388. *
  389. * MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  390. * MPATH_INFO_DSN: @dsn filled
  391. * MPATH_INFO_METRIC: @metric filled
  392. * MPATH_INFO_EXPTIME: @exptime filled
  393. * MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  394. * MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  395. * MPATH_INFO_FLAGS: @flags filled
  396. */
  397. enum mpath_info_flags {
  398. MPATH_INFO_FRAME_QLEN = BIT(0),
  399. MPATH_INFO_DSN = BIT(1),
  400. MPATH_INFO_METRIC = BIT(2),
  401. MPATH_INFO_EXPTIME = BIT(3),
  402. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  403. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  404. MPATH_INFO_FLAGS = BIT(6),
  405. };
  406. /**
  407. * struct mpath_info - mesh path information
  408. *
  409. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  410. *
  411. * @filled: bitfield of flags from &enum mpath_info_flags
  412. * @frame_qlen: number of queued frames for this destination
  413. * @dsn: destination sequence number
  414. * @metric: metric (cost) of this mesh path
  415. * @exptime: expiration time for the mesh path from now, in msecs
  416. * @flags: mesh path flags
  417. * @discovery_timeout: total mesh path discovery timeout, in msecs
  418. * @discovery_retries: mesh path discovery retries
  419. */
  420. struct mpath_info {
  421. u32 filled;
  422. u32 frame_qlen;
  423. u32 dsn;
  424. u32 metric;
  425. u32 exptime;
  426. u32 discovery_timeout;
  427. u8 discovery_retries;
  428. u8 flags;
  429. };
  430. /**
  431. * struct bss_parameters - BSS parameters
  432. *
  433. * Used to change BSS parameters (mainly for AP mode).
  434. *
  435. * @use_cts_prot: Whether to use CTS protection
  436. * (0 = no, 1 = yes, -1 = do not change)
  437. * @use_short_preamble: Whether the use of short preambles is allowed
  438. * (0 = no, 1 = yes, -1 = do not change)
  439. * @use_short_slot_time: Whether the use of short slot time is allowed
  440. * (0 = no, 1 = yes, -1 = do not change)
  441. * @basic_rates: basic rates in IEEE 802.11 format
  442. * (or NULL for no change)
  443. * @basic_rates_len: number of basic rates
  444. */
  445. struct bss_parameters {
  446. int use_cts_prot;
  447. int use_short_preamble;
  448. int use_short_slot_time;
  449. u8 *basic_rates;
  450. u8 basic_rates_len;
  451. };
  452. struct mesh_config {
  453. /* Timeouts in ms */
  454. /* Mesh plink management parameters */
  455. u16 dot11MeshRetryTimeout;
  456. u16 dot11MeshConfirmTimeout;
  457. u16 dot11MeshHoldingTimeout;
  458. u16 dot11MeshMaxPeerLinks;
  459. u8 dot11MeshMaxRetries;
  460. u8 dot11MeshTTL;
  461. bool auto_open_plinks;
  462. /* HWMP parameters */
  463. u8 dot11MeshHWMPmaxPREQretries;
  464. u32 path_refresh_time;
  465. u16 min_discovery_timeout;
  466. u32 dot11MeshHWMPactivePathTimeout;
  467. u16 dot11MeshHWMPpreqMinInterval;
  468. u16 dot11MeshHWMPnetDiameterTraversalTime;
  469. };
  470. /**
  471. * struct ieee80211_txq_params - TX queue parameters
  472. * @queue: TX queue identifier (NL80211_TXQ_Q_*)
  473. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  474. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  475. * 1..32767]
  476. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  477. * 1..32767]
  478. * @aifs: Arbitration interframe space [0..255]
  479. */
  480. struct ieee80211_txq_params {
  481. enum nl80211_txq_q queue;
  482. u16 txop;
  483. u16 cwmin;
  484. u16 cwmax;
  485. u8 aifs;
  486. };
  487. /* from net/wireless.h */
  488. struct wiphy;
  489. /* from net/ieee80211.h */
  490. struct ieee80211_channel;
  491. /**
  492. * struct cfg80211_ssid - SSID description
  493. * @ssid: the SSID
  494. * @ssid_len: length of the ssid
  495. */
  496. struct cfg80211_ssid {
  497. u8 ssid[IEEE80211_MAX_SSID_LEN];
  498. u8 ssid_len;
  499. };
  500. /**
  501. * struct cfg80211_scan_request - scan request description
  502. *
  503. * @ssids: SSIDs to scan for (active scan only)
  504. * @n_ssids: number of SSIDs
  505. * @channels: channels to scan on.
  506. * @n_channels: number of channels for each band
  507. * @ie: optional information element(s) to add into Probe Request or %NULL
  508. * @ie_len: length of ie in octets
  509. * @wiphy: the wiphy this was for
  510. * @ifidx: the interface index
  511. */
  512. struct cfg80211_scan_request {
  513. struct cfg80211_ssid *ssids;
  514. int n_ssids;
  515. struct ieee80211_channel **channels;
  516. u32 n_channels;
  517. const u8 *ie;
  518. size_t ie_len;
  519. /* internal */
  520. struct wiphy *wiphy;
  521. int ifidx;
  522. };
  523. /**
  524. * enum cfg80211_signal_type - signal type
  525. *
  526. * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
  527. * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
  528. * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
  529. */
  530. enum cfg80211_signal_type {
  531. CFG80211_SIGNAL_TYPE_NONE,
  532. CFG80211_SIGNAL_TYPE_MBM,
  533. CFG80211_SIGNAL_TYPE_UNSPEC,
  534. };
  535. /**
  536. * struct cfg80211_bss - BSS description
  537. *
  538. * This structure describes a BSS (which may also be a mesh network)
  539. * for use in scan results and similar.
  540. *
  541. * @bssid: BSSID of the BSS
  542. * @tsf: timestamp of last received update
  543. * @beacon_interval: the beacon interval as from the frame
  544. * @capability: the capability field in host byte order
  545. * @information_elements: the information elements (Note that there
  546. * is no guarantee that these are well-formed!)
  547. * @len_information_elements: total length of the information elements
  548. * @signal: signal strength value (type depends on the wiphy's signal_type)
  549. * @hold: BSS should not expire
  550. * @free_priv: function pointer to free private data
  551. * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  552. */
  553. struct cfg80211_bss {
  554. struct ieee80211_channel *channel;
  555. u8 bssid[ETH_ALEN];
  556. u64 tsf;
  557. u16 beacon_interval;
  558. u16 capability;
  559. u8 *information_elements;
  560. size_t len_information_elements;
  561. s32 signal;
  562. void (*free_priv)(struct cfg80211_bss *bss);
  563. u8 priv[0] __attribute__((__aligned__(sizeof(void *))));
  564. };
  565. /**
  566. * struct cfg80211_auth_request - Authentication request data
  567. *
  568. * This structure provides information needed to complete IEEE 802.11
  569. * authentication.
  570. * NOTE: This structure will likely change when more code from mac80211 is
  571. * moved into cfg80211 so that non-mac80211 drivers can benefit from it, too.
  572. * Before using this in a driver that does not use mac80211, it would be better
  573. * to check the status of that work and better yet, volunteer to work on it.
  574. *
  575. * @chan: The channel to use or %NULL if not specified (auto-select based on
  576. * scan results)
  577. * @peer_addr: The address of the peer STA (AP BSSID in infrastructure case);
  578. * this field is required to be present; if the driver wants to help with
  579. * BSS selection, it should use (yet to be added) MLME event to allow user
  580. * space SME to be notified of roaming candidate, so that the SME can then
  581. * use the authentication request with the recommended BSSID and whatever
  582. * other data may be needed for authentication/association
  583. * @ssid: SSID or %NULL if not yet available
  584. * @ssid_len: Length of ssid in octets
  585. * @auth_type: Authentication type (algorithm)
  586. * @ie: Extra IEs to add to Authentication frame or %NULL
  587. * @ie_len: Length of ie buffer in octets
  588. */
  589. struct cfg80211_auth_request {
  590. struct ieee80211_channel *chan;
  591. u8 *peer_addr;
  592. const u8 *ssid;
  593. size_t ssid_len;
  594. enum nl80211_auth_type auth_type;
  595. const u8 *ie;
  596. size_t ie_len;
  597. };
  598. /**
  599. * struct cfg80211_assoc_request - (Re)Association request data
  600. *
  601. * This structure provides information needed to complete IEEE 802.11
  602. * (re)association.
  603. * NOTE: This structure will likely change when more code from mac80211 is
  604. * moved into cfg80211 so that non-mac80211 drivers can benefit from it, too.
  605. * Before using this in a driver that does not use mac80211, it would be better
  606. * to check the status of that work and better yet, volunteer to work on it.
  607. *
  608. * @chan: The channel to use or %NULL if not specified (auto-select based on
  609. * scan results)
  610. * @peer_addr: The address of the peer STA (AP BSSID); this field is required
  611. * to be present and the STA must be in State 2 (authenticated) with the
  612. * peer STA
  613. * @ssid: SSID
  614. * @ssid_len: Length of ssid in octets
  615. * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
  616. * @ie_len: Length of ie buffer in octets
  617. * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
  618. */
  619. struct cfg80211_assoc_request {
  620. struct ieee80211_channel *chan;
  621. u8 *peer_addr;
  622. const u8 *ssid;
  623. size_t ssid_len;
  624. const u8 *ie;
  625. size_t ie_len;
  626. bool use_mfp;
  627. };
  628. /**
  629. * struct cfg80211_deauth_request - Deauthentication request data
  630. *
  631. * This structure provides information needed to complete IEEE 802.11
  632. * deauthentication.
  633. *
  634. * @peer_addr: The address of the peer STA (AP BSSID); this field is required
  635. * to be present and the STA must be authenticated with the peer STA
  636. * @ie: Extra IEs to add to Deauthentication frame or %NULL
  637. * @ie_len: Length of ie buffer in octets
  638. */
  639. struct cfg80211_deauth_request {
  640. u8 *peer_addr;
  641. u16 reason_code;
  642. const u8 *ie;
  643. size_t ie_len;
  644. };
  645. /**
  646. * struct cfg80211_disassoc_request - Disassociation request data
  647. *
  648. * This structure provides information needed to complete IEEE 802.11
  649. * disassocation.
  650. *
  651. * @peer_addr: The address of the peer STA (AP BSSID); this field is required
  652. * to be present and the STA must be associated with the peer STA
  653. * @ie: Extra IEs to add to Disassociation frame or %NULL
  654. * @ie_len: Length of ie buffer in octets
  655. */
  656. struct cfg80211_disassoc_request {
  657. u8 *peer_addr;
  658. u16 reason_code;
  659. const u8 *ie;
  660. size_t ie_len;
  661. };
  662. /**
  663. * struct cfg80211_ibss_params - IBSS parameters
  664. *
  665. * This structure defines the IBSS parameters for the join_ibss()
  666. * method.
  667. *
  668. * @ssid: The SSID, will always be non-null.
  669. * @ssid_len: The length of the SSID, will always be non-zero.
  670. * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
  671. * search for IBSSs with a different BSSID.
  672. * @channel: The channel to use if no IBSS can be found to join.
  673. * @channel_fixed: The channel should be fixed -- do not search for
  674. * IBSSs to join on other channels.
  675. * @ie: information element(s) to include in the beacon
  676. * @ie_len: length of that
  677. * @beacon_interval: beacon interval to use
  678. */
  679. struct cfg80211_ibss_params {
  680. u8 *ssid;
  681. u8 *bssid;
  682. struct ieee80211_channel *channel;
  683. u8 *ie;
  684. u8 ssid_len, ie_len;
  685. u16 beacon_interval;
  686. bool channel_fixed;
  687. };
  688. /**
  689. * enum wiphy_params_flags - set_wiphy_params bitfield values
  690. * WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
  691. * WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  692. * WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  693. * WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  694. */
  695. enum wiphy_params_flags {
  696. WIPHY_PARAM_RETRY_SHORT = 1 << 0,
  697. WIPHY_PARAM_RETRY_LONG = 1 << 1,
  698. WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
  699. WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
  700. };
  701. /**
  702. * struct cfg80211_ops - backend description for wireless configuration
  703. *
  704. * This struct is registered by fullmac card drivers and/or wireless stacks
  705. * in order to handle configuration requests on their interfaces.
  706. *
  707. * All callbacks except where otherwise noted should return 0
  708. * on success or a negative error code.
  709. *
  710. * All operations are currently invoked under rtnl for consistency with the
  711. * wireless extensions but this is subject to reevaluation as soon as this
  712. * code is used more widely and we have a first user without wext.
  713. *
  714. * @suspend: wiphy device needs to be suspended
  715. * @resume: wiphy device needs to be resumed
  716. *
  717. * @add_virtual_intf: create a new virtual interface with the given name,
  718. * must set the struct wireless_dev's iftype.
  719. *
  720. * @del_virtual_intf: remove the virtual interface determined by ifindex.
  721. *
  722. * @change_virtual_intf: change type/configuration of virtual interface,
  723. * keep the struct wireless_dev's iftype updated.
  724. *
  725. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  726. * when adding a group key.
  727. *
  728. * @get_key: get information about the key with the given parameters.
  729. * @mac_addr will be %NULL when requesting information for a group
  730. * key. All pointers given to the @callback function need not be valid
  731. * after it returns.
  732. *
  733. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  734. * and @key_index
  735. *
  736. * @set_default_key: set the default key on an interface
  737. *
  738. * @set_default_mgmt_key: set the default management frame key on an interface
  739. *
  740. * @add_beacon: Add a beacon with given parameters, @head, @interval
  741. * and @dtim_period will be valid, @tail is optional.
  742. * @set_beacon: Change the beacon parameters for an access point mode
  743. * interface. This should reject the call when no beacon has been
  744. * configured.
  745. * @del_beacon: Remove beacon configuration and stop sending the beacon.
  746. *
  747. * @add_station: Add a new station.
  748. *
  749. * @del_station: Remove a station; @mac may be NULL to remove all stations.
  750. *
  751. * @change_station: Modify a given station.
  752. *
  753. * @get_mesh_params: Put the current mesh parameters into *params
  754. *
  755. * @set_mesh_params: Set mesh parameters.
  756. * The mask is a bitfield which tells us which parameters to
  757. * set, and which to leave alone.
  758. *
  759. * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
  760. *
  761. * @change_bss: Modify parameters for a given BSS.
  762. *
  763. * @set_txq_params: Set TX queue parameters
  764. *
  765. * @set_channel: Set channel
  766. *
  767. * @scan: Request to do a scan. If returning zero, the scan request is given
  768. * the driver, and will be valid until passed to cfg80211_scan_done().
  769. * For scan results, call cfg80211_inform_bss(); you can call this outside
  770. * the scan/scan_done bracket too.
  771. *
  772. * @auth: Request to authenticate with the specified peer
  773. * @assoc: Request to (re)associate with the specified peer
  774. * @deauth: Request to deauthenticate from the specified peer
  775. * @disassoc: Request to disassociate from the specified peer
  776. *
  777. * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
  778. * cfg80211_ibss_joined(), also call that function when changing BSSID due
  779. * to a merge.
  780. * @leave_ibss: Leave the IBSS.
  781. *
  782. * @set_wiphy_params: Notify that wiphy parameters have changed;
  783. * @changed bitfield (see &enum wiphy_params_flags) describes which values
  784. * have changed. The actual parameter values are available in
  785. * struct wiphy. If returning an error, no value should be changed.
  786. */
  787. struct cfg80211_ops {
  788. int (*suspend)(struct wiphy *wiphy);
  789. int (*resume)(struct wiphy *wiphy);
  790. int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
  791. enum nl80211_iftype type, u32 *flags,
  792. struct vif_params *params);
  793. int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
  794. int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
  795. enum nl80211_iftype type, u32 *flags,
  796. struct vif_params *params);
  797. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  798. u8 key_index, const u8 *mac_addr,
  799. struct key_params *params);
  800. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  801. u8 key_index, const u8 *mac_addr, void *cookie,
  802. void (*callback)(void *cookie, struct key_params*));
  803. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  804. u8 key_index, const u8 *mac_addr);
  805. int (*set_default_key)(struct wiphy *wiphy,
  806. struct net_device *netdev,
  807. u8 key_index);
  808. int (*set_default_mgmt_key)(struct wiphy *wiphy,
  809. struct net_device *netdev,
  810. u8 key_index);
  811. int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
  812. struct beacon_parameters *info);
  813. int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
  814. struct beacon_parameters *info);
  815. int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
  816. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  817. u8 *mac, struct station_parameters *params);
  818. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  819. u8 *mac);
  820. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  821. u8 *mac, struct station_parameters *params);
  822. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  823. u8 *mac, struct station_info *sinfo);
  824. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  825. int idx, u8 *mac, struct station_info *sinfo);
  826. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  827. u8 *dst, u8 *next_hop);
  828. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  829. u8 *dst);
  830. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  831. u8 *dst, u8 *next_hop);
  832. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  833. u8 *dst, u8 *next_hop,
  834. struct mpath_info *pinfo);
  835. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  836. int idx, u8 *dst, u8 *next_hop,
  837. struct mpath_info *pinfo);
  838. int (*get_mesh_params)(struct wiphy *wiphy,
  839. struct net_device *dev,
  840. struct mesh_config *conf);
  841. int (*set_mesh_params)(struct wiphy *wiphy,
  842. struct net_device *dev,
  843. const struct mesh_config *nconf, u32 mask);
  844. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  845. struct bss_parameters *params);
  846. int (*set_txq_params)(struct wiphy *wiphy,
  847. struct ieee80211_txq_params *params);
  848. int (*set_channel)(struct wiphy *wiphy,
  849. struct ieee80211_channel *chan,
  850. enum nl80211_channel_type channel_type);
  851. int (*scan)(struct wiphy *wiphy, struct net_device *dev,
  852. struct cfg80211_scan_request *request);
  853. int (*auth)(struct wiphy *wiphy, struct net_device *dev,
  854. struct cfg80211_auth_request *req);
  855. int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
  856. struct cfg80211_assoc_request *req);
  857. int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
  858. struct cfg80211_deauth_request *req);
  859. int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
  860. struct cfg80211_disassoc_request *req);
  861. int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
  862. struct cfg80211_ibss_params *params);
  863. int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
  864. int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
  865. };
  866. /*
  867. * wireless hardware and networking interfaces structures
  868. * and registration/helper functions
  869. */
  870. /**
  871. * struct wiphy - wireless hardware description
  872. * @idx: the wiphy index assigned to this item
  873. * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
  874. * @custom_regulatory: tells us the driver for this device
  875. * has its own custom regulatory domain and cannot identify the
  876. * ISO / IEC 3166 alpha2 it belongs to. When this is enabled
  877. * we will disregard the first regulatory hint (when the
  878. * initiator is %REGDOM_SET_BY_CORE).
  879. * @strict_regulatory: tells us the driver for this device will ignore
  880. * regulatory domain settings until it gets its own regulatory domain
  881. * via its regulatory_hint(). After its gets its own regulatory domain
  882. * it will only allow further regulatory domain settings to further
  883. * enhance compliance. For example if channel 13 and 14 are disabled
  884. * by this regulatory domain no user regulatory domain can enable these
  885. * channels at a later time. This can be used for devices which do not
  886. * have calibration information gauranteed for frequencies or settings
  887. * outside of its regulatory domain.
  888. * @reg_notifier: the driver's regulatory notification callback
  889. * @regd: the driver's regulatory domain, if one was requested via
  890. * the regulatory_hint() API. This can be used by the driver
  891. * on the reg_notifier() if it chooses to ignore future
  892. * regulatory domain changes caused by other drivers.
  893. * @signal_type: signal type reported in &struct cfg80211_bss.
  894. * @cipher_suites: supported cipher suites
  895. * @n_cipher_suites: number of supported cipher suites
  896. * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
  897. * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
  898. * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  899. * -1 = fragmentation disabled, only odd values >= 256 used
  900. * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
  901. */
  902. struct wiphy {
  903. /* assign these fields before you register the wiphy */
  904. /* permanent MAC address */
  905. u8 perm_addr[ETH_ALEN];
  906. /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  907. u16 interface_modes;
  908. bool custom_regulatory;
  909. bool strict_regulatory;
  910. enum cfg80211_signal_type signal_type;
  911. int bss_priv_size;
  912. u8 max_scan_ssids;
  913. u16 max_scan_ie_len;
  914. int n_cipher_suites;
  915. const u32 *cipher_suites;
  916. u8 retry_short;
  917. u8 retry_long;
  918. u32 frag_threshold;
  919. u32 rts_threshold;
  920. /* If multiple wiphys are registered and you're handed e.g.
  921. * a regular netdev with assigned ieee80211_ptr, you won't
  922. * know whether it points to a wiphy your driver has registered
  923. * or not. Assign this to something global to your driver to
  924. * help determine whether you own this wiphy or not. */
  925. void *privid;
  926. struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
  927. /* Lets us get back the wiphy on the callback */
  928. int (*reg_notifier)(struct wiphy *wiphy,
  929. struct regulatory_request *request);
  930. /* fields below are read-only, assigned by cfg80211 */
  931. const struct ieee80211_regdomain *regd;
  932. /* the item in /sys/class/ieee80211/ points to this,
  933. * you need use set_wiphy_dev() (see below) */
  934. struct device dev;
  935. /* dir in debugfs: ieee80211/<wiphyname> */
  936. struct dentry *debugfsdir;
  937. char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
  938. };
  939. /**
  940. * wiphy_priv - return priv from wiphy
  941. *
  942. * @wiphy: the wiphy whose priv pointer to return
  943. */
  944. static inline void *wiphy_priv(struct wiphy *wiphy)
  945. {
  946. BUG_ON(!wiphy);
  947. return &wiphy->priv;
  948. }
  949. /**
  950. * set_wiphy_dev - set device pointer for wiphy
  951. *
  952. * @wiphy: The wiphy whose device to bind
  953. * @dev: The device to parent it to
  954. */
  955. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  956. {
  957. wiphy->dev.parent = dev;
  958. }
  959. /**
  960. * wiphy_dev - get wiphy dev pointer
  961. *
  962. * @wiphy: The wiphy whose device struct to look up
  963. */
  964. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  965. {
  966. return wiphy->dev.parent;
  967. }
  968. /**
  969. * wiphy_name - get wiphy name
  970. *
  971. * @wiphy: The wiphy whose name to return
  972. */
  973. static inline const char *wiphy_name(struct wiphy *wiphy)
  974. {
  975. return dev_name(&wiphy->dev);
  976. }
  977. /**
  978. * wiphy_new - create a new wiphy for use with cfg80211
  979. *
  980. * @ops: The configuration operations for this device
  981. * @sizeof_priv: The size of the private area to allocate
  982. *
  983. * Create a new wiphy and associate the given operations with it.
  984. * @sizeof_priv bytes are allocated for private use.
  985. *
  986. * The returned pointer must be assigned to each netdev's
  987. * ieee80211_ptr for proper operation.
  988. */
  989. struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
  990. /**
  991. * wiphy_register - register a wiphy with cfg80211
  992. *
  993. * @wiphy: The wiphy to register.
  994. *
  995. * Returns a non-negative wiphy index or a negative error code.
  996. */
  997. extern int wiphy_register(struct wiphy *wiphy);
  998. /**
  999. * wiphy_unregister - deregister a wiphy from cfg80211
  1000. *
  1001. * @wiphy: The wiphy to unregister.
  1002. *
  1003. * After this call, no more requests can be made with this priv
  1004. * pointer, but the call may sleep to wait for an outstanding
  1005. * request that is being handled.
  1006. */
  1007. extern void wiphy_unregister(struct wiphy *wiphy);
  1008. /**
  1009. * wiphy_free - free wiphy
  1010. *
  1011. * @wiphy: The wiphy to free
  1012. */
  1013. extern void wiphy_free(struct wiphy *wiphy);
  1014. /**
  1015. * struct wireless_dev - wireless per-netdev state
  1016. *
  1017. * This structure must be allocated by the driver/stack
  1018. * that uses the ieee80211_ptr field in struct net_device
  1019. * (this is intentional so it can be allocated along with
  1020. * the netdev.)
  1021. *
  1022. * @wiphy: pointer to hardware description
  1023. * @iftype: interface type
  1024. * @list: (private) Used to collect the interfaces
  1025. * @netdev: (private) Used to reference back to the netdev
  1026. * @current_bss: (private) Used by the internal configuration code
  1027. * @bssid: (private) Used by the internal configuration code
  1028. * @ssid: (private) Used by the internal configuration code
  1029. * @ssid_len: (private) Used by the internal configuration code
  1030. * @wext: (private) Used by the internal wireless extensions compat code
  1031. * @wext_bssid: (private) Used by the internal wireless extensions compat code
  1032. */
  1033. struct wireless_dev {
  1034. struct wiphy *wiphy;
  1035. enum nl80211_iftype iftype;
  1036. /* private to the generic wireless code */
  1037. struct list_head list;
  1038. struct net_device *netdev;
  1039. /* currently used for IBSS - might be rearranged in the future */
  1040. struct cfg80211_bss *current_bss;
  1041. u8 bssid[ETH_ALEN];
  1042. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1043. u8 ssid_len;
  1044. #ifdef CONFIG_WIRELESS_EXT
  1045. /* wext data */
  1046. struct {
  1047. struct cfg80211_ibss_params ibss;
  1048. u8 bssid[ETH_ALEN];
  1049. s8 default_key, default_mgmt_key;
  1050. } wext;
  1051. #endif
  1052. };
  1053. /**
  1054. * wdev_priv - return wiphy priv from wireless_dev
  1055. *
  1056. * @wdev: The wireless device whose wiphy's priv pointer to return
  1057. */
  1058. static inline void *wdev_priv(struct wireless_dev *wdev)
  1059. {
  1060. BUG_ON(!wdev);
  1061. return wiphy_priv(wdev->wiphy);
  1062. }
  1063. /*
  1064. * Utility functions
  1065. */
  1066. /**
  1067. * ieee80211_channel_to_frequency - convert channel number to frequency
  1068. */
  1069. extern int ieee80211_channel_to_frequency(int chan);
  1070. /**
  1071. * ieee80211_frequency_to_channel - convert frequency to channel number
  1072. */
  1073. extern int ieee80211_frequency_to_channel(int freq);
  1074. /*
  1075. * Name indirection necessary because the ieee80211 code also has
  1076. * a function named "ieee80211_get_channel", so if you include
  1077. * cfg80211's header file you get cfg80211's version, if you try
  1078. * to include both header files you'll (rightfully!) get a symbol
  1079. * clash.
  1080. */
  1081. extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
  1082. int freq);
  1083. /**
  1084. * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  1085. */
  1086. static inline struct ieee80211_channel *
  1087. ieee80211_get_channel(struct wiphy *wiphy, int freq)
  1088. {
  1089. return __ieee80211_get_channel(wiphy, freq);
  1090. }
  1091. /**
  1092. * ieee80211_get_response_rate - get basic rate for a given rate
  1093. *
  1094. * @sband: the band to look for rates in
  1095. * @basic_rates: bitmap of basic rates
  1096. * @bitrate: the bitrate for which to find the basic rate
  1097. *
  1098. * This function returns the basic rate corresponding to a given
  1099. * bitrate, that is the next lower bitrate contained in the basic
  1100. * rate map, which is, for this function, given as a bitmap of
  1101. * indices of rates in the band's bitrate table.
  1102. */
  1103. struct ieee80211_rate *
  1104. ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  1105. u32 basic_rates, int bitrate);
  1106. /*
  1107. * Radiotap parsing functions -- for controlled injection support
  1108. *
  1109. * Implemented in net/wireless/radiotap.c
  1110. * Documentation in Documentation/networking/radiotap-headers.txt
  1111. */
  1112. /**
  1113. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  1114. * @rtheader: pointer to the radiotap header we are walking through
  1115. * @max_length: length of radiotap header in cpu byte ordering
  1116. * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
  1117. * @this_arg: pointer to current radiotap arg
  1118. * @arg_index: internal next argument index
  1119. * @arg: internal next argument pointer
  1120. * @next_bitmap: internal pointer to next present u32
  1121. * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  1122. */
  1123. struct ieee80211_radiotap_iterator {
  1124. struct ieee80211_radiotap_header *rtheader;
  1125. int max_length;
  1126. int this_arg_index;
  1127. u8 *this_arg;
  1128. int arg_index;
  1129. u8 *arg;
  1130. __le32 *next_bitmap;
  1131. u32 bitmap_shifter;
  1132. };
  1133. extern int ieee80211_radiotap_iterator_init(
  1134. struct ieee80211_radiotap_iterator *iterator,
  1135. struct ieee80211_radiotap_header *radiotap_header,
  1136. int max_length);
  1137. extern int ieee80211_radiotap_iterator_next(
  1138. struct ieee80211_radiotap_iterator *iterator);
  1139. /*
  1140. * Regulatory helper functions for wiphys
  1141. */
  1142. /**
  1143. * regulatory_hint - driver hint to the wireless core a regulatory domain
  1144. * @wiphy: the wireless device giving the hint (used only for reporting
  1145. * conflicts)
  1146. * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  1147. * should be in. If @rd is set this should be NULL. Note that if you
  1148. * set this to NULL you should still set rd->alpha2 to some accepted
  1149. * alpha2.
  1150. *
  1151. * Wireless drivers can use this function to hint to the wireless core
  1152. * what it believes should be the current regulatory domain by
  1153. * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  1154. * domain should be in or by providing a completely build regulatory domain.
  1155. * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  1156. * for a regulatory domain structure for the respective country.
  1157. *
  1158. * The wiphy must have been registered to cfg80211 prior to this call.
  1159. * For cfg80211 drivers this means you must first use wiphy_register(),
  1160. * for mac80211 drivers you must first use ieee80211_register_hw().
  1161. *
  1162. * Drivers should check the return value, its possible you can get
  1163. * an -ENOMEM.
  1164. */
  1165. extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  1166. /**
  1167. * regulatory_hint_11d - hints a country IE as a regulatory domain
  1168. * @wiphy: the wireless device giving the hint (used only for reporting
  1169. * conflicts)
  1170. * @country_ie: pointer to the country IE
  1171. * @country_ie_len: length of the country IE
  1172. *
  1173. * We will intersect the rd with the what CRDA tells us should apply
  1174. * for the alpha2 this country IE belongs to, this prevents APs from
  1175. * sending us incorrect or outdated information against a country.
  1176. */
  1177. extern void regulatory_hint_11d(struct wiphy *wiphy,
  1178. u8 *country_ie,
  1179. u8 country_ie_len);
  1180. /**
  1181. * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  1182. * @wiphy: the wireless device we want to process the regulatory domain on
  1183. * @regd: the custom regulatory domain to use for this wiphy
  1184. *
  1185. * Drivers can sometimes have custom regulatory domains which do not apply
  1186. * to a specific country. Drivers can use this to apply such custom regulatory
  1187. * domains. This routine must be called prior to wiphy registration. The
  1188. * custom regulatory domain will be trusted completely and as such previous
  1189. * default channel settings will be disregarded. If no rule is found for a
  1190. * channel on the regulatory domain the channel will be disabled.
  1191. */
  1192. extern void wiphy_apply_custom_regulatory(
  1193. struct wiphy *wiphy,
  1194. const struct ieee80211_regdomain *regd);
  1195. /**
  1196. * freq_reg_info - get regulatory information for the given frequency
  1197. * @wiphy: the wiphy for which we want to process this rule for
  1198. * @center_freq: Frequency in KHz for which we want regulatory information for
  1199. * @bandwidth: the bandwidth requirement you have in KHz, if you do not have one
  1200. * you can set this to 0. If this frequency is allowed we then set
  1201. * this value to the maximum allowed bandwidth.
  1202. * @reg_rule: the regulatory rule which we have for this frequency
  1203. *
  1204. * Use this function to get the regulatory rule for a specific frequency on
  1205. * a given wireless device. If the device has a specific regulatory domain
  1206. * it wants to follow we respect that unless a country IE has been received
  1207. * and processed already.
  1208. *
  1209. * Returns 0 if it was able to find a valid regulatory rule which does
  1210. * apply to the given center_freq otherwise it returns non-zero. It will
  1211. * also return -ERANGE if we determine the given center_freq does not even have
  1212. * a regulatory rule for a frequency range in the center_freq's band. See
  1213. * freq_in_rule_band() for our current definition of a band -- this is purely
  1214. * subjective and right now its 802.11 specific.
  1215. */
  1216. extern int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 *bandwidth,
  1217. const struct ieee80211_reg_rule **reg_rule);
  1218. /*
  1219. * Temporary wext handlers & helper functions
  1220. *
  1221. * In the future cfg80211 will simply assign the entire wext handler
  1222. * structure to netdevs it manages, but we're not there yet.
  1223. */
  1224. int cfg80211_wext_giwname(struct net_device *dev,
  1225. struct iw_request_info *info,
  1226. char *name, char *extra);
  1227. int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
  1228. u32 *mode, char *extra);
  1229. int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
  1230. u32 *mode, char *extra);
  1231. int cfg80211_wext_siwscan(struct net_device *dev,
  1232. struct iw_request_info *info,
  1233. union iwreq_data *wrqu, char *extra);
  1234. int cfg80211_wext_giwscan(struct net_device *dev,
  1235. struct iw_request_info *info,
  1236. struct iw_point *data, char *extra);
  1237. int cfg80211_wext_siwmlme(struct net_device *dev,
  1238. struct iw_request_info *info,
  1239. struct iw_point *data, char *extra);
  1240. int cfg80211_wext_giwrange(struct net_device *dev,
  1241. struct iw_request_info *info,
  1242. struct iw_point *data, char *extra);
  1243. int cfg80211_ibss_wext_siwfreq(struct net_device *dev,
  1244. struct iw_request_info *info,
  1245. struct iw_freq *freq, char *extra);
  1246. int cfg80211_ibss_wext_giwfreq(struct net_device *dev,
  1247. struct iw_request_info *info,
  1248. struct iw_freq *freq, char *extra);
  1249. int cfg80211_ibss_wext_siwessid(struct net_device *dev,
  1250. struct iw_request_info *info,
  1251. struct iw_point *data, char *ssid);
  1252. int cfg80211_ibss_wext_giwessid(struct net_device *dev,
  1253. struct iw_request_info *info,
  1254. struct iw_point *data, char *ssid);
  1255. int cfg80211_ibss_wext_siwap(struct net_device *dev,
  1256. struct iw_request_info *info,
  1257. struct sockaddr *ap_addr, char *extra);
  1258. int cfg80211_ibss_wext_giwap(struct net_device *dev,
  1259. struct iw_request_info *info,
  1260. struct sockaddr *ap_addr, char *extra);
  1261. struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
  1262. struct iw_freq *freq);
  1263. int cfg80211_wext_siwrts(struct net_device *dev,
  1264. struct iw_request_info *info,
  1265. struct iw_param *rts, char *extra);
  1266. int cfg80211_wext_giwrts(struct net_device *dev,
  1267. struct iw_request_info *info,
  1268. struct iw_param *rts, char *extra);
  1269. int cfg80211_wext_siwfrag(struct net_device *dev,
  1270. struct iw_request_info *info,
  1271. struct iw_param *frag, char *extra);
  1272. int cfg80211_wext_giwfrag(struct net_device *dev,
  1273. struct iw_request_info *info,
  1274. struct iw_param *frag, char *extra);
  1275. int cfg80211_wext_siwretry(struct net_device *dev,
  1276. struct iw_request_info *info,
  1277. struct iw_param *retry, char *extra);
  1278. int cfg80211_wext_giwretry(struct net_device *dev,
  1279. struct iw_request_info *info,
  1280. struct iw_param *retry, char *extra);
  1281. int cfg80211_wext_siwencodeext(struct net_device *dev,
  1282. struct iw_request_info *info,
  1283. struct iw_point *erq, char *extra);
  1284. int cfg80211_wext_siwencode(struct net_device *dev,
  1285. struct iw_request_info *info,
  1286. struct iw_point *erq, char *keybuf);
  1287. int cfg80211_wext_giwencode(struct net_device *dev,
  1288. struct iw_request_info *info,
  1289. struct iw_point *erq, char *keybuf);
  1290. /*
  1291. * callbacks for asynchronous cfg80211 methods, notification
  1292. * functions and BSS handling helpers
  1293. */
  1294. /**
  1295. * cfg80211_scan_done - notify that scan finished
  1296. *
  1297. * @request: the corresponding scan request
  1298. * @aborted: set to true if the scan was aborted for any reason,
  1299. * userspace will be notified of that
  1300. */
  1301. void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted);
  1302. /**
  1303. * cfg80211_inform_bss - inform cfg80211 of a new BSS
  1304. *
  1305. * @wiphy: the wiphy reporting the BSS
  1306. * @bss: the found BSS
  1307. * @signal: the signal strength, type depends on the wiphy's signal_type
  1308. * @gfp: context flags
  1309. *
  1310. * This informs cfg80211 that BSS information was found and
  1311. * the BSS should be updated/added.
  1312. */
  1313. struct cfg80211_bss*
  1314. cfg80211_inform_bss_frame(struct wiphy *wiphy,
  1315. struct ieee80211_channel *channel,
  1316. struct ieee80211_mgmt *mgmt, size_t len,
  1317. s32 signal, gfp_t gfp);
  1318. struct cfg80211_bss*
  1319. cfg80211_inform_bss(struct wiphy *wiphy,
  1320. struct ieee80211_channel *channel,
  1321. const u8 *bssid,
  1322. u64 timestamp, u16 capability, u16 beacon_interval,
  1323. const u8 *ie, size_t ielen,
  1324. s32 signal, gfp_t gfp);
  1325. struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
  1326. struct ieee80211_channel *channel,
  1327. const u8 *bssid,
  1328. const u8 *ssid, size_t ssid_len,
  1329. u16 capa_mask, u16 capa_val);
  1330. static inline struct cfg80211_bss *
  1331. cfg80211_get_ibss(struct wiphy *wiphy,
  1332. struct ieee80211_channel *channel,
  1333. const u8 *ssid, size_t ssid_len)
  1334. {
  1335. return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
  1336. WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
  1337. }
  1338. struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy,
  1339. struct ieee80211_channel *channel,
  1340. const u8 *meshid, size_t meshidlen,
  1341. const u8 *meshcfg);
  1342. void cfg80211_put_bss(struct cfg80211_bss *bss);
  1343. /**
  1344. * cfg80211_unlink_bss - unlink BSS from internal data structures
  1345. * @wiphy: the wiphy
  1346. * @bss: the bss to remove
  1347. *
  1348. * This function removes the given BSS from the internal data structures
  1349. * thereby making it no longer show up in scan results etc. Use this
  1350. * function when you detect a BSS is gone. Normally BSSes will also time
  1351. * out, so it is not necessary to use this function at all.
  1352. */
  1353. void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  1354. /**
  1355. * cfg80211_send_rx_auth - notification of processed authentication
  1356. * @dev: network device
  1357. * @buf: authentication frame (header + body)
  1358. * @len: length of the frame data
  1359. *
  1360. * This function is called whenever an authentication has been processed in
  1361. * station mode. The driver is required to call either this function or
  1362. * cfg80211_send_auth_timeout() to indicate the result of cfg80211_ops::auth()
  1363. * call.
  1364. */
  1365. void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len);
  1366. /**
  1367. * cfg80211_send_auth_timeout - notification of timed out authentication
  1368. * @dev: network device
  1369. * @addr: The MAC address of the device with which the authentication timed out
  1370. */
  1371. void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr);
  1372. /**
  1373. * cfg80211_send_rx_assoc - notification of processed association
  1374. * @dev: network device
  1375. * @buf: (re)association response frame (header + body)
  1376. * @len: length of the frame data
  1377. *
  1378. * This function is called whenever a (re)association response has been
  1379. * processed in station mode. The driver is required to call either this
  1380. * function or cfg80211_send_assoc_timeout() to indicate the result of
  1381. * cfg80211_ops::assoc() call.
  1382. */
  1383. void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len);
  1384. /**
  1385. * cfg80211_send_assoc_timeout - notification of timed out association
  1386. * @dev: network device
  1387. * @addr: The MAC address of the device with which the association timed out
  1388. */
  1389. void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr);
  1390. /**
  1391. * cfg80211_send_deauth - notification of processed deauthentication
  1392. * @dev: network device
  1393. * @buf: deauthentication frame (header + body)
  1394. * @len: length of the frame data
  1395. *
  1396. * This function is called whenever deauthentication has been processed in
  1397. * station mode. This includes both received deauthentication frames and
  1398. * locally generated ones.
  1399. */
  1400. void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len);
  1401. /**
  1402. * cfg80211_send_disassoc - notification of processed disassociation
  1403. * @dev: network device
  1404. * @buf: disassociation response frame (header + body)
  1405. * @len: length of the frame data
  1406. *
  1407. * This function is called whenever disassociation has been processed in
  1408. * station mode. This includes both received disassociation frames and locally
  1409. * generated ones.
  1410. */
  1411. void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len);
  1412. /**
  1413. * cfg80211_hold_bss - exclude bss from expiration
  1414. * @bss: bss which should not expire
  1415. *
  1416. * In a case when the BSS is not updated but it shouldn't expire this
  1417. * function can be used to mark the BSS to be excluded from expiration.
  1418. */
  1419. void cfg80211_hold_bss(struct cfg80211_bss *bss);
  1420. /**
  1421. * cfg80211_unhold_bss - remove expiration exception from the BSS
  1422. * @bss: bss which can expire again
  1423. *
  1424. * This function marks the BSS to be expirable again.
  1425. */
  1426. void cfg80211_unhold_bss(struct cfg80211_bss *bss);
  1427. /**
  1428. * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
  1429. * @dev: network device
  1430. * @addr: The source MAC address of the frame
  1431. * @key_type: The key type that the received frame used
  1432. * @key_id: Key identifier (0..3)
  1433. * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
  1434. *
  1435. * This function is called whenever the local MAC detects a MIC failure in a
  1436. * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
  1437. * primitive.
  1438. */
  1439. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  1440. enum nl80211_key_type key_type, int key_id,
  1441. const u8 *tsc);
  1442. /**
  1443. * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
  1444. *
  1445. * @dev: network device
  1446. * @bssid: the BSSID of the IBSS joined
  1447. * @gfp: allocation flags
  1448. *
  1449. * This function notifies cfg80211 that the device joined an IBSS or
  1450. * switched to a different BSSID. Before this function can be called,
  1451. * either a beacon has to have been received from the IBSS, or one of
  1452. * the cfg80211_inform_bss{,_frame} functions must have been called
  1453. * with the locally generated beacon -- this guarantees that there is
  1454. * always a scan result for this IBSS. cfg80211 will handle the rest.
  1455. */
  1456. void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
  1457. #endif /* __NET_CFG80211_H */