cfg80211.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. #ifndef __NET_CFG80211_H
  2. #define __NET_CFG80211_H
  3. #include <linux/netlink.h>
  4. #include <linux/skbuff.h>
  5. #include <linux/nl80211.h>
  6. #include <net/genetlink.h>
  7. /* remove once we remove the wext stuff */
  8. #include <net/iw_handler.h>
  9. /*
  10. * 802.11 configuration in-kernel interface
  11. *
  12. * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
  13. */
  14. /**
  15. * struct vif_params - describes virtual interface parameters
  16. * @mesh_id: mesh ID to use
  17. * @mesh_id_len: length of the mesh ID
  18. */
  19. struct vif_params {
  20. u8 *mesh_id;
  21. int mesh_id_len;
  22. };
  23. /* Radiotap header iteration
  24. * implemented in net/wireless/radiotap.c
  25. * docs in Documentation/networking/radiotap-headers.txt
  26. */
  27. /**
  28. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  29. * @rtheader: pointer to the radiotap header we are walking through
  30. * @max_length: length of radiotap header in cpu byte ordering
  31. * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
  32. * @this_arg: pointer to current radiotap arg
  33. * @arg_index: internal next argument index
  34. * @arg: internal next argument pointer
  35. * @next_bitmap: internal pointer to next present u32
  36. * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  37. */
  38. struct ieee80211_radiotap_iterator {
  39. struct ieee80211_radiotap_header *rtheader;
  40. int max_length;
  41. int this_arg_index;
  42. u8 *this_arg;
  43. int arg_index;
  44. u8 *arg;
  45. __le32 *next_bitmap;
  46. u32 bitmap_shifter;
  47. };
  48. extern int ieee80211_radiotap_iterator_init(
  49. struct ieee80211_radiotap_iterator *iterator,
  50. struct ieee80211_radiotap_header *radiotap_header,
  51. int max_length);
  52. extern int ieee80211_radiotap_iterator_next(
  53. struct ieee80211_radiotap_iterator *iterator);
  54. /**
  55. * struct key_params - key information
  56. *
  57. * Information about a key
  58. *
  59. * @key: key material
  60. * @key_len: length of key material
  61. * @cipher: cipher suite selector
  62. * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
  63. * with the get_key() callback, must be in little endian,
  64. * length given by @seq_len.
  65. */
  66. struct key_params {
  67. u8 *key;
  68. u8 *seq;
  69. int key_len;
  70. int seq_len;
  71. u32 cipher;
  72. };
  73. /**
  74. * struct beacon_parameters - beacon parameters
  75. *
  76. * Used to configure the beacon for an interface.
  77. *
  78. * @head: head portion of beacon (before TIM IE)
  79. * or %NULL if not changed
  80. * @tail: tail portion of beacon (after TIM IE)
  81. * or %NULL if not changed
  82. * @interval: beacon interval or zero if not changed
  83. * @dtim_period: DTIM period or zero if not changed
  84. * @head_len: length of @head
  85. * @tail_len: length of @tail
  86. */
  87. struct beacon_parameters {
  88. u8 *head, *tail;
  89. int interval, dtim_period;
  90. int head_len, tail_len;
  91. };
  92. /**
  93. * enum station_flags - station flags
  94. *
  95. * Station capability flags. Note that these must be the bits
  96. * according to the nl80211 flags.
  97. *
  98. * @STATION_FLAG_CHANGED: station flags were changed
  99. * @STATION_FLAG_AUTHORIZED: station is authorized to send frames (802.1X)
  100. * @STATION_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
  101. * with short preambles
  102. * @STATION_FLAG_WME: station is WME/QoS capable
  103. */
  104. enum station_flags {
  105. STATION_FLAG_CHANGED = 1<<0,
  106. STATION_FLAG_AUTHORIZED = 1<<NL80211_STA_FLAG_AUTHORIZED,
  107. STATION_FLAG_SHORT_PREAMBLE = 1<<NL80211_STA_FLAG_SHORT_PREAMBLE,
  108. STATION_FLAG_WME = 1<<NL80211_STA_FLAG_WME,
  109. };
  110. /**
  111. * enum plink_action - actions to perform in mesh peers
  112. *
  113. * @PLINK_ACTION_INVALID: action 0 is reserved
  114. * @PLINK_ACTION_OPEN: start mesh peer link establishment
  115. * @PLINK_ACTION_BLOCL: block traffic from this mesh peer
  116. */
  117. enum plink_actions {
  118. PLINK_ACTION_INVALID,
  119. PLINK_ACTION_OPEN,
  120. PLINK_ACTION_BLOCK,
  121. };
  122. /**
  123. * struct station_parameters - station parameters
  124. *
  125. * Used to change and create a new station.
  126. *
  127. * @vlan: vlan interface station should belong to
  128. * @supported_rates: supported rates in IEEE 802.11 format
  129. * (or NULL for no change)
  130. * @supported_rates_len: number of supported rates
  131. * @station_flags: station flags (see &enum station_flags)
  132. * @listen_interval: listen interval or -1 for no change
  133. * @aid: AID or zero for no change
  134. */
  135. struct station_parameters {
  136. u8 *supported_rates;
  137. struct net_device *vlan;
  138. u32 station_flags;
  139. int listen_interval;
  140. u16 aid;
  141. u8 supported_rates_len;
  142. u8 plink_action;
  143. struct ieee80211_ht_cap *ht_capa;
  144. };
  145. /**
  146. * enum station_info_flags - station information flags
  147. *
  148. * Used by the driver to indicate which info in &struct station_info
  149. * it has filled in during get_station() or dump_station().
  150. *
  151. * @STATION_INFO_INACTIVE_TIME: @inactive_time filled
  152. * @STATION_INFO_RX_BYTES: @rx_bytes filled
  153. * @STATION_INFO_TX_BYTES: @tx_bytes filled
  154. * @STATION_INFO_LLID: @llid filled
  155. * @STATION_INFO_PLID: @plid filled
  156. * @STATION_INFO_PLINK_STATE: @plink_state filled
  157. */
  158. enum station_info_flags {
  159. STATION_INFO_INACTIVE_TIME = 1<<0,
  160. STATION_INFO_RX_BYTES = 1<<1,
  161. STATION_INFO_TX_BYTES = 1<<2,
  162. STATION_INFO_LLID = 1<<3,
  163. STATION_INFO_PLID = 1<<4,
  164. STATION_INFO_PLINK_STATE = 1<<5,
  165. };
  166. /**
  167. * struct station_info - station information
  168. *
  169. * Station information filled by driver for get_station() and dump_station.
  170. *
  171. * @filled: bitflag of flags from &enum station_info_flags
  172. * @inactive_time: time since last station activity (tx/rx) in milliseconds
  173. * @rx_bytes: bytes received from this station
  174. * @tx_bytes: bytes transmitted to this station
  175. * @llid: mesh local link id
  176. * @plid: mesh peer link id
  177. * @plink_state: mesh peer link state
  178. */
  179. struct station_info {
  180. u32 filled;
  181. u32 inactive_time;
  182. u32 rx_bytes;
  183. u32 tx_bytes;
  184. u16 llid;
  185. u16 plid;
  186. u8 plink_state;
  187. };
  188. /**
  189. * enum monitor_flags - monitor flags
  190. *
  191. * Monitor interface configuration flags. Note that these must be the bits
  192. * according to the nl80211 flags.
  193. *
  194. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  195. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  196. * @MONITOR_FLAG_CONTROL: pass control frames
  197. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  198. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  199. */
  200. enum monitor_flags {
  201. MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
  202. MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
  203. MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
  204. MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
  205. MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
  206. };
  207. /**
  208. * enum mpath_info_flags - mesh path information flags
  209. *
  210. * Used by the driver to indicate which info in &struct mpath_info it has filled
  211. * in during get_station() or dump_station().
  212. *
  213. * MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  214. * MPATH_INFO_DSN: @dsn filled
  215. * MPATH_INFO_METRIC: @metric filled
  216. * MPATH_INFO_EXPTIME: @exptime filled
  217. * MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  218. * MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  219. * MPATH_INFO_FLAGS: @flags filled
  220. */
  221. enum mpath_info_flags {
  222. MPATH_INFO_FRAME_QLEN = BIT(0),
  223. MPATH_INFO_DSN = BIT(1),
  224. MPATH_INFO_METRIC = BIT(2),
  225. MPATH_INFO_EXPTIME = BIT(3),
  226. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  227. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  228. MPATH_INFO_FLAGS = BIT(6),
  229. };
  230. /**
  231. * struct mpath_info - mesh path information
  232. *
  233. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  234. *
  235. * @filled: bitfield of flags from &enum mpath_info_flags
  236. * @frame_qlen: number of queued frames for this destination
  237. * @dsn: destination sequence number
  238. * @metric: metric (cost) of this mesh path
  239. * @exptime: expiration time for the mesh path from now, in msecs
  240. * @flags: mesh path flags
  241. * @discovery_timeout: total mesh path discovery timeout, in msecs
  242. * @discovery_retries: mesh path discovery retries
  243. */
  244. struct mpath_info {
  245. u32 filled;
  246. u32 frame_qlen;
  247. u32 dsn;
  248. u32 metric;
  249. u32 exptime;
  250. u32 discovery_timeout;
  251. u8 discovery_retries;
  252. u8 flags;
  253. };
  254. /**
  255. * struct bss_parameters - BSS parameters
  256. *
  257. * Used to change BSS parameters (mainly for AP mode).
  258. *
  259. * @use_cts_prot: Whether to use CTS protection
  260. * (0 = no, 1 = yes, -1 = do not change)
  261. * @use_short_preamble: Whether the use of short preambles is allowed
  262. * (0 = no, 1 = yes, -1 = do not change)
  263. * @use_short_slot_time: Whether the use of short slot time is allowed
  264. * (0 = no, 1 = yes, -1 = do not change)
  265. * @basic_rates: basic rates in IEEE 802.11 format
  266. * (or NULL for no change)
  267. * @basic_rates_len: number of basic rates
  268. */
  269. struct bss_parameters {
  270. int use_cts_prot;
  271. int use_short_preamble;
  272. int use_short_slot_time;
  273. u8 *basic_rates;
  274. u8 basic_rates_len;
  275. };
  276. /**
  277. * enum reg_set_by - Indicates who is trying to set the regulatory domain
  278. * @REGDOM_SET_BY_INIT: regulatory domain was set by initialization. We will be
  279. * using a static world regulatory domain by default.
  280. * @REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world regulatory domain.
  281. * @REGDOM_SET_BY_USER: User asked the wireless core to set the
  282. * regulatory domain.
  283. * @REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the wireless core
  284. * it thinks its knows the regulatory domain we should be in.
  285. * @REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an 802.11 country
  286. * information element with regulatory information it thinks we
  287. * should consider.
  288. */
  289. enum reg_set_by {
  290. REGDOM_SET_BY_INIT,
  291. REGDOM_SET_BY_CORE,
  292. REGDOM_SET_BY_USER,
  293. REGDOM_SET_BY_DRIVER,
  294. REGDOM_SET_BY_COUNTRY_IE,
  295. };
  296. struct ieee80211_freq_range {
  297. u32 start_freq_khz;
  298. u32 end_freq_khz;
  299. u32 max_bandwidth_khz;
  300. };
  301. struct ieee80211_power_rule {
  302. u32 max_antenna_gain;
  303. u32 max_eirp;
  304. };
  305. struct ieee80211_reg_rule {
  306. struct ieee80211_freq_range freq_range;
  307. struct ieee80211_power_rule power_rule;
  308. u32 flags;
  309. };
  310. struct ieee80211_regdomain {
  311. u32 n_reg_rules;
  312. char alpha2[2];
  313. struct ieee80211_reg_rule reg_rules[];
  314. };
  315. #define MHZ_TO_KHZ(freq) ((freq) * 1000)
  316. #define KHZ_TO_MHZ(freq) ((freq) / 1000)
  317. #define DBI_TO_MBI(gain) ((gain) * 100)
  318. #define MBI_TO_DBI(gain) ((gain) / 100)
  319. #define DBM_TO_MBM(gain) ((gain) * 100)
  320. #define MBM_TO_DBM(gain) ((gain) / 100)
  321. #define REG_RULE(start, end, bw, gain, eirp, reg_flags) { \
  322. .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \
  323. .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \
  324. .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \
  325. .power_rule.max_antenna_gain = DBI_TO_MBI(gain), \
  326. .power_rule.max_eirp = DBM_TO_MBM(eirp), \
  327. .flags = reg_flags, \
  328. }
  329. struct mesh_config {
  330. /* Timeouts in ms */
  331. /* Mesh plink management parameters */
  332. u16 dot11MeshRetryTimeout;
  333. u16 dot11MeshConfirmTimeout;
  334. u16 dot11MeshHoldingTimeout;
  335. u16 dot11MeshMaxPeerLinks;
  336. u8 dot11MeshMaxRetries;
  337. u8 dot11MeshTTL;
  338. bool auto_open_plinks;
  339. /* HWMP parameters */
  340. u8 dot11MeshHWMPmaxPREQretries;
  341. u32 path_refresh_time;
  342. u16 min_discovery_timeout;
  343. u32 dot11MeshHWMPactivePathTimeout;
  344. u16 dot11MeshHWMPpreqMinInterval;
  345. u16 dot11MeshHWMPnetDiameterTraversalTime;
  346. };
  347. /**
  348. * struct ieee80211_txq_params - TX queue parameters
  349. * @queue: TX queue identifier (NL80211_TXQ_Q_*)
  350. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  351. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  352. * 1..32767]
  353. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  354. * 1..32767]
  355. * @aifs: Arbitration interframe space [0..255]
  356. */
  357. struct ieee80211_txq_params {
  358. enum nl80211_txq_q queue;
  359. u16 txop;
  360. u16 cwmin;
  361. u16 cwmax;
  362. u8 aifs;
  363. };
  364. /* from net/wireless.h */
  365. struct wiphy;
  366. /* from net/ieee80211.h */
  367. struct ieee80211_channel;
  368. /**
  369. * struct cfg80211_ops - backend description for wireless configuration
  370. *
  371. * This struct is registered by fullmac card drivers and/or wireless stacks
  372. * in order to handle configuration requests on their interfaces.
  373. *
  374. * All callbacks except where otherwise noted should return 0
  375. * on success or a negative error code.
  376. *
  377. * All operations are currently invoked under rtnl for consistency with the
  378. * wireless extensions but this is subject to reevaluation as soon as this
  379. * code is used more widely and we have a first user without wext.
  380. *
  381. * @add_virtual_intf: create a new virtual interface with the given name,
  382. * must set the struct wireless_dev's iftype.
  383. *
  384. * @del_virtual_intf: remove the virtual interface determined by ifindex.
  385. *
  386. * @change_virtual_intf: change type/configuration of virtual interface,
  387. * keep the struct wireless_dev's iftype updated.
  388. *
  389. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  390. * when adding a group key.
  391. *
  392. * @get_key: get information about the key with the given parameters.
  393. * @mac_addr will be %NULL when requesting information for a group
  394. * key. All pointers given to the @callback function need not be valid
  395. * after it returns.
  396. *
  397. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  398. * and @key_index
  399. *
  400. * @set_default_key: set the default key on an interface
  401. *
  402. * @add_beacon: Add a beacon with given parameters, @head, @interval
  403. * and @dtim_period will be valid, @tail is optional.
  404. * @set_beacon: Change the beacon parameters for an access point mode
  405. * interface. This should reject the call when no beacon has been
  406. * configured.
  407. * @del_beacon: Remove beacon configuration and stop sending the beacon.
  408. *
  409. * @add_station: Add a new station.
  410. *
  411. * @del_station: Remove a station; @mac may be NULL to remove all stations.
  412. *
  413. * @change_station: Modify a given station.
  414. *
  415. * @get_mesh_params: Put the current mesh parameters into *params
  416. *
  417. * @set_mesh_params: Set mesh parameters.
  418. * The mask is a bitfield which tells us which parameters to
  419. * set, and which to leave alone.
  420. *
  421. * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
  422. *
  423. * @change_bss: Modify parameters for a given BSS.
  424. *
  425. * @set_txq_params: Set TX queue parameters
  426. *
  427. * @set_channel: Set channel
  428. */
  429. struct cfg80211_ops {
  430. int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
  431. enum nl80211_iftype type, u32 *flags,
  432. struct vif_params *params);
  433. int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
  434. int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
  435. enum nl80211_iftype type, u32 *flags,
  436. struct vif_params *params);
  437. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  438. u8 key_index, u8 *mac_addr,
  439. struct key_params *params);
  440. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  441. u8 key_index, u8 *mac_addr, void *cookie,
  442. void (*callback)(void *cookie, struct key_params*));
  443. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  444. u8 key_index, u8 *mac_addr);
  445. int (*set_default_key)(struct wiphy *wiphy,
  446. struct net_device *netdev,
  447. u8 key_index);
  448. int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
  449. struct beacon_parameters *info);
  450. int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
  451. struct beacon_parameters *info);
  452. int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
  453. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  454. u8 *mac, struct station_parameters *params);
  455. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  456. u8 *mac);
  457. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  458. u8 *mac, struct station_parameters *params);
  459. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  460. u8 *mac, struct station_info *sinfo);
  461. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  462. int idx, u8 *mac, struct station_info *sinfo);
  463. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  464. u8 *dst, u8 *next_hop);
  465. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  466. u8 *dst);
  467. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  468. u8 *dst, u8 *next_hop);
  469. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  470. u8 *dst, u8 *next_hop,
  471. struct mpath_info *pinfo);
  472. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  473. int idx, u8 *dst, u8 *next_hop,
  474. struct mpath_info *pinfo);
  475. int (*get_mesh_params)(struct wiphy *wiphy,
  476. struct net_device *dev,
  477. struct mesh_config *conf);
  478. int (*set_mesh_params)(struct wiphy *wiphy,
  479. struct net_device *dev,
  480. const struct mesh_config *nconf, u32 mask);
  481. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  482. struct bss_parameters *params);
  483. int (*set_txq_params)(struct wiphy *wiphy,
  484. struct ieee80211_txq_params *params);
  485. int (*set_channel)(struct wiphy *wiphy,
  486. struct ieee80211_channel *chan,
  487. enum nl80211_sec_chan_offset);
  488. };
  489. /* temporary wext handlers */
  490. int cfg80211_wext_giwname(struct net_device *dev,
  491. struct iw_request_info *info,
  492. char *name, char *extra);
  493. int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
  494. u32 *mode, char *extra);
  495. int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
  496. u32 *mode, char *extra);
  497. #endif /* __NET_CFG80211_H */