Home | History | Annotate | Line # | Download | only in net80211
ieee80211_proto.c revision 1.12
      1 /*	$NetBSD: ieee80211_proto.c,v 1.12 2004/07/23 08:05:00 mycroft Exp $	*/
      2 /*-
      3  * Copyright (c) 2001 Atsushi Onoe
      4  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * Alternatively, this software may be distributed under the terms of the
     19  * GNU General Public License ("GPL") version 2 as published by the Free
     20  * Software Foundation.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #include <sys/cdefs.h>
     35 #ifdef __FreeBSD__
     36 __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_proto.c,v 1.8 2004/04/02 20:22:25 sam Exp $");
     37 #else
     38 __KERNEL_RCSID(0, "$NetBSD: ieee80211_proto.c,v 1.12 2004/07/23 08:05:00 mycroft Exp $");
     39 #endif
     40 
     41 /*
     42  * IEEE 802.11 protocol support.
     43  */
     44 
     45 #include "opt_inet.h"
     46 
     47 #include <sys/param.h>
     48 #include <sys/systm.h>
     49 #include <sys/mbuf.h>
     50 #include <sys/malloc.h>
     51 #include <sys/kernel.h>
     52 #include <sys/socket.h>
     53 #include <sys/sockio.h>
     54 #include <sys/endian.h>
     55 #include <sys/errno.h>
     56 #ifdef __FreeBSD__
     57 #include <sys/bus.h>
     58 #endif
     59 #include <sys/proc.h>
     60 #include <sys/sysctl.h>
     61 
     62 #ifdef __FreeBSD__
     63 #include <machine/atomic.h>
     64 #endif
     65 
     66 #include <net/if.h>
     67 #include <net/if_dl.h>
     68 #include <net/if_media.h>
     69 #include <net/if_arp.h>
     70 #ifdef __FreeBSD__
     71 #include <net/ethernet.h>
     72 #else
     73 #include <net/if_ether.h>
     74 #endif
     75 #include <net/if_llc.h>
     76 
     77 #include <net80211/ieee80211_var.h>
     78 #include <net80211/ieee80211_compat.h>
     79 
     80 #include <net/bpf.h>
     81 
     82 #ifdef INET
     83 #include <netinet/in.h>
     84 #ifdef __FreeBSD__
     85 #include <netinet/if_ether.h>
     86 #else
     87 #include <net/if_ether.h>
     88 #endif
     89 #endif
     90 
     91 #include <net/route.h>
     92 
     93 #define	IEEE80211_RATE2MBS(r)	(((r) & IEEE80211_RATE_VAL) / 2)
     94 
     95 const char *ieee80211_mgt_subtype_name[] = {
     96 	"assoc_req",	"assoc_resp",	"reassoc_req",	"reassoc_resp",
     97 	"probe_req",	"probe_resp",	"reserved#6",	"reserved#7",
     98 	"beacon",	"atim",		"disassoc",	"auth",
     99 	"deauth",	"reserved#13",	"reserved#14",	"reserved#15"
    100 };
    101 const char *ieee80211_state_name[IEEE80211_S_MAX] = {
    102 	"INIT",		/* IEEE80211_S_INIT */
    103 	"SCAN",		/* IEEE80211_S_SCAN */
    104 	"AUTH",		/* IEEE80211_S_AUTH */
    105 	"ASSOC",	/* IEEE80211_S_ASSOC */
    106 	"RUN"		/* IEEE80211_S_RUN */
    107 };
    108 
    109 static int ieee80211_newstate(struct ieee80211com *, enum ieee80211_state, int);
    110 
    111 void
    112 ieee80211_proto_attach(struct ifnet *ifp)
    113 {
    114 	struct ieee80211com *ic = (void *)ifp;
    115 
    116 	ifp->if_hdrlen = sizeof(struct ieee80211_frame);
    117 
    118 #ifdef notdef
    119 	ic->ic_rtsthreshold = IEEE80211_RTS_DEFAULT;
    120 #else
    121 	ic->ic_rtsthreshold = IEEE80211_RTS_MAX;
    122 #endif
    123 	ic->ic_fragthreshold = 2346;		/* XXX not used yet */
    124 	ic->ic_fixed_rate = -1;			/* no fixed rate */
    125 	ic->ic_protmode = IEEE80211_PROT_CTSONLY;
    126 
    127 #ifdef __FreeBSD__
    128 	mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF);
    129 #endif
    130 
    131 	/* protocol state change handler */
    132 	ic->ic_newstate = ieee80211_newstate;
    133 
    134 	/* initialize management frame handlers */
    135 	ic->ic_recv_mgmt = ieee80211_recv_mgmt;
    136 	ic->ic_send_mgmt = ieee80211_send_mgmt;
    137 }
    138 
    139 void
    140 ieee80211_proto_detach(struct ifnet *ifp)
    141 {
    142 	struct ieee80211com *ic = (void *)ifp;
    143 
    144 #ifdef __FreeBSD__
    145 	IF_DRAIN(&ic->ic_mgtq);
    146 	mtx_destroy(&ic->ic_mgtq.ifq_mtx);
    147 #else
    148 	IF_PURGE(&ic->ic_mgtq);
    149 	IF_PURGE(&ic->ic_pwrsaveq);
    150 #endif
    151 }
    152 
    153 void
    154 ieee80211_print_essid(u_int8_t *essid, int len)
    155 {
    156 	int i;
    157 	u_int8_t *p;
    158 
    159 	if (len > IEEE80211_NWID_LEN)
    160 		len = IEEE80211_NWID_LEN;
    161 	/* determine printable or not */
    162 	for (i = 0, p = essid; i < len; i++, p++) {
    163 		if (*p < ' ' || *p > 0x7e)
    164 			break;
    165 	}
    166 	if (i == len) {
    167 		printf("\"");
    168 		for (i = 0, p = essid; i < len; i++, p++)
    169 			printf("%c", *p);
    170 		printf("\"");
    171 	} else {
    172 		printf("0x");
    173 		for (i = 0, p = essid; i < len; i++, p++)
    174 			printf("%02x", *p);
    175 	}
    176 }
    177 
    178 void
    179 ieee80211_dump_pkt(u_int8_t *buf, int len, int rate, int rssi)
    180 {
    181 	struct ieee80211_frame *wh;
    182 	int i;
    183 
    184 	wh = (struct ieee80211_frame *)buf;
    185 	switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) {
    186 	case IEEE80211_FC1_DIR_NODS:
    187 		printf("NODS %s", ether_sprintf(wh->i_addr2));
    188 		printf("->%s", ether_sprintf(wh->i_addr1));
    189 		printf("(%s)", ether_sprintf(wh->i_addr3));
    190 		break;
    191 	case IEEE80211_FC1_DIR_TODS:
    192 		printf("TODS %s", ether_sprintf(wh->i_addr2));
    193 		printf("->%s", ether_sprintf(wh->i_addr3));
    194 		printf("(%s)", ether_sprintf(wh->i_addr1));
    195 		break;
    196 	case IEEE80211_FC1_DIR_FROMDS:
    197 		printf("FRDS %s", ether_sprintf(wh->i_addr3));
    198 		printf("->%s", ether_sprintf(wh->i_addr1));
    199 		printf("(%s)", ether_sprintf(wh->i_addr2));
    200 		break;
    201 	case IEEE80211_FC1_DIR_DSTODS:
    202 		printf("DSDS %s", ether_sprintf((u_int8_t *)&wh[1]));
    203 		printf("->%s", ether_sprintf(wh->i_addr3));
    204 		printf("(%s", ether_sprintf(wh->i_addr2));
    205 		printf("->%s)", ether_sprintf(wh->i_addr1));
    206 		break;
    207 	}
    208 	switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) {
    209 	case IEEE80211_FC0_TYPE_DATA:
    210 		printf(" data");
    211 		break;
    212 	case IEEE80211_FC0_TYPE_MGT:
    213 		printf(" %s", ieee80211_mgt_subtype_name[
    214 		    (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK)
    215 		    >> IEEE80211_FC0_SUBTYPE_SHIFT]);
    216 		break;
    217 	default:
    218 		printf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK);
    219 		break;
    220 	}
    221 	if (wh->i_fc[1] & IEEE80211_FC1_WEP)
    222 		printf(" WEP");
    223 	if (rate >= 0)
    224 		printf(" %dM", rate / 2);
    225 	if (rssi >= 0)
    226 		printf(" +%d", rssi);
    227 	printf("\n");
    228 	if (len > 0) {
    229 		for (i = 0; i < len; i++) {
    230 			if ((i & 1) == 0)
    231 				printf(" ");
    232 			printf("%02x", buf[i]);
    233 		}
    234 		printf("\n");
    235 	}
    236 }
    237 
    238 int
    239 ieee80211_fix_rate(struct ieee80211com *ic, struct ieee80211_node *ni, int flags)
    240 {
    241 #define	RV(v)	((v) & IEEE80211_RATE_VAL)
    242 	int i, j, ignore, error;
    243 	int okrate, badrate;
    244 	struct ieee80211_rateset *srs, *nrs;
    245 	u_int8_t r;
    246 
    247 	error = 0;
    248 	okrate = badrate = 0;
    249 	srs = &ic->ic_sup_rates[ieee80211_chan2mode(ic, ni->ni_chan)];
    250 	nrs = &ni->ni_rates;
    251 	for (i = 0; i < nrs->rs_nrates; ) {
    252 		ignore = 0;
    253 		if (flags & IEEE80211_F_DOSORT) {
    254 			/*
    255 			 * Sort rates.
    256 			 */
    257 			for (j = i + 1; j < nrs->rs_nrates; j++) {
    258 				if (RV(nrs->rs_rates[i]) > RV(nrs->rs_rates[j])) {
    259 					r = nrs->rs_rates[i];
    260 					nrs->rs_rates[i] = nrs->rs_rates[j];
    261 					nrs->rs_rates[j] = r;
    262 				}
    263 			}
    264 		}
    265 		r = nrs->rs_rates[i] & IEEE80211_RATE_VAL;
    266 		badrate = r;
    267 		if (flags & IEEE80211_F_DOFRATE) {
    268 			/*
    269 			 * Apply fixed rate constraint.  Note that we do
    270 			 * not apply the constraint to basic rates as
    271 			 * otherwise we may not be able to associate if
    272 			 * the rate set we submit to the AP is invalid
    273 			 * (e.g. fix rate at 36Mb/s which is not a basic
    274 			 * rate for 11a operation).
    275 			 */
    276 			if ((nrs->rs_rates[i] & IEEE80211_RATE_BASIC) == 0 &&
    277 			    ic->ic_fixed_rate >= 0 &&
    278 			    r != RV(srs->rs_rates[ic->ic_fixed_rate]))
    279 				ignore++;
    280 		}
    281 		if (flags & IEEE80211_F_DONEGO) {
    282 			/*
    283 			 * Check against supported rates.
    284 			 */
    285 			for (j = 0; j < srs->rs_nrates; j++) {
    286 				if (r == RV(srs->rs_rates[j])) {
    287 					/*
    288 					 * Overwrite with the supported rate
    289 					 * value so any basic rate bit is set.
    290 					 * This insures that response we send
    291 					 * to stations have the necessary basic
    292 					 * rate bit set.
    293 					 */
    294 					nrs->rs_rates[i] = srs->rs_rates[j];
    295 					break;
    296 				}
    297 			}
    298 			if (j == srs->rs_nrates) {
    299 				/*
    300 				 * A rate in the node's rate set is not
    301 				 * supported.  If this is a basic rate and we
    302 				 * are operating as an AP then this is an error.
    303 				 * Otherwise we just discard/ignore the rate.
    304 				 * Note that this is important for 11b stations
    305 				 * when they want to associate with an 11g AP.
    306 				 */
    307 				if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
    308 				    (nrs->rs_rates[i] & IEEE80211_RATE_BASIC))
    309 					error++;
    310 				ignore++;
    311 			}
    312 		}
    313 		if (flags & IEEE80211_F_DODEL) {
    314 			/*
    315 			 * Delete unacceptable rates.
    316 			 */
    317 			if (ignore) {
    318 				nrs->rs_nrates--;
    319 				for (j = i; j < nrs->rs_nrates; j++)
    320 					nrs->rs_rates[j] = nrs->rs_rates[j + 1];
    321 				nrs->rs_rates[j] = 0;
    322 				continue;
    323 			}
    324 		}
    325 		if (!ignore) {
    326 			okrate = nrs->rs_rates[i];
    327 			ni->ni_txrate = i;
    328 		}
    329 		i++;
    330 	}
    331 	if (okrate == 0 || error != 0)
    332 		return badrate | IEEE80211_RATE_BASIC;
    333 	else
    334 		return RV(okrate);
    335 #undef RV
    336 }
    337 
    338 static int
    339 ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int mgt)
    340 {
    341 	struct ifnet *ifp = &ic->ic_if;
    342 	struct ieee80211_node *ni;
    343 	enum ieee80211_state ostate;
    344 	ieee80211_node_critsec_decl(s);
    345 	int linkstate = LINK_STATE_DOWN;
    346 
    347 	ostate = ic->ic_state;
    348 	IEEE80211_DPRINTF(ic, IEEE80211_MSG_STATE, ("%s: %s -> %s\n", __func__,
    349 		ieee80211_state_name[ostate], ieee80211_state_name[nstate]));
    350 	ic->ic_state = nstate;			/* state transition */
    351 	ni = ic->ic_bss;			/* NB: no reference held */
    352 	switch (nstate) {
    353 	case IEEE80211_S_INIT:
    354 		switch (ostate) {
    355 		case IEEE80211_S_INIT:
    356 			break;
    357 		case IEEE80211_S_RUN:
    358 			switch (ic->ic_opmode) {
    359 			case IEEE80211_M_STA:
    360 				IEEE80211_SEND_MGMT(ic, ni,
    361 				    IEEE80211_FC0_SUBTYPE_DISASSOC,
    362 				    IEEE80211_REASON_ASSOC_LEAVE);
    363 				break;
    364 			case IEEE80211_M_HOSTAP:
    365 				ieee80211_node_critsec_begin(ic, s);
    366 				TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
    367 					if (ni->ni_associd == 0)
    368 						continue;
    369 					IEEE80211_SEND_MGMT(ic, ni,
    370 					    IEEE80211_FC0_SUBTYPE_DISASSOC,
    371 					    IEEE80211_REASON_ASSOC_LEAVE);
    372 				}
    373 				ieee80211_node_critsec_end(ic, s);
    374 				break;
    375 			default:
    376 				break;
    377 			}
    378 			/* FALLTHRU */
    379 		case IEEE80211_S_ASSOC:
    380 			switch (ic->ic_opmode) {
    381 			case IEEE80211_M_STA:
    382 				IEEE80211_SEND_MGMT(ic, ni,
    383 				    IEEE80211_FC0_SUBTYPE_DEAUTH,
    384 				    IEEE80211_REASON_AUTH_LEAVE);
    385 				break;
    386 			case IEEE80211_M_HOSTAP:
    387 				ieee80211_node_critsec_begin(ic, s);
    388 				TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
    389 					IEEE80211_SEND_MGMT(ic, ni,
    390 					    IEEE80211_FC0_SUBTYPE_DEAUTH,
    391 					    IEEE80211_REASON_AUTH_LEAVE);
    392 				}
    393 				ieee80211_node_critsec_end(ic, s);
    394 				break;
    395 			default:
    396 				break;
    397 			}
    398 			/* FALLTHRU */
    399 		case IEEE80211_S_AUTH:
    400 		case IEEE80211_S_SCAN:
    401 			ic->ic_mgt_timer = 0;
    402 #ifdef __FreeBSD__
    403 			IF_DRAIN(&ic->ic_mgtq);
    404 #else
    405 			IF_PURGE(&ic->ic_mgtq);
    406 			IF_PURGE(&ic->ic_pwrsaveq);
    407 #endif
    408 			if (ic->ic_wep_ctx != NULL) {
    409 				free(ic->ic_wep_ctx, M_DEVBUF);
    410 				ic->ic_wep_ctx = NULL;
    411 			}
    412 			ieee80211_free_allnodes(ic);
    413 			break;
    414 		}
    415 		break;
    416 	case IEEE80211_S_SCAN:
    417 		ic->ic_flags &= ~IEEE80211_F_SIBSS;
    418 		/* initialize bss for probe request */
    419 		IEEE80211_ADDR_COPY(ni->ni_macaddr, ifp->if_broadcastaddr);
    420 		IEEE80211_ADDR_COPY(ni->ni_bssid, ifp->if_broadcastaddr);
    421 		ni->ni_rates = ic->ic_sup_rates[
    422 			ieee80211_chan2mode(ic, ni->ni_chan)];
    423 		ni->ni_associd = 0;
    424 		ni->ni_rstamp = 0;
    425 		switch (ostate) {
    426 		case IEEE80211_S_INIT:
    427 			if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
    428 			    ic->ic_des_chan != IEEE80211_CHAN_ANYC) {
    429 				/*
    430 				 * AP operation and we already have a channel;
    431 				 * bypass the scan and startup immediately.
    432 				 */
    433 				ieee80211_create_ibss(ic, ic->ic_des_chan);
    434 			} else {
    435 				ieee80211_begin_scan(ifp);
    436 			}
    437 			break;
    438 		case IEEE80211_S_SCAN:
    439 			/* scan next */
    440 			if (ic->ic_flags & IEEE80211_F_ASCAN) {
    441 				IEEE80211_SEND_MGMT(ic, ni,
    442 				    IEEE80211_FC0_SUBTYPE_PROBE_REQ, 0);
    443 			}
    444 			break;
    445 		case IEEE80211_S_RUN:
    446 			/* beacon miss */
    447 			if (ifp->if_flags & IFF_DEBUG) {
    448 				/* XXX bssid clobbered above */
    449 				if_printf(ifp, "no recent beacons from %s;"
    450 				    " rescanning\n",
    451 				    ether_sprintf(ic->ic_bss->ni_bssid));
    452 			}
    453 			ieee80211_free_allnodes(ic);
    454 			/* FALLTHRU */
    455 		case IEEE80211_S_AUTH:
    456 		case IEEE80211_S_ASSOC:
    457 			/* timeout restart scan */
    458 			ni = ieee80211_find_node(ic, ic->ic_bss->ni_macaddr);
    459 			if (ni != NULL) {
    460 				ni->ni_fails++;
    461 				ieee80211_unref_node(&ni);
    462 			}
    463 			ieee80211_begin_scan(ifp);
    464 			break;
    465 		}
    466 		break;
    467 	case IEEE80211_S_AUTH:
    468 		switch (ostate) {
    469 		case IEEE80211_S_INIT:
    470 			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
    471 				("%s: invalid transition\n", __func__));
    472 			break;
    473 		case IEEE80211_S_SCAN:
    474 			IEEE80211_SEND_MGMT(ic, ni,
    475 			    IEEE80211_FC0_SUBTYPE_AUTH, 1);
    476 			break;
    477 		case IEEE80211_S_AUTH:
    478 		case IEEE80211_S_ASSOC:
    479 			switch (mgt) {
    480 			case IEEE80211_FC0_SUBTYPE_AUTH:
    481 				/* ??? */
    482 				IEEE80211_SEND_MGMT(ic, ni,
    483 				    IEEE80211_FC0_SUBTYPE_AUTH, 2);
    484 				break;
    485 			case IEEE80211_FC0_SUBTYPE_DEAUTH:
    486 				/* ignore and retry scan on timeout */
    487 				break;
    488 			}
    489 			break;
    490 		case IEEE80211_S_RUN:
    491 			switch (mgt) {
    492 			case IEEE80211_FC0_SUBTYPE_AUTH:
    493 				IEEE80211_SEND_MGMT(ic, ni,
    494 				    IEEE80211_FC0_SUBTYPE_AUTH, 2);
    495 				ic->ic_state = ostate;	/* stay RUN */
    496 				break;
    497 			case IEEE80211_FC0_SUBTYPE_DEAUTH:
    498 				/* try to reauth */
    499 				IEEE80211_SEND_MGMT(ic, ni,
    500 				    IEEE80211_FC0_SUBTYPE_AUTH, 1);
    501 				break;
    502 			}
    503 			break;
    504 		}
    505 		break;
    506 	case IEEE80211_S_ASSOC:
    507 		switch (ostate) {
    508 		case IEEE80211_S_INIT:
    509 		case IEEE80211_S_SCAN:
    510 		case IEEE80211_S_ASSOC:
    511 			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
    512 				("%s: invalid transition\n", __func__));
    513 			break;
    514 		case IEEE80211_S_AUTH:
    515 			IEEE80211_SEND_MGMT(ic, ni,
    516 			    IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 0);
    517 			break;
    518 		case IEEE80211_S_RUN:
    519 			IEEE80211_SEND_MGMT(ic, ni,
    520 			    IEEE80211_FC0_SUBTYPE_ASSOC_REQ, 1);
    521 			break;
    522 		}
    523 		break;
    524 	case IEEE80211_S_RUN:
    525 		linkstate = LINK_STATE_UP;
    526 		switch (ostate) {
    527 		case IEEE80211_S_INIT:
    528 		case IEEE80211_S_AUTH:
    529 		case IEEE80211_S_RUN:
    530 			IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
    531 				("%s: invalid transition\n", __func__));
    532 			break;
    533 		case IEEE80211_S_SCAN:		/* adhoc/hostap mode */
    534 		case IEEE80211_S_ASSOC:		/* infra mode */
    535 			IASSERT(ni->ni_txrate < ni->ni_rates.rs_nrates,
    536 				("%s: bogus xmit rate %u setup", __func__,
    537 					ni->ni_txrate));
    538 			if (ifp->if_flags & IFF_DEBUG) {
    539 				if_printf(ifp, " ");
    540 				if (ic->ic_opmode == IEEE80211_M_STA)
    541 					printf("associated ");
    542 				else
    543 					printf("synchronized ");
    544 				printf("with %s ssid ",
    545 				    ether_sprintf(ni->ni_bssid));
    546 				ieee80211_print_essid(ic->ic_bss->ni_essid,
    547 				    ni->ni_esslen);
    548 				printf(" channel %d start %uMb\n",
    549 					ieee80211_chan2ieee(ic, ni->ni_chan),
    550 					IEEE80211_RATE2MBS(ni->ni_rates.rs_rates[ni->ni_txrate]));
    551 			}
    552 			ic->ic_mgt_timer = 0;
    553 			(*ifp->if_start)(ifp);
    554 			break;
    555 		}
    556 		break;
    557 	}
    558 	if (ifp->if_link_state != linkstate) {
    559 		ifp->if_link_state = linkstate;
    560 		s = splnet();
    561 		rt_ifmsg(ifp);
    562 		splx(s);
    563 	}
    564 	return 0;
    565 }
    566