List of Available Wireless Networks with Golang (Under Linux)

Accessing Linux network APIs from Go

You very likely want to use cgo as it's really easy to call any C API

An added benefit is that C APIs are usually pretty stable over time as the library creators almost always opt for a new function rather than break the API of an existing one.

Running command line tools and parsing output is error prone as the software you call will most likely change it's output overtime, breaking your parsers.

WICD-CLI Script: How i read variable from the list of wireless networks

If you want a quick one-liner, you can use:

wicd-cli --wireless -cn `wicd-cli -l --wireless | grep 'D-Link' | cut -c1`

You can also introduce a new variable, say, NET_NUM to make the code more readable.

NET_NUM=$(wicd-cli -l --wireless | grep 'D-Link' | cut -c1)
wicd-cli --wireless -cn $NET_NUM

Or even a bash function to make it more general.

switch_net() {
[[ $# != 2 ]] && echo "usage: switch_net <ssid_regexp> && exit 1
SSID=$1
NET_NUM=$(wicd-cli -l --wireless | grep $SSID | cut -c1)
wicd-cli --wireless -cn $NET_NUM
}

and use it later on with:

switch_net "D-Link"

ubuntu: manipulating wireless networking

network-manager has a dbus service. You can use any language with dbus binding to talk to it.

While connected to a Wi-Fi network, get all of its access points

I couldn't find a way to retrieve all access points of a network in iOS.

For anyone curious, I went with storing SSID+BSSID as primary key and public IP as another field.

If the entry doesn't exist, I add it and check for other entries with the same IP and link them together.
If the entry does exist, I check if the IP hasn't changed since last time, since public IP can be dynamic. If it has, I update all entries with the old IP to the new IP.

It's still not a perfect solution. It doesn't cover the case where you go to a new access point of a network and the public IP for that network has changed, although it does fix itself to some extent if you go back to the first access point. Also, in general, places that have multiple access points also tend to have static IPs, so this case may be very situational.



Related Topics



Leave a reply



Submit