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>"
24 print "#include \"regdb.h\""
26 regdb = "const struct ieee80211_regdomain *reg_regdb[] = {\n"
33 !active && /^[ \t]*$/ {
37 !active && /country/ {
40 printf "static const struct ieee80211_regdomain regdom_%s = {\n", country
41 printf "\t.alpha2 = \"%s\",\n", country
42 printf "\t.reg_rules = {\n"
44 regdb = regdb "\t®dom_" country ",\n"
47 active && /^[ \t]*\(/ {
59 # power might be in mW...
66 } else if (power == 200) {
68 } else if (power == 500) {
70 } else if (power == 1000) {
73 print "Unknown power value in database!"
79 split(flagstr, flagarray, ",")
81 for (arg in flagarray) {
82 if (flagarray[arg] == "NO-OFDM") {
83 flags = flags "\n\t\t\tNL80211_RRF_NO_OFDM | "
84 } else if (flagarray[arg] == "NO-CCK") {
85 flags = flags "\n\t\t\tNL80211_RRF_NO_CCK | "
86 } else if (flagarray[arg] == "NO-INDOOR") {
87 flags = flags "\n\t\t\tNL80211_RRF_NO_INDOOR | "
88 } else if (flagarray[arg] == "NO-OUTDOOR") {
89 flags = flags "\n\t\t\tNL80211_RRF_NO_OUTDOOR | "
90 } else if (flagarray[arg] == "DFS") {
91 flags = flags "\n\t\t\tNL80211_RRF_DFS | "
92 } else if (flagarray[arg] == "PTP-ONLY") {
93 flags = flags "\n\t\t\tNL80211_RRF_PTP_ONLY | "
94 } else if (flagarray[arg] == "PTMP-ONLY") {
95 flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | "
96 } else if (flagarray[arg] == "PASSIVE-SCAN") {
97 flags = flags "\n\t\t\tNL80211_RRF_PASSIVE_SCAN | "
98 } else if (flagarray[arg] == "NO-IBSS") {
99 flags = flags "\n\t\t\tNL80211_RRF_NO_IBSS | "
103 printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, flags
107 active && /^[ \t]*$/ {
110 printf "\t.n_reg_rules = %d\n", rules
118 print "int reg_regdb_size = ARRAY_SIZE(reg_regdb);"