1 #include <linux/types.h>
4 * WARNING: This file needs to be kept in sync with
5 * - the parser (dbparse.py)
6 * - the generator code (db2bin.py)
10 #define REGDB_MAGIC 0x52474442
13 * Only supported version now, start at arbitrary number
14 * to have some more magic. We still consider this to be
15 * "Version 1" of the file.
17 #define REGDB_VERSION 19
20 * The signature at the end of the file is an RSA-signed
21 * SHA-1 hash of the file.
24 /* db file starts with a struct regdb_file_header */
26 struct regdb_file_header {
27 /* must be REGDB_MAGIC */
29 /* must be REGDB_VERSION */
32 * Pointer (offset) into file where country list starts
33 * and number of countries. The country list is sorted
34 * alphabetically to allow binary searching (should it
35 * become really huge). Each country is described by a
36 * struct regdb_file_reg_country.
38 __be32 reg_country_ptr;
39 __be32 reg_country_num;
40 /* length (in bytes) of the signature at the end of the file */
41 __be32 signature_length;
44 struct regdb_file_freq_range {
45 __be32 start_freq, /* in kHz */
46 end_freq, /* in kHz */
47 max_bandwidth; /* in kHz */
51 * Values of zero mean "not applicable", i.e. the regulatory
52 * does not limit a certain value.
54 struct regdb_file_power_rule {
55 /* antenna gain is in mBi (100 * dBi) */
56 __be32 max_antenna_gain;
57 /* this is in mBm (100 * dBm) */
61 /* must match <linux/nl80211.h> enum nl80211_reg_rule_flags */
64 RRF_NO_OFDM = 1<<0, /* OFDM modulation not allowed */
65 RRF_NO_CCK = 1<<1, /* CCK modulation not allowed */
66 RRF_NO_INDOOR = 1<<2, /* indoor operation not allowed */
67 RRF_NO_OUTDOOR = 1<<3, /* outdoor operation not allowed */
68 RRF_DFS = 1<<4, /* DFS support is required to be
70 RRF_PTP_ONLY = 1<<5, /* this is only for Point To Point
72 RRF_PTMP_ONLY = 1<<6, /* this is only for Point To Multi
74 RRF_PASSIVE_SCAN = 1<<7, /* passive scan is required */
75 RRF_NO_IBSS = 1<<8, /* IBSS is not allowed */
78 struct regdb_file_reg_rule {
79 /* pointers (offsets) into the file */
80 __be32 freq_range_ptr; /* pointer to a struct regdb_file_freq_range */
81 __be32 power_rule_ptr; /* pointer to a struct regdb_file_power_rule */
82 /* rule flags using enum reg_rule_flags */
86 struct regdb_file_reg_rules_collection {
88 /* pointers (offsets) into the file. There are reg_rule_num elements
89 * in the reg_rule_ptrs array pointing to struct
90 * regdb_file_reg_rule */
91 __be32 reg_rule_ptrs[];
94 struct regdb_file_reg_country {
97 /* pointer (offset) into the file to a struct
98 * regdb_file_reg_rules_collection */
99 __be32 reg_collection_ptr;
104 void *crda_get_file_ptr(__u8 *db, int dblen, int structlen, __be32 ptr);
105 int crda_verify_db_signature(__u8 *db, int dblen, int siglen);
109 * Verify that no unexpected padding is added to structures
113 #define ERROR_ON(cond) \
114 ((void)sizeof(char[1 - 2*!!(cond)]))
116 #define CHECK_STRUCT(name, size) \
117 ERROR_ON(sizeof(struct name) != size)
119 static inline void check_db_binary_structs(void)
121 CHECK_STRUCT(regdb_file_header, 20);
122 CHECK_STRUCT(regdb_file_freq_range, 12);
123 CHECK_STRUCT(regdb_file_power_rule, 8);
124 CHECK_STRUCT(regdb_file_reg_rule, 12);
125 CHECK_STRUCT(regdb_file_reg_rules_collection, 4);
126 CHECK_STRUCT(regdb_file_reg_country, 8);