aboutsummaryrefslogtreecommitdiffstats
path: root/platform-linux.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2012-07-23 16:45:46 -0700
committerDmitry Shmidt <dimitrysh@google.com>2012-07-23 16:54:15 -0700
commita3a2260384a906e1674c7498c2f479e9f37bc503 (patch)
tree5e5adc874a930144f847f57a08da862413b63668 /platform-linux.c
parent2af699ea51cca49bd0f19080c9d73170e5bdadbc (diff)
downloadexternal_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.zip
external_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.tar.gz
external_dhcpcd-a3a2260384a906e1674c7498c2f479e9f37bc503.tar.bz2
dhcpcd: Update to Version 5.5.6
Change-Id: I98c378688be723a2a602ec17c26bc13f2fd83cc8 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'platform-linux.c')
-rw-r--r--platform-linux.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/platform-linux.c b/platform-linux.c
index 79562c8..119ec50 100644
--- a/platform-linux.c
+++ b/platform-linux.c
@@ -1,6 +1,6 @@
/*
* dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2012 Roy Marples <roy@marples.name>
* All rights reserved
* Redistribution and use in source and binary forms, with or without
@@ -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"
@@ -102,3 +104,50 @@ hardware_platform(void)
errno = ESRCH;
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);
+}
+
+static const char *prefix = "/proc/sys/net/ipv6/conf";
+
+int
+check_ipv6(const char *ifname)
+{
+ int r;
+ char path[256];
+
+ if (ifname == NULL)
+ ifname = "all";
+
+ snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ifname);
+ r = check_proc_int(path);
+ if (r != 1 && r != 2) {
+ syslog(LOG_WARNING,
+ "%s: not configured to accept IPv6 RAs", ifname);
+ return 0;
+ }
+
+ if (r != 2) {
+ snprintf(path, sizeof(path), "%s/%s/forwarding",
+ prefix, ifname);
+ if (check_proc_int(path) != 0) {
+ syslog(LOG_WARNING,
+ "%s: configured as a router, not a host", ifname);
+ return 0;
+ }
+ }
+ return 1;
+}