summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2008-04-21 19:37:19 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2008-04-21 19:37:19 +0000
commit0f4e544d0e77a9b0eda38174c19f833aada81ab1 (patch)
tree0f4f71d1b56ef93db1083a7e98f9c75c4e9c7f29
parent06e76e129ee17747a1caac19c5a96e8ecff75b5c (diff)
move ieee80211_auth_open() to ieee80211_proto.c
move ieee80211_setup_rates() to ieee80211_node.c move some prototypes from ieee80211_proto.h to ieee80211_crypto.h
-rw-r--r--sys/net80211/ieee80211_crypto.h11
-rw-r--r--sys/net80211/ieee80211_input.c131
-rw-r--r--sys/net80211/ieee80211_node.c33
-rw-r--r--sys/net80211/ieee80211_node.h4
-rw-r--r--sys/net80211/ieee80211_proto.c95
-rw-r--r--sys/net80211/ieee80211_proto.h13
6 files changed, 144 insertions, 143 deletions
diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h
index 67f96ae5f25..e9e506b407b 100644
--- a/sys/net80211/ieee80211_crypto.h
+++ b/sys/net80211/ieee80211_crypto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto.h,v 1.12 2008/04/21 19:01:01 damien Exp $ */
+/* $OpenBSD: ieee80211_crypto.h,v 1.13 2008/04/21 19:37:18 damien Exp $ */
/* $NetBSD: ieee80211_crypto.h,v 1.2 2003/09/14 01:14:55 dyoung Exp $ */
/*-
@@ -131,6 +131,15 @@ extern void ieee80211_tkip_mic(struct mbuf *, int, const u_int8_t *,
u_int8_t[IEEE80211_TKIP_MICLEN]);
extern void ieee80211_michael_mic_failure(struct ieee80211com *, u_int64_t);
+extern void ieee80211_eapol_key_mic(struct ieee80211_eapol_key *,
+ const u_int8_t *);
+extern int ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *,
+ const u_int8_t *);
+extern void ieee80211_eapol_key_encrypt(struct ieee80211com *,
+ struct ieee80211_eapol_key *, const u_int8_t *);
+extern int ieee80211_eapol_key_decrypt(struct ieee80211_eapol_key *,
+ const u_int8_t *);
+
extern void ieee80211_derive_ptk(const u_int8_t *, size_t, const u_int8_t *,
const u_int8_t *, const u_int8_t *, const u_int8_t *, u_int8_t *,
size_t);
diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c
index cc96ccf87b9..a30eb6453e8 100644
--- a/sys/net80211/ieee80211_input.c
+++ b/sys/net80211/ieee80211_input.c
@@ -1,5 +1,5 @@
/* $NetBSD: ieee80211_input.c,v 1.24 2004/05/31 11:12:24 dyoung Exp $ */
-/* $OpenBSD: ieee80211_input.c,v 1.76 2008/04/21 19:27:13 damien Exp $ */
+/* $OpenBSD: ieee80211_input.c,v 1.77 2008/04/21 19:37:18 damien Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
@@ -64,11 +64,6 @@
#include <dev/rndvar.h>
-int ieee80211_setup_rates(struct ieee80211com *, struct ieee80211_node *,
- const u_int8_t *, const u_int8_t *, int);
-void ieee80211_auth_open(struct ieee80211com *,
- const struct ieee80211_frame *, struct ieee80211_node *, int,
- u_int32_t, u_int16_t, u_int16_t);
int ieee80211_parse_edca_params_body(struct ieee80211com *,
const u_int8_t *);
int ieee80211_parse_edca_params(struct ieee80211com *, const u_int8_t *);
@@ -663,130 +658,6 @@ ieee80211_decap(struct ifnet *ifp, struct mbuf *m, int hdrlen)
return m;
}
-/*
- * Install received rate set information in the node's state block.
- */
-int
-ieee80211_setup_rates(struct ieee80211com *ic, struct ieee80211_node *ni,
- const u_int8_t *rates, const u_int8_t *xrates, int flags)
-{
- struct ieee80211_rateset *rs = &ni->ni_rates;
-
- memset(rs, 0, sizeof(*rs));
- rs->rs_nrates = rates[1];
- memcpy(rs->rs_rates, rates + 2, rs->rs_nrates);
- if (xrates != NULL) {
- u_int8_t nxrates;
- /*
- * Tack on 11g extended supported rate element.
- */
- nxrates = xrates[1];
- if (rs->rs_nrates + nxrates > IEEE80211_RATE_MAXSIZE) {
- nxrates = IEEE80211_RATE_MAXSIZE - rs->rs_nrates;
- IEEE80211_DPRINTF(("%s: extended rate set too large;"
- " only using %u of %u rates\n",
- __func__, nxrates, xrates[1]));
- ic->ic_stats.is_rx_rstoobig++;
- }
- memcpy(rs->rs_rates + rs->rs_nrates, xrates+2, nxrates);
- rs->rs_nrates += nxrates;
- }
- return ieee80211_fix_rate(ic, ni, flags);
-}
-
-void
-ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh,
- struct ieee80211_node *ni, int rssi, u_int32_t rstamp, u_int16_t seq,
- u_int16_t status)
-{
- struct ifnet *ifp = &ic->ic_if;
- switch (ic->ic_opmode) {
- case IEEE80211_M_IBSS:
- if (ic->ic_state != IEEE80211_S_RUN ||
- seq != IEEE80211_AUTH_OPEN_REQUEST) {
- IEEE80211_DPRINTF(("%s: discard auth from %s; "
- "state %u, seq %u\n", __func__,
- ether_sprintf((u_int8_t *)wh->i_addr2),
- ic->ic_state, seq));
- ic->ic_stats.is_rx_bad_auth++;
- return;
- }
- ieee80211_new_state(ic, IEEE80211_S_AUTH,
- wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
- break;
-
- case IEEE80211_M_AHDEMO:
- /* should not come here */
- break;
-
- case IEEE80211_M_HOSTAP:
- if (ic->ic_state != IEEE80211_S_RUN ||
- seq != IEEE80211_AUTH_OPEN_REQUEST) {
- IEEE80211_DPRINTF(("%s: discard auth from %s; "
- "state %u, seq %u\n", __func__,
- ether_sprintf((u_int8_t *)wh->i_addr2),
- ic->ic_state, seq));
- ic->ic_stats.is_rx_bad_auth++;
- return;
- }
- if (ni == ic->ic_bss) {
- ni = ieee80211_alloc_node(ic, wh->i_addr2);
- if (ni == NULL) {
- ic->ic_stats.is_rx_nodealloc++;
- return;
- }
- IEEE80211_ADDR_COPY(ni->ni_bssid, ic->ic_bss->ni_bssid);
- ni->ni_rssi = rssi;
- ni->ni_rstamp = rstamp;
- ni->ni_chan = ic->ic_bss->ni_chan;
- }
- IEEE80211_SEND_MGMT(ic, ni,
- IEEE80211_FC0_SUBTYPE_AUTH, seq + 1);
- if (ifp->if_flags & IFF_DEBUG)
- printf("%s: station %s %s authenticated (open)\n",
- ifp->if_xname,
- ether_sprintf((u_int8_t *)ni->ni_macaddr),
- ni->ni_state != IEEE80211_STA_CACHE ?
- "newly" : "already");
- ieee80211_node_newstate(ni, IEEE80211_STA_AUTH);
- break;
-
- case IEEE80211_M_STA:
- if (ic->ic_state != IEEE80211_S_AUTH ||
- seq != IEEE80211_AUTH_OPEN_RESPONSE) {
- ic->ic_stats.is_rx_bad_auth++;
- IEEE80211_DPRINTF(("%s: discard auth from %s; "
- "state %u, seq %u\n", __func__,
- ether_sprintf((u_int8_t *)wh->i_addr2),
- ic->ic_state, seq));
- return;
- }
- if (ic->ic_flags & IEEE80211_F_RSNON) {
- /* XXX not here! */
- ic->ic_bss->ni_port_valid = 0;
- ic->ic_bss->ni_replaycnt_ok = 0;
- (*ic->ic_delete_key)(ic, ic->ic_bss,
- &ic->ic_bss->ni_pairwise_key);
- }
- if (status != 0) {
- if (ifp->if_flags & IFF_DEBUG)
- printf("%s: open authentication failed "
- "(reason %d) for %s\n", ifp->if_xname,
- status,
- ether_sprintf((u_int8_t *)wh->i_addr3));
- if (ni != ic->ic_bss)
- ni->ni_fails++;
- ic->ic_stats.is_rx_auth_fail++;
- return;
- }
- ieee80211_new_state(ic, IEEE80211_S_ASSOC,
- wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
- break;
- case IEEE80211_M_MONITOR:
- break;
- }
-}
-
/* unaligned little endian access */
#define LE_READ_2(p) \
((u_int16_t) \
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 53f4fe4af29..c7d0889a9cb 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.c,v 1.31 2008/04/16 18:32:15 damien Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.32 2008/04/21 19:37:18 damien Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
@@ -1013,6 +1013,37 @@ ieee80211_iterate_nodes(struct ieee80211com *ic, ieee80211_iter_func *f,
}
/*
+ * Install received rate set information in the node's state block.
+ */
+int
+ieee80211_setup_rates(struct ieee80211com *ic, struct ieee80211_node *ni,
+ const u_int8_t *rates, const u_int8_t *xrates, int flags)
+{
+ struct ieee80211_rateset *rs = &ni->ni_rates;
+
+ memset(rs, 0, sizeof(*rs));
+ rs->rs_nrates = rates[1];
+ memcpy(rs->rs_rates, rates + 2, rs->rs_nrates);
+ if (xrates != NULL) {
+ u_int8_t nxrates;
+ /*
+ * Tack on 11g extended supported rate element.
+ */
+ nxrates = xrates[1];
+ if (rs->rs_nrates + nxrates > IEEE80211_RATE_MAXSIZE) {
+ nxrates = IEEE80211_RATE_MAXSIZE - rs->rs_nrates;
+ IEEE80211_DPRINTF(("%s: extended rate set too large;"
+ " only using %u of %u rates\n",
+ __func__, nxrates, xrates[1]));
+ ic->ic_stats.is_rx_rstoobig++;
+ }
+ memcpy(rs->rs_rates + rs->rs_nrates, xrates+2, nxrates);
+ rs->rs_nrates += nxrates;
+ }
+ return ieee80211_fix_rate(ic, ni, flags);
+}
+
+/*
* Check if the specified node supports ERP.
*/
int
diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h
index 4cb40c5d397..af4cf950c7e 100644
--- a/sys/net80211/ieee80211_node.h
+++ b/sys/net80211/ieee80211_node.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.h,v 1.26 2008/04/16 18:32:15 damien Exp $ */
+/* $OpenBSD: ieee80211_node.h,v 1.27 2008/04/21 19:37:18 damien Exp $ */
/* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */
/*-
@@ -245,6 +245,8 @@ typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
extern void ieee80211_iterate_nodes(struct ieee80211com *ic,
ieee80211_iter_func *, void *);
extern void ieee80211_clean_nodes(struct ieee80211com *);
+extern int ieee80211_setup_rates(struct ieee80211com *,
+ struct ieee80211_node *, const u_int8_t *, const u_int8_t *, int);
extern int ieee80211_iserp_sta(const struct ieee80211_node *);
extern void ieee80211_node_join(struct ieee80211com *,
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index b77d2477289..771cbc20e5b 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.c,v 1.22 2008/04/16 18:32:15 damien Exp $ */
+/* $OpenBSD: ieee80211_proto.c,v 1.23 2008/04/21 19:37:18 damien Exp $ */
/* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */
/*-
@@ -430,6 +430,99 @@ ieee80211_gtk_rekey_timeout(void *arg)
timeout_add(&ic->ic_rsn_timeout, 3600 * hz);
}
+void
+ieee80211_auth_open(struct ieee80211com *ic, const struct ieee80211_frame *wh,
+ struct ieee80211_node *ni, int rssi, u_int32_t rstamp, u_int16_t seq,
+ u_int16_t status)
+{
+ struct ifnet *ifp = &ic->ic_if;
+ switch (ic->ic_opmode) {
+ case IEEE80211_M_IBSS:
+ if (ic->ic_state != IEEE80211_S_RUN ||
+ seq != IEEE80211_AUTH_OPEN_REQUEST) {
+ IEEE80211_DPRINTF(("%s: discard auth from %s; "
+ "state %u, seq %u\n", __func__,
+ ether_sprintf((u_int8_t *)wh->i_addr2),
+ ic->ic_state, seq));
+ ic->ic_stats.is_rx_bad_auth++;
+ return;
+ }
+ ieee80211_new_state(ic, IEEE80211_S_AUTH,
+ wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
+ break;
+
+ case IEEE80211_M_AHDEMO:
+ /* should not come here */
+ break;
+
+ case IEEE80211_M_HOSTAP:
+ if (ic->ic_state != IEEE80211_S_RUN ||
+ seq != IEEE80211_AUTH_OPEN_REQUEST) {
+ IEEE80211_DPRINTF(("%s: discard auth from %s; "
+ "state %u, seq %u\n", __func__,
+ ether_sprintf((u_int8_t *)wh->i_addr2),
+ ic->ic_state, seq));
+ ic->ic_stats.is_rx_bad_auth++;
+ return;
+ }
+ if (ni == ic->ic_bss) {
+ ni = ieee80211_alloc_node(ic, wh->i_addr2);
+ if (ni == NULL) {
+ ic->ic_stats.is_rx_nodealloc++;
+ return;
+ }
+ IEEE80211_ADDR_COPY(ni->ni_bssid, ic->ic_bss->ni_bssid);
+ ni->ni_rssi = rssi;
+ ni->ni_rstamp = rstamp;
+ ni->ni_chan = ic->ic_bss->ni_chan;
+ }
+ IEEE80211_SEND_MGMT(ic, ni,
+ IEEE80211_FC0_SUBTYPE_AUTH, seq + 1);
+ if (ifp->if_flags & IFF_DEBUG)
+ printf("%s: station %s %s authenticated (open)\n",
+ ifp->if_xname,
+ ether_sprintf((u_int8_t *)ni->ni_macaddr),
+ ni->ni_state != IEEE80211_STA_CACHE ?
+ "newly" : "already");
+ ieee80211_node_newstate(ni, IEEE80211_STA_AUTH);
+ break;
+
+ case IEEE80211_M_STA:
+ if (ic->ic_state != IEEE80211_S_AUTH ||
+ seq != IEEE80211_AUTH_OPEN_RESPONSE) {
+ ic->ic_stats.is_rx_bad_auth++;
+ IEEE80211_DPRINTF(("%s: discard auth from %s; "
+ "state %u, seq %u\n", __func__,
+ ether_sprintf((u_int8_t *)wh->i_addr2),
+ ic->ic_state, seq));
+ return;
+ }
+ if (ic->ic_flags & IEEE80211_F_RSNON) {
+ /* XXX not here! */
+ ic->ic_bss->ni_port_valid = 0;
+ ic->ic_bss->ni_replaycnt_ok = 0;
+ (*ic->ic_delete_key)(ic, ic->ic_bss,
+ &ic->ic_bss->ni_pairwise_key);
+ }
+ if (status != 0) {
+ if (ifp->if_flags & IFF_DEBUG)
+ printf("%s: open authentication failed "
+ "(reason %d) for %s\n", ifp->if_xname,
+ status,
+ ether_sprintf((u_int8_t *)wh->i_addr3));
+ if (ni != ic->ic_bss)
+ ni->ni_fails++;
+ ic->ic_stats.is_rx_auth_fail++;
+ return;
+ }
+ ieee80211_new_state(ic, IEEE80211_S_ASSOC,
+ wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK);
+ break;
+ case IEEE80211_M_MONITOR:
+ break;
+ }
+}
+
int
ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate,
int mgt)
diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h
index e3fb831dfb8..20f5da1ed1a 100644
--- a/sys/net80211/ieee80211_proto.h
+++ b/sys/net80211/ieee80211_proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.h,v 1.28 2008/04/16 18:32:15 damien Exp $ */
+/* $OpenBSD: ieee80211_proto.h,v 1.29 2008/04/21 19:37:18 damien Exp $ */
/* $NetBSD: ieee80211_proto.h,v 1.3 2003/10/13 04:23:56 dyoung Exp $ */
/*-
@@ -126,14 +126,9 @@ extern int ieee80211_ibss_merge(struct ieee80211com *,
struct ieee80211_node *, u_int64_t);
extern void ieee80211_reset_erp(struct ieee80211com *);
extern void ieee80211_set_shortslottime(struct ieee80211com *, int);
-extern void ieee80211_eapol_key_mic(struct ieee80211_eapol_key *,
- const u_int8_t *);
-extern int ieee80211_eapol_key_check_mic(struct ieee80211_eapol_key *,
- const u_int8_t *);
-extern void ieee80211_eapol_key_encrypt(struct ieee80211com *,
- struct ieee80211_eapol_key *, const u_int8_t *);
-extern int ieee80211_eapol_key_decrypt(struct ieee80211_eapol_key *,
- const u_int8_t *);
+extern void ieee80211_auth_open(struct ieee80211com *,
+ const struct ieee80211_frame *, struct ieee80211_node *, int,
+ u_int32_t, u_int16_t, u_int16_t);
extern void ieee80211_gtk_rekey_timeout(void *);
extern void ieee80211_setkeys(struct ieee80211com *);
extern void ieee80211_setkeysdone(struct ieee80211com *);