core: Request current regulatory setting when starting up

This commit is contained in:
Marcel Holtmann 2014-08-07 13:23:02 -07:00
parent a17584e680
commit c9b3adbbcf
1 changed files with 29 additions and 0 deletions

View File

@ -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");