wpa_supplicant_i.h

Go to the documentation of this file.
00001 
00016 #ifndef WPA_SUPPLICANT_I_H
00017 #define WPA_SUPPLICANT_I_H
00018 
00019 #include "driver.h"
00020 
00021 struct wpa_blacklist {
00022         struct wpa_blacklist *next;
00023         u8 bssid[ETH_ALEN];
00024         int count;
00025 };
00026 
00027 
00028 struct wpa_scan_result;
00029 struct wpa_sm;
00030 struct wpa_supplicant;
00031 
00036 struct wpa_interface {
00045         const char *confname;
00046 
00057         const char *ctrl_interface;
00058 
00063         const char *driver;
00064 
00075         const char *driver_param;
00076 
00081         const char *ifname;
00082 };
00083 
00088 struct wpa_params {
00093         int daemonize;
00094 
00105         int wait_for_interface;
00106 
00111         int wait_for_monitor;
00112 
00120         char *pid_file;
00121 
00126         int wpa_debug_level;
00127 
00138         int wpa_debug_show_keys;
00139 
00144         int wpa_debug_timestamp;
00145 
00150         char *ctrl_interface;
00151 };
00152 
00160 struct wpa_global {
00161         struct wpa_supplicant *ifaces;
00162         struct wpa_params params;
00163         int ctrl_sock;
00164 };
00165 
00175 struct wpa_supplicant {
00176         struct wpa_global *global;
00177         struct wpa_supplicant *next;
00178         struct l2_packet_data *l2;
00179         unsigned char own_addr[ETH_ALEN];
00180         char ifname[100];
00181 
00182         char *confname;
00183         struct wpa_config *conf;
00184         int countermeasures;
00185         time_t last_michael_mic_error;
00186         u8 bssid[ETH_ALEN];
00187         int reassociate; /* reassociation requested */
00188         int disconnected; /* all connections disabled; i.e., do no reassociate
00189                            * before this has been cleared */
00190         struct wpa_ssid *current_ssid;
00191 
00192         /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
00193         int pairwise_cipher;
00194         int group_cipher;
00195         int key_mgmt;
00196 
00197         void *drv_priv; /* private data used by driver_ops */
00198 
00199         struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
00200                                           * NULL = not yet initialized (start
00201                                           * with broadcast SSID)
00202                                           * BROADCAST_SSID_SCAN = broadcast
00203                                           * SSID was used in the previous scan
00204                                           */
00205 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
00206 
00207         struct wpa_scan_result *scan_results;
00208         int num_scan_results;
00209 
00210         struct wpa_driver_ops *driver;
00211         int interface_removed; /* whether the network interface has been
00212                                 * removed */
00213         struct wpa_sm *wpa;
00214         struct eapol_sm *eapol;
00215 
00216         int ctrl_sock; /* UNIX domain socket for control interface or -1 if
00217                         * not used */
00218         struct wpa_ctrl_dst *ctrl_dst;
00219 
00220         wpa_states wpa_state;
00221         int new_connection;
00222         int reassociated_connection;
00223 
00224         int eapol_received; /* number of EAPOL packets received after the
00225                              * previous association event */
00226 
00227         struct scard_data *scard;
00228 
00229         unsigned char last_eapol_src[ETH_ALEN];
00230 
00231         int keys_cleared;
00232 
00233         struct wpa_blacklist *blacklist;
00234 
00235         int scan_req; /* manual scan request; this forces a scan even if there
00236                        * are no enabled networks in the configuration */
00237 };
00238 
00239 
00240 /* wpa_supplicant.c */
00241 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
00242 
00243 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
00244 
00245 const char * wpa_supplicant_state_txt(int state);
00246 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s,
00247                                int wait_for_interface);
00248 struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s,
00249                                          const u8 *bssid);
00250 int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid);
00251 void wpa_blacklist_clear(struct wpa_supplicant *wpa_s);
00252 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
00253                               struct wpa_scan_result *bss,
00254                               struct wpa_ssid *ssid,
00255                               u8 *wpa_ie, size_t *wpa_ie_len);
00256 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
00257                               struct wpa_scan_result *bss,
00258                               struct wpa_ssid *ssid);
00259 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
00260                                        struct wpa_ssid *ssid);
00261 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
00262 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
00263 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
00264 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
00265                                      int sec, int usec);
00266 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
00267 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
00268 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
00269 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
00270                                    int reason_code);
00271 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
00272                                  int reason_code);
00273 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
00274 
00275 void wpa_show_license(void);
00276 
00277 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
00278                                                  struct wpa_interface *iface);
00279 int wpa_supplicant_remove_iface(struct wpa_global *global,
00280                                 struct wpa_supplicant *wpa_s);
00281 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
00282                                                  const char *ifname);
00283 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
00284 int wpa_supplicant_run(struct wpa_global *global);
00285 void wpa_supplicant_deinit(struct wpa_global *global);
00286 
00287 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
00288                               struct wpa_ssid *ssid);
00289 
00290 
00291 /* driver_ops */
00292 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
00293                                   const char *ifname)
00294 {
00295         if (wpa_s->driver->init) {
00296                 return wpa_s->driver->init(wpa_s, ifname);
00297         }
00298         return NULL;
00299 }
00300 
00301 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
00302 {
00303         if (wpa_s->driver->deinit)
00304                 wpa_s->driver->deinit(wpa_s->drv_priv);
00305 }
00306 
00307 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
00308                                     const char *param)
00309 {
00310         if (wpa_s->driver->set_param)
00311                 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
00312         return 0;
00313 }
00314 
00315 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
00316                                                int enabled)
00317 {
00318         if (wpa_s->driver->set_drop_unencrypted) {
00319                 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
00320                                                            enabled);
00321         }
00322         return -1;
00323 }
00324 
00325 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
00326                                               int enabled)
00327 {
00328         if (wpa_s->driver->set_countermeasures) {
00329                 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
00330                                                           enabled);
00331         }
00332         return -1;
00333 }
00334 
00335 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
00336                                        int auth_alg)
00337 {
00338         if (wpa_s->driver->set_auth_alg) {
00339                 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
00340                                                    auth_alg);
00341         }
00342         return -1;
00343 }
00344 
00345 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
00346 {
00347         if (wpa_s->driver->set_wpa) {
00348                 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
00349         }
00350         return 0;
00351 }
00352 
00353 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
00354                                     struct wpa_driver_associate_params *params)
00355 {
00356         if (wpa_s->driver->associate) {
00357                 return wpa_s->driver->associate(wpa_s->drv_priv, params);
00358         }
00359         return -1;
00360 }
00361 
00362 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
00363                                size_t ssid_len)
00364 {
00365         if (wpa_s->driver->scan) {
00366                 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
00367         }
00368         return -1;
00369 }
00370 
00371 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
00372                                            struct wpa_scan_result *results,
00373                                            size_t max_size)
00374 {
00375         if (wpa_s->driver->get_scan_results) {
00376                 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
00377                                                        results, max_size);
00378         }
00379         return -1;
00380 }
00381 
00382 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
00383 {
00384         if (wpa_s->driver->get_bssid) {
00385                 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
00386         }
00387         return -1;
00388 }
00389 
00390 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
00391 {
00392         if (wpa_s->driver->get_ssid) {
00393                 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
00394         }
00395         return -1;
00396 }
00397 
00398 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
00399                                    const u8 *addr, int key_idx, int set_tx,
00400                                    const u8 *seq, size_t seq_len,
00401                                    const u8 *key, size_t key_len)
00402 {
00403         if (wpa_s->driver->set_key) {
00404                 wpa_s->keys_cleared = 0;
00405                 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
00406                                               key_idx, set_tx, seq, seq_len,
00407                                               key, key_len);
00408         }
00409         return -1;
00410 }
00411 
00412 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
00413                                          const u8 *addr, int reason_code)
00414 {
00415         if (wpa_s->driver->deauthenticate) {
00416                 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
00417                                                      reason_code);
00418         }
00419         return -1;
00420 }
00421 
00422 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
00423                                        const u8 *addr, int reason_code)
00424 {
00425         if (wpa_s->driver->disassociate) {
00426                 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
00427                                                    reason_code);
00428         }
00429         return -1;
00430 }
00431 
00432 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
00433                                     const u8 *bssid, const u8 *pmkid)
00434 {
00435         if (wpa_s->driver->add_pmkid) {
00436                 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
00437         }
00438         return -1;
00439 }
00440 
00441 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
00442                                        const u8 *bssid, const u8 *pmkid)
00443 {
00444         if (wpa_s->driver->remove_pmkid) {
00445                 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
00446                                                    pmkid);
00447         }
00448         return -1;
00449 }
00450 
00451 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
00452 {
00453         if (wpa_s->driver->flush_pmkid) {
00454                 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
00455         }
00456         return -1;
00457 }
00458 
00459 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
00460                                    struct wpa_driver_capa *capa)
00461 {
00462         if (wpa_s->driver->get_capa) {
00463                 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
00464         }
00465         return -1;
00466 }
00467 
00468 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
00469 {
00470         if (wpa_s->driver->poll) {
00471                 wpa_s->driver->poll(wpa_s->drv_priv);
00472         }
00473 }
00474 
00475 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
00476 {
00477         if (wpa_s->driver->get_ifname) {
00478                 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
00479         }
00480         return NULL;
00481 }
00482 
00483 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
00484 {
00485         if (wpa_s->driver->get_mac_addr) {
00486                 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
00487         }
00488         return NULL;
00489 }
00490 
00491 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
00492                                      const u8 *dst, u16 proto,
00493                                      const u8 *data, size_t data_len)
00494 {
00495         if (wpa_s->driver->send_eapol)
00496                 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
00497                                                  data, data_len);
00498         return -1;
00499 }
00500 
00501 #endif /* WPA_SUPPLICANT_I_H */
00502 

Generated on Sat May 6 21:13:42 2006 for wpa_supplicant by  doxygen 1.4.2