diff -rNc2 dhcp-2.0b1pl1/Makefile.conf dhcp-2.0b1pl2/Makefile.conf *** dhcp-2.0b1pl1/Makefile.conf Sun May 17 22:31:17 1998 --- dhcp-2.0b1pl2/Makefile.conf Thu Jun 25 11:34:46 1998 *************** *** 1,5 **** ! # Makefile.dist # ! # Copyright (c) 1996, 1997 The Internet Software Consortium. # All rights reserved. # --- 1,5 ---- ! # Makefile.conf # ! # Copyright (c) 1996, 1997, 1998 The Internet Software Consortium. # All rights reserved. # *************** *** 93,97 **** #CC=gcc #COPTS = -Wall -Wstrict-prototypes -Wno-unused -Wno-implicit -Wno-comment \ ! # -Wno-uninitialized -Werror #CF = cf/sunos5-5.h #ADMMANDIR = /usr/share/man/cat1m --- 93,97 ---- #CC=gcc #COPTS = -Wall -Wstrict-prototypes -Wno-unused -Wno-implicit -Wno-comment \ ! # -Wno-uninitialized -Wno-char-subscript -Werror #CF = cf/sunos5-5.h #ADMMANDIR = /usr/share/man/cat1m *************** *** 145,148 **** --- 145,156 ---- #SCRIPT=freebsd ##--freebsd-- + + ## Rhapsody + ##--rhapsody-- + #CF = cf/rhapsody.h + #COPTS = -Wall -Wno-unused -Wno-implicit -Wno-comment \ + # -Wno-uninitialized -Werror -pipe + #SCRIPT=rhapsody + ##--rhapsody-- ## NetBSD diff -rNc2 dhcp-2.0b1pl1/RELNOTES dhcp-2.0b1pl2/RELNOTES *** dhcp-2.0b1pl1/RELNOTES Sun May 17 22:52:52 1998 --- dhcp-2.0b1pl2/RELNOTES Thu Jun 25 14:22:55 1998 *************** *** 1,6 **** Internet Software Consortium Dynamic Host Configuration Protocol Distribution ! Version 2, Beta 1, Patchlevel 1 ! May 17, 1998 Release Notes --- 1,6 ---- Internet Software Consortium Dynamic Host Configuration Protocol Distribution ! Version 2, Beta 1, Patchlevel 2 ! June 25, 1998 Release Notes *************** *** 46,49 **** --- 46,75 ---- future, and is intended for sites that are in a position to experiment, or for sites that desperately need the new features. + + CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 1 + + - Use -Wno-char-subscript on Solaris to prevent bogus warnings from + gcc on Solaris 2.6. + + - Add support for Apple's new Rhapsody operating system. + + - Use DLPI on Solaris instead of using the BSD Sockets API. + + - Fix two network input buffer overflow problems which could allow an + attacker to pervert the stack. + + - Fix an ancient typo that could theoretically cause memory + corruption. + + - Sort abandoned leases in at current time rather than end of time. + This allows abandoned leases to be reclaimed if there are no + available free leases. + + - If a client explicitly requests a lease that's been abandoned, it's + probably the system that was answering pings on that address, so let it + have the lease. + + - Fix a bunch of type conversion errors that are flagged by the Solaris + C compiler. CHANGES FROM VERSION 2.0 BETA 1 PATCHLEVEL 0 diff -rNc2 dhcp-2.0b1pl1/client/clparse.c dhcp-2.0b1pl2/client/clparse.c *** dhcp-2.0b1pl1/client/clparse.c Mon Oct 27 12:13:21 1997 --- dhcp-2.0b1pl2/client/clparse.c Thu Jun 25 14:11:27 1998 *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: clparse.c,v 1.13 1997/10/27 20:13:21 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: clparse.c,v 1.13.2.1 1998/06/25 21:11:27 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 772,777 **** /* Look up the option name hash table for the specified vendor. */ ! universe = (struct universe *)hash_lookup (&universe_hash, ! vendor, 0); /* If it's not there, we can't parse the rest of the declaration. */ --- 772,778 ---- /* Look up the option name hash table for the specified vendor. */ ! universe = ((struct universe *) ! hash_lookup (&universe_hash, ! (unsigned char *)vendor, 0)); /* If it's not there, we can't parse the rest of the declaration. */ *************** *** 789,793 **** /* Look up the actual option info... */ ! option = (struct option *)hash_lookup (universe -> hash, val, 0); /* If we didn't get an option structure, it's an undefined option. */ --- 790,795 ---- /* Look up the actual option info... */ ! option = (struct option *)hash_lookup (universe -> hash, ! (unsigned char *)val, 0); /* If we didn't get an option structure, it's an undefined option. */ diff -rNc2 dhcp-2.0b1pl1/common/Makefile.dist dhcp-2.0b1pl2/common/Makefile.dist *** dhcp-2.0b1pl1/common/Makefile.dist Sat Dec 6 03:25:21 1997 --- dhcp-2.0b1pl2/common/Makefile.dist Wed Jun 24 23:07:12 1998 *************** *** 33,40 **** SRC = raw.c parse.c nit.c icmp.c dispatch.c conflex.c upf.c bpf.c socket.c \ packet.c memory.c print.c options.c inet.c convert.c \ ! tree.c tables.c hash.c alloc.c errwarn.c inet_addr.c OBJ = raw.o parse.o nit.o icmp.o dispatch.o conflex.o upf.o bpf.o socket.o \ packet.o memory.o print.o options.o inet.o convert.o \ ! tree.o tables.o hash.o alloc.o errwarn.o inet_addr.o MAN = dhcp-options.5 --- 33,40 ---- SRC = raw.c parse.c nit.c icmp.c dispatch.c conflex.c upf.c bpf.c socket.c \ packet.c memory.c print.c options.c inet.c convert.c \ ! tree.c tables.c hash.c alloc.c errwarn.c inet_addr.c dlpi.c OBJ = raw.o parse.o nit.o icmp.o dispatch.o conflex.o upf.o bpf.o socket.o \ packet.o memory.o print.o options.o inet.o convert.o \ ! tree.o tables.o hash.o alloc.o errwarn.o inet_addr.o dlpi.o MAN = dhcp-options.5 diff -rNc2 dhcp-2.0b1pl1/common/convert.c dhcp-2.0b1pl2/common/convert.c *** dhcp-2.0b1pl1/common/convert.c Fri May 9 00:58:33 1997 --- dhcp-2.0b1pl2/common/convert.c Thu Jun 25 14:11:28 1998 *************** *** 44,48 **** #ifndef lint static char copyright[] = ! "$Id: convert.c,v 1.4 1997/05/09 07:58:33 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 44,48 ---- #ifndef lint static char copyright[] = ! "$Id: convert.c,v 1.4.2.1 1998/06/25 21:11:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 103,107 **** void putUShort (obuf, val) unsigned char *obuf; ! u_int16_t val; { u_int16_t tmp = htons (val); --- 103,107 ---- void putUShort (obuf, val) unsigned char *obuf; ! unsigned int val; { u_int16_t tmp = htons (val); *************** *** 111,115 **** void putShort (obuf, val) unsigned char *obuf; ! int16_t val; { int16_t tmp = htons (val); --- 111,115 ---- void putShort (obuf, val) unsigned char *obuf; ! int val; { int16_t tmp = htons (val); diff -rNc2 dhcp-2.0b1pl1/common/dispatch.c dhcp-2.0b1pl2/common/dispatch.c *** dhcp-2.0b1pl1/common/dispatch.c Fri Dec 5 20:03:37 1997 --- dhcp-2.0b1pl2/common/dispatch.c Thu Jun 25 14:11:28 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: dispatch.c,v 1.47 1997/12/06 04:03:37 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: dispatch.c,v 1.47.2.2 1998/06/25 21:11:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 55,59 **** static int interfaces_invalidated; void (*bootp_packet_handler) PROTO ((struct interface_info *, ! unsigned char *, int, unsigned short, struct iaddr, struct hardware *)); --- 55,59 ---- static int interfaces_invalidated; void (*bootp_packet_handler) PROTO ((struct interface_info *, ! struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *)); *************** *** 574,584 **** struct iaddr ifrom; int result; ! static unsigned char packbuf [4095]; /* Packet input buffer. ! Must be as large as largest ! possible MTU. */ struct interface_info *ip = l -> local; ! if ((result = receive_packet (ip, packbuf, sizeof packbuf, ! &from, &hfrom)) < 0) { warn ("receive_packet failed on %s: %m", ip -> name); return; --- 574,587 ---- struct iaddr ifrom; int result; ! union { ! unsigned char packbuf [4095]; /* Packet input buffer. ! Must be as large as largest ! possible MTU. */ ! struct dhcp_packet packet; ! } u; struct interface_info *ip = l -> local; ! if ((result = ! receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) { warn ("receive_packet failed on %s: %m", ip -> name); return; *************** *** 591,595 **** memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len); ! (*bootp_packet_handler) (ip, packbuf, result, from.sin_port, ifrom, &hfrom); } --- 594,598 ---- memcpy (ifrom.iabuf, &from.sin_addr, ifrom.len); ! (*bootp_packet_handler) (ip, &u.packet, result, from.sin_port, ifrom, &hfrom); } diff -rNc2 dhcp-2.0b1pl1/common/dlpi.c dhcp-2.0b1pl2/common/dlpi.c *** dhcp-2.0b1pl1/common/dlpi.c Wed Dec 31 16:00:00 1969 --- dhcp-2.0b1pl2/common/dlpi.c Sun Mar 15 22:11:03 1998 *************** *** 0 **** --- 1,1229 ---- + /* dlpi.c + + Data Link Provider Interface (DLPI) network interface code. */ + + /* + * Copyright (c) 1998 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 + * 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 The Internet Software Consortium 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 INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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. + * + * This software has been written for the Internet Software Consortium + * by Eric James Negaard, . To learn more about + * the Internet Software Consortium, see ``http://www.vix.com/isc''. + */ + + /* + * Based largely in part to the existing NIT code in nit.c. + * + * This code has been developed and tested on sparc-based machines running + * SunOS 5.5.1, with le and hme network interfaces. It should be pretty + * generic, though. + */ + + /* + * Implementation notes: + * + * I first tried to write this code to the "vanilla" DLPI 2.0 API. + * It worked on a Sun Ultra-1 with a hme interface, but didn't work + * on Sun SparcStation 5's with "le" interfaces (the packets sent out + * via dlpiunitdatareq contained an Ethernet type of 0x0000 instead + * of the expected 0x0800). + * + * Therefore I added the "DLPI_RAW" code which is a Sun extension to + * the DLPI standard. This code works on both of the above machines. + * This is configurable in the OS-dependent include file by defining + * USE_DLPI_RAW. + * + * It quickly became apparant that I should also use the "pfmod" + * STREAMS module to cut down on the amount of user level packet + * processing. I don't know how widely available "pfmod" is, so it's + * use is conditionally included. This is configurable in the + * OS-dependent include file by defining USE_DLPI_PFMOD. + * + * A major quirk on the Sun's at least, is that no packets seem to get + * sent out the interface until six seconds after the interface is + * first "attached" to [per system reboot] (it's actually from when + * the interface is attached, not when it is plumbed, so putting a + * sleep into the dhclient-script at PREINIT time doesn't help). I + * HAVE tried, without success to poll the fd to see when it is ready + * for writing. This doesn't help at all. If the sleeps are not done, + * the initial DHCPREQUEST or DHCPDISCOVER never gets sent out, so + * I've put them here, when register_send and register_receive are + * called (split up into two three-second sleeps between the notices, + * so that it doesn't seem like so long when you're watching :-). The + * amount of time to sleep is configurable in the OS-dependent include + * file by defining DLPI_FIRST_SEND_WAIT to be the number of seconds + * to sleep. + */ + + #include "dhcpd.h" + + #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE) + + # include + # include + # include + # include + # ifdef USE_DLPI_PFMOD + # include + # endif + # ifdef USE_POLL + # include + # endif + + # include + # include "includes/netinet/ip.h" + # include "includes/netinet/udp.h" + # include "includes/netinet/if_ether.h" + + # ifdef USE_DLPI_PFMOD + # ifdef USE_DLPI_RAW + # define DLPI_MODNAME "DLPI+RAW+PFMOD" + # else + # define DLPI_MODNAME "DLPI+PFMOD" + # endif + # else + # ifdef USE_DLPI_RAW + # define DLPI_MODNAME "DLPI+RAW" + # else + # define DLPI_MODNAME "DLPI" + # endif + # endif + + # ifndef ABS + # define ABS(x) ((x) >= 0 ? (x) : 0-(x)) + # endif + + static int strioctl PROTO ((int fd, int cmd, int timeout, int len, char *dp)); + + #define DLPI_MAXDLBUF 8192 /* Buffer size */ + #define DLPI_MAXDLADDR 1024 /* Max address size */ + #define DLPI_DEVDIR "/dev/" /* Device directory */ + #define DLPI_DEFAULTSAP 0x0800 /* IP protocol */ + + static void dlpi_makeaddr PROTO ((unsigned char *physaddr, int physaddrlen, + unsigned char *sap, int saplen, + unsigned char *buf)); + static void dlpi_parseaddr PROTO ((unsigned char *buf, + unsigned char *physaddr, + int physaddrlen, unsigned char *sap, + int saplen)); + static int dlpiopen PROTO ((char *ifname)); + static int dlpiunit PROTO ((char *ifname)); + static int dlpiinforeq PROTO ((int fd)); + static int dlpiphysaddrreq PROTO ((int fd, unsigned long addrtype)); + static int dlpiattachreq PROTO ((int fd, unsigned long ppa)); + static int dlpibindreq PROTO ((int fd, unsigned long sap, unsigned long max_conind, + unsigned long service_mode, unsigned long conn_mgmt, + unsigned long xidtest)); + static int dlpidetachreq PROTO ((int fd)); + static int dlpiunbindreq PROTO ((int fd)); + static int dlpiokack PROTO ((int fd, char *bufp)); + static int dlpiinfoack PROTO ((int fd, char *bufp)); + static int dlpiphysaddrack PROTO ((int fd, char *bufp)); + static int dlpibindack PROTO ((int fd, char *bufp)); + static int dlpiunitdatareq PROTO ((int fd, unsigned char *addr, + int addrlen, unsigned long minpri, + unsigned long maxpri, unsigned char *data, + int datalen)); + static int dlpiunitdataind PROTO ((int fd, + unsigned char *dstaddr, + unsigned long *dstaddrlen, + unsigned char *srcaddr, + unsigned long *srcaddrlen, + unsigned long *grpaddr, + unsigned char *data, + int datalen)); + + # ifndef USE_POLL + static void sigalrm PROTO ((int sig)); + # endif + static int expected PROTO ((unsigned long prim, union DL_primitives *dlp, + int msgflags)); + static int strgetmsg PROTO ((int fd, struct strbuf *ctlp, + struct strbuf *datap, int *flagsp, + char *caller)); + + /* Reinitializes the specified interface after an address change. This + is not required for packet-filter APIs. */ + + #ifdef USE_DLPI_SEND + void if_reinitialize_send (info) + struct interface_info *info; + { + } + #endif + + #ifdef USE_DLPI_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_dlpi (info) + struct interface_info *info; + { + int sock; + int unit; + long buf [DLPI_MAXDLBUF]; + union DL_primitives *dlp; + + dlp = (union DL_primitives *)buf; + + /* Open a DLPI device */ + if ((sock = dlpiopen (info -> name)) < 0) { + error ("Can't open DLPI device for %s: %m", info -> name); + } + + /* + * Get information about the provider. + */ + + /* + * Submit a DL_INFO_REQ request, to find + * the dl_mac_type and dl_provider_style + */ + if (dlpiinforeq(sock) < 0 || dlpiinfoack(sock, (char *)buf) < 0) { + error ("Can't get DLPI MAC type for %s: %m", info -> name); + } else { + switch (dlp -> info_ack.dl_mac_type) { + case DL_CSMACD: /* IEEE 802.3 */ + case DL_ETHER: + info -> hw_address.htype = HTYPE_ETHER; + break; + default: + error ("%s: unknown DLPI MAC type %d", + info -> name, + dlp -> info_ack.dl_mac_type); + break; + } + } + + if (dlp -> info_ack.dl_provider_style == DL_STYLE2) { + /* + * Attach to the device. If this fails, the device + * does not exist. + */ + unit = dlpiunit (info -> name); + + if (dlpiattachreq (sock, unit) < 0 + || dlpiokack (sock, (char *)buf) < 0) { + error ("Can't attach DLPI device for %s: %m", info -> name); + } + } + + /* + * Bind to the IP service access point (SAP), connectionless (CLDLS). + */ + if (dlpibindreq (sock, DLPI_DEFAULTSAP, 0, DL_CLDLS, 0, 0) < 0 + || dlpibindack (sock, (char *)buf) < 0) { + error ("Can't bind DLPI device for %s: %m", info -> name); + } + + /* + * Submit a DL_PHYS_ADDR_REQ request, to find + * the hardware address + */ + if (dlpiphysaddrreq (sock, DL_CURR_PHYS_ADDR) < 0 + || dlpiphysaddrack (sock, (char *)buf) < 0) { + error ("Can't get DLPI hardware address for %s: %m", + info -> name); + } + + info -> hw_address.hlen = dlp -> physaddr_ack.dl_addr_length; + memcpy (info -> hw_address.haddr, + (char *)buf + dlp -> physaddr_ack.dl_addr_offset, + dlp -> physaddr_ack.dl_addr_length); + + #ifdef USE_DLPI_RAW + if (strioctl (sock, DLIOCRAW, INFTIM, 0, 0) < 0) { + error ("Can't set DLPI RAW mode for %s: %m", + info -> name); + } + #endif + + #ifdef USE_DLPI_PFMOD + if (ioctl (sock, I_PUSH, "pfmod") < 0) { + error ("Can't push packet filter onto DLPI for %s: %m", + info -> name); + } + #endif + + return sock; + } + + static int + strioctl (fd, cmd, timeout, len, dp) + int fd; + int cmd; + int timeout; + int len; + char *dp; + { + struct strioctl sio; + int rslt; + + sio.ic_cmd = cmd; + sio.ic_timout = timeout; + sio.ic_len = len; + sio.ic_dp = dp; + + if ((rslt = ioctl (fd, I_STR, &sio)) < 0) { + return rslt; + } else { + return sio.ic_len; + } + } + + #ifdef USE_DLPI_SEND + void if_register_send (info) + struct interface_info *info; + { + /* If we're using the DLPI API for sending and receiving, + we don't need to register this interface twice. */ + #ifndef USE_DLPI_RECEIVE + # ifdef USE_DLPI_PFMOD + struct packetfilt pf; + # endif + + info -> wfdesc = if_register_dlpi (info); + + # ifdef USE_DLPI_PFMOD + /* Set up an PFMOD filter that rejects everything... */ + pf.Pf_Priority = 0; + pf.Pf_FilterLen = 1; + pf.Pf_Filter [0] = ENF_PUSHZERO; + + /* Install the filter */ + if (strioctl (info -> wfdesc, PFIOCSETF, INFTIM, + sizeof (pf), (char *)&pf) < 0) { + error ("Can't set PFMOD send filter on %s: %m", info -> name); + } + + # endif /* USE_DLPI_PFMOD */ + #else /* !defined (USE_DLPI_RECEIVE) */ + /* + * If using DLPI for both send and receive, simply re-use + * the read file descriptor that was set up earlier. + */ + info -> wfdesc = info -> rfdesc; + #endif + + if (!quiet_interface_discovery) + note ("Sending on DLPI/%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 -> name : "unattached")); + + #ifdef DLPI_FIRST_SEND_WAIT + /* See the implementation notes at the beginning of this file */ + # ifdef USE_DLPI_RECEIVE + sleep (DLPI_FIRST_SEND_WAIT - (DLPI_FIRST_SEND_WAIT / 2)); + # else + sleep (DLPI_FIRST_SEND_WAIT); + # endif + #endif + } + #endif /* USE_DLPI_SEND */ + + #ifdef USE_DLPI_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; + { + #ifdef USE_DLPI_PFMOD + struct packetfilt pf; + #endif + + /* Open a DLPI device and hang it on this interface... */ + info -> rfdesc = if_register_dlpi (info); + + #ifdef USE_DLPI_PFMOD + /* Set up the PFMOD 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; + + #ifdef USE_DLPI_RAW + 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_PUSH00FF + ENF_AND; + 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; + #else + /* + * The packets that will be received on this file descriptor + * will be IP packets (due to the SAP that was specified in + * the dlbind call). There will be no ethernet header. + * Therefore, setup the packet filter to check the protocol + * field for UDP, and the destination port number equal + * to the local port. All offsets are relative to the start + * of an IP packet. + */ + 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 + 4; + pf.Pf_Filter [pf.Pf_FilterLen++] = ENF_PUSH00FF + ENF_AND; + 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; + #endif + + /* Install the filter... */ + if (strioctl (info -> rfdesc, PFIOCSETF, INFTIM, + sizeof (pf), (char *)&pf) < 0) { + error ("Can't set PFMOD receive filter on %s: %m", info -> name); + } + #endif + + if (!quiet_interface_discovery) + note ("Listening on DLPI/%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 -> name : "unattached")); + + #ifdef DLPI_FIRST_SEND_WAIT + /* See the implementation notes at the beginning of this file */ + # ifdef USE_DLPI_SEND + sleep (DLPI_FIRST_SEND_WAIT / 2); + # else + sleep (DLPI_FIRST_SEND_WAIT); + # endif + #endif + } + #endif /* USE_DLPI_RECEIVE */ + + #ifdef USE_DLPI_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; + { + int dbuflen; + unsigned char dbuf [1536]; + unsigned char sap [2]; + unsigned char dstaddr [DLPI_MAXDLADDR]; + unsigned addrlen; + int saplen; + int rslt; + + dbuflen = 0; + + /* Assemble the headers... */ + #ifdef USE_DLPI_RAW + assemble_hw_header (interface, dbuf, &dbuflen, hto); + #endif + assemble_udp_ip_header (interface, dbuf, &dbuflen, from.s_addr, + to -> sin_addr.s_addr, to -> sin_port, + (unsigned char *)raw, len); + + /* Copy the data into the buffer (yuk). */ + memcpy (dbuf + dbuflen, raw, len); + dbuflen += len; + + #ifdef USE_DLPI_RAW + rslt = write (interface -> wfdesc, dbuf, dbuflen); + #else + /* XXX: Assumes ethernet, with two byte SAP */ + sap [0] = 0; /* ETHERTYPE_IP, high byte */ + sap [1] = 0x80; /* ETHERTYPE_IP, low byte */ + saplen = -2; /* -2 indicates a two byte SAP at the end + of the address */ + + /* Setup the destination address */ + if (hto && hto -> hlen == interface -> hw_address.hlen) { + dlpi_makeaddr (hto -> haddr, hto -> hlen, sap, saplen, dstaddr); + } else { + /* XXX: Assumes broadcast addr is all ones */ + /* Really should get the broadcast address as part of the + * dlpiinforeq, and store it somewhere in the interface structure. + */ + unsigned char bcast_ether [DLPI_MAXDLADDR]; + + memset ((char *)bcast_ether, 0xFF, interface -> hw_address.hlen); + dlpi_makeaddr (bcast_ether, interface -> hw_address.hlen, + sap, saplen, dstaddr); + } + addrlen = interface -> hw_address.hlen + ABS (saplen); + + /* Send the packet down the wire... */ + rslt = dlpiunitdatareq (interface -> wfdesc, dstaddr, addrlen, + 0, 0, dbuf, dbuflen); + #endif + return rslt; + } + #endif /* USE_DLPI_SEND */ + + #ifdef USE_DLPI_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; + { + unsigned char dbuf [1536]; + unsigned char sap [2]; + unsigned char srcaddr [DLPI_MAXDLADDR]; + unsigned long srcaddrlen; + int saplen; + int flags = 0; + int length = 0; + int offset = 0; + int bufix = 0; + int rslt; + + #ifdef USE_DLPI_RAW + length = read (interface -> rfdesc, dbuf, sizeof (dbuf)); + #else + length = dlpiunitdataind (interface -> rfdesc, (unsigned char *)NULL, + (unsigned long *)NULL, srcaddr, &srcaddrlen, + (unsigned long *)NULL, dbuf, sizeof (dbuf)); + #endif + + if (length <= 0) { + return length; + } + + #ifndef USE_DLPI_RAW + /* Copy sender info */ + /* XXX: Assumes ethernet, where SAP comes at end of haddr */ + saplen = -2; + if (hfrom && srcaddrlen == ABS(saplen) + interface -> hw_address.hlen) { + hfrom -> htype = interface -> hw_address.htype; + hfrom -> hlen = interface -> hw_address.hlen; + dlpi_parseaddr (srcaddr, hfrom -> haddr, + interface -> hw_address.hlen, sap, saplen); + } else if (hfrom) { + memset ((char *)hfrom, '\0', sizeof (*hfrom)); + } + #endif + + /* Decode the IP and UDP headers... */ + bufix = 0; + #ifdef USE_DLPI_RAW + /* Decode the physical header... */ + offset = decode_hw_header (interface, dbuf, 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; + #endif + offset = decode_udp_ip_header (interface, dbuf, bufix, + from, (unsigned char *)0, length); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) { + return 0; + } + + bufix += offset; + length -= offset; + + /* Copy out the data in the packet... */ + memcpy (buf, &dbuf [bufix], length); + return length; + } + #endif + + /* Common DLPI routines ... + * + * Written by Eric James Negaard, + * + * Based largely in part to the example code contained in the document + * "How to Use the STREAMS Data Link Provider Interface (DLPI)", written + * by Neal Nuckolls of SunSoft Internet Engineering. + * + * This code has been developed and tested on sparc-based machines running + * SunOS 5.5.1, with le and hme network interfaces. It should be pretty + * generic, though. + * + * The usual disclaimers apply. This code works for me. Don't blame me + * if it makes your machine or network go down in flames. That taken + * into consideration, use this code as you wish. If you make usefull + * modifications I'd appreciate hearing about it. + */ + + #define DLPI_MAXWAIT 15 /* Max timeout */ + + static void dlpi_makeaddr (physaddr, physaddrlen, sap, saplen, buf) + unsigned char *physaddr; + int physaddrlen; + unsigned char *sap; + int saplen; + unsigned char *buf; + { + /* + * If the saplen is negative, the SAP goes at the end of the address, + * otherwise it goes at the beginning. + */ + if (saplen >= 0) { + memcpy ((char *)buf, (char *)sap, saplen); + memcpy ((char *)&buf [saplen], (char *)physaddr, physaddrlen); + } else { + memcpy ((char *)buf, (char *)physaddr, physaddrlen); + memcpy ((char *)&buf [physaddrlen], (char *)sap, 0 - saplen); + } + } + + static void dlpi_parseaddr (buf, physaddr, physaddrlen, sap, saplen) + unsigned char *buf; + unsigned char *physaddr; + int physaddrlen; + unsigned char *sap; + int saplen; + { + /* + * If the saplen is negative, the SAP is at the end of the address, + * otherwise it is at the beginning. + */ + if (saplen >= 0) { + memcpy ((char *)sap, (char *)buf, saplen); + memcpy ((char *)physaddr, (char *)&buf [saplen], physaddrlen); + } else { + memcpy ((char *)physaddr, (char *)buf, physaddrlen); + memcpy ((char *)sap, (char *)&buf [physaddrlen], 0 - saplen); + } + } + + /* + * Parse an interface name and extract the unit number + */ + + static int dlpiunit (ifname) + char *ifname; + { + int fd; + char *cp, *dp, *ep; + int unit; + + if (!ifname) { + return 0; + } + + /* Advance to the end of the name */ + cp = ifname; + while (*cp) cp++; + /* Back up to the start of the first digit */ + while ((*(cp-1) >= '0' && *(cp-1) <= '9') || *(cp - 1) == ':') cp--; + + /* Convert the unit number */ + unit = 0; + while (*cp >= '0' && *cp <= '9') { + unit *= 10; + unit += (*cp++ - '0'); + } + + return unit; + } + + /* + * dlpiopen - open the DLPI device for a given interface name + */ + static int dlpiopen (ifname) + char *ifname; + { + char devname [50]; + char *cp, *dp, *ep; + + if (!ifname) { + return -1; + } + + /* Open a DLPI device */ + if (*ifname == '/') { + dp = devname; + } else { + /* Prepend the device directory */ + memcpy (devname, DLPI_DEVDIR, strlen (DLPI_DEVDIR)); + dp = &devname [strlen (DLPI_DEVDIR)]; + } + + /* Find the end of the interface name */ + ep = cp = ifname; + while (*ep) + ep++; + /* And back up to the first digit (unit number) */ + while ((*(ep - 1) >= '0' && *(ep - 1) <= '9') || *(ep - 1) == ':') + ep--; + + /* Copy everything up to the unit number */ + while (cp < ep) { + *dp++ = *cp++; + } + *dp = '\0'; + + return open (devname, O_RDWR, 0); + } + + /* + * dlpiinforeq - request information about the data link provider. + */ + + static int dlpiinforeq (fd) + int fd; + { + dl_info_req_t info_req; + struct strbuf ctl; + int flags; + + info_req.dl_primitive = DL_INFO_REQ; + + ctl.maxlen = 0; + ctl.len = sizeof (info_req); + ctl.buf = (char *)&info_req; + + flags = RS_HIPRI; + + return putmsg (fd, &ctl, (struct strbuf *)NULL, flags); + } + + /* + * dlpiphysaddrreq - request the current physical address. + */ + static int dlpiphysaddrreq (fd, addrtype) + int fd; + unsigned long addrtype; + { + dl_phys_addr_req_t physaddr_req; + struct strbuf ctl; + int flags; + + physaddr_req.dl_primitive = DL_PHYS_ADDR_REQ; + physaddr_req.dl_addr_type = addrtype; + + ctl.maxlen = 0; + ctl.len = sizeof (physaddr_req); + ctl.buf = (char *)&physaddr_req; + + flags = RS_HIPRI; + + return putmsg (fd, &ctl, (struct strbuf *)NULL, flags); + } + + /* + * dlpiattachreq - send a request to attach to a specific unit. + */ + static int dlpiattachreq (fd, ppa) + unsigned long ppa; + int fd; + { + dl_attach_req_t attach_req; + struct strbuf ctl; + int flags; + + attach_req.dl_primitive = DL_ATTACH_REQ; + attach_req.dl_ppa = ppa; + + ctl.maxlen = 0; + ctl.len = sizeof (attach_req); + ctl.buf = (char *)&attach_req; + + flags = 0; + + return putmsg (fd, &ctl, (struct strbuf*)NULL, flags); + } + + /* + * dlpibindreq - send a request to bind to a specific SAP address. + */ + static int dlpibindreq (fd, sap, max_conind, service_mode, conn_mgmt, xidtest) + unsigned long sap; + unsigned long max_conind; + unsigned long service_mode; + unsigned long conn_mgmt; + unsigned long xidtest; + int fd; + { + dl_bind_req_t bind_req; + struct strbuf ctl; + int flags; + + bind_req.dl_primitive = DL_BIND_REQ; + bind_req.dl_sap = sap; + bind_req.dl_max_conind = max_conind; + bind_req.dl_service_mode = service_mode; + bind_req.dl_conn_mgmt = conn_mgmt; + bind_req.dl_xidtest_flg = xidtest; + + ctl.maxlen = 0; + ctl.len = sizeof (bind_req); + ctl.buf = (char *)&bind_req; + + flags = 0; + + return putmsg (fd, &ctl, (struct strbuf*)NULL, flags); + } + + /* + * dlpiunbindreq - send a request to unbind. + */ + static int dlpiunbindreq (fd) + int fd; + { + dl_unbind_req_t unbind_req; + struct strbuf ctl; + int flags; + + unbind_req.dl_primitive = DL_UNBIND_REQ; + + ctl.maxlen = 0; + ctl.len = sizeof (unbind_req); + ctl.buf = (char *)&unbind_req; + + flags = 0; + + return putmsg (fd, &ctl, (struct strbuf*)NULL, flags); + } + + + /* + * dlpidetachreq - send a request to detach. + */ + static int dlpidetachreq (fd) + int fd; + { + dl_detach_req_t detach_req; + struct strbuf ctl; + int flags; + + detach_req.dl_primitive = DL_DETACH_REQ; + + ctl.maxlen = 0; + ctl.len = sizeof (detach_req); + ctl.buf = (char *)&detach_req; + + flags = 0; + + return putmsg (fd, &ctl, (struct strbuf*)NULL, flags); + } + + + /* + * dlpibindack - receive an ack to a dlbindreq. + */ + static int dlpibindack (fd, bufp) + char *bufp; + int fd; + { + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg (fd, &ctl, + (struct strbuf*)NULL, &flags, "dlpibindack") < 0) { + return -1; + } + + dlp = (union DL_primitives *)ctl.buf; + + if (!expected (DL_BIND_ACK, dlp, flags) < 0) { + return -1; + } + + if (ctl.len < sizeof (dl_bind_ack_t)) { + /* Returned structure is too short */ + return -1; + } + + return 0; + } + + /* + * dlpiokack - general acknowledgement reception. + */ + static int dlpiokack (fd, bufp) + char *bufp; + int fd; + { + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg (fd, &ctl, + (struct strbuf*)NULL, &flags, "dlpiokack") < 0) { + return -1; + } + + dlp = (union DL_primitives *)ctl.buf; + + if (!expected (DL_OK_ACK, dlp, flags) < 0) { + return -1; + } + + if (ctl.len < sizeof (dl_ok_ack_t)) { + /* Returned structure is too short */ + return -1; + } + + return 0; + } + + /* + * dlpiinfoack - receive an ack to a dlinforeq. + */ + static int dlpiinfoack (fd, bufp) + char *bufp; + int fd; + { + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg (fd, &ctl, (struct strbuf *)NULL, &flags, + "dlpiinfoack") < 0) { + return -1; + } + + dlp = (union DL_primitives *) ctl.buf; + + if (!expected (DL_INFO_ACK, dlp, flags) < 0) { + return -1; + } + + if (ctl.len < sizeof (dl_info_ack_t)) { + /* Returned structure is too short */ + return -1; + } + + return 0; + } + + /* + * dlpiphysaddrack - receive an ack to a dlpiphysaddrreq. + */ + int dlpiphysaddrack (fd, bufp) + char *bufp; + int fd; + { + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg (fd, &ctl, (struct strbuf *)NULL, &flags, + "dlpiphysaddrack") < 0) { + return -1; + } + + dlp = (union DL_primitives *)ctl.buf; + + if (!expected (DL_PHYS_ADDR_ACK, dlp, flags) < 0) { + return -1; + } + + if (ctl.len < sizeof (dl_phys_addr_ack_t)) { + /* Returned structure is too short */ + return -1; + } + + return 0; + } + + int dlpiunitdatareq (fd, addr, addrlen, minpri, maxpri, dbuf, dbuflen) + int fd; + unsigned char *addr; + int addrlen; + unsigned long minpri; + unsigned long maxpri; + unsigned char *dbuf; + int dbuflen; + { + long buf [DLPI_MAXDLBUF]; + union DL_primitives *dlp; + struct strbuf ctl, data; + + /* Set up the control information... */ + dlp = (union DL_primitives *)buf; + dlp -> unitdata_req.dl_primitive = DL_UNITDATA_REQ; + dlp -> unitdata_req.dl_dest_addr_length = addrlen; + dlp -> unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t); + dlp -> unitdata_req.dl_priority.dl_min = minpri; + dlp -> unitdata_req.dl_priority.dl_max = maxpri; + + /* Append the destination address */ + memcpy ((char *)buf + dlp -> unitdata_req.dl_dest_addr_offset, + addr, addrlen); + + ctl.maxlen = 0; + ctl.len = dlp -> unitdata_req.dl_dest_addr_offset + addrlen; + ctl.buf = (char *)buf; + + data.maxlen = 0; + data.buf = (char *)dbuf; + data.len = dbuflen; + + /* Send the packet down the wire... */ + return putmsg (fd, &ctl, &data, 0); + } + + static int dlpiunitdataind (fd, daddr, daddrlen, + saddr, saddrlen, grpaddr, dbuf, dlen) + int fd; + unsigned char *daddr; + unsigned long *daddrlen; + unsigned char *saddr; + unsigned long *saddrlen; + unsigned long *grpaddr; + unsigned char *dbuf; + int dlen; + { + long buf [DLPI_MAXDLBUF]; + union DL_primitives *dlp; + struct strbuf ctl, data; + int flags = 0; + int rslt; + + /* Set up the msg_buf structure... */ + dlp = (union DL_primitives *)buf; + dlp -> unitdata_ind.dl_primitive = DL_UNITDATA_IND; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = (char *)buf; + + data.maxlen = dlen; + data.len = 0; + data.buf = (char *)dbuf; + + rslt = getmsg (fd, &ctl, &data, &flags); + + if (rslt != 0) { + return -1; + } + + if (ctl.len < sizeof (dl_unitdata_ind_t) || + dlp -> unitdata_ind.dl_primitive != DL_UNITDATA_IND) { + return -1; + } + + if (data.len <= 0) { + return data.len; + } + + /* Copy sender info */ + if (saddr) { + memcpy (saddr, &buf [dlp -> unitdata_ind.dl_src_addr_offset], + dlp -> unitdata_ind.dl_src_addr_length); + } + if (saddrlen) { + *saddrlen = dlp -> unitdata_ind.dl_src_addr_length; + } + + /* Copy destination info */ + if (daddr) { + memcpy (daddr, &buf [dlp -> unitdata_ind.dl_dest_addr_offset], + dlp -> unitdata_ind.dl_dest_addr_length); + } + if (daddrlen) { + *daddrlen = dlp -> unitdata_ind.dl_dest_addr_length; + } + + if (grpaddr) { + *grpaddr = dlp -> unitdata_ind.dl_group_address; + } + + return data.len; + } + + /* + * expected - see if we got what we wanted. + */ + static int expected (prim, dlp, msgflags) + unsigned long prim; + union DL_primitives *dlp; + int msgflags; + { + if (msgflags != RS_HIPRI) { + /* Message was not M_PCPROTO */ + return 0; + } + + if (dlp -> dl_primitive != prim) { + /* Incorrect/unexpected return message */ + return 0; + } + + return 1; + } + + /* + * strgetmsg - get a message from a stream, with timeout. + */ + static int strgetmsg (fd, ctlp, datap, flagsp, caller) + struct strbuf *ctlp, *datap; + char *caller; + int *flagsp; + int fd; + { + int rslt; + #ifdef USE_POLL + struct pollfd pfd; + int count; + time_t now; + time_t starttime; + int to_msec; + #endif + + #ifdef USE_POLL + pfd.fd = fd; + pfd.events = POLLPRI; /* We're only interested in knowing + * when we can receive the next high + * priority message. + */ + pfd.revents = 0; + + now = time (&starttime); + while (now <= starttime + DLPI_MAXWAIT) { + to_msec = ((starttime + DLPI_MAXWAIT) - now) * 1000; + count = poll (&pfd, 1, to_msec); + + if (count == 0) { + /* error ("strgetmsg: timeout"); */ + return -1; + } else if (count < 0) { + if (errno == EAGAIN || errno == EINTR) { + time (&now); + continue; + } else { + /* error ("poll: %m"); */ + return -1; + } + } else { + break; + } + } + #else /* defined (USE_POLL) */ + /* + * Start timer. Can't use select, since it might return true if there + * were non High-Priority data available on the stream. + */ + (void) sigset (SIGALRM, sigalrm); + + if (alarm (DLPI_MAXWAIT) < 0) { + /* error ("alarm: %m"); */ + return -1; + } + #endif /* !defined (USE_POLL) */ + + /* + * Set flags argument and issue getmsg (). + */ + *flagsp = 0; + if ((rslt = getmsg (fd, ctlp, datap, flagsp)) < 0) { + return rslt; + } + + #ifndef USE_POLL + /* + * Stop timer. + */ + if (alarm (0) < 0) { + /* error ("alarm: %m"); */ + return -1; + } + #endif + + /* + * Check for MOREDATA and/or MORECTL. + */ + if (rslt & (MORECTL|MOREDATA)) { + return -1; + } + + /* + * Check for at least sizeof (long) control data portion. + */ + if (ctlp -> len < sizeof (long)) { + return -1; + } + + return 0; + } + + #ifndef USE_POLL + /* + * sigalrm - handle alarms. + */ + static void sigalrm (sig) + int sig; + { + fprintf (stderr, "strgetmsg: timeout"); + exit (1); + } + #endif /* !defined (USE_POLL) */ + + #endif /* USE_DLPI */ diff -rNc2 dhcp-2.0b1pl1/common/hash.c dhcp-2.0b1pl2/common/hash.c *** dhcp-2.0b1pl1/common/hash.c Mon Sep 9 00:04:45 1996 --- dhcp-2.0b1pl2/common/hash.c Thu Jun 25 14:11:29 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,52 **** #ifndef lint static char copyright[] = ! "$Id: hash.c,v 1.9 1996/09/09 07:04:45 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" ! static INLINE int do_hash PROTO ((char *, int, int)); struct hash_table *new_hash () --- 43,52 ---- #ifndef lint static char copyright[] = ! "$Id: hash.c,v 1.9.2.1 1998/06/25 21:11:29 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" ! static INLINE int do_hash PROTO ((unsigned char *, int, int)); struct hash_table *new_hash () *************** *** 61,70 **** static INLINE int do_hash (name, len, size) ! char *name; int len; int size; { register int accum = 0; ! register unsigned char *s = (unsigned char *)name; int i = len; if (i) { --- 61,70 ---- static INLINE int do_hash (name, len, size) ! unsigned char *name; int len; int size; { register int accum = 0; ! register unsigned char *s = name; int i = len; if (i) { *************** *** 93,97 **** struct hash_table *table; int len; ! char *name; unsigned char *pointer; { --- 93,97 ---- struct hash_table *table; int len; ! unsigned char *name; unsigned char *pointer; { *************** *** 119,123 **** struct hash_table *table; int len; ! char *name; { int hashno; --- 119,123 ---- struct hash_table *table; int len; ! unsigned char *name; { int hashno; *************** *** 132,136 **** if we find it, delete it. */ for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { ! if ((!bp -> len && !strcmp (bp -> name, name)) || (bp -> len == len && !memcmp (bp -> name, name, len))) { --- 132,137 ---- if we find it, delete it. */ for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { ! if ((!bp -> len && ! !strcmp ((char *)bp -> name, (char *)name)) || (bp -> len == len && !memcmp (bp -> name, name, len))) { *************** *** 149,153 **** unsigned char *hash_lookup (table, name, len) struct hash_table *table; ! char *name; int len; { --- 150,154 ---- unsigned char *hash_lookup (table, name, len) struct hash_table *table; ! unsigned char *name; int len; { *************** *** 167,171 **** } else { for (bp = table -> buckets [hashno]; bp; bp = bp -> next) ! if (!strcmp (bp -> name, name)) return bp -> value; } --- 168,172 ---- } else { for (bp = table -> buckets [hashno]; bp; bp = bp -> next) ! if (!strcmp ((char *)bp -> name, (char *)name)) return bp -> value; } diff -rNc2 dhcp-2.0b1pl1/common/icmp.c dhcp-2.0b1pl2/common/icmp.c *** dhcp-2.0b1pl1/common/icmp.c Wed Jun 4 13:59:40 1997 --- dhcp-2.0b1pl2/common/icmp.c Thu Jun 25 14:11:29 1998 *************** *** 1,3 **** ! /* dhcp.c ICMP Protocol engine - for sending out pings and receiving --- 1,3 ---- ! /* icmp.c ICMP Protocol engine - for sending out pings and receiving *************** *** 5,9 **** /* ! * Copyright (c) 1997 The Internet Software Consortium. * All rights reserved. * --- 5,9 ---- /* ! * Copyright (c) 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 44,48 **** #ifndef lint static char copyright[] = ! "$Id: icmp.c,v 1.7 1997/06/04 20:59:40 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 44,48 ---- #ifndef lint static char copyright[] = ! "$Id: icmp.c,v 1.7.2.1 1998/06/25 21:11:29 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 87,91 **** error ("Unable to disable SO_DONTROUTE on ICMP socket: %m"); ! add_protocol ("icmp", icmp_protocol_fd, icmp_echoreply, handler); } --- 87,92 ---- error ("Unable to disable SO_DONTROUTE on ICMP socket: %m"); ! add_protocol ("icmp", icmp_protocol_fd, icmp_echoreply, ! (void *)handler); } *************** *** 137,141 **** struct icmp *icfrom; struct sockaddr_in from; ! unsigned char icbuf [1500]; int status; int len; --- 138,142 ---- struct icmp *icfrom; struct sockaddr_in from; ! u_int8_t icbuf [1500]; int status; int len; *************** *** 144,148 **** len = sizeof from; ! status = recvfrom (protocol -> fd, icbuf, sizeof icbuf, 0, (struct sockaddr *)&from, &len); if (status < 0) { --- 145,149 ---- len = sizeof from; ! status = recvfrom (protocol -> fd, (char *)icbuf, sizeof icbuf, 0, (struct sockaddr *)&from, &len); if (status < 0) { *************** *** 166,170 **** /* If we were given a second-stage handler, call it. */ if (protocol -> local) { ! handler = protocol -> local; memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr); ia.len = sizeof from.sin_addr; --- 167,173 ---- /* If we were given a second-stage handler, call it. */ if (protocol -> local) { ! handler = ((void (*) PROTO ((struct iaddr, ! u_int8_t *, int))) ! protocol -> local); memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr); ia.len = sizeof from.sin_addr; diff -rNc2 dhcp-2.0b1pl1/common/memory.c dhcp-2.0b1pl2/common/memory.c *** dhcp-2.0b1pl1/common/memory.c Tue Sep 16 11:14:18 1997 --- dhcp-2.0b1pl2/common/memory.c Thu Jun 25 14:11:30 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: memory.c,v 1.35 1997/09/16 18:14:18 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: memory.c,v 1.35.2.2 1998/06/25 21:11:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 422,428 **** } *comp = *lease; ! lease -> next = dangling_leases; ! lease -> prev = (struct lease *)0; ! dangling_leases = lease; } else { /* Record the hostname information in the lease. */ --- 422,428 ---- } *comp = *lease; ! comp -> next = dangling_leases; ! comp -> prev = (struct lease *)0; ! dangling_leases = comp; } else { /* Record the hostname information in the lease. */ *************** *** 642,646 **** lease -> flags |= ABANDONED_LEASE; lt = *lease; ! lt.ends = MAX_TIME; warn ("Abandoning IP address %s: %s", piaddr (lease -> ip_addr), message); --- 642,646 ---- lease -> flags |= ABANDONED_LEASE; lt = *lease; ! lt.ends = cur_time; warn ("Abandoning IP address %s: %s", piaddr (lease -> ip_addr), message); *************** *** 839,846 **** if (type) add_hash (user_class_hash, ! tname, strlen (tname), (unsigned char *)class); else add_hash (vendor_class_hash, ! tname, strlen (tname), (unsigned char *)class); return class; } --- 839,848 ---- if (type) add_hash (user_class_hash, ! (unsigned char *)tname, strlen (tname), ! (unsigned char *)class); else add_hash (vendor_class_hash, ! (unsigned char *)tname, strlen (tname), ! (unsigned char *)class); return class; } *************** *** 848,852 **** struct class *find_class (type, name, len) int type; ! char *name; int len; { --- 850,854 ---- struct class *find_class (type, name, len) int type; ! unsigned char *name; int len; { diff -rNc2 dhcp-2.0b1pl1/common/options.c dhcp-2.0b1pl2/common/options.c *** dhcp-2.0b1pl1/common/options.c Sun May 17 22:24:23 1998 --- dhcp-2.0b1pl2/common/options.c Thu Jun 25 14:11:30 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: options.c,v 1.26.2.1 1998/05/18 05:24:23 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: options.c,v 1.26.2.3 1998/06/25 21:11:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 73,80 **** --- 73,82 ---- if (packet -> options [DHO_DHCP_OPTION_OVERLOAD].data [0] & 1) parse_option_buffer (packet, + (unsigned char *) packet -> raw -> file, sizeof packet -> raw -> file); if (packet -> options [DHO_DHCP_OPTION_OVERLOAD].data [0] & 2) parse_option_buffer (packet, + (unsigned char *) packet -> raw -> sname, sizeof packet -> raw -> sname); *************** *** 517,522 **** if (emit_quotes) *op++ = '"'; ! strcpy (op, dp); ! op += strlen (dp); if (emit_quotes) *op++ = '"'; --- 519,524 ---- if (emit_quotes) *op++ = '"'; ! strcpy (op, (char *)dp); ! op += strlen ((char *)dp); if (emit_quotes) *op++ = '"'; *************** *** 572,589 **** } ! void do_packet (interface, packbuf, len, from_port, from, hfrom) struct interface_info *interface; ! unsigned char *packbuf; int len; ! unsigned short from_port; struct iaddr from; struct hardware *hfrom; { struct packet tp; - struct dhcp_packet tdp; ! memcpy (&tdp, packbuf, len); memset (&tp, 0, sizeof tp); ! tp.raw = &tdp; tp.packet_length = len; tp.client_port = from_port; --- 574,594 ---- } ! void do_packet (interface, packet, len, from_port, from, hfrom) struct interface_info *interface; ! struct dhcp_packet *packet; int len; ! unsigned int from_port; struct iaddr from; struct hardware *hfrom; { struct packet tp; ! if (packet -> hlen > sizeof packet -> chaddr) { ! note ("Discarding packet with invalid hlen."); ! return; ! } ! memset (&tp, 0, sizeof tp); ! tp.raw = packet; tp.packet_length = len; tp.client_port = from_port; diff -rNc2 dhcp-2.0b1pl1/common/parse.c dhcp-2.0b1pl2/common/parse.c *** dhcp-2.0b1pl1/common/parse.c Fri May 9 01:08:53 1997 --- dhcp-2.0b1pl2/common/parse.c Thu Jun 25 14:11:31 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: parse.c,v 1.2 1997/05/09 08:08:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: parse.c,v 1.2.2.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 298,302 **** char *val; int token; ! unsigned char *bufp = buf, *s, *t; int count = 0; pair c = (pair)0; --- 298,303 ---- char *val; int token; ! unsigned char *bufp = buf, *s; ! char *t; int count = 0; pair c = (pair)0; *************** *** 344,348 **** s += size / 8; } else { ! t = (unsigned char *)malloc (strlen (val) + 1); if (!t) error ("no temp space for number."); --- 345,349 ---- s += size / 8; } else { ! t = (char *)malloc (strlen (val) + 1); if (!t) error ("no temp space for number."); diff -rNc2 dhcp-2.0b1pl1/common/print.c dhcp-2.0b1pl2/common/print.c *** dhcp-2.0b1pl1/common/print.c Fri Nov 28 23:52:10 1997 --- dhcp-2.0b1pl2/common/print.c Thu Jun 25 14:11:31 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: print.c,v 1.16 1997/11/29 07:52:10 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: print.c,v 1.16.2.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 179,183 **** dump_raw (bp -> name, bp -> len); else ! note (bp -> name); } } --- 179,183 ---- dump_raw (bp -> name, bp -> len); else ! note ((char *)bp -> name); } } diff -rNc2 dhcp-2.0b1pl1/common/socket.c dhcp-2.0b1pl2/common/socket.c *** dhcp-2.0b1pl1/common/socket.c Sun May 17 22:45:49 1998 --- dhcp-2.0b1pl2/common/socket.c Thu Jun 25 14:11:32 1998 *************** *** 51,55 **** #ifndef lint static char copyright[] = ! "$Id: socket.c,v 1.26.2.1 1998/05/18 05:45:49 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 51,55 ---- #ifndef lint static char copyright[] = ! "$Id: socket.c,v 1.26.2.2 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 225,229 **** do { #endif ! result = recvfrom (interface -> rfdesc, buf, len, 0, (struct sockaddr *)from, &flen); #ifdef IGNORE_HOSTUNREACH --- 225,229 ---- do { #endif ! result = recvfrom (interface -> rfdesc, (char *)buf, len, 0, (struct sockaddr *)from, &flen); #ifdef IGNORE_HOSTUNREACH diff -rNc2 dhcp-2.0b1pl1/common/tables.c dhcp-2.0b1pl2/common/tables.c *** dhcp-2.0b1pl1/common/tables.c Fri May 9 01:13:38 1997 --- dhcp-2.0b1pl2/common/tables.c Thu Jun 25 14:11:32 1998 *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: tables.c,v 1.13 1997/05/09 08:13:38 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: tables.c,v 1.13.2.1 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 682,690 **** for (i = 0; i < 256; i++) { dhcp_universe.options [i] = &dhcp_options [i]; ! add_hash (dhcp_universe.hash, dhcp_options [i].name, 0, (unsigned char *)&dhcp_options [i]); } universe_hash.hash_count = DEFAULT_HASH_SIZE; ! add_hash (&universe_hash, dhcp_universe.name, 0, (unsigned char *)&dhcp_universe); } --- 682,692 ---- for (i = 0; i < 256; i++) { dhcp_universe.options [i] = &dhcp_options [i]; ! add_hash (dhcp_universe.hash, ! (unsigned char *)dhcp_options [i].name, 0, (unsigned char *)&dhcp_options [i]); } universe_hash.hash_count = DEFAULT_HASH_SIZE; ! add_hash (&universe_hash, ! (unsigned char *)dhcp_universe.name, 0, (unsigned char *)&dhcp_universe); } diff -rNc2 dhcp-2.0b1pl1/configure dhcp-2.0b1pl2/configure *** dhcp-2.0b1pl1/configure Sun May 17 22:32:18 1998 --- dhcp-2.0b1pl2/configure Thu Jun 25 11:34:46 1998 *************** *** 8,11 **** --- 8,13 ---- if [ "$sysname" = "" ]; then case $uname in + Rhapsody) + sysname=rhapsody;; ULTRIX) sysname=ultrix;; diff -rNc2 dhcp-2.0b1pl1/includes/cf/rhapsody.h dhcp-2.0b1pl2/includes/cf/rhapsody.h *** dhcp-2.0b1pl1/includes/cf/rhapsody.h Wed Dec 31 16:00:00 1969 --- dhcp-2.0b1pl2/includes/cf/rhapsody.h Thu Jun 25 11:32:30 1998 *************** *** 0 **** --- 1,95 ---- + /* netbsd.h + + System dependencies for NetBSD... */ + + /* + * Copyright (c) 1996 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 + * 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 The Internet Software Consortium 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 INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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. + * + * This software was written for the Internet Software Consortium by Ted Lemon + * under a contract with Vixie Laboratories. + */ + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + + extern int h_errno; + + #include + #include + #include + #include + + #define ifr_netmask ifr_addr + + /* Varargs stuff... */ + #include + #define VA_DOTDOTDOT ... + #define va_dcl + #define VA_start(list, last) va_start (list, last) + + #ifndef _PATH_DHCPD_PID + #define _PATH_DHCPD_PID "/var/run/dhcpd.pid" + #endif + #ifndef _PATH_DHCPD_DB + #define _PATH_DHCPD_DB "/var/db/dhcpd.leases" + #endif + #ifndef _PATH_DHCLIENT_PID + #define _PATH_DHCLIENT_PID "/var/run/dhclient.pid" + #endif + #ifndef _PATH_DHCLIENT_DB + #define _PATH_DHCLIENT_DB "/var/db/dhclient.leases" + #endif + + #define EOL '\n' + #define VOIDPTR void * + + /* Time stuff... */ + #include + #define TIME time_t + #define GET_TIME(x) time ((x)) + + #define HAVE_SA_LEN + #define HAVE_MKSTEMP + + #if defined (USE_DEFAULT_NETWORK) + # define USE_BPF + #endif + + #ifdef __alpha__ + #define PTRSIZE_64BIT + #endif diff -rNc2 dhcp-2.0b1pl1/includes/dhcpd.h dhcp-2.0b1pl2/includes/dhcpd.h *** dhcp-2.0b1pl1/includes/dhcpd.h Fri Nov 21 23:52:16 1997 --- dhcp-2.0b1pl2/includes/dhcpd.h Thu Jun 25 14:11:33 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 460,465 **** unsigned char *, int, int, int)); void do_packet PROTO ((struct interface_info *, ! unsigned char *, int, ! unsigned short, struct iaddr, struct hardware *)); /* errwarn.c */ --- 460,465 ---- unsigned char *, int, int, int)); void do_packet PROTO ((struct interface_info *, ! struct dhcp_packet *, int, ! unsigned int, struct iaddr, struct hardware *)); /* errwarn.c */ *************** *** 554,558 **** void dhcpinform PROTO ((struct packet *)); void nak_lease PROTO ((struct packet *, struct iaddr *cip)); ! void ack_lease PROTO ((struct packet *, struct lease *, unsigned char, TIME)); void dhcp_reply PROTO ((struct lease *)); struct lease *find_lease PROTO ((struct packet *, --- 554,558 ---- void dhcpinform PROTO ((struct packet *)); void nak_lease PROTO ((struct packet *, struct iaddr *cip)); ! void ack_lease PROTO ((struct packet *, struct lease *, unsigned int, TIME)); void dhcp_reply PROTO ((struct lease *)); struct lease *find_lease PROTO ((struct packet *, *************** *** 591,595 **** void hw_hash_delete PROTO ((struct lease *)); struct class *add_class PROTO ((int, char *)); ! struct class *find_class PROTO ((int, char *, int)); struct group *clone_group PROTO ((struct group *, char *)); void write_leases PROTO ((void)); --- 591,595 ---- void hw_hash_delete PROTO ((struct lease *)); struct class *add_class PROTO ((int, char *)); ! struct class *find_class PROTO ((int, unsigned char *, int)); struct group *clone_group PROTO ((struct group *, char *)); void write_leases PROTO ((void)); *************** *** 735,740 **** extern int quiet_interface_discovery; extern void (*bootp_packet_handler) PROTO ((struct interface_info *, ! unsigned char *, int, unsigned short, ! struct iaddr, struct hardware *)); extern struct timeout *timeouts; void discover_interfaces PROTO ((int)); --- 735,741 ---- extern int quiet_interface_discovery; extern void (*bootp_packet_handler) PROTO ((struct interface_info *, ! struct dhcp_packet *, int, ! unsigned int, ! struct iaddr, struct hardware *)); extern struct timeout *timeouts; void discover_interfaces PROTO ((int)); *************** *** 754,760 **** /* hash.c */ struct hash_table *new_hash PROTO ((void)); ! void add_hash PROTO ((struct hash_table *, char *, int, unsigned char *)); ! void delete_hash_entry PROTO ((struct hash_table *, char *, int)); ! unsigned char *hash_lookup PROTO ((struct hash_table *, char *, int)); /* tables.c */ --- 755,762 ---- /* hash.c */ struct hash_table *new_hash PROTO ((void)); ! void add_hash PROTO ((struct hash_table *, unsigned char *, ! int, unsigned char *)); ! void delete_hash_entry PROTO ((struct hash_table *, unsigned char *, int)); ! unsigned char *hash_lookup PROTO ((struct hash_table *, unsigned char *, int)); /* tables.c */ *************** *** 774,779 **** void putULong PROTO ((unsigned char *, u_int32_t)); void putLong PROTO ((unsigned char *, int32_t)); ! void putUShort PROTO ((unsigned char *, u_int16_t)); ! void putShort PROTO ((unsigned char *, int16_t)); /* inet.c */ --- 776,781 ---- void putULong PROTO ((unsigned char *, u_int32_t)); void putLong PROTO ((unsigned char *, int32_t)); ! void putUShort PROTO ((unsigned char *, unsigned int)); ! void putShort PROTO ((unsigned char *, int)); /* inet.c */ *************** *** 913,918 **** /* dhcrelay.c */ ! void relay PROTO ((struct interface_info *, u_int8_t *, int, ! unsigned short, struct iaddr, struct hardware *)); /* icmp.c */ --- 915,920 ---- /* dhcrelay.c */ ! void relay PROTO ((struct interface_info *, struct dhcp_packet *, int, ! unsigned int, struct iaddr, struct hardware *)); /* icmp.c */ diff -rNc2 dhcp-2.0b1pl1/includes/hash.h dhcp-2.0b1pl2/includes/hash.h *** dhcp-2.0b1pl1/includes/hash.h Tue Nov 28 23:39:50 1995 --- dhcp-2.0b1pl2/includes/hash.h Thu Jun 25 14:11:33 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995 The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without --- 4,9 ---- /* ! * Copyright (c) 1995, 1996 The Internet Software Consortium. ! * All rights reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 44,48 **** struct hash_bucket { struct hash_bucket *next; ! char *name; int len; unsigned char *value; --- 45,49 ---- struct hash_bucket { struct hash_bucket *next; ! unsigned char *name; int len; unsigned char *value; diff -rNc2 dhcp-2.0b1pl1/includes/osdep.h dhcp-2.0b1pl2/includes/osdep.h *** dhcp-2.0b1pl1/includes/osdep.h Tue Sep 16 17:21:45 1997 --- dhcp-2.0b1pl2/includes/osdep.h Thu Jun 25 11:34:47 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1996 The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without --- 4,9 ---- /* ! * Copyright (c) 1996, 1997, 1998 The Internet Software Consortium. ! * All rights reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 53,57 **** !defined (USE_NIT) && \ !defined (USE_NIT_SEND) && \ ! !defined (USE_NIT_RECEIVE) # define USE_DEFAULT_NETWORK #endif --- 54,60 ---- !defined (USE_NIT) && \ !defined (USE_NIT_SEND) && \ ! !defined (USE_NIT_RECEIVE) && \ ! !defined (USR_DLPI_SEND) && \ ! !defined (USE_DLPI_RECEIVE) # define USE_DEFAULT_NETWORK #endif *************** *** 111,115 **** --- 114,122 ---- #ifdef NeXT + # ifdef __APPLE__ + # include "cf/rhapsody.h" + # else # include "cf/nextstep.h" + # endif #endif *************** *** 140,143 **** --- 147,155 ---- #endif + #ifdef USE_DLPI + # define USE_DLPI_SEND + # define USE_DLPI_RECEIVE + #endif + #ifdef USE_UPF # define USE_UPF_SEND *************** *** 153,157 **** fallback. */ ! #if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || defined (USE_UPF_SEND) # define USE_SOCKET_FALLBACK # define USE_FALLBACK --- 165,170 ---- fallback. */ ! #if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \ ! defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) # define USE_SOCKET_FALLBACK # define USE_FALLBACK *************** *** 165,169 **** #if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \ ! defined (USE_NIT_SEND) || defined (USE_UPF_SEND) # define PACKET_ASSEMBLY #endif --- 178,183 ---- #if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \ ! defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \ ! defined (USE_DLPI_SEND) # define PACKET_ASSEMBLY #endif *************** *** 176,181 **** #if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \ ! defined (USE_NIT_RECEIVE) || defined (USE_UPF_SEND) # define PACKET_DECODING #endif --- 190,202 ---- #if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \ ! defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \ ! defined (USE_DLPI_RECEIVE) # define PACKET_DECODING + #endif + + /* If we don't have a DLPI packet filter, we have to filter in userland. + Probably not worth doing, actually. */ + #if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD) + # define USERLAND_FILTER #endif diff -rNc2 dhcp-2.0b1pl1/relay/dhcrelay.c dhcp-2.0b1pl2/relay/dhcrelay.c *** dhcp-2.0b1pl1/relay/dhcrelay.c Tue Dec 9 12:19:52 1997 --- dhcp-2.0b1pl2/relay/dhcrelay.c Thu Jun 25 14:11:34 1998 *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: dhcrelay.c,v 1.9.2.1 1997/12/09 20:19:52 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: dhcrelay.c,v 1.9.2.4 1998/06/25 21:11:34 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 57,60 **** --- 57,66 ---- int log_perror = 1; + /* Needed to prevent linking against conflex.c. */ + int lexline; + int lexchar; + char *token_line; + char *tlname; + char *path_dhcrelay_pid = _PATH_DHCRELAY_PID; *************** *** 224,240 **** } ! void relay (ip, packbuf, length, from_port, from, hfrom) struct interface_info *ip; ! u_int8_t *packbuf; int length; ! u_int16_t from_port; struct iaddr from; struct hardware *hfrom; { - struct dhcp_packet *packet = (struct dhcp_packet *)packbuf; struct server_list *sp; struct sockaddr_in to; struct interface_info *out; struct hardware hto; /* If it's a bootreply, forward it to the client. */ --- 230,250 ---- } ! void relay (ip, packet, length, from_port, from, hfrom) struct interface_info *ip; ! struct dhcp_packet *packet; int length; ! unsigned int from_port; struct iaddr from; struct hardware *hfrom; { struct server_list *sp; struct sockaddr_in to; struct interface_info *out; struct hardware hto; + + if (packet -> hlen > sizeof packet -> chaddr) { + note ("Discarding packet with invalid hlen."); + return; + } /* If it's a bootreply, forward it to the client. */ diff -rNc2 dhcp-2.0b1pl1/server/confpars.c dhcp-2.0b1pl2/server/confpars.c *** dhcp-2.0b1pl1/server/confpars.c Mon Oct 27 12:22:40 1997 --- dhcp-2.0b1pl2/server/confpars.c Thu Jun 25 14:11:34 1998 *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: confpars.c,v 1.45 1997/10/27 20:22:40 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: confpars.c,v 1.45.2.1 1998/06/25 21:11:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 891,896 **** /* Look up the option name hash table for the specified vendor. */ ! universe = (struct universe *)hash_lookup (&universe_hash, ! vendor, 0); /* If it's not there, we can't parse the rest of the declaration. */ --- 891,897 ---- /* Look up the option name hash table for the specified vendor. */ ! universe = ((struct universe *) ! hash_lookup (&universe_hash, ! (unsigned char *)vendor, 0)); /* If it's not there, we can't parse the rest of the declaration. */ *************** *** 908,912 **** /* Look up the actual option info... */ ! option = (struct option *)hash_lookup (universe -> hash, val, 0); /* If we didn't get an option structure, it's an undefined option. */ --- 909,914 ---- /* Look up the actual option info... */ ! option = (struct option *)hash_lookup (universe -> hash, ! (unsigned char *)val, 0); /* If we didn't get an option structure, it's an undefined option. */ *************** *** 959,963 **** tree = tree_concat (tree, ! tree_const (val, strlen (val))); } else { --- 961,966 ---- tree = tree_concat (tree, ! tree_const ((unsigned char *) ! val, strlen (val))); } else { *************** *** 978,984 **** return; } ! tree = tree_concat (tree, ! tree_const (val, ! strlen (val))); break; --- 981,988 ---- return; } ! tree = tree_concat ! (tree, ! tree_const ((unsigned char *)val, ! strlen (val))); break; diff -rNc2 dhcp-2.0b1pl1/server/dhcp.c dhcp-2.0b1pl2/server/dhcp.c *** dhcp-2.0b1pl1/server/dhcp.c Sun May 17 22:28:06 1998 --- dhcp-2.0b1pl2/server/dhcp.c Thu Jun 25 14:20:41 1998 *************** *** 4,8 **** /* ! * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. * All rights reserved. * --- 4,8 ---- /* ! * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * *************** *** 43,47 **** #ifndef lint static char copyright[] = ! "$Id: dhcp.c,v 1.57.2.1 1998/05/18 05:28:06 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ --- 43,47 ---- #ifndef lint static char copyright[] = ! "$Id: dhcp.c,v 1.57.2.3 1998/06/25 21:20:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ *************** *** 50,54 **** int outstanding_pings; ! static unsigned char dhcp_message [256]; void dhcp (packet) --- 50,54 ---- int outstanding_pings; ! static char dhcp_message [256]; void dhcp (packet) *************** *** 428,434 **** /* Set DHCP_MESSAGE to whatever the message is */ options [DHO_DHCP_MESSAGE] = &dhcpmsg_tree; ! options [DHO_DHCP_MESSAGE] -> value = dhcp_message; ! options [DHO_DHCP_MESSAGE] -> len = strlen (dhcp_message); ! options [DHO_DHCP_MESSAGE] -> buf_size = strlen (dhcp_message); options [DHO_DHCP_MESSAGE] -> timeout = 0xFFFFFFFF; options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0; --- 428,434 ---- /* Set DHCP_MESSAGE to whatever the message is */ options [DHO_DHCP_MESSAGE] = &dhcpmsg_tree; ! options [DHO_DHCP_MESSAGE] -> value = (unsigned char *)dhcp_message; ! options [DHO_DHCP_MESSAGE] -> len = ! options [DHO_DHCP_MESSAGE] -> buf_size = strlen (dhcp_message); options [DHO_DHCP_MESSAGE] -> timeout = 0xFFFFFFFF; options [DHO_DHCP_MESSAGE] -> tree = (struct tree *)0; *************** *** 522,526 **** struct packet *packet; struct lease *lease; ! unsigned char offer; TIME when; { --- 522,526 ---- struct packet *packet; struct lease *lease; ! unsigned int offer; TIME when; { *************** *** 1242,1248 **** /* If the requested IP address isn't on the network the packet ! came from, or if it's been abandoned, don't use it. */ ! if (ip_lease && (ip_lease -> shared_network != share || ! (ip_lease -> flags & ABANDONED_LEASE))) ip_lease = (struct lease *)0; --- 1242,1252 ---- /* If the requested IP address isn't on the network the packet ! came from, don't use it. Allow abandoned leases to be matched ! here - if the client is requesting it, there's a decent chance ! that it's because the lease database got trashed and a client ! that thought it had this lease answered an ARP or PING, causing the ! lease to be abandoned. If so, this request probably came from ! that client. */ ! if (ip_lease && (ip_lease -> shared_network != share)) ip_lease = (struct lease *)0; *************** *** 1376,1379 **** --- 1380,1392 ---- } } + } + + /* If we find an abandoned lease, take it, but print a + warning message, so that if it continues to lose, + the administrator will eventually investigate. */ + if (lease -> flags & ABANDONED_LEASE) { + warn ("Reclaiming REQUESTed abandoned IP address %s.\n", + piaddr (lease -> ip_addr)); + lease -> flags &= ~ABANDONED_LEASE; } diff -rNc2 dhcp-2.0b1pl1/server/dhcpd.c dhcp-2.0b1pl2/server/dhcpd.c *** dhcp-2.0b1pl1/server/dhcpd.c Sat Dec 6 03:25:32 1997 --- dhcp-2.0b1pl2/server/dhcpd.c Sat Dec 6 03:25:32 1997 *************** *** 49,53 **** "Copyright 1995, 1996 The Internet Software Consortium."; static char arr [] = "All rights reserved."; ! static char message [] = "Internet Software Consortium DHCPD $Name: V2-BETA-2 $"; #include "dhcpd.h" --- 49,53 ---- "Copyright 1995, 1996 The Internet Software Consortium."; static char arr [] = "All rights reserved."; ! static char message [] = "Internet Software Consortium DHCPD $Name: V2-BETA-1-PATCH-2 $"; #include "dhcpd.h"