From beea6b0260e8d0b4689d16dc7dc80f07fd854768 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Mon, 18 Mar 2013 10:33:07 -0700 Subject: Check for socklen_t (suggested by g.esp and Stefanos Harhalakis) --- libnet/configure.ac | 13 +++++++++++++ libnet/src/libnet_raw.c | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 + #include + ], + [ 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; -- cgit v1.2.1