Browse files

basic wrapper around miniupnpc: c++ and cmake. nat-pmp to follow.

  • Loading branch information...
0 parents commit d74ec91def371366a8b57c8e279f7ddf6ecab6cd @RJ committed Jul 8, 2009
Showing with 7,909 additions and 0 deletions.
  1. +38 −0 CMakeLists.txt
  2. +26 −0 README
  3. +24 −0 include/portfwd.h
  4. +28 −0 src/main.cpp
  5. +105 −0 src/portfwd.cpp
  6. +133 −0 third-party/libnatpmp/.deps/getgateway.Po
  7. +134 −0 third-party/libnatpmp/.deps/natpmp.Po
  8. +516 −0 third-party/libnatpmp/Makefile
  9. +16 −0 third-party/libnatpmp/Makefile.am
  10. +516 −0 third-party/libnatpmp/Makefile.in
  11. +4 −0 third-party/libnatpmp/README
  12. +15 −0 third-party/libnatpmp/declspec.h
  13. +423 −0 third-party/libnatpmp/getgateway.c
  14. +31 −0 third-party/libnatpmp/getgateway.h
  15. BIN third-party/libnatpmp/getgateway.o
  16. BIN third-party/libnatpmp/libnatpmp.a
  17. +339 −0 third-party/libnatpmp/natpmp.c
  18. +187 −0 third-party/libnatpmp/natpmp.h
  19. BIN third-party/libnatpmp/natpmp.o
  20. +250 −0 third-party/miniupnpc-20090605/Changelog.txt
  21. +26 −0 third-party/miniupnpc-20090605/LICENCE
  22. +127 −0 third-party/miniupnpc-20090605/Makefile
  23. +74 −0 third-party/miniupnpc-20090605/Makefile.mingw
  24. +54 −0 third-party/miniupnpc-20090605/README
  25. +531 −0 third-party/miniupnpc-20090605/bsdqueue.h
  26. +24 −0 third-party/miniupnpc-20090605/codelength.h
  27. +15 −0 third-party/miniupnpc-20090605/declspec.h
  28. +113 −0 third-party/miniupnpc-20090605/igd_desc_parse.c
  29. +47 −0 third-party/miniupnpc-20090605/igd_desc_parse.h
  30. +52 −0 third-party/miniupnpc-20090605/man3/miniupnpc.3
  31. +7 −0 third-party/miniupnpc-20090605/mingw32make.bat
  32. +113 −0 third-party/miniupnpc-20090605/minisoap.c
  33. +15 −0 third-party/miniupnpc-20090605/minisoap.h
  34. +109 −0 third-party/miniupnpc-20090605/minissdpc.c
  35. +15 −0 third-party/miniupnpc-20090605/minissdpc.h
  36. +747 −0 third-party/miniupnpc-20090605/miniupnpc.c
  37. +31 −0 third-party/miniupnpc-20090605/miniupnpc.def
  38. +110 −0 third-party/miniupnpc-20090605/miniupnpc.h
  39. +460 −0 third-party/miniupnpc-20090605/miniupnpcmodule.c
  40. +15 −0 third-party/miniupnpc-20090605/miniupnpcstrings.h
  41. +222 −0 third-party/miniupnpc-20090605/miniwget.c
  42. +28 −0 third-party/miniupnpc-20090605/miniwget.h
  43. +191 −0 third-party/miniupnpc-20090605/minixml.c
  44. +37 −0 third-party/miniupnpc-20090605/minixml.h
  45. +149 −0 third-party/miniupnpc-20090605/minixmlvalid.c
  46. +52 −0 third-party/miniupnpc-20090605/pymoduletest.py
  47. +15 −0 third-party/miniupnpc-20090605/setup.py
  48. +15 −0 third-party/miniupnpc-20090605/setupmingw32.py
  49. +57 −0 third-party/miniupnpc-20090605/testigddescparse.c
  50. +88 −0 third-party/miniupnpc-20090605/testminixml.c
  51. +84 −0 third-party/miniupnpc-20090605/testupnpigd.py
  52. +44 −0 third-party/miniupnpc-20090605/testupnpreplyparse.c
  53. +36 −0 third-party/miniupnpc-20090605/updateminiupnpcstrings.sh
  54. +374 −0 third-party/miniupnpc-20090605/upnpc.c
  55. +573 −0 third-party/miniupnpc-20090605/upnpcommands.c
  56. +193 −0 third-party/miniupnpc-20090605/upnpcommands.h
  57. +66 −0 third-party/miniupnpc-20090605/upnperrors.c
  58. +26 −0 third-party/miniupnpc-20090605/upnperrors.h
  59. +127 −0 third-party/miniupnpc-20090605/upnpreplyparse.c
  60. +62 −0 third-party/miniupnpc-20090605/upnpreplyparse.h
