-/* $OpenBSD: ieee80211_ioctl.c,v 1.63 2018/08/06 11:42:18 benno Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.64 2018/09/01 08:20:56 stsp Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
memset(ic->ic_des_essid, 0, IEEE80211_NWID_LEN);
ic->ic_des_esslen = nwid.i_len;
memcpy(ic->ic_des_essid, nwid.i_nwid, nwid.i_len);
+ if (ic->ic_des_esslen > 0) {
+ /* 'nwid' disables auto-join magic */
+ ic->ic_flags &= ~IEEE80211_F_AUTO_JOIN;
+ } else {
+ /* '-nwid' re-enables auto-join */
+ ic->ic_flags |= IEEE80211_F_AUTO_JOIN;
+ }
/* disable WPA/WEP */
ieee80211_disable_rsn(ic);
ieee80211_disable_wep(ic);
ieee80211_disable_rsn(ic);
ieee80211_disable_wep(ic);
/* save nwid for auto-join */
- if (!(join.i_flags & IEEE80211_JOIN_DEL))
- ieee80211_add_ess(ic, 0, 0);
+ if (!(join.i_flags & IEEE80211_JOIN_DEL)) {
+ if (ieee80211_add_ess(ic, 0, 0) == 0)
+ ic->ic_flags |= IEEE80211_F_AUTO_JOIN;
+ }
ieee80211_set_ess(ic, ic->ic_des_essid);
error = ENETRESET;
break;
join.i_len = ic->ic_bss->ni_esslen;
memcpy(join.i_nwid, ic->ic_bss->ni_essid,
join.i_len);
- join.i_flags = IEEE80211_JOIN_FOUND;
+ if (ic->ic_flags & IEEE80211_F_AUTO_JOIN)
+ join.i_flags = IEEE80211_JOIN_FOUND;
error = copyout(&join, ifr->ifr_data,
sizeof(join));
break;
-/* $OpenBSD: ieee80211_node.c,v 1.142 2018/08/15 18:45:43 stsp Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.143 2018/09/01 08:20:56 stsp Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
if (ess == NULL)
continue;
+ /*
+ * Operate only on ic_des_essid if auto-join is disabled.
+ * We might have a password stored for this network.
+ */
+ if (!ISSET(ic->ic_flags, IEEE80211_F_AUTO_JOIN)) {
+ if (ic->ic_des_esslen == ess->esslen &&
+ memcmp(ic->ic_des_essid, ess->essid,
+ ess->esslen) == 0) {
+ ieee80211_set_ess(ic, ess->essid);
+ return;
+ }
+ continue;
+ }
+
if (selni == NULL) {
seless = ess;
selni = ni;
-/* $OpenBSD: ieee80211_var.h,v 1.87 2018/08/06 11:28:01 stsp Exp $ */
+/* $OpenBSD: ieee80211_var.h,v 1.88 2018/09/01 08:20:56 stsp Exp $ */
/* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */
/*-
#define IEEE80211_F_HTON 0x02000000 /* CONF: HT enabled */
#define IEEE80211_F_PBAR 0x04000000 /* CONF: PBAC required */
#define IEEE80211_F_BGSCAN 0x08000000 /* STATUS: background scan */
-#define IEEE80211_F_USERMASK 0xf0000000 /* CONF: ioctl flag mask */
+#define IEEE80211_F_AUTO_JOIN 0x10000000 /* CONF: auto-join active */
+#define IEEE80211_F_USERMASK 0xe0000000 /* CONF: ioctl flag mask */
/* ic_xflags */
#define IEEE80211_F_TX_MGMT_ONLY 0x00000001 /* leave data frames on ifq */