cfg80211.h 15 KB

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