lakinduakash / linux-wifi-hotspot

Feature-rich wifi hotspot creator for Linux which provides both GUI and command-line interface. It is also able to create a hotspot using the same wifi card which is connected to an AP already ( Similar to Windows 10).
BSD 2-Clause "Simplified" License
3.01k stars 278 forks source link

Update frequency parsing for iw 6.7 compatibility #367

Closed joanbm closed 6 months ago

joanbm commented 6 months ago

Since iw 6.7, which adds 802.11ah support, iw may print fractional frequencies (e.g. 917.4 MHz). The change in the formatting code can also affect frequencies in the 2.4 and 5 GHz bands, so a frequency that used to be shown as "2412 MHz" may now be shown as "2412.0 MHz".

This breaks the parsing logic in can_transmit_to_channel, ieee80211_frequency_to_channel and is_5ghz_frequency.

The problem in can_transmit_to_channel causes an error when creating an AP, due the frequency not being detected as supported ("ERROR: Your adapter can not transmit to channel 1, frequency band 2.4GHz.").

Fix this by changing the parsing logic to accept a trailing ".0" (or even ".00", etc.) suffix for the existing 2.4 and 5 GHz bands.

See also:

The PR also syncs the definition of ieee80211_frequency_to_channel with the latest iw release and fixes a minor mistake in a text message.

niksingh710 commented 6 months ago

@joanbm I am unsure but recently after updating my system I am facing this error

ERROR: Your adapter can not transmit to channel 1, frequency band 2.4GHz.

does this pr resolves that?

joanbm commented 6 months ago

@niksingh710 Yes, most likely. You probably have iw 6.7 (check iw --version), Arch Linux has it on their non-testing repositories already.

niksingh710 commented 6 months ago

@niksingh710 Yes, most likely. You probably have iw 6.7 (check iw --version), Arch Linux has it on their non-testing repositories already.

yep iw --version giving 6.7

akshettrj commented 6 months ago

I tried your branch and it seems to work for 2.4 GHz frequency but not for 5GHz... Although I think 5GHz did not work for me in the past as well

joanbm commented 6 months ago

I tried your branch and it seems to work for 2.4 GHz frequency but not for 5GHz... Although I think 5GHz did not work for me in the past as well

Hmm, unfortunately I don't have a 5GHz device around me right now to test it, but I can't see why it wouldn't work (provided it has in the past, that is).

akshettrj commented 6 months ago

Sorry, I was using wrong channels, it did work for 5GHz as well for me. My bad 😅

lakinduakash commented 6 months ago

Thanks for your contribution? Is it backward compatible for previous iw versions?

joanbm commented 6 months ago

Is it backward compatible for previous iw versions?

Yes, the changes in the regular expressions are optional (note the ? at the end of the decimal specifier) and I also did a small test with iw 5.9 just in case.

lakinduakash commented 6 months ago

Awesome! At the moment i don't have ubuntu machine to test. Thanks for testing and much appreciated.

niksingh710 commented 6 months ago

quite curious as last release was in nov and this pr fixes a bug introduced after the kernel release when will be the next release as arch does not have any -git package.

joanbm commented 6 months ago

quite curious as last release was in nov and this pr fixes a bug introduced after the kernel release when will be the next release as arch does not have any -git package.

FWIW the AUR package has a new pkgrel which already includes this patch (even though it’s not included in an official release yet) - see https://aur.archlinux.org/cgit/aur.git/commit/?h=linux-wifi-hotspot&id=08e15671e46e6182d8df7c631ba119bea40c1a99

niksingh710 commented 6 months ago

Thanks, buddy wasn't aware of that.