Commit aa5f2051 authored by Luis R. Rodriguez's avatar Luis R. Rodriguez

crda: move reglib_intersect_regdb() to reglib

There are no functional changes in this change.
Signed-off-by: 's avatarLuis R. Rodriguez <mcgrof@do-not-panic.com>
parent 73d19506
......@@ -6,69 +6,6 @@
#include "reglib.h"
/**
* reglib_intersect_regdb - intersects a regulatory database
*
* @regdb_file: the regulatory database to intersect
*
* Goes through an entire regulatory database and intersects all regulatory
* domains. This will skip any regulatory marked with an alpha2 of '00', which
* is used to indicate a world regulatory domain. If intersection is able
* to find rules that fit all regulatory domains it return a regulatory
* domain with such rules otherwise it returns NULL.
*/
const struct ieee80211_regdomain *reglib_intersect_regdb(char *regdb_file)
{
const struct ieee80211_regdomain *rd;
struct ieee80211_regdomain *prev_rd_intsct = NULL, *rd_intsct = NULL;
int intersected = 0;
unsigned int idx = 0;
reglib_for_each_country(rd, idx, regdb_file) {
if (reglib_is_world_regdom((const char *) rd->alpha2)) {
free((struct ieee80211_regdomain *) rd);
continue;
}
if (!prev_rd_intsct) {
prev_rd_intsct = (struct ieee80211_regdomain *) rd;
continue;
}
if (rd_intsct) {
free(prev_rd_intsct);
prev_rd_intsct = (struct ieee80211_regdomain *) rd_intsct;
}
rd_intsct = reglib_intersect_rds(prev_rd_intsct, rd);
if (!rd_intsct) {
free(prev_rd_intsct);
free((struct ieee80211_regdomain *) rd);
return NULL;
}
intersected++;
free((struct ieee80211_regdomain *) rd);
}
if (!idx)
return NULL;
if (intersected <= 0) {
rd_intsct = prev_rd_intsct;
prev_rd_intsct = NULL;
if (idx > 1) {
free(rd_intsct);
return NULL;
}
}
if (prev_rd_intsct)
free(prev_rd_intsct);
return rd_intsct;
}
int main(int argc, char **argv)
{
const struct ieee80211_regdomain *rd;
......
......@@ -554,6 +554,58 @@ reglib_intersect_rds(const struct ieee80211_regdomain *rd1,
return rd;
}
const struct ieee80211_regdomain *reglib_intersect_regdb(char *regdb_file)
{
const struct ieee80211_regdomain *rd;
struct ieee80211_regdomain *prev_rd_intsct = NULL, *rd_intsct = NULL;
int intersected = 0;
unsigned int idx = 0;
reglib_for_each_country(rd, idx, regdb_file) {
if (reglib_is_world_regdom((const char *) rd->alpha2)) {
free((struct ieee80211_regdomain *) rd);
continue;
}
if (!prev_rd_intsct) {
prev_rd_intsct = (struct ieee80211_regdomain *) rd;
continue;
}
if (rd_intsct) {
free(prev_rd_intsct);
prev_rd_intsct = (struct ieee80211_regdomain *) rd_intsct;
}
rd_intsct = reglib_intersect_rds(prev_rd_intsct, rd);
if (!rd_intsct) {
free(prev_rd_intsct);
free((struct ieee80211_regdomain *) rd);
return NULL;
}
intersected++;
free((struct ieee80211_regdomain *) rd);
}
if (!idx)
return NULL;
if (intersected <= 0) {
rd_intsct = prev_rd_intsct;
prev_rd_intsct = NULL;
if (idx > 1) {
free(rd_intsct);
return NULL;
}
}
if (prev_rd_intsct)
free(prev_rd_intsct);
return rd_intsct;
}
static const char *dfs_domain_name(enum regdb_dfs_regions region)
{
switch (region) {
......
......@@ -90,4 +90,17 @@ struct ieee80211_regdomain *
reglib_intersect_rds(const struct ieee80211_regdomain *rd1,
const struct ieee80211_regdomain *rd2);
/**
* reglib_intersect_regdb - intersects a regulatory database
*
* @regdb_file: the regulatory database to intersect
*
* Goes through an entire regulatory database and intersects all regulatory
* domains. This will skip any regulatory marked with an alpha2 of '00', which
* is used to indicate a world regulatory domain. If intersection is able
* to find rules that fit all regulatory domains it return a regulatory
* domain with such rules otherwise it returns NULL.
*/
const struct ieee80211_regdomain *reglib_intersect_regdb(char *regdb_file);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment