iwinfo.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. #ifndef __IWINFO_H_
  2. #define __IWINFO_H_
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/wait.h>
  6. #include <unistd.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <fcntl.h>
  11. #include <glob.h>
  12. #include <ctype.h>
  13. #include <dirent.h>
  14. #include <stdint.h>
  15. #include <sys/ioctl.h>
  16. #include <sys/mman.h>
  17. #include <net/if.h>
  18. #include <errno.h>
  19. #define IWINFO_BUFSIZE 24 * 1024
  20. #define IWINFO_ESSID_MAX_SIZE 32
  21. #define IWINFO_80211_A (1 << 0)
  22. #define IWINFO_80211_B (1 << 1)
  23. #define IWINFO_80211_G (1 << 2)
  24. #define IWINFO_80211_N (1 << 3)
  25. #define IWINFO_80211_AC (1 << 4)
  26. #define IWINFO_CIPHER_NONE (1 << 0)
  27. #define IWINFO_CIPHER_WEP40 (1 << 1)
  28. #define IWINFO_CIPHER_TKIP (1 << 2)
  29. #define IWINFO_CIPHER_WRAP (1 << 3)
  30. #define IWINFO_CIPHER_CCMP (1 << 4)
  31. #define IWINFO_CIPHER_WEP104 (1 << 5)
  32. #define IWINFO_CIPHER_AESOCB (1 << 6)
  33. #define IWINFO_CIPHER_CKIP (1 << 7)
  34. #define IWINFO_CIPHER_COUNT 8
  35. #define IWINFO_KMGMT_NONE (1 << 0)
  36. #define IWINFO_KMGMT_8021x (1 << 1)
  37. #define IWINFO_KMGMT_PSK (1 << 2)
  38. #define IWINFO_KMGMT_COUNT 3
  39. #define IWINFO_AUTH_OPEN (1 << 0)
  40. #define IWINFO_AUTH_SHARED (1 << 1)
  41. #define IWINFO_AUTH_COUNT 2
  42. #define IWINFO_FREQ_NO_10MHZ (1 << 0)
  43. #define IWINFO_FREQ_NO_20MHZ (1 << 1)
  44. #define IWINFO_FREQ_NO_HT40PLUS (1 << 2)
  45. #define IWINFO_FREQ_NO_HT40MINUS (1 << 3)
  46. #define IWINFO_FREQ_NO_80MHZ (1 << 4)
  47. #define IWINFO_FREQ_NO_160MHZ (1 << 5)
  48. extern const char *IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT];
  49. extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT];
  50. extern const char *IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT];
  51. enum iwinfo_opmode {
  52. IWINFO_OPMODE_UNKNOWN = 0,
  53. IWINFO_OPMODE_MASTER = 1,
  54. IWINFO_OPMODE_ADHOC = 2,
  55. IWINFO_OPMODE_CLIENT = 3,
  56. IWINFO_OPMODE_MONITOR = 4,
  57. IWINFO_OPMODE_AP_VLAN = 5,
  58. IWINFO_OPMODE_WDS = 6,
  59. IWINFO_OPMODE_MESHPOINT = 7,
  60. IWINFO_OPMODE_P2P_CLIENT = 8,
  61. IWINFO_OPMODE_P2P_GO = 9,
  62. };
  63. extern const char *IWINFO_OPMODE_NAMES[];
  64. enum iwinfo_htmode {
  65. IWINFO_HTMODE_HT20 = (1 << 0),
  66. IWINFO_HTMODE_HT40 = (1 << 1),
  67. IWINFO_HTMODE_VHT20 = (1 << 2),
  68. IWINFO_HTMODE_VHT40 = (1 << 3),
  69. IWINFO_HTMODE_VHT80 = (1 << 4),
  70. IWINFO_HTMODE_VHT80_80 = (1 << 5),
  71. IWINFO_HTMODE_VHT160 = (1 << 6),
  72. IWINFO_HTMODE_COUNT = 7
  73. };
  74. extern const char *IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT];
  75. struct iwinfo_rate_entry {
  76. uint32_t rate;
  77. int8_t mcs;
  78. uint8_t is_40mhz:1;
  79. uint8_t is_short_gi:1;
  80. uint8_t is_ht:1;
  81. uint8_t is_vht:1;
  82. uint8_t mhz;
  83. uint8_t nss;
  84. };
  85. struct iwinfo_assoclist_entry {
  86. uint8_t mac[6];
  87. int8_t signal;
  88. int8_t noise;
  89. uint32_t inactive;
  90. uint32_t rx_packets;
  91. uint32_t tx_packets;
  92. struct iwinfo_rate_entry rx_rate;
  93. struct iwinfo_rate_entry tx_rate;
  94. uint32_t rx_bytes;
  95. uint32_t tx_bytes;
  96. uint32_t tx_retries;
  97. uint32_t tx_failed;
  98. uint64_t t_offset;
  99. uint8_t is_authorized:1;
  100. uint8_t is_authenticated:1;
  101. uint8_t is_preamble_short:1;
  102. uint8_t is_wme:1;
  103. uint8_t is_mfp:1;
  104. uint8_t is_tdls:1;
  105. uint32_t thr;
  106. };
  107. struct iwinfo_txpwrlist_entry {
  108. uint8_t dbm;
  109. uint16_t mw;
  110. };
  111. struct iwinfo_freqlist_entry {
  112. uint8_t channel;
  113. uint32_t mhz;
  114. uint8_t restricted;
  115. uint32_t flags;
  116. };
  117. struct iwinfo_crypto_entry {
  118. uint8_t enabled;
  119. uint8_t wpa_version;
  120. uint8_t group_ciphers;
  121. uint8_t pair_ciphers;
  122. uint8_t auth_suites;
  123. uint8_t auth_algs;
  124. };
  125. struct iwinfo_scanlist_entry {
  126. uint8_t mac[6];
  127. char ssid[IWINFO_ESSID_MAX_SIZE+1];
  128. enum iwinfo_opmode mode;
  129. uint8_t channel;
  130. uint8_t signal;
  131. uint8_t quality;
  132. uint8_t quality_max;
  133. struct iwinfo_crypto_entry crypto;
  134. };
  135. struct iwinfo_country_entry {
  136. uint16_t iso3166;
  137. char ccode[4];
  138. };
  139. struct iwinfo_iso3166_label {
  140. uint16_t iso3166;
  141. char name[28];
  142. };
  143. struct iwinfo_hardware_id {
  144. uint16_t vendor_id;
  145. uint16_t device_id;
  146. uint16_t subsystem_vendor_id;
  147. uint16_t subsystem_device_id;
  148. };
  149. struct iwinfo_hardware_entry {
  150. char vendor_name[64];
  151. char device_name[64];
  152. uint16_t vendor_id;
  153. uint16_t device_id;
  154. uint16_t subsystem_vendor_id;
  155. uint16_t subsystem_device_id;
  156. int16_t txpower_offset;
  157. int16_t frequency_offset;
  158. };
  159. extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
  160. #define IWINFO_HARDWARE_FILE "/usr/share/libiwinfo/hardware.txt"
  161. struct iwinfo_ops {
  162. const char *name;
  163. int (*probe)(const char *ifname);
  164. int (*mode)(const char *, int *);
  165. int (*channel)(const char *, int *);
  166. int (*frequency)(const char *, int *);
  167. int (*frequency_offset)(const char *, int *);
  168. int (*txpower)(const char *, int *);
  169. int (*txpower_offset)(const char *, int *);
  170. int (*bitrate)(const char *, int *);
  171. int (*signal)(const char *, int *);
  172. int (*noise)(const char *, int *);
  173. int (*quality)(const char *, int *);
  174. int (*quality_max)(const char *, int *);
  175. int (*mbssid_support)(const char *, int *);
  176. int (*hwmodelist)(const char *, int *);
  177. int (*htmodelist)(const char *, int *);
  178. int (*ssid)(const char *, char *);
  179. int (*bssid)(const char *, char *);
  180. int (*country)(const char *, char *);
  181. int (*hardware_id)(const char *, char *);
  182. int (*hardware_name)(const char *, char *);
  183. int (*encryption)(const char *, char *);
  184. int (*phyname)(const char *, char *);
  185. int (*assoclist)(const char *, char *, int *);
  186. int (*txpwrlist)(const char *, char *, int *);
  187. int (*scanlist)(const char *, char *, int *);
  188. int (*freqlist)(const char *, char *, int *);
  189. int (*countrylist)(const char *, char *, int *);
  190. int (*lookup_phy)(const char *, char *);
  191. void (*close)(void);
  192. };
  193. const char * iwinfo_type(const char *ifname);
  194. const struct iwinfo_ops * iwinfo_backend(const char *ifname);
  195. const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
  196. void iwinfo_finish(void);
  197. extern const struct iwinfo_ops wext_ops;
  198. extern const struct iwinfo_ops madwifi_ops;
  199. extern const struct iwinfo_ops nl80211_ops;
  200. extern const struct iwinfo_ops wl_ops;
  201. #include "iwinfo/utils.h"
  202. #endif