diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-10 17:29:40 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-10 22:30:35 +0100 |
commit | 9198e12ca32db7812b2a79b5922233ec80890306 (patch) | |
tree | 16f9c6a8e12b2792f0ea3b31a150a23df74c858b /src/network/networkd-network-bus.c | |
parent | 53d6837510478e1275b294654663635466cbafc7 (diff) |
networkd: bus - expose MatchMAC
Diffstat (limited to 'src/network/networkd-network-bus.c')
-rw-r--r-- | src/network/networkd-network-bus.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c index 6e7cbc5a45..f1b58b322f 100644 --- a/src/network/networkd-network-bus.c +++ b/src/network/networkd-network-bus.c @@ -25,12 +25,49 @@ #include "networkd.h" +static int property_get_ether_addrs( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + Network *n = userdata; + const char *ether = NULL; + int r; + + assert(bus); + assert(reply); + assert(n); + + if (n->match_mac) + ether = ether_ntoa(n->match_mac); + + r = sd_bus_message_open_container(reply, 'a', "s"); + if (r < 0) + return r; + + if (ether) { + r = sd_bus_message_append(reply, "s", strempty(ether)); + if (r < 0) + return r; + } + + r = sd_bus_message_close_container(reply); + if (r < 0) + return r; + + return 1; +} + const sd_bus_vtable network_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_PROPERTY("Description", "s", NULL, offsetof(Network, description), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("SourcePath", "s", NULL, offsetof(Network, filename), SD_BUS_VTABLE_PROPERTY_CONST), -/* SD_BUS_PROPERTY("MatchMAC", "s", NULL TODO, offsetof(Network, match_mac), SD_BUS_VTABLE_PROPERTY_CONST), */ + SD_BUS_PROPERTY("MatchMAC", "as", property_get_ether_addrs, offsetof(Network, match_mac), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("MatchPath", "s", NULL, offsetof(Network, match_path), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("MatchDriver", "s", NULL, offsetof(Network, match_driver), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("MatchType", "s", NULL, offsetof(Network, match_type), SD_BUS_VTABLE_PROPERTY_CONST), |