Browse Source

Do not use country_code default (was: US)

If country_code is not included in hostapd.conf, refuse to enable IEEE
802.11d and do not try to set the regulatory domain in kernel.
Jouni Malinen 16 years ago
parent
commit
6f4071c084
3 changed files with 15 additions and 10 deletions
  1. 6 2
      hostapd/config.c
  2. 7 5
      hostapd/hostapd.c
  3. 2 3
      hostapd/hostapd.conf

+ 6 - 2
hostapd/config.c

@@ -250,8 +250,6 @@ static struct hostapd_config * hostapd_config_defaults(void)
 	conf->send_probe_response = 1;
 	conf->bridge_packets = INTERNAL_BRIDGE_DO_NOT_CONTROL;
 
-	os_memcpy(conf->country, "US ", 3);
-
 	for (i = 0; i < NUM_TX_QUEUES; i++)
 		conf->tx_queue[i].aifs = -1; /* use hw default */
 
@@ -970,6 +968,12 @@ static int hostapd_config_check(struct hostapd_config *conf)
 {
 	size_t i;
 
+	if (conf->ieee80211d && (!conf->country[0] || !conf->country[1])) {
+		wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
+			   "setting the country_code");
+		return -1;
+	}
+
 	for (i = 0; i < conf->num_bss; i++) {
 		if (hostapd_config_check_bss(&conf->bss[i], conf))
 			return -1;

+ 7 - 5
hostapd/hostapd.c

@@ -1478,11 +1478,13 @@ static int setup_interface(struct hostapd_iface *iface)
 		      OP_MODE_PURE);
 #endif /* CONFIG_IEEE80211N */
 
-	os_memcpy(country, hapd->iconf->country, 3);
-	country[3] = '\0';
-	if (hostapd_set_country(hapd, country) < 0) {
-		wpa_printf(MSG_ERROR, "Failed to set country code");
-		return -1;
+	if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
+		os_memcpy(country, hapd->iconf->country, 3);
+		country[3] = '\0';
+		if (hostapd_set_country(hapd, country) < 0) {
+			wpa_printf(MSG_ERROR, "Failed to set country code");
+			return -1;
+		}
 	}
 
 	if (hapd->iconf->ieee80211d &&

+ 2 - 3
hostapd/hostapd.conf

@@ -77,10 +77,9 @@ ctrl_interface_group=0
 # SSID to be used in IEEE 802.11 management frames
 ssid=test
 
-# Country code (ISO/IEC 3166-1).  Used to set regulatory domain.
-# Modify as needed to indicate country in which device is operating.
+# Country code (ISO/IEC 3166-1). Used to set regulatory domain.
+# Set as needed to indicate country in which device is operating.
 # This can limit available channels and transmit power.
-# (default: US)
 #country_code=US
 
 # Enable IEEE 802.11d. This advertises the country_code and the set of allowed