P2P: Derive group interface name bit more sensibly
The interface name for the P2P group interface is derived from the P2P management interface. When the P2P management interface is a P2P Device interface, i.e., p2p-dev-wlanX, the name for the group interface is abbreviated to p2p-X (X being group index). When the P2P management interface starts with p2p-dev- use its postfix instead. So P2P management interface p2p-dev-wlan3 results in group interface name p2p-wlan3-0. Signed-hostap: Arend van Spriel <arend@broadcom.com>
This commit is contained in:
parent
c68f6200a7
commit
2e5ba4b6d1
1 changed files with 25 additions and 9 deletions
|
@ -61,6 +61,8 @@
|
||||||
#define P2P_CONCURRENT_SEARCH_DELAY 500
|
#define P2P_CONCURRENT_SEARCH_DELAY 500
|
||||||
#endif /* P2P_CONCURRENT_SEARCH_DELAY */
|
#endif /* P2P_CONCURRENT_SEARCH_DELAY */
|
||||||
|
|
||||||
|
#define P2P_MGMT_DEVICE_PREFIX "p2p-dev-"
|
||||||
|
|
||||||
enum p2p_group_removal_reason {
|
enum p2p_group_removal_reason {
|
||||||
P2P_GROUP_REMOVAL_UNKNOWN,
|
P2P_GROUP_REMOVAL_UNKNOWN,
|
||||||
P2P_GROUP_REMOVAL_SILENT,
|
P2P_GROUP_REMOVAL_SILENT,
|
||||||
|
@ -983,6 +985,26 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void wpas_p2p_get_group_ifname(struct wpa_supplicant *wpa_s,
|
||||||
|
char *ifname, size_t len)
|
||||||
|
{
|
||||||
|
char *ifname_ptr = wpa_s->ifname;
|
||||||
|
|
||||||
|
if (os_strncmp(wpa_s->ifname, P2P_MGMT_DEVICE_PREFIX,
|
||||||
|
os_strlen(P2P_MGMT_DEVICE_PREFIX)) == 0) {
|
||||||
|
ifname_ptr = os_strrchr(wpa_s->ifname, '-') + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
os_snprintf(ifname, len, "p2p-%s-%d", ifname_ptr, wpa_s->p2p_group_idx);
|
||||||
|
if (os_strlen(ifname) >= IFNAMSIZ &&
|
||||||
|
os_strlen(wpa_s->ifname) < IFNAMSIZ) {
|
||||||
|
/* Try to avoid going over the IFNAMSIZ length limit */
|
||||||
|
os_snprintf(ifname, sizeof(ifname), "p2p-%d",
|
||||||
|
wpa_s->p2p_group_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
|
static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
|
||||||
enum wpa_driver_if_type type)
|
enum wpa_driver_if_type type)
|
||||||
{
|
{
|
||||||
|
@ -1000,14 +1022,7 @@ static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
os_snprintf(ifname, sizeof(ifname), "p2p-%s-%d", wpa_s->ifname,
|
wpas_p2p_get_group_ifname(wpa_s, ifname, sizeof(ifname));
|
||||||
wpa_s->p2p_group_idx);
|
|
||||||
if (os_strlen(ifname) >= IFNAMSIZ &&
|
|
||||||
os_strlen(wpa_s->ifname) < IFNAMSIZ) {
|
|
||||||
/* Try to avoid going over the IFNAMSIZ length limit */
|
|
||||||
os_snprintf(ifname, sizeof(ifname), "p2p-%d",
|
|
||||||
wpa_s->p2p_group_idx);
|
|
||||||
}
|
|
||||||
force_ifname[0] = '\0';
|
force_ifname[0] = '\0';
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "P2P: Create a new interface %s for the group",
|
wpa_printf(MSG_DEBUG, "P2P: Create a new interface %s for the group",
|
||||||
|
@ -2983,7 +2998,8 @@ int wpas_p2p_add_p2pdev_interface(struct wpa_supplicant *wpa_s)
|
||||||
char force_name[100];
|
char force_name[100];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
os_snprintf(ifname, sizeof(ifname), "p2p-dev-%s", wpa_s->ifname);
|
os_snprintf(ifname, sizeof(ifname), P2P_MGMT_DEVICE_PREFIX "%s",
|
||||||
|
wpa_s->ifname);
|
||||||
force_name[0] = '\0';
|
force_name[0] = '\0';
|
||||||
wpa_s->pending_interface_type = WPA_IF_P2P_DEVICE;
|
wpa_s->pending_interface_type = WPA_IF_P2P_DEVICE;
|
||||||
ret = wpa_drv_if_add(wpa_s, WPA_IF_P2P_DEVICE, ifname, NULL, NULL,
|
ret = wpa_drv_if_add(wpa_s, WPA_IF_P2P_DEVICE, ifname, NULL, NULL,
|
||||||
|
|
Loading…
Reference in a new issue