From owner-svn-src-all@freebsd.org Thu May 26 13:14:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA518B4B5D0; Thu, 26 May 2016 13:14:09 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9133110F6; Thu, 26 May 2016 13:14:09 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4QDE8nZ047159; Thu, 26 May 2016 13:14:08 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QDE8VT047157; Thu, 26 May 2016 13:14:08 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605261314.u4QDE8VT047157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Thu, 26 May 2016 13:14:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300738 - in head: sbin/ifconfig sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 13:14:09 -0000 Author: avos Date: Thu May 26 13:14:08 2016 New Revision: 300738 URL: https://svnweb.freebsd.org/changeset/base/300738 Log: 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 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 Modified: head/sbin/ifconfig/ifieee80211.c head/sys/net80211/ieee80211_regdomain.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Thu May 26 12:43:15 2016 (r300737) +++ head/sbin/ifconfig/ifieee80211.c Thu May 26 13:14:08 2016 (r300738) @@ -5141,6 +5141,44 @@ print_string(const u_int8_t *buf, int le } } +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, ®domain); + + /* 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) ¶ms; if (ioctl(s, SIOCIFCREATE2, ifr) < 0) err(1, "SIOCIFCREATE2"); + + setdefregdomain(s); } static Modified: head/sys/net80211/ieee80211_regdomain.c ============================================================================== --- head/sys/net80211/ieee80211_regdomain.c Thu May 26 12:43:15 2016 (r300737) +++ head/sys/net80211/ieee80211_regdomain.c Thu May 26 13:14:08 2016 (r300738) @@ -69,10 +69,7 @@ ieee80211_regdomain_attach(struct ieee80 { 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;