P2P: Copy config from p2pdev when not using dedicated group interface

When the P2P Device interface is used and an existing interface is used
for P2P GO/Client, the P2P Device configuration was not cloned to the
configuration of the existing interface. Thus, configuration parameters
such as idle_group_time, etc., were not propagated to the P2P GO/Client
interface.

Handle this by copying all configuration parameters of the P2P device
interface to the reused interface, with the following exceptions:

1. Copy the NFC key data only if it was not set in the configuration
   file.
2. The WPS string fields are set only if they were not previously set
   in the configuration of the destination interface (based on the
   assumption that these fields should be identical among all
   interfaces).

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
Andrei Otcheretianski 2016-04-07 13:32:08 +03:00 committed by Jouni Malinen
parent 3c88d26941
commit 9b377be037

View file

@ -1951,7 +1951,12 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
d = dst->conf; d = dst->conf;
s = src->conf; s = src->conf;
#define C(n) if (s->n) d->n = os_strdup(s->n) #define C(n) \
do { \
if (s->n && !d->n) \
d->n = os_strdup(s->n); \
} while (0)
C(device_name); C(device_name);
C(manufacturer); C(manufacturer);
C(model_name); C(model_name);
@ -1979,7 +1984,10 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
d->disable_scan_offload = s->disable_scan_offload; d->disable_scan_offload = s->disable_scan_offload;
d->passive_scan = s->passive_scan; d->passive_scan = s->passive_scan;
if (s->wps_nfc_dh_privkey && s->wps_nfc_dh_pubkey) { if (s->wps_nfc_dh_privkey && s->wps_nfc_dh_pubkey &&
!d->wps_nfc_pw_from_config) {
wpabuf_free(d->wps_nfc_dh_privkey);
wpabuf_free(d->wps_nfc_dh_pubkey);
d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey); d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey);
d->wps_nfc_dh_pubkey = wpabuf_dup(s->wps_nfc_dh_pubkey); d->wps_nfc_dh_pubkey = wpabuf_dup(s->wps_nfc_dh_pubkey);
} }
@ -1987,23 +1995,6 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
} }
static void wpas_p2p_clone_config_dh(struct wpa_supplicant *dst,
const struct wpa_supplicant *src)
{
struct wpa_config *d;
const struct wpa_config *s;
d = dst->conf;
s = src->conf;
if (s->wps_nfc_dh_privkey && s->wps_nfc_dh_pubkey &&
!d->wps_nfc_dh_privkey && !d->wps_nfc_dh_pubkey) {
d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey);
d->wps_nfc_dh_pubkey = wpabuf_dup(s->wps_nfc_dh_pubkey);
}
}
static void wpas_p2p_get_group_ifname(struct wpa_supplicant *wpa_s, static void wpas_p2p_get_group_ifname(struct wpa_supplicant *wpa_s,
char *ifname, size_t len) char *ifname, size_t len)
{ {
@ -2255,7 +2246,7 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
group_wpa_s = wpa_s->parent; group_wpa_s = wpa_s->parent;
wpa_s->global->p2p_group_formation = group_wpa_s; wpa_s->global->p2p_group_formation = group_wpa_s;
if (group_wpa_s != wpa_s) if (group_wpa_s != wpa_s)
wpas_p2p_clone_config_dh(group_wpa_s, wpa_s); wpas_p2p_clone_config(group_wpa_s, wpa_s);
} }
group_wpa_s->p2p_in_provisioning = 1; group_wpa_s->p2p_in_provisioning = 1;
@ -6013,7 +6004,7 @@ wpas_p2p_get_group_iface(struct wpa_supplicant *wpa_s, int addr_allocated,
"P2P: Use primary interface for group operations"); "P2P: Use primary interface for group operations");
wpa_s->p2p_first_connection_timeout = 0; wpa_s->p2p_first_connection_timeout = 0;
if (wpa_s != wpa_s->p2pdev) if (wpa_s != wpa_s->p2pdev)
wpas_p2p_clone_config_dh(wpa_s, wpa_s->p2pdev); wpas_p2p_clone_config(wpa_s, wpa_s->p2pdev);
return wpa_s; return wpa_s;
} }