-/* $OpenBSD: ieee80211_proto.c,v 1.75 2017/05/30 10:50:33 stsp Exp $ */
+/* $OpenBSD: ieee80211_proto.c,v 1.76 2017/06/02 15:31:26 stsp Exp $ */
/* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */
/*-
"11n", /* IEEE80211_MODE_11N */
};
+void ieee80211_set_beacon_miss_threshold(struct ieee80211com *);
int ieee80211_newstate(struct ieee80211com *, enum ieee80211_state, int);
void
}
}
+void
+ieee80211_set_beacon_miss_threshold(struct ieee80211com *ic)
+{
+ struct ifnet *ifp = &ic->ic_if;
+
+ /*
+ * Scale the missed beacon counter threshold to the AP's actual
+ * beacon interval. Give the AP at least 700 ms to time out and
+ * round up to ensure that at least one beacon may be missed.
+ */
+ int btimeout = MIN(7 * ic->ic_bss->ni_intval, 700);
+ btimeout = MAX(btimeout, 2 * ic->ic_bss->ni_intval);
+ if (ic->ic_bss->ni_intval > 0) /* don't crash if interval is bogus */
+ ic->ic_bmissthres = btimeout / ic->ic_bss->ni_intval;
+
+ if (ifp->if_flags & IFF_DEBUG)
+ printf("%s: missed beacon threshold set to %d beacons, "
+ "beacon interval is %u TU\n", ifp->if_xname,
+ ic->ic_bmissthres, ic->ic_bss->ni_intval);
+}
+
int
ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate,
int mgt)
ieee80211_set_link_state(ic, LINK_STATE_UP);
}
ic->ic_mgt_timer = 0;
+ ieee80211_set_beacon_miss_threshold(ic);
if_start(ifp);
break;
}