Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux iw #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Linux iw #16

wants to merge 4 commits into from

Conversation

msolters
Copy link
Owner

@msolters msolters commented Jul 2, 2016

nmcli seems to give different results in different distros. Rather than write a different parsing rules for each version, I tried to replace nmcli wherever possible with iw, iwconfig, or ifconfig, tools I hope will prove to be more version-portable.

But, this branch has to be tested to know for sure! I'm especially interested if anyone on 14.04 can try this out, and see how WiFi scanning & reset go.

@msolters
Copy link
Owner Author

msolters commented Jul 2, 2016

At this point, AP connection is still handled by nmcli, but that is the only feature that still relies on the tool.

@IMG-PRCSNG
Copy link

I checked #16 out.

These were the issues I was facing.

  • I wasn't able to understand why you were using ap-force. I wasn't able to find any reference on why to use that option. It will be helpful if you can point me to some resource. I was able to scan for wifi on removing ap-force option and with root privileges.
  • nmcli creates another profile for the ssid we are connecting to even if it is a known network

Suggestions

  • Root privileges can be circumvented if we trigger a scan event and dump result on scan completion / cache the results on update so that we don't have to force a re-scan every time.
  • Feature request : We can look for existing wifi profiles and try to reuse them if possible.

@msolters
Copy link
Owner Author

msolters commented Jul 5, 2016

Ok, let me address your points in the same order:

  • ap-force is an artifact of the reason I originally developed this package, which is to help me generate a headless SoftAP setup mechanism for a e.g. RPi type system. ap-force is required to scan nearby WiFi networks when the wireless interface is in master mode. In my experience, if your interface is acting as an AP itself, you can't also scan for networks unless you include that argument. That being said, I was not aware of it preventing the scanning operation in the event you aren't in master mode. I certainly can't reproduce that issue. However, given the rather limited use case of operating in master mode, perhaps it is fine to just omit it here. That's something that we can test easily.
  • Regarding root privileges, it seems to me there is no way around it in Linux. We are running a server-side script that is explicitly controlling the system's radio chipsets. Perhaps sudo is a reasonable requirement for such software. At the end of the day, the developers of the underlying tools themselves thought so.
  • Regarding nmcli profiles; it's a good point. I seem to recall implementing your suggestions -- search for a match before creating a new one -- but maybe I am thinking of the win32 implementation, which has a similar kind of virtual interface list. I'll have to look more deeply into that.

@msolters
Copy link
Owner Author

msolters commented Jul 5, 2016

Yes; regarding the nmcli profiles, it seems that what I am doing is first checking for any matches by SSID only; then, should we already have a profile that matches the SSID we're trying to connect to, we delete it before creating a new one: https://github.com/msolters/wifi-control-node/blob/master/src/linux.coffee#L159

My reasoning here was that I didn't assume the previous configuration still held true; what if the password had changed (or what if security type had been changed/removed itself)? It would always be more reliable to just do what the user specified as opposed to allow previous decisions to silently override what the user expected to happen. I'm not yet convinced this should not be the desired behaviour.

@IMG-PRCSNG
Copy link

Let me see if I got it right

  • ap-force is useful when the system itself is an access point (which disables ability to scan)
  • I get your point regarding root privileges. Scanning needs higher level of permissions.
  • You are deleting previous profile created before starting another one. But this again has one more problem - version issues of nmcli - The syntax is different.

There is also a callback in iw called event. It tells when iw finishes executing any task (like scan, connect, etc.) - Probably suitable for any async tasks. We can monitor it for events but sounds overkill.

Is there any check against resource busy errors? Like, when you try to manually scan when there is a scan in progress, I guess it throws an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants