Commit graph

42 commits

Author SHA1 Message Date
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
Daniel Eklöf
9944a8f972 modules: don't assume module content is a dictionary
This is done by having each module implement a top-level verifier
function.
2019-01-13 11:54:57 +01:00
Daniel Eklöf
71515e4079 config: conf_verify_dict() now assumes attr list is NULL-terminated 2019-01-13 11:37:05 +01:00
Daniel Eklöf
ec4a47e5db modules: rename module_info -> plugin_info
This is the same name used by particles.
2019-01-13 11:18:32 +01:00
Daniel Eklöf
42104db1ca modules: move files back to a common directory (again) 2019-01-12 21:24:20 +01:00
Daniel Eklöf
8809cbb481 Put each module in its own subdirectory 2019-01-12 11:19:57 +01:00
Daniel Eklöf
bf5ad4d6b7 module/network: both thrd_current() and getpid() are 32-bit 2019-01-06 20:41:34 +01:00
Daniel Eklöf
0ab8dad7b9 module/network: initialize MAC address to 0
This fixes a valgrind "uninitialized value(s)" warning.
2019-01-01 13:10:44 +01:00
Daniel Eklöf
a96f901a15 module/network: disable debug logging 2019-01-01 13:10:35 +01:00
Daniel Eklöf
ea2cc50194 module/network: process_reply() -> parse_reply() 2018-12-31 13:44:49 +01:00
Daniel Eklöf
b2af90abbc module/network: IFA_ADDRESS: include add/del in log message 2018-12-31 13:42:32 +01:00
Daniel Eklöf
24842d9b28 module/network: RTM_NEWLINK/DELLINK: don't do anything if nothing's changed
We're only interrested in a few of the attributes. Thus, there's no
need to log or update anything, if none of those attributes haven't
changed.
2018-12-31 13:40:43 +01:00
Daniel Eklöf
dcf8051f1a module/network: break out message parsing code
This also allows us to actually handle errors (by aborting run())
2018-12-31 13:36:44 +01:00
Daniel Eklöf
8352d89491 module/network: break out message receiving code 2018-12-31 13:27:37 +01:00
Daniel Eklöf
b3f3f91dc2 module/network: drop libnl dependency, use raw netlink sockets instead 2018-12-31 13:19:01 +01:00
Daniel Eklöf
4c4f0ce7a0 module: network: monitor ethernet interfaces
State exposed (tag names):

* name: the interface name ("eth0" etc)
* index: the interface index, "ifindex"
* state: operational state (down, up etc)
* mac: the Ethernet hardware address
* ipv4: the *last* IPv4 address added to the interface
* ipv6: the *last* IPv6 address added to the interface

State we monitor (for changes):

* state
* ipv4 addresses
* ipv6 addresses
2018-12-30 20:40:10 +01:00