5 #include <linux/types.h>
9 /* Common regulatory structures, functions and helpers */
11 /* This matches the kernel's data structures */
12 struct ieee80211_freq_range {
15 __u32 max_bandwidth_khz;
18 struct ieee80211_power_rule {
19 __u32 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 {
32 struct ieee80211_reg_rule reg_rules[];
35 static inline int is_world_regdom(const char *alpha2)
37 if (alpha2[0] == '0' && alpha2[1] == '0')
42 static inline int isalpha_upper(char letter)
44 if (letter >= 'A' && letter <= 'Z')
49 static inline int is_alpha2(const char *alpha2)
51 if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
57 static inline int is_len_2(const char *alpha2)
59 if (alpha2[0] == '\0' || (alpha2[1] == '\0'))
61 if (alpha2[2] == '\0')
66 static inline int is_valid_regdom(const char *alpha2)
68 if (!is_len_2(alpha2))
71 if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
77 static inline __u32 max(__u32 a, __u32 b)
79 return (a > b) ? a : b;
82 static inline __u32 min(__u32 a, __u32 b)
84 return (a > b) ? b : a;
87 void *crda_get_file_ptr(__u8 *db, int dblen, int structlen, __be32 ptr);
88 int crda_verify_db_signature(__u8 *db, int dblen, int siglen);
90 /* File reg db entry -> rd converstion utilities */
91 void reg_rule2rd(__u8 *db, int dblen,
92 __be32 ruleptr, struct ieee80211_reg_rule *rd_reg_rule);
93 int country2rd(__u8 *db, int dblen,
94 struct regdb_file_reg_country *country,
95 struct ieee80211_regdomain **rdp);
98 int is_valid_reg_rule(const struct ieee80211_reg_rule *rule);
99 void print_reg_rule(struct ieee80211_reg_rule *rule);
100 void print_regdom(struct ieee80211_regdomain *rd);