]> git.ipfire.org Git - network.git/commitdiff
networkd: Pass daemon to all functions called by the bus
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Feb 2023 23:25:17 +0000 (23:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Feb 2023 23:25:17 +0000 (23:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/bus.c
src/networkd/bus.h
src/networkd/daemon.c

index eab123ce38e3ace39805ba56ac99d88bdd88b463..e854f7ba95dc6f6f53609ab3de71ba56c01b53b5 100644 (file)
@@ -59,7 +59,7 @@ static int nw_bus_on_connect(sd_bus_message* m, void* data, sd_bus_error* error)
        return 0;
 }
 
-int nw_bus_connect(sd_bus* bus, sd_event* loop) {
+int nw_bus_connect(sd_bus* bus, sd_event* loop, struct nw_daemon* daemon) {
        int r;
 
        // Create a bus object
@@ -124,7 +124,7 @@ int nw_bus_connect(sd_bus* bus, sd_event* loop) {
        }
 
        // Register the implementation
-       r = nw_bus_register_implementation(bus, &daemon_implementation, NULL);
+       r = nw_bus_register_implementation(bus, &daemon_implementation, daemon);
        if (r)
                return r;
 
index 05846e51e4323efff58fc11f94f56fb8c63a4b7f..55e65b817300e182b9d49539ba17eb9f988438be 100644 (file)
@@ -28,7 +28,9 @@
 #include <systemd/sd-bus.h>
 #include <systemd/sd-event.h>
 
-int nw_bus_connect(sd_bus* bus, sd_event* loop);
+#include "daemon.h"
+
+int nw_bus_connect(sd_bus* bus, sd_event* loop, struct nw_daemon* daemon);
 
 struct nw_bus_implementation {
        const char* path;
index 86731d157f57ac3e1766d2687d53ad1c7aed2c7b..a478e6015fb86280900ecc3300fab756500778c5 100644 (file)
@@ -227,7 +227,7 @@ static int nw_daemon_setup(struct nw_daemon* daemon) {
                return r;
 
        // Connect to the system bus
-       r = nw_bus_connect(daemon->bus, daemon->loop);
+       r = nw_bus_connect(daemon->bus, daemon->loop, daemon);
        if (r)
                return r;