This lets iw parse the DFS region passed on by the kernel when one is found for the currently used regulatory domain. Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxxxxxxxx> --- reg.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/reg.c b/reg.c index c4ee1c4..4fa5bec 100644 --- a/reg.c +++ b/reg.c @@ -96,6 +96,31 @@ COMMAND(reg, set, "<ISO/IEC 3166-1 alpha2>", NL80211_CMD_REQ_SET_REG, 0, CIB_NONE, handle_reg_set, "Notify the kernel about the current regulatory domain."); +static void print_dfs_region(__u8 dfs_region) +{ + if (!dfs_region) + return; + + printf("DFS Master region: "); + + switch (dfs_region) { + case NL80211_DFS_FCC: + printf("FCC"); + break; + case NL80211_DFS_ETSI: + printf("ETSI"); + break; + case NL80211_DFS_JP: + printf("JP"); + break; + default: + printf("Uknown"); + break; + } + + printf("\n"); +} + static int print_reg_handler(struct nl_msg *msg, void *arg) { @@ -107,6 +132,7 @@ static int print_reg_handler(struct nl_msg *msg, void *arg) struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); char *alpha2; + __u8 dfs_region = 0; struct nlattr *nl_rule; int rem_rule; static struct nla_policy reg_rule_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { @@ -132,7 +158,12 @@ static int print_reg_handler(struct nl_msg *msg, void *arg) } alpha2 = nla_data(tb_msg[NL80211_ATTR_REG_ALPHA2]); + + if (tb_msg[NL80211_ATTR_DFS_REGION]) + dfs_region = nla_get_u8(tb_msg[NL80211_ATTR_DFS_REGION]); + printf("country %c%c:\n", alpha2[0], alpha2[1]); + print_dfs_region(dfs_region); nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule) { struct nlattr *tb_rule[NL80211_FREQUENCY_ATTR_MAX + 1]; -- 1.7.4.15.g7811d -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html