Commit graph

65 commits

Author SHA1 Message Date
Daniel Eklöf
a367895dc6
Open sockets, files etc with FD_CLOEXEC 2024-10-23 09:36:59 +02:00
Daniel Eklöf
54902f46ab
module: network: hardcode type to "wlan" when we see NL80211_CMD_NEW_INTERFACE
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.
2024-08-20 07:40:08 +02:00
Daniel Eklöf
699c563051
module: network: add 'kind' tag
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
2024-08-20 07:40:08 +02:00
Daniel Eklöf
a5ae61b5df
module: network: add 'type` tag
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
2024-08-20 07:39:59 +02:00
Daniel Eklöf
9cc5e0f7a7
module/network: plug memory leak
Free the 'ifaces' list, not just its contents.
2024-06-09 10:08:38 +02:00
Birger Schacht
3a7455913f
fix: typo
Probaly -> Probably
2024-04-30 08:56:18 +02:00
Sertonix
547cef5afb network: fix missing break in switch statement
This can cause the first character of the string to be read as an iface state.

Fixes https://codeberg.org/dnkl/yambar/issues/377
2024-04-22 16:23:16 +02:00
Delgan
b85ba99980 Apply "clang-format" preferences globally 2024-04-07 10:05:10 +02:00
Sertonix
c44c66c83f
network: use dynlist instead of fixed name
Closes #271
Closes #265
Closes #71
2024-04-01 08:34:18 +02:00
Delgan
e1f78a16ab
Add new "quality" tag to "network" module 2024-01-04 13:44:54 +01:00
tiosgz
5e3859f218 module/network: allow poll-interval == 0
Apparently the possibility to disable it was missed when the interval
was migrated to use milliseconds.
2023-04-08 20:06:07 +00:00
Oleg Hahm
8ccd79ad08 modules/network: do not use IPv6 link-local
Probably you don't want to see your IPv6 link-local address but rather a
global one.
2023-03-08 18:41:20 +01:00
Daniel Eklöf
e4edbd26c6
modules: change min poll interval from 500ms to 250ms 2022-12-27 13:20:31 +01:00
Daniel Eklöf
500b051fe4
module/network: poll-interval: convert value from ‘seconds’ to ‘milliseconds’ 2022-12-22 12:06:15 +01:00
Daniel Eklöf
3ca274759a
module: const:ify ‘module’ argument to module->description() 2022-12-14 12:05:17 +01:00
Daniel Eklöf
8f1a123de2
module/network: only log SSID when different from current one
This prevents log spamming with poll-interval set

