Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX equivalent for IP_RECVERR

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.

like image 345
kmdent Avatar asked Apr 28 '15 23:04

kmdent


People also ask

What is the equivalent of ipconfig on a Mac?

Excuse the question if it seems stupid, always used mac for specific software, never had to get right into the operating system. Thanks in advance. The equivalent to ipconfig would be ifconfig. Open the terminal (located inside the Utilities folder) and type: to get information on how to use this command.

Can I use advanced IP scanner on a Mac?

Advanced IP Scanner is not available for Mac but there are plenty of alternatives that runs on macOS with similar functionality. The best Mac alternative is Nmap, which is both free and Open Source.

What's the iptables equivalent in OSX for above command?

What's the iptables equivalent in OSX for above command? Show activity on this post. The "equivalent" of iptables on macOS is pf (packet filter). Refer to the manual page for the configuration file here:

How do I renew my IP address on a Linux system?

Open the terminal (located inside the Utilities folder) and type: to get information on how to use this command. If you just want to renew the IP address, open System Preferences, click on Network, select the network interface in question and click on "Renew DHCP lease".


1 Answers

Sorry to say but OS X is not supporting extended IP_RECVERR socket capabilities.

You can use: #ifdef IP_RECVERRto make it build on OS X where RECVERR/ERRQUEUE don't exist.

But if you are looking for that particular code execution, I think you have to port IP_RECVERR socket capability & MSG_ERRQUEUE in mac OS X. Thats sound like "I got new things to play". Happy coding.

like image 157
Brijesh Valera Avatar answered Oct 09 '22 15:10

Brijesh Valera