-
- if (wl_ioctl(dev, (ap ? WLC_SET_BSSID : WLC_REASSOC), wrqu->ap_addr.sa_data, 6) < 0)
+
+ if (wl_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra)) < 0)
+ return -EINVAL;
+
+ if (!infra) {
+ wl_ioctl(dev, WLC_SET_BSSID, wrqu->ap_addr.sa_data, 6);
+
+ reg.size = 4;
+ reg.byteoff = 0x184;
+ reg.val = bss_force << 16 | bss_force;
+ wl_ioctl(dev, WLC_W_REG, ®, sizeof(reg));
+
+ reg.byteoff = 0x180;
+ wl_ioctl(dev, WLC_R_REG, ®, sizeof(reg));
+ reg.val = bss_force << 16;
+ wl_ioctl(dev, WLC_W_REG, ®, sizeof(reg));
+ }
+
+ if (wl_ioctl(dev, ((ap || !infra) ? WLC_SET_BSSID : WLC_REASSOC), wrqu->ap_addr.sa_data, 6) < 0)