cfg80211.h 51 KB

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