diff --git a/dbus/DBus-interface b/dbus/DBus-interface index 2db5c30..954c5b9 100644 --- a/dbus/DBus-interface +++ b/dbus/DBus-interface @@ -243,6 +243,10 @@ IPv4 or IPv6 address of the lease to remove. Note that this function will trigger the DhcpLeaseRemoved signal and the configured DHCP lease script will be run with the "del" action. +GetMetrics +---------- + +Returns an array with various metrics for DNS and DHCP. 2. SIGNALS diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index f3c36a4..ce895b8 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -366,6 +366,11 @@ been built with DBus support. If the service name is given, dnsmasq provides service at that name, rather than the default which is .B uk.org.thekelleys.dnsmasq .TP +.B --enable-ubus +Enable dnsmasq UBus interface. It sends notifications via UBus on +DHCPACK and DHCPRELEASE events. Furthermore it offers metrics. +Requires that dnsmasq has been built with UBus support. +.TP .B \-o, --strict-order By default, dnsmasq will send queries to any of the upstream servers it knows about and tries to favour servers that are known to diff --git a/src/dnsmasq.c b/src/dnsmasq.c index c70b90e..bad1443 100644 --- a/src/dnsmasq.c +++ b/src/dnsmasq.c @@ -225,6 +225,11 @@ int main (int argc, char **argv) die(_("loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF); #endif +#ifndef HAVE_UBUS + if (option_bool(OPT_UBUS)) + die(_("Ubus not available: set HAVE_UBUS in src/config.h"), NULL, EC_BADCONF); +#endif + if (daemon->max_port < daemon->min_port) die(_("max_port cannot be smaller than min_port"), NULL, EC_BADCONF); @@ -950,9 +955,10 @@ int main (int argc, char **argv) #endif #ifdef HAVE_UBUS - set_ubus_listeners(); + if (option_bool(OPT_UBUS) + set_ubus_listeners(); #endif - + #ifdef HAVE_DHCP if (daemon->dhcp || daemon->relay4) { @@ -1084,7 +1090,8 @@ int main (int argc, char **argv) #endif #ifdef HAVE_UBUS - check_ubus_listeners(); + if (daemon->enable_ubus) + check_ubus_listeners(); #endif check_dns_listeners(now); diff --git a/src/dnsmasq.h b/src/dnsmasq.h index 1d76552..4cf12bf 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -255,7 +255,8 @@ struct event_desc { #define OPT_MAC_HEX 55 #define OPT_TFTP_APREF_MAC 56 #define OPT_RAPID_COMMIT 57 -#define OPT_LAST 58 +#define OPT_UBUS 58 +#define OPT_LAST 59 /* extra flags for my_syslog, we use a couple of facilities since they are known not to occupy the same bits as priorities, no matter how syslog.h is set up. */ diff --git a/src/option.c b/src/option.c index 8a9e6fe..9f1b84f 100644 --- a/src/option.c +++ b/src/option.c @@ -163,6 +163,7 @@ struct myoption { #define LOPT_RAPID_COMMIT 351 #define LOPT_DUMPFILE 352 #define LOPT_DUMPMASK 353 +#define LOPT_UBUS 354 #ifdef HAVE_GETOPT_LONG static const struct option opts[] = @@ -233,6 +234,7 @@ static const struct myoption opts[] = { "txt-record", 1, 0, 'Y' }, { "dns-rr", 1, 0, LOPT_RR }, { "enable-dbus", 2, 0, '1' }, + { "enable-ubus", 0, 0, LOPT_UBUS }, { "bootp-dynamic", 2, 0, '3' }, { "dhcp-mac", 1, 0, '4' }, { "no-ping", 0, 0, '5' }, @@ -420,6 +422,7 @@ static struct { { 'z', OPT_NOWILD, NULL, gettext_noop("Bind only to interfaces in use."), NULL }, { 'Z', OPT_ETHERS, NULL, gettext_noop("Read DHCP static host information from %s."), ETHERSFILE }, { '1', ARG_ONE, "[=]", gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL }, + { LOPT_UBUS, OPT_UBUS, NULL, gettext_noop("Enable the UBus interface."), NULL }, { '2', ARG_DUP, "", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL }, { '3', ARG_DUP, "[=tag:]...", gettext_noop("Enable dynamic address allocation for bootp."), NULL }, { '4', ARG_DUP, "set:,", gettext_noop("Map MAC address (with wildcards) to option set."), NULL }, @@ -1746,7 +1749,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma #endif } break; - + case 'x': /* --pid-file */ daemon->runfile = opt_string_alloc(arg); break;