feat: add support for setting/getting the wireless regulatory region#162
feat: add support for setting/getting the wireless regulatory region#162tomasff wants to merge 4 commits into
Conversation
|
Hi @SuperQ @nickgarlis - sorry for the direct ping, tried to add you as reviewer but GH won't let me 😅 Let me know what you think - thanks! |
|
Hi @tomasff I don't see any reason why this shouldn't be part of the package. Do you think it'd be possible to add some integration tests for it ? Not sure what would be the best way to test it but I believe |
| } | ||
| } | ||
|
|
||
| func TestClient_SetRegulatoryRegion(t *testing.T) { |
There was a problem hiding this comment.
Intentionally simple as we cannot assume the regulatory database is available.
Could maybe check the region after with the caveat that the test may be flaky if the regulatory DB is not available.
|
Thanks! Included a |
| // See | ||
| // - https://wireless.docs.kernel.org/en/latest/en/developers/regulatory/wireless-regdb.html | ||
| // - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/wireless/nl80211.c?h=a55f7f5f29b32c2c53cc291899cf9b0c25a07f7c#n9920 | ||
| func (c *client) GetRegulatoryDomain() (*RegulatoryDomain, error) { |
There was a problem hiding this comment.
This supports specifying the radio instead of globally scoped, however, given SetRegulatoryRegion is already globally scopped it seemed appropriate to make it consistent.
If needed, we can add a GetInterfaceRegulatoryDomain(*Interface) later and extract this to a common handler - let me know what you think
| // region must be an ISO 3166-1 alpha-2 country code (e.g. "GB" or "US"). | ||
| // | ||
| // See https://wireless.docs.kernel.org/en/latest/en/developers/regulatory/wireless-regdb.html | ||
| func (c *client) SetRegulatoryRegion(region string, hint RegulatoryHint) error { |
There was a problem hiding this comment.
Would it make sense for SetRegulatoryRegion to accept a struct in case it ever accepts more attributes ?
I had a look at net/wireless/nl80211.c and it seems like more attributes are used ? Can you double check ? I am not familiar with this family but it seems like it's one of the less documented ones.
There was a problem hiding this comment.
Also worth checking for the rest of the requests
There was a problem hiding this comment.
The one currently implemented only has the hint, the one linked is very similar but slightly different 😅
This also tripped me up while I was reading, there's nl80211_req_set_reg and nl80211_set_reg.
It seems the set_reg variant can be used to provide the specific the regulatory rules, whereas req_set_reg takes the region + hint and looks up the rules from the regulatory database
Allows setting the regulatory region so that we can use channels that are not available everywhere e.g. channel 13 on the 2.4ghz band.
ReloadRegulatoryDatabase- To reload the regulatory db if it was not available during early boot when cfg80211 is loaded. For example, in gokrazy cfg80211 is built into the kernel and attempts to load the regulatory.db before the root fs can be read.SetRegulatoryRegion- To set the regulatory region used by all devicesTested on gokrazy's wifi succesfully with region
GBand channel 13 on a Pi Zero 2W.