Merge set_key and hapd_set_key driver_ops into a single function

This commit is contained in:
Jouni Malinen 2009-11-23 16:58:32 +02:00 committed by Jouni Malinen
parent fd7a5dd15f
commit 642187d6bf
19 changed files with 81 additions and 117 deletions

View file

@ -87,9 +87,9 @@ hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
int set_tx, const u8 *seq, size_t seq_len,
const u8 *key, size_t key_len)
{
if (hapd->driver == NULL || hapd->driver->hapd_set_key == NULL)
if (hapd->driver == NULL || hapd->driver->set_key == NULL)
return 0;
return hapd->driver->hapd_set_key(ifname, hapd->drv_priv, alg, addr,
return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
key_idx, set_tx, seq, seq_len, key,
key_len);
}

View file

@ -15,7 +15,7 @@
#ifndef DRIVER_H
#define DRIVER_H
#define WPA_SUPPLICANT_DRIVER_VERSION 3
#define WPA_SUPPLICANT_DRIVER_VERSION 4
#include "defs.h"
@ -593,6 +593,7 @@ struct wpa_driver_ops {
/**
* set_key - Configure encryption key
* @ifname: Interface name (for multi-SSID/VLAN support)
* @priv: private driver interface data
* @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
* %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
@ -634,8 +635,9 @@ struct wpa_driver_ops {
* in driver_*.c set_key() implementation, see driver_ndis.c for an
* example on how this can be done.
*/
int (*set_key)(void *priv, wpa_alg alg, const u8 *addr,
int key_idx, int set_tx, const u8 *seq, size_t seq_len,
int (*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);
/**
@ -1246,10 +1248,6 @@ struct wpa_driver_ops {
*/
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,

View file

@ -1315,7 +1315,7 @@ const struct wpa_driver_ops wpa_driver_atheros_ops = {
.deinit = madwifi_deinit,
.set_ieee8021x = madwifi_set_ieee8021x,
.set_privacy = madwifi_set_privacy,
.hapd_set_key = madwifi_set_key,
.set_key = madwifi_set_key,
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,

View file

@ -188,8 +188,8 @@ static int wpa_driver_atmel_set_wpa(void *priv, int enabled)
}
static int wpa_driver_atmel_set_key(void *priv, wpa_alg alg,
const u8 *addr, int key_idx,
static int wpa_driver_atmel_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)
{

View file

@ -162,7 +162,8 @@ static int wpa_driver_broadcom_set_wpa(void *priv, int enable)
return 0;
}
static int wpa_driver_broadcom_set_key(void *priv, wpa_alg alg,
static int wpa_driver_broadcom_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)

View file

@ -828,7 +828,7 @@ const struct wpa_driver_ops wpa_driver_bsd_ops = {
.hapd_deinit = bsd_deinit,
.set_ieee8021x = bsd_set_ieee8021x,
.set_privacy = bsd_set_privacy,
.hapd_set_key = bsd_set_key,
.set_key = bsd_set_key,
.get_seqnum = bsd_get_seqnum,
.flush = bsd_flush,
.set_generic_elem = bsd_set_opt_ie,
@ -1023,7 +1023,7 @@ wpa_driver_bsd_del_key(struct wpa_driver_bsd_data *drv, int key_idx,
}
static int
wpa_driver_bsd_set_key(void *priv, wpa_alg alg,
wpa_driver_bsd_set_key(const char *ifname, void *priv, wpa_alg alg,
const unsigned char *addr, int key_idx, int set_tx,
const u8 *seq, size_t seq_len,
const u8 *key, size_t key_len)

View file

@ -431,10 +431,10 @@ static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
}
static int hostap_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)
static int wpa_driver_hostap_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)
{
struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param *param;
@ -1350,8 +1350,8 @@ static void show_set_key_error(struct prism2_hostapd_param *param)
}
static int wpa_driver_hostap_set_key(void *priv, wpa_alg alg,
const u8 *addr, int key_idx,
static int wpa_driver_hostap_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)
{
@ -1700,12 +1700,12 @@ static void wpa_driver_hostap_deinit(void *priv)
const struct wpa_driver_ops wpa_driver_hostap_ops = {
.name = "hostap",
.desc = "Host AP driver (Intersil Prism2/2.5/3)",
.set_key = wpa_driver_hostap_set_key,
#ifdef HOSTAPD
.hapd_init = hostap_init,
.hapd_deinit = hostap_driver_deinit,
.set_ieee8021x = hostap_set_ieee8021x,
.set_privacy = hostap_set_privacy,
.hapd_set_key = hostap_set_key,
.get_seqnum = hostap_get_seqnum,
.flush = hostap_flush,
.set_generic_elem = hostap_set_generic_elem,
@ -1727,7 +1727,6 @@ const struct wpa_driver_ops wpa_driver_hostap_ops = {
.get_bssid = wpa_driver_hostap_get_bssid,
.get_ssid = wpa_driver_hostap_get_ssid,
.set_wpa = wpa_driver_hostap_set_wpa,
.set_key = wpa_driver_hostap_set_key,
.set_countermeasures = wpa_driver_hostap_set_countermeasures,
.set_drop_unencrypted = wpa_driver_hostap_set_drop_unencrypted,
.scan = wpa_driver_hostap_scan,

View file

@ -213,7 +213,7 @@ static int wpa_driver_ipw_set_wpa(void *priv, int enabled)
}
static int wpa_driver_ipw_set_key(void *priv, wpa_alg alg,
static int wpa_driver_ipw_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)

View file

@ -455,9 +455,10 @@ madwifi_del_key(void *priv, const u8 *addr, int key_idx)
}
static int
madwifi_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)
wpa_driver_madwifi_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)
{
struct madwifi_driver_data *drv = priv;
struct ieee80211req_key wk;
@ -1530,7 +1531,7 @@ wpa_driver_madwifi_del_key(struct wpa_driver_madwifi_data *drv, int key_idx,
}
static int
wpa_driver_madwifi_set_key(void *priv, wpa_alg alg,
wpa_driver_madwifi_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)
@ -1552,8 +1553,8 @@ wpa_driver_madwifi_set_key(void *priv, wpa_alg alg,
* configuration with IEEE80211_IOCTL_SETKEY, so use
* Linux wireless extensions ioctl for this.
*/
return wpa_driver_wext_set_key(drv->wext, alg, addr,
key_idx, set_tx,
return wpa_driver_wext_set_key(ifname, drv->wext, alg,
addr, key_idx, set_tx,
seq, seq_len,
key, key_len);
}
@ -1910,12 +1911,12 @@ static void wpa_driver_madwifi_deinit(void *priv)
const struct wpa_driver_ops wpa_driver_madwifi_ops = {
.name = "madwifi",
.desc = "MADWIFI 802.11 support (Atheros, etc.)",
.set_key = wpa_driver_madwifi_set_key,
#ifdef HOSTAPD
.hapd_init = madwifi_init,
.hapd_deinit = madwifi_deinit,
.set_ieee8021x = madwifi_set_ieee8021x,
.set_privacy = madwifi_set_privacy,
.hapd_set_key = madwifi_set_key,
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,
@ -1934,7 +1935,6 @@ const struct wpa_driver_ops wpa_driver_madwifi_ops = {
#else /* HOSTAPD */
.get_bssid = wpa_driver_madwifi_get_bssid,
.get_ssid = wpa_driver_madwifi_get_ssid,
.set_key = wpa_driver_madwifi_set_key,
.init = wpa_driver_madwifi_init,
.deinit = wpa_driver_madwifi_deinit,
.set_countermeasures = wpa_driver_madwifi_set_countermeasures,

View file

@ -975,8 +975,8 @@ static int wpa_driver_ndis_add_wep(struct wpa_driver_ndis_data *drv,
}
static int wpa_driver_ndis_set_key(void *priv, wpa_alg alg, const u8 *addr,
int key_idx, int set_tx,
static int wpa_driver_ndis_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)
{
@ -1083,7 +1083,8 @@ wpa_driver_ndis_associate(void *priv,
continue;
wpa_printf(MSG_DEBUG, "NDIS: Re-setting static WEP "
"key %d", i);
wpa_driver_ndis_set_key(drv, WPA_ALG_WEP, bcast, i,
wpa_driver_ndis_set_key(drv->ifname, drv, WPA_ALG_WEP,
bcast, i,
i == params->wep_tx_keyidx,
NULL, 0, params->wep_key[i],
params->wep_key_len[i]);
@ -3221,7 +3222,6 @@ const struct wpa_driver_ops wpa_driver_ndis_ops = {
NULL /* hapd_deinit */,
NULL /* set_ieee8021x */,
NULL /* set_privacy */,
NULL /* hapd_set_key */,
NULL /* get_seqnum */,
NULL /* get_seqnum_igtk */,
NULL /* flush */,

View file

@ -107,8 +107,8 @@ static int wpa_ndiswrapper_set_wpa(void *priv, int enabled)
return ret;
}
static int wpa_ndiswrapper_set_key(void *priv, wpa_alg alg, const u8 *addr,
int key_idx, int set_tx,
static int wpa_ndiswrapper_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)
{
@ -142,8 +142,8 @@ static int wpa_ndiswrapper_set_key(void *priv, wpa_alg alg, const u8 *addr,
* did not associate. Try to make sure the keys are cleared so
* that plaintext APs can be used in all cases.
*/
wpa_driver_wext_set_key(drv->wext, alg, addr, key_idx, set_tx,
seq, seq_len, key, key_len);
wpa_driver_wext_set_key(ifname, drv->wext, alg, addr, key_idx,
set_tx, seq, seq_len, key, key_len);
}
return ret;

View file

@ -1726,11 +1726,14 @@ nla_put_failure:
}
static int nl_set_encr(int ifindex, struct wpa_driver_nl80211_data *drv,
wpa_alg alg, const u8 *addr, int key_idx, int set_tx,
static int wpa_driver_nl80211_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)
{
struct wpa_driver_nl80211_data *drv = priv;
int ifindex = if_nametoindex(ifname);
struct nl_msg *msg;
int ret;
@ -1942,18 +1945,6 @@ nla_put_failure:
}
static int wpa_driver_nl80211_set_key(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)
{
struct wpa_driver_nl80211_data *drv = priv;
return nl_set_encr(drv->ifindex, drv, alg, addr, key_idx, set_tx, seq,
seq_len, key, key_len);
}
static int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv,
const u8 *addr, int cmd, u16 reason_code)
{
@ -2046,7 +2037,8 @@ retry:
for (i = 0; i < 4; i++) {
if (!params->wep_key[i])
continue;
wpa_driver_nl80211_set_key(drv, WPA_ALG_WEP, NULL, i,
wpa_driver_nl80211_set_key(drv->ifname, drv, WPA_ALG_WEP, NULL,
i,
i == params->wep_tx_keyidx, NULL, 0,
params->wep_key[i],
params->wep_key_len[i]);
@ -3746,16 +3738,6 @@ static int have_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx)
}
static int i802_set_key(const char *iface, 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)
{
struct wpa_driver_nl80211_data *drv = priv;
return nl_set_encr(if_nametoindex(iface), drv, alg, addr, key_idx,
set_tx, seq, seq_len, key, key_len);
}
static inline int min_int(int a, int b)
{
if (a < b)
@ -4404,7 +4386,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
#ifdef HOSTAPD
.hapd_init = i802_init,
.hapd_deinit = i802_deinit,
.hapd_set_key = i802_set_key,
.get_seqnum = i802_get_seqnum,
.flush = i802_flush,
.read_sta_data = i802_read_sta_data,

View file

@ -199,8 +199,9 @@ prism54_sta_set_flags(void *priv, const u8 *addr, int total_flags,
}
static int prism54_set_key(const char *ifname, void *priv, wpa_alg alg,
const u8 *addr, int key_idx, int set_tx,
static int wpa_driver_prism54_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)
{
@ -1159,7 +1160,8 @@ static int wpa_driver_prism54_set_wpa(void *priv, int enabled)
}
static int wpa_driver_prism54_set_key(void *priv, wpa_alg alg,
static int wpa_driver_prism54_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)
@ -1419,12 +1421,12 @@ static void wpa_driver_prism54_deinit(void *priv)
const struct wpa_driver_ops wpa_driver_prism54_ops = {
.name = "prism54",
.desc = "Prism54.org driver (Intersil Prism GT/Duette/Indigo)",
.set_key = wpa_driver_prism54_set_key,
#ifdef HOSTAPD
.hapd_init = prism54_driver_init,
.hapd_deinit = prism54_driver_deinit,
/* .set_ieee8021x = prism54_init_1x, */
.set_privacy = prism54_set_privacy_invoked,
.hapd_set_key = prism54_set_key,
.get_seqnum = prism54_get_seqnum,
.flush = prism54_flush,
.set_generic_elem = prism54_set_generic_elem,
@ -1438,7 +1440,6 @@ const struct wpa_driver_ops wpa_driver_prism54_ops = {
.get_bssid = wpa_driver_prism54_get_bssid,
.get_ssid = wpa_driver_prism54_get_ssid,
.set_wpa = wpa_driver_prism54_set_wpa,
.set_key = wpa_driver_prism54_set_key,
.set_countermeasures = wpa_driver_prism54_set_countermeasures,
.set_drop_unencrypted = wpa_driver_prism54_set_drop_unencrypted,
.scan = wpa_driver_prism54_scan,

View file

@ -196,7 +196,8 @@ wpa_driver_privsep_get_scan_results2(void *priv)
}
static int wpa_driver_privsep_set_key(void *priv, wpa_alg alg, const u8 *addr,
static int wpa_driver_privsep_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)

View file

@ -1241,7 +1241,8 @@ static int wpa_driver_ralink_add_wep(struct wpa_driver_ralink_data *drv,
return res;
}
static int wpa_driver_ralink_set_key(void *priv, wpa_alg alg, const u8 *addr,
static int wpa_driver_ralink_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)

View file

@ -1124,21 +1124,6 @@ static int test_driver_set_privacy(const char *ifname, void *priv, int enabled)
}
static int test_driver_set_key(const char *iface, 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)
{
wpa_printf(MSG_DEBUG, "%s(iface=%s alg=%d idx=%d set_tx=%d)",
__func__, iface, alg, key_idx, set_tx);
if (addr)
wpa_printf(MSG_DEBUG, " addr=" MACSTR, MAC2STR(addr));
if (key)
wpa_hexdump_key(MSG_DEBUG, " key", key, key_len);
return 0;
}
static int test_driver_set_sta_vlan(void *priv, const u8 *addr,
const char *ifname, int vlan_id)
{
@ -1457,22 +1442,20 @@ static struct wpa_scan_results * wpa_driver_test_get_scan_results2(void *priv)
}
static int wpa_driver_test_set_key(void *priv, wpa_alg alg, const u8 *addr,
int key_idx, int set_tx,
static int wpa_driver_test_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)
{
wpa_printf(MSG_DEBUG, "%s: priv=%p alg=%d key_idx=%d set_tx=%d",
__func__, priv, alg, key_idx, set_tx);
if (addr) {
wpa_printf(MSG_DEBUG, "%s: ifname=%s priv=%p alg=%d key_idx=%d "
"set_tx=%d",
__func__, ifname, priv, alg, key_idx, set_tx);
if (addr)
wpa_printf(MSG_DEBUG, " addr=" MACSTR, MAC2STR(addr));
}
if (seq) {
if (seq)
wpa_hexdump(MSG_DEBUG, " seq", seq, seq_len);
}
if (key) {
wpa_hexdump(MSG_DEBUG, " key", key, key_len);
}
if (key)
wpa_hexdump_key(MSG_DEBUG, " key", key, key_len);
return 0;
}
@ -2527,7 +2510,6 @@ const struct wpa_driver_ops wpa_driver_test_ops = {
.valid_bss_mask = test_driver_valid_bss_mask,
.hapd_set_ssid = test_driver_set_ssid,
.set_privacy = test_driver_set_privacy,
.hapd_set_key = test_driver_set_key,
.set_sta_vlan = test_driver_set_sta_vlan,
.sta_add = test_driver_sta_add,
.send_ether = test_driver_send_ether,

View file

@ -1820,7 +1820,7 @@ static int wpa_driver_wext_set_key_ext(void *priv, wpa_alg alg,
* This function uses SIOCSIWENCODEEXT by default, but tries to use
* SIOCSIWENCODE if the extended ioctl fails when configuring a WEP key.
*/
int wpa_driver_wext_set_key(void *priv, wpa_alg alg,
int wpa_driver_wext_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)

View file

@ -53,7 +53,7 @@ int wpa_driver_wext_get_ssid(void *priv, u8 *ssid);
int wpa_driver_wext_set_ssid(void *priv, const u8 *ssid, size_t ssid_len);
int wpa_driver_wext_set_freq(void *priv, int freq);
int wpa_driver_wext_set_mode(void *priv, int mode);
int wpa_driver_wext_set_key(void *priv, wpa_alg alg,
int wpa_driver_wext_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);

View file

@ -160,9 +160,9 @@ static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
{
if (wpa_s->driver->set_key) {
wpa_s->keys_cleared = 0;
return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
key_idx, set_tx, seq, seq_len,
key, key_len);
return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv,
alg, addr, key_idx, set_tx,
seq, seq_len, key, key_len);
}
return -1;
}