9 /* Common regulatory structures, functions and helpers */
11 /* This matches the kernel's data structures */
12 struct ieee80211_freq_range {
13 uint32_t start_freq_khz;
14 uint32_t end_freq_khz;
15 uint32_t max_bandwidth_khz;
18 struct ieee80211_power_rule {
19 uint32_t max_antenna_gain;
23 struct ieee80211_reg_rule {
24 struct ieee80211_freq_range freq_range;
25 struct ieee80211_power_rule power_rule;
29 struct ieee80211_regdomain {
33 struct ieee80211_reg_rule reg_rules[];
36 static inline int is_world_regdom(const char *alpha2)
38 if (alpha2[0] == '0' && alpha2[1] == '0')
43 static inline int isalpha_upper(char letter)
45 if (letter >= 'A' && letter <= 'Z')
50 static inline int is_alpha2(const char *alpha2)
52 if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
57 static inline int is_valid_regdom(const char *alpha2)
59 if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
65 static inline uint32_t max(uint32_t a, uint32_t b)
67 return (a > b) ? a : b;
70 static inline uint32_t min(uint32_t a, uint32_t b)
72 return (a > b) ? b : a;
75 void *crda_get_file_ptr(uint8_t *db, int dblen, int structlen, uint32_t ptr);
76 int crda_verify_db_signature(uint8_t *db, int dblen, int siglen);
78 /* File reg db entry -> rd converstion utilities */
79 struct ieee80211_regdomain *country2rd(uint8_t *db, int dblen,
80 struct regdb_file_reg_country *country);
82 struct ieee80211_regdomain *
83 reglib_get_country_idx(unsigned int idx, const char *file);
85 #define reglib_for_each_country(__rd, __idx, __file) \
86 for (__rd = reglib_get_country_idx(__idx, __file); \
88 __rd = reglib_get_country_idx(__idx, __file), \
91 struct ieee80211_regdomain *
92 reglib_get_country_alpha2(const char *alpha2, const char *file);
95 void print_regdom(struct ieee80211_regdomain *rd);