OSX has IP_BOUND_IF.
*BSD has IP_RECVIF, but no IP_SENDIF. And IP_RECVIF is a socket
option which is set, and then causes any _subsequent_ recvmsg()
call to have another cmsg structure added, with the sockaddr_dl
containing the interface. The application is then responsible
for comparing the interface IDs, and discarding packets which
don't match.
#include <fcntl.h>
#include <libgen.h>
#include <netinet/tcp.h>
+#include <netinet/in.h>
/** Initialize common datagram information
*
return 0;
}
+/*
+ * Use the OSX native versions on OSX.
+ */
+#ifdef __APPLE__
+#undef SO_BINDTODEVICE
+#endif
+
#ifdef SO_BINDTODEVICE
/** Linux bind to device by name.
*
}
#elif defined(IP_BOUND_IF) || defined(IPV6_BOUND_IF)
-/** *BSD bind to interface by index.
+/** OSX bind to interface by index.
*
*/
static int fr_bio_fd_socket_bind_to_device(fr_bio_fd_t *my, UNUSED fr_bio_fd_config_t const *cfg)
#if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) || defined(IPV6_PKTINFO)
struct iovec iov; //!< for recvfromto
struct msghdr msgh; //!< for recvfromto
- uint8_t cbuf[256]; //!< for recvfromto
+ uint8_t cbuf[sizeof(struct cmsghdr) * 2]; //!< for recvfromto
#endif
} fr_bio_fd_t;