I'm working on an app for MacOSX Sierra (10.12.6). It has an IPv6 UDP socket on which it receives requests. This runs on a multi-homed host. I need a way to get the IPv6 destination address for each received packet. After searching the web I've found two potential socket options to use with recvmsg: IP_RECVDSTADDR and IP_RECVPKTINFO. I've tried them both with no success.
const unsigned int opt = 1;
rc = setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof opt);
if (rc < 0) {
perror("setsockopt(IPPROTO_IP, IP_RECVDSTADDR) failed");
}
I get the error with either option, IP_RECVDSTADDR and IP_RECVPKTINFO.
How do I do this?