Support NAT-PMP on Windows

- Link in libws32 and libiphlpapi, needed for libnatpmp (both in
  ./configure and when compiling tor-fw-helper-natpmp.c)
- Define STATICLIB under Windows, to allow tor-fw-helper-natpmp.c to link
- Don't include arpa/inet.h which isn't present in Mingw32 and doesn't
  appear to be needed on either Windows or MacOS X
This commit is contained in:
Steven Murdoch 2011-11-30 19:37:17 +00:00 committed by Steven Murdoch
parent b5a306e82c
commit 5dbfb1b3e0
3 changed files with 9 additions and 4 deletions

View File

@ -548,9 +548,12 @@ dnl There are no packages for Debian or Redhat as of this patch
if test "$natpmp" = "true"; then if test "$natpmp" = "true"; then
AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.]) AC_DEFINE(NAT_PMP, 1, [Define to 1 if we are building with nat-pmp.])
TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp], TOR_SEARCH_LIBRARY(libnatpmp, $trylibnatpmpdir, [-lnatpmp $TOR_LIB_WS32 $TOR_LIB_IPHLPAPI],
[#include <natpmp.h>],
[#include <natpmp.h>], [#include <natpmp.h>],
[#ifdef MS_WINDOWS
#define STATICLIB
#endif
#include <natpmp.h>],
[ int r; [ int r;
natpmp_t natpmp; natpmp_t natpmp;
natpmpresp_t response; natpmpresp_t response;

View File

@ -15,7 +15,7 @@ noinst_HEADERS = \
if NAT_PMP if NAT_PMP
nat_pmp_ldflags = @TOR_LDFLAGS_libnatpmp@ nat_pmp_ldflags = @TOR_LDFLAGS_libnatpmp@
nat_pmp_ldadd = -lnatpmp nat_pmp_ldadd = -lnatpmp @TOR_LIB_IPHLPAPI@
nat_pmp_cppflags = @TOR_CPPFLAGS_libnatpmp@ nat_pmp_cppflags = @TOR_CPPFLAGS_libnatpmp@
else else
nat_pmp_ldflags = nat_pmp_ldflags =

View File

@ -9,11 +9,13 @@
#include "orconfig.h" #include "orconfig.h"
#ifdef NAT_PMP #ifdef NAT_PMP
#ifdef MS_WINDOWS
#define STATICLIB
#endif
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <arpa/inet.h>
// debugging stuff // debugging stuff
#include <assert.h> #include <assert.h>