From d6c9d4740bb2058f816317a385f90d078e7830c6 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 25 Nov 2008 12:10:35 +0200 Subject: [PATCH] driver_nl80211: Added set_country() handler 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 " is not needed anymore when using hostapd. --- hostapd/driver_nl80211.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hostapd/driver_nl80211.c b/hostapd/driver_nl80211.c index bcbbcd79b..3fcb4dd36 100644 --- a/hostapd/driver_nl80211.c +++ b/hostapd/driver_nl80211.c @@ -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, };