38 CMakeLists.txt
@@ -0,0 +1,38 @@
+PROJECT(libportfwd)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
+SET(CMAKE_VERBOSE_MAKEFILE ON)
+SET(CMAKE_INSTALL_PREFIX "/usr/local/")
+
+SET(MINIUPNP_DIR "third-party/miniupnpc-20090605/")
+SET(NATPMP_DIR "third-party/libnatpmp")
+
+SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
+SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
+ADD_DEFINITIONS(-Wall -O2 -DNDEBUG)
+INCLUDE_DIRECTORIES(${MINIUPNP_DIR} include)
+
+ADD_LIBRARY(portfwd STATIC
+
+ # the needed bits of miniupnpc (no python module, no tests, no cli)
+ ${MINIUPNP_DIR}/igd_desc_parse.c
+ ${MINIUPNP_DIR}/minisoap.c
+ ${MINIUPNP_DIR}/minissdpc.c
+ ${MINIUPNP_DIR}/miniupnpc.c
+ ${MINIUPNP_DIR}/miniwget.c
+ ${MINIUPNP_DIR}/minixml.c
+ ${MINIUPNP_DIR}/minixmlvalid.c
+ ${MINIUPNP_DIR}/upnpc.c
+ ${MINIUPNP_DIR}/upnpcommands.c
+ ${MINIUPNP_DIR}/upnperrors.c
+ ${MINIUPNP_DIR}/upnpreplyparse.c
+
+ # Our wrapper:
+ src/portfwd.cpp
+)
+
+ADD_EXECUTABLE(portfwd-test
+ src/main.cpp
+ )
+TARGET_LINK_LIBRARIES(portfwd-test portfwd)
+
+
26 README
@@ -0,0 +1,26 @@
+libportfwd
+----------
+A basic, lightweight c++ wrapper around miniupnp and nat-pmp libraries
+for setting up port fwds, and finding out external IP address.
+
+See: http://miniupnp.free.fr/
+
+Designed to wrap up miniupnpc/natpmp libs into a static lib with a small API
+so other projects can easily setup port fwds without shipping extra libs/deps.
+
+Uses cmake to build needed bits of miniupnpc..
+
+NB/TODO
+-------
+I don't have a nat-pmp capable device (eg: airport express)
+so haven't implemented that bit yet. only supports upnp atm.
+
+Usage
+-----
+See the demo in main.cpp, but here's the jist:
+
+ Portfwd pf;
+ pf.init();
+ pf.add("192.168.1.2", 1234); // your lan IP, and port to fwd
+ pf.remove(1234); // remove port fwding on exit!
+
24 include/portfwd.h
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <cstdio>
+#include <iostream>
+//fwd:
+struct UPNPUrls;
+struct IGDdatas;
+
+class Portfwd
+{
+ public:
+ Portfwd();
+ ~Portfwd();
+ bool init();
+ bool add(const std::string& ip, unsigned short port);
+ bool remove(unsigned short port);
+ std::string external_ip();
+
+ protected:
+ struct UPNPUrls* urls;
+ struct IGDdatas* data;
+};
+
28 src/main.cpp
@@ -0,0 +1,28 @@
+#include "portfwd.h"
+int main(int argc, char** argv)
+{
+ if(argc!=3)
+ {
+ printf("Usage: %s <lan ip> <port>\n", argv[0]);
+ return 1;
+ }
+ int port = atoi(argv[2]);
+ std::string lanip = std::string(argv[1]);
+ printf("Using %s:%d\n", lanip.c_str(), port);
+ Portfwd pf;
+ if(!pf.init())
+ {
+ printf("Portfwd.init() failed.\n");
+ return 2;
+ }
+ printf("External IP: %s\n", pf.external_ip().c_str());
+ printf("%s\n", ((pf.add( lanip, port ))?"Added":"Failed to add") );
+
+ printf("Any key to exit...\n");
+ char foo;
+ scanf("%c",&foo);
+
+ printf("%s\n", ((pf.remove( port ))?"Removed.":"Failed to remove") );
+ return 0;
+}
+
105 src/portfwd.cpp
@@ -0,0 +1,105 @@
+#include "portfwd.h"
+
+#include "miniwget.h"
+#include "miniupnpc.h"
+#include "upnpcommands.h"
+
+Portfwd::Portfwd()
+ : urls(0), data(0)
+{
+}
+
+Portfwd::~Portfwd()
+{
+ if(urls) free(urls);
+ if(data) free(data);
+}
+
+bool
+Portfwd::init()
+{
+ struct UPNPDev * devlist;
+ struct UPNPDev * dev;
+ char * descXML;
+ int descXMLsize = 0;
+ printf("TB : init_upnp()\n");
+ urls = (UPNPUrls*)malloc(sizeof(struct UPNPUrls));
+ data = (IGDdatas*)malloc(sizeof(struct IGDdatas));
+ memset(urls, 0, sizeof(struct UPNPUrls));
+ memset(data, 0, sizeof(struct IGDdatas));
+ devlist = upnpDiscover(2000, NULL, NULL, 0);
+ if (devlist)
+ {
+ dev = devlist;
+ while (dev)
+ {
+ if (strstr (dev->st, "InternetGatewayDevice"))
+ break;
+ dev = dev->pNext;
+ }
+ if (!dev)
+ dev = devlist; /* defaulting to first device */
+
+ printf("UPnP device :\n"
+ " desc: %s\n st: %s\n",
+ dev->descURL, dev->st);
+
+ descXML = (char*)miniwget(dev->descURL, &descXMLsize);
+ if (descXML)
+ {
+ parserootdesc (descXML, descXMLsize, data);
+ free (descXML); descXML = 0;
+ GetUPNPUrls (urls, data, dev->descURL);
+ }
+ freeUPNPDevlist(devlist);
+ return true;
+ }
+ return false;
+}
+
+bool
+Portfwd::add( const std::string& ip, unsigned short port )
+{
+ char port_str[16];
+ int r;
+ printf("TB : upnp_add_redir (%s, %d)\n", ip.c_str(), port);
+ if(urls->controlURL[0] == '\0')
+ {
+ printf("TB : the init was not done !\n");
+ return false;
+ }
+ sprintf(port_str, "%d", port);
+ r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
+ port_str, port_str, ip.c_str(), 0, "TCP", NULL);
+ if(r!=0)
+ {
+ printf("AddPortMapping(%s, %s, %s) failed, code %d\n", port_str, port_str, ip.c_str(), r);
+ return false;
+ }
+ return true;
+}
+
+bool
+Portfwd::remove( unsigned short port )
+{
+ char port_str[16];
+ printf("TB : upnp_rem_redir (%d)\n", port);
+ if(urls->controlURL[0] == '\0')
+ {
+ printf("TB : the init was not done !\n");
+ return false;
+ }
+ sprintf(port_str, "%d", port);
+ int r = UPNP_DeletePortMapping(urls->controlURL, data->servicetype, port_str, "TCP", NULL);
+ return r == 0;
+}
+
+std::string
+Portfwd::external_ip()
+{
+ char ip[16];
+ int r = UPNP_GetExternalIPAddress( urls->controlURL, data->servicetype, (char*)&ip );
+ if( r != 0 ) return "";
+ return std::string(ip);
+}
+
133 third-party/libnatpmp/.deps/getgateway.Po
@@ -0,0 +1,133 @@
+getgateway.o: getgateway.c /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stddef.h \
+ /usr/include/bits/types.h /usr/include/bits/typesizes.h \
+ /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stdarg.h \
+ /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
+ /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \
+ /usr/include/bits/byteswap.h /usr/include/netinet/in.h \
+ /usr/include/stdint.h /usr/include/bits/wchar.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/sys/types.h /usr/include/time.h /usr/include/sys/select.h \
+ /usr/include/bits/select.h /usr/include/bits/sigset.h \
+ /usr/include/bits/time.h /usr/include/sys/sysmacros.h \
+ /usr/include/bits/pthreadtypes.h /usr/include/bits/uio.h \
+ /usr/include/bits/socket.h /usr/include/bits/sockaddr.h \
+ /usr/include/asm/socket.h /usr/include/asm/sockios.h \
+ /usr/include/bits/socket2.h /usr/include/bits/in.h \
+ /usr/include/sys/param.h \
+ /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include-fixed/limits.h \
+ /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include-fixed/syslimits.h \
+ /usr/include/limits.h /usr/include/bits/posix1_lim.h \
+ /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
+ /usr/include/bits/posix2_lim.h /usr/include/linux/param.h \
+ /usr/include/asm/param.h getgateway.h declspec.h
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/sys/cdefs.h:
+
+/usr/include/bits/wordsize.h:
+
+/usr/include/gnu/stubs.h:
+
+/usr/include/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stddef.h:
+
+/usr/include/bits/types.h:
+
+/usr/include/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stdarg.h:
+
+/usr/include/bits/stdio_lim.h:
+
+/usr/include/bits/sys_errlist.h:
+
+/usr/include/bits/stdio.h:
+
+/usr/include/bits/stdio2.h:
+
+/usr/include/ctype.h:
+
+/usr/include/endian.h:
+
+/usr/include/bits/endian.h:
+
+/usr/include/bits/byteswap.h:
+
+/usr/include/netinet/in.h:
+
+/usr/include/stdint.h:
+
+/usr/include/bits/wchar.h:
+
+/usr/include/sys/socket.h:
+
+/usr/include/sys/uio.h:
+
+/usr/include/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/sys/select.h:
+
+/usr/include/bits/select.h:
+
+/usr/include/bits/sigset.h:
+
+/usr/include/bits/time.h:
+
+/usr/include/sys/sysmacros.h:
+
+/usr/include/bits/pthreadtypes.h:
+
+/usr/include/bits/uio.h:
+
+/usr/include/bits/socket.h:
+
+/usr/include/bits/sockaddr.h:
+
+/usr/include/asm/socket.h:
+
+/usr/include/asm/sockios.h:
+
+/usr/include/bits/socket2.h:
+
+/usr/include/bits/in.h:
+
+/usr/include/sys/param.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/4.3.3/include-fixed/limits.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/4.3.3/include-fixed/syslimits.h:
+
+/usr/include/limits.h:
+
+/usr/include/bits/posix1_lim.h:
+
+/usr/include/bits/local_lim.h:
+
+/usr/include/linux/limits.h:
+
+/usr/include/bits/posix2_lim.h:
+
+/usr/include/linux/param.h:
+
+/usr/include/asm/param.h:
+
+getgateway.h:
+
+declspec.h:
134 third-party/libnatpmp/.deps/natpmp.Po
@@ -0,0 +1,134 @@
+natpmp.o: natpmp.c /usr/include/string.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stddef.h \
+ /usr/include/bits/string.h /usr/include/bits/string2.h \
+ /usr/include/endian.h /usr/include/bits/endian.h \
+ /usr/include/bits/byteswap.h /usr/include/bits/types.h \
+ /usr/include/bits/typesizes.h /usr/include/stdlib.h \
+ /usr/include/bits/string3.h /usr/include/time.h \
+ /usr/include/bits/time.h /usr/include/sys/time.h \
+ /usr/include/sys/select.h /usr/include/bits/select.h \
+ /usr/include/bits/sigset.h /usr/include/errno.h \
+ /usr/include/bits/errno.h /usr/include/linux/errno.h \
+ /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
+ /usr/include/asm-generic/errno-base.h /usr/include/unistd.h \
+ /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \
+ /usr/include/getopt.h /usr/include/bits/unistd.h /usr/include/fcntl.h \
+ /usr/include/bits/fcntl.h /usr/include/sys/types.h \
+ /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \
+ /usr/include/bits/fcntl2.h /usr/include/sys/socket.h \
+ /usr/include/sys/uio.h /usr/include/bits/uio.h \
+ /usr/include/bits/socket.h /usr/include/bits/sockaddr.h \
+ /usr/include/asm/socket.h /usr/include/asm/sockios.h \
+ /usr/include/bits/socket2.h natpmp.h /usr/include/netinet/in.h \
+ /usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/bits/in.h \
+ getgateway.h declspec.h
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/sys/cdefs.h:
+
+/usr/include/bits/wordsize.h:
+
+/usr/include/gnu/stubs.h:
+
+/usr/include/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/4.3.3/include/stddef.h:
+
+/usr/include/bits/string.h:
+
+/usr/include/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/bits/endian.h:
+
+/usr/include/bits/byteswap.h:
+
+/usr/include/bits/types.h:
+
+/usr/include/bits/typesizes.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/bits/string3.h:
+
+/usr/include/time.h:
+
+/usr/include/bits/time.h:
+
+/usr/include/sys/time.h:
+
+/usr/include/sys/select.h:
+
+/usr/include/bits/select.h:
+
+/usr/include/bits/sigset.h:
+
+/usr/include/errno.h:
+
+/usr/include/bits/errno.h:
+
+/usr/include/linux/errno.h:
+
+/usr/include/asm/errno.h:
+
+/usr/include/asm-generic/errno.h:
+
+/usr/include/asm-generic/errno-base.h:
+
+/usr/include/unistd.h:
+
+/usr/include/bits/posix_opt.h:
+
+/usr/include/bits/confname.h:
+
+/usr/include/getopt.h:
+
+/usr/include/bits/unistd.h:
+
+/usr/include/fcntl.h:
+
+/usr/include/bits/fcntl.h:
+
+/usr/include/sys/types.h:
+
+/usr/include/sys/sysmacros.h:
+
+/usr/include/bits/pthreadtypes.h:
+
+/usr/include/bits/fcntl2.h:
+
+/usr/include/sys/socket.h:
+
+/usr/include/sys/uio.h:
+
+/usr/include/bits/uio.h:
+
+/usr/include/bits/socket.h:
+
+/usr/include/bits/sockaddr.h:
+
+/usr/include/asm/socket.h:
+
+/usr/include/asm/sockios.h:
+
+/usr/include/bits/socket2.h:
+
+natpmp.h:
+
+/usr/include/netinet/in.h:
+
+/usr/include/stdint.h:
+
+/usr/include/bits/wchar.h:
+
+/usr/include/bits/in.h:
+
+getgateway.h:
+
+declspec.h:
516 third-party/libnatpmp/Makefile
@@ -0,0 +1,516 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# third-party/libnatpmp/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+
+pkgdatadir = $(datadir)/transmission
+pkglibdir = $(libdir)/transmission
+pkgincludedir = $(includedir)/transmission
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+subdir = third-party/libnatpmp
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx-pthread.m4 \
+ $(top_srcdir)/m4/check-ssl.m4 $(top_srcdir)/m4/glib-gettext.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
+ $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libnatpmp_a_AR = $(AR) $(ARFLAGS)
+libnatpmp_a_LIBADD =
+am_libnatpmp_a_OBJECTS = getgateway.$(OBJEXT) natpmp.$(OBJEXT)
+libnatpmp_a_OBJECTS = $(am_libnatpmp_a_OBJECTS)
+DEFAULT_INCLUDES = -I.
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libnatpmp_a_SOURCES)
+DIST_SOURCES = $(libnatpmp_a_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/rj/src/transmission-1.72/missing --run aclocal-1.10
+ALL_LINGUAS =
+AMTAR = ${SHELL} /home/rj/src/transmission-1.72/missing --run tar
+AR = ar
+AUTOCONF = ${SHELL} /home/rj/src/transmission-1.72/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/rj/src/transmission-1.72/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/rj/src/transmission-1.72/missing --run automake-1.10
+AWK = gawk
+CATALOGS =
+CATOBJEXT = .gmo
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2 -g -O3 -std=gnu99 -ggdb3 -Wall -W -Wpointer-arith -Wformat-security -Wcast-align -Wundef -Wcast-align -Wstrict-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wunused-parameter -Wwrite-strings -Wextra -Wdeclaration-after-statement -Winit-self
+CPP = gcc -E
+CPPFLAGS =
+CURL_MINIMUM = 7.16.3
+CXX = g++
+CXXCPP = g++ -E
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O3
+CYGPATH_W = echo
+DATADIRNAME = share
+DBUS_BINDING_TOOL =
+DBUS_GLIB_CFLAGS =
+DBUS_GLIB_LIBS =
+DBUS_GLIB_MINIMUM = 0.70
+DEFS = -DPACKAGE_NAME=\"transmission\" -DPACKAGE_TARNAME=\"transmission\" -DPACKAGE_VERSION=\"1.72\" -DPACKAGE_STRING=\"transmission\ 1.72\" -DPACKAGE_BUGREPORT=\"http://trac.transmissionbt.com/newticket\" -DPACKAGE=\"transmission\" -DVERSION=\"1.72\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DTR_STABLE_RELEASE=1 -DSTDC_HEADERS=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_DAEMON=1 -DHAVE_DIRNAME=1 -DHAVE_BASENAME=1 -DHAVE_DAEMON=1 -DHAVE_STRCASECMP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_POSIX_FALLOCATE=1 -DHAVE_MEMMEM=1 -DHAVE_PTHREAD=1 -DHAVE__TMP_DUMMY1_ZLIB_H=1 -DHAVE_ZLIB=1 -DHAVE_DECL_POSIX_FADVISE=1 -DHAVE_POSIX_FADVISE=1 -DWITH_INOTIFY=1 -DHAVE_LIBINTL_H=1 -DGETTEXT_PACKAGE=\"transmission\" -DHAVE_LOCALE_H=1 -DHAVE_LC_MESSAGES=1 -DHAVE_BIND_TEXTDOMAIN_CODESET=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1 -DENABLE_NLS=1
+DEPDIR = .deps
+DSYMUTIL =
+DUMPBIN =
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+FGREP = /bin/grep -F
+GETTEXT_PACKAGE = transmission
+GIO_CFLAGS =
+GIO_LIBS =
+GIO_MINIMUM = 2.15.5
+GLIB_MINIMUM = 2.6.0
+GMOFILES =
+GMSGFMT = /usr/bin/msgfmt
+GREP = /bin/grep
+GTK_CFLAGS =
+GTK_LIBS =
+GTK_MINIMUM = 2.6.0
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+INSTOBJEXT = .mo
+INTLLIBS =
+INTLTOOL_EXTRACT = /usr/bin/intltool-extract
+INTLTOOL_MERGE = /usr/bin/intltool-merge
+INTLTOOL_PERL = /usr/bin/perl
+INTLTOOL_UPDATE = /usr/bin/intltool-update
+LD = /usr/bin/ld -m elf_x86_64
+LDFLAGS =
+LIBCURL_CFLAGS =
+LIBCURL_LIBS = -lcurl
+LIBEVENT_CFLAGS = -I$(top_srcdir)/third-party/libevent -I$(top_builddir)/third-party/libevent
+LIBEVENT_LIBS = $(top_builddir)/third-party/libevent/libevent.la
+LIBEVENT_MINIUM =
+LIBNOTIFY_CFLAGS =
+LIBNOTIFY_LIBS =
+LIBNOTIFY_MINIMUM = 0.4.3
+LIBOBJS =
+LIBS =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIPO =
+LN_S = ln -s
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/rj/src/transmission-1.72/missing --run makeinfo
+MKDIR_P = /bin/mkdir -p
+MKINSTALLDIRS = ./mkinstalldirs
+MSGFMT = /usr/bin/msgfmt
+MSGMERGE = /usr/bin/msgmerge
+NM = /usr/bin/nm -B
+NMEDIT =
+OBJDUMP = objdump
+OBJEXT = o
+OPENSSL_CFLAGS =
+OPENSSL_LIBS = -lssl -lcrypto
+OPENSSL_MINIMUM = 0.9.4
+OTOOL =
+OTOOL64 =
+PACKAGE = transmission
+PACKAGE_BUGREPORT = http://trac.transmissionbt.com/newticket
+PACKAGE_NAME = transmission
+PACKAGE_STRING = transmission 1.72
+PACKAGE_TARNAME = transmission
+PACKAGE_VERSION = 1.72
+PATH_SEPARATOR = :
+PEERID_PREFIX = -TR1720-
+PKG_CONFIG = /usr/bin/pkg-config
+POFILES =
+POSUB = po
+PO_IN_DATADIR_FALSE =
+PO_IN_DATADIR_TRUE =
+PTHREAD_CC = gcc
+PTHREAD_CFLAGS = -pthread
+PTHREAD_LIBS =
+RANLIB = ranlib
+SED = /bin/sed
+SET_MAKE =
+SHELL = /bin/bash
+STRIP = strip
+USERAGENT_PREFIX = 1.72
+USE_NLS = yes
+VERSION = 1.72
+WINDRES =
+XGETTEXT = /usr/bin/xgettext
+ZLIB_CFLAGS =
+ZLIB_LDFLAGS =
+ZLIB_LIBS = -lz
+abs_builddir = /home/rj/src/transmission-1.72/third-party/libnatpmp
+abs_srcdir = /home/rj/src/transmission-1.72/third-party/libnatpmp
+abs_top_builddir = /home/rj/src/transmission-1.72
+abs_top_srcdir = /home/rj/src/transmission-1.72
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+ac_ct_DUMPBIN =
+acx_pthread_config =
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = tar --format=ustar -chf - "$$tardir"
+am__untar = tar -xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias =
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host = x86_64-unknown-linux-gnu
+host_alias =
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = $(SHELL) /home/rj/src/transmission-1.72/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+lt_ECHO = echo
+mandir = ${datarootdir}/man
+mkdir_p = /bin/mkdir -p
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+subdirs = third-party/libevent
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../../
+top_builddir = ../..
+top_srcdir = ../..
+transmissionlocaledir = ${prefix}/${DATADIRNAME}/locale
+noinst_LIBRARIES = libnatpmp.a
+AM_CPPFLAGS = -DENABLE_STRNATPMPERR
+libnatpmp_a_SOURCES = \
+ getgateway.c \
+ natpmp.c
+
+noinst_HEADERS = \
+ declspec.h \
+ getgateway.h \
+ natpmp.h
+
+extra_DIST = \
+ README \
+ LICENSE
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu third-party/libnatpmp/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu third-party/libnatpmp/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libnatpmp.a: $(libnatpmp_a_OBJECTS) $(libnatpmp_a_DEPENDENCIES)
+ -rm -f libnatpmp.a
+ $(libnatpmp_a_AR) libnatpmp.a $(libnatpmp_a_OBJECTS) $(libnatpmp_a_LIBADD)
+ $(RANLIB) libnatpmp.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/getgateway.Po
+include ./$(DEPDIR)/natpmp.Po
+
+.c.o:
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(COMPILE) -c $<
+
+.c.obj:
+ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+# source='$<' object='$@' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
16 third-party/libnatpmp/Makefile.am
@@ -0,0 +1,16 @@
+noinst_LIBRARIES = libnatpmp.a
+
+AM_CPPFLAGS = -DENABLE_STRNATPMPERR
+
+libnatpmp_a_SOURCES = \
+ getgateway.c \
+ natpmp.c
+
+noinst_HEADERS = \
+ declspec.h \
+ getgateway.h \
+ natpmp.h
+
+extra_DIST = \
+ README \
+ LICENSE
516 third-party/libnatpmp/Makefile.in
@@ -0,0 +1,516 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = third-party/libnatpmp
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/acx-pthread.m4 \
+ $(top_srcdir)/m4/check-ssl.m4 $(top_srcdir)/m4/glib-gettext.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
+ $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libnatpmp_a_AR = $(AR) $(ARFLAGS)
+libnatpmp_a_LIBADD =
+am_libnatpmp_a_OBJECTS = getgateway.$(OBJEXT) natpmp.$(OBJEXT)
+libnatpmp_a_OBJECTS = $(am_libnatpmp_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libnatpmp_a_SOURCES)
+DIST_SOURCES = $(libnatpmp_a_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALL_LINGUAS = @ALL_LINGUAS@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CURL_MINIMUM = @CURL_MINIMUM@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIRNAME = @DATADIRNAME@
+DBUS_BINDING_TOOL = @DBUS_BINDING_TOOL@
+DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@
+DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@
+DBUS_GLIB_MINIMUM = @DBUS_GLIB_MINIMUM@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GIO_MINIMUM = @GIO_MINIMUM@
+GLIB_MINIMUM = @GLIB_MINIMUM@
+GMOFILES = @GMOFILES@
+GMSGFMT = @GMSGFMT@
+GREP = @GREP@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+GTK_MINIMUM = @GTK_MINIMUM@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
+INTLLIBS = @INTLLIBS@
+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
+INTLTOOL_MERGE = @INTLTOOL_MERGE@
+INTLTOOL_PERL = @INTLTOOL_PERL@
+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBCURL_CFLAGS = @LIBCURL_CFLAGS@
+LIBCURL_LIBS = @LIBCURL_LIBS@
+LIBEVENT_CFLAGS = @LIBEVENT_CFLAGS@
+LIBEVENT_LIBS = @LIBEVENT_LIBS@
+LIBEVENT_MINIUM = @LIBEVENT_MINIUM@
+LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@
+LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@
+LIBNOTIFY_MINIMUM = @LIBNOTIFY_MINIMUM@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+OPENSSL_MINIMUM = @OPENSSL_MINIMUM@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PEERID_PREFIX = @PEERID_PREFIX@
+PKG_CONFIG = @PKG_CONFIG@
+POFILES = @POFILES@
+POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+USERAGENT_PREFIX = @USERAGENT_PREFIX@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WINDRES = @WINDRES@
+XGETTEXT = @XGETTEXT@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LDFLAGS = @ZLIB_LDFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+transmissionlocaledir = @transmissionlocaledir@
+noinst_LIBRARIES = libnatpmp.a
+AM_CPPFLAGS = -DENABLE_STRNATPMPERR
+libnatpmp_a_SOURCES = \
+ getgateway.c \
+ natpmp.c
+
+noinst_HEADERS = \
+ declspec.h \
+ getgateway.h \
+ natpmp.h
+
+extra_DIST = \
+ README \
+ LICENSE
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu third-party/libnatpmp/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu third-party/libnatpmp/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libnatpmp.a: $(libnatpmp_a_OBJECTS) $(libnatpmp_a_DEPENDENCIES)
+ -rm -f libnatpmp.a
+ $(libnatpmp_a_AR) libnatpmp.a $(libnatpmp_a_OBJECTS) $(libnatpmp_a_LIBADD)
+ $(RANLIB) libnatpmp.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgateway.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/natpmp.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
4 third-party/libnatpmp/README
@@ -0,0 +1,4 @@
+libnatpmp is written by Thomas Bernard.
+Its homepage is http://miniupnp.tuxfamily.org/libnatpmp.html
+This code is from the libnatpmp-20090310 snapshot
+
15 third-party/libnatpmp/declspec.h
@@ -0,0 +1,15 @@
+#ifndef __DECLSPEC_H__
+#define __DECLSPEC_H__
+
+#if defined(WIN32) && !defined(STATICLIB)
+ #ifdef NATPMP_EXPORTS
+ #define LIBSPEC __declspec(dllexport)
+ #else
+ #define LIBSPEC __declspec(dllimport)
+ #endif
+#else
+ #define LIBSPEC
+#endif
+
+#endif
+
423 third-party/libnatpmp/getgateway.c
@@ -0,0 +1,423 @@
+/* $Id: getgateway.c,v 1.13 2009/03/10 10:15:31 nanard Exp $ */
+/* libnatpmp
+ * Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+#include <stdio.h>
+#include <ctype.h>
+#ifndef WIN32
+#include <netinet/in.h>
+#endif
+#include <sys/param.h>
+/* There is no portable method to get the default route gateway.
+ * So below are three differents functions implementing this.
+ * Parsing /proc/net/route is for linux.
+ * sysctl is the way to access such informations on BSD systems.
+ * Many systems should provide route information through raw PF_ROUTE
+ * sockets. */
+#ifdef __linux__
+#define USE_PROC_NET_ROUTE
+#undef USE_SOCKET_ROUTE
+#undef USE_SYSCTL_NET_ROUTE
+#endif
+
+#ifdef BSD
+#undef USE_PROC_NET_ROUTE
+#define USE_SOCKET_ROUTE
+#undef USE_SYSCTL_NET_ROUTE
+#endif
+
+#ifdef __APPLE__
+#undef USE_PROC_NET_ROUTE
+#undef USE_SOCKET_ROUTE
+#define USE_SYSCTL_NET_ROUTE
+#endif
+
+#if (defined(sun) && defined(__SVR4))
+#undef USE_PROC_NET_ROUTE
+#define USE_SOCKET_ROUTE
+#undef USE_SYSCTL_NET_ROUTE
+#endif
+
+#ifdef WIN32
+#undef USE_PROC_NET_ROUTE
+#undef USE_SOCKET_ROUTE
+#undef USE_SYSCTL_NET_ROUTE
+#define USE_WIN32_CODE
+#endif
+
+#ifdef USE_SYSCTL_NET_ROUTE
+#include <stdlib.h>
+#include <sys/sysctl.h>
+#include <sys/socket.h>
+#include <net/route.h>
+#endif
+#ifdef USE_SOCKET_ROUTE
+#include <unistd.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/route.h>
+#endif
+#ifdef WIN32
+#include <unknwn.h>
+#include <winreg.h>
+#define MAX_KEY_LENGTH 255
+#define MAX_VALUE_LENGTH 16383
+#endif
+#include "getgateway.h"
+
+#ifndef WIN32
+#define SUCCESS (0)
+#define FAILED (-1)
+#endif
+
+#ifdef USE_PROC_NET_ROUTE
+int getdefaultgateway(in_addr_t * addr)
+{
+ long d, g;
+ char buf[256];
+ int line = 0;
+ FILE * f;
+ char * p;
+ f = fopen("/proc/net/route", "r");
+ if(!f)
+ return FAILED;
+ while(fgets(buf, sizeof(buf), f)) {
+ if(line > 0) {
+ p = buf;
+ while(*p && !isspace(*p))
+ p++;
+ while(*p && isspace(*p))
+ p++;
+ if(sscanf(p, "%lx%lx", &d, &g)==2) {
+ if(d == 0) { /* default */
+ *addr = g;
+ fclose(f);
+ return SUCCESS;
+ }
+ }
+ }
+ line++;
+ }
+ /* default route not found ! */
+ if(f)
+ fclose(f);
+ return FAILED;
+}
+#endif /* #ifdef USE_PROC_NET_ROUTE */
+
+
+#ifdef USE_SYSCTL_NET_ROUTE
+
+#define ROUNDUP(a) \
+ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+
+int getdefaultgateway(in_addr_t * addr)
+{
+#if 0
+ /* net.route.0.inet.dump.0.0 ? */
+ int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET,
+ NET_RT_DUMP, 0, 0/*tableid*/};
+#endif
+ /* net.route.0.inet.flags.gateway */
+ int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET,
+ NET_RT_FLAGS, RTF_GATEWAY};
+ size_t l;
+ char * buf, * p;
+ struct rt_msghdr * rt;
+ struct sockaddr * sa;
+ struct sockaddr * sa_tab[RTAX_MAX];
+ int i;
+ int r = FAILED;
+ if(sysctl(mib, sizeof(mib)/sizeof(int), 0, &l, 0, 0) < 0) {
+ return FAILED;
+ }
+ if(l>0) {
+ buf = malloc(l);
+ if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) {
+ free(buf);
+ return FAILED;
+ }
+ for(p=buf; p<buf+l; p+=rt->rtm_msglen) {
+ rt = (struct rt_msghdr *)p;
+ sa = (struct sockaddr *)(rt + 1);
+ for(i=0; i<RTAX_MAX; i++) {
+ if(rt->rtm_addrs & (1 << i)) {
+ sa_tab[i] = sa;
+ sa = (struct sockaddr *)((char *)sa + ROUNDUP(sa->sa_len));
+ } else {
+ sa_tab[i] = NULL;
+ }
+ }
+ if( ((rt->rtm_addrs & (RTA_DST|RTA_GATEWAY)) == (RTA_DST|RTA_GATEWAY))
+ && sa_tab[RTAX_DST]->sa_family == AF_INET
+ && sa_tab[RTAX_GATEWAY]->sa_family == AF_INET) {
+ if(((struct sockaddr_in *)sa_tab[RTAX_DST])->sin_addr.s_addr == 0) {
+ *addr = ((struct sockaddr_in *)(sa_tab[RTAX_GATEWAY]))->sin_addr.s_addr;
+ r = SUCCESS;
+ }
+ }
+ }
+ free(buf);
+ }
+ return r;
+}
+#endif /* #ifdef USE_SYSCTL_NET_ROUTE */
+
+
+#ifdef USE_SOCKET_ROUTE
+/* Thanks to Darren Kenny for this code */
+#define NEXTADDR(w, u) \
+ if (rtm_addrs & (w)) {\
+ l = sizeof(struct sockaddr); memmove(cp, &(u), l); cp += l;\
+ }
+
+#define rtm m_rtmsg.m_rtm
+
+struct {
+ struct rt_msghdr m_rtm;
+ char m_space[512];
+} m_rtmsg;
+
+int getdefaultgateway(in_addr_t *addr)
+{
+ int s, seq, l, rtm_addrs, i;
+ pid_t pid;
+ struct sockaddr so_dst, so_mask;
+ char *cp = m_rtmsg.m_space;
+ struct sockaddr *gate = NULL, *sa;
+ struct rt_msghdr *msg_hdr;
+
+ pid = getpid();
+ seq = 0;
+ rtm_addrs = RTA_DST | RTA_NETMASK;
+
+ memset(&so_dst, 0, sizeof(so_dst));
+ memset(&so_mask, 0, sizeof(so_mask));
+ memset(&rtm, 0, sizeof(struct rt_msghdr));
+
+ rtm.rtm_type = RTM_GET;
+ rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
+ rtm.rtm_version = RTM_VERSION;
+ rtm.rtm_seq = ++seq;
+ rtm.rtm_addrs = rtm_addrs;
+
+ so_dst.sa_family = AF_INET;
+ so_mask.sa_family = AF_INET;
+
+ NEXTADDR(RTA_DST, so_dst);
+ NEXTADDR(RTA_NETMASK, so_mask);
+
+ rtm.rtm_msglen = l = cp - (char *)&m_rtmsg;
+
+ s = socket(PF_ROUTE, SOCK_RAW, 0);
+
+ if (write(s, (char *)&m_rtmsg, l) < 0) {
+ close(s);
+ return FAILED;
+ }
+
+ do {
+ l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
+ } while (l > 0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid));
+
+ close(s);
+
+ msg_hdr = &rtm;
+
+ cp = ((char *)(msg_hdr + 1));
+ if (msg_hdr->rtm_addrs) {
+ for (i = 1; i; i <<= 1)
+ if (i & msg_hdr->rtm_addrs) {
+ sa = (struct sockaddr *)cp;
+ if (i == RTA_GATEWAY )
+ gate = sa;
+
+ cp += sizeof(struct sockaddr);
+ }
+ } else {
+ return FAILED;
+ }
+
+
+ if (gate != NULL ) {
+ *addr = ((struct sockaddr_in *)gate)->sin_addr.s_addr;
+ return SUCCESS;
+ } else {
+ return FAILED;
+ }
+}
+#endif /* #ifdef USE_SOCKET_ROUTE */
+
+#ifdef USE_WIN32_CODE
+int getdefaultgateway(in_addr_t * addr)
+{
+ HKEY networkCardsKey;
+ HKEY networkCardKey;
+ HKEY interfacesKey;
+ HKEY interfaceKey;
+ DWORD i = 0;
+ DWORD numSubKeys = 0;
+ TCHAR keyName[MAX_KEY_LENGTH];
+ DWORD keyNameLength = MAX_KEY_LENGTH;
+ TCHAR keyValue[MAX_VALUE_LENGTH];
+ DWORD keyValueLength = MAX_VALUE_LENGTH;
+ DWORD keyValueType = REG_SZ;
+ TCHAR gatewayValue[MAX_VALUE_LENGTH];
+ DWORD gatewayValueLength = MAX_VALUE_LENGTH;
+ DWORD gatewayValueType = REG_MULTI_SZ;
+ int done = 0;
+
+ char networkCardsPath[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards";
+ char interfacesPath[] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces";
+
+ // The windows registry lists its primary network devices in the following location:
+ // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
+ //
+ // Each network device has its own subfolder, named with an index, with various properties:
+ // -NetworkCards
+ // -5
+ // -Description = Broadcom 802.11n Network Adapter
+ // -ServiceName = {E35A72F8-5065-4097-8DFE-C7790774EE4D}
+ // -8
+ // -Description = Marvell Yukon 88E8058 PCI-E Gigabit Ethernet Controller
+ // -ServiceName = {86226414-5545-4335-A9D1-5BD7120119AD}
+ //
+ // The above service name is the name of a subfolder within:
+ // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
+ //
+ // There may be more subfolders in this interfaces path than listed in the network cards path above:
+ // -Interfaces
+ // -{3a539854-6a70-11db-887c-806e6f6e6963}
+ // -DhcpIPAddress = 0.0.0.0
+ // -[more]
+ // -{E35A72F8-5065-4097-8DFE-C7790774EE4D}
+ // -DhcpIPAddress = 10.0.1.4
+ // -DhcpDefaultGateway = 10.0.1.1
+ // -[more]
+ // -{86226414-5545-4335-A9D1-5BD7120119AD}
+ // -DhcpIpAddress = 10.0.1.5
+ // -DhcpDefaultGateay = 10.0.1.1
+ // -[more]
+ //
+ // In order to extract this information, we enumerate each network card, and extract the ServiceName value.
+ // This is then used to open the interface subfolder, and attempt to extract a DhcpDefaultGateway value.
+ // Once one is found, we're done.
+ //
+ // It may be possible to simply enumerate the interface folders until we find one with a DhcpDefaultGateway value.
+ // However, the technique used is the technique most cited on the web, and we assume it to be more correct.
+
+ if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predifined key
+ networkCardsPath, // Name of registry subkey to open
+ 0, // Reserved - must be zero
+ KEY_READ, // Mask - desired access rights
+ &networkCardsKey)) // Pointer to output key
+ {
+ // Unable to open network cards keys
+ return -1;
+ }
+
+ if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predefined key
+ interfacesPath, // Name of registry subkey to open
+ 0, // Reserved - must be zero
+ KEY_READ, // Mask - desired access rights
+ &interfacesKey)) // Pointer to output key
+ {
+ // Unable to open interfaces key
+ RegCloseKey(networkCardsKey);
+ return -1;
+ }
+
+ // Figure out how many subfolders are within the NetworkCards folder
+ RegQueryInfoKey(networkCardsKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ //printf( "Number of subkeys: %u\n", (unsigned int)numSubKeys);
+
+ // Enumrate through each subfolder within the NetworkCards folder
+ for(i = 0; i < numSubKeys && !done; i++)
+ {
+ keyNameLength = MAX_KEY_LENGTH;
+ if(ERROR_SUCCESS == RegEnumKeyEx(networkCardsKey, // Open registry key
+ i, // Index of subkey to retrieve
+ keyName, // Buffer that receives the name of the subkey
+ &keyNameLength, // Variable that receives the size of the above buffer
+ NULL, // Reserved - must be NULL
+ NULL, // Buffer that receives the class string
+ NULL, // Variable that receives the size of the above buffer
+ NULL)) // Variable that receives the last write time of subkey
+ {
+ if(RegOpenKeyEx(networkCardsKey, keyName, 0, KEY_READ, &networkCardKey) == ERROR_SUCCESS)
+ {
+ keyValueLength = MAX_VALUE_LENGTH;
+ if(ERROR_SUCCESS == RegQueryValueEx(networkCardKey, // Open registry key
+ "ServiceName", // Name of key to query
+ NULL, // Reserved - must be NULL
+ &keyValueType, // Receives value type
+ keyValue, // Receives value
+ &keyValueLength)) // Receives value length in bytes
+ {
+ //printf("keyValue: %s\n", keyValue);
+
+ if(RegOpenKeyEx(interfacesKey, keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS)
+ {
+ gatewayValueLength = MAX_VALUE_LENGTH;
+ if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
+ "DhcpDefaultGateway", // Name of key to query
+ NULL, // Reserved - must be NULL
+ &gatewayValueType, // Receives value type
+ gatewayValue, // Receives value
+ &gatewayValueLength)) // Receives value length in bytes
+ {
+ // Check to make sure it's a string
+ if(gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ)
+ {
+ //printf("gatewayValue: %s\n", gatewayValue);
+ done = 1;
+ }
+ }
+ else if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
+ "DefaultGateway", // Name of key to query
+ NULL, // Reserved - must be NULL
+ &gatewayValueType, // Receives value type
+ gatewayValue, // Receives value
+ &gatewayValueLength)) // Receives value length in bytes
+ {
+ // Check to make sure it's a string
+ if(gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ)
+ {
+ //printf("gatewayValue: %s\n", gatewayValue);
+ done = 1;
+ }
+ }
+ RegCloseKey(interfaceKey);
+ }
+ }
+ RegCloseKey(networkCardKey);
+ }
+ }
+ }
+
+ RegCloseKey(interfacesKey);
+ RegCloseKey(networkCardsKey);
+
+ if(done)
+ {
+ *addr = inet_addr(gatewayValue);
+ return 0;
+ }
+
+ return -1;
+}
+#endif /* #ifdef USE_WIN32_CODE */
+
31 third-party/libnatpmp/getgateway.h
@@ -0,0 +1,31 @@
+/* $Id: getgateway.h,v 1.3 2008/07/02 22:33:06 nanard Exp $ */
+/* libnatpmp
+ * Copyright (c) 2007, Thomas BERNARD <miniupnp@free.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+#ifndef __GETGATEWAY_H__
+#define __GETGATEWAY_H__
+
+#ifdef WIN32
+#include <stdint.h>
+#define in_addr_t uint32_t
+#endif
+#include "declspec.h"
+
+/* getdefaultgateway() :
+ * return value :
+ * 0 : success
+ * -1 : failure */
+LIBSPEC int getdefaultgateway(in_addr_t * addr);
+
+#endif
BIN third-party/libnatpmp/getgateway.o
Binary file not shown.
BIN third-party/libnatpmp/libnatpmp.a
Binary file not shown.
339 third-party/libnatpmp/natpmp.c
@@ -0,0 +1,339 @@
+/* $Id: natpmp.c,v 1.8 2008/07/02 22:33:06 nanard Exp $ */
+/* libnatpmp
+ * Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
+ * http://miniupnp.free.fr/libnatpmp.html
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#ifdef WIN32
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+#include <io.h>
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define ECONNREFUSED WSAECONNREFUSED
+#else
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#define closesocket close
+#endif
+#include "natpmp.h"
+#include "getgateway.h"
+
+int initnatpmp(natpmp_t * p)
+{
+#ifdef WIN32
+ u_long ioctlArg = 1;
+#else
+ int flags;
+#endif
+ struct sockaddr_in addr;
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+ memset(p, 0, sizeof(natpmp_t));
+ p->s = socket(PF_INET, SOCK_DGRAM, 0);
+ if(p->s < 0)
+ return NATPMP_ERR_SOCKETERROR;
+#ifdef WIN32
+ if(ioctlsocket(p->s, FIONBIO, &ioctlArg) == SOCKET_ERROR)
+ return NATPMP_ERR_FCNTLERROR;
+#else
+ if((flags = fcntl(p->s, F_GETFL, 0)) < 0)
+ return NATPMP_ERR_FCNTLERROR;
+ if(fcntl(p->s, F_SETFL, flags | O_NONBLOCK) < 0)
+ return NATPMP_ERR_FCNTLERROR;
+#endif
+
+ if(getdefaultgateway(&(p->gateway)) < 0)
+ return NATPMP_ERR_CANNOTGETGATEWAY;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(NATPMP_PORT);
+ addr.sin_addr.s_addr = p->gateway;
+ if(connect(p->s, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+ return NATPMP_ERR_CONNECTERR;
+ return 0;
+}
+
+int closenatpmp(natpmp_t * p)
+{
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+ if(closesocket(p->s) < 0)
+ return NATPMP_ERR_CLOSEERR;
+ return 0;
+}
+
+static int sendpendingrequest(natpmp_t * p)
+{
+ int r;
+/* struct sockaddr_in addr;*/
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+/* memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(NATPMP_PORT);
+ addr.sin_addr.s_addr = p->gateway;
+ r = (int)sendto(p->s, p->pending_request, p->pending_request_len, 0,
+ (struct sockaddr *)&addr, sizeof(addr));*/
+ r = (int)send(p->s, p->pending_request, p->pending_request_len, 0);
+ return (r<0) ? NATPMP_ERR_SENDERR : r;
+}
+
+static int sendnatpmprequest(natpmp_t * p)
+{
+ int n;
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+ /* TODO : check if no request is allready pending */
+ p->has_pending_request = 1;
+ p->try_number = 1;
+ n = sendpendingrequest(p);
+ gettimeofday(&p->retry_time, NULL); // check errors !
+ p->retry_time.tv_usec += 250000; /* add 250ms */
+ if(p->retry_time.tv_usec >= 1000000) {
+ p->retry_time.tv_usec -= 1000000;
+ p->retry_time.tv_sec++;
+ }
+ return n;
+}
+
+int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout)
+{
+ struct timeval now;
+ if(!p || !timeout)
+ return NATPMP_ERR_INVALIDARGS;
+ if(!p->has_pending_request)
+ return NATPMP_ERR_NOPENDINGREQ;
+ if(gettimeofday(&now, NULL) < 0)
+ return NATPMP_ERR_GETTIMEOFDAYERR;
+ timeout->tv_sec = p->retry_time.tv_sec - now.tv_sec;
+ timeout->tv_usec = p->retry_time.tv_usec - now.tv_usec;
+ if(timeout->tv_usec < 0) {
+ timeout->tv_usec += 1000000;
+ timeout->tv_sec--;
+ }
+ return 0;
+}
+
+int sendpublicaddressrequest(natpmp_t * p)
+{
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+ //static const unsigned char request[] = { 0, 0 };
+ p->pending_request[0] = 0;
+ p->pending_request[1] = 0;
+ p->pending_request_len = 2;
+ // TODO: return 0 instead of sizeof(request) ??
+ return sendnatpmprequest(p);
+}
+
+int sendnewportmappingrequest(natpmp_t * p, int protocol,
+ uint16_t privateport, uint16_t publicport,
+ uint32_t lifetime)
+{
+ if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP))
+ return NATPMP_ERR_INVALIDARGS;
+ p->pending_request[0] = 0;
+ p->pending_request[1] = protocol;
+ p->pending_request[2] = 0;
+ p->pending_request[3] = 0;
+ *((uint16_t *)(p->pending_request + 4)) = htons(privateport);
+ *((uint16_t *)(p->pending_request + 6)) = htons(publicport);
+ *((uint32_t *)(p->pending_request + 8)) = htonl(lifetime);
+ p->pending_request_len = 12;
+ return sendnatpmprequest(p);
+}
+
+static int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response)
+{
+ unsigned char buf[16];
+ struct sockaddr_in addr;
+ socklen_t addrlen = sizeof(addr);
+ int n;
+ if(!p)
+ return NATPMP_ERR_INVALIDARGS;
+ n = recvfrom(p->s, buf, sizeof(buf), 0,
+ (struct sockaddr *)&addr, &addrlen);
+ if(n<0)
+ switch(errno) {
+ /*case EAGAIN:*/
+ case EWOULDBLOCK:
+ n = NATPMP_TRYAGAIN;
+ break;
+ case ECONNREFUSED:
+ n = NATPMP_ERR_NOGATEWAYSUPPORT;
+ break;
+ default:
+ n = NATPMP_ERR_RECVFROM;
+ }
+ /* check that addr is correct (= gateway) */
+ else if(addr.sin_addr.s_addr != p->gateway)
+ n = NATPMP_ERR_WRONGPACKETSOURCE;
+ else {
+ response->resultcode = ntohs(*((uint16_t *)(buf + 2)));
+ response->epoch = ntohl(*((uint32_t *)(buf + 4)));
+ if(buf[0] != 0)
+ n = NATPMP_ERR_UNSUPPORTEDVERSION;
+ else if(buf[1] < 128 || buf[1] > 130)
+ n = NATPMP_ERR_UNSUPPORTEDOPCODE;
+ else if(response->resultcode != 0) {
+ switch(response->resultcode) {
+ case 1:
+ n = NATPMP_ERR_UNSUPPORTEDVERSION;
+ break;
+ case 2:
+ n = NATPMP_ERR_NOTAUTHORIZED;
+ break;
+ case 3:
+ n = NATPMP_ERR_NETWORKFAILURE;
+ break;
+ case 4:
+ n = NATPMP_ERR_OUTOFRESOURCES;
+ break;
+ case 5:
+ n = NATPMP_ERR_UNSUPPORTEDOPCODE;
+ break;
+ default:
+ n = NATPMP_ERR_UNDEFINEDERROR;
+ }
+ } else {
+ response->type = buf[1] & 0x7f;
+ if(buf[1] == 128)
+ //response->publicaddress.addr = *((uint32_t *)(buf + 8));
+ response->pnu.publicaddress.addr.s_addr = *((uint32_t *)(buf + 8));
+ else {
+ response->pnu.newportmapping.privateport = ntohs(*((uint16_t *)(buf + 8)));
+ response->pnu.newportmapping.mappedpublicport = ntohs(*((uint16_t *)(buf + 10)));
+ response->pnu.newportmapping.lifetime = ntohl(*((uint32_t *)(buf + 12)));
+ }
+ n = 0;
+ }
+ }
+ return n;
+}
+
+int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response)
+{
+ int n;
+ if(!p || !response)
+ return NATPMP_ERR_INVALIDARGS;
+ if(!p->has_pending_request)
+ return NATPMP_ERR_NOPENDINGREQ;
+ n = readnatpmpresponse(p, response);
+ if(n<0) {
+ if(n==NATPMP_TRYAGAIN) {
+ struct timeval now;
+ gettimeofday(&now, NULL); // check errors !
+ if(timercmp(&now, &p->retry_time, >=)) {
+ int delay, r;
+ if(p->try_number >= 9) {
+ return NATPMP_ERR_NOGATEWAYSUPPORT;
+ }
+ /*printf("retry! %d\n", p->try_number);*/
+ delay = 250 * (1<<p->try_number); // ms
+ /*for(i=0; i<p->try_number; i++)
+ delay += delay;*/
+ p->retry_time.tv_sec += (delay / 1000);
+ p->retry_time.tv_usec += (delay % 1000) * 1000;
+ if(p->retry_time.tv_usec >= 1000000) {
+ p->retry_time.tv_usec -= 1000000;
+ p->retry_time.tv_sec++;
+ }
+ p->try_number++;
+ r = sendpendingrequest(p);
+ if(r<0)
+ return r;
+ }
+ }
+ } else {
+ p->has_pending_request = 0;
+ }
+ return n;
+}
+
+#ifdef ENABLE_STRNATPMPERR
+const char * strnatpmperr(int r)
+{
+ const char * s;
+ switch(r) {
+ case NATPMP_ERR_INVALIDARGS:
+ s = "invalid arguments";
+ break;
+ case NATPMP_ERR_SOCKETERROR:
+ s = "socket() failed";
+ break;
+ case NATPMP_ERR_CANNOTGETGATEWAY:
+ s = "cannot get default gateway ip address";
+ break;
+ case NATPMP_ERR_CLOSEERR:
+#ifdef WIN32
+ s = "closesocket() failed";
+#else
+ s = "close() failed";
+#endif
+ break;
+ case NATPMP_ERR_RECVFROM:
+ s = "recvfrom() failed";
+ break;
+ case NATPMP_ERR_NOPENDINGREQ:
+ s = "no pending request";
+ break;
+ case NATPMP_ERR_NOGATEWAYSUPPORT:
+ s = "the gateway does not support nat-pmp";
+ break;
+ case NATPMP_ERR_CONNECTERR:
+ s = "connect() failed";
+ break;
+ case NATPMP_ERR_WRONGPACKETSOURCE:
+ s = "packet not received from the default gateway";
+ break;
+ case NATPMP_ERR_SENDERR:
+ s = "send() failed";
+ break;
+ case NATPMP_ERR_FCNTLERROR:
+ s = "fcntl() failed";
+ break;
+ case NATPMP_ERR_GETTIMEOFDAYERR:
+ s = "gettimeofday() failed";
+ break;
+ case NATPMP_ERR_UNSUPPORTEDVERSION:
+ s = "unsupported nat-pmp version error from server";
+ break;
+ case NATPMP_ERR_UNSUPPORTEDOPCODE:
+ s = "unsupported nat-pmp opcode error from server";
+ break;
+ case NATPMP_ERR_UNDEFINEDERROR:
+ s = "undefined nat-pmp server error";
+ break;
+ case NATPMP_ERR_NOTAUTHORIZED:
+ s = "not authorized";
+ break;
+ case NATPMP_ERR_NETWORKFAILURE:
+ s = "network failure";
+ break;
+ case NATPMP_ERR_OUTOFRESOURCES:
+ s = "nat-pmp server out of resources";
+ break;
+ default: