Subject: Re: nmap not working?
To: Martin Husemann <email@example.com>
From: Greg Troxel <firstname.lastname@example.org>
Date: 11/09/2007 15:03:31
I took a look at the nmap source and it is using SIOCGIFCONF
incorrectly. The following should help, but I'm running an old kernel
on my notebook and can't test it.
Basically, the rule for SIOCGIFCONF is that the next ifreq is right
after this one, unless the struct sockaddr_foo (by its length) is too
big to fit in the union that is supposed to hold the sockaddr. That
always used to be struct sockaddr, and now it's struct sockaddr_storage,
which by construction is supposed to be big enough.
--- tcpip.cc.~1~ 2006-12-07 22:01:19.000000000 -0500
+++ tcpip.cc 2007-11-09 14:59:06.000000000 -0500
@@ -2632,7 +2632,12 @@
/* On some platforms (such as FreeBSD), the length of each ifr changes
based on the sockaddr type used, so we get the next length now */
- len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
+ len = ifr->ifr_addr.sa_len;
+ if (len < sizeof(ifr->ifr_ifru))
+ len = sizeof(ifr->ifr_ifru);
+ len += sizeof(ifr->ifr_name);
+ printf("sa_len %d len %d\n", ifr->ifr_addr.sa_len, len);
/* skip any device with no name */