X-Git-Url: http://git.maemo.org/git/?p=wpasupplicant;a=blobdiff_plain;f=src%2Fdrivers%2Fdriver.h;h=cadc5818a2bc375475fb0ba9e42f1b4cd5293c43;hp=e3f9cd710087c75a069816d4bda7d11341223977;hb=4b9841d34c0d601a898f508c4164fe2451494fdd;hpb=c2a04078513bffce2e3c2968fbb1e1381ab72059 diff --git a/src/drivers/driver.h b/src/drivers/driver.h index e3f9cd7..cadc581 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1,6 +1,6 @@ /* * WPA Supplicant - driver interface definition - * Copyright (c) 2003-2008, Jouni Malinen + * Copyright (c) 2003-2009, Jouni Malinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -19,6 +19,41 @@ #include "defs.h" +#define HOSTAPD_CHAN_DISABLED 0x00000001 +#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002 +#define HOSTAPD_CHAN_NO_IBSS 0x00000004 +#define HOSTAPD_CHAN_RADAR 0x00000008 + +struct hostapd_channel_data { + short chan; /* channel number (IEEE 802.11) */ + short freq; /* frequency in MHz */ + int flag; /* flag for hostapd use (HOSTAPD_CHAN_*) */ + u8 max_tx_power; /* maximum transmit power in dBm */ +}; + +#define HOSTAPD_RATE_ERP 0x00000001 +#define HOSTAPD_RATE_BASIC 0x00000002 +#define HOSTAPD_RATE_PREAMBLE2 0x00000004 +#define HOSTAPD_RATE_SUPPORTED 0x00000010 +#define HOSTAPD_RATE_OFDM 0x00000020 +#define HOSTAPD_RATE_CCK 0x00000040 +#define HOSTAPD_RATE_MANDATORY 0x00000100 + +struct hostapd_rate_data { + int rate; /* rate in 100 kbps */ + int flags; /* HOSTAPD_RATE_ flags */ +}; + +struct hostapd_hw_modes { + hostapd_hw_mode mode; + int num_channels; + struct hostapd_channel_data *channels; + int num_rates; + struct hostapd_rate_data *rates; + u16 ht_capab; +}; + + #define AUTH_ALG_OPEN_SYSTEM 0x01 #define AUTH_ALG_SHARED_KEY 0x02 #define AUTH_ALG_LEAP 0x04 @@ -26,6 +61,7 @@ #define IEEE80211_MODE_INFRA 0 #define IEEE80211_MODE_IBSS 1 +#define IEEE80211_MODE_AP 2 #define IEEE80211_CAP_ESS 0x0001 #define IEEE80211_CAP_IBSS 0x0002 @@ -188,6 +224,13 @@ struct wpa_driver_scan_params { * extra_ies_len - Length of extra_ies in octets */ size_t extra_ies_len; + + /** + * freqs - Array of frequencies to scan or %NULL for all frequencies + * + * The frequency is set in MHz. The array is zero-terminated. + */ + int *freqs; }; /** @@ -202,6 +245,9 @@ struct wpa_driver_auth_params { int auth_alg; const u8 *ie; size_t ie_len; + const u8 *wep_key[4]; + size_t wep_key_len[4]; + int wep_tx_keyidx; }; /** @@ -350,6 +396,15 @@ struct wpa_driver_associate_params { * be prepared to handle %NULL value as an error. */ const u8 *psk; + + /** + * drop_unencrypted - Enable/disable unencrypted frame filtering + * + * Configure the driver to drop all non-EAPOL frames (both receive and + * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must + * still be allowed for key negotiation. + */ + int drop_unencrypted; }; /** @@ -387,54 +442,70 @@ struct wpa_driver_capa { /* Driver provides separate commands for authentication and association (SME in * wpa_supplicant). */ #define WPA_DRIVER_FLAGS_SME 0x00000020 +/* Driver supports AP mode */ +#define WPA_DRIVER_FLAGS_AP 0x00000040 unsigned int flags; int max_scan_ssids; }; -#define WPA_CHAN_W_SCAN 0x00000001 -#define WPA_CHAN_W_ACTIVE_SCAN 0x00000002 -#define WPA_CHAN_W_IBSS 0x00000004 - -struct wpa_channel_data { - short chan; /* channel number (IEEE 802.11) */ - short freq; /* frequency in MHz */ - int flag; /* flag for user space use (WPA_CHAN_*) */ +struct ieee80211_rx_status { + int channel; + int ssi; }; -#define WPA_RATE_ERP 0x00000001 -#define WPA_RATE_BASIC 0x00000002 -#define WPA_RATE_PREAMBLE2 0x00000004 -#define WPA_RATE_SUPPORTED 0x00000010 -#define WPA_RATE_OFDM 0x00000020 -#define WPA_RATE_CCK 0x00000040 -#define WPA_RATE_MANDATORY 0x00000100 -struct wpa_rate_data { - int rate; /* rate in 100 kbps */ - int flags; /* WPA_RATE_ flags */ +struct hostapd_data; + +struct hostap_sta_driver_data { + unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes; + unsigned long current_tx_rate; + unsigned long inactive_msec; + unsigned long flags; + unsigned long num_ps_buf_frames; + unsigned long tx_retry_failed; + unsigned long tx_retry_count; + int last_rssi; + int last_ack_rssi; }; -typedef enum { - WPA_MODE_IEEE80211B, - WPA_MODE_IEEE80211G, - WPA_MODE_IEEE80211A, - NUM_WPA_MODES -} wpa_hw_mode; +struct hostapd_sta_add_params { + const u8 *addr; + u16 aid; + u16 capability; + const u8 *supp_rates; + size_t supp_rates_len; + int flags; + u16 listen_interval; + const struct ht_cap_ie *ht_capabilities; +}; -struct wpa_hw_modes { - wpa_hw_mode mode; - int num_channels; - struct wpa_channel_data *channels; - int num_rates; - struct wpa_rate_data *rates; +struct hostapd_freq_params { + int mode; + int freq; + int channel; + int ht_enabled; + int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled, + * secondary channel below primary, 1 = HT40 + * enabled, secondary channel above primary */ }; +enum hostapd_driver_if_type { + HOSTAPD_IF_VLAN +}; -struct ieee80211_rx_status { - int channel; - int ssi; +struct wpa_init_params { + const u8 *bssid; + const char *ifname; + const u8 *ssid; + size_t ssid_len; + const char *test_socket; + int use_pae_group_addr; + char **bridge; + size_t num_bridge; + + u8 *own_addr; /* buffer for writing own MAC address */ }; @@ -620,6 +691,9 @@ struct wpa_driver_ops { * Configure the driver to drop all non-EAPOL frames (both receive and * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must * still be allowed for key negotiation. + * + * This function is deprecated. New driver wrapper implementations + * should use associate() parameter drop_unencrypted instead. */ int (*set_drop_unencrypted)(void *priv, int enabled); @@ -637,7 +711,7 @@ struct wpa_driver_ops { * results event for wpa_supplicant which will eventually request the * results with wpa_driver_get_scan_results(). * - * This function is depracated. New driver wrapper implementations + * This function is deprecated. New driver wrapper implementations * should implement support for scan2(). */ int (*scan)(void *priv, const u8 *ssid, size_t ssid_len); @@ -655,7 +729,7 @@ struct wpa_driver_ops { * returned and the remaining entries will not be included in the * buffer. * - * This function is depracated. New driver wrapper implementations + * This function is deprecated. New driver wrapper implementations * should implement support for get_scan_results2(). */ int (*get_scan_results)(void *priv, @@ -711,6 +785,9 @@ struct wpa_driver_ops { * associate() params, so set_auth_alg may not be needed in case of * most drivers. * + * This function is deprecated. New driver wrapper implementations + * should use associate() parameter auth_alg instead. + * * Returns: 0 on success, -1 on failure */ int (*set_auth_alg)(void *priv, int auth_alg); @@ -773,7 +850,7 @@ struct wpa_driver_ops { int (*flush_pmkid)(void *priv); /** - * flush_pmkid - Flush PMKSA cache + * get_capa - Get driver capabilities * @priv: private driver interface data * * Returns: 0 on success, -1 on failure @@ -886,14 +963,14 @@ struct wpa_driver_ops { * This function is only needed for drivers that export MLME * (management frame processing) to wpa_supplicant. */ - struct wpa_hw_modes * (*get_hw_feature_data)(void *priv, - u16 *num_modes, - u16 *flags); + struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv, + u16 *num_modes, + u16 *flags); /** * set_channel - Set channel * @priv: Private driver interface data - * @phymode: WPA_MODE_IEEE80211B, .. + * @phymode: HOSTAPD_MODE_IEEE80211B, .. * @chan: IEEE 802.11 channel number * @freq: Frequency of the channel in MHz * Returns: 0 on success, -1 on failure @@ -901,7 +978,7 @@ struct wpa_driver_ops { * This function is only needed for drivers that export MLME * (management frame processing) to wpa_supplicant. */ - int (*set_channel)(void *priv, wpa_hw_mode phymode, int chan, + int (*set_channel)(void *priv, hostapd_hw_mode phymode, int chan, int freq); /** @@ -1028,8 +1105,12 @@ struct wpa_driver_ops { * This handler will be called before any key configuration and call to * associate() handler in order to allow the operation mode to be * configured as early as possible. This information is also available - * in associate() params and as such, some driver wrappers may not need + * in associate() params and as such, driver wrappers may not need * to implement set_mode() handler. + * + * This function is deprecated. New driver wrapper implementations + * should use associate() parameter mode instead. + * * Returns: 0 on success, -1 on failure */ int (*set_mode)(void *priv, int mode); @@ -1114,8 +1195,148 @@ struct wpa_driver_ops { * function is expected to take care of IEEE 802.11 authentication, * too. */ - int (*authenticate)(void *priv, - struct wpa_driver_auth_params *params); + int (*authenticate)(void *priv, + struct wpa_driver_auth_params *params); + + int (*set_beacon)(void *priv, const u8 *head, size_t head_len, + const u8 *tail, size_t tail_len, int dtim_period); + + int (*set_beacon_int)(void *priv, int value); + + void * (*hapd_init)(struct hostapd_data *hapd, + struct wpa_init_params *params); + void (*hapd_deinit)(void *priv); + + /** + * set_8021x - enable/disable IEEE 802.1X support + * @ifname: Interface name (for multi-SSID/VLAN support) + * @priv: driver private data + * @enabled: 1 = enable, 0 = disable + * + * Returns: 0 on success, -1 on failure + * + * Configure the kernel driver to enable/disable 802.1X support. + * This may be an empty function if 802.1X support is always enabled. + */ + int (*set_ieee8021x)(const char *ifname, void *priv, int enabled); + + /** + * set_privacy - enable/disable privacy + * @priv: driver private data + * @enabled: 1 = privacy enabled, 0 = disabled + * + * Return: 0 on success, -1 on failure + * + * Configure privacy. + */ + int (*set_privacy)(const char *ifname, void *priv, int enabled); + + int (*hapd_set_key)(const char *ifname, void *priv, wpa_alg alg, + const u8 *addr, int key_idx, int set_tx, + const u8 *seq, size_t seq_len, + const u8 *key, size_t key_len); + int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr, + int idx, u8 *seq); + int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr, + int idx, u8 *seq); + int (*flush)(void *priv); + int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem, + size_t elem_len); + + int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data, + const u8 *addr); + int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data, + size_t data_len, int encrypt, + const u8 *own_addr); + int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr, + int reason); + int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr, + int reason); + int (*sta_remove)(void *priv, const u8 *addr); + int (*hapd_get_ssid)(const char *ifname, void *priv, u8 *buf, int len); + int (*hapd_set_ssid)(const char *ifname, void *priv, const u8 *buf, + int len); + int (*hapd_set_countermeasures)(void *priv, int enabled); + int (*sta_add)(const char *ifname, void *priv, + struct hostapd_sta_add_params *params); + int (*get_inact_sec)(void *priv, const u8 *addr); + int (*sta_clear_stats)(void *priv, const u8 *addr); + + int (*set_freq)(void *priv, struct hostapd_freq_params *freq); + int (*set_rts)(void *priv, int rts); + int (*set_frag)(void *priv, int frag); + int (*set_retry)(void *priv, int short_retry, int long_retry); + + int (*sta_set_flags)(void *priv, const u8 *addr, + int total_flags, int flags_or, int flags_and); + int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates, + int mode); + int (*set_ieee80211d)(void *priv, int enabled); + int (*hapd_set_beacon)(const char *ifname, void *priv, + const u8 *head, size_t head_len, + const u8 *tail, size_t tail_len, + int dtim_period); + + /* Configure internal bridge: + * 0 = disabled, i.e., client separation is enabled (no bridging of + * packets between associated STAs + * 1 = enabled, i.e., bridge packets between associated STAs (default) + */ + int (*set_internal_bridge)(void *priv, int value); + /* Configure broadcast SSID mode: + * 0 = include SSID in Beacon frames and reply to Probe Request frames + * that use broadcast SSID + * 1 = hide SSID from Beacon frames and ignore Probe Request frames for + * broadcast SSID + */ + int (*set_broadcast_ssid)(void *priv, int value); + int (*set_cts_protect)(void *priv, int value); + int (*set_preamble)(void *priv, int value); + int (*set_short_slot_time)(void *priv, int value); + int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min, + int cw_max, int burst_time); + int (*bss_add)(void *priv, const char *ifname, const u8 *bssid); + int (*bss_remove)(void *priv, const char *ifname); + int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask); + int (*passive_scan)(void *priv, int now, int our_mode_only, + int interval, int _listen, int *channel, + int *last_rx); + int (*if_add)(const char *iface, void *priv, + enum hostapd_driver_if_type type, char *ifname, + const u8 *addr); + int (*if_update)(void *priv, enum hostapd_driver_if_type type, + char *ifname, const u8 *addr); + int (*if_remove)(void *priv, enum hostapd_driver_if_type type, + const char *ifname, const u8 *addr); + int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname, + int vlan_id); + /** + * commit - Optional commit changes handler + * @priv: driver private data + * Returns: 0 on success, -1 on failure + * + * This optional handler function can be registered if the driver + * interface implementation needs to commit changes (e.g., by setting + * network interface up) at the end of initial configuration. If set, + * this handler will be called after initial setup has been completed. + */ + int (*commit)(void *priv); + + int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto, + const u8 *data, size_t data_len); + + int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted, + u32 session_timeout); + int (*set_radius_acl_expire)(void *priv, const u8 *mac); + + int (*set_ht_params)(const char *ifname, void *priv, + const u8 *ht_capab, size_t ht_capab_len, + const u8 *ht_oper, size_t ht_oper_len); + + int (*set_wps_beacon_ie)(const char *ifname, void *priv, + const u8 *ie, size_t len); + int (*set_wps_probe_resp_ie)(const char *ifname, void *priv, + const u8 *ie, size_t len); }; /** @@ -1271,7 +1492,16 @@ typedef enum wpa_event_type { * to receiving deauthenticate frame from the AP or when sending that * frame to the current AP. */ - EVENT_DEAUTH + EVENT_DEAUTH, + + /** + * EVENT_ASSOC_REJECT - Association rejected + * + * This event should be called when (re)association attempt has been + * rejected by the AP. Information about authentication result is + * included in union wpa_event_data::assoc_reject. + */ + EVENT_ASSOC_REJECT } wpa_event_type; @@ -1352,6 +1582,7 @@ union wpa_event_data { */ struct michael_mic_failure { int unicast; + const u8 *src; } michael_mic_failure; /** @@ -1420,6 +1651,34 @@ union wpa_event_data { const u8 *ies; size_t ies_len; } auth; + + /** + * struct assoc_reject - Data for EVENT_ASSOC_REJECT events + */ + struct assoc_reject { + /** + * resp_ies - (Re)Association Response IEs + * + * Optional association data from the driver. This data is not + * required WPA, but may be useful for some protocols and as + * such, should be reported if this is available to the driver + * interface. + * + * This should start with the first IE (fixed fields before IEs + * are not included). + */ + u8 *resp_ies; + + /** + * resp_ies_len - Length of resp_ies in bytes + */ + size_t resp_ies_len; + + /** + * status_code - Status Code from (Re)association Response + */ + u16 status_code; + } assoc_reject; }; /** @@ -1454,8 +1713,6 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len, struct ieee80211_rx_status *rx_status); -void wpa_supplicant_sta_free_hw_features(struct wpa_hw_modes *hw_features, - size_t num_hw_features); const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie); #define WPA_IE_VENDOR_TYPE 0x0050f201 @@ -1468,4 +1725,38 @@ int wpa_scan_get_max_rate(const struct wpa_scan_res *res); void wpa_scan_results_free(struct wpa_scan_results *res); void wpa_scan_sort_results(struct wpa_scan_results *res); +/* hostapd functions for driver wrappers */ + +struct sta_info; +struct ieee80211_hdr; + +void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, + int reassoc); +void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr, + const u8 *buf, size_t len, int ack); +void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, + const struct ieee80211_hdr *hdr, size_t len); +int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, + const u8 *ie, size_t ielen); +void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr); +void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa, + const u8 *buf, size_t len); + +struct hostapd_frame_info { + u32 phytype; + u32 channel; + u32 datarate; + u32 ssi_signal; + + unsigned int passive_scan:1; +}; + +void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, struct hostapd_frame_info *fi); +void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len, + u16 stype, int ok); +void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr); +struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd, + const u8 *addr); + #endif /* DRIVER_H */