]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl82011: Make wiphy-specific country (alpha2) available in STATUS-DRIVER
authorJouni Malinen <j@w1.fi>
Mon, 31 Dec 2018 14:41:24 +0000 (16:41 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 31 Dec 2018 14:41:24 +0000 (16:41 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
src/drivers/driver_nl80211.c

index b887eb2519d636b880c5667ef78d8d822ae8ecd5..4cf2bdae2805ee5d40b45c94d164f4c5ee30a48e 100644 (file)
@@ -8688,6 +8688,8 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen)
        struct wpa_driver_nl80211_data *drv = bss->drv;
        int res;
        char *pos, *end;
+       struct nl_msg *msg;
+       char alpha2[3] = { 0, 0, 0 };
 
        pos = buf;
        end = buf + buflen;
@@ -8832,6 +8834,23 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen)
                pos += res;
        }
 
+       msg = nlmsg_alloc();
+       if (msg &&
+           nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_REG) &&
+           nla_put_u32(msg, NL80211_ATTR_WIPHY, drv->wiphy_idx) == 0) {
+               if (send_and_recv_msgs(drv, msg, nl80211_get_country,
+                                      alpha2) == 0 &&
+                   alpha2[0]) {
+                       res = os_snprintf(pos, end - pos, "country=%s\n",
+                                         alpha2);
+                       if (os_snprintf_error(end - pos, res))
+                               return pos - buf;
+                       pos += res;
+               }
+       } else {
+               nlmsg_free(msg);
+       }
+
        return pos - buf;
 }