Index: Makefile.in =================================================================== --- Makefile.in.orig 2006-11-08 10:13:19.147571000 -0600 +++ Makefile.in 2006-11-08 17:37:57.191007000 -0600 @@ -63,7 +63,7 @@ $(TARGET): $(DEPS) @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/libnsock.a $(OBJS) @echo Compiling nmap rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) # This empty rule is used to force execution of certain rules where I can't conveniently specify # all of the prerequisites (e.g. recursive makes and such) Index: libdnet-stripped/configure.in =================================================================== --- libdnet-stripped/configure.in.orig 2006-11-08 10:13:19.279976000 -0600 +++ libdnet-stripped/configure.in 2006-11-08 17:37:57.425292000 -0600 @@ -223,6 +227,8 @@ dnl Check for Ethernet interface. if test "$ac_cv_header_Iphlpapi_h" = yes ; then AC_LIBOBJ([eth-win32]) +elif test "$ac_cv_header_sys_ndd_var_h" = yes ; then + AC_LIBOBJ([eth-ndd]) elif test "$ac_cv_header_net_pfilt_h" = yes ; then AC_LIBOBJ([eth-pfilt]) elif test "$ac_cv_dnet_bsd_bpf" = yes ; then @@ -231,8 +237,6 @@ AC_LIBOBJ([eth-linux]) elif test "$ac_cv_header_net_raw_h" = yes ; then AC_LIBOBJ([eth-snoop]) -elif test "$ac_cv_header_sys_ndd_var_h" = yes ; then - AC_LIBOBJ([eth-ndd]) elif test "$ac_cv_header_sys_dlpi_h" = yes || \ test "$ac_cv_header_sys_dlpihdr_h" = yes ; then AC_LIBOBJ([eth-dlpi]) Index: tcpip.cc =================================================================== --- tcpip.cc.orig 2006-11-08 10:13:19.968148000 -0600 +++ tcpip.cc 2006-11-08 17:37:58.946073000 -0600 @@ -1015,22 +1019,21 @@ } return; } - // fill ip header. no error check. // This function is also changing what's needed from host to network order. static inline int fill_ip_raw( struct ip *ip, int packetlen, u8* ipopt, int ipoptlen, - int ip_tos, int ip_id, int ip_off, int ip_ttl, int ip_p, + int in_ip_tos, int in_ip_id, int in_ip_off, int in_ip_ttl, int in_ip_p, const struct in_addr *ip_src, const struct in_addr *ip_dst) { ip->ip_v = 4; ip->ip_hl = 5 + (ipoptlen/4); - ip->ip_tos = ip_tos; + ip->ip_tos = in_ip_tos; ip->ip_len = htons(packetlen); - ip->ip_id = htons(ip_id); - ip->ip_off = htons(ip_off); - ip->ip_ttl = ip_ttl; - ip->ip_p = ip_p; + ip->ip_id = htons(in_ip_id); + ip->ip_off = htons(in_ip_off); + ip->ip_ttl = in_ip_ttl; + ip->ip_p = in_ip_p; ip->ip_src.s_addr = ip_src->s_addr; ip->ip_dst.s_addr = ip_dst->s_addr; Index: tcpip.h =================================================================== --- tcpip.h.orig 2006-11-08 10:13:19.992285000 -0600 +++ tcpip.h 2006-11-08 17:37:59.063054000 -0600 @@ -158,6 +158,7 @@ #include +#include #if HAVE_NETINET_IN_H #include #endif @@ -228,8 +229,7 @@ #include #include #include -#include -#ifndef WIN32 +#if !defined(WIN32) #include #endif Index: libdnet-stripped/src/route-bsd.c =================================================================== --- libdnet-stripped/src/route-bsd.c.orig 2006-11-08 10:13:19.322096000 -0600 +++ libdnet-stripped/src/route-bsd.c 2006-11-08 17:37:59.129699000 -0600 @@ -213,7 +213,10 @@ return (0); } -#if defined(HAVE_SYS_SYSCTL_H) || defined(HAVE_STREAMS_ROUTE) +#if defined(HAVE_SYS_SYSCTL_H) || defined(HAVE_STREAMS_ROUTE) || defined(_AIX) +#ifdef _AIX +#include +#endif int route_loop(route_t *r, route_handler callback, void *arg) { @@ -222,7 +225,23 @@ struct sockaddr *sa; char *buf, *lim, *next; int ret; -#ifdef HAVE_SYS_SYSCTL_H +#ifdef _AIX + int len = getkerninfo(KINFO_RT_DUMP,0,0,0); + + if (len == 0) + return (0); + + if ((buf = malloc(len)) == NULL) + return (-1); + + if (getkerninfo(KINFO_RT_DUMP,buf,&len,0) < 0) { + free(buf); + return (-1); + } + lim = buf + len; + next = buf; + +#elif defined (HAVE_SYS_SYSCTL_H) int mib[6] = { CTL_NET, PF_ROUTE, 0, 0 /* XXX */, NET_RT_DUMP, 0 }; size_t len; Index: nmap.h =================================================================== --- nmap.h.orig 2006-11-08 10:13:20.016526000 -0600 +++ nmap.h 2006-11-08 17:37:59.172504000 -0600 @@ -123,139 +123,6 @@ #include -#if HAVE_UNISTD_H -#include -#endif - -#ifdef STDC_HEADERS -#include -#else -void *malloc(); -void *realloc(); -#endif - -#if STDC_HEADERS || HAVE_STRING_H -#include -#if !STDC_HEADERS && HAVE_MEMORY_H -#include -#endif -#endif -#if HAVE_STRINGS_H -#include -#endif - -#ifdef HAVE_BSTRING_H -#include -#endif - -#include -#include - -#ifndef WIN32 /* from nmapNT -- seems to work */ -#include -#endif /* !WIN32 */ - -#ifdef HAVE_SYS_PARAM_H -#include /* Defines MAXHOSTNAMELEN on BSD*/ -#endif - -/* Linux uses these defines in netinet/ip.h and netinet/tcp.h to - use the correct struct ip and struct tcphdr */ -#ifndef __FAVOR_BSD -#define __FAVOR_BSD -#endif -#ifndef __USE_BSD -#define __USE_BSD -#endif -#ifndef __BSD_SOURCE -#define __BSD_SOURCE -#endif - -/* BSDI needs this to insure the correct struct ip */ -#undef _IP_VHL - -#include - -#if HAVE_RPC_TYPES_H -#include -#endif - -#if HAVE_SYS_SOCKET_H -#include -#endif - -#include - -#if HAVE_NETINET_IN_H -#include -#endif - -#include - -#if HAVE_NETDB_H -#include -#endif - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include -#include - -#ifdef HAVE_PWD_H -#include -#endif - -#ifndef NETINET_IN_SYSTEM_H /* why does OpenBSD not do this? */ -#include /* defines n_long needed for netinet/ip.h */ -#define NETINET_IN_SYSTEM_H -#endif -#ifndef NETINET_IP_H /* why does OpenBSD not do this? */ -#include -#define NETINET_IP_H -#endif -// #include - -#if HAVE_ARPA_INET_H -#include -#endif - -#include -#include -#ifndef __FAVOR_BSD -#define __FAVOR_BSD -#endif -#ifndef NETINET_TCP_H /* why does OpenBSD not do this? */ -#include /*#include */ -#define NETINET_TCP_H -#endif - -#if HAVE_SYS_RESOURCE_H -#include -#endif - -/*#include *//* defines struct arphdr needed for if_ether.h */ -// #if HAVE_NET_IF_H -// #ifndef NET_IF_H /* why doesn't OpenBSD do this?! */ -// #include -// #define NET_IF_H -// #endif -// #endif -// #if HAVE_NETINET_IF_ETHER_H -// #ifndef NETINET_IF_ETHER_H -// #include -// #define NETINET_IF_ETHER_H -// #endif /* NETINET_IF_ETHER_H */ -// #endif /* HAVE_NETINET_IF_ETHER_H */ - /******* DEFINES ************/ /* User configurable #defines: */ @@ -405,11 +272,144 @@ # define recvfrom6_t int #endif + +#if HAVE_UNISTD_H +#include +#endif + +#ifdef STDC_HEADERS +#include +#else +void *malloc(); +void *realloc(); +#endif + +#if STDC_HEADERS || HAVE_STRING_H +#include +#if !STDC_HEADERS && HAVE_MEMORY_H +#include +#endif +#endif +#if HAVE_STRINGS_H +#include +#endif + +#ifdef HAVE_BSTRING_H +#include +#endif + +#include +#include + +#ifndef WIN32 /* from nmapNT -- seems to work */ +#include +#endif /* !WIN32 */ + +#ifdef HAVE_SYS_PARAM_H +#include /* Defines MAXHOSTNAMELEN on BSD*/ +#endif + +/* Linux uses these defines in netinet/ip.h and netinet/tcp.h to + use the correct struct ip and struct tcphdr */ +#ifndef __FAVOR_BSD +#define __FAVOR_BSD +#endif +#ifndef __USE_BSD +#define __USE_BSD +#endif +#ifndef __BSD_SOURCE +#define __BSD_SOURCE +#endif + +#include "tcpip.h" +/* BSDI needs this to insure the correct struct ip */ +#undef _IP_VHL + +#include + +#if HAVE_RPC_TYPES_H +#include +#endif + +#if HAVE_SYS_SOCKET_H +#include +#endif + +#include + +#if HAVE_NETINET_IN_H +#include +#endif + +#include + +#if HAVE_NETDB_H +#include +#endif + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#include +#include + +#ifdef HAVE_PWD_H +#include +#endif + +#ifndef NETINET_IN_SYSTEM_H /* why does OpenBSD not do this? */ +#include /* defines n_long needed for netinet/ip.h */ +#define NETINET_IN_SYSTEM_H +#endif +#ifndef NETINET_IP_H /* why does OpenBSD not do this? */ +#include +#define NETINET_IP_H +#endif +// #include + +#if HAVE_ARPA_INET_H +#include +#endif + +#include +#include +#ifndef __FAVOR_BSD +#define __FAVOR_BSD +#endif +#ifndef NETINET_TCP_H /* why does OpenBSD not do this? */ +#include /*#include */ +#define NETINET_TCP_H +#endif + +#if HAVE_SYS_RESOURCE_H +#include +#endif + +/*#include *//* defines struct arphdr needed for if_ether.h */ +// #if HAVE_NET_IF_H +// #ifndef NET_IF_H /* why doesn't OpenBSD do this?! */ +// #include +// #define NET_IF_H +// #endif +// #endif +// #if HAVE_NETINET_IF_ETHER_H +// #ifndef NETINET_IF_ETHER_H +// #include +// #define NETINET_IF_ETHER_H +// #endif /* NETINET_IF_ETHER_H */ +// #endif /* HAVE_NETINET_IF_ETHER_H */ /********************** LOCAL INCLUDES *****************************/ #include "output.h" #include "portlist.h" -#include "tcpip.h" #include "global_structures.h" #include "nmap_error.h" #include "utils.h" Index: libdnet-stripped/src/eth-ndd.c =================================================================== --- libdnet-stripped/src/eth-ndd.c.orig 2006-11-08 10:13:19.370722000 -0600 +++ libdnet-stripped/src/eth-ndd.c 2006-11-08 17:41:31.774290000 -0600 @@ -32,25 +32,35 @@ { struct sockaddr_ndd_8022 sa; eth_t *e; - if ((e = calloc(1, sizeof(*e))) == NULL) return (NULL); - + memset(&sa,0,sizeof(sa)); if ((e->fd = socket(AF_NDD, SOCK_DGRAM, NDD_PROT_ETHER)) < 0) + { + /* fprintf(stderr,"socket failed: %s\n",strerror(errno));*/ return (eth_close(e)); - + } sa.sndd_8022_family = AF_NDD; sa.sndd_8022_len = sizeof(sa); sa.sndd_8022_filtertype = NS_ETHERTYPE; sa.sndd_8022_ethertype = ETH_TYPE_IP; sa.sndd_8022_filterlen = sizeof(struct ns_8022); strlcpy(sa.sndd_8022_nddname, device, sizeof(sa.sndd_8022_nddname)); + strlcpy(e->device, device, sizeof(e->device)); if (bind(e->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) - return (eth_close(e)); + { + /* fprintf(stderr,"bind failed: %s\n",strerror(errno));*/ + /* return (eth_close(e)); */ + /* don't actually fail here, some stuff might still work + * without using eth_ */ + } if (connect(e->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) + { + /* fprintf(stderr,"connect failed: %s\n",strerror(errno));*/ return (eth_close(e)); + } /* XXX - SO_BROADCAST needed? */ @@ -60,7 +70,11 @@ ssize_t eth_send(eth_t *e, const void *buf, size_t len) { - return (write(e->fd, buf, len)); + ssize_t numbytes = write(e->fd, buf, len); + /*if (0== numbytes) { + fprintf(stderr,"write failed: %s\n",strerror(errno)); + }*/ + return (numbytes); } eth_t * @@ -98,6 +112,7 @@ if (strcmp(nddp->ndd_alias, e->device) == 0 || strcmp(nddp->ndd_name, e->device) == 0) { memcpy(ea, nddp->ndd_addr, sizeof(*ea)); + break; } } free(nddp); Index: Target.cc =================================================================== --- Target.cc.orig 2006-11-08 10:13:20.041393000 -0600 +++ Target.cc 2006-11-08 17:37:59.287852000 -0600 @@ -335,7 +335,11 @@ that information here. directlyConnected() will abort if it hasn't been set yet. */ void Target::setDirectlyConnected(bool connected) { +#ifndef _AIX directly_connected = connected? 1 : 0; +#else + directly_connected = 0; +#endif } bool Target::directlyConnected() {