I'm trying to port a TraceRoute program from Linux to OSX, and i'm having trouble finding the IP_RECVERR equivalent.
The way most people do the packet parsing is:
setsockopt (sock, IPPROTO_IPV4, IP_RECVERR, &on, sizeof (on))
And then when the packet comes in do something along the lines of:
sock_extended_err* err = nullptr;
for (cmsghdr* cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
switch (cmsg->cmsg_level) {
case IPPROTO_IPV4:
if (cmsg->cmsg_type == IP_RECVERR) {
err = (sock_extended_err*)CSMSG_DATA(cmsg);
}
break;
}
}
There also isn't an sock_extended_err on OSX which is problematic. I really just need to know if have had an error, and where the error originated.