Wlan interfaces apparently report themselves as ARPHRD_ETHER in their
ifinfomsg struct (despite there being a ARPHRD_IEEE80211 type...).
"Fix" by hardcoding the type to "wlan" when we receive a
NL80211_CMD_NEW_INTERFACE message.
The tag maps to the IFLA_INFO_KIND (part of the IFLA_LINKINFO)
netlink attribute.
This attribute is only available on virtual interfaces. Examples of
valid values are:
* bond
* bridge
* gre
* tun
* veth
This tag maps to the ifinfomsg->ifi_type member, which is set to one
of the ARPHRD_xyz values, defined in linux/if_arp.h.
There's a *ton* of them, and we can't possibly add a string mapping
for _all_ of them, so for now, set to one of:
* loopback
* ether
* wlan
* ARPHRD_NNN, where N is a number
Recent kernels, or possibly updated wireless drivers, no longer
provide the SSID in `NL80211_CMD_NEW_STATION` responses.
For yambar, this meant the SSID was always missing.
This patch fixes this, by also issuing a NL80211_CMD_GET_SCAN
command. The response to this (NL80211_CMD_SCAN_RESULTS) _may_ return
many access points. Pick out the one that we’re associated with, and
inspect its BSS_INFORMATION_ELEMENTS. This is a raw data structure
containing, among other things, the SSID.
I haven’t been able to find any documentation of the format, but could
glean enough from
https://git.kernel.org/pub/scm/linux/kernel/git/jberg/iw.git/tree/scan.c#n2313
to be able to parse out the SSID.
Note that we get a “device or resource busy” error if we try to issue
both the NL80211_CMD_GET_STATION and the NL80211_CMD_GET_SCAN commands
at the same time. Therefore, we issue the GET_SCAN command after
completing the GET_STATION command.
Closes#226
Exports two new tags from network module, `ul-speed` and `dl-speed`.
Because these work through polling, poll-interval must be set.
Otherwise, these two tags always will be 0.
This fixes an issue where we sometimes failed to retrieve the SSID; we
sent one initial request before the family ID had been set.
Then, we received the family ID and tried to send another
request. However, if the first request was still in progress, the
second request was never made.
Since the first request lacked the family ID, that response didn’t
contain anything useful.
This adds a new ‘poll-interval’ option to the network module. When set
to a non-zero value, the following Wi-Fi stats will be updated:
* Signal strength
* RX+TX bitrate
This cleans up the nl80211 handling quite a bit, and adds initial
support for nl80211 notifications.
* We now join the nl80211 MLME multicast group (done by parsing the
CTRL_ATTR_MCAST_GROUPS attribute in the reply to our
CTRL_CMD_GETFAMILY request). This gives us CONNECT and DISCONNECT
notifications, allowing us to request and reset SSID that way, instead
of detecting the link’s OPER state.
* Before parsing an nl80211 message, verify it’s for us, by looking
for a NL80211_ATTR_IFINDEX attribute in the message (and comparing the
contents with our previously detected ifindex).
In cases where it makes sense, use calloc() instead of malloc():
* When allocating large objects with many members, many for which
NULL/0 is a good default value.
* Arrays etc where we explicitly initialize to NULL anyway.
Since this struct only contained function pointers, make all modules
export those functions directly.
The plugin manager now defines a module interface struct, and fills it
it by dlsym:ing the functions that used to be in module_info.
All modules are expected to handle a call to content() after having
been instantiated.
I.e. modules *cannot* even expect run() to have started running.
Previously we allowed it on the bar, and on all particles. Now we also
allow it on all modules.
This allows us to specify a "default" font/foreground on a per-module
basis, having it applied to all the modules particles.