Commit 7cebd20f authored by Simon Kelley's avatar Simon Kelley

import of dnsmasq-2.31.tar.gz

parent 26d0dbaf
...@@ -1803,9 +1803,35 @@ version 2.29 ...@@ -1803,9 +1803,35 @@ version 2.29
version 2.30 version 2.30
Fixed crash when a DHCP client requested a broadcast Fixed crash when a DHCP client requested a broadcast
reply. This problem was introduced in version 2.29. reply. This problem was introduced in version 2.28.
Thanks to Sandra Dekkers for the bug report. Thanks to Sandra Dekkers for the bug report.
version 2.31
Added --dhcp-script option. There have been calls for this
for a long time from many good people. Fabio Muzzi gets
the prize for finally convincing me.
Added example dbus config file and moved dbus stuff into
its own directory.
Removed horribly outdated Redhat RPM build files. These
are obsolete now that dnsmasq in in Fedora extras. Thanks
to Patrick "Jima" Laughton, the Fedora package
maintainer.
Added workaround for Linux kernel bug. This manifests
itself as failure of DHCP on kernels with "support for
classical IP over ATM" configured. That includes most
Debian kernel packages. Many thanks to A. Costa and
Benjamin Kudria for their huge efforts in chasing this
down.
Force-kill child processes when dnsmasq is sent a sigterm,
otherwise an unclosed TCP connection could keep dnsmasq
hanging round for a few minutes.
Tweaked config.h logic for uclibc build. It will now pick
up MMU and IPV6 status correctly on every system I tested.
......
...@@ -6,10 +6,10 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o isc.o network.o \ ...@@ -6,10 +6,10 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o isc.o network.o \
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o
.c.o: .c.o:
$(CC) $(CFLAGS) $(I18N) `../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1` $(RPM_OPT_FLAGS) -Wall -W -c $< $(CC) $(CFLAGS) $(COPTS) $(I18N) `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1` $(RPM_OPT_FLAGS) -Wall -W -c $<
dnsmasq : $(OBJS) dnsmasq : $(OBJS)
$(CC) -o $@ $(OBJS) `../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1` $(LIBS) $(CC) -o $@ $(OBJS) `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1` $(LIBS)
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
xgettext -d dnsmasq --foreign-user --keyword=_ -o dnsmasq.pot -i $(OBJS:.o=.c) xgettext -d dnsmasq --foreign-user --keyword=_ -o dnsmasq.pot -i $(OBJS:.o=.c)
......
#!/bin/sh #!/bin/sh
if grep -q "^\#.*define.*HAVE_DBUS" config.h ; then if grep -q "^\#.*define.*HAVE_DBUS" config.h || grep -q HAVE_DBUS ; then
exec $* exec $*
fi fi
......
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="uk.org.thekelleys.dnsmasq"/>
<allow send_destination="uk.org.thekelleys.dnsmasq"/>
<allow send_interface="uk.org.thekelleys.dnsmasq"/>
</policy>
<policy context="default">
<deny own="uk.org.thekelleys.dnsmasq"/>
<deny send_destination="uk.org.thekelleys.dnsmasq"/>
<deny send_interface="uk.org.thekelleys.dnsmasq"/>
</policy>
</busconfig>
###############################################################################
#
# General mumbojumbo
#
###############################################################################
Name: dnsmasq
Version: 2.30
Release: 1
License: GPL
Group: System Environment/Daemons
Vendor: Simon Kelley
Packager: Simon Kelley
Distribution: Red Hat Linux
URL: http://www.thekelleys.org.uk/dnsmasq
Source0: %{name}-%{version}.tar.gz
Requires: chkconfig
BuildRoot: /var/tmp/%{name}-%{version}
Summary: A lightweight caching nameserver
%description
Dnsmasq is lightweight, easy to configure DNS forwarder and DHCP server. It
is designed to provide DNS and, optionally, DHCP, to a small network. It can
serve the names of local machines which are not in the global DNS. The DHCP
server integrates with the DNS server and allows machines with DHCP-allocated
addresses to appear in the DNS with names configured either in each host or
in a central configuration file. Dnsmasq supports static and dynamic DHCP
leases and BOOTP for network booting of diskless machines.
###############################################################################
#
# Build
#
###############################################################################
%prep
%setup -q
%build
make all-i18n PREFIX=/usr
###############################################################################
#
# Install
#
###############################################################################
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p -m 755 $RPM_BUILD_ROOT/usr/sbin
mkdir -p -m 755 $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p -m 755 $RPM_BUILD_ROOT/usr/share/man/man8
cp rpm/dnsmasq.rh $RPM_BUILD_ROOT/etc/rc.d/init.d/dnsmasq
make install-i18n DESTDIR=$RPM_BUILD_ROOT PREFIX=/usr
strip $RPM_BUILD_ROOT/usr/sbin/dnsmasq
cp src/dnsmasq $RPM_BUILD_ROOT/usr/sbin
cp dnsmasq.conf.example $RPM_BUILD_ROOT/etc/dnsmasq.conf
###############################################################################
#
# Clean up
#
###############################################################################
%clean
rm -rf $RPM_BUILD_ROOT
###############################################################################
#
# Post-install scriptlet
#
###############################################################################
%post
/sbin/chkconfig --add dnsmasq
###############################################################################
#
# Pre-uninstall scriptlet
#
# If there's a time when your package needs to have one last look around before
# the user erases it, the place to do it is in the %preun script. Anything that
# a package needs to do immediately prior to RPM taking any action to erase the
# package, can be done here.
#
###############################################################################
%preun
if [ $1 = 0 ]; then # execute this only if we are NOT doing an upgrade
service dnsmasq stop >/dev/null 2>&1
/sbin/chkconfig --del dnsmasq
fi
###############################################################################
#
# Post-uninstall scriptlet
#
# The %postun script executes after the package has been removed. It is the
# last chance for a package to clean up after itself.
#
###############################################################################
%postun
if [ "$1" -ge "1" ]; then
service dnsmasq restart >/dev/null 2>&1
fi
###############################################################################
#
# File list
#
###############################################################################
%files
%defattr(-,root,root)
%doc CHANGELOG COPYING FAQ doc.html setup.html UPGRADING_to_2.0
%config /etc/rc.d/init.d/dnsmasq
%config /etc/dnsmasq.conf
%attr(0755,root,root) /etc/rc.d/init.d/dnsmasq
%attr(0664,root,root) /etc/dnsmasq.conf
%attr(0755,root,root) /usr/sbin/dnsmasq
#%attr(0644,root,root) /usr/share/man/*/man8/dnsmasq*
%attr(0644,root,root) /usr/share/man/man8/dnsmasq*
%attr(0644,root,root) /usr/share/locale/*/LC_MESSAGES/*
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
############################################################################### ###############################################################################
Name: dnsmasq Name: dnsmasq
Version: 2.30 Version: 2.31
Release: 1 Release: 1
Copyright: GPL Copyright: GPL
Group: Productivity/Networking/DNS/Servers Group: Productivity/Networking/DNS/Servers
......
...@@ -285,6 +285,12 @@ bogus-priv ...@@ -285,6 +285,12 @@ bogus-priv
# http://www.isc.org/index.pl?/sw/dhcp/authoritative.php # http://www.isc.org/index.pl?/sw/dhcp/authoritative.php
#dhcp-authoritative #dhcp-authoritative
# Run an executable when a DHCP lease is created or destroyed.
# The arguments sent to the script are "add" or "del",
# then the MAC address, the IP address and finally the hostname
# if there is one.
#dhcp-script=/bin/echo
# Set the cachesize here. # Set the cachesize here.
#cache-size=150 #cache-size=150
......
...@@ -22,7 +22,8 @@ Supported platforms include Linux (with glibc and uclibc), *BSD and ...@@ -22,7 +22,8 @@ Supported platforms include Linux (with glibc and uclibc), *BSD and
Mac OS X. Mac OS X.
Dnsmasq is included in at least the following Linux distributions: Dnsmasq is included in at least the following Linux distributions:
Gentoo, Debian, Slackware, Suse, Gentoo, Debian, Slackware, Suse,
Smoothwall, IP-Cop, floppyfw, Firebox, LEAF, Freesco, fli4l, CoyoteLinux and Smoothwall, IP-Cop, floppyfw, Firebox, LEAF, Freesco, fli4l,
CoyoteLinux, Endian Firewall and
Clarkconnect. It is also available as a FreeBSD port and is used in Clarkconnect. It is also available as a FreeBSD port and is used in
Linksys wireless routers and the m0n0wall project. Linksys wireless routers and the m0n0wall project.
<P> <P>
......
...@@ -533,7 +533,34 @@ is given but no dhcp-range option is given then dnsmasq version 1 ...@@ -533,7 +533,34 @@ is given but no dhcp-range option is given then dnsmasq version 1
behaviour is activated. The file given is assumed to be an ISC dhcpd behaviour is activated. The file given is assumed to be an ISC dhcpd
lease file and parsed for leases which are then added to the DNS lease file and parsed for leases which are then added to the DNS
system if they have a hostname. This functionality may have been system if they have a hostname. This functionality may have been
excluded from dnsmasq at compile time, in which case an error will occur. excluded from dnsmasq at compile time, in which case an error will
occur. In any case note that ISC leasefile integration is a deprecated
feature. It should not be used in new installations, and will be
removed in a future release.
.TP
.B \-6 --dhcp-script=<path>
Whenever a new DHCP lease is created, or an old one destroyed, the
binary specified by this option is run. The arguments to the binary
are "add", "old" or "del", the MAC
address of the host (or "<null>"), the IP address, and the hostname,
if known. "add" means a lease has been created, "del" means it has
been destroyed, "old" is a notification of an existing lease when
dnsmasq starts or a change to MAC address or hostname of an existing lease.
The process is run as any unprivileged user which dnsmasq
runs as, so it may be necessary to inhibit dropping of the root user,
using the
.B -u
directive, if the script needs root privs.
The environment is inherited from the invoker of dnsmasq,
and all file decriptors are
closed except stdin, stdout and stderr which are open to /dev/null
(except in debug mode).
The script is not invoked concurrently: if subsequent lease
changes occur, the script is not invoked again until any existing
invokation exits. At dnsmasq startup, the script will be invoked for
all existing leases as they are read from the lease file. Expired
leases will be called with "del" and others with "old". <path>
must be an absolute pathname, no PATH search occurs.
.TP .TP
.B \-s, --domain=<domain> .B \-s, --domain=<domain>
Specifies the domain for the DHCP server. This has two effects; Specifies the domain for the DHCP server. This has two effects;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
#
# Startup script for the DNS caching server
#
# chkconfig: 2345 99 01
# description: This script starts your DNS caching server
# processname: dnsmasq
# pidfile: /var/run/dnsmasq.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
dnsmasq=/usr/sbin/dnsmasq
[ -f $dnsmasq ] || exit 0
# change this line if you want dnsmasq to serve an MX record for
# the host it is running on.
MAILHOSTNAME=""
# change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
RESOLV_CONF=""
# change this if you want dnsmasq to cache any "hostname" or "client-hostname" from
# a dhcpd's lease file
DHCP_LEASE="/var/lib/dhcp/dhcpd.leases"
DOMAIN_SUFFIX=`dnsdomainname`
OPTIONS=""
if [ ! -z "${MAILHOSTNAME}" ]; then
OPTIONS="$OPTIONS -m $MAILHOSTNAME"
fi
if [ ! -z "${RESOLV_CONF}" ]; then
OPTIONS="$OPTIONS -r $RESOLV_CONF"
fi
if [ ! -z "${DHCP_LEASE}" ]; then
OPTIONS="$OPTIONS -l $DHCP_LEASE"
fi
if [ ! -z "${DOMAIN_SUFFIX}" ]; then
OPTIONS="$OPTIONS -s $DOMAIN_SUFFIX"
fi
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n "Starting dnsmasq: "
daemon $dnsmasq $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnsmasq
;;
stop)
if test "x`pidof dnsmasq`" != x; then
echo -n "Shutting down dnsmasq: "
killproc dnsmasq
fi
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnsmasq /var/run/dnsmasq.pid
;;
status)
status dnsmasq
RETVAL=$?
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
condrestart)
if test "x`/sbin/pidof dnsmasq`" != x; then
$0 stop
$0 start
RETVAL=$?
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
exit 1
esac
exit $RETVAL
...@@ -48,7 +48,12 @@ void init_bpf(struct daemon *daemon) ...@@ -48,7 +48,12 @@ void init_bpf(struct daemon *daemon)
{ {
sprintf(ifreq.iov_base, "/dev/bpf%d", i++); sprintf(ifreq.iov_base, "/dev/bpf%d", i++);
if ((daemon->dhcp_raw_fd = open(ifreq.iov_base, O_RDWR, 0)) != -1) if ((daemon->dhcp_raw_fd = open(ifreq.iov_base, O_RDWR, 0)) != -1)
return; {
int flags = fcntl(daemon->dhcp_raw_fd, F_GETFD);
if (flags != -1)
fcntl(daemon->dhcp_raw_fd, F_SETFD, flags | FD_CLOEXEC);
return;
}
} }
if (errno != EBUSY) if (errno != EBUSY)
die(_("cannot create DHCP BPF socket: %s"), NULL); die(_("cannot create DHCP BPF socket: %s"), NULL);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#define VERSION "2.30" #define VERSION "2.31"
#define FTABSIZ 150 /* max number of outstanding requests */ #define FTABSIZ 150 /* max number of outstanding requests */
#define MAX_PROCS 20 /* max no children for TCP requests */ #define MAX_PROCS 20 /* max no children for TCP requests */
...@@ -79,7 +79,8 @@ ...@@ -79,7 +79,8 @@
/* Get linux C library versions. */ /* Get linux C library versions. */
#if defined(__linux__) && !defined(__UCLIBC__) && !defined(__uClinux__) #if defined(__linux__) && !defined(__UCLIBC__) && !defined(__uClinux__)
# include <libio.h> /*# include <libio.h> */
# include <features.h>
#endif #endif
...@@ -203,11 +204,13 @@ NOTES: ...@@ -203,11 +204,13 @@ NOTES:
#define HAVE_DEV_URANDOM #define HAVE_DEV_URANDOM
#define HAVE_DEV_RANDOM #define HAVE_DEV_RANDOM
#undef HAVE_SOCKADDR_SA_LEN #undef HAVE_SOCKADDR_SA_LEN
#if !defined(__UCLIBC_HAS_MMU__) #if !defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__)
# define NO_FORK # define NO_FORK
#endif #endif
#if !defined(__UCLIBC_HAS_IPV6__) #if defined(__UCLIBC_HAS_IPV6__)
# define NO_IPV6 # ifndef IPV6_V6ONLY
# define IPV6_V6ONLY 26
# endif
#endif #endif
/* This is for glibc 2.x */ /* This is for glibc 2.x */
...@@ -282,4 +285,3 @@ typedef unsigned long in_addr_t; ...@@ -282,4 +285,3 @@ typedef unsigned long in_addr_t;
# define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */ # define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
#endif #endif
...@@ -240,7 +240,7 @@ DBusHandlerResult message_handler(DBusConnection *connection, ...@@ -240,7 +240,7 @@ DBusHandlerResult message_handler(DBusConnection *connection,
check_servers(daemon); check_servers(daemon);
} }
else if (strcmp(method, "ClearCache") == 0) else if (strcmp(method, "ClearCache") == 0)
clear_cache_and_reload(daemon); clear_cache_and_reload(daemon, dnsmasq_time());
else else
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
...@@ -260,7 +260,7 @@ char *dbus_init(struct daemon *daemon) ...@@ -260,7 +260,7 @@ char *dbus_init(struct daemon *daemon)
dbus_error_init (&dbus_error); dbus_error_init (&dbus_error);
if (!(connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error))) if (!(connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error)))
return NULL; return NULL;
dbus_connection_set_exit_on_disconnect(connection, FALSE); dbus_connection_set_exit_on_disconnect(connection, FALSE);
dbus_connection_set_watch_functions(connection, add_watch, remove_watch, dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
NULL, (void *)daemon, NULL); NULL, (void *)daemon, NULL);
......
...@@ -25,14 +25,13 @@ void dhcp_init(struct daemon *daemon) ...@@ -25,14 +25,13 @@ void dhcp_init(struct daemon *daemon)
{ {
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in saddr; struct sockaddr_in saddr;
int flags, oneopt = 1; int oneopt = 1;
struct dhcp_config *configs, *cp; struct dhcp_config *configs, *cp;
if (fd == -1) if (fd == -1)
die (_("cannot create DHCP socket : %s"), NULL); die (_("cannot create DHCP socket : %s"), NULL);
if ((flags = fcntl(fd, F_GETFL, 0)) == -1 || if (!fix_fd(fd) ||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1 ||
#if defined(HAVE_LINUX_NETWORK) #if defined(HAVE_LINUX_NETWORK)
setsockopt(fd, SOL_IP, IP_PKTINFO, &oneopt, sizeof(oneopt)) == -1 || setsockopt(fd, SOL_IP, IP_PKTINFO, &oneopt, sizeof(oneopt)) == -1 ||
#elif defined(IP_RECVIF) #elif defined(IP_RECVIF)
...@@ -203,8 +202,9 @@ void dhcp_packet(struct daemon *daemon, time_t now) ...@@ -203,8 +202,9 @@ void dhcp_packet(struct daemon *daemon, time_t now)
return; return;
lease_prune(NULL, now); /* lose any expired leases */ lease_prune(NULL, now); /* lose any expired leases */
iov.iov_len = dhcp_reply(daemon, parm.current, ifr.ifr_name, (size_t)sz, now, unicast_dest); iov.iov_len = dhcp_reply(daemon, parm.current, ifr.ifr_name, (size_t)sz, now, unicast_dest);
lease_update_file(daemon); lease_update_file(daemon, now);
lease_update_dns(daemon); lease_update_dns(daemon);
lease_collect(daemon);
if (iov.iov_len == 0) if (iov.iov_len == 0)
return; return;
...@@ -258,9 +258,18 @@ void dhcp_packet(struct daemon *daemon, time_t now) ...@@ -258,9 +258,18 @@ void dhcp_packet(struct daemon *daemon, time_t now)
/* unicast to unconfigured client */ /* unicast to unconfigured client */
dest.sin_addr = mess->yiaddr; dest.sin_addr = mess->yiaddr;
dest.sin_port = htons(DHCP_CLIENT_PORT); dest.sin_port = htons(DHCP_CLIENT_PORT);
if (mess->hlen != 0 && mess->htype != 0) if (mess->hlen != 0 && mess->hlen <= 14 && mess->htype != 0)
arp_inject(daemon->netlinkfd, mess->yiaddr, iface_index, {
mess->chaddr, mess->hlen); /* inject mac address direct into ARP cache.
struct sockaddr limits size to 14 bytes. */
struct arpreq req;
*((struct sockaddr_in *)&req.arp_pa) = dest;
req.arp_ha.sa_family = mess->htype;
memcpy(req.arp_ha.sa_data, mess->chaddr, mess->hlen);
strncpy(req.arp_dev, ifr.ifr_name, 16);
req.arp_flags = ATF_COM;
ioctl(daemon->dhcpfd, SIOCSARP, &req);
}
} }
#else #else
else else
......
This diff is collapsed.
...@@ -288,7 +288,9 @@ struct dhcp_lease { ...@@ -288,7 +288,9 @@ struct dhcp_lease {
int clid_len; /* length of client identifier */ int clid_len; /* length of client identifier */
unsigned char *clid; /* clientid */ unsigned char *clid; /* clientid */
char *hostname, *fqdn; /* name from client-hostname option or config */ char *hostname, *fqdn; /* name from client-hostname option or config */
int auth_name; /* hostname came from config, not from client */ char auth_name; /* hostname came from config, not from client */
char new; /* newly created */
char old; /* read from leasefile */
time_t expires; /* lease expiry */ time_t expires; /* lease expiry */
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
unsigned int length; unsigned int length;
...@@ -411,6 +413,7 @@ struct daemon { ...@@ -411,6 +413,7 @@ struct daemon {
char *username, *groupname; char *username, *groupname;
char *domain_suffix; char *domain_suffix;
char *runfile; char *runfile;
char *lease_change_command;
struct iname *if_names, *if_addrs, *if_except, *dhcp_except; struct iname *if_names, *if_addrs, *if_except, *dhcp_except;
struct bogus_addr *bogus_addr; struct bogus_addr *bogus_addr;
struct server *servers; struct server *servers;
...@@ -440,6 +443,7 @@ struct daemon { ...@@ -440,6 +443,7 @@ struct daemon {
struct server *last_server; struct server *last_server;
struct server *srv_save; /* Used for resend on DoD */ struct server *srv_save; /* Used for resend on DoD */
size_t packet_len; /* " " */ size_t packet_len; /* " " */
pid_t script_pid, tcp_pids[MAX_PROCS];
int num_kids; int num_kids;
/* DHCP state */ /* DHCP state */
...@@ -522,6 +526,8 @@ int parse_hex(char *in, unsigned char *out, int maxlen, ...@@ -522,6 +526,8 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
int memcmp_masked(unsigned char *a, unsigned char *b, int len, int memcmp_masked(unsigned char *a, unsigned char *b, int len,
unsigned int mask); unsigned int mask);
int expand_buf(struct iovec *iov, size_t size); int expand_buf(struct iovec *iov, size_t size);
char *print_mac(struct daemon *daemon, unsigned char *mac, int len);
/* option.c */ /* option.c */
struct daemon *read_opts (int argc, char **argv, char *compile_opts); struct daemon *read_opts (int argc, char **argv, char *compile_opts);
...@@ -541,6 +547,7 @@ struct listener *create_wildcard_listeners(int port); ...@@ -541,6 +547,7 @@ struct listener *create_wildcard_listeners(int port);
struct listener *create_bound_listeners(struct daemon *daemon); struct listener *create_bound_listeners(struct daemon *daemon);
int iface_check(struct daemon *daemon, int family, int iface_check(struct daemon *daemon, int family,
struct all_addr *addr, char *name); struct all_addr *addr, char *name);
int fix_fd(int fd);
/* dhcp.c */ /* dhcp.c */
void dhcp_init(struct daemon *daemon); void dhcp_init(struct daemon *daemon);
...@@ -564,12 +571,11 @@ char *strip_hostname(struct daemon *daemon, char *hostname); ...@@ -564,12 +571,11 @@ char *strip_hostname(struct daemon *daemon, char *hostname);
char *host_from_dns(struct daemon *daemon, struct in_addr addr); char *host_from_dns(struct daemon *daemon, struct in_addr addr);
/* lease.c */ /* lease.c */
void lease_update_file(struct daemon *daemon); void lease_update_file(struct daemon *daemon, time_t now);
void lease_update_dns(struct daemon *daemon); void lease_update_dns(struct daemon *daemon);
void lease_init(struct daemon *daemon, time_t now); void lease_init(struct daemon *daemon, time_t now);
struct dhcp_lease *lease_allocate(unsigned char *hwaddr, unsigned char *clid, struct dhcp_lease *lease_allocate(struct in_addr addr);
int hw_len, int hw_type, int clid_len, struct in_addr addr); void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
int lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
unsigned char *clid, int hw_len, int hw_type, int clid_len); unsigned char *clid, int hw_len, int hw_type, int clid_len);
void lease_set_hostname(struct dhcp_lease *lease, char *name, void lease_set_hostname(struct dhcp_lease *lease, char *name,
char *suffix, int auth); char *suffix, int auth);
...@@ -579,6 +585,7 @@ struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr, int hw_len, int h ...@@ -579,6 +585,7 @@ struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr, int hw_len, int h
struct dhcp_lease *lease_find_by_addr(struct in_addr addr); struct dhcp_lease *lease_find_by_addr(struct in_addr addr);
void lease_prune(struct dhcp_lease *target, time_t now); void lease_prune(struct dhcp_lease *target, time_t now);
void lease_update_from_configs(struct daemon *daemon); void lease_update_from_configs(struct daemon *daemon);
void lease_collect(struct daemon *daemon);
/* rfc2131.c */ /* rfc2131.c */
size_t dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, size_t sz, time_t now, int unicast_dest); size_t dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, size_t sz, time_t now, int unicast_dest);
...@@ -586,7 +593,7 @@ size_t dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *ifa ...@@ -586,7 +593,7 @@ size_t dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *ifa
/* dnsmasq.c */ /* dnsmasq.c */
int make_icmp_sock(void); int make_icmp_sock(void);
int icmp_ping(struct daemon *daemon, struct in_addr addr); int icmp_ping(struct daemon *daemon, struct in_addr addr);
void clear_cache_and_reload(struct daemon *daemon); void clear_cache_and_reload(struct daemon *daemon, time_t now);
/* isc.c */ /* isc.c */
#ifdef HAVE_ISC_READER #ifdef HAVE_ISC_READER
...@@ -599,8 +606,6 @@ void netlink_init(struct daemon *daemon); ...@@ -599,8 +606,6 @@ void netlink_init(struct daemon *daemon);
int iface_enumerate(struct daemon *daemon, void *parm, int iface_enumerate(struct daemon *daemon, void *parm,
int (*ipv4_callback)(), int (*ipv6_callback)()); int (*ipv4_callback)(), int (*ipv6_callback)());
void netlink_multicast(struct daemon *daemon); void netlink_multicast(struct daemon *daemon);
void arp_inject(int fd, struct in_addr addr,
int iface, unsigned char *mac, unsigned int mac_len);
#endif #endif
/* bpf.c */ /* bpf.c */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -19,7 +19,7 @@ struct myoption { ...@@ -19,7 +19,7 @@ struct myoption {
int val; int val;
}; };
#define OPTSTRING "531yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:" #define OPTSTRING "531yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:"
static const struct myoption opts[] = { static const struct myoption opts[] = {
{"version", 0, 0, 'v'}, {"version", 0, 0, 'v'},
...@@ -82,6 +82,7 @@ static const struct myoption opts[] = { ...@@ -82,6 +82,7 @@ static const struct myoption opts[] = {
{"bootp-dynamic", 0, 0, '3'}, {"bootp-dynamic", 0, 0, '3'},
{"dhcp-mac", 1, 0, '4'}, {"dhcp-mac", 1, 0, '4'},
{"no-ping", 0, 0, '5'}, {"no-ping", 0, 0, '5'},
{"dhcp-script", 1, 0, '6'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
...@@ -180,6 +181,7 @@ static const struct { ...@@ -180,6 +181,7 @@ static const struct {
{ "-3, --bootp-dynamic", gettext_noop("Enable dynamic address allocation for bootp."), NULL }, { "-3, --bootp-dynamic", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
{ "-4, --dhcp-mac=<id>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL }, { "-4, --dhcp-mac=<id>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
{ "-5, --no-ping", gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL }, { "-5, --no-ping", gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL },
{ "-6, --dhcp-script=path", gettext_noop("Script to run on DHCP lease creation and destruction."), NULL },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
...@@ -609,6 +611,15 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts) ...@@ -609,6 +611,15 @@ struct daemon *read_opts (int argc, char **argv, char *compile_opts)
case 'l': case 'l':
daemon->lease_file = safe_string_alloc(arg); daemon->lease_file = safe_string_alloc(arg);
break; break;
case '6':
#ifdef NO_FORK
problem = _("cannot run scripts under uClinux");
option = '?';
#else
daemon->lease_change_command = safe_string_alloc(arg);
#endif
break;
case 'H': case 'H':
{ {
......
This diff is collapsed.
...@@ -396,3 +396,17 @@ int expand_buf(struct iovec *iov, size_t size) ...@@ -396,3 +396,17 @@ int expand_buf(struct iovec *iov, size_t size)
return 1; return 1;
} }
char *print_mac(struct daemon *daemon, unsigned char *mac, int len)
{
char *p = daemon->namebuff;
int i;
if (len == 0)
sprintf(p, "<null>");
else
for (i = 0; i < len; i++)
p += sprintf(p, "%.2x%s", mac[i], (i == len - 1) ? "" : ":");
return daemon->namebuff;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment