2014-07-02 12:02:25

by Janusz Dziedzic

[permalink] [raw]
Subject: [PATCH] crda: db2rd, parse/print CAC time

db2rd, parse and print DFS CAC time

Signed-off-by: Janusz Dziedzic <[email protected]>
---
crda.c | 3 +++
reglib.c | 15 ++++++++++++++-
reglib.h | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/crda.c b/crda.c
index 4751a39..f40131f 100644
--- a/crda.c
+++ b/crda.c
@@ -131,6 +131,9 @@ static int put_reg_rule(const struct ieee80211_reg_rule *rule, struct nl_msg *ms
NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN, power_rule->max_antenna_gain);
NLA_PUT_U32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP, power_rule->max_eirp);

+ if (rule->dfs_cac_ms)
+ NLA_PUT_U32(msg, NL80211_ATTR_DFS_CAC_TIME, rule->dfs_cac_ms);
+
return 0;

nla_put_failure:
diff --git a/reglib.c b/reglib.c
index 6db3e75..e00e9b8 100644
--- a/reglib.c
+++ b/reglib.c
@@ -723,6 +723,11 @@ static void print_reg_rule(const struct ieee80211_reg_rule *rule)
else
printf("N/A)");

+ if (rule->dfs_cac_ms)
+ printf(", (%u)", rule->dfs_cac_ms);
+ else
+ printf(", (N/A)");
+
if (rule->flags & RRF_NO_OFDM)
printf(", NO-OFDM");
if (rule->flags & RRF_NO_CCK)
@@ -801,6 +806,7 @@ static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
char *line_p;
int hits, r = 0;
float start_freq_khz, end_freq_khz, max_bandwidth_khz, max_eirp;
+ unsigned int dfs_cac_ms = 0;

memset(line, 0, sizeof(line));
line_p = fgets(line, sizeof(line), fp);
@@ -846,8 +852,15 @@ static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)

/* Next get optional arguments (flags ...) */
strsep(&line_p, ",");
- if (line_p)
+ if (line_p) {
+ /* Check DFS CAC time */
+ hits = sscanf(line_p, " (%u)", &dfs_cac_ms);
+ if (hits == 1)
+ reg_rule->dfs_cac_ms = dfs_cac_ms;
+
+ /* Check flags */
reg_rule->flags = reglib_parse_rule_flag(line_p);
+ }

return r;
}
diff --git a/reglib.h b/reglib.h
index afd5ef6..77aa42a 100644
--- a/reglib.h
+++ b/reglib.h
@@ -28,6 +28,7 @@ struct ieee80211_reg_rule {
struct ieee80211_freq_range freq_range;
struct ieee80211_power_rule power_rule;
uint32_t flags;
+ uint32_t dfs_cac_ms;
};

struct ieee80211_regdomain {
--
1.7.9.5



2014-07-03 15:35:46

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [wireless-regdb] [PATCH] crda: db2rd, parse/print CAC time

On Thu, Jul 03, 2014 at 08:34:37AM +0200, Janusz Dziedzic wrote:
> On 3 July 2014 08:26, Janusz Dziedzic <[email protected]> wrote:
> > On 3 July 2014 00:06, Luis R. Rodriguez <[email protected]> wrote:
> >> On Wed, Jul 2, 2014 at 5:02 AM, Janusz Dziedzic
> >> <[email protected]> wrote:
> >>> db2rd, parse and print DFS CAC time
> >>>
> >>> Signed-off-by: Janusz Dziedzic <[email protected]>
> >>
> >>
> >> This doesn't print the DFS CAC if its a in a line like this:
> >>
> >> (5250 - 5330 @ 0), (20), (60000), DFS, AUTO-BW
> >>
> > will check this, BTW BW=0 is not allowed I think.
> >
>
> Did such test:
> country AE: DFS-FCC
> (2402 - 2482 @ 40), (20)
> (5170 - 5250 @ 80), (17)
> (5250 - 5330 @ 0), (24), (60000), DFS, AUTO-BW
> (5490 - 5730 @ 80), (24), DFS
> (5735 - 5835 @ 80), (30)
>
> And get:
> ./db2rd < db.txt
>
> country AE: DFS-FCC
> (2402.000 - 2482.000 @ 40.000), (20.00), (N/A)
> (5170.000 - 5250.000 @ 80.000), (17.00), (N/A)
> (5250.000 - 5330.000 @ 0.000), (24.00), (60000), DFS, AUTO-BW
> (5490.000 - 5730.000 @ 80.000), (24.00), (N/A), DFS
> (5735.000 - 5835.000 @ 80.000), (30.00), (N/A)
>
> Seems works fine. Did you install reglib, could be you are using old one?
> I am using x86_64.

Heh yeah that's the issue, sorry, patch pushed!

Luis

2014-07-03 06:34:39

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: db2rd, parse/print CAC time

On 3 July 2014 08:26, Janusz Dziedzic <[email protected]> wrote:
> On 3 July 2014 00:06, Luis R. Rodriguez <[email protected]> wrote:
>> On Wed, Jul 2, 2014 at 5:02 AM, Janusz Dziedzic
>> <[email protected]> wrote:
>>> db2rd, parse and print DFS CAC time
>>>
>>> Signed-off-by: Janusz Dziedzic <[email protected]>
>>
>>
>> This doesn't print the DFS CAC if its a in a line like this:
>>
>> (5250 - 5330 @ 0), (20), (60000), DFS, AUTO-BW
>>
> will check this, BTW BW=0 is not allowed I think.
>

Did such test:
country AE: DFS-FCC
(2402 - 2482 @ 40), (20)
(5170 - 5250 @ 80), (17)
(5250 - 5330 @ 0), (24), (60000), DFS, AUTO-BW
(5490 - 5730 @ 80), (24), DFS
(5735 - 5835 @ 80), (30)

And get:
./db2rd < db.txt

country AE: DFS-FCC
(2402.000 - 2482.000 @ 40.000), (20.00), (N/A)
(5170.000 - 5250.000 @ 80.000), (17.00), (N/A)
(5250.000 - 5330.000 @ 0.000), (24.00), (60000), DFS, AUTO-BW
(5490.000 - 5730.000 @ 80.000), (24.00), (N/A), DFS
(5735.000 - 5835.000 @ 80.000), (30.00), (N/A)

Seems works fine. Did you install reglib, could be you are using old one?
I am using x86_64.

BR
Janusz

2014-07-02 22:06:43

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH] crda: db2rd, parse/print CAC time

On Wed, Jul 2, 2014 at 5:02 AM, Janusz Dziedzic
<[email protected]> wrote:
> db2rd, parse and print DFS CAC time
>
> Signed-off-by: Janusz Dziedzic <[email protected]>


This doesn't print the DFS CAC if its a in a line like this:

(5250 - 5330 @ 0), (20), (60000), DFS, AUTO-BW

Luis

2014-07-03 06:26:42

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: [PATCH] crda: db2rd, parse/print CAC time

On 3 July 2014 00:06, Luis R. Rodriguez <[email protected]> wrote:
> On Wed, Jul 2, 2014 at 5:02 AM, Janusz Dziedzic
> <[email protected]> wrote:
>> db2rd, parse and print DFS CAC time
>>
>> Signed-off-by: Janusz Dziedzic <[email protected]>
>
>
> This doesn't print the DFS CAC if its a in a line like this:
>
> (5250 - 5330 @ 0), (20), (60000), DFS, AUTO-BW
>
will check this, BTW BW=0 is not allowed I think.

BR
Janusz