In case IPv6 is not enabled don't try to init DHCPv6/RA and NDP but only
init DHCPv4. This allows odhcpd to start up in absence of IPv6 support.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
uloop_end();
}
-
static void print_usage(const char *app)
{
printf(
);
}
+static bool ipv6_enabled(void)
+{
+ int fd = socket(AF_INET6, SOCK_DGRAM, 0);
+
+ if (fd < 0)
+ return false;
+
+ close(fd);
+
+ return true;
+}
int main(int argc, char **argv)
{
if (netlink_init())
return 4;
- if (router_init())
- return 4;
+ if (ipv6_enabled()) {
+ if (router_init())
+ return 4;
- if (dhcpv6_init())
- return 4;
+ if (dhcpv6_init())
+ return 4;
- if (ndp_init())
+ if (ndp_init())
+ return 4;
+ }
+#ifndef DHCPV4_SUPPORT
+ else
return 4;
-
-#ifdef DHCPV4_SUPPORT
+#else
if (dhcpv4_init())
return 4;
#endif