diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-02-15 19:44:16 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-02-15 19:44:16 +0000 |
commit | 665c26fbfa839aefa17124ac2f607c306e0de4fd (patch) | |
tree | b12344918126d0a5f315a1a641fefcda1f35c259 /sys/net80211 | |
parent | 61223f4f3d7070ebf88b91c6fdcc6892ed7bdbbd (diff) |
add the manual tx power option. this is supported by some prism2/2.5/3
cards in hostap mode but it depends on the firmware version. support
for other wireless chipsets will be added in the future using the
net80211-framework.
ok robert@ bob@ danh@, tested by some others
Diffstat (limited to 'sys/net80211')
-rw-r--r-- | sys/net80211/ieee80211_ioctl.c | 26 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ioctl.h | 16 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 6 |
3 files changed, 42 insertions, 6 deletions
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 0a1ea1f2fe6..36dd974b946 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.c,v 1.4 2004/11/25 11:20:04 reyk Exp $ */ +/* $OpenBSD: ieee80211_ioctl.c,v 1.5 2005/02/15 19:44:15 reyk Exp $ */ /* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */ /*- @@ -1130,6 +1130,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ieee80211_bssid *bssid; struct ieee80211chanreq *chanreq; struct ieee80211_channel *chan; + struct ieee80211_txpower *txpower; struct ieee80211_wepkey keys[IEEE80211_WEP_NKID]; static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -1369,6 +1370,29 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifr = (struct ifreq *)data; copyout(&ic->ic_stats, ifr->ifr_data, sizeof (ic->ic_stats)); break; + case SIOCS80211TXPOWER: + txpower = (struct ieee80211_txpower *)data; + if ((error = suser(curproc, 0))) + break; + if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0) { + error = EINVAL; + break; + } + if (!(IEEE80211_TXPOWER_MIN < txpower->i_val && + txpower->i_val < IEEE80211_TXPOWER_MAX)) { + error = EINVAL; + break; + } + ic->ic_txpower = txpower->i_val; + error = ENETRESET; + break; + case SIOCG80211TXPOWER: + txpower = (struct ieee80211_txpower *)data; + if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0) + error = EINVAL; + else + txpower->i_val = ic->ic_txpower; + break; case SIOCSIFMTU: ifr = (struct ifreq *)data; if (!(IEEE80211_MTU_MIN <= ifr->ifr_mtu && diff --git a/sys/net80211/ieee80211_ioctl.h b/sys/net80211/ieee80211_ioctl.h index 7716947b961..a3a205cf046 100644 --- a/sys/net80211/ieee80211_ioctl.h +++ b/sys/net80211/ieee80211_ioctl.h @@ -1,5 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.h,v 1.1 2004/06/22 22:53:52 millert Exp $ */ -/* $OpenBSD: ieee80211_ioctl.h,v 1.1 2004/06/22 22:53:52 millert Exp $ */ +/* $OpenBSD: ieee80211_ioctl.h,v 1.2 2005/02/15 19:44:15 reyk Exp $ */ /* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */ /*- @@ -206,6 +205,19 @@ struct ieee80211_bssid { #define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid) #define SIOCG80211STATS _IOWR('i', 242, struct ifreq) + +struct ieee80211_txpower { + char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */ + int i_mode; /* auto, manual */ + int16_t i_val; /* dBm */ +}; + +#define SIOCS80211TXPOWER _IOW('i', 243, struct ieee80211_txpower) +#define SIOCG80211TXPOWER _IOWR('i', 244, struct ieee80211_txpower) + +#define IEEE80211_TXPOWER_MODE_FIXED 0 /* fixed tx power value */ +#define IEEE80211_TXPOWER_MODE_AUTO 1 /* auto level control */ + #endif #endif /* _NET80211_IEEE80211_IOCTL_H_ */ diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 8903d3dcebc..26fd666bbd4 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.4 2004/12/25 20:40:19 deraadt Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.5 2005/02/15 19:44:15 reyk Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -53,7 +53,7 @@ ((struct ieee80211_channel *) IEEE80211_CHAN_ANY) #define IEEE80211_TXPOWER_MAX 100 /* max power */ -#define IEEE80211_TXPOWER_MIN 0 /* kill radio (if possible) */ +#define IEEE80211_TXPOWER_MIN -50 /* kill radio (if possible) */ enum ieee80211_phytype { IEEE80211_T_DS, /* direct sequence spread spectrum */ @@ -225,7 +225,7 @@ struct ieee80211com { u_int16_t ic_txmin; /* min tx retry count */ u_int16_t ic_txmax; /* max tx retry count */ u_int16_t ic_txlifetime; /* tx lifetime */ - u_int16_t ic_txpower; /* tx power setting (dbM) */ + int16_t ic_txpower; /* tx power setting (dBm) */ u_int16_t ic_bmisstimeout;/* beacon miss threshold (ms) */ int ic_mgt_timer; /* mgmt timeout */ int ic_inact_timer; /* inactivity timer wait */ |