1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Use a special struct_ip.h to include <netinet/ip.h> and accoutrements.

The comment in struct_ip.h explains the reasoning for this. The AIX C library
uses #defines that change the names of members of struct ip, and conflict with
some existing code. (Notably struct ip_hdr in libdnet and IPv4Header::h in
libnetutil.) We can still use the AIX files if we include <netinet/ip.h> after
this other code has been preprocessed. That's hard to enforce when
<netinet/ip.h> is included from another header file; this new file allows
including it always late, and only where needed.
This commit is contained in:
david
2011-09-21 07:31:38 +00:00
parent c87da9aa8b
commit fee764a5d8
9 changed files with 85 additions and 48 deletions

View File

@@ -104,6 +104,8 @@
#include "utils.h"
#include "output.h"
#include "struct_ip.h"
#include <stdio.h>
extern NmapOps o;

24
nmap.h
View File

@@ -150,20 +150,6 @@ void *realloc();
#include <sys/param.h> /* 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 <stdio.h>
#if HAVE_RPC_TYPES_H
@@ -204,16 +190,6 @@ void *realloc();
#include <pwd.h>
#endif
#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */
#include <netinet/in_systm.h> /* 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 <netinet/ip.h>
#define NETINET_IP_H
#endif
// #include <netinet/ip_icmp.h>
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif

View File

@@ -9,6 +9,8 @@
#include "nse_main.h"
#include "nse_utility.h"
#include "struct_ip.h"
extern "C" {
#include "lua.h"
#include "lauxlib.h"

View File

@@ -99,6 +99,9 @@
#include "utils.h"
#include "FPEngine.h"
#include <dnet.h>
#include "struct_ip.h"
#include <list>
using namespace std;

View File

@@ -105,6 +105,9 @@
#include "Target.h"
#include "targets.h"
#include "utils.h"
#include "struct_ip.h"
#include <math.h>
#include <list>
#include <map>

45
struct_ip.h Normal file
View File

@@ -0,0 +1,45 @@
/* The C library on AIX defines the names of various members of struct ip to
something else in <netinet/ip.h>:
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 <netinet/in_systm.h> /* 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 <netinet/ip.h>
#define NETINET_IP_H
#endif
#ifndef WIN32
#include <netinet/ip_icmp.h>
#endif

View File

@@ -103,6 +103,7 @@
#include "Target.h"
#include "utils.h"
#include "struct_ip.h"
#if HAVE_SYS_TIME_H
#include <sys/time.h>

24
tcpip.h
View File

@@ -133,19 +133,6 @@ void *realloc();
#include <sys/param.h> /* 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 <stdio.h>
#if HAVE_NETINET_IN_H
@@ -165,14 +152,6 @@ void *realloc();
#endif
#include <arpa/inet.h>
#ifndef NETINET_IN_SYSTM_H /* This guarding is needed for at least some versions of OpenBSD */
#include <netinet/in_systm.h> /* 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 <netinet/ip.h>
#define NETINET_IP_H
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -208,9 +187,6 @@ extern "C" {
#include <errno.h>
#include <signal.h>
#include <dnet.h>
#ifndef WIN32
#include <netinet/ip_icmp.h>
#endif

View File

@@ -137,6 +137,8 @@ individually.
#include "NmapOps.h"
#include "Target.h"
#include "struct_ip.h"
#include <dnet.h>
#include <algorithm>
@@ -145,6 +147,33 @@ individually.
#include <set>
#include <vector>
/* 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 <netinet/in_systm.h> /* 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 <netinet/ip.h>
#define NETINET_IP_H
#endif
#ifndef WIN32
#include <netinet/ip_icmp.h>
#endif
extern NmapOps o;
/* The highest TTL we go up to if the target itself doesn't respond. */