initial commit
[project/unetd.git] / unetd.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
4 */
5 #ifndef __UNETD_H
6 #define __UNETD_H
7
8 #include <stdbool.h>
9
10 #include <libubox/vlist.h>
11 #include <libubox/blobmsg.h>
12 #include <libubox/utils.h>
13 #include "utils.h"
14 #include "siphash.h"
15 #include "wg.h"
16 #include "pex.h"
17 #include "network.h"
18 #include "host.h"
19 #include "service.h"
20
21 extern bool dummy_mode;
22 extern bool debug;
23
24 #define D(format, ...) \
25 do { \
26 if (debug) \
27 fprintf(stderr, "%s(%d) " format "\n", \
28 __func__, __LINE__, ##__VA_ARGS__); \
29 } while (0)
30
31 #define D_NET(net, format, ...) D("network %s " format, network_name(net), ##__VA_ARGS__)
32 #define D_HOST(net, host, format, ...) D_NET(net, "host %s " format, network_host_name(host), ##__VA_ARGS__)
33 #define D_PEER(net, peer, format, ...) D_NET(net, "host %s " format, network_peer_name(peer), ##__VA_ARGS__)
34
35
36 void unetd_write_hosts(void);
37 void unetd_ubus_init(void);
38 void unetd_ubus_netifd_update(struct blob_attr *data);
39 void unetd_ubus_netifd_add_route(struct network *net, union network_endpoint *ep);
40
41 #endif