iwinfo: assign explicit length to IWINFO_*_NAMES[] to fix compile issues
[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 };
93
94 struct iwinfo_assoclist_entry {
95         uint8_t mac[6];
96         int8_t signal;
97         int8_t noise;
98         uint32_t inactive;
99         uint32_t rx_packets;
100         uint32_t tx_packets;
101         struct iwinfo_rate_entry rx_rate;
102         struct iwinfo_rate_entry tx_rate;
103         uint32_t rx_bytes;
104         uint32_t tx_bytes;
105         uint32_t tx_retries;
106         uint32_t tx_failed;
107         uint64_t t_offset;
108         uint8_t is_authorized:1;
109         uint8_t is_authenticated:1;
110         uint8_t is_preamble_short:1;
111         uint8_t is_wme:1;
112         uint8_t is_mfp:1;
113         uint8_t is_tdls:1;
114 };
115
116 struct iwinfo_txpwrlist_entry {
117         uint8_t  dbm;
118         uint16_t mw;
119 };
120
121 struct iwinfo_freqlist_entry {
122         uint8_t channel;
123         uint32_t mhz;
124         uint8_t restricted;
125 };
126
127 struct iwinfo_crypto_entry {
128         uint8_t enabled;
129         uint8_t wpa_version;
130         uint8_t group_ciphers;
131         uint8_t pair_ciphers;
132         uint8_t auth_suites;
133         uint8_t auth_algs;
134 };
135
136 struct iwinfo_scanlist_entry {
137         uint8_t mac[6];
138         char ssid[IWINFO_ESSID_MAX_SIZE+1];
139         enum iwinfo_opmode mode;
140         uint8_t channel;
141         uint8_t signal;
142         uint8_t quality;
143         uint8_t quality_max;
144         struct iwinfo_crypto_entry crypto;
145 };
146
147 struct iwinfo_country_entry {
148         uint16_t iso3166;
149         char ccode[4];
150 };
151
152 struct iwinfo_iso3166_label {
153         uint16_t iso3166;
154         char name[28];
155 };
156
157 struct iwinfo_hardware_id {
158         uint16_t vendor_id;
159         uint16_t device_id;
160         uint16_t subsystem_vendor_id;
161         uint16_t subsystem_device_id;
162 };
163
164 struct iwinfo_hardware_entry {
165         char vendor_name[64];
166         char device_name[64];
167         uint16_t vendor_id;
168         uint16_t device_id;
169         uint16_t subsystem_vendor_id;
170         uint16_t subsystem_device_id;
171         int16_t txpower_offset;
172         int16_t frequency_offset;
173 };
174
175 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
176
177 #define IWINFO_HARDWARE_FILE    "/usr/share/libiwinfo/hardware.txt"
178
179
180 struct iwinfo_ops {
181         const char *name;
182
183         int (*probe)(const char *ifname);
184         int (*mode)(const char *, int *);
185         int (*channel)(const char *, int *);
186         int (*frequency)(const char *, int *);
187         int (*frequency_offset)(const char *, int *);
188         int (*txpower)(const char *, int *);
189         int (*txpower_offset)(const char *, int *);
190         int (*bitrate)(const char *, int *);
191         int (*signal)(const char *, int *);
192         int (*noise)(const char *, int *);
193         int (*quality)(const char *, int *);
194         int (*quality_max)(const char *, int *);
195         int (*mbssid_support)(const char *, int *);
196         int (*hwmodelist)(const char *, int *);
197         int (*htmodelist)(const char *, int *);
198         int (*ssid)(const char *, char *);
199         int (*bssid)(const char *, char *);
200         int (*country)(const char *, char *);
201         int (*hardware_id)(const char *, char *);
202         int (*hardware_name)(const char *, char *);
203         int (*encryption)(const char *, char *);
204         int (*phyname)(const char *, char *);
205         int (*assoclist)(const char *, char *, int *);
206         int (*txpwrlist)(const char *, char *, int *);
207         int (*scanlist)(const char *, char *, int *);
208         int (*freqlist)(const char *, char *, int *);
209         int (*countrylist)(const char *, char *, int *);
210         int (*lookup_phy)(const char *, char *);
211         void (*close)(void);
212 };
213
214 const char * iwinfo_type(const char *ifname);
215 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
216 const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
217 void iwinfo_finish(void);
218
219 extern const struct iwinfo_ops wext_ops;
220 extern const struct iwinfo_ops madwifi_ops;
221 extern const struct iwinfo_ops nl80211_ops;
222 extern const struct iwinfo_ops wl_ops;
223
224 #include "iwinfo/utils.h"
225
226 #endif