3 # genregdb.awk -- generate regdb.c from db.txt
5 # Actually, it reads from stdin (presumed to be db.txt) and writes
6 # to stdout (presumed to be regdb.c), but close enough...
8 # Copyright 2009 John W. Linville <linville@tuxdriver.com>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License version 2 as
12 # published by the Free Software Foundation.
19 print " * DO NOT EDIT -- file generated from data in db.txt"
22 print "#include <linux/nl80211.h>"
23 print "#include <net/cfg80211.h>"
25 regdb =
"const struct ieee80211_regdomain *reg_regdb[] = {\n"
32 !active
&& /^
[ \t]*$
/ {
36 !active
&& /country
/ {
39 printf "static const struct ieee80211_regdomain regdom_%s = {\n", country
40 printf "\t.alpha2 = \"%s\",\n", country
41 printf "\t.reg_rules = {\n"
43 regdb = regdb
"\t®dom_" country
",\n"
46 active
&& /^
[ \t]*\
(/ {
58 # power might be in mW...
65 } else if (power ==
200) {
67 } else if (power ==
500) {
69 } else if (power ==
1000) {
72 print "Unknown power value in database!"
78 split(flagstr
, flagarray
, ",")
80 for (arg in flagarray
) {
81 if (flagarray
[arg
] ==
"NO-OFDM") {
82 flags = flags
"\n\t\t\tNL80211_RRF_NO_OFDM | "
83 } else if (flagarray
[arg
] ==
"NO-CCK") {
84 flags = flags
"\n\t\t\tNL80211_RRF_NO_CCK | "
85 } else if (flagarray
[arg
] ==
"NO-INDOOR") {
86 flags = flags
"\n\t\t\tNL80211_RRF_NO_INDOOR | "
87 } else if (flagarray
[arg
] ==
"NO-OUTDOOR") {
88 flags = flags
"\n\t\t\tNL80211_RRF_NO_OUTDOOR | "
89 } else if (flagarray
[arg
] ==
"DFS") {
90 flags = flags
"\n\t\t\tNL80211_RRF_DFS | "
91 } else if (flagarray
[arg
] ==
"PTP-ONLY") {
92 flags = flags
"\n\t\t\tNL80211_RRF_PTP_ONLY | "
93 } else if (flagarray
[arg
] ==
"PTMP-ONLY") {
94 flags = flags
"\n\t\t\tNL80211_RRF_PTMP_ONLY | "
95 } else if (flagarray
[arg
] ==
"PASSIVE-SCAN") {
96 flags = flags
"\n\t\t\tNL80211_RRF_PASSIVE_SCAN | "
97 } else if (flagarray
[arg
] ==
"NO-IBSS") {
98 flags = flags
"\n\t\t\tNL80211_RRF_NO_IBSS | "
102 printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start
, end, bw
, gain
, power
, flags
106 active
&& /^
[ \t]*$
/ {
109 printf "\t.n_reg_rules = %d\n", rules
117 print "int reg_regdb_size = ARRAY_SIZE(reg_regdb);"