[package] add libiwinfo (moved from LuCI trunk)
[openwrt/svn-archive/archive.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 <net/if.h>
19 #include <errno.h>
20
21
22 #define IWINFO_BUFSIZE 24 * 1024
23 #define IWINFO_ESSID_MAX_SIZE 32
24
25 #define IWINFO_80211_A (1 << 0)
26 #define IWINFO_80211_B (1 << 1)
27 #define IWINFO_80211_G (1 << 2)
28 #define IWINFO_80211_N (1 << 3)
29
30 #define IWINFO_CIPHER_NONE (1 << 0)
31 #define IWINFO_CIPHER_WEP40 (1 << 1)
32 #define IWINFO_CIPHER_TKIP (1 << 2)
33 #define IWINFO_CIPHER_WRAP (1 << 3)
34 #define IWINFO_CIPHER_CCMP (1 << 4)
35 #define IWINFO_CIPHER_WEP104 (1 << 5)
36 #define IWINFO_CIPHER_AESOCB (1 << 6)
37 #define IWINFO_CIPHER_CKIP (1 << 7)
38
39 #define IWINFO_KMGMT_NONE (1 << 0)
40 #define IWINFO_KMGMT_8021x (1 << 1)
41 #define IWINFO_KMGMT_PSK (1 << 2)
42
43 #define IWINFO_AUTH_OPEN (1 << 0)
44 #define IWINFO_AUTH_SHARED (1 << 1)
45
46 extern const char *IWINFO_CIPHER_NAMES[];
47 extern const char *IWINFO_KMGMT_NAMES[];
48 extern const char *IWINFO_AUTH_NAMES[];
49
50
51 struct iwinfo_assoclist_entry {
52 uint8_t mac[6];
53 int8_t signal;
54 int8_t noise;
55 };
56
57 struct iwinfo_txpwrlist_entry {
58 uint8_t dbm;
59 uint16_t mw;
60 };
61
62 struct iwinfo_freqlist_entry {
63 uint8_t channel;
64 uint32_t mhz;
65 uint8_t restricted;
66 };
67
68 struct iwinfo_crypto_entry {
69 uint8_t enabled;
70 uint8_t wpa_version;
71 uint8_t group_ciphers;
72 uint8_t pair_ciphers;
73 uint8_t auth_suites;
74 uint8_t auth_algs;
75 };
76
77 struct iwinfo_scanlist_entry {
78 uint8_t mac[6];
79 uint8_t ssid[IWINFO_ESSID_MAX_SIZE+1];
80 uint8_t mode[8];
81 uint8_t channel;
82 uint8_t signal;
83 uint8_t quality;
84 uint8_t quality_max;
85 struct iwinfo_crypto_entry crypto;
86 };
87
88 struct iwinfo_country_entry {
89 uint16_t iso3166;
90 uint8_t ccode[4];
91 };
92
93 struct iwinfo_iso3166_label {
94 uint16_t iso3166;
95 uint8_t name[28];
96 };
97
98 extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
99
100
101 struct iwinfo_ops {
102 int (*channel)(const char *, int *);
103 int (*frequency)(const char *, int *);
104 int (*txpower)(const char *, int *);
105 int (*bitrate)(const char *, int *);
106 int (*signal)(const char *, int *);
107 int (*noise)(const char *, int *);
108 int (*quality)(const char *, int *);
109 int (*quality_max)(const char *, int *);
110 int (*mbssid_support)(const char *, int *);
111 int (*hwmodelist)(const char *, int *);
112 int (*mode)(const char *, char *);
113 int (*ssid)(const char *, char *);
114 int (*bssid)(const char *, char *);
115 int (*country)(const char *, char *);
116 int (*encryption)(const char *, char *);
117 int (*assoclist)(const char *, char *, int *);
118 int (*txpwrlist)(const char *, char *, int *);
119 int (*scanlist)(const char *, char *, int *);
120 int (*freqlist)(const char *, char *, int *);
121 int (*countrylist)(const char *, char *, int *);
122 void (*close)(void);
123 };
124
125 const char * iwinfo_type(const char *ifname);
126 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
127 void iwinfo_finish(void);
128
129 #include "iwinfo/wext.h"
130
131 #ifdef USE_WL
132 #include "iwinfo/wl.h"
133 #endif
134
135 #ifdef USE_MADWIFI
136 #include "iwinfo/madwifi.h"
137 #endif
138
139 #ifdef USE_NL80211
140 #include "iwinfo/nl80211.h"
141 #endif
142
143 #endif