summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-01-25 22:10:35 (GMT)
committerSwift Review <review@swift.im>2015-02-09 17:12:36 (GMT)
commit4fa1338b324c5e11218cea29c474da42b9142651 (patch)
tree2b3c68a0208ac9558abb7ab862c88a8a793891f2 /3rdParty/LibNATPMP/src/libnatpmp
parent415e2a0e26af19e00b7cafb58be72909ae1d8212 (diff)
downloadswift-4fa1338b324c5e11218cea29c474da42b9142651.zip
swift-4fa1338b324c5e11218cea29c474da42b9142651.tar.bz2
Update libnatpmp to version of release 20140401
Additional fixes: - applied our Android patch, as it has been applied before - added and applied a new patch that disables getdefaultgateway() dummy on the Windows platform Test-Information: Verified that it builds. Change-Id: Id5ebbada26fadbaf3aff1135aa997c49d88c9d84
Diffstat (limited to '3rdParty/LibNATPMP/src/libnatpmp')
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/LICENSE2
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/Makefile104
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/declspec.h12
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/getgateway.c103
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/getgateway.h43
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/natpmp.c69
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/natpmp.h56
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/natpmpc.c59
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.c46
-rw-r--r--3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.h44
10 files changed, 369 insertions, 169 deletions
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/LICENSE b/3rdParty/LibNATPMP/src/libnatpmp/LICENSE
index 14db2fe..7fff2c2 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/LICENSE
+++ b/3rdParty/LibNATPMP/src/libnatpmp/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2007-2009, Thomas BERNARD
+Copyright (c) 2007-2011, Thomas BERNARD
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/Makefile b/3rdParty/LibNATPMP/src/libnatpmp/Makefile
index b523e53..b67b3e8 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/Makefile
+++ b/3rdParty/LibNATPMP/src/libnatpmp/Makefile
@@ -1,30 +1,59 @@
-# $Id: Makefile,v 1.16 2011/01/03 17:31:03 nanard Exp $
+# $Id: Makefile,v 1.23 2013/11/26 16:38:15 nanard Exp $
# This Makefile is designed for use with GNU make
# libnatpmp
-# (c) 2007-2011 Thomas Bernard
+# (c) 2007-2013 Thomas Bernard
# http://miniupnp.free.fr/libnatpmp.html
OS = $(shell uname -s)
CC = gcc
-INSTALL = install
+INSTALL = install -p
+ARCH = $(shell uname -m | sed -e s/i.86/i686/)
+VERSION = $(shell cat VERSION)
+
+ifeq ($(OS), Darwin)
+JARSUFFIX=mac
+endif
+ifeq ($(OS), Linux)
+JARSUFFIX=linux
+endif
+ifneq (,$(findstring WIN,$(OS)))
+JARSUFFIX=win32
+endif
# APIVERSION is used in soname
APIVERSION = 1
-LDFLAGS = --no-undefined
-CFLAGS = -O -fPIC -Wall -DENABLE_STRNATPMPERR
+#LDFLAGS = -Wl,--no-undefined
+CFLAGS ?= -Os
+#CFLAGS = -g -O0
+CFLAGS += -fPIC
+CFLAGS += -Wall
+#CFLAGS += -Wextra
+CFLAGS += -DENABLE_STRNATPMPERR
+#CFLAGS += -Wstrict-aliasing
LIBOBJS = natpmp.o getgateway.o
-OBJS = $(LIBOBJS) testgetgateway.o natpmpc.o
+OBJS = $(LIBOBJS) testgetgateway.o natpmpc.o natpmp-jni.o
STATICLIB = libnatpmp.a
ifeq ($(OS), Darwin)
- SHAREDLIB = libnatpmp.dynlib
+ SHAREDLIB = libnatpmp.dylib
+ JNISHAREDLIB = libjninatpmp.dylib
SONAME = $(basename $(SHAREDLIB)).$(APIVERSION).dylib
CFLAGS := -DMACOSX -D_DARWIN_C_SOURCE $(CFLAGS)
+ SONAMEFLAGS=-Wl,-install_name,$(JNISHAREDLIB) -dynamiclib -framework JavaVM
+else
+ifneq (,$(findstring WIN,$(OS)))
+ SHAREDLIB = natpmp.dll
+ JNISHAREDLIB = jninatpmp.dll
+ CC = i686-w64-mingw32-gcc
+ EXTRA_LD = -lws2_32 -lIphlpapi -Wl,--no-undefined -Wl,--enable-runtime-pseudo-reloc --Wl,kill-at
else
SHAREDLIB = libnatpmp.so
+ JNISHAREDLIB = libjninatpmp.so
SONAME = $(SHAREDLIB).$(APIVERSION)
+ SONAMEFLAGS=-Wl,-soname,$(JNISHAREDLIB)
+endif
endif
HEADERS = natpmp.h
@@ -36,6 +65,13 @@ INSTALLDIRINC = $(INSTALLPREFIX)/include
INSTALLDIRLIB = $(INSTALLPREFIX)/lib
INSTALLDIRBIN = $(INSTALLPREFIX)/bin
+JAVA ?= java
+JAVAC ?= javac
+JAVAH ?= javah
+JAVAPACKAGE = fr/free/miniupnp/libnatpmp
+JAVACLASSES = $(JAVAPACKAGE)/NatPmp.class $(JAVAPACKAGE)/NatPmpResponse.class $(JAVAPACKAGE)/LibraryExtractor.class $(JAVAPACKAGE)/URLUtils.class
+JNIHEADERS = fr_free_miniupnp_libnatpmp_NatPmp.h
+
.PHONY: all clean depend install cleaninstall installpythonmodule
all: $(STATICLIB) $(SHAREDLIB) $(EXECUTABLES)
@@ -48,9 +84,9 @@ installpythonmodule: pythonmodule
python setup.py install
clean:
- $(RM) $(OBJS) $(EXECUTABLES) $(STATICLIB) $(SHAREDLIB)
+ $(RM) $(OBJS) $(EXECUTABLES) $(STATICLIB) $(SHAREDLIB) $(JAVACLASSES) $(JNISHAREDLIB)
$(RM) pythonmodule
- $(RM) -r build/ dist/
+ $(RM) -r build/ dist/ libraries/
depend:
makedepend -f$(MAKEFILE_LIST) -Y $(OBJS:.o=.c) 2>/dev/null
@@ -65,6 +101,48 @@ install: $(HEADERS) $(STATICLIB) $(SHAREDLIB) natpmpc-shared
$(INSTALL) -m 755 natpmpc-shared $(INSTALLDIRBIN)/natpmpc
ln -s -f $(SONAME) $(INSTALLDIRLIB)/$(SHAREDLIB)
+$(JNIHEADERS): fr/free/miniupnp/libnatpmp/NatPmp.class
+ $(JAVAH) -jni fr.free.miniupnp.libnatpmp.NatPmp
+
+%.class: %.java
+ $(JAVAC) -cp . $<
+
+$(JNISHAREDLIB): $(SHAREDLIB) $(JNIHEADERS) $(JAVACLASSES)
+ifeq (,$(JAVA_HOME))
+ @echo "Check your JAVA_HOME environement variable" && false
+endif
+ifneq (,$(findstring WIN,$(OS)))
+ $(CC) -m32 -D_JNI_Implementation_ -Wl,--kill-at \
+ -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" \
+ natpmp-jni.c -shared \
+ -o $(JNISHAREDLIB) -L. -lnatpmp -lws2_32 -lIphlpapi
+else
+ $(CC) $(CFLAGS) -c -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" natpmp-jni.c
+ $(CC) $(CFLAGS) -o $(JNISHAREDLIB) -shared $(SONAMEFLAGS) natpmp-jni.o -lc -L. -lnatpmp
+endif
+
+jar: $(JNISHAREDLIB)
+ find fr -name '*.class' -print > classes.list
+ $(eval JNISHAREDLIBPATH := $(shell java fr.free.miniupnp.libnatpmp.LibraryExtractor))
+ mkdir -p libraries/$(JNISHAREDLIBPATH)
+ mv $(JNISHAREDLIB) libraries/$(JNISHAREDLIBPATH)/$(JNISHAREDLIB)
+ jar cf natpmp_$(JARSUFFIX).jar @classes.list libraries/$(JNISHAREDLIBPATH)/$(JNISHAREDLIB)
+ $(RM) classes.list
+
+jnitest: $(JNISHAREDLIB) JavaTest.class
+ $(RM) libjninatpmp.so
+ $(JAVA) -Djna.nosys=true -cp . JavaTest
+
+mvn_install:
+ mvn install:install-file -Dfile=java/natpmp_$(JARSUFFIX).jar \
+ -DgroupId=com.github \
+ -DartifactId=natpmp \
+ -Dversion=$(VERSION) \
+ -Dpackaging=jar \
+ -Dclassifier=$(JARSUFFIX) \
+ -DgeneratePom=true \
+ -DcreateChecksum=true
+
cleaninstall:
$(RM) $(addprefix $(INSTALLDIRINC), $(HEADERS))
$(RM) $(INSTALLDIRLIB)/$(SONAME)
@@ -72,12 +150,13 @@ cleaninstall:
$(RM) $(INSTALLDIRLIB)/$(STATICLIB)
testgetgateway: testgetgateway.o getgateway.o
+ $(CC) $(LDFLAGS) -o $@ $^ $(EXTRA_LD)
natpmpc-static: natpmpc.o $(STATICLIB)
- $(CC) -o $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^ $(EXTRA_LD)
natpmpc-shared: natpmpc.o $(SHAREDLIB)
- $(CC) -o $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^ $(EXTRA_LD)
$(STATICLIB): $(LIBOBJS)
$(AR) crs $@ $?
@@ -86,9 +165,10 @@ $(SHAREDLIB): $(LIBOBJS)
ifeq ($(OS), Darwin)
$(CC) -dynamiclib -Wl,-install_name,$(SONAME) -o $@ $^
else
- $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
+ $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^ $(EXTRA_LD)
endif
+
# DO NOT DELETE
natpmp.o: natpmp.h getgateway.h declspec.h
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/declspec.h b/3rdParty/LibNATPMP/src/libnatpmp/declspec.h
index ea479d1..a76be02 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/declspec.h
+++ b/3rdParty/LibNATPMP/src/libnatpmp/declspec.h
@@ -1,14 +1,20 @@
-#ifndef __DECLSPEC_H__
-#define __DECLSPEC_H__
+#ifndef DECLSPEC_H_INCLUDED
+#define DECLSPEC_H_INCLUDED
#if defined(WIN32) && !defined(STATICLIB)
+ /* for windows dll */
#ifdef NATPMP_EXPORTS
#define LIBSPEC __declspec(dllexport)
#else
#define LIBSPEC __declspec(dllimport)
#endif
#else
- #define LIBSPEC
+ #if defined(__GNUC__) && __GNUC__ >= 4
+ /* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */
+ #define LIBSPEC __attribute__ ((visibility ("default")))
+ #else
+ #define LIBSPEC
+ #endif
#endif
#endif
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c
index bcde3ad..3a3f9a6 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c
+++ b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c
@@ -1,18 +1,32 @@
-/* $Id: getgateway.c,v 1.19 2009/12/19 15:20:45 nanard Exp $ */
+/* $Id: getgateway.c,v 1.24 2014/03/31 12:41:35 nanard Exp $ */
/* libnatpmp
- * Copyright (c) 2007-2009, 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. */
+
+Copyright (c) 2007-2011, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#include <stdio.h>
#include <ctype.h>
#ifndef WIN32
@@ -35,7 +49,7 @@
#undef USE_SYSCTL_NET_ROUTE
#endif
-#ifdef BSD
+#if defined(BSD) || defined(__FreeBSD_kernel__)
#undef USE_PROC_NET_ROUTE
#define USE_SOCKET_ROUTE
#undef USE_SYSCTL_NET_ROUTE
@@ -53,6 +67,13 @@
#undef USE_SYSCTL_NET_ROUTE
#endif
+#if !defined(USE_PROC_NET_ROUTE) && !defined(USE_SOCKET_ROUTE) && !defined(USE_SYSCTL_NET_ROUTE) && !defined(WIN32)
+int getdefaultgateway(in_addr_t * addr)
+{
+ return -1;
+}
+#endif
+
#ifdef WIN32
#undef USE_PROC_NET_ROUTE
#undef USE_SOCKET_ROUTE
@@ -70,7 +91,7 @@
#include <w32api/windef.h>
#include <w32api/winbase.h>
#include <w32api/winreg.h>
-#endif
+#endif
#ifdef __HAIKU__
#include <stdlib.h>
@@ -78,7 +99,7 @@
#include <net/if.h>
#include <sys/sockio.h>
#define USE_HAIKU_CODE
-#endif
+#endif
#ifdef USE_SYSCTL_NET_ROUTE
#include <stdlib.h>
@@ -117,11 +138,11 @@
/*
parse /proc/net/route which is as follow :
-Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
-wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
-eth0 0000FEA9 00000000 0001 0 0 0 0000FFFF 0 0 0
-wlan0 00000000 0101A8C0 0003 0 0 0 00000000 0 0 0
-eth0 00000000 00000000 0001 0 0 1000 00000000 0 0 0
+Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
+wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
+eth0 0000FEA9 00000000 0001 0 0 0 0000FFFF 0 0 0
+wlan0 00000000 0101A8C0 0003 0 0 0 00000000 0 0 0
+eth0 00000000 00000000 0001 0 0 1000 00000000 0 0 0
One header line, and then one line by route by route table entry.
*/
@@ -238,7 +259,7 @@ 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;
+ char *cp = m_rtmsg.m_space;
struct sockaddr *gate = NULL, *sa;
struct rt_msghdr *msg_hdr;
@@ -254,7 +275,7 @@ int getdefaultgateway(in_addr_t *addr)
rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
rtm.rtm_version = RTM_VERSION;
rtm.rtm_seq = ++seq;
- rtm.rtm_addrs = rtm_addrs;
+ rtm.rtm_addrs = rtm_addrs;
so_dst.sa_family = AF_INET;
so_mask.sa_family = AF_INET;
@@ -274,7 +295,7 @@ int getdefaultgateway(in_addr_t *addr)
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;
@@ -321,7 +342,7 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
DWORD gatewayValueLength = MAX_VALUE_LENGTH;
DWORD gatewayValueType = REG_MULTI_SZ;
int done = 0;
-
+
//const char * networkCardsPath = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards";
//const char * interfacesPath = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces";
#ifdef UNICODE
@@ -339,7 +360,7 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
#endif
// 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
@@ -348,10 +369,10 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
// -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}
@@ -365,15 +386,15 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
// -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
+
+ 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
@@ -382,7 +403,7 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
// 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
@@ -393,12 +414,12 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
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++)
{
@@ -422,7 +443,7 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
(LPBYTE)keyValue, // Receives value
&keyValueLength)) // Receives value length in bytes
{
-// printf("keyValue: %s\n", keyValue);
+// printf("keyValue: %s\n", keyValue);
if(RegOpenKeyEx(interfacesKey, keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS)
{
gatewayValueLength = MAX_VALUE_LENGTH;
@@ -461,10 +482,10 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
}
}
}
-
+
RegCloseKey(interfacesKey);
RegCloseKey(networkCardsKey);
-
+
if(done)
{
#if UNICODE
@@ -481,7 +502,7 @@ LIBSPEC int getdefaultgateway(in_addr_t * addr)
#endif
return 0;
}
-
+
return -1;
}
#endif /* #ifdef USE_WIN32_CODE */
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.h b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.h
index 51dadb7..da98d1a 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.h
+++ b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.h
@@ -1,23 +1,36 @@
-/* $Id: getgateway.h,v 1.4 2009/12/19 12:00:00 nanard Exp $ */
+/* $Id: getgateway.h,v 1.7 2013/09/10 20:09:04 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. */
+Copyright (c) 2007-2013, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef __GETGATEWAY_H__
#define __GETGATEWAY_H__
#ifdef WIN32
-#if !defined(_MSC_VER)
+#if !defined(_MSC_VER) || _MSC_VER >= 1600
#include <stdint.h>
#else
typedef unsigned long uint32_t;
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/natpmp.c b/3rdParty/LibNATPMP/src/libnatpmp/natpmp.c
index 53869c3..a09f217 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/natpmp.c
+++ b/3rdParty/LibNATPMP/src/libnatpmp/natpmp.c
@@ -1,19 +1,31 @@
-/* $Id: natpmp.c,v 1.13 2011/01/03 17:31:03 nanard Exp $ */
+/* $Id: natpmp.c,v 1.18 2013/11/26 08:47:36 nanard Exp $ */
/* libnatpmp
- * Copyright (c) 2007-2011, 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. */
+Copyright (c) 2007-2013, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#ifdef __linux__
#define _BSD_SOURCE 1
#endif
@@ -30,6 +42,7 @@
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ECONNREFUSED WSAECONNREFUSED
#include "wingettimeofday.h"
+#define gettimeofday natpmp_gettimeofday
#else
#include <errno.h>
#include <unistd.h>
@@ -40,13 +53,14 @@
#endif
#include "natpmp.h"
#include "getgateway.h"
+#include <stdio.h>
LIBSPEC int initnatpmp(natpmp_t * p, int forcegw, in_addr_t forcedgw)
{
#ifdef WIN32
u_long ioctlArg = 1;
#else
- int flags;
+ int flags;
#endif
struct sockaddr_in addr;
if(!p)
@@ -71,7 +85,7 @@ LIBSPEC int initnatpmp(natpmp_t * p, int forcegw, in_addr_t forcedgw)
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);
@@ -164,9 +178,20 @@ LIBSPEC int sendnewportmappingrequest(natpmp_t * p, int protocol,
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);
+ /* break strict-aliasing rules :
+ *((uint16_t *)(p->pending_request + 4)) = htons(privateport); */
+ p->pending_request[4] = (privateport >> 8) & 0xff;
+ p->pending_request[5] = privateport & 0xff;
+ /* break stric-aliasing rules :
+ *((uint16_t *)(p->pending_request + 6)) = htons(publicport); */
+ p->pending_request[6] = (publicport >> 8) & 0xff;
+ p->pending_request[7] = publicport & 0xff;
+ /* break stric-aliasing rules :
+ *((uint32_t *)(p->pending_request + 8)) = htonl(lifetime); */
+ p->pending_request[8] = (lifetime >> 24) & 0xff;
+ p->pending_request[9] = (lifetime >> 16) & 0xff;
+ p->pending_request[10] = (lifetime >> 8) & 0xff;
+ p->pending_request[11] = lifetime & 0xff;
p->pending_request_len = 12;
return sendnatpmprequest(p);
}
@@ -182,7 +207,11 @@ LIBSPEC int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response)
n = recvfrom(p->s, buf, sizeof(buf), 0,
(struct sockaddr *)&addr, &addrlen);
if(n<0)
+#ifdef WIN32
+ switch(WSAGetLastError()) {
+#else
switch(errno) {
+#endif
/*case EAGAIN:*/
case EWOULDBLOCK:
n = NATPMP_TRYAGAIN;
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/natpmp.h b/3rdParty/LibNATPMP/src/libnatpmp/natpmp.h
index c870371..6791c76 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/natpmp.h
+++ b/3rdParty/LibNATPMP/src/libnatpmp/natpmp.h
@@ -1,19 +1,31 @@
-/* $Id: natpmp.h,v 1.14 2011/01/03 17:31:03 nanard Exp $ */
+/* $Id: natpmp.h,v 1.19 2014/04/01 09:39:29 nanard Exp $ */
/* libnatpmp
- * Copyright (c) 2007-2011, 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. */
+Copyright (c) 2007-2013, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef __NATPMP_H__
#define __NATPMP_H__
@@ -23,21 +35,23 @@
#include <time.h>
#if !defined(_MSC_VER)
#include <sys/time.h>
-#endif
+#endif /* !defined(_MSC_VER) */
+
#ifdef WIN32
#include <winsock2.h>
#if !defined(_MSC_VER) || _MSC_VER >= 1600
#include <stdint.h>
-#else
+#else /* !defined(_MSC_VER) || _MSC_VER >= 1600 */
typedef unsigned long uint32_t;
typedef unsigned short uint16_t;
-#endif
+#endif /* !defined(_MSC_VER) || _MSC_VER >= 1600 */
#define in_addr_t uint32_t
#include "declspec.h"
-#else
-#define LIBSPEC
+#else /* WIN32 */
#include <netinet/in.h>
-#endif
+#endif /* WIN32 */
+
+#include "declspec.h"
#ifdef ANDROID
#include <arpa/inet.h>
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/natpmpc.c b/3rdParty/LibNATPMP/src/libnatpmp/natpmpc.c
index d869572..611bd2d 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/natpmpc.c
+++ b/3rdParty/LibNATPMP/src/libnatpmp/natpmpc.c
@@ -1,19 +1,31 @@
-/* $Id: natpmpc.c,v 1.9 2011/04/18 18:25:21 nanard Exp $ */
+/* $Id: natpmpc.c,v 1.13 2012/08/21 17:23:38 nanard Exp $ */
/* libnatpmp
- * Copyright (c) 2007-2011, 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. */
+Copyright (c) 2007-2011, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
@@ -67,6 +79,7 @@ int main(int argc, char * * argv)
int command = 0;
int forcegw = 0;
in_addr_t gateway = 0;
+ struct in_addr gateway_in_use;
#ifdef WIN32
WSADATA wsaData;
@@ -95,7 +108,7 @@ int main(int argc, char * * argv)
break;
case 'a':
command = 'a';
- if(argc < i + 3) {
+ if(argc < i + 4) {
fprintf(stderr, "Not enough arguments for option -%c\n", argv[i][1]);
return 1;
}
@@ -118,10 +131,11 @@ int main(int argc, char * * argv)
fprintf(stderr, "%s is not a valid protocol\n", argv[i]);
return 1;
}
- if(argc >= i) {
- i++;
- if(1 != sscanf(argv[i], "%u", &lifetime)) {
+ if(argc > i + 1) {
+ if(1 != sscanf(argv[i+1], "%u", &lifetime)) {
fprintf(stderr, "%s is not a correct 32bits unsigned integer\n", argv[i]);
+ } else {
+ i++;
}
}
break;
@@ -143,7 +157,8 @@ int main(int argc, char * * argv)
if(r<0)
return 1;
- printf("using gateway : %s\n", inet_ntoa(*((struct in_addr *)&natpmp.gateway)));
+ gateway_in_use.s_addr = natpmp.gateway;
+ printf("using gateway : %s\n", inet_ntoa(gateway_in_use));
/* sendpublicaddressrequest() */
r = sendpublicaddressrequest(&natpmp);
@@ -170,7 +185,7 @@ int main(int argc, char * * argv)
fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n",
strnatpmperr(r));
#endif
- fprintf(stderr, " errno=%d '%s'\n",
+ fprintf(stderr, " errno=%d '%s'\n",
sav_errno, strerror(sav_errno));
}
} while(r==NATPMP_TRYAGAIN);
@@ -207,7 +222,7 @@ int main(int argc, char * * argv)
#endif
return 1;
}
-
+
printf("Mapped public port %hu protocol %s to local port %hu "
"liftime %u\n",
response.pnu.newportmapping.mappedpublicport,
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.c b/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.c
index 5b1b8a6..cb730e1 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.c
+++ b/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.c
@@ -1,19 +1,31 @@
-/* $Id: wingettimeofday.c,v 1.3 2009/12/19 12:00:00 nanard Exp $ */
+/* $Id: wingettimeofday.c,v 1.6 2013/09/10 20:13:26 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. */
+Copyright (c) 2007-2013, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#ifdef WIN32
#if defined(_MSC_VER)
struct timeval {
@@ -30,10 +42,8 @@ typedef struct _FILETIME {
} FILETIME;
void __stdcall GetSystemTimeAsFileTime(FILETIME*);
-
-//int gettimeofday(struct timeval* p, void* tz /* IGNORED */);
-int gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
+int natpmp_gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
union {
long long ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME ft;
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.h b/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.h
index ed6c599..1d18d9f 100644
--- a/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.h
+++ b/3rdParty/LibNATPMP/src/libnatpmp/wingettimeofday.h
@@ -1,19 +1,31 @@
-/* $Id: wingettimeofday.h,v 1.1 2009/12/19 12:02:42 nanard Exp $ */
+/* $Id: wingettimeofday.h,v 1.5 2013/09/11 07:22:25 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. */
+Copyright (c) 2007-2013, Thomas BERNARD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef __WINGETTIMEOFDAY_H__
#define __WINGETTIMEOFDAY_H__
#ifdef WIN32
@@ -22,6 +34,6 @@
#else
#include <sys/time.h>
#endif
-int gettimeofday(struct timeval* p, void* tz /* IGNORED */);
+int natpmp_gettimeofday(struct timeval* p, void* tz /* IGNORED */);
#endif
#endif