iwinfo: implement proper hardware detection for ar23xx SoC devices like the NanoStation 2
[openwrt/staging/chunkeey.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_assoclist_entry {
53 uint8_t mac[6];
54 int8_t signal;
55 int8_t noise;
56 };
57
58 struct iwinfo_txpwrlist_entry {
59 uint8_t dbm;
60 uint16_t mw;
61 };
62
63 struct iwinfo_freqlist_entry {
64 uint8_t channel;
65 uint32_t mhz;
66 uint8_t restricted;
67 };
68
69 struct iwinfo_crypto_entry {
70 uint8_t enabled;
71 uint8_t wpa_version;
72 uint8_t group_ciphers;
73 uint8_t pair_ciphers;
74 uint8_t auth_suites;
75 uint8_t auth_algs;
76 };
77
78 struct iwinfo_scanlist_entry {
79 uint8_t mac[6];
80 uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
81 uint8_t mode[8];
82 uint8_t channel;
83 uint8_t signal;
84 uint8_t quality;
85 uint8_t quality_max;
86 struct iwinfo_crypto_entry crypto;
87 };
88
89 struct iwinfo_country_entry {
90 uint16_t iso3166;
91 uint8_t ccode[4];
92 };
93
94 struct iwinfo_iso3166_label {
95 uint16_t iso3166;
96 uint8_t name[28];
97 };
98
99 struct iwinfo_hardware_id {
100 uint16_t vendor_id;
101 uint16_t device_id;
102 uint16_t subsystem_vendor_id;
103 uint16_t subsystem_device_id;
104 };
105
106 struct iwinfo_hardware_entry {
107 const char *vendor_name;
108 const char *device_name;
109 uint16_t vendor_id;
110 uint16_t device_id;
111 uint16_t subsystem_vendor_id;
112 uint16_t subsystem_device_id;
113 int16_t txpower_offset;
114 int16_t frequency_offset;
115 };
116
117 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
118 extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
119
120
121 struct iwinfo_ops {
122 int (*channel)(const char *, int *);
123 int (*frequency)(const char *, int *);
124 int (*frequency_offset)(const char *, int *);
125 int (*txpower)(const char *, int *);
126 int (*txpower_offset)(const char *, int *);
127 int (*bitrate)(const char *, int *);
128 int (*signal)(const char *, int *);
129 int (*noise)(const char *, int *);
130 int (*quality)(const char *, int *);
131 int (*quality_max)(const char *, int *);
132 int (*mbssid_support)(const char *, int *);
133 int (*hwmodelist)(const char *, int *);
134 int (*mode)(const char *, char *);
135 int (*ssid)(const char *, char *);
136 int (*bssid)(const char *, char *);
137 int (*country)(const char *, char *);
138 int (*hardware_id)(const char *, char *);
139 int (*hardware_name)(const char *, char *);
140 int (*encryption)(const char *, char *);
141 int (*assoclist)(const char *, char *, int *);
142 int (*txpwrlist)(const char *, char *, int *);
143 int (*scanlist)(const char *, char *, int *);
144 int (*freqlist)(const char *, char *, int *);
145 int (*countrylist)(const char *, char *, int *);
146 void (*close)(void);
147 };
148
149 const char * iwinfo_type(const char *ifname);
150 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
151 void iwinfo_finish(void);
152
153 #include "iwinfo/wext.h"
154
155 #ifdef USE_WL
156 #include "iwinfo/wl.h"
157 #endif
158
159 #ifdef USE_MADWIFI
160 #include "iwinfo/madwifi.h"
161 #endif
162
163 #ifdef USE_NL80211
164 #include "iwinfo/nl80211.h"
165 #endif
166
167 #endif