xref: /freebsd/lib/lib80211/lib80211_regdomain.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1 /*-
2  * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef _LIB80211_REGDOMAIN_H_
26 #define _LIB80211_REGDOMAIN_H_
27 
28 #include <sys/cdefs.h>
29 #include <sys/queue.h>
30 
31 #include <net80211/ieee80211_regdomain.h>
32 
33 __BEGIN_DECLS
34 
35 struct freqband {
36 	uint16_t	freqStart;	/* starting frequency (MHz) */
37 	uint16_t	freqEnd;	/* ending frequency (MHz) */
38 	uint8_t		chanWidth;	/* channel width (MHz) */
39 	uint8_t		chanSep;	/* channel sepaaration (MHz) */
40 	uint32_t	flags;		/* common operational constraints */
41 
42 	const void	*id;
43 	LIST_ENTRY(freqband) next;
44 };
45 
46 /* private flags, don't pass to os */
47 #define	REQ_ECM		0x1		/* enable if ECM set */
48 #define	REQ_INDOOR	0x2		/* enable only for indoor operation */
49 #define	REQ_OUTDOOR	0x4		/* enable only for outdoor operation */
50 
51 #define	REQ_FLAGS	(REQ_ECM|REQ_INDOOR|REQ_OUTDOOR)
52 
53 struct netband {
54 	const struct freqband *band;	/* channel list description */
55 	uint8_t		maxPower;	/* regulatory cap on tx power (dBm) */
56 	uint8_t		maxPowerDFS;	/* regulatory cap w/ DFS (dBm) */
57 	uint8_t		maxAntGain;	/* max allowed antenna gain (.5 dBm) */
58 	uint32_t	flags;		/* net80211 channel flags */
59 
60 	LIST_ENTRY(netband) next;
61 };
62 typedef LIST_HEAD(, netband) netband_head;
63 
64 struct country;
65 
66 struct regdomain {
67 	enum RegdomainCode	sku;	/* regdomain code/SKU */
68 	const char		*name;	/* printable name */
69 	const struct country	*cc;	/* country code for 1-1/default map */
70 
71 	netband_head	 bands_11b;	/* 11b operation */
72 	netband_head	 bands_11g;	/* 11g operation */
73 	netband_head	 bands_11a;	/* 11a operation */
74 	netband_head	 bands_11ng;	/* 11ng operation */
75 	netband_head	 bands_11na;	/* 11na operation */
76 	netband_head	 bands_11ac;	/* 11ac 5GHz operation */
77 	netband_head	 bands_11acg;	/* 11ac 2GHz operation */
78 
79 	LIST_ENTRY(regdomain)	next;
80 };
81 
82 struct country {
83 	enum ISOCountryCode	code;
84 #define	NO_COUNTRY	0xffff
85 	const struct regdomain	*rd;
86 	const char*		isoname;
87 	const char*		name;
88 
89 	LIST_ENTRY(country)	next;
90 };
91 
92 struct ident;
93 
94 struct regdata {
95 	LIST_HEAD(, country)	countries;	/* country code table */
96 	LIST_HEAD(, regdomain)	domains;	/* regulatory domains */
97 	LIST_HEAD(, freqband)	freqbands;	/* frequency band table */
98 	struct ident		*ident;		/* identifier table */
99 };
100 
101 #define	_PATH_REGDOMAIN	"/etc/regdomain.xml"
102 
103 struct regdata *lib80211_alloc_regdata(void);
104 void	lib80211_free_regdata(struct regdata *);
105 
106 int	lib80211_regdomain_readconfig(struct regdata *, const void *, size_t);
107 void	lib80211_regdomain_cleanup(struct regdata *);
108 
109 const struct regdomain *lib80211_regdomain_findbysku(const struct regdata *,
110 	enum RegdomainCode);
111 const struct regdomain *lib80211_regdomain_findbyname(const struct regdata *,
112 	const char *);
113 
114 const struct country *lib80211_country_findbycc(const struct regdata *,
115 	enum ISOCountryCode);
116 const struct country *lib80211_country_findbyname(const struct regdata *,
117 	const char *);
118 
119 __END_DECLS
120 
121 #endif /* _LIB80211_REGDOMAIN_H_ */
122