Closes #232
2022-10-16 16:17:08 +02:00
Daniel Eklöf
4143099e94
module/network: resurrect SSID
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
2022-09-10 13:46:34 +02:00
Daniel Eklöf
d002919bad
module/network: generate nl80211 sequence number from /dev/urandom 2022-09-03 12:05:58 +02:00
Daniel Eklöf
2759ba6349
module/network: generate nl80211 sequence number from /dev/urandom 2022-08-28 20:19:22 +02:00
Johannes
03e1c7dc13 module/network: Add link stats
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.
2022-06-06 15:11:24 +02:00
Daniel Eklöf
eb5cb9869c
module/network: log signal strength and TX/RX bitrates at debug level 2022-06-06 14:30:22 +02:00
Daniel Eklöf
ca077447c2
module/network: tx/rx-bitrate is now in bits/s instead of Mb/s 2022-06-02 22:25:53 +02:00
Daniel Eklöf
4bb81e8940
modules: add SOCK_CLOEXEC to all socket() calls 2022-03-29 18:21:13 +02:00
Daniel Eklöf
f166bbbf54
modules: verify: use conf_verify_unsigned() for options that should be >= 0 2021-11-15 18:17:29 +01:00
Daniel Eklöf
9ffd305b59
network: must re-send station request when we receive family ID
The get station request also fails if the family ID is invalid.
2021-10-24 17:47:54 +02:00
Daniel Eklöf
4e96dbd7f7
network: don’t send nl80211 request if we don’t have a family-id
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.
2021-10-24 17:35:15 +02:00
Daniel Eklöf
dabb2e1407
module/network: add support for periodically polling Wi-Fi stats
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
2021-09-01 19:10:23 +02:00
Daniel Eklöf
d450bf12a1
module/network: re-request station info when we’re re-connected 2021-09-01 19:10:22 +02:00
Daniel Eklöf
e8a2f8df9a
module/network: reset signal strength and RX+TX bitrates on disconnect 2021-09-01 19:10:22 +02:00
Daniel Eklöf
a685dadb75
module/network: expose signal strength and rx+tx bitrates 2021-09-01 19:10:22 +02:00
Daniel Eklöf
b27eff36f9
module/network: nl80211: join the MLME mcast group, ignore messages not for us
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).
2021-09-01 19:10:22 +02:00
Daniel Eklöf
9b3548736a
module/network: refactor: add foreach_nlattr()
This function iterates all attributes of a NETLINK_GENERIC message,
and calls the provided callback for each attribute.
2021-09-01 19:10:22 +02:00
Daniel Eklöf
5249d9ef79
module/network: use separate functions to connect to RT/GENL netlink 2021-09-01 19:10:21 +02:00
Daniel Eklöf
d39e6b8b94
module/network: initial support for Wifi extensions
Currently capable of getting the SSID.
2021-09-01 19:10:21 +02:00
Daniel Eklöf
7d3851046e
log: pull in log.{c,h} from foot 2021-08-15 11:41:12 +02:00
Daniel Eklöf
ed2b8c4874
modules: implement description() 2021-06-20 21:15:24 +02:00
Daniel Eklöf
86522d653d
modules: move 'content' and 'anchors' to MODULE_COMMON_ATTRS
All modules implement these. The only one that differs is the i3
module. It still implements them, but 'content' uses an internal
verifier function.
2020-01-24 21:08:39 +01:00
Daniel Eklöf
0550d2799d
tllist: use tllist from external git repository 2019-11-17 19:17:34 +01:00
Daniel Eklöf
b6e61f9c7e modules: use calloc() instead of malloc()
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.
2019-02-09 11:11:31 +01:00
Daniel Eklöf
ae5029826b cmake: break out bar stuff to separate CMakeLists.txt 2019-02-07 12:06:16 +01:00
Daniel Eklöf
452c4b6015 plugins: export a const function pointer interface struct 2019-01-26 18:32:04 +01:00
Daniel Eklöf
9e2ebf3cab module/network: thrd_t isn't an integer in musl 2019-01-20 14:30:39 +01:00
Daniel Eklöf
502c2bd746 module/network: remove debug logging 2019-01-19 17:01:38 +01:00
Daniel Eklöf
0d591fe5a1 allow plugins to be compiled into the f00bar main binary 2019-01-14 20:57:03 +01:00
Daniel Eklöf
4a26664d8d particles: remove config-verify.h from particle.h 2019-01-13 17:41:39 +01:00
Daniel Eklöf
bc62843c91 modules: get rid of struct module_info
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.
2019-01-13 17:09:11 +01:00
Daniel Eklöf
76d135e257 module: remove module_run_context
Store abort_fd directly in the module struct instead. This then allows
us to pass the module pointer as-is to the modules' run functions.
2019-01-13 15:34:59 +01:00
Daniel Eklöf
acdeff3b6e module: remove ready_fd
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.
2019-01-13 15:25:39 +01:00
Daniel Eklöf
a425378576 config: allow font/foreground attributes on modules too
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.
2019-01-13 14:24:44 +01:00
Daniel Eklöf
8dc278aaf2 config: pass a struct with inheritable values
For now, font and foreground color
2019-01-13 14:13:14 +01:00