crda: add nested support for libnl-3.2

Skip libnl-3.1 due to broken .pc files.

Tested to work with:
- libnl-3.2.3 (Debian 3.2.3-1)

Changes-licensed-under: ISC
Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: move country2rd() and its helper to reglib.c

Start cleaning the way we deal with reglib.c as the goal
is to make that stuff a library to be shared first in
userspace with the regulatory simulator [0]. We start
off by moving country2rd() and its helper over to
reglib.c.

[0] git://github.com/mcgrof/regsim.git

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: add a reglib iterator reglib_for_each_country()

To allow for a simple library on reglib.c we want to enable
an iterator over the regulatory database that does not have
to lock the file, or pass references to the file. We instead
add an iterator reglib_get_country_idx() which will use a
new reglib_get_country_idx(), that does an O(n) search for
each new regulatory domain it needs to read.

The trade off here is to allow for a simple reglib.c implementation
at the cost that upon each iteration reglib_get_country_idx()
we will will be opening the regdb, and verifying the db signature.
Given that the only user of this iterator is regdbdump though and
that this is used for debugging for now this is trade off I am
willing to live with.

Systems that want to use the regdb as a database for fine tuning
radio parameters dynamically and reading this file very *often*
(seconds, minutes, who knows what the future holds) may want to
consider a slight optimization of exporting the direct mmap()
through the library but we are I think light years away from that.

Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
crda: make intersect.c use reglib_for_each_country()

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: close fd upon leaving

This was never done. Do this at the end for now but soon
this will be changed in preference for the file opening
only to be done by crda for checking which file to use
to pass on to reglib for usage.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: add new reglib_get_country_alpha2()

This will be used by CRDA to find the alpha2.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: add dfs_region to the ieee80211_regdomain data structure

This will be used later once crda.c starts using the
ieee80211_regdomain data structure passed on from reglib
instead of using the mmap()'d regulatory file directly.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: make crda use reglib_get_country_alpha2()

This removes all file specific operations over to the
reglib. This also required converting the processing of the
regulatory domain from the mmap'd rules to the standard
ieee80211_regdomain data structure.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: clean header files

Remove unused headers now that we have an object
(soon to be library) using what it has to separately.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: make country2rd() static

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: make usage of regdb.h exclusive to reglib.c

The only other remaining user of regdb.h is regdbdump tool
but as I see it this utility can exist in either a reglib
library, or on each OS for its own specific adaptation of
the reglib code. For now we just make regdbump use the local
copy of nl80211.h. Later the reglib library can have its own
print / dump utility if we deem it necessary.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
crda: rename reglib_get_*() routines

reglib_get_country_idx() --> reglib_get_rd_alpha2()
reglib_get_country_alpha2() --> reglib_get_rd_alpha2()

This reflects better what we provide back out.

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>