Update internal MAC address on EVENT_INTERFACE_ENABLED events
This allows the MAC address of the interface to be changed when the interface is set down even if the interface does not get completed removed and re-added. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
aef85ba204
commit
bfba8deb8b
3 changed files with 24 additions and 12 deletions
|
@ -2380,6 +2380,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
|
||||||
case EVENT_INTERFACE_ENABLED:
|
case EVENT_INTERFACE_ENABLED:
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
|
wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
|
||||||
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
|
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
|
||||||
|
wpa_supplicant_update_mac_addr(wpa_s);
|
||||||
#ifdef CONFIG_AP
|
#ifdef CONFIG_AP
|
||||||
if (!wpa_s->ap_iface) {
|
if (!wpa_s->ap_iface) {
|
||||||
wpa_supplicant_set_state(wpa_s,
|
wpa_supplicant_set_state(wpa_s,
|
||||||
|
|
|
@ -2054,25 +2054,15 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
|
||||||
* wpa_supplicant_driver_init - Initialize driver interface parameters
|
|
||||||
* @wpa_s: Pointer to wpa_supplicant data
|
|
||||||
* Returns: 0 on success, -1 on failure
|
|
||||||
*
|
|
||||||
* This function is called to initialize driver interface parameters.
|
|
||||||
* wpa_drv_init() must have been called before this function to initialize the
|
|
||||||
* driver interface.
|
|
||||||
*/
|
|
||||||
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
|
|
||||||
{
|
{
|
||||||
static int interface_count = 0;
|
|
||||||
|
|
||||||
if (wpa_s->driver->send_eapol) {
|
if (wpa_s->driver->send_eapol) {
|
||||||
const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
|
const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
|
||||||
if (addr)
|
if (addr)
|
||||||
os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
|
os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
|
||||||
} else if (!(wpa_s->drv_flags &
|
} else if (!(wpa_s->drv_flags &
|
||||||
WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
|
WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
|
||||||
|
l2_packet_deinit(wpa_s->l2);
|
||||||
wpa_s->l2 = l2_packet_init(wpa_s->ifname,
|
wpa_s->l2 = l2_packet_init(wpa_s->ifname,
|
||||||
wpa_drv_get_mac_addr(wpa_s),
|
wpa_drv_get_mac_addr(wpa_s),
|
||||||
ETH_P_EAPOL,
|
ETH_P_EAPOL,
|
||||||
|
@ -2094,6 +2084,26 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
|
||||||
MAC2STR(wpa_s->own_addr));
|
MAC2STR(wpa_s->own_addr));
|
||||||
wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
|
wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wpa_supplicant_driver_init - Initialize driver interface parameters
|
||||||
|
* @wpa_s: Pointer to wpa_supplicant data
|
||||||
|
* Returns: 0 on success, -1 on failure
|
||||||
|
*
|
||||||
|
* This function is called to initialize driver interface parameters.
|
||||||
|
* wpa_drv_init() must have been called before this function to initialize the
|
||||||
|
* driver interface.
|
||||||
|
*/
|
||||||
|
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
|
||||||
|
{
|
||||||
|
static int interface_count = 0;
|
||||||
|
|
||||||
|
if (wpa_supplicant_update_mac_addr(wpa_s) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (wpa_s->bridge_ifname[0]) {
|
if (wpa_s->bridge_ifname[0]) {
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge "
|
wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge "
|
||||||
"interface '%s'", wpa_s->bridge_ifname);
|
"interface '%s'", wpa_s->bridge_ifname);
|
||||||
|
|
|
@ -522,6 +522,7 @@ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
|
||||||
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
|
int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
|
||||||
|
|
||||||
const char * wpa_supplicant_state_txt(enum wpa_states state);
|
const char * wpa_supplicant_state_txt(enum wpa_states state);
|
||||||
|
int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
|
||||||
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
|
int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
|
||||||
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
|
||||||
struct wpa_bss *bss, struct wpa_ssid *ssid,
|
struct wpa_bss *bss, struct wpa_ssid *ssid,
|
||||||
|
|
Loading…
Reference in a new issue