summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-02-04 15:37:42 +0000
committerRoy Marples <roy@marples.name>2012-02-04 15:37:42 +0000
commit0d77ae0270f65b957bd7678ad978530637a22a59 (patch)
tree0c72e386bbe53d275e178e472d34aa3bb15c0420
parent441b06bc38676163fff3b6f6e97a59906759b662 (diff)
downloaddhcpcd-0d77ae0270f65b957bd7678ad978530637a22a59.tar.xz
Add kernel IPv6 RA and forwarding detection on Linux.
-rw-r--r--platform-linux.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/platform-linux.c b/platform-linux.c
index 923c9746..e2d2844b 100644
--- a/platform-linux.c
+++ b/platform-linux.c
@@ -27,7 +27,9 @@
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
#include "common.h"
#include "platform.h"
@@ -103,10 +105,35 @@ hardware_platform(void)
return p;
}
+static int
+check_proc_int(const char *path)
+{
+ FILE *fp;
+ char *buf;
+
+ fp = fopen(path, "r");
+ if (fp == NULL)
+ return -1;
+ buf = get_line(fp);
+ fclose(fp);
+ if (buf == NULL)
+ return -1;
+ return atoi(buf);
+}
+
int
check_ipv6(void)
{
-
- // FIXME: Add IPv6 detection here
- return 1;
+
+ if (check_proc_int("/proc/sys/net/ipv6/conf/all/accept_ra") != 1) {
+ syslog(LOG_WARNING,
+ "Kernel is not configured to accept IPv6 RAs");
+ return 0;
+ }
+ if (check_proc_int("/proc/sys/net/ipv6/conf/all/forwarding") != 0) {
+ syslog(LOG_WARNING,
+ "Kernel is configured as a router, not a host");
+ return 0;
+ }
+ return 1;
}