aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@Atheros.com>2008-12-09 20:11:14 (GMT)
committerJouni Malinen <j@w1.fi>2008-12-09 20:11:14 (GMT)
commit6d1584905c5897aa1ce117cb4e6b16d28a0f397f (patch)
tree2d41f08708e9e19f1dac606fdec5bee691686f2d /wpa_supplicant
parent556f5a2a281dc725f16cbf986c3f17aff4115e13 (diff)
downloadhostap-06-6d1584905c5897aa1ce117cb4e6b16d28a0f397f.zip
hostap-06-6d1584905c5897aa1ce117cb4e6b16d28a0f397f.tar.gz
hostap-06-6d1584905c5897aa1ce117cb4e6b16d28a0f397f.tar.bz2
wpa_supplicant: Add support for setting of a regulatory domain
This adds support for setting of a regulatory domain to wpa_supplicant drivers. It also adds regulatory domain setting for the nl80211 driver. We expect an ISO / IEC 3166 alpha2 in the wpa configuration file as a global.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/config.h8
-rw-r--r--wpa_supplicant/config_file.c21
-rw-r--r--wpa_supplicant/wpa_supplicant.c6
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h8
4 files changed, 43 insertions, 0 deletions
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index b05576d..3ec2a01 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -252,6 +252,14 @@ struct wpa_config {
* uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
*/
u8 uuid[16];
+
+ /**
+ * alpha2 - Country code
+ *
+ * This is the ISO/IEC alpha2 country code for which we are operating
+ * in
+ */
+ char alpha2[2];
};
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index acc9ee5..09d6a67 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -270,6 +270,20 @@ static int wpa_config_process_blob(struct wpa_config *config, FILE *f,
#endif /* CONFIG_NO_CONFIG_BLOBS */
+static int wpa_config_process_country(struct wpa_config *config, char *pos)
+{
+ if (!pos[0] || !pos[1]) {
+ wpa_printf(MSG_DEBUG, "Invalid country set");
+ return -1;
+ }
+ config->alpha2[0] = pos[0];
+ config->alpha2[1] = pos[1];
+ wpa_printf(MSG_DEBUG, "country='%c%c'",
+ config->alpha2[0], config->alpha2[1]);
+ return 0;
+}
+
+
#ifdef CONFIG_CTRL_IFACE
static int wpa_config_process_ctrl_interface(struct wpa_config *config,
char *pos)
@@ -503,6 +517,9 @@ static int wpa_config_process_global(struct wpa_config *config, char *pos,
return wpa_config_process_uuid(config, line, pos + 5);
#endif /* CONFIG_WPS */
+ if (os_strncmp(pos, "country=", 8) == 0)
+ return wpa_config_process_country(config, pos + 8);
+
return -1;
}
@@ -874,6 +891,10 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
fprintf(f, "uuid=%s\n", buf);
}
#endif /* CONFIG_WPS */
+ if (config->alpha2[0] && config->alpha2[1]) {
+ fprintf(f, "country=%c%c\n",
+ config->alpha2[0], config->alpha2[1]);
+ }
}
#endif /* CONFIG_NO_CONFIG_WRITE */
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 00d20c9..c3e7dbd 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1790,6 +1790,12 @@ static int wpa_supplicant_init_iface2(struct wpa_supplicant *wpa_s)
if (wpa_supplicant_driver_init(wpa_s) < 0)
return -1;
+ if (wpa_s->conf->alpha2[0] && wpa_s->conf->alpha2[1] &&
+ wpa_drv_set_country(wpa_s, wpa_s->conf->alpha2)) {
+ wpa_printf(MSG_DEBUG, "Failed to set country");
+ return -1;
+ }
+
wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
if (wpas_wps_init(wpa_s))
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index ab7aa94..3232198 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -676,6 +676,14 @@ static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
return -1;
}
+static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
+ const char *alpha2)
+{
+ if (wpa_s->driver->set_country)
+ return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
+ return 0;
+}
+
static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
const u8 *data, size_t data_len)
{