From c9b3adbbcf3489f8ba6757092b7f8a7b3ae95e5b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 7 Aug 2014 13:23:02 -0700 Subject: [PATCH] core: Request current regulatory setting when starting up --- src/wiphy.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/wiphy.c b/src/wiphy.c index e31a3d17..fd939d75 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -329,6 +329,29 @@ static void wiphy_regulatory_notify(struct l_genl_msg *msg, void *user_data) } } +static void regulatory_info_callback(struct l_genl_msg *msg, void *user_data) +{ + struct l_genl_attr attr; + uint16_t type, len; + const void *data; + + if (!l_genl_attr_init(&attr, msg)) + return; + + while (l_genl_attr_next(&attr, &type, &len, &data)) { + switch (type) { + case NL80211_ATTR_REG_ALPHA2: + if (len != 3) { + l_warn("Invalid regulatory alpha2 attribute"); + return; + } + + l_debug("Regulatory alpha2 is %s", (char *) data); + break; + } + } +} + static void protocol_features_callback(struct l_genl_msg *msg, void *user_data) { struct l_genl_attr attr; @@ -395,6 +418,12 @@ static void nl80211_appeared(void *user_data) l_error("Getting protocol features failed"); l_genl_msg_unref(msg); + msg = l_genl_msg_new(NL80211_CMD_GET_REG); + if (!l_genl_family_send(nl80211, msg, regulatory_info_callback, + NULL, NULL)) + l_error("Getting regulatory info failed"); + l_genl_msg_unref(msg); + msg = l_genl_msg_new(NL80211_CMD_GET_WIPHY); if (!l_genl_family_dump(nl80211, msg, wiphy_dump_callback, NULL, NULL)) l_error("Getting all wiphy devices failed");