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) {
#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;
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,
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);