Import NetBSD dhclient(8), dhcpd(8), dhcrelay(8)

dhcrelay(8) and omshell(1) have not been tested.

Change-Id: I0cad89f65666af4e366a86e130ce8df0894c3bb4
This commit is contained in:
David van Moolenbroek
2017-02-16 16:31:25 +00:00
parent 00b67f09dd
commit 83ee113ee0
289 changed files with 182445 additions and 3 deletions

View File

@@ -142,7 +142,10 @@
./etc/rc.d/SERVERS minix-base
./etc/rc.d/blacklistd minix-base
./etc/rc.d/bootconf.sh minix-base
./etc/rc.d/dhclient minix-base
./etc/rc.d/dhcpcd minix-base
./etc/rc.d/dhcpd minix-base
./etc/rc.d/dhcrelay minix-base
./etc/rc.d/fsck minix-base
./etc/rc.d/ftpd minix-base
./etc/rc.d/inetd minix-base
@@ -234,6 +237,8 @@
./sbin/blacklistctl minix-base
./sbin/blacklistd minix-base
./sbin/chown minix-base
./sbin/dhclient-script minix-base
./sbin/dhclient minix-base
./sbin/dhcpcd minix-base
./sbin/fsck minix-base
./sbin/fsck_ext2fs minix-base
@@ -1077,6 +1082,8 @@
./usr/sbin/chroot minix-base
./usr/sbin/ddns-confgen minix-base
./usr/sbin/dev_mkdb minix-base
./usr/sbin/dhcpd minix-base
./usr/sbin/dhcrelay minix-base
./usr/sbin/diskctl minix-base
./usr/sbin/dnssec-dsfromkey minix-base
./usr/sbin/dnssec-importkey minix-base
@@ -1110,6 +1117,7 @@
./usr/sbin/named minix-base
./usr/sbin/newfs_mfs minix-base
./usr/sbin/nsec3hash minix-base
./usr/sbin/omshell minix-base
./usr/sbin/pkg_add minix-base crypto
./usr/sbin/pkg_admin minix-base crypto
./usr/sbin/pkg_create minix-base crypto
@@ -1151,6 +1159,8 @@
./usr/share/calendar/calendar.music minix-base
./usr/share/calendar/calendar.netbsd minix-base
./usr/share/calendar/calendar.usholiday minix-base
./usr/share/dhcpd minix-base
./usr/share/dhcpd/pxe.defs minix-base
./usr/share/doc minix-base
./usr/share/doc/html minix-base obsolete
./usr/share/doc/html/bzip2 minix-base obsolete
@@ -1222,6 +1232,8 @@
./usr/share/examples/blacklist minix-base
./usr/share/examples/blacklist/blacklistd.conf minix-base
./usr/share/examples/blacklist/npf.conf minix-base
./usr/share/examples/dhcp minix-base
./usr/share/examples/dhcp/dhcpd.conf minix-base
./usr/share/examples/ftpd minix-base
./usr/share/examples/libsaslc minix-base
./usr/share/examples/libsaslc/README minix-base crypto

View File

@@ -167,6 +167,7 @@
./usr/libdata/debug/sbin/blacklistctl.debug minix-debug debug
./usr/libdata/debug/sbin/blacklistd.debug minix-debug debug
./usr/libdata/debug/sbin/chown.debug minix-debug debug
./usr/libdata/debug/sbin/dhclient.debug minix-debug debug
./usr/libdata/debug/sbin/dhcpcd.debug minix-debug debug
./usr/libdata/debug/sbin/fsck.debug minix-debug debug
./usr/libdata/debug/sbin/fsck_ext2fs.debug minix-debug debug
@@ -619,6 +620,8 @@
./usr/libdata/debug/usr/sbin/chroot.debug minix-debug debug
./usr/libdata/debug/usr/sbin/ddns-confgen.debug minix-debug debug
./usr/libdata/debug/usr/sbin/dev_mkdb.debug minix-debug debug
./usr/libdata/debug/usr/sbin/dhcpd.debug minix-debug debug
./usr/libdata/debug/usr/sbin/dhcrelay.debug minix-debug debug
./usr/libdata/debug/usr/sbin/diskctl.debug minix-debug debug
./usr/libdata/debug/usr/sbin/dnssec-dsfromkey.debug minix-debug debug
./usr/libdata/debug/usr/sbin/dnssec-importkey.debug minix-debug debug
@@ -644,6 +647,7 @@
./usr/libdata/debug/usr/sbin/named-journalprint.debug minix-debug debug
./usr/libdata/debug/usr/sbin/named.debug minix-debug debug
./usr/libdata/debug/usr/sbin/nsec3hash.debug minix-debug debug
./usr/libdata/debug/usr/sbin/omshell.debug minix-debug debug
./usr/libdata/debug/usr/sbin/pkg_add.debug minix-debug debug
./usr/libdata/debug/usr/sbin/pkg_admin.debug minix-debug debug
./usr/libdata/debug/usr/sbin/pkg_create.debug minix-debug debug

View File

@@ -252,6 +252,7 @@
./usr/man/man1/objcopy.1 minix-man binutils
./usr/man/man1/objdump.1 minix-man binutils
./usr/man/man1/od.1 minix-man
./usr/man/man1/omshell.1 minix-man
./usr/man/man1/openssl.1 minix-man crypto
./usr/man/man1/openssl_CA.pl.1 minix-man crypto
./usr/man/man1/openssl_asn1parse.1 minix-man crypto
@@ -3284,8 +3285,14 @@
./usr/man/man5/configfile.5 minix-man
./usr/man/man5/cpio.5 minix-man
./usr/man/man5/crontab.5 minix-man
./usr/man/man5/dhclient.conf.5 minix-man
./usr/man/man5/dhclient.leases.5 minix-man
./usr/man/man5/dhcp-eval.5 minix-man
./usr/man/man5/dhcp-options.5 minix-man
./usr/man/man5/dhcp.conf.5 minix-man obsolete
./usr/man/man5/dhcpcd.conf.5 minix-man
./usr/man/man5/dhcpd.conf.5 minix-man
./usr/man/man5/dhcpd.leases.5 minix-man
./usr/man/man5/dir.5 minix-man obsolete
./usr/man/man5/editrc.5 minix-man
./usr/man/man5/ethers.5 minix-man obsolete
@@ -3404,9 +3411,12 @@
./usr/man/man8/ddns-confgen.8 minix-man
./usr/man/man8/dev_mkdb.8 minix-man
./usr/man/man8/devsize.8 minix-man
./usr/man/man8/dhclient-script.8 minix-man
./usr/man/man8/dhclient.8 minix-man
./usr/man/man8/dhcpcd-run-hooks.8 minix-man
./usr/man/man8/dhcpcd.8 minix-man
./usr/man/man8/dhcpd.8 minix-man obsolete
./usr/man/man8/dhcpd.8 minix-man
./usr/man/man8/dhcrelay.8 minix-man
./usr/man/man8/diskctl.8 minix-man
./usr/man/man8/dnssec-dsfromkey.8 minix-man
./usr/man/man8/dnssec-importkey.8 minix-man

View File

@@ -178,6 +178,7 @@
./usr/share
./usr/share/atf
./usr/share/calendar
./usr/share/dhcpd
./usr/share/doc
./usr/share/doc/psd
./usr/share/doc/reference
@@ -195,6 +196,7 @@
./usr/share/examples
./usr/share/examples/atf
./usr/share/examples/blacklist
./usr/share/examples/dhcp
./usr/share/examples/ftpd
./usr/share/examples/kyua-cli
./usr/share/examples/libsaslc

View File

@@ -30,7 +30,7 @@ CONFIGFILES=\
\
bootconf.sh \
\
dhcpcd \
dhclient dhcpcd dhcpd dhcrelay \
fsck ftpd \
\
\

22
etc/rc.d/dhclient Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
#
# $NetBSD: dhclient,v 1.9 2004/08/13 18:08:03 mycroft Exp $
#
# PROVIDE: dhclient
# REQUIRE: network mountcritlocal
# BEFORE: NETWORKING
#
# Note that there no syslog logging of dhclient messages at boot because
# dhclient needs to start before services that syslog depends upon do.
#
$_rc_subr_loaded . /etc/rc.subr
name="dhclient"
rcvar=$name
command="/sbin/${name}"
pidfile="/var/run/${name}.pid"
load_rc_config $name
run_rc_command "$1"

28
etc/rc.d/dhcpd Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
#
# $NetBSD: dhcpd,v 1.7 2014/07/17 07:17:03 spz Exp $
#
# PROVIDE: dhcpd
# REQUIRE: DAEMON
# BEFORE: LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="dhcpd"
rcvar=$name
command="/usr/sbin/${name}"
start_precmd="dhcpd_precmd"
pidfile="/var/run/${name}.pid"
required_files="/etc/${name}.conf"
dhcpd_precmd()
{
if [ ! -e "/var/db/${name}.leases" ]; then
echo "Creating /var/db/${name}.leases"
touch /var/db/${name}.leases
fi
}
load_rc_config $name
run_rc_command "$1"

18
etc/rc.d/dhcrelay Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
#
# $NetBSD: dhcrelay,v 1.6 2004/08/13 18:08:03 mycroft Exp $
#
# PROVIDE: dhcrelay
# REQUIRE: DAEMON
# BEFORE: LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="dhcrelay"
rcvar=$name
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
load_rc_config $name
run_rc_command "$1"

View File

@@ -44,6 +44,6 @@ SUBDIR+= librtld_db
.endif
#MINIX:
SUBDIR+= blacklist nvi
SUBDIR+= blacklist dhcp nvi
.include <bsd.subdir.mk>

5
external/bsd/dhcp/Makefile vendored Normal file
View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:29 christos Exp $
SUBDIR= lib share .WAIT bin
.include <bsd.subdir.mk>

76
external/bsd/dhcp/Makefile.inc vendored Normal file
View File

@@ -0,0 +1,76 @@
# $NetBSD: Makefile.inc,v 1.15 2015/09/27 21:01:27 mlelstv Exp $
WARNS?= 1 # XXX -Wshadow -Wcast-qual -Wsign-compare
.include <bsd.own.mk>
USE_FORT?= yes # network client/server
CWARNFLAGS.clang+= -Wno-tautological-compare \
-Wno-conversion -Wno-constant-logical-operand \
-Wno-format-security -Wno-error=unused-const-variable
DIST:= ${.PARSEDIR}/dist
BIND:= ${.PARSEDIR}/../bind/dist
.PATH: ${DIST}/${DHCPSRCDIR}
COBJDIR!=cd ${.PARSEDIR}/lib/common && ${PRINTOBJDIR}
OMOBJDIR!=cd ${.PARSEDIR}/lib/omapip && ${PRINTOBJDIR}
DSTOBJDIR!=cd ${.PARSEDIR}/lib/dst && ${PRINTOBJDIR}
.if (${USE_INET6} != "no")
CPPFLAGS+= -DDHCPv6
.endif
.if !defined(__MINIX)
CPPFLAGS+= -DISC_PLATFORM_USETHREADS -DHAVE_CONFIG_H
.else # defined(__MINIX)
CPPFLAGS+= -DHAVE_CONFIG_H
.endif # defined(__MINIX)
CPPFLAGS+= -I${DIST} -I${DIST}/includes -I${DIST}/../include
CPPFLAGS+= -I${BIND} -I${BIND}/includes -I${BIND}/../include
.for dir in isc dns irs
CPPFLAGS+= -I${BIND}/lib/${dir}/include
CPPFLAGS+= -I${BIND}/lib/${dir}/unix/include
.if !defined(__MINIX)
CPPFLAGS+= -I${BIND}/lib/${dir}/pthreads/include
.else # defined(__MINIX)
CPPFLAGS+= -I${BIND}/lib/${dir}/nothreads/include
.endif # defined(__MINIX)
.endfor
CPPFLAGS+= -DLOCALSTATEDIR='"/var"'
LDADD+= ${COBJDIR}/libdhcp.a
LDADD+= ${OMOBJDIR}/libomapi.a ${DSTOBJDIR}/libdst.a
.if defined(PROG) && ${PROG} == "dhclient"
LDADD+=-Wl,-Bstatic
.endif
LDADD+= -lirs -lisccfg -ldns -lisc
.if !defined(__MINIX)
LDADD+=-lpthread
.endif # !defined(__MINIX)
.if (${MKCRYPTO} != "no")
.if (${MKKERBEROS} != "no")
LDADD+= -lgssapi -lkrb5 -lhx509 -lheimntlm -lheimbase \
-lcom_err -lroken -lasn1 -lwind
DPADD+= ${LIBGSSAPI} ${LIBKRB5} ${LIBHX509} ${LIBHEIMNTLM} ${LIBHEIMBASE} \
${LIBCOM_ERR} ${LIBROKEN} ${LIBASN1} ${LIBWIND}
.endif
# MINIX3 note: partial dynamic linking results in an unusable binary somehow
.if defined(PROG) && ${PROG} == "dhclient" && !defined(__MINIX)
LDADD+=-Wl,-Bdynamic
.endif
.if !defined(__MINIX)
LDADD+= -lcrypto -lipsec -lcrypt
DPADD+= ${LIBCRYPTO} ${LIBIPSEC} ${LIBCRYPT}
.else # defined(__MINIX)
LDADD+= -lcrypto -lcrypt
DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
.endif # defined(__MINIX)
.endif
.if defined(PROG) && ${PROG} == "dhclient" && !defined(__MINIX)
LDADD+=-Wl,-Bdynamic
.endif
DPADD+= ${COBJDIR}/libdhcp.a
DPADD+= ${OMOBJDIR}/libomapi.a ${DSTOBJDIR}/libdst.a
DPADD+= ${LIBDNS} ${LIBISC}
.if !defined(__MINIX)
DPADD+= ${LIBPTHREAD}
.endif # !defined(__MINIX)

5
external/bsd/dhcp/bin/Makefile vendored Normal file
View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
SUBDIR= clientscript server client relay omshell
.include <bsd.subdir.mk>

2
external/bsd/dhcp/bin/Makefile.inc vendored Normal file
View File

@@ -0,0 +1,2 @@
.include "${.PARSEDIR}/../Makefile.inc"
BINDIR?=/usr/sbin

17
external/bsd/dhcp/bin/client/Makefile vendored Normal file
View File

@@ -0,0 +1,17 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
BINDIR= /sbin
.include <bsd.own.mk> # for MKDYNAMICROOT definition
SRCS = dhclient.c clparse.c dhc6.c
PROG = dhclient
MAN = dhclient.8 dhclient.conf.5 dhclient.leases.5 dhclient-script.8
CPPFLAGS += -DCLIENT_PATH='"PATH=/usr/bin:/usr/sbin:/bin:/sbin"'
DHCPSRCDIR= client
.if (${MKDYNAMICROOT} == "no")
LDSTATIC?= -static
.endif
.include <bsd.prog.mk>

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
NOOBJ= # defined
SCRIPTS=dhclient-script
SCRIPTSDIR=/sbin
.include <bsd.prog.mk>

View File

@@ -0,0 +1,282 @@
#!/bin/sh
#
# $NetBSD: dhclient-script,v 1.2 2015/02/26 09:59:55 roy Exp $
ENTERHOOKS=/etc/dhclient-enter-hooks
EXITHOOKS=/etc/dhclient-exit-hooks
RESOLV=/etc/resolv.conf
SIGNATURE="# Created by dhclient from"
INTSIG="$SIGNATURE $interface"
echo_resolv_conf() {
echo "$INTSIG"
echo search $new_domain_name
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver
done
}
make_resolv_conf() {
if [ ! -z "$new_domain_name_servers" ]; then
if [ -x /sbin/resolvconf ]; then
echo_resolv_conf | /sbin/resolvconf -a $interface
else
if [ -f $RESOLV ]; then
while read line; do
case $line in
"$SIGNATURE"*)
;;
*)
mv $RESOLV $RESOLV.save;;
esac
break
done < $RESOLV
fi
echo_resolv_conf > $RESOLV
fi
fi
}
restore_resolv_conf() {
if [ -x /sbin/resolvconf ]; then
/sbin/resolvconf -d $interface
elif [ -f $RESOLV.save -a -f $RESOLV ]; then
while read line; do
case $line in
"$INTSIG"*)
mv $RESOLV.save $RESOLV;;
esac
break
done < $RESOLV
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f "$EXITHOOKS" ]; then
. "$EXITHOOKS"
fi
# probably should do something with exit status of the local script
exit $exit_status
}
add_new_routes() {
for router in $new_routers; do
route add default $router
done >/dev/null 2>&1
set -- $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
}
delete_old_routes() {
for router in $old_routers; do
route delete default $router
done >/dev/null 2>&1
set -- $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
route -n flush -inet -llinfo -host
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f $ENTERHOOKS ]; then
exit_status=0
. $ENTERHOOKS
# 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
exit $exit_status
fi
fi
#if [ ! -z "$new_host_name" ]; then
# echo New Host Name: $new_host_name
#fi
#
#if [ ! -z "$new_nis_domain" ]; then
# echo New NIS Domain: $new_nis_domain
#fi
#
#if [ ! -z "$new_network_number" ]; then
# echo New Network Number: $new_network_number
#fi
if [ ! -z "$new_broadcast_address" ]; then
# echo New Broadcast Address: $new_broadcast_address
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ ! -z "$old_broadcast_address" ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ ! -z "$new_subnet_mask" ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ ! -z "$old_subnet_mask" ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ ! -z "$alias_subnet_mask" ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
case "$reason" in
MEDIUM)
test -z "$medium" && exit_with_hooks 0
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
;;
PREINIT)
if [ ! -z "$alias_ip_address" ]; then
ifconfig $interface inet \
-alias $alias_ip_address >/dev/null 2>&1
fi
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
exit_with_hooks 0
;;
ARPCHECK|ARPSEND)
exit_with_hooks 0
;;
BOUND|RENEW|REBIND|REBOOT)
if [ ! -z "$new_nis_domain" ]; then
if type domainname > /dev/null 2>&1; then
domainname $new_nis_domain
fi
fi
if type hostname > /dev/null 2>&1; then
if [ \( -z "$current_hostname" \) -o \
\( "x$new_host_name" = "x$old_hostname" \) ]; then
current_hostname=`hostname`
fi
if [ \( -z "$current_hostname" \) -o \
\( "x$new_host_name" != "x$old_hostname" \) ]; then
hostname $new_host_name
fi
fi
if [ \( ! -z "$old_ip_address" \) -a \( ! -z "$alias_ip_address" \) -a \
\( "x$alias_ip_address" != "x$old_ip_address" \) ]; then
ifconfig $interface inet \
-alias $alias_ip_address > /dev/null 2>&1
fi
if [ \( ! -z "$old_ip_address" \) -a \
\( "x$old_ip_address" != "x$new_ip_address" \) ]; then
eval "ifconfig $interface inet -alias $old_ip_address $medium"
delete_old_routes
fi
if [ \( -z "$old_ip_address" \) -o \
\( "x$old_ip_address" != "x$new_ip_address" \) -o \
\( "x$reason" = "xBOUND" \) -o \( "x$reason" = "xREBOOT" \) ]; then
eval "ifconfig $interface inet $new_ip_address \
$new_netmask_arg $new_broadcast_arg $medium"
add_new_routes
fi
if [ \( ! -z "$alias_ip_address" \) -a \
\( "x$new_ip_address" != "x$alias_ip_address" \) ]; then
ifconfig $interface inet alias $alias_ip_address \
$alias_subnet_arg
fi
make_resolv_conf
exit_with_hooks 0
;;
EXPIRE|FAIL|RELEASE|STOP)
if [ ! -z "$old_nis_domain" ]; then
if type domainname > /dev/null 2>&1; then
# delete the old nis domain name
domainname ""
fi
fi
if [ ! -z "$alias_ip_address" ]; then
ifconfig $interface inet -alias $alias_ip_address
fi > /dev/null 2>&1
if [ ! -z "$old_ip_address" ]; then
eval "ifconfig $interface inet -alias $old_ip_address $medium"
delete_old_routes
fi
if [ ! -z "$alias_ip_address" ]; then
ifconfig $interface inet alias $alias_ip_address \
$alias_subnet_arg
fi
restore_resolv_conf
exit_with_hooks 0
;;
TIMEOUT)
if [ ! -z "$alias_ip_address" ]; then
ifconfig $interface inet -alias $alias_ip_address
fi > /dev/null 2>&1
if [ ! -z "$new_host_name" ]; then
if type hostname > /dev/null 2>&1; then
hostname $new_host_name
fi
fi
if [ ! -z "$new_nis_domain" ]; then
if type domainname > /dev/null 2>&1; then
domainname $new_nis_domain
fi
fi
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $medium"
sleep 1
if [ ! -z "$new_routers" ]; then
set -- $new_routers
if ping -n -q -c 1 -w 1 $1; then
if [ \( ! -z "$alias_ip_address" \) -a \
\( "x$new_ip_address" != "x$alias_ip_address" \) ]
then
ifconfig $interface inet alias \
$alias_ip_address $alias_subnet_arg
fi
add_new_routes
make_resolv_conf
exit_with_hooks 0
fi
fi
eval "ifconfig $interface inet -alias $new_ip_address $medium"
delete_old_routes
exit_with_hooks 1
;;
*)
exit_with_hooks 0
;;
esac

16
external/bsd/dhcp/bin/omshell/Makefile vendored Normal file
View File

@@ -0,0 +1,16 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
.include <bsd.own.mk>
SRCS = omshell.c
PROG = omshell
MAN = omshell.1
DHCPSRCDIR= dhcpctl
CTLOBJDIR!=cd $(.CURDIR)/../../lib/dhcpctl && ${PRINTOBJDIR}
LDADD+= ${CTLOBJDIR}/libdhcpctl.a
DPADD+= ${CTLOBJDIR}/libdhcpctl.a
.include <bsd.prog.mk>

9
external/bsd/dhcp/bin/relay/Makefile vendored Normal file
View File

@@ -0,0 +1,9 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
SRCS = dhcrelay.c
PROG = dhcrelay
MAN = dhcrelay.8
DHCPSRCDIR= relay
.include <bsd.prog.mk>

18
external/bsd/dhcp/bin/server/Makefile vendored Normal file
View File

@@ -0,0 +1,18 @@
# $NetBSD: Makefile,v 1.1 2013/03/24 15:54:30 christos Exp $
.include <bsd.own.mk>
SRCS = dhcpd.c dhcp.c dhcpv6.c bootp.c confpars.c db.c class.c failover.c \
omapi.c mdb.c mdb6.c stables.c salloc.c ddns.c dhcpleasequery.c
PROG = dhcpd
MAN = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
DHCPSRCDIR= server
.if ${MKSHARE} != "no"
FILESDIR= /usr/share/examples/dhcp
FILES= dhcpd.conf
.endif
.include <bsd.prog.mk>

104
external/bsd/dhcp/bin/server/dhcpd.conf vendored Normal file
View File

@@ -0,0 +1,104 @@
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Dynamic DNS update scheme - must be set to "none", "interim" or "ad-hoc".
ddns-update-style none;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}
# A slightly different configuration for an internal subnet.
subnet 10.5.5.0 netmask 255.255.255.224 {
range 10.5.5.26 10.5.5.30;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 10.5.5.1;
option broadcast-address 10.5.5.31;
default-lease-time 600;
max-lease-time 7200;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
filename "vmunix.passacaglia";
server-name "toccata.fugue.com";
}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool {
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}

102
external/bsd/dhcp/dhcp2netbsd vendored Executable file
View File

@@ -0,0 +1,102 @@
#! /bin/sh
#
# $NetBSD: dhcp2netbsd,v 1.2 2013/03/27 00:38:41 christos Exp $
#
# Copyright (c) 2003, 2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# dhcp2netbsd: convert a dhcp source tree into a
# format suitable for import. Works on current dir.
# You can run this only once if you want it to work.
#
# based on file2netbsd
#
PROG="$(basename "$0")"
if [ -z "$1" ]
then
echo "Usage: $PROG <directory>" 1>&2
exit 1
fi
FILE="$1"
### Wipe out stuff we don't want
rm -fr bind
### Remove the $'s around RCS tags
cleantags "$FILE"
### Add NetBSD RCS Id
find "$FILE" -type f -name '*.[chly]' -print | while read c; do
sed -e '1{/$NetBSD/!{i\
/* \$NetBSD\$ */\
};}' $c > /tmp/dhcp1$$
mv /tmp/dhcp1$$ $c && echo did source mods for $c
done
find "$FILE" -type f -name '*.[cly]' -print | while read c; do
sed -e \
'/:\/\/www.isc.org/,/^ \*\// {
/^ \*\//a\
\
#include <sys/cdefs.h>\
__RCSID("\$NetBSD\$");
}' $c > /tmp/dhcp1$$
mv /tmp/dhcp1$$ $c && echo did source mods for $c
done
for f in dst/dst_api.c dst/dst_support.c dst/hmac_link.c dst/prandom.c \
omapip/inet_addr.c omapip/iscprint.c server/dhcpv6.c \
server/dhcpleasequery.c server/ldap.c server/mdb6.c; do
c=$FILE/$f
sed -E -e \
'/\* TH(E|IS) SOFTWARE/,/^ \*\// {
/^ \*\//a\
\
#include <sys/cdefs.h>\
__RCSID("\$NetBSD\$");\
}' $c > /tmp/dhcp1$$
mv /tmp/dhcp1$$ $c && echo did source mods for $c
done
#### Add RCS tags to man pages
find "$FILE" -type f -name '*.[0-9]' -print | while read m; do
sed -e '1{/$NetBSD/!i\
.\\" \$NetBSD\$\
.\\"
}' $m > /tmp/dhcp2$$
mv /tmp/dhcp2$$ $m && echo did manpage mods for $m
done
echo done
echo You can import now. Use the following command:
echo cvs -d cvs.netbsd.org:/cvsroot import src/external/bsd/dhcp/dist ISC DHCPX_Y_Z
exit 0

23
external/bsd/dhcp/dist/LICENSE vendored Normal file
View File

@@ -0,0 +1,23 @@
# Copyright (c) 2004-2014 by Internet Systems Consortium, Inc. ("ISC")
# Copyright (c) 1995-2003 by Internet Software Consortium
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Internet Systems Consortium, Inc.
# 950 Charter Street
# Redwood City, CA 94063
# <info@isc.org>
# https://www.isc.org/
See the specific source files for any additional copyright or
license statements.

31
external/bsd/dhcp/dist/Makefile.am vendored Normal file
View File

@@ -0,0 +1,31 @@
#
# automake adds dependencies that we don't like, so we explicitly remove them
#
Makefile:
#
# We have a lot of files that we want shipped with the distribution.
#
EXTRA_DIST = RELNOTES LICENSE \
contrib/3.0b1-lease-convert contrib/dhclient-tz-exithook.sh \
contrib/dhcp.spec contrib/sethostname.sh contrib/solaris.init \
contrib/ms2isc/Registry.pm contrib/ms2isc/ms2isc.pl \
contrib/ms2isc/readme.txt contrib/ldap/dhcpd-conf-to-ldap \
contrib/ldap/dhcp.schema contrib/ldap/README.ldap \
contrib/dhcp-lease-list.pl \
doc/IANA-arp-parameters doc/Makefile doc/References.html \
doc/References.txt doc/References.xml doc/api+protocol \
doc/ja_JP.eucJP/dhclient-script.8 doc/ja_JP.eucJP/dhclient.8 \
doc/ja_JP.eucJP/dhclient.conf.5 doc/ja_JP.eucJP/dhclient.leases.5 \
doc/ja_JP.eucJP/dhcp-eval.5 doc/ja_JP.eucJP/dhcp-options.5 \
doc/examples/dhclient-dhcpv6.conf doc/examples/dhcpd-dhcpv6.conf \
doc/devel/arch.dox doc/devel/atf.dox doc/devel/contrib.dox \
doc/devel/debug.dox doc/devel/isc-logo.jpg doc/devel/mainpage.dox \
doc/devel/omapi.dox doc/devel/qa.dox util/bindvar.sh \
bind/Makefile bind/bind.tar.gz bind/version.tmp \
common/tests/Atffile server/tests/Atffile
SUBDIRS = bind includes tests common dst omapip client dhcpctl relay server
nobase_include_HEADERS = dhcpctl/dhcpctl.h

832
external/bsd/dhcp/dist/Makefile.in vendored Normal file
View File

@@ -0,0 +1,832 @@
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(top_srcdir)/doc/devel/doxyfile.in $(nobase_include_HEADERS) \
README compile config.guess config.sub depcomp install-sh \
missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES = doc/devel/doxyfile
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(includedir)"
HEADERS = $(nobase_include_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
ATF_CFLAGS = @ATF_CFLAGS@
ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_CFLAGS = @LDAP_CFLAGS@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_prefix_program = @ac_prefix_program@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
byte_order = @byte_order@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
# We have a lot of files that we want shipped with the distribution.
#
EXTRA_DIST = RELNOTES LICENSE \
contrib/3.0b1-lease-convert contrib/dhclient-tz-exithook.sh \
contrib/dhcp.spec contrib/sethostname.sh contrib/solaris.init \
contrib/ms2isc/Registry.pm contrib/ms2isc/ms2isc.pl \
contrib/ms2isc/readme.txt contrib/ldap/dhcpd-conf-to-ldap \
contrib/ldap/dhcp.schema contrib/ldap/README.ldap \
contrib/dhcp-lease-list.pl \
doc/IANA-arp-parameters doc/Makefile doc/References.html \
doc/References.txt doc/References.xml doc/api+protocol \
doc/ja_JP.eucJP/dhclient-script.8 doc/ja_JP.eucJP/dhclient.8 \
doc/ja_JP.eucJP/dhclient.conf.5 doc/ja_JP.eucJP/dhclient.leases.5 \
doc/ja_JP.eucJP/dhcp-eval.5 doc/ja_JP.eucJP/dhcp-options.5 \
doc/examples/dhclient-dhcpv6.conf doc/examples/dhcpd-dhcpv6.conf \
doc/devel/arch.dox doc/devel/atf.dox doc/devel/contrib.dox \
doc/devel/debug.dox doc/devel/isc-logo.jpg doc/devel/mainpage.dox \
doc/devel/omapi.dox doc/devel/qa.dox util/bindvar.sh \
bind/Makefile bind/bind.tar.gz bind/version.tmp \
common/tests/Atffile server/tests/Atffile
SUBDIRS = bind includes tests common dst omapip client dhcpctl relay server
nobase_include_HEADERS = dhcpctl/dhcpctl.h
all: all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
doc/devel/doxyfile: $(top_builddir)/config.status $(top_srcdir)/doc/devel/doxyfile.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-nobase_includeHEADERS: $(nobase_include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
fi; \
$(am__nobase_list) | while read dir files; do \
xfiles=; for file in $$files; do \
if test -f "$$file"; then xfiles="$$xfiles $$file"; \
else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
test -z "$$xfiles" || { \
test "x$$dir" = x. || { \
echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \
$(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \
echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \
$(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \
done
uninstall-nobase_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \
$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-nobase_includeHEADERS
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-nobase_includeHEADERS
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-generic distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-nobase_includeHEADERS \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
tags-am uninstall uninstall-am uninstall-nobase_includeHEADERS
#
# automake adds dependencies that we don't like, so we explicitly remove them
#
Makefile:
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

718
external/bsd/dhcp/dist/README vendored Normal file
View File

@@ -0,0 +1,718 @@
Internet Systems Consortium DHCP Distribution
Version 4.3.0
3 February 2014
README FILE
You should read this file carefully before trying to install or use
the ISC DHCP Distribution.
TABLE OF CONTENTS
1 WHERE TO FIND DOCUMENTATION
2 RELEASE STATUS
3 BUILDING THE DHCP DISTRIBUTION
3.1 UNPACKING IT
3.2 CONFIGURING IT
3.2.1 DYNAMIC DNS UPDATES
3.2.2 LOCALLY DEFINED OPTIONS
3.3 BUILDING IT
4 INSTALLING THE DHCP DISTRIBUTION
5 USING THE DHCP DISTRIBUTION
5.1 FIREWALL RULES
5.2 LINUX
5.2.1 IF_TR.H NOT FOUND
5.2.2 SO_ATTACH_FILTER UNDECLARED
5.2.3 PROTOCOL NOT CONFIGURED
5.2.4 BROADCAST
5.2.6 IP BOOTP AGENT
5.2.7 MULTIPLE INTERFACES
5.3 SCO
5.4 HP-UX
5.5 ULTRIX
5.6 FreeBSD
5.7 NeXTSTEP
5.8 SOLARIS
5.8.1 Solaris 11
5.8.2 Solaris 11 and ATF
5.8.3 Other Solaris Items
5.9 AIX
5.10 MacOS X
6 SUPPORT
6.1 HOW TO REPORT BUGS
7 HISTORY
WHERE TO FIND DOCUMENTATION
Documentation for this software includes this README file, the
RELNOTES file, and the manual pages, which are in the server, common,
client and relay subdirectories. The README file (this file) includes
late-breaking operational and system-specific information that you
should read even if you don't want to read the manual pages, and that
you should *certainly* read if you run into trouble. Internet
standards relating to the DHCP protocol are listed in the References
document that is available in html, txt and xml formats in doc/
subdirectory. You will have the best luck reading the manual pages if
you build this software and then install it, although you can read
them directly out of the distribution if you need to.
DHCP server documentation is in the dhcpd man page. Information about
the DHCP server lease database is in the dhcpd.leases man page.
Server configuration documentation is in the dhcpd.conf man page as
well as the dhcp-options man page. A sample DHCP server
configuration is in the file server/dhcpd.conf.example. The source for
the dhcpd, dhcpd.leases and dhcpd.conf man pages is in the server/ sub-
directory in the distribution. The source for the dhcp-options.5
man page is in the common/ subdirectory.
DHCP Client documentation is in the dhclient man page. DHCP client
configuration documentation is in the dhclient.conf man page and the
dhcp-options man page. The DHCP client configuration script is
documented in the dhclient-script man page. The format of the DHCP
client lease database is documented in the dhclient.leases man page.
The source for all these man pages is in the client/ subdirectory in
the distribution. In addition, the dhcp-options man page should be
referred to for information about DHCP options.
DHCP relay agent documentation is in the dhcrelay man page, the source
for which is distributed in the relay/ subdirectory.
To read installed manual pages, use the man command. Type "man page"
where page is the name of the manual page. This will only work if
you have installed the ISC DHCP distribution using the ``make install''
command (described later).
If you want to read manual pages that aren't installed, you can type
``nroff -man page |more'' where page is the filename of the
unformatted manual page. The filename of an unformatted manual page
is the name of the manual page, followed by '.', followed by some
number - 5 for documentation about files, and 8 for documentation
about programs. For example, to read the dhcp-options man page,
you would type ``nroff -man common/dhcp-options.5 |more'', assuming
your current working directory is the top level directory of the ISC
DHCP Distribution.
Please note that the pathnames of files to which our manpages refer
will not be correct for your operating system until after you iterate
'make install' (so if you're reading a manpage out of the source
directory, it may not have up-to-date information).
RELEASE STATUS
This is ISC DHCP 4.3.0. The major theme for this release is "ipv6 uplift",
in which we enhance the v6 code to support many of the features found
in the v4 code. These include: support for v6, support for on_commit,
on_expiry and on_release in v6, support for accessing v6 relay options
and better log messages for v6 addresses. Non v6 features include:
support for the standard DDNS, better OMAPI class and sub-class support
allowing for dynamic addition and removal of sub-classes, and support for
DDNS without zone statements.
In this release, the DHCPv6 server should be fully functional on Linux,
Solaris, or any BSD. The DHCPv6 client should be similarly functional
except on Solaris.
The DHCPv4 server, relay, and client, should be fully functional
on Linux, Solaris, any BSD, HPUX, SCO, NextSTEP, and Irix.
If you are running the DHCP distribution on a machine which is a
firewall, or if there is a firewall between your DHCP server(s) and
DHCP clients, please read the section on firewalls which appears later
in this document.
If you wish to run the DHCP Distribution on Linux, please see the
Linux-specific notes later in this document. If you wish to run on an
SCO release, please see the SCO-specific notes later in this document.
You particularly need to read these notes if you intend to support
Windows 95 clients. If you are running HP-UX or Ultrix, please read the
notes for those operating systems below. If you are running NeXTSTEP,
please see the notes on NeXTSTEP below.
If you start dhcpd and get a message, "no free bpf", that means you
need to configure the Berkeley Packet Filter into your operating
system kernel. On NetBSD, FreeBSD and BSD/os, type ``man bpf'' for
information. On Digital Unix, type ``man pfilt''.
BUILDING THE DHCP DISTRIBUTION
UNPACKING IT
To build the DHCP Distribution, unpack the compressed tar file using
the tar utility and the gzip command - type something like:
gunzip dhcp-4.3.0.tar.gz
tar xvf dhcp-4.3.0.tar
CONFIGURING IT
Now, cd to the dhcp-4.3.0 subdirectory that you've just created and
configure the source tree by typing:
./configure
If the configure utility can figure out what sort of system you're
running on, it will create a custom Makefile for you for that
system; otherwise, it will complain. If it can't figure out what
system you are using, that system is not supported - you are on
your own.
Several options may be enabled or disabled via the configure command.
You can get a list of these by typing:
./configure --help
DYNAMIC DNS UPDATES
A fully-featured implementation of dynamic DNS updates is included in
this release. It uses libraries from BIND and, to avoid issues with
different versions, includes the necessary BIND version. The appropriate
BIND libraries will be compiled and installed in the bind subdirectory
as part of the make step. In order to build the necessary libraries you
will need to have "gmake" available on your build system.
There is documentation for the DDNS support in the dhcpd.conf manual
page - see the beginning of this document for information on finding
manual pages.
LOCALLY DEFINED OPTIONS
In previous versions of the DHCP server there was a mechanism whereby
options that were not known by the server could be configured using
a name made up of the option code number and an identifier:
"option-nnn" This is no longer supported, because it is not future-
proof. Instead, if you want to use an option that the server doesn't
know about, you must explicitly define it using the method described
in the dhcp-options man page under the DEFINING NEW OPTIONS heading.
BUILDING IT
Once you've run configure, just type ``make'', and after a while
you should have a dhcp server. If you get compile errors on one
of the supported systems mentioned earlier, please let us know.
If you get warnings, it's not likely to be a problem - the DHCP
server compiles completely warning-free on as many architectures
as we can manage, but there are a few for which this is difficult.
If you get errors on a system not mentioned above, you will need
to do some programming or debugging on your own to get the DHCP
Distribution working.
INSTALLING THE DHCP DISTRIBUTION
Once you have successfully gotten the DHCP Distribution to build, you
can install it by typing ``make install''. If you already have an old
version of the DHCP Distribution installed, you may want to save it
before typing ``make install''.
USING THE DHCP DISTRIBUTION
FIREWALL RULES
If you are running the DHCP server or client on a computer that's also
acting as a firewall, you must be sure to allow DHCP packets through
the firewall. In particular, your firewall rules _must_ allow packets
from IP address 0.0.0.0 to IP address 255.255.255.255 from UDP port 68
to UDP port 67 through. They must also allow packets from your local
firewall's IP address and UDP port 67 through to any address your DHCP
server might serve on UDP port 68. Finally, packets from relay agents
on port 67 to the DHCP server on port 67, and vice versa, must be
permitted.
We have noticed that on some systems where we are using a packet
filter, if you set up a firewall that blocks UDP port 67 and 68
entirely, packets sent through the packet filter will not be blocked.
However, unicast packets will be blocked. This can result in strange
behaviour, particularly on DHCP clients, where the initial packet
exchange is broadcast, but renewals are unicast - the client will
appear to be unable to renew until it starts broadcasting its
renewals, and then suddenly it'll work. The fix is to fix the
firewall rules as described above.
PARTIAL SERVERS
If you have a server that is connected to two networks, and you only
want to provide DHCP service on one of those networks (e.g., you are
using a cable modem and have set up a NAT router), if you don't write
any subnet declaration for the network you aren't supporting, the DHCP
server will ignore input on that network interface if it can. If it
can't, it will refuse to run - some operating systems do not have the
capability of supporting DHCP on machines with more than one
interface, and ironically this is the case even if you don't want to
provide DHCP service on one of those interfaces.
LINUX
There are three big LINUX issues: the all-ones broadcast address,
Linux 2.1 ip_bootp_agent enabling, and operations with more than one
network interface. There are also two potential compilation/runtime
problems for Linux 2.1/2.2: the "SO_ATTACH_FILTER undeclared" problem
and the "protocol not configured" problem.
LINUX: PROTOCOL NOT CONFIGURED
If you get the following message, it's because your kernel doesn't
have the linux packetfilter or raw packet socket configured:
Make sure CONFIG_PACKET (Packet socket) and CONFIG_FILTER (Socket
Filtering) are enabled in your kernel configuration
If this happens, you need to configure your Linux kernel to support
Socket Filtering and the Packet socket, or to select a kernel provided
by your Linux distribution that has these enabled (virtually all modern
ones do by default).
LINUX: BROADCAST
If you are running a recent version of Linux, this won't be a problem,
but on older versions of Linux (kernel versions prior to 2.2), there
is a potential problem with the broadcast address being sent
incorrectly.
In order for dhcpd to work correctly with picky DHCP clients (e.g.,
Windows 95), it must be able to send packets with an IP destination
address of 255.255.255.255. Unfortunately, Linux changes an IP
destination of 255.255.255.255 into the local subnet broadcast address
(here, that's 192.5.5.223).
This isn't generally a problem on Linux 2.2 and later kernels, since
we completely bypass the Linux IP stack, but on old versions of Linux
2.1 and all versions of Linux prior to 2.1, it is a problem - pickier
DHCP clients connected to the same network as the ISC DHCP server or
ISC relay agent will not see messages from the DHCP server. It *is*
possible to run into trouble with this on Linux 2.2 and later if you
are running a version of the DHCP server that was compiled on a Linux
2.0 system, though.
It is possible to work around this problem on some versions of Linux
by creating a host route from your network interface address to
255.255.255.255. The command you need to use to do this on Linux
varies from version to version. The easiest version is:
route add -host 255.255.255.255 dev eth0
On some older Linux systems, you will get an error if you try to do
this. On those systems, try adding the following entry to your
/etc/hosts file:
255.255.255.255 all-ones
Then, try:
route add -host all-ones dev eth0
Another route that has worked for some users is:
route add -net 255.255.255.0 dev eth0
If you are not using eth0 as your network interface, you should
specify the network interface you *are* using in your route command.
LINUX: IP BOOTP AGENT
Some versions of the Linux 2.1 kernel apparently prevent dhcpd from
working unless you enable it by doing the following:
echo 1 >/proc/sys/net/ipv4/ip_bootp_agent
LINUX: MULTIPLE INTERFACES
Very old versions of the Linux kernel do not provide a networking API
that allows dhcpd to operate correctly if the system has more than one
broadcast network interface. However, Linux 2.0 kernels with version
numbers greater than or equal to 2.0.31 add an API feature: the
SO_BINDTODEVICE socket option. If SO_BINDTODEVICE is present, it is
possible for dhcpd to operate on Linux with more than one network
interface. In order to take advantage of this, you must be running a
2.0.31 or greater kernel, and you must have 2.0.31 or later system
headers installed *before* you build the DHCP Distribution.
We have heard reports that you must still add routes to 255.255.255.255
in order for the all-ones broadcast to work, even on 2.0.31 kernels.
In fact, you now need to add a route for each interface. Hopefully
the Linux kernel gurus will get this straight eventually.
Linux 2.1 and later kernels do not use SO_BINDTODEVICE or require the
broadcast address hack, but do support multiple interfaces, using the
Linux Packet Filter.
LINUX: OpenWrt
DHCP 4.1 has been tested on OpenWrt 7.09 and 8.09. In keeping with
standard practice, client/scripts now includes a dhclient-script file
for OpenWrt. However, this is not sufficient by itself to run dhcp on
OpenWrt; a full OpenWrt package for DHCP is available at
ftp://ftp.isc.org/isc/dhcp/dhcp-4.1.0-openwrt.tar.gz
LINUX: 802.1q VLAN INTERFACES
If you're using 802.1q vlan interfaces on Linux, it is necessary to
vconfig the subinterface(s) to rewrite the 802.1q information out of
packets received by the dhcpd daemon via LPF:
vconfig set_flag eth1.523 1 1
Note that this may affect the performance of your system, since the
Linux kernel must rewrite packets received via this interface. For
more information, consult the vconfig man pages.
SCO
ISC DHCP will now work correctly on newer versions of SCO out of the
box (tested on OpenServer 5.05b, assumed to work on UnixWare 7).
Older versions of SCO have the same problem as Linux (described earlier).
The thing is, SCO *really* doesn't want to let you add a host route to
the all-ones broadcast address.
You can try the following:
ifconfig net0 xxx.xxx.xxx.xxx netmask 0xNNNNNNNN broadcast 255.255.255.255
If this doesn't work, you can also try the following strange hack:
ifconfig net0 alias 10.1.1.1 netmask 8.0.0.0
Apparently this works because of an interaction between SCO's support
for network classes and the weird netmask. The 10.* network is just a
dummy that can generally be assumed to be safe. Don't ask why this
works. Just try it. If it works for you, great.
HP-UX
HP-UX has the same problem with the all-ones broadcast address that
SCO and Linux have. One user reported that adding the following to
/etc/rc.config.d/netconf helped (you may have to modify this to suit
your local configuration):
INTERFACE_NAME[0]=lan0
IP_ADDRESS[0]=1.1.1.1
SUBNET_MASK[0]=255.255.255.0
BROADCAST_ADDRESS[0]="255.255.255.255"
LANCONFIG_ARGS[0]="ether"
DHCP_ENABLE[0]=0
ULTRIX
Now that we have Ultrix packet filter support, the DHCP Distribution
on Ultrix should be pretty trouble-free. However, one thing you do
need to be aware of is that it now requires that the pfilt device be
configured into your kernel and present in /dev. If you type ``man
packetfilter'', you will get some information on how to configure your
kernel for the packet filter (if it isn't already) and how to make an
entry for it in /dev.
FreeBSD
Versions of FreeBSD prior to 2.2 have a bug in BPF support in that the
ethernet driver swaps the ethertype field in the ethernet header
downstream from BPF, which corrupts the output packet. If you are
running a version of FreeBSD prior to 2.2, and you find that dhcpd
can't communicate with its clients, you should #define BROKEN_FREEBSD_BPF
in site.h and recompile.
Modern versions of FreeBSD include the ISC DHCP 3.0 client as part of
the base system, and the full distribution (for the DHCP server and
relay agent) is available from the Ports Collection in
/usr/ports/net/isc-dhcp3, or as a package on FreeBSD installation
CDROMs.
NeXTSTEP
The NeXTSTEP support uses the NeXTSTEP Berkeley Packet Filter
extension, which is not included in the base NextStep system. You
must install this extension in order to get dhcpd or dhclient to work.
SOLARIS
There are two known issues seen when compiling using the Sun compiler.
The first is that older Sun compilers generate an error on some of
our uses of the flexible array option. Newer versions only generate
a warning, which can be safely ignored. If you run into this error
("type of struct member "buf" can not be derived from structure with
flexible array member"), upgrade your tools to Oracle Solaris Studio
(previously Sun Studio) 12 or something newer.
The second is the interaction between the configure script and the
makefiles for the Bind libraries. Currently we don't pass all
environment variables between the DHCP configure and the Bind configure.
If you attempt to specify the compiler you wish to use like this:
CC=/opt/SUNWspro/bin/cc ./configure
"make" may not build the Bind libraries with that compiler.
In order to use the same compiler for Bind and DHCP we suggest the
following commands:
CC=/opt/SUNWspro/bin/cc ./configure
CC=/opt/SUNWspro/bin/cc make
Solaris 11
We have integrated a patch from Oracle to use sockets instead of
DLPI on Solaris 11. This functionality was written for use with
Solaris Studio 12.2 and requires the system/header package.
By default this code is disabled in order to minimize disruptions
for current users. In order to enable this code you will need to
enable both USE_SOCKETS and USE_V4_PKTINFO as part of the
configuration step. The command line would be something like:
./configure --enable-use-sockets --enable-ipv4-pktinfo
Solaris 11 and ATF
We have reports that ATF 0.15 and 0.16 do not build on Solaris 11. The
following changes to the ATF source code appear to fix this issue:
diff -ru atf-0.15/atf-c/tp_test.c atf-0.15-patched/atf-c/tp_test.c
--- atf-0.15/atf-c/tp_test.c 2011-12-06 06:31:11.000000000 +0100
+++ atf-0.15-patched/atf-c/tp_test.c 2012-06-19 15:54:57.000000000 +0200
@@ -28,6 +28,7 @@
*/
#include <string.h>
+#include <stdio.h>
#include <unistd.h>
#include <atf-c.h>
diff -ru atf-0.15/atf-run/requirements.cpp atf-0.15-patched/atf-run/requirements.cpp
--- atf-0.15/atf-run/requirements.cpp 2012-01-13 20:44:25.000000000 +0100
+++ atf-0.15-patched/atf-run/requirements.cpp 2012-06-19 15:41:51.000000000 +0200
@@ -29,7 +29,7 @@
extern "C" {
#include <sys/param.h>
-#include <sys/sysctl.h>
+//#include <sys/sysctl.h>
}
#include <cerrno>
Other Solaris Items
One problem which has been observed and is not fixed in this
patchlevel has to do with using DLPI on Solaris machines. The symptom
of this problem is that the DHCP server never receives any requests.
This has been observed with Solaris 2.6 and Solaris 7 on Intel x86
systems, although it may occur with other systems as well. If you
encounter this symptom, and you are running the DHCP server on a
machine with a single broadcast network interface, you may wish to
edit the includes/site.h file and uncomment the #define USE_SOCKETS
line. Then type ``make clean; make''. As an alternative workaround,
it has been reported that running 'snoop' will cause the dhcp server
to start receiving packets. So the practice reported to us is to run
snoop at dhcpd startup time, with arguments to cause it to receive one
packet and exit.
snoop -c 1 udp port 67 > /dev/null &
The DHCP client on Solaris will only work with DLPI. If you run it
and it just keeps saying it's sending DHCPREQUEST packets, but never
gets a response, you may be having DLPI trouble as described above.
If so, we have no solution to offer at this time, aside from the above
workaround which should also work here. Also, because Solaris requires
you to "plumb" an interface before it can be detected by the DHCP client,
you must either specify the name(s) of the interface(s) you want to
configure on the command line, or must plumb the interfaces prior to
invoking the DHCP client. This can be done with ``ifconfig iface plumb'',
where iface is the name of the interface (e.g., ``ifconfig hme0 plumb'').
It should be noted that Solaris versions from 2.6 onward include a
DHCP client that you can run with ``/sbin/ifconfig iface dhcp start''
rather than using the ISC DHCP client, including DHCPv6. Consequently,
we don't believe there is a need for the client to run on Solaris, and
have not engineered the needed DHCPv6 modifications for the dhclient-script.
If you feel this is in error, or have a need, please contact us.
AIX
The AIX support uses the BSD socket API, which cannot differentiate on
which network interface a broadcast packet was received; thus the DHCP
server and relay will work only on a single interface. (They do work
on multi-interface machines if configured to listen on only one of the
interfaces.)
We have reports of Windows XP clients having difficulty retrieving
addresses from a server running on an AIX machine. This issue
was traced to the client requiring messages be sent to the all ones
broadcast address (255.255.255.255) while the AIX server was sending
to 192.168.0.255.
You may be able to solve this by including a relay between the client
and server with the relay configured to use a broadcast of all-ones.
A second option that worked for AIX 5.1 but doesn't seem to work for
AIX 5.3 was to:
create a host file entry for all-ones (255.255.255.255)
and then add a route:
route add -host all-ones -interface <local-ip-address>
The ISC DHCP distribution does not include a dhclient-script for AIX--
AIX comes with a DHCP client. Contribution of a working dhclient-script
for AIX would be welcome.
MacOS X
The MacOS X system uses a TCP/IP stack derived from FreeBSD with a
user-friendly interface named the System Configuration Framework.
As it includes a builtin DHCPv4 client (you are better just using that),
this text is only about the DHCPv6 client (``dhclient -6 ...''). The DNS
configuration (domain search list and name servers' addresses) is managed
by a System Configuration agent, not by /etc/resolv.conf (which is a link
to /var/run/resolv.conf, which itself only reflects the internal state;
the System Configuration framework's Dynamic Store).
This means that modifying resolv.conf directly doesn't have the
intended effect, instead the macos script sample creates its own
resolv.conf.dhclient6 in /var/run, and inserts the contents of this
file into the Dynamic Store.
When updating the address configuration the System Configuration
framework expects the prefix and a default router along with the
configured address. As this extra information is not available via
the DHCPv6 protocol the System Configuration framework isn't usable
for address configuration, instead ifconfig is used directly.
Note the Dynamic Store (from which /var/run/resolv.conf is built) is
recomputed from scratch when the current location/set is changed.
Running the dhclient-script reinstalls the resolv.conf.dhclient6
configuration.
SUPPORT
The Internet Systems Consortium DHCP server is developed and distributed
by ISC in the public trust, thanks to the generous donations of its
sponsors. ISC now also offers commercial quality support contracts for
ISC DHCP, more information about ISC Support Contracts can be found at
the following URL:
https://www.isc.org/services/support/
Please understand that we may not respond to support inquiries unless
you have a support contract. ISC will continue its practice of always
responding to critical items that effect the entire community, and
responding to all other requests for support upon ISC's mailing lists
on a best-effort basis.
However, ISC DHCP has attracted a fairly sizable following on the
Internet, which means that there are a lot of knowledgeable users who
may be able to help you if you get stuck. These people generally
read the dhcp-users@isc.org mailing list. Be sure to provide as much
detail in your query as possible.
If you are going to use ISC DHCP, you should probably subscribe to
the dhcp-users or dhcp-announce mailing lists.
WHERE TO SEND FEATURE REQUESTS: We like to hear your feedback. We may
not respond to it all the time, but we do read it. If ISC DHCP doesn't
work well for you, or you have an idea that would improve it for your
use, please send your suggestion to dhcp-suggest@isc.org. This is also
an excellent place to send patches that add new features.
WHERE TO REPORT BUGS: If you want the act of sending in a bug report
to result in you getting help in the form of a fixed piece of
software, you are asking for help. Your bug report is helpful to us,
but fundamentally you are making a support request, so please use the
addresses described in the previous paragraphs. If you are _sure_ that
your problem is a bug, and not user error, or if your bug report
includes a patch, you can send it to our ticketing system at
dhcp-bugs@isc.org. If you have not received a notice that the ticket
has been resolved, then we're still working on it.
PLEASE DO NOT REPORT BUGS IN OLD SOFTWARE RELEASES! Fetch the latest
release and see if the bug is still in that version of the software,
and if it is still present, _then_ report it. ISC release versions
always have three numbers, for example: 1.2.3. The 'major release' is
1 here, the 'minor release' is 2, and the 'maintenance release' is 3.
ISC will accept bug reports against the most recent two major.minor
releases: for example, 1.0.0 and 0.9.0, but not 0.8.* or prior.
PLEASE take a moment to determine where the ISC DHCP distribution
that you're using came from. ISC DHCP is sometimes heavily modified
by integrators in various operating systems - it's not that we
feel that our software is perfect and incapable of having bugs, but
rather that it is very frustrating to find out after many days trying
to help someone that the sources you're looking at aren't what they're
running. When in doubt, please retrieve the source distribution from
ISC's web page and install it.
HOW TO REPORT BUGS OR REQUEST HELP
When you report bugs or ask for help, please provide us complete
information. A list of information we need follows. Please read it
carefully, and put all the information you can into your initial bug
report. This will save us a great deal of time and more informative
bug reports are more likely to get handled more quickly overall.
1. The specific operating system name and version of the
machine on which the DHCP server or client is running.
2. The specific operating system name and version of the
machine on which the client is running, if you are having
trouble getting a client working with the server.
3. If you're running Linux, the version number we care about is
the kernel version and maybe the library version, not the
distribution version - e.g., while we don't mind knowing
that you're running Redhat version mumble.foo, we must know
what kernel version you're running, and it helps if you can
tell us what version of the C library you're running,
although if you don't know that off the top of your head it
may be hard for you to figure it out, so don't go crazy
trying.
4. The specific version of the DHCP distribution you're
running, as reported by dhcpd -t.
5. Please explain the problem carefully, thinking through what
you're saying to ensure that you don't assume we know
something about your situation that we don't know.
6. Include your dhcpd.conf and dhcpd.leases file as MIME attachments
if they're not over 100 kilobytes in size each. If they are
this large, please make them available to us eg via a hidden
http:// URL or FTP site. If you're not comfortable releasing
this information due to sensitive contents, you may encrypt
the file to our release signing key, available on our website.
7. Include a log of your server or client running until it
encounters the problem - for example, if you are having
trouble getting some client to get an address, restart the
server with the -d flag and then restart the client, and
send us what the server prints. Likewise, with the client,
include the output of the client as it fails to get an
address or otherwise does the wrong thing. Do not leave
out parts of the output that you think aren't interesting.
8. If the client or server is dumping core, please run the
debugger and get a stack trace, and include that in your
bug report. For example, if your debugger is gdb, do the
following:
gdb dhcpd dhcpd.core
(gdb) where
[...]
(gdb) quit
This assumes that it's the dhcp server you're debugging, and
that the core file is in dhcpd.core.
Please see https://www.isc.org/software/dhcp/ for details on how to subscribe
to the ISC DHCP mailing lists.
HISTORY
ISC DHCP was originally written by Ted Lemon under a contract with
Vixie Labs with the goal of being a complete reference implementation
of the DHCP protocol. Funding for this project was provided by
Internet Systems Consortium. The first release of the ISC DHCP
distribution in December 1997 included just the DHCP server.
Release 2 in June 1999 added a DHCP client and a BOOTP/DHCP relay
agent. DHCP 3 was released in October 2001 and included DHCP failover
support, OMAPI, Dynamic DNS, conditional behaviour, client classing,
and more. Version 3 of the DHCP server was funded by Nominum, Inc.
The 4.0 release in December 2007 introduced DHCPv6 protocol support
for the server and client.
This product includes cryptographic software written
by Eric Young (eay@cryptsoft.com).

3680
external/bsd/dhcp/dist/RELNOTES vendored Normal file

File diff suppressed because it is too large Load Diff

1185
external/bsd/dhcp/dist/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
dist_sysconf_DATA = dhclient.conf.example
sbin_PROGRAMS = dhclient
dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
scripts/netbsd scripts/nextstep scripts/openbsd \
scripts/solaris scripts/openwrt
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a ../bind/lib/libirs.a \
../bind/lib/libdns.a ../bind/lib/libisccfg.a ../bind/lib/libisc.a
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
EXTRA_DIST = $(man_MANS)
dhclient.o: dhclient.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhclient.c
dhc6.o: dhc6.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhc6.c

View File

@@ -0,0 +1,735 @@
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = dhclient$(EXEEXT)
subdir = client
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp $(dist_sysconf_DATA)
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" \
"$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)"
PROGRAMS = $(sbin_PROGRAMS)
am_dhclient_OBJECTS = clparse.$(OBJEXT) dhclient.$(OBJEXT) \
dhc6.$(OBJEXT)
dhclient_OBJECTS = $(am_dhclient_OBJECTS)
dhclient_DEPENDENCIES = ../common/libdhcp.a ../omapip/libomapi.a \
../bind/lib/libirs.a ../bind/lib/libdns.a \
../bind/lib/libisccfg.a ../bind/lib/libisc.a
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(dhclient_SOURCES)
DIST_SOURCES = $(dhclient_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man5dir = $(mandir)/man5
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
DATA = $(dist_sysconf_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
ATF_CFLAGS = @ATF_CFLAGS@
ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_CFLAGS = @LDAP_CFLAGS@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_prefix_program = @ac_prefix_program@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
byte_order = @byte_order@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
dist_sysconf_DATA = dhclient.conf.example
dhclient_SOURCES = clparse.c dhclient.c dhc6.c \
scripts/bsdos scripts/freebsd scripts/linux scripts/macos \
scripts/netbsd scripts/nextstep scripts/openbsd \
scripts/solaris scripts/openwrt
dhclient_LDADD = ../common/libdhcp.a ../omapip/libomapi.a ../bind/lib/libirs.a \
../bind/lib/libdns.a ../bind/lib/libisccfg.a ../bind/lib/libisc.a
man_MANS = dhclient.8 dhclient-script.8 dhclient.conf.5 dhclient.leases.5
EXTRA_DIST = $(man_MANS)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign client/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign client/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
} \
; done
uninstall-sbinPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(sbindir)" && rm -f $$files
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
dhclient$(EXEEXT): $(dhclient_OBJECTS) $(dhclient_DEPENDENCIES) $(EXTRA_dhclient_DEPENDENCIES)
@rm -f dhclient$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dhclient_OBJECTS) $(dhclient_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clparse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhc6.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhclient.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
install-man5: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man5dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.5[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
done; }
uninstall-man5:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man5dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.5[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
install-man8: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man8dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.8[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
done; }
uninstall-man8:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man8dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.8[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
install-dist_sysconfDATA: $(dist_sysconf_DATA)
@$(NORMAL_INSTALL)
@list='$(dist_sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(sysconfdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \
done
uninstall-dist_sysconfDATA:
@$(NORMAL_UNINSTALL)
@list='$(dist_sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(sysconfdir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA)
installdirs:
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-man
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-dist_sysconfDATA install-sbinPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man: install-man5 install-man8
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-dist_sysconfDATA uninstall-man \
uninstall-sbinPROGRAMS
uninstall-man: uninstall-man5 uninstall-man8
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dist_sysconfDATA \
install-dvi install-dvi-am install-exec install-exec-am \
install-html install-html-am install-info install-info-am \
install-man install-man5 install-man8 install-pdf \
install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-dist_sysconfDATA \
uninstall-man uninstall-man5 uninstall-man8 \
uninstall-sbinPROGRAMS
dhclient.o: dhclient.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhclient.c
dhc6.o: dhc6.c
$(COMPILE) -DCLIENT_PATH='"PATH=$(sbindir):/sbin:/bin:/usr/sbin:/usr/bin"' \
-DLOCALSTATEDIR='"$(localstatedir)"' -c dhc6.c
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

2239
external/bsd/dhcp/dist/client/clparse.c vendored Normal file

File diff suppressed because it is too large Load Diff

5108
external/bsd/dhcp/dist/client/dhc6.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,235 @@
.\" $NetBSD: dhclient-script.8,v 1.1.1.3 2014/07/12 11:57:34 spz Exp $
.\"
.\" dhclient-script.8
.\"
.\" Copyright (c) 2012,2014 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Internet Systems Consortium, Inc.
.\" 950 Charter Street
.\" Redwood City, CA 94063
.\" <info@isc.org>
.\" https://www.isc.org/
.\"
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
.\" Id: dhclient-script.8,v 1.14 2010/07/02 23:09:14 sar Exp
.\"
.TH dhclient-script 8
.SH NAME
dhclient-script - DHCP client network configuration script
.SH DESCRIPTION
The DHCP client network configuration script is invoked from time to
time by \fBdhclient(8)\fR. This script is used by the dhcp client to
set each interface's initial configuration prior to requesting an
address, to test the address once it has been offered, and to set the
interface's final configuration once a lease has been acquired. If no
lease is acquired, the script is used to test predefined leases, if
any, and also called once if no valid lease can be identified.
.PP
This script is not meant to be customized by the end user. If local
customizations are needed, they should be possible using the enter and
exit hooks provided (see HOOKS for details). These hooks will allow the
user to override the default behaviour of the client in creating a
.B /etc/resolv.conf
file.
.PP
No standard client script exists for some operating systems, even though
the actual client may work, so a pioneering user may well need to create
a new script or modify an existing one. In general, customizations specific
to a particular computer should be done in the
.B ETCDIR/dhclient.conf
file. If you find that you can't make such a customization without
customizing
.B ETCDIR/dhclient.conf
or using the enter and exit hooks, please submit a bug report.
.SH HOOKS
When it starts, the client script first defines a shell function,
.B make_resolv_conf ,
which is later used to create the
.B /etc/resolv.conf
file. To override the default behaviour, redefine this function in
the enter hook script.
.PP
On after defining the make_resolv_conf function, the client script checks
for the presence of an executable
.B ETCDIR/dhclient-enter-hooks
script, and if present, it invokes the script inline, using the Bourne
shell \'.\' command. The entire environment documented under OPERATION
is available to this script, which may modify the environment if needed
to change the behaviour of the script. If an error occurs during the
execution of the script, it can set the exit_status variable to a nonzero
value, and
.B CLIENTBINDIR/dhclient-script
will exit with that error code immediately after the client script exits.
.PP
After all processing has completed,
.B CLIENTBINDIR/dhclient-script
checks for the presence of an executable
.B ETCDIR/dhclient-exit-hooks
script, which if present is invoked using the \'.\' command. The exit
status of dhclient-script will be passed to dhclient-exit-hooks in the
exit_status shell variable, and will always be zero if the script
succeeded at the task for which it was invoked. The rest of the
environment as described previously for dhclient-enter-hooks is also
present. The
.B ETCDIR/dhclient-exit-hooks
script can modify the valid of exit_status to change the exit status
of dhclient-script.
.SH OPERATION
When dhclient needs to invoke the client configuration script, it
defines a set of variables in the environment, and then invokes
.B CLIENTBINDIR/dhclient-script.
In all cases, $reason is set to the name of the reason why the script
has been invoked. The following reasons are currently defined:
MEDIUM, PREINIT, BOUND, RENEW, REBIND, REBOOT, EXPIRE, FAIL, STOP, RELEASE,
NBI and TIMEOUT.
.PP
.SH MEDIUM
The DHCP client is requesting that an interface's media type
be set. The interface name is passed in $interface, and the media
type is passed in $medium.
.SH PREINIT
The DHCP client is requesting that an interface be configured as
required in order to send packets prior to receiving an actual
address. For clients which use the BSD socket library, this means
configuring the interface with an IP address of 0.0.0.0 and a
broadcast address of 255.255.255.255. For other clients, it may be
possible to simply configure the interface up without actually giving
it an IP address at all. The interface name is passed in $interface,
and the media type in $medium.
.PP
If an IP alias has been declared in dhclient.conf, its address will be
passed in $alias_ip_address, and that ip alias should be deleted from
the interface, along with any routes to it.
.SH BOUND
The DHCP client has done an initial binding to a new address. The
new ip address is passed in $new_ip_address, and the interface name is
passed in $interface. The media type is passed in $medium. Any
options acquired from the server are passed using the option name
described in \fBdhcp-options\fR, except that dashes (\'-\') are replaced
by underscores (\'_\') in order to make valid shell variables, and the
variable names start with new_. So for example, the new subnet mask
would be passed in $new_subnet_mask. The options that the client
explicitly requested via a PRL or ORO option are passed with the same
option name as above but prepended with requested_ and with a value of 1,
or example requested_subnet_mask=1. No such variable is defined for
options not requested by the client or options that don't require a
request option, such as the ip address (*_ip_address) or expiration
time (*_expiry).
.PP
Before actually configuring the address, dhclient-script should
somehow ARP for it and exit with a nonzero status if it receives a
reply. In this case, the client will send a DHCPDECLINE message to
the server and acquire a different address. This may also be done in
the RENEW, REBIND, or REBOOT states, but is not required, and indeed
may not be desirable.
.PP
When a binding has been completed, a lot of network parameters are
likely to need to be set up. A new /etc/resolv.conf needs to be
created, using the values of $new_domain_name and
$new_domain_name_servers (which may list more than one server,
separated by spaces). A default route should be set using
$new_routers, and static routes may need to be set up using
$new_static_routes.
.PP
If an IP alias has been declared, it must be set up here. The alias
IP address will be written as $alias_ip_address, and other DHCP
options that are set for the alias (e.g., subnet mask) will be passed
in variables named as described previously except starting with
$alias_ instead of $new_. Care should be taken that the alias IP
address not be used if it is identical to the bound IP address
($new_ip_address), since the other alias parameters may be incorrect
in this case.
.SH RENEW
When a binding has been renewed, the script is called as in BOUND,
except that in addition to all the variables starting with $new_, and
$requested_ there is another set of variables starting with $old_.
Persistent settings that may have changed need to be deleted - for
example, if a local route to the bound address is being configured,
the old local route should be deleted. If the default route has changed,
the old default route should be deleted. If the static routes have changed,
the old ones should be deleted. Otherwise, processing can be done as with
BOUND.
.SH REBIND
The DHCP client has rebound to a new DHCP server. This can be handled
as with RENEW, except that if the IP address has changed, the ARP
table should be cleared.
.SH REBOOT
The DHCP client has successfully reacquired its old address after a
reboot. This can be processed as with BOUND.
.SH EXPIRE
The DHCP client has failed to renew its lease or acquire a new one,
and the lease has expired. The IP address must be relinquished, and
all related parameters should be deleted, as in RENEW and REBIND.
.SH FAIL
The DHCP client has been unable to contact any DHCP servers, and any
leases that have been tested have not proved to be valid. The
parameters from the last lease tested should be deconfigured. This
can be handled in the same way as EXPIRE.
.SH STOP
The dhclient has been informed to shut down gracefully, the
dhclient-script should unconfigure or shutdown the interface as
appropriate.
.SH RELEASE
The dhclient has been executed using the -r flag, indicating that the
administrator wishes it to release its lease(s). dhclient-script should
unconfigure or shutdown the interface.
.SH NBI
No-Broadcast-Interfaces...dhclient was unable to find any interfaces
upon which it believed it should commence DHCP. What dhclient-script
should do in this situation is entirely up to the implementor.
.SH TIMEOUT
The DHCP client has been unable to contact any DHCP servers.
However, an old lease has been identified, and its parameters have
been passed in as with BOUND. The client configuration script should
test these parameters and, if it has reason to believe they are valid,
should exit with a value of zero. If not, it should exit with a
nonzero value.
.PP
The usual way to test a lease is to set up the network as with REBIND
(since this may be called to test more than one lease) and then ping
the first router defined in $routers. If a response is received, the
lease must be valid for the network to which the interface is
currently connected. It would be more complete to try to ping all of
the routers listed in $new_routers, as well as those listed in
$new_static_routes, but current scripts do not do this.
.SH FILES
Each operating system should generally have its own script file,
although the script files for similar operating systems may be similar
or even identical. The script files included in Internet
Systems Consortium DHCP distribution appear in the distribution tree
under client/scripts, and bear the names of the operating systems on
which they are intended to work.
.SH BUGS
If more than one interface is being used, there's no obvious way to
avoid clashes between server-supplied configuration parameters - for
example, the stock dhclient-script rewrites /etc/resolv.conf. If
more than one interface is being configured, /etc/resolv.conf will be
repeatedly initialized to the values provided by one server, and then
the other. Assuming the information provided by both servers is
valid, this shouldn't cause any real problems, but it could be
confusing.
.SH SEE ALSO
dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and
dhclient.leases(5).
.SH AUTHOR
.B dhclient-script(8)
To learn more about Internet Systems Consortium,
see
.B https://www.isc.org.

507
external/bsd/dhcp/dist/client/dhclient.8 vendored Normal file
View File

@@ -0,0 +1,507 @@
.\" $NetBSD: dhclient.8,v 1.3 2014/07/12 12:09:37 spz Exp $
.\"
.\" Id: dhclient.8,v 1.36 2011/04/15 21:58:12 sar Exp
.\"
.\" Copyright (c) 2004,2007-2014 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Internet Systems Consortium, Inc.
.\" 950 Charter Street
.\" Redwood City, CA 94063
.\" <info@isc.org>
.\" https://www.isc.org/
.\"
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
.TH dhclient 8
.SH NAME
dhclient - Dynamic Host Configuration Protocol Client
.SH SYNOPSIS
.B dhclient
[
.B -4
|
.B -6
]
[
.B -S
]
[
.B -N
[
.B -N...
]
]
[
.B -T
[
.B -T...
]
]
[
.B -P
[
.B -P...
]
]
[
.B -i
]
[
.B -I
]
[
.B -D
.I LL|LLT
]
[
.B -p
.I port-number
]
[
.B -d
]
[
.B -e
.I VAR=value
]
[
.B -m
]
[
.B -q
]
[
.B -1
]
[
.B -r
|
.B -x
]
[
.B -lf
.I lease-file
]
[
.B -pf
.I pid-file
]
[
.B --no-pid
]
[
.B -cf
.I config-file
]
[
.B -sf
.I script-file
]
[
.B -s
.I server-addr
]
[
.B -g
.I relay
]
[
.B -n
]
[
.B -nw
]
[
.B -w
]
[
.B -v
]
[
.B --version
]
[
.I if0
[
.I ...ifN
]
]
.SH DESCRIPTION
The Internet Systems Consortium DHCP Client, \fBdhclient\fR, provides a
means for configuring one or more network interfaces using the Dynamic
Host Configuration Protocol, BOOTP protocol, or if these protocols
fail, by statically assigning an address.
.SH OPERATION
.PP
The DHCP protocol allows a host to contact a central server which
maintains a list of IP addresses which may be assigned on one or more
subnets. A DHCP client may request an address from this pool, and
then use it on a temporary basis for communication on network. The
DHCP protocol also provides a mechanism whereby a client can learn
important details about the network to which it is attached, such as
the location of a default router, the location of a name server, and
so on.
.PP
There are two versions of the DHCP protocol DHCPv4 and DHCPv6. At
startup the client may be started for one or the other via the
.B -4
or
.B -6
options.
.PP
On startup, \fBdhclient\fR reads the dhclient.conf
for configuration instructions. It then gets a list of all the
network interfaces that are configured in the current system. For
each interface, it attempts to configure the interface using the DHCP
protocol.
.PP
In order to keep track of leases across system reboots and server
restarts, \fBdhclient\fR keeps a list of leases it has been assigned in the
dhclient.leases file. On startup, after reading the dhclient.conf
file, \fBdhclient\fR reads the dhclient.leases file to refresh its memory
about what leases it has been assigned.
.PP
When a new lease is acquired, it is appended to the end of the
dhclient.leases file. In order to prevent the file from becoming
arbitrarily large, from time to time \fBdhclient\fR creates a new
dhclient.leases file from its in-core lease database. The old version
of the dhclient.leases file is retained under the name
.IR dhclient.leases~
until the next time \fBdhclient\fR rewrites the database.
.PP
Old leases are kept around in case the DHCP server is unavailable when
\fBdhclient\fR is first invoked (generally during the initial system boot
process). In that event, old leases from the dhclient.leases file
which have not yet expired are tested, and if they are determined to
be valid, they are used until either they expire or the DHCP server
becomes available.
.PP
A mobile host which may sometimes need to access a network on which no
DHCP server exists may be preloaded with a lease for a fixed
address on that network. When all attempts to contact a DHCP server
have failed, \fBdhclient\fR will try to validate the static lease, and if it
succeeds, will use that lease until it is restarted.
.PP
A mobile host may also travel to some networks on which DHCP is not
available but BOOTP is. In that case, it may be advantageous to
arrange with the network administrator for an entry on the BOOTP
database, so that the host can boot quickly on that network rather
than cycling through the list of old leases.
.SH COMMAND LINE
.PP
The names of the network interfaces that \fBdhclient\fR should attempt to
configure may be specified on the command line. If no interface names
are specified on the command line \fBdhclient\fR will normally identify all
network interfaces, eliminating non-broadcast interfaces if
possible, and attempt to configure each interface.
.PP
It is also possible to specify interfaces by name in the dhclient.conf
file. If interfaces are specified in this way, then the client will
only configure interfaces that are either specified in the
configuration file or on the command line, and will ignore all other
interfaces.
.PP
The client normally prints no output during its startup sequence. It
can be made to emit verbose messages displaying the startup sequence events
until it has acquired an address by supplying the
.B -v
command line argument. In either case, the client logs messages using
the
.B syslog(3)
facility.
.SH OPTIONS
.TP
.BI \-4
Use the DHCPv4 protocol to obtain an IPv4 address and configuration
parameters. This is the default and cannot be combined with
\fB\-6\fR.
.TP
.BI \-6
Use the DHCPv6 protocol to obtain whatever IPv6 addresses are available
along with configuration parameters. It cannot be combined with
\fB\-4\fR. The \fB\-S -T -P -N\fR and
\fB\-D\fR arguments provide more control over aspects of the DHCPv6
processing. Note: it is not recommended to mix queries of different
types together or even to share the lease file between them.
.TP
.BI \-1
Try to get a lease once. On failure exit with code 2. In DHCPv6 this
sets the maximum duration of the initial exchange to
.I timeout
(from dhclient.conf with a default of sixty seconds).
.TP
.BI \-d
.\" This is not intuitive.
Force
.B dhclient
to run as a foreground process. Normally the DHCP client will run
in the foreground until is has configured an interface at which time
it will revert to running in the background. This option is useful
when running the client under a debugger, or when running it out of
inittab on System V systems. This implies \fB-v\fR.
.TP
.BI \-nw
Become a daemon immediately (nowait) rather than waiting until an
IP address has been acquired.
.TP
.BI \-m
Don't require that the responding ethernet address of the dhcp server
matches the one we expect.
.TP
.BI \-q
Be quiet at startup, this is the default.
.TP
.BI \-v
Enable verbose log messages.
.\" This prints the version, copyright and URL.
.TP
.BI \-w
Continue running even if no broadcast interfaces were found. Normally
DHCP client will exit if it isn't able to identify any network interfaces
to configure. On laptop computers and other computers with
hot-swappable I/O buses, it is possible that a broadcast interface may
be added after system startup. This flag can be used to cause the client
not to exit when it doesn't find any such interfaces. The
.B omshell(1)
program can then be used to notify the client when a network interface
has been added or removed, so that the client can attempt to configure an IP
address on that interface.
.TP
.BI \-n
Do not configure any interfaces. This is most likely to be useful in
combination with the
.B -w
flag.
.TP
.BI \-e \ VAR=value
Define additional environment variables for the environment where
.B dhclient-script
executes. You may specify multiple
.B \-e
options on the command line.
.TP
.BI \-r
Release the current lease and stop the running DHCP client as previously
recorded in the PID file. When shutdown via this method
.B dhclient-script
will be executed with the specific reason for calling the script set.
The client normally doesn't release the current lease as this is not
required by the DHCP protocol but some cable ISPs require their clients
to notify the server if they wish to release an assigned IP address.
.\" TODO what dhclient-script argument?
.\" When released,
.TP
.BI \-x
Stop the running DHCP client without releasing the current lease.
Kills existing \fBdhclient\fR process as previously recorded in the
PID file. When shutdown via this method
.B dhclient-script
will be executed with the specific reason for calling the script set.
.TP
.BI \-p \ port-number
The UDP port number on which the DHCP client should listen and transmit.
If unspecified,
.B dhclient
uses the default port of 68. This is mostly useful for debugging purposes.
If a different port is specified on which the client should listen and
transmit, the client will also use a different destination port -
one less than the specified port.
.TP
.BI \-s \ server-addr
Specify the server IP address or fully qualified domain name to use as
a destination for DHCP protocol messages before
.B dhclient
has acquired an IP address. Normally,
.B dhclient
transmits these messages to 255.255.255.255 (the IP limited broadcast
address). Overriding this is mostly useful for debugging purposes. This
feature is not supported in DHCPv6 (\fB-6\fR) mode.
.TP
.BI \-g \ relay
.\" mockup relay
Set the giaddr field of all packets to the \fIrelay\fR IP address
simulating a relay agent. This is for testing purposes only and
should not be expected to work in any consistent or useful way.
.TP
.BI \-i
Use a DUID with DHCPv4 clients. If no DUID is available in the
lease file one will be constructed and saved. The DUID will be
used to construct a RFC4361 style client id that will be included
in the client's messages. This client id can be overridden by
setting a client id in the configuration file. Overridding the
client id in this fashion is discouraged.
.TP
.BI \-I
Use the standard DDNS scheme from RFCs 4701 & 4702.
.TP
.BI \--version
Print version number and exit.
.PP
.I Options available for DHCPv6 mode:
.TP
.BI \-S
.\" TODO: mention DUID?
Use Information-request to get only stateless configuration parameters
(i.e., without address). This implies \fB\-6\fR. It also doesn't
rewrite the lease database.
.\" TODO: May not be used with -N -P or -T. ??
.TP
.BI \-T
.\" TODO wanted_ia_ta++
Ask for IPv6 temporary addresses, one set per \fB\-T\fR flag. This
implies \fB\-6\fR and also disables the normal address query.
See \fB\-N\fR to restore it.
.TP
.BI \-P
Enable IPv6 prefix delegation. This implies \fB\-6\fR and also
disables the normal address query. See \fB\-N\fR to restore it.
Note only one requested interface is allowed.
.TP
.BI \-D \ LL\ or\ LLT
Override the default when selecting the type of DUID to use. By default,
DHCPv6 \fBdhclient\fR creates an identifier based on the link-layer address
(DUID-LL) if it is running in stateless mode (with \fB\-S\fR, not
requesting an address), or it creates an identifier based on the
link-layer address plus a timestamp (DUID-LLT) if it is running in
stateful mode (without \fB\-S\fR, requesting an address). When DHCPv4
is configured to use a DUID using \fB\-i\fR option the default is to use
a DUID-LLT. \fB\-D\fR
overrides these default, with a value of either \fILL\fR or \fILLT\fR.
.TP
.BI \-N
.\" TODO: is this for telling an already running dhclient?
Restore normal address query for IPv6. This implies \fB-6\fR.
It is used to restore normal operation after using \fB-T\fR or \fB-P\fR.
.PP
.I Modifying default file locations:
The following options can be used to modify the locations a client uses
for its files. They can be particularly useful if, for example,
.B DBDIR
or
.B RUNDIR
have not been mounted when the DHCP client is started.
.TP
.BI \-cf \ config-file
Path to the client configuration file. If unspecified, the default
.B ETCDIR/dhclient.conf
is used. See \fBdhclient.conf(5)\fR for a description of this file.
.TP
.BI \-lf \ lease-file
Path to the lease database file. If unspecified, the default
.B DBDIR/dhclient.leases
is used. See \fBdhclient.leases(5)\fR for a description of this file.
.TP
.BI \-pf \ pid-file
Path to the process ID file. If unspecified, the default
.B RUNDIR/dhclient.pid
is used.
.TP
.BI \--no-pid
Option to disable writing pid files. By default the program
will write a pid file. If the program is invoked with this
option it will not attempt to kill any existing client processes
even if invoked with \fB-r\fR or \fB-x\fR.
.TP
.BI \-sf \ script-file
Path to the network configuration script invoked by
.B dhclient
when it gets a lease. If unspecified, the default
.B CLIENTBINDIR/dhclient-script
is used. See \fBdhclient-script(8)\fR for a description of this file.
.PP
.SH CONFIGURATION
The syntax of the \fBdhclient.conf(5)\fR file is discussed separately.
.SH OMAPI
The DHCP client provides some ability to control it while it is
running, without stopping it. This capability is provided using OMAPI,
an API for manipulating remote objects. OMAPI clients connect to the
client using TCP/IP, authenticate, and can then examine the client's
current status and make changes to it.
.PP
Rather than implementing the underlying OMAPI protocol directly, user
programs should use the dhcpctl API or OMAPI itself. Dhcpctl is a
wrapper that handles some of the housekeeping chores that OMAPI does
not do automatically. Dhcpctl and OMAPI are documented in
\fBdhcpctl(3)\fR
and \fBomapi(3)\fR. Most things you'd want to do with the client can
be done directly using the \fBomshell(1)\fR command, rather than
having to write a special program.
.SH THE CONTROL OBJECT
The control object allows you to shut the client down, releasing all
leases that it holds and deleting any DNS records it may have added.
It also allows you to pause the client - this unconfigures any
interfaces the client is using. You can then restart it, which
causes it to reconfigure those interfaces. You would normally pause
the client prior to going into hibernation or sleep on a laptop
computer. You would then resume it after the power comes back.
This allows PC cards to be shut down while the computer is hibernating
or sleeping, and then reinitialized to their previous state once the
computer comes out of hibernation or sleep.
.PP
The control object has one attribute - the state attribute. To shut
the client down, set its state attribute to 2. It will automatically
do a DHCPRELEASE. To pause it, set its state attribute to 3. To
resume it, set its state attribute to 4.
.PP
.SH ENVIRONMENT VARIABLES
.PP
The following environment variables may be defined
to override the builtin defaults for file locations.
Note that use of the related command-line options
will ignore the corresponding environment variable settings.
.TP
.B PATH_DHCLIENT_CONF
The dhclient.conf configuration file.
.TP
.B PATH_DHCLIENT_DB
The dhclient.leases database.
.TP
.B PATH_DHCLIENT_PID
The dhclient PID file.
.TP
.B PATH_DHCLIENT_SCRIPT
The dhclient-script file.
.PP
.SH FILES
.B CLIENTBINDIR/dhclient-script,
.B ETCDIR/dhclient.conf, DBDIR/dhclient.leases, RUNDIR/dhclient.pid,
.B DBDIR/dhclient.leases~.
.SH SEE ALSO
dhcpd(8), dhcrelay(8), dhclient-script(8), dhclient.conf(5),
dhclient.leases(5), dhcp-eval(5).
.SH AUTHOR
.B dhclient(8)
To learn more about Internet Systems Consortium,
see
.B https://www.isc.org
.PP
This client was substantially modified and enhanced by Elliot Poger
for use on Linux while he was working on the MosquitoNet project at
Stanford.
.PP
The current version owes much to Elliot's Linux enhancements, but
was substantially reorganized and partially rewritten by Ted Lemon
so as to use the same networking framework that the Internet Systems
Consortium DHCP server uses. Much system-specific configuration code
was moved into a shell script so that as support for more operating
systems is added, it will not be necessary to port and maintain
system-specific configuration code to these operating systems - instead,
the shell script can invoke the native tools to accomplish the same
purpose.
.PP

4578
external/bsd/dhcp/dist/client/dhclient.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,736 @@
.\" $NetBSD: dhclient.conf.5,v 1.1.1.3 2014/07/12 11:57:36 spz Exp $
.\"
.\" Id: dhclient.conf.5,v 1.34 2012/01/24 22:23:39 sar Exp
.\"
.\" Copyright (c) 2009-2012,2014 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Internet Systems Consortium, Inc.
.\" 950 Charter Street
.\" Redwood City, CA 94063
.\" <info@isc.org>
.\" https://www.isc.org/
.\"
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
.TH dhclient.conf 5
.SH NAME
dhclient.conf - DHCP client configuration file
.SH DESCRIPTION
The dhclient.conf file contains configuration information for
.IR dhclient,
the Internet Systems Consortium DHCP Client.
.PP
The dhclient.conf file is a free-form ASCII text file. It is parsed by
the recursive-descent parser built into dhclient. The file may contain
extra tabs and newlines for formatting purposes. Keywords in the file
are case-insensitive. Comments may be placed anywhere within the
file (except within quotes). Comments begin with the # character and
end at the end of the line.
.PP
The dhclient.conf file can be used to configure the behaviour of the
client in a wide variety of ways: protocol timing, information
requested from the server, information required of the server,
defaults to use if the server does not provide certain information,
values with which to override information provided by the server, or
values to prepend or append to information provided by the server.
The configuration file can also be preinitialized with addresses to
use on networks that don't have DHCP servers.
.SH PROTOCOL TIMING
The timing behaviour of the client need not be configured by the user.
If no timing configuration is provided by the user, a fairly
reasonable timing behaviour will be used by default - one which
results in fairly timely updates without placing an inordinate load on
the server.
.PP
The following statements can be used to adjust the timing behaviour of
the DHCP client if required, however:
.PP
.I The
.B timeout
.I statement
.PP
.B timeout
.I time
.B ;
.PP
The
.I timeout
statement determines the amount of time that must pass between the
time that the client begins to try to determine its address and the
time that it decides that it's not going to be able to contact a
server. By default, this timeout is sixty seconds. After the
timeout has passed, if there are any static leases defined in the
configuration file, or any leases remaining in the lease database that
have not yet expired, the client will loop through these leases
attempting to validate them, and if it finds one that appears to be
valid, it will use that lease's address. If there are no valid
static leases or unexpired leases in the lease database, the client
will restart the protocol after the defined retry interval.
.PP
.I The
.B retry
.I statement
.PP
\fBretry \fItime\fR\fB;\fR
.PP
The
.I retry
statement determines the time that must pass after the client has
determined that there is no DHCP server present before it tries again
to contact a DHCP server. By default, this is five minutes.
.PP
.I The
.B select-timeout
.I statement
.PP
\fBselect-timeout \fItime\fR\fB;\fR
.PP
It is possible (some might say desirable) for there to be more than
one DHCP server serving any given network. In this case, it is
possible that a client may be sent more than one offer in response to
its initial lease discovery message. It may be that one of these
offers is preferable to the other (e.g., one offer may have the
address the client previously used, and the other may not).
.PP
The
.I select-timeout
is the time after the client sends its first lease discovery request
at which it stops waiting for offers from servers, assuming that it
has received at least one such offer. If no offers have been
received by the time the
.I select-timeout
has expired, the client will accept the first offer that arrives.
.PP
By default, the select-timeout is zero seconds - that is, the client
will take the first offer it sees.
.PP
.I The
.B reboot
.I statement
.PP
\fBreboot \fItime\fR\fB;\fR
.PP
When the client is restarted, it first tries to reacquire the last
address it had. This is called the INIT-REBOOT state. If it is
still attached to the same network it was attached to when it last
ran, this is the quickest way to get started. The
.I reboot
statement sets the time that must elapse after the client first tries
to reacquire its old address before it gives up and tries to discover
a new address. By default, the reboot timeout is ten seconds.
.PP
.I The
.B backoff-cutoff
.I statement
.PP
\fBbackoff-cutoff \fItime\fR\fB;\fR
.PP
The client uses an exponential backoff algorithm with some randomness,
so that if many clients try to configure themselves at the same time,
they will not make their requests in lockstep. The
.I backoff-cutoff
statement determines the maximum amount of time that the client is
allowed to back off, the actual value will be evaluated randomly between
1/2 to 1 1/2 times the \fItime\fR specified. It defaults to fifteen
seconds.
.PP
.I The
.B initial-interval
.I statement
.PP
\fBinitial-interval \fItime\fR\fB;\fR
.PP
The
.I initial-interval
statement sets the amount of time between the first attempt to reach a
server and the second attempt to reach a server. Each time a message
is sent, the interval between messages is incremented by twice the
current interval multiplied by a random number between zero and one.
If it is greater than the backoff-cutoff amount, it is set to that
amount. It defaults to ten seconds.
.PP
.I The initial-delay
.I statement
.PP
\fBinitial-delay \fItime\fR\fB;\fR
.PP
.I initial-delay
parameter sets the maximum time client can wait after start before
commencing first transmission.
According to RFC2131 Section 4.4.1, client should wait a random time between
startup and the actual first transmission. Previous versions of ISC DHCP
client used to wait random time up to 5 seconds, but that was unwanted
due to impact on startup time. As such, new versions have the default
initial delay set to 0. To restore old behavior, please set initial-delay
to 5.
.SH LEASE REQUIREMENTS AND REQUESTS
The DHCP protocol allows the client to request that the server send it
specific information, and not send it other information that it is not
prepared to accept. The protocol also allows the client to reject
offers from servers if they don't contain information the client
needs, or if the information provided is not satisfactory.
.PP
There is a variety of data contained in offers that DHCP servers send
to DHCP clients. The data that can be specifically requested is what
are called \fIDHCP Options\fR. DHCP Options are defined in
\fBdhcp-options(5)\fR.
.PP
.I The
.B request
.I statement
.PP
\fB[ also ] request [ [ \fIoption-space\fR . ] \fIoption\fR ] [\fB,\fI ... ]\fB;\fR
.PP
The request statement causes the client to request that any server
responding to the client send the client its values for the specified
options. Only the option names should be specified in the request
statement - not option parameters. By default, the DHCPv4 client
requests the subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers and host-name options while the DHCPv6
client requests the dhcp6 name-servers and domain-search options. Note
that if you enter a \'request\' statement, you over-ride these defaults
and these options will not be requested.
.PP
In some cases, it may be desirable to send no parameter request list
at all. To do this, simply write the request statement but specify
no parameters:
.PP
.nf
request;
.fi
.PP
In most cases, it is desirable to simply add one option to the request
list which is of interest to the client in question. In this case, it
is best to \'also request\' the additional options:
.PP
.nf
also request domain-search, dhcp6.sip-servers-addresses;
.fi
.PP
.I The
.B require
.I statement
.PP
\fB[ also ] require [ [ \fIoption-space\fR . ] \fIoption\fR ] [\fB,\fI ... ]\fB;\fR
.PP
The require statement lists options that must be sent in order for an
offer to be accepted. Offers that do not contain all the listed
options will be ignored. There is no default require list.
.PP
.nf
require name-servers;
interface eth0 {
also require domain-search;
}
.PP
.I The
.B send
.I statement
.PP
\fBsend { [ \fIoption declaration\fR ]
[\fB,\fI ... \fIoption declaration\fR ]\fB}\fR
.PP
The send statement causes the client to send the specified options to
the server with the specified values. These are full option
declarations as described in \fBdhcp-options(5)\fR. Options that are
always sent in the DHCP protocol should not be specified here, except
that the client can specify a requested \fBdhcp-lease-time\fR option other
than the default requested lease time, which is two hours. The other
obvious use for this statement is to send information to the server
that will allow it to differentiate between this client and other
clients or kinds of clients.
.SH DYNAMIC DNS
The client now has some very limited support for doing DNS updates
when a lease is acquired. This is prototypical, and probably doesn't
do what you want. It also only works if you happen to have control
over your DNS server, which isn't very likely.
.PP
Note that everything in this section is true whether you are using DHCPv4
or DHCPv6. The exact same syntax is used for both.
.PP
To make it work, you have to declare a key and zone as in the DHCP
server (see \fBdhcpd.conf\fR(5) for details). You also need to
configure the \fIfqdn\fR option on the client, as follows:
.PP
.nf
send fqdn.fqdn "grosse.fugue.com.";
send fqdn.encoded on;
send fqdn.server-update off;
also request fqdn, dhcp6.fqdn;
.fi
.PP
The \fIfqdn.fqdn\fR option \fBMUST\fR be a fully-qualified domain
name. You \fBMUST\fR define a zone statement for the zone to be
updated. The \fIfqdn.encoded\fR option may need to be set to
\fIon\fR or \fIoff\fR, depending on the DHCP server you are using.
.PP
.I The
.B do-forward-updates
.I statement
.PP
\fBdo-forward-updates [ \fIflag\fR ] \fB;\fR
.PP
If you want to do DNS updates in the DHCP client
script (see \fBdhclient-script(8)\fR) rather than having the
DHCP client do the update directly (for example, if you want to
use SIG(0) authentication, which is not supported directly by the
DHCP client, you can instruct the client not to do the update using
the \fBdo-forward-updates\fR statement. \fIFlag\fR should be \fBtrue\fR
if you want the DHCP client to do the update, and \fBfalse\fR if
you don't want the DHCP client to do the update. By default, the DHCP
client will do the DNS update.
.SH OPTION MODIFIERS
In some cases, a client may receive option data from the server which
is not really appropriate for that client, or may not receive
information that it needs, and for which a useful default value
exists. It may also receive information which is useful, but which
needs to be supplemented with local information. To handle these
needs, several option modifiers are available.
.PP
.I The
.B default
.I statement
.PP
\fBdefault [ \fIoption declaration\fR ] \fB;\fR
.PP
If for some option the client should use the value supplied by
the server, but needs to use some default value if no value was supplied
by the server, these values can be defined in the
.B default
statement.
.PP
.I The
.B supersede
.I statement
.PP
\fBsupersede [ \fIoption declaration\fR ] \fB;\fR
.PP
If for some option the client should always use a locally-configured
value or values rather than whatever is supplied by the server, these
values can be defined in the
.B supersede
statement.
.PP
.I The
.B prepend
.I statement
.PP
\fBprepend [ \fIoption declaration\fR ] \fB;\fR
.PP
If for some set of options the client should use a value you
supply, and then use the values supplied by
the server, if any, these values can be defined in the
.B prepend
statement. The
.B prepend
statement can only be used for options which
allow more than one value to be given. This restriction is not
enforced - if you ignore it, the behaviour will be unpredictable.
.PP
.I The
.B append
.I statement
.PP
\fBappend [ \fIoption declaration\fR ] \fB;\fR
.PP
If for some set of options the client should first use the values
supplied by the server, if any, and then use values you supply, these
values can be defined in the
.B append
statement. The
.B append
statement can only be used for options which
allow more than one value to be given. This restriction is not
enforced - if you ignore it, the behaviour will be unpredictable.
.SH LEASE DECLARATIONS
.PP
.I The
.B lease
.I declaration
.PP
\fBlease {\fR \fIlease-declaration\fR [ ... \fIlease-declaration ] \fB}\fR
.PP
The DHCP client may decide after some period of time (see \fBPROTOCOL
TIMING\fR) that it is not going to succeed in contacting a
server. At that time, it consults its own database of old leases and
tests each one that has not yet timed out by pinging the listed router
for that lease to see if that lease could work. It is possible to
define one or more \fIfixed\fR leases in the client configuration file
for networks where there is no DHCP or BOOTP service, so that the
client can still automatically configure its address. This is done
with the
.B lease
statement.
.PP
NOTE: the lease statement is also used in the dhclient.leases file in
order to record leases that have been received from DHCP servers.
Some of the syntax for leases as described below is only needed in the
dhclient.leases file. Such syntax is documented here for
completeness.
.PP
A lease statement consists of the lease keyword, followed by a left
curly brace, followed by one or more lease declaration statements,
followed by a right curly brace. The following lease declarations
are possible:
.PP
\fBbootp;\fR
.PP
The
.B bootp
statement is used to indicate that the lease was acquired using the
BOOTP protocol rather than the DHCP protocol. It is never necessary
to specify this in the client configuration file. The client uses
this syntax in its lease database file.
.PP
\fBinterface\fR \fB"\fR\fIstring\fR\fB";\fR
.PP
The
.B interface
lease statement is used to indicate the interface on which the lease
is valid. If set, this lease will only be tried on a particular
interface. When the client receives a lease from a server, it always
records the interface number on which it received that lease.
If predefined leases are specified in the dhclient.conf file, the
interface should also be specified, although this is not required.
.PP
\fBfixed-address\fR \fIip-address\fR\fB;\fR
.PP
The
.B fixed-address
statement is used to set the ip address of a particular lease. This
is required for all lease statements. The IP address must be
specified as a dotted quad (e.g., 12.34.56.78).
.PP
\fBfilename "\fR\fIstring\fR\fB";\fR
.PP
The
.B filename
statement specifies the name of the boot filename to use. This is
not used by the standard client configuration script, but is included
for completeness.
.PP
\fBserver-name "\fR\fIstring\fR\fB";\fR
.PP
The
.B server-name
statement specifies the name of the boot server name to use. This is
also not used by the standard client configuration script.
.PP
\fBoption\fR \fIoption-declaration\fR\fB;\fR
.PP
The
.B option
statement is used to specify the value of an option supplied by the
server, or, in the case of predefined leases declared in
dhclient.conf, the value that the user wishes the client configuration
script to use if the predefined lease is used.
.PP
\fBscript "\fIscript-name\fB";\fR
.PP
The
.B script
statement is used to specify the pathname of the dhcp client
configuration script. This script is used by the dhcp client to set
each interface's initial configuration prior to requesting an address,
to test the address once it has been offered, and to set the
interface's final configuration once a lease has been acquired. If
no lease is acquired, the script is used to test predefined leases, if
any, and also called once if no valid lease can be identified. For
more information, see
.B dhclient-script(8).
.PP
\fBvendor option space "\fIname\fB";\fR
.PP
The
.B vendor option space
statement is used to specify which option space should be used for
decoding the vendor-encapsulate-options option if one is received.
The \fIdhcp-vendor-identifier\fR can be used to request a specific
class of vendor options from the server. See
.B dhcp-options(5)
for details.
.PP
\fBmedium "\fImedia setup\fB";\fR
.PP
The
.B medium
statement can be used on systems where network interfaces cannot
automatically determine the type of network to which they are
connected. The media setup string is a system-dependent parameter
which is passed to the dhcp client configuration script when
initializing the interface. On Unix and Unix-like systems, the
argument is passed on the ifconfig command line when configuring the
interface.
.PP
The dhcp client automatically declares this parameter if it uses a
media type (see the
.B media
statement) when configuring the interface in order to obtain a lease.
This statement should be used in predefined leases only if the network
interface requires media type configuration.
.PP
\fBrenew\fR \fIdate\fB;\fR
.PP
\fBrebind\fR \fIdate\fB;\fR
.PP
\fBexpire\fR \fIdate\fB;\fR
.PP
The \fBrenew\fR statement defines the time at which the dhcp client
should begin trying to contact its server to renew a lease that it is
using. The \fBrebind\fR statement defines the time at which the dhcp
client should begin to try to contact \fIany\fR dhcp server in order
to renew its lease. The \fBexpire\fR statement defines the time at
which the dhcp client must stop using a lease if it has not been able
to contact a server in order to renew it.
.PP
These declarations are automatically set in leases acquired by the
DHCP client, but must also be configured in predefined leases - a
predefined lease whose expiry time has passed will not be used by the
DHCP client.
.PP
Dates are specified in one of two ways. The software will output times in
these two formats depending on if the \fBdb-time-format\fR configuration
parameter has been set to \fIdefault\fR or \fIlocal\fR.
.PP
If it is set to \fIdefault\fR, then \fIdate\fR values appear as follows:
.PP
\fI<weekday> <year>\fB/\fI<month>\fB/\fI<day>
<hour>\fB:\fI<minute>\fB:\fI<second>\fR
.PP
The weekday is present to make it easy for a human to tell when a
lease expires - it's specified as a number from zero to six, with zero
being Sunday. When declaring a predefined lease, it can always be
specified as zero. The year is specified with the century, so it
should generally be four digits except for really long leases. The
month is specified as a number starting with 1 for January. The day
of the month is likewise specified starting with 1. The hour is a
number between 0 and 23, the minute a number between 0 and 59, and the
second also a number between 0 and 59.
.PP
If the \fBdb-time-format\fR configuration was set to \fIlocal\fR, then
the \fIdate\fR values appear as follows:
.PP
\fBepoch\fR \fI<seconds-since-epoch>\fR\fB; #\fR \fI<day-name> <month-name>
<day-number> <hours>\fR\fB:\fR\fI<minutes>\fR\fB:\fR\fI<seconds> <year>\fR
.PP
The \fIseconds-since-epoch\fR is as according to the system's local clock (often
referred to as "unix time"). The \fB#\fR symbol supplies a comment that
describes what actual time this is as according to the system's configured
timezone, at the time the value was written. It is provided only for human
inspection, the epoch time is the only recommended value for machine
inspection.
.PP
Note that when defining a static lease, one may use either time format one
wishes, and need not include the comment or values after it.
.PP
If the time is infinite in duration, then the \fIdate\fR is \fBnever\fR
instead of an actual date.
.SH ALIAS DECLARATIONS
\fBalias { \fI declarations ... \fB}\fR
.PP
Some DHCP clients running TCP/IP roaming protocols may require that in
addition to the lease they may acquire via DHCP, their interface also
be configured with a predefined IP alias so that they can have a
permanent IP address even while roaming. The Internet Systems
Consortium DHCP client doesn't support roaming with fixed addresses
directly, but in order to facilitate such experimentation, the dhcp
client can be set up to configure an IP alias using the
.B alias
declaration.
.PP
The alias declaration resembles a lease declaration, except that
options other than the subnet-mask option are ignored by the standard
client configuration script, and expiry times are ignored. A typical
alias declaration includes an interface declaration, a fixed-address
declaration for the IP alias address, and a subnet-mask option
declaration. A medium statement should never be included in an alias
declaration.
.SH OTHER DECLARATIONS
\fBdb-time-format\fR [ \fIdefault\fR | \fIlocal\fR ] \fB;\fR
.PP
The \fBdb-time-format\fR option determines which of two output methods are
used for printing times in leases files. The \fIdefault\fR format provides
day-and-time in UTC, whereas \fIlocal\fR uses a seconds-since-epoch to store
the time value, and helpfully places a local timezone time in a comment on
the same line. The formats are described in detail in this manpage, within
the LEASE DECLARATIONS section.
.PP
\fBreject \fIcidr-ip-address\fR [\fB,\fR \fI...\fB \fIcidr-ip-address\fR ] \fB;\fR
.PP
The
.B reject
statement causes the DHCP client to reject offers from
servers whose server identifier matches any of the specified hosts or
subnets. This can be used to avoid being configured by rogue or
misconfigured dhcp servers, although it should be a last resort -
better to track down the bad DHCP server and fix it.
.PP
The \fIcidr-ip-address\fR configuration type is of the
form \fIip-address\fR[\fB/\fIprefixlen\fR], where \fIip-address\fR is a
dotted quad IP address, and \fRprefixlen\fR is the CIDR prefix length of
the subnet, counting the number of significant bits in the netmask starting
from the leftmost end. Example configuration syntax:
.PP
.I \fIreject\fR 192.168.0.0\fB/\fR16\fB,\fR 10.0.0.5\fB;\fR
.PP
The above example would cause offers from any server identifier in the
entire RFC 1918 "Class C" network 192.168.0.0/16, or the specific
single address 10.0.0.5, to be rejected.
.PP
\fBinterface "\fIname\fB" { \fIdeclarations ... \fB }
.PP
A client with more than one network interface may require different
behaviour depending on which interface is being configured. All
timing parameters and declarations other than lease and alias
declarations can be enclosed in an interface declaration, and those
parameters will then be used only for the interface that matches the
specified name. Interfaces for which there is no interface
declaration will use the parameters declared outside of any interface
declaration, or the default settings.
.PP
.B Note well:
ISC dhclient only maintains one list of interfaces, which is either
determined at startup from command line arguments, or otherwise is
autodetected. If you supplied the list of interfaces on the command
line, this configuration clause will add the named interface to the
list in such a way that will cause it to be configured by DHCP. Which
may not be the result you had intended. This is an undesirable side
effect that will be addressed in a future release.
.PP
\fBpseudo "\fIname\fR" "\fIreal-name\fB" { \fIdeclarations ... \fB }
.PP
Under some circumstances it can be useful to declare a pseudo-interface
and have the DHCP client acquire a configuration for that interface.
Each interface that the DHCP client is supporting normally has a DHCP
client state machine running on it to acquire and maintain its lease.
A pseudo-interface is just another state machine running on the
interface named \fIreal-name\fR, with its own lease and its own
state. If you use this feature, you must provide a client identifier
for both the pseudo-interface and the actual interface, and the two
identifiers must be different. You must also provide a separate
client script for the pseudo-interface to do what you want with the IP
address. For example:
.PP
.nf
interface "ep0" {
send dhcp-client-identifier "my-client-ep0";
}
pseudo "secondary" "ep0" {
send dhcp-client-identifier "my-client-ep0-secondary";
script "/etc/dhclient-secondary";
}
.fi
.PP
The client script for the pseudo-interface should not configure the
interface up or down - essentially, all it needs to handle are the
states where a lease has been acquired or renewed, and the states
where a lease has expired. See \fBdhclient-script(8)\fR for more
information.
.PP
\fBmedia "\fImedia setup\fB"\fI [ \fB, "\fImedia setup\fB", \fI... ]\fB;\fR
.PP
The
.B media
statement defines one or more media configuration parameters which may
be tried while attempting to acquire an IP address. The dhcp client
will cycle through each media setup string on the list, configuring
the interface using that setup and attempting to boot, and then trying
the next one. This can be used for network interfaces which aren't
capable of sensing the media type unaided - whichever media type
succeeds in getting a request to the server and hearing the reply is
probably right (no guarantees).
.PP
The media setup is only used for the initial phase of address
acquisition (the DHCPDISCOVER and DHCPOFFER packets). Once an
address has been acquired, the dhcp client will record it in its lease
database and will record the media type used to acquire the address.
Whenever the client tries to renew the lease, it will use that same
media type. The lease must expire before the client will go back to
cycling through media types.
.PP
\fBhardware\fR \fIlink-type mac-address\fR\fB;\fR
.PP
The
.B hardware
statement defines the hardware MAC address to use for this interface,
for DHCP servers or relays to direct their replies. dhclient will determine
the interface's MAC address automatically, so use of this parameter
is not recommended. The \fIlink-type\fR corresponds to the interface's
link layer type (example: \'ethernet\'), while the \fImac-address\fR is
a string of colon-separated hexadecimal values for octets.
.PP
\fBanycast-mac\fR \fIlink-type mac-address\fR\fB;\fR
.PP
The
.B anycast-mac
statement over-rides the all-ones broadcast MAC address dhclient will use
when it is transmitting packets to the all-ones limited broadcast IPv4
address. This configuration parameter is useful to reduce the number of
broadcast packets transmitted by DHCP clients, but is only useful if you
know the DHCP service(s) anycast MAC address prior to configuring your
client. The \fIlink-type\fR and \fImac-address\fR parameters are configured
in a similar manner to the \fBhardware\fR statement.
.PP
.SH SAMPLE
The following configuration file is used on a laptop running NetBSD
1.3. The laptop has an IP alias of 192.5.5.213, and has one
interface, ep0 (a 3com 3C589C). Booting intervals have been
shortened somewhat from the default, because the client is known to
spend most of its time on networks with little DHCP activity. The
laptop does roam to multiple networks.
.nf
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
reject 192.33.137.209;
interface "ep0" {
send host-name "andare.fugue.com";
hardware ethernet 00:a0:24:ab:fb:9c;
send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
send dhcp-lease-time 3600;
supersede domain-search "fugue.com", "rc.vix.com", "home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
script "CLIENTBINDIR/dhclient-script";
media "media 10baseT/UTP", "media 10base2/BNC";
}
alias {
interface "ep0";
fixed-address 192.5.5.213;
option subnet-mask 255.255.255.255;
}
.fi
This is a very complicated dhclient.conf file - in general, yours
should be much simpler. In many cases, it's sufficient to just
create an empty dhclient.conf file - the defaults are usually fine.
.SH SEE ALSO
dhcp-options(5), dhcp-eval(5), dhclient.leases(5), dhcpd(8), dhcpd.conf(5),
RFC2132, RFC2131.
.SH AUTHOR
.B dhclient(8)
Information about Internet Systems Consortium can be found at
.B https://www.isc.org.

View File

@@ -0,0 +1,36 @@
send host-name = pick-first-value(gethostname(), "ISC-dhclient");
send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
send dhcp-lease-time 3600;
supersede domain-search "fugue.com", "home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
script "/etc/dhclient-script";
media "-link0 -link1 -link2", "link0 link1";
reject 192.33.137.209;
alias {
interface "ep0";
fixed-address 192.5.5.213;
option subnet-mask 255.255.255.255;
}
lease {
interface "ep0";
fixed-address 192.33.137.200;
medium "link0 link1";
option host-name "andare.swiftmedia.com";
option subnet-mask 255.255.255.0;
option broadcast-address 192.33.137.255;
option routers 192.33.137.250;
option domain-name-servers 127.0.0.1;
renew 2 2000/1/12 00:00:01;
rebind 2 2000/1/12 00:00:01;
expire 2 2000/1/12 00:00:01;
}

View File

@@ -0,0 +1,53 @@
.\" $NetBSD: dhclient.leases.5,v 1.1.1.3 2014/07/12 11:57:38 spz Exp $
.\"
.\" Id: dhclient.leases.5,v 1.8 2011/02/23 23:50:55 sar Exp
.\"
.\" Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1997-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Internet Systems Consortium, Inc.
.\" 950 Charter Street
.\" Redwood City, CA 94063
.\" <info@isc.org>
.\" https://www.isc.org/
.\"
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
.\" Id: dhclient.leases.5,v 1.8 2011/02/23 23:50:55 sar Exp
.\"
.TH dhclient.leases 5
.SH NAME
dhclient.leases - DHCP client lease database
.SH DESCRIPTION
The Internet Systems Consortium DHCP client keeps a persistent
database of leases that it has acquired that are still valid. The
database is a free-form ASCII file containing one valid declaration
per lease. If more than one declaration appears for a given lease,
the last one in the file is used. The file is written as a log, so
this is not an unusual occurrence.
.PP
The format of the lease declarations is described in
.B dhclient.conf(5).
.SH FILES
.B DBDIR/dhclient.leases
.SH SEE ALSO
dhclient(8), dhcp-options(5), dhclient.conf(5), dhcpd(8),
dhcpd.conf(5), RFC2132, RFC2131.
.SH AUTHOR
.B dhclient(8)
Information about Internet Systems Consortium can be found at
.B https://www.isc.org.

324
external/bsd/dhcp/dist/client/scripts/bsdos vendored Executable file
View File

@@ -0,0 +1,324 @@
#!/bin/sh
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
if [ "x$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >> /etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
done
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$new_network_number != x ]; then
echo New Network Number: $new_network_number
fi
if [ x$new_broadcast_address != x ]; then
echo New Broadcast Address: $new_broadcast_address
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv4 Handlers
###
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0;
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
if [ "$new_static_routes" != "" ]; then
set $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
fi
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ]; then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
sleep 1
if [ "$new_routers" != "" ]; then
set $new_routers
if ping -q -c 1 -w 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
set $new_static_routes
while [ $# -gt 1 ]; do
route add $0 $1
shift; shift
done
make_resolv_conf
exit_with_hooks 0
fi
fi
eval "ifconfig $interface inet -alias $new_ip_address $medium"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen}
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
# XXX:
# There doesn't appear to be a way to update an addr to indicate
# preference.
exit_with_hooks 0
fi
if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen}
exit_with_hooks 0
fi
exit_with_hooks 0

View File

@@ -0,0 +1,392 @@
#!/bin/sh
#
# Id: freebsd,v 1.24 2011/05/18 19:55:44 sar Exp
#
# $FreeBSD$
if [ -x /usr/bin/logger ]; then
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
else
LOGGER=echo
fi
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
( cat /dev/null > /etc/resolv.conf.dhclient )
exit_status=$?
if [ $exit_status -ne 0 ]; then
$LOGGER "Unable to create /etc/resolv.conf.dhclient: Error $exit_status"
else
if [ "x$new_domain_search" != x ]; then
( echo search $new_domain_search >> /etc/resolv.conf.dhclient )
exit_status=$?
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
( echo search $new_domain_name >> /etc/resolv.conf.dhclient )
exit_status=$?
fi
for nameserver in $new_domain_name_servers; do
if [ $exit_status -ne 0 ]; then
break
fi
( echo nameserver $nameserver >>/etc/resolv.conf.dhclient )
exit_status=$?
done
# If there were no errors, attempt to mv the new file into place.
if [ $exit_status -eq 0 ]; then
( mv /etc/resolv.conf.dhclient /etc/resolv.conf )
exit_status=$?
fi
if [ $exit_status -ne 0 ]; then
$LOGGER "Error while writing new /etc/resolv.conf."
fi
fi
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
( cat /dev/null > /etc/resolv.conf.dhclient6 )
exit_status=$?
if [ $exit_status -ne 0 ] ; then
$LOGGER "Unable to create /etc/resolv.conf.dhclient6: Error $exit_status"
else
if [ "x${new_dhcp6_domain_search}" != x ] ; then
( echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 )
exit_status=$?
fi
for nameserver in ${new_dhcp6_name_servers} ; do
if [ $exit_status -ne 0 ] ; then
break
fi
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
( echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6 )
exit_status=$?
done
if [ $exit_status -eq 0 ] ; then
( mv /etc/resolv.conf.dhclient6 /etc/resolv.conf )
exit_status=$?
fi
if [ $exit_status -ne 0 ] ; then
$LOGGER "Error while writing new /etc/resolv.conf."
fi
fi
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$new_network_number != x ]; then
$LOGGER New Network Number: $new_network_number
fi
if [ x$new_broadcast_address != x ]; then
$LOGGER New Broadcast Address: $new_broadcast_address
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv4 Handlers
###
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0;
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`/bin/hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
$LOGGER "New Hostname: $new_host_name"
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
then
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
done
if [ -n "$old_static_routes" ]; then
set -- $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
$LOGGER "New IP Address ($interface): $new_ip_address"
$LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
$LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
if [ -n "$new_routers" ]; then
$LOGGER "New Routers: $new_routers"
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
# If the subnet is captive, eg the netmask is /32 but the default
# gateway is (obviously) outside of this, then we need to produce a
# host route to reach the gateway.
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router -interface $interface
fi
route add default $router >/dev/null 2>&1
done
if [ -n "$new_static_routes" ]; then
$LOGGER "New Static Routes: $new_static_routes"
set -- $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
fi
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
for router in $new_routers; do
# If the subnet is captive, eg the netmask is /32 but the default
# gateway is (obviously) outside of this, then we need to produce a
# host route to reach the gateway.
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router -interface $interface
fi
route add default $router >/dev/null 2>&1
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ]; then
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
done
if [ -n "$old_static_routes" ]; then
set -- $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
|sh >/dev/null 2>&1
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
$LOGGER "New IP Address ($interface): $new_ip_address"
$LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
$LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
sleep 1
if [ -n "$new_routers" ]; then
$LOGGER "New Routers: $new_routers"
set -- $new_routers
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router -interface $interface
fi
route add default $router >/dev/null 2>&1
done
set -- $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
make_resolv_conf
exit_with_hooks 0
fi
fi
eval "ifconfig $interface inet -alias $new_ip_address $medium"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
if [ -n "$old_static_routes" ]; then
set -- $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
|sh >/dev/null 2>&1
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_address} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address} deprecated
exit_with_hooks 0
fi
if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${old_ip6_address}/${old_ip6_prefixlen} -alias
exit_with_hooks 0
fi
exit_with_hooks 0

318
external/bsd/dhcp/dist/client/scripts/linux vendored Executable file
View File

@@ -0,0 +1,318 @@
#!/bin/bash
# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# No guarantees about this. I'm a novice at the details of Linux
# networking.
# Notes:
# 0. This script is based on the netbsd script supplied with dhcp-970306.
# 1. ifconfig down apparently deletes all relevant routes and flushes
# the arp cache, so this doesn't need to be done explicitly.
# 2. The alias address handling here has not been tested AT ALL.
# I'm just going by the doc of modern Linux ip aliasing, which uses
# notations like eth0:0, eth0:1, for each alias.
# 3. I have to calculate the network address, and calculate the broadcast
# address if it is not supplied. This might be much more easily done
# by the dhclient C code, and passed on.
# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
# of the $1 in its args.
# 'ip' just looks too weird. /sbin/ip looks less weird.
ip=/sbin/ip
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
chmod 644 /etc/resolv.conf.dhclient
if [ x"$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ x"$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
shopt -s nocasematch
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
if [[ "$nameserver" =~ ^fe80:: ]]
then
zone_id="%$interface"
else
zone_id=
fi
echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
done
shopt -u nocasematch
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
###
### DHCPv4 Handlers
###
if [ x$new_broadcast_address != x ]; then
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_subnet_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_subnet_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
if [ x$reason = xMEDIUM ]; then
# Linux doesn't do mediums (ok, ok, media).
exit_with_hooks 0
fi
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
ifconfig $interface:0- inet 0
fi
ifconfig $interface 0 up
# We need to give the kernel some time to get the interface up.
sleep 1
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = "x(none)" ] || \
[ x$current_hostname = xlocalhost ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$new_host_name != x$old_host_name ]; then
hostname "$new_host_name"
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
# Possible new alias. Remove old alias.
ifconfig $interface:0- inet 0
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
ifconfig $interface inet 0 down
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
ifconfig $interface inet $new_ip_address $new_subnet_arg \
$new_broadcast_arg $mtu_arg
# Add a network route to the computed network address.
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
for router in $old_routers; do
route del default gw $router
done
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface:0- inet 0
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address $interface:0
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.
ifconfig $interface:0- inet 0
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
ifconfig $interface inet 0 down
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address $interface:0
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0- inet 0
fi
ifconfig $interface inet $new_ip_address $new_subnet_arg \
$new_broadcast_arg $mtu_arg
set $new_routers
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address dev $interface:0
fi
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
make_resolv_conf
exit_with_hooks 0
fi
ifconfig $interface inet 0 down
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ x$reason = xPREINIT6 ] ; then
# Ensure interface is up.
${ip} link set ${interface} up
# Remove any stale addresses from aborted clients.
${ip} -f inet6 addr flush dev ${interface} scope global permanent
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ x$reason = xBOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ x$reason = xDEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global preferred_lft 0
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
dev ${interface}
exit_with_hooks 0
fi
exit_with_hooks 0

View File

@@ -0,0 +1,207 @@
#!/bin/sh
#
# Id: macos,v 1.4 2011/09/20 16:59:54 sar Exp
#
# automous run of this script will commit the DNS setting
#
if [ -x /usr/bin/logger ]; then
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
else
LOGGER=echo
fi
to_commit="yes"
make_resolv_conf() {
to_commit="no"
if [ "x${new_dhcp6_name_servers}" != x ]; then
( cat /dev/null > /var/run/resolv.conf.dhclient6 )
exit_status=$?
if [ $exit_status -ne 0 ]; then
$LOGGER "Unable to create /var/run/resolv.conf.dhclient6: Error $exit_status"
else
if [ "x${new_dhcp6_domain_search}" != x ]; then
( echo search ${new_dhcp6_domain_search} >> /var/run/resolv.conf.dhclient6 )
exit_status=$?
fi
for nameserver in ${new_dhcp6_name_servers} ; do
if [ $exit_status -ne 0 ]; then
break
fi
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
( echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6 )
exit_status=$?
done
if [ $exit_status -eq 0 ]; then
to_commit="force"
commit_resolv_conf
fi
fi
fi
}
# Try to commit /var/run/resolv.conf.dhclient6 contents to
# System Configuration framework's Dynamic Store.
# Note this will be cleared by the next location change
# or preempted by IPv4.
#
# The System Configuration agent "IPMonitor" gets the DNS configuration
# from the IPv4 or IPv6 primary service in the Dynamic Store
# (managed by configd).
commit_resolv_conf() {
if [ -f /var/run/resolv.conf.dhclient6 ]; then
if [ -x /usr/sbin/scutil ]; then
serviceID=`echo show State:/Network/Global/IPv6 | \
/usr/sbin/scutil | \
awk '/PrimaryService/ { print $3 }'`
echo $serviceID
if [ x$serviceID = x ]; then
$LOGGER "Can't find the primary IPv6 service"
else
tmp=`mktemp SC_dhclient6.XXXXXXXXXX`
echo list | /usr/sbin/scutil > /tmp/$tmp
grep -q State:/Network/Service/$serviceID/DNS /tmp/$tmp
grep_status=$?
if [ $grep_status -eq 0 ]; then
$LOGGER "DNS service already set in primary IPv6 service"
rm /tmp/$tmp
else
res=/var/run/resolv.conf.dhclient6
cp /dev/null /tmp/$tmp
grep -q '^nameserver' $res
grep_status=$?
if [ $grep_status -eq 0 ]; then
echo d.add ServerAddresses '*' \
`awk 'BEGIN { n="" } \
/^nameserver/ { n=n " " $2 } \
END { print n}' < $res` >> /tmp/$tmp
fi
grep -q '^search' $res
grep_status=$?
if [ $grep_status -eq 0 ]; then
echo d.add SearchDomains '*' \
`sed 's/^search//' < $res` >> /tmp/$tmp
fi
echo set State:/Network/Service/$serviceID/DNS >> /tmp/$tmp
echo quit >> /tmp/$tmp
cat /tmp/$tmp
/usr/sbin/scutil < /tmp/$tmp
rm /tmp/$tmp
fi
fi
else
$LOGGER "Can't find SystemConfiguration tools."
fi
else
if [ $to_commit = force ]; then
$LOGGER "Can't find /var/run/resolv.conf.dhclient6"
fi
fi
to_commit="done"
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv6 Handlers
###
if [ x$reason = xPREINIT6 ]; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ]; then
echo Prefix $reason old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ x$reason = xBOUND6 ]; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ]; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ]; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ x$reason = xDEPREF6 ]; then
if [ x${new_ip6_address} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${new_ip6_address} deprecated
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ]; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ]; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 ${old_ip6_address}/${old_ip6_prefixlen} -alias
exit_with_hooks 0
fi
if [ $to_commit = yes ]; then
commit_resolv_conf
fi
exit_with_hooks 0

324
external/bsd/dhcp/dist/client/scripts/netbsd vendored Executable file
View File

@@ -0,0 +1,324 @@
#!/bin/sh
make_resolv_conf() {
if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
if [ "x$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
done
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$new_network_number != x ]; then
echo New Network Number: $new_network_number
fi
if [ x$new_broadcast_address != x ]; then
echo New Broadcast Address: $new_broadcast_address
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv4 Handlers
###
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
if [ "$new_static_routes" != "" ]; then
set $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
fi
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ]; then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
sleep 1
if [ "$new_routers" != "" ]; then
set $new_routers
if ping -q -c 1 -w 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
set $new_static_routes
while [ $# -gt 1 ]; do
route add $0 $1
shift; shift
done
make_resolv_conf
exit_with_hooks 0
fi
fi
eval "ifconfig $interface inet -alias $new_ip_address $medium"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen}
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
# XXX:
# There doesn't appear to be a way to update an addr to indicate
# preference.
exit_with_hooks 0
fi
if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen}
exit_with_hooks 0
fi
exit_with_hooks 0

View File

@@ -0,0 +1,61 @@
#!/bin/sh
#
# simplified dhclient-script for NeXTSTEP/OPENSTEP
#
# removed a lot of the cruft from the netbsd version since NeXTSTEP doesn't
# support aliases and lots of things were breaking for no good reason
#
# 14 Sep 1997, David W. Young
#
if [ x$reason = xPREINIT ]; then
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 up >/dev/null 2>&1
exit 0
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
then
ifconfig $interface $new_ip_address netmask $new_subnet_mask \
>/dev/null 2>&1
route add $new_ip_address 127.1 0 >/dev/null 2>&1
for router in $new_routers ; do
route add default $router 1 >/dev/null 2>&1
done
fi
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
if [ "x$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
fi
exit 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$old_ip_address != x ]; then
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
done
fi
exit 0
fi

View File

@@ -0,0 +1,318 @@
#!/bin/sh
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
if [ x"$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ x"$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
done
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$new_network_number != x ]; then
echo New Network Number: $new_network_number
fi
if [ x$new_broadcast_address != x ]; then
echo New Broadcast Address: $new_broadcast_address
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$reason = xMEDIUM ]; then
eval "ifconfig $interface $medium"
eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
sleep 1
exit_with_hooks 0
fi
###
### DHCPv4 Handlers
###
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0;
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $medium"
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
if [ "$new_static_routes" != "" ]; then
set $new_static_routes
while [ $# -gt 1 ]; do
route add $1 $2
shift; shift
done
fi
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ]; then
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
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $medium"
sleep 1
if [ "$new_routers" != "" ]; then
set $new_routers
if ping -q -c 1 -w 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router >/dev/null 2>&1
done
set $new_static_routes
while [ $# -gt 1 ]; do
route add $0 $1
shift; shift
done
make_resolv_conf
exit_with_hooks 0
fi
fi
eval "ifconfig $interface inet -alias $new_ip_address $medium"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
if [ "$old_static_routes" != "" ]; then
set $old_static_routes
while [ $# -gt 1 ]; do
route delete $1 $2
shift; shift
done
fi
arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
|sh >/dev/null 2>&1
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ ${reason} = PREINIT6 ] ; then
# Ensure interface is up.
ifconfig ${interface} up
# XXX: Remove any stale addresses from aborted clients.
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ ${reason} = BOUND6 ] ; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 add ${new_ip6_address}/${new_ip6_prefixlen}
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ ${reason} = DEPREF6 ] ; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
# XXX:
# There doesn't appear to be a way to update an addr to indicate
# preference.
exit_with_hooks 0
fi
if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
ifconfig ${interface} inet6 delete ${old_ip6_address}/${old_ip6_prefixlen}
exit_with_hooks 0
fi
exit_with_hooks 0

287
external/bsd/dhcp/dist/client/scripts/openwrt vendored Executable file
View File

@@ -0,0 +1,287 @@
#!/bin/sh
# 'ip' just looks too weird. /sbin/ip looks less weird.
ip=/usr/sbin/ip
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
chmod 644 /etc/resolv.conf.dhclient
if [ x"$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ x"$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
cat /dev/null > /etc/resolv.conf.dhclient6
chmod 644 /etc/resolv.conf.dhclient6
if [ "x${new_dhcp6_domain_search}" != x ] ; then
echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
fe80:*) zone_id="%$interface";;
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
done
mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
###
### DHCPv4 Handlers
###
if [ x$new_broadcast_address != x ]; then
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_subnet_arg="netmask $new_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
if [ x$reason = xMEDIUM ]; then
# Linux doesn't do mediums (ok, ok, media).
exit_with_hooks 0
fi
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
ifconfig $interface:0- 0.0.0.0
fi
ifconfig $interface 0.0.0.0 up
# We need to give the kernel some time to get the interface up.
sleep 1
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
# Possible new alias. Remove old alias.
ifconfig $interface:0- 0.0.0.0
fi
if [ x$old_ip_address != x ] && \
[ x$old_ip_address != x$new_ip_address ]; then
# IP address changed. Bringing down the interface will delete all routes,
# and clear the ARP cache.
ifconfig $interface 0.0.0.0 down
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
ifconfig $interface $new_ip_address $new_subnet_arg \
$new_broadcast_arg $mtu_arg
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route del default gw $router
done
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
ifconfig $interface:0- 0.0.0.0
ifconfig $interface:0 $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address $interface:0
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.
ifconfig $interface:0- 0.0.0.0
fi
if [ x$old_ip_address != x ]; then
# Shut down interface, which will delete routes and clear arp cache.
ifconfig $interface 0.0.0.0 down
fi
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0 $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address $interface:0
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
ifconfig $interface:0- 0.0.0.0
fi
ifconfig $interface $new_ip_address $new_subnet_arg \
$new_broadcast_arg $mtu_arg
set $new_routers
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
ifconfig $interface:0 $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address dev $interface:0
fi
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
route add -host $router dev $interface
fi
route add default gw $router $metric_arg dev $interface
done
make_resolv_conf
exit_with_hooks 0
fi
ifconfig $interface 0.0.0.0 down
exit_with_hooks 1
fi
###
### DHCPv6 Handlers
###
if [ x$reason = xPREINIT6 ]; then
# Ensure interface is up.
${ip} link set ${interface} up
# Remove any stale addresses from aborted clients.
${ip} -f inet6 addr flush dev ${interface} scope global permanent
exit_with_hooks 0
fi
if [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
exit_with_hooks 0
fi
if [ x$reason = xBOUND6 ]; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Check for nameserver options.
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xRENEW6 ] || [ x$reason = xREBIND6 ]; then
if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global
# Make sure nothing has moved around on us.
# Nameservers/domains/etc.
if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
make_resolv_conf
fi
exit_with_hooks 0
fi
if [ x$reason = xDEPREF6 ]; then
if [ x${new_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global preferred_lft 0
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE6 -o x$reason = xRELEASE6 -o x$reason = xSTOP6 ]; then
if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
exit_with_hooks 2;
fi
${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
dev ${interface}
exit_with_hooks 0
fi
exit_with_hooks 0

203
external/bsd/dhcp/dist/client/scripts/solaris vendored Executable file
View File

@@ -0,0 +1,203 @@
#!/bin/sh
make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
cat /dev/null > /etc/resolv.conf.dhclient
if [ x"$new_domain_search" != x ]; then
echo search $new_domain_search >> /etc/resolv.conf.dhclient
elif [ x"$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
echo search $new_domain_name >> /etc/resolv.conf.dhclient
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.dhclient
done
mv /etc/resolv.conf.dhclient /etc/resolv.conf
fi
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1
if [ -f /etc/dhclient-exit-hooks ]; then
. /etc/dhclient-exit-hooks
fi
# probably should do something with exit status of the local script
exit $exit_status
}
# Invoke the local dhcp client enter hooks, if they exist.
if [ -f /etc/dhclient-enter-hooks ]; then
exit_status=0
. /etc/dhclient-enter-hooks
# 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
exit $exit_status
fi
fi
if [ x$new_broadcast_address != x ]; then
new_broadcast_arg="broadcast $new_broadcast_address"
fi
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ x$new_subnet_mask != x ]; then
new_netmask_arg="netmask $new_subnet_mask"
fi
if [ x$old_subnet_mask != x ]; then
old_netmask_arg="netmask $old_subnet_mask"
fi
if [ x$alias_subnet_mask != x ]; then
alias_subnet_arg="netmask $alias_subnet_mask"
fi
if [ x$new_interface_mtu != x ]; then
mtu_arg="mtu $new_interface_mtu"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
fi
ifconfig=/sbin/ifconfig
release=`uname -r`
release=`expr $release : '\(.*\)\..*'`
relmajor=`echo $release |sed -e 's/^\([^\.]*\)\..*$/\1/'`
relminor=`echo $release |sed -e 's/^.*\.\([^\.]*\)$/\1/'`
if [ x$reason = xMEDIUM ]; then
eval "$ifconfig $interface $medium"
$ifconfig $interface
sleep 1
exit_with_hooks 0
fi
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
$ifconfig ${interface}:1 0 down > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ $relmajor -gt 5 ] || ( [ $relmajor -eq 5 ] && [ $relminor -ge 5 ] )
then
# Turn the interface on
$ifconfig $interface plumb
$ifconfig $interface up
else
$ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
broadcast 255.255.255.255 up
fi
exit_with_hooks 0
fi
if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
exit_with_hooks 0;
fi
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`hostname`
if [ x$current_hostname = x ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$current_hostname = x ] || \
[ x$new_host_name != x$old_host_name ]; then
hostname $new_host_name
fi
fi
if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
[ x$alias_ip_address != x$old_ip_address ]; then
$ifconfig ${interface}:1 inet 0 down > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
$ifconfig ${interface} inet 0 down
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
done
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
route add $new_ip_address 127.1 1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router 1 >/dev/null 2>&1
done
else
# we haven't changed the address, have we changed other options
# that we wish to update?
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
$LOGGER "New Routers: $new_routers"
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
for router in $new_routers; do
route add default $router 1 >/dev/null 2>&1
done
fi
fi
if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
then
$ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1 1
fi
make_resolv_conf
exit_with_hooks 0
fi
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
$ifconfig ${interface}:1 0 down > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
if [ x$old_ip_address != x ]; then
$ifconfig $interface inet 0 down
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
done
fi
if [ x$alias_ip_address != x ]; then
$ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1 1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
$ifconfig ${interface}:1 0 down > /dev/null 2>&1
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
$new_broadcast_arg $mtu_arg $metric_arg $medium"
sleep 1
set $new_routers
if ping -s -n -I 1 $1 64 1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
$ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1 1
fi
route add $new_ip_address 127.1 1 >/dev/null 2>&1
for router in $new_routers; do
route add default $router 1 >/dev/null 2>&1
done
make_resolv_conf
exit_with_hooks 0
fi
$ifconfig $interface inet 0 down
for router in $old_routers; do
route delete default $router >/dev/null 2>&1
done
exit_with_hooks 1
fi
exit_with_hooks 0

View File

@@ -0,0 +1,17 @@
AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
AM_CFLAGS = $(LDAP_CFLAGS)
noinst_LIBRARIES = libdhcp.a
libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
dispatch.c dlpi.c dns.c ethernet.c execute.c fddi.c \
icmp.c inet.c lpf.c memory.c nit.c ns_name.c options.c \
packet.c parse.c print.c raw.c resolv.c socket.c \
tables.c tr.c tree.c upf.c
man_MANS = dhcp-eval.5 dhcp-options.5
EXTRA_DIST = $(man_MANS)
# We want to build this directory first, before descending into tests subdir.
# The reason is that ideally the tests should link existing objects from this
# directory. That eliminates any discrepancies between tested code and
# production code. Sadly, we are not there yet.
SUBDIRS = . tests

View File

@@ -0,0 +1,777 @@
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = common
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
libdhcp_a_AR = $(AR) $(ARFLAGS)
libdhcp_a_LIBADD =
am_libdhcp_a_OBJECTS = alloc.$(OBJEXT) bpf.$(OBJEXT) comapi.$(OBJEXT) \
conflex.$(OBJEXT) ctrace.$(OBJEXT) discover.$(OBJEXT) \
dispatch.$(OBJEXT) dlpi.$(OBJEXT) dns.$(OBJEXT) \
ethernet.$(OBJEXT) execute.$(OBJEXT) fddi.$(OBJEXT) \
icmp.$(OBJEXT) inet.$(OBJEXT) lpf.$(OBJEXT) memory.$(OBJEXT) \
nit.$(OBJEXT) ns_name.$(OBJEXT) options.$(OBJEXT) \
packet.$(OBJEXT) parse.$(OBJEXT) print.$(OBJEXT) raw.$(OBJEXT) \
resolv.$(OBJEXT) socket.$(OBJEXT) tables.$(OBJEXT) \
tr.$(OBJEXT) tree.$(OBJEXT) upf.$(OBJEXT)
libdhcp_a_OBJECTS = $(am_libdhcp_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libdhcp_a_SOURCES)
DIST_SOURCES = $(libdhcp_a_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man5dir = $(mandir)/man5
am__installdirs = "$(DESTDIR)$(man5dir)"
NROFF = nroff
MANS = $(man_MANS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
ATF_CFLAGS = @ATF_CFLAGS@
ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_CFLAGS = @LDAP_CFLAGS@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_prefix_program = @ac_prefix_program@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
byte_order = @byte_order@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I.. -DLOCALSTATEDIR='"@localstatedir@"'
AM_CFLAGS = $(LDAP_CFLAGS)
noinst_LIBRARIES = libdhcp.a
libdhcp_a_SOURCES = alloc.c bpf.c comapi.c conflex.c ctrace.c discover.c \
dispatch.c dlpi.c dns.c ethernet.c execute.c fddi.c \
icmp.c inet.c lpf.c memory.c nit.c ns_name.c options.c \
packet.c parse.c print.c raw.c resolv.c socket.c \
tables.c tr.c tree.c upf.c
man_MANS = dhcp-eval.5 dhcp-options.5
EXTRA_DIST = $(man_MANS)
# We want to build this directory first, before descending into tests subdir.
# The reason is that ideally the tests should link existing objects from this
# directory. That eliminates any discrepancies between tested code and
# production code. Sadly, we are not there yet.
SUBDIRS = . tests
all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign common/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign common/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libdhcp.a: $(libdhcp_a_OBJECTS) $(libdhcp_a_DEPENDENCIES) $(EXTRA_libdhcp_a_DEPENDENCIES)
$(AM_V_at)-rm -f libdhcp.a
$(AM_V_AR)$(libdhcp_a_AR) libdhcp.a $(libdhcp_a_OBJECTS) $(libdhcp_a_LIBADD)
$(AM_V_at)$(RANLIB) libdhcp.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bpf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/comapi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conflex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctrace.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/discover.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dispatch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlpi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethernet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execute.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fddi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lpf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nit.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ns_name.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resolv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tables.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tree.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upf.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
install-man5: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man5dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.5[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
done; }
uninstall-man5:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man5dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.5[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile $(LIBRARIES) $(MANS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(man5dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-man
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man: install-man5
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-man
uninstall-man: uninstall-man5
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-generic clean-noinstLIBRARIES \
cscopelist-am ctags ctags-am distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-man5 install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-man \
uninstall-man5
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1302
external/bsd/dhcp/dist/common/alloc.c vendored Normal file

File diff suppressed because it is too large Load Diff

652
external/bsd/dhcp/dist/common/bpf.c vendored Normal file
View File

@@ -0,0 +1,652 @@
/* $NetBSD: bpf.c,v 1.3 2014/07/12 12:09:37 spz Exp $ */
/* bpf.c
BPF socket interface code, originally contributed by Archie Cobbs. */
/*
* Copyright (c) 2009,2012-2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
* This software was contributed to Internet Systems Consortium
* by Archie Cobbs.
*
* Patches for FDDI support on Digital Unix were written by Bill
* Stapleton, and maintained for a while by Mike Meredith before he
* managed to get me to integrate them.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: bpf.c,v 1.3 2014/07/12 12:09:37 spz Exp $");
#include "dhcpd.h"
#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \
|| defined (USE_LPF_RECEIVE)
# if defined (USE_LPF_RECEIVE)
# include <asm/types.h>
# include <linux/filter.h>
# define bpf_insn sock_filter /* Linux: dare to be gratuitously different. */
# else
# include <sys/ioctl.h>
# include <sys/uio.h>
# include <net/bpf.h>
# if defined (NEED_OSF_PFILT_HACKS)
# include <net/pfilt.h>
# endif
# endif
#include <sys/param.h>
#include <netinet/in_systm.h>
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
#endif
#if defined(USE_BPF_SEND) || defined(USE_BPF_RECEIVE) || defined(USE_BPF_HWADDR)
#include <net/if_types.h>
#include <ifaddrs.h>
#endif
#include <errno.h>
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
#ifdef USE_BPF_SEND
void if_reinitialize_send (info)
struct interface_info *info;
{
}
#endif
#ifdef USE_BPF_RECEIVE
void if_reinitialize_receive (info)
struct interface_info *info;
{
}
#endif
/* Called by get_interface_list for each interface that's discovered.
Opens a packet filter for each interface and adds it to the select
mask. */
#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
int if_register_bpf (info)
struct interface_info *info;
{
int sock;
char filename[50];
int b;
/* Open a BPF device */
for (b = 0; 1; b++) {
/* %Audit% 31 bytes max. %2004.06.17,Safe% */
sprintf(filename, BPF_FORMAT, b);
sock = open (filename, O_RDWR, 0);
if (sock < 0) {
if (errno == EBUSY) {
continue;
} else {
if (!b)
log_fatal ("No bpf devices.%s%s%s",
" Please read the README",
" section for your operating",
" system.");
log_fatal ("Can't find free bpf: %m");
}
} else {
break;
}
}
/* Set the BPF device to point at this interface. */
if (ioctl (sock, BIOCSETIF, info -> ifp) < 0)
log_fatal ("Can't attach interface %s to bpf device %s: %m",
info -> name, filename);
get_hw_addr(info->name, &info->hw_address);
return sock;
}
#endif /* USE_BPF_SEND || USE_BPF_RECEIVE */
#ifdef USE_BPF_SEND
void if_register_send (info)
struct interface_info *info;
{
/* If we're using the bpf API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_BPF_RECEIVE
info -> wfdesc = if_register_bpf (info, interface);
#else
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
log_info ("Sending on BPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_send (info)
struct interface_info *info;
{
/* If we're using the bpf API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_BPF_RECEIVE
close (info -> wfdesc);
#endif
info -> wfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling output on BPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_BPF_SEND */
#if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE)
/* Packet filter program...
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the BPF program! XXX */
struct bpf_insn dhcp_bpf_filter [] = {
/* Make sure this is an IP packet... */
BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12),
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
/* Make sure it's a UDP packet... */
BPF_STMT (BPF_LD + BPF_B + BPF_ABS, 23),
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6),
/* Make sure this isn't a fragment... */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20),
BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0),
/* Get the IP header length... */
BPF_STMT (BPF_LDX + BPF_B + BPF_MSH, 14),
/* Make sure it's to the right port... */
BPF_STMT (BPF_LD + BPF_H + BPF_IND, 16),
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */
/* If we passed all the tests, ask for the whole packet. */
BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
/* Otherwise, drop it. */
BPF_STMT(BPF_RET+BPF_K, 0),
};
#if defined (DEC_FDDI)
struct bpf_insn *bpf_fddi_filter;
#endif
int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
#if defined (HAVE_TR_SUPPORT)
struct bpf_insn dhcp_bpf_tr_filter [] = {
/* accept all token ring packets due to variable length header */
/* if we want to get clever, insert the program here */
/* If we passed all the tests, ask for the whole packet. */
BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
/* Otherwise, drop it. */
BPF_STMT(BPF_RET+BPF_K, 0),
};
int dhcp_bpf_tr_filter_len = (sizeof dhcp_bpf_tr_filter /
sizeof (struct bpf_insn));
#endif /* HAVE_TR_SUPPORT */
#endif /* USE_LPF_RECEIVE || USE_BPF_RECEIVE */
#if defined (USE_BPF_RECEIVE)
void if_register_receive (info)
struct interface_info *info;
{
int flag = 1;
struct bpf_version v;
struct bpf_program p;
#ifdef NEED_OSF_PFILT_HACKS
u_int32_t bits;
#endif
#ifdef DEC_FDDI
int link_layer;
#endif /* DEC_FDDI */
/* Open a BPF device and hang it on this interface... */
info -> rfdesc = if_register_bpf (info);
/* Make sure the BPF version is in range... */
if (ioctl (info -> rfdesc, BIOCVERSION, &v) < 0)
log_fatal ("Can't get BPF version: %m");
if (v.bv_major != BPF_MAJOR_VERSION ||
v.bv_minor < BPF_MINOR_VERSION)
log_fatal ("BPF version mismatch - recompile DHCP!");
/* Set immediate mode so that reads return as soon as a packet
comes in, rather than waiting for the input buffer to fill with
packets. */
if (ioctl (info -> rfdesc, BIOCIMMEDIATE, &flag) < 0)
log_fatal ("Can't set immediate mode on bpf device: %m");
#ifdef NEED_OSF_PFILT_HACKS
/* Allow the copyall flag to be set... */
if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0)
log_fatal ("Can't set ALLOWCOPYALL: %m");
/* Clear all the packet filter mode bits first... */
bits = 0;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
log_fatal ("Can't clear pfilt bits: %m");
/* Set the ENBATCH, ENCOPYALL, ENBPFHDR bits... */
bits = ENBATCH | ENCOPYALL | ENBPFHDR;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
log_fatal ("Can't set ENBATCH|ENCOPYALL|ENBPFHDR: %m");
#endif
/* Get the required BPF buffer length from the kernel. */
if (ioctl (info -> rfdesc, BIOCGBLEN, &info -> rbuf_max) < 0)
log_fatal ("Can't get bpf buffer length: %m");
info -> rbuf = dmalloc (info -> rbuf_max, MDL);
if (!info -> rbuf)
log_fatal ("Can't allocate %ld bytes for bpf input buffer.",
(long)(info -> rbuf_max));
info -> rbuf_offset = 0;
info -> rbuf_len = 0;
/* Set up the bpf filter program structure. */
p.bf_len = dhcp_bpf_filter_len;
#ifdef DEC_FDDI
/* See if this is an FDDI interface, flag it for later. */
if (ioctl(info -> rfdesc, BIOCGDLT, &link_layer) >= 0 &&
link_layer == DLT_FDDI) {
if (!bpf_fddi_filter) {
bpf_fddi_filter = dmalloc (sizeof bpf_fddi_filter,
MDL);
if (!bpf_fddi_filter)
log_fatal ("No memory for FDDI filter.");
memcpy (bpf_fddi_filter,
dhcp_bpf_filter, sizeof dhcp_bpf_filter);
/* Patch the BPF program to account for the difference
in length between ethernet headers (14), FDDI and
802.2 headers (16 +8=24, +10).
XXX changes to filter program may require changes to
XXX the insn number(s) used below! */
bpf_fddi_filter[0].k += 10;
bpf_fddi_filter[2].k += 10;
bpf_fddi_filter[4].k += 10;
bpf_fddi_filter[6].k += 10;
bpf_fddi_filter[7].k += 10;
}
p.bf_insns = bpf_fddi_filter;
} else
#endif /* DEC_FDDI */
p.bf_insns = dhcp_bpf_filter;
/* Patch the server port into the BPF program...
XXX changes to filter program may require changes
to the insn number(s) used below! XXX */
dhcp_bpf_filter [8].k = ntohs (local_port);
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
log_fatal ("Can't install packet filter program: %m");
if (!quiet_interface_discovery)
log_info ("Listening on BPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_receive (info)
struct interface_info *info;
{
close (info -> rfdesc);
info -> rfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling input on BPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_BPF_RECEIVE */
#ifdef USE_BPF_SEND
ssize_t send_packet (interface, packet, raw, len, from, to, hto)
struct interface_info *interface;
struct packet *packet;
struct dhcp_packet *raw;
size_t len;
struct in_addr from;
struct sockaddr_in *to;
struct hardware *hto;
{
unsigned hbufp = 0, ibufp = 0;
double hw [4];
double ip [32];
struct iovec iov [3];
int result;
if (!strcmp (interface -> name, "fallback"))
return send_fallback (interface, packet, raw,
len, from, to, hto);
if (hto == NULL && interface->anycast_mac_addr.hlen)
hto = &interface->anycast_mac_addr;
/* Assemble the headers... */
assemble_hw_header (interface, (unsigned char *)hw, &hbufp, hto);
assemble_udp_ip_header (interface,
(unsigned char *)ip, &ibufp, from.s_addr,
to -> sin_addr.s_addr, to -> sin_port,
(unsigned char *)raw, len);
/* Fire it off */
iov [0].iov_base = ((char *)hw);
iov [0].iov_len = hbufp;
iov [1].iov_base = ((char *)ip);
iov [1].iov_len = ibufp;
iov [2].iov_base = (char *)raw;
iov [2].iov_len = len;
result = writev(interface -> wfdesc, iov, 3);
if (result < 0)
log_error ("send_packet: %m");
return result;
}
#endif /* USE_BPF_SEND */
#ifdef USE_BPF_RECEIVE
ssize_t receive_packet (interface, buf, len, from, hfrom)
struct interface_info *interface;
unsigned char *buf;
size_t len;
struct sockaddr_in *from;
struct hardware *hfrom;
{
int length = 0;
int offset = 0;
struct bpf_hdr hdr;
unsigned paylen;
/* All this complexity is because BPF doesn't guarantee
that only one packet will be returned at a time. We're
getting what we deserve, though - this is a terrible abuse
of the BPF interface. Sigh. */
/* Process packets until we get one we can return or until we've
done a read and gotten nothing we can return... */
/* If the buffer is empty, fill it. */
if (interface->rbuf_offset >= interface->rbuf_len) {
length = read(interface->rfdesc, interface->rbuf,
(size_t)interface->rbuf_max);
if (length <= 0) {
#ifdef __FreeBSD__
if (errno == ENXIO) {
#else
if (errno == EIO) {
#endif
dhcp_interface_remove
((omapi_object_t *)interface, NULL);
}
return (length);
}
interface->rbuf_offset = 0;
interface->rbuf_len = BPF_WORDALIGN(length);
}
do {
/* If there isn't room for a whole bpf header, something went
wrong, but we'll ignore it and hope it goes away... XXX */
if (interface->rbuf_len -
interface->rbuf_offset < sizeof hdr) {
interface->rbuf_offset = interface->rbuf_len;
continue;
}
/* Copy out a bpf header... */
memcpy(&hdr, &interface->rbuf[interface->rbuf_offset],
sizeof hdr);
/* If the bpf header plus data doesn't fit in what's left
of the buffer, stick head in sand yet again... */
if (interface->rbuf_offset +
hdr.bh_hdrlen + hdr.bh_caplen > interface->rbuf_len) {
interface->rbuf_offset = interface->rbuf_len;
continue;
}
/* If the captured data wasn't the whole packet, or if
the packet won't fit in the input buffer, all we
can do is drop it. */
if (hdr.bh_caplen != hdr.bh_datalen) {
interface->rbuf_offset =
BPF_WORDALIGN(interface->rbuf_offset +
hdr.bh_hdrlen + hdr.bh_caplen);
continue;
}
/* Skip over the BPF header... */
interface->rbuf_offset += hdr.bh_hdrlen;
/* Decode the physical header... */
offset = decode_hw_header(interface, interface->rbuf,
interface->rbuf_offset, hfrom);
/* If a physical layer checksum failed (dunno of any
physical layer that supports this, but WTH), skip this
packet. */
if (offset < 0) {
interface->rbuf_offset =
BPF_WORDALIGN(interface->rbuf_offset +
hdr.bh_caplen);
continue;
}
interface->rbuf_offset += offset;
hdr.bh_caplen -= offset;
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header(interface, interface->rbuf,
interface->rbuf_offset,
from, hdr.bh_caplen, &paylen);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0) {
interface->rbuf_offset =
BPF_WORDALIGN(interface->rbuf_offset +
hdr.bh_caplen);
continue;
}
interface->rbuf_offset = interface->rbuf_offset + offset;
hdr.bh_caplen -= offset;
/* If there's not enough room to stash the packet data,
we have to skip it (this shouldn't happen in real
life, though). */
if (hdr.bh_caplen > len) {
interface->rbuf_offset =
BPF_WORDALIGN(interface->rbuf_offset +
hdr.bh_caplen);
continue;
}
/* Copy out the data in the packet... */
memcpy(buf, interface->rbuf + interface->rbuf_offset, paylen);
interface->rbuf_offset =
BPF_WORDALIGN(interface->rbuf_offset + hdr.bh_caplen);
return paylen;
} while (interface->rbuf_offset < interface->rbuf_len);
return (0);
}
int can_unicast_without_arp (ip)
struct interface_info *ip;
{
return 1;
}
int can_receive_unicast_unconfigured (ip)
struct interface_info *ip;
{
return 1;
}
int supports_multiple_interfaces (ip)
struct interface_info *ip;
{
return 1;
}
void maybe_setup_fallback ()
{
isc_result_t status;
struct interface_info *fbi = (struct interface_info *)0;
if (setup_fallback (&fbi, MDL)) {
if_register_fallback (fbi);
status = omapi_register_io_object ((omapi_object_t *)fbi,
if_readsocket, 0,
fallback_discard, 0, 0);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register I/O handle for %s: %s",
fbi -> name, isc_result_totext (status));
interface_dereference (&fbi, MDL);
}
}
#endif
#if defined(USE_BPF_RECEIVE) || defined(USE_BPF_HWADDR)
static int
lladdr_active(int s, const char *name, const struct ifaddrs *ifa)
{
if (ifa->ifa_addr->sa_family != AF_LINK)
return 0;
if (strcmp(ifa->ifa_name, name) != 0)
return 0;
#ifdef SIOCGLIFADDR
{
struct if_laddrreq iflr;
const struct sockaddr_dl *sdl;
sdl = satocsdl(ifa->ifa_addr);
memset(&iflr, 0, sizeof(iflr));
strlcpy(iflr.iflr_name, ifa->ifa_name, sizeof(iflr.iflr_name));
memcpy(&iflr.addr, ifa->ifa_addr, MIN(ifa->ifa_addr->sa_len,
sizeof(iflr.addr)));
iflr.flags = IFLR_PREFIX;
iflr.prefixlen = sdl->sdl_alen * NBBY;
if (ioctl(s, SIOCGLIFADDR, &iflr) == -1) {
log_fatal("ioctl(SIOCGLIFADDR): %m");
}
if ((iflr.flags & IFLR_ACTIVE) == 0)
return 0;
}
#endif
return 1;
}
void
get_hw_addr(const char *name, struct hardware *hw) {
struct ifaddrs *ifa;
struct ifaddrs *p;
struct sockaddr_dl *sa;
int s;
if ((s = socket(AF_LINK, SOCK_DGRAM, 0)) == -1) {
log_fatal("socket AF_LINK: %m");
}
if (getifaddrs(&ifa) != 0) {
log_fatal("Error getting interface information; %m");
}
/*
* Loop through our interfaces finding a match.
*/
sa = NULL;
for (p = ifa; p != NULL; p = p->ifa_next) {
if (lladdr_active(s, name, p)) {
sa = (struct sockaddr_dl *)p->ifa_addr;
break;
}
}
if (sa == NULL) {
log_fatal("No interface called '%s'", name);
}
close(s);
/*
* Pull out the appropriate information.
*/
switch (sa->sdl_type) {
case IFT_ETHER:
hw->hlen = sa->sdl_alen + 1;
hw->hbuf[0] = HTYPE_ETHER;
memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
break;
case IFT_ISO88023:
case IFT_ISO88024: /* "token ring" */
case IFT_ISO88025:
case IFT_ISO88026:
hw->hlen = sa->sdl_alen + 1;
hw->hbuf[0] = HTYPE_IEEE802;
memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
break;
#ifdef IFT_FDDI
case IFT_FDDI:
hw->hlen = sa->sdl_alen + 1;
hw->hbuf[0] = HTYPE_FDDI;
memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
break;
#endif /* IFT_FDDI */
default:
log_fatal("Unsupported device type %d for \"%s\"",
sa->sdl_type, name);
}
freeifaddrs(ifa);
}
#endif

925
external/bsd/dhcp/dist/common/comapi.c vendored Normal file
View File

@@ -0,0 +1,925 @@
/* $NetBSD: comapi.c,v 1.1.1.3 2014/07/12 11:57:39 spz Exp $ */
/* omapi.c
OMAPI object interfaces for the DHCP server. */
/*
* Copyright (c) 2012,2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: comapi.c,v 1.1.1.3 2014/07/12 11:57:39 spz Exp $");
/* Many, many thanks to Brian Murrell and BCtel for this code - BCtel
provided the funding that resulted in this code and the entire
OMAPI support library being written, and Brian helped brainstorm
and refine the requirements. To the extent that this code is
useful, you have Brian and BCtel to thank. Any limitations in the
code are a result of mistakes on my part. -- Ted Lemon */
#include "dhcpd.h"
#include <omapip/omapip_p.h>
OMAPI_OBJECT_ALLOC (subnet, struct subnet, dhcp_type_subnet)
OMAPI_OBJECT_ALLOC (shared_network, struct shared_network,
dhcp_type_shared_network)
OMAPI_OBJECT_ALLOC (group_object, struct group_object, dhcp_type_group)
OMAPI_OBJECT_ALLOC (dhcp_control, dhcp_control_object_t, dhcp_type_control)
omapi_object_type_t *dhcp_type_interface;
omapi_object_type_t *dhcp_type_group;
omapi_object_type_t *dhcp_type_shared_network;
omapi_object_type_t *dhcp_type_subnet;
omapi_object_type_t *dhcp_type_control;
dhcp_control_object_t *dhcp_control_object;
void dhcp_common_objects_setup ()
{
isc_result_t status;
status = omapi_object_type_register (&dhcp_type_control,
"control",
dhcp_control_set_value,
dhcp_control_get_value,
dhcp_control_destroy,
dhcp_control_signal_handler,
dhcp_control_stuff_values,
dhcp_control_lookup,
dhcp_control_create,
dhcp_control_remove, 0, 0, 0,
sizeof (dhcp_control_object_t),
0, RC_MISC);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register control object type: %s",
isc_result_totext (status));
status = dhcp_control_allocate (&dhcp_control_object, MDL);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't make initial control object: %s",
isc_result_totext (status));
dhcp_control_object -> state = server_startup;
status = omapi_object_type_register (&dhcp_type_group,
"group",
dhcp_group_set_value,
dhcp_group_get_value,
dhcp_group_destroy,
dhcp_group_signal_handler,
dhcp_group_stuff_values,
dhcp_group_lookup,
dhcp_group_create,
dhcp_group_remove, 0, 0, 0,
sizeof (struct group_object), 0,
RC_MISC);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register group object type: %s",
isc_result_totext (status));
status = omapi_object_type_register (&dhcp_type_subnet,
"subnet",
dhcp_subnet_set_value,
dhcp_subnet_get_value,
dhcp_subnet_destroy,
dhcp_subnet_signal_handler,
dhcp_subnet_stuff_values,
dhcp_subnet_lookup,
dhcp_subnet_create,
dhcp_subnet_remove, 0, 0, 0,
sizeof (struct subnet), 0,
RC_MISC);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register subnet object type: %s",
isc_result_totext (status));
status = omapi_object_type_register
(&dhcp_type_shared_network,
"shared-network",
dhcp_shared_network_set_value,
dhcp_shared_network_get_value,
dhcp_shared_network_destroy,
dhcp_shared_network_signal_handler,
dhcp_shared_network_stuff_values,
dhcp_shared_network_lookup,
dhcp_shared_network_create,
dhcp_shared_network_remove, 0, 0, 0,
sizeof (struct shared_network), 0, RC_MISC);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register shared network object type: %s",
isc_result_totext (status));
interface_setup ();
}
isc_result_t dhcp_group_set_value (omapi_object_t *h,
omapi_object_t *id,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
struct group_object *group;
isc_result_t status;
if (h -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)h;
/* XXX For now, we can only set these values on new group objects.
XXX Soon, we need to be able to update group objects. */
if (!omapi_ds_strcmp (name, "name")) {
if (group -> name)
return ISC_R_EXISTS;
if (value -> type == omapi_datatype_data ||
value -> type == omapi_datatype_string) {
group -> name = dmalloc (value -> u.buffer.len + 1,
MDL);
if (!group -> name)
return ISC_R_NOMEMORY;
memcpy (group -> name,
value -> u.buffer.value,
value -> u.buffer.len);
group -> name [value -> u.buffer.len] = 0;
} else
return DHCP_R_INVALIDARG;
return ISC_R_SUCCESS;
}
if (!omapi_ds_strcmp (name, "statements")) {
if (group -> group && group -> group -> statements)
return ISC_R_EXISTS;
if (!group -> group) {
if (!clone_group (&group -> group, root_group, MDL))
return ISC_R_NOMEMORY;
}
if (value -> type == omapi_datatype_data ||
value -> type == omapi_datatype_string) {
struct parse *parse;
int lose = 0;
parse = NULL;
status = new_parse(&parse, -1,
(char *) value->u.buffer.value,
value->u.buffer.len,
"network client", 0);
if (status != ISC_R_SUCCESS || parse == NULL)
return status;
if (!(parse_executable_statements
(&group -> group -> statements, parse, &lose,
context_any))) {
end_parse (&parse);
return DHCP_R_BADPARSE;
}
end_parse (&parse);
return ISC_R_SUCCESS;
} else
return DHCP_R_INVALIDARG;
}
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> set_value) {
status = ((*(h -> inner -> type -> set_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
struct group_object *group;
isc_result_t status;
if (h -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)h;
if (!omapi_ds_strcmp (name, "name"))
return omapi_make_string_value (value,
name, group -> name, MDL);
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> get_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
{
struct group_object *group, *t;
if (h -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)h;
if (group -> name) {
if (group_name_hash) {
t = (struct group_object *)0;
if (group_hash_lookup (&t, group_name_hash,
group -> name,
strlen (group -> name), MDL)) {
group_hash_delete (group_name_hash,
group -> name,
strlen (group -> name),
MDL);
group_object_dereference (&t, MDL);
}
}
dfree (group -> name, file, line);
group -> name = (char *)0;
}
if (group -> group)
group_dereference (&group -> group, MDL);
return ISC_R_SUCCESS;
}
isc_result_t dhcp_group_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
struct group_object *group;
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)h;
if (!strcmp (name, "updated")) {
/* A group object isn't valid if a subgroup hasn't yet been
associated with it. */
if (!group -> group)
return DHCP_R_INVALIDARG;
/* Group objects always have to have names. */
if (!group -> name) {
char hnbuf [64];
sprintf (hnbuf, "ng%08lx%08lx",
(unsigned long)cur_time,
(unsigned long)group);
group -> name = dmalloc (strlen (hnbuf) + 1, MDL);
if (!group -> name)
return ISC_R_NOMEMORY;
strcpy (group -> name, hnbuf);
}
supersede_group (group, 1);
updatep = 1;
}
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> signal_handler))
(h -> inner, name, ap));
if (status == ISC_R_SUCCESS)
return status;
}
if (updatep)
return ISC_R_SUCCESS;
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_group_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
struct group_object *group;
isc_result_t status;
if (h -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)h;
/* Write out all the values. */
if (group -> name) {
status = omapi_connection_put_name (c, "name");
if (status != ISC_R_SUCCESS)
return status;
status = omapi_connection_put_string (c, group -> name);
if (status != ISC_R_SUCCESS)
return status;
}
/* Write out the inner object, if any. */
if (h -> inner && h -> inner -> type -> stuff_values) {
status = ((*(h -> inner -> type -> stuff_values))
(c, id, h -> inner));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_SUCCESS;
}
isc_result_t dhcp_group_lookup (omapi_object_t **lp,
omapi_object_t *id, omapi_object_t *ref)
{
omapi_value_t *tv = (omapi_value_t *)0;
isc_result_t status;
struct group_object *group;
if (!ref)
return DHCP_R_NOKEYS;
/* First see if we were sent a handle. */
status = omapi_get_value_str (ref, id, "handle", &tv);
if (status == ISC_R_SUCCESS) {
status = omapi_handle_td_lookup (lp, tv -> value);
omapi_value_dereference (&tv, MDL);
if (status != ISC_R_SUCCESS)
return status;
/* Don't return the object if the type is wrong. */
if ((*lp) -> type != dhcp_type_group) {
omapi_object_dereference (lp, MDL);
return DHCP_R_INVALIDARG;
}
}
/* Now look for a name. */
status = omapi_get_value_str (ref, id, "name", &tv);
if (status == ISC_R_SUCCESS) {
group = (struct group_object *)0;
if (group_name_hash &&
group_hash_lookup (&group, group_name_hash,
(const char *)
tv -> value -> u.buffer.value,
tv -> value -> u.buffer.len, MDL)) {
omapi_value_dereference (&tv, MDL);
if (*lp && *lp != (omapi_object_t *)group) {
group_object_dereference (&group, MDL);
omapi_object_dereference (lp, MDL);
return DHCP_R_KEYCONFLICT;
} else if (!*lp) {
/* XXX fix so that hash lookup itself creates
XXX the reference. */
omapi_object_reference (lp,
(omapi_object_t *)group,
MDL);
group_object_dereference (&group, MDL);
}
} else if (!*lp)
return ISC_R_NOTFOUND;
}
/* If we get to here without finding a group, no valid key was
specified. */
if (!*lp)
return DHCP_R_NOKEYS;
if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
omapi_object_dereference (lp, MDL);
return ISC_R_NOTFOUND;
}
return ISC_R_SUCCESS;
}
isc_result_t dhcp_group_create (omapi_object_t **lp,
omapi_object_t *id)
{
struct group_object *group;
isc_result_t status;
group = (struct group_object *)0;
status = group_object_allocate (&group, MDL);
if (status != ISC_R_SUCCESS)
return status;
group -> flags = GROUP_OBJECT_DYNAMIC;
status = omapi_object_reference (lp, (omapi_object_t *)group, MDL);
group_object_dereference (&group, MDL);
return status;
}
isc_result_t dhcp_group_remove (omapi_object_t *lp,
omapi_object_t *id)
{
struct group_object *group;
isc_result_t status;
if (lp -> type != dhcp_type_group)
return DHCP_R_INVALIDARG;
group = (struct group_object *)lp;
group -> flags |= GROUP_OBJECT_DELETED;
if (group_write_hook) {
if (!(*group_write_hook) (group))
return ISC_R_IOERROR;
}
status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
return status;
}
isc_result_t dhcp_control_set_value (omapi_object_t *h,
omapi_object_t *id,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
dhcp_control_object_t *control;
isc_result_t status;
unsigned long newstate;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
control = (dhcp_control_object_t *)h;
if (!omapi_ds_strcmp (name, "state")) {
status = omapi_get_int_value (&newstate, value);
if (status != ISC_R_SUCCESS)
return status;
status = dhcp_set_control_state (control -> state, newstate);
if (status == ISC_R_SUCCESS)
control -> state = value -> u.integer;
return status;
}
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> set_value) {
status = ((*(h -> inner -> type -> set_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
dhcp_control_object_t *control;
isc_result_t status;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
control = (dhcp_control_object_t *)h;
if (!omapi_ds_strcmp (name, "state"))
return omapi_make_int_value (value,
name, (int)control -> state, MDL);
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> get_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_control_destroy (omapi_object_t *h,
const char *file, int line)
{
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
/* Can't destroy the control object. */
return ISC_R_NOPERM;
}
isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
/* In this function h should be a (dhcp_control_object_t *) */
isc_result_t status;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> signal_handler))
(h -> inner, name, ap));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_control_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
dhcp_control_object_t *control;
isc_result_t status;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
control = (dhcp_control_object_t *)h;
/* Write out all the values. */
status = omapi_connection_put_name (c, "state");
if (status != ISC_R_SUCCESS)
return status;
status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
if (status != ISC_R_SUCCESS)
return status;
status = omapi_connection_put_uint32 (c, control -> state);
if (status != ISC_R_SUCCESS)
return status;
/* Write out the inner object, if any. */
if (h -> inner && h -> inner -> type -> stuff_values) {
status = ((*(h -> inner -> type -> stuff_values))
(c, id, h -> inner));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_SUCCESS;
}
isc_result_t dhcp_control_lookup (omapi_object_t **lp,
omapi_object_t *id, omapi_object_t *ref)
{
omapi_value_t *tv = (omapi_value_t *)0;
isc_result_t status;
/* First see if we were sent a handle. */
if (ref) {
status = omapi_get_value_str (ref, id, "handle", &tv);
if (status == ISC_R_SUCCESS) {
status = omapi_handle_td_lookup (lp, tv -> value);
omapi_value_dereference (&tv, MDL);
if (status != ISC_R_SUCCESS)
return status;
/* Don't return the object if the type is wrong. */
if ((*lp) -> type != dhcp_type_control) {
omapi_object_dereference (lp, MDL);
return DHCP_R_INVALIDARG;
}
}
}
/* Otherwise, stop playing coy - there's only one control object,
so we can just return it. */
dhcp_control_reference ((dhcp_control_object_t **)lp,
dhcp_control_object, MDL);
return ISC_R_SUCCESS;
}
isc_result_t dhcp_control_create (omapi_object_t **lp,
omapi_object_t *id)
{
/* Can't create a control object - there can be only one. */
return ISC_R_NOPERM;
}
isc_result_t dhcp_control_remove (omapi_object_t *lp,
omapi_object_t *id)
{
/* Form is emptiness; emptiness form. The control object
cannot go out of existance. */
return ISC_R_NOPERM;
}
isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
omapi_object_t *id,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
/* In this function h should be a (struct subnet *) */
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
/* No values to set yet. */
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> set_value) {
status = ((*(h -> inner -> type -> set_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
/* In this function h should be a (struct subnet *) */
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
/* No values to get yet. */
/* Try to find some inner object that can provide the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> get_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
{
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct subnet *subnet;
#endif
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
subnet = (struct subnet *)h;
if (subnet -> next_subnet)
subnet_dereference (&subnet -> next_subnet, file, line);
if (subnet -> next_sibling)
subnet_dereference (&subnet -> next_sibling, file, line);
if (subnet -> shared_network)
shared_network_dereference (&subnet -> shared_network,
file, line);
if (subnet -> interface)
interface_dereference (&subnet -> interface, file, line);
if (subnet -> group)
group_dereference (&subnet -> group, file, line);
#endif
return ISC_R_SUCCESS;
}
isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
/* In this function h should be a (struct subnet *) */
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
/* Can't write subnets yet. */
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> signal_handler))
(h -> inner, name, ap));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
/* In this function h should be a (struct subnet *) */
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
/* Can't stuff subnet values yet. */
/* Write out the inner object, if any. */
if (h -> inner && h -> inner -> type -> stuff_values) {
status = ((*(h -> inner -> type -> stuff_values))
(c, id, h -> inner));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_SUCCESS;
}
isc_result_t dhcp_subnet_lookup (omapi_object_t **lp,
omapi_object_t *id,
omapi_object_t *ref)
{
/* Can't look up subnets yet. */
/* If we get to here without finding a subnet, no valid key was
specified. */
if (!*lp)
return DHCP_R_NOKEYS;
return ISC_R_SUCCESS;
}
isc_result_t dhcp_subnet_create (omapi_object_t **lp,
omapi_object_t *id)
{
return ISC_R_NOTIMPLEMENTED;
}
isc_result_t dhcp_subnet_remove (omapi_object_t *lp,
omapi_object_t *id)
{
return ISC_R_NOTIMPLEMENTED;
}
isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
omapi_object_t *id,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
/* In this function h should be a (struct shared_network *) */
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
/* No values to set yet. */
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> set_value) {
status = ((*(h -> inner -> type -> set_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
/* In this function h should be a (struct shared_network *) */
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
/* No values to get yet. */
/* Try to find some inner object that can provide the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> get_value))
(h -> inner, id, name, value));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
const char *file, int line)
{
/* In this function h should be a (struct shared_network *) */
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct shared_network *shared_network;
#endif
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
shared_network = (struct shared_network *)h;
if (shared_network -> next)
shared_network_dereference (&shared_network -> next,
file, line);
if (shared_network -> name) {
dfree (shared_network -> name, file, line);
shared_network -> name = 0;
}
if (shared_network -> subnets)
subnet_dereference (&shared_network -> subnets, file, line);
if (shared_network -> interface)
interface_dereference (&shared_network -> interface,
file, line);
if (shared_network -> pools)
omapi_object_dereference ((omapi_object_t **)
&shared_network -> pools, file, line);
if (shared_network -> group)
group_dereference (&shared_network -> group, file, line);
#if defined (FAILOVER_PROTOCOL)
if (shared_network -> failover_peer)
omapi_object_dereference ((omapi_object_t **)
&shared_network -> failover_peer,
file, line);
#endif
#endif /* DEBUG_MEMORY_LEAKAGE */
return ISC_R_SUCCESS;
}
isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
const char *name,
va_list ap)
{
/* In this function h should be a (struct shared_network *) */
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
/* Can't write shared_networks yet. */
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
status = ((*(h -> inner -> type -> signal_handler))
(h -> inner, name, ap));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_NOTFOUND;
}
isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
/* In this function h should be a (struct shared_network *) */
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
/* Can't stuff shared_network values yet. */
/* Write out the inner object, if any. */
if (h -> inner && h -> inner -> type -> stuff_values) {
status = ((*(h -> inner -> type -> stuff_values))
(c, id, h -> inner));
if (status == ISC_R_SUCCESS)
return status;
}
return ISC_R_SUCCESS;
}
isc_result_t dhcp_shared_network_lookup (omapi_object_t **lp,
omapi_object_t *id,
omapi_object_t *ref)
{
/* Can't look up shared_networks yet. */
/* If we get to here without finding a shared_network, no valid key was
specified. */
if (!*lp)
return DHCP_R_NOKEYS;
return ISC_R_SUCCESS;
}
isc_result_t dhcp_shared_network_create (omapi_object_t **lp,
omapi_object_t *id)
{
return ISC_R_NOTIMPLEMENTED;
}
isc_result_t dhcp_shared_network_remove (omapi_object_t *lp,
omapi_object_t *id)
{
return ISC_R_NOTIMPLEMENTED;
}

1534
external/bsd/dhcp/dist/common/conflex.c vendored Normal file

File diff suppressed because it is too large Load Diff

295
external/bsd/dhcp/dist/common/ctrace.c vendored Normal file
View File

@@ -0,0 +1,295 @@
/* $NetBSD: ctrace.c,v 1.1.1.2 2014/07/12 11:57:40 spz Exp $ */
/* trace.c
Subroutines that support dhcp tracing... */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2001-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: ctrace.c,v 1.1.1.2 2014/07/12 11:57:40 spz Exp $");
#include "dhcpd.h"
#if defined (TRACING)
void trace_interface_register (trace_type_t *ttype, struct interface_info *ip)
{
trace_interface_packet_t tipkt;
if (trace_record ()) {
memset (&tipkt, 0, sizeof tipkt);
memcpy (&tipkt.hw_address,
&ip -> hw_address, sizeof ip -> hw_address);
if (ip->address_count)
memcpy(&tipkt.primary_address,
ip->addresses, sizeof(*ip->addresses));
memcpy (tipkt.name, ip -> name, sizeof ip -> name);
tipkt.index = htonl (ip -> index);
trace_write_packet (ttype, sizeof tipkt, (char *)&tipkt, MDL);
}
}
void trace_interface_input (trace_type_t *ttype, unsigned len, char *buf)
{
trace_interface_packet_t *tipkt;
struct interface_info *ip;
struct sockaddr_in *sin;
struct iaddr addr;
isc_result_t status;
if (len != sizeof *tipkt) {
log_error ("trace interface packet size mismatch: %ld != %d",
(long)(sizeof *tipkt), len);
return;
}
tipkt = (trace_interface_packet_t *)buf;
ip = (struct interface_info *)0;
status = interface_allocate (&ip, MDL);
if (status != ISC_R_SUCCESS) {
foo:
log_error ("trace_interface_input: %s.",
isc_result_totext (status));
return;
}
ip -> ifp = dmalloc (sizeof *(ip -> ifp), MDL);
if (!ip -> ifp) {
interface_dereference (&ip, MDL);
status = ISC_R_NOMEMORY;
goto foo;
}
memcpy (&ip -> hw_address, &tipkt -> hw_address,
sizeof ip -> hw_address);
/* XXX: Without the full addresses state it's not quite a full
* trace.
*/
ip->address_count = ip->address_max = 1;
ip->addresses = dmalloc(sizeof(*ip->addresses), MDL);
memcpy(ip->addresses, &tipkt->primary_address, sizeof(*ip->addresses));
memcpy (ip -> name, tipkt -> name, sizeof ip -> name);
ip -> index = ntohl (tipkt -> index);
interface_snorf (ip, 0);
if (dhcp_interface_discovery_hook)
(*dhcp_interface_discovery_hook) (ip);
/* Fake up an ifp. */
memcpy (ip -> ifp -> ifr_name, ip -> name, sizeof ip -> name);
#ifdef HAVE_SA_LEN
ip -> ifp -> ifr_addr.sa_len = sizeof (struct sockaddr_in);
#endif
sin = (struct sockaddr_in *)&ip -> ifp -> ifr_addr;
sin->sin_addr = ip->addresses[0];
addr.len = 4;
memcpy (addr.iabuf, &sin -> sin_addr.s_addr, addr.len);
if (dhcp_interface_setup_hook)
(*dhcp_interface_setup_hook) (ip, &addr);
interface_stash (ip);
if (!quiet_interface_discovery) {
log_info ("Listening on Trace/%s/%s%s%s",
ip -> name,
print_hw_addr (ip -> hw_address.hbuf [0],
ip -> hw_address.hlen - 1,
&ip -> hw_address.hbuf [1]),
(ip -> shared_network ? "/" : ""),
(ip -> shared_network ?
ip -> shared_network -> name : ""));
if (strcmp (ip -> name, "fallback")) {
log_info ("Sending on Trace/%s/%s%s%s",
ip -> name,
print_hw_addr (ip -> hw_address.hbuf [0],
ip -> hw_address.hlen - 1,
&ip -> hw_address.hbuf [1]),
(ip -> shared_network ? "/" : ""),
(ip -> shared_network ?
ip -> shared_network -> name : ""));
}
}
interface_dereference (&ip, MDL);
}
void trace_interface_stop (trace_type_t *ttype) {
/* XXX */
}
void trace_inpacket_stash (struct interface_info *interface,
struct dhcp_packet *packet,
unsigned len,
unsigned int from_port,
struct iaddr from,
struct hardware *hfrom)
{
trace_inpacket_t tip;
trace_iov_t iov [2];
if (!trace_record ())
return;
tip.from_port = from_port;
tip.from = from;
tip.from.len = htonl (tip.from.len);
if (hfrom) {
tip.hfrom = *hfrom;
tip.havehfrom = 1;
} else {
memset (&tip.hfrom, 0, sizeof tip.hfrom);
tip.havehfrom = 0;
}
tip.index = htonl (interface -> index);
iov [0].buf = (char *)&tip;
iov [0].len = sizeof tip;
iov [1].buf = (char *)packet;
iov [1].len = len;
trace_write_packet_iov (inpacket_trace, 2, iov, MDL);
}
void trace_inpacket_input (trace_type_t *ttype, unsigned len, char *buf)
{
trace_inpacket_t *tip;
int index;
if (len < sizeof *tip) {
log_error ("trace_input_packet: too short - %d", len);
return;
}
tip = (trace_inpacket_t *)buf;
index = ntohl (tip -> index);
tip -> from.len = ntohl (tip -> from.len);
if (index > interface_count ||
index < 0 ||
!interface_vector [index]) {
log_error ("trace_input_packet: unknown interface index %d",
index);
return;
}
if (!bootp_packet_handler) {
log_error ("trace_input_packet: no bootp packet handler.");
return;
}
(*bootp_packet_handler) (interface_vector [index],
(struct dhcp_packet *)(tip + 1),
len - sizeof *tip,
tip -> from_port,
tip -> from,
(tip -> havehfrom ?
&tip -> hfrom
: (struct hardware *)0));
}
void trace_inpacket_stop (trace_type_t *ttype) { }
ssize_t trace_packet_send (struct interface_info *interface,
struct packet *packet,
struct dhcp_packet *raw,
size_t len,
struct in_addr from,
struct sockaddr_in *to,
struct hardware *hto)
{
trace_outpacket_t tip;
trace_iov_t iov [2];
if (trace_record ()) {
if (hto) {
tip.hto = *hto;
tip.havehto = 1;
} else {
memset (&tip.hto, 0, sizeof tip.hto);
tip.havehto = 0;
}
tip.from.len = 4;
memcpy (tip.from.iabuf, &from, 4);
tip.to.len = 4;
memcpy (tip.to.iabuf, &to -> sin_addr, 4);
tip.to_port = to -> sin_port;
tip.index = htonl (interface -> index);
iov [0].buf = (char *)&tip;
iov [0].len = sizeof tip;
iov [1].buf = (char *)raw;
iov [1].len = len;
trace_write_packet_iov (outpacket_trace, 2, iov, MDL);
}
if (!trace_playback ()) {
return send_packet (interface, packet, raw, len,
from, to, hto);
}
return len;
}
void trace_outpacket_input (trace_type_t *ttype, unsigned len, char *buf)
{
trace_outpacket_t *tip;
int index;
if (len < sizeof *tip) {
log_error ("trace_input_packet: too short - %d", len);
return;
}
tip = (trace_outpacket_t *)buf;
index = ntohl (tip -> index);
if (index > interface_count ||
index < 0 ||
!interface_vector [index]) {
log_error ("trace_input_packet: unknown interface index %d",
index);
return;
}
/* XXX would be nice to somehow take notice of these. */
}
void trace_outpacket_stop (trace_type_t *ttype) { }
void trace_seed_stash (trace_type_t *ttype, unsigned seed)
{
u_int32_t outseed;
if (!trace_record ())
return;
outseed = htonl (seed);
trace_write_packet (ttype, sizeof outseed, (char *)&outseed, MDL);
return;
}
void trace_seed_input (trace_type_t *ttype, unsigned length, char *buf)
{
u_int32_t *seed;
if (length != sizeof seed) {
log_error ("trace_seed_input: wrong size (%d)", length);
}
seed = (u_int32_t *)buf;
srandom (ntohl (*seed));
}
void trace_seed_stop (trace_type_t *ttype) { }
#endif /* TRACING */

View File

@@ -0,0 +1,506 @@
.\" $NetBSD: dhcp-eval.5,v 1.1.1.3 2014/07/12 11:57:40 spz Exp $
.\"
.\" Id: dhcp-eval.5,v 1.33 2012/05/17 15:50:14 sar Exp
.\"
.\" Copyright (c) 2009-2012,2014 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" Internet Systems Consortium, Inc.
.\" 950 Charter Street
.\" Redwood City, CA 94063
.\" <info@isc.org>
.\" https://www.isc.org/
.\"
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
.TH dhcp-eval 5
.SH NAME
dhcp-eval - ISC DHCP conditional evaluation
.SH DESCRIPTION
The Internet Systems Consortium DHCP client and server both provide
the ability to perform conditional behavior depending on the contents
of packets they receive. The syntax for specifying this conditional
behaviour is documented here.
.SH REFERENCE: CONDITIONAL BEHAVIOUR
Conditional behaviour is specified using the if statement and the else
or elsif statements. A conditional statement can appear anywhere
that a regular statement (e.g., an option statement) can appear, and
can enclose one or more such statements. A typical conditional
statement in a server might be:
.PP
.nf
if option dhcp-user-class = "accounting" {
max-lease-time 17600;
option domain-name "accounting.example.org";
option domain-name-servers ns1.accounting.example.org,
ns2.accounting.example.org;
} elsif option dhcp-user-class = "sales" {
max-lease-time 17600;
option domain-name "sales.example.org";
option domain-name-servers ns1.sales.example.org,
ns2.sales.example.org;
} elsif option dhcp-user-class = "engineering" {
max-lease-time 17600;
option domain-name "engineering.example.org";
option domain-name-servers ns1.engineering.example.org,
ns2.engineering.example.org;
} else {
max-lease-time 600;
option domain-name "misc.example.org";
option domain-name-servers ns1.misc.example.org,
ns2.misc.example.org;
}
.fi
.PP
On the client side, an example of conditional evaluation might be:
.PP
.nf
# example.org filters DNS at its firewall, so we have to use their DNS
# servers when we connect to their network. If we are not at
# example.org, prefer our own DNS server.
if not option domain-name = "example.org" {
prepend domain-name-servers 127.0.0.1;
}
.fi
.PP
The
.B if
statement and the
.B elsif
continuation statement both take boolean expressions as their
arguments. That is, they take expressions that, when evaluated,
produce a boolean result. If the expression evaluates to true, then
the statements enclosed in braces following the
.B if
statement are executed, and all subsequent
.B elsif
and
.B else
clauses are skipped. Otherwise, each subsequent
.B elsif
clause's expression is checked, until an elsif clause is encountered
whose test evaluates to true. If such a clause is found, the
statements in braces following it are executed, and then any
subsequent
.B elsif
and
.B else
clauses are skipped. If all the
.B if
and
.B elsif
clauses are checked but none
of their expressions evaluate true, then if there is an
.B else
clause, the statements enclosed in braces following the
.B else
are evaluated. Boolean expressions that evaluate to null are
treated as false in conditionals.
.SH BOOLEAN EXPRESSIONS
The following is the current list of boolean expressions that are
supported by the DHCP distribution.
.PP
.I data-expression-1 \fB=\fR \fIdata-expression-2\fR
.RS 0.25i
.PP
The \fB=\fR operator compares the values of two data expressions,
returning true if they are the same, false if they are not. If
either the left-hand side or the right-hand side are null, the
result is also null.
.RE
.PP
.I data-expression-1 \fB~=\fR \fIdata-expression-2\fR
.I data-expression-1 \fB~~\fR \fIdata-expression-2\fR
.RS 0.25i
.PP
The \fB~=\fR and \fB~~\fR operators (not available on all systems) perform
extended regex(7) matching of the values of two data expressions, returning
true if \fIdata-expression-1\fR matches against the regular expression
evaluated by \fIdata-expression-2\fR, or false if it does not match or
encounters some error. If either the left-hand side or the right-hand side
are null or empty strings, the result is also false. The \fB~~\fR operator
differs from the \fB~=\fR operator in that it is case-insensitive.
.RE
.PP
.I boolean-expression-1 \fBand\fR \fIboolean-expression-2\fR
.PP
.RS 0.25i
The \fBand\fR operator evaluates to true if the boolean expression on
the left-hand side and the boolean expression on the right-hand side
both evaluate to true. Otherwise, it evaluates to false. If either
the expression on the left-hand side or the expression on the
right-hand side are null, the result is null.
.RE
.PP
.I boolean-expression-1 \fBor\fR \fIboolean-expression-2\fR
.PP
.RS 0.25i
The \fBor\fR operator evaluates to true if either the boolean
expression on the left-hand side or the boolean expression on the
right-hand side evaluate to true. Otherwise, it evaluates to false.
If either the expression on the left-hand side or the expression on
the right-hand side are null, the result is null.
.RE
.PP
.B not \fIboolean-expression
.PP
.RS 0.25i
The \fBnot\fR operator evaluates to true if \fIboolean-expression\fR
evaluates to false, and returns false if \fIboolean-expression\fR evaluates
to true. If \fIboolean-expression\fR evaluates to null, the result
is also null.
.RE
.PP
.B exists \fIoption-name\fR
.PP
.RS 0.25i
The \fBexists\fR expression returns true if the specified option
exists in the incoming DHCP packet being processed.
.RE
.B known
.PP
.RS 0.25i
The \fBknown\fR expression returns true if the client whose request is
currently being processed is known - that is, if there's a host
declaration for it.
.RE
.B static
.PP
.RS 0.25i
The \fBstatic\fR expression returns true if the lease assigned to the
client whose request is currently being processed is derived from a static
address assignment.
.RE
.SH DATA EXPRESSIONS
Several of the boolean expressions above depend on the results of
evaluating data expressions. A list of these expressions is provided
here.
.PP
.B substring (\fIdata-expr\fB, \fIoffset\fB, \fIlength\fB)\fR
.PP
.RS 0.25i
The \fBsubstring\fR operator evaluates the data expression and returns
the substring of the result of that evaluation that starts
\fIoffset\fR bytes from the beginning, continuing for \fIlength\fR
bytes. \fIOffset\fR and \fIlength\fR are both numeric expressions.
If \fIdata-expr\fR, \fIoffset\fR or \fIlength\fR evaluate to null,
then the result is also null. If \fIoffset\fR is greater than or
equal to the length of the evaluated data, then a zero-length data
string is returned. If \fIlength\fI is greater then the remaining
length of the evaluated data after \fIoffset\fR, then a data string
containing all data from \fIoffset\fR to the end of the evaluated data
is returned.
.RE
.PP
.B suffix (\fIdata-expr\fB, \fIlength\fB)\fR
.PP
.RS 0.25i
The \fBsuffix\fR operator evaluates \fIdata-expr\fR and returns the
last \fIlength\fR bytes of the result of that evaluation. \fILength\fR
is a numeric expression. If \fIdata-expr\fR or \fIlength\fR evaluate
to null, then the result is also null. If \fIsuffix\fR evaluates to a
number greater than the length of the evaluated data, then the
evaluated data is returned.
.RE
.PP
.B lcase (\fIdata-expr\fB)\fR
.PP
.RS 0.25i
The \fBlcase\fR function returns the result of evaluating
\fIdata-expr\fR converted to lower case. If \fIdata-expr\fR evaluates
to null, then the result is also null.
.RE
.PP
.B ucase (\fIdata-expr\fB)\fR
.PP
.RS 0.25i
The \fBucase\fR function returns the result of evaluating
\fIdata-expr\fR converted to upper case. If \fIdata-expr\fR evaluates
to null, then the result is also null.
.RE
.PP
.B option \fIoption-name\fR
.PP
.RS 0.25i
The \fBoption\fR operator returns the contents of the specified option in
the packet to which the server is responding.
.RE
.PP
.B config-option \fIoption-name\fR
.PP
.RS 0.25i
The \fBconfig-option\fR operator returns the value for the specified option
that the DHCP client or server has been configured to send.
.RE
.PP
.B gethostname()
.PP
.RS 0.25i
The \fBgethostname()\fR function returns a data string whose contents are a
character string, the results of calling gethostname() on the local
system with a size limit of 255 bytes (not including NULL terminator). This
can be used for example to configure dhclient to send the local hostname
without knowing the local hostname at the time dhclient.conf is written.
.RE
.PP
.B hardware
.PP
.RS 0.25i
The \fBhardware\fR operator returns a data string whose first element
is the type of network interface indicated in packet being considered,
and whose subsequent elements are client's link-layer address. If
there is no packet, or if the RFC2131 \fIhlen\fR field is invalid,
then the result is null. Hardware types include ethernet (1),
token-ring (6), and fddi (8). Hardware types are specified by the
IETF, and details on how the type numbers are defined can be found in
RFC2131 (in the ISC DHCP distribution, this is included in the doc/
subdirectory).
.RE
.PP
.B packet (\fIoffset\fB, \fIlength\fB)\fR
.PP
.RS 0.25i
The \fBpacket\fR operator returns the specified portion of the packet
being considered, or null in contexts where no packet is being
considered. \fIOffset\fR and \fIlength\fR are applied to the
contents packet as in the \fBsubstring\fR operator.
.RE
.PP
.I string
.PP
.RS 0.25i
A string, enclosed in quotes, may be specified as a data expression,
and returns the text between the quotes, encoded in ASCII. The
backslash ('\\') character is treated specially, as in C programming: '\\t'
means TAB, '\\r' means carriage return, '\\n' means newline, and '\\b' means
bell. Any octal value can be specified with '\\nnn', where nnn is any
positive octal number less than 0400. Any hexadecimal value can be
specified with '\\xnn', where nn is any positive hexadecimal number less
than or equal to 0xff.
.RE
.PP
.I colon-separated hexadecimal list
.PP
.RS 0.25i
A list of hexadecimal octet values, separated by colons, may be
specified as a data expression.
.RE
.PP
.B concat (\fIdata-expr1\fB, ..., \fIdata-exprN\fB)\fR
.RS 0.25i
The expressions are evaluated, and the results of each evaluation are
concatenated in the sequence that the subexpressions are listed. If
any subexpression evaluates to null, the result of the concatenation
is null.
.RE
.PP
.B reverse (\fInumeric-expr1\fB, \fIdata-expr2\fB)\fR
.RS 0.25i
The two expressions are evaluated, and then the result of evaluating
the data expression is reversed in place, using hunks of the size
specified in the numeric expression. For example, if the numeric
expression evaluates to four, and the data expression evaluates to
twelve bytes of data, then the reverse expression will evaluate to
twelve bytes of data, consisting of the last four bytes of the
input data, followed by the middle four bytes, followed by the first
four bytes.
.RE
.PP
.B leased-address
.RS 0.25i
In any context where the client whose request is being processed has
been assigned an IP address, this data expression returns that IP
address. In any context where the client whose request is being
processed has not been assigned an ip address, if this data expression
is found in executable statements executed on that client's behalf,
a log message indicating "there is no lease associated with this client"
is syslogged to the debug level (this is considered dhcpd.conf debugging
information).
.RE
.PP
.B binary-to-ascii (\fInumeric-expr1\fB, \fInumeric-expr2\fB,
.B \fIdata-expr1\fB,\fR \fIdata-expr2\fB)\fR
.RS 0.25i
Converts the result of evaluating data-expr2 into a text string
containing one number for each element of the result of evaluating
data-expr2. Each number is separated from the other by the result of
evaluating data-expr1. The result of evaluating numeric-expr1
specifies the base (2 through 16) into which the numbers should be
converted. The result of evaluating numeric-expr2 specifies the
width in bits of each number, which may be either 8, 16 or 32.
.PP
As an example of the preceding three types of expressions, to produce
the name of a PTR record for the IP address being assigned to a
client, one could write the following expression:
.RE
.PP
.nf
concat (binary-to-ascii (10, 8, ".",
reverse (1, leased-address)),
".in-addr.arpa.");
.fi
.RE
.PP
.B encode-int (\fInumeric-expr\fB, \fIwidth\fB)\fR
.RS 0.25i
Numeric-expr is evaluated and encoded as a data string of the
specified width, in network byte order (most significant byte first).
If the numeric expression evaluates to the null value, the result is
also null.
.RE
.PP
.B pick-first-value (\fIdata-expr1\fR [ ... \fIexpr\fRn ] \fB)\fR
.RS 0.25i
The pick-first-value function takes any number of data expressions as
its arguments. Each expression is evaluated, starting with the first
in the list, until an expression is found that does not evaluate to a
null value. That expression is returned, and none of the subsequent
expressions are evaluated. If all expressions evaluate to a null
value, the null value is returned.
.RE
.PP
.B host-decl-name
.RS 0.25i
The host-decl-name function returns the name of the host declaration
that matched the client whose request is currently being processed, if
any. If no host declaration matched, the result is the null value.
.RE
.SH NUMERIC EXPRESSIONS
Numeric expressions are expressions that evaluate to an integer. In
general, the maximum size of such an integer should not be assumed to
be representable in fewer than 32 bits, but the precision of such
integers may be more than 32 bits.
.PP
.B extract-int (\fIdata-expr\fB, \fIwidth\fB)\fR
.PP
.RS 0.25i
The \fBextract-int\fR operator extracts an integer value in network
byte order from the result of evaluating the specified data
expression. Width is the width in bits of the integer to extract.
Currently, the only supported widths are 8, 16 and 32. If the
evaluation of the data expression doesn't provide sufficient bits to
extract an integer of the specified size, the null value is returned.
.RE
.PP
.B lease-time
.PP
.RS 0.25i
The duration of the current lease - that is, the difference between
the current time and the time that the lease expires.
.RE
.PP
.I number
.PP
.RS 0.25i
Any number between zero and the maximum representable size may be
specified as a numeric expression.
.RE
.PP
.B client-state
.PP
.RS 0.25i
The current state of the client instance being processed. This is
only useful in DHCP client configuration files. Possible values are:
.TP 2
.I \(bu
Booting - DHCP client is in the INIT state, and does not yet have an
IP address. The next message transmitted will be a DHCPDISCOVER,
which will be broadcast.
.TP
.I \(bu
Reboot - DHCP client is in the INIT-REBOOT state. It has an IP
address, but is not yet using it. The next message to be transmitted
will be a DHCPREQUEST, which will be broadcast. If no response is
heard, the client will bind to its address and move to the BOUND state.
.TP
.I \(bu
Select - DHCP client is in the SELECTING state - it has received at
least one DHCPOFFER message, but is waiting to see if it may receive
other DHCPOFFER messages from other servers. No messages are sent in
the SELECTING state.
.TP
.I \(bu
Request - DHCP client is in the REQUESTING state - it has received at
least one DHCPOFFER message, and has chosen which one it will
request. The next message to be sent will be a DHCPREQUEST message,
which will be broadcast.
.TP
.I \(bu
Bound - DHCP client is in the BOUND state - it has an IP address. No
messages are transmitted in this state.
.TP
.I \(bu
Renew - DHCP client is in the RENEWING state - it has an IP address,
and is trying to contact the server to renew it. The next message to
be sent will be a DHCPREQUEST message, which will be unicast directly
to the server.
.TP
.I \(bu
Rebind - DHCP client is in the REBINDING state - it has an IP address,
and is trying to contact any server to renew it. The next message to
be sent will be a DHCPREQUEST, which will be broadcast.
.RE
.SH REFERENCE: ACTION EXPRESSIONS
.PP
.B log (\fIpriority\fB, \fIdata-expr\fB)\fR
.RS 0.25i
.PP
Logging statements may be used to send information to the standard logging
channels. A logging statement includes an optional priority (\fBfatal\fR,
\fBerror\fR, \fBinfo\fR, or \fBdebug\fR), and a data expression.
.PP
Logging statements take only a single data expression argument, so if you
want to output multiple data values, you will need to use the \fBconcat\fR
operator to concatenate them.
.RE
.PP
.B execute (\fIcommand-path\fB [, \fIdata-expr1\fB, ... \fIdata-exprN\fB]);\fR
.RS 0.25i
.PP
The \fBexecute\fR statement runs an external command. The first argument
is a string literal containing the name or path of the command to run.
The other arguments, if present, are either string literals or data-
expressions which evaluate to text strings, to be passed as command-line
arguments to the command.
.PP
\fBexecute\fR is synchronous; the program will block until the external
command being run has finished. Please note that lengthy program
execution (for example, in an "on commit" in dhcpd.conf) may result in
bad performance and timeouts. Only external applications with very short
execution times are suitable for use.
.PP
Passing user-supplied data to an external application might be dangerous.
Make sure the external application checks input buffers for validity.
Non-printable ASCII characters will be converted into dhcpd.conf language
octal escapes ("\\nnn"), make sure your external command handles them as
such.
.PP
It is possible to use the execute statement in any context, not only
on events. If you put it in a regular scope in the configuration file
you will execute that command every time a scope is evaluated.
.RE
.SH REFERENCE: DYNAMIC DNS UPDATES
.PP
See the dhcpd.conf and dhclient.conf man pages for more information
about DDNS.
.SH SEE ALSO
dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcp-options(5), dhcpd(8),
dhclient(8), RFC2132, RFC2131.
.SH AUTHOR
Information about Internet Systems Consortium can be found at
.B https://www.isc.org.

File diff suppressed because it is too large Load Diff

1863
external/bsd/dhcp/dist/common/discover.c vendored Normal file

File diff suppressed because it is too large Load Diff

439
external/bsd/dhcp/dist/common/dispatch.c vendored Normal file
View File

@@ -0,0 +1,439 @@
/* $NetBSD: dispatch.c,v 1.4 2014/07/12 12:09:37 spz Exp $ */
/* dispatch.c
Network input dispatcher... */
/*
* Copyright (c) 2004-2011,2013 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: dispatch.c,v 1.4 2014/07/12 12:09:37 spz Exp $");
#include "dhcpd.h"
#include <sys/time.h>
struct timeout *timeouts;
static struct timeout *free_timeouts;
void set_time(TIME t)
{
/* Do any outstanding timeouts. */
if (cur_tv . tv_sec != t) {
cur_tv . tv_sec = t;
cur_tv . tv_usec = 0;
process_outstanding_timeouts ((struct timeval *)0);
}
}
struct timeval *process_outstanding_timeouts (struct timeval *tvp)
{
/* Call any expired timeouts, and then if there's
still a timeout registered, time out the select
call then. */
another:
if (timeouts) {
struct timeout *t;
if ((timeouts -> when . tv_sec < cur_tv . tv_sec) ||
((timeouts -> when . tv_sec == cur_tv . tv_sec) &&
(timeouts -> when . tv_usec <= cur_tv . tv_usec))) {
t = timeouts;
timeouts = timeouts -> next;
(*(t -> func)) (t -> what);
if (t -> unref)
(*t -> unref) (&t -> what, MDL);
t -> next = free_timeouts;
free_timeouts = t;
goto another;
}
if (tvp) {
tvp -> tv_sec = timeouts -> when . tv_sec;
tvp -> tv_usec = timeouts -> when . tv_usec;
}
return tvp;
} else
return (struct timeval *)0;
}
/* Wait for packets to come in using select(). When one does, call
receive_packet to receive the packet and possibly strip hardware
addressing information from it, and then call through the
bootp_packet_handler hook to try to do something with it. */
/*
* Use the DHCP timeout list as a place to store DHCP specific
* information, but use the ISC timer system to actually dispatch
* the events.
*
* There are several things that the DHCP timer code does that the
* ISC code doesn't:
* 1) It allows for negative times
* 2) The cancel arguments are different. The DHCP code uses the
* function and data to find the proper timer to cancel while the
* ISC code uses a pointer to the timer.
* 3) The DHCP code includes provision for incrementing and decrementing
* a reference counter associated with the data.
* The first one is fairly easy to fix but will take some time to go throuh
* the callers and update them. The second is also not all that difficult
* in concept - add a pointer to the appropriate structures to hold a pointer
* to the timer and use that. The complications arise in trying to ensure
* that all of the corner cases are covered. The last one is potentially
* more painful and requires more investigation.
*
* The plan is continue with the older DHCP calls and timer list. The
* calls will continue to manipulate the list but will also pass a
* timer to the ISC timer code for the actual dispatch. Later, if desired,
* we can go back and modify the underlying calls to use the ISC
* timer functions directly without requiring all of the code to change
* at the same time.
*/
void
dispatch(void)
{
isc_result_t status;
do {
status = isc_app_ctxrun(dhcp_gbl_ctx.actx);
/*
* isc_app_ctxrun can be stopped by receiving a
* signal. It will return ISC_R_RELOAD in that
* case. That is a normal behavior.
*/
if (status == ISC_R_RELOAD) {
/*
* dhcp_set_control_state() will do the job.
* Note its first argument is ignored.
*/
status = dhcp_set_control_state(server_shutdown,
server_shutdown);
if (status == ISC_R_SUCCESS)
status = ISC_R_RELOAD;
}
} while (status == ISC_R_RELOAD);
log_fatal ("Dispatch routine failed: %s -- exiting",
isc_result_totext (status));
}
static void
isclib_timer_callback(isc_task_t *taskp,
isc_event_t *eventp)
{
struct timeout *t = (struct timeout *)eventp->ev_arg;
struct timeout *q, *r;
/* Get the current time... */
gettimeofday (&cur_tv, (struct timezone *)0);
/*
* Find the timeout on the dhcp list and remove it.
* As the list isn't ordered we search the entire list
*/
r = NULL;
for (q = timeouts; q; q = q->next) {
if (q == t) {
if (r)
r->next = q->next;
else
timeouts = q->next;
break;
}
r = q;
}
/*
* The timer should always be on the list. If it is we do
* the work and detach the timer block, if not we log an error.
* In both cases we attempt free the ISC event and continue
* processing.
*/
if (q != NULL) {
/* call the callback function */
(*(q->func)) (q->what);
if (q->unref) {
(*q->unref) (&q->what, MDL);
}
q->next = free_timeouts;
isc_timer_detach(&q->isc_timeout);
free_timeouts = q;
} else {
/*
* Hmm, we should clean up the timer structure but aren't
* sure about the pointer to the timer block we got so
* don't try to - may change this to a log_fatal
*/
log_error("Error finding timer structure");
}
isc_event_free(&eventp);
return;
}
/* maximum value for usec */
#define USEC_MAX 1000000
#define DHCP_SEC_MAX 0xFFFFFFFF
void add_timeout (when, where, what, ref, unref)
struct timeval *when;
void (*where) (void *);
void *what;
tvref_t ref;
tvunref_t unref;
{
struct timeout *t, *q;
int usereset = 0;
isc_result_t status;
int64_t sec;
int usec;
isc_interval_t interval;
isc_time_t expires;
/* See if this timeout supersedes an existing timeout. */
t = (struct timeout *)0;
for (q = timeouts; q; q = q->next) {
if ((where == NULL || q->func == where) &&
q->what == what) {
if (t)
t->next = q->next;
else
timeouts = q->next;
usereset = 1;
break;
}
t = q;
}
/* If we didn't supersede a timeout, allocate a timeout
structure now. */
if (!q) {
if (free_timeouts) {
q = free_timeouts;
free_timeouts = q->next;
} else {
q = ((struct timeout *)
dmalloc(sizeof(struct timeout), MDL));
if (!q) {
log_fatal("add_timeout: no memory!");
}
}
memset(q, 0, sizeof *q);
q->func = where;
q->ref = ref;
q->unref = unref;
if (q->ref)
(*q->ref)(&q->what, what, MDL);
else
q->what = what;
}
/*
* The value passed in is a time from an epoch but we need a relative
* time so we need to do some math to try and recover the period.
* This is complicated by the fact that not all of the calls cared
* about the usec value, if it's zero we assume the caller didn't care.
*
* The ISC timer library doesn't seem to like negative values
* and can't accept any values above 4G-1 seconds so we limit
* the values to 0 <= value < 4G-1. We do it before
* checking the trace option so that both the trace code and
* the working code use the same values.
*/
sec = when->tv_sec - cur_tv.tv_sec;
usec = when->tv_usec - cur_tv.tv_usec;
if ((when->tv_usec != 0) && (usec < 0)) {
sec--;
usec += USEC_MAX;
}
if (sec < 0) {
sec = 0;
usec = 0;
} else if (sec > DHCP_SEC_MAX) {
log_error("Timeout requested too large "
"reducing to 2^^32-1");
sec = DHCP_SEC_MAX;
usec = 0;
} else if (usec < 0) {
usec = 0;
} else if (usec >= USEC_MAX) {
usec = USEC_MAX - 1;
}
/*
* This is necessary for the tracing code but we put it
* here in case we want to compare timing information
* for some reason, like debugging.
*/
q->when.tv_sec = cur_tv.tv_sec + (sec & DHCP_SEC_MAX);
q->when.tv_usec = usec;
#if defined (TRACING)
if (trace_playback()) {
/*
* If we are doing playback we need to handle the timers
* within this code rather than having the isclib handle
* them for us. We need to keep the timer list in order
* to allow us to find the ones to timeout.
*
* By using a different timer setup in the playback we may
* have variations between the orginal and the playback but
* it's the best we can do for now.
*/
/* Beginning of list? */
if (!timeouts || (timeouts->when.tv_sec > q-> when.tv_sec) ||
((timeouts->when.tv_sec == q->when.tv_sec) &&
(timeouts->when.tv_usec > q->when.tv_usec))) {
q->next = timeouts;
timeouts = q;
return;
}
/* Middle of list? */
for (t = timeouts; t->next; t = t->next) {
if ((t->next->when.tv_sec > q->when.tv_sec) ||
((t->next->when.tv_sec == q->when.tv_sec) &&
(t->next->when.tv_usec > q->when.tv_usec))) {
q->next = t->next;
t->next = q;
return;
}
}
/* End of list. */
t->next = q;
q->next = (struct timeout *)0;
return;
}
#endif
/*
* Don't bother sorting the DHCP list, just add it to the front.
* Eventually the list should be removed as we migrate the callers
* to the native ISC timer functions, if it becomes a performance
* problem before then we may need to order the list.
*/
q->next = timeouts;
timeouts = q;
isc_interval_set(&interval, sec & DHCP_SEC_MAX, usec * 1000);
status = isc_time_nowplusinterval(&expires, &interval);
if (status != ISC_R_SUCCESS) {
/*
* The system time function isn't happy or returned
* a value larger than isc_time_t can hold.
*/
log_fatal("Unable to set up timer: %s",
isc_result_totext(status));
}
if (usereset == 0) {
status = isc_timer_create(dhcp_gbl_ctx.timermgr,
isc_timertype_once, &expires,
NULL, dhcp_gbl_ctx.task,
isclib_timer_callback,
(void *)q, &q->isc_timeout);
} else {
status = isc_timer_reset(q->isc_timeout,
isc_timertype_once, &expires,
NULL, 0);
}
/* If it fails log an error and die */
if (status != ISC_R_SUCCESS) {
log_fatal("Unable to add timeout to isclib\n");
}
return;
}
void cancel_timeout (where, what)
void (*where) (void *);
void *what;
{
struct timeout *t, *q;
/* Look for this timeout on the list, and unlink it if we find it. */
t = (struct timeout *)0;
for (q = timeouts; q; q = q -> next) {
if (q->func == where && q->what == what) {
if (t)
t->next = q->next;
else
timeouts = q->next;
break;
}
t = q;
}
/*
* If we found the timeout, cancel it and put it on the free list.
* The TRACING stuff is ugly but we don't add a timer when doing
* playback so we don't want to remove them then either.
*/
if (q) {
#if defined (TRACING)
if (!trace_playback()) {
#endif
isc_timer_detach(&q->isc_timeout);
#if defined (TRACING)
}
#endif
if (q->unref)
(*q->unref) (&q->what, MDL);
q->next = free_timeouts;
free_timeouts = q;
}
}
#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
void cancel_all_timeouts ()
{
struct timeout *t, *n;
for (t = timeouts; t; t = n) {
n = t->next;
isc_timer_detach(&t->isc_timeout);
if (t->unref && t->what)
(*t->unref) (&t->what, MDL);
t->next = free_timeouts;
free_timeouts = t;
}
}
void relinquish_timeouts ()
{
struct timeout *t, *n;
for (t = free_timeouts; t; t = n) {
n = t->next;
dfree(t, MDL);
}
}
#endif

1418
external/bsd/dhcp/dist/common/dlpi.c vendored Normal file

File diff suppressed because it is too large Load Diff

2589
external/bsd/dhcp/dist/common/dns.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,91 @@
/* $NetBSD: ethernet.c,v 1.1.1.2 2014/07/12 11:57:43 spz Exp $ */
/* ethernet.c
Packet assembly code, originally contributed by Archie Cobbs. */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: ethernet.c,v 1.1.1.2 2014/07/12 11:57:43 spz Exp $");
#include "dhcpd.h"
#if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
#include "includes/netinet/if_ether.h"
#endif /* PACKET_ASSEMBLY || PACKET_DECODING */
#if defined (PACKET_ASSEMBLY)
/* Assemble an hardware header... */
void assemble_ethernet_header (interface, buf, bufix, to)
struct interface_info *interface;
unsigned char *buf;
unsigned *bufix;
struct hardware *to;
{
struct isc_ether_header eh;
if (to && to -> hlen == 7) /* XXX */
memcpy (eh.ether_dhost, &to -> hbuf [1],
sizeof eh.ether_dhost);
else
memset (eh.ether_dhost, 0xff, sizeof (eh.ether_dhost));
if (interface -> hw_address.hlen - 1 == sizeof (eh.ether_shost))
memcpy (eh.ether_shost, &interface -> hw_address.hbuf [1],
sizeof (eh.ether_shost));
else
memset (eh.ether_shost, 0x00, sizeof (eh.ether_shost));
eh.ether_type = htons (ETHERTYPE_IP);
memcpy (&buf [*bufix], &eh, ETHER_HEADER_SIZE);
*bufix += ETHER_HEADER_SIZE;
}
#endif /* PACKET_ASSEMBLY */
#ifdef PACKET_DECODING
/* Decode a hardware header... */
ssize_t decode_ethernet_header (interface, buf, bufix, from)
struct interface_info *interface;
unsigned char *buf;
unsigned bufix;
struct hardware *from;
{
struct isc_ether_header eh;
memcpy (&eh, buf + bufix, ETHER_HEADER_SIZE);
#ifdef USERLAND_FILTER
if (ntohs (eh.ether_type) != ETHERTYPE_IP)
return -1;
#endif
memcpy (&from -> hbuf [1], eh.ether_shost, sizeof (eh.ether_shost));
from -> hbuf [0] = ARPHRD_ETHER;
from -> hlen = (sizeof eh.ether_shost) + 1;
return ETHER_HEADER_SIZE;
}
#endif /* PACKET_DECODING */

1173
external/bsd/dhcp/dist/common/execute.c vendored Normal file

File diff suppressed because it is too large Load Diff

90
external/bsd/dhcp/dist/common/fddi.c vendored Normal file
View File

@@ -0,0 +1,90 @@
/* $NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $ */
/* fddi.c
Packet assembly code, originally contributed by Archie Cobbs. */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $");
#include "dhcpd.h"
#if defined (DEC_FDDI)
#include <netinet/if_fddi.h>
#include <net/if_llc.h>
#if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
#include "includes/netinet/if_ether.h"
#endif /* PACKET_ASSEMBLY || PACKET_DECODING */
#if defined (PACKET_ASSEMBLY)
/* Assemble an hardware header... */
void assemble_fddi_header (interface, buf, bufix, to)
struct interface_info *interface;
unsigned char *buf;
unsigned *bufix;
struct hardware *to;
{
struct fddi_header fh;
struct llc lh;
if (to && to -> hlen == 7)
memcpy (fh.fddi_dhost, &to -> hbuf [1],
sizeof (fh.fddi_dhost));
memcpy (fh.fddi_shost,
&interface -> hw_address.hbuf [1], sizeof (fh.fddi_shost));
fh.fddi_fc = FDDIFC_LLC_ASYNC;
memcpy (&buf [*bufix], &fh, sizeof fh);
*bufix += sizeof fh;
lh.llc_dsap = LLC_SNAP_LSAP;
lh.llc_ssap = LLC_SNAP_LSAP;
lh.llc_un.type_snap.control = LLC_UI;
lh.llc_un.type_snap.ether_type = htons (ETHERTYPE_IP);
memcpy (&buf [*bufix], &lh, LLC_SNAP_LEN);
*bufix += LLC_SNAP_LEN;
}
#endif /* PACKET_ASSEMBLY */
#ifdef PACKET_DECODING
/* Decode a hardware header... */
ssize_t decode_fddi_header (interface, buf, bufix, from)
struct interface_info *interface;
unsigned char *buf;
unsigned bufix;
struct hardware *from;
{
struct fddi_header fh;
struct llc lh;
from -> hbuf [0] = HTYPE_FDDI;
memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost);
return FDDI_HEADER_SIZE + LLC_SNAP_LEN;
}
#endif /* PACKET_DECODING */
#endif /* DEC_FDDI */

304
external/bsd/dhcp/dist/common/icmp.c vendored Normal file
View File

@@ -0,0 +1,304 @@
/* $NetBSD: icmp.c,v 1.3 2014/07/12 12:09:37 spz Exp $ */
/* dhcp.c
ICMP Protocol engine - for sending out pings and receiving
responses. */
/*
* Copyright (c) 2011,2013,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: icmp.c,v 1.3 2014/07/12 12:09:37 spz Exp $");
#include "dhcpd.h"
#include "netinet/ip.h"
#include "netinet/ip_icmp.h"
struct icmp_state *icmp_state;
static omapi_object_type_t *dhcp_type_icmp;
static int no_icmp;
OMAPI_OBJECT_ALLOC (icmp_state, struct icmp_state, dhcp_type_icmp)
#if defined (TRACING)
trace_type_t *trace_icmp_input;
trace_type_t *trace_icmp_output;
#endif
/* Initialize the ICMP protocol. */
void icmp_startup (routep, handler)
int routep;
void (*handler) (struct iaddr, u_int8_t *, int);
{
struct protoent *proto;
int protocol = 1;
int state;
isc_result_t result;
/* Only initialize icmp once. */
if (dhcp_type_icmp)
log_fatal ("attempted to reinitialize icmp protocol");
result = omapi_object_type_register (&dhcp_type_icmp, "icmp",
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (struct icmp_state),
0, RC_MISC);
if (result != ISC_R_SUCCESS)
log_fatal ("Can't register icmp object type: %s",
isc_result_totext (result));
icmp_state_allocate (&icmp_state, MDL);
icmp_state -> icmp_handler = handler;
#if defined (TRACING)
trace_icmp_input = trace_type_register ("icmp-input", (void *)0,
trace_icmp_input_input,
trace_icmp_input_stop, MDL);
trace_icmp_output = trace_type_register ("icmp-output", (void *)0,
trace_icmp_output_input,
trace_icmp_output_stop, MDL);
/* If we're playing back a trace file, don't create the socket
or set up the callback. */
if (!trace_playback ()) {
#endif
/* Get the protocol number (should be 1). */
proto = getprotobyname ("icmp");
if (proto)
protocol = proto -> p_proto;
/* Get a raw socket for the ICMP protocol. */
icmp_state -> socket = socket (AF_INET, SOCK_RAW, protocol);
if (icmp_state -> socket < 0) {
no_icmp = 1;
log_error ("unable to create icmp socket: %m");
return;
}
#if defined (HAVE_SETFD)
if (fcntl (icmp_state -> socket, F_SETFD, 1) < 0)
log_error ("Can't set close-on-exec on icmp: %m");
#endif
/* Make sure it does routing... */
state = 0;
if (setsockopt (icmp_state -> socket, SOL_SOCKET, SO_DONTROUTE,
(char *)&state, sizeof state) < 0)
log_fatal ("Can't disable SO_DONTROUTE on ICMP: %m");
result = (omapi_register_io_object
((omapi_object_t *)icmp_state,
icmp_readsocket, 0, icmp_echoreply, 0, 0));
if (result != ISC_R_SUCCESS)
log_fatal ("Can't register icmp handle: %s",
isc_result_totext (result));
#if defined (TRACING)
}
#endif
}
int icmp_readsocket (h)
omapi_object_t *h;
{
struct icmp_state *state;
state = (struct icmp_state *)h;
return state -> socket;
}
int icmp_echorequest (addr)
struct iaddr *addr;
{
struct sockaddr_in to;
struct icmp icmp;
int status;
#if defined (TRACING)
trace_iov_t iov [2];
#endif
if (no_icmp)
return 1;
if (!icmp_state)
log_fatal ("ICMP protocol used before initialization.");
memset (&to, 0, sizeof(to));
#ifdef HAVE_SA_LEN
to.sin_len = sizeof to;
#endif
to.sin_family = AF_INET;
to.sin_port = 0; /* unused. */
memcpy (&to.sin_addr, addr -> iabuf, sizeof to.sin_addr); /* XXX */
icmp.icmp_type = ICMP_ECHO;
icmp.icmp_code = 0;
icmp.icmp_cksum = 0;
icmp.icmp_seq = 0;
#ifdef _LP64
icmp.icmp_id = (((u_int32_t)(u_int64_t)addr) ^
(u_int32_t)(((u_int64_t)addr) >> 32));
#else
icmp.icmp_id = (u_int32_t)addr;
#endif
memset (&icmp.icmp_dun, 0, sizeof icmp.icmp_dun);
icmp.icmp_cksum = wrapsum (checksum ((unsigned char *)&icmp,
sizeof icmp, 0));
#if defined (TRACING)
if (trace_playback ()) {
char *buf = (char *)0;
unsigned buflen = 0;
/* Consume the ICMP event. */
status = trace_get_packet (&trace_icmp_output, &buflen, &buf);
if (status != ISC_R_SUCCESS)
log_error ("icmp_echorequest: %s",
isc_result_totext (status));
if (buf)
dfree (buf, MDL);
} else {
if (trace_record ()) {
iov [0].buf = (char *)addr;
iov [0].len = sizeof *addr;
iov [1].buf = (char *)&icmp;
iov [1].len = sizeof icmp;
trace_write_packet_iov (trace_icmp_output,
2, iov, MDL);
}
#endif
/* Send the ICMP packet... */
status = sendto (icmp_state -> socket,
(char *)&icmp, sizeof icmp, 0,
(struct sockaddr *)&to, sizeof to);
if (status < 0)
log_error ("icmp_echorequest %s: %m",
inet_ntoa(to.sin_addr));
if (status != sizeof icmp)
return 0;
#if defined (TRACING)
}
#endif
return 1;
}
isc_result_t icmp_echoreply (h)
omapi_object_t *h;
{
struct icmp *icfrom;
struct ip *ip;
struct sockaddr_in from;
u_int8_t icbuf [1500];
int status;
SOCKLEN_T sl;
int hlen, len;
struct iaddr ia;
struct icmp_state *state;
#if defined (TRACING)
trace_iov_t iov [2];
#endif
state = (struct icmp_state *)h;
sl = sizeof from;
status = recvfrom (state -> socket, (char *)icbuf, sizeof icbuf, 0,
(struct sockaddr *)&from, &sl);
if (status < 0) {
log_error ("icmp_echoreply: %m");
return ISC_R_UNEXPECTED;
}
/* Find the IP header length... */
ip = (struct ip *)icbuf;
hlen = IP_HL (ip);
/* Short packet? */
if (status < hlen + (sizeof *icfrom)) {
return ISC_R_SUCCESS;
}
len = status - hlen;
icfrom = (struct icmp *)(icbuf + hlen);
/* Silently discard ICMP packets that aren't echoreplies. */
if (icfrom -> icmp_type != ICMP_ECHOREPLY) {
return ISC_R_SUCCESS;
}
/* If we were given a second-stage handler, call it. */
if (state -> icmp_handler) {
memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr);
ia.len = sizeof from.sin_addr;
#if defined (TRACING)
if (trace_record ()) {
ia.len = htonl(ia.len);
iov [0].buf = (char *)&ia;
iov [0].len = sizeof ia;
iov [1].buf = (char *)icbuf;
iov [1].len = len;
trace_write_packet_iov (trace_icmp_input, 2, iov, MDL);
ia.len = ntohl(ia.len);
}
#endif
(*state -> icmp_handler) (ia, icbuf, len);
}
return ISC_R_SUCCESS;
}
#if defined (TRACING)
void trace_icmp_input_input (trace_type_t *ttype, unsigned length, char *buf)
{
struct iaddr *ia;
u_int8_t *icbuf;
ia = (struct iaddr *)buf;
ia->len = ntohl(ia->len);
icbuf = (u_int8_t *)(ia + 1);
if (icmp_state -> icmp_handler)
(*icmp_state -> icmp_handler) (*ia, icbuf,
(int)(length - sizeof ia));
}
void trace_icmp_input_stop (trace_type_t *ttype) { }
void trace_icmp_output_input (trace_type_t *ttype, unsigned length, char *buf)
{
struct iaddr ia;
if (length != (sizeof (struct icmp) + sizeof (ia))) {
log_error ("trace_icmp_output_input: data size mismatch %d:%d",
length, (int)(sizeof (struct icmp) + sizeof (ia)));
return;
}
ia.len = 4;
memcpy (ia.iabuf, buf, 4);
log_error ("trace_icmp_output_input: unsent ping to %s", piaddr (ia));
}
void trace_icmp_output_stop (trace_type_t *ttype) { }
#endif /* TRACING */

628
external/bsd/dhcp/dist/common/inet.c vendored Normal file
View File

@@ -0,0 +1,628 @@
/* $NetBSD: inet.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $ */
/* inet.c
Subroutines to manipulate internet addresses and ports in a safely portable
way... */
/*
* Copyright (c) 2011,2013,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2007-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2005 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: inet.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $");
#include "dhcpd.h"
/* Return just the network number of an internet address... */
struct iaddr subnet_number (addr, mask)
struct iaddr addr;
struct iaddr mask;
{
int i;
struct iaddr rv;
if (addr.len > sizeof(addr.iabuf))
log_fatal("subnet_number():%s:%d: Invalid addr length.", MDL);
if (addr.len != mask.len)
log_fatal("subnet_number():%s:%d: Addr/mask length mismatch.",
MDL);
rv.len = 0;
/* Both addresses must have the same length... */
if (addr.len != mask.len)
return rv;
rv.len = addr.len;
for (i = 0; i < rv.len; i++)
rv.iabuf [i] = addr.iabuf [i] & mask.iabuf [i];
return rv;
}
/* Combine a network number and a integer to produce an internet address.
This won't work for subnets with more than 32 bits of host address, but
maybe this isn't a problem. */
struct iaddr ip_addr (subnet, mask, host_address)
struct iaddr subnet;
struct iaddr mask;
u_int32_t host_address;
{
int i, j, k;
u_int32_t swaddr;
struct iaddr rv;
unsigned char habuf [sizeof swaddr];
if (subnet.len > sizeof(subnet.iabuf))
log_fatal("ip_addr():%s:%d: Invalid addr length.", MDL);
if (subnet.len != mask.len)
log_fatal("ip_addr():%s:%d: Addr/mask length mismatch.",
MDL);
swaddr = htonl (host_address);
memcpy (habuf, &swaddr, sizeof swaddr);
/* Combine the subnet address and the host address. If
the host address is bigger than can fit in the subnet,
return a zero-length iaddr structure. */
rv = subnet;
j = rv.len - sizeof habuf;
for (i = sizeof habuf - 1; i >= 0; i--) {
if (mask.iabuf [i + j]) {
if (habuf [i] > (mask.iabuf [i + j] ^ 0xFF)) {
rv.len = 0;
return rv;
}
for (k = i - 1; k >= 0; k--) {
if (habuf [k]) {
rv.len = 0;
return rv;
}
}
rv.iabuf [i + j] |= habuf [i];
break;
} else
rv.iabuf [i + j] = habuf [i];
}
return rv;
}
/* Given a subnet number and netmask, return the address on that subnet
for which the host portion of the address is all ones (the standard
broadcast address). */
struct iaddr broadcast_addr (subnet, mask)
struct iaddr subnet;
struct iaddr mask;
{
int i;
struct iaddr rv;
if (subnet.len > sizeof(subnet.iabuf))
log_fatal("broadcast_addr():%s:%d: Invalid addr length.", MDL);
if (subnet.len != mask.len)
log_fatal("broadcast_addr():%s:%d: Addr/mask length mismatch.",
MDL);
if (subnet.len != mask.len) {
rv.len = 0;
return rv;
}
for (i = 0; i < subnet.len; i++) {
rv.iabuf [i] = subnet.iabuf [i] | (~mask.iabuf [i] & 255);
}
rv.len = subnet.len;
return rv;
}
u_int32_t host_addr (addr, mask)
struct iaddr addr;
struct iaddr mask;
{
int i;
u_int32_t swaddr;
struct iaddr rv;
if (addr.len > sizeof(addr.iabuf))
log_fatal("host_addr():%s:%d: Invalid addr length.", MDL);
if (addr.len != mask.len)
log_fatal("host_addr():%s:%d: Addr/mask length mismatch.",
MDL);
rv.len = 0;
/* Mask out the network bits... */
rv.len = addr.len;
for (i = 0; i < rv.len; i++)
rv.iabuf [i] = addr.iabuf [i] & ~mask.iabuf [i];
/* Copy out up to 32 bits... */
memcpy (&swaddr, &rv.iabuf [rv.len - sizeof swaddr], sizeof swaddr);
/* Swap it and return it. */
return ntohl (swaddr);
}
int addr_eq (addr1, addr2)
struct iaddr addr1, addr2;
{
if (addr1.len > sizeof(addr1.iabuf))
log_fatal("addr_eq():%s:%d: Invalid addr length.", MDL);
if (addr1.len != addr2.len)
return 0;
return memcmp (addr1.iabuf, addr2.iabuf, addr1.len) == 0;
}
/* addr_match
*
* compares an IP address against a network/mask combination
* by ANDing the IP with the mask and seeing whether the result
* matches the masked network value.
*/
int
addr_match(addr, match)
struct iaddr *addr;
struct iaddrmatch *match;
{
int i;
if (addr->len != match->addr.len)
return 0;
for (i = 0 ; i < addr->len ; i++) {
if ((addr->iabuf[i] & match->mask.iabuf[i]) !=
match->addr.iabuf[i])
return 0;
}
return 1;
}
/*
* Compares the addresses a1 and a2.
*
* If a1 < a2, returns -1.
* If a1 == a2, returns 0.
* If a1 > a2, returns 1.
*
* WARNING: if a1 and a2 differ in length, returns 0.
*/
int
addr_cmp(const struct iaddr *a1, const struct iaddr *a2) {
int i;
if (a1->len != a2->len) {
return 0;
}
for (i=0; i<a1->len; i++) {
if (a1->iabuf[i] < a2->iabuf[i]) {
return -1;
}
if (a1->iabuf[i] > a2->iabuf[i]) {
return 1;
}
}
return 0;
}
/*
* Performs a bitwise-OR of two addresses.
*
* Returns 1 if the result is non-zero, or 0 otherwise.
*
* WARNING: if a1 and a2 differ in length, returns 0.
*/
int
addr_or(struct iaddr *result, const struct iaddr *a1, const struct iaddr *a2) {
int i;
int all_zero;
if (a1->len != a2->len) {
return 0;
}
all_zero = 1;
result->len = a1->len;
for (i=0; i<a1->len; i++) {
result->iabuf[i] = a1->iabuf[i] | a2->iabuf[i];
if (result->iabuf[i] != 0) {
all_zero = 0;
}
}
return !all_zero;
}
/*
* Performs a bitwise-AND of two addresses.
*
* Returns 1 if the result is non-zero, or 0 otherwise.
*
* WARNING: if a1 and a2 differ in length, returns 0.
*/
int
addr_and(struct iaddr *result, const struct iaddr *a1, const struct iaddr *a2) {
int i;
int all_zero;
if (a1->len != a2->len) {
return 0;
}
all_zero = 1;
result->len = a1->len;
for (i=0; i<a1->len; i++) {
result->iabuf[i] = a1->iabuf[i] & a2->iabuf[i];
if (result->iabuf[i] != 0) {
all_zero = 0;
}
}
return !all_zero;
}
/*
* Check if a bitmask of the given length is valid for the address.
* This is not the case if any bits longer than the bitmask are 1.
*
* So, this is valid:
*
* 127.0.0.0/8
*
* But this is not:
*
* 127.0.0.1/8
*
* Because the final ".1" would get masked out by the /8.
*/
isc_boolean_t
is_cidr_mask_valid(const struct iaddr *addr, int bits) {
int zero_bits;
int zero_bytes;
int i;
char byte;
int shift_bits;
/*
* Check our bit boundaries.
*/
if (bits < 0) {
return ISC_FALSE;
}
if (bits > (addr->len * 8)) {
return ISC_FALSE;
}
/*
* Figure out how many low-order bits need to be zero.
*/
zero_bits = (addr->len * 8) - bits;
zero_bytes = zero_bits / 8;
/*
* Check to make sure the low-order bytes are zero.
*/
for (i=1; i<=zero_bytes; i++) {
if (addr->iabuf[addr->len-i] != 0) {
return ISC_FALSE;
}
}
/*
* Look to see if any bits not in right-hand bytes are
* non-zero, by making a byte that has these bits set to zero
* comparing to the original byte. If these two values are
* equal, then the right-hand bits are zero, and we are
* happy.
*/
shift_bits = zero_bits % 8;
if (shift_bits == 0) return ISC_TRUE;
byte = addr->iabuf[addr->len-zero_bytes-1];
return (((byte >> shift_bits) << shift_bits) == byte);
}
/*
* range2cidr
*
* Converts a range of IP addresses to a set of CIDR networks.
*
* Examples:
* 192.168.0.0 - 192.168.0.255 = 192.168.0.0/24
* 10.0.0.0 - 10.0.1.127 = 10.0.0.0/24, 10.0.1.0/25
* 255.255.255.32 - 255.255.255.255 = 255.255.255.32/27, 255.255.255.64/26,
* 255.255.255.128/25
*/
isc_result_t
range2cidr(struct iaddrcidrnetlist **result,
const struct iaddr *lo, const struct iaddr *hi) {
struct iaddr addr;
struct iaddr mask;
int bit;
struct iaddr end_addr;
struct iaddr dummy;
int ofs, val;
struct iaddrcidrnetlist *net;
int tmp;
if (result == NULL) {
return DHCP_R_INVALIDARG;
}
if (*result != NULL) {
return DHCP_R_INVALIDARG;
}
if ((lo == NULL) || (hi == NULL) || (lo->len != hi->len)) {
return DHCP_R_INVALIDARG;
}
/*
* Put our start and end in the right order, if reversed.
*/
if (addr_cmp(lo, hi) > 0) {
const struct iaddr *tmp;
tmp = lo;
lo = hi;
hi = tmp;
}
/*
* Theory of operation:
*
* -------------------
* Start at the low end, and keep trying larger networks
* until we get one that is too big (explained below).
*
* We keep a "mask", which is the ones-complement of a
* normal netmask. So, a /23 has a netmask of 255.255.254.0,
* and a mask of 0.0.1.255.
*
* We know when a network is too big when we bitwise-AND the
* mask with the starting address and we get a non-zero
* result, like this:
*
* addr: 192.168.1.0, mask: 0.0.1.255
* bitwise-AND: 0.0.1.0
*
* A network is also too big if the bitwise-OR of the mask
* with the starting address is larger than the end address,
* like this:
*
* start: 192.168.1.0, mask: 0.0.1.255, end: 192.168.0.255
* bitwise-OR: 192.168.1.255
*
* -------------------
* Once we have found a network that is too big, we add the
* appropriate CIDR network to our list of found networks.
*
* We then use the next IP address as our low address, and
* begin the process of searching for a network that is
* too big again, starting with an empty mask.
*/
addr = *lo;
bit = 0;
memset(&mask, 0, sizeof(mask));
mask.len = addr.len;
while (addr_cmp(&addr, hi) <= 0) {
/*
* Bitwise-OR mask with (1 << bit)
*/
ofs = addr.len - (bit / 8) - 1;
val = 1 << (bit % 8);
if (ofs >= 0) {
mask.iabuf[ofs] |= val;
}
/*
* See if we're too big, and save this network if so.
*/
addr_or(&end_addr, &addr, &mask);
if ((ofs < 0) ||
(addr_cmp(&end_addr, hi) > 0) ||
addr_and(&dummy, &addr, &mask)) {
/*
* Add a new prefix to our list.
*/
net = dmalloc(sizeof(*net), MDL);
if (net == NULL) {
while (*result != NULL) {
net = (*result)->next;
dfree(*result, MDL);
*result = net;
}
return ISC_R_NOMEMORY;
}
net->cidrnet.lo_addr = addr;
net->cidrnet.bits = (addr.len * 8) - bit;
net->next = *result;
*result = net;
/*
* Figure out our new starting address,
* by adding (1 << bit) to our previous
* starting address.
*/
tmp = addr.iabuf[ofs] + val;
while ((ofs >= 0) && (tmp > 255)) {
addr.iabuf[ofs] = tmp - 256;
ofs--;
tmp = addr.iabuf[ofs] + 1;
}
if (ofs < 0) {
/* Gone past last address, we're done. */
break;
}
addr.iabuf[ofs] = tmp;
/*
* Reset our bit and mask.
*/
bit = 0;
memset(mask.iabuf, 0, sizeof(mask.iabuf));
memset(end_addr.iabuf, 0, sizeof(end_addr.iabuf));
} else {
/*
* If we're not too big, increase our network size.
*/
bit++;
}
}
/*
* We're done.
*/
return ISC_R_SUCCESS;
}
/*
* Free a list of CIDR networks, such as returned from range2cidr().
*/
isc_result_t
free_iaddrcidrnetlist(struct iaddrcidrnetlist **result) {
struct iaddrcidrnetlist *p;
if (result == NULL) {
return DHCP_R_INVALIDARG;
}
if (*result == NULL) {
return DHCP_R_INVALIDARG;
}
while (*result != NULL) {
p = *result;
*result = p->next;
dfree(p, MDL);
}
return ISC_R_SUCCESS;
}
/* piaddr() turns an iaddr structure into a printable address. */
/* XXX: should use a const pointer rather than passing the structure */
const char *
piaddr(const struct iaddr addr) {
static char
pbuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
/* "255.255.255.255" */
/* INSIST((addr.len == 0) || (addr.len == 4) || (addr.len == 16)); */
if (addr.len == 0) {
return "<null address>";
}
if (addr.len == 4) {
return inet_ntop(AF_INET, addr.iabuf, pbuf, sizeof(pbuf));
}
if (addr.len == 16) {
return inet_ntop(AF_INET6, addr.iabuf, pbuf, sizeof(pbuf));
}
log_fatal("piaddr():%s:%d: Invalid address length %d.", MDL,
addr.len);
/* quell compiler warnings */
return NULL;
}
/* piaddrmask takes an iaddr structure mask, determines the bitlength of
* the mask, and then returns the printable CIDR notation of the two.
*/
char *
piaddrmask(struct iaddr *addr, struct iaddr *mask) {
int mw;
unsigned int oct, bit;
if ((addr->len != 4) && (addr->len != 16))
log_fatal("piaddrmask():%s:%d: Address length %d invalid",
MDL, addr->len);
if (addr->len != mask->len)
log_fatal("piaddrmask():%s:%d: Address and mask size mismatch",
MDL);
/* Determine netmask width in bits. */
for (mw = (mask->len * 8) ; mw > 0 ; ) {
oct = (mw - 1) / 8;
bit = 0x80 >> ((mw - 1) % 8);
if (!mask->iabuf[oct])
mw -= 8;
else if (mask->iabuf[oct] & bit)
break;
else
mw--;
}
if (mw < 0)
log_fatal("Impossible condition at %s:%d.", MDL);
return piaddrcidr(addr, mw);
}
/* Format an address and mask-length into printable CIDR notation. */
char *
piaddrcidr(const struct iaddr *addr, unsigned int bits) {
static char
ret[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255/128")];
/* "255.255.255.255/32" */
/* INSIST(addr != NULL); */
/* INSIST((addr->len == 4) || (addr->len == 16)); */
/* INSIST(bits <= (addr->len * 8)); */
if (bits > (addr->len * 8))
return NULL;
sprintf(ret, "%s/%d", piaddr(*addr), bits);
return ret;
}
/* Validate that the string represents a valid port number and
* return it in network byte order
*/
u_int16_t
validate_port(char *port) {
long local_port = 0;
long lower = 1;
long upper = 65535;
char *endptr;
errno = 0;
local_port = strtol(port, &endptr, 10);
if ((*endptr != '\0') || (errno == ERANGE) || (errno == EINVAL))
log_fatal ("Invalid port number specification: %s", port);
if (local_port < lower || local_port > upper)
log_fatal("Port number specified is out of range (%ld-%ld).",
lower, upper);
return htons((u_int16_t)local_port);
}

482
external/bsd/dhcp/dist/common/lpf.c vendored Normal file
View File

@@ -0,0 +1,482 @@
/* $NetBSD: lpf.c,v 1.1.1.4 2014/07/12 11:57:44 spz Exp $ */
/* lpf.c
Linux packet filter code, contributed by Brian Murrel at Interlinx
Support Services in Vancouver, B.C. */
/*
* Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: lpf.c,v 1.1.1.4 2014/07/12 11:57:44 spz Exp $");
#include "dhcpd.h"
#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
#include <sys/uio.h>
#include <errno.h>
#include <asm/types.h>
#include <linux/filter.h>
#include <linux/if_ether.h>
#include <netinet/in_systm.h>
#include <net/if_packet.h>
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
#endif
#if defined (USE_LPF_RECEIVE) || defined (USE_LPF_HWADDR)
#include <sys/ioctl.h>
#include <net/if.h>
#endif
#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
#ifdef USE_LPF_SEND
void if_reinitialize_send (info)
struct interface_info *info;
{
}
#endif
#ifdef USE_LPF_RECEIVE
void if_reinitialize_receive (info)
struct interface_info *info;
{
}
#endif
/* Called by get_interface_list for each interface that's discovered.
Opens a packet filter for each interface and adds it to the select
mask. */
int if_register_lpf (info)
struct interface_info *info;
{
int sock;
struct sockaddr sa;
/* Make an LPF socket. */
if ((sock = socket(PF_PACKET, SOCK_PACKET,
htons((short)ETH_P_ALL))) < 0) {
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EINVAL) {
log_error ("socket: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",
"in your kernel");
log_fatal ("configuration!");
}
log_fatal ("Open a socket for LPF: %m");
}
/* Bind to the interface name */
memset (&sa, 0, sizeof sa);
sa.sa_family = AF_PACKET;
strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data);
if (bind (sock, &sa, sizeof sa)) {
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT || errno == EINVAL) {
log_error ("socket: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",
"in your kernel");
log_fatal ("configuration!");
}
log_fatal ("Bind socket to interface: %m");
}
get_hw_addr(info->name, &info->hw_address);
return sock;
}
#endif /* USE_LPF_SEND || USE_LPF_RECEIVE */
#ifdef USE_LPF_SEND
void if_register_send (info)
struct interface_info *info;
{
/* If we're using the lpf API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_LPF_RECEIVE
info -> wfdesc = if_register_lpf (info);
#else
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
log_info ("Sending on LPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_send (info)
struct interface_info *info;
{
/* don't need to close twice if we are using lpf for sending and
receiving */
#ifndef USE_LPF_RECEIVE
/* for LPF this is simple, packet filters are removed when sockets
are closed */
close (info -> wfdesc);
#endif
info -> wfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling output on LPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_LPF_SEND */
#ifdef USE_LPF_RECEIVE
/* Defined in bpf.c. We can't extern these in dhcpd.h without pulling
in bpf includes... */
extern struct sock_filter dhcp_bpf_filter [];
extern int dhcp_bpf_filter_len;
#if defined (HAVE_TR_SUPPORT)
extern struct sock_filter dhcp_bpf_tr_filter [];
extern int dhcp_bpf_tr_filter_len;
static void lpf_tr_filter_setup (struct interface_info *);
#endif
static void lpf_gen_filter_setup (struct interface_info *);
void if_register_receive (info)
struct interface_info *info;
{
/* Open a LPF device and hang it on this interface... */
info -> rfdesc = if_register_lpf (info);
#if defined (HAVE_TR_SUPPORT)
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
lpf_tr_filter_setup (info);
else
#endif
lpf_gen_filter_setup (info);
if (!quiet_interface_discovery)
log_info ("Listening on LPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_receive (info)
struct interface_info *info;
{
/* for LPF this is simple, packet filters are removed when sockets
are closed */
close (info -> rfdesc);
info -> rfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling input on LPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
static void lpf_gen_filter_setup (info)
struct interface_info *info;
{
struct sock_fprog p;
memset(&p, 0, sizeof(p));
/* Set up the bpf filter program structure. This is defined in
bpf.c */
p.len = dhcp_bpf_filter_len;
p.filter = dhcp_bpf_filter;
/* Patch the server port into the LPF program...
XXX changes to filter program may require changes
to the insn number(s) used below! XXX */
dhcp_bpf_filter [8].k = ntohs ((short)local_port);
if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p,
sizeof p) < 0) {
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT) {
log_error ("socket: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",
"in your kernel");
log_fatal ("configuration!");
}
log_fatal ("Can't install packet filter program: %m");
}
}
#if defined (HAVE_TR_SUPPORT)
static void lpf_tr_filter_setup (info)
struct interface_info *info;
{
struct sock_fprog p;
memset(&p, 0, sizeof(p));
/* Set up the bpf filter program structure. This is defined in
bpf.c */
p.len = dhcp_bpf_tr_filter_len;
p.filter = dhcp_bpf_tr_filter;
/* Patch the server port into the LPF program...
XXX changes to filter program may require changes
XXX to the insn number(s) used below!
XXX Token ring filter is null - when/if we have a filter
XXX that's not, we'll need this code.
XXX dhcp_bpf_filter [?].k = ntohs (local_port); */
if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p,
sizeof p) < 0) {
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT) {
log_error ("socket: %m - make sure");
log_error ("CONFIG_PACKET (Packet socket) %s",
"and CONFIG_FILTER");
log_error ("(Socket Filtering) are enabled %s",
"in your kernel");
log_fatal ("configuration!");
}
log_fatal ("Can't install packet filter program: %m");
}
}
#endif /* HAVE_TR_SUPPORT */
#endif /* USE_LPF_RECEIVE */
#ifdef USE_LPF_SEND
ssize_t send_packet (interface, packet, raw, len, from, to, hto)
struct interface_info *interface;
struct packet *packet;
struct dhcp_packet *raw;
size_t len;
struct in_addr from;
struct sockaddr_in *to;
struct hardware *hto;
{
unsigned hbufp = 0, ibufp = 0;
double hh [16];
double ih [1536 / sizeof (double)];
unsigned char *buf = (unsigned char *)ih;
struct sockaddr_pkt sa;
int result;
int fudge;
if (!strcmp (interface -> name, "fallback"))
return send_fallback (interface, packet, raw,
len, from, to, hto);
if (hto == NULL && interface->anycast_mac_addr.hlen)
hto = &interface->anycast_mac_addr;
/* Assemble the headers... */
assemble_hw_header (interface, (unsigned char *)hh, &hbufp, hto);
fudge = hbufp % 4; /* IP header must be word-aligned. */
memcpy (buf + fudge, (unsigned char *)hh, hbufp);
ibufp = hbufp + fudge;
assemble_udp_ip_header (interface, buf, &ibufp, from.s_addr,
to -> sin_addr.s_addr, to -> sin_port,
(unsigned char *)raw, len);
memcpy (buf + ibufp, raw, len);
/* For some reason, SOCK_PACKET sockets can't be connected,
so we have to do a sentdo every time. */
memset (&sa, 0, sizeof sa);
sa.spkt_family = AF_PACKET;
strncpy ((char *)sa.spkt_device,
(const char *)interface -> ifp, sizeof sa.spkt_device);
sa.spkt_protocol = htons(ETH_P_IP);
result = sendto (interface -> wfdesc,
buf + fudge, ibufp + len - fudge, 0,
(const struct sockaddr *)&sa, sizeof sa);
if (result < 0)
log_error ("send_packet: %m");
return result;
}
#endif /* USE_LPF_SEND */
#ifdef USE_LPF_RECEIVE
ssize_t receive_packet (interface, buf, len, from, hfrom)
struct interface_info *interface;
unsigned char *buf;
size_t len;
struct sockaddr_in *from;
struct hardware *hfrom;
{
int length = 0;
int offset = 0;
unsigned char ibuf [1536];
unsigned bufix = 0;
unsigned paylen;
length = read (interface -> rfdesc, ibuf, sizeof ibuf);
if (length <= 0)
return length;
bufix = 0;
/* Decode the physical header... */
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
/* If a physical layer checksum failed (dunno of any
physical layer that supports this, but WTH), skip this
packet. */
if (offset < 0) {
return 0;
}
bufix += offset;
length -= offset;
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix, from,
(unsigned)length, &paylen);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
return 0;
bufix += offset;
length -= offset;
if (length < paylen)
log_fatal("Internal inconsistency at %s:%d.", MDL);
/* Copy out the data in the packet... */
memcpy(buf, &ibuf[bufix], paylen);
return paylen;
}
int can_unicast_without_arp (ip)
struct interface_info *ip;
{
return 1;
}
int can_receive_unicast_unconfigured (ip)
struct interface_info *ip;
{
return 1;
}
int supports_multiple_interfaces (ip)
struct interface_info *ip;
{
return 1;
}
void maybe_setup_fallback ()
{
isc_result_t status;
struct interface_info *fbi = (struct interface_info *)0;
if (setup_fallback (&fbi, MDL)) {
if_register_fallback (fbi);
status = omapi_register_io_object ((omapi_object_t *)fbi,
if_readsocket, 0,
fallback_discard, 0, 0);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register I/O handle for \"%s\": %s",
fbi -> name, isc_result_totext (status));
interface_dereference (&fbi, MDL);
}
}
#endif
#if defined (USE_LPF_RECEIVE) || defined (USE_LPF_HWADDR)
void
get_hw_addr(const char *name, struct hardware *hw) {
int sock;
struct ifreq tmp;
struct sockaddr *sa;
if (strlen(name) >= sizeof(tmp.ifr_name)) {
log_fatal("Device name too long: \"%s\"", name);
}
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
log_fatal("Can't create socket for \"%s\": %m", name);
}
memset(&tmp, 0, sizeof(tmp));
strcpy(tmp.ifr_name, name);
if (ioctl(sock, SIOCGIFHWADDR, &tmp) < 0) {
log_fatal("Error getting hardware address for \"%s\": %m",
name);
}
sa = &tmp.ifr_hwaddr;
switch (sa->sa_family) {
case ARPHRD_ETHER:
hw->hlen = 7;
hw->hbuf[0] = HTYPE_ETHER;
memcpy(&hw->hbuf[1], sa->sa_data, 6);
break;
case ARPHRD_IEEE802:
#ifdef ARPHRD_IEEE802_TR
case ARPHRD_IEEE802_TR:
#endif /* ARPHRD_IEEE802_TR */
hw->hlen = 7;
hw->hbuf[0] = HTYPE_IEEE802;
memcpy(&hw->hbuf[1], sa->sa_data, 6);
break;
case ARPHRD_FDDI:
hw->hlen = 7;
hw->hbuf[0] = HTYPE_FDDI;
memcpy(&hw->hbuf[1], sa->sa_data, 6);
break;
default:
log_fatal("Unsupported device type %ld for \"%s\"",
(long int)sa->sa_family, name);
}
close(sock);
}
#endif

152
external/bsd/dhcp/dist/common/memory.c vendored Normal file
View File

@@ -0,0 +1,152 @@
/* $NetBSD: memory.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $ */
/* memory.c
Memory-resident database... */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: memory.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $");
#include "dhcpd.h"
struct group *root_group;
group_hash_t *group_name_hash;
int (*group_write_hook) (struct group_object *);
isc_result_t delete_group (struct group_object *group, int writep)
{
struct group_object *d;
/* The group should exist and be hashed - if not, it's invalid. */
if (group_name_hash) {
d = (struct group_object *)0;
group_hash_lookup (&d, group_name_hash, group -> name,
strlen (group -> name), MDL);
} else
return DHCP_R_INVALIDARG;
if (!d)
return DHCP_R_INVALIDARG;
/* Also not okay to delete a group that's not the one in
the hash table. */
if (d != group)
return DHCP_R_INVALIDARG;
/* If it's dynamic, and we're deleting it, we can just blow away the
hash table entry. */
if ((group -> flags & GROUP_OBJECT_DYNAMIC) &&
!(group -> flags & GROUP_OBJECT_STATIC)) {
group_hash_delete (group_name_hash,
group -> name, strlen (group -> name), MDL);
} else {
group -> flags |= GROUP_OBJECT_DELETED;
if (group -> group)
group_dereference (&group -> group, MDL);
}
/* Store the group declaration in the lease file. */
if (writep && group_write_hook) {
if (!(*group_write_hook) (group))
return ISC_R_IOERROR;
}
return ISC_R_SUCCESS;
}
isc_result_t supersede_group (struct group_object *group, int writep)
{
struct group_object *t;
/* Register the group in the group name hash table,
so we can look it up later. */
if (group_name_hash) {
t = (struct group_object *)0;
group_hash_lookup (&t, group_name_hash,
group -> name,
strlen (group -> name), MDL);
if (t && t != group) {
/* If this isn't a dynamic entry, then we need to flag
the replacement as not dynamic either - otherwise,
if the dynamic entry is deleted later, the static
entry will come back next time the server is stopped
and restarted. */
if (!(t -> flags & GROUP_OBJECT_DYNAMIC))
group -> flags |= GROUP_OBJECT_STATIC;
/* Delete the old object if it hasn't already been
deleted. If it has already been deleted, get rid of
the hash table entry. This is a legitimate
situation - a deleted static object needs to be kept
around so we remember it's deleted. */
if (!(t -> flags & GROUP_OBJECT_DELETED))
delete_group (t, 0);
else {
group_hash_delete (group_name_hash,
group -> name,
strlen (group -> name),
MDL);
group_object_dereference (&t, MDL);
}
}
} else {
group_new_hash(&group_name_hash, GROUP_HASH_SIZE, MDL);
t = (struct group_object *)0;
}
/* Add the group to the group name hash if it's not
already there, and also thread it into the list of
dynamic groups if appropriate. */
if (!t) {
group_hash_add (group_name_hash, group -> name,
strlen (group -> name), group, MDL);
}
/* Store the group declaration in the lease file. */
if (writep && group_write_hook) {
if (!(*group_write_hook) (group))
return ISC_R_IOERROR;
}
return ISC_R_SUCCESS;
}
int clone_group (struct group **gp, struct group *group,
const char *file, int line)
{
struct group *g = (struct group *)0;
/* Normally gp should contain the null pointer, but for convenience
it's permissible to clone a group into itself. */
if (*gp && *gp != group)
return 0;
if (!group_allocate (&g, file, line))
return 0;
if (group == *gp)
*gp = (struct group *)0;
group_reference (gp, g, file, line);
g -> authoritative = group -> authoritative;
group_reference (&g -> next, group, file, line);
group_dereference (&g, file, line);
return 1;
}

420
external/bsd/dhcp/dist/common/nit.c vendored Normal file
View File

@@ -0,0 +1,420 @@
/* $NetBSD: nit.c,v 1.1.1.2 2014/07/12 11:57:45 spz Exp $ */
/* nit.c
Network Interface Tap (NIT) network interface code, by Ted Lemon
with one crucial tidbit of help from Stu Grossmen. */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: nit.c,v 1.1.1.2 2014/07/12 11:57:45 spz Exp $");
#include "dhcpd.h"
#if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <net/nit.h>
#include <net/nit_if.h>
#include <net/nit_pf.h>
#include <net/nit_buf.h>
#include <sys/stropts.h>
#include <net/packetfilt.h>
#include <netinet/in_systm.h>
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
#ifdef USE_NIT_SEND
void if_reinitialize_send (info)
struct interface_info *info;
{
}
#endif
#ifdef USE_NIT_RECEIVE
void if_reinitialize_receive (info)
struct interface_info *info;
{
}
#endif
/* Called by get_interface_list for each interface that's discovered.
Opens a packet filter for each interface and adds it to the select
mask. */
int if_register_nit (info)
struct interface_info *info;
{
int sock;
char filename[50];
struct ifreq ifr;
struct strioctl sio;
/* Open a NIT device */
sock = open ("/dev/nit", O_RDWR);
if (sock < 0)
log_fatal ("Can't open NIT device for %s: %m", info -> name);
/* Set the NIT device to point at this interface. */
sio.ic_cmd = NIOCBIND;
sio.ic_len = sizeof *(info -> ifp);
sio.ic_dp = (char *)(info -> ifp);
sio.ic_timout = INFTIM;
if (ioctl (sock, I_STR, &sio) < 0)
log_fatal ("Can't attach interface %s to nit device: %m",
info -> name);
/* Get the low-level address... */
sio.ic_cmd = SIOCGIFADDR;
sio.ic_len = sizeof ifr;
sio.ic_dp = (char *)&ifr;
sio.ic_timout = INFTIM;
if (ioctl (sock, I_STR, &sio) < 0)
log_fatal ("Can't get physical layer address for %s: %m",
info -> name);
/* XXX code below assumes ethernet interface! */
info -> hw_address.hlen = 7;
info -> hw_address.hbuf [0] = ARPHRD_ETHER;
memcpy (&info -> hw_address.hbuf [1],
ifr.ifr_ifru.ifru_addr.sa_data, 6);
if (ioctl (sock, I_PUSH, "pf") < 0)
log_fatal ("Can't push packet filter onto NIT for %s: %m",
info -> name);
return sock;
}
#endif /* USE_NIT_SEND || USE_NIT_RECEIVE */
#ifdef USE_NIT_SEND
void if_register_send (info)
struct interface_info *info;
{
/* If we're using the nit API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_NIT_RECEIVE
struct packetfilt pf;
struct strioctl sio;
info -> wfdesc = if_register_nit (info);
pf.Pf_Priority = 0;
pf.Pf_FilterLen = 1;
pf.Pf_Filter [0] = ENF_PUSHZERO;
/* Set up an NIT filter that rejects everything... */
sio.ic_cmd = NIOCSETF;
sio.ic_len = sizeof pf;
sio.ic_dp = (char *)&pf;
sio.ic_timout = INFTIM;
if (ioctl (info -> wfdesc, I_STR, &sio) < 0)
log_fatal ("Can't set NIT filter: %m");
#else
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
log_info ("Sending on NIT/%s%s%s",
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_send (info)
struct interface_info *info;
{
/* If we're using the nit API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_NIT_RECEIVE
close (info -> wfdesc);
#endif
info -> wfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling output on NIT/%s%s%s",
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_NIT_SEND */
#ifdef USE_NIT_RECEIVE
/* Packet filter program...
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the NIT program! XXX */
void if_register_receive (info)
struct interface_info *info;
{
int flag = 1;
u_int32_t x;
struct packetfilt pf;
struct strioctl sio;
u_int16_t addr [2];
struct timeval t;
/* Open a NIT device and hang it on this interface... */
info -> rfdesc = if_register_nit (info);
/* Set the snap length to 0, which means always take the whole
packet. */
x = 0;
if (ioctl (info -> rfdesc, NIOCSSNAP, &x) < 0)
log_fatal ("Can't set NIT snap length on %s: %m", info -> name);
/* Set the stream to byte stream mode */
if (ioctl (info -> rfdesc, I_SRDOPT, RMSGN) != 0)
log_info ("I_SRDOPT failed on %s: %m", info -> name);
#if 0
/* Push on the chunker... */
if (ioctl (info -> rfdesc, I_PUSH, "nbuf") < 0)
log_fatal ("Can't push chunker onto NIT STREAM: %m");
/* Set the timeout to zero. */
t.tv_sec = 0;
t.tv_usec = 0;
if (ioctl (info -> rfdesc, NIOCSTIME, &t) < 0)
log_fatal ("Can't set chunk timeout: %m");
#endif
/* Ask for no header... */
x = 0;
if (ioctl (info -> rfdesc, NIOCSFLAGS, &x) < 0)
log_fatal ("Can't set NIT flags on %s: %m", info -> name);
/* Set up the NIT filter program. */
/* XXX Unlike the BPF filter program, this one won't work if the
XXX IP packet is fragmented or if there are options on the IP
XXX header. */
pf.Pf_Priority = 0;
pf.Pf_FilterLen = 0;
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 6;
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
pf.Pf_Filter [pf.Pf_FilterLen++] = htons (ETHERTYPE_IP);
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT;
pf.Pf_Filter [pf.Pf_FilterLen++] = htons (IPPROTO_UDP);
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 11;
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_AND;
pf.Pf_Filter [pf.Pf_FilterLen++] = htons (0xFF);
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND;
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 18;
pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
pf.Pf_Filter [pf.Pf_FilterLen++] = local_port;
/* Install the filter... */
sio.ic_cmd = NIOCSETF;
sio.ic_len = sizeof pf;
sio.ic_dp = (char *)&pf;
sio.ic_timout = INFTIM;
if (ioctl (info -> rfdesc, I_STR, &sio) < 0)
log_fatal ("Can't set NIT filter on %s: %m", info -> name);
if (!quiet_interface_discovery)
log_info ("Listening on NIT/%s%s%s",
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_receive (info)
struct interface_info *info;
{
/* If we're using the nit API for sending and receiving,
we don't need to register this interface twice. */
close (info -> rfdesc);
info -> rfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling input on NIT/%s%s%s",
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_NIT_RECEIVE */
#ifdef USE_NIT_SEND
ssize_t send_packet (interface, packet, raw, len, from, to, hto)
struct interface_info *interface;
struct packet *packet;
struct dhcp_packet *raw;
size_t len;
struct in_addr from;
struct sockaddr_in *to;
struct hardware *hto;
{
unsigned hbufp, ibufp;
double hh [16];
double ih [1536 / sizeof (double)];
unsigned char *buf = (unsigned char *)ih;
struct sockaddr *junk;
struct strbuf ctl, data;
struct sockaddr_in foo;
int result;
if (!strcmp (interface -> name, "fallback"))
return send_fallback (interface, packet, raw,
len, from, to, hto);
if (hto == NULL && interface->anycast_mac_addr.hlen)
hto = &interface->anycast_mac_addr;
/* Start with the sockaddr struct... */
junk = (struct sockaddr *)&hh [0];
hbufp = (((unsigned char *)&junk -> sa_data [0]) -
(unsigned char *)&hh[0]);
ibufp = 0;
/* Assemble the headers... */
assemble_hw_header (interface, (unsigned char *)junk, &hbufp, hto);
assemble_udp_ip_header (interface, buf, &ibufp,
from.s_addr, to -> sin_addr.s_addr,
to -> sin_port, (unsigned char *)raw, len);
/* Copy the data into the buffer (yuk). */
memcpy (buf + ibufp, raw, len);
/* Set up the sockaddr structure... */
#if USE_SIN_LEN
junk -> sa_len = hbufp - 2; /* XXX */
#endif
junk -> sa_family = AF_UNSPEC;
/* Set up the msg_buf structure... */
ctl.buf = (char *)&hh [0];
ctl.maxlen = ctl.len = hbufp;
data.buf = (char *)&ih [0];
data.maxlen = data.len = ibufp + len;
result = putmsg (interface -> wfdesc, &ctl, &data, 0);
if (result < 0)
log_error ("send_packet: %m");
return result;
}
#endif /* USE_NIT_SEND */
#ifdef USE_NIT_RECEIVE
ssize_t receive_packet (interface, buf, len, from, hfrom)
struct interface_info *interface;
unsigned char *buf;
size_t len;
struct sockaddr_in *from;
struct hardware *hfrom;
{
int nread;
int length = 0;
int offset = 0;
unsigned char ibuf [1536];
int bufix = 0;
unsigned paylen;
length = read (interface -> rfdesc, ibuf, sizeof ibuf);
if (length <= 0)
return length;
/* Decode the physical header... */
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
/* If a physical layer checksum failed (dunno of any
physical layer that supports this, but WTH), skip this
packet. */
if (offset < 0) {
return 0;
}
bufix += offset;
length -= offset;
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
from, length, &paylen);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
return 0;
bufix += offset;
length -= offset;
if (length < paylen)
log_fatal("Internal inconsistency at %s:%d.", MDL);
/* Copy out the data in the packet... */
memcpy(buf, &ibuf[bufix], paylen);
return paylen;
}
int can_unicast_without_arp (ip)
struct interface_info *ip;
{
return 1;
}
int can_receive_unicast_unconfigured (ip)
struct interface_info *ip;
{
return 1;
}
int supports_multiple_interfaces (ip)
struct interface_info *ip;
{
return 1;
}
void maybe_setup_fallback ()
{
isc_result_t status;
struct interface_info *fbi = (struct interface_info *)0;
if (setup_fallback (&fbi, MDL)) {
if_register_fallback (fbi);
status = omapi_register_io_object ((omapi_object_t *)fbi,
if_readsocket, 0,
fallback_discard, 0, 0);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register I/O handle for %s: %s",
fbi -> name, isc_result_totext (status));
interface_dereference (&fbi, MDL);
}
}
#endif

662
external/bsd/dhcp/dist/common/ns_name.c vendored Normal file
View File

@@ -0,0 +1,662 @@
/* $NetBSD: ns_name.c,v 1.7 2014/07/12 12:09:37 spz Exp $ */
/*
* Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* http://www.isc.org/
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: ns_name.c,v 1.7 2014/07/12 12:09:37 spz Exp $");
#ifndef lint
static const char rcsid[] = "Id: ns_name.c,v 1.2 2009/10/28 04:12:29 sar Exp ";
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include "minires.h"
#include "arpa/nameser.h"
/* Data. */
static const char digits[] = "0123456789";
/* Forward. */
static int special(int);
static int printable(int);
static int dn_find(const u_char *, const u_char *,
const u_char * const *,
const u_char * const *);
/* Public. */
/*
* MRns_name_ntop(src, dst, dstsiz)
* Convert an encoded domain name to printable ascii as per RFC1035.
* return:
* Number of bytes written to buffer, or -1 (with errno set)
* notes:
* The root is returned as "."
* All other domains are returned in non absolute form
*/
int
MRns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
const u_char *cp;
char *dn, *eom;
u_char c;
u_int n;
cp = src;
dn = dst;
eom = dst + dstsiz;
while ((n = *cp++) != 0) {
if ((n & NS_CMPRSFLGS) != 0) {
/* Some kind of compression pointer. */
errno = EMSGSIZE;
return (-1);
}
if (dn != dst) {
if (dn >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = '.';
}
if (dn + n >= eom) {
errno = EMSGSIZE;
return (-1);
}
for ((void)NULL; n > 0; n--) {
c = *cp++;
if (special(c)) {
if (dn + 1 >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = '\\';
*dn++ = (char)c;
} else if (!printable(c)) {
if (dn + 3 >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = '\\';
*dn++ = digits[c / 100];
*dn++ = digits[(c % 100) / 10];
*dn++ = digits[c % 10];
} else {
if (dn >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = (char)c;
}
}
}
if (dn == dst) {
if (dn >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = '.';
}
if (dn >= eom) {
errno = EMSGSIZE;
return (-1);
}
*dn++ = '\0';
return (dn - dst);
}
/*
* MRns_name_pton(src, dst, dstsiz)
* Convert a ascii string into an encoded domain name as per RFC1035.
* return:
* -1 if it fails
* 1 if string was fully qualified
* 0 is string was not fully qualified
* notes:
* Enforces label and domain length limits.
*/
int
MRns_name_pton(const char *src, u_char *dst, size_t dstsiz) {
u_char *label, *bp, *eom;
int c, n, escaped;
char *cp;
escaped = 0;
bp = dst;
eom = dst + dstsiz;
label = bp++;
while ((c = *src++) != 0) {
if (escaped) {
if ((cp = strchr(digits, c)) != NULL) {
n = (cp - digits) * 100;
if ((c = *src++) == 0 ||
(cp = strchr(digits, c)) == NULL) {
errno = EMSGSIZE;
return (-1);
}
n += (cp - digits) * 10;
if ((c = *src++) == 0 ||
(cp = strchr(digits, c)) == NULL) {
errno = EMSGSIZE;
return (-1);
}
n += (cp - digits);
if (n > 255) {
errno = EMSGSIZE;
return (-1);
}
c = n;
}
escaped = 0;
} else if (c == '\\') {
escaped = 1;
continue;
} else if (c == '.') {
c = (bp - label - 1);
if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */
errno = EMSGSIZE;
return (-1);
}
if (label >= eom) {
errno = EMSGSIZE;
return (-1);
}
*label = c;
/* Fully qualified ? */
if (*src == '\0') {
if (c != 0) {
if (bp >= eom) {
errno = EMSGSIZE;
return (-1);
}
*bp++ = '\0';
}
if ((bp - dst) > MAXCDNAME) {
errno = EMSGSIZE;
return (-1);
}
return (1);
}
if (c == 0 || *src == '.') {
errno = EMSGSIZE;
return (-1);
}
label = bp++;
continue;
}
if (bp >= eom) {
errno = EMSGSIZE;
return (-1);
}
*bp++ = (u_char)c;
}
c = (bp - label - 1);
if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */
errno = EMSGSIZE;
return (-1);
}
if (label >= eom) {
errno = EMSGSIZE;
return (-1);
}
*label = c;
if (c != 0) {
if (bp >= eom) {
errno = EMSGSIZE;
return (-1);
}
*bp++ = 0;
}
if ((bp - dst) > MAXCDNAME) { /* src too big */
errno = EMSGSIZE;
return (-1);
}
return (0);
}
#ifdef notdef
/*
* MRns_name_ntol(src, dst, dstsiz)
* Convert a network strings labels into all lowercase.
* return:
* Number of bytes written to buffer, or -1 (with errno set)
* notes:
* Enforces label and domain length limits.
*/
int
MRns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz) {
const u_char *cp;
u_char *dn, *eom;
u_char c;
u_int n;
cp = src;
dn = dst;
eom = dst + dstsiz;
if (dn >= eom) {
errno = EMSGSIZE;
return (-1);
}
while ((n = *cp++) != 0) {
if ((n & NS_CMPRSFLGS) != 0) {
/* Some kind of compression pointer. */
errno = EMSGSIZE;
return (-1);
}
*dn++ = n;
if (dn + n >= eom) {
errno = EMSGSIZE;
return (-1);
}
for ((void)NULL; n > 0; n--) {
c = *cp++;
if (isupper(c))
*dn++ = tolower(c);
else
*dn++ = c;
}
}
*dn++ = '\0';
return (dn - dst);
}
#endif
/*
* MRns_name_unpack(msg, eom, src, dst, dstsiz)
* Unpack a domain name from a message, source may be compressed.
* return:
* -1 if it fails, or consumed octets if it succeeds.
*/
int
MRns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
u_char *dst, size_t dstsiz)
{
const u_char *srcp, *dstlim;
u_char *dstp;
unsigned n;
int len;
int checked;
len = -1;
checked = 0;
dstp = dst;
srcp = src;
dstlim = dst + dstsiz;
if (srcp < msg || srcp >= eom) {
errno = EMSGSIZE;
return (-1);
}
/* Fetch next label in domain name. */
while ((n = *srcp++) != 0) {
/* Check for indirection. */
switch (n & NS_CMPRSFLGS) {
case 0:
/* Limit checks. */
if (dstp + n + 1 >= dstlim || srcp + n >= eom) {
errno = EMSGSIZE;
return (-1);
}
checked += n + 1;
*dstp++ = n;
memcpy(dstp, srcp, n);
dstp += n;
srcp += n;
break;
case NS_CMPRSFLGS:
if (srcp >= eom) {
errno = EMSGSIZE;
return (-1);
}
if (len < 0)
len = srcp - src + 1;
n = ((n & 0x3f) << 8) | (*srcp & 0xff);
if (n >= eom - msg) { /* Out of range. */
errno = EMSGSIZE;
return (-1);
}
srcp = msg + n;
checked += 2;
/*
* Check for loops in the compressed name;
* if we've looked at the whole message,
* there must be a loop.
*/
if (checked >= eom - msg) {
errno = EMSGSIZE;
return (-1);
}
break;
default:
errno = EMSGSIZE;
return (-1); /* flag error */
}
}
*dstp = '\0';
if (len < 0)
len = srcp - src;
return (len);
}
/*
* MRns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
* Pack domain name 'domain' into 'comp_dn'.
* return:
* Size of the compressed name, or -1.
* notes:
* 'dnptrs' is an array of pointers to previous compressed names.
* dnptrs[0] is a pointer to the beginning of the message. The array
* ends with NULL.
* 'lastdnptr' is a pointer to the end of the array pointed to
* by 'dnptrs'.
* Side effects:
* The list of pointers in dnptrs is updated for labels inserted into
* the message as we compress the name. If 'dnptr' is NULL, we don't
* try to compress names. If 'lastdnptr' is NULL, we don't update the
* list.
*/
int
MRns_name_pack(const u_char *src, u_char *dst, unsigned dstsiz,
const u_char **dnptrs, const u_char **lastdnptr)
{
u_char *dstp;
const u_char **cpp, **lpp, *eob, *msg;
const u_char *srcp;
unsigned n;
int l;
srcp = src;
dstp = dst;
eob = dstp + dstsiz;
lpp = cpp = NULL;
if (dnptrs != NULL) {
if ((msg = *dnptrs++) != NULL) {
for (cpp = dnptrs; *cpp != NULL; cpp++)
(void)NULL;
lpp = cpp; /* end of list to search */
}
} else
msg = NULL;
/* make sure the domain we are about to add is legal */
l = 0;
do {
n = *srcp;
if ((n & NS_CMPRSFLGS) != 0) {
errno = EMSGSIZE;
return (-1);
}
l += n + 1;
if (l > MAXCDNAME) {
errno = EMSGSIZE;
return (-1);
}
srcp += n + 1;
} while (n != 0);
/* from here on we need to reset compression pointer array on error */
srcp = src;
do {
/* Look to see if we can use pointers. */
n = *srcp;
if (n != 0 && msg != NULL) {
l = dn_find(srcp, msg, (const u_char * const *)dnptrs,
(const u_char * const *)lpp);
if (l >= 0) {
if (dstp + 1 >= eob) {
goto cleanup;
}
*dstp++ = (l >> 8) | NS_CMPRSFLGS;
*dstp++ = l % 256;
return (dstp - dst);
}
/* Not found, save it. */
if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
(dstp - msg) < 0x4000) {
*cpp++ = dstp;
*cpp = NULL;
}
}
/* copy label to buffer */
if (n & NS_CMPRSFLGS) { /* Should not happen. */
goto cleanup;
}
if (dstp + 1 + n >= eob) {
goto cleanup;
}
memcpy(dstp, srcp, n + 1);
srcp += n + 1;
dstp += n + 1;
} while (n != 0);
if (dstp > eob) {
cleanup:
if (msg != NULL)
*lpp = NULL;
errno = EMSGSIZE;
return (-1);
}
return (dstp - dst);
}
#ifdef notdef
/*
* MRns_name_uncompress(msg, eom, src, dst, dstsiz)
* Expand compressed domain name to presentation format.
* return:
* Number of bytes read out of `src', or -1 (with errno set).
* note:
* Root domain returns as "." not "".
*/
int
MRns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src,
char *dst, size_t dstsiz)
{
u_char tmp[NS_MAXCDNAME];
int n;
if ((n = MRns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
return (-1);
if (MRns_name_ntop(tmp, dst, dstsiz) == -1)
return (-1);
return (n);
}
#endif
/*
* MRns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr)
* Compress a domain name into wire format, using compression pointers.
* return:
* Number of bytes consumed in `dst' or -1 (with errno set).
* notes:
* 'dnptrs' is an array of pointers to previous compressed names.
* dnptrs[0] is a pointer to the beginning of the message.
* The list ends with NULL. 'lastdnptr' is a pointer to the end of the
* array pointed to by 'dnptrs'. Side effect is to update the list of
* pointers for labels inserted into the message as we compress the name.
* If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
* is NULL, we don't update the list.
*/
int
MRns_name_compress(const char *src, u_char *dst, size_t dstsiz,
const u_char **dnptrs, const u_char **lastdnptr)
{
u_char tmp[NS_MAXCDNAME];
if (MRns_name_pton(src, tmp, sizeof tmp) == -1)
return (-1);
return (MRns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr));
}
#ifdef notdef
/*
* MRns_name_skip(ptrptr, eom)
* Advance *ptrptr to skip over the compressed name it points at.
* return:
* 0 on success, -1 (with errno set) on failure.
*/
int
MRns_name_skip(const u_char **ptrptr, const u_char *eom) {
const u_char *cp;
u_int n;
cp = *ptrptr;
while (cp < eom && (n = *cp++) != 0) {
/* Check for indirection. */
switch (n & NS_CMPRSFLGS) {
case 0: /* normal case, n == len */
cp += n;
continue;
case NS_CMPRSFLGS: /* indirection */
cp++;
break;
default: /* illegal type */
errno = EMSGSIZE;
return (-1);
}
break;
}
if (cp > eom) {
errno = EMSGSIZE;
return (-1);
}
*ptrptr = cp;
return (0);
}
#endif
/* Private. */
/*
* special(ch)
* Thinking in noninternationalized USASCII (per the DNS spec),
* is this characted special ("in need of quoting") ?
* return:
* boolean.
*/
static int
special(int ch) {
switch (ch) {
case 0x22: /* '"' */
case 0x2E: /* '.' */
case 0x3B: /* ';' */
case 0x5C: /* '\\' */
/* Special modifiers in zone files. */
case 0x40: /* '@' */
case 0x24: /* '$' */
return (1);
default:
return (0);
}
}
/*
* printable(ch)
* Thinking in noninternationalized USASCII (per the DNS spec),
* is this character visible and not a space when printed ?
* return:
* boolean.
*/
static int
printable(int ch) {
return (ch > 0x20 && ch < 0x7f);
}
/*
* Thinking in noninternationalized USASCII (per the DNS spec),
* convert this character to lower case if it's upper case.
*/
static int
mklower(int ch) {
if (ch >= 0x41 && ch <= 0x5A)
return (ch + 0x20);
return (ch);
}
/*
* dn_find(domain, msg, dnptrs, lastdnptr)
* Search for the counted-label name in an array of compressed names.
* return:
* offset from msg if found, or -1.
* notes:
* dnptrs is the pointer to the first name on the list,
* not the pointer to the start of the message.
*/
static int
dn_find(const u_char *domain, const u_char *msg,
const u_char * const *dnptrs,
const u_char * const *lastdnptr)
{
const u_char *dn, *cp, *sp;
const u_char * const *cpp;
u_int n;
for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
dn = domain;
sp = cp = *cpp;
while ((n = *cp++) != 0) {
/*
* check for indirection
*/
switch (n & NS_CMPRSFLGS) {
case 0: /* normal case, n == len */
if (n != *dn++)
goto next;
for ((void)NULL; n > 0; n--)
if (mklower(*dn++) != mklower(*cp++))
goto next;
/* Is next root for both ? */
if (*dn == '\0' && *cp == '\0')
return (sp - msg);
if (*dn)
continue;
goto next;
case NS_CMPRSFLGS: /* indirection */
cp = msg + (((n & 0x3f) << 8) | *cp);
break;
default: /* illegal type */
errno = EMSGSIZE;
return (-1);
}
}
next: ;
}
errno = ENOENT;
return (-1);
}

4189
external/bsd/dhcp/dist/common/options.c vendored Normal file

File diff suppressed because it is too large Load Diff

365
external/bsd/dhcp/dist/common/packet.c vendored Normal file
View File

@@ -0,0 +1,365 @@
/* $NetBSD: packet.c,v 1.1.1.4 2014/07/12 11:57:46 spz Exp $ */
/* packet.c
Packet assembly code, originally contributed by Archie Cobbs. */
/*
* Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
* This code was originally contributed by Archie Cobbs, and is still
* very similar to that contribution, although the packet checksum code
* has been hacked significantly with the help of quite a few ISC DHCP
* users, without whose gracious and thorough help the checksum code would
* still be disabled.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: packet.c,v 1.1.1.4 2014/07/12 11:57:46 spz Exp $");
#include "dhcpd.h"
#if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
#endif /* PACKET_ASSEMBLY || PACKET_DECODING */
/* Compute the easy part of the checksum on a range of bytes. */
u_int32_t checksum (buf, nbytes, sum)
unsigned char *buf;
unsigned nbytes;
u_int32_t sum;
{
unsigned i;
#ifdef DEBUG_CHECKSUM
log_debug ("checksum (%x %d %x)", buf, nbytes, sum);
#endif
/* Checksum all the pairs of bytes first... */
for (i = 0; i < (nbytes & ~1U); i += 2) {
#ifdef DEBUG_CHECKSUM_VERBOSE
log_debug ("sum = %x", sum);
#endif
sum += (u_int16_t) ntohs(*((u_int16_t *)(buf + i)));
/* Add carry. */
if (sum > 0xFFFF)
sum -= 0xFFFF;
}
/* If there's a single byte left over, checksum it, too. Network
byte order is big-endian, so the remaining byte is the high byte. */
if (i < nbytes) {
#ifdef DEBUG_CHECKSUM_VERBOSE
log_debug ("sum = %x", sum);
#endif
sum += buf [i] << 8;
/* Add carry. */
if (sum > 0xFFFF)
sum -= 0xFFFF;
}
return sum;
}
/* Finish computing the checksum, and then put it into network byte order. */
u_int32_t wrapsum (sum)
u_int32_t sum;
{
#ifdef DEBUG_CHECKSUM
log_debug ("wrapsum (%x)", sum);
#endif
sum = ~sum & 0xFFFF;
#ifdef DEBUG_CHECKSUM_VERBOSE
log_debug ("sum = %x", sum);
#endif
#ifdef DEBUG_CHECKSUM
log_debug ("wrapsum returns %x", htons (sum));
#endif
return htons(sum);
}
#ifdef PACKET_ASSEMBLY
void assemble_hw_header (interface, buf, bufix, to)
struct interface_info *interface;
unsigned char *buf;
unsigned *bufix;
struct hardware *to;
{
switch (interface->hw_address.hbuf[0]) {
#if defined(HAVE_TR_SUPPORT)
case HTYPE_IEEE802:
assemble_tr_header(interface, buf, bufix, to);
break;
#endif
#if defined (DEC_FDDI)
case HTYPE_FDDI:
assemble_fddi_header(interface, buf, bufix, to);
break;
#endif
case HTYPE_INFINIBAND:
log_error("Attempt to assemble hw header for infiniband");
break;
case HTYPE_ETHER:
default:
assemble_ethernet_header(interface, buf, bufix, to);
break;
}
}
/* UDP header and IP header assembled together for convenience. */
void assemble_udp_ip_header (interface, buf, bufix,
from, to, port, data, len)
struct interface_info *interface;
unsigned char *buf;
unsigned *bufix;
u_int32_t from;
u_int32_t to;
u_int32_t port;
unsigned char *data;
unsigned len;
{
struct ip ip;
struct udphdr udp;
memset (&ip, 0, sizeof ip);
/* Fill out the IP header */
IP_V_SET (&ip, 4);
IP_HL_SET (&ip, 20);
ip.ip_tos = IPTOS_LOWDELAY;
ip.ip_len = htons(sizeof(ip) + sizeof(udp) + len);
ip.ip_id = 0;
ip.ip_off = 0;
ip.ip_ttl = 128;
ip.ip_p = IPPROTO_UDP;
ip.ip_sum = 0;
ip.ip_src.s_addr = from;
ip.ip_dst.s_addr = to;
/* Checksum the IP header... */
ip.ip_sum = wrapsum (checksum ((unsigned char *)&ip, sizeof ip, 0));
/* Copy the ip header into the buffer... */
memcpy (&buf [*bufix], &ip, sizeof ip);
*bufix += sizeof ip;
/* Fill out the UDP header */
udp.uh_sport = local_port; /* XXX */
udp.uh_dport = port; /* XXX */
udp.uh_ulen = htons(sizeof(udp) + len);
memset (&udp.uh_sum, 0, sizeof udp.uh_sum);
/* Compute UDP checksums, including the ``pseudo-header'', the UDP
header and the data. */
udp.uh_sum =
wrapsum (checksum ((unsigned char *)&udp, sizeof udp,
checksum (data, len,
checksum ((unsigned char *)
&ip.ip_src,
2 * sizeof ip.ip_src,
IPPROTO_UDP +
(u_int32_t)
ntohs (udp.uh_ulen)))));
/* Copy the udp header into the buffer... */
memcpy (&buf [*bufix], &udp, sizeof udp);
*bufix += sizeof udp;
}
#endif /* PACKET_ASSEMBLY */
#ifdef PACKET_DECODING
/* Decode a hardware header... */
/* Support for ethernet, TR and FDDI
* Doesn't support infiniband yet as the supported oses shouldn't get here
*/
ssize_t decode_hw_header (interface, buf, bufix, from)
struct interface_info *interface;
unsigned char *buf;
unsigned bufix;
struct hardware *from;
{
switch(interface->hw_address.hbuf[0]) {
#if defined (HAVE_TR_SUPPORT)
case HTYPE_IEEE802:
return (decode_tr_header(interface, buf, bufix, from));
#endif
#if defined (DEC_FDDI)
case HTYPE_FDDI:
return (decode_fddi_header(interface, buf, bufix, from));
#endif
case HTYPE_INFINIBAND:
log_error("Attempt to decode hw header for infiniband");
return (0);
case HTYPE_ETHER:
default:
return (decode_ethernet_header(interface, buf, bufix, from));
}
}
/* UDP header and IP header decoded together for convenience. */
ssize_t
decode_udp_ip_header(struct interface_info *interface,
unsigned char *buf, unsigned bufix,
struct sockaddr_in *from, unsigned buflen,
unsigned *rbuflen)
{
unsigned char *data;
struct ip ip;
struct udphdr udp;
unsigned char *upp, *endbuf;
u_int32_t ip_len, ulen, pkt_len;
u_int32_t sum, usum;
static int ip_packets_seen;
static int ip_packets_bad_checksum;
static int udp_packets_seen;
static int udp_packets_bad_checksum;
static int udp_packets_length_checked;
static int udp_packets_length_overflow;
unsigned len;
/* Designate the end of the input buffer for bounds checks. */
endbuf = buf + bufix + buflen;
/* Assure there is at least an IP header there. */
if ((buf + bufix + sizeof(ip)) > endbuf)
return -1;
/* Copy the IP header into a stack aligned structure for inspection.
* There may be bits in the IP header that we're not decoding, so we
* copy out the bits we grok and skip ahead by ip.ip_hl * 4.
*/
upp = buf + bufix;
memcpy(&ip, upp, sizeof(ip));
ip_len = (*upp & 0x0f) << 2;
upp += ip_len;
/* Check the IP packet length. */
pkt_len = ntohs(ip.ip_len);
if (pkt_len > buflen)
return -1;
/* Assure after ip_len bytes that there is enough room for a UDP header. */
if ((upp + sizeof(udp)) > endbuf)
return -1;
/* Copy the UDP header into a stack aligned structure for inspection. */
memcpy(&udp, upp, sizeof(udp));
#ifdef USERLAND_FILTER
/* Is it a UDP packet? */
if (ip.ip_p != IPPROTO_UDP)
return -1;
/* Is it to the port we're serving? */
if (udp.uh_dport != local_port)
return -1;
#endif /* USERLAND_FILTER */
ulen = ntohs(udp.uh_ulen);
if (ulen < sizeof(udp))
return -1;
udp_packets_length_checked++;
if ((upp + ulen) > endbuf) {
udp_packets_length_overflow++;
if ((udp_packets_length_checked > 4) &&
((udp_packets_length_checked /
udp_packets_length_overflow) < 2)) {
log_info("%d udp packets in %d too long - dropped",
udp_packets_length_overflow,
udp_packets_length_checked);
udp_packets_length_overflow = 0;
udp_packets_length_checked = 0;
}
return -1;
}
if ((ulen < sizeof(udp)) || ((upp + ulen) > endbuf))
return -1;
/* Check the IP header checksum - it should be zero. */
++ip_packets_seen;
if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
++ip_packets_bad_checksum;
if (ip_packets_seen > 4 &&
(ip_packets_seen / ip_packets_bad_checksum) < 2) {
log_info ("%d bad IP checksums seen in %d packets",
ip_packets_bad_checksum, ip_packets_seen);
ip_packets_seen = ip_packets_bad_checksum = 0;
}
return -1;
}
/* Copy out the IP source address... */
memcpy(&from->sin_addr, &ip.ip_src, 4);
/* Compute UDP checksums, including the ``pseudo-header'', the UDP
header and the data. If the UDP checksum field is zero, we're
not supposed to do a checksum. */
data = upp + sizeof(udp);
len = ulen - sizeof(udp);
usum = udp.uh_sum;
udp.uh_sum = 0;
/* XXX: We have to pass &udp, because we have to zero the checksum
* field before calculating the sum...'upp' isn't zeroed.
*/
sum = wrapsum(checksum((unsigned char *)&udp, sizeof(udp),
checksum(data, len,
checksum((unsigned char *)&ip.ip_src,
8, IPPROTO_UDP + ulen))));
udp_packets_seen++;
if (usum && usum != sum) {
udp_packets_bad_checksum++;
if (udp_packets_seen > 4 &&
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
log_info ("%d bad udp checksums in %d packets",
udp_packets_bad_checksum, udp_packets_seen);
udp_packets_seen = udp_packets_bad_checksum = 0;
}
return -1;
}
/* Copy out the port... */
memcpy (&from -> sin_port, &udp.uh_sport, sizeof udp.uh_sport);
/* Save the length of the UDP payload. */
if (rbuflen != NULL)
*rbuflen = len;
/* Return the index to the UDP payload. */
return ip_len + sizeof udp;
}
#endif /* PACKET_DECODING */

5673
external/bsd/dhcp/dist/common/parse.c vendored Normal file

File diff suppressed because it is too large Load Diff

1523
external/bsd/dhcp/dist/common/print.c vendored Normal file

File diff suppressed because it is too large Load Diff

137
external/bsd/dhcp/dist/common/raw.c vendored Normal file
View File

@@ -0,0 +1,137 @@
/* $NetBSD: raw.c,v 1.1.1.2 2014/07/12 11:57:46 spz Exp $ */
/* raw.c
BSD raw socket interface code... */
/* XXX
It's not clear how this should work, and that lack of clarity is
terribly detrimental to the NetBSD 1.1 kernel - it crashes and
burns.
Using raw sockets ought to be a big win over using BPF or something
like it, because you don't need to deal with the complexities of
the physical layer, but it appears not to be possible with existing
raw socket implementations. This may be worth revisiting in the
future. For now, this code can probably be considered a curiosity.
Sigh. */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: raw.c,v 1.1.1.2 2014/07/12 11:57:46 spz Exp $");
#include "dhcpd.h"
#if defined (USE_RAW_SEND)
#include <sys/uio.h>
/* Generic interface registration routine... */
void if_register_send (info)
struct interface_info *info;
{
struct sockaddr_in name;
int sock;
struct socklist *tmp;
int flag;
/* Set up the address we're going to connect to. */
name.sin_family = AF_INET;
name.sin_port = local_port;
name.sin_addr.s_addr = htonl (INADDR_BROADCAST);
memset (name.sin_zero, 0, sizeof (name.sin_zero));
/* List addresses on which we're listening. */
if (!quiet_interface_discovery)
log_info ("Sending on %s, port %d",
piaddr (info -> address), htons (local_port));
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
log_fatal ("Can't create dhcp socket: %m");
/* Set the BROADCAST option so that we can broadcast DHCP responses. */
flag = 1;
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
&flag, sizeof flag) < 0)
log_fatal ("Can't set SO_BROADCAST option on dhcp socket: %m");
/* Set the IP_HDRINCL flag so that we can supply our own IP
headers... */
if (setsockopt (sock, IPPROTO_IP, IP_HDRINCL, &flag, sizeof flag) < 0)
log_fatal ("Can't set IP_HDRINCL flag: %m");
info -> wfdesc = sock;
if (!quiet_interface_discovery)
log_info ("Sending on Raw/%s%s%s",
info -> name,
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_send (info)
struct interface_info *info;
{
close (info -> wfdesc);
info -> wfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling output on Raw/%s%s%s",
info -> name,
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
size_t send_packet (interface, packet, raw, len, from, to, hto)
struct interface_info *interface;
struct packet *packet;
struct dhcp_packet *raw;
size_t len;
struct in_addr from;
struct sockaddr_in *to;
struct hardware *hto;
{
unsigned char buf [256];
int bufp = 0;
struct iovec iov [2];
int result;
/* Assemble the headers... */
assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
to -> sin_addr.s_addr, to -> sin_port,
(unsigned char *)raw, len);
/* Fire it off */
iov [0].iov_base = (char *)buf;
iov [0].iov_len = bufp;
iov [1].iov_base = (char *)raw;
iov [1].iov_len = len;
result = writev(interface -> wfdesc, iov, 2);
if (result < 0)
log_error ("send_packet: %m");
return result;
}
#endif /* USE_SOCKET_SEND */

193
external/bsd/dhcp/dist/common/resolv.c vendored Normal file
View File

@@ -0,0 +1,193 @@
/* $NetBSD: resolv.c,v 1.1.1.2 2014/07/12 11:57:46 spz Exp $ */
/* resolv.c
Parser for /etc/resolv.conf file. */
/*
* Copyright (c) 2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: resolv.c,v 1.1.1.2 2014/07/12 11:57:46 spz Exp $");
#include "dhcpd.h"
struct name_server *name_servers;
struct domain_search_list *domains;
char path_resolv_conf [] = _PATH_RESOLV_CONF;
void read_resolv_conf (parse_time)
TIME parse_time;
{
int file;
struct parse *cfile;
const char *val;
int token;
struct name_server *sp, *sl, *ns;
struct domain_search_list *dp, *dl, *nd;
isc_result_t status;
if ((file = open (path_resolv_conf, O_RDONLY)) < 0) {
log_error ("Can't open %s: %m", path_resolv_conf);
return;
}
cfile = NULL;
status = new_parse(&cfile, file, NULL, 0, path_resolv_conf, 1);
if (status != ISC_R_SUCCESS || cfile == NULL)
return;
do {
token = next_token (&val, (unsigned *)0, cfile);
if (token == END_OF_FILE)
break;
else if (token == EOL)
continue;
else if (token == DOMAIN || token == SEARCH) {
do {
struct domain_search_list *nd, **dp;
char *dn;
dn = parse_host_name (cfile);
if (!dn)
break;
dp = &domains;
for (nd = domains; nd; nd = nd -> next) {
dp = &nd -> next;
if (!strcmp (nd -> domain, dn))
break;
}
if (!nd) {
nd = new_domain_search_list (MDL);
if (!nd)
log_fatal ("No memory for %s",
dn);
nd -> next =
(struct domain_search_list *)0;
*dp = nd;
nd -> domain = dn;
}
nd -> rcdate = parse_time;
token = peek_token (&val,
(unsigned *)0, cfile);
} while (token != EOL);
if (token != EOL) {
parse_warn (cfile,
"junk after domain declaration");
skip_to_semi (cfile);
}
skip_token(&val, (unsigned *)0, cfile);
} else if (token == NAMESERVER) {
struct name_server *ns, **sp;
struct iaddr iaddr;
parse_ip_addr (cfile, &iaddr);
sp = &name_servers;
for (ns = name_servers; ns; ns = ns -> next) {
sp = &ns -> next;
if (!memcmp (&ns -> addr.sin_addr,
iaddr.iabuf, iaddr.len))
break;
}
if (!ns) {
ns = new_name_server (MDL);
if (!ns)
log_fatal ("No memory for nameserver %s",
piaddr (iaddr));
ns -> next = (struct name_server *)0;
*sp = ns;
memcpy (&ns -> addr.sin_addr,
iaddr.iabuf, iaddr.len);
#ifdef HAVE_SA_LEN
ns -> addr.sin_len = sizeof ns -> addr;
#endif
ns -> addr.sin_family = AF_INET;
ns -> addr.sin_port = htons (53);
memset (ns -> addr.sin_zero, 0,
sizeof ns -> addr.sin_zero);
}
ns -> rcdate = parse_time;
skip_to_semi (cfile);
} else
skip_to_semi (cfile); /* Ignore what we don't grok. */
} while (1);
skip_token(&val, (unsigned *)0, cfile);
/* Lose servers that are no longer in /etc/resolv.conf. */
sl = (struct name_server *)0;
for (sp = name_servers; sp; sp = ns) {
ns = sp -> next;
if (sp -> rcdate != parse_time) {
if (sl)
sl -> next = sp -> next;
else
name_servers = sp -> next;
/* We can't actually free the name server structure,
because somebody might be hanging on to it. If
your /etc/resolv.conf file changes a lot, this
could be a noticeable memory leak. */
} else
sl = sp;
}
/* Lose domains that are no longer in /etc/resolv.conf. */
dl = (struct domain_search_list *)0;
for (dp = domains; dp; dp = nd) {
nd = dp -> next;
if (dp -> rcdate != parse_time) {
if (dl)
dl -> next = dp -> next;
else
domains = dp -> next;
free_domain_search_list (dp, MDL);
} else
dl = dp;
}
end_parse (&cfile);
}
/* Pick a name server from the /etc/resolv.conf file. */
struct name_server *first_name_server ()
{
static TIME rcdate;
struct stat st;
/* Check /etc/resolv.conf and reload it if it's changed. */
if (cur_time > rcdate) {
if (stat (path_resolv_conf, &st) < 0) {
log_error ("Can't stat %s", path_resolv_conf);
return (struct name_server *)0;
}
if (st.st_mtime > rcdate) {
rcdate = cur_time + 1;
read_resolv_conf (rcdate);
}
}
return name_servers;
}

1224
external/bsd/dhcp/dist/common/socket.c vendored Normal file

File diff suppressed because it is too large Load Diff

1503
external/bsd/dhcp/dist/common/tables.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
Content-Type: application/X-atf-atffile; version="1"
prop: test-suite = dhcp4
tp-glob: *_unittest

View File

@@ -0,0 +1,30 @@
SUBDIRS = .
AM_CPPFLAGS = $(ATF_CFLAGS) -I$(top_srcdir)/includes
EXTRA_DIST = Atffile
ATF_TESTS =
if HAVE_ATF
ATF_TESTS += alloc_unittest dns_unittest
alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
alloc_unittest_LDADD = $(ATF_LDFLAGS)
alloc_unittest_LDADD += ../libdhcp.a \
../../omapip/libomapi.a ../../bind/lib/libirs.a \
../../bind/lib/libdns.a ../../bind/lib/libisccfg.a ../../bind/lib/libisc.a
dns_unittest_SOURCES = dns_unittest.c $(top_srcdir)/tests/t_api_dhcp.c
dns_unittest_LDADD = $(ATF_LDFLAGS)
dns_unittest_LDADD += ../libdhcp.a \
../../omapip/libomapi.a ../../bind/lib/libirs.a \
../../bind/lib/libdns.a ../../bind/lib/libisccfg.a ../../bind/lib/libisc.a
check: $(ATF_TESTS)
atf-run | atf-report
endif
check_PROGRAMS = $(ATF_TESTS)

View File

@@ -0,0 +1,701 @@
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@HAVE_ATF_TRUE@am__append_1 = alloc_unittest dns_unittest
check_PROGRAMS = $(am__EXEEXT_2)
subdir = common/tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/includes/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_ATF_TRUE@am__EXEEXT_1 = alloc_unittest$(EXEEXT) \
@HAVE_ATF_TRUE@ dns_unittest$(EXEEXT)
am__EXEEXT_2 = $(am__EXEEXT_1)
am__alloc_unittest_SOURCES_DIST = test_alloc.c \
$(top_srcdir)/tests/t_api_dhcp.c
@HAVE_ATF_TRUE@am_alloc_unittest_OBJECTS = test_alloc.$(OBJEXT) \
@HAVE_ATF_TRUE@ t_api_dhcp.$(OBJEXT)
alloc_unittest_OBJECTS = $(am_alloc_unittest_OBJECTS)
am__DEPENDENCIES_1 =
@HAVE_ATF_TRUE@alloc_unittest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@HAVE_ATF_TRUE@ ../libdhcp.a ../../omapip/libomapi.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libirs.a ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
am__dns_unittest_SOURCES_DIST = dns_unittest.c \
$(top_srcdir)/tests/t_api_dhcp.c
@HAVE_ATF_TRUE@am_dns_unittest_OBJECTS = dns_unittest.$(OBJEXT) \
@HAVE_ATF_TRUE@ t_api_dhcp.$(OBJEXT)
dns_unittest_OBJECTS = $(am_dns_unittest_OBJECTS)
@HAVE_ATF_TRUE@dns_unittest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
@HAVE_ATF_TRUE@ ../libdhcp.a ../../omapip/libomapi.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libirs.a ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(alloc_unittest_SOURCES) $(dns_unittest_SOURCES)
DIST_SOURCES = $(am__alloc_unittest_SOURCES_DIST) \
$(am__dns_unittest_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
ATF_CFLAGS = @ATF_CFLAGS@
ATF_LDFLAGS = @ATF_LDFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_CFLAGS = @LDAP_CFLAGS@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_prefix_program = @ac_prefix_program@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
byte_order = @byte_order@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = .
AM_CPPFLAGS = $(ATF_CFLAGS) -I$(top_srcdir)/includes
EXTRA_DIST = Atffile
ATF_TESTS = $(am__append_1)
@HAVE_ATF_TRUE@alloc_unittest_SOURCES = test_alloc.c $(top_srcdir)/tests/t_api_dhcp.c
@HAVE_ATF_TRUE@alloc_unittest_LDADD = $(ATF_LDFLAGS) ../libdhcp.a \
@HAVE_ATF_TRUE@ ../../omapip/libomapi.a ../../bind/lib/libirs.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
@HAVE_ATF_TRUE@dns_unittest_SOURCES = dns_unittest.c $(top_srcdir)/tests/t_api_dhcp.c
@HAVE_ATF_TRUE@dns_unittest_LDADD = $(ATF_LDFLAGS) ../libdhcp.a \
@HAVE_ATF_TRUE@ ../../omapip/libomapi.a ../../bind/lib/libirs.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libdns.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisccfg.a \
@HAVE_ATF_TRUE@ ../../bind/lib/libisc.a
all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign common/tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign common/tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
alloc_unittest$(EXEEXT): $(alloc_unittest_OBJECTS) $(alloc_unittest_DEPENDENCIES) $(EXTRA_alloc_unittest_DEPENDENCIES)
@rm -f alloc_unittest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(alloc_unittest_OBJECTS) $(alloc_unittest_LDADD) $(LIBS)
dns_unittest$(EXEEXT): $(dns_unittest_OBJECTS) $(dns_unittest_DEPENDENCIES) $(EXTRA_dns_unittest_DEPENDENCIES)
@rm -f dns_unittest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(dns_unittest_OBJECTS) $(dns_unittest_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dns_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_api_dhcp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_alloc.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
t_api_dhcp.o: $(top_srcdir)/tests/t_api_dhcp.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT t_api_dhcp.o -MD -MP -MF $(DEPDIR)/t_api_dhcp.Tpo -c -o t_api_dhcp.o `test -f '$(top_srcdir)/tests/t_api_dhcp.c' || echo '$(srcdir)/'`$(top_srcdir)/tests/t_api_dhcp.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_api_dhcp.Tpo $(DEPDIR)/t_api_dhcp.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/tests/t_api_dhcp.c' object='t_api_dhcp.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o t_api_dhcp.o `test -f '$(top_srcdir)/tests/t_api_dhcp.c' || echo '$(srcdir)/'`$(top_srcdir)/tests/t_api_dhcp.c
t_api_dhcp.obj: $(top_srcdir)/tests/t_api_dhcp.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT t_api_dhcp.obj -MD -MP -MF $(DEPDIR)/t_api_dhcp.Tpo -c -o t_api_dhcp.obj `if test -f '$(top_srcdir)/tests/t_api_dhcp.c'; then $(CYGPATH_W) '$(top_srcdir)/tests/t_api_dhcp.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/tests/t_api_dhcp.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_api_dhcp.Tpo $(DEPDIR)/t_api_dhcp.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/tests/t_api_dhcp.c' object='t_api_dhcp.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o t_api_dhcp.obj `if test -f '$(top_srcdir)/tests/t_api_dhcp.c'; then $(CYGPATH_W) '$(top_srcdir)/tests/t_api_dhcp.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/tests/t_api_dhcp.c'; fi`
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(am__recursive_targets) check-am install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-checkPROGRAMS clean-generic cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am
@HAVE_ATF_TRUE@check: $(ATF_TESTS)
@HAVE_ATF_TRUE@ atf-run | atf-report
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,176 @@
/* $NetBSD: dns_unittest.c,v 1.1.1.1 2014/07/12 11:57:48 spz Exp $ */
/*
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <config.h>
#include <atf-c.h>
#include "dhcpd.h"
/*
* This file provides unit tests for the dns and ddns code.
* Currently this is limited to verifying the dhcid code is
* working properly. In time we may be able to expand the
* tests to cover other areas.
*
* The tests for the interim txt records comapre to previous
* internally generated values.
*
* The tests for the standard dhcid records compare to values
* from rfc 4701
*/
char *name_1 = "chi6.example.com";
u_int8_t clid_1[] = {0x00, 0x01, 0x00, 0x06, 0x41, 0x2d, 0xf1, 0x66, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
u_int8_t std_result_1[] = {0x00, 0x02, 0x01, 0x63, 0x6f, 0xc0, 0xb8, 0x27, 0x1c,
0x82, 0x82, 0x5b, 0xb1, 0xac, 0x5c, 0x41, 0xcf, 0x53,
0x51, 0xaa, 0x69, 0xb4, 0xfe, 0xbd, 0x94, 0xe8, 0xf1,
0x7c, 0xdb, 0x95, 0x00, 0x0d, 0xa4, 0x8c, 0x40};
char *int_result_1 = "\"02abf8cd3753dc1847be40858becd77865";
char *name_2 = "chi.example.com";
u_int8_t clid_2[] = {0x01, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c};
u_int8_t std_result_2[] = {0x00, 0x01, 0x01, 0x39, 0x20, 0xfe, 0x5d, 0x1d, 0xce,
0xb3, 0xfd, 0x0b, 0xa3, 0x37, 0x97, 0x56, 0xa7, 0x0d,
0x73, 0xb1, 0x70, 0x09, 0xf4, 0x1d, 0x58, 0xbd, 0xdb,
0xfc, 0xd6, 0xa2, 0x50, 0x39, 0x56, 0xd8, 0xda};
char *int_result_2 = "\"31934ffa9344a3ab86c380505a671e5113";
char *name_3 = "client.example.com";
u_int8_t clid_3[] = {0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
u_int8_t std_result_3[] = {0x00, 0x00, 0x01, 0xc4, 0xb9, 0xa5, 0xb2, 0x49, 0x65,
0x13, 0x43, 0x15, 0x8d, 0xde, 0x7b, 0xcc, 0x77, 0x16,
0x98, 0x41, 0xf7, 0xa4, 0x24, 0x3a, 0x57, 0x2b, 0x5c,
0x28, 0x3f, 0xff, 0xed, 0xeb, 0x3f, 0x75, 0xe6};
char *int_result_3 = "\"0046b6cacea62dc1d4567b068175d1f808";
void call_get_std_dhcid(int test, int type,
u_int8_t *clid, unsigned clidlen,
char *name, unsigned namelen,
u_int8_t *dhcid, unsigned dhcid_len)
{
dhcp_ddns_cb_t ddns_cb;
struct data_string *id;
memset(&ddns_cb, 0, sizeof(ddns_cb));
ddns_cb.dhcid_class = dns_rdatatype_dhcid;;
id = &ddns_cb.fwd_name;
if (!buffer_allocate(&id->buffer, namelen, MDL))
atf_tc_fail("Unable to allocate buffer for std test %d", test);
id->data = id->buffer->data;
memcpy(id->buffer->data, name, namelen);
id->len = namelen;
if (get_dhcid(&ddns_cb, type, clid, clidlen) != 1) {
atf_tc_fail("Unable to get std dhcid for %d", test);
} else if (ddns_cb.dhcid_class != dns_rdatatype_dhcid) {
atf_tc_fail("Wrong class for std dhcid for %d", test);
} else if (ddns_cb.dhcid.len != dhcid_len) {
atf_tc_fail("Wrong length for std dhcid for %d", test);
} else if (memcmp(ddns_cb.dhcid.data, dhcid, dhcid_len) != 0) {
atf_tc_fail("Wrong digest for std dhcid for %d", test);
}
/* clean up */
data_string_forget(&ddns_cb.dhcid, MDL);
return;
}
ATF_TC(standard_dhcid);
ATF_TC_HEAD(standard_dhcid, tc)
{
atf_tc_set_md_var(tc, "descr", "Verify standard dhcid construction.");
}
ATF_TC_BODY(standard_dhcid, tc)
{
call_get_std_dhcid(1, 2, clid_1, sizeof(clid_1),
name_1, strlen(name_1),
std_result_1, 35);
call_get_std_dhcid(2, 1, clid_2, sizeof(clid_2),
name_2, strlen(name_2),
std_result_2, 35);
call_get_std_dhcid(3, 0, clid_3, sizeof(clid_3),
name_3, strlen(name_3),
std_result_3, 35);
}
void call_get_int_dhcid(int test, int type,
u_int8_t *clid, unsigned clidlen,
char *dhcid, unsigned dhcid_len)
{
dhcp_ddns_cb_t ddns_cb;
memset(&ddns_cb, 0, sizeof(ddns_cb));
ddns_cb.dhcid_class = dns_rdatatype_txt;;
if (get_dhcid(&ddns_cb, type, clid, clidlen) != 1) {
atf_tc_fail("Unable to get txt dhcid for %d", test);
} else if (ddns_cb.dhcid_class != dns_rdatatype_txt) {
atf_tc_fail("Wrong class for txt dhcid for %d", test);
} else if (ddns_cb.dhcid.len != dhcid_len) {
atf_tc_fail("Wrong length for txt dhcid for %d", test);
} else if (memcmp(ddns_cb.dhcid.data, dhcid, dhcid_len) != 0) {
atf_tc_fail("Wrong digest for txt dhcid for %d", test);
}
/* clean up */
data_string_forget(&ddns_cb.dhcid, MDL);
return;
}
ATF_TC(interim_dhcid);
ATF_TC_HEAD(interim_dhcid, tc)
{
atf_tc_set_md_var(tc, "descr", "Verify interim dhcid construction.");
}
ATF_TC_BODY(interim_dhcid, tc)
{
call_get_int_dhcid(1, 2, clid_1, sizeof(clid_1),
int_result_1, 35);
call_get_int_dhcid(2, DHO_DHCP_CLIENT_IDENTIFIER,
clid_2, sizeof(clid_2),
int_result_2, 35);
call_get_int_dhcid(3, 0, clid_3, sizeof(clid_3),
int_result_3, 35);
}
/* This macro defines main() method that will call specified
test cases. tp and simple_test_case names can be whatever you want
as long as it is a valid variable identifier. */
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, interim_dhcid);
ATF_TP_ADD_TC(tp, standard_dhcid);
return (atf_no_error());
}

View File

@@ -0,0 +1,402 @@
/* $NetBSD: test_alloc.c,v 1.1.1.3 2014/07/12 11:57:48 spz Exp $ */
/*
* Copyright (c) 2007,2009,2012 by Internet Systems Consortium, Inc. ("ISC")
*
* We test the functions provided in alloc.c here. These are very
* basic functions, and it is very important that they work correctly.
*
* You can see two different styles of testing:
*
* - In the first, we have a single test for each function that tests
* all of the possible ways it can operate. (This is the case for
* the buffer tests.)
*
* - In the second, we have a separate test for each of the ways a
* function can operate. (This is the case for the data_string
* tests.)
*
* The advantage of a single test per function is that you have fewer
* tests, and less duplicated and extra code. The advantage of having
* a separate test is that each test is simpler. Plus if you need to
* allow certain tests to fail for some reason (known bugs that are
* hard to fix for example), then
*/
/** @TODO: dmalloc() test */
#include "config.h"
#include <atf-c.h>
#include "dhcpd.h"
ATF_TC(buffer_allocate);
ATF_TC_HEAD(buffer_allocate, tc) {
atf_tc_set_md_var(tc, "descr", "buffer_allocate basic test");
}
ATF_TC_BODY(buffer_allocate, tc) {
struct buffer *buf = 0;
/*
* Check a 0-length buffer.
*/
buf = NULL;
if (!buffer_allocate(&buf, 0, MDL)) {
atf_tc_fail("failed on 0-len buffer");
}
if (!buffer_dereference(&buf, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
if (buf != NULL) {
atf_tc_fail("buffer_dereference() did not NULL-out buffer");
}
/*
* Check an actual buffer.
*/
buf = NULL;
if (!buffer_allocate(&buf, 100, MDL)) {
atf_tc_fail("failed on allocate 100 bytes\n");
}
if (!buffer_dereference(&buf, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
if (buf != NULL) {
atf_tc_fail("buffer_dereference() did not NULL-out buffer");
}
/*
* Okay, we're happy.
*/
atf_tc_pass();
}
ATF_TC(buffer_reference);
ATF_TC_HEAD(buffer_reference, tc) {
atf_tc_set_md_var(tc, "descr", "buffer_reference basic test");
}
ATF_TC_BODY(buffer_reference, tc) {
struct buffer *a, *b;
/*
* Create a buffer.
*/
a = NULL;
if (!buffer_allocate(&a, 100, MDL)) {
atf_tc_fail("failed on allocate 100 bytes");
}
/**
* Confirm buffer_reference() doesn't work if we pass in NULL.
*
* @TODO: we should confirm we get an error message here.
*/
if (buffer_reference(NULL, a, MDL)) {
atf_tc_fail("succeeded on an error input");
}
/**
* @TODO: we should confirm we get an error message if we pass
* a non-NULL target.
*/
/*
* Confirm we work under normal circumstances.
*/
b = NULL;
if (!buffer_reference(&b, a, MDL)) {
atf_tc_fail("buffer_reference() failed");
}
if (b != a) {
atf_tc_fail("incorrect pointer returned");
}
if (b->refcnt != 2) {
atf_tc_fail("incorrect refcnt");
}
/*
* Clean up.
*/
if (!buffer_dereference(&b, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
if (!buffer_dereference(&a, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
}
ATF_TC(buffer_dereference);
ATF_TC_HEAD(buffer_dereference, tc) {
atf_tc_set_md_var(tc, "descr", "buffer_dereference basic test");
}
ATF_TC_BODY(buffer_dereference, tc) {
struct buffer *a, *b;
/**
* Confirm buffer_dereference() doesn't work if we pass in NULL.
*
* TODO: we should confirm we get an error message here.
*/
if (buffer_dereference(NULL, MDL)) {
atf_tc_fail("succeeded on an error input");
}
/**
* Confirm buffer_dereference() doesn't work if we pass in
* a pointer to NULL.
*
* @TODO: we should confirm we get an error message here.
*/
a = NULL;
if (buffer_dereference(&a, MDL)) {
atf_tc_fail("succeeded on an error input");
}
/*
* Confirm we work under normal circumstances.
*/
a = NULL;
if (!buffer_allocate(&a, 100, MDL)) {
atf_tc_fail("failed on allocate");
}
if (!buffer_dereference(&a, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
if (a != NULL) {
atf_tc_fail("non-null buffer after buffer_dereference()");
}
/**
* Confirm we get an error from negative refcnt.
*
* @TODO: we should confirm we get an error message here.
*/
a = NULL;
if (!buffer_allocate(&a, 100, MDL)) {
atf_tc_fail("failed on allocate");
}
b = NULL;
if (!buffer_reference(&b, a, MDL)) {
atf_tc_fail("buffer_reference() failed");
}
a->refcnt = 0; /* purposely set to invalid value */
if (buffer_dereference(&a, MDL)) {
atf_tc_fail("buffer_dereference() succeeded on error input");
}
a->refcnt = 2;
if (!buffer_dereference(&b, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
if (!buffer_dereference(&a, MDL)) {
atf_tc_fail("buffer_dereference() failed");
}
}
ATF_TC(data_string_forget);
ATF_TC_HEAD(data_string_forget, tc) {
atf_tc_set_md_var(tc, "descr", "data_string_forget basic test");
}
ATF_TC_BODY(data_string_forget, tc) {
struct buffer *buf;
struct data_string a;
const char *str = "Lorem ipsum dolor sit amet turpis duis.";
/*
* Create the string we want to forget.
*/
memset(&a, 0, sizeof(a));
a.len = strlen(str);
buf = NULL;
if (!buffer_allocate(&buf, a.len, MDL)) {
atf_tc_fail("out of memory");
}
if (!buffer_reference(&a.buffer, buf, MDL)) {
atf_tc_fail("buffer_reference() failed");
}
a.data = a.buffer->data;
memcpy(a.buffer->data, str, a.len);
/*
* Forget and confirm we've forgotten.
*/
data_string_forget(&a, MDL);
if (a.len != 0) {
atf_tc_fail("incorrect length");
}
if (a.data != NULL) {
atf_tc_fail("incorrect data");
}
if (a.terminated) {
atf_tc_fail("incorrect terminated");
}
if (a.buffer != NULL) {
atf_tc_fail("incorrect buffer");
}
if (buf->refcnt != 1) {
atf_tc_fail("too many references to buf");
}
/*
* Clean up buffer.
*/
if (!buffer_dereference(&buf, MDL)) {
atf_tc_fail("buffer_reference() failed");
}
}
ATF_TC(data_string_forget_nobuf);
ATF_TC_HEAD(data_string_forget_nobuf, tc) {
atf_tc_set_md_var(tc, "descr", "data_string_forget test, "
"data_string without buffer");
}
ATF_TC_BODY(data_string_forget_nobuf, tc) {
struct data_string a;
const char *str = "Lorem ipsum dolor sit amet massa nunc.";
/*
* Create the string we want to forget.
*/
memset(&a, 0, sizeof(a));
a.len = strlen(str);
a.data = (const unsigned char *)str;
a.terminated = 1;
/*
* Forget and confirm we've forgotten.
*/
data_string_forget(&a, MDL);
if (a.len != 0) {
atf_tc_fail("incorrect length");
}
if (a.data != NULL) {
atf_tc_fail("incorrect data");
}
if (a.terminated) {
atf_tc_fail("incorrect terminated");
}
if (a.buffer != NULL) {
atf_tc_fail("incorrect buffer");
}
}
ATF_TC(data_string_copy);
ATF_TC_HEAD(data_string_copy, tc) {
atf_tc_set_md_var(tc, "descr", "data_string_copy basic test");
}
ATF_TC_BODY(data_string_copy, tc) {
struct data_string a, b;
const char *str = "Lorem ipsum dolor sit amet orci aliquam.";
/*
* Create the string we want to copy.
*/
memset(&a, 0, sizeof(a));
a.len = strlen(str);
if (!buffer_allocate(&a.buffer, a.len, MDL)) {
atf_tc_fail("out of memory");
}
a.data = a.buffer->data;
memcpy(a.buffer->data, str, a.len);
/*
* Copy the string, and confirm it works.
*/
memset(&b, 0, sizeof(b));
data_string_copy(&b, &a, MDL);
if (b.len != a.len) {
atf_tc_fail("incorrect length");
}
if (b.data != a.data) {
atf_tc_fail("incorrect data");
}
if (b.terminated != a.terminated) {
atf_tc_fail("incorrect terminated");
}
if (b.buffer != a.buffer) {
atf_tc_fail("incorrect buffer");
}
/*
* Clean up.
*/
data_string_forget(&b, MDL);
data_string_forget(&a, MDL);
}
ATF_TC(data_string_copy_nobuf);
ATF_TC_HEAD(data_string_copy_nobuf, tc) {
atf_tc_set_md_var(tc, "descr", "data_string_copy test, "
"data_string without buffer");
}
ATF_TC_BODY(data_string_copy_nobuf, tc) {
struct data_string a, b;
const char *str = "Lorem ipsum dolor sit amet cras amet.";
/*
* Create the string we want to copy.
*/
memset(&a, 0, sizeof(a));
a.len = strlen(str);
a.data = (const unsigned char *)str;
a.terminated = 1;
/*
* Copy the string, and confirm it works.
*/
memset(&b, 0, sizeof(b));
data_string_copy(&b, &a, MDL);
if (b.len != a.len) {
atf_tc_fail("incorrect length");
}
if (b.data != a.data) {
atf_tc_fail("incorrect data");
}
if (b.terminated != a.terminated) {
atf_tc_fail("incorrect terminated");
}
if (b.buffer != a.buffer) {
atf_tc_fail("incorrect buffer");
}
/*
* Clean up.
*/
data_string_forget(&b, MDL);
data_string_forget(&a, MDL);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, buffer_allocate);
ATF_TP_ADD_TC(tp, buffer_reference);
ATF_TP_ADD_TC(tp, buffer_dereference);
ATF_TP_ADD_TC(tp, data_string_forget);
ATF_TP_ADD_TC(tp, data_string_forget_nobuf);
ATF_TP_ADD_TC(tp, data_string_copy);
ATF_TP_ADD_TC(tp, data_string_copy_nobuf);
return (atf_no_error());
}

335
external/bsd/dhcp/dist/common/tr.c vendored Normal file
View File

@@ -0,0 +1,335 @@
/* $NetBSD: tr.c,v 1.1.1.3 2014/07/12 11:57:48 spz Exp $ */
/* tr.c
token ring interface support
Contributed in May of 1999 by Andrew Chittenden */
/*
* Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: tr.c,v 1.1.1.3 2014/07/12 11:57:48 spz Exp $");
#include "dhcpd.h"
#if defined (HAVE_TR_SUPPORT) && \
(defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING))
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
#include "netinet/if_tr.h"
#include <sys/time.h>
/*
* token ring device handling subroutines. These are required as token-ring
* does not have a simple on-the-wire header but requires the use of
* source routing
*/
static int insert_source_routing (struct trh_hdr *trh, struct interface_info* interface);
static void save_source_routing (struct trh_hdr *trh, struct interface_info* interface);
static void expire_routes (void);
/*
* As we keep a list of interesting routing information only, a singly
* linked list is all we need
*/
struct routing_entry {
struct routing_entry *next;
unsigned char addr[TR_ALEN];
unsigned char iface[5];
u_int16_t rcf; /* route control field */
u_int16_t rseg[8]; /* routing registers */
unsigned long access_time; /* time we last used this entry */
};
static struct routing_entry *routing_info = NULL;
static int routing_timeout = 10;
static struct timeval routing_timer;
void assemble_tr_header (interface, buf, bufix, to)
struct interface_info *interface;
unsigned char *buf;
unsigned *bufix;
struct hardware *to;
{
struct trh_hdr *trh;
int hdr_len;
struct trllc *llc;
/* set up the token header */
trh = (struct trh_hdr *) &buf[*bufix];
if (interface -> hw_address.hlen - 1 == sizeof (trh->saddr))
memcpy (trh->saddr, &interface -> hw_address.hbuf [1],
sizeof (trh->saddr));
else
memset (trh->saddr, 0x00, sizeof (trh->saddr));
if (to && to -> hlen == 7) /* XXX */
memcpy (trh->daddr, &to -> hbuf [1], sizeof trh->daddr);
else
memset (trh->daddr, 0xff, sizeof (trh->daddr));
hdr_len = insert_source_routing (trh, interface);
trh->ac = AC;
trh->fc = LLC_FRAME;
/* set up the llc header for snap encoding after the tr header */
llc = (struct trllc *)(buf + *bufix + hdr_len);
llc->dsap = EXTENDED_SAP;
llc->ssap = EXTENDED_SAP;
llc->llc = UI_CMD;
llc->protid[0] = 0;
llc->protid[1] = 0;
llc->protid[2] = 0;
llc->ethertype = htons(ETHERTYPE_IP);
hdr_len += sizeof(struct trllc);
*bufix += hdr_len;
}
static unsigned char tr_broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/*
* decoding the token header is a bit complex as you can see here. It is
* further complicated by the linux kernel stripping off some valuable
* information (see comment below) even though we've asked for the raw
* packets.
*/
ssize_t decode_tr_header (interface, buf, bufix, from)
struct interface_info *interface;
unsigned char *buf;
unsigned bufix;
struct hardware *from;
{
struct trh_hdr *trh = (struct trh_hdr *) buf + bufix;
struct trllc *llc;
struct ip *ip;
struct udphdr *udp;
unsigned int route_len = 0;
ssize_t hdr_len;
struct timeval now;
/* see whether any source routing information has expired */
gettimeofday(&now, NULL);
if (routing_timer.tv_sec == 0)
routing_timer.tv_sec = now.tv_sec + routing_timeout;
else if ((now.tv_sec - routing_timer.tv_sec) > 0)
expire_routes();
/* the kernel might have stripped off the source
* routing bit. We try a heuristic to determine whether
* this is the case and put it back on if so
*/
route_len = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
llc = (struct trllc *)(buf + bufix + sizeof(struct trh_hdr)-TR_MAXRIFLEN+route_len);
if (llc->dsap == EXTENDED_SAP
&& llc->ssap == EXTENDED_SAP
&& llc->llc == UI_CMD
&& llc->protid[0] == 0
&& llc->protid[1] == 0
&& llc->protid[2] == 0) {
/* say there is source routing information present */
trh->saddr[0] |= TR_RII;
}
if (trh->saddr[0] & TR_RII)
route_len = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
else
route_len = 0;
hdr_len = sizeof (struct trh_hdr) - TR_MAXRIFLEN + route_len;
/* now filter out unwanted packets: this is based on the packet
* filter code in bpf.c */
llc = (struct trllc *)(buf + bufix + hdr_len);
ip = (struct ip *) (llc + 1);
udp = (struct udphdr *) ((unsigned char*) ip + IP_HL (ip));
/* make sure it is a snap encoded, IP, UDP, unfragmented packet sent
* to our port */
if (llc->dsap != EXTENDED_SAP
|| ntohs(llc->ethertype) != ETHERTYPE_IP
|| ip->ip_p != IPPROTO_UDP
|| (ntohs (ip->ip_off) & IP_OFFMASK) != 0
|| udp->uh_dport != local_port)
return -1;
/* only save source routing information for packets from valued hosts */
save_source_routing(trh, interface);
return hdr_len + sizeof (struct trllc);
}
/* insert_source_routing inserts source route information into the token ring
* header
*/
static int insert_source_routing (trh, interface)
struct trh_hdr *trh;
struct interface_info* interface;
{
struct routing_entry *rover;
struct timeval now;
unsigned int route_len = 0;
gettimeofday(&now, NULL);
/* single route broadcasts as per rfc 1042 */
if (memcmp(trh->daddr, tr_broadcast,TR_ALEN) == 0) {
trh->saddr[0] |= TR_RII;
trh->rcf = ((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK;
trh->rcf |= (TR_RCF_FRAME2K | TR_RCF_LIMITED_BROADCAST);
trh->rcf = htons(trh->rcf);
} else {
/* look for a routing entry */
for (rover = routing_info; rover != NULL; rover = rover->next) {
if (memcmp(rover->addr, trh->daddr, TR_ALEN) == 0)
break;
}
if (rover != NULL) {
/* success: route that frame */
if ((rover->rcf & TR_RCF_LEN_MASK) >> 8) {
u_int16_t rcf = rover->rcf;
memcpy(trh->rseg,rover->rseg,sizeof(trh->rseg));
rcf ^= TR_RCF_DIR_BIT;
rcf &= ~TR_RCF_BROADCAST_MASK;
trh->rcf = htons(rcf);
trh->saddr[0] |= TR_RII;
}
rover->access_time = now.tv_sec;
} else {
/* we don't have any routing information so send a
* limited broadcast */
trh->saddr[0] |= TR_RII;
trh->rcf = ((sizeof(trh->rcf)) << 8) & TR_RCF_LEN_MASK;
trh->rcf |= (TR_RCF_FRAME2K | TR_RCF_LIMITED_BROADCAST);
trh->rcf = htons(trh->rcf);
}
}
/* return how much of the header we've actually used */
if (trh->saddr[0] & TR_RII)
route_len = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
else
route_len = 0;
return sizeof (struct trh_hdr) - TR_MAXRIFLEN + route_len;
}
/*
* save any source routing information
*/
static void save_source_routing(trh, interface)
struct trh_hdr *trh;
struct interface_info *interface;
{
struct routing_entry *rover;
struct timeval now;
unsigned char saddr[TR_ALEN];
u_int16_t rcf = 0;
gettimeofday(&now, NULL);
memcpy(saddr, trh->saddr, sizeof(saddr));
saddr[0] &= 0x7f; /* strip off source routing present flag */
/* scan our table to see if we've got it */
for (rover = routing_info; rover != NULL; rover = rover->next) {
if (memcmp(&rover->addr[0], &saddr[0], TR_ALEN) == 0)
break;
}
/* found an entry so update it with fresh information */
if (rover != NULL) {
if ((trh->saddr[0] & TR_RII) &&
((ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8) > 2) {
rcf = ntohs(trh->rcf);
rcf &= ~TR_RCF_BROADCAST_MASK;
memcpy(rover->rseg, trh->rseg, sizeof(rover->rseg));
}
rover->rcf = rcf;
rover->access_time = now.tv_sec;
return; /* that's all folks */
}
/* no entry found, so create one */
rover = dmalloc (sizeof (struct routing_entry), MDL);
if (rover == NULL) {
fprintf(stderr,
"%s: unable to save source routing information\n",
__FILE__);
return;
}
memcpy(rover->addr, saddr, sizeof(rover->addr));
memcpy(rover->iface, interface->name, 5);
rover->access_time = now.tv_sec;
if (trh->saddr[0] & TR_RII) {
if (((ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8) > 2) {
rcf = ntohs(trh->rcf);
rcf &= ~TR_RCF_BROADCAST_MASK;
memcpy(rover->rseg, trh->rseg, sizeof(rover->rseg));
}
rover->rcf = rcf;
}
/* insert into list */
rover->next = routing_info;
routing_info = rover;
return;
}
/*
* get rid of old routes
*/
static void expire_routes()
{
struct routing_entry *rover;
struct routing_entry **prover = &routing_info;
struct timeval now;
gettimeofday(&now, NULL);
while((rover = *prover) != NULL) {
if ((now.tv_sec - rover->access_time) > routing_timeout) {
*prover = rover->next;
dfree (rover, MDL);
} else
prover = &rover->next;
}
/* Reset the timer */
routing_timer.tv_sec = now.tv_sec + routing_timeout;
routing_timer.tv_usec = now.tv_usec;
}
#endif

4088
external/bsd/dhcp/dist/common/tree.c vendored Normal file

File diff suppressed because it is too large Load Diff

371
external/bsd/dhcp/dist/common/upf.c vendored Normal file
View File

@@ -0,0 +1,371 @@
/* $NetBSD: upf.c,v 1.1.1.2 2014/07/12 11:57:48 spz Exp $ */
/* upf.c
Ultrix PacketFilter interface code. */
/*
* Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Internet Systems Consortium, Inc.
* 950 Charter Street
* Redwood City, CA 94063
* <info@isc.org>
* https://www.isc.org/
*
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: upf.c,v 1.1.1.2 2014/07/12 11:57:48 spz Exp $");
#include "dhcpd.h"
#if defined (USE_UPF_SEND) || defined (USE_UPF_RECEIVE)
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <net/pfilt.h>
#include <netinet/in_systm.h>
#include "includes/netinet/ip.h"
#include "includes/netinet/udp.h"
#include "includes/netinet/if_ether.h"
/* Reinitializes the specified interface after an address change. This
is not required for packet-filter APIs. */
#ifdef USE_UPF_SEND
void if_reinitialize_send (info)
struct interface_info *info;
{
}
#endif
#ifdef USE_UPF_RECEIVE
void if_reinitialize_receive (info)
struct interface_info *info;
{
}
#endif
/* Called by get_interface_list for each interface that's discovered.
Opens a packet filter for each interface and adds it to the select
mask. */
int if_register_upf (info)
struct interface_info *info;
{
int sock;
char filename[50];
int b;
struct endevp param;
/* Open a UPF device */
for (b = 0; 1; b++) {
/* %Audit% Cannot exceed 36 bytes. %2004.06.17,Safe% */
sprintf(filename, "/dev/pf/pfilt%d", b);
sock = open (filename, O_RDWR, 0);
if (sock < 0) {
if (errno == EBUSY) {
continue;
} else {
log_fatal ("Can't find free upf: %m");
}
} else {
break;
}
}
/* Set the UPF device to point at this interface. */
if (ioctl (sock, EIOCSETIF, info -> ifp) < 0)
log_fatal ("Can't attach interface %s to upf device %s: %m",
info -> name, filename);
/* Get the hardware address. */
if (ioctl (sock, EIOCDEVP, &param) < 0)
log_fatal ("Can't get interface %s hardware address: %m",
info -> name);
/* We only know how to do ethernet. */
if (param.end_dev_type != ENDT_10MB)
log_fatal ("Invalid device type on network interface %s: %d",
info -> name, param.end_dev_type);
if (param.end_addr_len != 6)
log_fatal ("Invalid hardware address length on %s: %d",
info -> name, param.end_addr_len);
info -> hw_address.hlen = 7;
info -> hw_address.hbuf [0] = ARPHRD_ETHER;
memcpy (&info -> hw_address.hbuf [1], param.end_addr, 6);
return sock;
}
#endif /* USE_UPF_SEND || USE_UPF_RECEIVE */
#ifdef USE_UPF_SEND
void if_register_send (info)
struct interface_info *info;
{
/* If we're using the upf API for sending and receiving,
we don't need to register this interface twice. */
#ifndef USE_UPF_RECEIVE
info -> wfdesc = if_register_upf (info, interface);
#else
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
log_info ("Sending on UPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_send (info)
struct interface_info *info;
{
#ifndef USE_UPF_RECEIVE
close (info -> wfdesc);
#endif
info -> wfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling output on UPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_UPF_SEND */
#ifdef USE_UPF_RECEIVE
/* Packet filter program...
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the UPF program! XXX */
void if_register_receive (info)
struct interface_info *info;
{
int flag = 1;
u_int32_t addr;
struct enfilter pf;
u_int32_t bits;
/* Open a UPF device and hang it on this interface... */
info -> rfdesc = if_register_upf (info);
/* Allow the copyall flag to be set... */
if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0)
log_fatal ("Can't set ALLOWCOPYALL: %m");
/* Clear all the packet filter mode bits first... */
flag = (ENHOLDSIG | ENBATCH | ENTSTAMP | ENPROMISC |
ENNONEXCL | ENCOPYALL);
if (ioctl (info -> rfdesc, EIOCMBIC, &flag) < 0)
log_fatal ("Can't clear pfilt bits: %m");
/* Set the ENBATCH and ENCOPYALL bits... */
bits = ENBATCH | ENCOPYALL;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
log_fatal ("Can't set ENBATCH|ENCOPYALL: %m");
/* Set up the UPF filter program. */
/* XXX Unlike the BPF filter program, this one won't work if the
XXX IP packet is fragmented or if there are options on the IP
XXX header. */
pf.enf_Priority = 0;
pf.enf_FilterLen = 0;
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHWORD + 6;
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
pf.enf_Filter [pf.enf_FilterLen++] = htons (ETHERTYPE_IP);
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHLIT;
pf.enf_Filter [pf.enf_FilterLen++] = htons (IPPROTO_UDP);
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHWORD + 11;
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHLIT + ENF_AND;
pf.enf_Filter [pf.enf_FilterLen++] = htons (0xFF);
pf.enf_Filter [pf.enf_FilterLen++] = ENF_CAND;
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHWORD + 18;
pf.enf_Filter [pf.enf_FilterLen++] = ENF_PUSHLIT + ENF_CAND;
pf.enf_Filter [pf.enf_FilterLen++] = local_port;
if (ioctl (info -> rfdesc, EIOCSETF, &pf) < 0)
log_fatal ("Can't install packet filter program: %m");
if (!quiet_interface_discovery)
log_info ("Listening on UPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
void if_deregister_receive (info)
struct interface_info *info;
{
close (info -> rfdesc);
info -> rfdesc = -1;
if (!quiet_interface_discovery)
log_info ("Disabling input on UPF/%s/%s%s%s",
info -> name,
print_hw_addr (info -> hw_address.hbuf [0],
info -> hw_address.hlen - 1,
&info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
}
#endif /* USE_UPF_RECEIVE */
#ifdef USE_UPF_SEND
ssize_t send_packet (interface, packet, raw, len, from, to, hto)
struct interface_info *interface;
struct packet *packet;
struct dhcp_packet *raw;
size_t len;
struct in_addr from;
struct sockaddr_in *to;
struct hardware *hto;
{
unsigned hbufp = 0, ibufp = 0;
double hw [4];
double ip [32];
struct iovec iov [3];
int result;
int fudge;
if (!strcmp (interface -> name, "fallback"))
return send_fallback (interface, packet, raw,
len, from, to, hto);
if (hto == NULL && interface->anycast_mac_addr.hlen)
hto = &interface->anycast_mac_addr;
/* Assemble the headers... */
assemble_hw_header (interface, (unsigned char *)hw, &hbufp, hto);
assemble_udp_ip_header (interface,
(unsigned char *)ip, &ibufp, from.s_addr,
to -> sin_addr.s_addr, to -> sin_port,
(unsigned char *)raw, len);
/* Fire it off */
iov [0].iov_base = ((char *)hw);
iov [0].iov_len = hbufp;
iov [1].iov_base = ((char *)ip);
iov [1].iov_len = ibufp;
iov [2].iov_base = (char *)raw;
iov [2].iov_len = len;
result = writev(interface -> wfdesc, iov, 3);
if (result < 0)
log_error ("send_packet: %m");
return result;
}
#endif /* USE_UPF_SEND */
#ifdef USE_UPF_RECEIVE
ssize_t receive_packet (interface, buf, len, from, hfrom)
struct interface_info *interface;
unsigned char *buf;
size_t len;
struct sockaddr_in *from;
struct hardware *hfrom;
{
int nread;
int length = 0;
int offset = 0;
unsigned char ibuf [1500 + sizeof (struct enstamp)];
int bufix = 0;
unsigned paylen;
length = read (interface -> rfdesc, ibuf, sizeof ibuf);
if (length <= 0)
return length;
bufix = sizeof (struct enstamp);
/* Decode the physical header... */
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
/* If a physical layer checksum failed (dunno of any
physical layer that supports this, but WTH), skip this
packet. */
if (offset < 0) {
return 0;
}
bufix += offset;
length -= offset;
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
from, length, &paylen);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
return 0;
bufix += offset;
length -= offset;
if (length < paylen)
log_fatal("Internal inconsistency at %s:%d.", MDL);
/* Copy out the data in the packet... */
memcpy (buf, &ibuf[bufix], paylen);
return paylen;
}
int can_unicast_without_arp (ip)
struct interface_info *ip;
{
return 1;
}
int can_receive_unicast_unconfigured (ip)
struct interface_info *ip;
{
return 1;
}
int supports_multiple_interfaces (ip)
struct interface_info *ip;
{
return 1;
}
void maybe_setup_fallback ()
{
isc_result_t status;
struct interface_info *fbi = (struct interface_info *)0;
if (setup_fallback (&fbi, MDL)) {
if_register_fallback (fbi);
status = omapi_register_io_object ((omapi_object_t *)fbi,
if_readsocket, 0,
fallback_discard, 0, 0);
if (status != ISC_R_SUCCESS)
log_fatal ("Can't register I/O handle for %s: %s",
fbi -> name, isc_result_totext (status));
interface_dereference (&fbi, MDL);
}
}
#endif

347
external/bsd/dhcp/dist/compile vendored Executable file
View File

@@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

1558
external/bsd/dhcp/dist/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1788
external/bsd/dhcp/dist/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

8245
external/bsd/dhcp/dist/configure vendored Executable file

File diff suppressed because it is too large Load Diff

668
external/bsd/dhcp/dist/configure.ac vendored Normal file
View File

@@ -0,0 +1,668 @@
AC_INIT([DHCP],[4.3.0],[dhcp-users@isc.org])
# we specify "foreign" to avoid having to have the GNU mandated files,
# like AUTHORS, COPYING, and such
AM_INIT_AUTOMAKE([foreign])
# we specify AM_MAINTAINER_MODE to avoid problems with rebuilding
# the configure and makefiles. Without it users doing things that
# change the timestamps on the code, like checking it into a cvs
# tree, could trigger a rebuild of the infrastructure files which
# might fail if they don't have the correct tools.
AM_MAINTAINER_MODE
AC_CANONICAL_HOST
# We want to turn on warnings if we are using gcc and the user did
# not specify CFLAGS. The autoconf check for the C compiler sets the
# CFLAGS if gcc is used, so we will save it before we run that check.
SAVE_CFLAGS="$CFLAGS"
# Now find our C compiler.
AC_PROG_CC
# Suppress warnings about --datarootdir
AC_DEFUN([AC_DATAROOTDIR_CHECKED])
# If we have gcc, and AC_PROG_CC changed the flags, then we know the
# user did not specify any flags. Add warnings in this case.
if test "$GCC" = "yes"; then
if test "$CFLAGS" != "$SAVE_CFLAGS"; then
STD_CWARNINGS="$STD_CWARNINGS -Wall -Werror -fno-strict-aliasing"
fi
fi
# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
# parts of the IPv6 Advanced Socket API as a result. This is stupid
# as it breaks how the two halves (Basic and Advanced) of the IPv6
# Socket API were designed to be used but we have to live with it.
# Use this to define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_RANLIB
AC_CONFIG_HEADERS([includes/config.h])
# we sometimes need to know byte order for building packets
AC_C_BIGENDIAN(AC_SUBST(byte_order, BIG_ENDIAN),
AC_SUBST(byte_order, LITTLE_ENDIAN))
AC_DEFINE_UNQUOTED([DHCP_BYTE_ORDER], [$byte_order],
[Define to BIG_ENDIAN for MSB (Motorola or SPARC CPUs)
or LITTLE_ENDIAN for LSB (Intel CPUs).])
# Optional compile-time DEBUGging.
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],[create a debug-only version of the software (default is no).]),
[enable_debug=yes],[enable_debug=no])
# This is very much off by default.
if test "$enable_debug" = "yes" ; then
AC_DEFINE([DEBUG], [1],
[Define to compile debug-only DHCP software.])
# Just override CFLAGS to totally to remove optimization.
CFLAGS="-g"
fi
# XXX: there are actually quite a lot more DEBUG_ features we could enable,
# but I don't want to pollute the --help space.
#
#/* #define DEBUG_TOKENS */
#/* #define DEBUG_PACKET */
#/* #define DEBUG_EXPRESSIONS */
#/* #define DEBUG_FIND_LEASE */
#/* #define DEBUG_EXPRESSION_PARSE */
#/* #define DEBUG_CLASS_MATCHING */
#/* #define DEBUG_MEMORY_LEAKAGE */
#/* #define DEBUG_MALLOC_POOL */
#/* #define DEBUG_LEASE_STATE_TRANSITIONS */
#/* #define DEBUG_RC_HISTORY */
#/* #define DEBUG_RC_HISTORY_EXHAUSTIVELY */
#/* #define RC_HISTORY_MAX 10240 */
#/* #define POINTER_DEBUG */
#/* #define DEBUG_FAILOVER_MESSAGES */
#/* #define DEBUG_FAILOVER_TIMING */
#/* #define DEBUG_DUMP_ALL_LEASES */
# Failover optional compile-time feature.
AC_ARG_ENABLE(failover,
AS_HELP_STRING([--enable-failover],[enable support for failover (default is yes)]))
# Failover is on by default, so define if it is not explicitly disabled.
if test "$enable_failover" != "no"; then
AC_DEFINE([FAILOVER_PROTOCOL], [1],
[Define to include Failover Protocol support.])
fi
# execute() support.
AC_ARG_ENABLE(execute,
AS_HELP_STRING([--enable-execute],[enable support for execute() in config (default is yes)]))
# execute() is on by default, so define if it is not explicitly disabled.
if test "$enable_execute" != "no" ; then
AC_DEFINE([ENABLE_EXECUTE], [1],
[Define to include execute() config language support.])
fi
# Server tracing support.
AC_ARG_ENABLE(tracing,
AS_HELP_STRING([--enable-tracing],[enable support for server activity tracing (default is yes)]))
# tracing is on by default, so define if it is not explicitly disabled.
if test "$enable_tracing" != "no" ; then
AC_DEFINE([TRACING], [1],
[Define to include server activity tracing support.])
fi
# Delayed-ack feature support (experimental).
AC_ARG_ENABLE(delayed_ack,
AS_HELP_STRING([--enable-delayed-ack],[queues multiple DHCPACK replies (default is no)]))
if test "$enable_delayed_ack" = "yes"; then
AC_DEFINE([DELAYED_ACK], [1],
[Define to queue multiple DHCPACK replies per fsync.])
fi
# DHCPv6 optional compile-time feature.
AC_ARG_ENABLE(dhcpv6,
AS_HELP_STRING([--enable-dhcpv6],[enable support for DHCPv6 (default is yes)]))
# DHCPv6 is on by default, so define if it is not explicitly disabled.
if test "$enable_dhcpv6" != "no"; then
AC_DEFINE([DHCPv6], [1],
[Define to 1 to include DHCPv6 support.])
fi
# PARANOIA is off by default (until we can test it with all features)
AC_ARG_ENABLE(paranoia,
AS_HELP_STRING([--enable-paranoia],[enable support for chroot/setuid (default is no)]))
AC_ARG_ENABLE(early_chroot,
AS_HELP_STRING([--enable-early-chroot],[enable chrooting prior to configuration (default is no)]))
# If someone enables early chroot, but does not enable paranoia, do so for
# them.
if test "$enable_paranoia" != "yes" && \
test "$enable_early_chroot" = "yes" ; then
enable_paranoia="yes"
fi
if test "$enable_paranoia" = "yes" ; then
AC_DEFINE([PARANOIA], [1],
[Define to any value to include Ari's PARANOIA patch.])
fi
if test "$enable_early_chroot" = "yes" ; then
AC_DEFINE([EARLY_CHROOT], [1],
[Define to any value to chroot() prior to loading config.])
fi
AC_ARG_ENABLE(ipv4_pktinfo,
AS_HELP_STRING([--enable-ipv4-pktinfo],[enable use of pktinfo on IPv4 sockets (default is no)]))
if test "$enable_ipv4_pktinfo" = "yes"; then
AC_DEFINE([USE_V4_PKTINFO], [1],
[Define to 1 to enable IPv4 packet info support.])
fi
AC_ARG_ENABLE(use_sockets,
AS_HELP_STRING([--enable-use-sockets],[use the standard BSD socket API (default is no)]))
if test "$enable_use_sockets" = "yes"; then
AC_DEFINE([USE_SOCKETS], [1],
[Define to 1 to use the standard BSD socket API.])
fi
# Try to hnadle incorrect byte order for secs field
# This is off by default
AC_ARG_ENABLE(secs_byteorder,
AS_HELP_STRING([--enable-secs-byteorder],[Correct bad byteorders in the secs field (default is no).]))
if test "$enable_secs_byteorder" = "yes" ; then
AC_DEFINE([SECS_BYTEORDER], [1],
[Define to correct bad byteorders in secs field.])
fi
# Testing section
atf_path="no"
AC_ARG_WITH([atf],
AS_HELP_STRING([--with-atf=PATH],[specify location where atf was installed]),
[atf_path="$withval"])
if test "$atf_path" != "no" ; then
# Config path for pkg-config
atf_pcp=""
if test "$atf_path" != "yes" ; then
if test -f $atf_path/lib/pkgconfig/atf-c.pc ; then
atf_pcp=$atf_path/lib/pkgconfig
elif test -f $atf_path/lib64/pkgconfig/atf-c.pc ; then
atf_pcp=$atf_path/lib64/pkgconfig
fi
else
# Not specified, try some common paths
atf_dirs="/usr /usr/local /usr/pkg /opt /opt/local"
for d in $atf_dirs
do
if test -f $d/lib/pkgconfig/atf-c.pc ; then
atf_pcp=$d/lib/pkgconfig
elif test -f $d/lib64/pkgconfig/atf-c.pc ; then
atf_pcp=$d/lib64/pkgconfig
fi
done
fi
if test "$atf_pcp" = "" ; then
AC_MSG_ERROR([Unable to find atf files in location specified])
else
ATF_CFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --cflags atf-c` -DUNIT_TEST"
ATF_LDFLAGS="`PKG_CONFIG_PATH=$atf_pcp pkg-config --libs atf-c`"
AC_SUBST(ATF_CFLAGS)
AC_SUBST(ATF_LDFLAGS)
fi
fi
AM_CONDITIONAL(HAVE_ATF, test "$atf_pcp" != "")
### Uncomment this once docs.lab.isc.org upgrades to automake 1.11
### AM_COND_IF([HAVE_ATF], [AC_DEFINE([HAVE_ATF], [1], [ATF framework specified?])])
###
### Path fun. Older versions of DHCP were installed in /usr/sbin, so we
### need to look there and potentially overwrite by default (but not if
### the user configures an alternate value). LOCALSTATEDIR is totally
### braindead. No one uses /usr/local/var/db/ nor /usr/local/var/run, and
### they would be insane for suggesting it. We need to look in /var/for
### 'db' and 'state/dhcp' for db files, and /var/run for pid files by
### default.
###
AC_PREFIX_PROGRAM(dhcpd)
# XXX - isn't there SOME WAY to default autoconf to /var instead of
# /usr/local/var/no/one/has/this/please/stop/trying?
case "$localstatedir" in
'${prefix}/var')
localstatedir=/var
;;
esac
# Allow specification of alternate state files
AC_ARG_WITH(srv-lease-file,
AS_HELP_STRING([--with-srv-lease-file=PATH],[File for dhcpd leases
(default is LOCALSTATEDIR/db/dhcpd.leases)]),
AC_DEFINE_UNQUOTED([_PATH_DHCPD_DB], ["$withval"],
[File for dhcpd leases.]))
echo -n "checking for dhcpd.leases location..."
if [[ "x$with_srv_lease_file" = "x" ]] ; then
if [[ -d "${localstatedir}/db" ]] ; then
with_srv_lease_file="${localstatedir}/db/dhcpd.leases"
elif [[ -d "${localstatedir}/state" ]] ; then
if [[ -d "${localstatedir}/state/dhcp" ]] ; then
with_srv_lease_file="${localstatedir}/state/dhcp/dhcpd.leases"
else
with_srv_lease_file="${localstatedir}/state/dhcpd.leases"
fi
elif [[ -d "${localstatedir}/lib" ]] ; then
if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
with_srv_lease_file="${localstatedir}/lib/dhcp/dhcpd.leases"
else
with_srv_lease_file="${localstatedir}/lib/dhcpd.leases"
fi
elif [[ -d "${localstatedir}/etc" ]] ; then
with_srv_lease_file="${localstatedir}/etc/dhcpd.leases"
else
with_srv_lease_file="/etc/dhcpd.leases"
fi
fi
echo "$with_srv_lease_file"
AC_ARG_WITH(srv6-lease-file,
AS_HELP_STRING([--with-srv6-lease-file=PATH],[File for dhcpd6 leases
(default is LOCALSTATEDIR/db/dhcpd6.leases)]),
AC_DEFINE_UNQUOTED([_PATH_DHCPD6_DB], ["$withval"],
[File for dhcpd6 leases.]))
echo -n "checking for dhcpd6.leases location..."
if [[ "x$with_srv6_lease_file" = "x" ]] ; then
if [[ -d "${localstatedir}/db" ]] ; then
with_srv6_lease_file="${localstatedir}/db/dhcpd6.leases"
elif [[ -d "${localstatedir}/state" ]] ; then
if [[ -d "${localstatedir}/state/dhcp" ]] ; then
with_srv6_lease_file="${localstatedir}/state/dhcp/dhcpd6.leases"
else
with_srv6_lease_file="${localstatedir}/state/dhcpd6.leases"
fi
elif [[ -d "${localstatedir}/lib" ]] ; then
if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
with_srv6_lease_file="${localstatedir}/lib/dhcp/dhcpd6.leases"
else
with_srv6_lease_file="${localstatedir}/lib/dhcpd6.leases"
fi
elif [[ -d "${localstatedir}/etc" ]] ; then
with_srv6_lease_file="${localstatedir}/etc/dhcpd6.leases"
else
with_srv6_lease_file="/etc/dhcpd6.leases"
fi
fi
echo "$with_srv6_lease_file"
AC_ARG_WITH(cli-lease-file,
AS_HELP_STRING([--with-cli-lease-file=PATH],[File for dhclient leases
(default is LOCALSTATEDIR/db/dhclient.leases)]),
AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_DB], ["$withval"],
[File for dhclient leases.]))
echo -n "checking for dhclient.leases location..."
if [[ "x$with_cli_lease_file" = "x" ]] ; then
if [[ -d "${localstatedir}/db" ]] ; then
with_cli_lease_file="${localstatedir}/db/dhclient.leases"
elif [[ -d "${localstatedir}/state" ]] ; then
if [[ -d "${localstatedir}/state/dhcp" ]] ; then
with_cli_lease_file="${localstatedir}/state/dhcp/dhclient.leases"
else
with_cli_lease_file="${localstatedir}/state/dhclient.leases"
fi
elif [[ -d "${localstatedir}/lib" ]] ; then
if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
with_cli_lease_file="${localstatedir}/lib/dhcp/dhclient.leases"
else
with_cli_lease_file="${localstatedir}/lib/dhclient.leases"
fi
elif [[ -d "${localstatedir}/etc" ]] ; then
with_cli_lease_file="${localstatedir}/etc/dhclient.leases"
else
with_cli_lease_file="/etc/dhclient.leases"
fi
fi
echo "$with_cli_lease_file"
AC_ARG_WITH(cli6-lease-file,
AS_HELP_STRING([--with-cli6-lease-file=PATH],[File for dhclient6 leases
(default is LOCALSTATEDIR/db/dhclient6.leases)]),
AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_DB], ["$withval"],
[File for dhclient6 leases.]))
echo -n "checking for dhclient6.leases location..."
if [[ "x$with_cli6_lease_file" = "x" ]] ; then
if [[ -d "${localstatedir}/db" ]] ; then
with_cli6_lease_file="${localstatedir}/db/dhclient6.leases"
elif [[ -d "${localstatedir}/state" ]] ; then
if [[ -d "${localstatedir}/state/dhcp" ]] ; then
with_cli6_lease_file="${localstatedir}/state/dhcp/dhclient6.leases"
else
with_cli6_lease_file="${localstatedir}/state/dhclient6.leases"
fi
elif [[ -d "${localstatedir}/lib" ]] ; then
if [[ -d "${localstatedir}/lib/dhcp" ]] ; then
with_cli6_lease_file="${localstatedir}/lib/dhcp/dhclient6.leases"
else
with_cli6_lease_file="${localstatedir}/lib/dhclient6.leases"
fi
elif [[ -d "${localstatedir}/etc" ]] ; then
with_cli6_lease_file="${localstatedir}/etc/dhclient6.leases"
else
with_cli6_lease_file="/etc/dhclient6.leases"
fi
fi
echo "$with_cli6_lease_file"
AC_ARG_WITH(srv-pid-file,
AS_HELP_STRING([--with-srv-pid-file=PATH],[File for dhcpd process information
(default is LOCALSTATEDIR/run/dhcpd.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCPD_PID], ["$withval"],
[File for dhcpd process information.]))
AC_ARG_WITH(srv6-pid-file,
AS_HELP_STRING([--with-srv6-pid-file=PATH],[File for dhcpd6 process information
(default is LOCALSTATEDIR/run/dhcpd6.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCPD6_PID], ["$withval"],
[File for dhcpd6 process information.]))
AC_ARG_WITH(cli-pid-file,
AS_HELP_STRING([--with-cli-pid-file=PATH],[File for dhclient process information
(default is LOCALSTATEDIR/run/dhclient.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCLIENT_PID], ["$withval"],
[File for dhclient process information.]))
AC_ARG_WITH(cli6-pid-file,
AS_HELP_STRING([--with-cli6-pid-file=PATH],[File for dhclient6 process information
(default is LOCALSTATEDIR/run/dhclient6.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCLIENT6_PID], ["$withval"],
[File for dhclient6 process information.]))
AC_ARG_WITH(relay-pid-file,
AS_HELP_STRING([--with-relay-pid-file=PATH],[File for dhcrelay process information
(default is LOCALSTATEDIR/run/dhcrelay.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCRELAY_PID], ["$withval"],
[File for dhcrelay process information.]))
AC_ARG_WITH(relay6-pid-file,
AS_HELP_STRING([--with-relay6-pid-file=PATH],[File for dhcrelay6 process information
(default is LOCALSTATEDIR/run/dhcrelay6.pid)]),
AC_DEFINE_UNQUOTED([_PATH_DHCRELAY6_PID], ["$withval"],
[File for dhcrelay6 process information.]))
# Check basic types.
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
# Some systems need the u_intX_t types defined across.
AC_CHECK_TYPE([u_int8_t], [], [
AC_TYPE_UINT8_T
AC_DEFINE(u_int8_t, [uint8_t], [Define a type for 8-bit unsigned
integers.])
])
AC_CHECK_TYPE([u_int16_t], [], [
AC_TYPE_UINT16_T
AC_DEFINE(u_int16_t, [uint16_t], [Define a type for 16-bit unsigned
integers.])
])
AC_CHECK_TYPE([u_int32_t], [], [
AC_TYPE_UINT32_T
AC_DEFINE(u_int32_t, [uint32_t], [Define a type for 32-bit unsigned
integers.])
])
AC_CHECK_TYPE([u_int64_t], [], [
AC_TYPE_UINT64_T
AC_DEFINE(u_int64_t, [uint64_t], [Define a type for 64-bit unsigned
integers.])
])
# see if ifaddrs.h is available
AC_CHECK_HEADERS(ifaddrs.h)
# figure out what IPv4 interface code to use
AC_CHECK_HEADERS(linux/types.h) # needed for linux/filter.h on old systems
AC_CHECK_HEADER(linux/filter.h, DO_LPF=1, ,
[
#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif
])
if test -n "$DO_LPF"
then
AC_DEFINE([HAVE_LPF], [1],
[Define to 1 to use the Linux Packet Filter interface code.])
else
AC_CHECK_HEADER(sys/dlpi.h, DO_DLPI=1)
if test -n "$DO_DLPI"
then
AC_DEFINE([HAVE_DLPI], [1],
[Define to 1 to use DLPI interface code.])
else
AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
if test -n "$DO_BPF"
then
AC_DEFINE([HAVE_BPF], [1],
[Define to 1 to use the
Berkeley Packet Filter interface code.])
fi
fi
fi
# SIOCGLIFCONF uses some transport structures. Trick is not all platforms
# use the same structures. We like to use 'struct lifconf' and 'struct
# lifreq', but we'll use these other structures if they're present. HPUX
# does not define 'struct lifnum', but does use SIOCGLIFNUM - they use an
# int value.
#
AC_MSG_CHECKING([for struct lifnum])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
]], [[ struct lifnum a;
]])],[AC_MSG_RESULT(yes)
AC_DEFINE([ISC_PLATFORM_HAVELIFNUM], [1],
[Define to 1 if the system has 'struct lifnum'.])],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for struct if_laddrconf])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h>
#include <net/if6.h>
]], [[ struct if_laddrconf a;
]])],[AC_MSG_RESULT(yes)
AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRCONF], [1],
[Define to 1 if the system has 'struct if_laddrconf'.])],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING([for struct if_laddrreq])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <net/if6.h>
]], [[ struct if_laddrreq a;
]])],[AC_MSG_RESULT(yes)
AC_DEFINE([ISC_PLATFORM_HAVEIF_LADDRREQ], [1],
[Define to 1 if the system has 'struct if_laddrreq'.])],[AC_MSG_RESULT(no)])
#
# check for GCC noreturn attribute
#
AC_MSG_CHECKING(for GCC noreturn attribute)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[void foo() __attribute__((noreturn));]])],[AC_MSG_RESULT(yes)
AC_DEFINE([ISC_DHCP_NORETURN], [__attribute__((noreturn))],
[Define to the string for a noreturn attribute.])],[AC_MSG_RESULT(no)
AC_DEFINE([ISC_DHCP_NORETURN], [],
[Define to the string for a noreturn attribute.])])
# Look for optional headers.
AC_CHECK_HEADERS(sys/socket.h net/if_dl.h net/if6.h regex.h)
# Solaris needs some libraries for functions
AC_SEARCH_LIBS(socket, [socket])
AC_SEARCH_LIBS(inet_ntoa, [nsl])
AC_SEARCH_LIBS(inet_aton, [socket nsl], ,
AC_DEFINE([NEED_INET_ATON], [1],
[Define to 1 if the inet_aton() function is missing.]))
# Check for a standalone regex library.
AC_SEARCH_LIBS(regcomp, [regex])
AC_CHECK_FUNCS(strlcat)
# For HP/UX we need -lipv6 for if_nametoindex, perhaps others.
AC_SEARCH_LIBS(if_nametoindex, [ipv6])
# check for /dev/random (declares HAVE_DEV_RANDOM)
AC_CHECK_FILE(/dev/random,
AC_DEFINE([HAVE_DEV_RANDOM], [1],
[Define to 1 if you have the /dev/random file.]))
# see if there is a "sa_len" field in our interface information structure
AC_CHECK_MEMBER(struct sockaddr.sa_len,
AC_DEFINE([HAVE_SA_LEN], [],
[Define to 1 if the sockaddr structure has a length field.]),
,
[#include <sys/socket.h>])
# figure out pointer size
AC_CHECK_SIZEOF(struct iaddr *, , [
#include "includes/inet.h"
#include <stdio.h>
])
# Solaris does not have the msg_control or msg_controlen members
# in the msghdr structure unless you define:
#
# _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED, and __EXTENSIONS__
#
# See the "standards" man page for details.
#
# We check for the msg_control member, and if it is not found, we check
# again with the appropriate defines added to the CFLAGS. (In order to
# do this we have to remove the check from the cache, which is what the
# "unset" is for.)
AC_CHECK_MEMBER(struct msghdr.msg_control,,
[CFLAGS="$CFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
CFLAGS="$CFLAGS -D__EXTENSIONS__"
unset ac_cv_member_struct_msghdr_msg_control
AC_CHECK_MEMBER(struct msghdr.msg_control,,
[AC_MSG_ERROR([Missing msg_control member in
msg_control structure.])],
[
#include <sys/types.h>
#include <sys/socket.h>
])
],
[
#include <sys/types.h>
#include <sys/socket.h>
])
libbind=
AC_ARG_WITH(libbind,
AS_HELP_STRING([--with-libbind=PATH],[bind includes and libraries are in PATH
(default is ./bind)]),
use_libbind="$withval", use_libbind="no")
case "$use_libbind" in
yes)
libbind="\${top_srcdir}/bind"
;;
no)
libbind="\${top_srcdir}/bind"
;;
*)
libbind="$use_libbind"
;;
esac
# OpenLDAP support.
AC_ARG_WITH(ldap,
AS_HELP_STRING([--with-ldap],[enable OpenLDAP support in dhcpd (default is no)]),
[ldap=$withval],
[ldap=no])
# OpenLDAP with SSL support.
AC_ARG_WITH(ldapcrypto,
AS_HELP_STRING([--with-ldapcrypto],[enable OpenLDAP crypto support in dhcpd (default is no)]),
[ldapcrypto=$withval],
[ldapcrypto=no])
# OpenLDAP support is disabled by default, if enabled then SSL support is an
# extra optional that is also disabled by default. Enabling LDAP SSL support
# implies enabling LDAP support.
if test x$ldap = xyes || test x$ldapcrypto = xyes ; then
AC_SEARCH_LIBS(ldap_initialize, [ldap], ,
AC_MSG_FAILURE([*** Cannot find ldap_initialize with -lldap - do you need to install an OpenLDAP2 Devel package?]))
AC_SEARCH_LIBS(ber_pvt_opt_on, [lber], ,
AC_MSG_FAILURE([*** Cannot find ber_pvt_opt_on with -llber - do you need to install an OpenLDAP2 Devel package?]))
if test x$ldapcrypto = xyes ; then
AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION -DLDAP_USE_SSL"])
else
AC_SUBST(LDAP_CFLAGS, ["-DLDAP_CONFIGURATION"])
fi
fi
# Append selected warning levels to CFLAGS before substitution (but after
# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
CFLAGS="$CFLAGS $STD_CWARNINGS"
# Try to add the bind include directory
CFLAGS="$CFLAGS -I$libbind/include"
case "$host" in
*-darwin*)
CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542" ;;
esac
AC_C_FLEXIBLE_ARRAY_MEMBER
AC_CONFIG_FILES([
Makefile
client/Makefile
common/Makefile
common/tests/Makefile
dhcpctl/Makefile
dst/Makefile
includes/Makefile
omapip/Makefile
relay/Makefile
server/Makefile
tests/Makefile
server/tests/Makefile
doc/devel/doxyfile
])
AC_OUTPUT
sh util/bindvar.sh
cat > config.report << END
ISC DHCP source configure results:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Package:
Name: $PACKAGE_NAME
Version: $PACKAGE_VERSION
C Compiler: $CC
Flags:
DEFS: $DEFS
CFLAGS: $CFLAGS
Features:
debug: $enable_debug
failover: $enable_failover
execute: $enable_execute
Developer:
ATF unittests : $atf_path
END
# TODO: Add Perl system tests
if test "$atf_path" != "no"
then
echo "ATF_CFLAGS : $ATF_CFLAGS" >> config.report
echo "ATF_LDFLAGS : $ATF_LDFLAGS" >> config.report
echo
fi
cat config.report
echo
echo Now you can type "make" to build ISC DHCP
echo

View File

@@ -0,0 +1,126 @@
#!/usr/bin/perl
#
# Start Date: Mon, 26 Mar 2001 14:24:09 +0200
# Time-stamp: <Monday, 26 March 2001 16:09:44 by brister>
# File: leaseconvertor.pl
# RCSId: Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp
#
# Description: Convert 3.0b1 to 3.0b2/final lease file format
#
require 5.004;
my $rcsID =<<'EOM';
Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp
EOM
use strict;
my $revstatement =<<'EOS';
switch (ns-update (delete (1, 12, ddns-rev-name, null))) {
case 0:
unset ddns-rev-name;
break;
}
EOS
my $fwdstatement =<<'EOS';
switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) {
case 0:
unset ddns-fwd-name;
break;
}
EOS
if (@ARGV && $ARGV[0] =~ m!^-!) {
usage();
}
# read stdin and write stdout.
while (<>) {
if (! /^lease\s/) {
print;
} else {
my $lease = $_;
while (<>) {
$lease .= $_;
# in a b1 file we should only see a left curly brace on a lease
# lines. Seening it anywhere else means the user is probably
# running a b2 or later file through this.
# Ditto for a 'set' statement.
if (m!\{! || m!^\s*set\s!) {
warn "this doesn't look like a 3.0b1 file. Ignoring rest.\n";
print $lease;
dumpRestAndExit();
}
last if m!^\}\s*$!;
}
# $lease contains all the lines for the lease entry.
$lease = makeNewLease($lease);
print $lease;
}
}
sub usage {
my $prog = $0;
$prog =~ s!.*/!!;
print STDERR <<EOM;
usage: $prog [ file ]
Reads from the lease file listed on the command line (or stdin if not filename
given) and writes to stdout. Converts a 3.0b1-style leases file to a 3.0b2
style (for ad-hoc ddns updates).
EOM
exit (0);
}
# takes a string that's the lines of a lease entry and converts it, if
# necessary to a b2 style lease entry. Returns the new lease in printable form.
sub makeNewLease {
my ($lease) = @_;
my $convertedfwd;
my $convertedrev;
my $newlease = "";
foreach (split "\n", $lease) {
if (m!^(\s+)(ddns-fwd-name|ddns-rev-name)\s+(\"[^\"]+\"\s*;)!) {
$newlease .= $1 . "set " . $2 . " = " . $3 . "\n";
# If there's one of them, then it will always be the -fwd-. There
# may not always be a -rev-.
$convertedfwd++;
$convertedrev++ if ($2 eq "ddns-rev-name");
} elsif (m!^\s*\}!) {
if ($convertedfwd) {
$newlease .= "\ton expiry or release {\n";
$newlease .= $revstatement if $convertedrev;
$newlease .= $fwdstatement;
$newlease .= "\t on expiry or release;\n\t}\n";
}
$newlease .= "}\n";
} else {
$newlease .= $_ . "\n";
}
}
return $newlease;
}
sub dumpRestAndExit {
while (<>) {
print;
}
exit (0);
}

View File

@@ -0,0 +1,179 @@
#!/bin/bash
#
# dhclient-tz-exithook.sh
# Version 1.01 elear
#
# Copyright (c) 2007, Cisco Systems, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# - Neither the name of Cisco Systems, Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# the following script is used to set the timezone based on the new
# dhcp timezone option defined currently in the IETF document
# draft-ietf-dhc-timezone-option-04.txt.
# this code is intended for use with ISC's dhclient. it is to be called
# either as, or by, dhclient-exit-hooks
#
# As this is test code, in order for it to be called two changes
# must be made to /etc/dhclient.conf. First, dhclient.conf must be
# aware of the tzName option. The IANA has assigned tzName option
# code 101. You may need to add this to your configuration file.
#
# option tzName code 101 = text;
#
# Next, add tzName to the list of options in the "request" statement.
# For example:
#
# request subnet-mask, broadcast-address, time-offset, routers,
# domain-name, domain-name-servers, host-name, tzName;
#
#
# And of course make sure that your dhcp server is transmitting timezone
# information for option 101. For IOS this can be done as follows:
#
# option 101 ascii "Europe/Berlin"
#
timefile=/etc/localtime
oldfile=$timefile.old
tmpfile=$timefile.$$
# function to clean up just in case we are interrupted or something
# bad happens.
restore_file () {
if [ ! -f $timefile ]; then
$DEBUG mv $tmpfile $timefile
fi
$DEBUG rm $tmpfile
exit
}
#set DEBUG to "echo" to see what would happen.
if [ x$DEBUG = x ]; then
DEBUG=
fi
# if something has already gone wrong we're not doing a thing.
if [ x$exit_status != x0 ]; then
exit $exit_status
fi
# if we don't have a new timezone, then we have nothing to change, so
# goodbye.
if [ x$new_tzName = x ]; then
exit 0
fi
# if the timezone doesn't exist, goodbye.
if [ ! -e $timefile ]; then
exit 0
fi
# find zoneinfo. use the first one.
ftz=0
for a in /usr/share/zoneinfo /usr/lib/zoneinfo /var/share/zoneinfo /var/zoneinfo; do
if [ -d $a -a $ftz = 0 ]; then
zoneinfo=$a
ftz=1
fi
done
# no zoneinfo found. goodbye.
if [ x$zoneinfo = x ]; then
exit 0
fi
# timezone not found. goodbye.
if [ ! -f $zoneinfo/$new_tzName ]; then
exit 0
fi
# if we're here we can actually do something useful.
# first, link a copy of the existing timefile.
$DEBUG ln $timefile $tmpfile
if [ $? != 0 ]; then
echo "unable to create temporary file"
exit -1
fi
# in case of interrupt, cleanup.
trap restore_file SIGINT SIGSEGV SIGQUIT SIGTERM
# we destroy old backup files in this process. if we cannot and the
# file exists then something went wrong.
if [ -e $oldfile ]; then
$DEBUG rm $oldfile
if [ $? != 0 ]; then
echo "$0: failed to remove $oldfile"
rm -f $tmpfile
exit -1
fi
fi
# sensitive part happens here:
#
$DEBUG mv $timefile $oldfile
if [ $? != 0 ]; then
echo "$0: failed to move old $timefile file out of the way"
rm $tmpfile
exit -1
fi
$DEBUG ln $zoneinfo/$new_tzName $timefile
# we don't complain just yet- a hard link could fail because
# we're on two different file systems. Go for a soft link.
#
if [ $? != 0 ]; then
$DEBUG ln -s $zoneinfo/$new_tzName $timefile
fi
if [ $? != 0 ]; then # failed to softlink. now we're getting nervous.
echo "$0: unable to establish new timezone. Attempting to revert."
$DEBUG ln $tmpfile $timefile
fi
if [ $? != 0 ]; then # we're absolutely hosed
echo "$0: unable to link or softlink timezone file, and unable to restore old file - giving up!"
exit -1
fi
$DEBUG rm $tmpfile
exit $?

View File

@@ -0,0 +1,199 @@
#!/usr/bin/perl
#
# Shows current leases.
#
# THIS SCRIPT IS PUBLIC DOMAIN, NO RIGHTS RESERVED!
#
# I've removed the email addresses of Christian and vom to avoid
# putting them on spam lists. If either of you would like to have
# your email in here please send mail to the DHCP bugs list at ISC.
#
# 2008-07-13, Christian Hammers
#
# 2009-06-?? - added loading progress counter, pulls hostname, adjusted formatting
# vom
#
# 2013-04-22 - added option to choose lease file, made manufacture information
# optional, sar
use strict;
use warnings;
use POSIX qw(strftime);
my $LEASES = '/var/db/dhcpd.leases';
my @all_leases;
my @leases;
my @OUIS = ('/usr/share/misc/oui.txt', '/usr/local/etc/oui.txt');
my $OUI_URL = 'http://standards.ieee.org/regauth/oui/oui.txt';
my $oui;
my %data;
my $opt_format = 'human';
my $opt_keep = 'active';
our $total_leases = 0;
## Return manufactorer name for specified MAC address (aa:bb:cc:dd:ee:ff).
sub get_manufactorer_for_mac($) {
my $manu = "-NA-";
if (defined $oui) {
$manu = join('-', ($_[0] =~ /^(..):(..):(..):/));
$manu = `grep -i '$manu' $oui | cut -f3`;
chomp($manu);
}
return $manu;
}
## Read oui.txt or print warning.
sub check_oui_file() {
for my $oui_cand (@OUIS) {
if ( -r $oui_cand) {
$oui = $oui_cand;
last;
}
}
if (not defined $oui) {
print(STDERR "To get manufacturer names please download $OUI_URL ");
print(STDERR "to /usr/local/etc/oui.txt\n");
}
}
## Read current leases file into array.
sub read_dhcpd_leases() {
open(F, $LEASES) or die("Cannot open $LEASES: $!");
my $content = join('', <F>);
close(F);
@all_leases = split(/lease/, $content);
foreach my $lease (@all_leases) {
if ($lease =~ /^\s+([\.\d]+)\s+{.*starts \d+ ([\/\d\ \:]+);.*ends \d+ ([\/\d\ \:]+);.*ethernet ([a-f0-9:]+);/s) {
++$total_leases;
}
}
}
## Add manufactor name and sort out obsolet assignements.
sub process_leases() {
my $gm_now = strftime("%Y/%m/%d %H:%M:%S", gmtime());
my %tmp_leases; # for sorting and filtering
my $counter = 1;
# parse entries
foreach my $lease (@all_leases) {
# skip invalid lines
next if not ($lease =~ /^\s+([\.\d]+)\s+{.*starts \d+ ([\/\d\ \:]+);.*ends \d+ ([\/\d\ \:]+);.*ethernet ([a-f0-9:]+);(.*client-hostname \"(\S+)\";)*/s);
# skip outdated lines
next if ($opt_keep eq 'active' and $3 lt $gm_now);
my $percent = (($counter / $total_leases)*100);
printf "Processing: %2d%% complete\r", $percent;
++$counter;
my $hostname = "-NA-";
if ($6) {
$hostname = $6;
}
my $mac = $4;
my $date_end = $3;
my %entry = (
'ip' => $1,
'date_begin' => $2,
'date_end' => $date_end,
'mac' => $mac,
'hostname' => $hostname,
'manu' => get_manufactorer_for_mac($mac),
);
$entry{'date_begin'} =~ s#\/#-#g; # long live ISO 8601
$entry{'date_end'} =~ s#\/#-#g;
if ($opt_keep eq 'all') {
push(@leases, \%entry);
} elsif (not defined $tmp_leases{$mac} or $tmp_leases{$mac}{'date_end'} gt $date_end) {
$tmp_leases{$mac} = \%entry;
}
}
# In case we used the hash to filtered
if (%tmp_leases) {
foreach (sort keys %tmp_leases) {
my $h = $tmp_leases{$_};
push(@leases, $h);
}
}
# print "\n";
}
# Output all valid leases.
sub output_leases() {
if ($opt_format eq 'human') {
printf "%-19s%-16s%-15s%-20s%-20s\n","MAC","IP","hostname","valid until","manufacturer";
print("===============================================================================================\n");
}
foreach (@leases) {
if ($opt_format eq 'human') {
printf("%-19s%-16s%-15s%-20s%-20s\n",
$_->{'mac'}, # MAC
$_->{'ip'}, # IP address
$_->{'hostname'}, # hostname
$_->{'date_end'}, # Date
$_->{'manu'}); # manufactor name
} else {
printf("MAC %s IP %s HOSTNAME %s BEGIN %s END %s MANUFACTURER %s\n",
$_->{'mac'},
$_->{'ip'},
$_->{'hostname'},
$_->{'date_begin'},
$_->{'date_end'},
$_->{'manu'});
}
}
}
# Commandline Processing.
sub cli_processing() {
while (my $arg = shift(@ARGV)) {
if ($arg eq '--help') {
print(
"Prints active DHCP leases.\n\n".
"Usage: $0 [options]\n".
" --help shows this help\n".
" --parsable machine readable output with full dates\n".
" --last prints the last (even if end<now) entry for every MAC\n".
" --all prints all entries i.e. more than one per MAC\n".
" --lease uses the next argument as the name of the lease file\n".
" the default is /var/db/dhcpd.leases\n".
"\n");
exit(0);
} elsif ($arg eq '--parsable') {
$opt_format = 'parsable';
} elsif ($arg eq '--last') {
$opt_keep = 'last';
} elsif ($arg eq '--all') {
$opt_keep = 'all';
} elsif ($arg eq '--lease') {
$LEASES = shift(@ARGV);
} else {
die("Unknown option $arg");
}
}
}
#
# main()
#
cli_processing();
check_oui_file();
read_dhcpd_leases();
process_leases();
output_leases();

157
external/bsd/dhcp/dist/contrib/dhcp.spec vendored Normal file
View File

@@ -0,0 +1,157 @@
Summary: The Internet Systems Consortium (ISC) DHCP server
Name: dhcp
%define version 3.0.2
Version: %{version}
Release: 2tac
Group: System Environment/Daemons
Source: /usr/local/src/RPM/SOURCES/dhcp-%{version}.tar.gz
Copyright: ISC
BuildRoot: /var/tmp/dhcp-%{version}-root
%description
Dhcp includes the DHCP server which is used for dynamically configuring
hosts on a network. Host configuration items such as IP address, name
servers, domain name, etc. can all be retrieved from the DHCP server by
a DHCP client. This eases the burden of network wide configuration by
putting all of the configuration into one place.
%package client
Summary: A DHCP client
Group: System Environment/Configuration
%description client
Dhcp client is a DHCP client for various UNIX operating systems. It allows
a UNIX machine to obtain it's networking parameters from a DHCP server.
%package relay
Summary: A DHCP relay
Group: System Environment/Daemons
%description relay
Dhcp relay is a relay agent for DHCP packets. It is used on a subnet with
DHCP clients to "relay" their requests to a subnet that has a DHCP server
on it. Because DHCP packets can be broadcast, they will not be routed off
of the local subnet. The DHCP relay takes care of this for the client.
%package devel
Summary: Development headers and libraries for the dhcpctl API
Group: Development/Libraries
%description devel
Dhcp devel contains all of the libraries and headers for developing with
the dhcpctl API.
%prep
%setup -q -n dhcp-%{version}
# do some file editing
egrep "VARRUN
ETC
VARDB" site.conf | sed -e 's/ *=/=/g' -e 's/= */=/g' > vars
. ./vars
cat << EOF >> includes/site.h
#define _PATH_DHCPD_PID "$VARRUN/dhcpd.pid"
#define _PATH_DHCPD_DB "$ETC/dhcpd.leases"
#define _PATH_DHCPD_CONF "$ETC/dhcpd.conf"
EOF
./configure --with-nsupdate
%build
make
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/sbin
make DESTDIR="$RPM_BUILD_ROOT" install
%ifos linux
mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/{init,rc0,rc1,rc2,rc3,rc4,rc5,rc6}.d
install -m 755 linux.init ${RPM_BUILD_ROOT}/etc/rc.d/init.d/dhcpd
%else
%ifos solaris
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
sed -e s'|@PREFIX@|%{_prefix}|g' < contrib/solaris.init > ${RPM_BUILD_ROOT}/etc/init.d/dhcpd
chmod 755 ${RPM_BUILD_ROOT}/etc/init.d/dhcpd
%endif
%endif
# strip binaries and libraries
strip $RPM_BUILD_ROOT%{_prefix}/sbin/* || :
for i in `find $RPM_BUILD_ROOT/ -type 'f' -perm '+a=x' ! -name 'lib*so*'`; do
file $i |grep -q "not stripped" && strip $i
done
%post
%ifos linux
/sbin/chkconfig --add dhcpd
/etc/rc.d/init.d/dhcpd start
%else
%ifos solaris
ln /etc/init.d/dhcpd /etc/rc2.d/S90dhcpd
ln /etc/init.d/dhcpd /etc/rc0.d/K30dhcpd
/etc/init.d/dhcpd start
%else
echo "Unknown O/S. You will need to manually configure your\nsystem"
echo "to start the DHCP server on system startup."
%endif
%endif
%preun
if [ $1 = 0 ]; then
%ifos linux
/etc/rc.d/init.d/dhcpd stop
/sbin/chkconfig --del dhcpd
%else
%ifos solaris
/etc/init.d/dhcpd stop
rm /etc/rc2.d/S90dhcpd
rm /etc/rc0.d/K30dhcpd
%else
echo "Unknown O/S. You will need to manually clean up the DHCP"
echo "server startup\n in your system startup environment."
%endif
%endif
fi
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc COPYRIGHT DOCUMENTATION ISC-LICENSE CHANGES README RELNOTES doc/*
%{_prefix}/sbin/dhcpd
%{_prefix}/man/cat1m/dhcpd.1m
%{_prefix}/man/cat4/dhcpd.conf.4
%{_prefix}/man/cat4/dhcpd.leases.4
%{_prefix}/man/cat4/dhcp-options.4
%{_prefix}/man/cat4/dhcp-eval.4
%{_prefix}/man/cat4/dhcp-contrib.4
%ifos linux
%config /etc/rc.d/init.d/dhcpd
%else
%ifos solaris
%config /etc/init.d/dhcpd
%endif
%endif
%files devel
%{_prefix}/man/cat3
%{_prefix}/lib
%{_prefix}/include
%files client
%{_prefix}/etc/dhclient-script
%{_prefix}/sbin/dhclient
%{_prefix}/man/cat1m/dhclient.1m
%{_prefix}/man/cat1m/dhclient-script.1m
%{_prefix}/man/cat4/dhclient.conf.4
%{_prefix}/man/cat4/dhclient.leases.4
%files relay
%{_prefix}/sbin/dhcrelay
%{_prefix}/man/cat1m/dhcrelay.1m
%changelog
* Fri Oct 1 1999 Brian J. Murrell <brian@interlinx.bc.ca>
- write a spec file for dhcpd

View File

@@ -0,0 +1,191 @@
LDAP Support in DHCP
Original Author: Brian Masney <masneyb@gftp.org>
Current Maintainer: David Cantrell <dcantrell@redhat.com>
Last updated 07-Jul-2009
This document describes setting up the DHCP server to read it's configuration
from LDAP. This work is based on the IETF document
draft-ietf-dhc-ldap-schema-01.txt included in the doc directory. For the
latest version of this document, please see
http://dcantrel.fedorapeople.org/dhcp/ldap-patch/
First question on most people's mind is "Why do I want to store my
configuration in LDAP?" If you run a small DHCP server, and the configuration
on it rarely changes, then you won't need to store your configuration in LDAP.
But, if you have several DHCP servers, and you want an easy way to manage your
configuration, this can be a solution.
The first step will be to setup your LDAP server. I am using OpenLDAP from
www.openldap.org. Building and installing OpenLDAP is beyond the scope of
this document. There is plenty of documentation out there about this. Once
you have OpenLDAP installed, you will have to edit your slapd.conf file. I
added the following 2 lines to my configuration file:
include /etc/ldap/schema/dhcp.schema
index dhcpHWAddress eq
index dhcpClassData eq
The first line tells it to include the dhcp schema file. You will find this
file under the contrib directory in this distribution. You will need to copy
this file to where your other schema files are (maybe /etc/openldap/schema/).
The second line sets up an index for the dhcpHWAddress parameter. The third
parameter is for reading subclasses from LDAP every time a DHCP request comes
in. Make sure you run the slapindex command and restart slapd to have these
changes to into effect.
Now that you have LDAP setup, you should be able to use gq
(http://biot.com/gq/) to verify that the dhcp schema file is loaded into LDAP.
Pull up gq, and click on the Schema tab. Go under objectClasses, and you
should see at least the following object classes listed: dhcpClass, dhcpGroup,
dhcpHost, dhcpOptions, dhcpPool, dhcpServer, dhcpService, dhcpSharedNetwork,
dhcpSubClass, and dhcpSubnet. If you do not see these, you need to check over
your LDAP configuration before you go any further.
You should now be ready to build DHCP. If you would like to enable LDAP in
dhcpd, you will need to perform the following steps:
* Apply the patch here to the unpacked ISC dhcp source tree.
* Regenerate the configure script (requires GNU autoconf and automake):
aclocal
libtoolize --copy --force
autoconf
autoheader
automake --foreign --add-missing --copy
* Run ./configure with the '--with-ldap' argument to enable OpenLDAP.
If you want LDAP over SSL, also use the '--with-ldapcrypto' argument.
* Run 'make' to build ISC dhcp.
Once you have DHCP installed, you will need to setup your initial plaintext
config file. In my /etc/dhcpd.conf file, I have:
ldap-server "localhost";
ldap-port 389;
ldap-username "cn=DHCP User, dc=ntelos, dc=net";
ldap-password "blah";
ldap-base-dn "dc=ntelos, dc=net";
ldap-method dynamic;
ldap-debug-file "/var/log/dhcp-ldap-startup.log";
If SSL has been enabled at compile time, the dhcp server trys to use TLS if
possible, but continues without TLS if not.
You can modify this behaviour using following option in /etc/dhcp/dhcpd.conf:
ldap-ssl <off | ldaps | start_tls | on>
off: disables TLS/LDAPS.
ldaps: enables LDAPS -- don't forget to set ldap-port to 636.
start_tls: enables TLS using START_TLS command
on: enables LDAPS if ldap-port is set to 636 or TLS in
other cases.
See also "man 5 ldap.conf" for description the following TLS related
options:
ldap-tls-reqcert, ldap-tls-ca-file, ldap-tls-ca-dir, ldap-tls-cert
ldap-tls-key, ldap-tls-crlcheck, ldap-tls-ciphers, ldap-tls-randfile
All of these parameters should be self explanatory except for the ldap-method.
You can set this to static or dynamic. If you set it to static, the
configuration is read once on startup, and LDAP isn't used anymore. But, if
you set this to dynamic, the configuration is read once on startup, and the
hosts that are stored in LDAP are looked up every time a DHCP request comes
in.
When the optional statement ldap-debug-file is specified, on startup the DHCP
server will write out the configuration that it generated from LDAP. If you
are getting errors about your LDAP configuration, this is a good place to
start looking.
The next step is to set up your LDAP tree. Here is an example config that will
give a 10.100.0.x address to machines that have a host entry in LDAP.
Otherwise, it will give a 10.200.0.x address to them. (NOTE: replace
dc=ntelos, dc=net with your base dn). If you would like to convert your
existing dhcpd.conf file to LDIF format, there is a script
dhcpd-conf-to-ldap that will convert it for you. Type
dhcpd-conf-to-ldap --help to see the usage information for this script.
# You must specify the server's host name in LDAP that you are going to run
# DHCP on and point it to which config tree you want to use. Whenever DHCP
# first starts up, it will do a search for this entry to find out which
# config to use
dn: cn=brian.ntelos.net, dc=ntelos, dc=net
objectClass: top
objectClass: dhcpServer
cn: brian.ntelos.net
dhcpServiceDN: cn=DHCP Service Config, dc=ntelos, dc=net
# Here is the config tree that brian.ntelos.net points to.
dn: cn=DHCP Service Config, dc=ntelos, dc=net
cn: DHCP Service Config
objectClass: top
objectClass: dhcpService
dhcpPrimaryDN: dc=ntelos, dc=net
dhcpStatements: ddns-update-style none
dhcpStatements: default-lease-time 600
dhcpStatements: max-lease-time 7200
# Set up a shared network segment
dn: cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
cn: WV
objectClass: top
objectClass: dhcpSharedNetwork
# Set up a subnet declaration with a pool statement. Also note that we have
# a dhcpOptions object with this entry
dn: cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
cn: 10.100.0.0
objectClass: top
objectClass: dhcpSubnet
objectClass: dhcpOptions
dhcpOption: domain-name-servers 10.100.0.2
dhcpOption: routers 10.100.0.1
dhcpOption: subnet-mask 255.255.255.0
dhcpOption: broadcast-address 10.100.0.255
dhcpNetMask: 24
# Set up a pool for this subnet. Only known hosts will get these IPs
dn: cn=Known Pool, cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
cn: Known Pool
objectClass: top
objectClass: dhcpPool
dhcpRange: 10.100.0.3 10.100.0.254
dhcpPermitList: deny unknown-clients
# Set up another subnet declaration with a pool statement
dn: cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
cn: 10.200.0.0
objectClass: top
objectClass: dhcpSubnet
objectClass: dhcpOptions
dhcpOption: domain-name-servers 10.200.0.2
dhcpOption: routers 10.200.0.1
dhcpOption: subnet-mask 255.255.255.0
dhcpOption: broadcast-address 10.200.0.255
dhcpNetMask: 24
# Set up a pool for this subnet. Only unknown hosts will get these IPs
dn: cn=Known Pool, cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
cn: Known Pool
objectClass: top
objectClass: dhcpPool
dhcpRange: 10.200.0.3 10.200.0.254
dhcpPermitList: deny known clients
# Set aside a group for all of our known MAC addresses
dn: cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
objectClass: top
objectClass: dhcpGroup
cn: Customers
# Host entry for my laptop
dn: cn=brianlaptop, cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
objectClass: top
objectClass: dhcpHost
cn: brianlaptop
dhcpHWAddress: ethernet 00:00:00:00:00:00
You can use the command ldapadd to load all of these entries into your LDAP
server. After you load this, you should be able to start up DHCP. If you run
into problems reading the configuration, try running dhcpd with the -d flag.
If you still have problems, edit the site.conf file in the DHCP source and
add the line: COPTS= -DDEBUG_LDAP and recompile DHCP. (make sure you run make
clean and rerun configure before you rebuild).

View File

@@ -0,0 +1,462 @@
attributetype ( 2.16.840.1.113719.1.203.4.1
NAME 'dhcpPrimaryDN'
EQUALITY distinguishedNameMatch
DESC 'The DN of the dhcpServer which is the primary server for the configuration.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.2
NAME 'dhcpSecondaryDN'
EQUALITY distinguishedNameMatch
DESC 'The DN of dhcpServer(s) which provide backup service for the configuration.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.3
NAME 'dhcpStatements'
EQUALITY caseIgnoreIA5Match
DESC 'Flexible storage for specific data depending on what object this exists in. Like conditional statements, server parameters, etc. This allows the standard to evolve without needing to adjust the schema.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.4
NAME 'dhcpRange'
EQUALITY caseIgnoreIA5Match
DESC 'The starting & ending IP Addresses in the range (inclusive), separated by a hyphen; if the range only contains one address, then just the address can be specified with no hyphen. Each range is defined as a separate value.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.5
NAME 'dhcpPermitList'
EQUALITY caseIgnoreIA5Match
DESC 'This attribute contains the permit lists associated with a pool. Each permit list is defined as a separate value.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.6
NAME 'dhcpNetMask'
EQUALITY integerMatch
DESC 'The subnet mask length for the subnet. The mask can be easily computed from this length.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.7
NAME 'dhcpOption'
EQUALITY caseIgnoreIA5Match
DESC 'Encoded option values to be sent to clients. Each value represents a single option and contains (OptionTag, Length, OptionValue) encoded in the format used by DHCP.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.8
NAME 'dhcpClassData'
EQUALITY caseIgnoreIA5Match
DESC 'Encoded text string or list of bytes expressed in hexadecimal, separated by colons. Clients match subclasses based on matching the class data with the results of match or spawn with statements in the class name declarations.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.9
NAME 'dhcpOptionsDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of the dhcpOption objects containing the configuration options provided by the server.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.10
NAME 'dhcpHostDN'
EQUALITY distinguishedNameMatch
DESC 'the distinguished name(s) of the dhcpHost objects.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.11
NAME 'dhcpPoolDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of pools.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.12
NAME 'dhcpGroupDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of the groups.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.13
NAME 'dhcpSubnetDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of the subnets.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.14
NAME 'dhcpLeaseDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name of a client address.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE)
attributetype ( 2.16.840.1.113719.1.203.4.15
NAME 'dhcpLeasesDN'
DESC 'The distinguished name(s) client addresses.'
EQUALITY distinguishedNameMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.16
NAME 'dhcpClassesDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of a class(es) in a subclass.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.17
NAME 'dhcpSubclassesDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of subclass(es).'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.18
NAME 'dhcpSharedNetworkDN'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name(s) of sharedNetworks.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.19
NAME 'dhcpServiceDN'
EQUALITY distinguishedNameMatch
DESC 'The DN of dhcpService object(s)which contain the configuration information. Each dhcpServer object has this attribute identifying the DHCP configuration(s) that the server is associated with.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.20
NAME 'dhcpVersion'
DESC 'The version attribute of this object.'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.21
NAME 'dhcpImplementation'
EQUALITY caseIgnoreIA5Match
DESC 'Description of the DHCP Server implementation e.g. DHCP Servers vendor.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.22
NAME 'dhcpAddressState'
EQUALITY caseIgnoreIA5Match
DESC 'This stores information about the current binding-status of an address. For dynamic addresses managed by DHCP, the values should be restricted to the following: "FREE", "ACTIVE", "EXPIRED", "RELEASED", "RESET", "ABANDONED", "BACKUP". For other addresses, it SHOULD be one of the following: "UNKNOWN", "RESERVED" (an address that is managed by DHCP that is reserved for a specific client), "RESERVED-ACTIVE" (same as reserved, but address is currently in use), "ASSIGNED" (assigned manually or by some other mechanism), "UNASSIGNED", "NOTASSIGNABLE".'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.23
NAME 'dhcpExpirationTime'
EQUALITY generalizedTimeMatch
DESC 'This is the time the current lease for an address expires.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.24
NAME 'dhcpStartTimeOfState'
EQUALITY generalizedTimeMatch
DESC 'This is the time of the last state change for a leased address.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.25
NAME 'dhcpLastTransactionTime'
EQUALITY generalizedTimeMatch
DESC 'This is the last time a valid DHCP packet was received from the client.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.26
NAME 'dhcpBootpFlag'
EQUALITY booleanMatch
DESC 'This indicates whether the address was assigned via BOOTP.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.27
NAME 'dhcpDomainName'
EQUALITY caseIgnoreIA5Match
DESC 'This is the name of the domain sent to the client by the server. It is essentially the same as the value for DHCP option 15 sent to the client, and represents only the domain - not the full FQDN. To obtain the full FQDN assigned to the client you must prepend the "dhcpAssignedHostName" to this value with a ".".'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.28
NAME 'dhcpDnsStatus'
EQUALITY integerMatch
DESC 'This indicates the status of updating DNS resource records on behalf of the client by the DHCP server for this address. The value is a 16-bit bitmask.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.29
NAME 'dhcpRequestedHostName'
EQUALITY caseIgnoreIA5Match
DESC 'This is the hostname that was requested by the client.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.30
NAME 'dhcpAssignedHostName'
EQUALITY caseIgnoreIA5Match
DESC 'This is the actual hostname that was assigned to a client. It may not be the name that was requested by the client. The fully qualified domain name can be determined by appending the value of "dhcpDomainName" (with a dot separator) to this name.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.31
NAME 'dhcpReservedForClient'
EQUALITY distinguishedNameMatch
DESC 'The distinguished name of a "dhcpClient" that an address is reserved for. This may not be the same as the "dhcpAssignedToClient" attribute if the address is being reassigned but the current lease has not yet expired.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.32
NAME 'dhcpAssignedToClient'
EQUALITY distinguishedNameMatch
DESC 'This is the distinguished name of a "dhcpClient" that an address is currently assigned to. This attribute is only present in the class when the address is leased.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.33
NAME 'dhcpRelayAgentInfo'
EQUALITY octetStringMatch
DESC 'If the client request was received via a relay agent, this contains information about the relay agent that was available from the DHCP request. This is a hex-encoded option value.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.34
NAME 'dhcpHWAddress'
EQUALITY caseIgnoreIA5Match
DESC 'The clients hardware address that requested this IP address.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.35
NAME 'dhcpHashBucketAssignment'
EQUALITY octetStringMatch
DESC 'HashBucketAssignment bit map for the DHCP Server, as defined in DHC Load Balancing Algorithm [RFC 3074].'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.36
NAME 'dhcpDelayedServiceParameter'
EQUALITY integerMatch
DESC 'Delay in seconds corresponding to Delayed Service Parameter configuration, as defined in DHC Load Balancing Algorithm [RFC 3074]. '
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.37
NAME 'dhcpMaxClientLeadTime'
EQUALITY integerMatch
DESC 'Maximum Client Lead Time configuration in seconds, as defined in DHCP Failover Protocol [FAILOVR]'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.38
NAME 'dhcpFailOverEndpointState'
EQUALITY caseIgnoreIA5Match
DESC 'Server (Failover Endpoint) state, as defined in DHCP Failover Protocol [FAILOVR]'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.39
NAME 'dhcpErrorLog'
EQUALITY caseIgnoreIA5Match
DESC 'Generic error log attribute that allows logging error conditions within a dhcpService or a dhcpSubnet, like no IP addresses available for lease.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.40
NAME 'dhcpLocatorDN'
EQUALITY distinguishedNameMatch
DESC 'The DN of dhcpLocator object which contain the DNs of all DHCP configuration objects. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.41
NAME 'dhcpKeyAlgorithm'
EQUALITY caseIgnoreIA5Match
DESC 'Algorithm to generate TSIG Key'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.42
NAME 'dhcpKeySecret'
EQUALITY octetStringMatch
DESC 'Secret to generate TSIG Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.43
NAME 'dhcpDnsZoneServer'
EQUALITY caseIgnoreIA5Match
DESC 'Master server of the DNS Zone'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 2.16.840.1.113719.1.203.4.44
NAME 'dhcpKeyDN'
EQUALITY distinguishedNameMatch
DESC 'The DNs of TSIG Key to use in secure dynamic updates. In case of locator object, this will be list of TSIG keys. In case of DHCP Service, Shared Network, Subnet and DNS Zone, it will be a single key.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
attributetype ( 2.16.840.1.113719.1.203.4.45
NAME 'dhcpZoneDN'
EQUALITY distinguishedNameMatch
DESC 'The DNs of DNS Zone. In case of locator object, this will be list of DNS Zones in the tree. In case of DHCP Service, Shared Network and Subnet, it will be a single DNS Zone.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
attributetype ( 2.16.840.1.113719.1.203.4.46
NAME 'dhcpFailOverPrimaryServer'
EQUALITY caseIgnoreIA5Match
DESC 'IP address or DNS name of the server playing primary role in DHC Load Balancing and Fail over.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.47
NAME 'dhcpFailOverSecondaryServer'
EQUALITY caseIgnoreIA5Match
DESC 'IP address or DNS name of the server playing secondary role in DHC Load Balancing and Fail over.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 2.16.840.1.113719.1.203.4.48
NAME 'dhcpFailOverPrimaryPort'
EQUALITY integerMatch
DESC 'Port on which primary server listens for connections from its fail over peer (secondary server)'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.49
NAME 'dhcpFailOverSecondaryPort'
EQUALITY integerMatch
DESC 'Port on which secondary server listens for connections from its fail over peer (primary server)'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.50
NAME 'dhcpFailOverResponseDelay'
EQUALITY integerMatch
DESC 'Maximum response time in seconds, before Server assumes that connection to fail over peer has failed'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.51
NAME 'dhcpFailOverUnackedUpdates'
EQUALITY integerMatch
DESC 'Number of BNDUPD messages that server can send before it receives BNDACK from its fail over peer'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.52
NAME 'dhcpFailOverSplit'
EQUALITY integerMatch
DESC 'Split between the primary and secondary servers for fail over purpose'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.53
NAME 'dhcpFailOverLoadBalanceTime'
EQUALITY integerMatch
DESC 'Cutoff time in seconds, after which load balance is disabled'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
attributetype ( 2.16.840.1.113719.1.203.4.54
NAME 'dhcpFailOverPeerDN'
EQUALITY distinguishedNameMatch
DESC 'The DNs of Fail over peers. In case of locator object, this will be list of fail over peers in the tree. In case of Subnet and pool, it will be a single Fail Over Peer'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
#List of all servers in the tree
attributetype ( 2.16.840.1.113719.1.203.4.55
NAME 'dhcpServerDN'
EQUALITY distinguishedNameMatch
DESC 'List of all DHCP Servers in the tree. Used by dhcpLocatorObject'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
attributetype ( 2.16.840.1.113719.1.203.4.56
NAME 'dhcpComments'
EQUALITY caseIgnoreIA5Match
DESC 'Generic attribute that allows coments within any DHCP object'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
# Classes
objectclass ( 2.16.840.1.113719.1.203.6.1
NAME 'dhcpService'
DESC 'Service object that represents the actual DHCP Service configuration. This is a container object.'
SUP top
MUST (cn)
MAY ( dhcpPrimaryDN $ dhcpSecondaryDN $ dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $dhcpComments $ dhcpOption) )
objectclass ( 2.16.840.1.113719.1.203.6.2
NAME 'dhcpSharedNetwork'
DESC 'This stores configuration information for a shared network.'
SUP top
MUST cn
MAY ( dhcpSubnetDN $ dhcpPoolDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpStatements $dhcpComments $ dhcpOption) X-NDS_CONTAINMENT ('dhcpService' ) )
objectclass ( 2.16.840.1.113719.1.203.6.3
NAME 'dhcpSubnet'
DESC 'This class defines a subnet. This is a container object.'
SUP top
MUST ( cn $ dhcpNetMask )
MAY ( dhcpRange $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $ dhcpComments $ dhcpOption ) X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork') )
objectclass ( 2.16.840.1.113719.1.203.6.4
NAME 'dhcpPool'
DESC 'This stores configuration information about a pool.'
SUP top
MUST ( cn $ dhcpRange )
MAY ( dhcpClassesDN $ dhcpPermitList $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $dhcpKeyDN $ dhcpStatements $ dhcpComments $ dhcpOption )
X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpSharedNetwork') )
objectclass ( 2.16.840.1.113719.1.203.6.5
NAME 'dhcpGroup'
DESC 'Group object that lists host DNs and parameters. This is a container object.'
SUP top
MUST cn
MAY ( dhcpHostDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption )
X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpService' ) )
objectclass ( 2.16.840.1.113719.1.203.6.6
NAME 'dhcpHost'
DESC 'This represents information about a particular client'
SUP top
MUST cn
MAY (dhcpLeaseDN $ dhcpHWAddress $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption)
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' 'dhcpGroup') )
objectclass ( 2.16.840.1.113719.1.203.6.7
NAME 'dhcpClass'
DESC 'Represents information about a collection of related clients.'
SUP top
MUST cn
MAY (dhcpSubClassesDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption)
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' ) )
objectclass ( 2.16.840.1.113719.1.203.6.8
NAME 'dhcpSubClass'
DESC 'Represents information about a collection of related classes.'
SUP top
MUST cn
MAY (dhcpClassData $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption) X-NDS_CONTAINMENT 'dhcpClass' )
objectclass ( 2.16.840.1.113719.1.203.6.9
NAME 'dhcpOptions'
DESC 'Represents information about a collection of options defined.'
SUP top AUXILIARY
MUST cn
MAY ( dhcpOption $ dhcpComments )
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet' 'dhcpPool' 'dhcpGroup' 'dhcpHost' 'dhcpClass' ) )
objectclass ( 2.16.840.1.113719.1.203.6.10
NAME 'dhcpLeases'
DESC 'This class represents an IP Address, which may or may not have been leased.'
SUP top
MUST ( cn $ dhcpAddressState )
MAY ( dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress )
X-NDS_CONTAINMENT ( 'dhcpService' 'dhcpSubnet' 'dhcpPool') )
objectclass ( 2.16.840.1.113719.1.203.6.11
NAME 'dhcpLog'
DESC 'This is the object that holds past information about the IP address. The cn is the time/date stamp when the address was assigned or released, the address state at the time, if the address was assigned or released.'
SUP top
MUST ( cn )
MAY ( dhcpAddressState $ dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress $ dhcpErrorLog)
X-NDS_CONTAINMENT ('dhcpLeases' 'dhcpPool' 'dhcpSubnet' 'dhcpSharedNetwork' 'dhcpService' ) )
objectclass ( 2.16.840.1.113719.1.203.6.12
NAME 'dhcpServer'
DESC 'DHCP Server Object'
SUP top
MUST ( cn )
MAY (dhcpServiceDN $ dhcpLocatorDN $ dhcpVersion $ dhcpImplementation $ dhcpHashBucketAssignment $ dhcpDelayedServiceParameter $ dhcpMaxClientLeadTime $ dhcpFailOverEndpointState $ dhcpStatements $ dhcpComments $ dhcpOption)
X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )
objectclass ( 2.16.840.1.113719.1.203.6.13
NAME 'dhcpTSigKey'
DESC 'TSIG key for secure dynamic updates'
SUP top
MUST (cn $ dhcpKeyAlgorithm $ dhcpKeySecret )
MAY ( dhcpComments )
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
objectclass ( 2.16.840.1.113719.1.203.6.14
NAME 'dhcpDnsZone'
DESC 'DNS Zone for updating leases'
SUP top
MUST (cn $ dhcpDnsZoneServer )
MAY (dhcpKeyDN $ dhcpComments)
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
objectclass ( 2.16.840.1.113719.1.203.6.15
NAME 'dhcpFailOverPeer'
DESC 'This class defines the Fail over peer'
SUP top
MUST ( cn $ dhcpFailOverPrimaryServer $ dhcpFailOverSecondaryServer $ dhcpFailoverPrimaryPort $ dhcpFailOverSecondaryPort) MAY (dhcpFailOverResponseDelay $ dhcpFailOverUnackedUpdates $ dhcpMaxClientLeadTime $ dhcpFailOverSplit $ dhcpHashBucketAssignment $ dhcpFailOverLoadBalanceTime $ dhcpComments )
X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
objectclass ( 2.16.840.1.113719.1.203.6.16
NAME 'dhcpLocator'
DESC 'Locator object for DHCP configuration in the tree. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree'
SUP top
MUST ( cn )
MAY ( dhcpServiceDN $dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpKeyDN $ dhcpZoneDN $ dhcpFailOverPeerDN $ dhcpOption $ dhcpComments)
X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )

View File

@@ -0,0 +1,760 @@
#!/usr/bin/perl -w
# Brian Masney <masneyb@gftp.org>
# To use this script, set your base DN below. Then run
# ./dhcpd-conf-to-ldap.pl < /path-to-dhcpd-conf/dhcpd.conf > output-file
# The output of this script will generate entries in LDIF format. You can use
# the slapadd command to add these entries into your LDAP server. You will
# definately want to double check that your LDAP entries are correct before
# you load them into LDAP.
# This script does not do much error checking. Make sure before you run this
# that the DHCP server doesn't give any errors about your config file
# FailOver notes:
# Failover is disabled by default, since it may need manually intervention.
# You can try the '--use=failover' option to see what happens :-)
#
# If enabled, the failover pool references will be written to LDIF output.
# The failover configs itself will be added to the dhcpServer statements
# and not to the dhcpService object (since this script uses only one and
# it may be usefull to have multiple service containers in failover mode).
# Further, this script does not check if primary or secondary makes sense,
# it simply converts what it gets...
use Net::Domain qw(hostname hostfqdn hostdomain);
use Getopt::Long;
my $domain = hostdomain(); # your.domain
my $basedn = "dc=".$domain;
$basedn =~ s/\./,dc=/g; # dc=your,dc=domain
my $server = hostname(); # hostname (nodename)
my $dhcpcn = 'DHCP Config'; # CN of DHCP config tree
my $dhcpdn = "cn=$dhcpcn, $basedn"; # DHCP config tree DN
my $second = ''; # secondary server DN / hostname
my $i_conf = ''; # dhcp.conf file to read or stdin
my $o_ldif = ''; # output ldif file name or stdout
my @use = (); # extended flags (failover)
sub usage($;$)
{
my $rc = shift;
my $err= shift;
print STDERR "Error: $err\n\n" if(defined $err);
print STDERR <<__EOF_USAGE__;
usage:
$0 [options] < dhcpd.conf > dhcpd.ldif
options:
--basedn "dc=your,dc=domain" ("$basedn")
--dhcpdn "dhcp config DN" ("$dhcpdn")
--server "dhcp server name" ("$server")
--second "secondary server or DN" ("$second")
--conf "/path/to/dhcpd.conf" (default is stdin)
--ldif "/path/to/output.ldif" (default is stdout)
--use "extended features" (see source comments)
__EOF_USAGE__
exit($rc);
}
sub next_token
{
local ($lowercase) = @_;
local ($token, $newline);
do
{
if (!defined ($line) || length ($line) == 0)
{
$line = <>;
return undef if !defined ($line);
chop $line;
$line_number++;
$token_number = 0;
}
$line =~ s/#.*//;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
}
while (length ($line) == 0);
if (($token, $newline) = $line =~ /^(.*?)\s+(.*)/)
{
if ($token =~ /^"/) {
#handle quoted token
if ($token !~ /"\s*$/)
{
($tok, $newline) = $newline =~ /([^"]+")(.*)/;
$token .= " $tok";
}
}
$line = $newline;
}
else
{
$token = $line;
$line = '';
}
$token_number++;
$token =~ y/[A-Z]/[a-z]/ if $lowercase;
return ($token);
}
sub remaining_line
{
local ($block) = shift || 0;
local ($tmp, $str);
$str = "";
while (defined($tmp = next_token (0)))
{
$str .= ' ' if !($str eq "");
$str .= $tmp;
last if $tmp =~ /;\s*$/;
last if($block and $tmp =~ /\s*[}{]\s*$/);
}
$str =~ s/;$//;
return ($str);
}
sub
add_dn_to_stack
{
local ($dn) = @_;
$current_dn = "$dn, $current_dn";
}
sub
remove_dn_from_stack
{
$current_dn =~ s/^.*?,\s*//;
}
sub
parse_error
{
print "Parse error on line number $line_number at token number $token_number\n";
exit (1);
}
sub
print_entry
{
return if (scalar keys %curentry == 0);
if (!defined ($curentry{'type'}))
{
$hostdn = "cn=$server, $basedn";
print "dn: $hostdn\n";
print "cn: $server\n";
print "objectClass: top\n";
print "objectClass: dhcpServer\n";
print "dhcpServiceDN: $current_dn\n";
if(grep(/FaIlOvEr/i, @use))
{
foreach my $fo_peer (keys %failover)
{
next if(scalar(@{$failover{$fo_peer}}) <= 1);
print "dhcpStatements: failover peer $fo_peer { ",
join('; ', @{$failover{$fo_peer}}), "; }\n";
}
}
print "\n";
print "dn: $current_dn\n";
print "cn: $dhcpcn\n";
print "objectClass: top\n";
print "objectClass: dhcpService\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
print "dhcpPrimaryDN: $hostdn\n";
if(grep(/FaIlOvEr/i, @use) and ($second ne ''))
{
print "dhcpSecondaryDN: $second\n";
}
}
elsif ($curentry{'type'} eq 'subnet')
{
print "dn: $current_dn\n";
print "cn: " . $curentry{'ip'} . "\n";
print "objectClass: top\n";
print "objectClass: dhcpSubnet\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
print "dhcpNetMask: " . $curentry{'netmask'} . "\n";
if (defined ($curentry{'ranges'}))
{
foreach $statement (@{$curentry{'ranges'}})
{
print "dhcpRange: $statement\n";
}
}
}
elsif ($curentry{'type'} eq 'shared-network')
{
print "dn: $current_dn\n";
print "cn: " . $curentry{'descr'} . "\n";
print "objectClass: top\n";
print "objectClass: dhcpSharedNetwork\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
}
elsif ($curentry{'type'} eq 'group')
{
print "dn: $current_dn\n";
print "cn: group", $curentry{'idx'}, "\n";
print "objectClass: top\n";
print "objectClass: dhcpGroup\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
}
elsif ($curentry{'type'} eq 'host')
{
print "dn: $current_dn\n";
print "cn: " . $curentry{'host'} . "\n";
print "objectClass: top\n";
print "objectClass: dhcpHost\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
if (defined ($curentry{'hwaddress'}))
{
$curentry{'hwaddress'} =~ y/[A-Z]/[a-z]/;
print "dhcpHWAddress: " . $curentry{'hwaddress'} . "\n";
}
}
elsif ($curentry{'type'} eq 'pool')
{
print "dn: $current_dn\n";
print "cn: pool", $curentry{'idx'}, "\n";
print "objectClass: top\n";
print "objectClass: dhcpPool\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
if (defined ($curentry{'ranges'}))
{
foreach $statement (@{$curentry{'ranges'}})
{
print "dhcpRange: $statement\n";
}
}
}
elsif ($curentry{'type'} eq 'class')
{
print "dn: $current_dn\n";
print "cn: " . $curentry{'class'} . "\n";
print "objectClass: top\n";
print "objectClass: dhcpClass\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
}
elsif ($curentry{'type'} eq 'subclass')
{
print "dn: $current_dn\n";
print "cn: " . $curentry{'subclass'} . "\n";
print "objectClass: top\n";
print "objectClass: dhcpSubClass\n";
if (defined ($curentry{'options'}))
{
print "objectClass: dhcpOptions\n";
}
print "dhcpClassData: " . $curentry{'class'} . "\n";
}
if (defined ($curentry{'statements'}))
{
foreach $statement (@{$curentry{'statements'}})
{
print "dhcpStatements: $statement\n";
}
}
if (defined ($curentry{'options'}))
{
foreach $statement (@{$curentry{'options'}})
{
print "dhcpOption: $statement\n";
}
}
print "\n";
undef (%curentry);
}
sub parse_netmask
{
local ($netmask) = @_;
local ($i);
if ((($a, $b, $c, $d) = $netmask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) != 4)
{
parse_error ();
}
$num = (($a & 0xff) << 24) |
(($b & 0xff) << 16) |
(($c & 0xff) << 8) |
($d & 0xff);
for ($i=1; $i<=32 && $num & (1 << (32 - $i)); $i++)
{
}
$i--;
return ($i);
}
sub parse_subnet
{
local ($ip, $tmp, $netmask);
print_entry () if %curentry;
$ip = next_token (0);
parse_error () if !defined ($ip);
$tmp = next_token (1);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq 'netmask');
$tmp = next_token (0);
parse_error () if !defined ($tmp);
$netmask = parse_netmask ($tmp);
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
add_dn_to_stack ("cn=$ip");
$curentry{'type'} = 'subnet';
$curentry{'ip'} = $ip;
$curentry{'netmask'} = $netmask;
$cursubnet = $ip;
$curcounter{$ip} = { pool => 0, group => 0 };
}
sub parse_shared_network
{
local ($descr, $tmp);
print_entry () if %curentry;
$descr = next_token (0);
parse_error () if !defined ($descr);
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
add_dn_to_stack ("cn=$descr");
$curentry{'type'} = 'shared-network';
$curentry{'descr'} = $descr;
}
sub parse_host
{
local ($descr, $tmp);
print_entry () if %curentry;
$host = next_token (0);
parse_error () if !defined ($host);
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
add_dn_to_stack ("cn=$host");
$curentry{'type'} = 'host';
$curentry{'host'} = $host;
}
sub parse_group
{
local ($descr, $tmp);
print_entry () if %curentry;
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
my $idx;
if(exists($curcounter{$cursubnet})) {
$idx = ++$curcounter{$cursubnet}->{'group'};
} else {
$idx = ++$curcounter{''}->{'group'};
}
add_dn_to_stack ("cn=group".$idx);
$curentry{'type'} = 'group';
$curentry{'idx'} = $idx;
}
sub parse_pool
{
local ($descr, $tmp);
print_entry () if %curentry;
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
my $idx;
if(exists($curcounter{$cursubnet})) {
$idx = ++$curcounter{$cursubnet}->{'pool'};
} else {
$idx = ++$curcounter{''}->{'pool'};
}
add_dn_to_stack ("cn=pool".$idx);
$curentry{'type'} = 'pool';
$curentry{'idx'} = $idx;
}
sub parse_class
{
local ($descr, $tmp);
print_entry () if %curentry;
$class = next_token (0);
parse_error () if !defined ($class);
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
$class =~ s/\"//g;
add_dn_to_stack ("cn=$class");
$curentry{'type'} = 'class';
$curentry{'class'} = $class;
}
sub parse_subclass
{
local ($descr, $tmp);
print_entry () if %curentry;
$class = next_token (0);
parse_error () if !defined ($class);
$subclass = next_token (0);
parse_error () if !defined ($subclass);
$tmp = next_token (0);
parse_error () if !defined ($tmp);
parse_error () if !($tmp eq '{');
add_dn_to_stack ("cn=$subclass");
$curentry{'type'} = 'subclass';
$curentry{'class'} = $class;
$curentry{'subclass'} = $subclass;
}
sub parse_hwaddress
{
local ($type, $hw, $tmp);
$type = next_token (1);
parse_error () if !defined ($type);
$hw = next_token (1);
parse_error () if !defined ($hw);
$hw =~ s/;$//;
$curentry{'hwaddress'} = "$type $hw";
}
sub parse_range
{
local ($tmp, $str);
$str = remaining_line ();
if (!($str eq ''))
{
$str =~ s/;$//;
push (@{$curentry{'ranges'}}, $str);
}
}
sub parse_statement
{
local ($token) = shift;
local ($str);
if ($token eq 'option')
{
$str = remaining_line ();
push (@{$curentry{'options'}}, $str);
}
elsif($token eq 'failover')
{
$str = remaining_line (1); # take care on block
if($str =~ /[{]/)
{
my ($peername, @statements);
parse_error() if($str !~ /^\s*peer\s+(.+?)\s+[{]\s*$/);
parse_error() if(($peername = $1) !~ /^\"?[^\"]+\"?$/);
#
# failover config block found:
# e.g. 'failover peer "some-name" {'
#
if(not grep(/FaIlOvEr/i, @use))
{
print STDERR "Warning: Failover config 'peer $peername' found!\n";
print STDERR " Skipping it, since failover disabled!\n";
print STDERR " You may try out --use=failover option.\n";
}
until($str =~ /[}]/ or $str eq "")
{
$str = remaining_line (1);
# collect all statements, except ending '}'
push(@statements, $str) if($str !~ /[}]/);
}
$failover{$peername} = [@statements];
}
else
{
#
# pool reference to failover config is fine
# e.g. 'failover peer "some-name";'
#
if(not grep(/FaIlOvEr/i, @use))
{
print STDERR "Warning: Failover reference '$str' found!\n";
print STDERR " Skipping it, since failover disabled!\n";
print STDERR " You may try out --use=failover option.\n";
}
else
{
push (@{$curentry{'statements'}}, $token. " " . $str);
}
}
}
elsif($token eq 'zone')
{
$str = $token;
while($str !~ /}$/) {
$str .= ' ' . next_token (0);
}
push (@{$curentry{'statements'}}, $str);
}
elsif($token =~ /^(authoritative)[;]*$/)
{
push (@{$curentry{'statements'}}, $1);
}
else
{
$str = $token . " " . remaining_line ();
push (@{$curentry{'statements'}}, $str);
}
}
my $ok = GetOptions(
'basedn=s' => \$basedn,
'dhcpdn=s' => \$dhcpdn,
'server=s' => \$server,
'second=s' => \$second,
'conf=s' => \$i_conf,
'ldif=s' => \$o_ldif,
'use=s' => \@use,
'h|help|usage' => sub { usage(0); },
);
unless($server =~ /^\w+/)
{
usage(1, "invalid server name '$server'");
}
unless($basedn =~ /^\w+=[^,]+/)
{
usage(1, "invalid base dn '$basedn'");
}
if($dhcpdn =~ /^cn=([^,]+)/i)
{
$dhcpcn = "$1";
}
$second = '' if not defined $second;
unless($second eq '' or $second =~ /^cn=[^,]+\s*,\s*\w+=[^,]+/i)
{
if($second =~ /^cn=[^,]+$/i)
{
# relative DN 'cn=name'
$second = "$second, $basedn";
}
elsif($second =~ /^\w+/)
{
# assume hostname only
$second = "cn=$second, $basedn";
}
else
{
usage(1, "invalid secondary '$second'")
}
}
usage(1) unless($ok);
if($i_conf ne "" and -f $i_conf)
{
if(not open(STDIN, '<', $i_conf))
{
print STDERR "Error: can't open conf file '$i_conf': $!\n";
exit(1);
}
}
if($o_ldif ne "")
{
if(-e $o_ldif)
{
print STDERR "Error: output ldif name '$o_ldif' already exists!\n";
exit(1);
}
if(not open(STDOUT, '>', $o_ldif))
{
print STDERR "Error: can't open ldif file '$o_ldif': $!\n";
exit(1);
}
}
print STDERR "Creating LDAP Configuration with the following options:\n";
print STDERR "\tBase DN: $basedn\n";
print STDERR "\tDHCP DN: $dhcpdn\n";
print STDERR "\tServer DN: cn=$server, $basedn\n";
print STDERR "\tSecondary DN: $second\n"
if(grep(/FaIlOvEr/i, @use) and $second ne '');
print STDERR "\n";
my $token;
my $token_number = 0;
my $line_number = 0;
my %curentry;
my $cursubnet = '';
my %curcounter = ( '' => { pool => 0, group => 0 } );
$current_dn = "$dhcpdn";
$curentry{'descr'} = $dhcpcn;
$line = '';
%failover = ();
while (($token = next_token (1)))
{
if ($token eq '}')
{
print_entry () if %curentry;
if($current_dn =~ /.+?,\s*${dhcpdn}$/) {
# don't go below dhcpdn ...
remove_dn_from_stack ();
}
}
elsif ($token eq 'subnet')
{
parse_subnet ();
next;
}
elsif ($token eq 'shared-network')
{
parse_shared_network ();
next;
}
elsif ($token eq 'class')
{
parse_class ();
next;
}
elsif ($token eq 'subclass')
{
parse_subclass ();
next;
}
elsif ($token eq 'pool')
{
parse_pool ();
next;
}
elsif ($token eq 'group')
{
parse_group ();
next;
}
elsif ($token eq 'host')
{
parse_host ();
next;
}
elsif ($token eq 'hardware')
{
parse_hwaddress ();
next;
}
elsif ($token eq 'range')
{
parse_range ();
next;
}
else
{
parse_statement ($token);
next;
}
}
close(STDIN) if($i_conf);
close(STDOUT) if($o_ldif);
print STDERR "Done.\n";

View File

@@ -0,0 +1,361 @@
# Registry.pm
# A perl module provided easy Windows Registry access
#
# Author: Shu-Min Chang
#
# Copyright(c) 2002 Intel Corporation. All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution
# 3. Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE INTEL CORPORATION AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL CORPORATION OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVICED OF THE POSSIBILITY OF SUCH
# DAMAGE.
package Registry;
use strict;
use Win32API::Registry 0.21 qw( :ALL );
###############################################################################
#-----------------------------------------
sub GetRegKeyVal($*) {
my ($FullRegPath, $value) = @_;
#-----------------------------------------
# Purpose: uses Win32API to get registry information from a given server
#
# WARNING: this procedure is VERY Win32 specific, you'll need a Win32 manual
# to figure out why something is done.
# input: $FullRegPath: a MS specific way of fully qualifying a registry path
# \\Server\RootKey\Path\ValueName
# output: *value: the value of the registry key of $FullRegPath
#
my ($RemoteMachine, $RootKey, $RegPath, $KeyName, $i);
#print "in sub:GetRegKeyVal:Parameters:", @_, "\n";
# Check the for valid fully qualified registry path
return -1 if (! ($FullRegPath =~ /\\.+\\.+/)) && (!($FullRegPath =~ /\\\\.+\\.+\\.+/));
$RemoteMachine = (index($FullRegPath, "\\\\") == $[ ? substr($FullRegPath, $[+2, index($FullRegPath, "\\", $[+2)-2):0);
#print "RemoteMachine = $RemoteMachine\n";
$i = $RemoteMachine ? $[+3+length($RemoteMachine) : $[+1;
$RootKey = substr ($FullRegPath, $i, index($FullRegPath, "\\", $i)-$i);
$KeyName = $FullRegPath;
$KeyName =~ s/.*\\(.+)/$1/;
#print "KeyName = $KeyName\n";
$i = index($FullRegPath, $RootKey, $[+length($RemoteMachine)) + $[ + length($RootKey)+1;
$RegPath = substr ($FullRegPath, $i, length($FullRegPath) - length($KeyName) -$i - 1);
#print "RegPath = $RegPath\n";
my ($RootKeyHandle, $handle, $key, $type);
if ($RemoteMachine) {
$RootKeyHandle = regConstant($RootKey);
if (!RegConnectRegistry ($RemoteMachine, $RootKeyHandle, $handle)) {
$$value = regLastError();
return -2;
}
} else { # not valid actually because I can't find the mapping table of default
# local handle mapping. Should always pass in the Machine name to use for now
$handle = $RootKey;
}
if (!RegOpenKeyEx ($handle, $RegPath, 0, KEY_READ, $key)) {
$$value = regLastError();
#print "regLastError = $$value\n";
return -3;
}
if (!RegQueryValueEx( $key, $KeyName, [], $type, $$value, [] )) {
$$value = regLastError();
#print "regLastError = $$value\n";
return -4;
}
#print "RegType=$type\n"; # Perl doesn't fetch type, at this in this
# ActiveState 5.6.0 that I'm using
#print "RegValue=$$value\n";
RegCloseKey ($key);
RegCloseKey ($handle);
return 0;
}
###############################################################################
#-----------------------------------------
sub GetRegSubkeyList($*) {
my ($FullKeyRegPath, $Subkeys) = @_;
#-----------------------------------------
# Purpose: uses Win32API to get registry subkey list from a given server
#
# WARNING: this procedure is VERY Win32 specific, you'll need a Win32 manual
# to figure out why something is done.
# input: $FullKeyRegPath: a MS specific way of fully qualifying a registry path
# \\Server\RootKey\Path\KeyName
# output: *Subkeys: the list of subkeys in array of the registry key of
# $FullKeyRegPath
#
my ($RemoteMachine, $RootKey, $RegPath, $KeyName, $i);
#print "in sub:GetRegSubkeyList:Parameters:", @_, "\n";
# Check the for valid registry key path
return -1 if (! ($FullKeyRegPath =~ /\\.+\\.+/)) && (!($FullKeyRegPath =~ /\\\\.+\\.+\\.+/));
$RemoteMachine = (index($FullKeyRegPath, "\\\\") == $[ ? substr($FullKeyRegPath, $[+2, index($FullKeyRegPath, "\\", $[+2)-2):0);
#print "RemoteMachine = $RemoteMachine\n";
$i = $RemoteMachine ? $[+3+length($RemoteMachine) : $[+1;
$RootKey = substr ($FullKeyRegPath, $i, index($FullKeyRegPath, "\\", $i)-$i);
$i = index($FullKeyRegPath, $RootKey, $[+length($RemoteMachine)) + $[ + length($RootKey)+1;
$RegPath = substr ($FullKeyRegPath, $i);
#print "RegPath = $RegPath\n";
my ($RootKeyHandle, $handle, $key, $type);
if ($RemoteMachine) {
$RootKeyHandle = regConstant($RootKey);
if (!RegConnectRegistry ($RemoteMachine, $RootKeyHandle, $handle)) {
@$Subkeys[0]= regLastError();
return -2;
}
} else { # not valid actually because I can't find the mapping table of default
# local handle mapping. Should always pass in the Machine name to use for now
$handle = $RootKey;
}
if (!RegOpenKeyEx ($handle, $RegPath, 0, KEY_READ, $key)) {
@$Subkeys[0] = regLastError();
#print "regLastError = @$Subkeys[0]\n";
return -3;
}
my $tmp;
# For some reason, the regLastError() stays at ERROR_NO_MORE_ITEMS
# in occasional call sequence, so I'm resetting the error code
# before entering the loop
regLastError(0);
for ($i=0; regLastError()==regConstant("ERROR_NO_MORE_ITEMS"); $i++) {
#print "\nERROR: error enumumerating reg\n";
if (RegEnumKeyEx ($key, $i, $tmp, [], [], [], [], [])) {
@$Subkeys[$i] = $tmp;
}
}
#print "RegType=$type\n";
#print "RegValue=@$Subkeys\n";
RegCloseKey ($key);
RegCloseKey ($handle);
return 0;
}
#####################################################
sub ExtractOptionIps ($) {
my ($MSDHCPOption6Value) = @_;
my @ip;
# purpose: DHCP registry specific; to return the extracted IP addresses from
# the input variable
# input:
# $MSDHCPOption6Value: Option 6 was used to develop, but it works for any
# other options of the same datatype.
# output: none
# return:
# @ip: an arry of IP addresses in human readable format.
# First extract the size of the option
my ($byte, $size, $ind1, $ind2, @octet) = unpack("VVVV", $MSDHCPOption6Value);
# print "byte = $byte\nsize=$size\nind1=$ind1\nind2=$ind2\n";
# Calculate total number of bytes that IP addresses occupy
my $number = $size * $ind1;
($byte, $size, $ind1, $ind2, @octet) = unpack("VVVVC$number", $MSDHCPOption6Value);
for (my $i=0; $i<$#octet; $i=$i+4) {
$ip[$i/4] = "$octet[$i+3]\.$octet[$i+2]\.$octet[$i+1]\.$octet[$i]";
}
return @ip;
}
#####################################################
sub ExtractOptionStrings ($) {
my ($MSDHCPOption15Value) = @_;
my @string;
# purpose: DHCP registry specific; to return the extracted string from
# the input variable
# input:
# $MSDHCPOption15Value: Option 15 was used to develop, but it works for any
# other options of the same datatype.
# output: none
# return:
# @string: an arry of strings in human readable format.
# First extract the size of the option
my ($byte, $start, $ind1, $ind2, $size, @data) = unpack("VVVVV", $MSDHCPOption15Value);
# print "byte = $byte\nstart=$start\nind1=$ind1\nind2=$ind2\nsize=$size\n";
# Calculate total number of bytes that IP addresses occupy
my $number = $size * $ind1;
($byte, $start, $ind1, $ind2, $size, @data) = unpack("VVVVVC$number", $MSDHCPOption15Value);
for (my $i=0; $i<$ind1; $i++) {
# actually this is only programmed to do one string, until I see
# example of how the multiple strings are represented, I don't have a
# guess to how to program them properly.
for (my $j=0; $j<$#data & $data[$j]!=0; $j+=2) {
$string[$i] = $string[$i].chr($data[$j]);
}
}
return @string;
}
#####################################################
sub ExtractOptionHex ($) {
my ($MSDHCPOption46Value) = @_;
my @Hex;
# purpose: DHCP registry specific; to return the extracted hex from the input
# variable
# input:
# $MSDHCPOption46Value: Option 46 was used to develop, but it works for any
# other options of the same datatype.
# output: none
# return:
# @Hex: an arry of hex strings in human readable format.
my $Temp;
# First extract the size of the option
my ($byte, $unknown, $ind1, $ind2, @data) = unpack("VVVV", $MSDHCPOption46Value);
# print "byte=$byte\nunknown=$unknown\nind1=$ind1\nind2=$ind2\n";
# Calculate total number of bytes that IP addresses occupy
my $number = $byte - 15;
($byte, $unknown, $ind1, $ind2, @data) = unpack("VVVVC$number", $MSDHCPOption46Value);
# printf "data=%4x\n", $data[0];
for (my $i=0; $i<$ind1; $i++) {
# actually this is only programmed to do one Hex, until I see
# example of how the multiple Hexes are represented, I don't have a
# guess to how to program them properly.
for (my $j=3; $j>=0; $j--) {
$Hex[$i] = $Hex[$i].sprintf ("%x", $data[$j+$i*4]);
}
}
return @Hex;
}
#####################################################
sub ExtractExclusionRanges ($) {
my ($MSDHCPExclusionRanges) = @_;
my @RangeList;
# purpose: DHCP registry specific; to return the extracted exclusion ranges
# from the input variable
# input:
# $MSDHCPExclusionRanges: Exclusion range as DHCP server returns them
# output: none
# return:
# @RangeList: an arry of paird IP addresses strings in human readable format.
# First extract the size of the option
my ($paircount, @data) = unpack("V", $MSDHCPExclusionRanges);
# print "paircount = $paircount\n";
# Calculate total number of bytes that IP addresses occupy
# my $number = $paircount * 4*2;
# ($paircount, @data) = unpack("VC$number", $MSDHCPExclusionRanges);
#
# for (my $i=0; $i<$#data; $i=$i+4) {
# $ip[$i/4] = "$data[$i+3]\.$data[$i+2]\.$data[$i+1]\.$data[$i]";
# }
#
my $number = $paircount * 2;
($paircount, @data) = unpack("VL$number", $MSDHCPExclusionRanges);
for (my $i=0; $i<=$#data; $i++) {
$RangeList[$i] = pack ("L", $data[$i]);
# print "extracted", ExtractIp ($RangeList[$i]), "\n";
}
return @RangeList;
}
#####################################################
sub ExtractIp ($) {
my ($octet) = @_;
# purpose: to return the registry saved IP address in a readable form
# input:
# $octet: a 4 byte data storing the IP address as the registry save it as
# output: none
# return: anonymous variable of a string of IP address
my (@data) = unpack ("C4", $octet);
return "$data[3]\.$data[2]\.$data[1]\.$data[0]";
}
#####################################################
sub ExtractHex ($) {
my ($HexVal) = @_;
my @Hex;
# purpose: to return the registry saved hex number in a readable form
# input:
# $octet: a 4 byte data storing the hex number as the registry save it as
# output: none
# return:
# $Hex: string of hex digit
# First extract the size of the option
my (@data) = unpack("C4", $HexVal);
for (my $i=3; $i>=0; $i--) {
$Hex[0] = $Hex[0] . sprintf ("%x", $data[$i]);
}
return @Hex;
}
1;

View File

@@ -0,0 +1,634 @@
#set ts=3
#
# ms2isc.pl
# MS NT4 DHCP to ISC DHCP Configuration Migration Tool
#
# Author: Shu-Min Chang
#
# Copyright(c) 2003 Intel Corporation. All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution
# 3. Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE INTEL CORPORATION AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL CORPORATION OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVICED OF THE POSSIBILITY OF SUCH
# DAMAGE.
use strict;
use Socket;
use Getopt::Std;
use Filehandle;
use Registry; # Custom Perl Module to make Registry access easier.
my $usage = << 'ENDOFHELP';
Purpose: A Perl Script converting MS NT4 DHCP configuration to ISC DHCP3
configuration file by reading NT4's registry.
Requires: Registry.pm and ActiveState 5.6.0
Usage: $ARGV -s <Srv> -o <Out> [-p <Pri> [-k <key>]] [-f <Fo>]
<Srv> Server IP or name for NT4 DHCP server to fetch the configuration from.
<Out> Output filename for the configuration file.
<Pri> Primary DNS server name for sending the dynamic DNS update to.
<Key> Key name for use in updating the dynamic DNS zone.
<Fo> Failover peer name shared with the DHCP partner.
Essentially the <Srv> needs to be an NT4 (3.x should work but not tested) which
you should have registry read access to. You must run this script from a
Windows machine because of the requirement to access the registry.
The <Pri> is optional parameter for desginating the dynamic DNS update if
missing then the "zone" section of the declaration will be skipped. The <Key>
is needed if you've configured your DNS zone with a key, in addition, you'll
need to define that key in this DHCP configuration file elsewhere manually,
read the DHCP Handbook to figure out what you need to define.
The <Fo> specifies the fail-over peer name in the pool section, you'll need to
define additional detail elsewhere manually, again read the DHCP handbook.
NOTE: the program only knows of the following global and subnet options:
3, 6, 15, 28, 44, and 46
If it runs into options other than the known ones, it will quit. You
may fix this by modifying the following procedures:
GetGlobalOptions
GetScopes
PrintSubnetConfig
In addition, the resulting subnets configuration will have the "deny
dynamic bootp clients" you should take them out if that's not what you
want :).
Finally, as the parameter structures implied, it is assumed that you
want the same zone primary and update key for all zones and that the
same failover is to be applied to all the pools. Furthermore the
subnet zones are all assumed to be class C delineated, but if you
happend to be delegated at the class B level, this will work fine too.
Author: Shu-Min Chang <smchang@yahoo.com>
Copyright: Please read the top of the source code
Acknowledgement:
Brian L. King for coding help, Douglas A. Darrah for testing, and James E.
Pressley for being the DHCP reference book :).
Usage: $ARGV -s <Srv> -o <Out> [-p <Pri> [-k <key>]] [-f <Fo>]
Version: 1.0.1
ENDOFHELP
###################### Begin Main Program ####################################
my (%opts, %GlobalOptions, %SuperScopes, %Scopes);
### Get parameters and make sure that they meet the require/optoinal criteria
getopts('s:o:p:k:f:', \%opts) or die $usage;
($opts{s} and $opts{o}) or die $usage;
if ($opts{k}) { $opts{p} or die $usage; }
### Read all the registry stuff into the memory
%GlobalOptions = GetGlobalOptions($opts{s});
%SuperScopes = GetSuperScope($opts{s});
%Scopes = GetScopes ($opts{s});
### Process and print out to the output file
my ($outfile, $i, $j, @Domains);
$outfile = new FileHandle "> $opts{o}";
if (!defined $outfile) {
die "Can't open file: $opts{o}: $!";
}
for $i (keys %SuperScopes) {
print $outfile "\n##############################################################\n";
my ($Scopename) = $i;
$Scopename =~ s/ //g;
print $outfile "shared-network $Scopename {\n";
foreach $j (@{$SuperScopes{$i}}) {
PrintSubnetConfig($outfile, \%GlobalOptions, \%{$Scopes{$j}}, $j, "\t", $opts{f});
InsertIfUnique (\@Domains, $Scopes{$j}{domain}) if exists $Scopes{$j}{domain};
delete $Scopes{$j};
}
print $outfile "}\n";
if ($opts{p} or $opts{k}) {
foreach $j (@{$SuperScopes{$i}}) {
PrintSubnetUpdate($outfile, $j, $opts{p}, $opts{k});
}
}
}
for $i (keys %Scopes) {
print $outfile "\n##############################################################\n";
PrintSubnetConfig($outfile, \%GlobalOptions, \%{$Scopes{$i}}, $i, "", $opts{f});
if ($opts{p} or $opts{k}) { PrintSubnetUpdate($outfile, $i, $opts{p}, $opts{k}); }
InsertIfUnique (\@Domains, $Scopes{$i}{domain}) if exists $Scopes{$i}{domain};
}
if ($opts{p} or $opts{k}) {
InsertIfUnique (\@Domains, $GlobalOptions{domain}) if exists $GlobalOptions{domain};
for $i (@Domains) {
PrintDomainUpdate($outfile, $i, $opts{p}, $opts{k});
}
}
undef ($outfile);
print "Done.\n";
exit();
################################## End Main Program ###########################
######################################################################
sub InsertIfUnique ($$) {
my ($Array, $data) = @_;
# purpose: insert $data into array @{$Array} iff the data is not in there yet
# input:
# $data: scalar data to be added to the @{$Array} if unique
# $Array: reference of the Array to compare the uniqueness of the $data
# output:
# $Array: reference of the array with the resulting array.
# return: none
my ($i);
for ($i=0; $i<=$#{$Array} && ${$Array}[$i] ne $data; $i++) { }
if ($i > $#{$Array}) {
${$Array}[$i] = $data;
}
}
######################################################################
sub PrintDomainUpdate ($$$$) {
my ($outfile, $Domain, $DDNSServer, $key) = @_;
# purpose: print out the foward domain zone update declaration
# input:
# $outfile: filehandle of the file to write the output to
# $Domain: a string representing the forward domain
# $DDNSServer: a string of the DNS server accepting the DDNS update
# $key: a string representing the key used to update the zone
# output: none
# return: none
#
print $outfile "zone $Domain {\n";
print $outfile "\tprimary $DDNSServer;\n";
!$key or print $outfile "\tkey $key;\n";
print $outfile "}\n";
}
######################################################################
sub PrintSubnetUpdate ($$$$) {
my ($outfile, $Subnet, $DDNSServer, $key) = @_;
# purpose: print out the reverse domain zone update declaration
# input:
# $outfile: filehandle of the file to write the output to
# $Subnet: a string representing the subnet in the form 1.2.3.4
# $DDNSServer: a string of the DNS server accepting the DDNS update
# $key: a string representing the key used to update the zone
# output: none
# return: none
#
my ($Reverse);
$_ = join (".", reverse(split(/\./, $Subnet)));
m/\d*\.(.*)/;
$Reverse = $1;
print $outfile "zone $Reverse.in-addr.arpa. {\n";
print $outfile "\tprimary $DDNSServer;\n";
!$key or print $outfile "\tkey $key;\n";
print $outfile "}\n";
}
######################################################################
sub PrintSubnetConfig ($$$$$$) {
my ($outfile, $GlobalOptions, $Scope, $Subnet, $prefix, $failover) = @_;
# purpose: print out the effective scope configuration for one subnet as
# derived from the global and scope options.
# input:
# $outfile: filehandle of the file to write the output to
# $GlobalOptions: refernce to the hashed variable from GetGlobalOptions
# $Scopes: reference to the hashed variable of the subnet in interest
# $Subnet: string variable of the subnet being processed
# $prefix: string to be printed before each line (designed for tab)
# $failover: string to be used for the "failover peer" line
# output: none
# return: none
#
my ($pound) = ( ${$Scope}{disable}? "#".$prefix : $prefix);
print $outfile $pound, "subnet $Subnet netmask ${$Scope}{mask} {\n";
print $outfile "$prefix# Name: ${$Scope}{name}\n";
print $outfile "$prefix# Comment: ${$Scope}{comment}\n";
if (exists ${$Scope}{routers}) {
print $outfile $pound, "\toption routers @{${$Scope}{routers}};\n";
} elsif (exists ${$GlobalOptions}{routers}) {
print $outfile $pound, "\toption routers @{${$GlobalOptions}{routers}};\t# NOTE: obtained from global option, bad practice detected\n";
} else {
print $outfile "### WARNING: No router was found for this subnet!!! ##########\n";
}
if (exists ${$Scope}{dnses}) {
print $outfile $pound, "\toption domain-name-servers ", join(",", @{${$Scope}{dnses}}), ";\n";
} elsif (exists ${$GlobalOptions}{dnses}) {
print $outfile $pound, "\toption domain-name-servers ", join(",", @{${$GlobalOptions}{dnses}}), ";\n";
}
if (exists ${$Scope}{domain}) {
print $outfile $pound, "\toption domain-name \"${$Scope}{domain}\";\n";
} elsif (exists ${$GlobalOptions}{domain}) {
print $outfile $pound, "\toption domain-name \"${$GlobalOptions}{domain}\";\n";
}
if (exists ${$Scope}{broadcast}) {
print $outfile $pound, "\toption broadcast-address ${$Scope}{broadcast};\n";
} elsif (exists ${$GlobalOptions}{broadcast}) {
print $outfile $pound, "\toption broadcast-address ${$GlobalOptions}{broadcast};\n";
}
if (exists ${$Scope}{winses}) {
print $outfile $pound, "\toption netbios-name-servers ", join(",", @{${$Scope}{winses}}), ";\n";
} elsif (exists ${$GlobalOptions}{winses}) {
print $outfile $pound, "\toption netbios-name-servers ", join(",", @{${$GlobalOptions}{winses}}), ";\n";
}
if (exists ${$Scope}{winstype}) {
print $outfile $pound, "\toption netbios-node-type ${$Scope}{winstype};\n";
} elsif (exists ${$GlobalOptions}{winstype}) {
print $outfile $pound, "\toption netbios-node-type ${$GlobalOptions}{winstype};\n"
}
print $outfile $pound, "\tdefault-lease-time ${$Scope}{leaseduration};\n";
print $outfile $pound, "\tpool {\n";
for (my $r=0; $r<=$#{${$Scope}{ranges}}; $r+=2) {
print $outfile $pound, "\t\trange ${$Scope}{ranges}[$r] ${$Scope}{ranges}[$r+1];\n";
}
!$failover or print $outfile $pound, "\t\tfailover peer \"$failover\";\n";
print $outfile $pound, "\t\tdeny dynamic bootp clients;\n";
print $outfile $pound, "\t}\n";
print $outfile $pound, "}\n";
}
######################################################################
sub GetScopes ($) {
my ($Server) = @_;
my (%Scopes);
# purpose: to return NT4 server's scope configuration
# input:
# $Server: string of the valid IP or name of the NT4 server
# output: none
# return:
# %Scope: hash of hash of hash of various data types to be returned of the
# following data structure
# $Scope{<subnet>}{disable} => boolean
# $Scope{<subnet>}{mask} => string (e.g. "1.2.3.255")
# $Scope{<subnet>}{name} => string (e.g "Office Subnet #1")
# $Scope{<subnet>}{comment} => string (e.g. "This is a funny subnet")
# $Scope{<subnet>}{ranges} => array of paired inclusion IP addresses
# (e.g. "1.2.3.1 1.2.3.10 1.2.3.100 10.2.3.200
# says that we have 2 inclusion ranges of
# 1-10 and 100-200)
# $Scopes{<subnet>}{routers} => array of IP address strings
# $Scopes{<subnet>}{dnses} => array of IP address/name string
# $Scopes{<subnet>}{domain} > string
# $Scopes{<subnet>}{broadcast} => string
# $Scopes{<subnet>}{winses} => array of IP addresses/name string
# $Scopes{<subnet>}{winstype} => integer
# $Scopes{<subnet>}{leaseduration} => integer
my ($RegVal, @Subnets, @Router, $SubnetName, $SubnetComment, @SubnetOptions, @SRouter, @SDNSServers, @SDomainname, @SWINSservers, @SNetBIOS, @SLeaseDuration, @SSubnetState, @SExclusionRanges, @SSubnetAddress, @SSubnetMask, @SFirstAddress, $SStartAddress, $SEndAddress, @InclusionRanges, @SBroadcastAddress);
print "Getting list of subnets\n";
if (Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets", \@Subnets)) {
die "Unable to obtain a list of subnets from the server!\n";
}
for (my $i=0; $i<=$#Subnets; $i++) {
print "\t Fetching Subnet $Subnets[$i] (",$i+1, "/", $#Subnets+1, "): ";
print ".";
if (!Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\IpRanges", \@SFirstAddress)) {
# Don't know why MS has a tree for this, but as far
# as I can tell, only one subtree will ever come out of
# this, so I'm skipping the 'for' loop
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\IpRanges\\$SFirstAddress[0]\\StartAddress", \$RegVal)) {
$SStartAddress = $RegVal;
}
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\IpRanges\\$SFirstAddress[0]\\EndAddress", \$RegVal)) {
$SEndAddress = $RegVal;
}
# print "\n\tInclusion Range: ", Registry::ExtractIp($SStartAddress), " - ", Registry::ExtractIp($SEndAddress),"\n";
} else {
die "\n\n# Error Getting Inclusion Range FirstAddress!!!\n\n";
}
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\ExcludedIpRanges", \$RegVal)) {
@SExclusionRanges = Registry::ExtractExclusionRanges($RegVal);
# for (my $j=2; $j<=$#SExclusionRanges; $j+=2) {
# if (unpack("L",$SExclusionRanges[$j]) < unpack("L",$SExclusionRanges[$j-2])) {
# print ("\n******** Subnet exclusion ranges out of order ********\n");
# }
# }
@SExclusionRanges = sort(@SExclusionRanges);
# print "\n\tExclusion Ranges: ";
# for (my $j=0; $j<=$#SExclusionRanges; $j+=2) {
# print "\n\t\t",Registry::ExtractIp($SExclusionRanges[$j])," - ",Registry::ExtractIp($SExclusionRanges[$j+1]);
# }
}
@InclusionRanges = FindInclusionRanges ($SStartAddress, $SEndAddress, @SExclusionRanges);
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetName", \$RegVal)) {
$SubnetName = $RegVal;
# print "\n\tSubnetName: $SubnetName";
}
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetComment", \$RegVal)) {
$SubnetComment = $RegVal;
# print "\n\tSubnetComment: $SubnetComment";
}
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetAddress", \$RegVal)) {
@SSubnetAddress = Registry::ExtractIp($RegVal);
# print "\n\tSubnetAddress: $SSubnetAddress[0]";
}
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetMask", \$RegVal)) {
@SSubnetMask = Registry::ExtractIp($RegVal);
# print "\n\tSubnetMask: $SSubnetMask[0]";
}
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetState", \$RegVal)) {
@SSubnetState = Registry::ExtractHex ($RegVal);
# print "\n\tSubnetState = $SSubnetState[0]";
}
$Scopes{$Subnets[$i]}{disable} = hex($SSubnetState[0]) ? 1 : 0;
$Scopes{$Subnets[$i]}{mask} = $SSubnetMask[0];
$Scopes{$Subnets[$i]}{name} = $SubnetName;
$Scopes{$Subnets[$i]}{comment} = $SubnetComment;
for (my $r=0; $r<=$#InclusionRanges; $r++) {
$Scopes{$Subnets[$i]}{ranges}[$r] = Registry::ExtractIp($InclusionRanges[$r]);
}
################## Get scope options
my (@SubnetOptionsList);
print "\n\t\tOptions:";
if (Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetOptions", \@SubnetOptionsList)) {
die "Unable to get subnet options list for $Subnets[$i]!\n";
}
for (my $j=0; $j<=$#SubnetOptionsList; $j++) {
print ".";
if (!Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\Subnets\\$Subnets[$i]\\SubnetOptions\\$SubnetOptionsList[$j]\\OptionValue", \$RegVal)) {
for ($SubnetOptionsList[$j]) {
/003/ and do {
# @SRouter = Registry::ExtractOptionIps($RegVal);
$Scopes{$Subnets[$i]}{routers} = [Registry::ExtractOptionIps($RegVal)];
last;
};
/006/ and do {
@SDNSServers = Registry::ExtractOptionIps($RegVal);
for (my $d=0; $d<=$#SDNSServers; $d++) {
my ($ipname, $rest) = gethostbyaddr(pack("C4", split(/\./, $SDNSServers[$d])), &AF_INET);
$Scopes{$Subnets[$i]}{dnses}[$d] = $ipname ? $ipname : $SDNSServers[$d];
}
last;
};
/015/ and do {
@SDomainname = Registry::ExtractOptionStrings($RegVal);
$Scopes{$Subnets[$i]}{domain} = $SDomainname[0];
last;
};
/028/ and do {
@SBroadcastAddress = Registry::ExtractOptionIps($RegVal);
$Scopes{$Subnets[$i]}{broadcast} = $SBroadcastAddress[0];
last;
};
/044/ and do {
@SWINSservers = Registry::ExtractOptionIps($RegVal);
for (my $w=0; $w<=$#SWINSservers; $w++) {
my ($ipname, $rest) = gethostbyaddr(pack("C4", split(/\./, $SWINSservers[$w])), &AF_INET);
$Scopes{$Subnets[$i]}{winses}[$w] = $ipname ? $ipname : $SWINSservers[$w];
}
last;
};
/046/ and do {
@SNetBIOS = Registry::ExtractOptionHex($RegVal);
$Scopes{$Subnets[$i]}{winstype} = hex($SNetBIOS[0]);
last;
};
/051/ and do {
@SLeaseDuration = Registry::ExtractOptionHex($RegVal);
$Scopes{$Subnets[$i]}{leaseduration} = hex($SLeaseDuration[0]);
last;
};
die "This program does not recognize subnet option \#$SubnetOptionsList[$j] yet!\n"
}
} else {
die "Unable to obtain option SubnetOptionsList[$j] from $Subnets[$i], most likely a registry problem!\n"
}
}
print "\n";
}
return %Scopes;
}
######################################################################
sub FindInclusionRanges ($$@) {
my ($StartAddress, $EndAddress, @ExclusionRanges) = @_;
# Purpose: to calculate and return the DHCP inclusion ranges out of
# data provided by the NT4 DHCP server
# input: $StartAddress:
# $EndAddress:
# @ExclusionRanges
# output: none
# return: An arry of IP address pair representing the inclusion ranges
# in the native registry format.
#
my ($SA, $EA, @ER);
$SA = unpack("L", $StartAddress);
$EA = unpack("L", $EndAddress);
@ER = @ExclusionRanges;
for (my $i=0; $i<=$#ER; $i++) {
$ER[$i] = unpack ("L", $ER[$i]);
}
my @InclusionRanges;
$InclusionRanges[0] = $SA;
$InclusionRanges[1] = $EA;
for (my $i=0; $i<=$#ER; $i+=2) {
if ($ER[$i] == $InclusionRanges[$#InclusionRanges-1]) {
$InclusionRanges[$#InclusionRanges-1] = $ER[$i+1] + 1;
}
if ($ER[$i] > $InclusionRanges[$#InclusionRanges-1]) {
$InclusionRanges[$#InclusionRanges] = $ER[$i]-1;
}
if (($ER[$i+1] > $InclusionRanges[$#InclusionRanges]) &&
($ER[$i+1] != $EA)) {
$InclusionRanges[$#InclusionRanges+1] = $ER[$i+1] + 1;
$InclusionRanges[$#InclusionRanges+1] = $EA;
}
if ($InclusionRanges[$#InclusionRanges] < $InclusionRanges[$#InclusionRanges-1]) {
$#InclusionRanges -= 2;
}
}
for (my $i=0; $i<=$#InclusionRanges; $i++) {
$InclusionRanges[$i] = pack("L", $InclusionRanges[$i]);
# print "Inclusion: ", Registry::ExtractIp($InclusionRanges[$i]), "\n";
}
return @InclusionRanges;
}
####################################################################
sub GetSuperScope ($) {
my ($Server) = @_;
my (%SuperScopes);
#
# purpose: gets the Superscope list from the given server
# input:
# $Server: string of the valid IP address or name of the NT4 server
# ouput: none
# return:
# %SuperScopes: hash of array subnets with the following data structure
# $SuperScopes{<SuperscopeName>} => array of sunbets
#
my (@SuperScopeNames, @SCSubnetList);
print "Getting Superscope list: ";
if (!Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\SuperScope", \@SuperScopeNames)) {
for (my $i=0; $i<=$#SuperScopeNames; $i++) {
print ".";
if (!Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\SuperScope\\$SuperScopeNames[$i]", \@SCSubnetList)) {
$SuperScopes{$SuperScopeNames[$i]} = [@SCSubnetList];
}
}
print "\n";
}
return %SuperScopes;
}
####################################################################
sub GetGlobalOptions($) {
my ($Server) = @_;
my (%GlobalOptions);
# purpose: to return NT4 server's global scope configuration
# input:
# $Server: string of the valid IP or name of the NT4 server
# output: none
# return:
# %GlobalOptions: hash of hash of various data types to be returned of the
# following data structure
# $GlobalOptions{routers} => array of IP address strings
# $GlobalOptions{dnses} => array of IP address/name string
# $GlobalOptions{domain} > string
# $GlobalOptions{broadcast} => string
# $GlobalOptions{winses} => array of IP addresses/name string
# $GlobalOptions{winstype} => integer
my ($RegVal, @temp, @GlobalOptionValues);
print "Getting Global Options: ";
if (Registry::GetRegSubkeyList ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\Configuration\\GlobalOptionValues", \@GlobalOptionValues)) {
die "Unable to obtain GlobalOptionValues";
}
for (my $i=0; $i<=$#GlobalOptionValues; $i++) {
print ".";
if (Registry::GetRegKeyVal ("\\\\$Server\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\DHCPServer\\configuration\\globaloptionvalues\\$GlobalOptionValues[$i]\\optionvalue", \$RegVal)) {
die "Unable to retrive global option $GlobalOptionValues[$i]\n";
}
for ($GlobalOptionValues[$i]) {
/003/ and do {
@temp=Registry::ExtractOptionIps($RegVal);
$GlobalOptions{routers} = [@temp];
last;
};
/006/ and do {
# DNS Servers
@temp = Registry::ExtractOptionIps($RegVal);
for (my $d=0; $d<=$#temp; $d++) {
my ($ipname, $rest) = gethostbyaddr(pack("C4", split(/\./, $temp[$d])), &AF_INET);
$GlobalOptions{dnses}[$d] = $ipname ? $ipname : $temp[$d];
}
last;
};
/015/ and do {
# Domain Name
@temp = Registry::ExtractOptionStrings($RegVal);
$GlobalOptions{domain} = $temp[0];
last;
};
/028/ and do {
# broadcast address
@temp = Registry::ExtractOptionIps($RegVal);
$GlobalOptions{broadcast} = $temp[0];
last;
};
/044/ and do {
# WINS Servers
@temp = Registry::ExtractOptionIps ($RegVal);
$GlobalOptions{winses} = [@temp];
for (my $w=0; $w<=$#temp; $w++) {
my ($ipname, $rest) = gethostbyaddr(pack("C4", split(/\./, $temp[$w])), &AF_INET);
$GlobalOptions{winses}[$w] = $ipname ? $ipname : $temp[$w];
}
last;
};
/046/ and do {
# NETBIOS node type
@temp = Registry::ExtractOptionHex($RegVal);
$GlobalOptions{winstype} = hex($temp[0]);
last;
};
die "This program does not recgonize global option \#$GlobalOptionValues[$i] yet!\n"
}
}
print "\n";
return %GlobalOptions;
}

View File

@@ -0,0 +1,15 @@
Copyright: please read the top of the source code.
Usage:
Objective: please read the help screen by executing the program without any
parameter.
Revision:
SMC: Shu-Min Chang
Who When What
--- ------ --------------------------------------------------------------------
SMC 021107 Initial release Version 1.0 to ISC DHCP repository
SMC 030129 Fixed inclusion range calculation by sorting exclusion before
passing to FindInclusionRanges
SMC 030228 release 1.0.1 to ISC DHCP repository

View File

@@ -0,0 +1,29 @@
#!/bin/sh
# This script can be installed in /etc/dhclient-enter-hooks to set the client's
# hostname based either on the hostname that the DHCP server supplied or the
# hostname in whatever ptr record exists for the assigned IP address.
if [ x$new_host_name = x ]; then
ptrname=`echo $new_ip_address \
|sed -e \
's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1.in-addr.arpa/'`
(echo "set type=ptr"; echo "$ptrname") |nslookup >/tmp/nslookup.$$
set `sed -n -e "s/$ptrname[ ]*\(canonical \)*name *= *\(.*\)/\2 \1/p" \
< /tmp/nslookup.$$` _
if [ x$1 = x_ ]; then
new_host_name=""
else
if [ $# -gt 1 ] && [ x$2 = xcanonical ]; then
new_host_name=`sed -n -e "s/$1[ ]*name *= *\(.*\)/\1/p" \
</tmp/nslookup.$$`
else
new_host_name=$1
fi
fi
rm /tmp/nslookup.$$
fi
if [ x$new_host_name != x ]; then
hostname $new_host_name
fi

Some files were not shown because too many files have changed in this diff Show More