iwinfo: add per-station rate and mcs info to assoclist op
[openwrt/staging/florian.git] / package / iwinfo / src / 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
31 #define IWINFO_CIPHER_NONE (1 << 0)
32 #define IWINFO_CIPHER_WEP40 (1 << 1)
33 #define IWINFO_CIPHER_TKIP (1 << 2)
34 #define IWINFO_CIPHER_WRAP (1 << 3)
35 #define IWINFO_CIPHER_CCMP (1 << 4)
36 #define IWINFO_CIPHER_WEP104 (1 << 5)
37 #define IWINFO_CIPHER_AESOCB (1 << 6)
38 #define IWINFO_CIPHER_CKIP (1 << 7)
39
40 #define IWINFO_KMGMT_NONE (1 << 0)
41 #define IWINFO_KMGMT_8021x (1 << 1)
42 #define IWINFO_KMGMT_PSK (1 << 2)
43
44 #define IWINFO_AUTH_OPEN (1 << 0)
45 #define IWINFO_AUTH_SHARED (1 << 1)
46
47 extern const char *IWINFO_CIPHER_NAMES[];
48 extern const char *IWINFO_KMGMT_NAMES[];
49 extern const char *IWINFO_AUTH_NAMES[];
50
51
52 struct iwinfo_rate_entry {
53 uint16_t rate;
54 uint8_t mcs;
55 uint8_t is_40mhz:1;
56 uint8_t is_short_gi:1;
57 };
58
59 struct iwinfo_assoclist_entry {
60 uint8_t mac[6];
61 int8_t signal;
62 int8_t noise;
63 uint32_t inactive;
64 uint32_t rx_packets;
65 uint32_t tx_packets;
66 struct iwinfo_rate_entry rx_rate;
67 struct iwinfo_rate_entry tx_rate;
68 };
69
70 struct iwinfo_txpwrlist_entry {
71 uint8_t dbm;
72 uint16_t mw;
73 };
74
75 struct iwinfo_freqlist_entry {
76 uint8_t channel;
77 uint32_t mhz;
78 uint8_t restricted;
79 };
80
81 struct iwinfo_crypto_entry {
82 uint8_t enabled;
83 uint8_t wpa_version;
84 uint8_t group_ciphers;
85 uint8_t pair_ciphers;
86 uint8_t auth_suites;
87 uint8_t auth_algs;
88 };
89
90 struct iwinfo_scanlist_entry {
91 uint8_t mac[6];
92 uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
93 uint8_t mode[8];
94 uint8_t channel;
95 uint8_t signal;
96 uint8_t quality;
97 uint8_t quality_max;
98 struct iwinfo_crypto_entry crypto;
99 };
100
101 struct iwinfo_country_entry {
102 uint16_t iso3166;
103 uint8_t ccode[4];
104 };
105
106 struct iwinfo_iso3166_label {
107 uint16_t iso3166;
108 uint8_t name[28];
109 };
110
111 struct iwinfo_hardware_id {
112 uint16_t vendor_id;
113 uint16_t device_id;
114 uint16_t subsystem_vendor_id;
115 uint16_t subsystem_device_id;
116 };
117
118 struct iwinfo_hardware_entry {
119 const char *vendor_name;
120 const char *device_name;
121 uint16_t vendor_id;
122 uint16_t device_id;
123 uint16_t subsystem_vendor_id;
124 uint16_t subsystem_device_id;
125 int16_t txpower_offset;
126 int16_t frequency_offset;
127 };
128
129 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
130 extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
131
132
133 struct iwinfo_ops {
134 int (*channel)(const char *, int *);
135 int (*frequency)(const char *, int *);
136 int (*frequency_offset)(const char *, int *);
137 int (*txpower)(const char *, int *);
138 int (*txpower_offset)(const char *, int *);
139 int (*bitrate)(const char *, int *);
140 int (*signal)(const char *, int *);
141 int (*noise)(const char *, int *);
142 int (*quality)(const char *, int *);
143 int (*quality_max)(const char *, int *);
144 int (*mbssid_support)(const char *, int *);
145 int (*hwmodelist)(const char *, int *);
146 int (*mode)(const char *, char *);
147 int (*ssid)(const char *, char *);
148 int (*bssid)(const char *, char *);
149 int (*country)(const char *, char *);
150 int (*hardware_id)(const char *, char *);
151 int (*hardware_name)(const char *, char *);
152 int (*encryption)(const char *, char *);
153 int (*assoclist)(const char *, char *, int *);
154 int (*txpwrlist)(const char *, char *, int *);
155 int (*scanlist)(const char *, char *, int *);
156 int (*freqlist)(const char *, char *, int *);
157 int (*countrylist)(const char *, char *, int *);
158 void (*close)(void);
159 };
160
161 const char * iwinfo_type(const char *ifname);
162 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
163 void iwinfo_finish(void);
164
165 #include "iwinfo/wext.h"
166
167 #ifdef USE_WL
168 #include "iwinfo/wl.h"
169 #endif
170
171 #ifdef USE_MADWIFI
172 #include "iwinfo/madwifi.h"
173 #endif
174
175 #ifdef USE_NL80211
176 #include "iwinfo/nl80211.h"
177 #endif
178
179 #endif