Deleted Added
full compact
34c34
< __FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 148863 2005-08-08 18:46:36Z sam $");
---
> __FBSDID("$FreeBSD: head/sys/net80211/ieee80211_node.c 148936 2005-08-10 16:22:30Z sam $");
264,267d263
< /* NB: hack, setup so next_scan starts with the first channel */
< if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC)
< ieee80211_set_chan(ic, ic->ic_bss,
< &ic->ic_channels[IEEE80211_CHAN_MAX]);
273c269
< ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan));
---
> ieee80211_chan2ieee(ic, ic->ic_curchan));
327c323
< chan = ic->ic_bss->ni_chan;
---
> chan = ic->ic_curchan;
335c331
< ieee80211_chan2ieee(ic, ic->ic_bss->ni_chan),
---
> ieee80211_chan2ieee(ic, ic->ic_curchan),
337c333,339
< ieee80211_set_chan(ic, ic->ic_bss, chan);
---
> ic->ic_curchan = chan;
> /*
> * XXX drivers should do this as needed,
> * XXX for now maintain compatibility
> */
> ic->ic_bss->ni_rates =
> ic->ic_sup_rates[ieee80211_chan2mode(ic, chan)];
341c343
< } while (chan != ic->ic_bss->ni_chan);
---
> } while (chan != ic->ic_curchan);
410a413
> ic->ic_curchan = chan;
792a796
> ic->ic_curchan = selbs->ni_chan;
1087a1092,1262
> #ifdef IEEE80211_DEBUG
> static void
> dump_probe_beacon(u_int8_t subtype, int isnew,
> const u_int8_t mac[IEEE80211_ADDR_LEN],
> const struct ieee80211_scanparams *sp)
> {
>
> printf("[%s] %s%s on chan %u (bss chan %u) ",
> ether_sprintf(mac), isnew ? "new " : "",
> ieee80211_mgt_subtype_name[subtype >> IEEE80211_FC0_SUBTYPE_SHIFT],
> sp->chan, sp->bchan);
> ieee80211_print_essid(sp->ssid + 2, sp->ssid[1]);
> printf("\n");
>
> if (isnew) {
> printf("[%s] caps 0x%x bintval %u erp 0x%x",
> ether_sprintf(mac), sp->capinfo, sp->bintval, sp->erp);
> if (sp->country != NULL) {
> #ifdef __FreeBSD__
> printf(" country info %*D",
> sp->country[1], sp->country+2, " ");
> #else
> int i;
> printf(" country info");
> for (i = 0; i < sp->country[1]; i++)
> printf(" %02x", sp->country[i+2]);
> #endif
> }
> printf("\n");
> }
> }
> #endif /* IEEE80211_DEBUG */
>
> static void
> saveie(u_int8_t **iep, const u_int8_t *ie)
> {
>
> if (ie == NULL)
> *iep = NULL;
> else
> ieee80211_saveie(iep, ie);
> }
>
> /*
> * Process a beacon or probe response frame.
> */
> void
> ieee80211_add_scan(struct ieee80211com *ic,
> const struct ieee80211_scanparams *sp,
> const struct ieee80211_frame *wh,
> int subtype, int rssi, int rstamp)
> {
> #define ISPROBE(_st) ((_st) == IEEE80211_FC0_SUBTYPE_PROBE_RESP)
> struct ieee80211_node_table *nt = &ic->ic_scan;
> struct ieee80211_node *ni;
> int newnode = 0;
>
> ni = ieee80211_find_node(nt, wh->i_addr2);
> if (ni == NULL) {
> /*
> * Create a new entry.
> */
> ni = ic->ic_node_alloc(nt);
> if (ni == NULL) {
> ic->ic_stats.is_rx_nodealloc++;
> return;
> }
> ieee80211_setup_node(nt, ni, wh->i_addr2);
> /*
> * XXX inherit from ic_bss.
> */
> ni->ni_authmode = ic->ic_bss->ni_authmode;
> ni->ni_txpower = ic->ic_bss->ni_txpower;
> ni->ni_vlan = ic->ic_bss->ni_vlan; /* XXX?? */
> ieee80211_set_chan(ic, ni, ic->ic_curchan);
> ni->ni_rsn = ic->ic_bss->ni_rsn;
> newnode = 1;
> }
> #ifdef IEEE80211_DEBUG
> if (ieee80211_msg_scan(ic) && (ic->ic_flags & IEEE80211_F_SCAN))
> dump_probe_beacon(subtype, newnode, wh->i_addr2, sp);
> #endif
> /* XXX ap beaconing multiple ssid w/ same bssid */
> if (sp->ssid[1] != 0 &&
> (ISPROBE(subtype) || ni->ni_esslen == 0)) {
> ni->ni_esslen = sp->ssid[1];
> memset(ni->ni_essid, 0, sizeof(ni->ni_essid));
> memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]);
> }
> ni->ni_scangen = ic->ic_scan.nt_scangen;
> IEEE80211_ADDR_COPY(ni->ni_bssid, wh->i_addr3);
> ni->ni_rssi = rssi;
> ni->ni_rstamp = rstamp;
> memcpy(ni->ni_tstamp.data, sp->tstamp, sizeof(ni->ni_tstamp));
> ni->ni_intval = sp->bintval;
> ni->ni_capinfo = sp->capinfo;
> ni->ni_chan = &ic->ic_channels[sp->chan];
> ni->ni_fhdwell = sp->fhdwell;
> ni->ni_fhindex = sp->fhindex;
> ni->ni_erp = sp->erp;
> if (sp->tim != NULL) {
> struct ieee80211_tim_ie *ie =
> (struct ieee80211_tim_ie *) sp->tim;
>
> ni->ni_dtim_count = ie->tim_count;
> ni->ni_dtim_period = ie->tim_period;
> }
> /*
> * Record the byte offset from the mac header to
> * the start of the TIM information element for
> * use by hardware and/or to speedup software
> * processing of beacon frames.
> */
> ni->ni_timoff = sp->timoff;
> /*
> * Record optional information elements that might be
> * used by applications or drivers.
> */
> saveie(&ni->ni_wme_ie, sp->wme);
> saveie(&ni->ni_wpa_ie, sp->wpa);
>
> /* NB: must be after ni_chan is setup */
> ieee80211_setup_rates(ni, sp->rates, sp->xrates, IEEE80211_F_DOSORT);
>
> if (!newnode)
> ieee80211_free_node(ni);
> #undef ISPROBE
> }
>
> /*
> * Do node discovery in adhoc mode on receipt of a beacon
> * or probe response frame. Note that for the driver's
> * benefit we we treat this like an association so the
> * driver has an opportunity to setup it's private state.
> */
> struct ieee80211_node *
> ieee80211_add_neighbor(struct ieee80211com *ic,
> const struct ieee80211_frame *wh,
> const struct ieee80211_scanparams *sp)
> {
> struct ieee80211_node *ni;
>
> ni = ieee80211_dup_bss(&ic->ic_sta, wh->i_addr2);/* XXX alloc_node? */
> if (ni != NULL) {
> ni->ni_esslen = sp->ssid[1];
> memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]);
> IEEE80211_ADDR_COPY(ni->ni_bssid, wh->i_addr3);
> memcpy(ni->ni_tstamp.data, sp->tstamp, sizeof(ni->ni_tstamp));
> ni->ni_intval = sp->bintval;
> ni->ni_capinfo = sp->capinfo;
> ni->ni_chan = ic->ic_bss->ni_chan;
> ni->ni_fhdwell = sp->fhdwell;
> ni->ni_fhindex = sp->fhindex;
> ni->ni_erp = sp->erp;
> ni->ni_timoff = sp->timoff;
> if (sp->wme != NULL)
> ieee80211_saveie(&ni->ni_wme_ie, sp->wme);
> if (sp->wpa != NULL)
> ieee80211_saveie(&ni->ni_wpa_ie, sp->wpa);
>
> /* NB: must be after ni_chan is setup */
> ieee80211_setup_rates(ni, sp->rates, sp->xrates, IEEE80211_F_DOSORT);
>
> if (ic->ic_newassoc != NULL)
> ic->ic_newassoc(ni, 1);
> /* XXX not right for 802.1x/WPA */
> ieee80211_node_authorize(ni);
> }
> return ni;
> }
>