1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-27 09:59:04 +00:00

Note last commit in libdnet/NMAP_MODIFICATIONS

This commit is contained in:
dmiller
2014-09-09 21:19:09 +00:00
parent 73275cc872
commit c22c1119e9

View File

@@ -1910,3 +1910,73 @@ index 44e7dd2..47f3705 100644
#ifdef HAVE_SOCKADDR_SA_LEN
#define NEXTSA(s) \
o Fix hw address getting on AIX
diff --git a/libdnet-stripped/src/intf.c b/libdnet-stripped/src/intf.c
index 184c077..2df6a4d 100644
--- a/libdnet-stripped/src/intf.c
+++ b/libdnet-stripped/src/intf.c
@@ -20,6 +20,10 @@
# include <sys/sockio.h>
#endif
/* XXX - AIX */
+#ifdef HAVE_GETKERNINFO
+#include <sys/ndd_var.h>
+#include <sys/kinfo.h>
+#endif
#ifndef IP_MULTICAST
# define IP_MULTICAST
#endif
@@ -477,6 +481,11 @@ static int
_intf_get_noalias(intf_t *intf, struct intf_entry *entry)
{
struct ifreq ifr;
+#ifdef HAVE_GETKERNINFO
+ int size;
+ struct kinfo_ndd *nddp;
+ void *end;
+#endif
/* Get interface index. */
entry->intf_index = if_nametoindex(entry->intf_name);
@@ -517,7 +526,39 @@ _intf_get_noalias(intf_t *intf, struct intf_entry *entry)
return (-1);
}
} else if (entry->intf_type == INTF_TYPE_ETH) {
-#if defined(SIOCGIFHWADDR)
+#if defined(HAVE_GETKERNINFO)
+ /* AIX also defines SIOCGIFHWADDR, but it fails silently?
+ * This is the method IBM recommends here:
+ * http://www-01.ibm.com/support/knowledgecenter/ssw_aix_53/com.ibm.aix.progcomm/doc/progcomc/skt_sndother_ex.htm%23ssqinc2joyc?lang=en
+ */
+ /* How many bytes will be returned? */
+ size = getkerninfo(KINFO_NDD, 0, 0, 0);
+ if (size <= 0) {
+ return -1;
+ }
+ nddp = (struct kinfo_ndd *)malloc(size);
+
+ if (!nddp) {
+ return -1;
+ }
+ /* Get all Network Device Driver (NDD) info */
+ if (getkerninfo(KINFO_NDD, nddp, &size, 0) < 0) {
+ free(nddp);
+ return -1;
+ }
+ /* Loop over the returned values until we find a match */
+ end = (void *)nddp + size;
+ while ((void *)nddp < end) {
+ if (!strcmp(nddp->ndd_alias, entry->intf_name) ||
+ !strcmp(nddp->ndd_name, entry->intf_name)) {
+ addr_pack(&entry->intf_link_addr, ADDR_TYPE_ETH, ETH_ADDR_BITS,
+ nddp->ndd_addr, ETH_ADDR_LEN);
+ break;
+ } else
+ nddp++;
+ }
+ free(nddp);
+#elif defined(SIOCGIFHWADDR)
if (ioctl(intf->fd, SIOCGIFHWADDR, &ifr) < 0)
return (-1);
if (addr_ston(&ifr.ifr_addr, &entry->intf_link_addr) < 0)