]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/hostapd/driver.h
This commit was generated by cvs2svn to compensate for changes in r147455,
[FreeBSD/FreeBSD.git] / contrib / hostapd / driver.h
1 #ifndef DRIVER_H
2 #define DRIVER_H
3
4 struct driver_ops {
5         const char *name;               /* as appears in the config file */
6
7         int (*init)(struct hostapd_data *hapd);
8         void (*deinit)(void *priv);
9
10         int (*wireless_event_init)(void *priv);
11         void (*wireless_event_deinit)(void *priv);
12
13         /**
14          * set_8021x - enable/disable 802.1x support
15          * @priv: driver private data
16          * @enabled: 1 = enable, 0 = disable
17          *
18          * Returns: 0 on success, -1 on failure
19          *
20          * Configure the kernel driver to enable/disable 802.1x support.
21          * This may be an empty function if 802.1x support is always enabled.
22          */
23         int (*set_ieee8021x)(void *priv, int enabled);
24
25         /**
26          * set_privacy - enable/disable privacy
27          * @priv: driver private data
28          * @enabled: 1 = privacy enabled, 0 = disabled
29          *
30          * Return: 0 on success, -1 on failure
31          *
32          * Configure privacy.
33          */
34         int (*set_privacy)(void *priv, int enabled);
35
36         int (*set_encryption)(void *priv, const char *alg, u8 *addr,
37                               int idx, u8 *key, size_t key_len);
38         int (*get_seqnum)(void *priv, u8 *addr, int idx, u8 *seq);
39         int (*flush)(void *priv);
40         int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
41
42         int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
43                              u8 *addr);
44         int (*send_eapol)(void *priv, u8 *addr, u8 *data, size_t data_len,
45                           int encrypt);
46         int (*set_sta_authorized)(void *driver, u8 *addr, int authorized);
47         int (*sta_deauth)(void *priv, u8 *addr, int reason);
48         int (*sta_disassoc)(void *priv, u8 *addr, int reason);
49         int (*sta_remove)(void *priv, u8 *addr);
50         int (*get_ssid)(void *priv, u8 *buf, int len);
51         int (*set_ssid)(void *priv, u8 *buf, int len);
52         int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
53                                int flags);
54         int (*set_assoc_ap)(void *priv, u8 *addr);
55         int (*sta_add)(void *priv, u8 *addr, u16 aid, u16 capability,
56                        u8 tx_supp_rates);
57         int (*get_inact_sec)(void *priv, u8 *addr);
58         int (*sta_clear_stats)(void *priv, u8 *addr);
59 };
60
61 static inline int
62 hostapd_driver_init(struct hostapd_data *hapd)
63 {
64         if (hapd->driver == NULL || hapd->driver->init == NULL)
65                 return -1;
66         return hapd->driver->init(hapd);
67 }
68
69 static inline void
70 hostapd_driver_deinit(struct hostapd_data *hapd)
71 {
72         if (hapd->driver == NULL || hapd->driver->deinit == NULL)
73                 return;
74         hapd->driver->deinit(hapd->driver);
75 }
76
77 static inline int
78 hostapd_wireless_event_init(struct hostapd_data *hapd)
79 {
80         if (hapd->driver == NULL ||
81             hapd->driver->wireless_event_init == NULL)
82                 return 0;
83         return hapd->driver->wireless_event_init(hapd->driver);
84 }
85
86 static inline void
87 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
88 {
89         if (hapd->driver == NULL ||
90             hapd->driver->wireless_event_deinit == NULL)
91                 return;
92         hapd->driver->wireless_event_deinit(hapd->driver);
93 }
94
95 static inline int
96 hostapd_set_ieee8021x(struct hostapd_data *hapd, int enabled)
97 {
98         if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
99                 return 0;
100         return hapd->driver->set_ieee8021x(hapd->driver, enabled);
101 }
102
103 static inline int
104 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
105 {
106         if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
107                 return 0;
108         return hapd->driver->set_privacy(hapd->driver, enabled);
109 }
110
111 static inline int
112 hostapd_set_encryption(struct hostapd_data *hapd, const char *alg, u8 *addr,
113                        int idx, u8 *key, size_t key_len)
114 {
115         if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
116                 return 0;
117         return hapd->driver->set_encryption(hapd->driver, alg, addr, idx, key,
118                                             key_len);
119 }
120
121 static inline int
122 hostapd_get_seqnum(struct hostapd_data *hapd, u8 *addr, int idx, u8 *seq)
123 {
124         if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
125                 return 0;
126         return hapd->driver->get_seqnum(hapd->driver, addr, idx, seq);
127 }
128
129 static inline int
130 hostapd_flush(struct hostapd_data *hapd)
131 {
132         if (hapd->driver == NULL || hapd->driver->flush == NULL)
133                 return 0;
134         return hapd->driver->flush(hapd->driver);
135 }
136
137 static inline int
138 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
139                          size_t elem_len)
140 {
141         if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
142                 return 0;
143         return hapd->driver->set_generic_elem(hapd->driver, elem, elem_len);
144 }
145
146 static inline int
147 hostapd_read_sta_data(struct hostapd_data *hapd,
148                       struct hostap_sta_driver_data *data, u8 *addr)
149 {
150         if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
151                 return -1;
152         return hapd->driver->read_sta_data(hapd->driver, data, addr);
153 }
154
155 static inline int
156 hostapd_send_eapol(struct hostapd_data *hapd, u8 *addr, u8 *data,
157                    size_t data_len, int encrypt)
158 {
159         if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
160                 return 0;
161         return hapd->driver->send_eapol(hapd->driver, addr, data, data_len,
162                                         encrypt);
163 }
164
165 static inline int
166 hostapd_set_sta_authorized(struct hostapd_data *hapd, u8 *addr, int authorized)
167 {
168         if (hapd->driver == NULL || hapd->driver->set_sta_authorized == NULL)
169                 return 0;
170         return hapd->driver->set_sta_authorized(hapd->driver, addr,
171                                                 authorized);
172 }
173
174 static inline int
175 hostapd_sta_deauth(struct hostapd_data *hapd, u8 *addr, int reason)
176 {
177         if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
178                 return 0;
179         return hapd->driver->sta_deauth(hapd->driver, addr, reason);
180 }
181
182 static inline int
183 hostapd_sta_disassoc(struct hostapd_data *hapd, u8 *addr, int reason)
184 {
185         if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
186                 return 0;
187         return hapd->driver->sta_disassoc(hapd->driver, addr, reason);
188 }
189
190 static inline int
191 hostapd_sta_remove(struct hostapd_data *hapd, u8 *addr)
192 {
193         if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
194                 return 0;
195         return hapd->driver->sta_remove(hapd->driver, addr);
196 }
197
198 static inline int
199 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
200 {
201         if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
202                 return 0;
203         return hapd->driver->get_ssid(hapd->driver, buf, len);
204 }
205
206 static inline int
207 hostapd_set_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
208 {
209         if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
210                 return 0;
211         return hapd->driver->set_ssid(hapd->driver, buf, len);
212 }
213
214 static inline int
215 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
216                         int flags)
217 {
218         if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
219                 return 0;
220         return hapd->driver->send_mgmt_frame(hapd->driver, msg, len, flags);
221 }
222
223 static inline int
224 hostapd_set_assoc_ap(struct hostapd_data *hapd, u8 *addr)
225 {
226         if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
227                 return 0;
228         return hapd->driver->set_assoc_ap(hapd->driver, addr);
229 }
230
231 static inline int
232 hostapd_sta_add(struct hostapd_data *hapd, u8 *addr, u16 aid, u16 capability,
233                 u8 tx_supp_rates)
234 {
235         if (hapd->driver == NULL || hapd->driver->sta_add == NULL)
236                 return 0;
237         return hapd->driver->sta_add(hapd->driver, addr, aid, capability,
238                                      tx_supp_rates);
239 }
240
241 static inline int
242 hostapd_get_inact_sec(struct hostapd_data *hapd, u8 *addr)
243 {
244         if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
245                 return 0;
246         return hapd->driver->get_inact_sec(hapd->driver, addr);
247 }
248
249
250 void driver_register(const char *name, const struct driver_ops *ops);
251 void driver_unregister(const char *name);
252 const struct driver_ops *driver_lookup(const char *name);
253
254 static inline int
255 hostapd_sta_clear_stats(struct hostapd_data *hapd, u8 *addr)
256 {
257         if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
258                 return 0;
259         return hapd->driver->sta_clear_stats(hapd->driver, addr);
260 }
261
262 #endif /* DRIVER_H */