wireless.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /************************************************************************************
  2. * include/nuttx/wireless/wireless.h
  3. * Wireless network IOCTL commands
  4. *
  5. * Copyright (C) 2011-2013, 2017-2018 Gregory Nutt. All rights reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ************************************************************************************/
  36. /* This file includes common definitions to be used in all wireless network drivers
  37. * (when applicable).
  38. */
  39. #ifndef __INCLUDE_NUTTX_WIRELESS_WIRELESS_H
  40. #define __INCLUDE_NUTTX_WIRELESS_WIRELESS_H
  41. /************************************************************************************
  42. * Included Files
  43. ************************************************************************************/
  44. #include <nuttx/config.h>
  45. #include <sys/socket.h>
  46. #include <stdint.h>
  47. #include <net/if.h>
  48. #include <nuttx/fs/ioctl.h>
  49. /************************************************************************************
  50. * Pre-processor Definitions
  51. ************************************************************************************/
  52. /* Network Driver IOCTL Commands ****************************************************/
  53. /* Use of these IOCTL commands requires a socket descriptor created by the socket()
  54. * interface.
  55. */
  56. /* Wireless identification */
  57. #define SIOCSIWCOMMIT _WLIOC(0x0000) /* Commit pending changes to driver */
  58. #define SIOCGIWNAME _WLIOC(0x0001) /* Get name of wireless protocol */
  59. /* Basic Operations */
  60. #define SIOCSIWNWID _WLIOC(0x0002) /* Set network ID (pre-802.11) */
  61. #define SIOCGIWNWID _WLIOC(0x0003) /* Get network ID (the cell) */
  62. #define SIOCSIWFREQ _WLIOC(0x0004) /* Set channel/frequency (Hz) */
  63. #define SIOCGIWFREQ _WLIOC(0x0005) /* Get channel/frequency (Hz) */
  64. #define SIOCSIWMODE _WLIOC(0x0006) /* Set operation mode */
  65. #define SIOCGIWMODE _WLIOC(0x0007) /* Get operation mode */
  66. #define SIOCSIWSENS _WLIOC(0x0008) /* Set sensitivity (dBm) */
  67. #define SIOCGIWSENS _WLIOC(0x0009) /* Get sensitivity (dBm) */
  68. /* Informational */
  69. #define SIOCSIWRANGE _WLIOC(0x000a) /* Unused */
  70. #define SIOCGIWRANGE _WLIOC(0x000b) /* Get range of parameters */
  71. #define SIOCSIWPRIV _WLIOC(0x000c) /* Unused */
  72. #define SIOCGIWPRIV _WLIOC(0x000d) /* Get private ioctl interface info */
  73. #define SIOCSIWSTATS _WLIOC(0x000e) /* Unused */
  74. #define SIOCGIWSTATS _WLIOC(0x000f) /* Get wireless stats */
  75. /* Spy support (statistics per MAC address - used for Mobile IP support) */
  76. #define SIOCSIWSPY _WLIOC(0x0010) /* Set spy addresses */
  77. #define SIOCGIWSPY _WLIOC(0x0011) /* Get spy info (quality of link) */
  78. #define SIOCSIWTHRSPY _WLIOC(0x0012) /* Set spy threshold (spy event) */
  79. #define SIOCGIWTHRSPY _WLIOC(0x0013) /* Get spy threshold */
  80. /* Access point manipulation */
  81. #define SIOCSIWAP _WLIOC(0x0014) /* Set access point MAC addresses */
  82. #define SIOCGIWAP _WLIOC(0x0015) /* Get access point MAC addresses */
  83. /* 0x0016: See SIOCSIWMLME */
  84. #define SIOCGIWAPLIST _WLIOC(0x0017) /* Deprecated in favor of scanning */
  85. #define SIOCSIWSCAN _WLIOC(0x0018) /* Trigger scanning (list cells) */
  86. #define SIOCGIWSCAN _WLIOC(0x0019) /* Get scanning results */
  87. /* 802.11 specific support */
  88. #define SIOCSIWESSID _WLIOC(0x001a) /* Set ESSID (network name) */
  89. #define SIOCGIWESSID _WLIOC(0x001b) /* Get ESSID */
  90. #define SIOCSIWNICKN _WLIOC(0x001c) /* Set node name/nickname */
  91. #define SIOCGIWNICKN _WLIOC(0x001d) /* Get node name/nickname */
  92. #define SIOCSIWRATE _WLIOC(0x0020) /* Set default bit rate (bps) */
  93. #define SIOCGIWRATE _WLIOC(0x0021) /* Get default bit rate (bps) */
  94. #define SIOCSIWRTS _WLIOC(0x0022) /* Set RTS/CTS threshold (bytes) */
  95. #define SIOCGIWRTS _WLIOC(0x0023) /* Get RTS/CTS threshold (bytes) */
  96. #define SIOCSIWFRAG _WLIOC(0x0024) /* Set fragmentation thr (bytes) */
  97. #define SIOCGIWFRAG _WLIOC(0x0025) /* Get fragmentation thr (bytes) */
  98. #define SIOCSIWTXPOW _WLIOC(0x0026) /* Set transmit power (dBm) */
  99. #define SIOCGIWTXPOW _WLIOC(0x0027) /* Get transmit power (dBm) */
  100. #define SIOCSIWRETRY _WLIOC(0x0028) /* Set retry limits and lifetime */
  101. #define SIOCGIWRETRY _WLIOC(0x0029) /* Get retry limits and lifetime */
  102. /* Encoding */
  103. #define SIOCSIWENCODE _WLIOC(0x002a) /* Set encoding token & mode */
  104. #define SIOCGIWENCODE _WLIOC(0x002b) /* Get encoding token & mode */
  105. /* Power saving */
  106. #define SIOCSIWPOWER _WLIOC(0x002c) /* Set Power Management settings */
  107. #define SIOCGIWPOWER _WLIOC(0x002d) /* Get Power Management settings */
  108. /* WPA : Generic IEEE 802.11 information element */
  109. #define SIOCSIWGENIE _WLIOC(0x0030) /* Set generic IE */
  110. #define SIOCGIWGENIE _WLIOC(0x0031) /* Get generic IE */
  111. /* WPA : IEEE 802.11 MLME requests */
  112. #define SIOCSIWMLME _WLIOC(0x0016) /* Request MLME operation */
  113. /* WPA : Authentication mode parameters */
  114. #define SIOCSIWAUTH _WLIOC(0x0032) /* Set authentication mode params */
  115. #define SIOCGIWAUTH _WLIOC(0x0033) /* Get authentication mode params */
  116. /* WPA : Extended version of encoding configuration */
  117. #define SIOCSIWENCODEEXT _WLIOC(0x0034) /* Set encoding token & mode */
  118. #define SIOCGIWENCODEEXT _WLIOC(0x0035) /* Get encoding token & mode */
  119. /* WPA2 : PMKSA cache management */
  120. #define SIOCSIWPMKSA _WLIOC(0x0036) /* PMKSA cache operation */
  121. /* Device-specific network IOCTL commands ******************************************/
  122. #define WL_NETFIRST 0x0000 /* First network command */
  123. #define WL_NNETCMDS 0x0037 /* Number of network commands */
  124. /* Reserved for Bluetooth network devices (see bt_ioctls.h) */
  125. #define WL_BLUETOOTHFIRST (WL_NETFIRST + WL_NNETCMDS)
  126. #define WL_BLUETOOTHCMDS (26)
  127. #define WL_IBLUETOOTHCMD(cmd) (_WLIOCVALID(cmd) && \
  128. _IOC_NR(cmd) >= WL_BLUETOOTHFIRST && \
  129. _IOC_NR(cmd) < (WL_BLUETOOTHFIRST + WL_BLUETOOTHCMDS))
  130. /* Reserved for IEEE802.15.4 wireless network devices
  131. * NOTE: Not used. Currently logic uses IOCTL commands from the IEEE802.15.4
  132. * character driver space.
  133. */
  134. #define WL_802154FIRST (WL_BLUETOOTHFIRST + WL_BLUETOOTHCMDS)
  135. #define WL_N802154CMDS (3)
  136. #define WL_IS802154CMD(cmd) (_WLIOCVALID(cmd) && \
  137. _IOC_NR(cmd) >= WL_802154FIRST && \
  138. _IOC_NR(cmd) < (WL_802154FIRST + WL_N802154CMDS))
  139. /* Reserved for network packet radio network devices */
  140. #define WL_PKTRADIOFIRST (WL_802154FIRST + WL_N802154CMDS)
  141. #define WL_NPKTRADIOCMDS (3)
  142. #define WL_ISPKTRADIOCMD(cmd) (_WLIOCVALID(cmd) && \
  143. _IOC_NR(cmd) >= WL_PKTRADIOFIRST && \
  144. _IOC_NR(cmd) < (WL_PKTRADIOFIRST + WL_NPKTRADIOCMDS))
  145. /* ------------------------------ WIRELESS EVENTS -------------------------------- */
  146. /* Those are *NOT* ioctls, do not issue request on them !!! */
  147. /* Most events use the same identifier as ioctl requests */
  148. #define IWEVTXDROP 0x8c00 /* Packet dropped to excessive retry */
  149. #define IWEVQUAL 0x8c01 /* Quality part of statistics (scan) */
  150. #define IWEVCUSTOM 0x8c02 /* Driver specific ascii string */
  151. #define IWEVREGISTERED 0x8c03 /* Discovered a new node (AP mode) */
  152. #define IWEVEXPIRED 0x8c04 /* Expired a node (AP mode) */
  153. #define IWEVGENIE 0x8c05 /* Generic IE (WPA, RSN, WMM, ..)
  154. * (scan results); This includes id and
  155. * length fields. One IWEVGENIE may
  156. * contain more than one IE. Scan
  157. * results may contain one or more
  158. * IWEVGENIE events. */
  159. #define IWEVMICHAELMICFAILURE 0x8c06 /* Michael MIC failure
  160. * (struct iw_michaelmicfailure)
  161. */
  162. #define IWEVASSOCREQIE 0x8c07 /* IEs used in (Re)Association Request.
  163. * The data includes id and length
  164. * fields and may contain more than one
  165. * IE. This event is required in
  166. * Managed mode if the driver
  167. * generates its own WPA/RSN IE. This
  168. * should be sent just before
  169. * IWEVREGISTERED event for the
  170. * association. */
  171. #define IWEVASSOCRESPIE 0x8c08 /* IEs used in (Re)Association
  172. * Response. The data includes id and
  173. * length fields and may contain more
  174. * than one IE. This may be sent
  175. * between IWEVASSOCREQIE and
  176. * IWEVREGISTERED events for the
  177. * association. */
  178. #define IWEVPMKIDCAND 0x8c09 /* PMKID candidate for RSN
  179. * pre-authentication
  180. * (struct iw_pmkid_cand) */
  181. #define IWEVFIRST 0x8c00
  182. #define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
  183. /* Other Common Wireless Definitions ***********************************************/
  184. /* Maximum size of the ESSID and NICKN strings */
  185. #define IW_ESSID_MAX_SIZE 32
  186. /* Modes of operation */
  187. #define IW_MODE_AUTO 0 /* Let the driver decides */
  188. #define IW_MODE_ADHOC 1 /* Single cell network */
  189. #define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
  190. #define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
  191. #define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
  192. #define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
  193. #define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
  194. #define IW_MODE_MESH 7 /* Mesh (IEEE 802.11s) network */
  195. /* Statistics flags (bitmask in updated) */
  196. #define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
  197. #define IW_QUAL_LEVEL_UPDATED 0x02
  198. #define IW_QUAL_NOISE_UPDATED 0x04
  199. #define IW_QUAL_ALL_UPDATED 0x07
  200. #define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
  201. #define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
  202. #define IW_QUAL_LEVEL_INVALID 0x20
  203. #define IW_QUAL_NOISE_INVALID 0x40
  204. #define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
  205. #define IW_QUAL_ALL_INVALID 0x70
  206. /* Flags for encoding (along with the token) */
  207. #define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
  208. #define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
  209. #define IW_ENCODE_MODE 0xF000 /* Modes defined below */
  210. #define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
  211. #define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
  212. #define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
  213. #define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
  214. #define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
  215. #define IW_ENCODE_TEMP 0x0400 /* Temporary key */
  216. /* Frequency flags */
  217. #define IW_FREQ_AUTO 0 /* Let the driver decides */
  218. #define IW_FREQ_FIXED 1 /* Force a specific value */
  219. #define IW_MAX_FREQUENCIES 32 /* Max. frequencies in struct iw_range */
  220. /* Transmit Power flags available */
  221. #define IW_TXPOW_TYPE 0x00ff /* Type of value */
  222. # define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
  223. # define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
  224. # define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
  225. #define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
  226. /* Scan-related */
  227. /* Scanning request flags */
  228. #define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
  229. #define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
  230. #define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
  231. #define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
  232. #define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
  233. #define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
  234. #define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
  235. #define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
  236. #define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
  237. /* struct iw_scan_req scan_type */
  238. #define IW_SCAN_TYPE_ACTIVE 0
  239. #define IW_SCAN_TYPE_PASSIVE 1
  240. /* Maximum size of returned data */
  241. #define IW_SCAN_MAX_DATA 4096 /* In bytes */
  242. /* Scan capability flags - in (struct iw_range *)->scan_capa */
  243. #define IW_SCAN_CAPA_NONE 0x00
  244. #define IW_SCAN_CAPA_ESSID 0x01
  245. #define IW_SCAN_CAPA_BSSID 0x02
  246. #define IW_SCAN_CAPA_CHANNEL 0x04
  247. #define IW_SCAN_CAPA_MODE 0x08
  248. #define IW_SCAN_CAPA_RATE 0x10
  249. #define IW_SCAN_CAPA_TYPE 0x20
  250. #define IW_SCAN_CAPA_TIME 0x40
  251. /* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
  252. #define IW_AUTH_INDEX 0x0FFF
  253. #define IW_AUTH_FLAGS 0xF000
  254. /* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
  255. * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
  256. * parameter that is being set/get to; value will be read/written to
  257. * struct iw_param value field)
  258. */
  259. #define IW_AUTH_WPA_VERSION 0
  260. #define IW_AUTH_CIPHER_PAIRWISE 1
  261. #define IW_AUTH_CIPHER_GROUP 2
  262. #define IW_AUTH_KEY_MGMT 3
  263. #define IW_AUTH_TKIP_COUNTERMEASURES 4
  264. #define IW_AUTH_DROP_UNENCRYPTED 5
  265. #define IW_AUTH_80211_AUTH_ALG 6
  266. #define IW_AUTH_WPA_ENABLED 7
  267. #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
  268. #define IW_AUTH_ROAMING_CONTROL 9
  269. #define IW_AUTH_PRIVACY_INVOKED 10
  270. #define IW_AUTH_CIPHER_GROUP_MGMT 11
  271. #define IW_AUTH_MFP 12
  272. /* IW_AUTH_WPA_VERSION values (bit field) */
  273. #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
  274. #define IW_AUTH_WPA_VERSION_WPA 0x00000002
  275. #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
  276. /* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
  277. #define IW_AUTH_CIPHER_NONE 0x00000001
  278. #define IW_AUTH_CIPHER_WEP40 0x00000002
  279. #define IW_AUTH_CIPHER_TKIP 0x00000004
  280. #define IW_AUTH_CIPHER_CCMP 0x00000008
  281. #define IW_AUTH_CIPHER_WEP104 0x00000010
  282. #define IW_AUTH_CIPHER_AES_CMAC 0x00000020
  283. /* IW_AUTH_KEY_MGMT values (bit field) */
  284. #define IW_AUTH_KEY_MGMT_802_1X 1
  285. #define IW_AUTH_KEY_MGMT_PSK 2
  286. /* IW_AUTH_80211_AUTH_ALG values (bit field) */
  287. #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
  288. #define IW_AUTH_ALG_SHARED_KEY 0x00000002
  289. #define IW_AUTH_ALG_LEAP 0x00000004
  290. /* IW_AUTH_ROAMING_CONTROL values */
  291. #define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
  292. #define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
  293. * control */
  294. /* SIOCSIWENCODEEXT definitions */
  295. #define IW_ENCODE_SEQ_MAX_SIZE 8
  296. /* struct iw_encode_ext ->alg */
  297. #define IW_ENCODE_ALG_NONE 0
  298. #define IW_ENCODE_ALG_WEP 1
  299. #define IW_ENCODE_ALG_TKIP 2
  300. #define IW_ENCODE_ALG_CCMP 3
  301. #define IW_ENCODE_ALG_PMK 4
  302. #define IW_ENCODE_ALG_AES_CMAC 5
  303. /************************************************************************************
  304. * Public Types
  305. ************************************************************************************/
  306. /* TODO:
  307. *
  308. * - Add types for statistics (struct iw_statistics and related)
  309. * - Add struct iw_range for use with IOCTL commands that need exchange mode data
  310. * that could not fit in iwreq.
  311. * - Private IOCTL data support (struct iw_priv_arg)
  312. * - Quality
  313. * - WPA support.
  314. * - Wireless events.
  315. * - Various flag definitions.
  316. *
  317. * These future additions will all need to be compatible with BSD/Linux definitions.
  318. */
  319. /* Generic format for most parameters that fit in a int32_t */
  320. struct iw_param
  321. {
  322. int32_t value; /* The value of the parameter itself */
  323. uint8_t fixed; /* Hardware should not use auto select */
  324. uint8_t disabled; /* Disable the feature */
  325. uint16_t flags; /* Optional flags */
  326. };
  327. /* Large data reference. For all data larger than 16 octets, we need to use a
  328. * pointer to memory allocated in user space.
  329. */
  330. struct iw_point
  331. {
  332. FAR void *pointer; /* Pointer to the data (in user space) */
  333. uint16_t length; /* number of fields or size in bytes */
  334. uint16_t flags; /* Optional flags */
  335. };
  336. /* For numbers lower than 10^9, we encode the number in 'm' and set 'e' to 0
  337. * For number greater than 10^9, we divide it by the lowest power of 10 to
  338. * get 'm' lower than 10^9, with 'm'= f / (10^'e')...
  339. * The power of 10 is in 'e', the result of the division is in 'm'.
  340. */
  341. struct iw_freq
  342. {
  343. int32_t m; /* Mantissa */
  344. int16_t e; /* Exponent */
  345. uint8_t i; /* List index (when in range struct) */
  346. uint8_t flags; /* Flags (fixed/auto) */
  347. };
  348. /* Quality of the link */
  349. struct iw_quality
  350. {
  351. uint8_t qual; /* link quality (%retries, SNR,
  352. * %missed beacons or better...) */
  353. uint8_t level; /* signal level (dBm) */
  354. uint8_t noise; /* noise level (dBm) */
  355. uint8_t updated; /* Flags to know if updated */
  356. };
  357. /* This union defines the data payload of an ioctl, and is used in struct iwreq
  358. * below.
  359. */
  360. union iwreq_data
  361. {
  362. char name[IFNAMSIZ]; /* Network interface name */
  363. struct iw_point essid; /* Extended network name */
  364. struct iw_param nwid; /* Network id (or domain - the cell) */
  365. struct iw_freq freq; /* frequency or channel :
  366. * 0-1000 = channel
  367. * > 1000 = frequency in Hz */
  368. struct iw_param sens; /* signal level threshold */
  369. struct iw_param bitrate; /* default bit rate */
  370. struct iw_param txpower; /* default transmit power */
  371. struct iw_param rts; /* RTS threshold threshold */
  372. struct iw_param frag; /* Fragmentation threshold */
  373. uint32_t mode; /* Operation mode */
  374. struct iw_param retry; /* Retry limits & lifetime */
  375. struct iw_point encoding; /* Encoding stuff : tokens */
  376. struct iw_param power; /* PM duration/timeout */
  377. struct iw_quality qual; /* Quality part of statistics */
  378. struct sockaddr ap_addr; /* Access point address */
  379. struct sockaddr addr; /* Destination address (hw/mac) */
  380. struct iw_param param; /* Other small parameters */
  381. struct iw_point data; /* Other large parameters */
  382. };
  383. /* This is the structure used to exchange data in wireless IOCTLs. This structure
  384. * is the same as 'struct ifreq', but defined for use with wireless IOCTLs.
  385. */
  386. struct iwreq
  387. {
  388. char ifr_name[IFNAMSIZ]; /* Interface name, e.g. "eth0" */
  389. union iwreq_data u; /* Data payload */
  390. };
  391. /* Range of parameters (currently only frequencies) */
  392. struct iw_range
  393. {
  394. uint8_t num_frequency; /* Number of frequencies in the freq[] list */
  395. struct iw_freq freq[IW_MAX_FREQUENCIES];
  396. };
  397. /* A Wireless Event. */
  398. struct iw_event
  399. {
  400. uint16_t len; /* Real length of ata */
  401. uint16_t cmd; /* Wireless IOCTL command*/
  402. union iwreq_data u; /* Fixed IOCTL payload */
  403. };
  404. /* WPA support */
  405. struct iw_encode_ext
  406. {
  407. uint32_t ext_flags; /* IW_ENCODE_EXT_* */
  408. uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
  409. uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
  410. struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
  411. * (group) keys or unicast address for
  412. * individual keys */
  413. uint16_t alg; /* IW_ENCODE_ALG_* */
  414. uint16_t key_len;
  415. uint8_t key[0];
  416. };
  417. /* Optional data for scan request
  418. *
  419. * Note: these optional parameters are controlling parameters for the
  420. * scanning behavior, these do not apply to getting scan results
  421. * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
  422. * provide a merged results with all BSSes even if the previous scan
  423. * request limited scanning to a subset, e.g., by specifying an SSID.
  424. * Especially, scan results are required to include an entry for the
  425. * current BSS if the driver is in Managed mode and associated with an AP.
  426. */
  427. struct iw_scan_req
  428. {
  429. uint8_t scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
  430. uint8_t essid_len;
  431. uint8_t num_channels; /* num entries in channel_list;
  432. * 0 = scan all allowed channels */
  433. uint8_t flags; /* reserved as padding; use zero, this may
  434. * be used in the future for adding flags
  435. * to request different scan behavior */
  436. struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
  437. * individual address of a specific BSS */
  438. /* Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
  439. * the current ESSID. This allows scan requests for specific ESSID
  440. * without having to change the current ESSID and potentially breaking
  441. * the current association.
  442. */
  443. uint8_t essid[IW_ESSID_MAX_SIZE];
  444. /* Optional parameters for changing the default scanning behavior.
  445. * These are based on the MLME-SCAN.request from IEEE Std 802.11.
  446. * TU is 1.024 ms. If these are set to 0, driver is expected to use
  447. * reasonable default values. min_channel_time defines the time that
  448. * will be used to wait for the first reply on each channel. If no
  449. * replies are received, next channel will be scanned after this. If
  450. * replies are received, total time waited on the channel is defined by
  451. * max_channel_time.
  452. */
  453. uint32_t min_channel_time; /* in TU */
  454. uint32_t max_channel_time; /* in TU */
  455. struct iw_freq channel_list[IW_MAX_FREQUENCIES];
  456. };
  457. #endif /* __INCLUDE_NUTTX_WIRELESS_WIRELESS_H */