1
0
mirror of https://git.openwrt.org/feed/routing.git synced 2024-06-16 20:23:58 +02:00
openwrt-routing/babeld/src/ubus.h
Polynomdivision 519c1ff731
babeld: send events via ubus (#633)
* babeld: send events via ubus

Send a notification via the ubus bus if we experience any changes in
neighbours, routes or xroutes.

The format looks like this:
  {route,xroute,neighbour}.add: Object was added
  {route,xroute,neighbour}.change: Object was changed
  {route,xroute,neighbour}.flush: Object was flushed

If ubus_bindings is turned off, it will minimally effect performance,
since only an if-statement has to be evaluated.
If no subscriber is available, it will minimally change the performance,
since only an if-statmenet that checks for subscribers has to be
evaluated.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-02-01 15:26:44 +01:00

88 lines
2.3 KiB
C

/*
IPC integration of babeld with OpenWrt.
The ubus interface offers following functions:
- get_info
- get_neighbours
- get_xroutes
- get_routes
All output is divided into IPv4 and IPv6.
Ubus notifications are sent if we receive updates for
- xroutes
- routes
- neighbours
The format is:
- {route,xroute,neighbour}.add: Object was added
- {route,xroute,neighbour}.change: Object was changed
- {route,xroute,neighbour}.flush: Object was flushed
*/
#include <libubus.h>
// Whether to enable ubus bindings (boolean option).
extern int ubus_bindings;
/**
* Initialize ubus interface.
*
* Connect to the ubus daemon and expose the ubus functions.
*
* @return if initializing ubus was successful
*/
bool babeld_add_ubus();
/**
* Add ubus socket to given filedescriptor set.
*
* We need to check repeatedly if the ubus socket has something to read.
* The functions allows to add the ubus socket to the normal while(1)-loop of
* babeld.
*
* @param readfs: the filedescriptor set
* @param maxfd: the current maximum file descriptor
* @return the maximum file descriptor
*/
int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd);
/**
* Check and process ubus socket.
*
* If the ubus-socket signals that data is available, the ubus_handle_event is
* called.
*/
void babeld_ubus_receive(fd_set *readfds);
/***
* Notify the ubus bus that a new xroute is received.
*
* If a new xroute is received or changed, we will notify subscribers.
*
* @param xroute: xroute that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_xroute(struct xroute *xroute, int kind);
/***
* Notify the ubus bus that a new route is received.
*
* If a new route is received or changed, we will notify subscribers.
*
* @param route: route that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_route(struct babel_route *route, int kind);
/***
* Notify the ubus bus that a new neighbour is received.
*
* If a new neighbour is received or changed, we will notify subscribers.
*
* @param neigh: neighbour that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_neighbour(struct neighbour *neigh, int kind);