driver_i.h

Go to the documentation of this file.
00001 
00017 #ifndef DRIVER_I_H
00018 #define DRIVER_I_H
00019 
00020 #include "drivers/driver.h"
00021 #include "config.h"
00022 
00023 static inline void *
00024 hostapd_driver_init(struct hostapd_data *hapd, const u8 *bssid)
00025 {
00026         struct wpa_init_params params;
00027         void *ret;
00028         size_t i;
00029 
00030         if (hapd->driver == NULL || hapd->driver->hapd_init == NULL)
00031                 return NULL;
00032 
00033         os_memset(&params, 0, sizeof(params));
00034         params.bssid = bssid;
00035         params.ifname = hapd->conf->iface;
00036         params.ssid = (const u8 *) hapd->conf->ssid.ssid;
00037         params.ssid_len = hapd->conf->ssid.ssid_len;
00038         params.test_socket = hapd->conf->test_socket;
00039         params.use_pae_group_addr = hapd->conf->use_pae_group_addr;
00040 
00041         params.num_bridge = hapd->iface->num_bss;
00042         params.bridge = os_zalloc(hapd->iface->num_bss * sizeof(char *));
00043         if (params.bridge == NULL)
00044                 return NULL;
00045         for (i = 0; i < hapd->iface->num_bss; i++) {
00046                 struct hostapd_data *bss = hapd->iface->bss[i];
00047                 if (bss->conf->bridge[0])
00048                         params.bridge[i] = bss->conf->bridge;
00049         }
00050 
00051         params.own_addr = hapd->own_addr;
00052 
00053         ret = hapd->driver->hapd_init(hapd, &params);
00054         os_free(params.bridge);
00055 
00056         return ret;
00057 }
00058 
00059 static inline void
00060 hostapd_driver_deinit(struct hostapd_data *hapd)
00061 {
00062         if (hapd->driver == NULL || hapd->driver->hapd_deinit == NULL)
00063                 return;
00064         hapd->driver->hapd_deinit(hapd->drv_priv);
00065 }
00066 
00067 static inline int
00068 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
00069                       int enabled)
00070 {
00071         if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
00072                 return 0;
00073         return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
00074 }
00075 
00076 static inline int
00077 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
00078 {
00079         if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
00080                 return 0;
00081         return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
00082                                          enabled);
00083 }
00084 
00085 static inline int
00086 hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
00087                 wpa_alg alg, const u8 *addr, int key_idx,
00088                 int set_tx, const u8 *seq, size_t seq_len,
00089                 const u8 *key, size_t key_len)
00090 {
00091         if (hapd->driver == NULL || hapd->driver->hapd_set_key == NULL)
00092                 return 0;
00093         return hapd->driver->hapd_set_key(ifname, hapd->drv_priv, alg, addr,
00094                                           key_idx, set_tx, seq, seq_len, key,
00095                                           key_len);
00096 }
00097 
00098 static inline int
00099 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
00100                    const u8 *addr, int idx, u8 *seq)
00101 {
00102         if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
00103                 return 0;
00104         return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
00105                                         seq);
00106 }
00107 
00108 static inline int
00109 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
00110                         const u8 *addr, int idx, u8 *seq)
00111 {
00112         if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
00113                 return -1;
00114         return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
00115                                              seq);
00116 }
00117 
00118 static inline int
00119 hostapd_flush(struct hostapd_data *hapd)
00120 {
00121         if (hapd->driver == NULL || hapd->driver->flush == NULL)
00122                 return 0;
00123         return hapd->driver->flush(hapd->drv_priv);
00124 }
00125 
00126 static inline int
00127 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
00128                          size_t elem_len)
00129 {
00130         if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
00131                 return 0;
00132         return hapd->driver->set_generic_elem(hapd->conf->iface,
00133                                               hapd->drv_priv, elem, elem_len);
00134 }
00135 
00136 static inline int
00137 hostapd_read_sta_data(struct hostapd_data *hapd,
00138                       struct hostap_sta_driver_data *data, const u8 *addr)
00139 {
00140         if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
00141                 return -1;
00142         return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
00143 }
00144 
00145 static inline int
00146 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
00147                    size_t data_len, int encrypt)
00148 {
00149         if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
00150                 return 0;
00151         return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
00152                                              data_len, encrypt,
00153                                              hapd->own_addr);
00154 }
00155 
00156 static inline int
00157 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
00158 {
00159         if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
00160                 return 0;
00161         return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
00162                                         reason);
00163 }
00164 
00165 static inline int
00166 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
00167 {
00168         if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
00169                 return 0;
00170         return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
00171                                           reason);
00172 }
00173 
00174 static inline int
00175 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
00176 {
00177         if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
00178                 return 0;
00179         return hapd->driver->sta_remove(hapd->drv_priv, addr);
00180 }
00181 
00182 static inline int
00183 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
00184 {
00185         if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
00186                 return 0;
00187         return hapd->driver->hapd_get_ssid(hapd->conf->iface, hapd->drv_priv,
00188                                            buf, len);
00189 }
00190 
00191 static inline int
00192 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
00193 {
00194         if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
00195                 return 0;
00196         return hapd->driver->hapd_set_ssid(hapd->conf->iface, hapd->drv_priv,
00197                                            buf, len);
00198 }
00199 
00200 static inline int
00201 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len)
00202 {
00203         if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
00204                 return 0;
00205         return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
00206 }
00207 
00208 static inline int
00209 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
00210 {
00211         if (hapd->driver == NULL ||
00212             hapd->driver->hapd_set_countermeasures == NULL)
00213                 return 0;
00214         return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
00215 }
00216 
00217 static inline int
00218 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
00219                 u16 aid, u16 capability, const u8 *supp_rates,
00220                 size_t supp_rates_len, int flags, u16 listen_interval,
00221                 const struct ht_cap_ie *ht_capabilities)
00222 {
00223         struct hostapd_sta_add_params params;
00224 
00225         if (hapd->driver == NULL)
00226                 return 0;
00227         if (hapd->driver->sta_add == NULL)
00228                 return 0;
00229 
00230         os_memset(&params, 0, sizeof(params));
00231         params.addr = addr;
00232         params.aid = aid;
00233         params.capability = capability;
00234         params.supp_rates = supp_rates;
00235         params.supp_rates_len = supp_rates_len;
00236         params.flags = flags;
00237         params.listen_interval = listen_interval;
00238         params.ht_capabilities = ht_capabilities;
00239         return hapd->driver->sta_add(ifname, hapd->drv_priv, &params);
00240 }
00241 
00242 static inline int
00243 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
00244 {
00245         if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
00246                 return 0;
00247         return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
00248 }
00249 
00250 static inline int
00251 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel,
00252                  int ht_enabled, int sec_channel_offset)
00253 {
00254         struct hostapd_freq_params data;
00255         if (hapd->driver == NULL)
00256                 return 0;
00257         if (hapd->driver->set_freq == NULL)
00258                 return 0;
00259         os_memset(&data, 0, sizeof(data));
00260         data.mode = mode;
00261         data.freq = freq;
00262         data.channel = channel;
00263         data.ht_enabled = ht_enabled;
00264         data.sec_channel_offset = sec_channel_offset;
00265         return hapd->driver->set_freq(hapd->drv_priv, &data);
00266 }
00267 
00268 static inline int
00269 hostapd_set_rts(struct hostapd_data *hapd, int rts)
00270 {
00271         if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
00272                 return 0;
00273         return hapd->driver->set_rts(hapd->drv_priv, rts);
00274 }
00275 
00276 static inline int
00277 hostapd_set_frag(struct hostapd_data *hapd, int frag)
00278 {
00279         if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
00280                 return 0;
00281         return hapd->driver->set_frag(hapd->drv_priv, frag);
00282 }
00283 
00284 static inline int
00285 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
00286                       int total_flags, int flags_or, int flags_and)
00287 {
00288         if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
00289                 return 0;
00290         return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
00291                                            flags_or, flags_and);
00292 }
00293 
00294 static inline int
00295 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
00296                       int *basic_rates, int mode)
00297 {
00298         if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
00299                 return 0;
00300         return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
00301                                            basic_rates, mode);
00302 }
00303 
00304 static inline int
00305 hostapd_set_country(struct hostapd_data *hapd, const char *country)
00306 {
00307         if (hapd->driver == NULL ||
00308             hapd->driver->set_country == NULL)
00309                 return 0;
00310         return hapd->driver->set_country(hapd->drv_priv, country);
00311 }
00312 
00313 static inline int
00314 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
00315 {
00316         if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
00317                 return 0;
00318         return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
00319 }
00320 
00321 static inline int
00322 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
00323                    const u8 *head, size_t head_len,
00324                    const u8 *tail, size_t tail_len, int dtim_period)
00325 {
00326         if (hapd->driver == NULL || hapd->driver->hapd_set_beacon == NULL)
00327                 return 0;
00328         return hapd->driver->hapd_set_beacon(ifname, hapd->drv_priv,
00329                                              head, head_len,
00330                                              tail, tail_len, dtim_period);
00331 }
00332 
00333 static inline int
00334 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
00335 {
00336         if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
00337                 return 0;
00338         return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
00339 }
00340 
00341 static inline int
00342 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
00343 {
00344         if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
00345                 return 0;
00346         return hapd->driver->set_beacon_int(hapd->drv_priv, value);
00347 }
00348 
00349 static inline int
00350 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
00351 {
00352         if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
00353                 return 0;
00354         return hapd->driver->set_cts_protect(hapd->drv_priv, value);
00355 }
00356 
00357 static inline int
00358 hostapd_set_preamble(struct hostapd_data *hapd, int value)
00359 {
00360         if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
00361                 return 0;
00362         return hapd->driver->set_preamble(hapd->drv_priv, value);
00363 }
00364 
00365 static inline int
00366 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
00367 {
00368         if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
00369                 return 0;
00370         return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
00371 }
00372 
00373 static inline int
00374 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
00375                             int cw_min, int cw_max, int burst_time)
00376 {
00377         if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
00378                 return 0;
00379         return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
00380                                                  cw_min, cw_max, burst_time);
00381 }
00382 
00383 static inline int
00384 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
00385 {
00386         if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
00387                 return 0;
00388         return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
00389 }
00390 
00391 static inline int
00392 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
00393 {
00394         if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
00395                 return 0;
00396         return hapd->driver->bss_remove(hapd->drv_priv, ifname);
00397 }
00398 
00399 static inline int
00400 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
00401                        const u8 *mask)
00402 {
00403         if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
00404                 return 1;
00405         return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
00406 }
00407 
00408 static inline int
00409 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
00410                char *ifname, const u8 *addr)
00411 {
00412         if (hapd->driver == NULL || hapd->driver->if_add == NULL)
00413                 return -1;
00414         return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
00415                                     ifname, addr);
00416 }
00417 
00418 static inline int
00419 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
00420                   char *ifname, const u8 *addr)
00421 {
00422         if (hapd->driver == NULL || hapd->driver->if_update == NULL)
00423                 return -1;
00424         return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
00425 }
00426 
00427 static inline int
00428 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
00429                   char *ifname, const u8 *addr)
00430 {
00431         if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
00432                 return -1;
00433         return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
00434 }
00435 
00436 static inline struct hostapd_hw_modes *
00437 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
00438                             u16 *flags)
00439 {
00440         if (hapd->driver == NULL ||
00441             hapd->driver->get_hw_feature_data == NULL)
00442                 return NULL;
00443         return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
00444                                                  flags);
00445 }
00446 
00447 static inline int
00448 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
00449                      const u8 *addr, int vlan_id)
00450 {
00451         if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
00452                 return 0;
00453         return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
00454 }
00455 
00456 static inline int
00457 hostapd_driver_commit(struct hostapd_data *hapd)
00458 {
00459         if (hapd->driver == NULL || hapd->driver->commit == NULL)
00460                 return 0;
00461         return hapd->driver->commit(hapd->drv_priv);
00462 }
00463 
00464 static inline int
00465 hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
00466                             int accepted, u32 session_timeout)
00467 {
00468         if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
00469                 return 0;
00470         return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
00471                                                  session_timeout);
00472 }
00473 
00474 static inline int
00475 hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
00476 {
00477         if (hapd->driver == NULL ||
00478             hapd->driver->set_radius_acl_expire == NULL)
00479                 return 0;
00480         return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
00481 }
00482 
00483 #ifdef CONFIG_IEEE80211N
00484 static inline int
00485 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
00486                       const u8 *ht_capab, size_t ht_capab_len,
00487                       const u8 *ht_oper, size_t ht_oper_len)
00488 {
00489         if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
00490             ht_capab == NULL || ht_oper == NULL)
00491                 return 0;
00492         return hapd->driver->set_ht_params(
00493                 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
00494                 ht_oper, ht_oper_len);
00495 }
00496 #endif /* CONFIG_IEEE80211N */
00497 
00498 static inline int
00499 hostapd_drv_none(struct hostapd_data *hapd)
00500 {
00501         return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
00502 }
00503 
00504 static inline int
00505 hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
00506 {
00507         if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
00508                 return 0;
00509         return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
00510                                                hapd->drv_priv, ie, len);
00511 }
00512 
00513 static inline int
00514 hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
00515                               size_t len)
00516 {
00517         if (hapd->driver == NULL ||
00518             hapd->driver->set_wps_probe_resp_ie == NULL)
00519                 return 0;
00520         return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
00521                                                    hapd->drv_priv, ie, len);
00522 }
00523 
00524 static inline int hostapd_driver_set_mode(struct hostapd_data *hapd, int mode)
00525 {
00526         if (hapd->driver == NULL || hapd->driver->set_mode == NULL)
00527                 return 0;
00528         return hapd->driver->set_mode(hapd->drv_priv, mode);
00529 }
00530 
00531 static inline int hostapd_driver_scan(struct hostapd_data *hapd,
00532                                       struct wpa_driver_scan_params *params)
00533 {
00534         if (hapd->driver && hapd->driver->scan2)
00535                 return hapd->driver->scan2(hapd->drv_priv, params);
00536         return -1;
00537 }
00538 
00539 static inline struct wpa_scan_results * hostapd_driver_get_scan_results(
00540         struct hostapd_data *hapd)
00541 {
00542         if (hapd->driver && hapd->driver->get_scan_results2)
00543                 return hapd->driver->get_scan_results2(hapd->drv_priv);
00544         return NULL;
00545 }
00546 
00547 #endif /* DRIVER_I_H */
00548 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:16:47 2009 for hostapd by  doxygen 1.6.1