]> git.ipfire.org Git - people/ms/network.git/blob - src/networkd/bus.h
29b1b4a55526b5da187b1b8112c7a6027f233122
[people/ms/network.git] / src / networkd / bus.h
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 #ifndef NETWORKD_BUS_H
22 #define NETWORKD_BUS_H
23
24 #define NETWORKD_BUS_DESCRIPTION "networkd"
25
26 #define DEFAULT_SYSTEM_BUS_ADDRESS "unix:path=/run/dbus/system_bus_socket"
27
28 #include <systemd/sd-bus.h>
29 #include <systemd/sd-event.h>
30
31 #include "daemon.h"
32
33 int nw_bus_connect(sd_bus** bus, sd_event* loop, nw_daemon* daemon);
34
35 struct nw_bus_vtable_pair {
36 const sd_bus_vtable* vtable;
37 sd_bus_object_find_t object_find;
38 };
39
40 typedef struct nw_bus_implementation {
41 const char* path;
42 const char* interface;
43 const sd_bus_vtable** vtables;
44 const struct nw_bus_vtable_pair* fallback_vtables;
45 sd_bus_node_enumerator_t node_enumerator;
46 const struct nw_bus_implementation** children;
47 } nw_bus_implementation;
48
49 #define BUS_FALLBACK_VTABLES(...) ((const struct nw_bus_vtable_pair[]) { __VA_ARGS__, {} })
50 #define BUS_IMPLEMENTATIONS(...) ((const nw_bus_implementation* []) { __VA_ARGS__, NULL })
51 #define BUS_VTABLES(...) ((const sd_bus_vtable* []){ __VA_ARGS__, NULL })
52
53 int nw_bus_register_implementation(sd_bus* bus,
54 const nw_bus_implementation* impl, void* data);
55
56 #endif /* NETWORKD_BUS_H */