]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
driver_nl80211: Added set_country() handler
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 25 Nov 2008 10:10:35 +0000 (12:10 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 25 Nov 2008 10:10:35 +0000 (12:10 +0200)
If country_code is set in hostapd.conf, hostapd will now update nl80211
regulatory data by setting the alpha2 string for CRDA. In other words,
"iw reg set <alpha2>" is not needed anymore when using hostapd.

hostapd/driver_nl80211.c

index bcbbcd79b9562b5bfcb3f94590a72e4b51bc629f..3fcb4dd36234855c5feadb5ab0d1ff2a88d38dfb 100644 (file)
@@ -1510,6 +1510,30 @@ static int i802_set_sta_vlan(void *priv, const u8 *addr,
 }
 
 
+static int i802_set_country(void *priv, const char *country)
+{
+       struct i802_driver_data *drv = priv;
+       struct nl_msg *msg;
+       char alpha2[3];
+
+       msg = nlmsg_alloc();
+       if (!msg)
+               return -ENOMEM;
+
+       genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
+                   0, NL80211_CMD_REQ_SET_REG, 0);
+
+       alpha2[0] = country[0];
+       alpha2[1] = country[1];
+       alpha2[2] = '\0';
+       NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, alpha2);
+
+       return send_and_recv_msgs(drv, msg, NULL, NULL);
+ nla_put_failure:
+       return -ENOBUFS;
+}
+
+
 static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
 {
        struct sta_info *sta;
@@ -2402,4 +2426,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .if_remove = i802_if_remove,
        .get_hw_feature_data = i802_get_hw_feature_data,
        .set_sta_vlan = i802_set_sta_vlan,
+       .set_country = i802_set_country,
 };