summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravos <avos@FreeBSD.org>2016-05-26 13:14:08 +0000
committeravos <avos@FreeBSD.org>2016-05-26 13:14:08 +0000
commit7b68b2abebc734de4ab8037e8db634937f2845f9 (patch)
tree879deddad8c09ceffb09d77ec86536b945c8a651
parente9737995b6a43920f2a0299feff3cd615aec1f72 (diff)
downloadFreeBSD-src-7b68b2abebc734de4ab8037e8db634937f2845f9.zip
FreeBSD-src-7b68b2abebc734de4ab8037e8db634937f2845f9.tar.gz
ifconfig: set by default FCC regulatory domain for wireless interfaces.
Change default regulatory domain from DEBUG (no limitations; exposes all device channels) to FCC; as a result, newly created wireless interface with default settings will have less chances to violate country-specific regulations. This change will not affect drivers with pre-initialized regdomain structure (currentry ath(4) and mwl(4)); in that case, the default channel list must correspond to the default regdomain / country setting. You can switch to another regdomain / country via corresponding ifconfig(8) options; the driver must implement ic_getradiocaps() method to restore full channel list. Full country / regdomain list may be obtained via 'ifconfig <iface> list countries' command. Example: change country to Germany: ifconfig wlan0 down # all wlans on the device must be down ifconfig wlan0 country DE ifconfig wlan0 up # wpa_supplicant(8), dhclient(8) etc At the creation time: ifconfig wlan0 create wlandev wpi0 country DE To make changes permanent add the following line to the rc.conf(5): create_args_wlan0="country DE" Tested with - Intel 3945BG (wpi(4)). - WUSB54GC (rum(4)). Reviewed by: adrian Relnotes: yes Differential Revision: https://reviews.freebsd.org/D6228
-rw-r--r--sbin/ifconfig/ifieee80211.c40
-rw-r--r--sys/net80211/ieee80211_regdomain.c3
2 files changed, 40 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 1e1e498..82c7515 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -5141,6 +5141,44 @@ print_string(const u_int8_t *buf, int len)
}
}
+static void
+setdefregdomain(int s)
+{
+ struct regdata *rdp = getregdata();
+ const struct regdomain *rd;
+
+ /* Check if regdomain/country was already set by a previous call. */
+ /* XXX is it possible? */
+ if (regdomain.regdomain != 0 ||
+ regdomain.country != CTRY_DEFAULT)
+ return;
+
+ getregdomain(s);
+
+ /* Check if it was already set by the driver. */
+ if (regdomain.regdomain != 0 ||
+ regdomain.country != CTRY_DEFAULT)
+ return;
+
+ /* Set FCC/US as default. */
+ rd = lib80211_regdomain_findbysku(rdp, SKU_FCC);
+ if (rd == NULL)
+ errx(1, "FCC regdomain was not found");
+
+ regdomain.regdomain = rd->sku;
+ if (rd->cc != NULL)
+ defaultcountry(rd);
+
+ /* Send changes to net80211. */
+ setregdomain_cb(s, &regdomain);
+
+ /* Cleanup (so it can be overriden by subsequent parameters). */
+ regdomain.regdomain = 0;
+ regdomain.country = CTRY_DEFAULT;
+ regdomain.isocc[0] = 0;
+ regdomain.isocc[1] = 0;
+}
+
/*
* Virtual AP cloning support.
*/
@@ -5162,6 +5200,8 @@ wlan_create(int s, struct ifreq *ifr)
ifr->ifr_data = (caddr_t) &params;
if (ioctl(s, SIOCIFCREATE2, ifr) < 0)
err(1, "SIOCIFCREATE2");
+
+ setdefregdomain(s);
}
static
diff --git a/sys/net80211/ieee80211_regdomain.c b/sys/net80211/ieee80211_regdomain.c
index f565a65..952208f 100644
--- a/sys/net80211/ieee80211_regdomain.c
+++ b/sys/net80211/ieee80211_regdomain.c
@@ -69,10 +69,7 @@ ieee80211_regdomain_attach(struct ieee80211com *ic)
{
if (ic->ic_regdomain.regdomain == 0 &&
ic->ic_regdomain.country == CTRY_DEFAULT) {
- ic->ic_regdomain.country = CTRY_UNITED_STATES; /* XXX */
ic->ic_regdomain.location = ' '; /* both */
- ic->ic_regdomain.isocc[0] = 'U'; /* XXX */
- ic->ic_regdomain.isocc[1] = 'S'; /* XXX */
/* NB: driver calls ieee80211_init_channels or similar */
}
ic->ic_getradiocaps = null_getradiocaps;
OpenPOWER on IntegriCloud