regdomain.h revision 178354
1178354Ssam/*- 2178354Ssam * Copyright (c) 2007-2008 Sam Leffler, Errno Consulting 3178354Ssam * All rights reserved. 4178354Ssam * 5178354Ssam * Redistribution and use in source and binary forms, with or without 6178354Ssam * modification, are permitted provided that the following conditions 7178354Ssam * are met: 8178354Ssam * 1. Redistributions of source code must retain the above copyright 9178354Ssam * notice, this list of conditions and the following disclaimer. 10178354Ssam * 2. Redistributions in binary form must reproduce the above copyright 11178354Ssam * notice, this list of conditions and the following disclaimer in the 12178354Ssam * documentation and/or other materials provided with the distribution. 13178354Ssam * 14178354Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15178354Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16178354Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17178354Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18178354Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19178354Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20178354Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21178354Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22178354Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23178354Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24178354Ssam * 25178354Ssam * $FreeBSD: head/sbin/ifconfig/regdomain.h 178354 2008-04-20 20:35:46Z sam $ 26178354Ssam */ 27178354Ssam#ifndef _LIB80211_H_ 28178354Ssam#define _LIB80211_H_ 29178354Ssam 30178354Ssam#include <sys/cdefs.h> 31178354Ssam#include <sys/queue.h> 32178354Ssam 33178354Ssam#include <net80211/ieee80211_regdomain.h> 34178354Ssam 35178354Ssam__BEGIN_DECLS 36178354Ssam 37178354Ssamstruct freqband { 38178354Ssam uint16_t freqStart; /* starting frequency (MHz) */ 39178354Ssam uint16_t freqEnd; /* ending frequency (MHz) */ 40178354Ssam uint8_t chanWidth; /* channel width (MHz) */ 41178354Ssam uint8_t chanSep; /* channel sepaaration (MHz) */ 42178354Ssam uint32_t flags; /* common operational constraints */ 43178354Ssam 44178354Ssam const void *id; 45178354Ssam LIST_ENTRY(freqband) next; 46178354Ssam}; 47178354Ssam 48178354Ssamstruct netband { 49178354Ssam const struct freqband *band; /* channel list description */ 50178354Ssam uint8_t maxPower; /* regulatory cap on tx power (dBm) */ 51178354Ssam uint8_t maxPowerDFS; /* regulatory cap w/ DFS (dBm) */ 52178354Ssam uint32_t flags; /* net80211 channel flags */ 53178354Ssam 54178354Ssam LIST_ENTRY(netband) next; 55178354Ssam}; 56178354Ssamtypedef LIST_HEAD(, netband) netband_head; 57178354Ssam 58178354Ssamstruct country; 59178354Ssam 60178354Ssamstruct regdomain { 61178354Ssam enum RegdomainCode sku; /* regdomain code/SKU */ 62178354Ssam const char *name; /* printable name */ 63178354Ssam const struct country *cc; /* country code for 1-1/default map */ 64178354Ssam 65178354Ssam netband_head bands_11b; /* 11b operation */ 66178354Ssam netband_head bands_11g; /* 11g operation */ 67178354Ssam netband_head bands_11a; /* 11a operation */ 68178354Ssam netband_head bands_11ng;/* 11ng operation */ 69178354Ssam netband_head bands_11na;/* 11na operation */ 70178354Ssam 71178354Ssam LIST_ENTRY(regdomain) next; 72178354Ssam}; 73178354Ssam 74178354Ssamstruct country { 75178354Ssam enum ISOCountryCode code; 76178354Ssam const struct regdomain *rd; 77178354Ssam const char* isoname; 78178354Ssam const char* name; 79178354Ssam 80178354Ssam LIST_ENTRY(country) next; 81178354Ssam}; 82178354Ssam 83178354Ssamstruct ident; 84178354Ssam 85178354Ssamstruct regdata { 86178354Ssam LIST_HEAD(, country) countries; /* country code table */ 87178354Ssam LIST_HEAD(, regdomain) domains; /* regulatory domains */ 88178354Ssam LIST_HEAD(, freqband) freqbands; /* frequency band table */ 89178354Ssam struct ident *ident; /* identifier table */ 90178354Ssam}; 91178354Ssam 92178354Ssam#define _PATH_REGDOMAIN "/etc/regdomain.xml" 93178354Ssam 94178354Ssamstruct regdata *lib80211_alloc_regdata(void); 95178354Ssamvoid lib80211_free_regdata(struct regdata *); 96178354Ssam 97178354Ssamint lib80211_regdomain_readconfig(struct regdata *, const void *, size_t); 98178354Ssamvoid lib80211_regdomain_cleanup(struct regdata *); 99178354Ssam 100178354Ssamconst struct regdomain *lib80211_regdomain_findbysku(const struct regdata *, 101178354Ssam enum RegdomainCode); 102178354Ssamconst struct regdomain *lib80211_regdomain_findbyname(const struct regdata *, 103178354Ssam const char *); 104178354Ssam 105178354Ssamconst struct country *lib80211_country_findbycc(const struct regdata *, 106178354Ssam enum ISOCountryCode); 107178354Ssamconst struct country *lib80211_country_findbyname(const struct regdata *, 108178354Ssam const char *); 109178354Ssam 110178354Ssam__END_DECLS 111178354Ssam 112178354Ssam#endif /* _LIB80211_H_ */ 113