Probe for the availability of AF_INET6 at startup. If it's not
available, default ipv6cp to disabled and refuse to let the user enable it.
This commit is contained in:
parent
bbebfb9f8c
commit
1b1f9ae878
@ -99,6 +99,7 @@
|
||||
#include "datalink.h"
|
||||
#include "iface.h"
|
||||
#include "server.h"
|
||||
#include "probe.h"
|
||||
#ifdef HAVE_DES
|
||||
#include "mppe.h"
|
||||
#endif
|
||||
@ -809,10 +810,12 @@ bundle_Create(const char *prefix, int type, int unit)
|
||||
*bundle.cfg.auth.name = '\0';
|
||||
*bundle.cfg.auth.key = '\0';
|
||||
bundle.cfg.opt = OPT_IDCHECK | OPT_LOOPBACK | OPT_SROUTES | OPT_TCPMSSFIXUP |
|
||||
#ifndef NOINET6
|
||||
OPT_IPCP | OPT_IPV6CP |
|
||||
#endif
|
||||
OPT_THROUGHPUT | OPT_UTMP;
|
||||
#ifndef NOINET6
|
||||
bundle.cfg.opt |= OPT_IPCP;
|
||||
if (probe.ipv6_available)
|
||||
bundle.cfg.opt |= OPT_IPV6CP;
|
||||
#endif
|
||||
*bundle.cfg.label = '\0';
|
||||
bundle.cfg.ifqueue = DEF_IFQUEUE;
|
||||
bundle.cfg.choked.timeout = CHOKED_TIMEOUT;
|
||||
|
@ -101,6 +101,7 @@
|
||||
#include "datalink.h"
|
||||
#include "iface.h"
|
||||
#include "id.h"
|
||||
#include "probe.h"
|
||||
|
||||
/* ``set'' values */
|
||||
#define VAR_AUTHKEY 0
|
||||
@ -2573,13 +2574,19 @@ OptSet(struct cmdargs const *arg)
|
||||
unsigned keep; /* Keep these bits */
|
||||
unsigned add; /* Add these bits */
|
||||
|
||||
if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL)
|
||||
if (ident_cmd(arg->argv[arg->argn - 2], &keep, &add) == NULL)
|
||||
return 1;
|
||||
|
||||
if (add == NEG_ENABLED && bit == OPT_IPV6CP && !probe.ipv6_available) {
|
||||
log_Printf(LogWARN, "IPv6 is not available on this machine\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (add)
|
||||
arg->bundle->cfg.opt |= bit;
|
||||
else
|
||||
arg->bundle->cfg.opt &= ~bit;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,8 @@ main(int argc, char **argv)
|
||||
struct prompt *prompt;
|
||||
struct switches sw;
|
||||
|
||||
probe_Init();
|
||||
|
||||
/*
|
||||
* We open 3 descriptors to ensure that STDIN_FILENO, STDOUT_FILENO and
|
||||
* STDERR_FILENO are always open. These are closed before DoLoop(),
|
||||
@ -531,9 +533,6 @@ DoLoop(struct bundle *bundle)
|
||||
{
|
||||
fd_set *rfds, *wfds, *efds;
|
||||
int i, nfds, nothing_done;
|
||||
struct probe probe;
|
||||
|
||||
probe_Init(&probe);
|
||||
|
||||
if ((rfds = mkfdset()) == NULL) {
|
||||
log_Printf(LogERROR, "DoLoop: Cannot create fd_set\n");
|
||||
|
@ -27,11 +27,15 @@
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "probe.h"
|
||||
#include "log.h"
|
||||
|
||||
struct probe probe;
|
||||
|
||||
/* Does select() alter the passed time value ? */
|
||||
static int
|
||||
select_changes_time(void)
|
||||
@ -44,10 +48,29 @@ select_changes_time(void)
|
||||
return t.tv_usec != 100000;
|
||||
}
|
||||
|
||||
void
|
||||
probe_Init(struct probe *p)
|
||||
#ifndef NOINET6
|
||||
static int
|
||||
ipv6_available(void)
|
||||
{
|
||||
p->select_changes_time = select_changes_time() ? 1 : 0;
|
||||
log_Printf(LogDEBUG, "Select changes time: %s\n",
|
||||
p->select_changes_time ? "yes" : "no");
|
||||
int s;
|
||||
|
||||
if ((s = ID0socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
|
||||
return 0;
|
||||
|
||||
close(s);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
probe_Init()
|
||||
{
|
||||
probe.select_changes_time = select_changes_time() ? 1 : 0;
|
||||
log_Printf(LogDEBUG, "Select changes time: %s\n",
|
||||
probe.select_changes_time ? "yes" : "no");
|
||||
#ifndef NOINET6
|
||||
probe.ipv6_available = ipv6_available() ? 1 : 0;
|
||||
log_Printf(LogDEBUG, "IPv6 available: %s\n",
|
||||
probe.ipv6_available ? "yes" : "no");
|
||||
#endif
|
||||
}
|
||||
|
@ -28,6 +28,11 @@
|
||||
|
||||
struct probe {
|
||||
unsigned select_changes_time : 1;
|
||||
#ifndef NOINET6
|
||||
unsigned ipv6_available : 1;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern void probe_Init(struct probe *);
|
||||
extern struct probe probe;
|
||||
|
||||
extern void probe_Init(void);
|
||||
|
Loading…
Reference in New Issue
Block a user