WiFi regulatory country database

#1

While configuring the radio0 device, you can set a country (presumably the one you currently reside), which will in turn provide you with a list of available channels based on regulatory database entries in package/kernel/mac80211/files/regdb.txt. However, the country list itself it taken from iwinfo_lib.c, which does not correlate it's list with the regdb.txt file.

There is a very similar thread that explains this problem here:

The problem with the thread is that it only mentions it as GUI bug. While in reality, if a country does not have any regulatory information about it written up in regdb.txt, it will choose the previous country regulations. (This is also quite stealthy, as the country name will actually change to what you designate it to, so you are unlikely to think that something is amiss) This might prove somewhat problematic as the channel settings could be breaking some kind of regulations.

So my question is: Should the countries without any regulatory information be listed there in the first place? The fix for this would be quite simple - simply remove the entries in iwinfo_lib.c or patch the logic to select '00' world regulatory zone by default it there is no entry about it in regdb.txt.

Edit: Upon further thought, the second patch suggestion (to default to '00') would be a tad bit difficult to provide as you would likely have to iterate over the entire regdb file to check whether the country exists or not. It seems less ninja'y and stealthy to simply remove these countries: https://pastebin.com/M2qTQFT5 (though this patch was created on an older version of OpenWrt, so might need some tweaking)

Edit #2: Here is the post where I display the problem using a month old snapshot build (it is lower down in the thread, though for ease of reading I decided to put this here as well):

1 Like
#2

Which version are you using?
It looks like maybe its 17.01 which still uses old regdb.txt inside of mac80211.
Newer version use wireless-regdb as a separate package

#3

Dunno. Though it's likely even older than that.

Any idea where I can find it? (the package) As I've spent quite some time looking for it and couldn't find it.

Edit: Upon further inspection, I have found that wireless-regdb still takes information from:
https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git

Unless I am mistaken, several countries (as an example - AG, "Antigua and Barbuda") still do not exist there, which exist in iwinfo_lib.c. Which I think still might cause problems mentioned in my initial post.

#4

If they are missing there then they need to be added.
Volunteers maintain it so if its missing and you need it then you add it.
Easiest way to find licences for 2.4, 5 and 60 GHz spectrum that is most likely regulated by one of government agencies and use some other country as a template and edit it accordingly.

Also, as far as that bug is concerned since you are using and ancient version its most likely already fixed

#5

I will try to flash a new version today/tomorrow, to check whether the bug I am talking about has persisted throughout the versions or whether it was fixed. The problem is that I don't really understand how it could have been fixed without stealthily changing the regulatory zone to '00' (world), as the entries there still do not exist and the countries that I removed in my patch do exist in the build.

When I have some free time, I will try to add the leftover countries, though it will probably be a long-term project, because it does seem quite difficult to do.

#6

You dont have to add all of the remaing countries, for starters add yours.
World is just used as a neutral default

#7

I managed to get my hands on a router that is currently running an OpenWRT Snapshot build.

iw-reg-get

config-wireless

wireless-conf

Version: OpenWrt SNAPSHOT r9730-ae9d3a25c2 / LuCI Master (git-19.079.18950-11e64f8)

This is the problem I was talking about. You change to a country without an existing regulatory entry and it will still be stuck with the previous country that you have selected. Apparently it still exists, even in newer OpenWRT versions. It also does not seem to default to '00' (world).

Edit: To clarify on the last bit of the post. In the first place, it is hard to tell, from LuCI and the WebUI in general, whether the country you have picked has a regulatory entry about it or not as there isn't any list you can correlate to. (which in itself is somewhat of a problem) Due to this, 'defaulting to 00' wouldn't really work, as you have to wait for the wireless device to reload before you can view if it has changed or not.

#8

Well, it makes sense.
If there is no regulatory information for that country then it makes sense for a last valid entry to remain.
I dont see its a bug when there is no regulatory information for you selection.

#9

The problem is how can you tell that your country does not have regulatory information about it, unless you're one of the few people that bothered to check the regulatory database in the first place?

Additionally, considering the country selection (AFAIK) is only used for setting the regulatory information for the radio0 device, it makes no sense to include countries in it that do not have any regulatory information about them in the first place.

IMO, it would make much more sense to simply remove them, which would prompt the user to use '00' (world) as an alternative. Another option is to default back to world. Though unless I am mistaken, you cannot get this information easily before you switch to the non-existing regulatory zone which requires the interface to load.

#10

Hm, maybe there is an issue.
LuCi is polling iw for country list.
Can you manually check with iw what regulatory domains are offered?

#11

I am fairly sure you do not have access to the regdb country list and to be quite fair, even if you did, you would have to iterate throughout quite an extensive list to check. (for loop inside of a for loop at the minimum with the worst case scenario being ~170 * ~100, unless you do it after a user has selected a country, though that would require JavaScript or some custom .parse() or .validate() method) That is, if you would want to filter out the countries shown to the user in LuCI.