babeld: adopt to upstream header-style (#640)
[feed/routing.git] / babeld / src / ubus.h
1 /*
2 IPC integration of babeld with OpenWrt.
3
4 The ubus interface offers following functions:
5 - get_info
6 - get_neighbours
7 - get_xroutes
8 - get_routes
9
10 All output is divided into IPv4 and IPv6.
11
12 Ubus notifications are sent if we receive updates for
13 - xroutes
14 - routes
15 - neighbours
16
17 The format is:
18 - {route,xroute,neighbour}.add: Object was added
19 - {route,xroute,neighbour}.change: Object was changed
20 - {route,xroute,neighbour}.flush: Object was flushed
21
22 */
23
24 #include <stdbool.h>
25 #include <sys/select.h>
26
27 struct babel_route;
28 struct neighbour;
29 struct xroute;
30
31 // Whether to enable ubus bindings (boolean option).
32 extern int ubus_bindings;
33
34 /**
35 * Initialize ubus interface.
36 *
37 * Connect to the ubus daemon and expose the ubus functions.
38 *
39 * @return if initializing ubus was successful
40 */
41 bool babeld_add_ubus();
42
43 /**
44 * Add ubus socket to given filedescriptor set.
45 *
46 * We need to check repeatedly if the ubus socket has something to read.
47 * The functions allows to add the ubus socket to the normal while(1)-loop of
48 * babeld.
49 *
50 * @param readfs: the filedescriptor set
51 * @param maxfd: the current maximum file descriptor
52 * @return the maximum file descriptor
53 */
54 int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd);
55
56 /**
57 * Check and process ubus socket.
58 *
59 * If the ubus-socket signals that data is available, the ubus_handle_event is
60 * called.
61 */
62 void babeld_ubus_receive(fd_set *readfds);
63
64 /***
65 * Notify the ubus bus that a new xroute is received.
66 *
67 * If a new xroute is received or changed, we will notify subscribers.
68 *
69 * @param xroute: xroute that experienced some change
70 * @param kind: kind that describes if we have a flush, add or change
71 */
72 void ubus_notify_xroute(struct xroute *xroute, int kind);
73
74 /***
75 * Notify the ubus bus that a new route is received.
76 *
77 * If a new route is received or changed, we will notify subscribers.
78 *
79 * @param route: route that experienced some change
80 * @param kind: kind that describes if we have a flush, add or change
81 */
82 void ubus_notify_route(struct babel_route *route, int kind);
83
84 /***
85 * Notify the ubus bus that a new neighbour is received.
86 *
87 * If a new neighbour is received or changed, we will notify subscribers.
88 *
89 * @param neigh: neighbour that experienced some change
90 * @param kind: kind that describes if we have a flush, add or change
91 */
92 void ubus_notify_neighbour(struct neighbour *neigh, int kind);