LIST_INSERT_HEAD(&ieee80211com_head, ic, ic_list);
ieee80211_ifattach(struct ifnet *ifp){	struct ieee80211com *ic = (void *)ifp;	struct ieee80211_channel *c;	int i;#if defined(__OpenBSD__)	memcpy(((struct arpcom *)ifp)->ac_enaddr, ic->ic_myaddr,		ETHER_ADDR_LEN);	ether_ifattach(ifp);#else	ether_ifattach(ifp, ic->ic_myaddr);#endif#if NBPFILTER > 0	BPF_ATTACH(ifp, DLT_IEEE802_11,	    sizeof(struct ieee80211_frame_addr4), &ic->ic_rawbpf);#endif	ieee80211_crypto_attach(ifp);	/*	 * Fill in 802.11 available channel set, mark	 * all available channels as active, and pick	 * a default channel if not already specified.	 */	memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));	ic->ic_modecaps |= 1<<IEEE80211_MODE_AUTO;	for (i = 0; i <= IEEE80211_CHAN_MAX; i++) {		c = &ic->ic_channels[i];		if (c->ic_flags) {			/*			 * Verify driver passed us valid data.			 */			if (i != ieee80211_chan2ieee(ic, c)) {				if_printf(ifp, "bad channel ignored; "					"freq %u flags %x number %u\n",					c->ic_freq, c->ic_flags, i);				c->ic_flags = 0;	/* NB: remove */				continue;			}			setbit(ic->ic_chan_avail, i);			/*			 * Identify mode capabilities.			 */			if (IEEE80211_IS_CHAN_A(c))				ic->ic_modecaps |= 1<<IEEE80211_MODE_11A;			if (IEEE80211_IS_CHAN_B(c))				ic->ic_modecaps |= 1<<IEEE80211_MODE_11B;			if (IEEE80211_IS_CHAN_PUREG(c))				ic->ic_modecaps |= 1<<IEEE80211_MODE_11G;			if (IEEE80211_IS_CHAN_FHSS(c))				ic->ic_modecaps |= 1<<IEEE80211_MODE_FH;			if (IEEE80211_IS_CHAN_T(c))				ic->ic_modecaps |= 1<<IEEE80211_MODE_TURBO;		}	}	/* validate ic->ic_curmode */	if ((ic->ic_modecaps & (1<<ic->ic_curmode)) == 0)		ic->ic_curmode = IEEE80211_MODE_AUTO;	ic->ic_des_chan = IEEE80211_CHAN_ANYC;	/* any channel is ok */	ieee80211_setbasicrates(ic);	(void) ieee80211_setmode(ic, ic->ic_curmode);	if (ic->ic_lintval == 0)		ic->ic_lintval = 100;		/* default sleep */	ic->ic_bmisstimeout = 7*ic->ic_lintval;	/* default 7 beacons */	ieee80211_node_attach(ifp);	ieee80211_proto_attach(ifp);}