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