Skip to content

Commit e42b053

Browse files
committed
Add BSSID assignment under WPA setting
Search the IBSS list for a network with matching WPA settings. If found, use its BSSID. If not, use the device's MAC address as the BSSID.
1 parent 5ca6cec commit e42b053

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

vwifi.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,12 +2074,26 @@ static int vwifi_join_ibss(struct wiphy *wiphy,
20742074
return -ERESTARTSYS;
20752075
/* Retrieve IBSS configuration parameters */
20762076
memcpy(vif->ssid, params->ssid, params->ssid_len);
2077+
vif->ibss_chandef = params->chandef;
2078+
vif->ssid_len = params->ssid_len;
20772079
/* When the BSSID is automatically generated by the system, it will not be
20782080
* passed as a parameter to the join function. */
20792081
if (params->bssid)
20802082
memcpy(vif->bssid, params->bssid, ETH_ALEN);
2081-
vif->ibss_chandef = params->chandef;
2082-
vif->ssid_len = params->ssid_len;
2083+
else {
2084+
/* Search for IBSS networks with WPA settings in the IBSS list. If a
2085+
* matching network exists, join it. Otherwise, create one. */
2086+
memcpy(vif->bssid, ndev->dev_addr, ETH_ALEN);
2087+
struct vwifi_vif *ibss_vif = NULL;
2088+
list_for_each_entry (ibss_vif, &vwifi->ibss_list, ibss_list) {
2089+
if (!memcmp(ibss_vif->ssid, vif->ssid, vif->ssid_len) &&
2090+
ibss_vif->ibss_chandef.center_freq1 ==
2091+
vif->ibss_chandef.center_freq1) {
2092+
memcpy(vif->bssid, ibss_vif->ndev->dev_addr, ETH_ALEN);
2093+
break;
2094+
}
2095+
}
2096+
}
20832097
vif->beacon_ie_len = params->ie_len;
20842098
memcpy(vif->beacon_ie, params->ie, params->ie_len);
20852099
vif->ibss_beacon_int = params->beacon_interval;

0 commit comments

Comments
 (0)