Merge wireless_event_{,de}init() into {,de}init() driver op

This commit is contained in:
Jouni Malinen 2009-04-03 11:51:40 +03:00 committed by Jouni Malinen
parent 0915d02c3c
commit a9a2cb5abb
8 changed files with 40 additions and 79 deletions

View file

@ -73,9 +73,6 @@ struct hapd_driver_ops {
void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
void (*deinit)(void *priv);
int (*wireless_event_init)(void *priv);
void (*wireless_event_deinit)(void *priv);
/**
* set_8021x - enable/disable IEEE 802.1X support
* @ifname: Interface name (for multi-SSID/VLAN support)

View file

@ -1074,9 +1074,8 @@ madwifi_get_we_version(struct madwifi_driver_data *drv)
static int
madwifi_wireless_event_init(void *priv)
madwifi_wireless_event_init(struct madwifi_driver_data *drv)
{
struct madwifi_driver_data *drv = priv;
int s;
struct sockaddr_nl local;
@ -1107,16 +1106,12 @@ madwifi_wireless_event_init(void *priv)
static void
madwifi_wireless_event_deinit(void *priv)
madwifi_wireless_event_deinit(struct madwifi_driver_data *drv)
{
struct madwifi_driver_data *drv = priv;
if (drv != NULL) {
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
@ -1232,6 +1227,9 @@ madwifi_init(struct hostapd_data *hapd)
madwifi_receive_probe_req(drv);
if (madwifi_wireless_event_init(drv))
goto bad;
return drv;
bad:
if (drv->sock_xmit != NULL)
@ -1249,6 +1247,7 @@ madwifi_deinit(void *priv)
{
struct madwifi_driver_data *drv = priv;
madwifi_wireless_event_deinit(drv);
(void) madwifi_set_iface_flags(drv, 0);
if (drv->ioctl_sock >= 0)
close(drv->ioctl_sock);
@ -1326,8 +1325,6 @@ const struct hapd_driver_ops wpa_driver_atheros_ops = {
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,
.wireless_event_init = madwifi_wireless_event_init,
.wireless_event_deinit = madwifi_wireless_event_deinit,
.sta_set_flags = madwifi_sta_set_flags,
.read_sta_data = madwifi_read_sta_driver_data,
.send_eapol = madwifi_send_eapol,

View file

@ -594,9 +594,8 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
}
static int
bsd_wireless_event_init(void *priv)
bsd_wireless_event_init(struct bsd_driver_data *drv)
{
struct bsd_driver_data *drv = priv;
int s;
drv->wext_sock = -1;
@ -613,16 +612,12 @@ bsd_wireless_event_init(void *priv)
}
static void
bsd_wireless_event_deinit(void *priv)
bsd_wireless_event_deinit(struct bsd_driver_data *drv)
{
struct bsd_driver_data *drv = priv;
if (drv != NULL) {
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
@ -724,6 +719,8 @@ bsd_init(struct hostapd_data *hapd)
goto bad;
bsd_set_iface_flags(drv, 0); /* mark down during setup */
if (bsd_wireless_event_init(drv))
goto bad;
return drv;
bad:
@ -742,6 +739,7 @@ bsd_deinit(void *priv)
{
struct bsd_driver_data *drv = priv;
bsd_wireless_event_deinit(drv);
(void) bsd_set_iface_flags(drv, 0);
if (drv->ioctl_sock >= 0)
close(drv->ioctl_sock);
@ -760,8 +758,6 @@ const struct hapd_driver_ops wpa_driver_bsd_ops = {
.get_seqnum = bsd_get_seqnum,
.flush = bsd_flush,
.set_generic_elem = bsd_set_opt_ie,
.wireless_event_init = bsd_wireless_event_init,
.wireless_event_deinit = bsd_wireless_event_deinit,
.sta_set_flags = bsd_sta_set_flags,
.read_sta_data = bsd_read_sta_driver_data,
.send_eapol = bsd_send_eapol,

View file

@ -1037,9 +1037,8 @@ static int hostap_get_we_version(struct hostap_driver_data *drv)
}
static int hostap_wireless_event_init(void *priv)
static int hostap_wireless_event_init(struct hostap_driver_data *drv)
{
struct hostap_driver_data *drv = priv;
int s;
struct sockaddr_nl local;
@ -1070,9 +1069,8 @@ static int hostap_wireless_event_init(void *priv)
}
static void hostap_wireless_event_deinit(void *priv)
static void hostap_wireless_event_deinit(struct hostap_driver_data *drv)
{
struct hostap_driver_data *drv = priv;
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
@ -1109,7 +1107,7 @@ static void * hostap_init(struct hostapd_data *hapd)
return NULL;
}
if (hostap_init_sockets(drv)) {
if (hostap_init_sockets(drv) || hostap_wireless_event_init(drv)) {
close(drv->ioctl_sock);
free(drv);
return NULL;
@ -1123,6 +1121,7 @@ static void hostap_driver_deinit(void *priv)
{
struct hostap_driver_data *drv = priv;
hostap_wireless_event_deinit(drv);
(void) hostap_set_iface_flags(drv, 0);
(void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
(void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0);
@ -1231,8 +1230,6 @@ const struct hapd_driver_ops wpa_driver_hostap_ops = {
.name = "hostap",
.init = hostap_init,
.deinit = hostap_driver_deinit,
.wireless_event_init = hostap_wireless_event_init,
.wireless_event_deinit = hostap_wireless_event_deinit,
.set_ieee8021x = hostap_set_ieee8021x,
.set_privacy = hostap_set_privacy,
.set_key = hostap_set_key,

View file

@ -43,24 +43,6 @@ hostapd_driver_deinit(struct hostapd_data *hapd)
hapd->driver->deinit(hapd->drv_priv);
}
static inline int
hostapd_wireless_event_init(struct hostapd_data *hapd)
{
if (hapd->driver == NULL ||
hapd->driver->wireless_event_init == NULL)
return 0;
return hapd->driver->wireless_event_init(hapd->drv_priv);
}
static inline void
hostapd_wireless_event_deinit(struct hostapd_data *hapd)
{
if (hapd->driver == NULL ||
hapd->driver->wireless_event_deinit == NULL)
return;
hapd->driver->wireless_event_deinit(hapd->drv_priv);
}
static inline int
hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
int enabled)

View file

@ -1130,9 +1130,8 @@ madwifi_get_we_version(struct madwifi_driver_data *drv)
static int
madwifi_wireless_event_init(void *priv)
madwifi_wireless_event_init(struct madwifi_driver_data *drv)
{
struct madwifi_driver_data *drv = priv;
int s;
struct sockaddr_nl local;
@ -1163,16 +1162,12 @@ madwifi_wireless_event_init(void *priv)
static void
madwifi_wireless_event_deinit(void *priv)
madwifi_wireless_event_deinit(struct madwifi_driver_data *drv)
{
struct madwifi_driver_data *drv = priv;
if (drv != NULL) {
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
close(drv->wext_sock);
}
@ -1288,6 +1283,9 @@ madwifi_init(struct hostapd_data *hapd)
madwifi_receive_probe_req(drv);
if (madwifi_wireless_event_init(drv))
goto bad;
return drv;
bad:
if (drv->sock_xmit != NULL)
@ -1305,6 +1303,7 @@ madwifi_deinit(void *priv)
{
struct madwifi_driver_data *drv = priv;
madwifi_wireless_event_deinit(drv);
(void) madwifi_set_iface_flags(drv, 0);
if (drv->ioctl_sock >= 0)
close(drv->ioctl_sock);
@ -1382,8 +1381,6 @@ const struct hapd_driver_ops wpa_driver_madwifi_ops = {
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,
.wireless_event_init = madwifi_wireless_event_init,
.wireless_event_deinit = madwifi_wireless_event_deinit,
.sta_set_flags = madwifi_sta_set_flags,
.read_sta_data = madwifi_read_sta_driver_data,
.send_eapol = madwifi_send_eapol,

View file

@ -2891,9 +2891,8 @@ static int hostap_get_we_version(struct i802_driver_data *drv)
}
static int i802_wireless_event_init(void *priv)
static int i802_wireless_event_init(struct i802_driver_data *drv)
{
struct i802_driver_data *drv = priv;
int s;
struct sockaddr_nl local;
@ -2924,9 +2923,8 @@ static int i802_wireless_event_init(void *priv)
}
static void i802_wireless_event_deinit(void *priv)
static void i802_wireless_event_deinit(struct i802_driver_data *drv)
{
struct i802_driver_data *drv = priv;
if (drv->wext_sock < 0)
return;
eloop_unregister_read_sock(drv->wext_sock);
@ -2999,6 +2997,9 @@ static void *i802_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
if (i802_init_sockets(drv, bssid))
goto failed;
if (i802_wireless_event_init(drv))
goto failed;
return drv;
failed:
@ -3018,6 +3019,8 @@ static void i802_deinit(void *priv)
struct i802_driver_data *drv = priv;
struct i802_bss *bss, *prev;
i802_wireless_event_deinit(drv);
if (drv->last_freq_ht) {
/* Clear HT flags from the driver */
struct hostapd_freq_params freq;
@ -3070,8 +3073,6 @@ const struct hapd_driver_ops wpa_driver_nl80211_ops = {
.init = i802_init,
.init_bssid = i802_init_bssid,
.deinit = i802_deinit,
.wireless_event_init = i802_wireless_event_init,
.wireless_event_deinit = i802_wireless_event_deinit,
.set_ieee8021x = i802_set_ieee8021x,
.set_privacy = i802_set_privacy,
.set_key = i802_set_key,

View file

@ -426,8 +426,6 @@ static void hostapd_cleanup(struct hostapd_data *hapd)
hostapd_deinit_wps(hapd);
hostapd_wireless_event_deinit(hapd);
#ifdef EAP_TLS_FUNCS
if (hapd->ssl_ctx) {
tls_deinit(hapd->ssl_ctx);
@ -1364,10 +1362,6 @@ static int setup_interface(struct hostapd_iface *iface)
return -1;
}
/* TODO: merge with hostapd_driver_init() ? */
if (hostapd_wireless_event_init(hapd) < 0)
return -1;
if (hostapd_get_hw_features(iface)) {
/* Not all drivers support this yet, so continue without hw
* feature data. */