diff options
author | brian <brian@FreeBSD.org> | 2001-08-15 13:53:38 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-15 13:53:38 +0000 |
commit | 1b1f9ae87849ba39b6e788293de28036e0b1dd38 (patch) | |
tree | eaaf26c704b6c4694590d7b0932894ce1fe8067f /usr.sbin/ppp/probe.c | |
parent | bbebfb9f8c06d991af6a4d982893bb211e80d572 (diff) | |
download | FreeBSD-src-1b1f9ae87849ba39b6e788293de28036e0b1dd38.zip FreeBSD-src-1b1f9ae87849ba39b6e788293de28036e0b1dd38.tar.gz |
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.
Diffstat (limited to 'usr.sbin/ppp/probe.c')
-rw-r--r-- | usr.sbin/ppp/probe.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/usr.sbin/ppp/probe.c b/usr.sbin/ppp/probe.c index 0b6b617..4cca3cb 100644 --- a/usr.sbin/ppp/probe.c +++ b/usr.sbin/ppp/probe.c @@ -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; } +#ifndef NOINET6 +static int +ipv6_available(void) +{ + int s; + + if ((s = ID0socket(AF_INET6, SOCK_DGRAM, 0)) == -1) + return 0; + + close(s); + return 1; +} +#endif + void -probe_Init(struct probe *p) +probe_Init() { - p->select_changes_time = select_changes_time() ? 1 : 0; + probe.select_changes_time = select_changes_time() ? 1 : 0; log_Printf(LogDEBUG, "Select changes time: %s\n", - p->select_changes_time ? "yes" : "no"); + 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 } |