iwinfo.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. extern const char *IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT];
  43. extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT];
  44. extern const char *IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT];
  45. enum iwinfo_opmode {
  46. IWINFO_OPMODE_UNKNOWN = 0,
  47. IWINFO_OPMODE_MASTER = 1,
  48. IWINFO_OPMODE_ADHOC = 2,
  49. IWINFO_OPMODE_CLIENT = 3,
  50. IWINFO_OPMODE_MONITOR = 4,
  51. IWINFO_OPMODE_AP_VLAN = 5,
  52. IWINFO_OPMODE_WDS = 6,
  53. IWINFO_OPMODE_MESHPOINT = 7,
  54. IWINFO_OPMODE_P2P_CLIENT = 8,
  55. IWINFO_OPMODE_P2P_GO = 9,
  56. };
  57. extern const char *IWINFO_OPMODE_NAMES[];
  58. enum iwinfo_htmode {
  59. IWINFO_HTMODE_HT20 = (1 << 0),
  60. IWINFO_HTMODE_HT40 = (1 << 1),
  61. IWINFO_HTMODE_VHT20 = (1 << 2),
  62. IWINFO_HTMODE_VHT40 = (1 << 3),
  63. IWINFO_HTMODE_VHT80 = (1 << 4),
  64. IWINFO_HTMODE_VHT80_80 = (1 << 5),
  65. IWINFO_HTMODE_VHT160 = (1 << 6),
  66. IWINFO_HTMODE_COUNT = 7
  67. };
  68. extern const char *IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT];
  69. struct iwinfo_rate_entry {
  70. uint32_t rate;
  71. int8_t mcs;
  72. uint8_t is_40mhz:1;
  73. uint8_t is_short_gi:1;
  74. uint8_t is_ht:1;
  75. uint8_t is_vht:1;
  76. uint8_t mhz;
  77. uint8_t nss;
  78. };
  79. struct iwinfo_assoclist_entry {
  80. uint8_t mac[6];
  81. int8_t signal;
  82. int8_t noise;
  83. uint32_t inactive;
  84. uint32_t rx_packets;
  85. uint32_t tx_packets;
  86. struct iwinfo_rate_entry rx_rate;
  87. struct iwinfo_rate_entry tx_rate;
  88. uint32_t rx_bytes;
  89. uint32_t tx_bytes;
  90. uint32_t tx_retries;
  91. uint32_t tx_failed;
  92. uint64_t t_offset;
  93. uint8_t is_authorized:1;
  94. uint8_t is_authenticated:1;
  95. uint8_t is_preamble_short:1;
  96. uint8_t is_wme:1;
  97. uint8_t is_mfp:1;
  98. uint8_t is_tdls:1;
  99. };
  100. struct iwinfo_txpwrlist_entry {
  101. uint8_t dbm;
  102. uint16_t mw;
  103. };
  104. struct iwinfo_freqlist_entry {
  105. uint8_t channel;
  106. uint32_t mhz;
  107. uint8_t restricted;
  108. };
  109. struct iwinfo_crypto_entry {
  110. uint8_t enabled;
  111. uint8_t wpa_version;
  112. uint8_t group_ciphers;
  113. uint8_t pair_ciphers;
  114. uint8_t auth_suites;
  115. uint8_t auth_algs;
  116. };
  117. struct iwinfo_scanlist_entry {
  118. uint8_t mac[6];
  119. char ssid[IWINFO_ESSID_MAX_SIZE+1];
  120. enum iwinfo_opmode mode;
  121. uint8_t channel;
  122. uint8_t signal;
  123. uint8_t quality;
  124. uint8_t quality_max;
  125. struct iwinfo_crypto_entry crypto;
  126. };
  127. struct iwinfo_country_entry {
  128. uint16_t iso3166;
  129. char ccode[4];
  130. };
  131. struct iwinfo_iso3166_label {
  132. uint16_t iso3166;
  133. char name[28];
  134. };
  135. struct iwinfo_hardware_id {
  136. uint16_t vendor_id;
  137. uint16_t device_id;
  138. uint16_t subsystem_vendor_id;
  139. uint16_t subsystem_device_id;
  140. };
  141. struct iwinfo_hardware_entry {
  142. char vendor_name[64];
  143. char device_name[64];
  144. uint16_t vendor_id;
  145. uint16_t device_id;
  146. uint16_t subsystem_vendor_id;
  147. uint16_t subsystem_device_id;
  148. int16_t txpower_offset;
  149. int16_t frequency_offset;
  150. };
  151. extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
  152. #define IWINFO_HARDWARE_FILE "/usr/share/libiwinfo/hardware.txt"
  153. struct iwinfo_ops {
  154. const char *name;
  155. int (*probe)(const char *ifname);
  156. int (*mode)(const char *, int *);
  157. int (*channel)(const char *, int *);
  158. int (*frequency)(const char *, int *);
  159. int (*frequency_offset)(const char *, int *);
  160. int (*txpower)(const char *, int *);
  161. int (*txpower_offset)(const char *, int *);
  162. int (*bitrate)(const char *, int *);
  163. int (*signal)(const char *, int *);
  164. int (*noise)(const char *, int *);
  165. int (*quality)(const char *, int *);
  166. int (*quality_max)(const char *, int *);
  167. int (*mbssid_support)(const char *, int *);
  168. int (*hwmodelist)(const char *, int *);
  169. int (*htmodelist)(const char *, int *);
  170. int (*ssid)(const char *, char *);
  171. int (*bssid)(const char *, char *);
  172. int (*country)(const char *, char *);
  173. int (*hardware_id)(const char *, char *);
  174. int (*hardware_name)(const char *, char *);
  175. int (*encryption)(const char *, char *);
  176. int (*phyname)(const char *, char *);
  177. int (*assoclist)(const char *, char *, int *);
  178. int (*txpwrlist)(const char *, char *, int *);
  179. int (*scanlist)(const char *, char *, int *);
  180. int (*freqlist)(const char *, char *, int *);
  181. int (*countrylist)(const char *, char *, int *);
  182. int (*lookup_phy)(const char *, char *);
  183. void (*close)(void);
  184. };
  185. const char * iwinfo_type(const char *ifname);
  186. const struct iwinfo_ops * iwinfo_backend(const char *ifname);
  187. const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
  188. void iwinfo_finish(void);
  189. extern const struct iwinfo_ops wext_ops;
  190. extern const struct iwinfo_ops madwifi_ops;
  191. extern const struct iwinfo_ops nl80211_ops;
  192. extern const struct iwinfo_ops wl_ops;
  193. #include "iwinfo/utils.h"
  194. #endif