summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2013-03-18 10:33:07 -0700
committerSam Roberts <vieuxtech@gmail.com>2013-03-18 10:36:40 -0700
commitbeea6b0260e8d0b4689d16dc7dc80f07fd854768 (patch)
treef595214dc9a5b5b8464fefe45bf984ee2406ccb5
parente4e69f683658bc9bd1736ecd439496654a878fe1 (diff)
downloadlibnet-beea6b0260e8d0b4689d16dc7dc80f07fd854768.tar.gz
Check for socklen_t (suggested by g.esp and Stefanos Harhalakis)
-rw-r--r--libnet/configure.ac13
-rw-r--r--libnet/src/libnet_raw.c6
2 files changed, 18 insertions, 1 deletions
diff --git a/libnet/configure.ac b/libnet/configure.ac
index 2688469..9108740 100644
--- a/libnet/configure.ac
+++ b/libnet/configure.ac
@@ -30,6 +30,19 @@ AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
+AC_MSG_CHECKING(for socklen_t)
+AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ ],
+ [ socklen_t x; ],
+ have_socklen_t=yes,
+ have_socklen_t=no)
+if test "x$have_socklen_t" = "xyes"; then
+ AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined])
+fi
+AC_MSG_RESULT($have_socklen_t)
+
dnl
dnl And some custom things
dnl
diff --git a/libnet/src/libnet_raw.c b/libnet/src/libnet_raw.c
index c8cfe16..98917f7 100644
--- a/libnet/src/libnet_raw.c
+++ b/libnet/src/libnet_raw.c
@@ -32,6 +32,10 @@
#include "common.h"
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t
+#endif
+
/* TODO this doesn't make any sense, the code in the #else branch is littered
with conditionals on __WIN32__ that are never reachable, what happened?
*/
@@ -63,7 +67,7 @@ libnet_close_raw6(libnet_t *l)
int
libnet_open_raw4(libnet_t *l)
{
- int len; /* now supposed to be socklen_t, but maybe old systems used int? */
+ socklen_t len;
#if !(__WIN32__)
int n = 1;