diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-11-01 22:34:20 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-11-01 22:34:20 +0000 |
commit | 53cea8683bd22a0049823b3815c3a8b7fb3d45ec (patch) | |
tree | 96da9cad8017fb93892870fb33541bb5025ecf9e /sys | |
parent | 9d7690c315da6d5b6d34d2b1b67ff85b51ff050f (diff) |
Add ieee80211_rate2plcp() and ieee80211_plcp2rate() functions.
Help and OK reyk@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net80211/ieee80211.c | 50 | ||||
-rw-r--r-- | sys/net80211/ieee80211_node.h | 3 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 6 |
3 files changed, 53 insertions, 6 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 0589896e195..5875cda0654 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211.c,v 1.25 2007/09/15 14:55:30 krw Exp $ */ +/* $OpenBSD: ieee80211.c,v 1.26 2007/11/01 22:34:19 mglocker Exp $ */ /* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */ /*- @@ -594,13 +594,17 @@ ieee80211_watchdog(struct ifnet *ifp) } const struct ieee80211_rateset ieee80211_std_rateset_11a = - { 8, { 12, 18, 24, 36, 48, 72, 96, 108 } }; + { 8, { 12, 18, 24, 36, 48, 72, 96, 108 }, + { 0x0b, 0x0f, 0x0a, 0x0e, 0x09, 0x0d, 0x08, 0x0c } }; const struct ieee80211_rateset ieee80211_std_rateset_11b = - { 4, { 2, 4, 11, 22 } }; + { 4, { 2, 4, 11, 22 }, + { 0x0a, 0x14, 0x37, 0x6e } }; const struct ieee80211_rateset ieee80211_std_rateset_11g = - { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 } }; + { 12, { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 }, + { 0x0a, 0x14, 0x37, 0x6e, 0x0b, 0x0f, 0x0a, 0x0e, 0x09, 0x0d, 0x08, + 0x0c } }; /* * Mark the basic rates for the 11g rate table based on the @@ -922,3 +926,41 @@ ieee80211_media2rate(int mword) return 0; #undef N } + +/* + * Convert bit rate (in 0.5Mbps units) to PLCP signal and vice versa. + */ +u_int8_t +ieee80211_rate2plcp(struct ieee80211com *ic, int rate, + enum ieee80211_phymode mode) +{ + int i; + + rate &= IEEE80211_RATE_VAL; + + for (i = 0; i < IEEE80211_RATE_MAXSIZE; i++) { + if (ic->ic_sup_rates[mode].rs_rates[i] == rate) + return (ic->ic_sup_rates[mode].rs_plcp[i]); + } + + IEEE80211_DPRINTF(("%s: unsupported rate %u\n", __func__, rate)); + + return (0); +} + +int +ieee80211_plcp2rate(struct ieee80211com *ic, u_int8_t plcp, + enum ieee80211_phymode mode) +{ + int i; + + for (i = 0; i < IEEE80211_RATE_MAXSIZE; i++) { + if (ic->ic_sup_rates[mode].rs_plcp[i] == plcp) + return (ic->ic_sup_rates[mode].rs_rates[i] & + IEEE80211_RATE_VAL); + } + + IEEE80211_DPRINTF(("%s: unsupported plcp %u\n", __func__, plcp)); + + return (0); +} diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index ebb61be724d..27ef087b9d0 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.h,v 1.23 2007/08/27 20:14:21 damien Exp $ */ +/* $OpenBSD: ieee80211_node.h,v 1.24 2007/11/01 22:34:19 mglocker Exp $ */ /* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */ /*- @@ -42,6 +42,7 @@ struct ieee80211_rateset { u_int8_t rs_nrates; u_int8_t rs_rates[IEEE80211_RATE_MAXSIZE]; + u_int8_t rs_plcp[IEEE80211_RATE_MAXSIZE]; }; extern const struct ieee80211_rateset ieee80211_std_rateset_11a; diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 098bf45c6f0..5563be06d13 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.33 2007/08/22 20:40:34 damien Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.34 2007/11/01 22:34:19 mglocker Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -313,6 +313,10 @@ int ieee80211_fix_rate(struct ieee80211com *, struct ieee80211_node *, int); int ieee80211_rate2media(struct ieee80211com *, int, enum ieee80211_phymode); int ieee80211_media2rate(int); +u_int8_t + ieee80211_rate2plcp(struct ieee80211com *, int, enum ieee80211_phymode); +int ieee80211_plcp2rate(struct ieee80211com *, u_int8_t, + enum ieee80211_phymode mode); u_int ieee80211_mhz2ieee(u_int, u_int); u_int ieee80211_chan2ieee(struct ieee80211com *, const struct ieee80211_channel *); |