/*-1* Copyright (c) 2007-2008 Sam Leffler, Errno Consulting2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT18* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,19* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY20* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF22* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*/24#ifndef _LIB80211_REGDOMAIN_H_25#define _LIB80211_REGDOMAIN_H_2627#include <sys/cdefs.h>28#include <sys/queue.h>2930#include <net80211/ieee80211_regdomain.h>3132__BEGIN_DECLS3334struct freqband {35uint16_t freqStart; /* starting frequency (MHz) */36uint16_t freqEnd; /* ending frequency (MHz) */37uint8_t chanWidth; /* channel width (MHz) */38uint8_t chanSep; /* channel sepaaration (MHz) */39uint32_t flags; /* common operational constraints */4041const void *id;42LIST_ENTRY(freqband) next;43};4445/* private flags, don't pass to os */46#define REQ_ECM 0x1 /* enable if ECM set */47#define REQ_INDOOR 0x2 /* enable only for indoor operation */48#define REQ_OUTDOOR 0x4 /* enable only for outdoor operation */4950#define REQ_FLAGS (REQ_ECM|REQ_INDOOR|REQ_OUTDOOR)5152struct netband {53const struct freqband *band; /* channel list description */54uint8_t maxPower; /* regulatory cap on tx power (dBm) */55uint8_t maxPowerDFS; /* regulatory cap w/ DFS (dBm) */56uint8_t maxAntGain; /* max allowed antenna gain (.5 dBm) */57uint32_t flags; /* net80211 channel flags */5859LIST_ENTRY(netband) next;60};61typedef LIST_HEAD(, netband) netband_head;6263struct country;6465struct regdomain {66enum RegdomainCode sku; /* regdomain code/SKU */67const char *name; /* printable name */68const struct country *cc; /* country code for 1-1/default map */6970netband_head bands_11b; /* 11b operation */71netband_head bands_11g; /* 11g operation */72netband_head bands_11a; /* 11a operation */73netband_head bands_11ng; /* 11ng operation */74netband_head bands_11na; /* 11na operation */75netband_head bands_11ac; /* 11ac 5GHz operation */76netband_head bands_11acg; /* 11ac 2GHz operation */7778LIST_ENTRY(regdomain) next;79};8081struct country {82enum ISOCountryCode code;83#define NO_COUNTRY 0xffff84const struct regdomain *rd;85const char* isoname;86const char* name;8788LIST_ENTRY(country) next;89};9091struct ident;9293struct regdata {94LIST_HEAD(, country) countries; /* country code table */95LIST_HEAD(, regdomain) domains; /* regulatory domains */96LIST_HEAD(, freqband) freqbands; /* frequency band table */97struct ident *ident; /* identifier table */98};99100#define _PATH_REGDOMAIN "/etc/regdomain.xml"101102struct regdata *lib80211_alloc_regdata(void);103void lib80211_free_regdata(struct regdata *);104105int lib80211_regdomain_readconfig(struct regdata *, const void *, size_t);106void lib80211_regdomain_cleanup(struct regdata *);107108const struct regdomain *lib80211_regdomain_findbysku(const struct regdata *,109enum RegdomainCode);110const struct regdomain *lib80211_regdomain_findbyname(const struct regdata *,111const char *);112113const struct country *lib80211_country_findbycc(const struct regdata *,114enum ISOCountryCode);115const struct country *lib80211_country_findbyname(const struct regdata *,116const char *);117118__END_DECLS119120#endif /* _LIB80211_REGDOMAIN_H_ */121122123