if (ltv->wi_val & htole16(0x01))
if (ltv->wi_val & htole16(0x01)) { val = PRIVACY_INVOKED;  if (sc->wi_authmode != IEEE80211_AUTH_OPEN || sc->sc_firmware_type == WI_SYMBOL) val |= EXCLUDE_UNENCRYPTED;
wi_write_record(sc, ltv)	struct wi_softc		*sc;	struct wi_ltv_gen	*ltv;{	u_int8_t		*ptr;	int			i;	struct wi_ltv_gen	p2ltv;	if (ltv->wi_type == WI_RID_PORTTYPE &&	    letoh16(ltv->wi_val) == WI_PORTTYPE_IBSS) {		/* Convert WI_PORTTYPE_IBSS to vendor IBSS port type. */		p2ltv.wi_type = WI_RID_PORTTYPE;		p2ltv.wi_len = 2;		p2ltv.wi_val = sc->wi_ibss_port;		ltv = &p2ltv;	} else if (sc->sc_firmware_type != WI_LUCENT) {		int v;		switch (ltv->wi_type) {		case WI_RID_TX_RATE:			p2ltv.wi_type = WI_RID_TX_RATE;			p2ltv.wi_len = 2;			switch (letoh16(ltv->wi_val)) {			case 1: v = 1; break;			case 2: v = 2; break;			case 3:	v = 15; break;			case 5: v = 4; break;			case 6: v = 3; break;			case 7: v = 7; break;			case 11: v = 8; break;			default: return EINVAL;			}			p2ltv.wi_val = htole16(v);			ltv = &p2ltv;			break;		case WI_RID_ENCRYPTION:			p2ltv.wi_type = WI_RID_P2_ENCRYPTION;			p2ltv.wi_len = 2;			if (ltv->wi_val & htole16(0x01))				if (sc->wi_ptype == WI_PORTTYPE_AP)					/* Disable tx encryption...					 * it's broken.					 */					p2ltv.wi_val = htole16(HOST_ENCRYPT |					    PRIVACY_INVOKED |					    EXCLUDE_UNENCRYPTED);				else					p2ltv.wi_val = htole16(PRIVACY_INVOKED |					    EXCLUDE_UNENCRYPTED);			else				p2ltv.wi_val = htole16(HOST_ENCRYPT | HOST_DECRYPT);			ltv = &p2ltv;			break;		case WI_RID_TX_CRYPT_KEY:			p2ltv.wi_type = WI_RID_P2_TX_CRYPT_KEY;			p2ltv.wi_len = 2;			p2ltv.wi_val = ltv->wi_val;			ltv = &p2ltv;			break;		case WI_RID_DEFLT_CRYPT_KEYS: {				int error;				int keylen;				struct wi_ltv_str ws;				struct wi_ltv_keys *wk = (struct wi_ltv_keys *)ltv;				keylen = wk->wi_keys[sc->wi_tx_key].wi_keylen;				for (i = 0; i < 4; i++) {					bzero(&ws, sizeof(ws));					ws.wi_len = (keylen > 5) ? 8 : 4;					ws.wi_type = WI_RID_P2_CRYPT_KEY0 + i;					bcopy(&wk->wi_keys[i].wi_keydat,					    ws.wi_str, keylen);					error = wi_write_record(sc,					    (struct wi_ltv_gen *)&ws);					if (error)						return (error);				}			}			return (0);		}	}	if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))		return(EIO);	CSR_WRITE_2(sc, WI_DATA1, ltv->wi_len);	CSR_WRITE_2(sc, WI_DATA1, ltv->wi_type);	ptr = (u_int8_t *)&ltv->wi_val;	if (ltv->wi_len > 1)		CSR_WRITE_RAW_2(sc, WI_DATA1, ptr, (ltv->wi_len-1) *2);	if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_WRITE, ltv->wi_type))		return(EIO);	return(0);}