changeset 2952:ac7eb3cb75ad draft

ipi6.ifiindex differes between OS's so have a cast function
author Roy Marples <roy@marples.name>
date Wed, 18 Feb 2015 20:09:57 +0000
parents 46e9825593fd
children 3d8a77ba7ca6
files dhcp6.c ipv6.h ipv6nd.c
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dhcp6.c	Wed Feb 18 16:52:49 2015 +0000
+++ b/dhcp6.c	Wed Feb 18 20:09:57 2015 +0000
@@ -1127,7 +1127,7 @@
 	cm->cmsg_type = IPV6_PKTINFO;
 	cm->cmsg_len = CMSG_LEN(sizeof(pi));
 	memset(&pi, 0, sizeof(pi));
-	pi.ipi6_ifindex = ifp->index;
+	pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
 	memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
 	if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
--- a/ipv6.h	Wed Feb 18 16:52:49 2015 +0000
+++ b/ipv6.h	Wed Feb 18 20:09:57 2015 +0000
@@ -186,6 +186,14 @@
 #define IP6BUFLEN	(CMSG_SPACE(sizeof(struct in6_pktinfo)) + \
 			CMSG_SPACE(sizeof(int)))
 
+
+/* ipi6.ifiindex differes between OS's so have a cast function */
+#ifdef __linux__
+#define CAST_IPI6_IFINDEX(idx) (int)(idx)
+#else
+#define CAST_IPI6_IFINDEX(idx) (idx)
+#endif
+
 #ifdef INET6
 struct ipv6_ctx {
 	struct sockaddr_in6 from;
@@ -205,9 +213,7 @@
 
 	int dhcp_fd;
 };
-#endif
 
-#ifdef INET6
 struct ipv6_ctx *ipv6_init(struct dhcpcd_ctx *);
 ssize_t ipv6_printaddr(char *, size_t, const uint8_t *, const char *);
 int ipv6_makestableprivate(struct in6_addr *addr,
--- a/ipv6nd.c	Wed Feb 18 16:52:49 2015 +0000
+++ b/ipv6nd.c	Wed Feb 18 20:09:57 2015 +0000
@@ -296,7 +296,7 @@
 	cm->cmsg_type = IPV6_PKTINFO;
 	cm->cmsg_len = CMSG_LEN(sizeof(pi));
 	memset(&pi, 0, sizeof(pi));
-	pi.ipi6_ifindex = ifp->index;
+	pi.ipi6_ifindex = CAST_IPI6_IFINDEX(ifp->index);
 	memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
 	syslog(LOG_DEBUG, "%s: sending Router Solicitation", ifp->name);