Import dhcpcd-5.1.1
Changes from dhcpcd-5.0.7 include * Only allow hardware families we know by default (over-ridable) * Fix persistent and timeout 0 options * Fix parsing of escape code sequencies * Don't bring up interfaces brought down when handling new interfaces * Allow un-encapsulated vendor option * Don't null terminate gratuitously when handling quotes * Fix various typos and grammatical errors * dhcpcd.conf simplified a little
This commit is contained in:
parent
350f3d2e59
commit
cc2e8e7e32
1
external/bsd/dhcpcd/dist/arp.c
vendored
1
external/bsd/dhcpcd/dist/arp.c
vendored
@ -28,6 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
2
external/bsd/dhcpcd/dist/bind.c
vendored
2
external/bsd/dhcpcd/dist/bind.c
vendored
@ -26,6 +26,8 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#ifdef BSD
|
||||
# include <paths.h>
|
||||
|
115
external/bsd/dhcpcd/dist/common.c
vendored
115
external/bsd/dhcpcd/dist/common.c
vendored
@ -25,6 +25,9 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Needed define to get at getline for glibc and FreeBSD */
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -35,7 +38,9 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#ifdef BSD
|
||||
# include <paths.h>
|
||||
#endif
|
||||
@ -56,16 +61,19 @@
|
||||
int clock_monotonic;
|
||||
static char *lbuf;
|
||||
static size_t lbuf_len;
|
||||
#ifdef DEBUG_MEMORY
|
||||
static char lbuf_set;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
static void
|
||||
free_lbuf(void)
|
||||
{
|
||||
free(lbuf);
|
||||
lbuf = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Handy routine to read very long lines in text files.
|
||||
* This means we read the whole line and avoid any nasty buffer overflows.
|
||||
* We strip leading space and avoid comment lines, making the code that calls
|
||||
@ -74,107 +82,28 @@ free_lbuf(void)
|
||||
char *
|
||||
get_line(FILE * __restrict fp)
|
||||
{
|
||||
char *p, *e;
|
||||
size_t last;
|
||||
|
||||
again:
|
||||
if (feof(fp))
|
||||
return NULL;
|
||||
char *p;
|
||||
ssize_t bytes;
|
||||
|
||||
#ifdef DEBUG_MEMORY
|
||||
if (lbuf == NULL)
|
||||
if (lbuf_set == 0) {
|
||||
atexit(free_lbuf);
|
||||
lbuf_set = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
last = 0;
|
||||
do {
|
||||
if (lbuf == NULL || last != 0) {
|
||||
lbuf_len += BUFSIZ;
|
||||
lbuf = xrealloc(lbuf, lbuf_len);
|
||||
}
|
||||
p = lbuf + last;
|
||||
memset(p, 0, BUFSIZ);
|
||||
if (fgets(p, BUFSIZ, fp) == NULL)
|
||||
break;
|
||||
last += strlen(p);
|
||||
if (last != 0 && lbuf[last - 1] == '\n') {
|
||||
lbuf[last - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
} while(!feof(fp));
|
||||
if (last == 0)
|
||||
return NULL;
|
||||
|
||||
e = p + last - 1;
|
||||
for (p = lbuf; p < e; p++) {
|
||||
if (*p != ' ' && *p != '\t')
|
||||
break;
|
||||
}
|
||||
if (p == e || *p == '#' || *p == ';')
|
||||
goto again;
|
||||
bytes = getline(&lbuf, &lbuf_len, fp);
|
||||
if (bytes == -1)
|
||||
return NULL;
|
||||
for (p = lbuf; *p == ' ' || *p == '\t'; p++)
|
||||
;
|
||||
} while (*p == '\0' || *p == '\n' || *p == '#' || *p == ';');
|
||||
if (lbuf[--bytes] == '\n')
|
||||
lbuf[bytes] = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Simple hack to return a random number without arc4random */
|
||||
#ifndef HAVE_ARC4RANDOM
|
||||
uint32_t arc4random(void)
|
||||
{
|
||||
int fd;
|
||||
static unsigned long seed;
|
||||
|
||||
if (seed == 0) {
|
||||
fd = open("/dev/urandom", 0);
|
||||
if (fd == -1 || read(fd, &seed, sizeof(seed)) == -1)
|
||||
seed = time(0);
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
srandom(seed);
|
||||
}
|
||||
|
||||
return (uint32_t)random();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* strlcpy is nice, shame glibc does not define it */
|
||||
#if HAVE_STRLCPY
|
||||
#else
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
const char *s = src;
|
||||
size_t n = size;
|
||||
|
||||
if (n && --n)
|
||||
do {
|
||||
if (!(*dst++ = *src++))
|
||||
break;
|
||||
} while (--n);
|
||||
|
||||
if (!n) {
|
||||
if (size)
|
||||
*dst = '\0';
|
||||
while (*src++);
|
||||
}
|
||||
|
||||
return src - s - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_CLOSEFROM
|
||||
#else
|
||||
int
|
||||
closefrom(int fd)
|
||||
{
|
||||
int max = getdtablesize();
|
||||
int i;
|
||||
int r = 0;
|
||||
|
||||
for (i = fd; i < max; i++)
|
||||
r += close(i);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
set_cloexec(int fd)
|
||||
{
|
||||
|
37
external/bsd/dhcpcd/dist/common.h
vendored
37
external/bsd/dhcpcd/dist/common.h
vendored
@ -28,12 +28,11 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
/* string.h pulls in features.h so the below define checks work */
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "defs.h"
|
||||
|
||||
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
|
||||
@ -68,34 +67,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ARC4RANDOM
|
||||
# ifdef __GLIBC__
|
||||
uint32_t arc4random(void);
|
||||
#else
|
||||
# define HAVE_ARC4RANDOM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
# define HAVE_STRLCPY 1
|
||||
#endif
|
||||
/* Only GLIBC doesn't support strlcpy */
|
||||
#ifdef __GLIBC__
|
||||
# if !defined(__UCLIBC__) && !defined (__dietlibc__)
|
||||
# undef HAVE_STRLCPY
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
# define HAVE_CLOSEFROM 1
|
||||
# endif
|
||||
#endif
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
int closefrom(int);
|
||||
#endif
|
||||
|
||||
int set_cloexec(int);
|
||||
int set_nonblock(int);
|
||||
char *get_line(FILE * __restrict);
|
||||
|
75
external/bsd/dhcpcd/dist/compat/getline.c
vendored
Normal file
75
external/bsd/dhcpcd/dist/compat/getline.c
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
* All rights reserved
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getline.h"
|
||||
|
||||
/* Redefine a small buffer for our simple text config files */
|
||||
#undef BUFSIZ
|
||||
#define BUFSIZ 128
|
||||
|
||||
ssize_t
|
||||
getline(char ** __restrict buf, size_t * __restrict buflen,
|
||||
FILE * __restrict fp)
|
||||
{
|
||||
size_t bytes, newlen;
|
||||
char *newbuf, *p;
|
||||
|
||||
if (buf == NULL || buflen == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (*buf == NULL)
|
||||
*buflen = 0;
|
||||
|
||||
bytes = 0;
|
||||
do {
|
||||
if (feof(fp))
|
||||
break;
|
||||
if (*buf == NULL || bytes != 0) {
|
||||
newlen = *buflen + BUFSIZ;
|
||||
newbuf = realloc(*buf, newlen);
|
||||
if (newbuf == NULL)
|
||||
return -1;
|
||||
*buf = newbuf;
|
||||
*buflen = newlen;
|
||||
}
|
||||
p = *buf + bytes;
|
||||
memset(p, 0, BUFSIZ);
|
||||
if (fgets(p, BUFSIZ, fp) == NULL)
|
||||
break;
|
||||
bytes += strlen(p);
|
||||
} while (bytes == 0 || *(*buf + (bytes - 1)) != '\n');
|
||||
if (bytes == 0)
|
||||
return -1;
|
||||
return bytes;
|
||||
}
|
36
external/bsd/dhcpcd/dist/compat/getline.h
vendored
Normal file
36
external/bsd/dhcpcd/dist/compat/getline.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
* All rights reserved
|
||||
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef GETLINE_H
|
||||
#define GETLINE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ssize_t getline(char ** __restrict buf, size_t * __restrict buflen,
|
||||
FILE * __restrict fp);
|
||||
#endif
|
76
external/bsd/dhcpcd/dist/config.h
vendored
76
external/bsd/dhcpcd/dist/config.h
vendored
@ -1,69 +1,7 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define PACKAGE "dhcpcd"
|
||||
#define VERSION "5.0.7"
|
||||
|
||||
/* Some systems do not have a working fork. */
|
||||
/* #define THERE_IS_NO_FORK */
|
||||
|
||||
/* Paths to things */
|
||||
#ifndef SYSCONFDIR
|
||||
# define SYSCONFDIR "/etc"
|
||||
#endif
|
||||
#ifndef LIBEXECDIR
|
||||
# define LIBEXECDIR "/libexec"
|
||||
#endif
|
||||
#ifndef RUNDIR
|
||||
# define RUNDIR "/var/run"
|
||||
#endif
|
||||
#ifndef DBDIR
|
||||
# define DBDIR "/var/db"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG
|
||||
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
|
||||
#endif
|
||||
#ifndef SCRIPT
|
||||
# define SCRIPT LIBEXECDIR "/" PACKAGE "-run-hooks"
|
||||
#endif
|
||||
#ifndef DUID
|
||||
# define DUID SYSCONFDIR "/" PACKAGE ".duid"
|
||||
#endif
|
||||
#ifndef LEASEFILE
|
||||
# define LEASEFILE DBDIR "/" PACKAGE "-%s.lease"
|
||||
#endif
|
||||
#ifndef PIDFILE
|
||||
# define PIDFILE RUNDIR "/" PACKAGE "%s%s.pid"
|
||||
#endif
|
||||
#ifndef CONTROLSOCKET
|
||||
# define CONTROLSOCKET RUNDIR "/" PACKAGE ".sock"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* netbsd */
|
||||
#define SYSCONFDIR "/etc"
|
||||
#define SBINDIR "/sbin"
|
||||
#define LIBEXECDIR "/libexec"
|
||||
#define DBDIR "/var/db"
|
||||
#define RUNDIR "/var/run"
|
||||
#include "compat/getline.h"
|
||||
|
11
external/bsd/dhcpcd/dist/configure.c
vendored
11
external/bsd/dhcpcd/dist/configure.c
vendored
@ -36,6 +36,7 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -654,10 +655,12 @@ configure(struct interface *iface)
|
||||
sort_interfaces();
|
||||
|
||||
if (dhcp == NULL) {
|
||||
build_routes();
|
||||
if (iface->addr.s_addr != 0)
|
||||
delete_address(iface);
|
||||
run_script(iface);
|
||||
if (!(ifo->options & DHCPCD_PERSISTENT)) {
|
||||
build_routes();
|
||||
if (iface->addr.s_addr != 0)
|
||||
delete_address(iface);
|
||||
run_script(iface);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
1
external/bsd/dhcpcd/dist/control.c
vendored
1
external/bsd/dhcpcd/dist/control.c
vendored
@ -31,6 +31,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
52
external/bsd/dhcpcd/dist/defs.h
vendored
Normal file
52
external/bsd/dhcpcd/dist/defs.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* dhcpcd - DHCP client daemon
|
||||
* Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define PACKAGE "dhcpcd"
|
||||
#define VERSION "5.1.1"
|
||||
|
||||
#ifndef CONFIG
|
||||
# define CONFIG SYSCONFDIR "/" PACKAGE ".conf"
|
||||
#endif
|
||||
#ifndef SCRIPT
|
||||
# define SCRIPT LIBEXECDIR "/" PACKAGE "-run-hooks"
|
||||
#endif
|
||||
#ifndef DUID
|
||||
# define DUID SYSCONFDIR "/" PACKAGE ".duid"
|
||||
#endif
|
||||
#ifndef LEASEFILE
|
||||
# define LEASEFILE DBDIR "/" PACKAGE "-%s.lease"
|
||||
#endif
|
||||
#ifndef PIDFILE
|
||||
# define PIDFILE RUNDIR "/" PACKAGE "%s%s.pid"
|
||||
#endif
|
||||
#ifndef CONTROLSOCKET
|
||||
# define CONTROLSOCKET RUNDIR "/" PACKAGE ".sock"
|
||||
#endif
|
||||
|
||||
#endif
|
38
external/bsd/dhcpcd/dist/dhcpcd.c
vendored
38
external/bsd/dhcpcd/dist/dhcpcd.c
vendored
@ -30,6 +30,7 @@ const char copyright[] = "Copyright (c) 2006-2009 Roy Marples";
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
@ -1187,7 +1188,7 @@ void
|
||||
handle_interface(int action, const char *ifname)
|
||||
{
|
||||
struct interface *ifs, *ifp, *ifn, *ifl = NULL;
|
||||
const char * const argv[] = { "dhcpcd", ifname };
|
||||
const char * const argv[] = { ifname };
|
||||
int i;
|
||||
|
||||
if (action == -1) {
|
||||
@ -1209,23 +1210,24 @@ handle_interface(int action, const char *ifname)
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ifs = discover_interfaces(2, UNCONST(argv)))) {
|
||||
for (ifp = ifs; ifp; ifp = ifp->next) {
|
||||
/* Check if we already have the interface */
|
||||
for (ifn = ifaces; ifn; ifn = ifn->next) {
|
||||
if (strcmp(ifn->name, ifp->name) == 0)
|
||||
break;
|
||||
ifl = ifn;
|
||||
}
|
||||
if (ifn)
|
||||
continue;
|
||||
init_state(ifp, 2, UNCONST(argv));
|
||||
if (ifl)
|
||||
ifl->next = ifp;
|
||||
else
|
||||
ifaces = ifp;
|
||||
start_interface(ifp);
|
||||
ifs = discover_interfaces(-1, UNCONST(argv));
|
||||
for (ifp = ifs; ifp; ifp = ifp->next) {
|
||||
if (strcmp(ifp->name, ifname) != 0)
|
||||
continue;
|
||||
/* Check if we already have the interface */
|
||||
for (ifn = ifaces; ifn; ifn = ifn->next) {
|
||||
if (strcmp(ifn->name, ifp->name) == 0)
|
||||
break;
|
||||
ifl = ifn;
|
||||
}
|
||||
if (ifn)
|
||||
continue;
|
||||
init_state(ifp, 0, NULL);
|
||||
if (ifl)
|
||||
ifl->next = ifp;
|
||||
else
|
||||
ifaces = ifp;
|
||||
start_interface(ifp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1752,7 +1754,7 @@ main(int argc, char **argv)
|
||||
(ifc == 0 && options & DHCPCD_LINK && options & DHCPCD_DAEMONISE))
|
||||
{
|
||||
daemonise();
|
||||
} else if (options & DHCPCD_DAEMONISE) {
|
||||
} else if (options & DHCPCD_DAEMONISE && ifo->timeout > 0) {
|
||||
oi = ifo->timeout;
|
||||
if (ifo->options & DHCPCD_IPV4LL)
|
||||
oi += 10;
|
||||
|
7
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
vendored
7
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
vendored
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd July 26, 2009
|
||||
.Dd September 2, 2009
|
||||
.Dt DHCPCD.CONF 5 SMM
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -256,6 +256,9 @@ You can specify more than one.
|
||||
Add an enscapulated vendor option.
|
||||
.Ar code
|
||||
should be between 1 and 254 inclusive.
|
||||
To add a raw vendor string, omit
|
||||
.Ar code
|
||||
but keep the comma.
|
||||
Examples.
|
||||
.Pp
|
||||
Set the vendor option 01 with an IP address.
|
||||
@ -264,6 +267,8 @@ Set the vendor option 02 with a hex code.
|
||||
.D1 vendor 02,01:02:03:04:05
|
||||
Set the vendor option 03 with an IP address as a string.
|
||||
.D1 vendor 03,\e"192.168.0.2\e"
|
||||
Set un-encapulated vendor option to hello world.
|
||||
.D1 vendor ,"hello world"
|
||||
.It Ic vendorclassid Ar string
|
||||
Change the default vendorclassid sent from dhcpcd-version.
|
||||
If not set then none is sent.
|
||||
|
1
external/bsd/dhcpcd/dist/duid.c
vendored
1
external/bsd/dhcpcd/dist/duid.c
vendored
@ -30,6 +30,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
35
external/bsd/dhcpcd/dist/if-options.c
vendored
35
external/bsd/dhcpcd/dist/if-options.c
vendored
@ -203,20 +203,24 @@ parse_string_hwaddr(char *sbuf, ssize_t slen, const char *str, int clid)
|
||||
}
|
||||
if (*str == '\\') {
|
||||
str++;
|
||||
switch(*str++) {
|
||||
switch(*str) {
|
||||
case '\0':
|
||||
break;
|
||||
case 'b':
|
||||
*sbuf++ = '\b';
|
||||
str++;
|
||||
break;
|
||||
case 'n':
|
||||
*sbuf++ = '\n';
|
||||
str++;
|
||||
break;
|
||||
case 'r':
|
||||
*sbuf++ = '\r';
|
||||
str++;
|
||||
break;
|
||||
case 't':
|
||||
*sbuf++ = '\t';
|
||||
str++;
|
||||
break;
|
||||
case 'x':
|
||||
/* Grab a hex code */
|
||||
@ -254,8 +258,10 @@ parse_string_hwaddr(char *sbuf, ssize_t slen, const char *str, int clid)
|
||||
} else
|
||||
*sbuf++ = *str++;
|
||||
}
|
||||
if (punt_last)
|
||||
if (punt_last) {
|
||||
*--sbuf = '\0';
|
||||
l--;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@ -450,6 +456,27 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
|
||||
syslog(LOG_ERR, "invalid vendor format");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If vendor starts with , then it is not encapsulated */
|
||||
if (p == arg) {
|
||||
arg++;
|
||||
s = parse_string((char *)ifo->vendor + 1,
|
||||
VENDOR_MAX_LEN, arg);
|
||||
if (s == -1) {
|
||||
syslog(LOG_ERR, "vendor: %m");
|
||||
return -1;
|
||||
}
|
||||
ifo->vendor[0] = (uint8_t)s;
|
||||
ifo->options |= DHCPCD_VENDORRAW;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Encapsulated vendor options */
|
||||
if (ifo->options & DHCPCD_VENDORRAW) {
|
||||
ifo->options &= ~DHCPCD_VENDORRAW;
|
||||
ifo->vendor[0] = 0;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
i = atoint(arg);
|
||||
arg = p + 1;
|
||||
@ -810,7 +837,7 @@ read_config(const char *file,
|
||||
}
|
||||
|
||||
/* Terminate the encapsulated options */
|
||||
if (ifo && ifo->vendor[0]) {
|
||||
if (ifo && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
|
||||
ifo->vendor[0]++;
|
||||
ifo->vendor[ifo->vendor[0]] = DHO_END;
|
||||
}
|
||||
@ -830,7 +857,7 @@ add_options(struct if_options *ifo, int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
/* Terminate the encapsulated options */
|
||||
if (r == 1 && ifo->vendor[0]) {
|
||||
if (r == 1 && ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) {
|
||||
ifo->vendor[0]++;
|
||||
ifo->vendor[ifo->vendor[0]] = DHO_END;
|
||||
}
|
||||
|
1
external/bsd/dhcpcd/dist/if-options.h
vendored
1
external/bsd/dhcpcd/dist/if-options.h
vendored
@ -69,6 +69,7 @@
|
||||
#define DHCPCD_LINK (1 << 20)
|
||||
#define DHCPCD_QUIET (1 << 21)
|
||||
#define DHCPCD_BACKGROUND (1 << 22)
|
||||
#define DHCPCD_VENDORRAW (1 << 23)
|
||||
|
||||
extern const struct option cf_options[];
|
||||
|
||||
|
2
external/bsd/dhcpcd/dist/if-pref.c
vendored
2
external/bsd/dhcpcd/dist/if-pref.c
vendored
@ -25,6 +25,8 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "dhcpcd.h"
|
||||
#include "if-pref.h"
|
||||
|
1
external/bsd/dhcpcd/dist/ipv4ll.c
vendored
1
external/bsd/dhcpcd/dist/ipv4ll.c
vendored
@ -28,6 +28,7 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
43
external/bsd/dhcpcd/dist/net.c
vendored
43
external/bsd/dhcpcd/dist/net.c
vendored
@ -99,7 +99,7 @@ inet_cidrtoaddr(int cidr, struct in_addr *addr)
|
||||
if (ocets > 0) {
|
||||
memset(&addr->s_addr, 255, (size_t)ocets - 1);
|
||||
|
||||
memset((unsigned char *)&addr->s_addr + (ocets - 1),
|
||||
memset((unsigned char *)&addr->s_addr + (ocets - 1),
|
||||
(256 - (1 << (32 - cidr) % 8)), 1);
|
||||
}
|
||||
|
||||
@ -218,21 +218,20 @@ init_interface(const char *ifname)
|
||||
goto eexit;
|
||||
}
|
||||
|
||||
if (up_interface(ifname) != 0)
|
||||
goto eexit;
|
||||
snprintf(iface->leasefile, sizeof(iface->leasefile),
|
||||
LEASEFILE, ifname);
|
||||
/* 0 is a valid fd, so init to -1 */
|
||||
iface->raw_fd = -1;
|
||||
iface->udp_fd = -1;
|
||||
iface->arp_fd = -1;
|
||||
close(s);
|
||||
return iface;
|
||||
goto exit;
|
||||
|
||||
eexit:
|
||||
free(iface);
|
||||
iface = NULL;
|
||||
exit:
|
||||
close(s);
|
||||
return NULL;
|
||||
return iface;
|
||||
}
|
||||
|
||||
void
|
||||
@ -308,6 +307,11 @@ discover_interfaces(int argc, char * const *argv)
|
||||
continue;
|
||||
p = argv[i];
|
||||
} else {
|
||||
/* -1 means we're discovering against a specific
|
||||
* interface, but we still need the below rules
|
||||
* to apply. */
|
||||
if (argc == -1 && strcmp(argv[0], ifa->ifa_name) != 0)
|
||||
continue;
|
||||
for (i = 0; i < ifdc; i++)
|
||||
if (!fnmatch(ifdv[i], ifa->ifa_name, 0))
|
||||
break;
|
||||
@ -322,6 +326,15 @@ discover_interfaces(int argc, char * const *argv)
|
||||
}
|
||||
if ((ifp = init_interface(p)) == NULL)
|
||||
continue;
|
||||
|
||||
/* Bring the interface up */
|
||||
if (!(ifp->flags & IFF_UP) && up_interface(p) != 0)
|
||||
/* Some drivers return ENODEV here when they are disabled by a switch.
|
||||
* We just blunder on as the carrier will be down anyway.
|
||||
* When the switch is enabled, it should bring the interface up.
|
||||
* Then we'll spot the carrier and start working. */
|
||||
syslog(LOG_ERR, "%s: up_interface: %m", p);
|
||||
|
||||
/* Don't allow loopback unless explicit */
|
||||
if (ifp->flags & IFF_LOOPBACK) {
|
||||
if (argc == 0 && ifac == 0) {
|
||||
@ -351,6 +364,22 @@ discover_interfaces(int argc, char * const *argv)
|
||||
if (ifp->hwlen != 0)
|
||||
memcpy(ifp->hwaddr, sll->sll_addr, ifp->hwlen);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if (!(ifp->flags & IFF_POINTOPOINT)) {
|
||||
switch(ifp->family) {
|
||||
case ARPHRD_ETHER: /* FALLTHROUGH */
|
||||
case ARPHRD_IEEE1394:
|
||||
break;
|
||||
default:
|
||||
if (argc == 0 && ifac == 0) {
|
||||
free_interface(ifp);
|
||||
continue;
|
||||
}
|
||||
syslog(LOG_WARNING,
|
||||
"%s: unknown hardware family", p);
|
||||
}
|
||||
}
|
||||
if (ifl)
|
||||
ifl->next = ifp;
|
||||
@ -383,7 +412,7 @@ do_address(const char *ifname,
|
||||
n = (const struct sockaddr_in *)(void *)ifa->ifa_netmask;
|
||||
if (ifa->ifa_flags & IFF_POINTOPOINT)
|
||||
d = (const struct sockaddr_in *)(void *)
|
||||
ifa->ifa_dstaddr;
|
||||
ifa->ifa_dstaddr;
|
||||
else
|
||||
d = NULL;
|
||||
if (act == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user