From 48ff61a710a9038a55ed40531686cb71593b9de9 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 21 Jul 2012 07:35:41 +0000 Subject: [PATCH] Handle ARPHRD_VOID in addr_ston. This type is used by OpenVZ venet interfaces. We "handle" such an address type just by blanking the MAC address field. Lack of support for this type of interface was preventing Nmap from working on certain systems. http://seclists.org/nmap-dev/2012/q2/763 An earlier message about this same type of interface is http://seclists.org/nmap-dev/2009/q3/303 --- CHANGELOG | 4 ++++ libdnet-stripped/NMAP_MODIFICATIONS | 29 +++++++++++++++++++++++++++++ libdnet-stripped/include/dnet/arp.h | 1 + libdnet-stripped/src/addr.c | 3 +++ 4 files changed, 37 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1501eae68..fe61360ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o Fixed a bug that prevented Nmap from finding any interfaces when any + interface had the type ARPHRD_VOID; this was the case for OpenVZ + venet interfaces. [Djalal Harouni, David Fifield] + o [Zenmap] Fixed a crash when using the en_NG locale: "ValueError: unknown locale: en_NG" [David Fifield] diff --git a/libdnet-stripped/NMAP_MODIFICATIONS b/libdnet-stripped/NMAP_MODIFICATIONS index ee1ea6516..92d2aa354 100644 --- a/libdnet-stripped/NMAP_MODIFICATIONS +++ b/libdnet-stripped/NMAP_MODIFICATIONS @@ -1096,3 +1096,32 @@ Index: libdnet-stripped/src/addr.c a->addr_type = ADDR_TYPE_ETH; a->addr_bits = ETH_ADDR_BITS; memcpy(&a->addr_eth, sa->sa_data, ETH_ADDR_LEN); + +o Added addr_ston support for ARPHRD_VOID devices. + +diff --git libdnet-stripped/include/dnet/arp.h libdnet-stripped/include/dnet/arp.h +index 2f3d0bf..ec020b4 100644 +--- libdnet-stripped/include/dnet/arp.h ++++ libdnet-stripped/include/dnet/arp.h +@@ -40,6 +40,7 @@ struct arp_hdr { + #define ARP_HRD_IEEE802 0x0006 /* IEEE 802 hardware */ + + #define ARP_HRD_IEEE80211_RADIOTAP 0x0323 /* IEEE 802.11 + radiotap header */ ++#define ARP_HRD_VOID 0xFFFF /* Void type, nothing is known */ + + /* + * Protocol address format +diff --git libdnet-stripped/src/addr.c libdnet-stripped/src/addr.c +index 392d44f..bf3e9e7 100644 +--- libdnet-stripped/src/addr.c ++++ libdnet-stripped/src/addr.c +@@ -343,6 +343,9 @@ addr_ston(const struct sockaddr *sa, struct addr *a) + a->addr_bits = IP_ADDR_BITS; + a->addr_ip = so->sin.sin_addr.s_addr; + break; ++ case ARP_HRD_VOID: ++ memset(&a->addr_eth, 0, ETH_ADDR_LEN); ++ break; + default: + errno = EINVAL; + return (-1); diff --git a/libdnet-stripped/include/dnet/arp.h b/libdnet-stripped/include/dnet/arp.h index 2f3d0bf39..ec020b49b 100644 --- a/libdnet-stripped/include/dnet/arp.h +++ b/libdnet-stripped/include/dnet/arp.h @@ -40,6 +40,7 @@ struct arp_hdr { #define ARP_HRD_IEEE802 0x0006 /* IEEE 802 hardware */ #define ARP_HRD_IEEE80211_RADIOTAP 0x0323 /* IEEE 802.11 + radiotap header */ +#define ARP_HRD_VOID 0xFFFF /* Void type, nothing is known */ /* * Protocol address format diff --git a/libdnet-stripped/src/addr.c b/libdnet-stripped/src/addr.c index 392d44fac..bf3e9e767 100644 --- a/libdnet-stripped/src/addr.c +++ b/libdnet-stripped/src/addr.c @@ -343,6 +343,9 @@ addr_ston(const struct sockaddr *sa, struct addr *a) a->addr_bits = IP_ADDR_BITS; a->addr_ip = so->sin.sin_addr.s_addr; break; + case ARP_HRD_VOID: + memset(&a->addr_eth, 0, ETH_ADDR_LEN); + break; default: errno = EINVAL; return (-1);