problems with libnet and cygwin
zhenjun xie <[email protected]> 19 Jun 2004 09:14:40 -0000
| Newsgroups | gmane.comp.security.libnet |
|---|---|
| Message-ID | <[email protected]> |
These days i was interested in libnet package,it
feazed me when i tried to compile it on cygwin.
Here are some problems and ways to resolve.Perhaps
some change are unsuitable,however,i issue these
just for debate.
platform : win2k peofessional server park 3
newly download cygwin from www.cygwin.com
gcc version 3.3.1 (cygming special)
winpcap 3.1beta3
libnet 1.1.2.1
*********************************************************************************
./configure
error message:
scanning available packet construction modules: 802.1q 802.1x 802.2 802.3 arp bg
p cdp data dhcp dns ethernet fddi gre icmp igmp ip ipsec isl link mpls ntp ospf
rip rpc sebek snmp stp tcp token_ring udp vrrp
checking for PacketSetMode in -lpacket... no
configure: error: packet lib not found.
resolve:
The fnative-struct option at configure file line 4756 was been used ,
which isnt available any more on gcc3.x.
So i change the line from
CFLAGS="$CFLAGS -mno-cygwin -O0 -fnative-struct -DNO_SNPRINTF -I/usr/include/pcap"
to
CFLAGS="$CFLAGS -mno-cygwin -O0 -mms-bitfields -DNO_SNPRINTF -I/usr/include/pcap".
reference http://mail.gnome.org/archives/gtk-list/2002-September/msg00074.html
*********************************************************************************
gcc -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -Wall -mno-cygwin -O0 -mms-b
itfields -DNO_SNPRINTF -I/usr/include/pcap -c `test -f 'libnet_build_arp.c' || e
cho './'`libnet_build_arp.c
In file included from /usr/include/pcap/pcap-stdinc.h:49,
from /usr/include/pcap/pcap.h:41,
from ../include/win32/libnet.h:41,
from libnet_build_arp.c:39:
/usr/include/pcap/bittypes.h:35: error: redefinition of `u_int8_t'
../include/win32/in_systm.h:42: error: `u_int8_t' previously declared here
/usr/include/pcap/bittypes.h:36: warning: redefinition of `int8_t'
/usr/i686-pc-mingw32/include/stdint.h:27: warning: `int8_t' previously declared
here
/usr/include/pcap/bittypes.h:51: error: redefinition of `u_int16_t'
../include/win32/in_systm.h:44: error: `u_int16_t' previously declared here
/usr/include/pcap/bittypes.h:52: warning: redefinition of `int16_t'
/usr/i686-pc-mingw32/include/stdint.h:29: warning: `int16_t' previously declared
here
/usr/include/pcap/bittypes.h:70: error: redefinition of `u_int32_t'
../include/win32/in_systm.h:46: error: `u_int32_t' previously declared here
/usr/include/pcap/bittypes.h:71: warning: redefinition of `int32_t'
/usr/i686-pc-mingw32/include/stdint.h:31: warning: `int32_t' previously declared
here
In file included from libnet_build_arp.c:39:
../include/win32/libnet.h:59:1: warning: "STDOUT_FILENO" redefined
In file included from /usr/include/pcap/pcap.h:51,
from ../include/win32/libnet.h:41,
from libnet_build_arp.c:39:
/usr/i686-pc-mingw32/include/stdio.h:43:1: warning: this is the location of the
previous definition
In file included from libnet_build_arp.c:39:
../include/win32/libnet.h:72: warning: ignoring #pragma comment
../include/win32/libnet.h:73: warning: ignoring #pragma comment
../include/win32/libnet.h:74: warning: ignoring #pragma comment
../include/win32/libnet.h:75: warning: ignoring #pragma comment
In file included from libnet_build_arp.c:39:
../include/win32/libnet.h:78:1: warning: "VERSION" redefined
In file included from libnet_build_arp.c:34:
../include/config.h:119:1: warning: this is the location of the previous definit
ion
In file included from ../include/win32/libnet.h:93,
from libnet_build_arp.c:39:
../include/libnet/libnet-macros.h:41:1: warning: "snprintf" redefined
In file included from libnet_build_arp.c:39:
../include/win32/libnet.h:60:1: warning: this is the location of the previous de
finition
In file included from ../include/libnet/libnet-structures.h:36,
from ../include/win32/libnet.h:95,
from libnet_build_arp.c:39:
/usr/include/pcap/Packet32.h:386: warning: `struct bpf_stat' declared inside par
ameter list
/usr/include/pcap/Packet32.h:386: warning: its scope is only this definition or
declaration, which is probably not what you want
/usr/include/pcap/Packet32.h:387: warning: `struct bpf_stat' declared inside par
ameter list
make[1]: *** [libnet_build_arp.o] Error 1
make[1]: Leaving directory `/usr/libnet/src'
make: *** [all-recursive] Error 1
resolve:
change libnet\include\win32\in_systm.h
+#ifndef HAVE_U_INT8_T
+#define HAVE_U_INT8_T 1
typedef unsigned char u_int8_t;
+#endif /* HAVE_U_INT8_T */
+#ifndef HAVE_U_INT16_T
+#define HAVE_U_INT16_T 1
typedef unsigned short u_int16_t;
+#endif /* HAVE_U_INT16_T */
+#ifndef HAVE_U_INT32_T
+#define HAVE_U_INT32_T 1
typedef unsigned int u_int32_t;
+#endif /* HAVE_U_INT32_T */
********************************************************************************
gcc -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -Wall -mno-cygwin -O0 -mms-b
itfields -DNO_SNPRINTF -I/usr/include/pcap -c `test -f 'libnet_port_list.c' || e
cho './'`libnet_port_list.c
In file included from libnet_port_list.c:39:
../include/win32/libnet.h:59:1: warning: "STDOUT_FILENO" redefined
In file included from /usr/include/pcap/pcap.h:51,
from ../include/win32/libnet.h:41,
from libnet_port_list.c:39:
/usr/i686-pc-mingw32/include/stdio.h:43:1: warning: this is the location of the
previous definition
In file included from libnet_port_list.c:39:
../include/win32/libnet.h:72: warning: ignoring #pragma comment
../include/win32/libnet.h:73: warning: ignoring #pragma comment
../include/win32/libnet.h:74: warning: ignoring #pragma comment
../include/win32/libnet.h:75: warning: ignoring #pragma comment
In file included from libnet_port_list.c:39:
../include/win32/libnet.h:78:1: warning: "VERSION" redefined
In file included from libnet_port_list.c:34:
../include/config.h:119:1: warning: this is the location of the previous definit
ion
In file included from ../include/win32/libnet.h:93,
from libnet_port_list.c:39:
../include/libnet/libnet-macros.h:41:1: warning: "snprintf" redefined
In file included from libnet_port_list.c:39:
../include/win32/libnet.h:60:1: warning: this is the location of the previous de
finition
In file included from ../include/libnet/libnet-structures.h:36,
from ../include/win32/libnet.h:95,
from libnet_port_list.c:39:
/usr/include/pcap/Packet32.h:386: warning: `struct bpf_stat' declared inside par
ameter list
/usr/include/pcap/Packet32.h:386: warning: its scope is only this definition or
declaration, which is probably not what you want
/usr/include/pcap/Packet32.h:387: warning: `struct bpf_stat' declared inside par
ameter list
libnet_port_list.c: In function `libnet_plist_chain_dump':
libnet_port_list.c:233: error: `stdout' undeclared (first use in this function)
libnet_port_list.c:233: error: (Each undeclared identifier is reported only once
libnet_port_list.c:233: error: for each function it appears in.)
make[1]: *** [libnet_port_list.o] Error 1
make[1]: Leaving directory `/usr/libnet/src'
make: *** [all-recursive] Error 1
resolve:
change libnet\src\libnet_port_list.c
int
libnet_plist_chain_dump(libnet_plist_t *plist)
{
if (plist == NULL)
{
return (-1);
}
for (; plist; plist = plist->next)
{
if (plist->bport == plist->eport)
{
- fprintf(stdout, "%d ", plist->bport);
+ printf("%d ", plist->bport);
}
else
{
- fprintf(stdout, "%d-%d ", plist->bport, plist->eport);
+ printf("%d-%d ", plist->bport, plist->eport);
}
}
- fprintf(stdout, "\n");
+ printf("\n");
return (1);
}
*******************************************************************************
gcc -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -Wall -mno-cygwin -O0 -mms-b
itfields -DNO_SNPRINTF -I/usr/include/pcap -c `test -f 'libnet_prand.c' || echo
'./'`libnet_prand.c
...
...
...
libnet_prand.c: In function `libnet_get_prand':
libnet_prand.c:80: error: `HCRYPTPROV' undeclared (first use in this function)
libnet_prand.c:80: error: (Each undeclared identifier is reported only once
libnet_prand.c:80: error: for each function it appears in.)
libnet_prand.c:80: error: syntax error before "hProv"
libnet_prand.c:81: warning: implicit declaration of function `CryptAcquireContex
t'
libnet_prand.c:81: error: `hProv' undeclared (first use in this function)
libnet_prand.c:82: error: `PROV_RSA_FULL' undeclared (first use in this function
)
libnet_prand.c:83: error: `CRYPT_VERIFYCONTEXT' undeclared (first use in this fu
nction)
libnet_prand.c:85: warning: implicit declaration of function `CryptGenRandom'
libnet_prand.c:87: warning: implicit declaration of function `CryptReleaseContex
t'
make: *** [libnet_prand.o] Error 1
resolve:
change libnet\src\libnet_prand.c
#if (HAVE_CONFIG_H)
#include "../include/config.h"
#endif
#if (!(_WIN32) || (__CYGWIN__))
#include "../include/libnet.h"
#else
#include "../include/win32/libnet.h"
+#include "/usr/include/w32api/wincrypt.h"
#endif
*******************************************************************************
gcc -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -Wall -mno-cygwin -O0 -mms-b
itfields -DNO_SNPRINTF -I/usr/include/pcap -c `test -f 'libnet_raw.c' || echo '.
/'`libnet_raw.c
In file included from libnet_raw.c:39:
../include/win32/libnet.h:59:1: warning: "STDOUT_FILENO" redefined
In file included from /usr/include/pcap/pcap.h:51,
from ../include/win32/libnet.h:41,
from libnet_raw.c:39:
/usr/i686-pc-mingw32/include/stdio.h:43:1: warning: this is the location of the
previous definition
In file included from libnet_raw.c:39:
../include/win32/libnet.h:72: warning: ignoring #pragma comment
../include/win32/libnet.h:73: warning: ignoring #pragma comment
../include/win32/libnet.h:74: warning: ignoring #pragma comment
../include/win32/libnet.h:75: warning: ignoring #pragma comment
In file included from libnet_raw.c:39:
../include/win32/libnet.h:78:1: warning: "VERSION" redefined
In file included from libnet_raw.c:34:
../include/config.h:119:1: warning: this is the location of the previous definit
ion
In file included from ../include/win32/libnet.h:93,
from libnet_raw.c:39:
../include/libnet/libnet-macros.h:41:1: warning: "snprintf" redefined
In file included from libnet_raw.c:39:
../include/win32/libnet.h:60:1: warning: this is the location of the previous de
finition
In file included from ../include/libnet/libnet-structures.h:36,
from ../include/win32/libnet.h:95,
from libnet_raw.c:39:
/usr/include/pcap/Packet32.h:386: warning: `struct bpf_stat' declared inside par
ameter list
/usr/include/pcap/Packet32.h:386: warning: its scope is only this definition or
declaration, which is probably not what you want
/usr/include/pcap/Packet32.h:387: warning: `struct bpf_stat' declared inside par
ameter list
libnet_raw.c:45: error: conflicting types for `libnet_open_raw4'
../include/libnet/libnet-functions.h:1950: error: previous declaration of `libne
t_open_raw4'
make: *** [libnet_raw.o] Error 1
resolve:
change libnet\include\libnet\libnet-functions.h
#if ((__WIN32__) && !(__CYGWIN__))
/*
* [Internal]
*/
- SOCKET
+ int
libnet_open_raw4(libnet_t *l);
#else
/*
* [Internal]
*/
int
libnet_open_raw4(libnet_t *l);
#endif
*************************************************************************
gcc -DHAVE_CONFIG_H -I. -I. -I../include -g -O2 -Wall -mno-cygwin -O0 -mms-b
itfields -DNO_SNPRINTF -I/usr/include/pcap -c `test -f 'libnet_version.c' || ech
o './'`libnet_version.c
In file included from libnet_version.c:37:
../include/win32/libnet.h:59:1: warning: "STDOUT_FILENO" redefined
In file included from /usr/include/pcap/pcap.h:51,
from ../include/win32/libnet.h:41,
from libnet_version.c:37:
/usr/i686-pc-mingw32/include/stdio.h:43:1: warning: this is the location of the
previous definition
In file included from libnet_version.c:37:
../include/win32/libnet.h:72: warning: ignoring #pragma comment
../include/win32/libnet.h:73: warning: ignoring #pragma comment
../include/win32/libnet.h:74: warning: ignoring #pragma comment
../include/win32/libnet.h:75: warning: ignoring #pragma comment
In file included from ../include/win32/libnet.h:93,
from libnet_version.c:37:
../include/libnet/libnet-macros.h:41:1: warning: "snprintf" redefined
In file included from libnet_version.c:37:
../include/win32/libnet.h:60:1: warning: this is the location of the previous de
finition
In file included from ../include/libnet/libnet-structures.h:36,
from ../include/win32/libnet.h:95,
from libnet_version.c:37:
/usr/include/pcap/Packet32.h:386: warning: `struct bpf_stat' declared inside par
ameter list
/usr/include/pcap/Packet32.h:386: warning: its scope is only this definition or
declaration, which is probably not what you want
/usr/include/pcap/Packet32.h:387: warning: `struct bpf_stat' declared inside par
ameter list
libnet_version.c: In function `__libnet_print_vers':
libnet_version.c:50: error: `stdout' undeclared (first use in this function)
libnet_version.c:50: error: (Each undeclared identifier is reported only once
libnet_version.c:50: error: for each function it appears in.)
make: *** [libnet_version.o] Error 1
resolve:
change libnet\src\libnet_version.c
void
__libnet_print_vers(void)
{
/*
* We don't check for error cos we really don't care.
*/
#if defined (__WIN32__)
- fprintf(stdout,"%s",banner);
+ printf("%s",banner);
#else
write(STDOUT_FILENO, banner, sizeof(banner) - 1);
#endif
}
*************************************************************************
Hereto,libnet.a was being bulid.
There still had some problem with samples hereinafter.
*************************************************************************
gcc -g -O2 -Wall -mno-cygwin -O0 -mms-bitfields -DNO_SNPRINTF -I/usr/include/pc
ap -o arp.exe arp.o ../src/libnet.a -lwpcap -lpacket -lws2_32
../src/libnet.a(libnet_link_win32.o)(.text+0x72d): In function `libnet_win32_get
_remote_mac':
/usr/libnet/src/libnet_link_win32.c:260: undefined reference to `_SendARP@16'
../src/libnet.a(libnet_link_win32.o)(.text+0x757):/usr/libnet/src/libnet_link_wi
n32.c:263: undefined reference to `_GetAdaptersInfo@8'
../src/libnet.a(libnet_link_win32.o)(.text+0x785):/usr/libnet/src/libnet_link_wi
n32.c:265: undefined reference to `_GetAdaptersInfo@8'
../src/libnet.a(libnet_link_win32.o)(.text+0x7e7):/usr/libnet/src/libnet_link_wi
n32.c:271: undefined reference to `_SendARP@16'
../src/libnet.a(libnet_link_win32.o)(.text+0x8a2): In function `libnet_win32_rea
d_arp_table':
/usr/libnet/src/libnet_link_win32.c:306: undefined reference to `_GetIpNetTable@
12'
../src/libnet.a(libnet_link_win32.o)(.text+0x8f7):/usr/libnet/src/libnet_link_wi
n32.c:310: undefined reference to `_GetIpNetTable@12'
collect2: ld returned 1 exit status
make[1]: *** [arp.exe] Error 1
make[1]: Leaving directory `/usr/libnet/sample'
make: *** [all-recursive] Error 1
Administrator@xie /usr/libnet
I was a little sad that there still needed package which came from msvc when making on cygwin,that stoped me.