From 74588e2bdbfb7bef1354d82701f8c6f7b4439c0b Mon Sep 17 00:00:00 2001 From: Marcus Glocker Date: Thu, 9 Aug 2007 21:24:03 +0000 Subject: If an association has failed, set the device back to INIT state. --- sys/dev/pcmcia/if_malo.c | 18 +++++++++++++----- sys/dev/pcmcia/if_malovar.h | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'sys/dev/pcmcia') diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index 5d06b5fa08d..27af1fb5d48 100644 --- a/sys/dev/pcmcia/if_malo.c +++ b/sys/dev/pcmcia/if_malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malo.c,v 1.48 2007/08/09 15:10:41 mglocker Exp $ */ +/* $OpenBSD: if_malo.c,v 1.49 2007/08/09 21:24:02 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -608,10 +608,12 @@ cmalo_init(struct ifnet *ifp) cmalo_intr_mask(sc, 1); } + /* reset association state flag */ + sc->sc_flags &= ~MALO_ASSOC_FAILED; + /* get current channel */ ic->ic_bss->ni_chan = ic->ic_ibss_chan; sc->sc_curchan = ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan); - DPRINTF(1, "%s: current channel is %d\n", sc->sc_dev.dv_xname, sc->sc_curchan); @@ -648,10 +650,13 @@ cmalo_init(struct ifnet *ifp) ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; + /* start network */ if (ic->ic_opmode != IEEE80211_M_MONITOR) ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); - - ieee80211_new_state(ic, IEEE80211_S_RUN, -1); + if (sc->sc_flags & MALO_ASSOC_FAILED) + ieee80211_new_state(ic, IEEE80211_S_INIT, -1); + else + ieee80211_new_state(ic, IEEE80211_S_RUN, -1); /* we are not context save anymore for FW commands */ sc->sc_cmd_ctxsave = 0; @@ -1730,7 +1735,10 @@ cmalo_cmd_rsp_assoc(struct malo_softc *sc) if (body->status) { DPRINTF(1, "%s: association failed (status %d)!\n", sc->sc_dev.dv_xname, body->status); - } + sc->sc_flags |= MALO_ASSOC_FAILED; + } else + DPRINTF(1, "%s: association successful\n", + sc->sc_dev.dv_xname, body->status); return (0); } diff --git a/sys/dev/pcmcia/if_malovar.h b/sys/dev/pcmcia/if_malovar.h index ae7c7c8f620..b630445b99e 100644 --- a/sys/dev/pcmcia/if_malovar.h +++ b/sys/dev/pcmcia/if_malovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malovar.h,v 1.23 2007/08/09 14:50:06 mglocker Exp $ */ +/* $OpenBSD: if_malovar.h,v 1.24 2007/08/09 21:24:02 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -41,6 +41,7 @@ /* device flags */ #define MALO_DEVICE_ATTACHED (1 << 0) #define MALO_FW_LOADED (1 << 1) +#define MALO_ASSOC_FAILED (1 << 2) /* * FW command structures -- cgit v1.2.3