From 984693e047aa813bc92f133c2faeb509fd8ee11c Mon Sep 17 00:00:00 2001 From: mellon Date: Wed, 24 Feb 1999 04:11:01 +0000 Subject: [PATCH] V2 Beta 1 Patchlevel 15 --- usr.sbin/dhcp/client/scripts/solaris | 53 +++++++++++----------- usr.sbin/dhcp/common/bpf.c | 18 +++++--- usr.sbin/dhcp/common/dispatch.c | 16 ++++--- usr.sbin/dhcp/common/dlpi.c | 43 +++++++++--------- usr.sbin/dhcp/common/lpf.c | 20 ++++++--- usr.sbin/dhcp/common/nit.c | 20 ++++++--- usr.sbin/dhcp/common/raw.c | 15 ++++--- usr.sbin/dhcp/common/socket.c | 19 +++++--- usr.sbin/dhcp/common/upf.c | 22 ++++++---- usr.sbin/dhcp/includes/cf/linux.h | 24 +++++++--- usr.sbin/dhcp/includes/cf/sunos5-5.h | 15 +------ usr.sbin/dhcp/relay/dhcrelay.c | 26 +++++------ usr.sbin/dhcp/server/dhcpd.conf | 66 ++++++---------------------- 13 files changed, 180 insertions(+), 177 deletions(-) diff --git a/usr.sbin/dhcp/client/scripts/solaris b/usr.sbin/dhcp/client/scripts/solaris index 3945d4e7e9bd..52a1885c7ccb 100644 --- a/usr.sbin/dhcp/client/scripts/solaris +++ b/usr.sbin/dhcp/client/scripts/solaris @@ -16,31 +16,32 @@ if [ x$alias_subnet_mask != x ]; then alias_subnet_arg="netmask $alias_subnet_mask" fi -# For Solaris, ifconfig lives in /sbin -OS=`uname -r` -if [ $OS = "5.5.1" ]; then - PATH=/sbin:$PATH -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 - ifconfig $interface $medium - ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1 - ifconfig $interface + $ifconfig $interface $medium + $ifconfig $interface sleep 1 exit 0 fi if [ x$reason = xPREINIT ]; then if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 + $ifconfig ${interface}:1 0 down > /dev/null 2>&1 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 fi - if [ $OS = "5.5.1" ]; then + if [ $relmajor -gt 5 ] || ( [ $relmajor -eq 5 ] && [ $relminor -ge 5 ] ) + then # Turn the interface on - ifconfig $interface plumb - ifconfig $interface inet 10.0.0.1 up + $ifconfig $interface plumb + $ifconfig $interface up else - ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ + $ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ broadcast 255.255.255.255 up fi exit 0 @@ -54,11 +55,11 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then 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 + $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 -alias $old_ip_address $medium + $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 @@ -67,7 +68,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ 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_netmask_arg \ + $ifconfig $interface inet $new_ip_address $new_netmask_arg \ $new_broadcast_arg $medium route add $new_ip_address 127.1 1 >/dev/null 2>&1 for router in $new_routers; do @@ -76,7 +77,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ 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 + $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg route add $alias_ip_address 127.0.0.1 1 fi echo search $new_domain_name >/etc/resolv.conf @@ -88,20 +89,20 @@ fi if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 + $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 -alias $old_ip_address $medium + $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 - arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p'i \ + 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 + $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg route add $alias_ip_address 127.0.0.1 1 fi exit 0 @@ -109,17 +110,17 @@ fi if [ x$reason = xTIMEOUT ]; then if [ x$alias_ip_address != x ]; then - ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1 + $ifconfig ${interface}:1 0 down > /dev/null 2>&1 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1 fi - ifconfig $interface inet $new_ip_address $new_netmask_arg \ + $ifconfig $interface inet $new_ip_address $new_netmask_arg \ $new_broadcast_arg $medium sleep 1 set $new_routers - if ping -c 1 -w 1 $1; then + 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 inet alias $alias_ip_address $alias_subnet_arg + $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 @@ -136,7 +137,7 @@ if [ x$reason = xTIMEOUT ]; then fi exit 0 fi - ifconfig $interface inet -alias $new_ip_address $medium + $ifconfig $interface inet 0 down for router in $old_routers; do route delete default $router >/dev/null 2>&1 done diff --git a/usr.sbin/dhcp/common/bpf.c b/usr.sbin/dhcp/common/bpf.c index 694faef9b759..7680c8b024e3 100644 --- a/usr.sbin/dhcp/common/bpf.c +++ b/usr.sbin/dhcp/common/bpf.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: bpf.c,v 1.1.1.4 1999/02/18 21:48:49 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bpf.c,v 1.1.1.5 1999/02/24 04:11:01 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -142,13 +142,14 @@ void if_register_send (info) info -> wfdesc = info -> rfdesc; #endif if (!quiet_interface_discovery) - note ("Sending on BPF/%s/%s/%s", + note ("Sending on BPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_BPF_SEND */ @@ -250,13 +251,14 @@ void if_register_receive (info) if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0) error ("Can't install packet filter program: %m"); if (!quiet_interface_discovery) - note ("Listening on BPF/%s/%s/%s", + note ("Listening on BPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_BPF_RECEIVE */ @@ -273,6 +275,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) int bufp = 0; unsigned char buf [256]; struct iovec iov [2]; + int result; if (!strcmp (interface -> name, "fallback")) return send_fallback (interface, packet, raw, @@ -290,7 +293,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) iov [1].iov_base = (char *)raw; iov [1].iov_len = len; - return writev(interface -> wfdesc, iov, 2); + result = writev(interface -> wfdesc, iov, 2); + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_BPF_SEND */ diff --git a/usr.sbin/dhcp/common/dispatch.c b/usr.sbin/dhcp/common/dispatch.c index 7e18af33d1f5..e16d22d49b20 100644 --- a/usr.sbin/dhcp/common/dispatch.c +++ b/usr.sbin/dhcp/common/dispatch.c @@ -3,8 +3,8 @@ Network input dispatcher... */ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. - * All rights reserved. + * Copyright (c) 1995, 1996, 1997, 1998, 1999 + * The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.1.1.8 1999/02/19 21:58:14 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.1.1.9 1999/02/24 04:11:02 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -434,9 +434,13 @@ void discover_interfaces (state) sizeof tmp -> ifp -> ifr_addr); /* We must have a subnet declaration for each interface. */ - if (!tmp -> shared_network && (state == DISCOVER_SERVER)) - error ("No subnet declaration for %s (%s).", - tmp -> name, inet_ntoa (foo.sin_addr)); + if (!tmp -> shared_network && (state == DISCOVER_SERVER)) { + warn ("No subnet declaration for %s (%s).", + tmp -> name, inet_ntoa (foo.sin_addr)); + warn ("Please write a subnet declaration for the %s", + "network segment to"); + error ("which interface %s is attached.", tmp -> name); + } /* Find subnets that don't have valid interface addresses... */ diff --git a/usr.sbin/dhcp/common/dlpi.c b/usr.sbin/dhcp/common/dlpi.c index bf75c4383864..d877db52088f 100644 --- a/usr.sbin/dhcp/common/dlpi.c +++ b/usr.sbin/dhcp/common/dlpi.c @@ -3,7 +3,7 @@ Data Link Provider Interface (DLPI) network interface code. */ /* - * Copyright (c) 1998 The Internet Software Consortium. + * Copyright (c) 1998, 1999 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -344,13 +344,14 @@ void if_register_send (info) #endif if (!quiet_interface_discovery) - note ("Sending on DLPI/%s/%s/%s", + note ("Sending on DLPI/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); #ifdef DLPI_FIRST_SEND_WAIT /* See the implementation notes at the beginning of this file */ @@ -397,7 +398,7 @@ void if_register_receive (info) 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; + pf.Pf_Filter [pf.Pf_FilterLen++] = htons (local_port); #else /* * The packets that will be received on this file descriptor @@ -415,7 +416,7 @@ void if_register_receive (info) pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_CAND; pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHWORD + 11; pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSHLIT + ENF_CAND; - pf.Pf_Filter [pf.Pf_FilterLen++] = local_port; + pf.Pf_Filter [pf.Pf_FilterLen++] = htons (local_port); #endif /* Install the filter... */ @@ -426,13 +427,14 @@ void if_register_receive (info) #endif if (!quiet_interface_discovery) - note ("Listening on DLPI/%s/%s/%s", + note ("Listening on DLPI/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); #ifdef DLPI_FIRST_SEND_WAIT /* See the implementation notes at the beginning of this file */ @@ -461,7 +463,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) unsigned char dstaddr [DLPI_MAXDLADDR]; unsigned addrlen; int saplen; - int rslt; + int result; if (!strcmp (interface -> name, "fallback")) return send_fallback (interface, packet, raw, @@ -482,7 +484,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) dbuflen += len; #ifdef USE_DLPI_RAW - rslt = write (interface -> wfdesc, dbuf, dbuflen); + result = write (interface -> wfdesc, dbuf, dbuflen); #else /* XXX: Assumes ethernet, with two byte SAP */ sap [0] = 0x08; /* ETHERTYPE_IP, high byte */ @@ -507,10 +509,12 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) addrlen = interface -> hw_address.hlen + ABS (saplen); /* Send the packet down the wire... */ - rslt = dlpiunitdatareq (interface -> wfdesc, dstaddr, addrlen, - 0, 0, dbuf, dbuflen); + result = dlpiunitdatareq (interface -> wfdesc, dstaddr, addrlen, + 0, 0, dbuf, dbuflen); #endif - return rslt; + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_DLPI_SEND */ @@ -531,7 +535,6 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) int length = 0; int offset = 0; int bufix = 0; - int rslt; #ifdef USE_DLPI_RAW length = read (interface -> rfdesc, dbuf, sizeof (dbuf)); @@ -1052,7 +1055,7 @@ static int dlpiunitdataind (fd, daddr, daddrlen, union DL_primitives *dlp; struct strbuf ctl, data; int flags = 0; - int rslt; + int result; /* Set up the msg_buf structure... */ dlp = (union DL_primitives *)buf; @@ -1066,9 +1069,9 @@ static int dlpiunitdataind (fd, daddr, daddrlen, data.len = 0; data.buf = (char *)dbuf; - rslt = getmsg (fd, &ctl, &data, &flags); + result = getmsg (fd, &ctl, &data, &flags); - if (rslt != 0) { + if (result != 0) { return -1; } @@ -1136,7 +1139,7 @@ static int strgetmsg (fd, ctlp, datap, flagsp, caller) int *flagsp; int fd; { - int rslt; + int result; #ifdef USE_POLL struct pollfd pfd; int count; @@ -1190,8 +1193,8 @@ static int strgetmsg (fd, ctlp, datap, flagsp, caller) * Set flags argument and issue getmsg (). */ *flagsp = 0; - if ((rslt = getmsg (fd, ctlp, datap, flagsp)) < 0) { - return rslt; + if ((result = getmsg (fd, ctlp, datap, flagsp)) < 0) { + return result; } #ifndef USE_POLL @@ -1207,7 +1210,7 @@ static int strgetmsg (fd, ctlp, datap, flagsp, caller) /* * Check for MOREDATA and/or MORECTL. */ - if (rslt & (MORECTL|MOREDATA)) { + if (result & (MORECTL|MOREDATA)) { return -1; } diff --git a/usr.sbin/dhcp/common/lpf.c b/usr.sbin/dhcp/common/lpf.c index 0d88b22f51dd..ed2db1cf2f14 100644 --- a/usr.sbin/dhcp/common/lpf.c +++ b/usr.sbin/dhcp/common/lpf.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: lpf.c,v 1.1.1.1 1999/02/18 21:48:50 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: lpf.c,v 1.1.1.2 1999/02/24 04:11:03 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -129,13 +129,14 @@ void if_register_send (info) info -> wfdesc = info -> rfdesc; #endif if (!quiet_interface_discovery) - note ("Sending on LPF/%s/%s/%s", + note ("Sending on LPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_LPF_SEND */ @@ -174,13 +175,14 @@ void if_register_receive (info) error ("Can't install packet filter program: %m"); } if (!quiet_interface_discovery) - note ("Listening on LPF/%s/%s/%s", + note ("Listening on LPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_LPF_RECEIVE */ @@ -197,6 +199,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) int bufp = 0; unsigned char buf [1500]; struct sockaddr sa; + int result; if (!strcmp (interface -> name, "fallback")) return send_fallback (interface, packet, raw, @@ -216,8 +219,11 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) strncpy (sa.sa_data, (const char *)interface -> ifp, sizeof sa.sa_data); - return sendto (interface -> wfdesc, buf, bufp + len, 0, - &sa, sizeof sa); + result = sendto (interface -> wfdesc, buf, bufp + len, 0, + &sa, sizeof sa); + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_LPF_SEND */ diff --git a/usr.sbin/dhcp/common/nit.c b/usr.sbin/dhcp/common/nit.c index d3dc27bb1d69..fb4972069dec 100644 --- a/usr.sbin/dhcp/common/nit.c +++ b/usr.sbin/dhcp/common/nit.c @@ -4,7 +4,7 @@ with one crucial tidbit of help from Stu Grossmen. */ /* - * Copyright (c) 1996 The Internet Software Consortium. + * Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: nit.c,v 1.1.1.4 1999/02/18 21:48:50 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: nit.c,v 1.1.1.5 1999/02/24 04:11:03 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -155,12 +155,13 @@ void if_register_send (info) info -> wfdesc = info -> rfdesc; #endif if (!quiet_interface_discovery) - note ("Sending on NIT/%s/%s", + note ("Sending on NIT/%s%s%s", print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_NIT_SEND */ @@ -238,12 +239,13 @@ void if_register_receive (info) error ("Can't set NIT filter on %s: %m", info -> name); if (!quiet_interface_discovery) - note ("Listening on NIT/%s/%s", + note ("Listening on NIT/%s%s%s", print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_NIT_RECEIVE */ @@ -263,6 +265,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) struct strbuf ctl, data; int hw_end; struct sockaddr_in foo; + int result; if (!strcmp (interface -> name, "fallback")) return send_fallback (interface, packet, raw, @@ -298,7 +301,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) data.buf = (char *)&buf [hw_end]; data.maxlen = data.len = bufp + len - hw_end; - return putmsg (interface -> wfdesc, &ctl, &data, 0); + result = putmsg (interface -> wfdesc, &ctl, &data, 0); + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_NIT_SEND */ diff --git a/usr.sbin/dhcp/common/raw.c b/usr.sbin/dhcp/common/raw.c index 5cbf4d1bc76d..0bf7bef5e581 100644 --- a/usr.sbin/dhcp/common/raw.c +++ b/usr.sbin/dhcp/common/raw.c @@ -16,7 +16,7 @@ Sigh. */ /* - * Copyright (c) 1995, 1996 The Internet Software Consortium. + * Copyright (c) 1995, 1996, 1997, 1999 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ #ifndef lint static char copyright[] = -"$Id: raw.c,v 1.1.1.2 1997/10/20 23:28:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: raw.c,v 1.1.1.3 1999/02/24 04:11:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -97,10 +97,11 @@ void if_register_send (info) info -> wfdesc = sock; if (!quiet_interface_discovery) - note ("Sending on Raw/%s/%s", + note ("Sending on Raw/%s%s%s", info -> name, + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } size_t send_packet (interface, packet, raw, len, from, to, hto) @@ -115,6 +116,7 @@ size_t send_packet (interface, packet, raw, len, from, to, 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, @@ -127,6 +129,9 @@ size_t send_packet (interface, packet, raw, len, from, to, hto) iov [1].iov_base = (char *)raw; iov [1].iov_len = len; - return writev(interface -> wfdesc, iov, 2); + result = writev(interface -> wfdesc, iov, 2); + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_SOCKET_SEND */ diff --git a/usr.sbin/dhcp/common/socket.c b/usr.sbin/dhcp/common/socket.c index 8cc59ae9ea6b..558ee55f5394 100644 --- a/usr.sbin/dhcp/common/socket.c +++ b/usr.sbin/dhcp/common/socket.c @@ -50,7 +50,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.1.1.6 1999/02/19 21:58:15 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.1.1.7 1999/02/24 04:11:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -159,11 +159,11 @@ void if_register_send (info) info -> wfdesc = info -> rfdesc; #endif if (!quiet_interface_discovery) - note ("Sending on Socket/%s/%s", + note ("Sending on Socket/%s%s%s", info -> name, + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); - + info -> shared_network -> name : "")); } #endif /* USE_SOCKET_SEND */ @@ -175,10 +175,11 @@ void if_register_receive (info) we don't need to register this interface twice. */ info -> rfdesc = if_register_socket (info); if (!quiet_interface_discovery) - note ("Listening on Socket/%s/%s", + note ("Listening on Socket/%s%s%s", info -> name, + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_SOCKET_RECEIVE */ @@ -206,6 +207,12 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) errno == ECONNREFUSED) && retry++ < 10); #endif + if (result < 0) { + warn ("send_packet: %m"); + if (errno == ENETUNREACH) + warn ("send_packet: please consult README file %s", + "regarding broadcast address."); + } return result; } #endif /* USE_SOCKET_SEND */ diff --git a/usr.sbin/dhcp/common/upf.c b/usr.sbin/dhcp/common/upf.c index 4207b6200702..3ce3f0b80e3c 100644 --- a/usr.sbin/dhcp/common/upf.c +++ b/usr.sbin/dhcp/common/upf.c @@ -3,8 +3,8 @@ Ultrix PacketFilter interface code. /* - * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. - * All rights reserved. + * Copyright (c) 1995, 1996, 1997, 1998, 1999 + * The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: upf.c,v 1.1.1.4 1999/02/18 21:48:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: upf.c,v 1.1.1.5 1999/02/24 04:11:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -143,13 +143,14 @@ void if_register_send (info) info -> wfdesc = info -> rfdesc; #endif if (!quiet_interface_discovery) - note ("Sending on UPF/%s/%s/%s", + note ("Sending on UPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_UPF_SEND */ @@ -208,13 +209,14 @@ void if_register_receive (info) if (ioctl (info -> rfdesc, EIOCSETF, &pf) < 0) error ("Can't install packet filter program: %m"); if (!quiet_interface_discovery) - note ("Listening on UPF/%s/%s/%s", + note ("Listening on UPF/%s/%s%s%s", info -> name, print_hw_addr (info -> hw_address.htype, info -> hw_address.hlen, info -> hw_address.haddr), + (info -> shared_network ? "/" : ""), (info -> shared_network ? - info -> shared_network -> name : "unattached")); + info -> shared_network -> name : "")); } #endif /* USE_UPF_RECEIVE */ @@ -231,6 +233,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) int bufp = 0; unsigned char buf [256]; struct iovec iov [2]; + int result; if (!strcmp (interface -> name, "fallback")) return send_fallback (interface, packet, raw, @@ -248,7 +251,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) iov [1].iov_base = (char *)raw; iov [1].iov_len = len; - return writev(interface -> wfdesc, iov, 2); + result = writev(interface -> wfdesc, iov, 2); + if (result < 0) + warn ("send_packet: %m"); + return result; } #endif /* USE_UPF_SEND */ diff --git a/usr.sbin/dhcp/includes/cf/linux.h b/usr.sbin/dhcp/includes/cf/linux.h index 35bd55a4a350..14fdd7c585d7 100644 --- a/usr.sbin/dhcp/includes/cf/linux.h +++ b/usr.sbin/dhcp/includes/cf/linux.h @@ -76,14 +76,19 @@ extern int h_errno; #include /* gettimeofday()*/ -#ifndef _PATH_DHCPD_PID -#define _PATH_DHCPD_PID "/var/run/dhcpd.pid" -#endif -#ifndef _PATH_DHCLIENT_PID -#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid" +/* Databases go in /var/state/dhcp. It would also be valid to put them + in /var/state/misc - indeed, given that there's only one lease file, it + would probably be better. However, I have some ideas for optimizing + the lease database that may result in a _lot_ of smaller files being + created, so in that context it makes more sense to have a seperate + directory. */ + +#ifndef _PATH_DHCPD_DB +#define _PATH_DHCPD_DB "/var/state/dhcp/dhcpd.leases" #endif + #ifndef _PATH_DHCLIENT_DB -#define _PATH_DHCLIENT_DB "/var/db/dhclient.leases" +#define _PATH_DHCLIENT_DB "/var/state/dhcp/dhclient.leases" #endif /* Varargs stuff... */ @@ -118,6 +123,13 @@ extern int h_errno; # define HAVE_SO_BINDTODEVICE # define HAVE_SIOCGIFHWADDR # else +# if (LINUX_MAJOR == 2) +# define HAVE_ARPHRD_METRICOM +# define HAVE_ARPHRD_IEEE802 +# define HAVE_ARPHRD_LOOPBACK +# define HAVE_SO_BINDTODEVICE +# define HAVE_SIOCGIFHWADDR +# endif # define USE_SOCKETS # define IGNORE_HOSTUNREACH # endif diff --git a/usr.sbin/dhcp/includes/cf/sunos5-5.h b/usr.sbin/dhcp/includes/cf/sunos5-5.h index be1b3a6f0774..07343b2d5ef4 100644 --- a/usr.sbin/dhcp/includes/cf/sunos5-5.h +++ b/usr.sbin/dhcp/includes/cf/sunos5-5.h @@ -118,19 +118,8 @@ extern int h_errno; #define NEED_INET_ATON #if defined (USE_DEFAULT_NETWORK) -# if defined (__sparc) -/* On sparc systems, use the DLPI API, which allows multiple interfaces - to be supported. DLPI is currently buggy on non-sparc machines. - It's unclear whether this is an O.S. bug or an endianness bug in - the DLPI code. */ -# define USE_DLPI -# define USE_DLPI_PFMOD -# else -/* On non-sparc systems, use BSD Socket API for receiving and sending - packets. This actually works pretty well on Solaris, which doesn't - censor the all-ones broadcast address. */ -# define USE_SOCKETS -# endif /* defined (__sparc) */ +# define USE_DLPI +# define USE_DLPI_PFMOD #endif #define USE_POLL diff --git a/usr.sbin/dhcp/relay/dhcrelay.c b/usr.sbin/dhcp/relay/dhcrelay.c index a7923013a0ce..a52b42068e61 100644 --- a/usr.sbin/dhcp/relay/dhcrelay.c +++ b/usr.sbin/dhcp/relay/dhcrelay.c @@ -42,7 +42,7 @@ #ifndef lint static char ocopyright [] = -"$Id: dhcrelay.c,v 1.1.1.6 1999/02/19 21:58:17 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcrelay.c,v 1.1.1.7 1999/02/24 04:11:06 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -76,7 +76,7 @@ struct server_list { static char copyright [] = "Copyright 1997, 1998, 1999 The Internet Software Consortium."; static char arr [] = "All rights reserved."; -static char message [] = "Internet Software Consortium DHCP Relay Agent V2.0b1pl14"; +static char message [] = "Internet Software Consortium DHCP Relay Agent V2.0b1pl15"; static char contrib [] = "\nPlease contribute if you find this software useful."; static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html\n"; @@ -293,12 +293,10 @@ void relay (ip, packet, length, from_port, from, hfrom) return; } - if (send_packet (out, - (struct packet *)0, - packet, length, out -> primary_address, - &to, &hto) < 0) - debug ("sendpkt: %m"); - else + if (!send_packet (out, + (struct packet *)0, + packet, length, out -> primary_address, + &to, &hto) < 0) debug ("forwarded BOOTREPLY for %s to %s", print_hw_addr (packet -> htype, packet -> hlen, packet -> chaddr), @@ -323,13 +321,11 @@ void relay (ip, packet, length, from_port, from, hfrom) /* Otherwise, it's a BOOTREQUEST, so forward it to all the servers. */ for (sp = servers; sp; sp = sp -> next) { - if (send_packet ((fallback_interface - ? fallback_interface : interfaces), - (struct packet *)0, - packet, length, ip -> primary_address, - &sp -> to, (struct hardware *)0) < 0) { - debug ("send_packet: %m"); - } else { + if (!send_packet ((fallback_interface + ? fallback_interface : interfaces), + (struct packet *)0, + packet, length, ip -> primary_address, + &sp -> to, (struct hardware *)0) < 0) { debug ("forwarded BOOTREQUEST for %s to %s", print_hw_addr (packet -> htype, packet -> hlen, packet -> chaddr), diff --git a/usr.sbin/dhcp/server/dhcpd.conf b/usr.sbin/dhcp/server/dhcpd.conf index a50dee0751de..d58d54d6eafb 100644 --- a/usr.sbin/dhcp/server/dhcpd.conf +++ b/usr.sbin/dhcp/server/dhcpd.conf @@ -1,66 +1,28 @@ # dhcpd.conf # -# Configuration file for ISC dhcpd +# Sample configuration file for ISC dhcpd # -# Hosts with more than one interface MUST specify a ``server-identifier'', -# which should be the IP address of the server's primary network interface, -# or if there is no interface that can be described that way, at least an -# interface whose address isn't likely to change. - -server-identifier toccata.fugue.com; - # option definitions common to all supported networks... option domain-name "fugue.com"; option domain-name-servers toccata.fugue.com; -# Shared network declaration is used to group subnets which share the same -# physical network together. The name is specified so that the shared -# network can be referred to in log messages - it serves no other function. +option subnet-mask 255.255.255.224; +default-lease-time 600; +max-lease-time 7200; -shared-network FUGUE { - -# option definitions common to this shared network. - option subnet-mask 255.255.255.224; - default-lease-time 600; - max-lease-time 7200; - -# One of the two IP subnets that share this physical network -# -# Address ranges can be specified for each subnet attached to -# a shared network. Since these subnets share the same physical -# network, addresses are pooled together, and assignments are made -# without regard to the actual subnet. If the optional dynamic-bootp -# keyword is given in the address range declaration, then addresses -# in that range can be assigned either with the DHCP protocol or the -# BOOTP protocol; otherwise, only DHCP clients will have addresses -# allocated from the address range. -# -# Note that each IP subnet can have its own options specific to that subnet. -# options that aren't specified in the subnet are taken from the shared -# network (if any) and then from the global option list. - - subnet 204.254.239.0 netmask 255.255.255.224 { - range 204.254.239.10 204.254.239.20; - option broadcast-address 204.254.239.31; - option routers prelude.fugue.com; - } - -# The other subnet that shares this physical network - subnet 204.254.239.32 netmask 255.255.255.224 { - range dynamic-bootp 204.254.239.10 204.254.239.20; - option broadcast-address 204.254.239.31; - option routers snarg.fugue.com; - } +subnet 204.254.239.0 netmask 255.255.255.224 { + range 204.254.239.10 204.254.239.20; + option broadcast-address 204.254.239.31; + option routers prelude.fugue.com; } -# IP subnets that are alone on their physical wire should be declared by -# themselves. ISC dhcpd may still refer to them as shared networks in -# log messages, but this is simply an artifact of the underlying data -# structures. -# -# Note that options can be specified in the subnet declaration which -# supersede the global options specified earlier. +# The other subnet that shares this physical network +subnet 204.254.239.32 netmask 255.255.255.224 { + range dynamic-bootp 204.254.239.10 204.254.239.20; + option broadcast-address 204.254.239.31; + option routers snarg.fugue.com; +} subnet 192.5.5.0 netmask 255.255.255.224 { range 192.5.5.26 192.5.5.30;