diff --git a/idle_scan.cc b/idle_scan.cc index ca21d5e84..3ba06bf7b 100644 --- a/idle_scan.cc +++ b/idle_scan.cc @@ -104,6 +104,8 @@ #include "utils.h" #include "output.h" +#include "struct_ip.h" + #include extern NmapOps o; diff --git a/nmap.h b/nmap.h index d2d3bbf86..01a3bbdc9 100644 --- a/nmap.h +++ b/nmap.h @@ -150,20 +150,6 @@ void *realloc(); #include /* Defines MAXHOSTNAMELEN on BSD*/ #endif -/* Linux uses these defines in netinet/ip.h to use the correct struct ip */ -#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 @@ -204,16 +190,6 @@ void *realloc(); #include #endif -#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */ -#include /* defines n_long needed for netinet/ip.h */ -#define NETINET_IN_SYSTM_H -#endif -#ifndef NETINET_IP_H /* This guarding is needed for at least some versions of OpenBSD */ -#include -#define NETINET_IP_H -#endif -// #include - #if HAVE_ARPA_INET_H #include #endif diff --git a/nse_dnet.cc b/nse_dnet.cc index 5b4ebfe56..e867e899f 100644 --- a/nse_dnet.cc +++ b/nse_dnet.cc @@ -9,6 +9,8 @@ #include "nse_main.h" #include "nse_utility.h" +#include "struct_ip.h" + extern "C" { #include "lua.h" #include "lauxlib.h" diff --git a/osscan2.cc b/osscan2.cc index 190df77d0..e0b307f98 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -99,6 +99,9 @@ #include "utils.h" #include "FPEngine.h" #include + +#include "struct_ip.h" + #include using namespace std; diff --git a/scan_engine.cc b/scan_engine.cc index 4655e984f..272c3b5d8 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -105,6 +105,9 @@ #include "Target.h" #include "targets.h" #include "utils.h" + +#include "struct_ip.h" + #include #include #include diff --git a/struct_ip.h b/struct_ip.h new file mode 100644 index 000000000..0eeb58598 --- /dev/null +++ b/struct_ip.h @@ -0,0 +1,45 @@ +/* The C library on AIX defines the names of various members of struct ip to + something else in : + +struct ip { + struct ip_firstfour ip_ff; +#define ip_v ip_ff.ip_fv +#define ip_hl ip_ff.ip_fhl +#define ip_vhl ip_ff.ip_fvhl +#define ip_tos ip_ff.ip_ftos +#define ip_len ip_ff.ip_flen + + This breaks code that actually wants to use names like ip_v for its own + purposes, like struct ip_hdr in libdnet. The AIX definitions will work + if they are included late in the list of includes, before other code that + might want to use the above names has already been preprocessed. The + includes that end up defining struct ip are therefore limited to this + file, so it can be included in a .cc file after other .h have been + included. */ + +/* Linux uses these defines in netinet/ip.h to use the correct struct ip */ +#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 + +#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */ +#include /* defines n_long needed for netinet/ip.h */ +#define NETINET_IN_SYSTM_H +#endif +#ifndef NETINET_IP_H /* This guarding is needed for at least some versions of OpenBSD */ +#include +#define NETINET_IP_H +#endif + +#ifndef WIN32 +#include +#endif diff --git a/tcpip.cc b/tcpip.cc index 6c5835b15..fab1af998 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -103,6 +103,7 @@ #include "Target.h" #include "utils.h" +#include "struct_ip.h" #if HAVE_SYS_TIME_H #include diff --git a/tcpip.h b/tcpip.h index 2482a274f..82911821d 100644 --- a/tcpip.h +++ b/tcpip.h @@ -133,19 +133,6 @@ void *realloc(); #include /* Defines MAXHOSTNAMELEN on BSD*/ #endif -/* Linux uses these defines in netinet/ip.h to use the correct struct ip */ -#ifndef __FAVOR_BSD -#define __FAVOR_BSD 1 -#endif -#ifndef _BSD_SOURCE -#define _BSD_SOURCE 1 -#endif -#ifndef __USE_BSD -#define __USE_BSD 1 -#endif -/* BSDI needs this to insure the correct struct ip */ -#undef _IP_VHL - #include #if HAVE_NETINET_IN_H @@ -165,14 +152,6 @@ void *realloc(); #endif #include -#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */ -#include /* defines n_long needed for netinet/ip.h */ -#define NETINET_IN_SYSTM_H -#endif -#ifndef NETINET_IP_H /* This guarding is needed for at least some versions of OpenBSD */ -#include -#define NETINET_IP_H -#endif #if HAVE_UNISTD_H #include #endif @@ -208,9 +187,6 @@ extern "C" { #include #include #include -#ifndef WIN32 -#include -#endif diff --git a/traceroute.cc b/traceroute.cc index 371eb5860..fafb7a67d 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -137,6 +137,8 @@ individually. #include "NmapOps.h" #include "Target.h" +#include "struct_ip.h" + #include #include @@ -145,6 +147,33 @@ individually. #include #include +/* Linux uses these defines in netinet/ip.h to use the correct struct ip */ +#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 + +#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */ +#include /* defines n_long needed for netinet/ip.h */ +#define NETINET_IN_SYSTM_H +#endif +#ifndef NETINET_IP_H /* This guarding is needed for at least some versions of OpenBSD */ +#include +#define NETINET_IP_H +#endif + +#ifndef WIN32 +#include +#endif + extern NmapOps o; /* The highest TTL we go up to if the target itself doesn't respond. */