]> git.ipfire.org Git - people/ms/network.git/blob - src/networkd/daemon-bus.c
networkd: Split daemon bus implementation into a separate file
[people/ms/network.git] / src / networkd / daemon-bus.c
1 /*#############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2023 IPFire Network Development Team #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 #############################################################################*/
20
21 #include <systemd/sd-bus.h>
22
23 #include "bus.h"
24 #include "daemon.h"
25 #include "zone-bus.h"
26
27 static int nw_daemon_bus_reload(sd_bus_message* m, void* data, sd_bus_error* error) {
28 struct nw_daemon* daemon = (struct nw_daemon*)data;
29
30 // Reload the daemon
31 nw_daemon_reload(daemon);
32
33 // Respond with an empty message
34 return sd_bus_reply_method_return(m, NULL);
35 }
36
37 static const sd_bus_vtable daemon_vtable[] = {
38 SD_BUS_VTABLE_START(0),
39 SD_BUS_METHOD("Reload", SD_BUS_NO_ARGS, SD_BUS_NO_RESULT,
40 nw_daemon_bus_reload, SD_BUS_VTABLE_UNPRIVILEGED),
41 SD_BUS_VTABLE_END,
42 };
43
44 const struct nw_bus_implementation daemon_bus_impl = {
45 .path = "/org/ipfire/network1",
46 .interface = "org.ipfire.network1",
47 .vtables = BUS_VTABLES(daemon_vtable),
48 .children = BUS_IMPLEMENTATIONS(&zone_bus_impl),
49 };