WPS NFC: Allow Device Password ID override for selected registrar

When a specific out-of-band Device Password is enabled, it can be useful
to be able to advertise that in the selected registrar information.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-04-02 18:27:36 +03:00 committed by Jouni Malinen
parent aaecb69d87
commit 8f7a6dd7d0
3 changed files with 20 additions and 14 deletions

View file

@ -197,7 +197,8 @@ enum wps_process_res wps_registrar_process_msg(struct wps_data *wps,
int wps_build_cred(struct wps_data *wps, struct wpabuf *msg); int wps_build_cred(struct wps_data *wps, struct wpabuf *msg);
int wps_device_store(struct wps_registrar *reg, int wps_device_store(struct wps_registrar *reg,
struct wps_device_data *dev, const u8 *uuid); struct wps_device_data *dev, const u8 *uuid);
void wps_registrar_selected_registrar_changed(struct wps_registrar *reg); void wps_registrar_selected_registrar_changed(struct wps_registrar *reg,
u16 dev_pw_id);
const u8 * wps_authorized_macs(struct wps_registrar *reg, size_t *count); const u8 * wps_authorized_macs(struct wps_registrar *reg, size_t *count);
int wps_registrar_pbc_overlap(struct wps_registrar *reg, int wps_registrar_pbc_overlap(struct wps_registrar *reg,
const u8 *addr, const u8 *uuid_e); const u8 *addr, const u8 *uuid_e);

View file

@ -766,7 +766,7 @@ int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *addr,
else else
wps_registrar_add_authorized_mac( wps_registrar_add_authorized_mac(
reg, (u8 *) "\xff\xff\xff\xff\xff\xff"); reg, (u8 *) "\xff\xff\xff\xff\xff\xff");
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
eloop_register_timeout(WPS_PBC_WALK_TIME, 0, eloop_register_timeout(WPS_PBC_WALK_TIME, 0,
wps_registrar_set_selected_timeout, wps_registrar_set_selected_timeout,
@ -788,7 +788,7 @@ static void wps_registrar_remove_pin(struct wps_registrar *reg,
addr = pin->enrollee_addr; addr = pin->enrollee_addr;
wps_registrar_remove_authorized_mac(reg, addr); wps_registrar_remove_authorized_mac(reg, addr);
wps_remove_pin(pin); wps_remove_pin(pin);
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
@ -951,7 +951,7 @@ static void wps_registrar_stop_pbc(struct wps_registrar *reg)
os_memset(reg->p2p_dev_addr, 0, ETH_ALEN); os_memset(reg->p2p_dev_addr, 0, ETH_ALEN);
wps_registrar_remove_authorized_mac(reg, wps_registrar_remove_authorized_mac(reg,
(u8 *) "\xff\xff\xff\xff\xff\xff"); (u8 *) "\xff\xff\xff\xff\xff\xff");
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
@ -999,7 +999,7 @@ int wps_registrar_button_pushed(struct wps_registrar *reg,
os_memset(reg->p2p_dev_addr, 0, ETH_ALEN); os_memset(reg->p2p_dev_addr, 0, ETH_ALEN);
wps_registrar_add_authorized_mac(reg, wps_registrar_add_authorized_mac(reg,
(u8 *) "\xff\xff\xff\xff\xff\xff"); (u8 *) "\xff\xff\xff\xff\xff\xff");
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
@ -1022,7 +1022,7 @@ static void wps_registrar_pin_completed(struct wps_registrar *reg)
wpa_printf(MSG_DEBUG, "WPS: PIN completed using internal Registrar"); wpa_printf(MSG_DEBUG, "WPS: PIN completed using internal Registrar");
eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
reg->selected_registrar = 0; reg->selected_registrar = 0;
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
@ -3279,7 +3279,7 @@ static void wps_registrar_set_selected_timeout(void *eloop_ctx,
"unselect internal Registrar"); "unselect internal Registrar");
reg->selected_registrar = 0; reg->selected_registrar = 0;
reg->pbc = 0; reg->pbc = 0;
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
@ -3351,7 +3351,8 @@ static void wps_registrar_sel_reg_union(struct wps_registrar *reg)
* This function is called when selected registrar state changes, e.g., when an * This function is called when selected registrar state changes, e.g., when an
* AP receives a SetSelectedRegistrar UPnP message. * AP receives a SetSelectedRegistrar UPnP message.
*/ */
void wps_registrar_selected_registrar_changed(struct wps_registrar *reg) void wps_registrar_selected_registrar_changed(struct wps_registrar *reg,
u16 dev_pw_id)
{ {
wpa_printf(MSG_DEBUG, "WPS: Selected registrar information changed"); wpa_printf(MSG_DEBUG, "WPS: Selected registrar information changed");
@ -3375,7 +3376,8 @@ void wps_registrar_selected_registrar_changed(struct wps_registrar *reg)
reg->sel_reg_dev_password_id_override = reg->sel_reg_dev_password_id_override =
DEV_PW_PUSHBUTTON; DEV_PW_PUSHBUTTON;
wps_set_pushbutton(&methods, reg->wps->config_methods); wps_set_pushbutton(&methods, reg->wps->config_methods);
} } else if (dev_pw_id)
reg->sel_reg_dev_password_id_override = dev_pw_id;
wpa_printf(MSG_DEBUG, "WPS: Internal Registrar selected " wpa_printf(MSG_DEBUG, "WPS: Internal Registrar selected "
"(pbc=%d)", reg->pbc); "(pbc=%d)", reg->pbc);
reg->sel_reg_config_methods_override = methods; reg->sel_reg_config_methods_override = methods;
@ -3497,12 +3499,15 @@ int wps_registrar_add_nfc_pw_token(struct wps_registrar *reg,
reg->pbc = 0; reg->pbc = 0;
wps_registrar_add_authorized_mac(reg, wps_registrar_add_authorized_mac(reg,
(u8 *) "\xff\xff\xff\xff\xff\xff"); (u8 *) "\xff\xff\xff\xff\xff\xff");
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, pw_id);
eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
eloop_register_timeout(WPS_PBC_WALK_TIME, 0, eloop_register_timeout(WPS_PBC_WALK_TIME, 0,
wps_registrar_set_selected_timeout, wps_registrar_set_selected_timeout,
reg, NULL); reg, NULL);
wpa_printf(MSG_DEBUG, "WPS: Added NFC Device Password %u to Registrar",
pw_id);
return 0; return 0;
} }
@ -3544,7 +3549,7 @@ void wps_registrar_remove_nfc_pw_token(struct wps_registrar *reg,
{ {
wps_registrar_remove_authorized_mac(reg, wps_registrar_remove_authorized_mac(reg,
(u8 *) "\xff\xff\xff\xff\xff\xff"); (u8 *) "\xff\xff\xff\xff\xff\xff");
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
#endif /* CONFIG_WPS_NFC */ #endif /* CONFIG_WPS_NFC */

View file

@ -22,7 +22,7 @@ static void upnp_er_set_selected_timeout(void *eloop_ctx, void *timeout_ctx)
struct wps_registrar *reg = timeout_ctx; struct wps_registrar *reg = timeout_ctx;
wpa_printf(MSG_DEBUG, "WPS: SetSelectedRegistrar from ER timed out"); wpa_printf(MSG_DEBUG, "WPS: SetSelectedRegistrar from ER timed out");
s->selected_registrar = 0; s->selected_registrar = 0;
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }
@ -71,7 +71,7 @@ int upnp_er_set_selected_registrar(struct wps_registrar *reg,
upnp_er_set_selected_timeout, s, reg); upnp_er_set_selected_timeout, s, reg);
} }
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
return 0; return 0;
} }
@ -83,5 +83,5 @@ void upnp_er_remove_notification(struct wps_registrar *reg,
s->selected_registrar = 0; s->selected_registrar = 0;
eloop_cancel_timeout(upnp_er_set_selected_timeout, s, reg); eloop_cancel_timeout(upnp_er_set_selected_timeout, s, reg);
if (reg) if (reg)
wps_registrar_selected_registrar_changed(reg); wps_registrar_selected_registrar_changed(reg, 0);
} }