From: damien Date: Mon, 21 Jul 2008 19:27:26 +0000 (+0000) Subject: add ieee80211_priv.h file: contains definitions private to net80211. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6aaa29fa19e000258c7d74124b91791d14d193ad;p=openbsd add ieee80211_priv.h file: contains definitions private to net80211. this must not be included by drivers. --- diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 3cfbf4a3b45..5e64258b045 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211.c,v 1.31 2008/04/26 20:03:34 damien Exp $ */ +/* $OpenBSD: ieee80211.c,v 1.32 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */ /*- @@ -62,6 +62,7 @@ #endif #include +#include #ifdef IEEE80211_DEBUG int ieee80211_debug = 0; diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h index 8914594ed74..d3a8bd08c98 100644 --- a/sys/net80211/ieee80211.h +++ b/sys/net80211/ieee80211.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211.h,v 1.35 2008/04/16 18:32:15 damien Exp $ */ +/* $OpenBSD: ieee80211.h,v 1.36 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211.h,v 1.6 2004/04/30 23:51:53 dyoung Exp $ */ /*- @@ -557,16 +557,9 @@ enum { * number may be overridden by the driver and/or by * user configuration. */ -#define IEEE80211_AID_MAX 2007 -#define IEEE80211_AID_DEF 1800 - -#define IEEE80211_AID(b) ((b) &~ 0xc000) -#define IEEE80211_AID_SET(b, w) \ - ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32))) -#define IEEE80211_AID_CLR(b, w) \ - ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32))) -#define IEEE80211_AID_ISSET(b, w) \ - ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) +#define IEEE80211_AID_MAX 2007 +#define IEEE80211_AID_DEF 1800 +#define IEEE80211_AID(b) ((b) &~ 0xc000) /* * RTS frame length parameters. The default is specified in diff --git a/sys/net80211/ieee80211_amrr.c b/sys/net80211/ieee80211_amrr.c index ad5f4e0f4e6..b238b2b22ee 100644 --- a/sys/net80211/ieee80211_amrr.c +++ b/sys/net80211/ieee80211_amrr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_amrr.c,v 1.3 2007/06/16 13:17:05 damien Exp $ */ +/* $OpenBSD: ieee80211_amrr.c,v 1.4 2008/07/21 19:27:26 damien Exp $ */ /*- * Copyright (c) 2006 @@ -31,6 +31,7 @@ #endif #include +#include #include #define is_success(amn) \ diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 2b989435719..4cdd07c2fa9 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.c,v 1.42 2008/06/16 18:32:04 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.c,v 1.43 2008/07/21 19:27:26 damien Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -40,6 +40,7 @@ #endif #include +#include #include #include @@ -466,17 +467,6 @@ ieee80211_derive_pmkid(const u_int8_t *pmk, size_t pmk_len, const u_int8_t *aa, memcpy(pmkid, hash, IEEE80211_PMKID_LEN); } -/* unaligned big endian access */ -#define BE_READ_2(p) \ - ((u_int16_t) \ - ((((const u_int8_t *)(p))[0] << 8) | \ - (((const u_int8_t *)(p))[1]))) - -#define BE_WRITE_2(p, v) do { \ - ((u_int8_t *)(p))[0] = (v) >> 8; \ - ((u_int8_t *)(p))[1] = (v) & 0xff; \ -} while (0) - /* * Compute the Key MIC field of an EAPOL-Key frame using the specified Key * Confirmation Key (KCK). The hash function can be either HMAC-MD5 or diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 0fa629c0a33..846c15eb94f 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.82 2008/07/21 19:05:21 damien Exp $ */ +/* $OpenBSD: ieee80211_input.c,v 1.83 2008/07/21 19:27:26 damien Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe @@ -61,6 +61,7 @@ #endif #include +#include int ieee80211_parse_edca_params_body(struct ieee80211com *, const u_int8_t *); @@ -630,18 +631,6 @@ ieee80211_decap(struct ifnet *ifp, struct mbuf *m, int hdrlen) return m; } -/* unaligned little endian access */ -#define LE_READ_2(p) \ - ((u_int16_t) \ - ((((const u_int8_t *)(p))[0]) | \ - (((const u_int8_t *)(p))[1] << 8))) -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((const u_int8_t *)(p))[0]) | \ - (((const u_int8_t *)(p))[1] << 8) | \ - (((const u_int8_t *)(p))[2] << 16) | \ - (((const u_int8_t *)(p))[3] << 24))) - /* * Parse an EDCA Parameter Set element (see 7.3.2.27). */ diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 8e4c3775205..ffec5d3226f 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.c,v 1.34 2008/06/09 07:07:16 djm Exp $ */ +/* $OpenBSD: ieee80211_node.c,v 1.35 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /*- @@ -65,6 +65,7 @@ #endif #include +#include #include diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index b18bcd351aa..59ea1c4c0d5 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_output.c,v 1.60 2008/07/21 19:05:21 damien Exp $ */ +/* $OpenBSD: ieee80211_output.c,v 1.61 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */ /*- @@ -64,6 +64,7 @@ #endif #include +#include enum ieee80211_edca_ac ieee80211_up_to_ac(struct ieee80211com *, int); int ieee80211_classify(struct ieee80211com *, struct mbuf *); @@ -594,12 +595,6 @@ bad: return NULL; } -/* unaligned little endian access */ -#define LE_WRITE_2(p, v) do { \ - ((u_int8_t *)(p))[0] = (v) & 0xff; \ - ((u_int8_t *)(p))[1] = (v) >> 8; \ -} while (0) - /* * Add a Capability Information field to a frame (see 7.3.1.4). */ diff --git a/sys/net80211/ieee80211_pae_input.c b/sys/net80211/ieee80211_pae_input.c index b7338624d54..c6d28080dd4 100644 --- a/sys/net80211/ieee80211_pae_input.c +++ b/sys/net80211/ieee80211_pae_input.c @@ -1,3 +1,5 @@ +/* $OpenBSD: ieee80211_pae_input.c,v 1.2 2008/07/21 19:27:26 damien Exp $ */ + /*- * Copyright (c) 2007,2008 Damien Bergamini * @@ -37,6 +39,7 @@ #endif #include +#include #include @@ -60,22 +63,6 @@ void ieee80211_recv_group_msg2(struct ieee80211com *, void ieee80211_recv_eapol_key_req(struct ieee80211com *, struct ieee80211_eapol_key *, struct ieee80211_node *); -/* unaligned big endian access */ -#define BE_READ_2(p) \ - ((u_int16_t)(p)[0] << 8 | (u_int16_t)(p)[1]) - -#define BE_READ_8(p) \ - ((u_int64_t)(p)[0] << 56 | (u_int64_t)(p)[1] << 48 | \ - (u_int64_t)(p)[2] << 40 | (u_int64_t)(p)[3] << 32 | \ - (u_int64_t)(p)[4] << 24 | (u_int64_t)(p)[5] << 16 | \ - (u_int64_t)(p)[6] << 8 | (u_int64_t)(p)[7]) - -/* unaligned little endian access */ -#define LE_READ_6(p) \ - ((u_int64_t)(p)[5] << 40 | (u_int64_t)(p)[4] << 32 | \ - (u_int64_t)(p)[3] << 24 | (u_int64_t)(p)[2] << 16 | \ - (u_int64_t)(p)[1] << 8 | (u_int64_t)(p)[0]) - /* * Process an incoming EAPOL frame. Notice that we are only interested in * EAPOL-Key frames with an IEEE 802.11 or WPA descriptor type. diff --git a/sys/net80211/ieee80211_pae_output.c b/sys/net80211/ieee80211_pae_output.c index 30dc8b981fa..6235c99b3a7 100644 --- a/sys/net80211/ieee80211_pae_output.c +++ b/sys/net80211/ieee80211_pae_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_pae_output.c,v 1.1 2008/07/21 19:05:21 damien Exp $ */ +/* $OpenBSD: ieee80211_pae_output.c,v 1.2 2008/07/21 19:27:26 damien Exp $ */ /*- * Copyright (c) 2007,2008 Damien Bergamini @@ -41,6 +41,7 @@ #endif #include +#include int ieee80211_send_eapol_key(struct ieee80211com *, struct mbuf *, struct ieee80211_node *, const struct ieee80211_ptk *); @@ -49,28 +50,6 @@ u_int8_t *ieee80211_add_gtk_kde(u_int8_t *, struct ieee80211_node *, u_int8_t *ieee80211_add_pmkid_kde(u_int8_t *, const u_int8_t *); struct mbuf *ieee80211_get_eapol_key(int, int, u_int); -/* unaligned big endian access */ -#define BE_READ_2(p) \ - ((u_int16_t)(p)[0] << 8 | (u_int16_t)(p)[1]) - -#define BE_WRITE_2(p, v) do { \ - (p)[0] = (v) >> 8; (p)[1] = (v); \ -} while (0) - -#define BE_WRITE_8(p, v) do { \ - (p)[0] = (v) >> 56; (p)[1] = (v) >> 48; \ - (p)[2] = (v) >> 40; (p)[3] = (v) >> 32; \ - (p)[4] = (v) >> 24; (p)[5] = (v) >> 16; \ - (p)[6] = (v) >> 8; (p)[7] = (v); \ -} while (0) - -/* unaligned little endian access */ -#define LE_WRITE_6(p, v) do { \ - (p)[5] = (v) >> 40; (p)[4] = (v) >> 32; \ - (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \ - (p)[1] = (v) >> 8; (p)[0] = (v); \ -} while (0) - /* * Send an EAPOL-Key frame to node `ni'. If MIC or encryption is required, * the PTK must be passed (otherwise it can be set to NULL.) diff --git a/sys/net80211/ieee80211_priv.h b/sys/net80211/ieee80211_priv.h new file mode 100644 index 00000000000..cfc3ca779e0 --- /dev/null +++ b/sys/net80211/ieee80211_priv.h @@ -0,0 +1,96 @@ +/* $OpenBSD: ieee80211_priv.h,v 1.1 2008/07/21 19:27:26 damien Exp $ */ + +/*- + * Copyright (c) 2008 Damien Bergamini + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _NET80211_IEEE80211_PRIV_H_ +#define _NET80211_IEEE80211_PRIV_H_ + +#ifdef IEEE80211_DEBUG +extern int ieee80211_debug; +#define IEEE80211_DPRINTF(X) do { if (ieee80211_debug) printf X; } while(0) +#define IEEE80211_DPRINTF2(X) do { if (ieee80211_debug>1) printf X; } while(0) +#else +#define IEEE80211_DPRINTF(X) +#define IEEE80211_DPRINTF2(X) +#endif + +#define IEEE80211_AID_SET(b, w) \ + ((w)[IEEE80211_AID(b) / 32] |= (1 << (IEEE80211_AID(b) % 32))) +#define IEEE80211_AID_CLR(b, w) \ + ((w)[IEEE80211_AID(b) / 32] &= ~(1 << (IEEE80211_AID(b) % 32))) +#define IEEE80211_AID_ISSET(b, w) \ + ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) + +/* unaligned big endian access */ +#define BE_READ_2(p) \ + ((u_int16_t) \ + ((((const u_int8_t *)(p))[0] << 8) | \ + (((const u_int8_t *)(p))[1]))) + +#define BE_READ_8(p) \ + ((u_int64_t)(p)[0] << 56 | (u_int64_t)(p)[1] << 48 | \ + (u_int64_t)(p)[2] << 40 | (u_int64_t)(p)[3] << 32 | \ + (u_int64_t)(p)[4] << 24 | (u_int64_t)(p)[5] << 16 | \ + (u_int64_t)(p)[6] << 8 | (u_int64_t)(p)[7]) + +#define BE_WRITE_2(p, v) do { \ + ((u_int8_t *)(p))[0] = (v) >> 8; \ + ((u_int8_t *)(p))[1] = (v) & 0xff; \ +} while (0) + +#define BE_WRITE_8(p, v) do { \ + (p)[0] = (v) >> 56; (p)[1] = (v) >> 48; \ + (p)[2] = (v) >> 40; (p)[3] = (v) >> 32; \ + (p)[4] = (v) >> 24; (p)[5] = (v) >> 16; \ + (p)[6] = (v) >> 8; (p)[7] = (v); \ +} while (0) + +/* unaligned little endian access */ +#define LE_READ_2(p) \ + ((u_int16_t) \ + ((((const u_int8_t *)(p))[0]) | \ + (((const u_int8_t *)(p))[1] << 8))) + +#define LE_READ_4(p) \ + ((u_int32_t) \ + ((((const u_int8_t *)(p))[0]) | \ + (((const u_int8_t *)(p))[1] << 8) | \ + (((const u_int8_t *)(p))[2] << 16) | \ + (((const u_int8_t *)(p))[3] << 24))) + +#define LE_READ_6(p) \ + ((u_int64_t)(p)[5] << 40 | (u_int64_t)(p)[4] << 32 | \ + (u_int64_t)(p)[3] << 24 | (u_int64_t)(p)[2] << 16 | \ + (u_int64_t)(p)[1] << 8 | (u_int64_t)(p)[0]) + +#define LE_WRITE_2(p, v) do { \ + ((u_int8_t *)(p))[0] = (v) & 0xff; \ + ((u_int8_t *)(p))[1] = (v) >> 8; \ +} while (0) + +#define LE_WRITE_4(p, v) do { \ + (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \ + (p)[1] = (v) >> 8; (p)[0] = (v); \ +} while (0) + +#define LE_WRITE_6(p, v) do { \ + (p)[5] = (v) >> 40; (p)[4] = (v) >> 32; \ + (p)[3] = (v) >> 24; (p)[2] = (v) >> 16; \ + (p)[1] = (v) >> 8; (p)[0] = (v); \ +} while (0) + +#endif /* _NET80211_IEEE80211_PRIV_H_ */ diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index 02e4c9ff6f7..e20ee07bfb8 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_proto.c,v 1.25 2008/07/21 18:43:18 damien Exp $ */ +/* $OpenBSD: ieee80211_proto.c,v 1.26 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */ /*- @@ -63,6 +63,7 @@ #endif #include +#include #include diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index e12ec242c4f..aad6495965e 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.39 2008/07/21 18:43:18 damien Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.40 2008/07/21 19:27:26 damien Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -357,15 +357,6 @@ enum ieee80211_phymode ieee80211_next_mode(struct ifnet *); enum ieee80211_phymode ieee80211_chan2mode(struct ieee80211com *, const struct ieee80211_channel *); -#ifdef IEEE80211_DEBUG -extern int ieee80211_debug; -#define IEEE80211_DPRINTF(X) do { if (ieee80211_debug) printf X; } while(0) -#define IEEE80211_DPRINTF2(X) do { if (ieee80211_debug>1) printf X; } while(0) -#else -#define IEEE80211_DPRINTF(X) -#define IEEE80211_DPRINTF2(X) -#endif - extern int ieee80211_cache_size; #endif /* _NET80211_IEEE80211_VAR_H_ */