FreeBSD/sys/dev/otus/if_otus.c
/*
 * Set up operating mode, MAC/BSS address and RX filter.
 */
Set up operating mode, MAC/BSS address and RX filter.
Set up operating mode MAC / BSS address and RX filter .
static void
otus_set_operating_mode(struct otus_softc *sc)
{
	struct ieee80211com *ic = &sc->sc_ic;
	struct ieee80211vap *vap;
	uint32_t cam_mode = AR_MAC_CAM_DEFAULTS;
	uint32_t rx_ctrl = AR_MAC_RX_CTRL_DEAGG | AR_MAC_RX_CTRL_SHORT_FILTER;
	uint32_t sniffer = AR_MAC_SNIFFER_DEFAULTS;
	uint32_t enc_mode = 0x78; 
	const uint8_t *macaddr;
	uint8_t bssid[IEEE80211_ADDR_LEN];
	struct ieee80211_node *ni;
	OTUS_LOCK_ASSERT(sc);
	IEEE80211_ADDR_COPY(bssid, zero_macaddr);
	vap = TAILQ_FIRST(&ic->ic_vaps);
	macaddr = ic->ic_macaddr;
	switch (ic->ic_opmode) {
	case IEEE80211_M_STA:
		if (vap) {
			ni = ieee80211_ref_node(vap->iv_bss);
			IEEE80211_ADDR_COPY(bssid, ni->ni_bssid);
			ieee80211_free_node(ni);
		}
		cam_mode |= AR_MAC_CAM_STA;
		rx_ctrl |= AR_MAC_RX_CTRL_PASS_TO_HOST;
		break;
	case IEEE80211_M_MONITOR:
	default:
		cam_mode |= AR_MAC_CAM_STA;
		rx_ctrl |= AR_MAC_RX_CTRL_PASS_TO_HOST;
		break;
	}
	otus_write(sc, AR_MAC_REG_SNIFFER, sniffer);
	otus_write(sc, AR_MAC_REG_CAM_MODE, cam_mode);
	otus_write(sc, AR_MAC_REG_ENCRYPTION, enc_mode);
	otus_write(sc, AR_MAC_REG_RX_CONTROL, rx_ctrl);
	otus_set_macaddr(sc, macaddr);
	otus_set_bssid(sc, bssid);
}
static void otus_set_operating_mode ( struct otus_softc * sc ) { struct ieee80211com * ic = & sc -> sc_ic ; struct ieee80211vap * vap ; uint32_t cam_mode = AR_MAC_CAM_DEFAULTS ; uint32_t rx_ctrl = AR_MAC_RX_CTRL_DEAGG | AR_MAC_RX_CTRL_SHORT_FILTER ; uint32_t sniffer = AR_MAC_SNIFFER_DEFAULTS ; uint32_t enc_mode = 0x78 ; const uint8_t * macaddr ; uint8_t bssid [ IEEE80211_ADDR_LEN ] ; struct ieee80211_node * ni ; OTUS_LOCK_ASSERT ( sc ) ; IEEE80211_ADDR_COPY ( bssid , zero_macaddr ) ; vap = TAILQ_FIRST ( & ic -> ic_vaps ) ; macaddr = ic -> ic_macaddr ; switch ( ic -> ic_opmode ) { case IEEE80211_M_STA : if ( vap ) { ni = ieee80211_ref_node ( vap -> iv_bss ) ; IEEE80211_ADDR_COPY ( bssid , ni -> ni_bssid ) ; ieee80211_free_node ( ni ) ; } cam_mode |= AR_MAC_CAM_STA ; rx_ctrl |= AR_MAC_RX_CTRL_PASS_TO_HOST ; break ; case IEEE80211_M_MONITOR : default : cam_mode |= AR_MAC_CAM_STA ; rx_ctrl |= AR_MAC_RX_CTRL_PASS_TO_HOST ; break ; } otus_write ( sc , AR_MAC_REG_SNIFFER , sniffer ) ; otus_write ( sc , AR_MAC_REG_CAM_MODE , cam_mode ) ; otus_write ( sc , AR_MAC_REG_ENCRYPTION , enc_mode ) ; otus_write ( sc , AR_MAC_REG_RX_CONTROL , rx_ctrl ) ; otus_set_macaddr ( sc , macaddr ) ; otus_set_bssid ( sc , bssid ) ; }
Set up operating mode, MAC/BSS address and RX filter.
Set up operating mode MAC / BSS address and RX filter .
/* XXX */ /*
	 * If we're in sniffer mode or we don't have a MAC
	 * address assigned, ensure it gets reset to all-zero.
	 */ /*
		 * Note: monitor mode ends up causing the MAC to
		 * generate ACK frames for everything it sees.
		 * So don't do that; instead just put it in STA mode
		 * and disable RX filters.
		 */ /*
	 * TODO: if/when we do hardware encryption, ensure it's
	 * disabled if the NIC is in monitor mode.
	 */ /* XXX barrier? */