From 171ac09a1c5a8329bb95af70d5ea1a14647fc337 Mon Sep 17 00:00:00 2001 From: damien Date: Wed, 27 Aug 2008 09:05:03 +0000 Subject: [PATCH] introduce new IEEE80211_STA_ONLY kernel option that can be set to remove IBSS and HostAP support from net80211 and 802.11 drivers. it can be used to shrink RAMDISK kernels for instance (like what was done for wi(4)). it also has the benefit of highlighting what is specific to IBSS and HostAP modes in the code. the cost is that we now have two code paths to maintain. --- sys/dev/ic/acx.c | 20 ++++++-- sys/dev/ic/an.c | 24 +++++++--- sys/dev/ic/ar5210.c | 4 +- sys/dev/ic/ar5211.c | 4 +- sys/dev/ic/ar5212.c | 4 +- sys/dev/ic/ath.c | 35 ++++++++++++-- sys/dev/ic/atw.c | 41 +++++++++++++---- sys/dev/ic/bwi.c | 22 +++++++-- sys/dev/ic/malo.c | 19 ++++++-- sys/dev/ic/pgt.c | 28 ++++++++--- sys/dev/ic/rt2560.c | 31 +++++++++++-- sys/dev/ic/rt2661.c | 30 ++++++++++-- sys/dev/ic/rt2860.c | 40 +++++++++++++--- sys/dev/ic/rtw.c | 33 +++++++++++-- sys/dev/pci/if_ipw.c | 24 ++++++++-- sys/dev/pci/if_iwi.c | 44 ++++++++++++++---- sys/dev/pci/if_iwn.c | 9 +++- sys/dev/pci/if_wpi.c | 9 +++- sys/dev/usb/if_ral.c | 33 ++++++++++--- sys/dev/usb/if_rum.c | 21 +++++++-- sys/dev/usb/if_zyd.c | 4 +- sys/net80211/ieee80211.c | 21 ++++++++- sys/net80211/ieee80211_crypto.c | 4 +- sys/net80211/ieee80211_crypto.h | 4 +- sys/net80211/ieee80211_crypto_tkip.c | 21 +++++++-- sys/net80211/ieee80211_input.c | 65 +++++++++++++++++++++----- sys/net80211/ieee80211_ioctl.c | 17 ++++++- sys/net80211/ieee80211_node.c | 69 ++++++++++++++++++++++------ sys/net80211/ieee80211_output.c | 41 +++++++++++++---- sys/net80211/ieee80211_pae_input.c | 51 ++++++++++++++++---- sys/net80211/ieee80211_pae_output.c | 16 ++++++- sys/net80211/ieee80211_proto.c | 33 ++++++++++--- sys/net80211/ieee80211_var.h | 4 +- 33 files changed, 674 insertions(+), 151 deletions(-) diff --git a/sys/dev/ic/acx.c b/sys/dev/ic/acx.c index f3b46dd1ffa..899cdda2535 100644 --- a/sys/dev/ic/acx.c +++ b/sys/dev/ic/acx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acx.c,v 1.86 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: acx.c,v 1.87 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2006 Jonathan Gray @@ -174,9 +174,11 @@ int acx_reset(struct acx_softc *); int acx_set_null_tmplt(struct acx_softc *); int acx_set_probe_req_tmplt(struct acx_softc *, const char *, int); +#ifndef IEEE80211_STA_ONLY int acx_set_probe_resp_tmplt(struct acx_softc *, struct ieee80211_node *); int acx_beacon_locate(struct mbuf *, u_int8_t); int acx_set_beacon_tmplt(struct acx_softc *, struct ieee80211_node *); +#endif int acx_read_eeprom(struct acx_softc *, uint32_t, uint8_t *); int acx_read_phyreg(struct acx_softc *, uint32_t, uint8_t *); @@ -306,9 +308,11 @@ acx_attach(struct acx_softc *sc) */ ic->ic_caps = IEEE80211_C_WEP | /* WEP */ - IEEE80211_C_IBSS | /* IBSS mode */ IEEE80211_C_MONITOR | /* Monitor mode */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode */ IEEE80211_C_HOSTAP | /* Access Point */ +#endif IEEE80211_C_SHPREAMBLE; /* Short preamble */ /* Get station id */ @@ -1766,6 +1770,7 @@ acx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) } break; case IEEE80211_S_RUN: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS || ic->ic_opmode == IEEE80211_M_HOSTAP) { struct ieee80211_node *ni; @@ -1808,7 +1813,7 @@ acx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) DPRINTF(("%s: join IBSS\n", sc->sc_dev.dv_xname)); error = 0; } - +#endif /* fake a join to init the tx rate */ if (ic->ic_opmode == IEEE80211_M_STA) acx_newassoc(ic, ic->ic_bss, 1); @@ -2367,6 +2372,7 @@ acx_set_probe_req_tmplt(struct acx_softc *sc, const char *ssid, int ssid_len) ACX_TMPLT_PROBE_REQ_SIZ(len))); } +#ifndef IEEE80211_STA_ONLY struct mbuf *ieee80211_get_probe_resp(struct ieee80211com *, struct ieee80211_node *); @@ -2469,6 +2475,7 @@ acx_set_beacon_tmplt(struct acx_softc *sc, struct ieee80211_node *ni) return (acx_set_tmplt(sc, ACXCMD_TMPLT_TIM, &tim, len)); } +#endif /* IEEE80211_STA_ONLY */ void acx_init_cmd_reg(struct acx_softc *sc) @@ -2496,7 +2503,12 @@ acx_join_bss(struct acx_softc *sc, uint8_t mode, struct ieee80211_node *node) bj->beacon_intvl = htole16(acx_beacon_intvl); /* TODO tunable */ - dtim_intvl = sc->sc_ic.ic_opmode == IEEE80211_M_IBSS ? 1 : 10; +#ifndef IEEE80211_STA_ONLY + if (sc->sc_ic.ic_opmode == IEEE80211_M_IBSS) + dtim_intvl = 1; + else +#endif + dtim_intvl = 10; sc->chip_set_bss_join_param(sc, bj->chip_spec, dtim_intvl); bj->ndata_txrate = ACX_NDATA_TXRATE_1; diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 0f238c326c5..e2e42000b29 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $OpenBSD: an.c,v 1.55 2008/07/21 18:43:19 damien Exp $ */ +/* $OpenBSD: an.c,v 1.56 2008/08/27 09:05:03 damien Exp $ */ /* $NetBSD: an.c,v 1.34 2005/06/20 02:49:18 atatat Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -281,8 +281,10 @@ an_attach(struct an_softc *sc) ic->ic_phytype = IEEE80211_T_DS; ic->ic_opmode = IEEE80211_M_STA; - ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_PMGT | IEEE80211_C_IBSS | - IEEE80211_C_MONITOR; + ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_PMGT | IEEE80211_C_MONITOR; +#ifndef IEEE80211_STA_ONLY + ic->ic_caps |= IEEE80211_C_IBSS; +#endif ic->ic_state = IEEE80211_S_INIT; IEEE80211_ADDR_COPY(ic->ic_myaddr, sc->sc_caps.an_oemaddr); @@ -675,8 +677,11 @@ an_linkstat_intr(struct an_softc *sc) DPRINTF(("an_linkstat_intr: status 0x%x\n", status)); if (status == AN_LINKSTAT_ASSOCIATED) { - if (ic->ic_state != IEEE80211_S_RUN || - ic->ic_opmode == IEEE80211_M_IBSS) + if (ic->ic_state != IEEE80211_S_RUN +#ifndef IEEE80211_STA_ONLY + || ic->ic_opmode == IEEE80211_M_IBSS +#endif + ) ieee80211_new_state(ic, IEEE80211_S_RUN, -1); } else { if (ic->ic_opmode == IEEE80211_M_STA) @@ -1004,10 +1009,12 @@ an_init(struct ifnet *ifp) AN_OPMODE_INFRASTRUCTURE_STATION; sc->sc_config.an_rxmode = AN_RXMODE_BC_MC_ADDR; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: sc->sc_config.an_opmode = AN_OPMODE_IBSS_ADHOC; sc->sc_config.an_rxmode = AN_RXMODE_BC_MC_ADDR; break; +#endif case IEEE80211_M_MONITOR: sc->sc_config.an_opmode = AN_OPMODE_INFRASTRUCTURE_STATION; @@ -1329,11 +1336,14 @@ an_media_change(struct ifnet *ifp) error = ENETRESET; } +#ifndef IEEE80211_STA_ONLY if (ime->ifm_media & IFM_IEEE80211_ADHOC) newmode = IEEE80211_M_IBSS; else if (ime->ifm_media & IFM_IEEE80211_HOSTAP) newmode = IEEE80211_M_HOSTAP; - else if (ime->ifm_media & IFM_IEEE80211_MONITOR) + else +#endif + if (ime->ifm_media & IFM_IEEE80211_MONITOR) newmode = IEEE80211_M_MONITOR; else newmode = IEEE80211_M_STA; @@ -1381,12 +1391,14 @@ an_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_ADHOC; break; case IEEE80211_M_HOSTAP: imr->ifm_active |= IFM_IEEE80211_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c index 7b4c393a87d..ee600939c29 100644 --- a/sys/dev/ic/ar5210.c +++ b/sys/dev/ic/ar5210.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5210.c,v 1.41 2007/11/01 20:32:16 reyk Exp $ */ +/* $OpenBSD: ar5210.c,v 1.42 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -484,6 +484,7 @@ ar5k_ar5210_set_opmode(struct ath_hal *hal) AR5K_AR5210_STA_ID1_PWR_SV; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: pcu_reg |= AR5K_AR5210_STA_ID1_ADHOC | AR5K_AR5210_STA_ID1_NO_PSPOLL | @@ -497,6 +498,7 @@ ar5k_ar5210_set_opmode(struct ath_hal *hal) AR5K_AR5210_STA_ID1_DESC_ANTENNA; beacon_reg |= AR5K_AR5210_BCR_AP; break; +#endif case IEEE80211_M_MONITOR: pcu_reg |= AR5K_AR5210_STA_ID1_NO_PSPOLL; diff --git a/sys/dev/ic/ar5211.c b/sys/dev/ic/ar5211.c index 7f8ecfbef15..e35b829cd5e 100644 --- a/sys/dev/ic/ar5211.c +++ b/sys/dev/ic/ar5211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5211.c,v 1.37 2008/07/30 07:15:39 reyk Exp $ */ +/* $OpenBSD: ar5211.c,v 1.38 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -686,6 +686,7 @@ ar5k_ar5211_set_opmode(struct ath_hal *hal) pcu_reg = 0; switch (hal->ah_op_mode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: pcu_reg |= AR5K_AR5211_STA_ID1_ADHOC | AR5K_AR5211_STA_ID1_DESC_ANTENNA; @@ -695,6 +696,7 @@ ar5k_ar5211_set_opmode(struct ath_hal *hal) pcu_reg |= AR5K_AR5211_STA_ID1_AP | AR5K_AR5211_STA_ID1_RTS_DEFAULT_ANTENNA; break; +#endif case IEEE80211_M_STA: case IEEE80211_M_MONITOR: diff --git a/sys/dev/ic/ar5212.c b/sys/dev/ic/ar5212.c index d457dad13b2..5cf3bf5b666 100644 --- a/sys/dev/ic/ar5212.c +++ b/sys/dev/ic/ar5212.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5212.c,v 1.45 2008/07/30 07:43:01 reyk Exp $ */ +/* $OpenBSD: ar5212.c,v 1.46 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter @@ -867,6 +867,7 @@ ar5k_ar5212_set_opmode(struct ath_hal *hal) pcu_reg = 0; switch (hal->ah_op_mode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: pcu_reg |= AR5K_AR5212_STA_ID1_ADHOC | AR5K_AR5212_STA_ID1_DESC_ANTENNA; @@ -876,6 +877,7 @@ ar5k_ar5212_set_opmode(struct ath_hal *hal) pcu_reg |= AR5K_AR5212_STA_ID1_AP | AR5K_AR5212_STA_ID1_RTS_DEFAULT_ANTENNA; break; +#endif case IEEE80211_M_STA: case IEEE80211_M_MONITOR: diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index c704c499dd0..fe5f04c1adb 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ath.c,v 1.74 2008/08/25 20:43:49 jmc Exp $ */ +/* $OpenBSD: ath.c,v 1.75 2008/08/27 09:05:03 damien Exp $ */ /* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */ /*- @@ -98,9 +98,11 @@ void ath_mcastfilter_accum(caddr_t, u_int32_t (*)[2]); void ath_mcastfilter_compute(struct ath_softc *, u_int32_t (*)[2]); u_int32_t ath_calcrxfilter(struct ath_softc *); void ath_mode_init(struct ath_softc *); +#ifndef IEEE80211_STA_ONLY int ath_beacon_alloc(struct ath_softc *, struct ieee80211_node *); void ath_beacon_proc(void *, int); void ath_beacon_free(struct ath_softc *); +#endif void ath_beacon_config(struct ath_softc *); int ath_desc_alloc(struct ath_softc *); void ath_desc_free(struct ath_softc *); @@ -133,8 +135,10 @@ int ath_rate_setup(struct ath_softc *sc, u_int mode); void ath_setcurmode(struct ath_softc *, enum ieee80211_phymode); void ath_rssadapt_updatenode(void *, struct ieee80211_node *); void ath_rssadapt_updatestats(void *); +#ifndef IEEE80211_STA_ONLY void ath_recv_mgmt(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *, int); +#endif void ath_disable(struct ath_softc *); void ath_power(int, void *); @@ -310,7 +314,9 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ATH_TASK_INIT(&sc->sc_rxorntask, ath_rxorn_proc, sc); ATH_TASK_INIT(&sc->sc_fataltask, ath_fatal_proc, sc); ATH_TASK_INIT(&sc->sc_bmisstask, ath_bmiss_proc, sc); +#ifndef IEEE80211_STA_ONLY ATH_TASK_INIT(&sc->sc_swbatask, ath_beacon_proc, sc); +#endif /* * For now just pre-allocate one data queue and one @@ -357,8 +363,10 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ic->ic_opmode = IEEE80211_M_STA; ic->ic_caps = IEEE80211_C_WEP /* wep supported */ | IEEE80211_C_PMGT /* power management */ +#ifndef IEEE80211_STA_ONLY | IEEE80211_C_IBSS /* ibss, nee adhoc, mode */ | IEEE80211_C_HOSTAP /* hostap mode */ +#endif | IEEE80211_C_MONITOR /* monitor mode */ | IEEE80211_C_SHSLOT /* short slot time supported */ | IEEE80211_C_SHPREAMBLE; /* short preamble supported */ @@ -386,8 +394,10 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ic->ic_node_getrssi = ath_node_getrssi; sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = ath_newstate; +#ifndef IEEE80211_STA_ONLY sc->sc_recv_mgmt = ic->ic_recv_mgmt; ic->ic_recv_mgmt = ath_recv_mgmt; +#endif ic->ic_max_rssi = AR5K_MAX_RSSI; bcopy(etherbroadcastaddr, sc->sc_broadcast_addr, IEEE80211_ADDR_LEN); @@ -766,8 +776,10 @@ ath_init1(struct ath_softc *sc) sc->sc_imask = HAL_INT_RX | HAL_INT_TX | HAL_INT_RXEOL | HAL_INT_RXORN | HAL_INT_FATAL | HAL_INT_GLOBAL; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) sc->sc_imask |= HAL_INT_MIB; +#endif ath_hal_set_intr(ah, sc->sc_imask); ifp->if_flags |= IFF_RUNNING; @@ -831,7 +843,9 @@ ath_stop(struct ifnet *ifp) sc->sc_rxlink = NULL; } IFQ_PURGE(&ifp->if_snd); +#ifndef IEEE80211_STA_ONLY ath_beacon_free(sc); +#endif ieee80211_new_state(ic, IEEE80211_S_INIT, -1); if (!sc->sc_invalid) { ath_hal_set_power(ah, HAL_PM_FULL_SLEEP, 0); @@ -1237,7 +1251,9 @@ ath_calcrxfilter(struct ath_softc *sc) | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; if (ic->ic_opmode != IEEE80211_M_STA) rfilt |= HAL_RX_FILTER_PROBEREQ; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_AHDEMO) +#endif rfilt |= HAL_RX_FILTER_BEACON; if (ifp->if_flags & IFF_PROMISC) rfilt |= HAL_RX_FILTER_PROM; @@ -1290,6 +1306,7 @@ ath_getmbuf(int flags, int type, u_int pktlen) return m; } +#ifndef IEEE80211_STA_ONLY int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni) { @@ -1438,6 +1455,7 @@ ath_beacon_free(struct ath_softc *sc) bf->bf_node = NULL; } } +#endif /* IEEE80211_STA_ONLY */ /* * Configure the beacon and sleep timers. @@ -1529,7 +1547,9 @@ ath_beacon_config(struct ath_softc *sc) ath_hal_set_beacon_timers(ah, &bs, 0/*XXX*/, 0, 0); sc->sc_imask |= HAL_INT_BMISS; ath_hal_set_intr(ah, sc->sc_imask); - } else { + } +#ifndef IEEE80211_STA_ONLY + else { ath_hal_set_intr(ah, 0); if (nexttbtt == intval) intval |= HAL_BEACON_RESET_TSF; @@ -1561,6 +1581,7 @@ ath_beacon_config(struct ath_softc *sc) if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_veol) ath_beacon_proc(sc, 0); } +#endif } int @@ -1801,7 +1822,6 @@ int ath_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) { struct ath_hal *ah = sc->sc_ah; - struct ieee80211com *ic = &sc->sc_ic; int error; struct mbuf *m; struct ath_desc *ds; @@ -1858,8 +1878,10 @@ ath_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) */ ds = bf->bf_desc; bzero(ds, sizeof(struct ath_desc)); - if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#ifndef IEEE80211_STA_ONLY + if (sc->sc_ic.ic_opmode != IEEE80211_M_HOSTAP) ds->ds_link = bf->bf_daddr; /* link to self */ +#endif ds->ds_data = bf->bf_segs[0].ds_addr; ath_hal_setup_rx_desc(ah, ds , m->m_len /* buffer size */ @@ -2946,13 +2968,14 @@ ath_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) /* * Allocate and setup the beacon frame for AP or adhoc mode. */ +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) { error = ath_beacon_alloc(sc, ni); if (error != 0) goto bad; } - +#endif /* * Configure the beacon and sleep timers. */ @@ -2981,6 +3004,7 @@ bad: return error; } +#ifndef IEEE80211_STA_ONLY void ath_recv_mgmt(struct ieee80211com *ic, struct mbuf *m, struct ieee80211_node *ni, struct ieee80211_rxinfo *rxi, int subtype) @@ -3005,6 +3029,7 @@ ath_recv_mgmt(struct ieee80211com *ic, struct mbuf *m, } return; } +#endif /* * Setup driver-specific state for a newly associated node. diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index d2b549bc5a8..e1487a88af4 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atw.c,v 1.60 2008/07/21 18:43:19 damien Exp $ */ +/* $OpenBSD: atw.c,v 1.61 2008/08/27 09:05:03 damien Exp $ */ /* $NetBSD: atw.c,v 1.69 2004/07/23 07:07:55 dyoung Exp $ */ /*- @@ -200,8 +200,10 @@ void atw_linkintr(struct atw_softc *, u_int32_t); /* 802.11 state machine */ int atw_newstate(struct ieee80211com *, enum ieee80211_state, int); int atw_tune(struct atw_softc *); +#ifndef IEEE80211_STA_ONLY void atw_recv_mgmt(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *, int); +#endif void atw_next_scan(void *); /* Device initialization */ @@ -812,9 +814,10 @@ atw_attach(struct atw_softc *sc) ic->ic_phytype = IEEE80211_T_DS; ic->ic_opmode = IEEE80211_M_STA; - ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_IBSS | - IEEE80211_C_HOSTAP | IEEE80211_C_MONITOR | IEEE80211_C_WEP; - + ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_MONITOR | IEEE80211_C_WEP; +#ifndef IEEE80211_STA_ONLY + ic->ic_caps |= IEEE80211_C_IBSS | IEEE80211_C_HOSTAP; +#endif ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; /* @@ -827,8 +830,10 @@ atw_attach(struct atw_softc *sc) sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = atw_newstate; +#ifndef IEEE80211_STA_ONLY sc->sc_recv_mgmt = ic->ic_recv_mgmt; ic->ic_recv_mgmt = atw_recv_mgmt; +#endif sc->sc_node_free = ic->ic_node_free; ic->ic_node_free = atw_node_free; @@ -1419,16 +1424,19 @@ atw_init(struct ifnet *ifp) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_AHDEMO: /* XXX */ case IEEE80211_M_IBSS: ic->ic_flags |= IEEE80211_F_IBSSON; /*FALLTHROUGH*/ case IEEE80211_M_HOSTAP: /* XXX */ break; - case IEEE80211_M_MONITOR: /* XXX */ +#endif + default: /* XXX */ break; } +#ifndef IEEE80211_STA_ONLY switch (ic->ic_opmode) { case IEEE80211_M_AHDEMO: case IEEE80211_M_HOSTAP: @@ -1439,7 +1447,7 @@ atw_init(struct ifnet *ifp) default: /* XXX */ break; } - +#endif sc->sc_wepctl = 0; atw_write_ssid(sc); @@ -2260,6 +2268,7 @@ atw_change_ibss(struct atw_softc *sc) atw_start_beacon(sc, 1); } +#ifndef IEEE80211_STA_ONLY void atw_recv_mgmt(struct ieee80211com *ic, struct mbuf *m, struct ieee80211_node *ni, struct ieee80211_rxinfo *rxi, int subtype) @@ -2287,6 +2296,7 @@ atw_recv_mgmt(struct ieee80211com *ic, struct mbuf *m, } return; } +#endif /* Write the SSID in the ieee80211com to the SRAM on the ADM8211. * In ad hoc mode, the SSID is written to the beacons sent by the @@ -2339,8 +2349,11 @@ void atw_start_beacon(struct atw_softc *sc, int start) { struct ieee80211com *ic = &sc->sc_ic; +#ifndef IEEE80211_STA_ONLY uint16_t chan; - uint32_t bcnt, bpli, cap0, cap1, capinfo; + uint32_t bpli; +#endif + uint32_t bcnt, cap0, cap1, capinfo; size_t len; if (ATW_IS_ENABLED(sc) == 0) @@ -2373,6 +2386,7 @@ atw_start_beacon(struct atw_softc *sc, int start) if (ic->ic_flags & IEEE80211_F_WEPON) capinfo |= IEEE80211_CAPINFO_PRIVACY; +#ifndef IEEE80211_STA_ONLY switch (ic->ic_opmode) { case IEEE80211_M_IBSS: len += 4; /* IBSS parameters */ @@ -2408,6 +2422,7 @@ atw_start_beacon(struct atw_softc *sc, int start) sc->sc_dev.dv_xname, bcnt)); DPRINTF(sc, ("%s: atw_start_beacon reg[ATW_CAP1] = %08x\n", sc->sc_dev.dv_xname, cap1)); +#endif } /* Return the 32 lsb of the last TSFT divisible by ival. */ @@ -2463,6 +2478,7 @@ atw_predict_beacon(struct atw_softc *sc) uint8_t tstamp[8]; } u; +#ifndef IEEE80211_STA_ONLY if ((ic->ic_opmode == IEEE80211_M_HOSTAP) || ((ic->ic_opmode == IEEE80211_M_IBSS) && (ic->ic_flags & IEEE80211_F_SIBSS))) { @@ -2470,7 +2486,9 @@ atw_predict_beacon(struct atw_softc *sc) u.word = htole64(tsft); (void)memcpy(&ic->ic_bss->ni_tstamp[0], &u.tstamp[0], sizeof(ic->ic_bss->ni_tstamp)); - } else { + } else +#endif + { (void)memcpy(&u, &ic->ic_bss->ni_tstamp[0], sizeof(u)); tsft = letoh64(u.word); } @@ -2550,7 +2568,10 @@ atw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) atw_write_ssid(sc); atw_write_sup_rates(sc); - if (ic->ic_opmode == IEEE80211_M_AHDEMO || + if ( +#ifndef IEEE80211_STA_ONLY + ic->ic_opmode == IEEE80211_M_AHDEMO || +#endif ic->ic_opmode == IEEE80211_M_MONITOR) break; @@ -2572,11 +2593,13 @@ atw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) if (nstate != IEEE80211_S_SCAN) timeout_del(&sc->sc_scan_to); +#ifndef IEEE80211_STA_ONLY if (nstate == IEEE80211_S_RUN && (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS)) atw_start_beacon(sc, 1); else +#endif atw_start_beacon(sc, 0); error = (*sc->sc_newstate)(ic, nstate, arg); diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c index 0cf7022bc5d..12bfabf7bc5 100644 --- a/sys/dev/ic/bwi.c +++ b/sys/dev/ic/bwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwi.c,v 1.78 2008/08/22 19:58:21 deraadt Exp $ */ +/* $OpenBSD: bwi.c,v 1.79 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. @@ -2107,12 +2107,14 @@ bwi_mac_opmode_init(struct bwi_mac *mac) mac_status |= BWI_MAC_STATUS_PROMISC; switch (ic->ic_opmode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: mac_status &= ~BWI_MAC_STATUS_INFRA; break; case IEEE80211_M_HOSTAP: mac_status |= BWI_MAC_STATUS_OPMODE_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: #if 0 /* Do you want data from your microwave oven? */ @@ -2133,14 +2135,18 @@ bwi_mac_opmode_init(struct bwi_mac *mac) CSR_WRITE_4(sc, BWI_MAC_STATUS, mac_status); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_IBSS && ic->ic_opmode != IEEE80211_M_HOSTAP) { +#endif if (sc->sc_bbp_id == BWI_BBPID_BCM4306 && sc->sc_bbp_rev == 3) pre_tbtt = 100; else pre_tbtt = 50; +#ifndef IEEE80211_STA_ONLY } else pre_tbtt = 2; +#endif CSR_WRITE_2(sc, BWI_MAC_PRE_TBTT, pre_tbtt); } @@ -2751,13 +2757,15 @@ void bwi_mac_lock(struct bwi_mac *mac) { struct bwi_softc *sc = mac->mac_sc; - struct ieee80211com *ic = &sc->sc_ic; KASSERT((mac->mac_flags & BWI_MAC_F_LOCKED) == 0); if (mac->mac_rev < 3) bwi_mac_stop(mac); - else if (ic->ic_opmode != IEEE80211_M_HOSTAP) + else +#ifndef IEEE80211_STA_ONLY + if (sc->sc_ic.ic_opmode != IEEE80211_M_HOSTAP) +#endif bwi_mac_config_ps(mac); CSR_SETBITS_4(sc, BWI_MAC_STATUS, BWI_MAC_STATUS_RFLOCK); @@ -2773,7 +2781,6 @@ void bwi_mac_unlock(struct bwi_mac *mac) { struct bwi_softc *sc = mac->mac_sc; - struct ieee80211com *ic = &sc->sc_ic; KASSERT(mac->mac_flags & BWI_MAC_F_LOCKED); @@ -2783,7 +2790,10 @@ bwi_mac_unlock(struct bwi_mac *mac) if (mac->mac_rev < 3) bwi_mac_start(mac); - else if (ic->ic_opmode != IEEE80211_M_HOSTAP) + else +#ifndef IEEE80211_STA_ONLY + if (sc->sc_ic.ic_opmode != IEEE80211_M_HOSTAP) +#endif bwi_mac_config_ps(mac); mac->mac_flags &= ~BWI_MAC_F_LOCKED; @@ -7478,8 +7488,10 @@ bwi_amrr_timeout(void *arg) if (ic->ic_opmode == IEEE80211_M_STA) bwi_iter_func(sc, ic->ic_bss); +#ifndef IEEE80211_STA_ONLY else ieee80211_iterate_nodes(ic, bwi_iter_func, sc); +#endif timeout_add(&sc->sc_amrr_ch, hz / 2); } diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c index 643fcf6313b..cfc24effef4 100644 --- a/sys/dev/ic/malo.c +++ b/sys/dev/ic/malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malo.c,v 1.85 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: malo.c,v 1.86 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -1225,16 +1225,20 @@ malo_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_ADHOC; break; - case IEEE80211_M_MONITOR: - imr->ifm_active |= IFM_IEEE80211_MONITOR; - break; case IEEE80211_M_AHDEMO: break; case IEEE80211_M_HOSTAP: break; +#endif + case IEEE80211_M_MONITOR: + imr->ifm_active |= IFM_IEEE80211_MONITOR; + break; + default: + break; } switch (ic->ic_curmode) { @@ -1932,9 +1936,11 @@ malo_update_slot(struct ieee80211com *ic) malo_set_slot(sc); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* TODO */ } +#endif } #ifdef MALO_DEBUG @@ -2286,9 +2292,12 @@ malo_cmd_set_rate(struct malo_softc *sc, uint8_t rate) bzero(body, sizeof(*body)); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* TODO */ - } else { + } else +#endif + { body->aprates[0] = 2; body->aprates[1] = 4; body->aprates[2] = 11; diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index 9d40b54e299..75131f32ddf 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.50 2008/07/21 18:43:19 damien Exp $ */ +/* $OpenBSD: pgt.c,v 1.51 2008/08/27 09:05:03 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -849,7 +849,9 @@ pgt_ieee80211_encap(struct pgt_softc *sc, struct ether_header *eh, if (ni != NULL) { if (ic->ic_opmode == IEEE80211_M_STA) { *ni = ieee80211_ref_node(ic->ic_bss); - } else { + } +#ifndef IEEE80211_STA_ONLY + else { *ni = ieee80211_find_node(ic, eh->ether_shost); /* * Make up associations for ad-hoc mode. To support @@ -869,6 +871,7 @@ pgt_ieee80211_encap(struct pgt_softc *sc, struct ether_header *eh, return (NULL); } } +#endif (*ni)->ni_inact = 0; } snap->llc_dsap = snap->llc_ssap = LLC_SNAP_LSAP; @@ -890,6 +893,7 @@ pgt_ieee80211_encap(struct pgt_softc *sc, struct ether_header *eh, IEEE80211_ADDR_COPY(frame->i_addr2, ic->ic_bss->ni_bssid); IEEE80211_ADDR_COPY(frame->i_addr3, eh->ether_shost); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: frame->i_fc[1] = IEEE80211_FC1_DIR_NODS; @@ -904,6 +908,7 @@ pgt_ieee80211_encap(struct pgt_softc *sc, struct ether_header *eh, IEEE80211_ADDR_COPY(frame->i_addr2, eh->ether_shost); IEEE80211_ADDR_COPY(frame->i_addr3, eh->ether_dhost); break; +#endif default: break; } @@ -1988,10 +1993,11 @@ pgt_net_attach(struct pgt_softc *sc) } } - ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_IBSS | IEEE80211_C_PMGT | - IEEE80211_C_HOSTAP | IEEE80211_C_TXPMGT | IEEE80211_C_SHSLOT | - IEEE80211_C_SHPREAMBLE | IEEE80211_C_MONITOR; - + ic->ic_caps = IEEE80211_C_WEP | IEEE80211_C_PMGT | IEEE80211_C_TXPMGT | + IEEE80211_C_SHSLOT | IEEE80211_C_SHPREAMBLE | IEEE80211_C_MONITOR; +#ifndef IEEE80211_STA_ONLY + ic->ic_caps |= IEEE80211_C_IBSS | IEEE80211_C_HOSTAP; +#endif ic->ic_opmode = IEEE80211_M_STA; ic->ic_state = IEEE80211_S_INIT; @@ -2095,6 +2101,7 @@ pgt_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_ADHOC; break; @@ -2104,6 +2111,7 @@ pgt_media_status(struct ifnet *ifp, struct ifmediareq *imr) case IEEE80211_M_HOSTAP: imr->ifm_active |= IFM_IEEE80211_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; @@ -2511,6 +2519,7 @@ pgt_watchdog(struct ifnet *ifp) sc->sc_ic.ic_opmode != IEEE80211_M_MONITOR) pgt_async_update(sc); +#ifndef IEEE80211_STA_ONLY /* * As a firmware-based HostAP, we should not time out * nodes inside the driver additionally to the timeout @@ -2530,6 +2539,7 @@ pgt_watchdog(struct ifnet *ifp) default: break; } +#endif ieee80211_watchdog(ifp); ifp->if_timer = 1; } @@ -2597,6 +2607,7 @@ pgt_update_hw_from_sw(struct pgt_softc *sc, int keepassoc, int keepnodes) bsstype = PGT_BSS_TYPE_STA; dot1x = PGT_DOT1X_AUTH_ENABLED; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: if (ifp->if_flags & IFF_PROMISC) mode = PGT_MODE_CLIENT; /* what to do? */ @@ -2626,6 +2637,7 @@ pgt_update_hw_from_sw(struct pgt_softc *sc, int keepassoc, int keepnodes) if (sc->sc_wds) config |= PGT_CONFIG_WDS; break; +#endif case IEEE80211_M_MONITOR: mode = PGT_MODE_PROMISCUOUS; bsstype = PGT_BSS_TYPE_ANY; @@ -2911,8 +2923,10 @@ pgt_update_sw_from_hw(struct pgt_softc *sc, struct pgt_async_trap *pa, letoh16(mlme->pom_id), letoh16(mlme->pom_state), letoh16(mlme->pom_code))); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) pgt_hostap_handle_mlme(sc, oid, mlme); +#endif break; } return; @@ -2990,9 +3004,11 @@ pgt_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) else ieee80211_free_allnodes(ic); +#ifndef IEEE80211_STA_ONLY /* Just use any old channel; we override it anyway. */ if (ic->ic_opmode == IEEE80211_M_HOSTAP) ieee80211_create_ibss(ic, ic->ic_ibss_chan); +#endif break; case IEEE80211_S_RUN: ic->ic_if.if_timer = 1; diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index 0879d492e97..e8f9cafdf05 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2560.c,v 1.38 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: rt2560.c,v 1.39 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -102,7 +102,9 @@ void rt2560_tx_intr(struct rt2560_softc *); void rt2560_prio_intr(struct rt2560_softc *); void rt2560_decryption_intr(struct rt2560_softc *); void rt2560_rx_intr(struct rt2560_softc *); +#ifndef IEEE80211_STA_ONLY void rt2560_beacon_expire(struct rt2560_softc *); +#endif void rt2560_wakeup_expire(struct rt2560_softc *); #if NBPFILTER > 0 uint8_t rt2560_rxrate(const struct rt2560_rx_desc *); @@ -113,8 +115,10 @@ uint8_t rt2560_plcp_signal(int); void rt2560_setup_tx_desc(struct rt2560_softc *, struct rt2560_tx_desc *, uint32_t, int, int, int, bus_addr_t); +#ifndef IEEE80211_STA_ONLY int rt2560_tx_bcn(struct rt2560_softc *, struct mbuf *, struct ieee80211_node *); +#endif int rt2560_tx_mgt(struct rt2560_softc *, struct mbuf *, struct ieee80211_node *); int rt2560_tx_data(struct rt2560_softc *, struct mbuf *, @@ -236,9 +240,11 @@ rt2560_attach(void *xsc, int id) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAp mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -703,8 +709,10 @@ rt2560_amrr_timeout(void *arg) s = splnet(); if (ic->ic_opmode == IEEE80211_M_STA) rt2560_iter_func(sc, ic->ic_bss); +#ifndef IEEE80211_STA_ONLY else ieee80211_iterate_nodes(ic, rt2560_iter_func, sc); +#endif splx(s); timeout_add(&sc->amrr_to, hz / 2); @@ -731,7 +739,6 @@ rt2560_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) struct rt2560_softc *sc = ic->ic_if.if_softc; enum ieee80211_state ostate; struct ieee80211_node *ni; - struct mbuf *m; int error = 0; ostate = ic->ic_state; @@ -774,9 +781,10 @@ rt2560_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) rt2560_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) { - m = ieee80211_beacon_alloc(ic, ni); + struct mbuf *m = ieee80211_beacon_alloc(ic, ni); if (m == NULL) { printf("%s: could not allocate beacon\n", sc->sc_dev.dv_xname); @@ -788,6 +796,7 @@ rt2560_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) if (error != 0) break; } +#endif /* turn assocation led on */ rt2560_update_led(sc, 1, 0); @@ -1268,6 +1277,7 @@ rt2560_rx_intr(struct rt2560_softc *sc) RAL_WRITE(sc, RT2560_SECCSR0, RT2560_KICK_DECRYPT); } +#ifndef IEEE80211_STA_ONLY /* * This function is called in HostAP or IBSS modes when it's time to send a * new beacon (every ni_intval milliseconds). @@ -1306,6 +1316,7 @@ rt2560_beacon_expire(struct rt2560_softc *sc) DPRINTFN(15, ("beacon expired\n")); } +#endif void rt2560_wakeup_expire(struct rt2560_softc *sc) @@ -1333,8 +1344,10 @@ rt2560_intr(void *arg) if (!(ifp->if_flags & IFF_RUNNING)) return 0; +#ifndef IEEE80211_STA_ONLY if (r & RT2560_BEACON_EXPIRE) rt2560_beacon_expire(sc); +#endif if (r & RT2560_WAKEUP_EXPIRE) rt2560_wakeup_expire(sc); @@ -1532,6 +1545,7 @@ rt2560_setup_tx_desc(struct rt2560_softc *sc, struct rt2560_tx_desc *desc, } } +#ifndef IEEE80211_STA_ONLY int rt2560_tx_bcn(struct rt2560_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) @@ -1587,6 +1601,7 @@ rt2560_tx_bcn(struct rt2560_softc *sc, struct mbuf *m0, return 0; } +#endif int rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0, @@ -1645,11 +1660,13 @@ rt2560_tx_mgt(struct rt2560_softc *sc, struct mbuf *m0, RAL_SIFS; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp for probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RT2560_TX_TIMESTAMP; +#endif } rt2560_setup_tx_desc(sc, desc, flags, m0->m_pkthdr.len, rate, 0, @@ -2268,9 +2285,11 @@ rt2560_enable_tsf_sync(struct rt2560_softc *sc) tmp = RT2560_ENABLE_TSF | RT2560_ENABLE_TBCN; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RT2560_ENABLE_TSF_SYNC(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RT2560_ENABLE_TSF_SYNC(2) | RT2560_ENABLE_BEACON_GENERATOR; +#endif RAL_WRITE(sc, RT2560_CSR14, tmp); DPRINTF(("enabling TSF synchronization\n")); @@ -2305,6 +2324,7 @@ rt2560_updateslot(struct ieee80211com *ic) { struct rt2560_softc *sc = ic->ic_if.if_softc; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* * In HostAP mode, we defer setting of new slot time until @@ -2313,6 +2333,7 @@ rt2560_updateslot(struct ieee80211com *ic) */ sc->sc_flags |= RT2560_UPDATE_SLOT; } else +#endif rt2560_set_slottime(sc); } @@ -2634,7 +2655,9 @@ rt2560_init(struct ifnet *ifp) tmp = RT2560_DROP_PHY_ERROR | RT2560_DROP_CRC_ERROR; if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RT2560_DROP_CTL | RT2560_DROP_VERSION_ERROR; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RT2560_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RT2560_DROP_NOT_TO_ME; diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index 6a1bbc4ca0a..a105b8f79f1 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2661.c,v 1.43 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: rt2661.c,v 1.44 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2006 @@ -101,7 +101,9 @@ void rt2661_tx_intr(struct rt2661_softc *); void rt2661_tx_dma_intr(struct rt2661_softc *, struct rt2661_tx_ring *); void rt2661_rx_intr(struct rt2661_softc *); +#ifndef IEEE80211_STA_ONLY void rt2661_mcu_beacon_expire(struct rt2661_softc *); +#endif void rt2661_mcu_wakeup(struct rt2661_softc *); void rt2661_mcu_cmd_intr(struct rt2661_softc *); int rt2661_intr(void *); @@ -150,7 +152,9 @@ void rt2661_rx_tune(struct rt2661_softc *); void rt2661_radar_start(struct rt2661_softc *); int rt2661_radar_stop(struct rt2661_softc *); #endif +#ifndef IEEE80211_STA_ONLY int rt2661_prepare_beacon(struct rt2661_softc *); +#endif void rt2661_enable_tsf_sync(struct rt2661_softc *); int rt2661_get_rssi(struct rt2661_softc *, uint8_t); void rt2661_power(int, void *); @@ -246,9 +250,11 @@ rt2661_attach(void *xsc, int id) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAP mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -805,9 +811,11 @@ rt2661_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) rt2661_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) rt2661_prepare_beacon(sc); +#endif if (ic->ic_opmode == IEEE80211_M_STA) { /* fake a join to init the tx rate */ @@ -1144,6 +1152,7 @@ skip: desc->flags |= htole32(RT2661_RX_BUSY); } } +#ifndef IEEE80211_STA_ONLY /* * This function is called in HostAP or IBSS modes when it's time to send a * new beacon (every ni_intval milliseconds). @@ -1169,6 +1178,7 @@ rt2661_mcu_beacon_expire(struct rt2661_softc *sc) DPRINTFN(15, ("beacon expired\n")); } +#endif void rt2661_mcu_wakeup(struct rt2661_softc *sc) @@ -1238,8 +1248,10 @@ rt2661_intr(void *arg) if (r2 & RT2661_MCU_CMD_DONE) rt2661_mcu_cmd_intr(sc); +#ifndef IEEE80211_STA_ONLY if (r2 & RT2661_MCU_BEACON_EXPIRE) rt2661_mcu_beacon_expire(sc); +#endif if (r2 & RT2661_MCU_WAKEUP) rt2661_mcu_wakeup(sc); @@ -1494,11 +1506,13 @@ rt2661_tx_mgt(struct rt2661_softc *sc, struct mbuf *m0, sc->sifs; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp in probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RT2661_TX_TIMESTAMP; +#endif } rt2661_setup_tx_desc(sc, desc, flags, 0 /* XXX HWSEQ */, @@ -2244,6 +2258,7 @@ rt2661_updateslot(struct ieee80211com *ic) { struct rt2661_softc *sc = ic->ic_if.if_softc; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* * In HostAP mode, we defer setting of new slot time until @@ -2252,6 +2267,7 @@ rt2661_updateslot(struct ieee80211com *ic) */ sc->sc_flags |= RT2661_UPDATE_SLOT; } else +#endif rt2661_set_slottime(sc); } @@ -2539,7 +2555,9 @@ rt2661_init(struct ifnet *ifp) if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RT2661_DROP_CTL | RT2661_DROP_VER_ERROR | RT2661_DROP_ACKCTS; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RT2661_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RT2661_DROP_NOT_TO_ME; @@ -2777,6 +2795,7 @@ rt2661_radar_stop(struct rt2661_softc *sc) } #endif +#ifndef IEEE80211_STA_ONLY int rt2661_prepare_beacon(struct rt2661_softc *sc) { @@ -2829,6 +2848,7 @@ rt2661_prepare_beacon(struct rt2661_softc *sc) return 0; } +#endif /* * Enable TSF synchronization and tell h/w to start sending beacons for IBSS @@ -2840,6 +2860,7 @@ rt2661_enable_tsf_sync(struct rt2661_softc *sc) struct ieee80211com *ic = &sc->sc_ic; uint32_t tmp; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA) { /* * Change default 16ms TBTT adjustment to 8ms. @@ -2847,7 +2868,7 @@ rt2661_enable_tsf_sync(struct rt2661_softc *sc) */ RAL_WRITE(sc, RT2661_TXRX_CSR10, 1 << 12 | 8); } - +#endif tmp = RAL_READ(sc, RT2661_TXRX_CSR9) & 0xff000000; /* set beacon interval (in 1/16ms unit) */ @@ -2856,9 +2877,10 @@ rt2661_enable_tsf_sync(struct rt2661_softc *sc) tmp |= RT2661_TSF_TICKING | RT2661_ENABLE_TBTT; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RT2661_TSF_MODE(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RT2661_TSF_MODE(2) | RT2661_GENERATE_BEACON; - +#endif RAL_WRITE(sc, RT2661_TXRX_CSR9, tmp); } diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c index 849e5e573b7..c73bc281d6f 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2860.c,v 1.18 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: rt2860.c,v 1.19 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2007,2008 @@ -140,7 +140,9 @@ int rt2860_init(struct ifnet *); void rt2860_stop(struct ifnet *, int); int rt2860_load_microcode(struct rt2860_softc *); void rt2860_calib(struct rt2860_softc *); +#ifndef IEEE80211_STA_ONLY int rt2860_setup_beacon(struct rt2860_softc *); +#endif void rt2860_enable_tsf_sync(struct rt2860_softc *); void rt2860_power(int, void *); @@ -236,9 +238,11 @@ rt2860_attach(void *xsc, int id) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAP mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -739,9 +743,9 @@ rt2860_updatestats(void *arg) { struct rt2860_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; - uint32_t tmp; int s; +#ifndef IEEE80211_STA_ONLY /* * In IBSS or HostAP modes (when the hardware sends beacons), the * MAC can run into a livelock and start sending CTS-to-self frames @@ -750,7 +754,7 @@ rt2860_updatestats(void *arg) */ if (ic->ic_curmode != IEEE80211_M_STA) { /* check if we're in a livelock situation.. */ - tmp = RAL_READ(sc, RT2860_DEBUG); + uint32_t tmp = RAL_READ(sc, RT2860_DEBUG); if ((tmp & (1 << 29)) && (tmp & (1 << 7 | 1 << 5))) { /* ..and reset MAC/BBP for a while.. */ DPRINTF(("CTS-to-self livelock detected\n")); @@ -760,12 +764,15 @@ rt2860_updatestats(void *arg) RT2860_MAC_RX_EN | RT2860_MAC_TX_EN); } } +#endif s = splnet(); if (ic->ic_opmode == IEEE80211_M_STA) rt2860_iter_func(sc, ic->ic_bss); +#ifndef IEEE80211_STA_ONLY else ieee80211_iterate_nodes(ic, rt2860_iter_func, arg); +#endif splx(s); timeout_add(&sc->amrr_to, hz / 2); @@ -847,9 +854,11 @@ rt2860_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) rt2860_set_bssid(sc, ic->ic_bss->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) rt2860_setup_beacon(sc); +#endif if (ic->ic_opmode == IEEE80211_M_STA) { /* fake a join to init the tx rate */ @@ -1240,11 +1249,13 @@ rt2860_intr(void *arg) if (r & RT2860_TX_DONE_INT0) rt2860_tx_intr(sc, 0); +#ifndef IEEE80211_STA_ONLY if (r & RT2860_MAC_INT_1) { /* pre-TBTT */ if ((sc->sc_flags & RT2860_UPD_BEACON) && rt2860_setup_beacon(sc) == 0) sc->sc_flags &= ~RT2860_UPD_BEACON; } +#endif if (r & RT2860_MAC_INT_0) { /* TBTT */ struct ieee80211com *ic = &sc->sc_ic; /* check if protection mode has changed */ @@ -1422,12 +1433,14 @@ rt2860_tx_data(struct rt2860_softc *sc, struct mbuf *m0, ic->ic_flags) + sc->sifs; *(uint16_t *)wh->i_dur = htole16(dur); } +#ifndef IEEE80211_STA_ONLY /* ask MAC to insert timestamp into probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) /* NOTE: beacons do not pass through tx_data() */ txwi->flags |= RT2860_TX_TS; +#endif #if NBPFILTER > 0 if (sc->sc_drvbpf != NULL) { @@ -2037,8 +2050,10 @@ rt2860_updateslot(struct ieee80211com *ic) struct rt2860_softc *sc = ic->ic_softc; uint32_t tmp; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) sc->sc_flags |= RT2860_UPD_BEACON; +#endif tmp = RAL_READ(sc, RT2860_BKOFF_SLOT_CFG); tmp &= ~0xff; @@ -2139,12 +2154,15 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, base = RT2860_SKEY(0, k->k_id); if (k->k_cipher == IEEE80211_CIPHER_TKIP) { RAL_WRITE_REGION_1(sc, base, k->k_key, 16); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { RAL_WRITE_REGION_1(sc, base + 16, &k->k_key[16], 8); RAL_WRITE_REGION_1(sc, base + 24, &k->k_key[24], 8); - } else { + } else +#endif + { RAL_WRITE_REGION_1(sc, base + 16, &k->k_key[24], 8); RAL_WRITE_REGION_1(sc, base + 24, @@ -2163,12 +2181,15 @@ rt2860_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, base = RT2860_PKEY(wcid); if (k->k_cipher == IEEE80211_CIPHER_TKIP) { RAL_WRITE_REGION_1(sc, base, k->k_key, 16); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { RAL_WRITE_REGION_1(sc, base + 16, &k->k_key[16], 8); RAL_WRITE_REGION_1(sc, base + 24, &k->k_key[24], 8); - } else { + } else +#endif + { RAL_WRITE_REGION_1(sc, base + 16, &k->k_key[24], 8); RAL_WRITE_REGION_1(sc, base + 24, @@ -2983,6 +3004,7 @@ rt2860_calib(struct rt2860_softc *sc) } } +#ifndef IEEE80211_STA_ONLY int rt2860_setup_beacon(struct rt2860_softc *sc) { @@ -3014,6 +3036,7 @@ rt2860_setup_beacon(struct rt2860_softc *sc) return 0; } +#endif void rt2860_enable_tsf_sync(struct rt2860_softc *sc) @@ -3032,7 +3055,9 @@ rt2860_enable_tsf_sync(struct rt2860_softc *sc) * reception. */ tmp |= 1 << RT2860_TSF_SYNC_MODE_SHIFT; - } else if (ic->ic_opmode == IEEE80211_M_IBSS) { + } +#ifndef IEEE80211_STA_ONLY + else if (ic->ic_opmode == IEEE80211_M_IBSS) { tmp |= RT2860_BCN_TX_EN; /* * Local TSF is updated with remote TSF on beacon reception @@ -3044,6 +3069,7 @@ rt2860_enable_tsf_sync(struct rt2860_softc *sc) /* SYNC with nobody */ tmp |= 3 << RT2860_TSF_SYNC_MODE_SHIFT; } +#endif RAL_WRITE(sc, RT2860_BCN_TIME_CFG, tmp); } diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index d2fbe888299..00f0b84bc73 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtw.c,v 1.68 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: rtw.c,v 1.69 2008/08/27 09:05:03 damien Exp $ */ /* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */ /*- @@ -98,15 +98,19 @@ void rtw_rxdesc_init(struct rtw_rxdesc_blk *, struct rtw_rxsoft *, int, int); void rtw_rxring_fixup(struct rtw_softc *); void rtw_io_enable(struct rtw_regs *, u_int8_t, int); void rtw_intr_rx(struct rtw_softc *, u_int16_t); +#ifndef IEEE80211_STA_ONLY void rtw_intr_beacon(struct rtw_softc *, u_int16_t); void rtw_intr_atim(struct rtw_softc *); +#endif void rtw_transmit_config(struct rtw_softc *); void rtw_pktfilt_load(struct rtw_softc *); void rtw_start(struct ifnet *); void rtw_watchdog(struct ifnet *); void rtw_next_scan(void *); +#ifndef IEEE80211_STA_ONLY void rtw_recv_mgmt(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *, int); +#endif struct ieee80211_node *rtw_node_alloc(struct ieee80211com *); void rtw_node_free(struct ieee80211com *, struct ieee80211_node *); void rtw_media_status(struct ifnet *, struct ifmediareq *); @@ -192,8 +196,10 @@ struct mbuf *rtw_80211_dequeue(struct rtw_softc *, struct ifqueue *, int, struct rtw_txsoft_blk **, struct rtw_txdesc_blk **, struct ieee80211_node **, short *); uint64_t rtw_tsf_extend(struct rtw_regs *, u_int32_t); +#ifndef IEEE80211_STA_ONLY void rtw_ibss_merge(struct rtw_softc *, struct ieee80211_node *, u_int32_t); +#endif void rtw_idle(struct rtw_regs *); void rtw_led_attach(struct rtw_led_state *, void *); void rtw_led_init(struct rtw_regs *); @@ -1455,6 +1461,7 @@ rtw_intr_tx(struct rtw_softc *sc, u_int16_t isr) rtw_start(&sc->sc_if); } +#ifndef IEEE80211_STA_ONLY void rtw_intr_beacon(struct rtw_softc *sc, u_int16_t isr) { @@ -1512,6 +1519,7 @@ rtw_intr_atim(struct rtw_softc *sc) /* TBD */ return; } +#endif /* IEEE80211_STA_ONLY */ #ifdef RTW_DEBUG void @@ -1845,10 +1853,12 @@ rtw_intr(void *arg) rtw_intr_rx(sc, isr & RTW_INTR_RX); if ((isr & RTW_INTR_TX) != 0) rtw_intr_tx(sc, isr & RTW_INTR_TX); +#ifndef IEEE80211_STA_ONLY if ((isr & RTW_INTR_BEACON) != 0) rtw_intr_beacon(sc, isr & RTW_INTR_BEACON); if ((isr & RTW_INTR_ATIMINT) != 0) rtw_intr_atim(sc); +#endif if ((isr & RTW_INTR_IOERROR) != 0) rtw_intr_ioerror(sc, isr & RTW_INTR_IOERROR); if ((isr & RTW_INTR_TIMEOUT) != 0) @@ -2242,6 +2252,7 @@ rtw_set_nettype(struct rtw_softc *sc, enum ieee80211_opmode opmode) msr = RTW_READ8(&sc->sc_regs, RTW_MSR) & ~RTW_MSR_NETYPE_MASK; switch (opmode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_AHDEMO: case IEEE80211_M_IBSS: msr |= RTW_MSR_NETYPE_ADHOC_OK; @@ -2249,6 +2260,7 @@ rtw_set_nettype(struct rtw_softc *sc, enum ieee80211_opmode opmode) case IEEE80211_M_HOSTAP: msr |= RTW_MSR_NETYPE_AP_OK; break; +#endif case IEEE80211_M_MONITOR: /* XXX */ msr |= RTW_MSR_NETYPE_NOLINK; @@ -2256,6 +2268,8 @@ rtw_set_nettype(struct rtw_softc *sc, enum ieee80211_opmode opmode) case IEEE80211_M_STA: msr |= RTW_MSR_NETYPE_INFRA_OK; break; + default: + break; } RTW_WRITE8(&sc->sc_regs, RTW_MSR, msr); @@ -2289,11 +2303,13 @@ rtw_pktfilt_load(struct rtw_softc *sc) case IEEE80211_M_MONITOR: sc->sc_rcr |= RTW_RCR_MONITOR; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_AHDEMO: case IEEE80211_M_IBSS: /* receive broadcasts in our BSS */ sc->sc_rcr |= RTW_RCR_ADD3; break; +#endif default: break; } @@ -3446,16 +3462,18 @@ rtw_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) break; case IEEE80211_S_RUN: switch (ic->ic_opmode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_HOSTAP: case IEEE80211_M_IBSS: rtw_set_nettype(sc, IEEE80211_M_MONITOR); /*FALLTHROUGH*/ case IEEE80211_M_AHDEMO: +#endif case IEEE80211_M_STA: rtw_join_bss(sc, ic->ic_bss->ni_bssid, ic->ic_bss->ni_intval); break; - case IEEE80211_M_MONITOR: + default: break; } rtw_set_nettype(sc, ic->ic_opmode); @@ -3484,6 +3502,7 @@ rtw_tsf_extend(struct rtw_regs *regs, u_int32_t rstamp) return ((u_int64_t)tsfth << 32) | rstamp; } +#ifndef IEEE80211_STA_ONLY void rtw_ibss_merge(struct rtw_softc *sc, struct ieee80211_node *ni, u_int32_t rstamp) @@ -3525,6 +3544,7 @@ rtw_recv_mgmt(struct ieee80211com *ic, struct mbuf *m, } return; } +#endif /* IEEE80211_STA_ONLY */ struct ieee80211_node * rtw_node_alloc(struct ieee80211com *ic) @@ -4058,9 +4078,10 @@ rtw_attach(struct rtw_softc *sc) ic->ic_phytype = IEEE80211_T_DS; ic->ic_opmode = IEEE80211_M_STA; - ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_IBSS | - IEEE80211_C_HOSTAP | IEEE80211_C_MONITOR | IEEE80211_C_WEP; - + ic->ic_caps = IEEE80211_C_PMGT | IEEE80211_C_MONITOR | IEEE80211_C_WEP; +#ifndef IEEE80211_STA_ONLY + ic->ic_caps |= IEEE80211_C_HOSTAP | IEEE80211_C_IBSS; +#endif ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b; rtw_led_attach(&sc->sc_led_state, (void *)sc); @@ -4075,8 +4096,10 @@ rtw_attach(struct rtw_softc *sc) mtbl->mt_newstate = ic->ic_newstate; ic->ic_newstate = rtw_newstate; +#ifndef IEEE80211_STA_ONLY mtbl->mt_recv_mgmt = ic->ic_recv_mgmt; ic->ic_recv_mgmt = rtw_recv_mgmt; +#endif mtbl->mt_node_free = ic->ic_node_free; ic->ic_node_free = rtw_node_free; diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 6542c14c8c7..2aa61f339e5 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipw.c,v 1.73 2008/07/21 18:43:18 damien Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.74 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2004-2008 @@ -228,7 +228,9 @@ ipw_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = +#ifndef IEEE80211_STA_ONLY IEEE80211_C_IBSS | /* IBSS mode supported */ +#endif IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ @@ -644,14 +646,15 @@ ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_IBSS; break; +#endif case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; - case IEEE80211_M_AHDEMO: - case IEEE80211_M_HOSTAP: + default: /* should not get there */ break; } @@ -1631,9 +1634,11 @@ ipw_read_firmware(struct ipw_softc *sc, struct ipw_firmware *fw) case IEEE80211_M_STA: name = "ipw-bss"; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: name = "ipw-ibss"; break; +#endif case IEEE80211_M_MONITOR: name = "ipw-monitor"; break; @@ -1682,9 +1687,11 @@ ipw_config(struct ipw_softc *sc) case IEEE80211_M_STA: data = htole32(IPW_MODE_BSS); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: data = htole32(IPW_MODE_IBSS); break; +#endif case IEEE80211_M_MONITOR: data = htole32(IPW_MODE_MONITOR); break; @@ -1697,7 +1704,10 @@ ipw_config(struct ipw_softc *sc) if (error != 0) return error; - if (ic->ic_opmode == IEEE80211_M_IBSS || + if ( +#ifndef IEEE80211_STA_ONLY + ic->ic_opmode == IEEE80211_M_IBSS || +#endif ic->ic_opmode == IEEE80211_M_MONITOR) { data = htole32(ieee80211_chan2ieee(ic, ic->ic_ibss_chan)); DPRINTF(("Setting channel to %u\n", letoh32(data))); @@ -1720,8 +1730,10 @@ ipw_config(struct ipw_softc *sc) config.flags = htole32(IPW_CFG_BSS_MASK | IPW_CFG_IBSS_MASK | IPW_CFG_PREAMBLE_AUTO | IPW_CFG_802_1x_ENABLE); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) config.flags |= htole32(IPW_CFG_IBSS_AUTO_START); +#endif if (ifp->if_flags & IFF_PROMISC) config.flags |= htole32(IPW_CFG_PROMISCUOUS); config.bss_chan = htole32(0x3fff); /* channels 1-14 */ @@ -1749,6 +1761,7 @@ ipw_config(struct ipw_softc *sc) if (error != 0) return error; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) { data = htole32(32); /* default value */ DPRINTF(("Setting tx power index to %u\n", letoh32(data))); @@ -1757,6 +1770,7 @@ ipw_config(struct ipw_softc *sc) if (error != 0) return error; } +#endif data = htole32(ic->ic_rtsthreshold); DPRINTF(("Setting RTS threshold to %u\n", letoh32(data))); @@ -1838,6 +1852,7 @@ ipw_config(struct ipw_softc *sc) if (error != 0) return error; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS || ic->ic_opmode == IEEE80211_M_HOSTAP) { data = htole32(ic->ic_lintval); @@ -1847,6 +1862,7 @@ ipw_config(struct ipw_softc *sc) if (error != 0) return error; } +#endif options.flags = htole32(0); options.channels = htole32(0x3fff); /* scan channels 1-14 */ diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 57858f61ee4..32cd3a77b38 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.87 2008/07/21 18:43:18 damien Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.88 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2004-2006 @@ -268,7 +268,9 @@ iwi_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = +#ifndef IEEE80211_STA_ONLY IEEE80211_C_IBSS | /* IBSS mode supported */ +#endif IEEE80211_C_MONITOR | /* monitor mode supported */ IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ @@ -688,19 +690,21 @@ iwi_media_status(struct ifnet *ifp, struct ifmediareq *imr) switch (ic->ic_opmode) { case IEEE80211_M_STA: break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_ADHOC; break; +#endif case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; - case IEEE80211_M_AHDEMO: - case IEEE80211_M_HOSTAP: + default: /* should not get there */ break; } } +#ifndef IEEE80211_STA_ONLY /* * This is only used for IBSS mode where the firmware expect an index to an * internal node table instead of a destination address. @@ -731,6 +735,7 @@ iwi_find_txnode(struct iwi_softc *sc, const uint8_t *macaddr) return i; } +#endif int iwi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) @@ -751,10 +756,13 @@ iwi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) break; case IEEE80211_S_RUN: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) { sc->nsta = 0; /* flush IBSS nodes */ ieee80211_new_state(ic, IEEE80211_S_AUTH, -1); - } else if (ic->ic_opmode == IEEE80211_M_MONITOR) + } else +#endif + if (ic->ic_opmode == IEEE80211_M_MONITOR) iwi_set_chan(sc, ic->ic_ibss_chan); /* assoc led on */ @@ -934,8 +942,7 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, wh = mtod(m, struct ieee80211_frame *); rxi.rxi_flags = 0; - if ((wh->i_fc[1] & IEEE80211_FC1_WEP) && - ic->ic_opmode != IEEE80211_M_MONITOR) { + if (wh->i_fc[1] & IEEE80211_FC1_WEP) { /* * Hardware decrypts the frame itself but leaves the WEP bit * set in the 802.11 header and doesn't remove the IV and CRC @@ -1296,6 +1303,7 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) m_copydata(m0, 0, sizeof (struct ieee80211_frame), (caddr_t)&desc->wh); m_adj(m0, sizeof (struct ieee80211_frame)); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) { station = iwi_find_txnode(sc, desc->wh.i_addr1); if (station == -1) { @@ -1305,6 +1313,7 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) return 0; } } +#endif error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0, BUS_DMA_NOWAIT); @@ -1826,7 +1835,11 @@ iwi_config(struct iwi_softc *sc) config.multicast_enabled = 1; config.silence_threshold = 30; config.report_noise = 1; - config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0; + config.answer_pbreq = +#ifndef IEEE80211_STA_ONLY + (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : +#endif + 0; DPRINTF(("Configuring adapter\n")); error = iwi_cmd(sc, IWI_CMD_SET_CONFIG, &config, sizeof config, 0); if (error != 0) @@ -2034,7 +2047,11 @@ iwi_auth_and_assoc(struct iwi_softc *sc) config.multicast_enabled = 1; config.silence_threshold = 30; config.report_noise = 1; - config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0; + config.answer_pbreq = +#ifndef IEEE80211_STA_ONLY + (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : +#endif + 0; if (ic->ic_curmode == IEEE80211_MODE_11G) config.bg_autodetection = 1; DPRINTF(("Configuring adapter\n")); @@ -2081,9 +2098,11 @@ iwi_auth_and_assoc(struct iwi_softc *sc) return error; bzero(&assoc, sizeof assoc); +#ifndef IEEE80211_STA_ONLY if (ic->ic_flags & IEEE80211_F_SIBSS) assoc.type = IWI_ASSOC_SIBSS; else +#endif assoc.type = IWI_ASSOC_ASSOCIATE; if (ic->ic_curmode == IEEE80211_MODE_11A) assoc.mode = IWI_MODE_11A; @@ -2112,9 +2131,11 @@ iwi_auth_and_assoc(struct iwi_softc *sc) assoc.lintval = htole16(ic->ic_lintval); assoc.intval = htole16(ni->ni_intval); IEEE80211_ADDR_COPY(assoc.bssid, ni->ni_bssid); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) IEEE80211_ADDR_COPY(assoc.dst, etherbroadcastaddr); else +#endif IEEE80211_ADDR_COPY(assoc.dst, ni->ni_bssid); DPRINTF(("Trying to associate to %s channel %u auth %u\n", @@ -2142,18 +2163,21 @@ iwi_init(struct ifnet *ifp) switch (sc->sc_ic.ic_opmode) { case IEEE80211_M_STA: - case IEEE80211_M_HOSTAP: name = "iwi-bss"; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: name = "iwi-ibss"; break; +#endif case IEEE80211_M_MONITOR: name = "iwi-monitor"; break; default: - name = NULL; /* should not get there */ + /* should not get there */ + error = EINVAL; + goto fail1; } if ((error = loadfirmware(name, &data, &size)) != 0) { diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 1c6b846a55d..52a7f664970 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.22 2008/07/31 20:14:17 damien Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.23 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2007,2008 @@ -3297,6 +3297,8 @@ iwn_config(struct iwn_softc *sc) sc->config.mode = IWN_MODE_STA; sc->config.filter |= htole32(IWN_FILTER_MULTICAST); break; +#ifndef IEEE80211_STA_ONLY +#ifdef notyet case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: sc->config.mode = IWN_MODE_IBSS; @@ -3304,11 +3306,16 @@ iwn_config(struct iwn_softc *sc) case IEEE80211_M_HOSTAP: sc->config.mode = IWN_MODE_HOSTAP; break; +#endif +#endif case IEEE80211_M_MONITOR: sc->config.mode = IWN_MODE_MONITOR; sc->config.filter |= htole32(IWN_FILTER_MULTICAST | IWN_FILTER_CTL | IWN_FILTER_PROMISC); break; + default: + /* should not get there */ + break; } sc->config.cck_mask = 0x0f; /* not yet negotiated */ sc->config.ofdm_mask = 0xff; /* not yet negotiated */ diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index e1030d61273..fb8c60fdd37 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.63 2008/07/31 20:14:17 damien Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.64 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2006, 2007 @@ -2608,6 +2608,8 @@ wpi_config(struct wpi_softc *sc) sc->config.mode = WPI_MODE_STA; sc->config.filter |= htole32(WPI_FILTER_MULTICAST); break; +#ifndef IEEE80211_STA_ONLY +#ifdef notyet case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: sc->config.mode = WPI_MODE_IBSS; @@ -2615,11 +2617,16 @@ wpi_config(struct wpi_softc *sc) case IEEE80211_M_HOSTAP: sc->config.mode = WPI_MODE_HOSTAP; break; +#endif +#endif case IEEE80211_M_MONITOR: sc->config.mode = WPI_MODE_MONITOR; sc->config.filter |= htole32(WPI_FILTER_MULTICAST | WPI_FILTER_CTL | WPI_FILTER_PROMISC); break; + default: + /* should not get there */ + break; } sc->config.cck_mask = 0x0f; /* not yet negotiated */ sc->config.ofdm_mask = 0xff; /* not yet negotiated */ diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 5e7a8c3400d..0adacf6c1bd 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.106 2008/08/14 16:02:24 damien Exp $ */ +/* $OpenBSD: if_ral.c,v 1.107 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -127,8 +127,10 @@ uint16_t ural_txtime(int, int, uint32_t); uint8_t ural_plcp_signal(int); void ural_setup_tx_desc(struct ural_softc *, struct ural_tx_desc *, uint32_t, int, int); +#ifndef IEEE80211_STA_ONLY int ural_tx_bcn(struct ural_softc *, struct mbuf *, struct ieee80211_node *); +#endif int ural_tx_data(struct ural_softc *, struct mbuf *, struct ieee80211_node *); void ural_start(struct ifnet *); @@ -295,9 +297,11 @@ ural_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAp mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -552,7 +556,6 @@ ural_task(void *arg) struct ieee80211com *ic = &sc->sc_ic; enum ieee80211_state ostate; struct ieee80211_node *ni; - struct mbuf *m; ostate = ic->ic_state; @@ -592,9 +595,10 @@ ural_task(void *arg) ural_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) { - m = ieee80211_beacon_alloc(ic, ni); + struct mbuf *m = ieee80211_beacon_alloc(ic, ni); if (m == NULL) { printf("%s: could not allocate beacon\n", sc->sc_dev.dv_xname); @@ -611,6 +615,7 @@ ural_task(void *arg) /* beacon is no longer needed */ m_freem(m); } +#endif /* make tx led blink on tx (controlled by ASIC) */ ural_write(sc, RAL_MAC_CSR20, 1); @@ -978,6 +983,7 @@ ural_setup_tx_desc(struct ural_softc *sc, struct ural_tx_desc *desc, #define RAL_TX_TIMEOUT 5000 +#ifndef IEEE80211_STA_ONLY int ural_tx_bcn(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) { @@ -1027,6 +1033,7 @@ ural_tx_bcn(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) return error; } +#endif int ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) @@ -1157,11 +1164,13 @@ ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) ic->ic_flags) + RAL_SIFS; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp in probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RAL_TX_TIMESTAMP; +#endif } #if NBPFILTER > 0 @@ -1661,8 +1670,16 @@ ural_enable_tsf_sync(struct ural_softc *sc) tmp = (16 * ic->ic_bss->ni_intval) << 4; ural_write(sc, RAL_TXRX_CSR18, tmp); - logcwmin = (ic->ic_opmode == IEEE80211_M_IBSS) ? 2 : 0; - preload = (ic->ic_opmode == IEEE80211_M_IBSS) ? 320 : 6; +#ifndef IEEE80211_STA_ONLY + if (ic->ic_opmode == IEEE80211_M_IBSS) { + logcwmin = 2; + preload = 320; + } else +#endif + { + logcwmin = 0; + preload = 6; + } tmp = logcwmin << 12 | preload; ural_write(sc, RAL_TXRX_CSR20, tmp); @@ -1670,8 +1687,10 @@ ural_enable_tsf_sync(struct ural_softc *sc) tmp = RAL_ENABLE_TSF | RAL_ENABLE_TBCN; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RAL_ENABLE_TSF_SYNC(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RAL_ENABLE_TSF_SYNC(2) | RAL_ENABLE_BEACON_GENERATOR; +#endif ural_write(sc, RAL_TXRX_CSR19, tmp); DPRINTF(("enabling TSF synchronization\n")); @@ -2041,7 +2060,9 @@ ural_init(struct ifnet *ifp) tmp = RAL_DROP_PHY_ERROR | RAL_DROP_CRC_ERROR; if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RAL_DROP_CTL | RAL_DROP_VERSION_ERROR; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RAL_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RAL_DROP_NOT_TO_ME; diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 758fe814af8..df53a86dad1 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.77 2008/08/19 02:34:04 deraadt Exp $ */ +/* $OpenBSD: if_rum.c,v 1.78 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini @@ -183,7 +183,9 @@ int rum_bbp_init(struct rum_softc *); int rum_init(struct ifnet *); void rum_stop(struct ifnet *, int); int rum_load_microcode(struct rum_softc *, const u_char *, size_t); +#ifndef IEEE80211_STA_ONLY int rum_prepare_beacon(struct rum_softc *); +#endif void rum_newassoc(struct ieee80211com *, struct ieee80211_node *, int); void rum_amrr_start(struct rum_softc *, struct ieee80211_node *); @@ -359,9 +361,11 @@ rum_attach(struct device *parent, struct device *self, void *aux) /* set device capabilities */ ic->ic_caps = - IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_MONITOR | /* monitor mode supported */ +#ifndef IEEE80211_STA_ONLY + IEEE80211_C_IBSS | /* IBSS mode supported */ IEEE80211_C_HOSTAP | /* HostAp mode supported */ +#endif IEEE80211_C_TXPMGT | /* tx power management */ IEEE80211_C_SHPREAMBLE | /* short preamble supported */ IEEE80211_C_SHSLOT | /* short slot time supported */ @@ -683,9 +687,11 @@ rum_task(void *arg) rum_set_bssid(sc, ni->ni_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP || ic->ic_opmode == IEEE80211_M_IBSS) rum_prepare_beacon(sc); +#endif if (ic->ic_opmode != IEEE80211_M_MONITOR) rum_enable_tsf_sync(sc); @@ -1173,11 +1179,13 @@ rum_tx_data(struct rum_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) ic->ic_flags) + sc->sifs; *(uint16_t *)wh->i_dur = htole16(dur); +#ifndef IEEE80211_STA_ONLY /* tell hardware to set timestamp in probe responses */ if ((wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP)) flags |= RT2573_TX_TIMESTAMP; +#endif } #if NBPFILTER > 0 @@ -1745,6 +1753,7 @@ rum_enable_tsf_sync(struct rum_softc *sc) struct ieee80211com *ic = &sc->sc_ic; uint32_t tmp; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA) { /* * Change default 16ms TBTT adjustment to 8ms. @@ -1752,6 +1761,7 @@ rum_enable_tsf_sync(struct rum_softc *sc) */ rum_write(sc, RT2573_TXRX_CSR10, 1 << 12 | 8); } +#endif tmp = rum_read(sc, RT2573_TXRX_CSR9) & 0xff000000; @@ -1761,9 +1771,10 @@ rum_enable_tsf_sync(struct rum_softc *sc) tmp |= RT2573_TSF_TICKING | RT2573_ENABLE_TBTT; if (ic->ic_opmode == IEEE80211_M_STA) tmp |= RT2573_TSF_MODE(1); +#ifndef IEEE80211_STA_ONLY else tmp |= RT2573_TSF_MODE(2) | RT2573_GENERATE_BEACON; - +#endif rum_write(sc, RT2573_TXRX_CSR9, tmp); } @@ -2064,7 +2075,9 @@ rum_init(struct ifnet *ifp) if (ic->ic_opmode != IEEE80211_M_MONITOR) { tmp |= RT2573_DROP_CTL | RT2573_DROP_VER_ERROR | RT2573_DROP_ACKCTS; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif tmp |= RT2573_DROP_TODS; if (!(ifp->if_flags & IFF_PROMISC)) tmp |= RT2573_DROP_NOT_TO_ME; @@ -2147,6 +2160,7 @@ rum_load_microcode(struct rum_softc *sc, const u_char *ucode, size_t size) return error; } +#ifndef IEEE80211_STA_ONLY int rum_prepare_beacon(struct rum_softc *sc) { @@ -2179,6 +2193,7 @@ rum_prepare_beacon(struct rum_softc *sc) return 0; } +#endif void rum_newassoc(struct ieee80211com *ic, struct ieee80211_node *ni, int isnew) diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index b509739439f..a19985d687f 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.69 2008/07/21 18:43:19 damien Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.70 2008/08/27 09:05:03 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini @@ -1734,10 +1734,12 @@ zyd_set_rxfilter(struct zyd_softc *sc) case IEEE80211_M_STA: rxfilter = ZYD_FILTER_BSS; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_HOSTAP: rxfilter = ZYD_FILTER_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: rxfilter = ZYD_FILTER_MONITOR; break; diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 3d4fc6c7ea4..e922fad906c 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211.c,v 1.33 2008/07/27 14:21:15 damien Exp $ */ +/* $OpenBSD: ieee80211.c,v 1.34 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */ /*- @@ -285,12 +285,14 @@ ieee80211_media_init(struct ifnet *ifp, continue; mopt = mopts[mode]; ADD(ic, IFM_AUTO, mopt); /* e.g. 11a auto */ +#ifndef IEEE80211_STA_ONLY if (ic->ic_caps & IEEE80211_C_IBSS) ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_IBSS); if (ic->ic_caps & IEEE80211_C_HOSTAP) ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_HOSTAP); if (ic->ic_caps & IEEE80211_C_AHDEMO) ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_ADHOC); +#endif if (ic->ic_caps & IEEE80211_C_MONITOR) ADD(ic, IFM_AUTO, mopt | IFM_IEEE80211_MONITOR); if (mode == IEEE80211_MODE_AUTO) @@ -302,12 +304,14 @@ ieee80211_media_init(struct ifnet *ifp, if (mword == 0) continue; ADD(ic, mword, mopt); +#ifndef IEEE80211_STA_ONLY if (ic->ic_caps & IEEE80211_C_IBSS) ADD(ic, mword, mopt | IFM_IEEE80211_IBSS); if (ic->ic_caps & IEEE80211_C_HOSTAP) ADD(ic, mword, mopt | IFM_IEEE80211_HOSTAP); if (ic->ic_caps & IEEE80211_C_AHDEMO) ADD(ic, mword, mopt | IFM_IEEE80211_ADHOC); +#endif if (ic->ic_caps & IEEE80211_C_MONITOR) ADD(ic, mword, mopt | IFM_IEEE80211_MONITOR); /* @@ -334,12 +338,14 @@ ieee80211_media_init(struct ifnet *ifp, continue; mword = IFM_SUBTYPE(mword); /* remove media options */ ADD(ic, mword, 0); +#ifndef IEEE80211_STA_ONLY if (ic->ic_caps & IEEE80211_C_IBSS) ADD(ic, mword, IFM_IEEE80211_IBSS); if (ic->ic_caps & IEEE80211_C_HOSTAP) ADD(ic, mword, IFM_IEEE80211_HOSTAP); if (ic->ic_caps & IEEE80211_C_AHDEMO) ADD(ic, mword, IFM_IEEE80211_ADHOC); +#endif if (ic->ic_caps & IEEE80211_C_MONITOR) ADD(ic, mword, IFM_IEEE80211_MONITOR); } @@ -456,17 +462,21 @@ ieee80211_media_change(struct ifnet *ifp) /* * Deduce new operating mode but don't install it just yet. */ +#ifndef IEEE80211_STA_ONLY if (ime->ifm_media & IFM_IEEE80211_ADHOC) newopmode = IEEE80211_M_AHDEMO; else if (ime->ifm_media & IFM_IEEE80211_HOSTAP) newopmode = IEEE80211_M_HOSTAP; else if (ime->ifm_media & IFM_IEEE80211_IBSS) newopmode = IEEE80211_M_IBSS; - else if (ime->ifm_media & IFM_IEEE80211_MONITOR) + else +#endif + if (ime->ifm_media & IFM_IEEE80211_MONITOR) newopmode = IEEE80211_M_MONITOR; else newopmode = IEEE80211_M_STA; +#ifndef IEEE80211_STA_ONLY /* * Autoselect doesn't make sense when operating as an AP. * If no phy mode has been selected, pick one and lock it @@ -481,6 +491,7 @@ ieee80211_media_change(struct ifnet *ifp) break; } } +#endif /* * Handle phy mode change. @@ -505,6 +516,7 @@ ieee80211_media_change(struct ifnet *ifp) */ if (ic->ic_opmode != newopmode) { ic->ic_opmode = newopmode; +#ifndef IEEE80211_STA_ONLY switch (newopmode) { case IEEE80211_M_AHDEMO: case IEEE80211_M_HOSTAP: @@ -516,6 +528,7 @@ ieee80211_media_change(struct ifnet *ifp) ic->ic_flags |= IEEE80211_F_IBSSON; break; } +#endif /* * Yech, slot time may change depending on the * operating mode so reset it to be sure everything @@ -549,6 +562,7 @@ ieee80211_media_status(struct ifnet *ifp, struct ifmediareq *imr) imr->ifm_active |= ieee80211_rate2media(ic, ni->ni_rates.rs_rates[ni->ni_txrate], ic->ic_curmode); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: imr->ifm_active |= IFM_IEEE80211_IBSS; break; @@ -558,9 +572,12 @@ ieee80211_media_status(struct ifnet *ifp, struct ifmediareq *imr) case IEEE80211_M_HOSTAP: imr->ifm_active |= IFM_IEEE80211_HOSTAP; break; +#endif case IEEE80211_M_MONITOR: imr->ifm_active |= IFM_IEEE80211_MONITOR; break; + default: + break; } switch (ic->ic_curmode) { case IEEE80211_MODE_11A: diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 7202564cec4..93c65db645c 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.c,v 1.54 2008/08/14 16:14:53 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.c,v 1.55 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -472,6 +472,7 @@ ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *key, return memcmp(key->mic, mic, EAPOL_KEY_MIC_LEN) != 0; } +#ifndef IEEE80211_STA_ONLY /* * Encrypt the Key Data field of an EAPOL-Key frame using the specified Key * Encryption Key (KEK). The encryption algorithm can be either ARC4 or @@ -529,6 +530,7 @@ ieee80211_eapol_key_encrypt(struct ieee80211com *ic, break; } } +#endif /* IEEE80211_STA_ONLY */ /* * Decrypt the Key Data field of an EAPOL-Key frame using the specified Key diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index 28c8c6c9731..56492203c3f 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.h,v 1.19 2008/08/12 19:29:07 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.h,v 1.20 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2007,2008 Damien Bergamini @@ -100,8 +100,10 @@ void ieee80211_eapol_key_mic(struct ieee80211_eapol_key *, const u_int8_t *); int ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *, const u_int8_t *); +#ifndef IEEE80211_STA_ONLY void ieee80211_eapol_key_encrypt(struct ieee80211com *, struct ieee80211_eapol_key *, const u_int8_t *); +#endif int ieee80211_eapol_key_decrypt(struct ieee80211_eapol_key *, const u_int8_t *); diff --git a/sys/net80211/ieee80211_crypto_tkip.c b/sys/net80211/ieee80211_crypto_tkip.c index 4f1fdde18e9..5bde7c517b3 100644 --- a/sys/net80211/ieee80211_crypto_tkip.c +++ b/sys/net80211/ieee80211_crypto_tkip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.7 2008/08/12 16:45:44 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto_tkip.c,v 1.8 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -80,10 +80,13 @@ ieee80211_tkip_set_key(struct ieee80211com *ic, struct ieee80211_key *k) * Use bits 128-191 as the Michael key for AA->SPA and bits * 192-255 as the Michael key for SPA->AA. */ +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { ctx->txmic = &k->k_key[16]; ctx->rxmic = &k->k_key[24]; - } else { + } else +#endif + { ctx->rxmic = &k->k_key[16]; ctx->txmic = &k->k_key[24]; } @@ -491,6 +494,7 @@ ieee80211_tkip_decrypt(struct ieee80211com *ic, struct mbuf *m0, return NULL; } +#ifndef IEEE80211_STA_ONLY /* * This function is called in HostAP mode to deauthenticate all STAs using * TKIP as their pairwise or group cipher (as part of TKIP countermeasures). @@ -509,6 +513,7 @@ ieee80211_tkip_deauth(void *arg, struct ieee80211_node *ni) ieee80211_node_leave(ic, ni); } } +#endif /* IEEE80211_STA_ONLY */ /* * This function can be called by the software TKIP crypto code or by the @@ -541,20 +546,26 @@ ieee80211_michael_mic_failure(struct ieee80211com *ic, u_int64_t tsc) } ic->ic_tkip_micfail = ticks; - if (ic->ic_opmode == IEEE80211_M_HOSTAP) { + switch (ic->ic_opmode) { +#ifndef IEEE80211_STA_ONLY + case IEEE80211_M_HOSTAP: /* refuse new TKIP associations for the next 60 seconds */ ic->ic_flags |= IEEE80211_F_COUNTERM; /* deauthenticate all currently associated STAs using TKIP */ ieee80211_iterate_nodes(ic, ieee80211_tkip_deauth, ic); - - } else if (ic->ic_opmode == IEEE80211_M_STA) { + break; +#endif + case IEEE80211_M_STA: /* deauthenticate from the AP.. */ IEEE80211_SEND_MGMT(ic, ic->ic_bss, IEEE80211_FC0_SUBTYPE_DEAUTH, IEEE80211_REASON_MIC_FAILURE); /* ..and find another one */ (void)ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); + break; + default: + break; } } diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index bb45bc3b5a6..2bc3425bdaa 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_input.c,v 1.100 2008/08/14 16:07:58 damien Exp $ */ +/* $OpenBSD: ieee80211_input.c,v 1.101 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe @@ -73,16 +73,22 @@ enum ieee80211_akm ieee80211_parse_rsn_akm(const u_int8_t[]); int ieee80211_parse_rsn_body(struct ieee80211com *, const u_int8_t *, u_int, struct ieee80211_rsnparams *); int ieee80211_save_ie(const u_int8_t *, u_int8_t **); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_pspoll(struct ieee80211com *, struct mbuf *, struct ieee80211_node *); +#endif void ieee80211_recv_probe_resp(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *, int); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_probe_req(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *); +#endif void ieee80211_recv_auth(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_assoc_req(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, struct ieee80211_rxinfo *, int); +#endif void ieee80211_recv_assoc_resp(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, int); void ieee80211_recv_deauth(struct ieee80211com *, struct mbuf *, @@ -208,6 +214,7 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, ni->ni_inact = 0; } +#ifndef IEEE80211_STA_ONLY if ((ic->ic_caps & IEEE80211_C_PMGT) && ic->ic_opmode == IEEE80211_M_HOSTAP && ni->ni_state == IEEE80211_STA_ASSOC) { @@ -237,7 +244,7 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, } } } - +#endif switch (type) { case IEEE80211_FC0_TYPE_DATA: switch (ic->ic_opmode) { @@ -267,6 +274,7 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, goto out; } break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: if (dir != IEEE80211_FC1_DIR_NODS) { @@ -325,7 +333,8 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, goto err; } break; - case IEEE80211_M_MONITOR: +#endif /* IEEE80211_STA_ONLY */ + default: /* can't get there */ goto out; } @@ -375,10 +384,12 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, ic->ic_stats.is_rx_wrongdir++; goto err; } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_AHDEMO) { ic->ic_stats.is_rx_ahdemo_mgt++; goto out; } +#endif subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; /* drop frames without interest */ @@ -423,10 +434,12 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, if (ic->ic_state == IEEE80211_S_SCAN) doprint = 1; break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_PROBE_REQ: if (ic->ic_opmode == IEEE80211_M_IBSS) doprint = 1; break; +#endif default: doprint = 1; break; @@ -464,9 +477,11 @@ ieee80211_input(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni, ic->ic_stats.is_rx_ctl++; subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; switch (subtype) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_PS_POLL: ieee80211_recv_pspoll(ic, m, ni); break; +#endif case IEEE80211_FC0_SUBTYPE_BAR: /* NYI */ break; @@ -498,10 +513,8 @@ ieee80211_deliver_data(struct ieee80211com *ic, struct mbuf *m, struct ieee80211_node *ni) { struct ifnet *ifp = &ic->ic_if; - struct ieee80211_node *ni1; struct ether_header *eh; struct mbuf *m1; - int error, len; eh = mtod(m, struct ether_header *); @@ -520,9 +533,13 @@ ieee80211_deliver_data(struct ieee80211com *ic, struct mbuf *m, * bridge EAPOL frames as suggested in C.1.1 of IEEE Std 802.1X. */ m1 = NULL; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP && !(ic->ic_flags & IEEE80211_F_NOBRIDGE) && eh->ether_type != htons(ETHERTYPE_PAE)) { + struct ieee80211_node *ni1; + int error, len; + if (ETHER_IS_MULTICAST(eh->ether_dhost)) { m1 = m_copym(m, 0, M_COPYALL, M_DONTWAIT); if (m1 == NULL) @@ -550,6 +567,7 @@ ieee80211_deliver_data(struct ieee80211com *ic, struct mbuf *m, } } } +#endif if (m != NULL) { #if NBPFILTER > 0 /* @@ -975,8 +993,10 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m0, */ #ifdef DIAGNOSTIC if (ic->ic_opmode != IEEE80211_M_STA && +#ifndef IEEE80211_STA_ONLY ic->ic_opmode != IEEE80211_M_IBSS && ic->ic_opmode != IEEE80211_M_HOSTAP && +#endif ic->ic_state != IEEE80211_S_SCAN) { panic("%s: impossible operating mode", __func__); } @@ -1085,6 +1105,7 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m0, DPRINTF(("invalid SSID element\n")); return; } + if ( #if IEEE80211_CHAN_MAX < 255 chan > IEEE80211_CHAN_MAX || @@ -1194,7 +1215,9 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m0, } if (ic->ic_state == IEEE80211_S_SCAN && +#ifndef IEEE80211_STA_ONLY ic->ic_opmode != IEEE80211_M_HOSTAP && +#endif (ic->ic_flags & IEEE80211_F_RSNON)) { struct ieee80211_rsnparams rsn; const u_int8_t *saveie = NULL; @@ -1255,7 +1278,11 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m0, * Anything else can be discarded (XXX and should be handled * above so we don't do so much work). */ - if (ic->ic_opmode == IEEE80211_M_IBSS || (is_new && isprobe)) { + if ( +#ifndef IEEE80211_STA_ONLY + ic->ic_opmode == IEEE80211_M_IBSS || +#endif + (is_new && isprobe)) { /* * Fake an association so the driver can setup it's * private state. The rate set has been setup above; @@ -1266,6 +1293,7 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m0, } } +#ifndef IEEE80211_STA_ONLY /*- * Probe request frame format: * [tlv] SSID @@ -1351,6 +1379,7 @@ ieee80211_recv_probe_req(struct ieee80211com *ic, struct mbuf *m0, } IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_PROBE_RESP, 0); } +#endif /* IEEE80211_STA_ONLY */ /*- * Authentication frame format: @@ -1385,17 +1414,20 @@ ieee80211_recv_auth(struct ieee80211com *ic, struct mbuf *m0, DPRINTF(("unsupported auth algorithm %d from %s\n", algo, ether_sprintf((u_int8_t *)wh->i_addr2))); ic->ic_stats.is_rx_auth_unsupported++; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* XXX hack to workaround calling convention */ IEEE80211_SEND_MGMT(ic, ni, IEEE80211_FC0_SUBTYPE_AUTH, (seq+1) | (IEEE80211_STATUS_ALG<<16)); } +#endif return; } ieee80211_auth_open(ic, wh, ni, rxi, seq, status); } +#ifndef IEEE80211_STA_ONLY /*- * (Re)Association request frame format: * [2] Capability information @@ -1636,6 +1668,7 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m0, } else ieee80211_node_join(ic, ni, resp); } +#endif /* IEEE80211_STA_ONLY */ /*- * (Re)Association response frame format: @@ -1785,7 +1818,6 @@ void ieee80211_recv_deauth(struct ieee80211com *ic, struct mbuf *m0, struct ieee80211_node *ni) { - struct ifnet *ifp = &ic->ic_if; const struct ieee80211_frame *wh; const u_int8_t *frm; u_int16_t reason; @@ -1806,17 +1838,19 @@ ieee80211_recv_deauth(struct ieee80211com *ic, struct mbuf *m0, ieee80211_new_state(ic, IEEE80211_S_AUTH, IEEE80211_FC0_SUBTYPE_DEAUTH); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_HOSTAP: if (ni != ic->ic_bss) { - if (ifp->if_flags & IFF_DEBUG) + if (ic->ic_if.if_flags & IFF_DEBUG) printf("%s: station %s deauthenticated " "by peer (reason %d)\n", - ifp->if_xname, + ic->ic_if.if_xname, ether_sprintf(ni->ni_macaddr), reason); ieee80211_node_leave(ic, ni); } break; +#endif default: break; } @@ -1830,7 +1864,6 @@ void ieee80211_recv_disassoc(struct ieee80211com *ic, struct mbuf *m0, struct ieee80211_node *ni) { - struct ifnet *ifp = &ic->ic_if; const struct ieee80211_frame *wh; const u_int8_t *frm; u_int16_t reason; @@ -1851,17 +1884,19 @@ ieee80211_recv_disassoc(struct ieee80211com *ic, struct mbuf *m0, ieee80211_new_state(ic, IEEE80211_S_ASSOC, IEEE80211_FC0_SUBTYPE_DISASSOC); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_HOSTAP: if (ni != ic->ic_bss) { - if (ifp->if_flags & IFF_DEBUG) + if (ic->ic_if.if_flags & IFF_DEBUG) printf("%s: station %s disassociated " "by peer (reason %d)\n", - ifp->if_xname, + ic->ic_if.if_xname, ether_sprintf(ni->ni_macaddr), reason); ieee80211_node_leave(ic, ni); } break; +#endif default: break; } @@ -1934,18 +1969,22 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0, case IEEE80211_FC0_SUBTYPE_PROBE_RESP: ieee80211_recv_probe_resp(ic, m0, ni, rxi, 1); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_PROBE_REQ: ieee80211_recv_probe_req(ic, m0, ni, rxi); break; +#endif case IEEE80211_FC0_SUBTYPE_AUTH: ieee80211_recv_auth(ic, m0, ni, rxi); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_ASSOC_REQ: ieee80211_recv_assoc_req(ic, m0, ni, rxi, 0); break; case IEEE80211_FC0_SUBTYPE_REASSOC_REQ: ieee80211_recv_assoc_req(ic, m0, ni, rxi, 1); break; +#endif case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: ieee80211_recv_assoc_resp(ic, m0, ni, 0); break; @@ -1969,6 +2008,7 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0, } } +#ifndef IEEE80211_STA_ONLY /* * Process an incoming PS-Poll control frame (see 11.2). */ @@ -2020,3 +2060,4 @@ ieee80211_recv_pspoll(struct ieee80211com *ic, struct mbuf *m, IF_ENQUEUE(&ic->ic_pwrsaveq, m); (*ifp->if_start)(ifp); } +#endif /* IEEE80211_STA_ONLY */ diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 4445b113d5d..c1e799fe52a 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.c,v 1.22 2008/08/12 19:29:07 damien Exp $ */ +/* $OpenBSD: ieee80211_ioctl.c,v 1.23 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */ /*- @@ -473,8 +473,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ic->ic_flags |= IEEE80211_F_DESBSSID; IEEE80211_ADDR_COPY(ic->ic_des_bssid, bssid->i_bssid); } +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) break; +#endif switch (ic->ic_state) { case IEEE80211_S_INIT: case IEEE80211_S_SCAN: @@ -493,10 +495,13 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) switch (ic->ic_state) { case IEEE80211_S_INIT: case IEEE80211_S_SCAN: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) IEEE80211_ADDR_COPY(bssid->i_bssid, ic->ic_myaddr); - else if (ic->ic_flags & IEEE80211_F_DESBSSID) + else +#endif + if (ic->ic_flags & IEEE80211_F_DESBSSID) IEEE80211_ADDR_COPY(bssid->i_bssid, ic->ic_des_bssid); else @@ -599,8 +604,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCS80211SCAN: if ((error = suser(curproc, 0)) != 0) break; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) break; +#endif if ((ifp->if_flags & IFF_UP) == 0) { error = ENETDOWN; break; @@ -628,10 +635,12 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCS80211NODE: if ((error = suser(curproc, 0)) != 0) break; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { error = EINVAL; break; } +#endif nr = (struct ieee80211_nodereq *)data; ni = ieee80211_find_node(ic, nr->nr_macaddr); @@ -691,7 +700,9 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCG80211FLAGS: flags = ic->ic_flags; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif flags &= ~IEEE80211_F_HOSTAPMASK; ifr->ifr_flags = flags >> IEEE80211_F_USERSHIFT; break; @@ -699,11 +710,13 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if ((error = suser(curproc, 0)) != 0) break; flags = (u_int32_t)ifr->ifr_flags << IEEE80211_F_USERSHIFT; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_HOSTAP && (flags & IEEE80211_F_HOSTAPMASK)) { error = EINVAL; break; } +#endif ic->ic_flags = (ic->ic_flags & ~IEEE80211_F_USERMASK) | flags; error = ENETRESET; break; diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 0dd5d7e277b..7252e17e4c2 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.c,v 1.43 2008/08/12 19:29:07 damien Exp $ */ +/* $OpenBSD: ieee80211_node.c,v 1.44 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /*- @@ -80,11 +80,13 @@ void ieee80211_setup_node(struct ieee80211com *, struct ieee80211_node *, void ieee80211_free_node(struct ieee80211com *, struct ieee80211_node *); struct ieee80211_node *ieee80211_alloc_node_helper(struct ieee80211com *); void ieee80211_node_cleanup(struct ieee80211com *, struct ieee80211_node *); +#ifndef IEEE80211_STA_ONLY void ieee80211_node_join_rsn(struct ieee80211com *, struct ieee80211_node *); void ieee80211_node_join_11g(struct ieee80211com *, struct ieee80211_node *); void ieee80211_node_leave_rsn(struct ieee80211com *, struct ieee80211_node *); void ieee80211_node_leave_11g(struct ieee80211com *, struct ieee80211_node *); void ieee80211_set_tim(struct ieee80211com *, int, int); +#endif #define M_80211_NODE M_DEVBUF @@ -92,7 +94,9 @@ void ieee80211_node_attach(struct ifnet *ifp) { struct ieee80211com *ic = (void *)ifp; +#ifndef IEEE80211_STA_ONLY int size; +#endif RB_INIT(&ic->ic_tree); ic->ic_node_alloc = ieee80211_node_alloc; @@ -106,6 +110,7 @@ ieee80211_node_attach(struct ifnet *ifp) ic->ic_max_aid = IEEE80211_AID_DEF; else if (ic->ic_max_aid > IEEE80211_AID_MAX) ic->ic_max_aid = IEEE80211_AID_MAX; +#ifndef IEEE80211_STA_ONLY size = howmany(ic->ic_max_aid, 32) * sizeof(u_int32_t); ic->ic_aid_bitmap = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); if (ic->ic_aid_bitmap == NULL) { @@ -125,6 +130,7 @@ ieee80211_node_attach(struct ifnet *ifp) timeout_set(&ic->ic_rsn_timeout, ieee80211_gtk_rekey_timeout, ic); } +#endif } struct ieee80211_node * @@ -207,11 +213,17 @@ ieee80211_begin_scan(struct ifnet *ifp) * In all but hostap mode scanning starts off in * an active mode before switching to passive. */ - if (ic->ic_opmode != IEEE80211_M_HOSTAP) { +#ifndef IEEE80211_STA_ONLY + if (ic->ic_opmode != IEEE80211_M_HOSTAP) +#endif + { ic->ic_flags |= IEEE80211_F_ASCAN; ic->ic_stats.is_scan_active++; - } else + } +#ifndef IEEE80211_STA_ONLY + else ic->ic_stats.is_scan_passive++; +#endif if (ifp->if_flags & IFF_DEBUG) printf("%s: begin %s scan\n", ifp->if_xname, (ic->ic_flags & IEEE80211_F_ASCAN) ? @@ -274,6 +286,7 @@ ieee80211_next_scan(struct ifnet *ifp) ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); } +#ifndef IEEE80211_STA_ONLY void ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan) { @@ -359,6 +372,7 @@ ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan) } ieee80211_new_state(ic, IEEE80211_S_RUN, -1); } +#endif /* IEEE80211_STA_ONLY */ int ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni) @@ -372,10 +386,13 @@ ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni) if (ic->ic_des_chan != IEEE80211_CHAN_ANYC && ni->ni_chan != ic->ic_des_chan) fail |= 0x01; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) { if ((ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) == 0) fail |= 0x02; - } else { + } else +#endif + { if ((ni->ni_capinfo & IEEE80211_CAPINFO_ESS) == 0) fail |= 0x02; } @@ -470,7 +487,6 @@ ieee80211_end_scan(struct ifnet *ifp) { struct ieee80211com *ic = (void *)ifp; struct ieee80211_node *ni, *nextbs, *selbs; - int i, fail; if (ifp->if_flags & IFF_DEBUG) printf("%s: end %s scan\n", ifp->if_xname, @@ -482,9 +498,12 @@ ieee80211_end_scan(struct ifnet *ifp) ni = RB_MIN(ieee80211_tree, &ic->ic_tree); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { /* XXX off stack? */ u_char occupied[howmany(IEEE80211_CHAN_MAX, NBBY)]; + int i, fail; + /* * The passive scan to look for existing AP's completed, * select a channel to camp on. Identify the channels @@ -506,16 +525,19 @@ ieee80211_end_scan(struct ifnet *ifp) ieee80211_create_ibss(ic, &ic->ic_channels[i]); goto wakeup; } +#endif if (ni == NULL) { DPRINTF(("no scan candidate\n")); notfound: + +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS && (ic->ic_flags & IEEE80211_F_IBSSON) && ic->ic_des_esslen != 0) { ieee80211_create_ibss(ic, ic->ic_ibss_chan); goto wakeup; } - +#endif /* * Scan the next mode if nothing has been found. This * is necessary if the device supports different @@ -610,15 +632,16 @@ ieee80211_end_scan(struct ifnet *ifp) ni->ni_rsncipher = IEEE80211_CIPHER_USEGROUP; ieee80211_node_newstate(selbs, IEEE80211_STA_BSS); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) { ieee80211_fix_rate(ic, ni, IEEE80211_F_DOFRATE | IEEE80211_F_DONEGO | IEEE80211_F_DODEL); if (ni->ni_rates.rs_nrates == 0) goto notfound; ieee80211_new_state(ic, IEEE80211_S_RUN, -1); - } else { + } else +#endif ieee80211_new_state(ic, IEEE80211_S_AUTH, -1); - } wakeup: if (ic->ic_scan_lock & IEEE80211_SCAN_REQUEST) { @@ -763,8 +786,10 @@ ieee80211_find_node(struct ieee80211com *ic, const u_int8_t *macaddr) struct ieee80211_node * ieee80211_find_txnode(struct ieee80211com *ic, const u_int8_t *macaddr) { +#ifndef IEEE80211_STA_ONLY struct ieee80211_node *ni; int s; +#endif /* * The destination address should be in the node table @@ -774,6 +799,7 @@ ieee80211_find_txnode(struct ieee80211com *ic, const u_int8_t *macaddr) if (ic->ic_opmode == IEEE80211_M_STA || IEEE80211_IS_MULTICAST(macaddr)) return ieee80211_ref_node(ic->ic_bss); +#ifndef IEEE80211_STA_ONLY s = splnet(); ni = ieee80211_find_node(ic, macaddr); splx(s); @@ -799,6 +825,9 @@ ieee80211_find_txnode(struct ieee80211com *ic, const u_int8_t *macaddr) (*ic->ic_newassoc)(ic, ni, 1); } return ieee80211_ref_node(ni); +#else + return NULL; /* can't get there */ +#endif /* IEEE80211_STA_ONLY */ } /* @@ -830,7 +859,6 @@ static __inline int ieee80211_needs_rxnode(struct ieee80211com *ic, const struct ieee80211_frame *wh, const u_int8_t **bssid) { - struct ieee80211_node *bss = ic->ic_bss; int monitor, rc = 0; monitor = (ic->ic_opmode == IEEE80211_M_MONITOR); @@ -851,10 +879,12 @@ ieee80211_needs_rxnode(struct ieee80211com *ic, rc = 1; break; default: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_STA) break; - rc = IEEE80211_ADDR_EQ(*bssid, bss->ni_bssid) || + rc = IEEE80211_ADDR_EQ(*bssid, ic->ic_bss->ni_bssid) || IEEE80211_ADDR_EQ(*bssid, etherbroadcastaddr); +#endif break; } break; @@ -862,19 +892,27 @@ ieee80211_needs_rxnode(struct ieee80211com *ic, switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) { case IEEE80211_FC1_DIR_NODS: *bssid = wh->i_addr3; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS || ic->ic_opmode == IEEE80211_M_AHDEMO) - rc = IEEE80211_ADDR_EQ(*bssid, bss->ni_bssid); + rc = IEEE80211_ADDR_EQ(*bssid, + ic->ic_bss->ni_bssid); +#endif break; case IEEE80211_FC1_DIR_TODS: *bssid = wh->i_addr1; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) - rc = IEEE80211_ADDR_EQ(*bssid, bss->ni_bssid); + rc = IEEE80211_ADDR_EQ(*bssid, + ic->ic_bss->ni_bssid); +#endif break; case IEEE80211_FC1_DIR_FROMDS: case IEEE80211_FC1_DIR_DSTODS: *bssid = wh->i_addr2; +#ifndef IEEE80211_STA_ONLY rc = (ic->ic_opmode == IEEE80211_M_HOSTAP); +#endif break; } break; @@ -904,9 +942,10 @@ ieee80211_find_rxnode(struct ieee80211com *ic, if (ni != NULL) return ieee80211_ref_node(ni); +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) return ieee80211_ref_node(ic->ic_bss); - +#endif /* XXX see remarks in ieee80211_find_txnode */ /* XXX no rate negotiation; just dup */ if ((ni = ieee80211_dup_bss(ic, wh->i_addr2)) == NULL) @@ -1026,6 +1065,7 @@ ieee80211_clean_nodes(struct ieee80211com *ic) /* * Send a deauthenticate frame. */ +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) { splx(s); IEEE80211_SEND_MGMT(ic, ni, @@ -1034,6 +1074,7 @@ ieee80211_clean_nodes(struct ieee80211com *ic) s = splnet(); ieee80211_node_leave(ic, ni); } else +#endif ieee80211_free_node(ic, ni); ic->ic_stats.is_node_timeout++; } @@ -1084,6 +1125,7 @@ ieee80211_setup_rates(struct ieee80211com *ic, struct ieee80211_node *ni, return ieee80211_fix_rate(ic, ni, flags); } +#ifndef IEEE80211_STA_ONLY /* * Check if the specified node supports ERP. */ @@ -1470,6 +1512,7 @@ ieee80211_set_tim(struct ieee80211com *ic, int aid, int set) else clrbit(ic->ic_tim_bitmap, aid & ~0xc000); } +#endif /* IEEE80211_STA_ONLY */ /* * Compare nodes in the tree by lladdr diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index 46f873a6156..f3c1b4e63d0 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_output.c,v 1.71 2008/08/15 08:15:27 damien Exp $ */ +/* $OpenBSD: ieee80211_output.c,v 1.72 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */ /*- @@ -75,16 +75,20 @@ u_int8_t *ieee80211_add_rsn_body(u_int8_t *, struct ieee80211com *, struct mbuf *ieee80211_getmgmt(int, int, u_int); struct mbuf *ieee80211_get_probe_req(struct ieee80211com *, struct ieee80211_node *); +#ifndef IEEE80211_STA_ONLY struct mbuf *ieee80211_get_probe_resp(struct ieee80211com *, struct ieee80211_node *); +#endif struct mbuf *ieee80211_get_auth(struct ieee80211com *, struct ieee80211_node *, u_int16_t, u_int16_t); struct mbuf *ieee80211_get_deauth(struct ieee80211com *, struct ieee80211_node *, u_int16_t); struct mbuf *ieee80211_get_assoc_req(struct ieee80211com *, struct ieee80211_node *, int); +#ifndef IEEE80211_STA_ONLY struct mbuf *ieee80211_get_assoc_resp(struct ieee80211com *, struct ieee80211_node *, u_int16_t); +#endif struct mbuf *ieee80211_get_disassoc(struct ieee80211com *, struct ieee80211_node *, u_int16_t); @@ -214,7 +218,10 @@ ieee80211_mgmt_output(struct ifnet *ifp, struct ieee80211_node *ni, if (ifp->if_flags & IFF_DEBUG) { /* avoid to print too many frames */ - if (ic->ic_opmode == IEEE80211_M_IBSS || + if ( +#ifndef IEEE80211_STA_ONLY + ic->ic_opmode == IEEE80211_M_IBSS || +#endif #ifdef IEEE80211_DEBUG ieee80211_debug > 1 || #endif @@ -302,6 +309,7 @@ static const struct ieee80211_edca_ac_params } }; +#ifndef IEEE80211_STA_ONLY static const struct ieee80211_edca_ac_params ieee80211_qap_edca_table[IEEE80211_MODE_MAX][EDCA_NUM_AC] = { [IEEE80211_MODE_FH] = { @@ -335,6 +343,7 @@ static const struct ieee80211_edca_ac_params [EDCA_AC_VO] = { 2, 2, 1, 47 } } }; +#endif /* IEEE80211_STA_ONLY */ /* * Return the EDCA Access Category to be used for transmitting a frame with @@ -358,9 +367,10 @@ ieee80211_up_to_ac(struct ieee80211com *ic, int up) ac = (up <= 7) ? up_to_ac[up] : EDCA_AC_BE; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) return ac; - +#endif /* * We do not support the admission control procedure defined in * IEEE Std 802.11e-2005 section 9.9.3.1.2. The spec says that @@ -584,6 +594,7 @@ ieee80211_encap(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node **pni) IEEE80211_ADDR_COPY(wh->i_addr2, eh.ether_shost); IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_dhost); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: wh->i_fc[1] = IEEE80211_FC1_DIR_NODS; @@ -597,7 +608,9 @@ ieee80211_encap(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node **pni) IEEE80211_ADDR_COPY(wh->i_addr2, ni->ni_bssid); IEEE80211_ADDR_COPY(wh->i_addr3, eh.ether_shost); break; - case IEEE80211_M_MONITOR: +#endif + default: + /* should not get there */ goto bad; } @@ -626,15 +639,19 @@ ieee80211_add_capinfo(u_int8_t *frm, struct ieee80211com *ic, { u_int16_t capinfo; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_IBSS) capinfo = IEEE80211_CAPINFO_IBSS; else if (ic->ic_opmode == IEEE80211_M_HOSTAP) capinfo = IEEE80211_CAPINFO_ESS; else +#endif capinfo = 0; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP && (ic->ic_flags & (IEEE80211_F_WEPON | IEEE80211_F_RSNON))) capinfo |= IEEE80211_CAPINFO_PRIVACY; +#endif /* NB: some 11a AP's reject the request when short preamble is set */ if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) @@ -672,6 +689,7 @@ ieee80211_add_rates(u_int8_t *frm, const struct ieee80211_rateset *rs) return frm + nrates; } +#ifndef IEEE80211_STA_ONLY /* * Add a FH Parameter Set element to a frame (see 7.3.2.3). */ @@ -814,6 +832,7 @@ ieee80211_add_erp(u_int8_t *frm, struct ieee80211com *ic) *frm++ = erp; return frm; } +#endif /* IEEE80211_STA_ONLY */ /* * Add a QoS Capability element to a frame (see 7.3.2.35). @@ -1041,6 +1060,7 @@ ieee80211_get_probe_req(struct ieee80211com *ic, struct ieee80211_node *ni) return m; } +#ifndef IEEE80211_STA_ONLY /*- * Probe response frame format: * [8] Timestamp @@ -1111,6 +1131,7 @@ ieee80211_get_probe_resp(struct ieee80211com *ic, struct ieee80211_node *ni) return m; } +#endif /* IEEE80211_STA_ONLY */ /*- * Authentication frame format: @@ -1233,6 +1254,7 @@ ieee80211_get_assoc_req(struct ieee80211com *ic, struct ieee80211_node *ni, return m; } +#ifndef IEEE80211_STA_ONLY /*- * (Re)Association response frame format: * [2] Capability information @@ -1278,6 +1300,7 @@ ieee80211_get_assoc_resp(struct ieee80211com *ic, struct ieee80211_node *ni, return m; } +#endif /* IEEE80211_STA_ONLY */ /*- * Disassociation frame format: @@ -1331,12 +1354,12 @@ ieee80211_send_mgmt(struct ieee80211com *ic, struct ieee80211_node *ni, timer = IEEE80211_TRANS_WAIT; break; - +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_PROBE_RESP: if ((m = ieee80211_get_probe_resp(ic, ni)) == NULL) senderr(ENOMEM, is_tx_nombuf); break; - +#endif case IEEE80211_FC0_SUBTYPE_AUTH: m = ieee80211_get_auth(ic, ni, arg >> 16, arg & 0xffff); if (m == NULL) @@ -1363,13 +1386,13 @@ ieee80211_send_mgmt(struct ieee80211com *ic, struct ieee80211_node *ni, timer = IEEE80211_TRANS_WAIT; break; - +#ifndef IEEE80211_STA_ONLY case IEEE80211_FC0_SUBTYPE_ASSOC_RESP: case IEEE80211_FC0_SUBTYPE_REASSOC_RESP: if ((m = ieee80211_get_assoc_resp(ic, ni, arg)) == NULL) senderr(ENOMEM, is_tx_nombuf); break; - +#endif case IEEE80211_FC0_SUBTYPE_DISASSOC: if ((m = ieee80211_get_disassoc(ic, ni, arg)) == NULL) senderr(ENOMEM, is_tx_nombuf); @@ -1450,6 +1473,7 @@ ieee80211_get_cts_to_self(struct ieee80211com *ic, u_int16_t dur) return m; } +#ifndef IEEE80211_STA_ONLY /*- * Beacon frame format: * [8] Timestamp @@ -1569,3 +1593,4 @@ ieee80211_pwrsave(struct ieee80211com *ic, struct ieee80211_node *ni, m->m_pkthdr.rcvif = (void *)ni; } } +#endif /* IEEE80211_STA_ONLY */ diff --git a/sys/net80211/ieee80211_pae_input.c b/sys/net80211/ieee80211_pae_input.c index 6866c0aaad8..0577d360db6 100644 --- a/sys/net80211/ieee80211_pae_input.c +++ b/sys/net80211/ieee80211_pae_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_pae_input.c,v 1.11 2008/08/13 17:38:02 damien Exp $ */ +/* $OpenBSD: ieee80211_pae_input.c,v 1.12 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2007,2008 Damien Bergamini @@ -49,23 +49,29 @@ void ieee80211_recv_4way_msg1(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_4way_msg2(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *, const u_int8_t *); +#endif void ieee80211_recv_4way_msg3(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_4way_msg4(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); void ieee80211_recv_4way_msg2or4(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); +#endif void ieee80211_recv_rsn_group_msg1(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); void ieee80211_recv_wpa_group_msg1(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); +#ifndef IEEE80211_STA_ONLY void ieee80211_recv_group_msg2(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); void ieee80211_recv_eapol_key_req(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); +#endif /* * Process an incoming EAPOL frame. Notice that we are only interested in @@ -144,16 +150,19 @@ ieee80211_eapol_key_input(struct ieee80211com *ic, struct mbuf *m0, /* determine message type (see 8.5.3.7) */ if (info & EAPOL_KEY_REQUEST) { +#ifndef IEEE80211_STA_ONLY /* EAPOL-Key Request frame */ ieee80211_recv_eapol_key_req(ic, key, ni); - +#endif } else if (info & EAPOL_KEY_PAIRWISE) { /* 4-Way Handshake */ if (info & EAPOL_KEY_KEYMIC) { if (info & EAPOL_KEY_KEYACK) ieee80211_recv_4way_msg3(ic, key, ni); +#ifndef IEEE80211_STA_ONLY else ieee80211_recv_4way_msg2or4(ic, key, ni); +#endif } else if (info & EAPOL_KEY_KEYACK) ieee80211_recv_4way_msg1(ic, key, ni); } else { @@ -165,8 +174,11 @@ ieee80211_eapol_key_input(struct ieee80211com *ic, struct mbuf *m0, ieee80211_recv_wpa_group_msg1(ic, key, ni); else ieee80211_recv_rsn_group_msg1(ic, key, ni); - } else + } +#ifndef IEEE80211_STA_ONLY + else ieee80211_recv_group_msg2(ic, key, ni); +#endif } done: if (m0 != NULL) @@ -185,10 +197,11 @@ ieee80211_recv_4way_msg1(struct ieee80211com *ic, const u_int8_t *pmkid; const u_int8_t *pmk; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA && ic->ic_opmode != IEEE80211_M_IBSS) return; - +#endif if (ni->ni_replaycnt_ok && BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) { ic->ic_stats.is_rx_eapol_replay++; @@ -246,6 +259,7 @@ ieee80211_recv_4way_msg1(struct ieee80211com *ic, (void)ieee80211_send_4way_msg2(ic, ni, key->replaycnt, &tptk); } +#ifndef IEEE80211_STA_ONLY /* * Process Message 2 of the 4-Way Handshake (sent by Supplicant). */ @@ -313,6 +327,7 @@ ieee80211_recv_4way_msg2(struct ieee80211com *ic, /* send message 3 to supplicant */ (void)ieee80211_send_4way_msg3(ic, ni); } +#endif /* IEEE80211_STA_ONLY */ /* * Process Message 3 of the 4-Way Handshake (sent by Authenticator). @@ -329,10 +344,11 @@ ieee80211_recv_4way_msg3(struct ieee80211com *ic, u_int16_t info, reason = 0; int keylen; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA && ic->ic_opmode != IEEE80211_M_IBSS) return; - +#endif if (ni->ni_replaycnt_ok && BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) { ic->ic_stats.is_rx_eapol_replay++; @@ -567,8 +583,11 @@ ieee80211_recv_4way_msg3(struct ieee80211com *ic, if (info & EAPOL_KEY_SECURE) { ni->ni_flags |= IEEE80211_NODE_TXRXPROT; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_IBSS || - ++ni->ni_key_count == 2) { + ++ni->ni_key_count == 2) +#endif + { DPRINTF(("marking port %s valid\n", ether_sprintf(ni->ni_macaddr))); ni->ni_port_valid = 1; @@ -582,6 +601,7 @@ ieee80211_recv_4way_msg3(struct ieee80211com *ic, } } +#ifndef IEEE80211_STA_ONLY /* * Process Message 4 of the 4-Way Handshake (sent by Supplicant). */ @@ -695,6 +715,7 @@ ieee80211_recv_4way_msg2or4(struct ieee80211com *ic, else ieee80211_recv_4way_msg4(ic, key, ni); } +#endif /* IEEE80211_STA_ONLY */ /* * Process Message 1 of the RSN Group Key Handshake (sent by Authenticator). @@ -709,10 +730,11 @@ ieee80211_recv_rsn_group_msg1(struct ieee80211com *ic, u_int16_t info, kid, reason = 0; int keylen; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA && ic->ic_opmode != IEEE80211_M_IBSS) return; - +#endif if (BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) { ic->ic_stats.is_rx_eapol_replay++; return; @@ -814,8 +836,11 @@ ieee80211_recv_rsn_group_msg1(struct ieee80211com *ic, } } if (info & EAPOL_KEY_SECURE) { +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_IBSS || - ++ni->ni_key_count == 2) { + ++ni->ni_key_count == 2) +#endif + { DPRINTF(("marking port %s valid\n", ether_sprintf(ni->ni_macaddr))); ni->ni_port_valid = 1; @@ -849,10 +874,11 @@ ieee80211_recv_wpa_group_msg1(struct ieee80211com *ic, u_int8_t kid; int keylen; +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_STA && ic->ic_opmode != IEEE80211_M_IBSS) return; - +#endif if (BE_READ_8(key->replaycnt) <= ni->ni_replaycnt) { ic->ic_stats.is_rx_eapol_replay++; return; @@ -904,8 +930,11 @@ ieee80211_recv_wpa_group_msg1(struct ieee80211com *ic, return; } if (info & EAPOL_KEY_SECURE) { +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode != IEEE80211_M_IBSS || - ++ni->ni_key_count == 2) { + ++ni->ni_key_count == 2) +#endif + { DPRINTF(("marking port %s valid\n", ether_sprintf(ni->ni_macaddr))); ni->ni_port_valid = 1; @@ -923,6 +952,7 @@ ieee80211_recv_wpa_group_msg1(struct ieee80211com *ic, (void)ieee80211_send_group_msg2(ic, ni, k); } +#ifndef IEEE80211_STA_ONLY /* * Process Message 2 of the Group Key Handshake (sent by Supplicant). */ @@ -1022,3 +1052,4 @@ ieee80211_recv_eapol_key_req(struct ieee80211com *ic, */ } } +#endif /* IEEE80211_STA_ONLY */ diff --git a/sys/net80211/ieee80211_pae_output.c b/sys/net80211/ieee80211_pae_output.c index 20610e5a186..cf5f4af2614 100644 --- a/sys/net80211/ieee80211_pae_output.c +++ b/sys/net80211/ieee80211_pae_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_pae_output.c,v 1.12 2008/08/15 08:15:27 damien Exp $ */ +/* $OpenBSD: ieee80211_pae_output.c,v 1.13 2008/08/27 09:05:04 damien Exp $ */ /*- * Copyright (c) 2007,2008 Damien Bergamini @@ -51,11 +51,13 @@ int ieee80211_send_eapol_key(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, const struct ieee80211_ptk *); +#ifndef IEEE80211_STA_ONLY u_int8_t *ieee80211_add_gtk_kde(u_int8_t *, struct ieee80211_node *, const struct ieee80211_key *); u_int8_t *ieee80211_add_pmkid_kde(u_int8_t *, const u_int8_t *); u_int8_t *ieee80211_add_igtk_kde(u_int8_t *, const struct ieee80211_key *); +#endif struct mbuf *ieee80211_get_eapol_key(int, int, u_int); /* @@ -104,6 +106,7 @@ ieee80211_send_eapol_key(struct ieee80211com *ic, struct mbuf *m, BE_WRITE_2(key->paylen, len - sizeof(*key)); BE_WRITE_2(key->len, len - 4); +#ifndef IEEE80211_STA_ONLY if (info & EAPOL_KEY_ENCRYPTED) { if (ni->ni_rsnprotos == IEEE80211_PROTO_WPA) { /* clear "Encrypted" bit for WPA */ @@ -118,14 +121,17 @@ ieee80211_send_eapol_key(struct ieee80211com *ic, struct mbuf *m, sizeof(*eh) + 4 + BE_READ_2(key->len); } } +#endif if (info & EAPOL_KEY_KEYMIC) ieee80211_eapol_key_mic(key, ptk->kck); len = m->m_pkthdr.len; s = splnet(); +#ifndef IEEE80211_STA_ONLY /* start a 100ms timeout if an answer is expected from supplicant */ if (info & EAPOL_KEY_KEYACK) timeout_add(&ni->ni_rsn_timeout, hz / 10); +#endif IFQ_ENQUEUE(&ifp->if_snd, m, NULL, error); if (error == 0) { ifp->if_obytes += len; @@ -137,6 +143,7 @@ ieee80211_send_eapol_key(struct ieee80211com *ic, struct mbuf *m, return error; } +#ifndef IEEE80211_STA_ONLY /* * Handle EAPOL-Key timeouts (no answer from supplicant). */ @@ -228,6 +235,7 @@ ieee80211_add_igtk_kde(u_int8_t *frm, const struct ieee80211_key *k) memcpy(frm, k->k_key, 16); return frm + 16; } +#endif /* IEEE80211_STA_ONLY */ struct mbuf * ieee80211_get_eapol_key(int flags, int type, u_int pktlen) @@ -252,6 +260,7 @@ ieee80211_get_eapol_key(int flags, int type, u_int pktlen) return m; } +#ifndef IEEE80211_STA_ONLY /* * Send 4-Way Handshake Message 1 to the supplicant. */ @@ -307,6 +316,7 @@ ieee80211_send_4way_msg1(struct ieee80211com *ic, struct ieee80211_node *ni) return ieee80211_send_eapol_key(ic, m, ni, NULL); } +#endif /* IEEE80211_STA_ONLY */ /* * Send 4-Way Handshake Message 2 to the authenticator. @@ -359,6 +369,7 @@ ieee80211_send_4way_msg2(struct ieee80211com *ic, struct ieee80211_node *ni, return ieee80211_send_eapol_key(ic, m, ni, tptk); } +#ifndef IEEE80211_STA_ONLY /* * Send 4-Way Handshake Message 3 to the supplicant. */ @@ -433,6 +444,7 @@ ieee80211_send_4way_msg3(struct ieee80211com *ic, struct ieee80211_node *ni) return ieee80211_send_eapol_key(ic, m, ni, &ni->ni_ptk); } +#endif /* IEEE80211_STA_ONLY */ /* * Send 4-Way Handshake Message 4 to the authenticator. @@ -477,6 +489,7 @@ ieee80211_send_4way_msg4(struct ieee80211com *ic, struct ieee80211_node *ni) return ieee80211_send_eapol_key(ic, m, ni, &ni->ni_ptk); } +#ifndef IEEE80211_STA_ONLY /* * Send Group Key Handshake Message 1 to the supplicant. */ @@ -545,6 +558,7 @@ ieee80211_send_group_msg1(struct ieee80211com *ic, struct ieee80211_node *ni) return ieee80211_send_eapol_key(ic, m, ni, &ni->ni_ptk); } +#endif /* IEEE80211_STA_ONLY */ /* * Send Group Key Handshake Message 2 to the authenticator. diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 1fbd042ecb7..4b2991c623f 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.33 2008/08/14 15:51:43 damien Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.34 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -284,9 +284,11 @@ ieee80211_fix_rate(struct ieee80211com *ic, struct ieee80211_node *ni, * Note that this is important for 11b stations * when they want to associate with an 11g AP. */ +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP && (nrs->rs_rates[i] & IEEE80211_RATE_BASIC)) error++; +#endif ignore++; } } @@ -331,10 +333,14 @@ ieee80211_reset_erp(struct ieee80211com *ic) * the device supports short slot time */ ieee80211_set_shortslottime(ic, - ic->ic_curmode == IEEE80211_MODE_11A || + ic->ic_curmode == IEEE80211_MODE_11A +#ifndef IEEE80211_STA_ONLY + || (ic->ic_curmode == IEEE80211_MODE_11G && ic->ic_opmode == IEEE80211_M_HOSTAP && - (ic->ic_caps & IEEE80211_C_SHSLOT))); + (ic->ic_caps & IEEE80211_C_SHSLOT)) +#endif + ); if (ic->ic_curmode == IEEE80211_MODE_11A || (ic->ic_caps & IEEE80211_C_SHPREAMBLE)) @@ -359,6 +365,7 @@ ieee80211_set_shortslottime(struct ieee80211com *ic, int on) ic->ic_updateslot(ic); } +#ifndef IEEE80211_STA_ONLY /* * Initiate a group key handshake with a node. */ @@ -452,6 +459,7 @@ ieee80211_gtk_rekey_timeout(void *arg) /* re-schedule a GTK rekeying after 3600s */ timeout_add(&ic->ic_rsn_timeout, 3600 * hz); } +#endif /* IEEE80211_STA_ONLY */ void ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, @@ -460,6 +468,7 @@ ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, { struct ifnet *ifp = &ic->ic_if; switch (ic->ic_opmode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: if (ic->ic_state != IEEE80211_S_RUN || seq != IEEE80211_AUTH_OPEN_REQUEST) { @@ -507,6 +516,7 @@ ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, "newly" : "already"); ieee80211_node_newstate(ni, IEEE80211_STA_AUTH); break; +#endif /* IEEE80211_STA_ONLY */ case IEEE80211_M_STA: if (ic->ic_state != IEEE80211_S_AUTH || @@ -539,7 +549,7 @@ ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh, ieee80211_new_state(ic, IEEE80211_S_ASSOC, wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK); break; - case IEEE80211_M_MONITOR: + default: break; } } @@ -552,7 +562,9 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, struct ieee80211_node *ni; enum ieee80211_state ostate; u_int rate; +#ifndef IEEE80211_STA_ONLY int s; +#endif ostate = ic->ic_state; DPRINTF(("%s -> %s\n", ieee80211_state_name[ostate], @@ -573,6 +585,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, IEEE80211_FC0_SUBTYPE_DISASSOC, IEEE80211_REASON_ASSOC_LEAVE); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_HOSTAP: s = splnet(); RB_FOREACH(ni, ieee80211_tree, &ic->ic_tree) { @@ -584,6 +597,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, } splx(s); break; +#endif default: break; } @@ -595,6 +609,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, IEEE80211_FC0_SUBTYPE_DEAUTH, IEEE80211_REASON_AUTH_LEAVE); break; +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_HOSTAP: s = splnet(); RB_FOREACH(ni, ieee80211_tree, &ic->ic_tree) { @@ -604,14 +619,17 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, } splx(s); break; +#endif default: break; } /* FALLTHROUGH */ case IEEE80211_S_AUTH: case IEEE80211_S_SCAN: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP) timeout_del(&ic->ic_rsn_timeout); +#endif ic->ic_mgt_timer = 0; IF_PURGE(&ic->ic_mgtq); IF_PURGE(&ic->ic_pwrsaveq); @@ -630,6 +648,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, ni->ni_rstamp = 0; switch (ostate) { case IEEE80211_S_INIT: +#ifndef IEEE80211_STA_ONLY if (ic->ic_opmode == IEEE80211_M_HOSTAP && ic->ic_des_chan != IEEE80211_CHAN_ANYC) { /* @@ -637,9 +656,9 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, * bypass the scan and startup immediately. */ ieee80211_create_ibss(ic, ic->ic_des_chan); - } else { + } else +#endif ieee80211_begin_scan(ifp); - } break; case IEEE80211_S_SCAN: /* scan next */ @@ -772,10 +791,12 @@ ieee80211_set_link_state(struct ieee80211com *ic, int nstate) struct ifnet *ifp = &ic->ic_if; switch (ic->ic_opmode) { +#ifndef IEEE80211_STA_ONLY case IEEE80211_M_IBSS: case IEEE80211_M_HOSTAP: nstate = LINK_STATE_UNKNOWN; break; +#endif case IEEE80211_M_MONITOR: nstate = LINK_STATE_DOWN; break; diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 9cf5978c6e5..4dc7b897e1f 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.46 2008/08/12 19:59:09 damien Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.47 2008/08/27 09:05:04 damien Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -75,9 +75,11 @@ enum ieee80211_phymode { enum ieee80211_opmode { IEEE80211_M_STA = 1, /* infrastructure station */ +#ifndef IEEE80211_STA_ONLY IEEE80211_M_IBSS = 0, /* IBSS (adhoc) station */ IEEE80211_M_AHDEMO = 3, /* Old lucent compatible adhoc demo */ IEEE80211_M_HOSTAP = 6, /* Software Access Point */ +#endif IEEE80211_M_MONITOR = 8 /* Monitor mode */ }; -- 2.20.1