aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bootpd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bootpd')
-rw-r--r--usr.sbin/bootpd/Makefile15
-rw-r--r--usr.sbin/bootpd/getether.c374
-rw-r--r--usr.sbin/bootpd/hwaddr.c294
-rw-r--r--usr.sbin/bootpd/rtmsg.c236
4 files changed, 0 insertions, 919 deletions
diff --git a/usr.sbin/bootpd/Makefile b/usr.sbin/bootpd/Makefile
deleted file mode 100644
index e661b6bb7852..000000000000
--- a/usr.sbin/bootpd/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# bootpd/Makefile
-# $Id: Makefile,v 1.1.1.1 1994/09/10 14:44:53 csgr Exp $
-
-PROG= bootpd
-#CFLAGS+= -DETC_ETHERS
-CFLAGS+= -DSYSLOG -DDEBUG -DVEND_CMU
-
-
-SRCS= bootpd.c dovend.c readfile.c hash.c dumptab.c \
- lookup.c getif.c hwaddr.c report.c tzone.c rtmsg.c
-
-MAN5= bootptab.5
-MAN8= bootpd.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/bootpd/getether.c b/usr.sbin/bootpd/getether.c
deleted file mode 100644
index 724a3767d3a7..000000000000
--- a/usr.sbin/bootpd/getether.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * getether.c : get the ethernet address of an interface
- *
- * All of this code is quite system-specific. As you may well
- * guess, it took a good bit of detective work to figure out!
- *
- * If you figure out how to do this on another system,
- * please let me know. <gwr@mc.com>
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <ctype.h>
-#include <syslog.h>
-
-#include "report.h"
-#define EALEN 6
-
-#if defined(ultrix) || (defined(__osf__) && defined(__alpha))
-/*
- * This is really easy on Ultrix! Thanks to
- * Harald Lundberg <hl@tekla.fi> for this code.
- *
- * The code here is not specific to the Alpha, but that was the
- * only symbol we could find to identify DEC's version of OSF.
- * (Perhaps we should just define DEC in the Makefile... -gwr)
- */
-
-#include <sys/ioctl.h>
-#include <net/if.h> /* struct ifdevea */
-
-getether(ifname, eap)
- char *ifname, *eap;
-{
- int rc = -1;
- int fd;
- struct ifdevea phys;
- bzero(&phys, sizeof(phys));
- strcpy(phys.ifr_name, ifname);
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- report(LOG_ERR, "getether: socket(INET,DGRAM) failed");
- return -1;
- }
- if (ioctl(fd, SIOCRPHYSADDR, &phys) < 0) {
- report(LOG_ERR, "getether: ioctl SIOCRPHYSADDR failed");
- } else {
- bcopy(&phys.current_pa[0], eap, EALEN);
- rc = 0;
- }
- close(fd);
- return rc;
-}
-
-#define GETETHER
-#endif /* ultrix|osf1 */
-
-
-#ifdef SUNOS
-
-#include <sys/sockio.h>
-#include <sys/time.h> /* needed by net_if.h */
-#include <net/nit_if.h> /* for NIOCBIND */
-#include <net/if.h> /* for struct ifreq */
-
-getether(ifname, eap)
- char *ifname; /* interface name from ifconfig structure */
- char *eap; /* Ether address (output) */
-{
- int rc = -1;
-
- struct ifreq ifrnit;
- int nit;
-
- bzero((char *) &ifrnit, sizeof(ifrnit));
- strncpy(&ifrnit.ifr_name[0], ifname, IFNAMSIZ);
-
- nit = open("/dev/nit", 0);
- if (nit < 0) {
- report(LOG_ERR, "getether: open /dev/nit: %s",
- get_errmsg());
- return rc;
- }
- do {
- if (ioctl(nit, NIOCBIND, &ifrnit) < 0) {
- report(LOG_ERR, "getether: NIOCBIND on nit");
- break;
- }
- if (ioctl(nit, SIOCGIFADDR, &ifrnit) < 0) {
- report(LOG_ERR, "getether: SIOCGIFADDR on nit");
- break;
- }
- bcopy(&ifrnit.ifr_addr.sa_data[0], eap, EALEN);
- rc = 0;
- } while (0);
- close(nit);
- return rc;
-}
-
-#define GETETHER
-#endif /* SUNOS */
-
-
-#if defined(__FreeBSD__) || defined(__NetBSD__)
-/* Thanks to John Brezak <brezak@ch.hp.com> for this code. */
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-
-getether(ifname, eap)
- char *ifname; /* interface name from ifconfig structure */
- char *eap; /* Ether address (output) */
-{
- int fd, rc = -1;
- register int n;
- struct ifreq ibuf[16], ifr;
- struct ifconf ifc;
- register struct ifreq *ifrp, *ifend;
-
- /* Fetch the interface configuration */
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- report(LOG_ERR, "getether: socket %s: %s", ifname, get_errmsg());
- return (fd);
- }
- ifc.ifc_len = sizeof(ibuf);
- ifc.ifc_buf = (caddr_t) ibuf;
- if (ioctl(fd, SIOCGIFCONF, (char *) &ifc) < 0 ||
- ifc.ifc_len < sizeof(struct ifreq)) {
- report(LOG_ERR, "getether: SIOCGIFCONF: %s", get_errmsg);
- goto out;
- }
- /* Search interface configuration list for link layer address. */
- ifrp = ibuf;
- ifend = (struct ifreq *) ((char *) ibuf + ifc.ifc_len);
- while (ifrp < ifend) {
- /* Look for interface */
- if (strcmp(ifname, ifrp->ifr_name) == 0 &&
- ifrp->ifr_addr.sa_family == AF_LINK &&
- ((struct sockaddr_dl *) &ifrp->ifr_addr)->sdl_type == IFT_ETHER) {
- bcopy(LLADDR((struct sockaddr_dl *) &ifrp->ifr_addr), eap, EALEN);
- rc = 0;
- break;
- }
- /* Bump interface config pointer */
- n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name);
- if (n < sizeof(*ifrp))
- n = sizeof(*ifrp);
- ifrp = (struct ifreq *) ((char *) ifrp + n);
- }
-
- out:
- close(fd);
- return (rc);
-}
-
-#define GETETHER
-#endif /* __NetBSD__ */
-
-
-#ifdef SVR4
-/*
- * This is for "Streams TCP/IP" by Lachman Associates.
- * They sure made this cumbersome! -gwr
- */
-
-#include <sys/sockio.h>
-#include <sys/dlpi.h>
-#include <stropts.h>
-#ifndef NULL
-#define NULL 0
-#endif
-
-getether(ifname, eap)
- char *ifname; /* interface name from ifconfig structure */
- char *eap; /* Ether address (output) */
-{
- int rc = -1;
- char devname[32];
- char tmpbuf[sizeof(union DL_primitives) + 16];
- struct strbuf cbuf;
- int fd, flags;
- union DL_primitives *dlp;
- char *enaddr;
- int unit = -1; /* which unit to attach */
-
- sprintf(devname, "/dev/%s", ifname);
- fd = open(devname, 2);
- if (fd < 0) {
- /* Try without the trailing digit. */
- char *p = devname + 5;
- while (isalpha(*p))
- p++;
- if (isdigit(*p)) {
- unit = *p - '0';
- *p = '\0';
- }
- fd = open(devname, 2);
- if (fd < 0) {
- report(LOG_ERR, "getether: open %s: %s",
- devname, get_errmsg());
- return rc;
- }
- }
-#ifdef DL_ATTACH_REQ
- /*
- * If this is a "Style 2" DLPI, then we must "attach" first
- * to tell the driver which unit (board, port) we want.
- * For now, decide this based on the device name.
- * (Should do "info_req" and check dl_provider_style ...)
- */
- if (unit >= 0) {
- memset(tmpbuf, 0, sizeof(tmpbuf));
- dlp = (union DL_primitives *) tmpbuf;
- dlp->dl_primitive = DL_ATTACH_REQ;
- dlp->attach_req.dl_ppa = unit;
- cbuf.buf = tmpbuf;
- cbuf.len = DL_ATTACH_REQ_SIZE;
- if (putmsg(fd, &cbuf, NULL, 0) < 0) {
- report(LOG_ERR, "getether: attach: putmsg: %s", get_errmsg());
- goto out;
- }
- /* Recv the ack. */
- cbuf.buf = tmpbuf;
- cbuf.maxlen = sizeof(tmpbuf);
- flags = 0;
- if (getmsg(fd, &cbuf, NULL, &flags) < 0) {
- report(LOG_ERR, "getether: attach: getmsg: %s", get_errmsg());
- goto out;
- }
- /*
- * Check the type, etc.
- */
- if (dlp->dl_primitive == DL_ERROR_ACK) {
- report(LOG_ERR, "getether: attach: dlpi_errno=%d, unix_errno=%d",
- dlp->error_ack.dl_errno,
- dlp->error_ack.dl_unix_errno);
- goto out;
- }
- if (dlp->dl_primitive != DL_OK_ACK) {
- report(LOG_ERR, "getether: attach: not OK or ERROR");
- goto out;
- }
- } /* unit >= 0 */
-#endif /* DL_ATTACH_REQ */
-
- /*
- * Get the Ethernet address the same way the ARP module
- * does when it is pushed onto a new stream (bind).
- * One should instead be able just do an dl_info_req
- * but many drivers do not supply the hardware address
- * in the response to dl_info_req (they MUST supply it
- * for dl_bind_ack because the ARP module requires it).
- */
- memset(tmpbuf, 0, sizeof(tmpbuf));
- dlp = (union DL_primitives *) tmpbuf;
- dlp->dl_primitive = DL_BIND_REQ;
- dlp->bind_req.dl_sap = 0x8FF; /* XXX - Unused SAP */
- cbuf.buf = tmpbuf;
- cbuf.len = DL_BIND_REQ_SIZE;
- if (putmsg(fd, &cbuf, NULL, 0) < 0) {
- report(LOG_ERR, "getether: bind: putmsg: %s", get_errmsg());
- goto out;
- }
- /* Recv the ack. */
- cbuf.buf = tmpbuf;
- cbuf.maxlen = sizeof(tmpbuf);
- flags = 0;
- if (getmsg(fd, &cbuf, NULL, &flags) < 0) {
- report(LOG_ERR, "getether: bind: getmsg: %s", get_errmsg());
- goto out;
- }
- /*
- * Check the type, etc.
- */
- if (dlp->dl_primitive == DL_ERROR_ACK) {
- report(LOG_ERR, "getether: bind: dlpi_errno=%d, unix_errno=%d",
- dlp->error_ack.dl_errno,
- dlp->error_ack.dl_unix_errno);
- goto out;
- }
- if (dlp->dl_primitive != DL_BIND_ACK) {
- report(LOG_ERR, "getether: bind: not OK or ERROR");
- goto out;
- }
- if (dlp->bind_ack.dl_addr_offset == 0) {
- report(LOG_ERR, "getether: bind: ack has no address");
- goto out;
- }
- if (dlp->bind_ack.dl_addr_length < EALEN) {
- report(LOG_ERR, "getether: bind: ack address truncated");
- goto out;
- }
- /*
- * Copy the Ethernet address out of the message.
- */
- enaddr = tmpbuf + dlp->bind_ack.dl_addr_offset;
- memcpy(eap, enaddr, EALEN);
- rc = 0;
-
- out:
- close(fd);
- return rc;
-}
-
-#define GETETHER
-#endif /* SVR4 */
-
-
-#ifdef linux
-/*
- * This is really easy on Linux! This version (for linux)
- * written by Nigel Metheringham <nigelm@ohm.york.ac.uk>
- *
- * The code is almost identical to the Ultrix code - however
- * the names are different to confuse the innocent :-)
- * Most of this code was stolen from the Ultrix bit above.
- */
-
-#include <sys/ioctl.h>
-#include <net/if.h> /* struct ifreq */
-
-/* In a properly configured system this should be either sys/socketio.h
- or sys/sockios.h, but on my distribution these don't line up correctly */
-#include <linux/sockios.h> /* Needed for IOCTL defs */
-
-getether(ifname, eap)
- char *ifname, *eap;
-{
- int rc = -1;
- int fd;
- struct ifreq phys;
- bzero(&phys, sizeof(phys));
- strcpy(phys.ifr_name, ifname);
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- report(LOG_ERR, "getether: socket(INET,DGRAM) failed");
- return -1;
- }
- if (ioctl(fd, SIOCGIFHWADDR, &phys) < 0) {
- report(LOG_ERR, "getether: ioctl SIOCGIFHWADDR failed");
- } else {
- bcopy(phys.ifr_hwaddr, eap, EALEN);
- rc = 0;
- }
- close(fd);
- return rc;
-}
-
-#define GETETHER
-#endif /* linux */
-
-
-/* If we don't know how on this system, just return an error. */
-#ifndef GETETHER
-getether(ifname, eap)
- char *ifname, *eap;
-{
- return -1;
-}
-
-#endif /* !GETETHER */
-
-/*
- * Local Variables:
- * tab-width: 4
- * c-indent-level: 4
- * c-argdecl-indent: 4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: -4
- * c-label-offset: -4
- * c-brace-offset: 0
- * End:
- */
diff --git a/usr.sbin/bootpd/hwaddr.c b/usr.sbin/bootpd/hwaddr.c
deleted file mode 100644
index 840b95333567..000000000000
--- a/usr.sbin/bootpd/hwaddr.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * hwaddr.c - routines that deal with hardware addresses.
- * (i.e. Ethernet)
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-
-#if defined(SUNOS) || defined(SVR4)
-#include <sys/sockio.h>
-#endif
-#ifdef SVR4
-#include <sys/stream.h>
-#include <stropts.h>
-#include <fcntl.h>
-#endif
-
-#include <net/if_arp.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#ifndef NO_UNISTD
-#include <unistd.h>
-#endif
-#include <syslog.h>
-
-#ifndef USE_BFUNCS
-/* Yes, memcpy is OK here (no overlapped copies). */
-#include <memory.h>
-#define bcopy(a,b,c) memcpy(b,a,c)
-#define bzero(p,l) memset(p,0,l)
-#define bcmp(a,b,c) memcmp(a,b,c)
-#endif
-
-/* For BSD 4.4, set arp entry by writing to routing socket */
-#if defined(BSD)
-#if BSD >= 199306
-extern int bsd_arp_set __P((struct in_addr *, char *, int));
-#endif
-#endif
-
-#include "bptypes.h"
-#include "hwaddr.h"
-#include "report.h"
-
-extern int debug;
-
-/*
- * Hardware address lengths (in bytes) and network name based on hardware
- * type code. List in order specified by Assigned Numbers RFC; Array index
- * is hardware type code. Entries marked as zero are unknown to the author
- * at this time. . . .
- */
-
-struct hwinfo hwinfolist[] =
-{
- {0, "Reserved"}, /* Type 0: Reserved (don't use this) */
- {6, "Ethernet"}, /* Type 1: 10Mb Ethernet (48 bits) */
- {1, "3Mb Ethernet"}, /* Type 2: 3Mb Ethernet (8 bits) */
- {0, "AX.25"}, /* Type 3: Amateur Radio AX.25 */
- {1, "ProNET"}, /* Type 4: Proteon ProNET Token Ring */
- {0, "Chaos"}, /* Type 5: Chaos */
- {6, "IEEE 802"}, /* Type 6: IEEE 802 Networks */
- {0, "ARCNET"} /* Type 7: ARCNET */
-};
-int hwinfocnt = sizeof(hwinfolist) / sizeof(hwinfolist[0]);
-
-
-/*
- * Setup the arp cache so that IP address 'ia' will be temporarily
- * bound to hardware address 'ha' of length 'len'.
- */
-void
-setarp(s, ia, ha, len)
- int s; /* socket fd */
- struct in_addr *ia;
- u_char *ha;
- int len;
-{
-#ifdef SIOCSARP
- struct arpreq arpreq; /* Arp request ioctl block */
- struct sockaddr_in *si;
-#ifdef SVR4
- int fd;
- struct strioctl iocb;
-#endif /* SVR4 */
-
- bzero((caddr_t) & arpreq, sizeof(arpreq));
- arpreq.arp_flags = ATF_INUSE | ATF_COM;
-
- /* Set up the protocol address. */
- arpreq.arp_pa.sa_family = AF_INET;
- si = (struct sockaddr_in *) &arpreq.arp_pa;
- si->sin_addr = *ia;
-
- /* Set up the hardware address. */
- bcopy(ha, arpreq.arp_ha.sa_data, len);
-
-#ifdef SVR4
- /*
- * And now the stuff for System V Rel 4.x which does not
- * appear to allow SIOCxxx ioctls on a socket descriptor.
- * Thanks to several people: (all sent the same fix)
- * Barney Wolff <barney@databus.com>,
- * bear@upsys.se (Bj|rn Sj|holm),
- * Michael Kuschke <Michael.Kuschke@Materna.DE>,
- */
- if ((fd=open("/dev/arp", O_RDWR)) < 0) {
- report(LOG_ERR, "open /dev/arp: %s\n", get_errmsg());
- }
- iocb.ic_cmd = SIOCSARP;
- iocb.ic_timout = 0;
- iocb.ic_dp = (char *)&arpreq;
- iocb.ic_len = sizeof(arpreq);
- if (ioctl(fd, I_STR, (caddr_t)&iocb) < 0) {
- report(LOG_ERR, "ioctl I_STR: %s\n", get_errmsg());
- }
- close (fd);
-
-#else /* SVR4 */
- /*
- * On SunOS, the ioctl sometimes returns ENXIO, and it
- * appears to happen when the ARP cache entry you tried
- * to add is already in the cache. (Sigh...)
- * XXX - Should this error simply be ignored? -gwr
- */
- if (ioctl(s, SIOCSARP, (caddr_t) & arpreq) < 0) {
- report(LOG_ERR, "ioctl SIOCSARP: %s", get_errmsg());
- }
-#endif /* SVR4 */
-#else /* SIOCSARP */
-#if defined(BSD) && (BSD >= 199306)
- bsd_arp_set(ia, ha, len);
-#else /* Not BSD 4.4, and SIOCSARP not defined */
- /*
- * Oh well, SIOCSARP is not defined. Just run arp(8).
- * XXX - Gag!
- */
- char buf[256];
- int status;
-
- sprintf(buf, "arp -s %s %s temp",
- inet_ntoa(*ia), haddrtoa(ha, len));
- if (debug > 2)
- report(LOG_INFO, buf);
- status = system(buf);
- if (status)
- report(LOG_ERR, "arp failed, exit code=0x%x", status);
- return;
-#endif /* ! 4.4 BSD */
-#endif /* SIOCSARP */
-}
-
-
-/*
- * Convert a hardware address to an ASCII string.
- */
-char *
-haddrtoa(haddr, hlen)
- u_char *haddr;
- int hlen;
-{
- static char haddrbuf[3 * MAXHADDRLEN + 1];
- char *bufptr;
-
- if (hlen > MAXHADDRLEN)
- hlen = MAXHADDRLEN;
-
- bufptr = haddrbuf;
- while (hlen > 0) {
- sprintf(bufptr, "%02X:", (unsigned) (*haddr++ & 0xFF));
- bufptr += 3;
- hlen--;
- }
- bufptr[-1] = 0;
- return (haddrbuf);
-}
-
-
-/*
- * haddr_conv802()
- * --------------
- *
- * Converts a backwards address to a canonical address and a canonical address
- * to a backwards address.
- *
- * INPUTS:
- * adr_in - pointer to six byte string to convert (unsigned char *)
- * addr_len - how many bytes to convert
- *
- * OUTPUTS:
- * addr_out - The string is updated to contain the converted address.
- *
- * CALLER:
- * many
- *
- * DATA:
- * Uses conv802table to bit-reverse the address bytes.
- */
-
-static u_char conv802table[256] =
-{
- /* 0x00 */ 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
- /* 0x08 */ 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
- /* 0x10 */ 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
- /* 0x18 */ 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
- /* 0x20 */ 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
- /* 0x28 */ 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
- /* 0x30 */ 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
- /* 0x38 */ 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
- /* 0x40 */ 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
- /* 0x48 */ 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
- /* 0x50 */ 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
- /* 0x58 */ 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
- /* 0x60 */ 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
- /* 0x68 */ 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
- /* 0x70 */ 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
- /* 0x78 */ 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
- /* 0x80 */ 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
- /* 0x88 */ 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
- /* 0x90 */ 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
- /* 0x98 */ 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
- /* 0xA0 */ 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
- /* 0xA8 */ 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
- /* 0xB0 */ 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
- /* 0xB8 */ 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
- /* 0xC0 */ 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
- /* 0xC8 */ 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
- /* 0xD0 */ 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
- /* 0xD8 */ 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
- /* 0xE0 */ 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
- /* 0xE8 */ 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
- /* 0xF0 */ 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
- /* 0xF8 */ 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF,
-};
-
-void
-haddr_conv802(addr_in, addr_out, len)
- register u_char *addr_in, *addr_out;
- int len;
-{
- u_char *lim;
-
- lim = addr_out + len;
- while (addr_out < lim)
- *addr_out++ = conv802table[*addr_in++];
-}
-
-#if 0
-/*
- * For the record, here is a program to generate the
- * bit-reverse table above.
- */
-static int
-bitrev(n)
- int n;
-{
- int i, r;
-
- r = 0;
- for (i = 0; i < 8; i++) {
- r <<= 1;
- r |= (n & 1);
- n >>= 1;
- }
- return r;
-}
-
-main()
-{
- int i;
- for (i = 0; i <= 0xFF; i++) {
- if ((i & 7) == 0)
- printf("/* 0x%02X */", i);
- printf(" 0x%02X,", bitrev(i));
- if ((i & 7) == 7)
- printf("\n");
- }
-}
-
-#endif
-
-/*
- * Local Variables:
- * tab-width: 4
- * c-indent-level: 4
- * c-argdecl-indent: 4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: -4
- * c-label-offset: -4
- * c-brace-offset: 0
- * End:
- */
diff --git a/usr.sbin/bootpd/rtmsg.c b/usr.sbin/bootpd/rtmsg.c
deleted file mode 100644
index 6de610271f48..000000000000
--- a/usr.sbin/bootpd/rtmsg.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 1984, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1994
- * Geoffrey M. Rehmet, All rights reserved.
- *
- * This code is derived from software which forms part of the 4.4-Lite
- * Berkeley software distribution, which was in derived from software
- * contributed to Berkeley by Sun Microsystems, Inc.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- */
-
-/*
- * from arp.c 8.2 (Berkeley) 1/2/94
- * $Id$
- */
-
-#include <sys/param.h>
-/*
- * Verify that we are at least 4.4 BSD
- */
-#if defined(BSD)
-#if BSD >= 199306
-
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#include "report.h"
-
-
-static int rtmsg __P((int));
-
-static int s = -1; /* routing socket */
-
-
-/*
- * Open the routing socket
- */
-static void getsocket () {
- if (s < 0) {
- s = socket(PF_ROUTE, SOCK_RAW, 0);
- if (s < 0) {
- report(LOG_ERR, "socket %s", strerror(errno));
- exit(1);
- }
- }
-}
-
-static struct sockaddr_in so_mask = {8, 0, 0, { 0xffffffff}};
-static struct sockaddr_inarp blank_sin = {sizeof(blank_sin), AF_INET }, sin_m;
-static struct sockaddr_dl blank_sdl = {sizeof(blank_sdl), AF_LINK }, sdl_m;
-static int expire_time, flags, export_only, doing_proxy;
-static struct {
- struct rt_msghdr m_rtm;
- char m_space[512];
-} m_rtmsg;
-
-/*
- * Set an individual arp entry
- */
-int bsd_arp_set(ia, eaddr, len)
- struct in_addr *ia;
- char *eaddr;
- int len;
-{
- register struct sockaddr_inarp *sin = &sin_m;
- register struct sockaddr_dl *sdl;
- register struct rt_msghdr *rtm = &(m_rtmsg.m_rtm);
- u_char *ea;
- struct timeval time;
-
- getsocket();
- sdl_m = blank_sdl;
- sin_m = blank_sin;
- sin->sin_addr = *ia;
-
- ea = (u_char *)LLADDR(&sdl_m);
- bcopy(eaddr, ea, len);
- sdl_m.sdl_alen = len;
- doing_proxy = flags = export_only = expire_time = 0;
-
- /* make arp entry temporary */
- gettimeofday(&time, 0);
- expire_time = time.tv_sec + 20 * 60;
-
-tryagain:
- if (rtmsg(RTM_GET) < 0) {
- report(LOG_WARNING, "rtmget: %s", strerror(errno));
- return (1);
- }
- sin = (struct sockaddr_inarp *)(rtm + 1);
- sdl = (struct sockaddr_dl *)(sin->sin_len + (char *)sin);
- if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
- if (sdl->sdl_family == AF_LINK &&
- (rtm->rtm_flags & RTF_LLINFO) &&
- !(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) {
- case IFT_ETHER: case IFT_FDDI: case IFT_ISO88023:
- case IFT_ISO88024: case IFT_ISO88025:
- goto overwrite;
- }
- if (doing_proxy == 0) {
- report(LOG_WARNING, "set: can only proxy for %s\n",
- inet_ntoa(sin->sin_addr));
- return (1);
- }
- if (sin_m.sin_other & SIN_PROXY) {
- report(LOG_WARNING,
- "set: proxy entry exists for non 802 device\n");
- return(1);
- }
- sin_m.sin_other = SIN_PROXY;
- export_only = 1;
- goto tryagain;
- }
-overwrite:
- if (sdl->sdl_family != AF_LINK) {
- report(LOG_WARNING,
- "cannot intuit interface index and type for %s\n",
- inet_ntoa(sin->sin_addr));
- return (1);
- }
- sdl_m.sdl_type = sdl->sdl_type;
- sdl_m.sdl_index = sdl->sdl_index;
- return (rtmsg(RTM_ADD));
-}
-
-
-static int rtmsg(cmd)
- int cmd;
-{
- static int seq;
- int rlen;
- register struct rt_msghdr *rtm = &m_rtmsg.m_rtm;
- register char *cp = m_rtmsg.m_space;
- register int l;
-
- errno = 0;
- bzero((char *)&m_rtmsg, sizeof(m_rtmsg));
- rtm->rtm_flags = flags;
- rtm->rtm_version = RTM_VERSION;
-
- switch (cmd) {
- default:
- report(LOG_ERR, "set_arp: internal wrong cmd - exiting");
- exit(1);
- case RTM_ADD:
- rtm->rtm_addrs |= RTA_GATEWAY;
- rtm->rtm_rmx.rmx_expire = expire_time;
- rtm->rtm_inits = RTV_EXPIRE;
- rtm->rtm_flags |= (RTF_HOST | RTF_STATIC);
- sin_m.sin_other = 0;
- if (doing_proxy) {
- if (export_only)
- sin_m.sin_other = SIN_PROXY;
- else {
- rtm->rtm_addrs |= RTA_NETMASK;
- rtm->rtm_flags &= ~RTF_HOST;
- }
- }
- /* FALLTHROUGH */
- case RTM_GET:
- rtm->rtm_addrs |= RTA_DST;
- }
-#define NEXTADDR(w, s) \
- if (rtm->rtm_addrs & (w)) { \
- bcopy((char *)&s, cp, sizeof(s)); cp += sizeof(s);}
-
- NEXTADDR(RTA_DST, sin_m);
- NEXTADDR(RTA_GATEWAY, sdl_m);
- NEXTADDR(RTA_NETMASK, so_mask);
-
- rtm->rtm_msglen = cp - (char *)&m_rtmsg;
-
- l = rtm->rtm_msglen;
- rtm->rtm_seq = ++seq;
- rtm->rtm_type = cmd;
- if ((rlen = write(s, (char *)&m_rtmsg, l)) < 0) {
- if ((errno != ESRCH) && !(errno == EEXIST && cmd == RTM_ADD)){
- report(LOG_WARNING, "writing to routing socket: %s",
- strerror(errno));
- return (-1);
- }
- }
- do {
- l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
- } while (l > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != getpid()));
- if (l < 0)
- report(LOG_WARNING, "arp: read from routing socket: %s\n",
- strerror(errno));
- return (0);
-}
-
-#endif /* BSD */
-#endif /* BSD >= 199306 */