cfg80211.h 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015
  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_HT40PLUS: extension channel above this channel
  53. * is not permitted.
  54. * @IEEE80211_CHAN_NO_HT40MINUS: 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_HT40PLUS = 1<<4,
  63. IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
  64. };
  65. #define IEEE80211_CHAN_NO_HT40 \
  66. (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
  67. /**
  68. * struct ieee80211_channel - channel definition
  69. *
  70. * This structure describes a single channel for use
  71. * with cfg80211.
  72. *
  73. * @center_freq: center frequency in MHz
  74. * @hw_value: hardware-specific value for the channel
  75. * @flags: channel flags from &enum ieee80211_channel_flags.
  76. * @orig_flags: channel flags at registration time, used by regulatory
  77. * code to support devices with additional restrictions
  78. * @band: band this channel belongs to.
  79. * @max_antenna_gain: maximum antenna gain in dBi
  80. * @max_power: maximum transmission power (in dBm)
  81. * @beacon_found: helper to regulatory code to indicate when a beacon
  82. * has been found on this channel. Use regulatory_hint_found_beacon()
  83. * to enable this, this is is useful only on 5 GHz band.
  84. * @orig_mag: internal use
  85. * @orig_mpwr: internal use
  86. */
  87. struct ieee80211_channel {
  88. enum ieee80211_band band;
  89. u16 center_freq;
  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. * @generation: generation number for nl80211 dumps.
  351. * This number should increase every time the list of stations
  352. * changes, i.e. when a station is added or removed, so that
  353. * userspace can tell whether it got a consistent snapshot.
  354. */
  355. struct station_info {
  356. u32 filled;
  357. u32 inactive_time;
  358. u32 rx_bytes;
  359. u32 tx_bytes;
  360. u16 llid;
  361. u16 plid;
  362. u8 plink_state;
  363. s8 signal;
  364. struct rate_info txrate;
  365. u32 rx_packets;
  366. u32 tx_packets;
  367. int generation;
  368. };
  369. /**
  370. * enum monitor_flags - monitor flags
  371. *
  372. * Monitor interface configuration flags. Note that these must be the bits
  373. * according to the nl80211 flags.
  374. *
  375. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  376. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  377. * @MONITOR_FLAG_CONTROL: pass control frames
  378. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  379. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  380. */
  381. enum monitor_flags {
  382. MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
  383. MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
  384. MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
  385. MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
  386. MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
  387. };
  388. /**
  389. * enum mpath_info_flags - mesh path information flags
  390. *
  391. * Used by the driver to indicate which info in &struct mpath_info it has filled
  392. * in during get_station() or dump_station().
  393. *
  394. * MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  395. * MPATH_INFO_DSN: @dsn filled
  396. * MPATH_INFO_METRIC: @metric filled
  397. * MPATH_INFO_EXPTIME: @exptime filled
  398. * MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  399. * MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  400. * MPATH_INFO_FLAGS: @flags filled
  401. */
  402. enum mpath_info_flags {
  403. MPATH_INFO_FRAME_QLEN = BIT(0),
  404. MPATH_INFO_DSN = BIT(1),
  405. MPATH_INFO_METRIC = BIT(2),
  406. MPATH_INFO_EXPTIME = BIT(3),
  407. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  408. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  409. MPATH_INFO_FLAGS = BIT(6),
  410. };
  411. /**
  412. * struct mpath_info - mesh path information
  413. *
  414. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  415. *
  416. * @filled: bitfield of flags from &enum mpath_info_flags
  417. * @frame_qlen: number of queued frames for this destination
  418. * @dsn: destination sequence number
  419. * @metric: metric (cost) of this mesh path
  420. * @exptime: expiration time for the mesh path from now, in msecs
  421. * @flags: mesh path flags
  422. * @discovery_timeout: total mesh path discovery timeout, in msecs
  423. * @discovery_retries: mesh path discovery retries
  424. * @generation: generation number for nl80211 dumps.
  425. * This number should increase every time the list of mesh paths
  426. * changes, i.e. when a station is added or removed, so that
  427. * userspace can tell whether it got a consistent snapshot.
  428. */
  429. struct mpath_info {
  430. u32 filled;
  431. u32 frame_qlen;
  432. u32 dsn;
  433. u32 metric;
  434. u32 exptime;
  435. u32 discovery_timeout;
  436. u8 discovery_retries;
  437. u8 flags;
  438. int generation;
  439. };
  440. /**
  441. * struct bss_parameters - BSS parameters
  442. *
  443. * Used to change BSS parameters (mainly for AP mode).
  444. *
  445. * @use_cts_prot: Whether to use CTS protection
  446. * (0 = no, 1 = yes, -1 = do not change)
  447. * @use_short_preamble: Whether the use of short preambles is allowed
  448. * (0 = no, 1 = yes, -1 = do not change)
  449. * @use_short_slot_time: Whether the use of short slot time is allowed
  450. * (0 = no, 1 = yes, -1 = do not change)
  451. * @basic_rates: basic rates in IEEE 802.11 format
  452. * (or NULL for no change)
  453. * @basic_rates_len: number of basic rates
  454. */
  455. struct bss_parameters {
  456. int use_cts_prot;
  457. int use_short_preamble;
  458. int use_short_slot_time;
  459. u8 *basic_rates;
  460. u8 basic_rates_len;
  461. };
  462. struct mesh_config {
  463. /* Timeouts in ms */
  464. /* Mesh plink management parameters */
  465. u16 dot11MeshRetryTimeout;
  466. u16 dot11MeshConfirmTimeout;
  467. u16 dot11MeshHoldingTimeout;
  468. u16 dot11MeshMaxPeerLinks;
  469. u8 dot11MeshMaxRetries;
  470. u8 dot11MeshTTL;
  471. bool auto_open_plinks;
  472. /* HWMP parameters */
  473. u8 dot11MeshHWMPmaxPREQretries;
  474. u32 path_refresh_time;
  475. u16 min_discovery_timeout;
  476. u32 dot11MeshHWMPactivePathTimeout;
  477. u16 dot11MeshHWMPpreqMinInterval;
  478. u16 dot11MeshHWMPnetDiameterTraversalTime;
  479. };
  480. /**
  481. * struct ieee80211_txq_params - TX queue parameters
  482. * @queue: TX queue identifier (NL80211_TXQ_Q_*)
  483. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  484. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  485. * 1..32767]
  486. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  487. * 1..32767]
  488. * @aifs: Arbitration interframe space [0..255]
  489. */
  490. struct ieee80211_txq_params {
  491. enum nl80211_txq_q queue;
  492. u16 txop;
  493. u16 cwmin;
  494. u16 cwmax;
  495. u8 aifs;
  496. };
  497. /* from net/wireless.h */
  498. struct wiphy;
  499. /* from net/ieee80211.h */
  500. struct ieee80211_channel;
  501. /**
  502. * struct cfg80211_ssid - SSID description
  503. * @ssid: the SSID
  504. * @ssid_len: length of the ssid
  505. */
  506. struct cfg80211_ssid {
  507. u8 ssid[IEEE80211_MAX_SSID_LEN];
  508. u8 ssid_len;
  509. };
  510. /**
  511. * struct cfg80211_scan_request - scan request description
  512. *
  513. * @ssids: SSIDs to scan for (active scan only)
  514. * @n_ssids: number of SSIDs
  515. * @channels: channels to scan on.
  516. * @n_channels: total number of channels to scan
  517. * @ie: optional information element(s) to add into Probe Request or %NULL
  518. * @ie_len: length of ie in octets
  519. * @wiphy: the wiphy this was for
  520. * @dev: the interface
  521. */
  522. struct cfg80211_scan_request {
  523. struct cfg80211_ssid *ssids;
  524. int n_ssids;
  525. u32 n_channels;
  526. const u8 *ie;
  527. size_t ie_len;
  528. /* internal */
  529. struct wiphy *wiphy;
  530. struct net_device *dev;
  531. bool aborted;
  532. /* keep last */
  533. struct ieee80211_channel *channels[0];
  534. };
  535. /**
  536. * enum cfg80211_signal_type - signal type
  537. *
  538. * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
  539. * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
  540. * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
  541. */
  542. enum cfg80211_signal_type {
  543. CFG80211_SIGNAL_TYPE_NONE,
  544. CFG80211_SIGNAL_TYPE_MBM,
  545. CFG80211_SIGNAL_TYPE_UNSPEC,
  546. };
  547. /**
  548. * struct cfg80211_bss - BSS description
  549. *
  550. * This structure describes a BSS (which may also be a mesh network)
  551. * for use in scan results and similar.
  552. *
  553. * @bssid: BSSID of the BSS
  554. * @tsf: timestamp of last received update
  555. * @beacon_interval: the beacon interval as from the frame
  556. * @capability: the capability field in host byte order
  557. * @information_elements: the information elements (Note that there
  558. * is no guarantee that these are well-formed!)
  559. * @len_information_elements: total length of the information elements
  560. * @signal: signal strength value (type depends on the wiphy's signal_type)
  561. * @free_priv: function pointer to free private data
  562. * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  563. */
  564. struct cfg80211_bss {
  565. struct ieee80211_channel *channel;
  566. u8 bssid[ETH_ALEN];
  567. u64 tsf;
  568. u16 beacon_interval;
  569. u16 capability;
  570. u8 *information_elements;
  571. size_t len_information_elements;
  572. s32 signal;
  573. void (*free_priv)(struct cfg80211_bss *bss);
  574. u8 priv[0] __attribute__((__aligned__(sizeof(void *))));
  575. };
  576. /**
  577. * ieee80211_bss_get_ie - find IE with given ID
  578. * @bss: the bss to search
  579. * @ie: the IE ID
  580. * Returns %NULL if not found.
  581. */
  582. const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
  583. /**
  584. * struct cfg80211_crypto_settings - Crypto settings
  585. * @wpa_versions: indicates which, if any, WPA versions are enabled
  586. * (from enum nl80211_wpa_versions)
  587. * @cipher_group: group key cipher suite (or 0 if unset)
  588. * @n_ciphers_pairwise: number of AP supported unicast ciphers
  589. * @ciphers_pairwise: unicast key cipher suites
  590. * @n_akm_suites: number of AKM suites
  591. * @akm_suites: AKM suites
  592. * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
  593. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  594. * required to assume that the port is unauthorized until authorized by
  595. * user space. Otherwise, port is marked authorized by default.
  596. */
  597. struct cfg80211_crypto_settings {
  598. u32 wpa_versions;
  599. u32 cipher_group;
  600. int n_ciphers_pairwise;
  601. u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
  602. int n_akm_suites;
  603. u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
  604. bool control_port;
  605. };
  606. /**
  607. * struct cfg80211_auth_request - Authentication request data
  608. *
  609. * This structure provides information needed to complete IEEE 802.11
  610. * authentication.
  611. *
  612. * @bss: The BSS to authenticate with.
  613. * @auth_type: Authentication type (algorithm)
  614. * @ie: Extra IEs to add to Authentication frame or %NULL
  615. * @ie_len: Length of ie buffer in octets
  616. * @key_len: length of WEP key for shared key authentication
  617. * @key_idx: index of WEP key for shared key authentication
  618. * @key: WEP key for shared key authentication
  619. */
  620. struct cfg80211_auth_request {
  621. struct cfg80211_bss *bss;
  622. const u8 *ie;
  623. size_t ie_len;
  624. enum nl80211_auth_type auth_type;
  625. const u8 *key;
  626. u8 key_len, key_idx;
  627. };
  628. /**
  629. * struct cfg80211_assoc_request - (Re)Association request data
  630. *
  631. * This structure provides information needed to complete IEEE 802.11
  632. * (re)association.
  633. * @bss: The BSS to associate with.
  634. * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
  635. * @ie_len: Length of ie buffer in octets
  636. * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
  637. * @crypto: crypto settings
  638. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame
  639. */
  640. struct cfg80211_assoc_request {
  641. struct cfg80211_bss *bss;
  642. const u8 *ie, *prev_bssid;
  643. size_t ie_len;
  644. struct cfg80211_crypto_settings crypto;
  645. bool use_mfp;
  646. };
  647. /**
  648. * struct cfg80211_deauth_request - Deauthentication request data
  649. *
  650. * This structure provides information needed to complete IEEE 802.11
  651. * deauthentication.
  652. *
  653. * @bss: the BSS to deauthenticate from
  654. * @ie: Extra IEs to add to Deauthentication frame or %NULL
  655. * @ie_len: Length of ie buffer in octets
  656. * @reason_code: The reason code for the deauthentication
  657. */
  658. struct cfg80211_deauth_request {
  659. struct cfg80211_bss *bss;
  660. const u8 *ie;
  661. size_t ie_len;
  662. u16 reason_code;
  663. };
  664. /**
  665. * struct cfg80211_disassoc_request - Disassociation request data
  666. *
  667. * This structure provides information needed to complete IEEE 802.11
  668. * disassocation.
  669. *
  670. * @bss: the BSS to disassociate from
  671. * @ie: Extra IEs to add to Disassociation frame or %NULL
  672. * @ie_len: Length of ie buffer in octets
  673. * @reason_code: The reason code for the disassociation
  674. */
  675. struct cfg80211_disassoc_request {
  676. struct cfg80211_bss *bss;
  677. const u8 *ie;
  678. size_t ie_len;
  679. u16 reason_code;
  680. };
  681. /**
  682. * struct cfg80211_ibss_params - IBSS parameters
  683. *
  684. * This structure defines the IBSS parameters for the join_ibss()
  685. * method.
  686. *
  687. * @ssid: The SSID, will always be non-null.
  688. * @ssid_len: The length of the SSID, will always be non-zero.
  689. * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
  690. * search for IBSSs with a different BSSID.
  691. * @channel: The channel to use if no IBSS can be found to join.
  692. * @channel_fixed: The channel should be fixed -- do not search for
  693. * IBSSs to join on other channels.
  694. * @ie: information element(s) to include in the beacon
  695. * @ie_len: length of that
  696. * @beacon_interval: beacon interval to use
  697. * @privacy: this is a protected network, keys will be configured
  698. * after joining
  699. */
  700. struct cfg80211_ibss_params {
  701. u8 *ssid;
  702. u8 *bssid;
  703. struct ieee80211_channel *channel;
  704. u8 *ie;
  705. u8 ssid_len, ie_len;
  706. u16 beacon_interval;
  707. bool channel_fixed;
  708. bool privacy;
  709. };
  710. /**
  711. * struct cfg80211_connect_params - Connection parameters
  712. *
  713. * This structure provides information needed to complete IEEE 802.11
  714. * authentication and association.
  715. *
  716. * @channel: The channel to use or %NULL if not specified (auto-select based
  717. * on scan results)
  718. * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
  719. * results)
  720. * @ssid: SSID
  721. * @ssid_len: Length of ssid in octets
  722. * @auth_type: Authentication type (algorithm)
  723. * @assoc_ie: IEs for association request
  724. * @assoc_ie_len: Length of assoc_ie in octets
  725. * @privacy: indicates whether privacy-enabled APs should be used
  726. * @crypto: crypto settings
  727. * @key_len: length of WEP key for shared key authentication
  728. * @key_idx: index of WEP key for shared key authentication
  729. * @key: WEP key for shared key authentication
  730. */
  731. struct cfg80211_connect_params {
  732. struct ieee80211_channel *channel;
  733. u8 *bssid;
  734. u8 *ssid;
  735. size_t ssid_len;
  736. enum nl80211_auth_type auth_type;
  737. u8 *ie;
  738. size_t ie_len;
  739. bool privacy;
  740. struct cfg80211_crypto_settings crypto;
  741. const u8 *key;
  742. u8 key_len, key_idx;
  743. };
  744. /**
  745. * enum wiphy_params_flags - set_wiphy_params bitfield values
  746. * WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
  747. * WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  748. * WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  749. * WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  750. */
  751. enum wiphy_params_flags {
  752. WIPHY_PARAM_RETRY_SHORT = 1 << 0,
  753. WIPHY_PARAM_RETRY_LONG = 1 << 1,
  754. WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
  755. WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
  756. };
  757. /**
  758. * enum tx_power_setting - TX power adjustment
  759. *
  760. * @TX_POWER_AUTOMATIC: the dbm parameter is ignored
  761. * @TX_POWER_LIMITED: limit TX power by the dbm parameter
  762. * @TX_POWER_FIXED: fix TX power to the dbm parameter
  763. */
  764. enum tx_power_setting {
  765. TX_POWER_AUTOMATIC,
  766. TX_POWER_LIMITED,
  767. TX_POWER_FIXED,
  768. };
  769. /*
  770. * cfg80211_bitrate_mask - masks for bitrate control
  771. */
  772. struct cfg80211_bitrate_mask {
  773. /*
  774. * As discussed in Berlin, this struct really
  775. * should look like this:
  776. struct {
  777. u32 legacy;
  778. u8 mcs[IEEE80211_HT_MCS_MASK_LEN];
  779. } control[IEEE80211_NUM_BANDS];
  780. * Since we can always fix in-kernel users, let's keep
  781. * it simpler for now:
  782. */
  783. u32 fixed; /* fixed bitrate, 0 == not fixed */
  784. u32 maxrate; /* in kbps, 0 == no limit */
  785. };
  786. /**
  787. * struct cfg80211_ops - backend description for wireless configuration
  788. *
  789. * This struct is registered by fullmac card drivers and/or wireless stacks
  790. * in order to handle configuration requests on their interfaces.
  791. *
  792. * All callbacks except where otherwise noted should return 0
  793. * on success or a negative error code.
  794. *
  795. * All operations are currently invoked under rtnl for consistency with the
  796. * wireless extensions but this is subject to reevaluation as soon as this
  797. * code is used more widely and we have a first user without wext.
  798. *
  799. * @suspend: wiphy device needs to be suspended
  800. * @resume: wiphy device needs to be resumed
  801. *
  802. * @add_virtual_intf: create a new virtual interface with the given name,
  803. * must set the struct wireless_dev's iftype. Beware: You must create
  804. * the new netdev in the wiphy's network namespace!
  805. *
  806. * @del_virtual_intf: remove the virtual interface determined by ifindex.
  807. *
  808. * @change_virtual_intf: change type/configuration of virtual interface,
  809. * keep the struct wireless_dev's iftype updated.
  810. *
  811. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  812. * when adding a group key.
  813. *
  814. * @get_key: get information about the key with the given parameters.
  815. * @mac_addr will be %NULL when requesting information for a group
  816. * key. All pointers given to the @callback function need not be valid
  817. * after it returns. This function should return an error if it is
  818. * not possible to retrieve the key, -ENOENT if it doesn't exist.
  819. *
  820. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  821. * and @key_index, return -ENOENT if the key doesn't exist.
  822. *
  823. * @set_default_key: set the default key on an interface
  824. *
  825. * @set_default_mgmt_key: set the default management frame key on an interface
  826. *
  827. * @add_beacon: Add a beacon with given parameters, @head, @interval
  828. * and @dtim_period will be valid, @tail is optional.
  829. * @set_beacon: Change the beacon parameters for an access point mode
  830. * interface. This should reject the call when no beacon has been
  831. * configured.
  832. * @del_beacon: Remove beacon configuration and stop sending the beacon.
  833. *
  834. * @add_station: Add a new station.
  835. *
  836. * @del_station: Remove a station; @mac may be NULL to remove all stations.
  837. *
  838. * @change_station: Modify a given station.
  839. *
  840. * @get_mesh_params: Put the current mesh parameters into *params
  841. *
  842. * @set_mesh_params: Set mesh parameters.
  843. * The mask is a bitfield which tells us which parameters to
  844. * set, and which to leave alone.
  845. *
  846. * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
  847. *
  848. * @change_bss: Modify parameters for a given BSS.
  849. *
  850. * @set_txq_params: Set TX queue parameters
  851. *
  852. * @set_channel: Set channel
  853. *
  854. * @scan: Request to do a scan. If returning zero, the scan request is given
  855. * the driver, and will be valid until passed to cfg80211_scan_done().
  856. * For scan results, call cfg80211_inform_bss(); you can call this outside
  857. * the scan/scan_done bracket too.
  858. *
  859. * @auth: Request to authenticate with the specified peer
  860. * @assoc: Request to (re)associate with the specified peer
  861. * @deauth: Request to deauthenticate from the specified peer
  862. * @disassoc: Request to disassociate from the specified peer
  863. *
  864. * @connect: Connect to the ESS with the specified parameters. When connected,
  865. * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
  866. * If the connection fails for some reason, call cfg80211_connect_result()
  867. * with the status from the AP.
  868. * @disconnect: Disconnect from the BSS/ESS.
  869. *
  870. * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
  871. * cfg80211_ibss_joined(), also call that function when changing BSSID due
  872. * to a merge.
  873. * @leave_ibss: Leave the IBSS.
  874. *
  875. * @set_wiphy_params: Notify that wiphy parameters have changed;
  876. * @changed bitfield (see &enum wiphy_params_flags) describes which values
  877. * have changed. The actual parameter values are available in
  878. * struct wiphy. If returning an error, no value should be changed.
  879. *
  880. * @set_tx_power: set the transmit power according to the parameters
  881. * @get_tx_power: store the current TX power into the dbm variable;
  882. * return 0 if successful
  883. *
  884. * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  885. * functions to adjust rfkill hw state
  886. *
  887. * @testmode_cmd: run a test mode command
  888. */
  889. struct cfg80211_ops {
  890. int (*suspend)(struct wiphy *wiphy);
  891. int (*resume)(struct wiphy *wiphy);
  892. int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
  893. enum nl80211_iftype type, u32 *flags,
  894. struct vif_params *params);
  895. int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev);
  896. int (*change_virtual_intf)(struct wiphy *wiphy,
  897. struct net_device *dev,
  898. enum nl80211_iftype type, u32 *flags,
  899. struct vif_params *params);
  900. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  901. u8 key_index, const u8 *mac_addr,
  902. struct key_params *params);
  903. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  904. u8 key_index, const u8 *mac_addr, void *cookie,
  905. void (*callback)(void *cookie, struct key_params*));
  906. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  907. u8 key_index, const u8 *mac_addr);
  908. int (*set_default_key)(struct wiphy *wiphy,
  909. struct net_device *netdev,
  910. u8 key_index);
  911. int (*set_default_mgmt_key)(struct wiphy *wiphy,
  912. struct net_device *netdev,
  913. u8 key_index);
  914. int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
  915. struct beacon_parameters *info);
  916. int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
  917. struct beacon_parameters *info);
  918. int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
  919. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  920. u8 *mac, struct station_parameters *params);
  921. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  922. u8 *mac);
  923. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  924. u8 *mac, struct station_parameters *params);
  925. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  926. u8 *mac, struct station_info *sinfo);
  927. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  928. int idx, u8 *mac, struct station_info *sinfo);
  929. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  930. u8 *dst, u8 *next_hop);
  931. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  932. u8 *dst);
  933. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  934. u8 *dst, u8 *next_hop);
  935. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  936. u8 *dst, u8 *next_hop,
  937. struct mpath_info *pinfo);
  938. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  939. int idx, u8 *dst, u8 *next_hop,
  940. struct mpath_info *pinfo);
  941. int (*get_mesh_params)(struct wiphy *wiphy,
  942. struct net_device *dev,
  943. struct mesh_config *conf);
  944. int (*set_mesh_params)(struct wiphy *wiphy,
  945. struct net_device *dev,
  946. const struct mesh_config *nconf, u32 mask);
  947. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  948. struct bss_parameters *params);
  949. int (*set_txq_params)(struct wiphy *wiphy,
  950. struct ieee80211_txq_params *params);
  951. int (*set_channel)(struct wiphy *wiphy,
  952. struct ieee80211_channel *chan,
  953. enum nl80211_channel_type channel_type);
  954. int (*scan)(struct wiphy *wiphy, struct net_device *dev,
  955. struct cfg80211_scan_request *request);
  956. int (*auth)(struct wiphy *wiphy, struct net_device *dev,
  957. struct cfg80211_auth_request *req);
  958. int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
  959. struct cfg80211_assoc_request *req);
  960. int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
  961. struct cfg80211_deauth_request *req,
  962. void *cookie);
  963. int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
  964. struct cfg80211_disassoc_request *req,
  965. void *cookie);
  966. int (*connect)(struct wiphy *wiphy, struct net_device *dev,
  967. struct cfg80211_connect_params *sme);
  968. int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
  969. u16 reason_code);
  970. int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
  971. struct cfg80211_ibss_params *params);
  972. int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
  973. int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
  974. int (*set_tx_power)(struct wiphy *wiphy,
  975. enum tx_power_setting type, int dbm);
  976. int (*get_tx_power)(struct wiphy *wiphy, int *dbm);
  977. int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
  978. u8 *addr);
  979. void (*rfkill_poll)(struct wiphy *wiphy);
  980. #ifdef CONFIG_NL80211_TESTMODE
  981. int (*testmode_cmd)(struct wiphy *wiphy, void *data, int len);
  982. #endif
  983. int (*set_bitrate_mask)(struct wiphy *wiphy,
  984. struct net_device *dev,
  985. const u8 *peer,
  986. const struct cfg80211_bitrate_mask *mask);
  987. /* some temporary stuff to finish wext */
  988. int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  989. bool enabled, int timeout);
  990. };
  991. /*
  992. * wireless hardware and networking interfaces structures
  993. * and registration/helper functions
  994. */
  995. /**
  996. * struct wiphy - wireless hardware description
  997. * @idx: the wiphy index assigned to this item
  998. * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
  999. * @custom_regulatory: tells us the driver for this device
  1000. * has its own custom regulatory domain and cannot identify the
  1001. * ISO / IEC 3166 alpha2 it belongs to. When this is enabled
  1002. * we will disregard the first regulatory hint (when the
  1003. * initiator is %REGDOM_SET_BY_CORE).
  1004. * @strict_regulatory: tells us the driver for this device will ignore
  1005. * regulatory domain settings until it gets its own regulatory domain
  1006. * via its regulatory_hint(). After its gets its own regulatory domain
  1007. * it will only allow further regulatory domain settings to further
  1008. * enhance compliance. For example if channel 13 and 14 are disabled
  1009. * by this regulatory domain no user regulatory domain can enable these
  1010. * channels at a later time. This can be used for devices which do not
  1011. * have calibration information gauranteed for frequencies or settings
  1012. * outside of its regulatory domain.
  1013. * @disable_beacon_hints: enable this if your driver needs to ensure that
  1014. * passive scan flags and beaconing flags may not be lifted by cfg80211
  1015. * due to regulatory beacon hints. For more information on beacon
  1016. * hints read the documenation for regulatory_hint_found_beacon()
  1017. * @reg_notifier: the driver's regulatory notification callback
  1018. * @regd: the driver's regulatory domain, if one was requested via
  1019. * the regulatory_hint() API. This can be used by the driver
  1020. * on the reg_notifier() if it chooses to ignore future
  1021. * regulatory domain changes caused by other drivers.
  1022. * @signal_type: signal type reported in &struct cfg80211_bss.
  1023. * @cipher_suites: supported cipher suites
  1024. * @n_cipher_suites: number of supported cipher suites
  1025. * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
  1026. * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
  1027. * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  1028. * -1 = fragmentation disabled, only odd values >= 256 used
  1029. * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
  1030. * @net: the network namespace this wiphy currently lives in
  1031. * @netnsok: if set to false, do not allow changing the netns of this
  1032. * wiphy at all
  1033. * @ps_default: default for powersave, will be set depending on the
  1034. * kernel's default on wiphy_new(), but can be changed by the
  1035. * driver if it has a good reason to override the default
  1036. */
  1037. struct wiphy {
  1038. /* assign these fields before you register the wiphy */
  1039. /* permanent MAC address */
  1040. u8 perm_addr[ETH_ALEN];
  1041. /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  1042. u16 interface_modes;
  1043. bool custom_regulatory;
  1044. bool strict_regulatory;
  1045. bool disable_beacon_hints;
  1046. bool netnsok;
  1047. bool ps_default;
  1048. enum cfg80211_signal_type signal_type;
  1049. int bss_priv_size;
  1050. u8 max_scan_ssids;
  1051. u16 max_scan_ie_len;
  1052. int n_cipher_suites;
  1053. const u32 *cipher_suites;
  1054. u8 retry_short;
  1055. u8 retry_long;
  1056. u32 frag_threshold;
  1057. u32 rts_threshold;
  1058. /* If multiple wiphys are registered and you're handed e.g.
  1059. * a regular netdev with assigned ieee80211_ptr, you won't
  1060. * know whether it points to a wiphy your driver has registered
  1061. * or not. Assign this to something global to your driver to
  1062. * help determine whether you own this wiphy or not. */
  1063. const void *privid;
  1064. struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
  1065. /* Lets us get back the wiphy on the callback */
  1066. int (*reg_notifier)(struct wiphy *wiphy,
  1067. struct regulatory_request *request);
  1068. /* fields below are read-only, assigned by cfg80211 */
  1069. const struct ieee80211_regdomain *regd;
  1070. /* the item in /sys/class/ieee80211/ points to this,
  1071. * you need use set_wiphy_dev() (see below) */
  1072. struct device dev;
  1073. /* dir in debugfs: ieee80211/<wiphyname> */
  1074. struct dentry *debugfsdir;
  1075. #ifdef CONFIG_NET_NS
  1076. /* the network namespace this phy lives in currently */
  1077. struct net *_net;
  1078. #endif
  1079. char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
  1080. };
  1081. #ifdef CONFIG_NET_NS
  1082. static inline struct net *wiphy_net(struct wiphy *wiphy)
  1083. {
  1084. return wiphy->_net;
  1085. }
  1086. static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
  1087. {
  1088. wiphy->_net = net;
  1089. }
  1090. #else
  1091. static inline struct net *wiphy_net(struct wiphy *wiphy)
  1092. {
  1093. return &init_net;
  1094. }
  1095. static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
  1096. {
  1097. }
  1098. #endif
  1099. /**
  1100. * wiphy_priv - return priv from wiphy
  1101. *
  1102. * @wiphy: the wiphy whose priv pointer to return
  1103. */
  1104. static inline void *wiphy_priv(struct wiphy *wiphy)
  1105. {
  1106. BUG_ON(!wiphy);
  1107. return &wiphy->priv;
  1108. }
  1109. /**
  1110. * priv_to_wiphy - return the wiphy containing the priv
  1111. *
  1112. * @priv: a pointer previously returned by wiphy_priv
  1113. */
  1114. static inline struct wiphy *priv_to_wiphy(void *priv)
  1115. {
  1116. BUG_ON(!priv);
  1117. return container_of(priv, struct wiphy, priv);
  1118. }
  1119. /**
  1120. * set_wiphy_dev - set device pointer for wiphy
  1121. *
  1122. * @wiphy: The wiphy whose device to bind
  1123. * @dev: The device to parent it to
  1124. */
  1125. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  1126. {
  1127. wiphy->dev.parent = dev;
  1128. }
  1129. /**
  1130. * wiphy_dev - get wiphy dev pointer
  1131. *
  1132. * @wiphy: The wiphy whose device struct to look up
  1133. */
  1134. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  1135. {
  1136. return wiphy->dev.parent;
  1137. }
  1138. /**
  1139. * wiphy_name - get wiphy name
  1140. *
  1141. * @wiphy: The wiphy whose name to return
  1142. */
  1143. static inline const char *wiphy_name(struct wiphy *wiphy)
  1144. {
  1145. return dev_name(&wiphy->dev);
  1146. }
  1147. /**
  1148. * wiphy_new - create a new wiphy for use with cfg80211
  1149. *
  1150. * @ops: The configuration operations for this device
  1151. * @sizeof_priv: The size of the private area to allocate
  1152. *
  1153. * Create a new wiphy and associate the given operations with it.
  1154. * @sizeof_priv bytes are allocated for private use.
  1155. *
  1156. * The returned pointer must be assigned to each netdev's
  1157. * ieee80211_ptr for proper operation.
  1158. */
  1159. struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv);
  1160. /**
  1161. * wiphy_register - register a wiphy with cfg80211
  1162. *
  1163. * @wiphy: The wiphy to register.
  1164. *
  1165. * Returns a non-negative wiphy index or a negative error code.
  1166. */
  1167. extern int wiphy_register(struct wiphy *wiphy);
  1168. /**
  1169. * wiphy_unregister - deregister a wiphy from cfg80211
  1170. *
  1171. * @wiphy: The wiphy to unregister.
  1172. *
  1173. * After this call, no more requests can be made with this priv
  1174. * pointer, but the call may sleep to wait for an outstanding
  1175. * request that is being handled.
  1176. */
  1177. extern void wiphy_unregister(struct wiphy *wiphy);
  1178. /**
  1179. * wiphy_free - free wiphy
  1180. *
  1181. * @wiphy: The wiphy to free
  1182. */
  1183. extern void wiphy_free(struct wiphy *wiphy);
  1184. /* internal structs */
  1185. struct cfg80211_conn;
  1186. struct cfg80211_internal_bss;
  1187. struct cfg80211_cached_keys;
  1188. #define MAX_AUTH_BSSES 4
  1189. /**
  1190. * struct wireless_dev - wireless per-netdev state
  1191. *
  1192. * This structure must be allocated by the driver/stack
  1193. * that uses the ieee80211_ptr field in struct net_device
  1194. * (this is intentional so it can be allocated along with
  1195. * the netdev.)
  1196. *
  1197. * @wiphy: pointer to hardware description
  1198. * @iftype: interface type
  1199. * @list: (private) Used to collect the interfaces
  1200. * @netdev: (private) Used to reference back to the netdev
  1201. * @current_bss: (private) Used by the internal configuration code
  1202. * @bssid: (private) Used by the internal configuration code
  1203. * @ssid: (private) Used by the internal configuration code
  1204. * @ssid_len: (private) Used by the internal configuration code
  1205. * @wext: (private) Used by the internal wireless extensions compat code
  1206. * @wext_bssid: (private) Used by the internal wireless extensions compat code
  1207. */
  1208. struct wireless_dev {
  1209. struct wiphy *wiphy;
  1210. enum nl80211_iftype iftype;
  1211. /* the remainder of this struct should be private to cfg80211 */
  1212. struct list_head list;
  1213. struct net_device *netdev;
  1214. struct mutex mtx;
  1215. struct work_struct cleanup_work;
  1216. /* currently used for IBSS and SME - might be rearranged later */
  1217. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1218. u8 ssid_len;
  1219. enum {
  1220. CFG80211_SME_IDLE,
  1221. CFG80211_SME_CONNECTING,
  1222. CFG80211_SME_CONNECTED,
  1223. } sme_state;
  1224. struct cfg80211_conn *conn;
  1225. struct cfg80211_cached_keys *connect_keys;
  1226. struct list_head event_list;
  1227. spinlock_t event_lock;
  1228. struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES];
  1229. struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES];
  1230. struct cfg80211_internal_bss *current_bss; /* associated / joined */
  1231. #ifdef CONFIG_WIRELESS_EXT
  1232. /* wext data */
  1233. struct {
  1234. struct cfg80211_ibss_params ibss;
  1235. struct cfg80211_connect_params connect;
  1236. struct cfg80211_cached_keys *keys;
  1237. u8 *ie;
  1238. size_t ie_len;
  1239. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  1240. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1241. s8 default_key, default_mgmt_key;
  1242. bool ps, prev_bssid_valid;
  1243. int ps_timeout;
  1244. } wext;
  1245. #endif
  1246. };
  1247. /**
  1248. * wdev_priv - return wiphy priv from wireless_dev
  1249. *
  1250. * @wdev: The wireless device whose wiphy's priv pointer to return
  1251. */
  1252. static inline void *wdev_priv(struct wireless_dev *wdev)
  1253. {
  1254. BUG_ON(!wdev);
  1255. return wiphy_priv(wdev->wiphy);
  1256. }
  1257. /*
  1258. * Utility functions
  1259. */
  1260. /**
  1261. * ieee80211_channel_to_frequency - convert channel number to frequency
  1262. */
  1263. extern int ieee80211_channel_to_frequency(int chan);
  1264. /**
  1265. * ieee80211_frequency_to_channel - convert frequency to channel number
  1266. */
  1267. extern int ieee80211_frequency_to_channel(int freq);
  1268. /*
  1269. * Name indirection necessary because the ieee80211 code also has
  1270. * a function named "ieee80211_get_channel", so if you include
  1271. * cfg80211's header file you get cfg80211's version, if you try
  1272. * to include both header files you'll (rightfully!) get a symbol
  1273. * clash.
  1274. */
  1275. extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
  1276. int freq);
  1277. /**
  1278. * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  1279. */
  1280. static inline struct ieee80211_channel *
  1281. ieee80211_get_channel(struct wiphy *wiphy, int freq)
  1282. {
  1283. return __ieee80211_get_channel(wiphy, freq);
  1284. }
  1285. /**
  1286. * ieee80211_get_response_rate - get basic rate for a given rate
  1287. *
  1288. * @sband: the band to look for rates in
  1289. * @basic_rates: bitmap of basic rates
  1290. * @bitrate: the bitrate for which to find the basic rate
  1291. *
  1292. * This function returns the basic rate corresponding to a given
  1293. * bitrate, that is the next lower bitrate contained in the basic
  1294. * rate map, which is, for this function, given as a bitmap of
  1295. * indices of rates in the band's bitrate table.
  1296. */
  1297. struct ieee80211_rate *
  1298. ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  1299. u32 basic_rates, int bitrate);
  1300. /*
  1301. * Radiotap parsing functions -- for controlled injection support
  1302. *
  1303. * Implemented in net/wireless/radiotap.c
  1304. * Documentation in Documentation/networking/radiotap-headers.txt
  1305. */
  1306. /**
  1307. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  1308. * @rtheader: pointer to the radiotap header we are walking through
  1309. * @max_length: length of radiotap header in cpu byte ordering
  1310. * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
  1311. * @this_arg: pointer to current radiotap arg
  1312. * @arg_index: internal next argument index
  1313. * @arg: internal next argument pointer
  1314. * @next_bitmap: internal pointer to next present u32
  1315. * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  1316. */
  1317. struct ieee80211_radiotap_iterator {
  1318. struct ieee80211_radiotap_header *rtheader;
  1319. int max_length;
  1320. int this_arg_index;
  1321. u8 *this_arg;
  1322. int arg_index;
  1323. u8 *arg;
  1324. __le32 *next_bitmap;
  1325. u32 bitmap_shifter;
  1326. };
  1327. extern int ieee80211_radiotap_iterator_init(
  1328. struct ieee80211_radiotap_iterator *iterator,
  1329. struct ieee80211_radiotap_header *radiotap_header,
  1330. int max_length);
  1331. extern int ieee80211_radiotap_iterator_next(
  1332. struct ieee80211_radiotap_iterator *iterator);
  1333. extern const unsigned char rfc1042_header[6];
  1334. extern const unsigned char bridge_tunnel_header[6];
  1335. /**
  1336. * ieee80211_get_hdrlen_from_skb - get header length from data
  1337. *
  1338. * Given an skb with a raw 802.11 header at the data pointer this function
  1339. * returns the 802.11 header length in bytes (not including encryption
  1340. * headers). If the data in the sk_buff is too short to contain a valid 802.11
  1341. * header the function returns 0.
  1342. *
  1343. * @skb: the frame
  1344. */
  1345. unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  1346. /**
  1347. * ieee80211_hdrlen - get header length in bytes from frame control
  1348. * @fc: frame control field in little-endian format
  1349. */
  1350. unsigned int ieee80211_hdrlen(__le16 fc);
  1351. /**
  1352. * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
  1353. * @skb: the 802.11 data frame
  1354. * @addr: the device MAC address
  1355. * @iftype: the virtual interface type
  1356. */
  1357. int ieee80211_data_to_8023(struct sk_buff *skb, u8 *addr,
  1358. enum nl80211_iftype iftype);
  1359. /**
  1360. * ieee80211_data_from_8023 - convert an 802.3 frame to 802.11
  1361. * @skb: the 802.3 frame
  1362. * @addr: the device MAC address
  1363. * @iftype: the virtual interface type
  1364. * @bssid: the network bssid (used only for iftype STATION and ADHOC)
  1365. * @qos: build 802.11 QoS data frame
  1366. */
  1367. int ieee80211_data_from_8023(struct sk_buff *skb, u8 *addr,
  1368. enum nl80211_iftype iftype, u8 *bssid, bool qos);
  1369. /**
  1370. * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
  1371. * @skb: the data frame
  1372. */
  1373. unsigned int cfg80211_classify8021d(struct sk_buff *skb);
  1374. /*
  1375. * Regulatory helper functions for wiphys
  1376. */
  1377. /**
  1378. * regulatory_hint - driver hint to the wireless core a regulatory domain
  1379. * @wiphy: the wireless device giving the hint (used only for reporting
  1380. * conflicts)
  1381. * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  1382. * should be in. If @rd is set this should be NULL. Note that if you
  1383. * set this to NULL you should still set rd->alpha2 to some accepted
  1384. * alpha2.
  1385. *
  1386. * Wireless drivers can use this function to hint to the wireless core
  1387. * what it believes should be the current regulatory domain by
  1388. * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  1389. * domain should be in or by providing a completely build regulatory domain.
  1390. * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  1391. * for a regulatory domain structure for the respective country.
  1392. *
  1393. * The wiphy must have been registered to cfg80211 prior to this call.
  1394. * For cfg80211 drivers this means you must first use wiphy_register(),
  1395. * for mac80211 drivers you must first use ieee80211_register_hw().
  1396. *
  1397. * Drivers should check the return value, its possible you can get
  1398. * an -ENOMEM.
  1399. */
  1400. extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  1401. /**
  1402. * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  1403. * @wiphy: the wireless device we want to process the regulatory domain on
  1404. * @regd: the custom regulatory domain to use for this wiphy
  1405. *
  1406. * Drivers can sometimes have custom regulatory domains which do not apply
  1407. * to a specific country. Drivers can use this to apply such custom regulatory
  1408. * domains. This routine must be called prior to wiphy registration. The
  1409. * custom regulatory domain will be trusted completely and as such previous
  1410. * default channel settings will be disregarded. If no rule is found for a
  1411. * channel on the regulatory domain the channel will be disabled.
  1412. */
  1413. extern void wiphy_apply_custom_regulatory(
  1414. struct wiphy *wiphy,
  1415. const struct ieee80211_regdomain *regd);
  1416. /**
  1417. * freq_reg_info - get regulatory information for the given frequency
  1418. * @wiphy: the wiphy for which we want to process this rule for
  1419. * @center_freq: Frequency in KHz for which we want regulatory information for
  1420. * @desired_bw_khz: the desired max bandwidth you want to use per
  1421. * channel. Note that this is still 20 MHz if you want to use HT40
  1422. * as HT40 makes use of two channels for its 40 MHz width bandwidth.
  1423. * If set to 0 we'll assume you want the standard 20 MHz.
  1424. * @reg_rule: the regulatory rule which we have for this frequency
  1425. *
  1426. * Use this function to get the regulatory rule for a specific frequency on
  1427. * a given wireless device. If the device has a specific regulatory domain
  1428. * it wants to follow we respect that unless a country IE has been received
  1429. * and processed already.
  1430. *
  1431. * Returns 0 if it was able to find a valid regulatory rule which does
  1432. * apply to the given center_freq otherwise it returns non-zero. It will
  1433. * also return -ERANGE if we determine the given center_freq does not even have
  1434. * a regulatory rule for a frequency range in the center_freq's band. See
  1435. * freq_in_rule_band() for our current definition of a band -- this is purely
  1436. * subjective and right now its 802.11 specific.
  1437. */
  1438. extern int freq_reg_info(struct wiphy *wiphy,
  1439. u32 center_freq,
  1440. u32 desired_bw_khz,
  1441. const struct ieee80211_reg_rule **reg_rule);
  1442. /*
  1443. * Temporary wext handlers & helper functions
  1444. *
  1445. * In the future cfg80211 will simply assign the entire wext handler
  1446. * structure to netdevs it manages, but we're not there yet.
  1447. */
  1448. int cfg80211_wext_giwname(struct net_device *dev,
  1449. struct iw_request_info *info,
  1450. char *name, char *extra);
  1451. int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
  1452. u32 *mode, char *extra);
  1453. int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
  1454. u32 *mode, char *extra);
  1455. int cfg80211_wext_siwscan(struct net_device *dev,
  1456. struct iw_request_info *info,
  1457. union iwreq_data *wrqu, char *extra);
  1458. int cfg80211_wext_giwscan(struct net_device *dev,
  1459. struct iw_request_info *info,
  1460. struct iw_point *data, char *extra);
  1461. int cfg80211_wext_siwmlme(struct net_device *dev,
  1462. struct iw_request_info *info,
  1463. struct iw_point *data, char *extra);
  1464. int cfg80211_wext_giwrange(struct net_device *dev,
  1465. struct iw_request_info *info,
  1466. struct iw_point *data, char *extra);
  1467. int cfg80211_wext_siwgenie(struct net_device *dev,
  1468. struct iw_request_info *info,
  1469. struct iw_point *data, char *extra);
  1470. int cfg80211_wext_siwauth(struct net_device *dev,
  1471. struct iw_request_info *info,
  1472. struct iw_param *data, char *extra);
  1473. int cfg80211_wext_giwauth(struct net_device *dev,
  1474. struct iw_request_info *info,
  1475. struct iw_param *data, char *extra);
  1476. int cfg80211_wext_siwfreq(struct net_device *dev,
  1477. struct iw_request_info *info,
  1478. struct iw_freq *freq, char *extra);
  1479. int cfg80211_wext_giwfreq(struct net_device *dev,
  1480. struct iw_request_info *info,
  1481. struct iw_freq *freq, char *extra);
  1482. int cfg80211_wext_siwessid(struct net_device *dev,
  1483. struct iw_request_info *info,
  1484. struct iw_point *data, char *ssid);
  1485. int cfg80211_wext_giwessid(struct net_device *dev,
  1486. struct iw_request_info *info,
  1487. struct iw_point *data, char *ssid);
  1488. int cfg80211_wext_siwrate(struct net_device *dev,
  1489. struct iw_request_info *info,
  1490. struct iw_param *rate, char *extra);
  1491. int cfg80211_wext_giwrate(struct net_device *dev,
  1492. struct iw_request_info *info,
  1493. struct iw_param *rate, char *extra);
  1494. int cfg80211_wext_siwrts(struct net_device *dev,
  1495. struct iw_request_info *info,
  1496. struct iw_param *rts, char *extra);
  1497. int cfg80211_wext_giwrts(struct net_device *dev,
  1498. struct iw_request_info *info,
  1499. struct iw_param *rts, char *extra);
  1500. int cfg80211_wext_siwfrag(struct net_device *dev,
  1501. struct iw_request_info *info,
  1502. struct iw_param *frag, char *extra);
  1503. int cfg80211_wext_giwfrag(struct net_device *dev,
  1504. struct iw_request_info *info,
  1505. struct iw_param *frag, char *extra);
  1506. int cfg80211_wext_siwretry(struct net_device *dev,
  1507. struct iw_request_info *info,
  1508. struct iw_param *retry, char *extra);
  1509. int cfg80211_wext_giwretry(struct net_device *dev,
  1510. struct iw_request_info *info,
  1511. struct iw_param *retry, char *extra);
  1512. int cfg80211_wext_siwencodeext(struct net_device *dev,
  1513. struct iw_request_info *info,
  1514. struct iw_point *erq, char *extra);
  1515. int cfg80211_wext_siwencode(struct net_device *dev,
  1516. struct iw_request_info *info,
  1517. struct iw_point *erq, char *keybuf);
  1518. int cfg80211_wext_giwencode(struct net_device *dev,
  1519. struct iw_request_info *info,
  1520. struct iw_point *erq, char *keybuf);
  1521. int cfg80211_wext_siwtxpower(struct net_device *dev,
  1522. struct iw_request_info *info,
  1523. union iwreq_data *data, char *keybuf);
  1524. int cfg80211_wext_giwtxpower(struct net_device *dev,
  1525. struct iw_request_info *info,
  1526. union iwreq_data *data, char *keybuf);
  1527. struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev);
  1528. int cfg80211_wext_siwpower(struct net_device *dev,
  1529. struct iw_request_info *info,
  1530. struct iw_param *wrq, char *extra);
  1531. int cfg80211_wext_giwpower(struct net_device *dev,
  1532. struct iw_request_info *info,
  1533. struct iw_param *wrq, char *extra);
  1534. int cfg80211_wext_siwap(struct net_device *dev,
  1535. struct iw_request_info *info,
  1536. struct sockaddr *ap_addr, char *extra);
  1537. int cfg80211_wext_giwap(struct net_device *dev,
  1538. struct iw_request_info *info,
  1539. struct sockaddr *ap_addr, char *extra);
  1540. /*
  1541. * callbacks for asynchronous cfg80211 methods, notification
  1542. * functions and BSS handling helpers
  1543. */
  1544. /**
  1545. * cfg80211_scan_done - notify that scan finished
  1546. *
  1547. * @request: the corresponding scan request
  1548. * @aborted: set to true if the scan was aborted for any reason,
  1549. * userspace will be notified of that
  1550. */
  1551. void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted);
  1552. /**
  1553. * cfg80211_inform_bss - inform cfg80211 of a new BSS
  1554. *
  1555. * @wiphy: the wiphy reporting the BSS
  1556. * @bss: the found BSS
  1557. * @signal: the signal strength, type depends on the wiphy's signal_type
  1558. * @gfp: context flags
  1559. *
  1560. * This informs cfg80211 that BSS information was found and
  1561. * the BSS should be updated/added.
  1562. */
  1563. struct cfg80211_bss*
  1564. cfg80211_inform_bss_frame(struct wiphy *wiphy,
  1565. struct ieee80211_channel *channel,
  1566. struct ieee80211_mgmt *mgmt, size_t len,
  1567. s32 signal, gfp_t gfp);
  1568. struct cfg80211_bss*
  1569. cfg80211_inform_bss(struct wiphy *wiphy,
  1570. struct ieee80211_channel *channel,
  1571. const u8 *bssid,
  1572. u64 timestamp, u16 capability, u16 beacon_interval,
  1573. const u8 *ie, size_t ielen,
  1574. s32 signal, gfp_t gfp);
  1575. struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
  1576. struct ieee80211_channel *channel,
  1577. const u8 *bssid,
  1578. const u8 *ssid, size_t ssid_len,
  1579. u16 capa_mask, u16 capa_val);
  1580. static inline struct cfg80211_bss *
  1581. cfg80211_get_ibss(struct wiphy *wiphy,
  1582. struct ieee80211_channel *channel,
  1583. const u8 *ssid, size_t ssid_len)
  1584. {
  1585. return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
  1586. WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
  1587. }
  1588. struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy,
  1589. struct ieee80211_channel *channel,
  1590. const u8 *meshid, size_t meshidlen,
  1591. const u8 *meshcfg);
  1592. void cfg80211_put_bss(struct cfg80211_bss *bss);
  1593. /**
  1594. * cfg80211_unlink_bss - unlink BSS from internal data structures
  1595. * @wiphy: the wiphy
  1596. * @bss: the bss to remove
  1597. *
  1598. * This function removes the given BSS from the internal data structures
  1599. * thereby making it no longer show up in scan results etc. Use this
  1600. * function when you detect a BSS is gone. Normally BSSes will also time
  1601. * out, so it is not necessary to use this function at all.
  1602. */
  1603. void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  1604. /**
  1605. * cfg80211_send_rx_auth - notification of processed authentication
  1606. * @dev: network device
  1607. * @buf: authentication frame (header + body)
  1608. * @len: length of the frame data
  1609. *
  1610. * This function is called whenever an authentication has been processed in
  1611. * station mode. The driver is required to call either this function or
  1612. * cfg80211_send_auth_timeout() to indicate the result of cfg80211_ops::auth()
  1613. * call. This function may sleep.
  1614. */
  1615. void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len);
  1616. /**
  1617. * cfg80211_send_auth_timeout - notification of timed out authentication
  1618. * @dev: network device
  1619. * @addr: The MAC address of the device with which the authentication timed out
  1620. *
  1621. * This function may sleep.
  1622. */
  1623. void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr);
  1624. /**
  1625. * cfg80211_send_rx_assoc - notification of processed association
  1626. * @dev: network device
  1627. * @buf: (re)association response frame (header + body)
  1628. * @len: length of the frame data
  1629. *
  1630. * This function is called whenever a (re)association response has been
  1631. * processed in station mode. The driver is required to call either this
  1632. * function or cfg80211_send_assoc_timeout() to indicate the result of
  1633. * cfg80211_ops::assoc() call. This function may sleep.
  1634. */
  1635. void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len);
  1636. /**
  1637. * cfg80211_send_assoc_timeout - notification of timed out association
  1638. * @dev: network device
  1639. * @addr: The MAC address of the device with which the association timed out
  1640. *
  1641. * This function may sleep.
  1642. */
  1643. void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr);
  1644. /**
  1645. * cfg80211_send_deauth - notification of processed deauthentication
  1646. * @dev: network device
  1647. * @buf: deauthentication frame (header + body)
  1648. * @len: length of the frame data
  1649. * @cookie: cookie from ->deauth if called within that callback,
  1650. * %NULL otherwise
  1651. *
  1652. * This function is called whenever deauthentication has been processed in
  1653. * station mode. This includes both received deauthentication frames and
  1654. * locally generated ones. This function may sleep.
  1655. */
  1656. void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len,
  1657. void *cookie);
  1658. /**
  1659. * cfg80211_send_disassoc - notification of processed disassociation
  1660. * @dev: network device
  1661. * @buf: disassociation response frame (header + body)
  1662. * @len: length of the frame data
  1663. * @cookie: cookie from ->disassoc if called within that callback,
  1664. * %NULL otherwise
  1665. *
  1666. * This function is called whenever disassociation has been processed in
  1667. * station mode. This includes both received disassociation frames and locally
  1668. * generated ones. This function may sleep.
  1669. */
  1670. void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len,
  1671. void *cookie);
  1672. /**
  1673. * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
  1674. * @dev: network device
  1675. * @addr: The source MAC address of the frame
  1676. * @key_type: The key type that the received frame used
  1677. * @key_id: Key identifier (0..3)
  1678. * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
  1679. * @gfp: allocation flags
  1680. *
  1681. * This function is called whenever the local MAC detects a MIC failure in a
  1682. * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
  1683. * primitive.
  1684. */
  1685. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  1686. enum nl80211_key_type key_type, int key_id,
  1687. const u8 *tsc, gfp_t gfp);
  1688. /**
  1689. * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
  1690. *
  1691. * @dev: network device
  1692. * @bssid: the BSSID of the IBSS joined
  1693. * @gfp: allocation flags
  1694. *
  1695. * This function notifies cfg80211 that the device joined an IBSS or
  1696. * switched to a different BSSID. Before this function can be called,
  1697. * either a beacon has to have been received from the IBSS, or one of
  1698. * the cfg80211_inform_bss{,_frame} functions must have been called
  1699. * with the locally generated beacon -- this guarantees that there is
  1700. * always a scan result for this IBSS. cfg80211 will handle the rest.
  1701. */
  1702. void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
  1703. /**
  1704. * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
  1705. * @wiphy: the wiphy
  1706. * @blocked: block status
  1707. */
  1708. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked);
  1709. /**
  1710. * wiphy_rfkill_start_polling - start polling rfkill
  1711. * @wiphy: the wiphy
  1712. */
  1713. void wiphy_rfkill_start_polling(struct wiphy *wiphy);
  1714. /**
  1715. * wiphy_rfkill_stop_polling - stop polling rfkill
  1716. * @wiphy: the wiphy
  1717. */
  1718. void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
  1719. #ifdef CONFIG_NL80211_TESTMODE
  1720. /**
  1721. * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
  1722. * @wiphy: the wiphy
  1723. * @approxlen: an upper bound of the length of the data that will
  1724. * be put into the skb
  1725. *
  1726. * This function allocates and pre-fills an skb for a reply to
  1727. * the testmode command. Since it is intended for a reply, calling
  1728. * it outside of the @testmode_cmd operation is invalid.
  1729. *
  1730. * The returned skb (or %NULL if any errors happen) is pre-filled
  1731. * with the wiphy index and set up in a way that any data that is
  1732. * put into the skb (with skb_put(), nla_put() or similar) will end
  1733. * up being within the %NL80211_ATTR_TESTDATA attribute, so all that
  1734. * needs to be done with the skb is adding data for the corresponding
  1735. * userspace tool which can then read that data out of the testdata
  1736. * attribute. You must not modify the skb in any other way.
  1737. *
  1738. * When done, call cfg80211_testmode_reply() with the skb and return
  1739. * its error code as the result of the @testmode_cmd operation.
  1740. */
  1741. struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy,
  1742. int approxlen);
  1743. /**
  1744. * cfg80211_testmode_reply - send the reply skb
  1745. * @skb: The skb, must have been allocated with
  1746. * cfg80211_testmode_alloc_reply_skb()
  1747. *
  1748. * Returns an error code or 0 on success, since calling this
  1749. * function will usually be the last thing before returning
  1750. * from the @testmode_cmd you should return the error code.
  1751. * Note that this function consumes the skb regardless of the
  1752. * return value.
  1753. */
  1754. int cfg80211_testmode_reply(struct sk_buff *skb);
  1755. /**
  1756. * cfg80211_testmode_alloc_event_skb - allocate testmode event
  1757. * @wiphy: the wiphy
  1758. * @approxlen: an upper bound of the length of the data that will
  1759. * be put into the skb
  1760. * @gfp: allocation flags
  1761. *
  1762. * This function allocates and pre-fills an skb for an event on the
  1763. * testmode multicast group.
  1764. *
  1765. * The returned skb (or %NULL if any errors happen) is set up in the
  1766. * same way as with cfg80211_testmode_alloc_reply_skb() but prepared
  1767. * for an event. As there, you should simply add data to it that will
  1768. * then end up in the %NL80211_ATTR_TESTDATA attribute. Again, you must
  1769. * not modify the skb in any other way.
  1770. *
  1771. * When done filling the skb, call cfg80211_testmode_event() with the
  1772. * skb to send the event.
  1773. */
  1774. struct sk_buff *cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy,
  1775. int approxlen, gfp_t gfp);
  1776. /**
  1777. * cfg80211_testmode_event - send the event
  1778. * @skb: The skb, must have been allocated with
  1779. * cfg80211_testmode_alloc_event_skb()
  1780. * @gfp: allocation flags
  1781. *
  1782. * This function sends the given @skb, which must have been allocated
  1783. * by cfg80211_testmode_alloc_event_skb(), as an event. It always
  1784. * consumes it.
  1785. */
  1786. void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp);
  1787. #define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
  1788. #else
  1789. #define CFG80211_TESTMODE_CMD(cmd)
  1790. #endif
  1791. /**
  1792. * cfg80211_connect_result - notify cfg80211 of connection result
  1793. *
  1794. * @dev: network device
  1795. * @bssid: the BSSID of the AP
  1796. * @req_ie: association request IEs (maybe be %NULL)
  1797. * @req_ie_len: association request IEs length
  1798. * @resp_ie: association response IEs (may be %NULL)
  1799. * @resp_ie_len: assoc response IEs length
  1800. * @status: status code, 0 for successful connection, use
  1801. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  1802. * the real status code for failures.
  1803. * @gfp: allocation flags
  1804. *
  1805. * It should be called by the underlying driver whenever connect() has
  1806. * succeeded.
  1807. */
  1808. void cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
  1809. const u8 *req_ie, size_t req_ie_len,
  1810. const u8 *resp_ie, size_t resp_ie_len,
  1811. u16 status, gfp_t gfp);
  1812. /**
  1813. * cfg80211_roamed - notify cfg80211 of roaming
  1814. *
  1815. * @dev: network device
  1816. * @bssid: the BSSID of the new AP
  1817. * @req_ie: association request IEs (maybe be %NULL)
  1818. * @req_ie_len: association request IEs length
  1819. * @resp_ie: association response IEs (may be %NULL)
  1820. * @resp_ie_len: assoc response IEs length
  1821. * @gfp: allocation flags
  1822. *
  1823. * It should be called by the underlying driver whenever it roamed
  1824. * from one AP to another while connected.
  1825. */
  1826. void cfg80211_roamed(struct net_device *dev, const u8 *bssid,
  1827. const u8 *req_ie, size_t req_ie_len,
  1828. const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp);
  1829. /**
  1830. * cfg80211_disconnected - notify cfg80211 that connection was dropped
  1831. *
  1832. * @dev: network device
  1833. * @ie: information elements of the deauth/disassoc frame (may be %NULL)
  1834. * @ie_len: length of IEs
  1835. * @reason: reason code for the disconnection, set it to 0 if unknown
  1836. * @gfp: allocation flags
  1837. *
  1838. * After it calls this function, the driver should enter an idle state
  1839. * and not try to connect to any AP any more.
  1840. */
  1841. void cfg80211_disconnected(struct net_device *dev, u16 reason,
  1842. u8 *ie, size_t ie_len, gfp_t gfp);
  1843. #endif /* __NET_CFG80211_H */