Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278215
b: refs/heads/master
c: 8b60b07
h: refs/heads/master
i:
  278213: a0884f7
  278211: 727f5de
  278207: 3448c4a
v: v3
  • Loading branch information
Luis R. Rodriguez authored and John W. Linville committed Nov 21, 2011
1 parent 80fc358 commit 10809c7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4713e962c5d98901890c446843ae4e0a9d37b7b3
refs/heads/master: 8b60b07805d557542160d852874fa6a1b969184e
21 changes: 21 additions & 0 deletions trunk/include/linux/nl80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,10 @@ enum nl80211_commands {
* probe-response frame. The DA field in the 802.11 header is zero-ed out,
* to be filled by the FW.
*
* @NL80211_ATTR_DFS_REGION: region for regulatory rules which this country
* abides to when initiating radiation on DFS channels. A country maps
* to one DFS region.
*
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
Expand Down Expand Up @@ -1408,6 +1412,8 @@ enum nl80211_attrs {

NL80211_ATTR_PROBE_RESP,

NL80211_ATTR_DFS_REGION,

/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
Expand Down Expand Up @@ -1916,6 +1922,21 @@ enum nl80211_reg_rule_flags {
NL80211_RRF_NO_IBSS = 1<<8,
};

/**
* enum nl80211_dfs_regions - regulatory DFS regions
*
* @NL80211_DFS_UNSET: Country has no DFS master region specified
* @NL80211_DFS_FCC_: Country follows DFS master rules from FCC
* @NL80211_DFS_FCC_: Country follows DFS master rules from ETSI
* @NL80211_DFS_JP_: Country follows DFS master rules from JP/MKK/Telec
*/
enum nl80211_dfs_regions {
NL80211_DFS_UNSET = 0,
NL80211_DFS_FCC = 1,
NL80211_DFS_ETSI = 2,
NL80211_DFS_JP = 3,
};

/**
* enum nl80211_survey_info - survey information
*
Expand Down
1 change: 1 addition & 0 deletions trunk/include/net/regulatory.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct ieee80211_reg_rule {
struct ieee80211_regdomain {
u32 n_reg_rules;
char alpha2[2];
u8 dfs_region;
struct ieee80211_reg_rule reg_rules[];
};

Expand Down
15 changes: 15 additions & 0 deletions trunk/net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
[NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG },
[NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY,
.len = IEEE80211_MAX_DATA_LEN },
[NL80211_ATTR_DFS_REGION] = { .type = NLA_U8 },
};

/* policy for the key attributes */
Expand Down Expand Up @@ -3382,6 +3383,9 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)

NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2,
cfg80211_regdomain->alpha2);
if (cfg80211_regdomain->dfs_region)
NLA_PUT_U8(msg, NL80211_ATTR_DFS_REGION,
cfg80211_regdomain->dfs_region);

nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES);
if (!nl_reg_rules)
Expand Down Expand Up @@ -3440,6 +3444,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
char *alpha2 = NULL;
int rem_reg_rules = 0, r = 0;
u32 num_rules = 0, rule_idx = 0, size_of_regd;
u8 dfs_region = 0;
struct ieee80211_regdomain *rd = NULL;

if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
Expand All @@ -3450,6 +3455,9 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)

alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);

if (info->attrs[NL80211_ATTR_DFS_REGION])
dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]);

nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
rem_reg_rules) {
num_rules++;
Expand Down Expand Up @@ -3477,6 +3485,13 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
rd->alpha2[0] = alpha2[0];
rd->alpha2[1] = alpha2[1];

/*
* Disable DFS master mode if the DFS region was
* not supported or known on this kernel.
*/
if (reg_supported_dfs_region(dfs_region))
rd->dfs_region = dfs_region;

nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
rem_reg_rules) {
nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
Expand Down
37 changes: 37 additions & 0 deletions trunk/net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,42 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd)
}
}

bool reg_supported_dfs_region(u8 dfs_region)
{
switch (dfs_region) {
case NL80211_DFS_UNSET:
case NL80211_DFS_FCC:
case NL80211_DFS_ETSI:
case NL80211_DFS_JP:
return true;
default:
REG_DBG_PRINT("Ignoring uknown DFS master region: %d\n",
dfs_region);
return false;
}
}

static void print_dfs_region(u8 dfs_region)
{
if (!dfs_region)
return;

switch (dfs_region) {
case NL80211_DFS_FCC:
pr_info(" DFS Master region FCC");
break;
case NL80211_DFS_ETSI:
pr_info(" DFS Master region ETSI");
break;
case NL80211_DFS_JP:
pr_info(" DFS Master region JP");
break;
default:
pr_info(" DFS Master region Uknown");
break;
}
}

static void print_regdomain(const struct ieee80211_regdomain *rd)
{

Expand Down Expand Up @@ -1973,6 +2009,7 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
pr_info("Regulatory domain changed to country: %c%c\n",
rd->alpha2[0], rd->alpha2[1]);
}
print_dfs_region(rd->dfs_region);
print_rd_rules(rd);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/net/wireless/reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern const struct ieee80211_regdomain *cfg80211_regdomain;

bool is_world_regdom(const char *alpha2);
bool reg_is_valid_request(const char *alpha2);
bool reg_supported_dfs_region(u8 dfs_region);

int regulatory_hint_user(const char *alpha2);

Expand Down

0 comments on commit 10809c7

Please sign in to comment.