Add OpenWRT ubus patch

Originally written by John Crispin <john@phrozen.org>
This commit is contained in:
Julian Kornberger
2018-07-21 21:45:03 +01:00
committed by Simon Kelley
parent 3b6eb197a8
commit caf4d571e6
6 changed files with 32 additions and 6 deletions

View File

@@ -94,6 +94,9 @@ HAVE_DBUS
support some methods to allow (re)configuration of the upstream DNS
servers via DBus.
HAVE_UBUS
define this if you want to link against libubus
HAVE_IDN
define this if you want international domain name 2003 support.

View File

@@ -947,8 +947,12 @@ int main (int argc, char **argv)
#ifdef HAVE_DBUS
set_dbus_listeners();
#endif
#endif
#ifdef HAVE_UBUS
set_ubus_listeners();
#endif
#ifdef HAVE_DHCP
if (daemon->dhcp || daemon->relay4)
{
@@ -1078,7 +1082,11 @@ int main (int argc, char **argv)
}
check_dbus_listeners();
#endif
#ifdef HAVE_UBUS
check_ubus_listeners();
#endif
check_dns_listeners(now);
#ifdef HAVE_TFTP

View File

@@ -1445,6 +1445,13 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
# endif
#endif
/* ubus.c */
#ifdef HAVE_UBUS
void set_ubus_listeners(void);
void check_ubus_listeners(void);
void ubus_event_bcast(const char *type, const char *mac, const char *ip, const char *name, const char *interface);
#endif
/* ipset.c */
#ifdef HAVE_IPSET
void ipset_init(void);

View File

@@ -1636,6 +1636,13 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
daemon->namebuff,
string ? string : "",
err ? err : "");
#ifdef HAVE_UBUS
if (!strcmp(type, "DHCPACK"))
ubus_event_bcast("dhcp.ack", daemon->namebuff, addr ? inet_ntoa(a) : NULL, string ? string : NULL, interface);
else if (!strcmp(type, "DHCPRELEASE"))
ubus_event_bcast("dhcp.release", daemon->namebuff, addr ? inet_ntoa(a) : NULL, string ? string : NULL, interface);
#endif
}
static void log_options(unsigned char *start, u32 xid)