]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/networkd/daemon-bus.c
networkd: Split daemon bus implementation into a separate file
[people/ms/network.git] / src / networkd / daemon-bus.c
diff --git a/src/networkd/daemon-bus.c b/src/networkd/daemon-bus.c
new file mode 100644 (file)
index 0000000..aac9775
--- /dev/null
@@ -0,0 +1,49 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2023 IPFire Network Development Team                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <systemd/sd-bus.h>
+
+#include "bus.h"
+#include "daemon.h"
+#include "zone-bus.h"
+
+static int nw_daemon_bus_reload(sd_bus_message* m, void* data, sd_bus_error* error) {
+       struct nw_daemon* daemon = (struct nw_daemon*)data;
+
+       // Reload the daemon
+       nw_daemon_reload(daemon);
+
+       // Respond with an empty message
+       return sd_bus_reply_method_return(m, NULL);
+}
+
+static const sd_bus_vtable daemon_vtable[] = {
+       SD_BUS_VTABLE_START(0),
+       SD_BUS_METHOD("Reload", SD_BUS_NO_ARGS, SD_BUS_NO_RESULT,
+               nw_daemon_bus_reload, SD_BUS_VTABLE_UNPRIVILEGED),
+       SD_BUS_VTABLE_END,
+};
+
+const struct nw_bus_implementation daemon_bus_impl = {
+       .path = "/org/ipfire/network1",
+       .interface = "org.ipfire.network1",
+       .vtables = BUS_VTABLES(daemon_vtable),
+       .children = BUS_IMPLEMENTATIONS(&zone_bus_impl),
+};