From owner-p4-projects@FreeBSD.ORG Mon Dec 15 11:45:41 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1177E16A4D0; Mon, 15 Dec 2003 11:45:41 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB0DA16A4CE for ; Mon, 15 Dec 2003 11:45:40 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6ABFA43D35 for ; Mon, 15 Dec 2003 11:45:39 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id hBFJjd0B020478 for ; Mon, 15 Dec 2003 11:45:39 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id hBFJjci2020475 for perforce@freebsd.org; Mon, 15 Dec 2003 11:45:38 -0800 (PST) (envelope-from sam@freebsd.org) Date: Mon, 15 Dec 2003 11:45:38 -0800 (PST) Message-Id: <200312151945.hBFJjci2020475@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 43952 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Dec 2003 19:45:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=43952 Change 43952 by sam@sam_ebb on 2003/12/15 11:44:45 hookup shared key authentication support to the ioctl infrastructure Affected files ... .. //depot/projects/netperf/sys/net80211/ieee80211_ioctl.c#11 edit .. //depot/projects/netperf/sys/net80211/ieee80211_output.c#13 edit .. //depot/projects/netperf/sys/net80211/ieee80211_proto.c#11 edit .. //depot/projects/netperf/sys/net80211/ieee80211_var.h#12 edit Differences ... ==== //depot/projects/netperf/sys/net80211/ieee80211_ioctl.c#11 (text+ko) ==== @@ -213,7 +213,7 @@ wreq.wi_len = 1; break; case WI_RID_CNFAUTHMODE: - wreq.wi_val[0] = htole16(1); /* TODO: open system only */ + wreq.wi_val[0] = htole16(ic->ic_authmode); wreq.wi_len = 1; break; case WI_RID_ENCRYPTION: @@ -632,8 +632,14 @@ case WI_RID_CNFAUTHMODE: if (len != 2) return EINVAL; - if (le16toh(wreq.wi_val[0]) != 1) - return EINVAL; /* TODO: shared key auth */ + if (le16toh(wreq.wi_val[0]) > IEEE80211_AUTH_SHARED) + return EINVAL; + /* shared key authentication requires WEP */ + if (le16toh(wreq.wi_val[0]) == IEEE80211_AUTH_SHARED && + (ic->ic_flags & IEEE80211_F_WEPON) == 0) + return EINVAL; + ic->ic_authmode = le16toh(wreq.wi_val[0]); + error = ENETRESET; break; case WI_RID_ENCRYPTION: if (len != 2) @@ -830,7 +836,7 @@ ireq->i_val = ic->ic_wep_txkey; break; case IEEE80211_IOC_AUTHMODE: - ireq->i_val = IEEE80211_AUTH_OPEN; + ireq->i_val = ic->ic_authmode; break; case IEEE80211_IOC_CHANNEL: switch (ic->ic_state) { @@ -928,11 +934,23 @@ ic->ic_wep_txkey = kid; error = ENETRESET; break; -#if 0 case IEEE80211_IOC_AUTHMODE: - sc->wi_authmode = ireq->i_val; + if (!(IEEE80211_AUTH_NONE <= ireq->i_val && + ireq->i_val <= IEEE80211_AUTH_SHARED)) { + error = EINVAL; + break; + } + if (ireq->i_val == IEEE80211_AUTH_SHARED && + (ic->ic_flags & IEEE80211_F_WEPON) == 0) { + /* shared key authentication requires WEP */ + error = EINVAL; + break; + } + if (ic->ic_authmode != ireq->i_val) { + ic->ic_authmode = ireq->i_val; + error = ENETRESET; + } break; -#endif case IEEE80211_IOC_CHANNEL: /* XXX 0xffff overflows 16-bit signed */ if (ireq->i_val == 0 || ==== //depot/projects/netperf/sys/net80211/ieee80211_output.c#13 (text+ko) ==== @@ -451,8 +451,17 @@ arg == IEEE80211_AUTH_SHARED_RESPONSE) && ni->ni_challenge != NULL); - is_shared_key = has_challenge || (ni->ni_challenge != NULL && - arg == IEEE80211_AUTH_SHARED_PASS); + /* + * Deduce whether we're doing open authentication or + * shared key authentication. We do the latter if + * we're in the middle of a shared key authentication + * handshake or if we're initiating an authentication + * request and configured to use shared key. + */ + is_shared_key = has_challenge || + arg >= IEEE80211_AUTH_SHARED_RESPONSE || + (arg == IEEE80211_AUTH_SHARED_REQUEST && + ic->ic_authmode == IEEE80211_AUTH_SHARED); if (has_challenge) { MH_ALIGN(m, 2 * 3 + 2 + IEEE80211_CHALLENGE_LEN); ==== //depot/projects/netperf/sys/net80211/ieee80211_proto.c#11 (text+ko) ==== @@ -103,6 +103,7 @@ #endif ic->ic_fragthreshold = 2346; /* XXX not used yet */ ic->ic_fixed_rate = -1; /* no fixed rate */ + ic->ic_authmode = IEEE80211_AUTH_OPEN; mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF); mtx_init(&ic->ic_pwrsaveq.ifq_mtx, ifp->if_xname, "power save q", MTX_DEF); ==== //depot/projects/netperf/sys/net80211/ieee80211_var.h#12 (text+ko) ==== @@ -203,6 +203,7 @@ u_int16_t ic_txlifetime; /* tx lifetime */ u_int16_t ic_txpower; /* tx power setting (dbM) */ u_int16_t ic_bmisstimeout;/* beacon miss threshold (ms) */ + u_int16_t ic_authmode; /* authentication mode */ int ic_mgt_timer; /* mgmt timeout */ int ic_inact_timer; /* inactivity timer wait */ int ic_des_esslen;