Nmap Development mailing list archives

Re: fix to build nmap on some OpenBSD archs


From: Sebastian Reitenbach <sebastia () l00-bugdead-prods de>
Date: Tue, 3 Aug 2010 09:37:41 +0200

Hi,

On Tuesday 03 August 2010 01:02:53 am David Fifield wrote:
On Thu, Jul 29, 2010 at 09:02:24AM +0200, Sebastian Reitenbach wrote:
Hi,

On Thursday 29 July 2010 05:38:12 am David Fifield wrote:
On Thu, Jul 08, 2010 at 12:58:57PM +0200, Sebastian Reitenbach wrote:
OpenBSD sparc and some others have gcc-2.95 as default compiler.
Appended patch against nmap 5.21 fixes compilation, so that I can
actually use it on my sparc.

Thanks. I see that this patch is mostly about not mixing code and
declarations in C code (not C++, where it is allowed). I have committed
that.

the patch regarding nsock/src/nsock_pcap.c was already in the OpenBSD
ports tree, only parts of it are responsible to fix the build with
gcc2. The part where I am not responsible and not sure what it fixes
is the following:

@@ -325,11 +323,14 @@ int do_actual_pcap_read(msevent *nse)
 void nse_readpcap(nsock_event nsee,
        const unsigned char **l2_data, size_t *l2_len,
        const unsigned char **l3_data, size_t *l3_len,
-       size_t *packet_len, struct timeval *ts)
+       size_t *packet_len, struct bpf_timeval *ts)
 {
        msevent *nse = (msevent *)nsee;

I guess the timeval is not existing.

I'm not sure about this either. You say it is necessary for you to
build on OpenBSD? What if you use the --with-libpcap=included configure
option? I tried applying this part of the patch on x86_64 GNU/Linux,
and got the error

I rechecked and saw that there are other patches needed to make this
work: http://www.openbsd.org/cgi-bin/cvsweb/ports/net/nmap/patches/patch-
nsock_include_nsock_h
http://www.openbsd.org/cgi-bin/cvsweb/ports/net/nmap/patches/patch-
nsock_src_nsock_pcap_h

Those are also needed to get nmap compiled on OpenBSD, also with newer
gcc, I tried on i386 with gcc-4.2.

I tried to remove above two patches and removed the patch above from
nsock_pcap.c, and tried to rebuild nmap, but I got this error:

cc -c -I/usr/local/include -I/usr/include -I../../nbase -DHAVE_CONFIG_H -
DNSOCK_VERSION=\"0.02\" -D_FORTIFY_SOURCE=2 -I../include -I../../libpcap
- DIWASHERECFLAGS -I/usr/local/include -Wall   nsock_pcap.c -o
nsock_pcap.o nsock_pcap.c: In function 'do_actual_pcap_read':
nsock_pcap.c:295: error: incompatible types in assignment
gmake[1]: *** [nsock_pcap.o] Error 1
gmake[1]: Leaving directory
`/home/ports/pobj/nmap-5.21/nmap-5.21/nsock/src' gmake: *** [nsock_build]
Error 2
*** Error code 2

Hmm, this looks like the patches weren't undone completely. The
incompatible types are probably bpf_timeval and timeval.

I tried compiling today on OpenBSD, with no patches at all, and did not
have a problem compiling Nsock.

Nmap is compiled with the following configure parameters:
            --with-libpcap=included \
                --with-openssl=/usr \
                --with-libdnet=/usr/local \
                --with-liblua=/usr/local \
                --with-libpcre=/usr/local \
                --with-mandir=/usr/local/man \
                --disable-nls

I exchanged the --with-libpcap=/usr with --with-libpcap=included and
tried to rebuild it but ran into the following error:

===>  Building for nmap-5.21
Makefile:341: makefile.dep: No such file or directory
c++ -MM -I/usr/include/lua -I/usr/local/include -I/usr/local/include -
I/usr/local/include  -I/usr/local/include -I/usr/include -Ilibpcap
-Inbase - Insock/include main.cc nmap.cc targets.cc tcpip.cc
nmap_error.cc utils.cc idle_scan.cc osscan.cc osscan2.cc output.cc
payload.cc scan_engine.cc timing.cc charpool.cc services.cc protocols.cc
nmap_rpc.cc portlist.cc NmapOps.cc TargetGroup.cc Target.cc
FingerPrintResults.cc service_scan.cc NmapOutputTable.cc MACLookup.cc
nmap_tty.cc nmap_dns.cc traceroute.cc portreasons.cc nse_main.cc
nse_nsock.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc
nse_binlib.cc nse_bit.cc nse_openssl.cc nse_ssl_cert.cc  > makefile.dep
gmake: *** No rule to make target `libpcap/Makefile', needed by
`pcap_build'. Stop.

For this, please try doing a "gmake distclean" before configuring with
--with-pcap=included.
I did ran a make clean && make distclean between. 
I just checked out nmap from svn, without any patches, and retried it on i386 
on a OpenBSD -current, about a month old. I had the following environment set:
CFLAGS=-I/usr/local/include
CPPFLAGS=-I/usr/local/include
CXXFLAGS=-I/usr/local/include
LDFLAGS=-I/usr/local/lib

and ran configure with the following parameters:
./configure -with-libpcap=included --with-openssl=/usr --with-
libdnet=/usr/local --with-liblua=/usr/local --with-libpcre=/usr/local --with-
mandir=/usr/local/man --disable-nls

and with: 
./configure -with-libpcap=/usr --with-openssl=/usr --with-libdnet=/usr/local 
--with-liblua=/usr/local --with-libpcre=/usr/local --with-
mandir=/usr/local/man --disable-nls

In both cases it ended here:

gmake[1]: Entering directory `/tmp/nmap/libnetutil'                                                                     
                                                                                                                        
                             
Makefile:41: makefile.dep: No such file or directory                                                                    
                                                                                                                        
                             
g++ -MM -I/usr/include/lua -I/usr/local/include -I/usr/local/include -
I/usr/local/include -I/usr/local/include -I/usr/include -I../libpcap -
I../nbase -I../nsock/include -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2 ./netutil.cc 
makefile.dep                                     
gmake[1]: Leaving directory `/tmp/nmap/libnetutil'                                                                      
                                                                                                                        
                             
gmake[1]: Entering directory `/tmp/nmap/libnetutil'                                                                     
                                                                                                                        
                             
g++ -c -I/usr/include/lua -I/usr/local/include -I/usr/local/include -
I/usr/local/include -I/usr/local/include -I/usr/include -I../libpcap -
I../nbase -I../nsock/include -DHAVE_CONFIG_H -D_FORTIFY_SOURCE=2 -
I/usr/local/include -Wall -fno-strict-aliasing netutil.cc -o netutil.o                                                  
                                                                                                                        
                                                                                             
netutil.cc: In function 'const char* ippackethdrinfo(const u8*, u32, int)':                                             
                                                                                                                        
                             
netutil.cc:2530: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2530: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2530: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2530: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2531: error: invalid use of void expression                                                                  
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2534: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2535: error: invalid use of void expression                                                                  
                                                                                                                        
                             
netutil.cc:2538: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2538: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2538: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2538: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2539: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2539: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2539: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2539: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2540: error: invalid use of void expression                                                                  
                                                                                                                        
                             
netutil.cc:2684: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2684: error: invalid use of incomplete type 'struct sctp_hdr'                                                
                                                                                                                        
                             
netutil.cc:2111: error: forward declaration of 'struct sctp_hdr'                                                        
                                                                                                                        
                             
netutil.cc:2684: error: invalid use of void expression                                                                  
                                                                                                                        
                             
gmake[1]: *** [netutil.o] Error 1                                                                                       
                                                                                                                        
                             
gmake[1]: Leaving directory `/tmp/nmap/libnetutil'                                                                      
                                                                                                                        
                             
gmake: *** [netutil_build] Error 2                           

When using --with-libpcap=/usr I saw the following in the configure output:
checking for pcap.h... yes                                                                                              
                                                                                                                        
                             
checking for pcap_datalink in -lpcap... yes                                                                             
                                                                                                                        
                             
checking if libpcap version is recent enough... no                                                                      
                                                                                                                        
                             
configure: creating ./config.status                                                                                     
                                                                                                                        
                             
config.status: creating Makefile     

I guess its then falling back to the internal libpcap?

Sebastian


David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: