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

@@ -53,6 +53,7 @@ top?=$(CURDIR)
dbus_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1` dbus_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
dbus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1` dbus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
ubus_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_UBUS $(PKG_CONFIG) --copy -lubox -lubus`
idn_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn` idn_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --cflags libidn`
idn_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn` idn_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_IDN $(PKG_CONFIG) --libs libidn`
idn2_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LIBIDN2 $(PKG_CONFIG) --cflags libidn2` idn2_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LIBIDN2 $(PKG_CONFIG) --cflags libidn2`
@@ -76,7 +77,7 @@ objs = cache.o rfc1035.o util.o option.o forward.o network.o \
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \ helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \ dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \
domain.o dnssec.o blockdata.o tables.o loop.o inotify.o \ domain.o dnssec.o blockdata.o tables.o loop.o inotify.o \
poll.o rrfilter.o edns0.o arp.o crypto.o dump.o poll.o rrfilter.o edns0.o arp.o crypto.o dump.o ubus.o
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \ hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \
dns-protocol.h radv-protocol.h ip6addr.h dns-protocol.h radv-protocol.h ip6addr.h
@@ -85,7 +86,7 @@ all : $(BUILDDIR)
@cd $(BUILDDIR) && $(MAKE) \ @cd $(BUILDDIR) && $(MAKE) \
top="$(top)" \ top="$(top)" \
build_cflags="$(version) $(dbus_cflags) $(idn2_cflags) $(idn_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags)" \ build_cflags="$(version) $(dbus_cflags) $(idn2_cflags) $(idn_cflags) $(ct_cflags) $(lua_cflags) $(nettle_cflags)" \
build_libs="$(dbus_libs) $(idn2_libs) $(idn_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs)" \ build_libs="$(dbus_libs) $(idn2_libs) $(idn_libs) $(ct_libs) $(lua_libs) $(sunos_libs) $(nettle_libs) $(gmp_libs) $(ubus_libs)" \
-f $(top)/Makefile dnsmasq -f $(top)/Makefile dnsmasq
mostly_clean : mostly_clean :

View File

@@ -11,7 +11,7 @@ LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
radv.c slaac.c auth.c ipset.c domain.c \ radv.c slaac.c auth.c ipset.c domain.c \
dnssec.c dnssec-openssl.c blockdata.c tables.c \ dnssec.c dnssec-openssl.c blockdata.c tables.c \
loop.c inotify.c poll.c rrfilter.c edns0.c arp.c \ loop.c inotify.c poll.c rrfilter.c edns0.c arp.c \
crypto.c dump.c crypto.c dump.c ubus.c
LOCAL_MODULE := dnsmasq LOCAL_MODULE := dnsmasq

View File

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

View File

@@ -949,6 +949,10 @@ int main (int argc, char **argv)
set_dbus_listeners(); set_dbus_listeners();
#endif #endif
#ifdef HAVE_UBUS
set_ubus_listeners();
#endif
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
if (daemon->dhcp || daemon->relay4) if (daemon->dhcp || daemon->relay4)
{ {
@@ -1079,6 +1083,10 @@ int main (int argc, char **argv)
check_dbus_listeners(); check_dbus_listeners();
#endif #endif
#ifdef HAVE_UBUS
check_ubus_listeners();
#endif
check_dns_listeners(now); check_dns_listeners(now);
#ifdef HAVE_TFTP #ifdef HAVE_TFTP

View File

@@ -1445,6 +1445,13 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
# endif # endif
#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 */ /* ipset.c */
#ifdef HAVE_IPSET #ifdef HAVE_IPSET
void ipset_init(void); void ipset_init(void);

View File

@@ -1636,6 +1636,13 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
daemon->namebuff, daemon->namebuff,
string ? string : "", string ? string : "",
err ? err : ""); 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) static void log_options(unsigned char *start, u32 xid)