5aed879cedeb5ba1f49baa5e93d4fe69aac41578
[libeap.git] / src / ap / ap_drv_ops.c
1 /*
2  * hostapd - Driver operations
3  * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #include "utils/includes.h"
16
17 #include "utils/common.h"
18 #include "drivers/driver.h"
19 #include "common/ieee802_11_defs.h"
20 #include "wps/wps.h"
21 #include "hostapd.h"
22 #include "ieee802_11.h"
23 #include "sta_info.h"
24 #include "ap_config.h"
25 #include "ap_drv_ops.h"
26
27
28 static int hostapd_sta_flags_to_drv(int flags)
29 {
30         int res = 0;
31         if (flags & WLAN_STA_AUTHORIZED)
32                 res |= WPA_STA_AUTHORIZED;
33         if (flags & WLAN_STA_WMM)
34                 res |= WPA_STA_WMM;
35         if (flags & WLAN_STA_SHORT_PREAMBLE)
36                 res |= WPA_STA_SHORT_PREAMBLE;
37         if (flags & WLAN_STA_MFP)
38                 res |= WPA_STA_MFP;
39         return res;
40 }
41
42
43 static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
44 {
45         struct wpabuf *beacon, *proberesp, *assocresp = NULL;
46         int ret;
47
48         if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
49                 return 0;
50
51         beacon = hapd->wps_beacon_ie;
52         proberesp = hapd->wps_probe_resp_ie;
53
54 #ifdef CONFIG_P2P
55         if (hapd->wps_beacon_ie == NULL && hapd->p2p_beacon_ie == NULL)
56                 beacon = NULL;
57         else {
58                 beacon = wpabuf_alloc((hapd->wps_beacon_ie ?
59                                        wpabuf_len(hapd->wps_beacon_ie) : 0) +
60                                       (hapd->p2p_beacon_ie ?
61                                        wpabuf_len(hapd->p2p_beacon_ie) : 0));
62                 if (beacon == NULL)
63                         return -1;
64                 if (hapd->wps_beacon_ie)
65                         wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
66                 if (hapd->p2p_beacon_ie)
67                         wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
68         }
69
70         if (hapd->wps_probe_resp_ie == NULL && hapd->p2p_probe_resp_ie == NULL)
71                 proberesp = NULL;
72         else {
73                 proberesp = wpabuf_alloc(
74                         (hapd->wps_probe_resp_ie ?
75                          wpabuf_len(hapd->wps_probe_resp_ie) : 0) +
76                         (hapd->p2p_probe_resp_ie ?
77                          wpabuf_len(hapd->p2p_probe_resp_ie) : 0));
78                 if (proberesp == NULL) {
79                         wpabuf_free(beacon);
80                         return -1;
81                 }
82                 if (hapd->wps_probe_resp_ie)
83                         wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
84                 if (hapd->p2p_probe_resp_ie)
85                         wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
86         }
87 #endif /* CONFIG_P2P */
88
89 #ifdef CONFIG_WPS2
90         if (hapd->conf->wps_state)
91                 assocresp = wps_build_assoc_resp_ie();
92 #endif /* CONFIG_WPS2 */
93
94         ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
95                                           assocresp);
96
97 #ifdef CONFIG_P2P
98         wpabuf_free(beacon);
99         wpabuf_free(proberesp);
100 #endif /* CONFIG_P2P */
101         wpabuf_free(assocresp);
102
103         return ret;
104 }
105
106
107 static int hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg,
108                            size_t len)
109 {
110         if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
111                 return 0;
112         return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
113 }
114
115
116 static int hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr,
117                               const u8 *data, size_t data_len, int encrypt)
118 {
119         if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
120                 return 0;
121         return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
122                                              data_len, encrypt,
123                                              hapd->own_addr);
124 }
125
126
127 static int hostapd_set_authorized(struct hostapd_data *hapd,
128                                   struct sta_info *sta, int authorized)
129 {
130         if (authorized) {
131                 return hostapd_sta_set_flags(hapd, sta->addr,
132                                              hostapd_sta_flags_to_drv(
133                                                      sta->flags),
134                                              WPA_STA_AUTHORIZED, ~0);
135         }
136
137         return hostapd_sta_set_flags(hapd, sta->addr,
138                                      hostapd_sta_flags_to_drv(sta->flags),
139                                      0, ~WPA_STA_AUTHORIZED);
140 }
141
142
143 static int hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
144                            enum wpa_alg alg, const u8 *addr, int key_idx,
145                            int set_tx, const u8 *seq, size_t seq_len,
146                            const u8 *key, size_t key_len)
147 {
148         if (hapd->driver == NULL || hapd->driver->set_key == NULL)
149                 return 0;
150         return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
151                                      key_idx, set_tx, seq, seq_len, key,
152                                      key_len);
153 }
154
155
156 static int hostapd_read_sta_data(struct hostapd_data *hapd,
157                                  struct hostap_sta_driver_data *data,
158                                  const u8 *addr)
159 {
160         if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
161                 return -1;
162         return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
163 }
164
165
166 static int hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
167 {
168         if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
169                 return 0;
170         return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
171 }
172
173
174 static int hostapd_set_sta_flags(struct hostapd_data *hapd,
175                                  struct sta_info *sta)
176 {
177         int set_flags, total_flags, flags_and, flags_or;
178         total_flags = hostapd_sta_flags_to_drv(sta->flags);
179         set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
180         if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
181              sta->auth_alg == WLAN_AUTH_FT) &&
182             sta->flags & WLAN_STA_AUTHORIZED)
183                 set_flags |= WPA_STA_AUTHORIZED;
184         flags_or = total_flags & set_flags;
185         flags_and = total_flags | ~set_flags;
186         return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
187                                      flags_or, flags_and);
188 }
189
190
191 static int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd,
192                                      const char *ifname, int enabled)
193 {
194         struct wpa_bss_params params;
195         os_memset(&params, 0, sizeof(params));
196         params.ifname = ifname;
197         params.enabled = enabled;
198         if (enabled) {
199                 params.wpa = hapd->conf->wpa;
200                 params.ieee802_1x = hapd->conf->ieee802_1x;
201                 params.wpa_group = hapd->conf->wpa_group;
202                 params.wpa_pairwise = hapd->conf->wpa_pairwise;
203                 params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
204                 params.rsn_preauth = hapd->conf->rsn_preauth;
205         }
206         return hostapd_set_ieee8021x(hapd, &params);
207 }
208
209
210 static int hostapd_set_radius_acl_auth(struct hostapd_data *hapd,
211                                        const u8 *mac, int accepted,
212                                        u32 session_timeout)
213 {
214         if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
215                 return 0;
216         return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
217                                                  session_timeout);
218 }
219
220
221 static int hostapd_set_radius_acl_expire(struct hostapd_data *hapd,
222                                          const u8 *mac)
223 {
224         if (hapd->driver == NULL ||
225             hapd->driver->set_radius_acl_expire == NULL)
226                 return 0;
227         return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
228 }
229
230
231 static int hostapd_set_bss_params(struct hostapd_data *hapd,
232                                   int use_protection)
233 {
234         int ret = 0;
235         int preamble;
236 #ifdef CONFIG_IEEE80211N
237         u8 buf[60], *ht_capab, *ht_oper, *pos;
238
239         pos = buf;
240         ht_capab = pos;
241         pos = hostapd_eid_ht_capabilities(hapd, pos);
242         ht_oper = pos;
243         pos = hostapd_eid_ht_operation(hapd, pos);
244         if (pos > ht_oper && ht_oper > ht_capab &&
245             hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
246                                   ht_oper + 2, ht_oper[1])) {
247                 wpa_printf(MSG_ERROR, "Could not set HT capabilities "
248                            "for kernel driver");
249                 ret = -1;
250         }
251
252 #endif /* CONFIG_IEEE80211N */
253
254         if (hostapd_set_cts_protect(hapd, use_protection)) {
255                 wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
256                            "driver");
257                 ret = -1;
258         }
259
260         if (hapd->iface->current_mode &&
261             hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
262             hostapd_set_short_slot_time(hapd,
263                                         hapd->iface->num_sta_no_short_slot_time
264                                         > 0 ? 0 : 1)) {
265                 wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
266                            "in kernel driver");
267                 ret = -1;
268         }
269
270         if (hapd->iface->num_sta_no_short_preamble == 0 &&
271             hapd->iconf->preamble == SHORT_PREAMBLE)
272                 preamble = SHORT_PREAMBLE;
273         else
274                 preamble = LONG_PREAMBLE;
275         if (hostapd_set_preamble(hapd, preamble)) {
276                 wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
277                            "driver");
278                 ret = -1;
279         }
280
281         return ret;
282 }
283
284
285 static int hostapd_set_beacon(struct hostapd_data *hapd,
286                               const u8 *head, size_t head_len,
287                               const u8 *tail, size_t tail_len, int dtim_period,
288                               int beacon_int)
289 {
290         if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
291                 return 0;
292         return hapd->driver->set_beacon(hapd->drv_priv,
293                                         head, head_len, tail, tail_len,
294                                         dtim_period, beacon_int);
295 }
296
297
298 static int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
299 {
300         char force_ifname[IFNAMSIZ];
301         u8 if_addr[ETH_ALEN];
302         return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, NULL, NULL, NULL,
303                               force_ifname, if_addr);
304 }
305
306 static int hostapd_vlan_if_remove(struct hostapd_data *hapd,
307                                   const char *ifname)
308 {
309         return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
310 }
311
312
313 static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr,
314                                int aid, int val)
315 {
316         if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
317                 return 0;
318         return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val);
319 }
320
321
322 static int hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
323                                 const u8 *addr, int vlan_id)
324 {
325         if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
326                 return 0;
327         return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
328                                           vlan_id);
329 }
330
331
332 static int hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
333 {
334         if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
335                 return 0;
336         return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
337 }
338
339
340 static int hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr,
341                               int reason)
342 {
343         if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
344                 return 0;
345         return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
346                                         reason);
347 }
348
349
350 static int hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr,
351                                 int reason)
352 {
353         if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
354                 return 0;
355         return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
356                                           reason);
357 }
358
359
360 static int hostapd_sta_add(struct hostapd_data *hapd,
361                            const u8 *addr, u16 aid, u16 capability,
362                            const u8 *supp_rates, size_t supp_rates_len,
363                            u16 listen_interval,
364                            const struct ieee80211_ht_capabilities *ht_capab)
365 {
366         struct hostapd_sta_add_params params;
367
368         if (hapd->driver == NULL)
369                 return 0;
370         if (hapd->driver->sta_add == NULL)
371                 return 0;
372
373         os_memset(&params, 0, sizeof(params));
374         params.addr = addr;
375         params.aid = aid;
376         params.capability = capability;
377         params.supp_rates = supp_rates;
378         params.supp_rates_len = supp_rates_len;
379         params.listen_interval = listen_interval;
380         params.ht_capabilities = ht_capab;
381         return hapd->driver->sta_add(hapd->drv_priv, &params);
382 }
383
384
385 static int hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
386 {
387         if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
388                 return 0;
389         return hapd->driver->sta_remove(hapd->drv_priv, addr);
390 }
391
392
393 static int hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
394 {
395         if (hapd->driver == NULL ||
396             hapd->driver->hapd_set_countermeasures == NULL)
397                 return 0;
398         return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
399 }
400
401
402 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
403 {
404         ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
405         ops->send_mgmt_frame = hostapd_send_mgmt_frame;
406         ops->send_eapol = hostapd_send_eapol;
407         ops->set_authorized = hostapd_set_authorized;
408         ops->set_key = hostapd_set_key;
409         ops->read_sta_data = hostapd_read_sta_data;
410         ops->sta_clear_stats = hostapd_sta_clear_stats;
411         ops->set_sta_flags = hostapd_set_sta_flags;
412         ops->set_drv_ieee8021x = hostapd_set_drv_ieee8021x;
413         ops->set_radius_acl_auth = hostapd_set_radius_acl_auth;
414         ops->set_radius_acl_expire = hostapd_set_radius_acl_expire;
415         ops->set_bss_params = hostapd_set_bss_params;
416         ops->set_beacon = hostapd_set_beacon;
417         ops->vlan_if_add = hostapd_vlan_if_add;
418         ops->vlan_if_remove = hostapd_vlan_if_remove;
419         ops->set_wds_sta = hostapd_set_wds_sta;
420         ops->set_sta_vlan = hostapd_set_sta_vlan;
421         ops->get_inact_sec = hostapd_get_inact_sec;
422         ops->sta_deauth = hostapd_sta_deauth;
423         ops->sta_disassoc = hostapd_sta_disassoc;
424         ops->sta_add = hostapd_sta_add;
425         ops->sta_remove = hostapd_sta_remove;
426         ops->set_countermeasures = hostapd_set_countermeasures;
427 }
428
429
430 int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
431 {
432         if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
433                 return 0;
434         return hapd->driver->set_privacy(hapd->drv_priv, enabled);
435 }
436
437
438 int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
439                              size_t elem_len)
440 {
441         if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
442                 return 0;
443         return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
444 }
445
446
447 int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
448 {
449         if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
450                 return 0;
451         return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
452 }
453
454
455 int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
456 {
457         if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
458                 return 0;
459         return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
460 }
461
462
463 int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
464                    const char *ifname, const u8 *addr, void *bss_ctx,
465                    void **drv_priv, char *force_ifname, u8 *if_addr)
466 {
467         if (hapd->driver == NULL || hapd->driver->if_add == NULL)
468                 return -1;
469         return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
470                                     bss_ctx, drv_priv, force_ifname, if_addr);
471 }
472
473
474 int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
475                       const char *ifname)
476 {
477         if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
478                 return -1;
479         return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
480 }
481
482
483 int hostapd_set_ieee8021x(struct hostapd_data *hapd,
484                           struct wpa_bss_params *params)
485 {
486         if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
487                 return 0;
488         return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
489 }
490
491
492 int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
493                        const u8 *addr, int idx, u8 *seq)
494 {
495         if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
496                 return 0;
497         return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
498                                         seq);
499 }
500
501
502 int hostapd_flush(struct hostapd_data *hapd)
503 {
504         if (hapd->driver == NULL || hapd->driver->flush == NULL)
505                 return 0;
506         return hapd->driver->flush(hapd->drv_priv);
507 }
508
509
510 int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
511                      int channel, int ht_enabled, int sec_channel_offset)
512 {
513         struct hostapd_freq_params data;
514         if (hapd->driver == NULL)
515                 return 0;
516         if (hapd->driver->set_freq == NULL)
517                 return 0;
518         os_memset(&data, 0, sizeof(data));
519         data.mode = mode;
520         data.freq = freq;
521         data.channel = channel;
522         data.ht_enabled = ht_enabled;
523         data.sec_channel_offset = sec_channel_offset;
524         return hapd->driver->set_freq(hapd->drv_priv, &data);
525 }
526
527 int hostapd_set_rts(struct hostapd_data *hapd, int rts)
528 {
529         if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
530                 return 0;
531         return hapd->driver->set_rts(hapd->drv_priv, rts);
532 }
533
534
535 int hostapd_set_frag(struct hostapd_data *hapd, int frag)
536 {
537         if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
538                 return 0;
539         return hapd->driver->set_frag(hapd->drv_priv, frag);
540 }
541
542
543 int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
544                           int total_flags, int flags_or, int flags_and)
545 {
546         if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
547                 return 0;
548         return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
549                                            flags_or, flags_and);
550 }
551
552
553 int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
554                           int *basic_rates, int mode)
555 {
556         if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
557                 return 0;
558         return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
559                                            basic_rates, mode);
560 }
561
562
563 int hostapd_set_country(struct hostapd_data *hapd, const char *country)
564 {
565         if (hapd->driver == NULL ||
566             hapd->driver->set_country == NULL)
567                 return 0;
568         return hapd->driver->set_country(hapd->drv_priv, country);
569 }
570
571
572 int hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
573 {
574         if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
575                 return 0;
576         return hapd->driver->set_cts_protect(hapd->drv_priv, value);
577 }
578
579
580 int hostapd_set_preamble(struct hostapd_data *hapd, int value)
581 {
582         if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
583                 return 0;
584         return hapd->driver->set_preamble(hapd->drv_priv, value);
585 }
586
587
588 int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
589 {
590         if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
591                 return 0;
592         return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
593 }
594
595
596 int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
597                                 int cw_min, int cw_max, int burst_time)
598 {
599         if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
600                 return 0;
601         return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
602                                                  cw_min, cw_max, burst_time);
603 }
604
605
606 int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
607                            const u8 *mask)
608 {
609         if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
610                 return 1;
611         return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
612 }
613
614
615 struct hostapd_hw_modes *
616 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
617                             u16 *flags)
618 {
619         if (hapd->driver == NULL ||
620             hapd->driver->get_hw_feature_data == NULL)
621                 return NULL;
622         return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
623                                                  flags);
624 }
625
626
627 int hostapd_driver_commit(struct hostapd_data *hapd)
628 {
629         if (hapd->driver == NULL || hapd->driver->commit == NULL)
630                 return 0;
631         return hapd->driver->commit(hapd->drv_priv);
632 }
633
634
635 int hostapd_set_ht_params(struct hostapd_data *hapd,
636                           const u8 *ht_capab, size_t ht_capab_len,
637                           const u8 *ht_oper, size_t ht_oper_len)
638 {
639         if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
640             ht_capab == NULL || ht_oper == NULL)
641                 return 0;
642         return hapd->driver->set_ht_params(hapd->drv_priv,
643                                            ht_capab, ht_capab_len,
644                                            ht_oper, ht_oper_len);
645 }
646
647
648 int hostapd_drv_none(struct hostapd_data *hapd)
649 {
650         return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
651 }
652
653
654 int hostapd_driver_scan(struct hostapd_data *hapd,
655                         struct wpa_driver_scan_params *params)
656 {
657         if (hapd->driver && hapd->driver->scan2)
658                 return hapd->driver->scan2(hapd->drv_priv, params);
659         return -1;
660 }
661
662
663 struct wpa_scan_results * hostapd_driver_get_scan_results(
664         struct hostapd_data *hapd)
665 {
666         if (hapd->driver && hapd->driver->get_scan_results2)
667                 return hapd->driver->get_scan_results2(hapd->drv_priv);
668         return NULL;
669 }
670
671
672 int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
673                            int duration)
674 {
675         if (hapd->driver && hapd->driver->set_noa)
676                 return hapd->driver->set_noa(hapd->drv_priv, count, start,
677                                              duration);
678         return -1;
679 }