mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +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:
@@ -104,6 +104,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern NmapOps o;
|
extern NmapOps o;
|
||||||
|
|||||||
24
nmap.h
24
nmap.h
@@ -150,20 +150,6 @@ void *realloc();
|
|||||||
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
||||||
#endif
|
#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>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if HAVE_RPC_TYPES_H
|
#if HAVE_RPC_TYPES_H
|
||||||
@@ -204,16 +190,6 @@ void *realloc();
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#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
|
#if HAVE_ARPA_INET_H
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "nse_main.h"
|
#include "nse_main.h"
|
||||||
#include "nse_utility.h"
|
#include "nse_utility.h"
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
|
|||||||
@@ -99,6 +99,9 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "FPEngine.h"
|
#include "FPEngine.h"
|
||||||
#include <dnet.h>
|
#include <dnet.h>
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|||||||
@@ -105,6 +105,9 @@
|
|||||||
#include "Target.h"
|
#include "Target.h"
|
||||||
#include "targets.h"
|
#include "targets.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|||||||
45
struct_ip.h
Normal file
45
struct_ip.h
Normal 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
|
||||||
1
tcpip.cc
1
tcpip.cc
@@ -103,6 +103,7 @@
|
|||||||
#include "Target.h"
|
#include "Target.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
#if HAVE_SYS_TIME_H
|
#if HAVE_SYS_TIME_H
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|||||||
24
tcpip.h
24
tcpip.h
@@ -133,19 +133,6 @@ void *realloc();
|
|||||||
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
#include <sys/param.h> /* Defines MAXHOSTNAMELEN on BSD*/
|
||||||
#endif
|
#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>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if HAVE_NETINET_IN_H
|
#if HAVE_NETINET_IN_H
|
||||||
@@ -165,14 +152,6 @@ void *realloc();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#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
|
#if HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -208,9 +187,6 @@ extern "C" {
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <dnet.h>
|
#include <dnet.h>
|
||||||
#ifndef WIN32
|
|
||||||
#include <netinet/ip_icmp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ individually.
|
|||||||
#include "NmapOps.h"
|
#include "NmapOps.h"
|
||||||
#include "Target.h"
|
#include "Target.h"
|
||||||
|
|
||||||
|
#include "struct_ip.h"
|
||||||
|
|
||||||
#include <dnet.h>
|
#include <dnet.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -145,6 +147,33 @@ individually.
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#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;
|
extern NmapOps o;
|
||||||
|
|
||||||
/* The highest TTL we go up to if the target itself doesn't respond. */
|
/* The highest TTL we go up to if the target itself doesn't respond. */
|
||||||
|
|||||||
Reference in New Issue
Block a user