aboutsummaryrefslogtreecommitdiffstats
path: root/net/isc-dhcp40-server
diff options
context:
space:
mode:
Diffstat (limited to 'net/isc-dhcp40-server')
-rw-r--r--net/isc-dhcp40-server/Makefile51
-rw-r--r--net/isc-dhcp40-server/files/isc-dhcpd.sh.sample98
-rw-r--r--net/isc-dhcp40-server/files/isc-dhcrelay.sh.sample100
-rw-r--r--net/isc-dhcp40-server/files/patch-client::clparse.c11
-rw-r--r--net/isc-dhcp40-server/files/patch-client::dhclient.883
-rw-r--r--net/isc-dhcp40-server/files/patch-client::dhclient.c545
-rw-r--r--net/isc-dhcp40-server/files/patch-client::dhclient.conf11
-rw-r--r--net/isc-dhcp40-server/files/patch-common::dhcp-options.532
-rw-r--r--net/isc-dhcp40-server/files/patch-common::discover.c238
-rw-r--r--net/isc-dhcp40-server/files/patch-common::dispatch.c29
-rw-r--r--net/isc-dhcp40-server/files/patch-common::parse.c22
-rw-r--r--net/isc-dhcp40-server/files/patch-dst::Makefile.dist29
-rw-r--r--net/isc-dhcp40-server/files/patch-freebsd45
-rw-r--r--net/isc-dhcp40-server/files/patch-includes::cf::freebsd.h53
-rw-r--r--net/isc-dhcp40-server/files/patch-includes::dhcpd.h56
-rw-r--r--net/isc-dhcp40-server/files/patch-site.conf8
-rw-r--r--net/isc-dhcp40-server/files/rc.isc-dhcpd.conf.sample7
-rw-r--r--net/isc-dhcp40-server/files/rc.isc-dhcrelay.conf.sample8
-rw-r--r--net/isc-dhcp40-server/pkg-message20
-rw-r--r--net/isc-dhcp40-server/pkg-plist6
20 files changed, 1283 insertions, 169 deletions
diff --git a/net/isc-dhcp40-server/Makefile b/net/isc-dhcp40-server/Makefile
index 069372c3bc0a..5677d5c1d8f7 100644
--- a/net/isc-dhcp40-server/Makefile
+++ b/net/isc-dhcp40-server/Makefile
@@ -8,6 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.1.r12
+PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@@ -19,6 +20,7 @@ MAINTAINER= cyrille.lefevre@laposte.net
COMMENT?= The ISC Dynamic Host Configuration Protocol server
USE_REINPLACE= yes
+USE_RC_SUBR= yes
.include <bsd.port.pre.mk>
@@ -111,6 +113,21 @@ RC_DIR= ${PREFIX}/etc/rc.d
DOCSDIR= ${PREFIX}/share/doc/${PKGBASE}
DATADIR= /var/db
+REINPLACE_SUB= PREFIX=${PREFIX}
+RCSCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
+PKGMESSAGE_SUB= PREFIX=${PREFIX} MAN1PREFIX=${MAN1PREFIX}
+
+# Pre-everything
+#
+
+.if ${SUBSYS} == client && !defined(WITHOUT_INTERFACE_POLLING)
+pre-everything::
+ @${ECHO_MSG}
+ @${ECHO_MSG} "If you want to compile without interface polling support."
+ @${ECHO_MSG} "hit Ctrl-C right now and use \"make WITHOUT_INTERFACE_POLLING=yes\""
+ @${ECHO_MSG}
+.endif
+
# Post-extract
#
@@ -127,12 +144,19 @@ extract-omshell:
post-patch: patch-scripts patch-makefile-conf \
patch-makefiles-dist patch-man-pages \
- patch-pkgmessage
+ patch-pkgmessage patch-site-conf \
+ patch-rc-scripts
patch-scripts:
- @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g' \
+ @${REINPLACE_CMD} ${REINPLACE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
+ ${WRKSRC}/client/dhclient.conf \
${WRKSRC}/client/scripts/freebsd
+patch-site-conf:
+.if ${SUBSYS} == client && !defined(WITHOUT_INTERFACE_POLLING)
+ @${ECHO_CMD} CFLAGS += -DENABLE_POLLING_MODE >> ${WRKSRC}/site.conf
+.endif
+
patch-makefile-conf:
@${REINPLACE_CMD} -e 's|^DEBUG[ ]*=|# DEBUG ?=|g' \
${WRKSRC}/Makefile.conf
@@ -147,9 +171,17 @@ patch-makefiles-dist:
patch-man-pages:
@${REINPLACE_CMD} -e '/^\.Fd$$/d' ${WRKSRC}/dhcpctl/dhcpctl.3
+patch-rc-scripts:
+.for f in ${RC_FILES}
+ @${SED} ${RCSCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
+ ${FILESDIR}/${f}.sh${SAMP_SUFX} > ${WRKDIR}/${f}.sh
+.endfor
+
patch-pkgmessage:
- @${SED} 's|%%PREFIX%%|${PREFIX}|g;s|%%MAN1PREFIX%%|${MAN1PREFIX}|g' \
+.if ${SUBSYS} != devel
+ @${SED} ${PKGMESSAGE_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
${MSG_FILE} > ${PKGMESSAGE}
+.endif
# Post-install
#
@@ -171,16 +203,7 @@ strip-binary-files:
install-startup-files:
.for f in ${RC_FILES}
-.if exists(${FILESDIR}/rc.${f}.conf${SAMP_SUFX})
- @${INSTALL_DATA} ${FILESDIR}/rc.${f}.conf${SAMP_SUFX} ${CONF_DIR}
-.if !exists(${CONF_DIR}/rc.${f}.conf)
- @${INSTALL_DATA} ${FILESDIR}/rc.${f}.conf${SAMP_SUFX} \
- ${CONF_DIR}/rc.${f}.conf
-.endif
-.endif
-.if exists(${FILESDIR}/${f}.sh${SAMP_SUFX})
- @${INSTALL_SCRIPT} ${FILESDIR}/${f}.sh${SAMP_SUFX} ${RC_DIR}
-.endif
+ @${INSTALL_SCRIPT} ${WRKDIR}/${f}.sh ${RC_DIR}
.endfor
install-doc-files:
@@ -211,8 +234,10 @@ create-data-files:
.endfor
display-message:
+.if ${SUBSYS} != devel
@${ECHO_MSG}
@${CAT} ${PKGMESSAGE}
@${ECHO_MSG}
+.endif
.include <bsd.port.post.mk>
diff --git a/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample b/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
index 17472ab3bb71..63bc57ba0f3d 100644
--- a/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
+++ b/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
@@ -2,77 +2,47 @@
#
# $FreeBSD$
#
-# Start or stop isc-dhcpd.
+# PROVIDE: dhcpd
+# REQUIRE: DAEMON
+# KEYWORD: FreeBSD
+#
+# Add the following line to /etc/rc.conf to enable dhcpd:
+#
+# dhcpd_enable="YES"
#
-rc_file=${0##*/}
-rc_arg=$1
-
-# override these variables in ${PREFIX}/etc/rc.isc-dhcpd.conf
-dhcpd_options= # command option(s)
-dhcpd_ifaces= # ethernet interface(s)
-
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${rc_file}\$"); then
- echo "${rc_file}: Cannot determine PREFIX." >&2
- echo "Please use the complete pathname." >&2
- exit 64
-fi
+# override these variables in /etc/rc.conf
+dhcpd_enable=NO
+dhcpd_flags= # command option(s)
+dhcpd_conf=%%PREFIX%%/etc/dhcpd.conf # configuration file
+dhcpd_ifaces= # ethernet interface(s)
-rcconf_dir=${PREFIX}/etc
-rcconf_file=rc.${rc_file%.sh}.conf
-rcconf_path=${rcconf_dir}/${rcconf_file}
+dhcpd_precmd ()
+{
+ dhcpd_rcconf=%%PREFIX%%/etc/rc.isc-dhcpd.conf
-if [ -f ${rcconf_path} ]; then
- . ${rcconf_path}
-fi
+ if [ -f ${dhcpd_rcconf} ]; then
+ warn "${dhcpd_rcconf} is obsolete, use /etc/rc.conf instead."
+ . ${dhcpd_rcconf}
-program_dir=${PREFIX}/sbin
-program_file=dhcpd
-program_path=${program_dir}/${program_file}
+ if [ -n "${dhcpd_options}" -a -z "${rc_flags}" ]; then
+ warn "dhcpd_options is obsolete, use dhcpd_flags instead."
+ rc_flags=${dhcpd_options}
+ fi
+ fi
-config_dir=${PREFIX}/etc
-config_file=${program_file}.conf
-config_path=${config_dir}/${config_file}
+ rc_flags="${rc_flags} -cf ${dhcpd_conf} ${dhcpd_ifaces}"
+}
-pid_dir=/var/run
-pid_file=${program_file}.pid
-pid_path=${pid_dir}/${pid_file}
+. %%RC_SUBR%%
-syslog_facility=daemon.err
+name=dhcpd
+rcvar=$(set_rcvar)
-case "$rc_arg" in
-start)
- if [ ! -x ${program_path} ]; then
- logger -sp ${syslog_facility} -t ${program_file} \
- "unable to start: ${program_path} is missing."
- exit 72
- fi
- if [ ! -f ${config_path} ]; then
- logger -sp ${syslog_facility} -t ${program_file} \
- "unable to start: ${config_path} is missing."
- exit 72
- fi
- ${program_path} ${dhcpd_options} ${dhcpd_ifaces} &&
- echo -n " ${program_file}"
- ;;
-stop)
- if [ -r ${pid_path} ]; then
- kill $(cat ${pid_path}) 2> /dev/null
- else
- killall ${program_file} 2> /dev/null
- fi
- ;;
-restart)
- $0 stop
- $0 start
- ;;
-status)
- ps -auxww | egrep ${program_file} | egrep -v "($0|egrep)"
- ;;
-*)
- echo "usage: ${rc_file} {start|stop|restart|status}" >&2
- exit 64
- ;;
-esac
+command=%%PREFIX%%/sbin/${name}
+pidfile=/var/run/${name}.pid
+required_files=${dhcpd_conf}
+start_precmd=${name}_precmd
-exit 0
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/net/isc-dhcp40-server/files/isc-dhcrelay.sh.sample b/net/isc-dhcp40-server/files/isc-dhcrelay.sh.sample
index de5f111d133c..4302d7360ff1 100644
--- a/net/isc-dhcp40-server/files/isc-dhcrelay.sh.sample
+++ b/net/isc-dhcp40-server/files/isc-dhcrelay.sh.sample
@@ -2,77 +2,57 @@
#
# $FreeBSD$
#
-# Start or stop isc-dhcrelay.
+# PROVIDE: dhcrelay
+# REQUIRE: DAEMON
+# KEYWORD: FreeBSD
+#
+# Add the following line to /etc/rc.conf to enable dhcrelay:
+#
+# dhcrelay_enable="YES"
#
-rc_file=${0##*/}
-rc_arg=$1
-
-# override these variables in ${PREFIX}/etc/rc.isc-dhcrelay.conf
-dhcrelay_options= # command option(s)
+# override these variables in /etc/rc.conf
+dhcrelay_enable=NO
+dhcrelay_flags= # command option(s)
+dhcrelay_servers= # dhcrelay server(s)
dhcrelay_ifaces= # ethernet interface(s)
-dhcrelay_servers= # dhcpd server(s)
-
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${rc_file}\$"); then
- echo "${rc_file}: Cannot determine PREFIX." >&2
- echo "Please use the complete pathname." >&2
- exit 64
-fi
-rcconf_dir=${PREFIX}/etc
-rcconf_file=rc.${rc_file%.sh}.conf
-rcconf_path=${rcconf_dir}/${rcconf_file}
+dhcrelay_precmd ()
+{
+ local ifaces
-if [ -f ${rcconf_path} ]; then
- . ${rcconf_path}
-fi
+ dhcrelay_rcconf=%%PREFIX%%/etc/rc.isc-dhcrelay.conf
-program_dir=${PREFIX}/sbin
-program_file=dhcrelay
-program_path=${program_dir}/${program_file}
+ if [ -f ${dhcrelay_rcconf} ]; then
+ warn "${dhcrelay_rcconf} is obsolete, use /etc/rc.conf instead."
+ . ${dhcrelay_rcconf}
-pid_dir=/var/run
-pid_file=${program_file}.pid
-pid_path=${pid_dir}/${pid_file}
-
-syslog_facility=daemon.err
-
-case "$rc_arg" in
-start)
- if [ ! -x ${program_path} ]; then
- logger -sp ${syslog_facility} -t ${program_file} \
- "unable to start: ${program_path} is missing."
- exit 72
+ if [ -n "${dhcrelay_options}" -a -z "${rc_flags}" ]; then
+ warn "dhcrelay_options is obsolete, use dhcrelay_flags instead."
+ rc_flags=${dhcrelay_options}
+ fi
fi
+
if [ -z "${dhcrelay_servers}" ]; then
- logger -sp ${syslog_facility} -t ${program_file} \
- "unable to start: no dhcpd server(s) configured."
- exit 64
+ err 1 "no dhcrelay server(s) configured."
fi
+
ifaces=
for iface in ${dhcrelay_ifaces}; do
- ifaces="$ifaces -i $iface"
+ ifaces="${ifaces} -i ${iface}"
done
- ${program_path} ${dhcrelay_options} ${ifaces} ${dhcrelay_servers} &&
- echo -n " ${program_file}"
- ;;
-stop)
- if [ -r ${pid_path} ]; then
- kill $(cat ${pid_path}) 2> /dev/null
- else
- killall ${program_file} 2> /dev/null
- fi
- ;;
-restart)
- $0 stop
- $0 start
- ;;
-status)
- ps -auxww | egrep ${program_file} | egrep -v "($0|egrep)"
- ;;
-*)
- echo "usage: ${rc_file} {start|stop|restart|status}" >&2
- ;;
-esac
-exit 0
+ rc_flags="${rc_flags} ${ifaces} ${dhcrelay_servers}"
+}
+
+. %%RC_SUBR%%
+
+name=dhcrelay
+rcvar=$(set_rcvar)
+
+command=%%PREFIX%%/sbin/${name}
+pidfile=/var/run/${name}.pid
+start_precmd=${name}_precmd
+
+load_rc_config ${name}
+run_rc_command "$1"
diff --git a/net/isc-dhcp40-server/files/patch-client::clparse.c b/net/isc-dhcp40-server/files/patch-client::clparse.c
new file mode 100644
index 000000000000..4140cc6e3109
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-client::clparse.c
@@ -0,0 +1,11 @@
+--- client/clparse.c.orig Mon Feb 10 01:39:57 2003
++++ client/clparse.c Wed Mar 3 01:35:39 2004
+@@ -785,7 +785,7 @@
+ if (status != ISC_R_SUCCESS)
+ log_fatal ("Can't record interface %s: %s",
+ name, isc_result_totext (status));
+- strcpy (ip -> name, name);
++ strlcpy (ip -> name, name, IFNAMSIZ);
+ if (dummy_interfaces) {
+ interface_reference (&ip -> next,
+ dummy_interfaces, MDL);
diff --git a/net/isc-dhcp40-server/files/patch-client::dhclient.8 b/net/isc-dhcp40-server/files/patch-client::dhclient.8
new file mode 100644
index 000000000000..a602907c31b6
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-client::dhclient.8
@@ -0,0 +1,83 @@
+--- client/dhclient.8.orig Sun Nov 17 03:25:43 2002
++++ client/dhclient.8 Wed Mar 3 02:06:52 2004
+@@ -18,6 +18,10 @@
+ .\"
+ .\" $Id: dhclient.8,v 1.12.2.7 2002/11/17 02:25:43 dhankins Exp $
+ .\"
++.\" Portions copyright (c) 2000 David E. O'Brien.
++.\" All rights reserved.
++.\" $FreeBSD$
++.\"
+ .TH dhclient 8
+ .SH NAME
+ dhclient - Dynamic Host Configuration Protocol Client
+@@ -28,12 +32,18 @@
+ .I port
+ ]
+ [
++.B -D
++]
++[
+ .B -d
+ ]
+ [
+ .B -q
+ ]
+ [
++.B -v
++]
++[
+ .B -1
+ ]
+ [
+@@ -64,6 +74,10 @@
+ relay
+ ]
+ [
++.B -i
++interval
++]
++[
+ .B -n
+ ]
+ [
+@@ -148,6 +162,15 @@
+ configuration file or on the command line, and will ignore all other
+ interfaces.
+ .PP
++The
++.B -D
++flag causes
++.B dhclient
++to save the script it creates for use in conjunction with
++.B dhclient-script
++in
++.IR /tmp.
++.PP
+ If the DHCP client should listen and transmit on a port other than the
+ standard (port 68), the
+ .B -p
+@@ -171,6 +194,12 @@
+ flag, followed by the IP address to send. This is only useful for testing,
+ and should not be expected to work in any consistent or useful way.
+ .PP
++On FreeBSD, dhclient can be enabled to automatically handle the
++link status of the network card. Normally polling is done every
++five seconds. The polling interval can be set using the
++.B -i
++flag, followed by the numbers of seconds. Minimum is one second.
++.PP
+ The DHCP client will normally run in the foreground until it has
+ configured an interface, and then will revert to running in the
+ background. To run force dhclient to always run as a foreground
+@@ -188,6 +217,10 @@
+ .B -q
+ flag prevents any messages other than errors from being printed to the
+ standard error descriptor.
++.B -v
++flag turns on all messages.
++Opposite of
++.B -q .
+ .PP
+ The client normally doesn't release the current lease as it is not
+ required by the DHCP protocol. Some cable ISPs require their clients
diff --git a/net/isc-dhcp40-server/files/patch-client::dhclient.c b/net/isc-dhcp40-server/files/patch-client::dhclient.c
new file mode 100644
index 000000000000..6ad84bfa9e13
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-client::dhclient.c
@@ -0,0 +1,545 @@
+--- client/dhclient.c.orig Sat Apr 26 23:51:39 2003
++++ client/dhclient.c Wed Mar 3 16:21:02 2004
+@@ -47,6 +47,13 @@
+ #include "dhcpd.h"
+ #include "version.h"
+
++#ifdef __FreeBSD__
++#include <sys/ioctl.h>
++#include <net/if_media.h>
++#include <net80211/ieee80211_ioctl.h>
++#include <net80211/ieee80211.h>
++#endif
++
+ TIME cur_time;
+ TIME default_lease_time = 43200; /* 12 hours... */
+ TIME max_lease_time = 86400; /* 24 hours... */
+@@ -82,8 +89,11 @@
+ struct string_list *client_env=NULL;
+ int client_env_count=0;
+ int onetry=0;
+-int quiet=0;
++int quiet=1;
+ int nowait=0;
++#ifdef ENABLE_POLLING_MODE
++int polling_interval = 5;
++#endif
+
+ static void usage PROTO ((void));
+
+@@ -184,6 +194,9 @@
+ } else if (!strcmp (argv [i], "-q")) {
+ quiet = 1;
+ quiet_interface_discovery = 1;
++ } else if (!strcmp (argv [i], "-v")) {
++ quiet = 0;
++ quiet_interface_discovery = 0;
+ } else if (!strcmp (argv [i], "-s")) {
+ if (++i == argc)
+ usage ();
+@@ -197,6 +210,19 @@
+ } else if (!strcmp (argv [i], "-n")) {
+ /* do not start up any interfaces */
+ interfaces_requested = 1;
++#ifdef ENABLE_POLLING_MODE
++ } else if (!strcmp (argv [i], "-i")) {
++ if (++i == argc)
++ usage ();
++ polling_interval = (int)strtol (argv [i],
++ (char **)NULL, 10);
++ if (polling_interval <= 0) {
++ log_info ("Incorrect polling interval %d",
++ polling_interval);
++ log_info ("Using a default of 5 seconds");
++ polling_interval = 5;
++ }
++#endif
+ } else if (!strcmp (argv [i], "-w")) {
+ /* do not exit if there are no broadcast interfaces. */
+ persist = 1;
+@@ -225,7 +251,16 @@
+ if (strlen (argv [i]) > sizeof tmp -> name)
+ log_fatal ("%s: interface name too long (max %ld)",
+ argv [i], (long)strlen (argv [i]));
+- strcpy (tmp -> name, argv [i]);
++ strlcpy (tmp -> name, argv [i], IFNAMSIZ);
++#ifdef __FreeBSD__
++ set_ieee80211 (tmp);
++#endif
++ /* Init some interface vars, enable polling */
++#ifdef ENABLE_POLLING_MODE
++ tmp -> forcediscover = 0;
++ tmp -> linkstate = HAVELINK;
++ tmp -> polling = 1;
++#endif /* ifdef ENABLE_POLLING_MODE */
+ if (interfaces) {
+ interface_reference (&tmp -> next,
+ interfaces, MDL);
+@@ -385,6 +420,16 @@
+ INTERFACE_AUTOMATIC)) !=
+ INTERFACE_REQUESTED))
+ continue;
++#ifdef __FreeBSD__
++ set_ieee80211 (ip);
++#endif
++#ifdef ENABLE_POLLING_MODE
++ ip -> forcediscover = 0;
++ if (ip -> client -> config -> media != NULL)
++ ip -> havemedia = 1;
++ else
++ ip -> havemedia = 0;
++#endif
+ script_init (ip -> client,
+ "PREINIT", (struct string_list *)0);
+ if (ip -> client -> alias)
+@@ -427,8 +472,13 @@
+ client -> state = S_INIT;
+ /* Set up a timeout to start the initialization
+ process. */
++#ifdef ENABLE_POLLING_MODE
++ add_timeout (cur_time + random () % 5 + 2,
++ state_polling, client, 0, 0);
++#else
+ add_timeout (cur_time + random () % 5,
+ state_reboot, client, 0, 0);
++#endif
+ }
+ }
+ }
+@@ -486,9 +536,9 @@
+ log_info (arr);
+ log_info (url);
+
+- log_error ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s",
+- "[-s server]");
+- log_error (" [-cf config-file] [-lf lease-file]%s",
++ log_error ("Usage: dhclient [-1Ddqrv] [-i polling-interval] %s",
++ "[-nw] [-p <port>] [-s server]");
++ log_error (" [-cf config-file] [-lf lease-file] %s",
+ "[-pf pid-file] [-e VAR=val]");
+ log_fatal (" [-sf script-file] [interface]");
+ }
+@@ -876,6 +926,15 @@
+ /* Write out the new lease. */
+ write_client_lease (client, client -> new, 0, 0);
+
++ /*
++ * It's now possible that state_reboot can be called
++ * after a interface link went down and is up again.
++ * To prevent tons of equal leases saved on disk, we rewrite
++ * them.
++ */
++ read_client_leases ();
++ rewrite_client_leases ();
++
+ /* Replace the old active lease with the new one. */
+ if (client -> active)
+ destroy_client_lease (client -> active);
+@@ -890,6 +949,12 @@
+ piaddr (client -> active -> address),
+ (long)(client -> active -> renewal - cur_time));
+ client -> state = S_BOUND;
++#ifdef ENABLE_POLLING_MODE
++ /* Init some interface vars, enable polling */
++ client -> interface -> linkstate = HAVELINK;
++ client -> interface -> forcediscover = 0;
++ client -> interface -> polling = 1;
++#endif /* ifdef ENABLE_POLLING_MODE */
+ reinitialize_interfaces ();
+ go_daemon ();
+ if (client -> config -> do_forward_update) {
+@@ -1352,6 +1417,11 @@
+ int interval;
+ int increase = 1;
+
++#ifdef ENABLE_POLLING_MODE
++ /* Disable polling for this interface */
++ client -> interface -> polling = 0;
++#endif
++
+ /* Figure out how long it's been since we started transmitting. */
+ interval = cur_time - client -> first_sending;
+
+@@ -1457,6 +1527,9 @@
+ struct client_lease *loop;
+ struct client_lease *lp;
+
++ if (client -> interface -> linkstate == NOLINK)
++ return;
++
+ loop = lp = client -> active;
+
+ log_info ("No DHCPOFFERS received.");
+@@ -1489,6 +1562,10 @@
+ log_info ("bound: renewal in %ld %s.",
+ (long)(client -> active -> renewal -
+ cur_time), "seconds");
++#ifdef ENABLE_POLLING_MODE
++ /* Enable polling for this interface */
++ client -> interface -> polling = 1;
++#endif
+ add_timeout (client -> active -> renewal,
+ state_bound, client, 0, 0);
+ } else {
+@@ -1496,6 +1573,11 @@
+ log_info ("bound: immediate renewal.");
+ state_bound (client);
+ }
++ /*
++ * Set the link status back to nolink, even
++ * if we have media settings.
++ */
++ client -> interface -> linkstate = NOLINK;
+ reinitialize_interfaces ();
+ go_daemon ();
+ return;
+@@ -1541,6 +1623,12 @@
+ }
+
+ log_info ("No working leases in persistent database - sleeping.");
++
++#ifdef ENABLE_POLLING_MODE
++ /* Enable polling for this interface */
++ client -> interface -> polling = 1;
++#endif
++
+ script_init (client, "FAIL", (struct string_list *)0);
+ if (client -> alias)
+ script_write_params (client, "alias_", client -> alias);
+@@ -1681,6 +1769,18 @@
+ client -> packet.secs = htons (65535);
+ }
+
++ /*
++ * Only try the first ten seconds to renew a lease from a
++ * given dhcp-server adress. After that, fall back to use
++ * state_reboot with INADDR_BROADCAST.
++ */
++ if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
++ (client -> state == S_RENEWING || client -> state == S_REBINDING)) {
++ if (client -> active && client -> active -> expiry > cur_time &&
++ interval >= 10)
++ goto cancel;
++ }
++
+ log_info ("DHCPREQUEST on %s to %s port %d",
+ client -> name ? client -> name : client -> interface -> name,
+ inet_ntoa (destination.sin_addr),
+@@ -1702,6 +1802,16 @@
+ from, &destination,
+ (struct hardware *)0);
+
++ /*
++ * If sendto() for a direct request fails, fall back to use
++ * state_reboot with INADDR_BROADCAST.
++ */
++ if (result == -1 && destination.sin_addr.s_addr != INADDR_BROADCAST &&
++ (client -> state == S_RENEWING || client -> state == S_REBINDING)) {
++ if (client -> active && client -> active -> expiry > cur_time)
++ goto cancel;
++ }
++
+ add_timeout (cur_time + client -> interval,
+ send_request, client, 0, 0);
+ }
+@@ -2597,6 +2707,13 @@
+ wstatus = 0;
+ }
+ } else {
++ if ((i = open(_PATH_DEVNULL, O_RDWR)) != -1) {
++ dup2(i, STDIN_FILENO);
++ dup2(i, STDOUT_FILENO);
++ dup2(i, STDERR_FILENO);
++ if (i > STDERR_FILENO)
++ close(i);
++ }
+ execve (scriptName, argv, envp);
+ log_error ("execve (%s, ...): %m", scriptName);
+ exit (0);
+@@ -2783,8 +2900,10 @@
+ case S_STOPPED:
+ break;
+ }
++#ifndef ENABLE_POLLING_MODE
+ client -> state = S_INIT;
+ state_reboot (client);
++#endif
+ }
+ }
+ }
+@@ -3010,7 +3129,9 @@
+ break;
+
+ case server_awaken:
++#ifndef ENABLE_POLLING_MODE
+ state_reboot (client);
++#endif
+ break;
+ }
+ }
+@@ -3147,3 +3268,265 @@
+ data_string_forget (&ddns_dhcid, MDL);
+ return rcode;
+ }
++
++/* Check to see if there's a wire plugged in */
++int
++interface_active(struct interface_info *ip) {
++#ifdef __FreeBSD__
++ struct ifmediareq ifmr;
++ int *media_list, i;
++ char *ifname;
++ int sock;
++
++ ifname = ip -> name;
++
++ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
++ log_fatal ("Can't create interface_active socket");
++
++ (void) memset (&ifmr, 0, sizeof (ifmr));
++ (void) strncpy (ifmr.ifm_name, ifname, sizeof (ifmr.ifm_name));
++
++ if (ioctl (sock, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
++ /*
++ * Interface doesn't support SIOCGIFMEDIA, presume okay
++ */
++ close (sock);
++ return (HAVELINK);
++ }
++ close (sock);
++
++ if (ifmr.ifm_count == 0) {
++ /*
++ * Assume that this means interface
++ * does not support SIOCGIFMEDIA
++ */
++ log_fatal ("%s: no media types?", ifname);
++ return (HAVELINK);
++ }
++
++ if (ifmr.ifm_status & IFM_AVALID) {
++ if (ip -> ieee80211) {
++ /*
++ * Wavelan devices need to be checked if they are
++ * associated.
++ */
++ if ((IFM_TYPE(ifmr.ifm_active) == IFM_IEEE80211) &&
++ (ifmr.ifm_status & IFM_ACTIVE)) {
++ return (HAVELINK);
++ }
++ } else {
++ if (ifmr.ifm_status & IFM_ACTIVE) {
++ return (HAVELINK);
++ }
++ }
++ /*
++ * We really have no link.
++ */
++ return (NOLINK);
++ }
++ /*
++ * IFM_AVALID is not set. We cannot check
++ * the link state. Assume HAVELINK.
++ */
++
++#endif /* Other OSs */
++ /*
++ * Always return a successful link if the OS
++ * is not supported.
++ */
++ return (HAVELINK);
++}
++
++#ifdef __FreeBSD__
++void
++set_ieee80211 (struct interface_info *ip) {
++
++ struct ieee80211req ireq;
++ u_int8_t data[32];
++ int associated = 0;
++ int *media_list, i;
++ char *ifname;
++ int sock;
++
++ ifname = ip -> name;
++
++ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
++ log_fatal ("Can't create interface_active socket");
++
++ (void) memset (&ireq, 0, sizeof (ireq));
++ (void) strncpy (ireq.i_name, ifname, sizeof (ireq.i_name));
++ ireq.i_data = &data;
++ ireq.i_type = IEEE80211_IOC_SSID;
++ ireq.i_val = -1;
++ /*
++ * If we can't get the SSID,
++ * this isn't an 802.11 device.
++ */
++ if (ioctl (sock, SIOCG80211, &ireq) < 0)
++ ip -> ieee80211 = 0;
++ else {
++#ifdef DEBUG
++ printf ("Device %s has 802.11\n", ifname);
++#endif
++ ip -> ieee80211 = 1;
++ }
++ close (sock);
++ }
++#endif /* __FreeBSD__ */
++
++#ifdef ENABLE_POLLING_MODE
++/* Go to background after some time */
++void state_background (cpp)
++ void *cpp;
++{
++ go_daemon ();
++}
++
++/* Check the state of the NICs if we have link */
++void state_polling (cpp)
++ void *cpp;
++{
++ static int doinitcheck = 0;
++ struct interface_info *ip;
++ struct client_state *client;
++ int result;
++
++ for (ip = interfaces; ip; ip = ip -> next) {
++ if (! ip -> polling)
++ continue;
++#ifdef DEBUG
++ printf ("%s: Polling interface state\n", ip -> name);
++ for (client = ip -> client;
++ client; client = client -> next) {
++ printf ("%s: client state of %d\n", ip -> name, ip -> client -> state);
++ printf ("%s: link = %d\n", ip -> name, ip -> linkstate);
++ }
++#endif
++
++ result = interface_active (ip);
++ /*
++ * If dhclient.conf contains media settings, we cannot
++ * abort if the interface is not set to active mode.
++ */
++ if (ip -> havemedia && ip -> client -> state != S_BOUND) {
++ if (result == HAVELINK)
++ ip -> forcediscover = 1;
++ result = HAVELINK;
++ }
++
++ /*
++ * The last status of the interface tells us
++ * the we've got no link ...
++ */
++ if (ip -> linkstate == NOLINK || ! doinitcheck) {
++ /*
++ * ... but we have now link. Let's send
++ * requests.
++ */
++ if (result == HAVELINK) {
++#ifdef DEBUG
++ if (ip -> havemedia)
++ printf ("%s: Trying media settings on interface\n",
++ ip -> name);
++ else
++ printf ("%s: Found Link on interface\n", ip -> name);
++#endif
++ /*
++ * Set the interface to state_bound. We assume that we have
++ * a working link. If we cannot reach the server directly,
++ * INADDR_BROADCAST is used.
++ */
++ for (client = ip -> client;
++ client; client = client -> next) {
++ cancel_timeout (state_init, client);
++ cancel_timeout (state_reboot, client);
++ cancel_timeout (state_selecting, client);
++ if (client -> active) {
++ add_timeout (cur_time + random () % 5,
++ state_bound, client, 0, 0);
++ } else {
++ add_timeout (cur_time + random () % 5,
++ state_reboot, client, 0, 0);
++ }
++ }
++ ip -> linkstate = HAVELINK;
++ } else {
++#ifdef DEBUG
++ printf ("%s: No link on interface\n", ip -> name);
++#endif
++ for (client = ip -> client;
++ client; client = client -> next) {
++ /*
++ * Without this add_timout(), dhclient does
++ * not poll on a interface if there
++ * is no cable plugged in at startup
++ * time. Because we add one additional second
++ * to the time of a normal timeout, we always
++ * skip and block a running one. This prevents
++ * that polling is done twice at the same time.
++ */
++ if (client -> state == S_INIT) {
++ add_timeout (cur_time + (polling_interval + 1),
++ state_polling, client, 0, 0);
++ }
++ }
++ ip -> linkstate = NOLINK;
++ /*
++ * Automatically go into the background after
++ * some time. Do this only if there are no
++ * media options available for a interface.
++ */
++ if (! ip -> havemedia && ! doinitcheck) {
++ add_timeout (cur_time + (polling_interval * 2),
++ state_background, client, 0, 0);
++ }
++ }
++ }
++
++ /*
++ * The last status of the interface tells us
++ * the we previously had link.
++ */
++ if (ip -> linkstate == HAVELINK && doinitcheck) {
++ if (result == NOLINK) {
++ /*
++ * We lost link on the interface, or it isn't
++ * associated anymore.
++ */
++#ifdef DEBUG
++ printf ("%s: Lost Link on interface\n", ip -> name);
++#endif
++ /*
++ * After we lost link, cycle again through the
++ * different media settings if available. Else
++ * set NOLINK.
++ */
++ if (ip -> havemedia)
++ ip -> forcediscover = 1;
++ else
++ ip -> linkstate = NOLINK;
++ }
++ /*
++ * If we happen to have a real link, but no
++ * active lease, force the interface into
++ * state_reboot. Do the same if media settings
++ * are available.
++ */
++ if (ip -> forcediscover) {
++ for (client = ip -> client;
++ client; client = client -> next) {
++ if (client -> state != S_REBOOTING &&
++ client -> state != S_SELECTING) {
++ add_timeout (cur_time + random () % 5,
++ state_reboot, client, 0, 0);
++ }
++ }
++ ip -> forcediscover = 0;
++ ip -> linkstate = HAVELINK;
++ }
++ /* We still have link, do nothing. */
++ }
++ }
++ doinitcheck = 1;
++}
++#endif /* ifdef ENABLE_POLLING_MODE */
diff --git a/net/isc-dhcp40-server/files/patch-client::dhclient.conf b/net/isc-dhcp40-server/files/patch-client::dhclient.conf
new file mode 100644
index 000000000000..2d9560f43bf8
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-client::dhclient.conf
@@ -0,0 +1,11 @@
+--- client/dhclient.conf.orig Tue Jun 3 00:50:44 1997
++++ client/dhclient.conf Wed Mar 3 02:20:41 2004
+@@ -11,7 +11,7 @@
+ reboot 10;
+ select-timeout 5;
+ initial-interval 2;
+-script "/etc/dhclient-script";
++script "%%PREFIX%%/sbin/dhclient-script";
+ media "-link0 -link1 -link2", "link0 link1";
+ reject 192.33.137.209;
+
diff --git a/net/isc-dhcp40-server/files/patch-common::dhcp-options.5 b/net/isc-dhcp40-server/files/patch-common::dhcp-options.5
new file mode 100644
index 000000000000..9d936cfffeee
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-common::dhcp-options.5
@@ -0,0 +1,32 @@
+--- common/dhcp-options.5.orig Sun Feb 23 04:27:42 2003
++++ common/dhcp-options.5 Wed Mar 3 02:12:13 2004
+@@ -431,7 +431,10 @@
+ the domain-name option to specify the domain name). See RFC 1035 for
+ character set restrictions. This option is only honored by
+ .B dhclient-script(8)
+-if the hostname for the client machine is not set.
++if the hostname for the client machine is not set (i.e., set to the empty
++string in
++.B rc.conf(5)
++).
+ .RE
+ .PP
+ .B option \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR
+@@ -654,7 +657,7 @@
+ This option specifies whether the client should configure its IP
+ layer to allow forwarding of datagrams with non-local source routes
+ (see Section 3.3.5 of [4] for a discussion of this topic). A value
+-of false means disallow forwarding of such datagrams, and a value of true
++of 0 means disallow forwarding of such datagrams, and a value of true
+ means allow forwarding.
+ .RE
+ .PP
+@@ -948,7 +951,7 @@
+ .PP
+ This option specifies whether or not the client should negotiate the
+ use of trailers (RFC 893 [14]) when using the ARP protocol. A value
+-of false indicates that the client should not attempt to use trailers. A
++of 0 indicates that the client should not attempt to use trailers. A
+ value of true means that the client should attempt to use trailers.
+ .RE
+ .PP
diff --git a/net/isc-dhcp40-server/files/patch-common::discover.c b/net/isc-dhcp40-server/files/patch-common::discover.c
new file mode 100644
index 000000000000..1cfcc2094098
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-common::discover.c
@@ -0,0 +1,238 @@
+--- common/discover.c.orig Fri Jul 25 21:44:15 2003
++++ common/discover.c Fri Mar 5 23:33:04 2004
+@@ -47,6 +47,7 @@
+ #endif /* not lint */
+
+ #include "dhcpd.h"
++#include <ifaddrs.h>
+ #include <sys/ioctl.h>
+
+ struct interface_info *interfaces, *dummy_interfaces, *fallback_interface;
+@@ -135,10 +136,7 @@
+ {
+ struct interface_info *tmp, *ip;
+ struct interface_info *last, *next;
+- char buf [2048];
+- struct ifconf ic;
+- struct ifreq ifr;
+- int i;
++ struct ifaddrs *ifap, *ifa;
+ int sock;
+ int address_count = 0;
+ struct subnet *subnet;
+@@ -157,61 +155,6 @@
+ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ log_fatal ("Can't create addrlist socket");
+
+- /* Get the interface configuration information... */
+-
+-#ifdef SIOCGIFCONF_ZERO_PROBE
+- /* linux will only tell us how long a buffer it wants if we give it
+- * a null buffer first. So, do a dry run to figure out the length.
+- *
+- * XXX this code is duplicated from below because trying to fold
+- * the logic into the if statement and goto resulted in excesssive
+- * obfuscation. The intent is that unless you run Linux you shouldn't
+- * have to deal with this. */
+-
+- ic.ifc_len = 0;
+- ic.ifc_ifcu.ifcu_buf = (caddr_t)NULL;
+-#else
+- /* otherwise, we just feed it a starting size, and it'll tell us if
+- * it needs more */
+-
+- ic.ifc_len = sizeof buf;
+- ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
+-#endif
+-
+- gifconf_again:
+- i = ioctl(sock, SIOCGIFCONF, &ic);
+-
+- if (i < 0)
+- log_fatal ("ioctl: SIOCGIFCONF: %m");
+-
+-#ifdef SIOCGIFCONF_ZERO_PROBE
+- /* Workaround for SIOCGIFCONF bug on some Linux versions. */
+- if (ic.ifc_ifcu.ifcu_buf == 0 && ic.ifc_len == 0) {
+- ic.ifc_len = sizeof buf;
+- ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
+- goto gifconf_again;
+- }
+-#endif
+-
+- /* If the SIOCGIFCONF resulted in more data than would fit in
+- a buffer, allocate a bigger buffer. */
+- if ((ic.ifc_ifcu.ifcu_buf == buf
+-#ifdef SIOCGIFCONF_ZERO_PROBE
+- || ic.ifc_ifcu.ifcu_buf == 0
+-#endif
+- ) && ic.ifc_len > sizeof buf) {
+- ic.ifc_ifcu.ifcu_buf = dmalloc ((size_t)ic.ifc_len, MDL);
+- if (!ic.ifc_ifcu.ifcu_buf)
+- log_fatal ("Can't allocate SIOCGIFCONF buffer.");
+- goto gifconf_again;
+-#ifdef SIOCGIFCONF_ZERO_PROBE
+- } else if (ic.ifc_ifcu.ifcu_buf == 0) {
+- ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
+- ic.ifc_len = sizeof buf;
+- goto gifconf_again;
+-#endif
+- }
+-
+
+ /* If we already have a list of interfaces, and we're running as
+ a DHCP server, the interfaces were requested. */
+@@ -224,51 +167,38 @@
+ else
+ ir = INTERFACE_REQUESTED;
+
++ if (getifaddrs(&ifap) != 0)
++ log_fatal ("getifaddrs failed");
++
+ /* Cycle through the list of interfaces looking for IP addresses. */
+- for (i = 0; i < ic.ifc_len;) {
+- struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
+-#ifdef HAVE_SA_LEN
+- if (ifp -> ifr_addr.sa_len > sizeof (struct sockaddr))
+- i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
+- else
+-#endif
+- i += sizeof *ifp;
++ for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
+
+ #ifdef ALIAS_NAMES_PERMUTED
+- if ((s = strrchr (ifp -> ifr_name, ':'))) {
++ if ((s = strrchr (ifa -> ifa_name, ':'))) {
+ *s = 0;
+ }
+ #endif
+
+ #ifdef SKIP_DUMMY_INTERFACES
+- if (!strncmp (ifp -> ifr_name, "dummy", 5))
++ if (!strncmp (ifa -> ifa_name, "dummy", 5))
+ continue;
+ #endif
+
+-
+- /* See if this is the sort of interface we want to
+- deal with. */
+- strcpy (ifr.ifr_name, ifp -> ifr_name);
+- if (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0)
+- log_fatal ("Can't get interface flags for %s: %m",
+- ifr.ifr_name);
+-
+ /* See if we've seen an interface that matches this one. */
+ for (tmp = interfaces; tmp; tmp = tmp -> next)
+- if (!strcmp (tmp -> name, ifp -> ifr_name))
++ if (!strcmp (tmp -> name, ifa -> ifa_name))
+ break;
+
+- /* Skip non broadcast interfaces (plus loopback and
+- point-to-point in case an OS incorrectly marks them
+- as broadcast). Also skip down interfaces unless we're
++ /* See if this is the sort of interface we want to
++ deal with. Skip loopback, point-to-point and down
++ interfaces, except don't skip down interfaces if we're
+ trying to get a list of configurable interfaces. */
+- if (((!(ifr.ifr_flags & IFF_BROADCAST) ||
+- ifr.ifr_flags & IFF_LOOPBACK ||
+- ifr.ifr_flags & IFF_POINTOPOINT) && !tmp) ||
+- (!(ifr.ifr_flags & IFF_UP) &&
++ if ((ifa->ifa_flags & IFF_LOOPBACK) ||
++ (ifa->ifa_flags & IFF_POINTOPOINT) ||
++ (!(ifa->ifa_flags & IFF_UP) &&
+ state != DISCOVER_UNCONFIGURED))
+ continue;
+-
++
+ /* If there isn't already an interface by this name,
+ allocate one. */
+ if (!tmp) {
+@@ -276,9 +206,9 @@
+ status = interface_allocate (&tmp, MDL);
+ if (status != ISC_R_SUCCESS)
+ log_fatal ("Error allocating interface %s: %s",
+- ifp -> ifr_name,
++ ifa -> ifa_name,
+ isc_result_totext (status));
+- strcpy (tmp -> name, ifp -> ifr_name);
++ strcpy (tmp -> name, ifa -> ifa_name);
+ interface_snorf (tmp, ir);
+ interface_dereference (&tmp, MDL);
+ tmp = interfaces; /* XXX */
+@@ -290,9 +220,9 @@
+ /* If we have the capability, extract link information
+ and record it in a linked list. */
+ #ifdef HAVE_AF_LINK
+- if (ifp -> ifr_addr.sa_family == AF_LINK) {
++ if (ifa -> ifa_addr->sa_family == AF_LINK) {
+ struct sockaddr_dl *foo = ((struct sockaddr_dl *)
+- (&ifp -> ifr_addr));
++ (ifa -> ifa_addr));
+ #if defined (HAVE_SIN_LEN)
+ tmp -> hw_address.hlen = foo -> sdl_alen;
+ #else
+@@ -305,12 +235,11 @@
+ } else
+ #endif /* AF_LINK */
+
+- if (ifp -> ifr_addr.sa_family == AF_INET) {
++ if (ifa -> ifa_addr->sa_family == AF_INET) {
+ struct iaddr addr;
+
+ /* Get a pointer to the address... */
+- memcpy (&foo, &ifp -> ifr_addr,
+- sizeof ifp -> ifr_addr);
++ bcopy(ifa->ifa_addr, &foo, sizeof(foo));
+
+ /* We don't want the loopback interface. */
+ if (foo.sin_addr.s_addr == htonl (INADDR_LOOPBACK) &&
+@@ -323,16 +252,15 @@
+ found, keep a pointer to ifreq structure in
+ which we found it. */
+ if (!tmp -> ifp) {
+-#ifdef HAVE_SA_LEN
+- unsigned len = ((sizeof ifp -> ifr_name) +
+- ifp -> ifr_addr.sa_len);
+-#else
+- unsigned len = sizeof *ifp;
+-#endif
++
++ int len = (IFNAMSIZ +
++ ifa -> ifa_addr->sa_len);
+ tif = (struct ifreq *)dmalloc (len, MDL);
+ if (!tif)
+ log_fatal ("no space for ifp.");
+- memcpy (tif, ifp, len);
++ strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
++ memcpy(&tif->ifr_addr, ifa->ifa_addr,
++ ifa->ifa_addr->sa_len);
+ tmp -> ifp = tif;
+ tmp -> primary_address = foo.sin_addr;
+ }
+@@ -346,9 +274,6 @@
+ }
+ }
+
+- /* If we allocated a buffer, free it. */
+- if (ic.ifc_ifcu.ifcu_buf != buf)
+- dfree (ic.ifc_ifcu.ifcu_buf, MDL);
+
+ #if defined (LINUX_SLASHPROC_DISCOVERY)
+ /* On Linux, interfaces that don't have IP addresses don't
+@@ -529,6 +454,7 @@
+ be able to configure, we can quit now. */
+ if (state == DISCOVER_UNCONFIGURED) {
+ close (sock);
++ freeifaddrs(ifap);
+ return;
+ }
+
+@@ -674,6 +600,7 @@
+ }
+
+ close (sock);
++ freeifaddrs(ifap);
+
+ if (state == DISCOVER_SERVER && wifcount == 0) {
+ log_info ("%s", "");
diff --git a/net/isc-dhcp40-server/files/patch-common::dispatch.c b/net/isc-dhcp40-server/files/patch-common::dispatch.c
new file mode 100644
index 000000000000..0aa709cf0860
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-common::dispatch.c
@@ -0,0 +1,29 @@
+--- common/dispatch.c.orig Sun Nov 17 03:26:57 2002
++++ common/dispatch.c Wed Mar 3 16:20:15 2004
+@@ -95,11 +95,26 @@
+ void dispatch ()
+ {
+ struct timeval tv, *tvp;
++#ifdef ENABLE_POLLING_MODE
++ struct timeval *tvp_new;
++#endif
+ isc_result_t status;
++ TIME cur_time;
+
++ tvp = NULL;
++#ifdef ENABLE_POLLING_MODE
++ tvp_new = NULL;
++#endif
+ /* Wait for a packet or a timeout... XXX */
+ do {
+ tvp = process_outstanding_timeouts (&tv);
++#ifdef ENABLE_POLLING_MODE
++ GET_TIME (&cur_time);
++ add_timeout(cur_time + polling_interval, state_polling, 0, 0, 0);
++ tvp_new = process_outstanding_timeouts(&tv);
++ if (tvp != NULL && (tvp -> tv_sec > tvp_new -> tv_sec))
++ tvp = tvp_new;
++#endif /* ENABLE_POLLING_MODE */
+ status = omapi_one_dispatch (0, tvp);
+ } while (status == ISC_R_TIMEDOUT || status == ISC_R_SUCCESS);
+ log_fatal ("omapi_one_dispatch failed: %s -- exiting.",
diff --git a/net/isc-dhcp40-server/files/patch-common::parse.c b/net/isc-dhcp40-server/files/patch-common::parse.c
new file mode 100644
index 000000000000..637d69e7f41b
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-common::parse.c
@@ -0,0 +1,22 @@
+--- common/parse.c.orig 2 Sep 2003 11:01:23 -0000
++++ common/parse.c 22 Feb 2004 10:44:52 -0000
+@@ -414,6 +414,7 @@
+ {
+ const char *val;
+ enum dhcp_token token;
++ int32_t num;
+
+ token = next_token (&val, (unsigned *)0, cfile);
+ if (token != NUMBER) {
+@@ -421,9 +422,9 @@
+ skip_to_semi (cfile);
+ return;
+ }
+- convert_num (cfile, (unsigned char *)timep, val, 10, 32);
++ convert_num (cfile, (unsigned char *)&num, val, 10, 32);
+ /* Unswap the number - convert_num returns stuff in NBO. */
+- *timep = ntohl (*timep); /* XXX */
++ *timep = ntohl (num);
+
+ parse_semi (cfile);
+ }
diff --git a/net/isc-dhcp40-server/files/patch-dst::Makefile.dist b/net/isc-dhcp40-server/files/patch-dst::Makefile.dist
new file mode 100644
index 000000000000..ad45436b1629
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-dst::Makefile.dist
@@ -0,0 +1,29 @@
+--- dst/Makefile.dist.orig Sun Nov 17 03:27:43 2002
++++ dst/Makefile.dist Fri Mar 5 23:40:45 2004
+@@ -26,12 +26,24 @@
+
+ all: libdst.a
+
+-install:
+-
+ libdst.a: $(OBJ)
+ rm -f dst.a
+ ar cruv libdst.a $(OBJ)
+ $(RANLIB) libdst.a
++
++install: all
++ for dir in $(LIBDIR);\
++ do \
++ foo=""; \
++ for bar in `echo $(DESTDIR)$${dir} |tr / ' '`; do \
++ foo=$${foo}/$$bar; \
++ if [ ! -d $$foo ]; then \
++ mkdir $$foo; \
++ chmod 755 $$foo; \
++ fi; \
++ done; \
++ done
++ $(INSTALL) libdst.a $(DESTDIR)$(LIBDIR)
+
+ depend:
+ $(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRC)
diff --git a/net/isc-dhcp40-server/files/patch-freebsd b/net/isc-dhcp40-server/files/patch-freebsd
index 61a0e0c093a8..9fef4fdab877 100644
--- a/net/isc-dhcp40-server/files/patch-freebsd
+++ b/net/isc-dhcp40-server/files/patch-freebsd
@@ -1,6 +1,15 @@
---- client/scripts/freebsd.orig Tue Feb 19 17:59:35 2002
-+++ client/scripts/freebsd Mon Apr 15 15:31:21 2002
-@@ -20,17 +20,17 @@
+--- client/scripts/freebsd.orig Sun Apr 27 21:44:01 2003
++++ client/scripts/freebsd Wed Mar 3 02:28:29 2004
+@@ -16,7 +16,7 @@
+ ( echo search $new_domain_name >/etc/resolv.conf )
+ exit_status=$?
+ else
+- rm /etc/resolv.conf
++ ( rm /etc/resolv.conf )
+ exit_status=$?
+ fi
+ if [ $exit_status -ne 0 ]; then
+@@ -32,17 +32,17 @@
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
@@ -22,7 +31,7 @@
# allow the local script to abort processing of this state
# local script must set exit_status variable to nonzero.
if [ $exit_status -ne 0 ]; then
-@@ -39,11 +39,11 @@
+@@ -51,11 +51,11 @@
fi
if [ x$new_network_number != x ]; then
@@ -36,3 +45,31 @@
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
+@@ -71,6 +71,15 @@
+ alias_subnet_arg="netmask $alias_subnet_mask"
+ fi
+
++# Get the interface to which our default route is bound to.
++if [ -x /usr/bin/netstat ]; then
++ if_defaultroute=`/usr/bin/netstat -rn \
++ | /usr/bin/grep "^default" \
++ | /usr/bin/awk '{print $6}'`
++else
++ if_defaultroute=""
++fi
++
+ if [ x$reason = xMEDIUM ]; then
+ eval "ifconfig $interface $medium"
+ eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
+@@ -113,7 +122,10 @@
+ eval "ifconfig $interface inet -alias $old_ip_address $medium"
+ route delete $old_ip_address 127.1 >/dev/null 2>&1
+ for router in $old_routers; do
+- route delete default $router >/dev/null 2>&1
++ if [ x$if_defaultroute = x ] || [ x$if_defaultroute = x$interface ]
++ then
++ route delete default $router >/dev/null 2>&1
++ fi
+ done
+ if [ -n "$old_static_routes" ]; then
+ set -- $old_static_routes
diff --git a/net/isc-dhcp40-server/files/patch-includes::cf::freebsd.h b/net/isc-dhcp40-server/files/patch-includes::cf::freebsd.h
new file mode 100644
index 000000000000..8fe1b6ef93a0
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-includes::cf::freebsd.h
@@ -0,0 +1,53 @@
+--- includes/cf/freebsd.h.orig Wed Mar 3 02:32:39 2004
++++ includes/cf/freebsd.h Wed Mar 3 02:31:56 2004
+@@ -101,6 +101,10 @@
+ #define SOCKLEN_T int
+ #endif
+
++#ifdef RESCUE
++#define _PATH_DHCLIENT_SCRIPT "/rescue/dhclient-script"
++#endif
++
+ #if defined (USE_DEFAULT_NETWORK)
+ # define USE_BPF
+ #endif
+@@ -111,6 +115,9 @@
+ #endif /* HAVE_DEV_RANDOM */
+
+ const char *cmds[] = {
++#ifndef RESCUE
++ /* rescue environment can't rely on these ... */
++ /* Actually, /sbin/dhclient shouldn't use these, either. */
+ "/bin/ps -axlw 2>&1",
+ "/usr/sbin/arp -an 2>&1",
+ "/usr/bin/netstat -an 2>&1",
+@@ -121,10 +128,12 @@
+ "/usr/sbin/iostat 2>&1",
+ "/usr/bin/vmstat 2>&1",
+ "/usr/bin/w 2>&1",
++#endif
+ NULL
+ };
+
+ const char *dirs[] = {
++#ifndef RESCUE
+ "/tmp",
+ "/usr/tmp",
+ ".",
+@@ -134,13 +143,16 @@
+ "/var/mail",
+ "/home",
+ "/usr/home",
++#endif
+ NULL
+ };
+
+ const char *files[] = {
++#ifndef RESCUE
+ "/var/log/messages",
+ "/var/log/wtmp",
+ "/var/log/lastlog",
++#endif
+ NULL
+ };
+ #endif /* NEED_PRAND_CONF */
diff --git a/net/isc-dhcp40-server/files/patch-includes::dhcpd.h b/net/isc-dhcp40-server/files/patch-includes::dhcpd.h
new file mode 100644
index 000000000000..afedaa818647
--- /dev/null
+++ b/net/isc-dhcp40-server/files/patch-includes::dhcpd.h
@@ -0,0 +1,56 @@
+--- includes/dhcpd.h.orig Mon Feb 10 02:22:46 2003
++++ includes/dhcpd.h Wed Mar 3 16:20:09 2004
+@@ -99,6 +99,9 @@
+ (((x) >> OPTION_HASH_EXP) & \
+ (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
+
++#define NOLINK 0
++#define HAVELINK 1
++
+ enum dhcp_shutdown_state {
+ shutdown_listeners,
+ shutdown_omapi_connections,
+@@ -783,6 +786,11 @@
+ unsigned remote_id_len; /* Length of Remote ID. */
+
+ char name [IFNAMSIZ]; /* Its name... */
++ int ieee80211; /* True if media is ieee802.11 */
++ int havemedia; /* True if we have a media table */
++ int linkstate; /* True if we have link */
++ int polling; /* True if polling is enabled */
++ int forcediscover; /* True if a discover is needed */
+ int index; /* Its index. */
+ int rfdesc; /* Its read file descriptor. */
+ int wfdesc; /* Its write file descriptor, if
+@@ -1845,6 +1853,9 @@
+ extern const char *path_dhclient_pid;
+ extern char *path_dhclient_script;
+ extern int interfaces_requested;
++#ifdef ENABLE_POLLING_MODE
++extern int polling_interval;
++#endif
+
+ extern struct client_config top_level_config;
+
+@@ -1858,12 +1869,21 @@
+ void send_decline PROTO ((void *));
+
+ void state_reboot PROTO ((void *));
++#ifdef ENABLE_POLLING_MODE
++void state_background PROTO ((void *));
++void state_polling PROTO ((void *));
++#endif
+ void state_init PROTO ((void *));
+ void state_selecting PROTO ((void *));
+ void state_requesting PROTO ((void *));
+ void state_bound PROTO ((void *));
+ void state_stop PROTO ((void *));
+ void state_panic PROTO ((void *));
++
++#ifdef __FreeBSD__
++void set_ieee80211 PROTO ((struct interface_info *));
++#endif
++int interface_active PROTO ((struct interface_info *));
+
+ void bind_lease PROTO ((struct client_state *));
+
diff --git a/net/isc-dhcp40-server/files/patch-site.conf b/net/isc-dhcp40-server/files/patch-site.conf
index 65f79b6a7550..1149e0c7925c 100644
--- a/net/isc-dhcp40-server/files/patch-site.conf
+++ b/net/isc-dhcp40-server/files/patch-site.conf
@@ -1,6 +1,6 @@
--- site.conf.orig Wed Jul 7 17:20:10 1999
-+++ site.conf Sun Jun 24 02:07:17 2001
-@@ -1,2 +1,35 @@
++++ site.conf Wed Mar 3 14:00:14 2004
+@@ -1,2 +1,39 @@
# Put local site configuration stuff here to override the default
# settings in Makefile.conf
+
@@ -23,6 +23,7 @@
+ETC = $(PREFIX)/etc
+LIBDIR = ${PREFIX}/lib
+INCDIR = ${PREFIX}/include
++CLIENT_PATH = \"PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/sbin:${PREFIX}/bin\"
+
+DEBUG ?= #none
+
@@ -36,3 +37,6 @@
+CFLAGS += -D_PATH_DHCLIENT_SCRIPT=\"$(CLIENTBINDIR)/dhclient-script\"
+CFLAGS += -D_PATH_DHCLIENT_DB=\"$(VARDB)/dhclient.leases\"
+CFLAGS += -D_PATH_DHCLIENT_PID=\"$(VARRUN)/dhclient.pid\"
++
++CFLAGS += -Dwarn=dhcp_warn
++CFLAGS += -DNOMINUM
diff --git a/net/isc-dhcp40-server/files/rc.isc-dhcpd.conf.sample b/net/isc-dhcp40-server/files/rc.isc-dhcpd.conf.sample
deleted file mode 100644
index edfe4bd7dc50..000000000000
--- a/net/isc-dhcp40-server/files/rc.isc-dhcpd.conf.sample
+++ /dev/null
@@ -1,7 +0,0 @@
-# $FreeBSD$
-#
-# isc-dhcpd startup configuration file.
-#
-
-dhcpd_options= # command option(s)
-dhcpd_ifaces= # ethernet interface(s)
diff --git a/net/isc-dhcp40-server/files/rc.isc-dhcrelay.conf.sample b/net/isc-dhcp40-server/files/rc.isc-dhcrelay.conf.sample
deleted file mode 100644
index b647c62f6137..000000000000
--- a/net/isc-dhcp40-server/files/rc.isc-dhcrelay.conf.sample
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-#
-# isc-dhcrelay startup configuration file.
-#
-
-dhcrelay_options= # command option(s)
-dhcrelay_ifaces= # ethernet interface(s)
-dhcrelay_servers= # dhcpd server(s)
diff --git a/net/isc-dhcp40-server/pkg-message b/net/isc-dhcp40-server/pkg-message
index b7828b2ac877..02c3fad98765 100644
--- a/net/isc-dhcp40-server/pkg-message
+++ b/net/isc-dhcp40-server/pkg-message
@@ -1,7 +1,15 @@
**** To setup dhcpd, you may have to copy %%PREFIX%%/etc/dhcpd.conf.sample
- to %%PREFIX%%/etc/dhcpd.conf for editing. You also have to rename
- %%PREFIX%%/etc/rc.d/isc-dhcpd.sh.sample to %%PREFIX%%/etc/rc.d/isc-\
- dhcpd.sh to enable automatic startup.
- %%PREFIX%%/etc/rc.isc-dhcpd.conf may be edited to tune some startup
- variables such as `dhcpd_options' or `dhcpd_ifaces', both defaulted
- to `nothing'. See dhcpd(8) for details about possible options.
+ to %%PREFIX%%/etc/dhcpd.conf for editing.
+
+**** This port installs dhcp daemon, but don't invokes dhcpd by default. If
+ you want to invoke dhcpd at startup, put these lines into /etc/rc.conf.
+
+ dhcpd_enable="YES"
+ dhcpd_flags="" # command option(s)
+ dhcpd_conf="%%PREFIX%%/etc/dhcpd.conf" # configuration file
+ dhcpd_ifaces="" # ethernet interface(s)
+
+**** For instance, rc.conf like variables are still read from
+ %%PREFIX%%/etc/rc.isc-dhcpd.conf. They should be move into
+ /etc/rc.conf. Also, the dhcpd_options variable must be
+ renamed dhcpd_flags.
diff --git a/net/isc-dhcp40-server/pkg-plist b/net/isc-dhcp40-server/pkg-plist
index 6976a5479acc..3212362358fa 100644
--- a/net/isc-dhcp40-server/pkg-plist
+++ b/net/isc-dhcp40-server/pkg-plist
@@ -1,11 +1,7 @@
@comment $FreeBSD$
bin/omshell
etc/dhcpd.conf.sample
-@unexec if cmp -s %D/etc/rc.isc-dhcpd.conf %D/etc/rc.isc-dhcpd.conf.sample; then rm -f %D/etc/rc.isc-dhcpd.conf; fi
-etc/rc.isc-dhcpd.conf.sample
-@exec [ -f %D/etc/rc.isc-dhcpd.conf ] || cp %D/etc/rc.isc-dhcpd.conf.sample %D/etc/rc.isc-dhcpd.conf
-etc/rc.d/isc-dhcpd.sh.sample
-@unexec rm -f etc/rc.d/isc-dhcpd.sh
+etc/rc.d/isc-dhcpd.sh
sbin/dhcpd
%%PORTDOCS%%%%DOCSDIR%%/ANONCVS
%%PORTDOCS%%%%DOCSDIR%%/CHANGES