diff options
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/wext-compat.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 711e00a0c9b5..9fbfb8536e75 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -744,3 +744,83 @@ int cfg80211_wext_giwencode(struct net_device *dev, | |||
744 | return err; | 744 | return err; |
745 | } | 745 | } |
746 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode); | 746 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode); |
747 | |||
748 | int cfg80211_wext_siwtxpower(struct net_device *dev, | ||
749 | struct iw_request_info *info, | ||
750 | union iwreq_data *data, char *extra) | ||
751 | { | ||
752 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
753 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
754 | enum tx_power_setting type; | ||
755 | int dbm = 0; | ||
756 | |||
757 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | ||
758 | return -EINVAL; | ||
759 | if (data->txpower.flags & IW_TXPOW_RANGE) | ||
760 | return -EINVAL; | ||
761 | |||
762 | if (!rdev->ops->set_tx_power) | ||
763 | return -EOPNOTSUPP; | ||
764 | |||
765 | /* only change when not disabling */ | ||
766 | if (!data->txpower.disabled) { | ||
767 | if (data->txpower.fixed) { | ||
768 | /* | ||
769 | * wext doesn't support negative values, see | ||
770 | * below where it's for automatic | ||
771 | */ | ||
772 | if (data->txpower.value < 0) | ||
773 | return -EINVAL; | ||
774 | dbm = data->txpower.value; | ||
775 | type = TX_POWER_FIXED; | ||
776 | /* TODO: do regulatory check! */ | ||
777 | } else { | ||
778 | /* | ||
779 | * Automatic power level setting, max being the value | ||
780 | * passed in from userland. | ||
781 | */ | ||
782 | if (data->txpower.value < 0) { | ||
783 | type = TX_POWER_AUTOMATIC; | ||
784 | } else { | ||
785 | dbm = data->txpower.value; | ||
786 | type = TX_POWER_LIMITED; | ||
787 | } | ||
788 | } | ||
789 | } else { | ||
790 | type = TX_POWER_OFF; | ||
791 | } | ||
792 | |||
793 | return rdev->ops->set_tx_power(wdev->wiphy, type, dbm);; | ||
794 | } | ||
795 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower); | ||
796 | |||
797 | int cfg80211_wext_giwtxpower(struct net_device *dev, | ||
798 | struct iw_request_info *info, | ||
799 | union iwreq_data *data, char *extra) | ||
800 | { | ||
801 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
802 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
803 | int err, val; | ||
804 | |||
805 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | ||
806 | return -EINVAL; | ||
807 | if (data->txpower.flags & IW_TXPOW_RANGE) | ||
808 | return -EINVAL; | ||
809 | |||
810 | if (!rdev->ops->get_tx_power) | ||
811 | return -EOPNOTSUPP; | ||
812 | |||
813 | err = rdev->ops->get_tx_power(wdev->wiphy, &val); | ||
814 | /* HACK!!! */ | ||
815 | if (err && err != -ENETDOWN) | ||
816 | return err; | ||
817 | |||
818 | /* well... oh well */ | ||
819 | data->txpower.fixed = 1; | ||
820 | data->txpower.disabled = err == -ENETDOWN; | ||
821 | data->txpower.value = val; | ||
822 | data->txpower.flags = IW_TXPOW_DBM; | ||
823 | |||
824 | return 0; | ||
825 | } | ||
826 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower); | ||