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 # Permission to use, copy, modify, and/or distribute this software for any
11 # purpose with or without fee is hereby granted, provided that the above
12 # copyright notice and this permission notice appear in all copies.
14 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 print " * DO NOT EDIT -- file generated from data in db.txt"
29 print "#include <linux/nl80211.h>"
30 print "#include <net/cfg80211.h>"
31 print "#include \"regdb.h\""
33 regdb = "const struct ieee80211_regdomain *reg_regdb[] = {\n"
40 !active && /^[ \t]*$/ {
44 !active && /country/ {
47 printf "static const struct ieee80211_regdomain regdom_%s = {\n", country
48 printf "\t.alpha2 = \"%s\",\n", country
50 printf "\t.dfs_region = NL80211_DFS_ETSI,\n"
51 else if ($NF ~ /DFS-FCC/)
52 printf "\t.dfs_region = NL80211_DFS_FCC,\n"
53 else if ($NF ~ /DFS-JP/)
54 printf "\t.dfs_region = NL80211_DFS_JP,\n"
55 printf "\t.reg_rules = {\n"
57 regdb = regdb "\t®dom_" country ",\n"
60 active && /^[ \t]*\(/ {
72 # power might be in mW...
79 } else if (power == 200) {
81 } else if (power == 500) {
83 } else if (power == 1000) {
86 print "Unknown power value in database!"
92 split(flagstr, flagarray, ",")
94 for (arg in flagarray) {
95 if (flagarray[arg] == "NO-OFDM") {
96 flags = flags "\n\t\t\tNL80211_RRF_NO_OFDM | "
97 } else if (flagarray[arg] == "NO-CCK") {
98 flags = flags "\n\t\t\tNL80211_RRF_NO_CCK | "
99 } else if (flagarray[arg] == "NO-INDOOR") {
100 flags = flags "\n\t\t\tNL80211_RRF_NO_INDOOR | "
101 } else if (flagarray[arg] == "NO-OUTDOOR") {
102 flags = flags "\n\t\t\tNL80211_RRF_NO_OUTDOOR | "
103 } else if (flagarray[arg] == "DFS") {
104 flags = flags "\n\t\t\tNL80211_RRF_DFS | "
105 } else if (flagarray[arg] == "PTP-ONLY") {
106 flags = flags "\n\t\t\tNL80211_RRF_PTP_ONLY | "
107 } else if (flagarray[arg] == "PTMP-ONLY") {
108 flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | "
109 } else if (flagarray[arg] == "PASSIVE-SCAN") {
110 flags = flags "\n\t\t\tNL80211_RRF_PASSIVE_SCAN | "
111 } else if (flagarray[arg] == "NO-IBSS") {
112 flags = flags "\n\t\t\tNL80211_RRF_NO_IBSS | "
116 printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, flags
120 active && /^[ \t]*$/ {
123 printf "\t.n_reg_rules = %d\n", rules
131 print "int reg_regdb_size = ARRAY_SIZE(reg_regdb);"