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