iwinfo.h 5.0 KB

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