1 #ifndef __IWINFO_H_ 2 #define __IWINFO_H_ 3 4 #include <sys/types.h> 5 #include <sys/stat.h> 6 #include <sys/wait.h> 7 #include <unistd.h> 8 #include <stdio.h> 9 #include <stdlib.h> 10 #include <string.h> 11 #include <fcntl.h> 12 #include <glob.h> 13 #include <ctype.h> 14 #include <dirent.h> 15 #include <stdint.h> 16 17 #include <sys/ioctl.h> 18 #include <sys/mman.h> 19 #include <net/if.h> 20 #include <errno.h> 21 22 23 #define IWINFO_BUFSIZE 24 * 1024 24 #define IWINFO_ESSID_MAX_SIZE 32 25 26 enum iwinfo_80211 { 27 IWINFO_80211_A = 0, 28 IWINFO_80211_B, 29 IWINFO_80211_G, 30 IWINFO_80211_N, 31 IWINFO_80211_AC, 32 IWINFO_80211_AD, 33 IWINFO_80211_AX, 34 35 /* keep last */ 36 IWINFO_80211_COUNT 37 }; 38 39 #define IWINFO_80211_A (1 << IWINFO_80211_A) 40 #define IWINFO_80211_B (1 << IWINFO_80211_B) 41 #define IWINFO_80211_G (1 << IWINFO_80211_G) 42 #define IWINFO_80211_N (1 << IWINFO_80211_N) 43 #define IWINFO_80211_AC (1 << IWINFO_80211_AC) 44 #define IWINFO_80211_AD (1 << IWINFO_80211_AD) 45 #define IWINFO_80211_AX (1 << IWINFO_80211_AX) 46 47 extern const char * const IWINFO_80211_NAMES[IWINFO_80211_COUNT]; 48 49 50 enum iwinfo_band { 51 IWINFO_BAND_24 = 0, 52 IWINFO_BAND_5, 53 IWINFO_BAND_6, 54 IWINFO_BAND_60, 55 56 /* keep last */ 57 IWINFO_BAND_COUNT 58 }; 59 60 #define IWINFO_BAND_24 (1 << IWINFO_BAND_24) 61 #define IWINFO_BAND_5 (1 << IWINFO_BAND_5) 62 #define IWINFO_BAND_6 (1 << IWINFO_BAND_6) 63 #define IWINFO_BAND_60 (1 << IWINFO_BAND_60) 64 65 extern const char * const IWINFO_BAND_NAMES[IWINFO_BAND_COUNT]; 66 67 68 enum iwinfo_cipher { 69 IWINFO_CIPHER_NONE = 0, 70 IWINFO_CIPHER_WEP40, 71 IWINFO_CIPHER_TKIP, 72 IWINFO_CIPHER_WRAP, 73 IWINFO_CIPHER_CCMP, 74 IWINFO_CIPHER_WEP104, 75 IWINFO_CIPHER_AESOCB, 76 IWINFO_CIPHER_CKIP, 77 IWINFO_CIPHER_GCMP, 78 IWINFO_CIPHER_CCMP256, 79 IWINFO_CIPHER_GCMP256, 80 81 /* keep last */ 82 IWINFO_CIPHER_COUNT 83 }; 84 85 #define IWINFO_CIPHER_NONE (1 << IWINFO_CIPHER_NONE) 86 #define IWINFO_CIPHER_WEP40 (1 << IWINFO_CIPHER_WEP40) 87 #define IWINFO_CIPHER_TKIP (1 << IWINFO_CIPHER_TKIP) 88 #define IWINFO_CIPHER_WRAP (1 << IWINFO_CIPHER_WRAP) 89 #define IWINFO_CIPHER_CCMP (1 << IWINFO_CIPHER_CCMP) 90 #define IWINFO_CIPHER_WEP104 (1 << IWINFO_CIPHER_WEP104) 91 #define IWINFO_CIPHER_AESOCB (1 << IWINFO_CIPHER_AESOCB) 92 #define IWINFO_CIPHER_CKIP (1 << IWINFO_CIPHER_CKIP) 93 #define IWINFO_CIPHER_GCMP (1 << IWINFO_CIPHER_GCMP) 94 #define IWINFO_CIPHER_CCMP256 (1 << IWINFO_CIPHER_CCMP256) 95 #define IWINFO_CIPHER_GCMP256 (1 << IWINFO_CIPHER_GCMP256) 96 97 extern const char * const IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT]; 98 99 100 enum iwinfo_kmgmt { 101 IWINFO_KMGMT_NONE = 0, 102 IWINFO_KMGMT_8021x, 103 IWINFO_KMGMT_PSK, 104 IWINFO_KMGMT_SAE, 105 IWINFO_KMGMT_OWE, 106 107 /* keep last */ 108 IWINFO_KMGMT_COUNT 109 }; 110 111 #define IWINFO_KMGMT_NONE (1 << IWINFO_KMGMT_NONE) 112 #define IWINFO_KMGMT_8021x (1 << IWINFO_KMGMT_8021x) 113 #define IWINFO_KMGMT_PSK (1 << IWINFO_KMGMT_PSK) 114 #define IWINFO_KMGMT_SAE (1 << IWINFO_KMGMT_SAE) 115 #define IWINFO_KMGMT_OWE (1 << IWINFO_KMGMT_OWE) 116 117 extern const char * const IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT]; 118 119 120 enum iwinfo_auth { 121 IWINFO_AUTH_OPEN = 0, 122 IWINFO_AUTH_SHARED, 123 124 /* keep last */ 125 IWINFO_AUTH_COUNT 126 }; 127 128 #define IWINFO_AUTH_OPEN (1 << IWINFO_AUTH_OPEN) 129 #define IWINFO_AUTH_SHARED (1 << IWINFO_AUTH_SHARED) 130 131 extern const char * const IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT]; 132 133 134 enum iwinfo_freq_flag { 135 IWINFO_FREQ_NO_10MHZ = 0, 136 IWINFO_FREQ_NO_20MHZ, 137 IWINFO_FREQ_NO_HT40PLUS, 138 IWINFO_FREQ_NO_HT40MINUS, 139 IWINFO_FREQ_NO_80MHZ, 140 IWINFO_FREQ_NO_160MHZ, 141 IWINFO_FREQ_NO_HE, 142 IWINFO_FREQ_NO_IR, 143 IWINFO_FREQ_INDOOR_ONLY, 144 145 /* keep last */ 146 IWINFO_FREQ_FLAG_COUNT, 147 }; 148 149 #define IWINFO_FREQ_NO_10MHZ (1 << IWINFO_FREQ_NO_10MHZ) 150 #define IWINFO_FREQ_NO_20MHZ (1 << IWINFO_FREQ_NO_20MHZ) 151 #define IWINFO_FREQ_NO_HT40PLUS (1 << IWINFO_FREQ_NO_HT40PLUS) 152 #define IWINFO_FREQ_NO_HT40MINUS (1 << IWINFO_FREQ_NO_HT40MINUS) 153 #define IWINFO_FREQ_NO_80MHZ (1 << IWINFO_FREQ_NO_80MHZ) 154 #define IWINFO_FREQ_NO_160MHZ (1 << IWINFO_FREQ_NO_160MHZ) 155 #define IWINFO_FREQ_NO_HE (1 << IWINFO_FREQ_NO_HE) 156 #define IWINFO_FREQ_NO_IR (1 << IWINFO_FREQ_NO_IR) 157 #define IWINFO_FREQ_INDOOR_ONLY (1 << IWINFO_FREQ_INDOOR_ONLY) 158 159 extern const char * const IWINFO_FREQ_FLAG_NAMES[IWINFO_FREQ_FLAG_COUNT]; 160 161 162 enum iwinfo_opmode { 163 IWINFO_OPMODE_UNKNOWN = 0, 164 IWINFO_OPMODE_MASTER, 165 IWINFO_OPMODE_ADHOC, 166 IWINFO_OPMODE_CLIENT, 167 IWINFO_OPMODE_MONITOR, 168 IWINFO_OPMODE_AP_VLAN, 169 IWINFO_OPMODE_WDS, 170 IWINFO_OPMODE_MESHPOINT, 171 IWINFO_OPMODE_P2P_CLIENT, 172 IWINFO_OPMODE_P2P_GO, 173 174 /* keep last */ 175 IWINFO_OPMODE_COUNT 176 }; 177 178 extern const char * const IWINFO_OPMODE_NAMES[IWINFO_OPMODE_COUNT]; 179 180 181 enum iwinfo_htmode { 182 IWINFO_HTMODE_HT20 = 0, 183 IWINFO_HTMODE_HT40, 184 IWINFO_HTMODE_VHT20, 185 IWINFO_HTMODE_VHT40, 186 IWINFO_HTMODE_VHT80, 187 IWINFO_HTMODE_VHT80_80, 188 IWINFO_HTMODE_VHT160, 189 IWINFO_HTMODE_NOHT, 190 IWINFO_HTMODE_HE20, 191 IWINFO_HTMODE_HE40, 192 IWINFO_HTMODE_HE80, 193 IWINFO_HTMODE_HE80_80, 194 IWINFO_HTMODE_HE160, 195 196 /* keep last */ 197 IWINFO_HTMODE_COUNT 198 }; 199 200 #define IWINFO_HTMODE_HT20 (1 << IWINFO_HTMODE_HT20) 201 #define IWINFO_HTMODE_HT40 (1 << IWINFO_HTMODE_HT40) 202 #define IWINFO_HTMODE_VHT20 (1 << IWINFO_HTMODE_VHT20) 203 #define IWINFO_HTMODE_VHT40 (1 << IWINFO_HTMODE_VHT40) 204 #define IWINFO_HTMODE_VHT80 (1 << IWINFO_HTMODE_VHT80) 205 #define IWINFO_HTMODE_VHT80_80 (1 << IWINFO_HTMODE_VHT80_80) 206 #define IWINFO_HTMODE_VHT160 (1 << IWINFO_HTMODE_VHT160) 207 #define IWINFO_HTMODE_NOHT (1 << IWINFO_HTMODE_NOHT) 208 #define IWINFO_HTMODE_HE20 (1 << IWINFO_HTMODE_HE20) 209 #define IWINFO_HTMODE_HE40 (1 << IWINFO_HTMODE_HE40) 210 #define IWINFO_HTMODE_HE80 (1 << IWINFO_HTMODE_HE80) 211 #define IWINFO_HTMODE_HE80_80 (1 << IWINFO_HTMODE_HE80_80) 212 #define IWINFO_HTMODE_HE160 (1 << IWINFO_HTMODE_HE160) 213 214 extern const char * const IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT]; 215 216 217 struct iwinfo_rate_entry { 218 uint32_t rate; 219 int8_t mcs; 220 uint8_t is_40mhz:1; 221 uint8_t is_short_gi:1; 222 uint8_t is_ht:1; 223 uint8_t is_vht:1; 224 uint8_t is_he:1; 225 uint8_t he_gi; 226 uint8_t he_dcm; 227 uint8_t mhz; 228 uint8_t nss; 229 }; 230 231 struct iwinfo_assoclist_entry { 232 uint8_t mac[6]; 233 int8_t signal; 234 int8_t signal_avg; 235 int8_t noise; 236 uint32_t inactive; 237 uint32_t connected_time; 238 uint32_t rx_packets; 239 uint32_t tx_packets; 240 uint64_t rx_drop_misc; 241 struct iwinfo_rate_entry rx_rate; 242 struct iwinfo_rate_entry tx_rate; 243 uint32_t rx_bytes; 244 uint32_t tx_bytes; 245 uint32_t tx_retries; 246 uint32_t tx_failed; 247 uint64_t t_offset; 248 uint8_t is_authorized:1; 249 uint8_t is_authenticated:1; 250 uint8_t is_preamble_short:1; 251 uint8_t is_wme:1; 252 uint8_t is_mfp:1; 253 uint8_t is_tdls:1; 254 uint32_t thr; 255 uint16_t llid; 256 uint16_t plid; 257 char plink_state[16]; 258 char local_ps[16]; 259 char peer_ps[16]; 260 char nonpeer_ps[16]; 261 }; 262 263 struct iwinfo_survey_entry { 264 uint64_t active_time; 265 uint64_t busy_time; 266 uint64_t busy_time_ext; 267 uint64_t rxtime; 268 uint64_t txtime; 269 uint32_t mhz; 270 uint8_t noise; 271 }; 272 273 struct iwinfo_txpwrlist_entry { 274 uint8_t dbm; 275 uint16_t mw; 276 }; 277 278 struct iwinfo_freqlist_entry { 279 uint8_t band; 280 uint8_t channel; 281 uint32_t mhz; 282 uint8_t restricted; 283 uint32_t flags; 284 }; 285 286 struct iwinfo_crypto_entry { 287 uint8_t enabled; 288 uint8_t wpa_version; 289 uint16_t group_ciphers; 290 uint16_t pair_ciphers; 291 uint8_t auth_suites; 292 uint8_t auth_algs; 293 }; 294 295 struct iwinfo_scanlist_ht_chan_entry { 296 uint8_t primary_chan; 297 uint8_t secondary_chan_off; 298 uint8_t chan_width; 299 }; 300 301 struct iwinfo_scanlist_vht_chan_entry { 302 uint8_t chan_width; 303 uint8_t center_chan_1; 304 uint8_t center_chan_2; 305 }; 306 307 extern const char * const ht_secondary_offset[4]; 308 /* 0 = 20 MHz 309 1 = 40 MHz or higher (refer to vht if supported) */ 310 extern const uint16_t ht_chan_width[2]; 311 /* 0 = 40 MHz or lower (refer to ht to a more precise width) 312 1 = 80 MHz 313 2 = 160 MHz 314 3 = 80+80 MHz */ 315 extern const uint16_t vht_chan_width[4]; 316 317 struct iwinfo_scanlist_entry { 318 uint8_t mac[6]; 319 char ssid[IWINFO_ESSID_MAX_SIZE+1]; 320 enum iwinfo_opmode mode; 321 uint8_t band; 322 uint8_t channel; 323 uint32_t mhz; 324 uint8_t signal; 325 uint8_t quality; 326 uint8_t quality_max; 327 struct iwinfo_crypto_entry crypto; 328 struct iwinfo_scanlist_ht_chan_entry ht_chan_info; 329 struct iwinfo_scanlist_vht_chan_entry vht_chan_info; 330 }; 331 332 struct iwinfo_country_entry { 333 uint16_t iso3166; 334 char ccode[4]; 335 }; 336 337 struct iwinfo_iso3166_label { 338 uint16_t iso3166; 339 const char name[28]; 340 }; 341 342 struct iwinfo_hardware_id { 343 uint16_t vendor_id; 344 uint16_t device_id; 345 uint16_t subsystem_vendor_id; 346 uint16_t subsystem_device_id; 347 char compatible[128]; 348 }; 349 350 struct iwinfo_hardware_entry { 351 char vendor_name[64]; 352 char device_name[64]; 353 uint16_t vendor_id; 354 uint16_t device_id; 355 uint16_t subsystem_vendor_id; 356 uint16_t subsystem_device_id; 357 int16_t txpower_offset; 358 int16_t frequency_offset; 359 char compatible[128]; 360 }; 361 362 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[]; 363 364 #define IWINFO_HARDWARE_FILE "/usr/share/libiwinfo/devices.txt" 365 366 367 struct iwinfo_ops { 368 const char *name; 369 370 int (*probe)(const char *ifname); 371 int (*mode)(const char *, int *); 372 int (*channel)(const char *, int *); 373 int (*center_chan1)(const char *, int *); 374 int (*center_chan2)(const char *, int *); 375 int (*frequency)(const char *, int *); 376 int (*frequency_offset)(const char *, int *); 377 int (*txpower)(const char *, int *); 378 int (*txpower_offset)(const char *, int *); 379 int (*bitrate)(const char *, int *); 380 int (*signal)(const char *, int *); 381 int (*noise)(const char *, int *); 382 int (*quality)(const char *, int *); 383 int (*quality_max)(const char *, int *); 384 int (*mbssid_support)(const char *, int *); 385 int (*hwmodelist)(const char *, int *); 386 int (*htmodelist)(const char *, int *); 387 int (*htmode)(const char *, int *); 388 int (*ssid)(const char *, char *); 389 int (*bssid)(const char *, char *); 390 int (*country)(const char *, char *); 391 int (*hardware_id)(const char *, char *); 392 int (*hardware_name)(const char *, char *); 393 int (*encryption)(const char *, char *); 394 int (*phyname)(const char *, char *); 395 int (*assoclist)(const char *, char *, int *); 396 int (*txpwrlist)(const char *, char *, int *); 397 int (*scanlist)(const char *, char *, int *); 398 int (*freqlist)(const char *, char *, int *); 399 int (*countrylist)(const char *, char *, int *); 400 int (*survey)(const char *, char *, int *); 401 int (*lookup_phy)(const char *, char *); 402 int (*phy_path)(const char *phyname, const char **path); 403 void (*close)(void); 404 }; 405 406 const char * iwinfo_type(const char *ifname); 407 const struct iwinfo_ops * iwinfo_backend(const char *ifname); 408 const struct iwinfo_ops * iwinfo_backend_by_name(const char *name); 409 void iwinfo_finish(void); 410 411 extern const struct iwinfo_ops wext_ops; 412 extern const struct iwinfo_ops madwifi_ops; 413 extern const struct iwinfo_ops nl80211_ops; 414 extern const struct iwinfo_ops wl_ops; 415 416 #include "iwinfo/utils.h" 417 418 #endif 419
This page was automatically generated by LXR 0.3.1. • OpenWrt