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
This commit is contained in:
Daniel Eklöf 2018-12-30 20:40:10 +01:00
parent c795718ad7
commit 4c4f0ce7a0
4 changed files with 413 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include "modules/i3.h"
#include "modules/label.h"
#include "modules/mpd.h"
#include "modules/network.h"
#include "modules/xkb.h"
#include "modules/xwindow.h"
@ -505,6 +506,19 @@ module_mpd_from_config(const struct yml_node *node,
particle_from_config(c, parent_font));
}
static struct module *
module_network_from_config(const struct yml_node *node,
const struct font *parent_font)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *content = yml_get_value(node, "content");
assert(yml_is_scalar(name));
return module_network(
yml_value_as_string(name), particle_from_config(content, parent_font));
}
struct bar *
conf_to_bar(const struct yml_node *bar)
{
@ -615,6 +629,8 @@ conf_to_bar(const struct yml_node *bar)
mods[idx] = module_backlight_from_config(it.node, font);
else if (strcmp(mod_name, "mpd") == 0)
mods[idx] = module_mpd_from_config(it.node, font);
else if (strcmp(mod_name, "network") == 0)
mods[idx] = module_network_from_config(it.node, font);
else
assert(false);
}