sync with OpenBSD -current
This commit is contained in:
parent
1093aeaee4
commit
f5750f4f6e
42 changed files with 42 additions and 9497 deletions
|
@ -54,7 +54,6 @@
|
||||||
./etc/examples/acme-client.conf
|
./etc/examples/acme-client.conf
|
||||||
./etc/examples/bgpd.conf
|
./etc/examples/bgpd.conf
|
||||||
./etc/examples/chio.conf
|
./etc/examples/chio.conf
|
||||||
./etc/examples/dhclient.conf
|
|
||||||
./etc/examples/dhcpd.conf
|
./etc/examples/dhcpd.conf
|
||||||
./etc/examples/doas.conf
|
./etc/examples/doas.conf
|
||||||
./etc/examples/dvmrpd.conf
|
./etc/examples/dvmrpd.conf
|
||||||
|
@ -329,7 +328,6 @@
|
||||||
./sbin/bioctl
|
./sbin/bioctl
|
||||||
./sbin/chown
|
./sbin/chown
|
||||||
./sbin/clri
|
./sbin/clri
|
||||||
./sbin/dhclient
|
|
||||||
./sbin/dhcp6leased
|
./sbin/dhcp6leased
|
||||||
./sbin/dhcpleased
|
./sbin/dhcpleased
|
||||||
./sbin/disklabel
|
./sbin/disklabel
|
||||||
|
|
|
@ -2233,8 +2233,6 @@
|
||||||
./usr/share/man/man5/crontab.5
|
./usr/share/man/man5/crontab.5
|
||||||
./usr/share/man/man5/cvs.5
|
./usr/share/man/man5/cvs.5
|
||||||
./usr/share/man/man5/defaultdomain.5
|
./usr/share/man/man5/defaultdomain.5
|
||||||
./usr/share/man/man5/dhclient.conf.5
|
|
||||||
./usr/share/man/man5/dhclient.leases.5
|
|
||||||
./usr/share/man/man5/dhcp-options.5
|
./usr/share/man/man5/dhcp-options.5
|
||||||
./usr/share/man/man5/dhcp6leased.conf.5
|
./usr/share/man/man5/dhcp6leased.conf.5
|
||||||
./usr/share/man/man5/dhcpd.conf.5
|
./usr/share/man/man5/dhcpd.conf.5
|
||||||
|
@ -2436,7 +2434,6 @@
|
||||||
./usr/share/man/man8/cvsbug.8
|
./usr/share/man/man8/cvsbug.8
|
||||||
./usr/share/man/man8/daily.8
|
./usr/share/man/man8/daily.8
|
||||||
./usr/share/man/man8/dev_mkdb.8
|
./usr/share/man/man8/dev_mkdb.8
|
||||||
./usr/share/man/man8/dhclient.8
|
|
||||||
./usr/share/man/man8/dhcp6leasectl.8
|
./usr/share/man/man8/dhcp6leasectl.8
|
||||||
./usr/share/man/man8/dhcp6leased.8
|
./usr/share/man/man8/dhcp6leased.8
|
||||||
./usr/share/man/man8/dhcpd.8
|
./usr/share/man/man8/dhcpd.8
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# $OpenBSD: Makefile,v 1.9 2018/06/25 16:29:00 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.10 2024/06/30 18:17:07 deraadt Exp $
|
||||||
|
|
||||||
PROG= gzip
|
PROG= gzip
|
||||||
SRCS= main.c gzopen.c
|
SRCS= main.c gzopen.c
|
||||||
SRCS+= adler32.c crc32.c inflate.c inftrees.c zutil.c
|
SRCS+= adler32.c crc32.c inflate.c inftrees.c zutil.c
|
||||||
COPTS+= -DSMALL -DDYNAMIC_CRC_TABLE -DNOBYFOUR -DNO_GZIP -DSLOW
|
COPTS+= -DSMALL -DDYNAMIC_CRC_TABLE -DNO_GZIP -DSLOW
|
||||||
.PATH: ${.CURDIR}/../../../usr.bin/compress
|
.PATH: ${.CURDIR}/../../../usr.bin/compress
|
||||||
.PATH: ${.CURDIR}/../../../lib/libz
|
.PATH: ${.CURDIR}/../../../lib/libz
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.489 2024/06/03 10:06:35 florian Exp $
|
# $OpenBSD: Makefile,v 1.490 2024/06/30 17:30:54 deraadt Exp $
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ MUTABLE=changelist daily etc.${MACHINE}/disktab \
|
||||||
pf.os protocols rc rc.conf rpc services shells syslog.conf weekly
|
pf.os protocols rc rc.conf rpc services shells syslog.conf weekly
|
||||||
|
|
||||||
# -rw-r--r--
|
# -rw-r--r--
|
||||||
EXAMPLES=acme-client.conf chio.conf dhclient.conf dhcpd.conf exports \
|
EXAMPLES=acme-client.conf chio.conf dhcpd.conf exports \
|
||||||
httpd.conf ifstated.conf inetd.conf man.conf mixerctl.conf \
|
httpd.conf ifstated.conf inetd.conf man.conf mixerctl.conf \
|
||||||
mrouted.conf ntpd.conf printcap rad.conf rbootd.conf \
|
mrouted.conf ntpd.conf printcap rad.conf rbootd.conf \
|
||||||
remote sensorsd.conf wsconsctl.conf
|
remote sensorsd.conf wsconsctl.conf
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# $OpenBSD: dhclient.conf,v 1.2 2017/10/16 23:43:41 krw Exp $
|
|
||||||
#
|
|
||||||
# DHCP Client Configuration
|
|
||||||
#
|
|
||||||
# See dhclient.conf(5) for possible contents of this file.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# send dhcp-lease-time 3600;
|
|
||||||
# send host-name "myhost";
|
|
||||||
# supersede host-name "myhost";
|
|
||||||
# supersede domain-name "my.domain";
|
|
||||||
# request subnet-mask, broadcast-address, time-offset, routers,
|
|
||||||
# domain-name, domain-name-servers, host-name, lpr-servers, ntp-servers;
|
|
||||||
# require subnet-mask, domain-name-servers, routers;
|
|
|
@ -1 +1 @@
|
||||||
# SecBSD 1.5-c5d0954: Mon Jun 10 00:00:00 UTC 2024 (Yatagarasu)
|
# SecBSD 1.5-d2504b0: Mon Jul 1 00:00:00 UTC 2024 (Yatagarasu)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: times.3,v 1.16 2022/09/11 06:38:10 jmc Exp $
|
.\" $OpenBSD: times.3,v 1.17 2024/07/01 00:05:43 jsg Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1990, 1991, 1993
|
.\" Copyright (c) 1990, 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: September 11 2022 $
|
.Dd $Mdocdate: July 1 2024 $
|
||||||
.Dt TIMES 3
|
.Dt TIMES 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -142,11 +142,3 @@ A
|
||||||
.Fn times
|
.Fn times
|
||||||
function first appeared in
|
function first appeared in
|
||||||
.At v3 .
|
.At v3 .
|
||||||
The tms structure first appeared in
|
|
||||||
.Bx 4.0
|
|
||||||
and was changed to use
|
|
||||||
.Vt clock_t
|
|
||||||
instead of
|
|
||||||
.Vt time_t
|
|
||||||
for its members in
|
|
||||||
.Bx 4.3 Net/2 .
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# $OpenBSD: Makefile,v 1.111 2024/06/03 10:05:18 florian Exp $
|
# $OpenBSD: Makefile,v 1.112 2024/06/30 17:30:54 deraadt Exp $
|
||||||
|
|
||||||
SUBDIR= atactl badsect bioctl clri dhclient dhcp6leased dhcpleased \
|
SUBDIR= atactl badsect bioctl clri dhcp6leased dhcpleased \
|
||||||
disklabel dmesg dump dumpfs fdisk fsck fsck_ext2fs fsck_ffs \
|
disklabel dmesg dump dumpfs fdisk fsck fsck_ext2fs fsck_ffs \
|
||||||
fsck_msdos fsdb fsirand growfs ifconfig iked init ipsecctl \
|
fsck_msdos fsdb fsirand growfs ifconfig iked init ipsecctl \
|
||||||
isakmpd kbd ldattach mknod mount \
|
isakmpd kbd ldattach mknod mount \
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
# $OpenBSD: Makefile,v 1.20 2017/07/08 20:38:31 krw Exp $
|
|
||||||
#
|
|
||||||
# Copyright (c) 1996, 1997 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.
|
|
||||||
#
|
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
|
||||||
|
|
||||||
SRCS= dhclient.c clparse.c dispatch.c bpf.c options.c \
|
|
||||||
conflex.c log.c packet.c \
|
|
||||||
parse.c privsep.c kroute.c
|
|
||||||
|
|
||||||
PROG= dhclient
|
|
||||||
LDADD+= -lutil
|
|
||||||
DPADD+= ${LIBUTIL}
|
|
||||||
MAN= dhclient.8 dhclient.conf.5 dhclient.leases.5
|
|
||||||
|
|
||||||
CFLAGS+=-Wall
|
|
||||||
CFLAGS+=-Wstrict-prototypes -Wmissing-prototypes
|
|
||||||
CFLAGS+=-Wmissing-declarations
|
|
||||||
CFLAGS+=-Wshadow -Wpointer-arith -Wcast-qual
|
|
||||||
CFLAGS+=-Wsign-compare
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,401 +0,0 @@
|
||||||
/* $OpenBSD: bpf.c,v 1.75 2019/03/18 00:00:59 dlg Exp $ */
|
|
||||||
|
|
||||||
/* BPF socket interface code, originally contributed by Archie Cobbs. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999
|
|
||||||
* The Internet Software Consortium. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <net/bpf.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/udp.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
get_bpf_sock(char *name)
|
|
||||||
{
|
|
||||||
struct ifreq ifr;
|
|
||||||
int sock;
|
|
||||||
|
|
||||||
if ((sock = open("/dev/bpf", O_RDWR | O_CLOEXEC)) == -1)
|
|
||||||
fatal("open(/dev/bpf)");
|
|
||||||
|
|
||||||
/* Set the BPF device to point at this interface. */
|
|
||||||
strlcpy(ifr.ifr_name, name, IFNAMSIZ);
|
|
||||||
if (ioctl(sock, BIOCSETIF, &ifr) == -1)
|
|
||||||
fatal("BIOCSETIF");
|
|
||||||
|
|
||||||
return sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
get_udp_sock(int rdomain)
|
|
||||||
{
|
|
||||||
int sock, on = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use raw socket for unicast send.
|
|
||||||
*/
|
|
||||||
if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) == -1)
|
|
||||||
fatal("socket(AF_INET, SOCK_RAW)");
|
|
||||||
if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &on,
|
|
||||||
sizeof(on)) == -1)
|
|
||||||
fatal("setsockopt(IP_HDRINCL)");
|
|
||||||
if (setsockopt(sock, IPPROTO_IP, SO_RTABLE, &rdomain,
|
|
||||||
sizeof(rdomain)) == -1)
|
|
||||||
fatal("setsockopt(SO_RTABLE)");
|
|
||||||
|
|
||||||
return sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Packet filter program.
|
|
||||||
*
|
|
||||||
* N.B.: Changes to the filter program may require changes to the
|
|
||||||
* constant offsets used in if_register_receive to patch the BPF program!
|
|
||||||
*/
|
|
||||||
struct bpf_insn dhcp_bpf_filter[] = {
|
|
||||||
/* Make sure this is an IP packet. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
|
|
||||||
|
|
||||||
/* Make sure it's a UDP packet. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 23),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 6),
|
|
||||||
|
|
||||||
/* Make sure this isn't a fragment. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 4, 0),
|
|
||||||
|
|
||||||
/* Get the IP header length. */
|
|
||||||
BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14),
|
|
||||||
|
|
||||||
/* Make sure it's to the right port. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */
|
|
||||||
|
|
||||||
/* If we passed all the tests, ask for the whole packet. */
|
|
||||||
BPF_STMT(BPF_RET+BPF_K, (unsigned int)-1),
|
|
||||||
|
|
||||||
/* Otherwise, drop it. */
|
|
||||||
BPF_STMT(BPF_RET+BPF_K, 0),
|
|
||||||
};
|
|
||||||
|
|
||||||
int dhcp_bpf_filter_len = sizeof(dhcp_bpf_filter) / sizeof(struct bpf_insn);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Packet write filter program:
|
|
||||||
* 'ip and udp and src port bootps and dst port (bootps or bootpc)'
|
|
||||||
*/
|
|
||||||
struct bpf_insn dhcp_bpf_wfilter[] = {
|
|
||||||
BPF_STMT(BPF_LD + BPF_B + BPF_IND, 14),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (IPVERSION << 4) + 5, 0, 12),
|
|
||||||
|
|
||||||
/* Make sure this is an IP packet. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 10),
|
|
||||||
|
|
||||||
/* Make sure it's a UDP packet. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 23),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 8),
|
|
||||||
|
|
||||||
/* Make sure this isn't a fragment. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 20),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JSET + BPF_K, 0x1fff, 6, 0), /* patched */
|
|
||||||
|
|
||||||
/* Get the IP header length. */
|
|
||||||
BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14),
|
|
||||||
|
|
||||||
/* Make sure it's from the right port. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 14),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 68, 0, 3),
|
|
||||||
|
|
||||||
/* Make sure it is to the right ports. */
|
|
||||||
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16),
|
|
||||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1),
|
|
||||||
|
|
||||||
/* If we passed all the tests, ask for the whole packet. */
|
|
||||||
BPF_STMT(BPF_RET+BPF_K, (unsigned int)-1),
|
|
||||||
|
|
||||||
/* Otherwise, drop it. */
|
|
||||||
BPF_STMT(BPF_RET+BPF_K, 0),
|
|
||||||
};
|
|
||||||
|
|
||||||
int dhcp_bpf_wfilter_len = sizeof(dhcp_bpf_wfilter) / sizeof(struct bpf_insn);
|
|
||||||
|
|
||||||
int
|
|
||||||
configure_bpf_sock(int bpffd)
|
|
||||||
{
|
|
||||||
struct bpf_version v;
|
|
||||||
struct bpf_program p;
|
|
||||||
int flag = 1, sz;
|
|
||||||
int fildrop = BPF_FILDROP_CAPTURE;
|
|
||||||
|
|
||||||
/* Make sure the BPF version is in range. */
|
|
||||||
if (ioctl(bpffd, BIOCVERSION, &v) == -1)
|
|
||||||
fatal("BIOCVERSION");
|
|
||||||
|
|
||||||
if (v.bv_major != BPF_MAJOR_VERSION ||
|
|
||||||
v.bv_minor < BPF_MINOR_VERSION)
|
|
||||||
fatalx("kernel BPF version out of range - recompile "
|
|
||||||
"dhclient");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set immediate mode so that reads return as soon as a packet
|
|
||||||
* comes in, rather than waiting for the input buffer to fill
|
|
||||||
* with packets.
|
|
||||||
*/
|
|
||||||
if (ioctl(bpffd, BIOCIMMEDIATE, &flag) == -1)
|
|
||||||
fatal("BIOCIMMEDIATE");
|
|
||||||
|
|
||||||
if (ioctl(bpffd, BIOCSFILDROP, &fildrop) == -1)
|
|
||||||
fatal("BIOCSFILDROP");
|
|
||||||
|
|
||||||
/* Get the required BPF buffer length from the kernel. */
|
|
||||||
if (ioctl(bpffd, BIOCGBLEN, &sz) == -1)
|
|
||||||
fatal("BIOCGBLEN");
|
|
||||||
|
|
||||||
/* Set up the bpf filter program structure. */
|
|
||||||
p.bf_len = dhcp_bpf_filter_len;
|
|
||||||
p.bf_insns = dhcp_bpf_filter;
|
|
||||||
|
|
||||||
/* Patch the server port into the BPF program.
|
|
||||||
*
|
|
||||||
* N.B.: changes to filter program may require changes to the
|
|
||||||
* insn number(s) used below!
|
|
||||||
*/
|
|
||||||
dhcp_bpf_filter[8].k = LOCAL_PORT;
|
|
||||||
|
|
||||||
if (ioctl(bpffd, BIOCSETF, &p) == -1)
|
|
||||||
fatal("BIOCSETF");
|
|
||||||
|
|
||||||
/* Set up the bpf write filter program structure. */
|
|
||||||
p.bf_len = dhcp_bpf_wfilter_len;
|
|
||||||
p.bf_insns = dhcp_bpf_wfilter;
|
|
||||||
|
|
||||||
if (dhcp_bpf_wfilter[7].k == 0x1fff)
|
|
||||||
dhcp_bpf_wfilter[7].k = htons(IP_MF|IP_OFFMASK);
|
|
||||||
|
|
||||||
if (ioctl(bpffd, BIOCSETWF, &p) == -1)
|
|
||||||
fatal("BIOCSETWF");
|
|
||||||
|
|
||||||
if (ioctl(bpffd, BIOCLOCK, NULL) == -1)
|
|
||||||
fatal("BIOCLOCK");
|
|
||||||
|
|
||||||
return sz;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t
|
|
||||||
send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to,
|
|
||||||
const char *desc)
|
|
||||||
{
|
|
||||||
struct iovec iov[4];
|
|
||||||
struct sockaddr_in dest;
|
|
||||||
struct ether_header eh;
|
|
||||||
struct ip ip;
|
|
||||||
struct udphdr udp;
|
|
||||||
struct msghdr msg;
|
|
||||||
struct dhcp_packet *packet = &ifi->sent_packet;
|
|
||||||
ssize_t result, total;
|
|
||||||
unsigned int iovcnt = 0, i;
|
|
||||||
int len = ifi->sent_packet_length;
|
|
||||||
|
|
||||||
memset(&dest, 0, sizeof(dest));
|
|
||||||
dest.sin_family = AF_INET;
|
|
||||||
dest.sin_port = htons(REMOTE_PORT);
|
|
||||||
dest.sin_addr.s_addr = to.s_addr;
|
|
||||||
|
|
||||||
if (to.s_addr == INADDR_BROADCAST) {
|
|
||||||
assemble_eh_header(ifi->hw_address, &eh);
|
|
||||||
iov[0].iov_base = &eh;
|
|
||||||
iov[0].iov_len = sizeof(eh);
|
|
||||||
iovcnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ip.ip_v = 4;
|
|
||||||
ip.ip_hl = 5;
|
|
||||||
ip.ip_tos = IPTOS_LOWDELAY;
|
|
||||||
ip.ip_len = htons(sizeof(ip) + sizeof(udp) + len);
|
|
||||||
ip.ip_id = 0;
|
|
||||||
ip.ip_off = 0;
|
|
||||||
ip.ip_ttl = 128;
|
|
||||||
ip.ip_p = IPPROTO_UDP;
|
|
||||||
ip.ip_sum = 0;
|
|
||||||
ip.ip_src.s_addr = from.s_addr;
|
|
||||||
ip.ip_dst.s_addr = to.s_addr;
|
|
||||||
ip.ip_sum = wrapsum(checksum((unsigned char *)&ip, sizeof(ip), 0));
|
|
||||||
iov[iovcnt].iov_base = &ip;
|
|
||||||
iov[iovcnt].iov_len = sizeof(ip);
|
|
||||||
iovcnt++;
|
|
||||||
|
|
||||||
udp.uh_sport = htons(LOCAL_PORT);
|
|
||||||
udp.uh_dport = htons(REMOTE_PORT);
|
|
||||||
udp.uh_ulen = htons(sizeof(udp) + len);
|
|
||||||
udp.uh_sum = 0;
|
|
||||||
udp.uh_sum = wrapsum(checksum((unsigned char *)&udp, sizeof(udp),
|
|
||||||
checksum((unsigned char *)packet, len,
|
|
||||||
checksum((unsigned char *)&ip.ip_src,
|
|
||||||
2 * sizeof(ip.ip_src),
|
|
||||||
IPPROTO_UDP + (uint32_t)ntohs(udp.uh_ulen)))));
|
|
||||||
iov[iovcnt].iov_base = &udp;
|
|
||||||
iov[iovcnt].iov_len = sizeof(udp);
|
|
||||||
iovcnt++;
|
|
||||||
|
|
||||||
iov[iovcnt].iov_base = packet;
|
|
||||||
iov[iovcnt].iov_len = len;
|
|
||||||
iovcnt++;
|
|
||||||
|
|
||||||
total = 0;
|
|
||||||
for (i = 0; i < iovcnt; i++)
|
|
||||||
total += iov[i].iov_len;
|
|
||||||
|
|
||||||
if (to.s_addr == INADDR_BROADCAST) {
|
|
||||||
result = writev(ifi->bpffd, iov, iovcnt);
|
|
||||||
if (result == -1)
|
|
||||||
log_warn("%s: writev(%s)", log_procname, desc);
|
|
||||||
else if (result < total) {
|
|
||||||
log_warnx("%s, writev(%s): %zd of %zd bytes",
|
|
||||||
log_procname, desc, result, total);
|
|
||||||
result = -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
|
||||||
msg.msg_name = (struct sockaddr *)&dest;
|
|
||||||
msg.msg_namelen = sizeof(dest);
|
|
||||||
msg.msg_iov = iov;
|
|
||||||
msg.msg_iovlen = iovcnt;
|
|
||||||
result = sendmsg(ifi->udpfd, &msg, 0);
|
|
||||||
if (result == -1)
|
|
||||||
log_warn("%s: sendmsg(%s)", log_procname, desc);
|
|
||||||
else if (result < total) {
|
|
||||||
result = -1;
|
|
||||||
log_warnx("%s, sendmsg(%s): %zd of %zd bytes",
|
|
||||||
log_procname, desc, result, total);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extract a DHCP packet from a bpf capture buffer.
|
|
||||||
*
|
|
||||||
* Each captured packet is
|
|
||||||
*
|
|
||||||
* <BPF header>
|
|
||||||
* <padding to BPF_WORDALIGN>
|
|
||||||
* <captured DHCP packet>
|
|
||||||
* <padding to BPF_WORDALIGN>
|
|
||||||
*
|
|
||||||
* Return the number of bytes processed or 0 if there is
|
|
||||||
* no valid DHCP packet in the buffer.
|
|
||||||
*/
|
|
||||||
ssize_t
|
|
||||||
receive_packet(unsigned char *buf, unsigned char *lim,
|
|
||||||
struct sockaddr_in *from, struct ether_addr *hfrom,
|
|
||||||
struct dhcp_packet *packet)
|
|
||||||
{
|
|
||||||
struct bpf_hdr bh;
|
|
||||||
struct ether_header eh;
|
|
||||||
unsigned char *pktlim, *data, *next;
|
|
||||||
size_t datalen;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
for (next = buf; next < lim; next = pktlim) {
|
|
||||||
/* No bpf header means no more packets. */
|
|
||||||
if (lim < next + sizeof(bh))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memcpy(&bh, next, sizeof(bh));
|
|
||||||
pktlim = next + BPF_WORDALIGN(bh.bh_hdrlen + bh.bh_caplen);
|
|
||||||
|
|
||||||
/* Truncated bpf packet means no more packets. */
|
|
||||||
if (lim < next + bh.bh_hdrlen + bh.bh_caplen)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Drop incompletely captured DHCP packets. */
|
|
||||||
if (bh.bh_caplen != bh.bh_datalen)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Drop packets with invalid ethernet/ip/udp headers.
|
|
||||||
*/
|
|
||||||
if (pktlim < next + bh.bh_hdrlen + sizeof(eh))
|
|
||||||
continue;
|
|
||||||
memcpy(&eh, next + bh.bh_hdrlen, sizeof(eh));
|
|
||||||
memcpy(hfrom->ether_addr_octet, eh.ether_shost, ETHER_ADDR_LEN);
|
|
||||||
|
|
||||||
len = decode_udp_ip_header(next + bh.bh_hdrlen + sizeof(eh),
|
|
||||||
bh.bh_caplen - sizeof(eh), from);
|
|
||||||
if (len < 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Drop packets larger than sizeof(struct dhcp_packet). */
|
|
||||||
datalen = bh.bh_caplen - (sizeof(eh) + len);
|
|
||||||
if (datalen > sizeof(*packet))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Extract the DHCP packet for further processing. */
|
|
||||||
data = next + bh.bh_hdrlen + sizeof(eh) + len;
|
|
||||||
memset(packet, DHO_END, sizeof(*packet));
|
|
||||||
memcpy(packet, data, datalen);
|
|
||||||
|
|
||||||
return (pktlim - buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,406 +0,0 @@
|
||||||
/* $OpenBSD: conflex.c,v 1.50 2019/01/26 23:26:20 krw Exp $ */
|
|
||||||
|
|
||||||
/* Lexical scanner for dhclient config file. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "dhctoken.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
int lexline;
|
|
||||||
int lexchar;
|
|
||||||
char *token_line;
|
|
||||||
char *tlname;
|
|
||||||
|
|
||||||
static char line1[81];
|
|
||||||
static char line2[81];
|
|
||||||
static char *prev_line;
|
|
||||||
static char *cur_line;
|
|
||||||
static int lpos;
|
|
||||||
static int line;
|
|
||||||
static int tlpos;
|
|
||||||
static int tline;
|
|
||||||
static int token;
|
|
||||||
static int ugflag;
|
|
||||||
static char *tval;
|
|
||||||
static char tokbuf[1500];
|
|
||||||
|
|
||||||
static void eol(void);
|
|
||||||
static void skip_to_eol(FILE *);
|
|
||||||
|
|
||||||
static int get_char(FILE *);
|
|
||||||
static int get_token(FILE *);
|
|
||||||
static int read_string(FILE *);
|
|
||||||
static int read_num_or_name(int, FILE *);
|
|
||||||
static int intern(char *, int);
|
|
||||||
|
|
||||||
void
|
|
||||||
new_parse(char *name)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Initialize all parsing state, as we are starting to parse a
|
|
||||||
* new file, 'name'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
memset(line1, 0, sizeof(line1));
|
|
||||||
memset(line2, 0, sizeof(line2));
|
|
||||||
memset(tokbuf, 0, sizeof(tokbuf));
|
|
||||||
|
|
||||||
lpos = line = 1;
|
|
||||||
tlpos = tline = token = ugflag = 0;
|
|
||||||
tval = NULL;
|
|
||||||
|
|
||||||
lexline = lexchar = 0;
|
|
||||||
cur_line = line1;
|
|
||||||
prev_line = line2;
|
|
||||||
token_line = cur_line;
|
|
||||||
tlname = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* eol() increments the lexical line.
|
|
||||||
*
|
|
||||||
* It is split from get_char() because read_num_or_name() does *not*
|
|
||||||
* want the lexical line incremented when a '\n' ends the token assembly.
|
|
||||||
* Instead, it ungetc()'s the '\n' for the next token parse to deal with.
|
|
||||||
* Incrementing the lexical line in that case causes parse_warn() to
|
|
||||||
* generate messages that display a blank line instead of the offending
|
|
||||||
* token in context.
|
|
||||||
*
|
|
||||||
* Invoccations of get_char() wanting to increment the lexical line on '\n'
|
|
||||||
* must call eol().
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
eol(void)
|
|
||||||
{
|
|
||||||
if (cur_line == line1) {
|
|
||||||
cur_line = line2;
|
|
||||||
prev_line = line1;
|
|
||||||
} else {
|
|
||||||
cur_line = line1;
|
|
||||||
prev_line = line2;
|
|
||||||
}
|
|
||||||
line++;
|
|
||||||
lpos = 1;
|
|
||||||
cur_line[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
get_char(FILE *cfile)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
c = getc(cfile);
|
|
||||||
|
|
||||||
if (ugflag == 0) {
|
|
||||||
if (c != EOF && c != '\n') {
|
|
||||||
if ((unsigned int)lpos < sizeof(line1)) {
|
|
||||||
cur_line[lpos - 1] = c;
|
|
||||||
cur_line[lpos] = 0;
|
|
||||||
}
|
|
||||||
lpos++;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
ugflag = 0;
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
get_token(FILE *cfile)
|
|
||||||
{
|
|
||||||
static char tb[2];
|
|
||||||
int c, ttok;
|
|
||||||
int l, p, u;
|
|
||||||
|
|
||||||
u = ugflag;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
l = line;
|
|
||||||
p = lpos - u;
|
|
||||||
u = 0;
|
|
||||||
|
|
||||||
c = get_char(cfile);
|
|
||||||
|
|
||||||
if (isascii(c) != 0 && isspace(c) != 0) {
|
|
||||||
if (c == '\n')
|
|
||||||
eol();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c == '#') {
|
|
||||||
skip_to_eol(cfile);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lexline = l;
|
|
||||||
lexchar = p;
|
|
||||||
if (c == '"') {
|
|
||||||
ttok = read_string(cfile);
|
|
||||||
break;
|
|
||||||
} else if (c == '-' || (isascii(c) != 0 && isalnum(c) != 0)) {
|
|
||||||
ttok = read_num_or_name(c, cfile);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
tb[0] = c;
|
|
||||||
tb[1] = 0;
|
|
||||||
tval = tb;
|
|
||||||
ttok = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ttok;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
next_token(char **rval, FILE *cfile)
|
|
||||||
{
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
if (token != 0) {
|
|
||||||
if (lexline != tline)
|
|
||||||
token_line = cur_line;
|
|
||||||
lexchar = tlpos;
|
|
||||||
lexline = tline;
|
|
||||||
rv = token;
|
|
||||||
token = 0;
|
|
||||||
} else {
|
|
||||||
rv = get_token(cfile);
|
|
||||||
token_line = cur_line;
|
|
||||||
}
|
|
||||||
if (rval != 0)
|
|
||||||
*rval = tval;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
peek_token(char **rval, FILE *cfile)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
|
|
||||||
if (token == 0) {
|
|
||||||
tlpos = lexchar;
|
|
||||||
tline = lexline;
|
|
||||||
token = get_token(cfile);
|
|
||||||
if (lexline != tline)
|
|
||||||
token_line = prev_line;
|
|
||||||
x = lexchar;
|
|
||||||
lexchar = tlpos;
|
|
||||||
tlpos = x;
|
|
||||||
x = lexline;
|
|
||||||
lexline = tline;
|
|
||||||
tline = x;
|
|
||||||
}
|
|
||||||
if (rval != 0)
|
|
||||||
*rval = tval;
|
|
||||||
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
skip_to_eol(FILE *cfile)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
c = get_char(cfile);
|
|
||||||
if (c == EOF)
|
|
||||||
return;
|
|
||||||
if (c == '\n') {
|
|
||||||
eol();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
read_string(FILE *cfile)
|
|
||||||
{
|
|
||||||
int i, c, bs;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read in characters until an un-escaped '"' is encountered.
|
|
||||||
*/
|
|
||||||
bs = i = 0;
|
|
||||||
while ((c = get_char(cfile)) != EOF) {
|
|
||||||
if (c == '"' && bs == 0)
|
|
||||||
break;
|
|
||||||
if (c == '\n')
|
|
||||||
eol();
|
|
||||||
|
|
||||||
tokbuf[i++] = c;
|
|
||||||
if (bs != 0)
|
|
||||||
bs = 0;
|
|
||||||
else if (c == '\\')
|
|
||||||
bs = 1;
|
|
||||||
|
|
||||||
if (i == sizeof(tokbuf) - 1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (bs == 1)
|
|
||||||
i--;
|
|
||||||
|
|
||||||
if (c == EOF)
|
|
||||||
parse_warn("eof in string constant");
|
|
||||||
else if (c != '"')
|
|
||||||
parse_warn("string constant too long");
|
|
||||||
|
|
||||||
tokbuf[i] = '\0';
|
|
||||||
tval = tokbuf;
|
|
||||||
|
|
||||||
return TOK_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
read_num_or_name(int c, FILE *cfile)
|
|
||||||
{
|
|
||||||
unsigned int i, xdigits;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
xdigits = (isxdigit(c) != 0) ? 1 : 0;
|
|
||||||
|
|
||||||
tokbuf[0] = c;
|
|
||||||
for (i = 1; i < sizeof(tokbuf); i++) {
|
|
||||||
c = get_char(cfile);
|
|
||||||
if (isascii(c) == 0 || (c != '-' && c != '_' &&
|
|
||||||
isalnum(c) == 0)) {
|
|
||||||
/* N.B.: Do not call eol()! '\n' is put back. */
|
|
||||||
ungetc(c, cfile);
|
|
||||||
ugflag = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isxdigit(c) != 0)
|
|
||||||
xdigits++;
|
|
||||||
tokbuf[i] = c;
|
|
||||||
}
|
|
||||||
if (i == sizeof(tokbuf)) {
|
|
||||||
parse_warn("token larger than internal buffer");
|
|
||||||
i--;
|
|
||||||
c = tokbuf[i];
|
|
||||||
if (isxdigit(c) != 0)
|
|
||||||
xdigits--;
|
|
||||||
}
|
|
||||||
tokbuf[i] = 0;
|
|
||||||
tval = tokbuf;
|
|
||||||
|
|
||||||
c = (unsigned int)tokbuf[0];
|
|
||||||
|
|
||||||
if (c == '-')
|
|
||||||
rv = TOK_NUMBER;
|
|
||||||
else
|
|
||||||
rv = intern(tval, TOK_NUMBER_OR_NAME);
|
|
||||||
|
|
||||||
if (rv == TOK_NUMBER_OR_NAME && xdigits != i)
|
|
||||||
rv = TOK_NAME;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct keywords {
|
|
||||||
const char *k_name;
|
|
||||||
int k_val;
|
|
||||||
} keywords[] = {
|
|
||||||
{ "append", TOK_APPEND },
|
|
||||||
{ "backoff-cutoff", TOK_BACKOFF_CUTOFF },
|
|
||||||
{ "bootp", TOK_BOOTP },
|
|
||||||
{ "default", TOK_DEFAULT },
|
|
||||||
{ "epoch", TOK_EPOCH },
|
|
||||||
{ "expire", TOK_EXPIRE },
|
|
||||||
{ "filename", TOK_FILENAME },
|
|
||||||
{ "fixed-address", TOK_FIXED_ADDR },
|
|
||||||
{ "ignore", TOK_IGNORE },
|
|
||||||
{ "initial-interval", TOK_INITIAL_INTERVAL },
|
|
||||||
{ "interface", TOK_INTERFACE },
|
|
||||||
{ "lease", TOK_LEASE },
|
|
||||||
{ "link-timeout", TOK_LINK_TIMEOUT },
|
|
||||||
{ "next-server", TOK_NEXT_SERVER },
|
|
||||||
{ "option", TOK_OPTION },
|
|
||||||
{ "prepend", TOK_PREPEND },
|
|
||||||
{ "rebind", TOK_REBIND },
|
|
||||||
{ "reboot", TOK_REBOOT },
|
|
||||||
{ "reject", TOK_REJECT },
|
|
||||||
{ "renew", TOK_RENEW },
|
|
||||||
{ "request", TOK_REQUEST },
|
|
||||||
{ "require", TOK_REQUIRE },
|
|
||||||
{ "retry", TOK_RETRY },
|
|
||||||
{ "select-timeout", TOK_SELECT_TIMEOUT },
|
|
||||||
{ "send", TOK_SEND },
|
|
||||||
{ "server-name", TOK_SERVER_NAME },
|
|
||||||
{ "ssid", TOK_SSID },
|
|
||||||
{ "supersede", TOK_SUPERSEDE },
|
|
||||||
{ "timeout", TOK_TIMEOUT },
|
|
||||||
{ "uselease", TOK_USELEASE }
|
|
||||||
};
|
|
||||||
|
|
||||||
int kw_cmp(const void *k, const void *e);
|
|
||||||
|
|
||||||
int
|
|
||||||
kw_cmp(const void *k, const void *e)
|
|
||||||
{
|
|
||||||
return strcasecmp(k, ((const struct keywords *)e)->k_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
intern(char *atom, int dfv)
|
|
||||||
{
|
|
||||||
const struct keywords *p;
|
|
||||||
|
|
||||||
p = bsearch(atom, keywords, sizeof(keywords)/sizeof(keywords[0]),
|
|
||||||
sizeof(keywords[0]), kw_cmp);
|
|
||||||
if (p != NULL)
|
|
||||||
return p->k_val;
|
|
||||||
return dfv;
|
|
||||||
}
|
|
|
@ -1,292 +0,0 @@
|
||||||
.\" $OpenBSD: dhclient.8,v 1.50 2022/05/16 17:15:16 abieber Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
.\" Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
|
|
||||||
.\" Enterprises, see ``http://www.vix.com''.
|
|
||||||
.Dd $Mdocdate: May 16 2022 $
|
|
||||||
.Dt DHCLIENT 8
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm dhclient
|
|
||||||
.Nd Dynamic Host Configuration Protocol (DHCP) client
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm
|
|
||||||
.Op Fl dnrv
|
|
||||||
.Op Fl c Ar file
|
|
||||||
.Op Fl i Ar options
|
|
||||||
.Ar interface
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm
|
|
||||||
uses the Dynamic Host Configuration Protocol (DHCP), or its
|
|
||||||
predecessor BOOTP, to configure a network interface.
|
|
||||||
Information typically provided via DHCP includes
|
|
||||||
IPv4 address and subnet mask, default route,
|
|
||||||
and domain name server.
|
|
||||||
.Pp
|
|
||||||
The options are as follows:
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Fl c Ar file
|
|
||||||
Specify an alternate location to
|
|
||||||
.Pa /etc/dhclient.conf
|
|
||||||
for the configuration file.
|
|
||||||
If
|
|
||||||
.Ar file
|
|
||||||
is the empty string then no configuration file is read.
|
|
||||||
.It Fl d
|
|
||||||
Do not daemonize.
|
|
||||||
If this option is specified,
|
|
||||||
.Nm
|
|
||||||
will run in the foreground and log to
|
|
||||||
.Em stderr .
|
|
||||||
.It Fl i Ar options
|
|
||||||
.Nm
|
|
||||||
will ignore values provided by leases for the options specified.
|
|
||||||
This list will supplement ignore statements in
|
|
||||||
.Xr dhclient.conf 5 .
|
|
||||||
.Ar options
|
|
||||||
must be a comma separated list of valid option names.
|
|
||||||
.It Fl n
|
|
||||||
Configtest mode.
|
|
||||||
Only check the configuration file for validity.
|
|
||||||
.It Fl r
|
|
||||||
Release the current lease back to the server it came from.
|
|
||||||
.Nm
|
|
||||||
exits after removing the active lease from
|
|
||||||
.Pa /var/db/dhclient.leases . Ns Aq Ar IFNAME ,
|
|
||||||
deleting the address the lease caused to be added to the interface,
|
|
||||||
and sending a DHCPRELEASE packet to the server that supplied the lease.
|
|
||||||
.Pp
|
|
||||||
If there is no
|
|
||||||
.Nm
|
|
||||||
controlling the specified interface, or
|
|
||||||
.Nm
|
|
||||||
has no active lease configured, no action is performed.
|
|
||||||
.It Fl v
|
|
||||||
Causes
|
|
||||||
.Nm
|
|
||||||
to show more information about interactions with the DHCP server and what
|
|
||||||
network configuration changes are attempted after accepting a lease.
|
|
||||||
.Fl v
|
|
||||||
is implied if either
|
|
||||||
.Fl d
|
|
||||||
or
|
|
||||||
.Fl n
|
|
||||||
is present.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
The DHCP protocol allows a host to contact a central server which
|
|
||||||
maintains a list of IP addresses which may be assigned on one or more
|
|
||||||
subnets.
|
|
||||||
A DHCP client may request an address from this pool, and
|
|
||||||
then use it on a temporary basis for communication on the network.
|
|
||||||
The DHCP protocol also provides a mechanism whereby a client can learn
|
|
||||||
important details about the network to which it is attached, such as
|
|
||||||
the location of a default router, the location of a name server, and
|
|
||||||
so on.
|
|
||||||
.Pp
|
|
||||||
On startup,
|
|
||||||
.Nm
|
|
||||||
reads
|
|
||||||
.Pa /etc/dhclient.conf
|
|
||||||
for configuration instructions.
|
|
||||||
It then attempts to configure the network interface
|
|
||||||
.Ar interface
|
|
||||||
with DHCP.
|
|
||||||
The special value
|
|
||||||
.Dq egress
|
|
||||||
may be used instead of a network interface name.
|
|
||||||
In this case
|
|
||||||
.Nm
|
|
||||||
will look for the network interface currently in the interface group
|
|
||||||
.Dq egress
|
|
||||||
and configure it with DHCP.
|
|
||||||
If there is more than one network interface in the egress group,
|
|
||||||
.Nm
|
|
||||||
will exit with an error.
|
|
||||||
.Pp
|
|
||||||
When configuring the interface,
|
|
||||||
.Nm
|
|
||||||
attempts to remove any existing addresses, gateway routes that use
|
|
||||||
the interface, and non-permanent
|
|
||||||
.Xr arp 8
|
|
||||||
entries.
|
|
||||||
.Nm
|
|
||||||
automatically exits whenever a new
|
|
||||||
.Nm
|
|
||||||
is run on the same interface.
|
|
||||||
.Pp
|
|
||||||
Once the interface is configured,
|
|
||||||
.Nm
|
|
||||||
constructs a
|
|
||||||
.Xr resolv.conf 5
|
|
||||||
file.
|
|
||||||
It does this only if any of the options
|
|
||||||
.Cm domain-name ,
|
|
||||||
.Cm domain-name-servers ,
|
|
||||||
or
|
|
||||||
.Cm domain-search
|
|
||||||
are present
|
|
||||||
(note that these options may be offered by the DHCP server but suppressed by
|
|
||||||
.Xr dhclient.conf 5 ) .
|
|
||||||
If a resolv.conf is constructed,
|
|
||||||
.Nm
|
|
||||||
appends any contents of the
|
|
||||||
.Pa /etc/resolv.conf.tail
|
|
||||||
file, which are read once at start up.
|
|
||||||
The constructed resolv.conf is copied into
|
|
||||||
.Pa /etc/resolv.conf
|
|
||||||
whenever the default route goes out the interface
|
|
||||||
.Nm
|
|
||||||
is running on.
|
|
||||||
.Nm
|
|
||||||
monitors the system for changes to the default route and re-checks
|
|
||||||
whether it should write its resolv.conf when possible changes are
|
|
||||||
detected.
|
|
||||||
.Pp
|
|
||||||
In order to keep track of leases across system reboots and server
|
|
||||||
restarts,
|
|
||||||
.Nm
|
|
||||||
keeps a list of leases it has been assigned in the
|
|
||||||
.Pa /var/db/dhclient.leases . Ns Aq Ar IFNAME
|
|
||||||
file.
|
|
||||||
.Ar IFNAME
|
|
||||||
represents the network interface of the DHCP client
|
|
||||||
.Pq e.g. em0 ,
|
|
||||||
one for each interface.
|
|
||||||
On startup, after reading the
|
|
||||||
.Xr dhclient.conf 5
|
|
||||||
file,
|
|
||||||
.Nm
|
|
||||||
reads the leases file to refresh its memory about what leases it has been
|
|
||||||
assigned.
|
|
||||||
.Pp
|
|
||||||
Old leases are kept around in case the DHCP server is unavailable when
|
|
||||||
.Nm
|
|
||||||
is first invoked (generally during the initial system boot
|
|
||||||
process).
|
|
||||||
In that event, old leases from the
|
|
||||||
.Pa dhclient.leases . Ns Aq Ar IFNAME
|
|
||||||
file which have not yet expired are tested, and if they are determined to
|
|
||||||
be valid, they are used until either they expire or the DHCP server
|
|
||||||
becomes available.
|
|
||||||
.Pp
|
|
||||||
A mobile host which may sometimes need to access a network on which no
|
|
||||||
DHCP server exists may be preloaded with a lease for a fixed
|
|
||||||
address on that network.
|
|
||||||
When all attempts to contact a DHCP server have failed,
|
|
||||||
.Nm
|
|
||||||
will try to validate the static lease, and if it
|
|
||||||
succeeds, it will use that lease until it is restarted.
|
|
||||||
.Pp
|
|
||||||
A mobile host may also travel to some networks on which DHCP is not
|
|
||||||
available but BOOTP is.
|
|
||||||
In that case, it may be advantageous to
|
|
||||||
arrange with the network administrator for an entry on the BOOTP
|
|
||||||
database, so that the host can boot quickly on that network rather
|
|
||||||
than cycling through the list of old leases.
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width "/var/db/dhclient.leases.<IFNAME>XXX" -compact
|
|
||||||
.It Pa /etc/dhclient.conf
|
|
||||||
DHCP client configuration file
|
|
||||||
.It Pa /etc/hostname.XXX
|
|
||||||
interface-specific configuration files
|
|
||||||
.It Pa /var/db/dhclient.leases . Ns Aq Ar IFNAME
|
|
||||||
database of acquired leases
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr dhclient.conf 5 ,
|
|
||||||
.Xr dhclient.leases 5 ,
|
|
||||||
.Xr hostname.if 5 ,
|
|
||||||
.Xr dhcpd 8 ,
|
|
||||||
.Xr dhcrelay 8 ,
|
|
||||||
.Xr ifconfig 8
|
|
||||||
.Sh STANDARDS
|
|
||||||
.Rs
|
|
||||||
.%A R. Droms
|
|
||||||
.%D October 1993
|
|
||||||
.%R RFC 1534
|
|
||||||
.%T Interoperation Between DHCP and BOOTP
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
.Rs
|
|
||||||
.%A R. Droms
|
|
||||||
.%D March 1997
|
|
||||||
.%R RFC 2131
|
|
||||||
.%T Dynamic Host Configuration Protocol
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
.Rs
|
|
||||||
.%A S. Alexander
|
|
||||||
.%A R. Droms
|
|
||||||
.%D March 1997
|
|
||||||
.%R RFC 2132
|
|
||||||
.%T DHCP Options and BOOTP Vendor Extensions
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
.Rs
|
|
||||||
.%A T. Lemon
|
|
||||||
.%A S. Cheshire
|
|
||||||
.%D November 2002
|
|
||||||
.%R RFC 3396
|
|
||||||
.%T Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
.Rs
|
|
||||||
.%A T. Lemon
|
|
||||||
.%A S. Cheshire
|
|
||||||
.%A B. Volz
|
|
||||||
.%D December 2002
|
|
||||||
.%R RFC 3442
|
|
||||||
.%T The Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4
|
|
||||||
.Re
|
|
||||||
.Pp
|
|
||||||
.Rs
|
|
||||||
.%A N. Swamy
|
|
||||||
.%A G. Halwasia
|
|
||||||
.%A P. Jhingram
|
|
||||||
.%D January 2013
|
|
||||||
.%R RFC 6842
|
|
||||||
.%T Client Identifier Option in DHCP Server Replies
|
|
||||||
.Re
|
|
||||||
.Sh AUTHORS
|
|
||||||
.An -nosplit
|
|
||||||
.Nm
|
|
||||||
was written by
|
|
||||||
.An Ted Lemon Aq Mt mellon@fugue.com
|
|
||||||
and
|
|
||||||
.An Elliot Poger Aq Mt elliot@poger.com .
|
|
||||||
.Pp
|
|
||||||
The current implementation was reworked by
|
|
||||||
.An Henning Brauer Aq Mt henning@openbsd.org .
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,301 +0,0 @@
|
||||||
.\" $OpenBSD: dhclient.conf.5,v 1.52 2022/03/31 17:27:19 naddy Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
.\" Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
|
|
||||||
.\" Enterprises, see ``http://www.vix.com''.
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: March 31 2022 $
|
|
||||||
.Dt DHCLIENT.CONF 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm dhclient.conf
|
|
||||||
.Nd DHCP client configuration file
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm
|
|
||||||
is the configuration file for
|
|
||||||
.Xr dhclient 8 .
|
|
||||||
It is a free-form ASCII text file made up of declarations, extra
|
|
||||||
tabs and newlines for formatting purposes and comments.
|
|
||||||
Keywords in the file are case-insensitive.
|
|
||||||
Comments begin with the
|
|
||||||
.Sq #
|
|
||||||
character and extend to the end of the current line.
|
|
||||||
.Sh PROTOCOL TIMING DECLARATIONS
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Ic backoff-cutoff Ar seconds ;
|
|
||||||
Sets the maximum number of seconds to
|
|
||||||
wait before retransmitting a packet.
|
|
||||||
The default is 10 seconds.
|
|
||||||
.It Ic initial-interval Ar seconds ;
|
|
||||||
Sets the number of seconds between the first packet transmission
|
|
||||||
and the first retransmission of the packet.
|
|
||||||
The default is 1 second.
|
|
||||||
.It Ic link-timeout Ar seconds ;
|
|
||||||
Sets the number of seconds
|
|
||||||
to wait for a lease before going into the background as a daemon.
|
|
||||||
The default is 10 seconds.
|
|
||||||
.It Ic reboot Ar seconds ;
|
|
||||||
Sets the number of seconds to wait
|
|
||||||
before giving up on reacquiring the previous lease, and how long
|
|
||||||
to attempt unicast renewal requests before falling back to broadcast
|
|
||||||
renewal requests.
|
|
||||||
The default is 1 second.
|
|
||||||
.It Ic retry Ar seconds ;
|
|
||||||
Sets the number of seconds to wait before starting a new attempt to
|
|
||||||
obtain a lease.
|
|
||||||
The default is 1 second.
|
|
||||||
.It Ic select-timeout Ar seconds ;
|
|
||||||
Sets the number of seconds to wait for additional leases after the
|
|
||||||
first lease arrives.
|
|
||||||
After
|
|
||||||
.Ic select-timeout
|
|
||||||
seconds the best lease received will be selected.
|
|
||||||
The default is 0 seconds, i.e. immediately use
|
|
||||||
the first acceptable lease received.
|
|
||||||
.It Ic timeout Ar seconds ;
|
|
||||||
Sets the number of seconds to wait for a lease.
|
|
||||||
If no lease is received, the first valid lease in
|
|
||||||
.Xr dhclient.leases 5
|
|
||||||
will be used.
|
|
||||||
The default is 30 seconds.
|
|
||||||
.El
|
|
||||||
.Sh DHCP OPTION DECLARATIONS
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Ic append Ar option option-value ;
|
|
||||||
Append
|
|
||||||
.Ar option-value
|
|
||||||
to the value of
|
|
||||||
.Ar option
|
|
||||||
in the lease.
|
|
||||||
Each
|
|
||||||
.Ic append
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic ignore ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.Pp
|
|
||||||
If the option's data cannot be appended to, i.e. it has a fixed size,
|
|
||||||
then
|
|
||||||
.Ic append
|
|
||||||
will be treated as
|
|
||||||
.Ic default .
|
|
||||||
.It Ic default Ar option option-value ;
|
|
||||||
If no value for
|
|
||||||
.Ar option
|
|
||||||
is present in the lease, use
|
|
||||||
.Ar option-value .
|
|
||||||
Each
|
|
||||||
.Ic default
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic ignore ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.It Ic ignore Op Ar option , ... ;
|
|
||||||
Discard values provided for the listed options.
|
|
||||||
.Ic ignore
|
|
||||||
statements are cumulative, except that an empty
|
|
||||||
list will remove all previously specified options.
|
|
||||||
Each
|
|
||||||
.Ic ignore
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.It Ic prepend Ar option option-value ;
|
|
||||||
Prepend
|
|
||||||
.Ar option-value
|
|
||||||
to the value of
|
|
||||||
.Ar option
|
|
||||||
in the lease.
|
|
||||||
Each
|
|
||||||
.Ic prepend
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic ignore ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.Pp
|
|
||||||
If the option's data cannot be prepended to, i.e. it has a fixed size,
|
|
||||||
then
|
|
||||||
.Ic prepend
|
|
||||||
will be treated as
|
|
||||||
.Ic supersede .
|
|
||||||
.It Ic request Op Ar option , ... ;
|
|
||||||
Ask that any lease contain values
|
|
||||||
for the listed options.
|
|
||||||
.Ic request
|
|
||||||
statements are cumulative, except that an empty
|
|
||||||
list will remove all previously specified options.
|
|
||||||
The default is to request the options
|
|
||||||
bootfile-name,
|
|
||||||
broadcast-address,
|
|
||||||
classless-static-routes,
|
|
||||||
host-name,
|
|
||||||
domain-name,
|
|
||||||
domain-name-servers,
|
|
||||||
domain-search,
|
|
||||||
routers,
|
|
||||||
subnet-mask,
|
|
||||||
tftp-server-name
|
|
||||||
and
|
|
||||||
time-offset.
|
|
||||||
.It Ic require Op Ar option , ... ;
|
|
||||||
Discard leases that do not contain the listed options.
|
|
||||||
.Ic require
|
|
||||||
statements are cumulative, except that an empty
|
|
||||||
list will remove all previously specified options.
|
|
||||||
The default is to require the option subnet-mask.
|
|
||||||
.It Ic send Ar option option-value ;
|
|
||||||
Include
|
|
||||||
.Ar option-value
|
|
||||||
in requests for a lease.
|
|
||||||
To include multiple options in requests,
|
|
||||||
.Ic send
|
|
||||||
can be used multiple times.
|
|
||||||
.It Ic supersede Ar option option-value ;
|
|
||||||
Use
|
|
||||||
.Ar option-value
|
|
||||||
for the given
|
|
||||||
.Ar option
|
|
||||||
regardless of the value in the lease.
|
|
||||||
Each
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic ignore ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.It Ic uselease Op Ar option , ... ;
|
|
||||||
Use the unmodified values provided in the lease for
|
|
||||||
any specified
|
|
||||||
.Ar option .
|
|
||||||
.Ic uselease
|
|
||||||
statements are cumulative.
|
|
||||||
If no
|
|
||||||
.Ar option
|
|
||||||
is specified, all lease option values will be used unmodified.
|
|
||||||
.Ic uselease
|
|
||||||
for
|
|
||||||
.Ar option
|
|
||||||
overrides any previous
|
|
||||||
.Ic append ,
|
|
||||||
.Ic default ,
|
|
||||||
.Ic ignore ,
|
|
||||||
.Ic prepend
|
|
||||||
or
|
|
||||||
.Ic supersede
|
|
||||||
for
|
|
||||||
.Ar option .
|
|
||||||
.El
|
|
||||||
.Sh OTHER DECLARATIONS
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Ic filename Ar path ;
|
|
||||||
Use
|
|
||||||
.Ar path
|
|
||||||
instead of the
|
|
||||||
.Ic file
|
|
||||||
field of the DHCP offer when binding a lease.
|
|
||||||
.It Ic fixed-address Ar ip-address ;
|
|
||||||
Use
|
|
||||||
.Ar ip-address
|
|
||||||
instead of the
|
|
||||||
.Ic yiaddr
|
|
||||||
field of the DHCP offer when binding a lease.
|
|
||||||
.It Ic interface Qo Ar name Qc No { Ar declaration ; ... ; No }
|
|
||||||
Apply any
|
|
||||||
.Ar declaration
|
|
||||||
only to the named interface.
|
|
||||||
.It Ic reject Ar ip-address ;
|
|
||||||
Discard leases from the specified address.
|
|
||||||
If more than one
|
|
||||||
.Ic reject
|
|
||||||
is present, all leases from any of the
|
|
||||||
addresses will be discarded.
|
|
||||||
.It Ic next-server Ar ip-address ;
|
|
||||||
Use
|
|
||||||
.Ar ip-address
|
|
||||||
instead of the
|
|
||||||
.Ic siaddr
|
|
||||||
field of the DHCP offer when binding a lease.
|
|
||||||
.It Ic server-name Ar host ;
|
|
||||||
Use
|
|
||||||
.Ar host
|
|
||||||
instead of the
|
|
||||||
.Ic sname
|
|
||||||
field of the DHCP offer when binding a lease.
|
|
||||||
.El
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width /etc/examples/dhclient.conf -compact
|
|
||||||
.It Pa /etc/dhclient.conf
|
|
||||||
.It Pa /etc/examples/dhclient.conf
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr dhclient.leases 5 ,
|
|
||||||
.Xr dhcp-options 5 ,
|
|
||||||
.Xr dhcpd.conf 5 ,
|
|
||||||
.Xr dhclient 8 ,
|
|
||||||
.Xr dhcpd 8
|
|
|
@ -1,170 +0,0 @@
|
||||||
.\" $OpenBSD: dhclient.leases.5,v 1.14 2017/12/18 14:17:58 krw Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
.\" Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
|
|
||||||
.\" Enterprises, see ``http://www.vix.com''.
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: December 18 2017 $
|
|
||||||
.Dt DHCLIENT.LEASES 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm dhclient.leases
|
|
||||||
.Nd DHCP client lease database
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Xr dhclient 8
|
|
||||||
keeps a persistent database of leases that it has acquired that are still
|
|
||||||
valid.
|
|
||||||
The database is a free-form ASCII file containing one valid declaration
|
|
||||||
per lease.
|
|
||||||
The file is written as a log, so the last declaration is the most recent
|
|
||||||
lease obtained.
|
|
||||||
.Pp
|
|
||||||
The lease file is named
|
|
||||||
.Pa /var/db/dhclient.leases . Ns Aq Ar IFNAME ,
|
|
||||||
where
|
|
||||||
.Qq IFNAME
|
|
||||||
represents the network interface
|
|
||||||
.Xr dhclient 8
|
|
||||||
acquired the lease on.
|
|
||||||
For example, if
|
|
||||||
.Xr dhclient 8
|
|
||||||
is configured for the em0 network device,
|
|
||||||
the lease file will be named
|
|
||||||
.Pa /var/db/dhclient.leases.em0 ,
|
|
||||||
.Pp
|
|
||||||
A lease statement has the format
|
|
||||||
.Pp
|
|
||||||
.D1 Ic lease No { Ar lease-declaration ; ... ; No }
|
|
||||||
.Pp
|
|
||||||
Where
|
|
||||||
.Ar lease\-declaration
|
|
||||||
is one of:
|
|
||||||
.Pp
|
|
||||||
.Bl -tag -width Ds -compact
|
|
||||||
.It Ic bootp
|
|
||||||
The lease was acquired using the
|
|
||||||
BOOTP protocol rather than the DHCP protocol.
|
|
||||||
.Pp
|
|
||||||
.It Ic epoch
|
|
||||||
The
|
|
||||||
.Xr time 3
|
|
||||||
when the lease was obtained.
|
|
||||||
This value is used to convert the values of the DHCP options
|
|
||||||
.Ic dhcp-lease-time ,
|
|
||||||
.Ic dhcp-renewal-time ,
|
|
||||||
and
|
|
||||||
.Ic dhcp-rebinding-time
|
|
||||||
to times.
|
|
||||||
A value of 0 will cause
|
|
||||||
.Ic epoch
|
|
||||||
to be set to the current time when
|
|
||||||
.Nm
|
|
||||||
is processed.
|
|
||||||
.Pp
|
|
||||||
.It Ic expire Ar date
|
|
||||||
.It Ic rebind Ar date
|
|
||||||
.It Ic renew Ar date
|
|
||||||
.Ic expire
|
|
||||||
is when
|
|
||||||
.Xr dhclient 8
|
|
||||||
will no longer use the lease to configure the interface.
|
|
||||||
.Ic rebind
|
|
||||||
is when
|
|
||||||
.Xr dhclient 8
|
|
||||||
will begin trying to renew the lease with broadcasts to any server.
|
|
||||||
.Ic renew
|
|
||||||
is when
|
|
||||||
.Xr dhclient 8
|
|
||||||
will begin trying to renew the lease with unicasts to the originating server.
|
|
||||||
.Pp
|
|
||||||
Dates are specified in accordance with the
|
|
||||||
.Xr strptime 3
|
|
||||||
format:
|
|
||||||
.Pp
|
|
||||||
.D1 %w %Y/%m/%d \&%T UTC
|
|
||||||
.Pp
|
|
||||||
For example:
|
|
||||||
.Pp
|
|
||||||
.Dl renew 1 2017/10/16 14:03:49 UTC
|
|
||||||
.Pp
|
|
||||||
.Ic expire ,
|
|
||||||
.Ic rebind ,
|
|
||||||
.Ic renew
|
|
||||||
are just comments that are ignored when processing
|
|
||||||
.Nm .
|
|
||||||
The values used by
|
|
||||||
.Xr dhclient 8
|
|
||||||
are always recalculated based on
|
|
||||||
.Ic epoch
|
|
||||||
when
|
|
||||||
.Nm
|
|
||||||
is processed.
|
|
||||||
.Pp
|
|
||||||
.It Ic filename Qq Ar string
|
|
||||||
The boot filename.
|
|
||||||
.Pp
|
|
||||||
.It Ic fixed-address Ar ip-address
|
|
||||||
The IPv4 address of the lease.
|
|
||||||
This is required for all lease statements.
|
|
||||||
The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78).
|
|
||||||
.Pp
|
|
||||||
.It Ic next-server Ar ip-address
|
|
||||||
The IPv4 address of the boot server.
|
|
||||||
The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78).
|
|
||||||
.Pp
|
|
||||||
.It Ic option Ar option option-value
|
|
||||||
The value of
|
|
||||||
.Ar option .
|
|
||||||
DHCP options are described in
|
|
||||||
.Xr dhcp-options 5 .
|
|
||||||
.Pp
|
|
||||||
.It Ic server-name Qq Ar string
|
|
||||||
The name of the boot server.
|
|
||||||
.Pp
|
|
||||||
.It Ic ssid Qq Ar string
|
|
||||||
The SSID to which the lease applies.
|
|
||||||
.El
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width "/var/db/dhclient.leases.IFNAME "
|
|
||||||
.It Pa /var/db/dhclient.leases . Ns Aq Ar IFNAME
|
|
||||||
Persistent database of leases for
|
|
||||||
.Aq Ar IFNAME .
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr dhclient.conf 5 ,
|
|
||||||
.Xr dhcp-options 5 ,
|
|
||||||
.Xr dhcpd.conf 5 ,
|
|
||||||
.Xr dhclient 8 ,
|
|
||||||
.Xr dhcpd 8
|
|
|
@ -1,201 +0,0 @@
|
||||||
/* $OpenBSD: dhcp.h,v 1.21 2017/07/24 16:17:35 krw Exp $ */
|
|
||||||
|
|
||||||
/* Protocol structures. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 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 has been written for the Internet Software Consortium
|
|
||||||
* by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DHCP_UDP_OVERHEAD (20 + /* IP header */ \
|
|
||||||
8) /* UDP header */
|
|
||||||
#define DHCP_SNAME_LEN 64
|
|
||||||
#define DHCP_FILE_LEN 128
|
|
||||||
#define DHCP_FIXED_NON_UDP 236
|
|
||||||
#define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD)
|
|
||||||
/* Everything but options. */
|
|
||||||
#define DHCP_MTU_MAX 1500
|
|
||||||
#define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN)
|
|
||||||
|
|
||||||
/* Respect historical limits on 'search' line in resolv.conf(5) */
|
|
||||||
#define DHCP_DOMAIN_SEARCH_LEN 1024
|
|
||||||
#define DHCP_DOMAIN_SEARCH_CNT 6
|
|
||||||
|
|
||||||
#define BOOTP_MIN_LEN 300
|
|
||||||
|
|
||||||
struct dhcp_packet {
|
|
||||||
uint8_t op; /* Message opcode/type */
|
|
||||||
uint8_t htype; /* Hardware addr type (see net/if_types.h) */
|
|
||||||
uint8_t hlen; /* Hardware addr length */
|
|
||||||
uint8_t hops; /* Number of relay agent hops from client */
|
|
||||||
uint32_t xid; /* Transaction ID */
|
|
||||||
uint16_t secs; /* Seconds since client started looking */
|
|
||||||
uint16_t flags; /* Flag bits */
|
|
||||||
struct in_addr ciaddr; /* Client IP address (if already in use) */
|
|
||||||
struct in_addr yiaddr; /* Client IP address */
|
|
||||||
struct in_addr siaddr; /* IP address of next server to talk to */
|
|
||||||
struct in_addr giaddr; /* DHCP relay agent IP address */
|
|
||||||
unsigned char chaddr[16]; /* Client hardware address */
|
|
||||||
char sname[DHCP_SNAME_LEN]; /* Server name */
|
|
||||||
char file[DHCP_FILE_LEN]; /* Boot filename */
|
|
||||||
unsigned char options[DHCP_OPTION_LEN];
|
|
||||||
/* Optional parameters
|
|
||||||
(actual length dependent on MTU). */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* BOOTP (rfc951) message types */
|
|
||||||
#define BOOTREQUEST 1
|
|
||||||
#define BOOTREPLY 2
|
|
||||||
|
|
||||||
/* Possible values for flags field. */
|
|
||||||
#define BOOTP_BROADCAST 32768L
|
|
||||||
|
|
||||||
/* Possible values for hardware type (htype) field. */
|
|
||||||
#define HTYPE_ETHER 1 /* Ethernet */
|
|
||||||
#define HTYPE_IPSEC_TUNNEL 31 /* IPsec Tunnel (RFC3456) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Magic cookie validating dhcp options field (and bootp vendor
|
|
||||||
* extensions field).
|
|
||||||
*/
|
|
||||||
#define DHCP_OPTIONS_COOKIE "\143\202\123\143"
|
|
||||||
#define DHCP_OPTIONS_COOKIE_LEN 4
|
|
||||||
#define DHCP_OPTIONS_MESSAGE_TYPE "\065\001\000"
|
|
||||||
|
|
||||||
/* DHCP Option codes: */
|
|
||||||
#define DHO_PAD 0
|
|
||||||
#define DHO_SUBNET_MASK 1
|
|
||||||
#define DHO_TIME_OFFSET 2
|
|
||||||
#define DHO_ROUTERS 3
|
|
||||||
#define DHO_TIME_SERVERS 4
|
|
||||||
#define DHO_NAME_SERVERS 5
|
|
||||||
#define DHO_DOMAIN_NAME_SERVERS 6
|
|
||||||
#define DHO_LOG_SERVERS 7
|
|
||||||
#define DHO_COOKIE_SERVERS 8
|
|
||||||
#define DHO_LPR_SERVERS 9
|
|
||||||
#define DHO_IMPRESS_SERVERS 10
|
|
||||||
#define DHO_RESOURCE_LOCATION_SERVERS 11
|
|
||||||
#define DHO_HOST_NAME 12
|
|
||||||
#define DHO_BOOT_SIZE 13
|
|
||||||
#define DHO_MERIT_DUMP 14
|
|
||||||
#define DHO_DOMAIN_NAME 15
|
|
||||||
#define DHO_SWAP_SERVER 16
|
|
||||||
#define DHO_ROOT_PATH 17
|
|
||||||
#define DHO_EXTENSIONS_PATH 18
|
|
||||||
#define DHO_IP_FORWARDING 19
|
|
||||||
#define DHO_NON_LOCAL_SOURCE_ROUTING 20
|
|
||||||
#define DHO_POLICY_FILTER 21
|
|
||||||
#define DHO_MAX_DGRAM_REASSEMBLY 22
|
|
||||||
#define DHO_DEFAULT_IP_TTL 23
|
|
||||||
#define DHO_PATH_MTU_AGING_TIMEOUT 24
|
|
||||||
#define DHO_PATH_MTU_PLATEAU_TABLE 25
|
|
||||||
#define DHO_INTERFACE_MTU 26
|
|
||||||
#define DHO_ALL_SUBNETS_LOCAL 27
|
|
||||||
#define DHO_BROADCAST_ADDRESS 28
|
|
||||||
#define DHO_PERFORM_MASK_DISCOVERY 29
|
|
||||||
#define DHO_MASK_SUPPLIER 30
|
|
||||||
#define DHO_ROUTER_DISCOVERY 31
|
|
||||||
#define DHO_ROUTER_SOLICITATION_ADDRESS 32
|
|
||||||
#define DHO_STATIC_ROUTES 33
|
|
||||||
#define DHO_TRAILER_ENCAPSULATION 34
|
|
||||||
#define DHO_ARP_CACHE_TIMEOUT 35
|
|
||||||
#define DHO_IEEE802_3_ENCAPSULATION 36
|
|
||||||
#define DHO_DEFAULT_TCP_TTL 37
|
|
||||||
#define DHO_TCP_KEEPALIVE_INTERVAL 38
|
|
||||||
#define DHO_TCP_KEEPALIVE_GARBAGE 39
|
|
||||||
#define DHO_NIS_DOMAIN 40
|
|
||||||
#define DHO_NIS_SERVERS 41
|
|
||||||
#define DHO_NTP_SERVERS 42
|
|
||||||
#define DHO_VENDOR_ENCAPSULATED_OPTIONS 43
|
|
||||||
#define DHO_NETBIOS_NAME_SERVERS 44
|
|
||||||
#define DHO_NETBIOS_DD_SERVER 45
|
|
||||||
#define DHO_NETBIOS_NODE_TYPE 46
|
|
||||||
#define DHO_NETBIOS_SCOPE 47
|
|
||||||
#define DHO_FONT_SERVERS 48
|
|
||||||
#define DHO_X_DISPLAY_MANAGER 49
|
|
||||||
#define DHO_DHCP_REQUESTED_ADDRESS 50
|
|
||||||
#define DHO_DHCP_LEASE_TIME 51
|
|
||||||
#define DHO_DHCP_OPTION_OVERLOAD 52
|
|
||||||
#define DHO_DHCP_MESSAGE_TYPE 53
|
|
||||||
#define DHO_DHCP_SERVER_IDENTIFIER 54
|
|
||||||
#define DHO_DHCP_PARAMETER_REQUEST_LIST 55
|
|
||||||
#define DHO_DHCP_MESSAGE 56
|
|
||||||
#define DHO_DHCP_MAX_MESSAGE_SIZE 57
|
|
||||||
#define DHO_DHCP_RENEWAL_TIME 58
|
|
||||||
#define DHO_DHCP_REBINDING_TIME 59
|
|
||||||
#define DHO_DHCP_CLASS_IDENTIFIER 60
|
|
||||||
#define DHO_DHCP_CLIENT_IDENTIFIER 61
|
|
||||||
#define DHO_NISPLUS_DOMAIN 64
|
|
||||||
#define DHO_NISPLUS_SERVERS 65
|
|
||||||
#define DHO_TFTP_SERVER 66
|
|
||||||
#define DHO_BOOTFILE_NAME 67
|
|
||||||
#define DHO_MOBILE_IP_HOME_AGENT 68
|
|
||||||
#define DHO_SMTP_SERVER 69
|
|
||||||
#define DHO_POP_SERVER 70
|
|
||||||
#define DHO_NNTP_SERVER 71
|
|
||||||
#define DHO_WWW_SERVER 72
|
|
||||||
#define DHO_FINGER_SERVER 73
|
|
||||||
#define DHO_IRC_SERVER 74
|
|
||||||
#define DHO_STREETTALK_SERVER 75
|
|
||||||
#define DHO_STREETTALK_DIRECTORY_ASSISTANCE_SERVER 76
|
|
||||||
#define DHO_DHCP_USER_CLASS_ID 77
|
|
||||||
#define DHO_RELAY_AGENT_INFORMATION 82
|
|
||||||
#define DHO_NDS_SERVERS 85
|
|
||||||
#define DHO_NDS_TREE_NAME 86
|
|
||||||
#define DHO_NDS_CONTEXT 87
|
|
||||||
#define DHO_DOMAIN_SEARCH 119
|
|
||||||
#define DHO_CLASSLESS_STATIC_ROUTES 121
|
|
||||||
#define DHO_TFTP_CONFIG_FILE 144
|
|
||||||
#define DHO_VOIP_CONFIGURATION_SERVER 150
|
|
||||||
#define DHO_CLASSLESS_MS_STATIC_ROUTES 249
|
|
||||||
#define DHO_AUTOPROXY_SCRIPT 252
|
|
||||||
#define DHO_END 255
|
|
||||||
#define DHO_COUNT 256 /* # of DHCP options */
|
|
||||||
|
|
||||||
/* DHCP message types. */
|
|
||||||
#define DHCPDISCOVER 1
|
|
||||||
#define DHCPOFFER 2
|
|
||||||
#define DHCPREQUEST 3
|
|
||||||
#define DHCPDECLINE 4
|
|
||||||
#define DHCPACK 5
|
|
||||||
#define DHCPNAK 6
|
|
||||||
#define DHCPRELEASE 7
|
|
||||||
#define DHCPINFORM 8
|
|
||||||
|
|
||||||
/* Relay Agent Information sub-options */
|
|
||||||
#define RAI_CIRCUIT_ID 1
|
|
||||||
#define RAI_REMOTE_ID 2
|
|
||||||
#define RAI_AGENT_ID 3
|
|
|
@ -1,255 +0,0 @@
|
||||||
/* $OpenBSD: dhcpd.h,v 1.299 2021/03/28 16:23:05 krw Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999
|
|
||||||
* The Internet Software Consortium. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define LOCAL_PORT 68
|
|
||||||
#define REMOTE_PORT 67
|
|
||||||
#define TERMINATE 1
|
|
||||||
#define RESTART 2
|
|
||||||
#define DB_TIMEFMT "%w %Y/%m/%d %T UTC"
|
|
||||||
#define RT_BUF_SIZE 2048
|
|
||||||
|
|
||||||
struct option_data {
|
|
||||||
unsigned int len;
|
|
||||||
uint8_t *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct reject_elem {
|
|
||||||
TAILQ_ENTRY(reject_elem) next;
|
|
||||||
struct in_addr addr;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct client_lease {
|
|
||||||
TAILQ_ENTRY(client_lease) next;
|
|
||||||
time_t epoch;
|
|
||||||
struct in_addr address;
|
|
||||||
struct in_addr next_server;
|
|
||||||
char *server_name;
|
|
||||||
char *filename;
|
|
||||||
char ssid[32];
|
|
||||||
uint8_t ssid_len;
|
|
||||||
struct option_data options[DHO_COUNT];
|
|
||||||
};
|
|
||||||
#define BOOTP_LEASE(l) ((l)->options[DHO_DHCP_MESSAGE_TYPE].len == 0)
|
|
||||||
|
|
||||||
/* Possible states in which the client can be. */
|
|
||||||
enum dhcp_state {
|
|
||||||
S_PREBOOT,
|
|
||||||
S_REBOOTING,
|
|
||||||
S_INIT,
|
|
||||||
S_SELECTING,
|
|
||||||
S_REQUESTING,
|
|
||||||
S_BOUND,
|
|
||||||
S_RENEWING
|
|
||||||
};
|
|
||||||
|
|
||||||
enum actions {
|
|
||||||
ACTION_USELEASE,
|
|
||||||
ACTION_DEFAULT,
|
|
||||||
ACTION_SUPERSEDE,
|
|
||||||
ACTION_PREPEND,
|
|
||||||
ACTION_APPEND,
|
|
||||||
ACTION_IGNORE
|
|
||||||
};
|
|
||||||
|
|
||||||
TAILQ_HEAD(client_lease_tq, client_lease);
|
|
||||||
|
|
||||||
struct client_config {
|
|
||||||
struct option_data defaults[DHO_COUNT];
|
|
||||||
enum actions default_actions[DHO_COUNT];
|
|
||||||
struct in_addr address;
|
|
||||||
struct in_addr next_server;
|
|
||||||
struct option_data send_options[DHO_COUNT];
|
|
||||||
uint8_t required_options[DHO_COUNT];
|
|
||||||
uint8_t requested_options[DHO_COUNT];
|
|
||||||
int requested_option_count;
|
|
||||||
int required_option_count;
|
|
||||||
time_t offer_interval;
|
|
||||||
time_t initial_interval;
|
|
||||||
time_t link_interval;
|
|
||||||
time_t retry_interval;
|
|
||||||
time_t select_interval;
|
|
||||||
time_t reboot_interval;
|
|
||||||
time_t backoff_cutoff;
|
|
||||||
TAILQ_HEAD(, reject_elem) reject_list;
|
|
||||||
char *filename;
|
|
||||||
char *server_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct interface_info {
|
|
||||||
struct ether_addr hw_address;
|
|
||||||
char name[IFNAMSIZ];
|
|
||||||
char ssid[32];
|
|
||||||
uint8_t ssid_len;
|
|
||||||
int bpffd; /* bpf - reading & broadcast writing*/
|
|
||||||
int udpfd; /* udp - unicast writing */
|
|
||||||
unsigned char *rbuf;
|
|
||||||
size_t rbuf_max;
|
|
||||||
int errors;
|
|
||||||
uint16_t index;
|
|
||||||
int link_state;
|
|
||||||
int rdomain;
|
|
||||||
int flags;
|
|
||||||
#define IFI_IN_CHARGE 0x01
|
|
||||||
uint32_t mtu;
|
|
||||||
struct dhcp_packet recv_packet;
|
|
||||||
struct dhcp_packet sent_packet;
|
|
||||||
int sent_packet_length;
|
|
||||||
uint32_t xid;
|
|
||||||
struct timespec timeout;
|
|
||||||
struct timespec reboot_timeout;
|
|
||||||
struct timespec expiry;
|
|
||||||
struct timespec rebind;
|
|
||||||
struct timespec renew;
|
|
||||||
void (*timeout_func)(struct interface_info *);
|
|
||||||
uint16_t secs;
|
|
||||||
struct timespec first_sending;
|
|
||||||
struct timespec link_timeout;
|
|
||||||
struct timespec offer_timeout;
|
|
||||||
struct timespec select_timeout;
|
|
||||||
enum dhcp_state state;
|
|
||||||
struct in_addr destination;
|
|
||||||
time_t interval;
|
|
||||||
struct in_addr requested_address;
|
|
||||||
struct client_lease *active;
|
|
||||||
struct client_lease *offer;
|
|
||||||
char *offer_src;
|
|
||||||
struct proposal *configured;
|
|
||||||
struct unwind_info *unwind_info;
|
|
||||||
struct client_lease_tq lease_db;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
|
|
||||||
#define _PATH_LEASE_DB "/var/db/dhclient.leases"
|
|
||||||
|
|
||||||
/* options.c */
|
|
||||||
int pack_options(unsigned char *, int,
|
|
||||||
struct option_data *);
|
|
||||||
struct option_data *unpack_options(struct dhcp_packet *);
|
|
||||||
char *pretty_print_option(unsigned int, struct option_data *,
|
|
||||||
int);
|
|
||||||
char *pretty_print_string(unsigned char *, size_t, int);
|
|
||||||
char *code_to_name(int);
|
|
||||||
char *code_to_format(int);
|
|
||||||
int code_to_action(int, int);
|
|
||||||
int name_to_code(char *);
|
|
||||||
void merge_option_data(char *, struct option_data *,
|
|
||||||
struct option_data *, struct option_data *);
|
|
||||||
|
|
||||||
/* conflex.c */
|
|
||||||
extern int lexline, lexchar;
|
|
||||||
extern char *token_line, *tlname;
|
|
||||||
|
|
||||||
void new_parse(char *);
|
|
||||||
int next_token(char **, FILE *);
|
|
||||||
int peek_token(char **, FILE *);
|
|
||||||
|
|
||||||
/* parse.c */
|
|
||||||
void skip_to_semi(FILE *);
|
|
||||||
int parse_semi(FILE *);
|
|
||||||
int parse_string(FILE *, char **);
|
|
||||||
int parse_ip_addr(FILE *, struct in_addr *);
|
|
||||||
int parse_cidr(FILE *, unsigned char *);
|
|
||||||
int parse_number(FILE *, long long *, long long, long long);
|
|
||||||
int parse_boolean(FILE *, unsigned char *);
|
|
||||||
void parse_warn(char *);
|
|
||||||
|
|
||||||
/* bpf.c */
|
|
||||||
int get_bpf_sock(char *);
|
|
||||||
int get_udp_sock(int);
|
|
||||||
int configure_bpf_sock(int);
|
|
||||||
ssize_t send_packet(struct interface_info *, struct in_addr,
|
|
||||||
struct in_addr, const char *);
|
|
||||||
ssize_t receive_packet(unsigned char *, unsigned char *,
|
|
||||||
struct sockaddr_in *, struct ether_addr *, struct dhcp_packet *);
|
|
||||||
|
|
||||||
/* dispatch.c */
|
|
||||||
void dispatch(struct interface_info *, int);
|
|
||||||
void set_timeout( struct interface_info *, time_t,
|
|
||||||
void (*)(struct interface_info *));
|
|
||||||
void cancel_timeout(struct interface_info *);
|
|
||||||
|
|
||||||
/* dhclient.c */
|
|
||||||
extern char *path_dhclient_conf;
|
|
||||||
extern char *path_lease_db;
|
|
||||||
extern char *log_procname;
|
|
||||||
extern struct client_config *config;
|
|
||||||
extern struct imsgbuf *unpriv_ibuf;
|
|
||||||
extern int quit;
|
|
||||||
extern int cmd_opts;
|
|
||||||
#define OPT_NOACTION 0x01
|
|
||||||
#define OPT_VERBOSE 0x02
|
|
||||||
#define OPT_FOREGROUND 0x04
|
|
||||||
#define OPT_RELEASE 0x08
|
|
||||||
|
|
||||||
void dhcpoffer(struct interface_info *, struct option_data *,
|
|
||||||
const char *);
|
|
||||||
void dhcpack(struct interface_info *, struct option_data *,
|
|
||||||
const char *);
|
|
||||||
void dhcpnak(struct interface_info *, const char *);
|
|
||||||
void bootreply(struct interface_info *, struct option_data *,
|
|
||||||
const char *);
|
|
||||||
void free_client_lease(struct client_lease *);
|
|
||||||
void routefd_handler(struct interface_info *, int);
|
|
||||||
void state_preboot(struct interface_info *);
|
|
||||||
char *rfc1035_as_string(unsigned char *, size_t);
|
|
||||||
|
|
||||||
/* packet.c */
|
|
||||||
void assemble_eh_header(struct ether_addr, struct ether_header *);
|
|
||||||
ssize_t decode_udp_ip_header(unsigned char *, uint32_t,
|
|
||||||
struct sockaddr_in *);
|
|
||||||
uint32_t checksum(unsigned char *, uint32_t, uint32_t);
|
|
||||||
uint32_t wrapsum(uint32_t);
|
|
||||||
|
|
||||||
/* clparse.c */
|
|
||||||
void init_config(void);
|
|
||||||
void read_conf(char *, uint8_t *, struct ether_addr *);
|
|
||||||
void read_lease_db(struct client_lease_tq *);
|
|
||||||
|
|
||||||
/* kroute.c */
|
|
||||||
unsigned int extract_route(uint8_t *, unsigned int, in_addr_t *,
|
|
||||||
in_addr_t *, in_addr_t *);
|
|
||||||
void write_resolv_conf(void);
|
|
||||||
|
|
||||||
void propose(struct proposal *);
|
|
||||||
void revoke_proposal(struct proposal *);
|
|
||||||
|
|
||||||
void tell_unwind(struct unwind_info *, int);
|
|
|
@ -1,82 +0,0 @@
|
||||||
/* $OpenBSD: dhctoken.h,v 1.16 2019/01/26 23:26:20 krw Exp $ */
|
|
||||||
|
|
||||||
/* Tokens for config file lexer and parser. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999
|
|
||||||
* The Internet Software Consortium. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define TOK_FIRST_TOKEN TOK_FILENAME
|
|
||||||
#define TOK_FILENAME 257
|
|
||||||
#define TOK_FIXED_ADDR 259
|
|
||||||
#define TOK_OPTION 260
|
|
||||||
#define TOK_STRING 262
|
|
||||||
#define TOK_NUMBER 263
|
|
||||||
#define TOK_NUMBER_OR_NAME 264
|
|
||||||
#define TOK_NAME 265
|
|
||||||
#define TOK_LEASE 266
|
|
||||||
#define TOK_SERVER_NAME 267
|
|
||||||
#define TOK_SEND 269
|
|
||||||
#define TOK_REQUEST 270
|
|
||||||
#define TOK_REQUIRE 271
|
|
||||||
#define TOK_TIMEOUT 272
|
|
||||||
#define TOK_RETRY 273
|
|
||||||
#define TOK_SELECT_TIMEOUT 274
|
|
||||||
#define TOK_NEXT_SERVER 275
|
|
||||||
#define TOK_INTERFACE 276
|
|
||||||
#define TOK_RENEW 277
|
|
||||||
#define TOK_REBIND 278
|
|
||||||
#define TOK_EXPIRE 279
|
|
||||||
#define TOK_BOOTP 280
|
|
||||||
#define TOK_DEFAULT 282
|
|
||||||
#define TOK_REBOOT 286
|
|
||||||
#define TOK_BACKOFF_CUTOFF 287
|
|
||||||
#define TOK_INITIAL_INTERVAL 288
|
|
||||||
#define TOK_SUPERSEDE 289
|
|
||||||
#define TOK_APPEND 290
|
|
||||||
#define TOK_PREPEND 291
|
|
||||||
#define TOK_REJECT 292
|
|
||||||
#define TOK_LINK_TIMEOUT 294
|
|
||||||
#define TOK_IGNORE 295
|
|
||||||
#define TOK_SSID 296
|
|
||||||
#define TOK_EPOCH 297
|
|
||||||
#define TOK_USELEASE 298
|
|
||||||
|
|
||||||
#define is_identifier(x) ((x) >= TOK_FIRST_TOKEN && \
|
|
||||||
(x) != TOK_STRING && \
|
|
||||||
(x) != TOK_NUMBER && \
|
|
||||||
(x) != EOF)
|
|
|
@ -1,322 +0,0 @@
|
||||||
/* $OpenBSD: dispatch.c,v 1.172 2021/03/28 17:25:21 krw Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
* Copyright (c) 1995, 1996, 1997, 1998, 1999
|
|
||||||
* The Internet Software Consortium. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/if_arp.h>
|
|
||||||
#include <net/if_media.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <imsg.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <resolv.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "privsep.h"
|
|
||||||
|
|
||||||
|
|
||||||
void bpffd_handler(struct interface_info *);
|
|
||||||
void dhcp_packet_dispatch(struct interface_info *, struct sockaddr_in *,
|
|
||||||
struct ether_addr *);
|
|
||||||
void flush_unpriv_ibuf(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Loop waiting for packets, timeouts or routing messages.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
dispatch(struct interface_info *ifi, int routefd)
|
|
||||||
{
|
|
||||||
const struct timespec link_intvl = {config->link_interval, 0};
|
|
||||||
struct pollfd fds[3];
|
|
||||||
struct timespec timeout;
|
|
||||||
struct timespec *ts;
|
|
||||||
void (*func)(struct interface_info *);
|
|
||||||
int nfds;
|
|
||||||
|
|
||||||
log_debug("%s: link is %s", log_procname,
|
|
||||||
LINK_STATE_IS_UP(ifi->link_state) ? "up" : "down");
|
|
||||||
|
|
||||||
while (quit == 0 || quit == RESTART) {
|
|
||||||
if (quit == RESTART) {
|
|
||||||
quit = 0;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ifi->link_timeout);
|
|
||||||
timespecadd(&ifi->link_timeout, &link_intvl, &ifi->link_timeout);
|
|
||||||
free(ifi->configured);
|
|
||||||
ifi->configured = NULL;
|
|
||||||
free(ifi->unwind_info);
|
|
||||||
ifi->unwind_info = NULL;
|
|
||||||
ifi->state = S_PREBOOT;
|
|
||||||
state_preboot(ifi);
|
|
||||||
}
|
|
||||||
if (timespecisset(&ifi->timeout)) {
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &timeout);
|
|
||||||
if (timespeccmp(&timeout, &ifi->timeout, >=)) {
|
|
||||||
func = ifi->timeout_func;
|
|
||||||
cancel_timeout(ifi);
|
|
||||||
(*(func))(ifi);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
timespecsub(&ifi->timeout, &timeout, &timeout);
|
|
||||||
ts = &timeout;
|
|
||||||
} else
|
|
||||||
ts = NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set up the descriptors to be polled.
|
|
||||||
*
|
|
||||||
* fds[0] == bpf socket for incoming packets
|
|
||||||
* fds[1] == routing socket for incoming RTM messages
|
|
||||||
* fds[2] == imsg socket to privileged process
|
|
||||||
*/
|
|
||||||
fds[0].fd = ifi->bpffd;
|
|
||||||
fds[1].fd = routefd;
|
|
||||||
fds[2].fd = unpriv_ibuf->fd;
|
|
||||||
fds[0].events = fds[1].events = fds[2].events = POLLIN;
|
|
||||||
|
|
||||||
if (unpriv_ibuf->w.queued)
|
|
||||||
fds[2].events |= POLLOUT;
|
|
||||||
|
|
||||||
nfds = ppoll(fds, 3, ts, NULL);
|
|
||||||
if (nfds == -1) {
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
log_warn("%s: ppoll(bpffd, routefd, unpriv_ibuf)",
|
|
||||||
log_procname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
|
|
||||||
log_debug("%s: bpffd: ERR|HUP|NVAL", log_procname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((fds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
|
|
||||||
log_debug("%s: routefd: ERR|HUP|NVAL", log_procname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((fds[2].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
|
|
||||||
log_debug("%s: unpriv_ibuf: ERR|HUP|NVAL", log_procname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nfds == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((fds[0].revents & POLLIN) != 0)
|
|
||||||
bpffd_handler(ifi);
|
|
||||||
if ((fds[1].revents & POLLIN) != 0)
|
|
||||||
routefd_handler(ifi, routefd);
|
|
||||||
if ((fds[2].revents & POLLOUT) != 0)
|
|
||||||
flush_unpriv_ibuf();
|
|
||||||
if ((fds[2].revents & POLLIN) != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
bpffd_handler(struct interface_info *ifi)
|
|
||||||
{
|
|
||||||
struct sockaddr_in from;
|
|
||||||
struct ether_addr hfrom;
|
|
||||||
unsigned char *next, *lim;
|
|
||||||
ssize_t n;
|
|
||||||
|
|
||||||
n = read(ifi->bpffd, ifi->rbuf, ifi->rbuf_max);
|
|
||||||
if (n == -1) {
|
|
||||||
log_warn("%s: read(bpffd)", log_procname);
|
|
||||||
ifi->errors++;
|
|
||||||
if (ifi->errors > 20)
|
|
||||||
fatalx("too many read(bpffd) failures");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ifi->errors = 0;
|
|
||||||
|
|
||||||
lim = ifi->rbuf + n;
|
|
||||||
for (next = ifi->rbuf; quit == 0 && n > 0; next += n) {
|
|
||||||
n = receive_packet(next, lim, &from, &hfrom, &ifi->recv_packet);
|
|
||||||
if (n > 0)
|
|
||||||
dhcp_packet_dispatch(ifi, &from, &hfrom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dhcp_packet_dispatch(struct interface_info *ifi, struct sockaddr_in *from,
|
|
||||||
struct ether_addr *hfrom)
|
|
||||||
{
|
|
||||||
struct in_addr ifrom;
|
|
||||||
struct dhcp_packet *packet = &ifi->recv_packet;
|
|
||||||
struct reject_elem *ap;
|
|
||||||
struct option_data *options;
|
|
||||||
char *src;
|
|
||||||
int i, rslt;
|
|
||||||
|
|
||||||
ifrom.s_addr = from->sin_addr.s_addr;
|
|
||||||
|
|
||||||
if (packet->hlen != ETHER_ADDR_LEN) {
|
|
||||||
log_debug("%s: discarding packet with hlen == %u", log_procname,
|
|
||||||
packet->hlen);
|
|
||||||
return;
|
|
||||||
} else if (memcmp(&ifi->hw_address, packet->chaddr,
|
|
||||||
sizeof(ifi->hw_address)) != 0) {
|
|
||||||
log_debug("%s: discarding packet with chaddr == %s",
|
|
||||||
log_procname,
|
|
||||||
ether_ntoa((struct ether_addr *)packet->chaddr));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ifi->xid != packet->xid) {
|
|
||||||
log_debug("%s: discarding packet with XID != %u (%u)",
|
|
||||||
log_procname, ifi->xid, packet->xid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAILQ_FOREACH(ap, &config->reject_list, next)
|
|
||||||
if (ifrom.s_addr == ap->addr.s_addr) {
|
|
||||||
log_debug("%s: discarding packet from address on reject "
|
|
||||||
"list (%s)", log_procname, inet_ntoa(ifrom));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
options = unpack_options(&ifi->recv_packet);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RFC 6842 says if the server sends a client identifier
|
|
||||||
* that doesn't match then the packet must be dropped.
|
|
||||||
*/
|
|
||||||
i = DHO_DHCP_CLIENT_IDENTIFIER;
|
|
||||||
if ((options[i].len != 0) &&
|
|
||||||
((options[i].len != config->send_options[i].len) ||
|
|
||||||
memcmp(options[i].data, config->send_options[i].data,
|
|
||||||
options[i].len) != 0)) {
|
|
||||||
log_debug("%s: discarding packet with client-identifier %s'",
|
|
||||||
log_procname, pretty_print_option(i, &options[i], 0));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rslt = asprintf(&src, "%s (%s)", inet_ntoa(ifrom), ether_ntoa(hfrom));
|
|
||||||
if (rslt == -1)
|
|
||||||
fatal("src");
|
|
||||||
|
|
||||||
i = DHO_DHCP_MESSAGE_TYPE;
|
|
||||||
if (options[i].data != NULL) {
|
|
||||||
/* Always try a DHCP packet, even if a bad option was seen. */
|
|
||||||
switch (options[i].data[0]) {
|
|
||||||
case DHCPOFFER:
|
|
||||||
dhcpoffer(ifi, options, src);
|
|
||||||
break;
|
|
||||||
case DHCPNAK:
|
|
||||||
dhcpnak(ifi, src);
|
|
||||||
break;
|
|
||||||
case DHCPACK:
|
|
||||||
dhcpack(ifi, options, src);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log_debug("%s: discarding DHCP packet of unknown type "
|
|
||||||
"(%d)", log_procname, options[i].data[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (packet->op == BOOTREPLY) {
|
|
||||||
bootreply(ifi, options, src);
|
|
||||||
} else {
|
|
||||||
log_debug("%s: discarding packet which is neither DHCP nor "
|
|
||||||
"BOOTP", log_procname);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* flush_unpriv_ibuf stuffs queued messages into the imsg socket.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
flush_unpriv_ibuf(void)
|
|
||||||
{
|
|
||||||
while (unpriv_ibuf->w.queued) {
|
|
||||||
if (msgbuf_write(&unpriv_ibuf->w) <= 0) {
|
|
||||||
if (errno == EAGAIN)
|
|
||||||
break;
|
|
||||||
if (quit == 0)
|
|
||||||
quit = TERMINATE;
|
|
||||||
if (errno != EPIPE && errno != 0)
|
|
||||||
log_warn("%s: msgbuf_write(unpriv_ibuf)",
|
|
||||||
log_procname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
set_timeout(struct interface_info *ifi, time_t secs,
|
|
||||||
void (*where)(struct interface_info *))
|
|
||||||
{
|
|
||||||
struct timespec now;
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
||||||
timespecclear(&ifi->timeout);
|
|
||||||
ifi->timeout.tv_sec = secs;
|
|
||||||
timespecadd(&ifi->timeout, &now, &ifi->timeout);
|
|
||||||
ifi->timeout_func = where;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cancel_timeout(struct interface_info *ifi)
|
|
||||||
{
|
|
||||||
timespecclear(&ifi->timeout);
|
|
||||||
ifi->timeout_func = NULL;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,199 +0,0 @@
|
||||||
/* $OpenBSD: log.c,v 1.2 2017/03/21 12:06:55 bluhm Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
static int debug;
|
|
||||||
static int verbose;
|
|
||||||
static const char *log_procname;
|
|
||||||
|
|
||||||
void
|
|
||||||
log_init(int n_debug, int facility)
|
|
||||||
{
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
debug = n_debug;
|
|
||||||
verbose = n_debug;
|
|
||||||
log_procinit(__progname);
|
|
||||||
|
|
||||||
if (!debug)
|
|
||||||
openlog(__progname, LOG_PID | LOG_NDELAY, facility);
|
|
||||||
|
|
||||||
tzset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_procinit(const char *procname)
|
|
||||||
{
|
|
||||||
if (procname != NULL)
|
|
||||||
log_procname = procname;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_setverbose(int v)
|
|
||||||
{
|
|
||||||
verbose = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
log_getverbose(void)
|
|
||||||
{
|
|
||||||
return (verbose);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
logit(int pri, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vlog(pri, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
vlog(int pri, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
char *nfmt;
|
|
||||||
int saved_errno = errno;
|
|
||||||
|
|
||||||
if (debug) {
|
|
||||||
/* best effort in out of mem situations */
|
|
||||||
if (asprintf(&nfmt, "%s\n", fmt) == -1) {
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
} else {
|
|
||||||
vfprintf(stderr, nfmt, ap);
|
|
||||||
free(nfmt);
|
|
||||||
}
|
|
||||||
fflush(stderr);
|
|
||||||
} else
|
|
||||||
vsyslog(pri, fmt, ap);
|
|
||||||
|
|
||||||
errno = saved_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_warn(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
char *nfmt;
|
|
||||||
va_list ap;
|
|
||||||
int saved_errno = errno;
|
|
||||||
|
|
||||||
/* best effort to even work in out of memory situations */
|
|
||||||
if (emsg == NULL)
|
|
||||||
logit(LOG_ERR, "%s", strerror(saved_errno));
|
|
||||||
else {
|
|
||||||
va_start(ap, emsg);
|
|
||||||
|
|
||||||
if (asprintf(&nfmt, "%s: %s", emsg,
|
|
||||||
strerror(saved_errno)) == -1) {
|
|
||||||
/* we tried it... */
|
|
||||||
vlog(LOG_ERR, emsg, ap);
|
|
||||||
logit(LOG_ERR, "%s", strerror(saved_errno));
|
|
||||||
} else {
|
|
||||||
vlog(LOG_ERR, nfmt, ap);
|
|
||||||
free(nfmt);
|
|
||||||
}
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = saved_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_warnx(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, emsg);
|
|
||||||
vlog(LOG_ERR, emsg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_info(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, emsg);
|
|
||||||
vlog(LOG_INFO, emsg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_debug(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
if (verbose) {
|
|
||||||
va_start(ap, emsg);
|
|
||||||
vlog(LOG_DEBUG, emsg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
vfatalc(int code, const char *emsg, va_list ap)
|
|
||||||
{
|
|
||||||
static char s[BUFSIZ];
|
|
||||||
const char *sep;
|
|
||||||
|
|
||||||
if (emsg != NULL) {
|
|
||||||
(void)vsnprintf(s, sizeof(s), emsg, ap);
|
|
||||||
sep = ": ";
|
|
||||||
} else {
|
|
||||||
s[0] = '\0';
|
|
||||||
sep = "";
|
|
||||||
}
|
|
||||||
if (code)
|
|
||||||
logit(LOG_CRIT, "fatal in %s: %s%s%s",
|
|
||||||
log_procname, s, sep, strerror(code));
|
|
||||||
else
|
|
||||||
logit(LOG_CRIT, "fatal in %s%s%s", log_procname, sep, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fatal(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, emsg);
|
|
||||||
vfatalc(errno, emsg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
fatalx(const char *emsg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, emsg);
|
|
||||||
vfatalc(0, emsg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/* $OpenBSD: log.h,v 1.2 2021/12/13 18:28:39 deraadt Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LOG_H
|
|
||||||
#define LOG_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
void log_init(int, int);
|
|
||||||
void log_procinit(const char *);
|
|
||||||
void log_setverbose(int);
|
|
||||||
int log_getverbose(void);
|
|
||||||
void log_warn(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
void log_warnx(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
void log_info(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
void log_debug(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
void logit(int, const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 2, 3)));
|
|
||||||
void vlog(int, const char *, va_list)
|
|
||||||
__attribute__((__format__ (printf, 2, 0)));
|
|
||||||
__dead void fatal(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
__dead void fatalx(const char *, ...)
|
|
||||||
__attribute__((__format__ (printf, 1, 2)));
|
|
||||||
|
|
||||||
#endif /* LOG_H */
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,215 +0,0 @@
|
||||||
/* $OpenBSD: packet.c,v 1.45 2021/02/22 23:43:59 jsg Exp $ */
|
|
||||||
|
|
||||||
/* Packet assembly code, originally contributed by Archie Cobbs. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1999 The Internet Software Consortium.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <netinet/udp.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
checksum(unsigned char *buf, uint32_t nbytes, uint32_t sum)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
/* Checksum all the pairs of bytes first. */
|
|
||||||
for (i = 0; i < (nbytes & ~1U); i += 2) {
|
|
||||||
sum += (uint16_t)ntohs(*((uint16_t *)(buf + i)));
|
|
||||||
if (sum > 0xFFFF)
|
|
||||||
sum -= 0xFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If there's a single byte left over, checksum it, too.
|
|
||||||
* Network byte order is big-endian, so the remaining byte is
|
|
||||||
* the high byte.
|
|
||||||
*/
|
|
||||||
if (i < nbytes) {
|
|
||||||
sum += buf[i] << 8;
|
|
||||||
if (sum > 0xFFFF)
|
|
||||||
sum -= 0xFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
wrapsum(uint32_t sum)
|
|
||||||
{
|
|
||||||
sum = ~sum & 0xFFFF;
|
|
||||||
return htons(sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
assemble_eh_header(struct ether_addr shost, struct ether_header *eh)
|
|
||||||
{
|
|
||||||
memset(eh->ether_dhost, 0xff, sizeof(eh->ether_dhost));
|
|
||||||
|
|
||||||
memcpy(eh->ether_shost, shost.ether_addr_octet,
|
|
||||||
sizeof(eh->ether_shost));
|
|
||||||
|
|
||||||
eh->ether_type = htons(ETHERTYPE_IP);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t
|
|
||||||
decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
|
|
||||||
struct sockaddr_in *from)
|
|
||||||
{
|
|
||||||
static int ip_packets_seen;
|
|
||||||
static int ip_packets_bad_checksum;
|
|
||||||
static int udp_packets_seen;
|
|
||||||
static int udp_packets_bad_checksum;
|
|
||||||
static int udp_packets_length_checked;
|
|
||||||
static int udp_packets_length_overflow;
|
|
||||||
struct ip *ip;
|
|
||||||
struct udphdr *udp;
|
|
||||||
unsigned char *data;
|
|
||||||
int len;
|
|
||||||
uint32_t ip_len;
|
|
||||||
uint32_t sum, usum;
|
|
||||||
|
|
||||||
/* Assure that an entire IP header is within the buffer. */
|
|
||||||
if (sizeof(*ip) > buflen)
|
|
||||||
return -1;
|
|
||||||
ip_len = (*buf & 0xf) << 2;
|
|
||||||
if (ip_len > buflen)
|
|
||||||
return -1;
|
|
||||||
ip = (struct ip *)(buf);
|
|
||||||
ip_packets_seen++;
|
|
||||||
|
|
||||||
/* Check the IP header checksum - it should be zero. */
|
|
||||||
if (wrapsum(checksum((unsigned char *)ip, ip_len, 0)) != 0) {
|
|
||||||
ip_packets_bad_checksum++;
|
|
||||||
if (ip_packets_seen > 4 && ip_packets_bad_checksum != 0 &&
|
|
||||||
(ip_packets_seen / ip_packets_bad_checksum) < 2) {
|
|
||||||
log_debug("%s: %d bad IP checksums seen in %d packets",
|
|
||||||
log_procname, ip_packets_bad_checksum,
|
|
||||||
ip_packets_seen);
|
|
||||||
ip_packets_seen = ip_packets_bad_checksum = 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&from->sin_addr, &ip->ip_src, sizeof(from->sin_addr));
|
|
||||||
|
|
||||||
if (ntohs(ip->ip_len) != buflen)
|
|
||||||
log_debug("%s: ip length %hu disagrees with bytes received %d",
|
|
||||||
log_procname, ntohs(ip->ip_len), buflen);
|
|
||||||
|
|
||||||
/* Assure that the entire IP packet is within the buffer. */
|
|
||||||
if (ntohs(ip->ip_len) > buflen)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Assure that the UDP header is within the buffer. */
|
|
||||||
if (ip_len + sizeof(*udp) > buflen)
|
|
||||||
return -1;
|
|
||||||
udp = (struct udphdr *)(buf + ip_len);
|
|
||||||
udp_packets_seen++;
|
|
||||||
|
|
||||||
/* Assure that the entire UDP packet is within the buffer. */
|
|
||||||
if (ip_len + ntohs(udp->uh_ulen) > buflen)
|
|
||||||
return -1;
|
|
||||||
data = buf + ip_len + sizeof(*udp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compute UDP checksums, including the ``pseudo-header'', the
|
|
||||||
* UDP header and the data. If the UDP checksum field is zero,
|
|
||||||
* we're not supposed to do a checksum.
|
|
||||||
*/
|
|
||||||
udp_packets_length_checked++;
|
|
||||||
len = ntohs(udp->uh_ulen) - sizeof(*udp);
|
|
||||||
if ((len < 0) || (len + data > buf + buflen)) {
|
|
||||||
udp_packets_length_overflow++;
|
|
||||||
if (udp_packets_length_checked > 4 &&
|
|
||||||
udp_packets_length_overflow != 0 &&
|
|
||||||
(udp_packets_length_checked /
|
|
||||||
udp_packets_length_overflow) < 2) {
|
|
||||||
log_debug("%s: %d udp packets in %d too long - dropped",
|
|
||||||
log_procname, udp_packets_length_overflow,
|
|
||||||
udp_packets_length_checked);
|
|
||||||
udp_packets_length_overflow =
|
|
||||||
udp_packets_length_checked = 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (len + data != buf + buflen)
|
|
||||||
log_debug("%s: accepting packet with data after udp payload",
|
|
||||||
log_procname);
|
|
||||||
|
|
||||||
usum = udp->uh_sum;
|
|
||||||
udp->uh_sum = 0;
|
|
||||||
|
|
||||||
sum = wrapsum(checksum((unsigned char *)udp, sizeof(*udp),
|
|
||||||
checksum(data, len, checksum((unsigned char *)&ip->ip_src,
|
|
||||||
2 * sizeof(ip->ip_src),
|
|
||||||
IPPROTO_UDP + (uint32_t)ntohs(udp->uh_ulen)))));
|
|
||||||
|
|
||||||
udp_packets_seen++;
|
|
||||||
if (usum != 0 && usum != sum) {
|
|
||||||
udp_packets_bad_checksum++;
|
|
||||||
if (udp_packets_seen > 4 && udp_packets_bad_checksum != 0 &&
|
|
||||||
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
|
|
||||||
log_debug("%s: %d bad udp checksums in %d packets",
|
|
||||||
log_procname, udp_packets_bad_checksum,
|
|
||||||
udp_packets_seen);
|
|
||||||
udp_packets_seen = udp_packets_bad_checksum = 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&from->sin_port, &udp->uh_sport, sizeof(udp->uh_sport));
|
|
||||||
|
|
||||||
return ip_len + sizeof(*udp);
|
|
||||||
}
|
|
|
@ -1,300 +0,0 @@
|
||||||
/* $OpenBSD: parse.c,v 1.83 2019/07/22 17:20:06 krw Exp $ */
|
|
||||||
|
|
||||||
/* Common parser code for dhcpd and dhclient. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1995, 1996, 1997, 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 Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
|
||||||
* Enterprises. To learn more about the Internet Software Consortium,
|
|
||||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
|
||||||
* Enterprises, see ``http://www.vix.com''.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vis.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "dhctoken.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Skip to the semicolon ending the current statement. If we encounter
|
|
||||||
* braces, the matching closing brace terminates the statement. If we
|
|
||||||
* encounter a right brace but haven't encountered a left brace, return
|
|
||||||
* leaving the brace in the token buffer for the caller. If we see a
|
|
||||||
* semicolon and haven't seen a left brace, return. This lets us skip
|
|
||||||
* over:
|
|
||||||
*
|
|
||||||
* statement;
|
|
||||||
* statement foo bar { }
|
|
||||||
* statement foo bar { statement { } }
|
|
||||||
* statement}
|
|
||||||
*
|
|
||||||
* ...et cetera.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
skip_to_semi(FILE *cfile)
|
|
||||||
{
|
|
||||||
int token;
|
|
||||||
int brace_count = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
token = peek_token(NULL, cfile);
|
|
||||||
if (token == '}') {
|
|
||||||
if (brace_count > 0) {
|
|
||||||
if (--brace_count == 0) {
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return;
|
|
||||||
} else if (token == '{') {
|
|
||||||
brace_count++;
|
|
||||||
} else if (token == ';' && brace_count == 0) {
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
} while (token != EOF);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
parse_semi(FILE *cfile)
|
|
||||||
{
|
|
||||||
int token;
|
|
||||||
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
if (token == ';')
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
parse_warn("expecting semicolon.");
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
parse_string(FILE *cfile, char **string)
|
|
||||||
{
|
|
||||||
static char unvisbuf[1500];
|
|
||||||
char *val;
|
|
||||||
int i, token;
|
|
||||||
|
|
||||||
token = next_token(&val, cfile);
|
|
||||||
if (token == TOK_STRING) {
|
|
||||||
i = strnunvis(unvisbuf, val, sizeof(unvisbuf));
|
|
||||||
if (i >= 0) {
|
|
||||||
*string = strdup(unvisbuf);
|
|
||||||
if (*string == NULL)
|
|
||||||
fatal("strdup(unvisbuf)");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_warn("expecting string.");
|
|
||||||
|
|
||||||
if (token != ';')
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* cidr :== ip-address "/" bit-count
|
|
||||||
* ip-address :== NUMBER [ DOT NUMBER [ DOT NUMBER [ DOT NUMBER ] ] ]
|
|
||||||
* bit-count :== 0..32
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
parse_cidr(FILE *cfile, unsigned char *cidr)
|
|
||||||
{
|
|
||||||
uint8_t buf[5];
|
|
||||||
const char *errstr;
|
|
||||||
char *val;
|
|
||||||
long long numval;
|
|
||||||
unsigned int i;
|
|
||||||
int token;
|
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
i = 1; /* Last four octets hold subnet, first octet the # of bits. */
|
|
||||||
do {
|
|
||||||
token = next_token(&val, cfile);
|
|
||||||
if (i == 0)
|
|
||||||
numval = strtonum(val, 0, 32, &errstr);
|
|
||||||
else
|
|
||||||
numval = strtonum(val, 0, UINT8_MAX, &errstr);
|
|
||||||
if (errstr != NULL)
|
|
||||||
break;
|
|
||||||
buf[i++] = numval;
|
|
||||||
if (i == 1) {
|
|
||||||
memcpy(cidr, buf, sizeof(buf)); /* XXX Need cidr_t */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
if (token == '/')
|
|
||||||
i = 0;
|
|
||||||
if (i == sizeof(buf))
|
|
||||||
break;
|
|
||||||
} while (token == '.' || token == '/');
|
|
||||||
|
|
||||||
parse_warn("expecting IPv4 CIDR block.");
|
|
||||||
|
|
||||||
if (token != ';')
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
parse_ip_addr(FILE *cfile, struct in_addr *addr)
|
|
||||||
{
|
|
||||||
struct in_addr buf;
|
|
||||||
const char *errstr;
|
|
||||||
char *val;
|
|
||||||
long long numval;
|
|
||||||
unsigned int i;
|
|
||||||
int token;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
token = next_token(&val, cfile);
|
|
||||||
numval = strtonum(val, 0, UINT8_MAX, &errstr);
|
|
||||||
if (errstr != NULL)
|
|
||||||
break;
|
|
||||||
((uint8_t *)&buf)[i++] = numval;
|
|
||||||
if (i == sizeof(buf)) {
|
|
||||||
memcpy(addr, &buf, sizeof(*addr));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
token = next_token(NULL, cfile);
|
|
||||||
} while (token == '.');
|
|
||||||
|
|
||||||
parse_warn("expecting IPv4 address.");
|
|
||||||
|
|
||||||
if (token != ';')
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
parse_boolean(FILE *cfile, unsigned char *buf)
|
|
||||||
{
|
|
||||||
char *val;
|
|
||||||
int token;
|
|
||||||
|
|
||||||
token = next_token(&val, cfile);
|
|
||||||
if (is_identifier(token) != 0) {
|
|
||||||
if (strcasecmp(val, "true") == 0 ||
|
|
||||||
strcasecmp(val, "on") == 0) {
|
|
||||||
buf[0] = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (strcasecmp(val, "false") == 0 ||
|
|
||||||
strcasecmp(val, "off") == 0) {
|
|
||||||
buf[0] = 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_warn("expecting boolean.");
|
|
||||||
if (token != ';')
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
parse_number(FILE *cfile, long long *number, long long low, long long high)
|
|
||||||
{
|
|
||||||
const char *errstr;
|
|
||||||
char *val, *msg;
|
|
||||||
int rslt, token;
|
|
||||||
long long numval;
|
|
||||||
|
|
||||||
token = next_token(&val, cfile);
|
|
||||||
|
|
||||||
numval = strtonum(val, low, high, &errstr);
|
|
||||||
if (errstr == NULL) {
|
|
||||||
*number = numval;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rslt = asprintf(&msg, "expecting integer between %lld and %lld", low,
|
|
||||||
high);
|
|
||||||
if (rslt != -1) {
|
|
||||||
parse_warn(msg);
|
|
||||||
free(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token != ';')
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
parse_warn(char *msg)
|
|
||||||
{
|
|
||||||
static char spaces[81];
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
log_warnx("%s: %s line %d: %s", log_procname, tlname, lexline, msg);
|
|
||||||
log_warnx("%s: %s", log_procname, token_line);
|
|
||||||
if ((unsigned int)lexchar < sizeof(spaces)) {
|
|
||||||
memset(spaces, 0, sizeof(spaces));
|
|
||||||
for (i = 0; (int)i < lexchar - 1; i++) {
|
|
||||||
if (token_line[i] == '\t')
|
|
||||||
spaces[i] = '\t';
|
|
||||||
else
|
|
||||||
spaces[i] = ' ';
|
|
||||||
}
|
|
||||||
log_warnx("%s: %s^", log_procname, spaces);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +0,0 @@
|
||||||
/* $OpenBSD: privsep.c,v 1.79 2020/11/21 18:34:25 krw Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
|
|
||||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
||||||
* OF OR IN CONNECTION WITH THE USE, ABUSE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/queue.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/if_ether.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <imsg.h>
|
|
||||||
#include <resolv.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "dhcp.h"
|
|
||||||
#include "dhcpd.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "privsep.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
dispatch_imsg(char *name, int rdomain, int ioctlfd, int routefd,
|
|
||||||
struct imsgbuf *ibuf)
|
|
||||||
{
|
|
||||||
static char *resolv_conf;
|
|
||||||
static int lastidx;
|
|
||||||
struct imsg imsg;
|
|
||||||
ssize_t n;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
index = if_nametoindex(name);
|
|
||||||
if (index == 0) {
|
|
||||||
log_warnx("%s: unknown interface", log_procname);
|
|
||||||
quit = TERMINATE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if ((n = imsg_get(ibuf, &imsg)) == -1)
|
|
||||||
fatal("imsg_get");
|
|
||||||
|
|
||||||
if (n == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (imsg.hdr.type) {
|
|
||||||
case IMSG_REVOKE:
|
|
||||||
if (imsg.hdr.len != IMSG_HEADER_SIZE +
|
|
||||||
sizeof(struct proposal))
|
|
||||||
log_warnx("%s: bad IMSG_REVOKE",
|
|
||||||
log_procname);
|
|
||||||
else
|
|
||||||
priv_revoke_proposal(name, ioctlfd, imsg.data,
|
|
||||||
&resolv_conf);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IMSG_PROPOSE:
|
|
||||||
if (imsg.hdr.len < IMSG_HEADER_SIZE +
|
|
||||||
sizeof(struct proposal))
|
|
||||||
log_warnx("%s: bad IMSG_PROPOSE",
|
|
||||||
log_procname);
|
|
||||||
else {
|
|
||||||
priv_propose(name, ioctlfd, imsg.data,
|
|
||||||
imsg.hdr.len - IMSG_HEADER_SIZE - sizeof(struct proposal),
|
|
||||||
&resolv_conf, routefd, rdomain, index, &lastidx);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IMSG_WRITE_RESOLV_CONF:
|
|
||||||
if (imsg.hdr.len != IMSG_HEADER_SIZE)
|
|
||||||
log_warnx("%s: bad IMSG_WRITE_RESOLV_CONF",
|
|
||||||
log_procname);
|
|
||||||
else
|
|
||||||
priv_write_resolv_conf(index, routefd, rdomain,
|
|
||||||
resolv_conf, &lastidx);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IMSG_TELL_UNWIND:
|
|
||||||
if (imsg.hdr.len != IMSG_HEADER_SIZE +
|
|
||||||
sizeof(struct unwind_info))
|
|
||||||
log_warnx("%s: bad IMSG_TELL_UNWIND",
|
|
||||||
log_procname);
|
|
||||||
else
|
|
||||||
priv_tell_unwind(index, routefd, rdomain, imsg.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
log_warnx("%s: received unknown message, code %u",
|
|
||||||
log_procname, imsg.hdr.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
imsg_free(&imsg);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/* $OpenBSD: privsep.h,v 1.70 2020/11/21 18:34:25 krw Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
|
|
||||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
||||||
* OF OR IN CONNECTION WITH THE USE, ABUSE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum imsg_code {
|
|
||||||
IMSG_NONE,
|
|
||||||
IMSG_REVOKE,
|
|
||||||
IMSG_WRITE_RESOLV_CONF,
|
|
||||||
IMSG_PROPOSE,
|
|
||||||
IMSG_TELL_UNWIND
|
|
||||||
};
|
|
||||||
|
|
||||||
struct proposal {
|
|
||||||
struct in_addr address;
|
|
||||||
struct in_addr netmask;
|
|
||||||
unsigned int routes_len;
|
|
||||||
unsigned int domains_len;
|
|
||||||
unsigned int ns_len;
|
|
||||||
int mtu;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct unwind_info {
|
|
||||||
in_addr_t ns[MAXNS];
|
|
||||||
unsigned int count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void dispatch_imsg(char *, int, int, int, struct imsgbuf *);
|
|
||||||
|
|
||||||
void priv_write_resolv_conf(int, int, int, char *, int *);
|
|
||||||
void priv_propose(char *, int, struct proposal *, size_t, char **, int, int,
|
|
||||||
int, int *);
|
|
||||||
|
|
||||||
void priv_revoke_proposal(char *, int, struct proposal *, char **);
|
|
||||||
|
|
||||||
void priv_tell_unwind(int, int, int, struct unwind_info *);
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: dmesg.8,v 1.17 2016/10/06 11:25:17 schwarze Exp $
|
.\" $OpenBSD: dmesg.8,v 1.18 2024/06/30 23:44:49 jsg Exp $
|
||||||
.\" $NetBSD: dmesg.8,v 1.9 1995/03/18 14:54:47 cgd Exp $
|
.\" $NetBSD: dmesg.8,v 1.9 1995/03/18 14:54:47 cgd Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1980, 1991, 1993
|
.\" Copyright (c) 1980, 1991, 1993
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93
|
.\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: October 6 2016 $
|
.Dd $Mdocdate: June 30 2024 $
|
||||||
.Dt DMESG 8
|
.Dt DMESG 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -82,4 +82,4 @@ at boot time
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
command appeared in
|
command appeared in
|
||||||
.Bx 3 .
|
.At v7 .
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: unwind.conf.5,v 1.33 2023/02/21 07:47:24 jmc Exp $
|
.\" $OpenBSD: unwind.conf.5,v 1.34 2024/06/30 16:10:26 florian Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2018 Florian Obser <florian@openbsd.org>
|
.\" Copyright (c) 2018 Florian Obser <florian@openbsd.org>
|
||||||
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
|
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: February 21 2023 $
|
.Dd $Mdocdate: June 30 2024 $
|
||||||
.Dt UNWIND.CONF 5
|
.Dt UNWIND.CONF 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -130,6 +130,11 @@ Force resolving of
|
||||||
.Ar name
|
.Ar name
|
||||||
and its subdomains by the given resolver
|
and its subdomains by the given resolver
|
||||||
.Ar type .
|
.Ar type .
|
||||||
|
The
|
||||||
|
.Ar type
|
||||||
|
must be listed in the
|
||||||
|
.Ic preference
|
||||||
|
list to be used.
|
||||||
If
|
If
|
||||||
.Cm accept bogus
|
.Cm accept bogus
|
||||||
is specified, validation is not enforced.
|
is specified, validation is not enforced.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.\" $OpenBSD: rc.8,v 1.46 2020/02/10 13:18:20 schwarze Exp $
|
.\" $OpenBSD: rc.8,v 1.47 2024/06/30 23:57:31 jsg Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1980, 1991, 1993
|
.\" Copyright (c) 1980, 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)rc.8 8.2 (Berkeley) 12/11/93
|
.\" @(#)rc.8 8.2 (Berkeley) 12/11/93
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: February 10 2020 $
|
.Dd $Mdocdate: June 30 2024 $
|
||||||
.Dt RC 8
|
.Dt RC 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -212,4 +212,4 @@ at boot time.
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
command appeared in
|
command appeared in
|
||||||
.Bx 4.0 .
|
.At v4 .
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.49 2023/04/17 00:05:35 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.50 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
COPTS?=
|
COPTS?=
|
||||||
MAN?= boot.8
|
MAN?= boot.8
|
||||||
|
@ -79,7 +79,7 @@ NOPROG=
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
.endif
|
.endif
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-DHIBERNATE
|
CPPFLAGS+=-DHIBERNATE
|
||||||
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
||||||
CFLAGS+=-m32 $(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
CFLAGS+=-m32 $(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.44 2023/04/17 00:05:35 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.45 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
MAN= cdboot.8
|
MAN= cdboot.8
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ NOPROG=
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS}
|
||||||
CPPFLAGS+=-DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-I${S}/stand/boot
|
CPPFLAGS+=-I${S}/stand/boot
|
||||||
CFLAGS+=-m32
|
CFLAGS+=-m32
|
||||||
CFLAGS+=${SACFLAGS} -D__INTERNAL_LIBSA_CREAD
|
CFLAGS+=${SACFLAGS} -D__INTERNAL_LIBSA_CREAD
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile.common,v 1.23 2024/04/25 18:31:49 kn Exp $
|
# $OpenBSD: Makefile.common,v 1.24 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
S= ${.CURDIR}/../../../../..
|
S= ${.CURDIR}/../../../../..
|
||||||
SADIR= ${.CURDIR}/../..
|
SADIR= ${.CURDIR}/../..
|
||||||
|
@ -70,7 +70,7 @@ ${PROG}: ${PROG.so}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
CFLAGS+= -Wno-pointer-sign
|
CFLAGS+= -Wno-pointer-sign
|
||||||
CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD
|
CPPFLAGS+= -DSMALL -DSLOW -D__INTERNAL_LIBSA_CREAD
|
||||||
CPPFLAGS+= -DHEAP_LIMIT=${EFI_HEAP_LIMIT} -DHIBERNATE
|
CPPFLAGS+= -DHEAP_LIMIT=${EFI_HEAP_LIMIT} -DHIBERNATE
|
||||||
|
|
||||||
${PROG.so}: ${OBJS}
|
${PROG.so}: ${OBJS}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.42 2023/04/17 00:05:35 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.43 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
MAN= pxeboot.8
|
MAN= pxeboot.8
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ NOPROG=
|
||||||
|
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
||||||
CFLAGS+=-m32
|
CFLAGS+=-m32
|
||||||
CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.22 2023/10/26 14:13:37 jsg Exp $
|
# $OpenBSD: Makefile,v 1.23 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
NOMAN= #
|
NOMAN= #
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ CPPFLAGS+= -nostdinc
|
||||||
CPPFLAGS+= -I${S} -I. -I${.CURDIR}
|
CPPFLAGS+= -I${S} -I. -I${.CURDIR}
|
||||||
CPPFLAGS+= -I${EFIDIR}/include -I${EFIDIR}/include/arm64
|
CPPFLAGS+= -I${EFIDIR}/include -I${EFIDIR}/include/arm64
|
||||||
CPPFLAGS+= -D_STANDALONE -DBOOT_STTY
|
CPPFLAGS+= -D_STANDALONE -DBOOT_STTY
|
||||||
CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD
|
CPPFLAGS+= -DSMALL -DSLOW -D__INTERNAL_LIBSA_CREAD
|
||||||
CPPFLAGS+= -DNEEDS_HEAP_H -DMDRANDOM -DFWRANDOM
|
CPPFLAGS+= -DNEEDS_HEAP_H -DMDRANDOM -DFWRANDOM
|
||||||
COPTS+= -Wno-attributes -Wno-format
|
COPTS+= -Wno-attributes -Wno-format
|
||||||
COPTS+= -ffreestanding -fno-stack-protector
|
COPTS+= -ffreestanding -fno-stack-protector
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.20 2023/09/06 01:47:37 jsg Exp $
|
# $OpenBSD: Makefile,v 1.21 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
NOMAN= #
|
NOMAN= #
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ CPPFLAGS+= -nostdinc
|
||||||
CPPFLAGS+= -I${S} -I. -I${.CURDIR}
|
CPPFLAGS+= -I${S} -I. -I${.CURDIR}
|
||||||
CPPFLAGS+= -I${EFIDIR}/include -I${EFIDIR}/include/arm
|
CPPFLAGS+= -I${EFIDIR}/include -I${EFIDIR}/include/arm
|
||||||
CPPFLAGS+= -D_STANDALONE -DBOOT_STTY
|
CPPFLAGS+= -D_STANDALONE -DBOOT_STTY
|
||||||
CPPFLAGS+= -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD
|
CPPFLAGS+= -DSMALL -DSLOW -D__INTERNAL_LIBSA_CREAD
|
||||||
CPPFLAGS+= -DNEEDS_HEAP_H
|
CPPFLAGS+= -DNEEDS_HEAP_H
|
||||||
COPTS+= -ffreestanding -fno-stack-protector
|
COPTS+= -ffreestanding -fno-stack-protector
|
||||||
COPTS+= -fshort-wchar -fPIC -fno-builtin
|
COPTS+= -fshort-wchar -fPIC -fno-builtin
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.75 2021/07/08 20:04:58 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.76 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
COPTS?=
|
COPTS?=
|
||||||
MAN?= boot.8
|
MAN?= boot.8
|
||||||
|
@ -83,7 +83,7 @@ NOPROG=
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
.endif
|
.endif
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-DHIBERNATE
|
CPPFLAGS+=-DHIBERNATE
|
||||||
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} -I${S}/stand/boot #-DCOMPAT_UFS
|
||||||
CFLAGS+=-m32 $(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
CFLAGS+=-m32 $(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.39 2021/07/08 20:04:58 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.40 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
MAN= cdboot.8
|
MAN= cdboot.8
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ NOPROG=
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS}
|
||||||
CPPFLAGS+=-DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-I${S}/stand/boot
|
CPPFLAGS+=-I${S}/stand/boot
|
||||||
CFLAGS+=${SACFLAGS} -D__INTERNAL_LIBSA_CREAD
|
CFLAGS+=${SACFLAGS} -D__INTERNAL_LIBSA_CREAD
|
||||||
CFLAGS+=-DOSREV=\"${OSREV}\" -DMACHINE=\"${MACHINE}\"
|
CFLAGS+=-DOSREV=\"${OSREV}\" -DMACHINE=\"${MACHINE}\"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.36 2021/07/08 20:04:58 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.37 2024/06/30 18:17:09 deraadt Exp $
|
||||||
|
|
||||||
MAN= pxeboot.8
|
MAN= pxeboot.8
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ NOPROG=
|
||||||
|
|
||||||
CPPFLAGS+=-DSOFTRAID
|
CPPFLAGS+=-DSOFTRAID
|
||||||
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} -DLINKADDR=${LINKADDR}
|
||||||
CPPFLAGS+=-DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
CPPFLAGS+=-DSLOW -DSMALL -DNO_GZIP -DDYNAMIC_CRC_TABLE -DBUILDFIXED
|
||||||
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT}
|
CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT}
|
||||||
CPPFLAGS+=-I${S}/stand/boot
|
CPPFLAGS+=-I${S}/stand/boot
|
||||||
CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
CFLAGS+=$(SACFLAGS) -D__INTERNAL_LIBSA_CREAD -fno-pie
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $OpenBSD: Makefile,v 1.10 2021/07/08 20:02:42 deraadt Exp $
|
# $OpenBSD: Makefile,v 1.11 2024/06/30 18:17:10 deraadt Exp $
|
||||||
# $NetBSD: Makefile,v 1.2 1997/01/22 01:36:30 cgd Exp $
|
# $NetBSD: Makefile,v 1.2 1997/01/22 01:36:30 cgd Exp $
|
||||||
|
|
||||||
LIB= z
|
LIB= z
|
||||||
|
@ -6,7 +6,7 @@ NOPIC=
|
||||||
NOPROFILE=
|
NOPROFILE=
|
||||||
|
|
||||||
# Tweak knobs to generate small libz code
|
# Tweak knobs to generate small libz code
|
||||||
CPPFLAGS+= -DSLOW -DSMALL -DNOBYFOUR -DNO_GZIP
|
CPPFLAGS+= -DSLOW -DSMALL -DNO_GZIP
|
||||||
CPPFLAGS+= -I. ${ZCPPFLAGS}
|
CPPFLAGS+= -I. ${ZCPPFLAGS}
|
||||||
|
|
||||||
# files to be copied down from libz.
|
# files to be copied down from libz.
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
|
||||||
#define MY_ZCALLOC
|
#define MY_ZCALLOC
|
||||||
#define NOBYFOUR
|
|
||||||
|
|
||||||
typedef long ptrdiff_t;
|
typedef long ptrdiff_t;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue