• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/iwinfo/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 #define IWINFO_80211_AD      (1 << 5)
 32 #define IWINFO_80211_AX      (1 << 6)
 33 
 34 #define IWINFO_CIPHER_NONE   (1 << 0)
 35 #define IWINFO_CIPHER_WEP40  (1 << 1)
 36 #define IWINFO_CIPHER_TKIP   (1 << 2)
 37 #define IWINFO_CIPHER_WRAP   (1 << 3)
 38 #define IWINFO_CIPHER_CCMP   (1 << 4)
 39 #define IWINFO_CIPHER_WEP104 (1 << 5)
 40 #define IWINFO_CIPHER_AESOCB (1 << 6)
 41 #define IWINFO_CIPHER_CKIP   (1 << 7)
 42 #define IWINFO_CIPHER_GCMP   (1 << 8)
 43 #define IWINFO_CIPHER_COUNT  9
 44 
 45 #define IWINFO_KMGMT_NONE    (1 << 0)
 46 #define IWINFO_KMGMT_8021x   (1 << 1)
 47 #define IWINFO_KMGMT_PSK     (1 << 2)
 48 #define IWINFO_KMGMT_SAE     (1 << 3)
 49 #define IWINFO_KMGMT_OWE     (1 << 4)
 50 #define IWINFO_KMGMT_COUNT   5
 51 
 52 #define IWINFO_AUTH_OPEN     (1 << 0)
 53 #define IWINFO_AUTH_SHARED   (1 << 1)
 54 #define IWINFO_AUTH_COUNT    2
 55 
 56 #define IWINFO_FREQ_NO_10MHZ            (1 << 0)
 57 #define IWINFO_FREQ_NO_20MHZ            (1 << 1)
 58 #define IWINFO_FREQ_NO_HT40PLUS         (1 << 2)
 59 #define IWINFO_FREQ_NO_HT40MINUS        (1 << 3)
 60 #define IWINFO_FREQ_NO_80MHZ            (1 << 4)
 61 #define IWINFO_FREQ_NO_160MHZ           (1 << 5)
 62 #define IWINFO_FREQ_NO_2160MHZ          (1 << 6)
 63 
 64 extern const char *IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT];
 65 extern const char *IWINFO_KMGMT_NAMES[IWINFO_KMGMT_COUNT];
 66 extern const char *IWINFO_AUTH_NAMES[IWINFO_AUTH_COUNT];
 67 
 68 
 69 enum iwinfo_opmode {
 70         IWINFO_OPMODE_UNKNOWN    = 0,
 71         IWINFO_OPMODE_MASTER     = 1,
 72         IWINFO_OPMODE_ADHOC      = 2,
 73         IWINFO_OPMODE_CLIENT     = 3,
 74         IWINFO_OPMODE_MONITOR    = 4,
 75         IWINFO_OPMODE_AP_VLAN    = 5,
 76         IWINFO_OPMODE_WDS        = 6,
 77         IWINFO_OPMODE_MESHPOINT  = 7,
 78         IWINFO_OPMODE_P2P_CLIENT = 8,
 79         IWINFO_OPMODE_P2P_GO     = 9,
 80 };
 81 
 82 extern const char *IWINFO_OPMODE_NAMES[];
 83 
 84 
 85 enum iwinfo_htmode {
 86         IWINFO_HTMODE_HT20       = (1 << 0),
 87         IWINFO_HTMODE_HT40       = (1 << 1),
 88         IWINFO_HTMODE_VHT20      = (1 << 2),
 89         IWINFO_HTMODE_VHT40      = (1 << 3),
 90         IWINFO_HTMODE_VHT80      = (1 << 4),
 91         IWINFO_HTMODE_VHT80_80   = (1 << 5),
 92         IWINFO_HTMODE_VHT160     = (1 << 6),
 93         IWINFO_HTMODE_NOHT       = (1 << 7),
 94         IWINFO_HTMODE_HE20       = (1 << 8),
 95         IWINFO_HTMODE_HE40       = (1 << 9),
 96         IWINFO_HTMODE_HE80       = (1 << 10),
 97         IWINFO_HTMODE_HE80_80    = (1 << 11),
 98         IWINFO_HTMODE_HE160      = (1 << 12),
 99 
100         IWINFO_HTMODE_COUNT      = 13
101 };
102 
103 extern const char *IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT];
104 
105 
106 struct iwinfo_rate_entry {
107         uint32_t rate;
108         int8_t mcs;
109         uint8_t is_40mhz:1;
110         uint8_t is_short_gi:1;
111         uint8_t is_ht:1;
112         uint8_t is_vht:1;
113         uint8_t is_he:1;
114         uint8_t he_gi;
115         uint8_t he_dcm;
116         uint8_t mhz;
117         uint8_t nss;
118 };
119 
120 struct iwinfo_assoclist_entry {
121         uint8_t mac[6];
122         int8_t signal;
123         int8_t signal_avg;
124         int8_t noise;
125         uint32_t inactive;
126         uint32_t connected_time;
127         uint32_t rx_packets;
128         uint32_t tx_packets;
129         uint64_t rx_drop_misc;
130         struct iwinfo_rate_entry rx_rate;
131         struct iwinfo_rate_entry tx_rate;
132         uint32_t rx_bytes;
133         uint32_t tx_bytes;
134         uint32_t tx_retries;
135         uint32_t tx_failed;
136         uint64_t t_offset;
137         uint8_t is_authorized:1;
138         uint8_t is_authenticated:1;
139         uint8_t is_preamble_short:1;
140         uint8_t is_wme:1;
141         uint8_t is_mfp:1;
142         uint8_t is_tdls:1;
143         uint32_t thr;
144         uint16_t llid;
145         uint16_t plid;
146         char plink_state[16];
147         char local_ps[16];
148         char peer_ps[16];
149         char nonpeer_ps[16];
150 };
151 
152 struct iwinfo_survey_entry {
153         uint64_t active_time;
154         uint64_t busy_time;
155         uint64_t busy_time_ext;
156         uint64_t rxtime;
157         uint64_t txtime;
158         uint32_t mhz;
159         uint8_t noise;
160 };
161 
162 struct iwinfo_txpwrlist_entry {
163         uint8_t  dbm;
164         uint16_t mw;
165 };
166 
167 struct iwinfo_freqlist_entry {
168         uint8_t channel;
169         uint32_t mhz;
170         uint8_t restricted;
171         uint32_t flags;
172 };
173 
174 struct iwinfo_crypto_entry {
175         uint8_t enabled;
176         uint8_t wpa_version;
177         uint16_t group_ciphers;
178         uint16_t pair_ciphers;
179         uint8_t auth_suites;
180         uint8_t auth_algs;
181 };
182 
183 struct iwinfo_scanlist_ht_chan_entry {
184         uint8_t primary_chan;
185         uint8_t secondary_chan_off;
186         uint8_t chan_width;
187 };
188 
189 struct iwinfo_scanlist_vht_chan_entry {
190         uint8_t chan_width;
191         uint8_t center_chan_1;
192         uint8_t center_chan_2;
193 };
194 
195 static const char *ht_secondary_offset[4] = {
196         "no secondary",
197         "above",
198         "[reserved!]",
199         "below",
200 };
201 
202 
203 static uint16_t ht_chan_width[2] = {
204         20, /* 20 MHz */
205         2040, /* 40 MHz or higher (refer to vht if supported) */
206 };
207 
208 static uint16_t vht_chan_width[] = {
209         [0] = 40, /* 40 MHz or lower (refer to ht to a more precise width) */
210         [1] = 80, /* 80 MHz */
211         [3] = 8080, /* 80+80 MHz */
212         [2] = 160, /* 160 MHz */
213 };
214 
215 struct iwinfo_scanlist_entry {
216         uint8_t mac[6];
217         char ssid[IWINFO_ESSID_MAX_SIZE+1];
218         enum iwinfo_opmode mode;
219         uint8_t channel;
220         uint8_t signal;
221         uint8_t quality;
222         uint8_t quality_max;
223         struct iwinfo_crypto_entry crypto;
224         struct iwinfo_scanlist_ht_chan_entry ht_chan_info;
225         struct iwinfo_scanlist_vht_chan_entry vht_chan_info;
226 };
227 
228 struct iwinfo_country_entry {
229         uint16_t iso3166;
230         char ccode[4];
231 };
232 
233 struct iwinfo_iso3166_label {
234         uint16_t iso3166;
235         char name[28];
236 };
237 
238 struct iwinfo_hardware_id {
239         uint16_t vendor_id;
240         uint16_t device_id;
241         uint16_t subsystem_vendor_id;
242         uint16_t subsystem_device_id;
243 };
244 
245 struct iwinfo_hardware_entry {
246         char vendor_name[64];
247         char device_name[64];
248         uint16_t vendor_id;
249         uint16_t device_id;
250         uint16_t subsystem_vendor_id;
251         uint16_t subsystem_device_id;
252         int16_t txpower_offset;
253         int16_t frequency_offset;
254 };
255 
256 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
257 
258 #define IWINFO_HARDWARE_FILE    "/usr/share/libiwinfo/hardware.txt"
259 
260 
261 struct iwinfo_ops {
262         const char *name;
263 
264         int (*probe)(const char *ifname);
265         int (*mode)(const char *, int *);
266         int (*channel)(const char *, int *);
267         int (*center_chan1)(const char *, int *);
268         int (*center_chan2)(const char *, int *);
269         int (*frequency)(const char *, int *);
270         int (*frequency_offset)(const char *, int *);
271         int (*txpower)(const char *, int *);
272         int (*txpower_offset)(const char *, int *);
273         int (*bitrate)(const char *, int *);
274         int (*signal)(const char *, int *);
275         int (*noise)(const char *, int *);
276         int (*quality)(const char *, int *);
277         int (*quality_max)(const char *, int *);
278         int (*mbssid_support)(const char *, int *);
279         int (*hwmodelist)(const char *, int *);
280         int (*htmodelist)(const char *, int *);
281         int (*htmode)(const char *, int *);
282         int (*ssid)(const char *, char *);
283         int (*bssid)(const char *, char *);
284         int (*country)(const char *, char *);
285         int (*hardware_id)(const char *, char *);
286         int (*hardware_name)(const char *, char *);
287         int (*encryption)(const char *, char *);
288         int (*phyname)(const char *, char *);
289         int (*assoclist)(const char *, char *, int *);
290         int (*txpwrlist)(const char *, char *, int *);
291         int (*scanlist)(const char *, char *, int *);
292         int (*freqlist)(const char *, char *, int *);
293         int (*countrylist)(const char *, char *, int *);
294         int (*survey)(const char *, char *, int *);
295         int (*lookup_phy)(const char *, char *);
296         int (*phy_path)(const char *phyname, const char **path);
297         void (*close)(void);
298 };
299 
300 const char * iwinfo_type(const char *ifname);
301 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
302 const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
303 void iwinfo_finish(void);
304 
305 extern const struct iwinfo_ops wext_ops;
306 extern const struct iwinfo_ops madwifi_ops;
307 extern const struct iwinfo_ops nl80211_ops;
308 extern const struct iwinfo_ops wl_ops;
309 
310 #include "iwinfo/utils.h"
311 
312 #endif
313 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt