ieee80211_sta.c (298376) | ieee80211_sta.c (299575) |
---|---|
1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> 27#ifdef __FreeBSD__ | 1/*- 2 * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include <sys/cdefs.h> 27#ifdef __FreeBSD__ |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_sta.c 298376 2016-04-20 21:15:55Z avos $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_sta.c 299575 2016-05-12 22:17:00Z avos $"); |
29#endif 30 31/* 32 * IEEE 802.11 Station mode support. 33 */ 34#include "opt_inet.h" 35#include "opt_wlan.h" 36 --- 934 unchanged lines hidden (view full) --- 971 972static void 973sta_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh, 974 uint8_t *frm, uint8_t *efrm, int rssi, int nf, 975 uint16_t seq, uint16_t status) 976{ 977 struct ieee80211vap *vap = ni->ni_vap; 978 uint8_t *challenge; | 29#endif 30 31/* 32 * IEEE 802.11 Station mode support. 33 */ 34#include "opt_inet.h" 35#include "opt_wlan.h" 36 --- 934 unchanged lines hidden (view full) --- 971 972static void 973sta_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh, 974 uint8_t *frm, uint8_t *efrm, int rssi, int nf, 975 uint16_t seq, uint16_t status) 976{ 977 struct ieee80211vap *vap = ni->ni_vap; 978 uint8_t *challenge; |
979 int estatus; | |
980 981 /* 982 * NB: this can happen as we allow pre-shared key 983 * authentication to be enabled w/o wep being turned 984 * on so that configuration of these can be done 985 * in any order. It may be better to enforce the 986 * ordering in which case this check would just be 987 * for sanity/consistency. 988 */ 989 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { 990 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 991 ni->ni_macaddr, "shared key auth", 992 "%s", " PRIVACY is disabled"); | 979 980 /* 981 * NB: this can happen as we allow pre-shared key 982 * authentication to be enabled w/o wep being turned 983 * on so that configuration of these can be done 984 * in any order. It may be better to enforce the 985 * ordering in which case this check would just be 986 * for sanity/consistency. 987 */ 988 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { 989 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 990 ni->ni_macaddr, "shared key auth", 991 "%s", " PRIVACY is disabled"); |
993 estatus = IEEE80211_STATUS_ALG; | |
994 goto bad; 995 } 996 /* 997 * Pre-shared key authentication is evil; accept 998 * it only if explicitly configured (it is supported 999 * mainly for compatibility with clients like OS X). 1000 */ 1001 if (ni->ni_authmode != IEEE80211_AUTH_AUTO && 1002 ni->ni_authmode != IEEE80211_AUTH_SHARED) { 1003 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1004 ni->ni_macaddr, "shared key auth", 1005 "bad sta auth mode %u", ni->ni_authmode); 1006 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ | 992 goto bad; 993 } 994 /* 995 * Pre-shared key authentication is evil; accept 996 * it only if explicitly configured (it is supported 997 * mainly for compatibility with clients like OS X). 998 */ 999 if (ni->ni_authmode != IEEE80211_AUTH_AUTO && 1000 ni->ni_authmode != IEEE80211_AUTH_SHARED) { 1001 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1002 ni->ni_macaddr, "shared key auth", 1003 "bad sta auth mode %u", ni->ni_authmode); 1004 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ |
1007 estatus = IEEE80211_STATUS_ALG; | |
1008 goto bad; 1009 } 1010 1011 challenge = NULL; 1012 if (frm + 1 < efrm) { 1013 if ((frm[1] + 2) > (efrm - frm)) { 1014 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1015 ni->ni_macaddr, "shared key auth", 1016 "ie %d/%d too long", 1017 frm[0], (frm[1] + 2) - (efrm - frm)); 1018 vap->iv_stats.is_rx_bad_auth++; | 1005 goto bad; 1006 } 1007 1008 challenge = NULL; 1009 if (frm + 1 < efrm) { 1010 if ((frm[1] + 2) > (efrm - frm)) { 1011 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1012 ni->ni_macaddr, "shared key auth", 1013 "ie %d/%d too long", 1014 frm[0], (frm[1] + 2) - (efrm - frm)); 1015 vap->iv_stats.is_rx_bad_auth++; |
1019 estatus = IEEE80211_STATUS_CHALLENGE; | |
1020 goto bad; 1021 } 1022 if (*frm == IEEE80211_ELEMID_CHALLENGE) 1023 challenge = frm; 1024 frm += frm[1] + 2; 1025 } 1026 switch (seq) { 1027 case IEEE80211_AUTH_SHARED_CHALLENGE: 1028 case IEEE80211_AUTH_SHARED_RESPONSE: 1029 if (challenge == NULL) { 1030 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1031 ni->ni_macaddr, "shared key auth", 1032 "%s", "no challenge"); 1033 vap->iv_stats.is_rx_bad_auth++; | 1016 goto bad; 1017 } 1018 if (*frm == IEEE80211_ELEMID_CHALLENGE) 1019 challenge = frm; 1020 frm += frm[1] + 2; 1021 } 1022 switch (seq) { 1023 case IEEE80211_AUTH_SHARED_CHALLENGE: 1024 case IEEE80211_AUTH_SHARED_RESPONSE: 1025 if (challenge == NULL) { 1026 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1027 ni->ni_macaddr, "shared key auth", 1028 "%s", "no challenge"); 1029 vap->iv_stats.is_rx_bad_auth++; |
1034 estatus = IEEE80211_STATUS_CHALLENGE; | |
1035 goto bad; 1036 } 1037 if (challenge[1] != IEEE80211_CHALLENGE_LEN) { 1038 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1039 ni->ni_macaddr, "shared key auth", 1040 "bad challenge len %d", challenge[1]); 1041 vap->iv_stats.is_rx_bad_auth++; | 1030 goto bad; 1031 } 1032 if (challenge[1] != IEEE80211_CHALLENGE_LEN) { 1033 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 1034 ni->ni_macaddr, "shared key auth", 1035 "bad challenge len %d", challenge[1]); 1036 vap->iv_stats.is_rx_bad_auth++; |
1042 estatus = IEEE80211_STATUS_CHALLENGE; | |
1043 goto bad; 1044 } 1045 default: 1046 break; 1047 } 1048 if (vap->iv_state != IEEE80211_S_AUTH) 1049 return; 1050 switch (seq) { --- 225 unchanged lines hidden (view full) --- 1276 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); 1277} 1278 1279static void 1280sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype, 1281 const struct ieee80211_rx_stats *rxs, 1282 int rssi, int nf) 1283{ | 1037 goto bad; 1038 } 1039 default: 1040 break; 1041 } 1042 if (vap->iv_state != IEEE80211_S_AUTH) 1043 return; 1044 switch (seq) { --- 225 unchanged lines hidden (view full) --- 1270 ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); 1271} 1272 1273static void 1274sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype, 1275 const struct ieee80211_rx_stats *rxs, 1276 int rssi, int nf) 1277{ |
1284#define ISPROBE(_st) ((_st) == IEEE80211_FC0_SUBTYPE_PROBE_RESP) | |
1285#define ISREASSOC(_st) ((_st) == IEEE80211_FC0_SUBTYPE_REASSOC_RESP) 1286 struct ieee80211vap *vap = ni->ni_vap; 1287 struct ieee80211com *ic = ni->ni_ic; 1288 struct ieee80211_channel *rxchan = ic->ic_curchan; 1289 struct ieee80211_frame *wh; 1290 uint8_t *frm, *efrm; 1291 uint8_t *rates, *xrates, *wme, *htcap, *htinfo; 1292 uint8_t rate; --- 563 unchanged lines hidden (view full) --- 1856 1857 default: 1858 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, 1859 wh, "mgt", "subtype 0x%x not handled", subtype); 1860 vap->iv_stats.is_rx_badsubtype++; 1861 break; 1862 } 1863#undef ISREASSOC | 1278#define ISREASSOC(_st) ((_st) == IEEE80211_FC0_SUBTYPE_REASSOC_RESP) 1279 struct ieee80211vap *vap = ni->ni_vap; 1280 struct ieee80211com *ic = ni->ni_ic; 1281 struct ieee80211_channel *rxchan = ic->ic_curchan; 1282 struct ieee80211_frame *wh; 1283 uint8_t *frm, *efrm; 1284 uint8_t *rates, *xrates, *wme, *htcap, *htinfo; 1285 uint8_t rate; --- 563 unchanged lines hidden (view full) --- 1849 1850 default: 1851 IEEE80211_DISCARD(vap, IEEE80211_MSG_ANY, 1852 wh, "mgt", "subtype 0x%x not handled", subtype); 1853 vap->iv_stats.is_rx_badsubtype++; 1854 break; 1855 } 1856#undef ISREASSOC |
1864#undef ISPROBE | |
1865} 1866 1867static void 1868sta_recv_ctl(struct ieee80211_node *ni, struct mbuf *m, int subtype) 1869{ 1870 switch (subtype) { 1871 case IEEE80211_FC0_SUBTYPE_BAR: 1872 ieee80211_recv_bar(ni, m); 1873 break; 1874 } 1875} | 1857} 1858 1859static void 1860sta_recv_ctl(struct ieee80211_node *ni, struct mbuf *m, int subtype) 1861{ 1862 switch (subtype) { 1863 case IEEE80211_FC0_SUBTYPE_BAR: 1864 ieee80211_recv_bar(ni, m); 1865 break; 1866 } 1867} |