Browse Source

Upgrade miniupnpc to 2.0

Adam Ierymenko 9 years ago
parent
commit
4342b71d7a

+ 0 - 178
ext/miniupnpc/CMakeLists.txt

@@ -1,178 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-
-project (miniupnpc C)
-set (MINIUPNPC_VERSION 1.9)
-set (MINIUPNPC_API_VERSION 15)
-
-if (NOT CMAKE_BUILD_TYPE)
-  if (WIN32)
-    set (DEFAULT_BUILD_TYPE MinSizeRel)
-  else (WIN32)
-    set (DEFAULT_BUILD_TYPE RelWithDebInfo)
-  endif(WIN32)
-    set (CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING
-        "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
-        FORCE)
-endif()
-
-option (UPNPC_BUILD_STATIC "Build static library" TRUE)
-option (UPNPC_BUILD_SHARED "Build shared library" TRUE)
-if (NOT WIN32)
-  option (UPNPC_BUILD_TESTS "Build test executables" TRUE)
-endif (NOT WIN32)
-option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
-
-mark_as_advanced (NO_GETADDRINFO)
-
-if (NO_GETADDRINFO)
-  add_definitions (-DNO_GETADDRINFO)
-endif (NO_GETADDRINFO)
-
-if (NOT WIN32)
-  add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
-  add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112L)
-else (NOT WIN32)
-  add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
-endif (NOT WIN32)
-
-if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-  add_definitions (-D_DARWIN_C_SOURCE)
-endif ()
-
-# Set compiler specific build flags
-if (CMAKE_COMPILER_IS_GNUC)
-  # Set our own default flags at first run.
-  if (NOT CONFIGURED)
-
-    if (NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
-      set (_PIC -fPIC)
-    endif (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
-
-    set (CMAKE_C_FLAGS "${_PIC} -Wall $ENV{CFLAGS}" # CMAKE_C_FLAGS gets appended to the other C flags
-        CACHE STRING "Flags used by the C compiler during normal builds." FORCE)
-    set (CMAKE_C_FLAGS_DEBUG "-g -DDDEBUG"
-        CACHE STRING "Flags used by the C compiler during debug builds." FORCE)
-    set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG"
-        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
-    set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG"
-        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
-    set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG"
-        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
-
-  endif (NOT CONFIGURED)
-endif ()
-
-configure_file (${CMAKE_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_BINARY_DIR}/miniupnpcstrings.h)
-include_directories (${CMAKE_BINARY_DIR})
-
-set (MINIUPNPC_SOURCES
-  igd_desc_parse.c
-  miniupnpc.c
-  minixml.c
-  minisoap.c
-  minissdpc.c
-  miniwget.c
-  upnpc.c
-  upnpcommands.c
-  upnpdev.c
-  upnpreplyparse.c
-  upnperrors.c
-  connecthostport.c
-  portlistingparse.c
-  receivedata.c
-)
-
-if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
-  set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
-endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
-
-if (WIN32)
-  set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
-                                                    COMPILE_DEFINITIONS "MINIUPNP_STATICLIB;MINIUPNP_EXPORTS"
-  )
-endif (WIN32)
-
-if (WIN32)
-  find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
-  find_library (IPHLPAPI_LIBRARY NAMES iphlpapi)
-  set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
-#elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
-#  find_library (SOCKET_LIBRARY NAMES socket)
-#  find_library (NSL_LIBRARY NAMES nsl)
-#  find_library (RESOLV_LIBRARY NAMES resolv)
-#  set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS})
-endif (WIN32)
-
-if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
-    message (FATAL "Both shared and static libraries are disabled!")
-endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
-
-if (UPNPC_BUILD_STATIC)
-  add_library (upnpc-static STATIC ${MINIUPNPC_SOURCES})
-  set_target_properties (upnpc-static PROPERTIES OUTPUT_NAME "miniupnpc")
-  target_link_libraries (upnpc-static ${LDLIBS})
-  set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-static)
-  set (UPNPC_LIBRARY_TARGET upnpc-static)
-endif (UPNPC_BUILD_STATIC)
-
-if (UPNPC_BUILD_SHARED)
-  add_library (upnpc-shared SHARED ${MINIUPNPC_SOURCES})
-  set_target_properties (upnpc-shared PROPERTIES OUTPUT_NAME "miniupnpc")
-  set_target_properties (upnpc-shared PROPERTIES VERSION ${MINIUPNPC_VERSION})
-  set_target_properties (upnpc-shared PROPERTIES SOVERSION ${MINIUPNPC_API_VERSION})
-  target_link_libraries (upnpc-shared ${LDLIBS})
-  set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-shared)
-  set (UPNPC_LIBRARY_TARGET upnpc-shared)
-endif (UPNPC_BUILD_SHARED)
-
-if (UPNPC_BUILD_TESTS)
-  add_executable (testminixml testminixml.c minixml.c igd_desc_parse.c)
-  target_link_libraries (testminixml ${LDLIBS})
-
-  add_executable (minixmlvalid minixmlvalid.c minixml.c)
-  target_link_libraries (minixmlvalid ${LDLIBS})
-
-  add_executable (testupnpreplyparse testupnpreplyparse.c
-                                     minixml.c upnpreplyparse.c)
-  target_link_libraries (testupnpreplyparse ${LDLIBS})
-
-  add_executable (testigddescparse testigddescparse.c
-                                   igd_desc_parse.c minixml.c miniupnpc.c miniwget.c minissdpc.c
-                                   upnpcommands.c upnpreplyparse.c minisoap.c connecthostport.c
-                                   portlistingparse.c receivedata.c
-  )
-  target_link_libraries (testigddescparse ${LDLIBS})
-
-  add_executable (testminiwget testminiwget.c
-                               miniwget.c miniupnpc.c minisoap.c upnpcommands.c minissdpc.c
-                               upnpreplyparse.c minixml.c igd_desc_parse.c connecthostport.c
-                               portlistingparse.c receivedata.c
-  )
-  target_link_libraries (testminiwget ${LDLIBS})
-
-# set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
-endif (UPNPC_BUILD_TESTS)
-
-
-install (TARGETS ${UPNPC_INSTALL_TARGETS}
-  RUNTIME DESTINATION bin
-  LIBRARY DESTINATION lib${LIB_SUFFIX}
-  ARCHIVE DESTINATION lib${LIB_SUFFIX}
-)
-install (FILES
-	miniupnpc.h
-  miniwget.h
-  upnpcommands.h
-  igd_desc_parse.h
-  upnpreplyparse.h
-  upnperrors.h
-  upnpdev.h
-  miniupnpctypes.h
-  portlistingparse.h
-  miniupnpc_declspec.h
-  DESTINATION include/miniupnpc
-)
-
-set (CONFIGURED YES CACHE INTERNAL "")
-
-# vim: ts=2:sw=2

+ 11 - 1
ext/miniupnpc/Changelog.txt

@@ -1,6 +1,16 @@
-$Id: Changelog.txt,v 1.219 2015/10/26 17:05:06 nanard Exp $
+$Id: Changelog.txt,v 1.223 2016/04/19 21:06:20 nanard Exp $
 miniUPnP client Changelog.
 
+VERSION 2.0 : released 2016/04/19
+
+2016/01/24:
+  change miniwget to return HTTP status code
+  increments API_VERSION to 16
+
+2016/01/22:
+  Improve UPNPIGD_IsConnected() to check if WAN address is not private.
+  parse HTTP response status line in miniwget.c
+
 2015/10/26:
   snprintf() overflow check. check overflow in simpleUPnPcommand2()
 

+ 0 - 379
ext/miniupnpc/Makefile

@@ -1,379 +0,0 @@
-# $Id: Makefile,v 1.132 2015/10/26 16:59:54 nanard Exp $
-# MiniUPnP Project
-# http://miniupnp.free.fr/
-# http://miniupnp.tuxfamily.org/
-# https://github.com/miniupnp/miniupnp
-# (c) 2005-2015 Thomas Bernard
-# to install use :
-# $ make DESTDIR=/tmp/dummylocation install
-# or
-# $ INSTALLPREFIX=/usr/local make install
-# or
-# $ make install (default INSTALLPREFIX is /usr)
-OS = $(shell uname -s)
-VERSION = $(shell cat VERSION)
-
-ifeq ($(OS), Darwin)
-JARSUFFIX=mac
-LIBTOOL ?= $(shell which libtool)
-endif
-ifeq ($(OS), Linux)
-JARSUFFIX=linux
-endif
-ifneq (,$(findstring NT-5.1,$(OS)))
-JARSUFFIX=win32
-endif
-
-HAVE_IPV6 ?= yes
-export HAVE_IPV6
-
-CC ?= gcc
-#AR = gar
-#CFLAGS = -O -g -DDEBUG
-CFLAGS ?= -O
-CFLAGS += -Wall
-CFLAGS += -W -Wstrict-prototypes
-CFLAGS += -fno-common
-CFLAGS += -DMINIUPNPC_SET_SOCKET_TIMEOUT
-CFLAGS += -DMINIUPNPC_GET_SRC_ADDR
-CFLAGS += -D_BSD_SOURCE
-CFLAGS += -D_DEFAULT_SOURCE
-ifneq ($(OS), FreeBSD)
-ifneq ($(OS), Darwin)
-#CFLAGS += -D_POSIX_C_SOURCE=200112L
-CFLAGS += -D_XOPEN_SOURCE=600
-endif
-endif
-#CFLAGS += -ansi
-# -DNO_GETADDRINFO
-INSTALL = install
-SH = /bin/sh
-JAVA = java
-# see http://code.google.com/p/jnaerator/
-#JNAERATOR = jnaerator-0.9.7.jar
-#JNAERATOR = jnaerator-0.9.8-shaded.jar
-#JNAERATORARGS = -library miniupnpc
-#JNAERATOR = jnaerator-0.10-shaded.jar
-#JNAERATOR = jnaerator-0.11-shaded.jar
-# https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12/jnaerator-0.12-shaded.jar
-JNAERATOR = jnaerator-0.12-shaded.jar
-JNAERATORARGS = -mode StandaloneJar -runtime JNAerator -library miniupnpc
-#JNAERATORBASEURL = http://jnaerator.googlecode.com/files/
-JNAERATORBASEURL = https://repo1.maven.org/maven2/com/nativelibs4java/jnaerator/0.12
-
-ifeq (SunOS, $(OS))
-  LDFLAGS=-lsocket -lnsl -lresolv
-endif
-
-# APIVERSION is used to build SONAME
-APIVERSION = 15
-
-SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \
-       upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \
-       minixmlvalid.c testupnpreplyparse.c minissdpc.c \
-       upnperrors.c testigddescparse.c testminiwget.c \
-       connecthostport.c portlistingparse.c receivedata.c \
-       upnpdev.c testportlistingparse.c miniupnpcmodule.c \
-       minihttptestserver.c \
-       listdevices.c
-
-LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
-          miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
-          connecthostport.o portlistingparse.o receivedata.o upnpdev.o
-
-ifneq ($(OS), AmigaOS)
-CFLAGS := -fPIC $(CFLAGS)
-LIBOBJS := $(LIBOBJS) minissdpc.o
-endif
-
-OBJS = $(patsubst %.c,%.o,$(SRCS))
-
-# HEADERS to install
-HEADERS = miniupnpc.h miniwget.h upnpcommands.h igd_desc_parse.h \
-          upnpreplyparse.h upnperrors.h miniupnpctypes.h \
-          portlistingparse.h \
-          upnpdev.h \
-          miniupnpc_declspec.h
-
-# library names
-LIBRARY = libminiupnpc.a
-ifeq ($(OS), Darwin)
-  SHAREDLIBRARY = libminiupnpc.dylib
-  SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib
-  CFLAGS := -D_DARWIN_C_SOURCE $(CFLAGS)
-else
-ifeq ($(JARSUFFIX), win32)
-  SHAREDLIBRARY = miniupnpc.dll
-else
-  # Linux/BSD/etc.
-  SHAREDLIBRARY = libminiupnpc.so
-  SONAME = $(SHAREDLIBRARY).$(APIVERSION)
-endif
-endif
-
-EXECUTABLES = upnpc-static listdevices
-EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \
-			  testigddescparse testminiwget testportlistingparse
-
-TESTMINIXMLOBJS = minixml.o igd_desc_parse.o testminixml.o
-
-TESTMINIWGETOBJS = miniwget.o testminiwget.o connecthostport.o receivedata.o
-
-TESTUPNPREPLYPARSE = testupnpreplyparse.o minixml.o upnpreplyparse.o
-
-TESTPORTLISTINGPARSE = testportlistingparse.o minixml.o portlistingparse.o
-
-TESTIGDDESCPARSE = testigddescparse.o igd_desc_parse.o minixml.o \
-                   miniupnpc.o miniwget.o upnpcommands.o upnpreplyparse.o \
-                   minisoap.o connecthostport.o receivedata.o \
-                   portlistingparse.o
-
-ifneq ($(OS), AmigaOS)
-EXECUTABLES := $(EXECUTABLES) upnpc-shared
-TESTMINIWGETOBJS := $(TESTMINIWGETOBJS) minissdpc.o
-TESTIGDDESCPARSE := $(TESTIGDDESCPARSE) minissdpc.o
-endif
-
-LIBDIR ?= lib
-# install directories
-INSTALLPREFIX ?= $(PREFIX)/usr
-INSTALLDIRINC = $(INSTALLPREFIX)/include/miniupnpc
-INSTALLDIRLIB = $(INSTALLPREFIX)/$(LIBDIR)
-INSTALLDIRBIN = $(INSTALLPREFIX)/bin
-INSTALLDIRMAN = $(INSTALLPREFIX)/share/man
-
-FILESTOINSTALL = $(LIBRARY) $(EXECUTABLES)
-ifneq ($(OS), AmigaOS)
-FILESTOINSTALL := $(FILESTOINSTALL) $(SHAREDLIBRARY)
-endif
-
-
-.PHONY:	install clean depend all check test everything \
-	installpythonmodule updateversion
-#	validateminixml validateminiwget
-
-all:	$(LIBRARY) $(EXECUTABLES)
-
-test:	check
-
-check:	validateminixml validateminiwget validateupnpreplyparse \
-	validateportlistingparse validateigddescparse
-
-everything:	all $(EXECUTABLES_ADDTESTS)
-
-pythonmodule:	$(LIBRARY) miniupnpcmodule.c setup.py
-	python setup.py build
-	touch $@
-
-installpythonmodule:	pythonmodule
-	python setup.py install
-
-pythonmodule3:	$(LIBRARY) miniupnpcmodule.c setup.py
-	python3 setup.py build
-	touch $@
-
-installpythonmodule3:	pythonmodule3
-	python3 setup.py install
-
-validateminixml:	minixmlvalid
-	@echo "minixml validation test"
-	./minixmlvalid
-	touch $@
-
-validateminiwget:	testminiwget minihttptestserver testminiwget.sh
-	@echo "miniwget validation test"
-	./testminiwget.sh
-	touch $@
-
-validateupnpreplyparse:	testupnpreplyparse testupnpreplyparse.sh
-	@echo "upnpreplyparse validation test"
-	./testupnpreplyparse.sh
-	touch $@
-
-validateportlistingparse:	testportlistingparse
-	@echo "portlistingparse validation test"
-	./testportlistingparse
-	touch $@
-
-validateigddescparse:	testigddescparse
-	@echo "igd desc parse validation test"
-	./testigddescparse testdesc/new_LiveBox_desc.xml testdesc/new_LiveBox_desc.values
-	./testigddescparse testdesc/linksys_WAG200G_desc.xml testdesc/linksys_WAG200G_desc.values
-	touch $@
-
-clean:
-	$(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h
-	$(RM) $(EXECUTABLES_ADDTESTS)
-	# clean python stuff
-	$(RM) pythonmodule pythonmodule3
-	$(RM) validateminixml validateminiwget validateupnpreplyparse
-	$(RM) validateigddescparse
-	$(RM) minihttptestserver
-	$(RM) -r build/ dist/
-	#python setup.py clean
-	# clean jnaerator stuff
-	$(RM) _jnaerator.* java/miniupnpc_$(OS).jar
-
-distclean: clean
-	$(RM) $(JNAERATOR) java/*.jar java/*.class out.errors.txt
-
-updateversion:	miniupnpc.h
-	cp miniupnpc.h miniupnpc.h.bak
-	sed 's/\(.*MINIUPNPC_API_VERSION\s\+\)[0-9]\+/\1$(APIVERSION)/' < miniupnpc.h.bak > miniupnpc.h
-
-install:	updateversion $(FILESTOINSTALL)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRINC)
-	$(INSTALL) -m 644 $(HEADERS) $(DESTDIR)$(INSTALLDIRINC)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRLIB)
-	$(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(INSTALLDIRLIB)
-ifneq ($(OS), AmigaOS)
-	$(INSTALL) -m 644 $(SHAREDLIBRARY) $(DESTDIR)$(INSTALLDIRLIB)/$(SONAME)
-	ln -fs $(SONAME) $(DESTDIR)$(INSTALLDIRLIB)/$(SHAREDLIBRARY)
-endif
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRBIN)
-ifeq ($(OS), AmigaOS)
-	$(INSTALL) -m 755 upnpc-static $(DESTDIR)$(INSTALLDIRBIN)/upnpc
-else
-	$(INSTALL) -m 755 upnpc-shared $(DESTDIR)$(INSTALLDIRBIN)/upnpc
-endif
-	$(INSTALL) -m 755 external-ip.sh $(DESTDIR)$(INSTALLDIRBIN)/external-ip
-ifneq ($(OS), AmigaOS)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRMAN)/man3
-	$(INSTALL) -m 644 man3/miniupnpc.3 $(DESTDIR)$(INSTALLDIRMAN)/man3/miniupnpc.3
-ifeq ($(OS), Linux)
-	gzip -f $(DESTDIR)$(INSTALLDIRMAN)/man3/miniupnpc.3
-endif
-endif
-
-install-static:	updateversion $(FILESTOINSTALL)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRINC)
-	$(INSTALL) -m 644 $(HEADERS) $(DESTDIR)$(INSTALLDIRINC)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRLIB)
-	$(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(INSTALLDIRLIB)
-	$(INSTALL) -d $(DESTDIR)$(INSTALLDIRBIN)
-	$(INSTALL) -m 755 external-ip.sh $(DESTDIR)$(INSTALLDIRBIN)/external-ip
-
-cleaninstall:
-	$(RM) -r $(DESTDIR)$(INSTALLDIRINC)
-	$(RM) $(DESTDIR)$(INSTALLDIRLIB)/$(LIBRARY)
-	$(RM) $(DESTDIR)$(INSTALLDIRLIB)/$(SHAREDLIBRARY)
-
-depend:
-	makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
-
-$(LIBRARY):	$(LIBOBJS)
-ifeq ($(OS), Darwin)
-	$(LIBTOOL) -static -o $@ $?
-else
-	$(AR) crs $@ $?
-endif
-
-$(SHAREDLIBRARY):	$(LIBOBJS)
-ifeq ($(OS), Darwin)
-#	$(CC) -dynamiclib $(LDFLAGS) -Wl,-install_name,$(SONAME) -o $@ $^
-	$(CC) -dynamiclib $(LDFLAGS) -Wl,-install_name,$(INSTALLDIRLIB)/$(SONAME) -o $@ $^
-else
-	$(CC) -shared $(LDFLAGS) -Wl,-soname,$(SONAME) -o $@ $^
-endif
-
-upnpc-static:	upnpc.o $(LIBRARY)
-	$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
-
-upnpc-shared:	upnpc.o $(SHAREDLIBRARY)
-	$(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS)
-
-listdevices:	listdevices.o $(LIBRARY)
-
-testminixml:	$(TESTMINIXMLOBJS)
-
-testminiwget:	$(TESTMINIWGETOBJS)
-
-minixmlvalid:	minixml.o minixmlvalid.o
-
-testupnpreplyparse:	$(TESTUPNPREPLYPARSE)
-
-testigddescparse:	$(TESTIGDDESCPARSE)
-
-testportlistingparse:	$(TESTPORTLISTINGPARSE)
-
-miniupnpcstrings.h:	miniupnpcstrings.h.in updateminiupnpcstrings.sh VERSION
-	$(SH) updateminiupnpcstrings.sh
-
-# ftp tool supplied with OpenBSD can download files from http.
-jnaerator-%.jar:
-	wget $(JNAERATORBASEURL)/$@ || \
-	curl -o $@ $(JNAERATORBASEURL)/$@ || \
-	ftp $(JNAERATORBASEURL)/$@
-
-jar: $(SHAREDLIBRARY)  $(JNAERATOR)
-	$(JAVA) -jar $(JNAERATOR) $(JNAERATORARGS) \
-	miniupnpc.h miniupnpc_declspec.h upnpcommands.h upnpreplyparse.h \
-	igd_desc_parse.h miniwget.h upnperrors.h $(SHAREDLIBRARY) \
-	-package fr.free.miniupnp -o . -jar java/miniupnpc_$(JARSUFFIX).jar -v
-
-mvn_install:
-	mvn install:install-file -Dfile=java/miniupnpc_$(JARSUFFIX).jar \
-	 -DgroupId=com.github \
-	 -DartifactId=miniupnp \
-	 -Dversion=$(VERSION) \
-	 -Dpackaging=jar \
-	 -Dclassifier=$(JARSUFFIX) \
-	 -DgeneratePom=true \
-	 -DcreateChecksum=true
-
-# make .deb packages
-deb: /usr/share/pyshared/stdeb all
-	(python setup.py --command-packages=stdeb.command bdist_deb)
-
-# install .deb packages
-ideb:
-	(sudo dpkg -i deb_dist/*.deb)
-
-/usr/share/pyshared/stdeb: /usr/share/doc/python-all-dev
-	(sudo apt-get install python-stdeb)
-
-/usr/share/doc/python-all-dev:
-	(sudo apt-get install python-all-dev)
-
-minihttptestserver:	minihttptestserver.o
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-igd_desc_parse.o: igd_desc_parse.h
-miniupnpc.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h upnpdev.h
-miniupnpc.o: minissdpc.h miniwget.h minisoap.h minixml.h upnpcommands.h
-miniupnpc.o: upnpreplyparse.h portlistingparse.h miniupnpctypes.h
-miniupnpc.o: connecthostport.h
-minixml.o: minixml.h
-minisoap.o: minisoap.h miniupnpcstrings.h
-miniwget.o: miniupnpcstrings.h miniwget.h miniupnpc_declspec.h
-miniwget.o: connecthostport.h receivedata.h
-upnpc.o: miniwget.h miniupnpc_declspec.h miniupnpc.h igd_desc_parse.h
-upnpc.o: upnpdev.h upnpcommands.h upnpreplyparse.h portlistingparse.h
-upnpc.o: miniupnpctypes.h upnperrors.h miniupnpcstrings.h
-upnpcommands.o: upnpcommands.h upnpreplyparse.h portlistingparse.h
-upnpcommands.o: miniupnpc_declspec.h miniupnpctypes.h miniupnpc.h
-upnpcommands.o: igd_desc_parse.h upnpdev.h
-upnpreplyparse.o: upnpreplyparse.h minixml.h
-testminixml.o: minixml.h igd_desc_parse.h
-minixmlvalid.o: minixml.h
-testupnpreplyparse.o: upnpreplyparse.h
-minissdpc.o: minissdpc.h miniupnpc_declspec.h upnpdev.h miniupnpc.h
-minissdpc.o: igd_desc_parse.h receivedata.h codelength.h
-upnperrors.o: upnperrors.h miniupnpc_declspec.h upnpcommands.h
-upnperrors.o: upnpreplyparse.h portlistingparse.h miniupnpctypes.h
-upnperrors.o: miniupnpc.h igd_desc_parse.h upnpdev.h
-testigddescparse.o: igd_desc_parse.h minixml.h miniupnpc.h
-testigddescparse.o: miniupnpc_declspec.h upnpdev.h
-testminiwget.o: miniwget.h miniupnpc_declspec.h
-connecthostport.o: connecthostport.h
-portlistingparse.o: portlistingparse.h miniupnpc_declspec.h miniupnpctypes.h
-portlistingparse.o: minixml.h
-receivedata.o: receivedata.h
-upnpdev.o: upnpdev.h miniupnpc_declspec.h
-testportlistingparse.o: portlistingparse.h miniupnpc_declspec.h
-testportlistingparse.o: miniupnpctypes.h
-miniupnpcmodule.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h
-miniupnpcmodule.o: upnpdev.h upnpcommands.h upnpreplyparse.h
-miniupnpcmodule.o: portlistingparse.h miniupnpctypes.h upnperrors.h
-listdevices.o: miniupnpc.h miniupnpc_declspec.h igd_desc_parse.h upnpdev.h

+ 0 - 98
ext/miniupnpc/Makefile.mingw

@@ -1,98 +0,0 @@
-# $Id: Makefile.mingw,v 1.22 2015/10/26 16:59:54 nanard Exp $
-# Miniupnp project.
-# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
-# (c) 2005-2015 Thomas Bernard
-# This Makefile is made for MinGW
-#
-CC ?= gcc
-#CFLAGS = -Wall -g -DDEBUG -D_WIN32_WINNT=0X501
-CFLAGS = -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501
-LDLIBS = -lws2_32 -liphlpapi
-# -lwsock32
-# -liphlpapi is needed for GetBestRoute() and GetIpAddrTable()
-PYTHON=\utils\python25\python
-OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \
-     minissdpc.o \
-     miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o \
-     connecthostport.o portlistingparse.o receivedata.o \
-     upnpdev.o
-OBJSDLL=$(addprefix dll/, $(OBJS))
-
-all:	init upnpc-static upnpc-shared testminixml libminiupnpc.a miniupnpc.dll
-
-init:
-	mkdir dll
-	echo init > init
-
-clean:
-	del upnpc testminixml *.o
-	del dll\*.o
-	del *.exe
-	del miniupnpc.dll
-	del libminiupnpc.a
-
-libminiupnpc.a:	$(OBJS)
-	$(AR) cr $@ $?
-
-pythonmodule:	libminiupnpc.a
-	$(PYTHON) setupmingw32.py build --compiler=mingw32
-	$(PYTHON) setupmingw32.py install --skip-build
-
-miniupnpc.dll:	libminiupnpc.a $(OBJSDLL)
-	dllwrap -k --driver-name gcc \
-	--def miniupnpc.def \
-	--output-def miniupnpc.dll.def \
-	--implib miniupnpc.lib -o $@ \
-	$(OBJSDLL) $(LDLIBS)
-
-miniupnpc.lib:	miniupnpc.dll
-#	echo $@ generated with $<
-
-dll/upnpc.o:	upnpc.o
-#	echo $@ generated with $<
-
-.c.o:
-	$(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $<
-	$(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o dll/$@ $<
-
-upnpc.o:	upnpc.c
-	$(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $<
-	$(CC) $(CFLAGS) -c -o dll/$@ $<
-
-# --enable-stdcall-fixup
-upnpc-static:	upnpc.o libminiupnpc.a
-	$(CC) -o $@ $^ $(LDLIBS)
-
-upnpc-shared:	dll/upnpc.o miniupnpc.lib
-	$(CC) -o $@ $^ $(LDLIBS)
-
-wingenminiupnpcstrings:	wingenminiupnpcstrings.o
-
-wingenminiupnpcstrings.o:	wingenminiupnpcstrings.c
-
-miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings
-	wingenminiupnpcstrings $< $@
-
-minixml.o:	minixml.c minixml.h
-
-upnpc.o:	miniwget.h minisoap.h miniupnpc.h igd_desc_parse.h
-upnpc.o:	upnpreplyparse.h upnpcommands.h upnperrors.h miniupnpcstrings.h
-
-miniwget.o:	miniwget.c miniwget.h miniupnpcstrings.h connecthostport.h
-
-minisoap.o:	minisoap.c minisoap.h miniupnpcstrings.h
-
-miniupnpc.o:	miniupnpc.c miniupnpc.h minisoap.h miniwget.h minixml.h
-
-igd_desc_parse.o:	igd_desc_parse.c igd_desc_parse.h
-
-testminixml:	minixml.o igd_desc_parse.o testminixml.c
-
-upnpreplyparse.o:	upnpreplyparse.c upnpreplyparse.h minixml.h
-
-upnpcommands.o:	upnpcommands.c upnpcommands.h upnpreplyparse.h miniupnpc.h portlistingparse.h
-
-minissdpc.o:	minissdpc.c minissdpc.h receivedata.h
-
-upnpdev.o:	upnpdev.c upnpdev.h
-

+ 4 - 1
ext/miniupnpc/README

@@ -3,7 +3,7 @@ Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
 github: https://github.com/miniupnp/miniupnp
 freecode: http://freecode.com/projects/miniupnp
 Author: Thomas Bernard
-Copyright (c) 2005-2014 Thomas Bernard
+Copyright (c) 2005-2016 Thomas Bernard
 This software is subject to the conditions detailed in the
 LICENSE file provided within this distribution.
 
@@ -32,6 +32,7 @@ To use the libminiupnpc in your application, link it with
 libminiupnpc.a (or .so) and use the following functions found in miniupnpc.h,
 upnpcommands.h and miniwget.h :
 - upnpDiscover()
+- UPNP_GetValidIGD()
 - miniwget()
 - parserootdesc()
 - GetUPNPUrls()
@@ -59,3 +60,5 @@ send me an email !
 For any question, you can use the web forum :
 http://miniupnp.tuxfamily.org/forum/
 
+Bugs should be reported on github :
+https://github.com/miniupnp/miniupnp/issues

+ 1 - 1
ext/miniupnpc/VERSION

@@ -1 +1 @@
-1.9
+2.0

+ 6 - 1
ext/miniupnpc/apiversions.txt

@@ -1,7 +1,12 @@
-$Id: apiversions.txt,v 1.8 2015/10/08 16:15:47 nanard Exp $
+$Id: apiversions.txt,v 1.9 2016/01/24 17:24:36 nanard Exp $
 
 Differences in API between miniUPnPc versions
 
+API version 16
+  added "status_code" argument to getHTTPResponse(), miniwget() and miniwget_getaddr()
+  updated macro :
+    #define MINIUPNPC_API_VERSION 16
+
 API version 15
   changed "sameport" argument of upnpDiscover() upnpDiscoverAll() upnpDiscoverDevice()
     to "localport". When 0 or 1, behaviour is not changed, but it can take

+ 0 - 97
ext/miniupnpc/java/JavaBridgeTest.java

@@ -1,97 +0,0 @@
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-
-import fr.free.miniupnp.*;
-
-/**
- *
- * @author syuu
- */
-public class JavaBridgeTest {
-    public static void main(String[] args) {
-        int UPNP_DELAY = 2000;
-        MiniupnpcLibrary miniupnpc = MiniupnpcLibrary.INSTANCE;
-        UPNPDev devlist = null;
-        UPNPUrls urls = new UPNPUrls();
-        IGDdatas data = new IGDdatas();
-        ByteBuffer lanaddr = ByteBuffer.allocate(16);
-        ByteBuffer intClient = ByteBuffer.allocate(16);
-        ByteBuffer intPort = ByteBuffer.allocate(6);
-        ByteBuffer desc = ByteBuffer.allocate(80);
-        ByteBuffer enabled = ByteBuffer.allocate(4);
-        ByteBuffer leaseDuration = ByteBuffer.allocate(16);
-        int ret;
-        int i;
-
-        if(args.length < 2) {
-            System.err.println("Usage : java [...] JavaBridgeTest port protocol");
-            System.out.println("  port is numeric, protocol is TCP or UDP");
-            return;
-        }
-
-        devlist = miniupnpc.upnpDiscover(UPNP_DELAY, (String) null, (String) null, 0, 0, (byte)2, IntBuffer.allocate(1));
-        if (devlist != null) {
-            System.out.println("List of UPNP devices found on the network :");
-            for (UPNPDev device = devlist; device != null; device = device.pNext) {
-                System.out.println("desc: " + device.descURL.getString(0) + " st: " + device.st.getString(0));
-            }
-            if ((i = miniupnpc.UPNP_GetValidIGD(devlist, urls, data, lanaddr, 16)) != 0) {
-                switch (i) {
-                    case 1:
-                        System.out.println("Found valid IGD : " + urls.controlURL.getString(0));
-                        break;
-                    case 2:
-                        System.out.println("Found a (not connected?) IGD : " + urls.controlURL.getString(0));
-                        System.out.println("Trying to continue anyway");
-                        break;
-                    case 3:
-                        System.out.println("UPnP device found. Is it an IGD ? : " + urls.controlURL.getString(0));
-                        System.out.println("Trying to continue anyway");
-                        break;
-                    default:
-                        System.out.println("Found device (igd ?) : " + urls.controlURL.getString(0));
-                        System.out.println("Trying to continue anyway");
-
-                }
-                System.out.println("Local LAN ip address : " + new String(lanaddr.array()));
-                ByteBuffer externalAddress = ByteBuffer.allocate(16);
-                miniupnpc.UPNP_GetExternalIPAddress(urls.controlURL.getString(0),
-                        new String(data.first.servicetype), externalAddress);
-                System.out.println("ExternalIPAddress = " + new String(externalAddress.array()));
-                ret = miniupnpc.UPNP_AddPortMapping(
-                        urls.controlURL.getString(0), // controlURL
-                        new String(data.first.servicetype), // servicetype
-                        args[0], // external Port
-                        args[0], // internal Port
-                        new String(lanaddr.array()), // internal client
-                        "added via miniupnpc/JAVA !", // description
-                        args[1], // protocol UDP or TCP
-                        null, // remote host (useless)
-                        "0"); // leaseDuration
-                if (ret != MiniupnpcLibrary.UPNPCOMMAND_SUCCESS)
-                    System.out.println("AddPortMapping() failed with code " + ret);
-                ret = miniupnpc.UPNP_GetSpecificPortMappingEntry(
-                        urls.controlURL.getString(0), new String(data.first.servicetype),
-                        args[0], args[1], null, intClient, intPort,
-                        desc, enabled, leaseDuration);
-                if (ret != MiniupnpcLibrary.UPNPCOMMAND_SUCCESS)
-                    System.out.println("GetSpecificPortMappingEntry() failed with code " + ret);
-                System.out.println("InternalIP:Port = " +
-                        new String(intClient.array()) + ":" + new String(intPort.array()) +
-                        " (" + new String(desc.array()) + ")");
-                ret = miniupnpc.UPNP_DeletePortMapping(
-                        urls.controlURL.getString(0),
-                        new String(data.first.servicetype),
-                        args[0], args[1], null);
-                if (ret != MiniupnpcLibrary.UPNPCOMMAND_SUCCESS)
-                    System.out.println("DelPortMapping() failed with code " + ret);
-                miniupnpc.FreeUPNPUrls(urls);
-            } else {
-                System.out.println("No valid UPNP Internet Gateway Device found.");
-            }
-            miniupnpc.freeUPNPDevlist(devlist);
-        } else {
-            System.out.println("No IGD UPnP Device found on the network !\n");
-        }
-    }
-}

+ 0 - 8
ext/miniupnpc/java/testjava.bat

@@ -1,8 +0,0 @@
-@echo off
-set JAVA=java
-set JAVAC=javac
-REM notice the semicolon for Windows.  Write once, run ... oh nevermind
-set CP=miniupnpc_win32.jar;.
-
-%JAVAC% -cp "%CP%" JavaBridgeTest.java || exit 1
-%JAVA% -cp "%CP%" JavaBridgeTest 12345 UDP || exit 1

+ 0 - 8
ext/miniupnpc/java/testjava.sh

@@ -1,8 +0,0 @@
-#!/bin/bash
-
-JAVA=java
-JAVAC=javac
-CP=$(for i in *.jar; do echo -n $i:; done).
-
-$JAVAC -cp $CP JavaBridgeTest.java || exit 1
-$JAVA -cp $CP JavaBridgeTest 12345 UDP || exit 1

+ 0 - 55
ext/miniupnpc/man3/miniupnpc.3

@@ -1,55 +0,0 @@
-.TH MINIUPNPC 3
-.SH NAME
-miniupnpc \- UPnP client library
-.SH SYNOPSIS
-.SH DESCRIPTION
-The miniupnpc library implement the UPnP protocol defined
-to dialog with Internet Gateway Devices. It also has
-the ability to use data gathered by minissdpd(1) about
-UPnP devices up on the network in order to skip the
-long UPnP device discovery process.
-.PP
-At first, upnpDiscover(3) has to be used to discover UPnP IGD present
-on the network. Then UPNP_GetValidIGD(3) to select the right one.
-Alternatively, UPNP_GetIGDFromUrl(3) could be used to bypass discovery
-process if the root description url of the device to use is known.
-Then all the UPNP_* functions can be used, such as
-UPNP_GetConnectionTypeInfo(3), UPNP_AddPortMapping(3), etc...
-.SH "HEADER FILES"
-.IP miniupnpc.h
-That's the main header file for the miniupnpc library API.
-It contains all the functions and structures related to device discovery.
-.IP upnpcommands.h
-This header file contain the UPnP IGD methods that are accessible
-through the miniupnpc API. The name of the C functions are matching
-the UPnP methods names. ie: GetGenericPortMappingEntry is
-UPNP_GetGenericPortMappingEntry.
-.SH "API FUNCTIONS"
-.IP "struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int localport, int ipv6, int * error);"
-execute the discovery process.
-delay (in millisecond) is the maximum time for waiting any device response.
-If available, device list will be obtained from MiniSSDPd.
-Default path for minissdpd socket will be used if minissdpdsock argument is NULL.
-If multicastif is not NULL, it will be used instead of the default multicast interface for sending SSDP discover packets.
-If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent 
-from the source port 1900 (same as destination port), if set to 
-UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will 
-be attempted as the source port.
-If ipv6 is not 0, IPv6 is used instead of IPv4 for the discovery process.
-.IP "void freeUPNPDevlist(struct UPNPDev * devlist);"
-free the list returned by upnpDiscover().
-.IP "int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);"
-browse the list of device returned by upnpDiscover(), find
-a live UPnP internet gateway device and fill structures passed as arguments
-with data used for UPNP methods invokation.
-.IP "int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);"
-permit to bypass the upnpDiscover() call if the xml root description
-URL of the UPnP IGD is known.
-Fill structures passed as arguments
-with data used for UPNP methods invokation.
-.IP "void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);"
-.IP "void FreeUPNPUrls(struct UPNPUrls *);"
-
-.SH "SEE ALSO"
-minissdpd(1)
-.SH BUGS

+ 5 - 1
ext/miniupnpc/minihttptestserver.c

@@ -1,4 +1,4 @@
-/* $Id: minihttptestserver.c,v 1.18 2015/07/15 12:41:15 nanard Exp $ */
+/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */
 /* Project : miniUPnP
  * Author : Thomas Bernard
  * Copyright (c) 2011-2015 Thomas Bernard
@@ -18,6 +18,10 @@
 #include <time.h>
 #include <errno.h>
 
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK         0x7f000001
+#endif
+
 #define CRAP_LENGTH (2048)
 
 volatile sig_atomic_t quit = 0;

+ 1 - 1
ext/miniupnpc/minisoap.c

@@ -22,7 +22,7 @@
 #include "minisoap.h"
 #ifdef _WIN32
 #define OS_STRING "Win32"
-#define MINIUPNPC_VERSION_STRING "1.9"
+#define MINIUPNPC_VERSION_STRING "2.0"
 #define UPNP_VERSION_STRING "UPnP/1.1"
 #endif
 

+ 23 - 4
ext/miniupnpc/minissdpc.c

@@ -1,7 +1,8 @@
 #define _CRT_SECURE_NO_WARNINGS
 
-/* $Id: minissdpc.c,v 1.30 2015/10/26 17:05:07 nanard Exp $ */
-/* Project : miniupnp
+/* $Id: minissdpc.c,v 1.31 2016/01/19 09:56:46 nanard Exp $ */
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * Project : miniupnp
  * Web : http://miniupnp.free.fr/
  * Author : Thomas BERNARD
  * copyright (c) 2005-2015 Thomas Bernard
@@ -69,6 +70,10 @@ struct sockaddr_un {
 #define HAS_IP_MREQN
 #endif
 
+#if !defined(HAS_IP_MREQN) && !defined(_WIN32)
+#include <sys/ioctl.h>
+#endif
+
 #if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
 /* Several versions of glibc don't define this structure,
  * define it here and compile with CFLAGS NEED_STRUCT_IP_MREQN */
@@ -649,11 +654,25 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
 				{
 					PRINT_SOCKET_ERROR("setsockopt");
 				}
-#else
+#elif !defined(_WIN32)
+				struct ifreq ifr;
+				int ifrlen = sizeof(ifr);
+				strncpy(ifr.ifr_name, multicastif, IFNAMSIZ);
+				ifr.ifr_name[IFNAMSIZ-1] = '\0';
+				if(ioctl(sudp, SIOCGIFADDR, &ifr, &ifrlen) < 0)
+				{
+					PRINT_SOCKET_ERROR("ioctl(...SIOCGIFADDR...)");
+				}
+				mc_if.s_addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+				if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
+				{
+					PRINT_SOCKET_ERROR("setsockopt");
+				}
+#else /* _WIN32 */
 #ifdef DEBUG
 				printf("Setting of multicast interface not supported with interface name.\n");
 #endif
-#endif
+#endif /* #ifdef HAS_IP_MREQN / !defined(_WIN32) */
 			}
 		}
 	}

+ 59 - 20
ext/miniupnpc/miniupnpc.c

@@ -1,10 +1,11 @@
 #define _CRT_SECURE_NO_WARNINGS
-/* $Id: miniupnpc.c,v 1.141 2015/10/26 17:05:07 nanard Exp $ */
-/* vim: tabstop=4 shiftwidth=4 noexpandtab */
-/* Project : miniupnp
+
+/* $Id: miniupnpc.c,v 1.149 2016/02/09 09:50:46 nanard Exp $ */
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * Project : miniupnp
  * Web : http://miniupnp.free.fr/
  * Author : Thomas BERNARD
- * copyright (c) 2005-2015 Thomas Bernard
+ * copyright (c) 2005-2016 Thomas Bernard
  * This software is subjet to the conditions detailed in the
  * provided LICENSE file. */
 #include <stdlib.h>
@@ -73,6 +74,25 @@
 #define SERVICEPREFIX "u"
 #define SERVICEPREFIX2 'u'
 
+/* check if an ip address is a private (LAN) address
+ * see https://tools.ietf.org/html/rfc1918 */
+static int is_rfc1918addr(const char * addr)
+{
+	/* 192.168.0.0     -   192.168.255.255 (192.168/16 prefix) */
+	if(COMPARE(addr, "192.168."))
+		return 1;
+	/* 10.0.0.0        -   10.255.255.255  (10/8 prefix) */
+	if(COMPARE(addr, "10."))
+		return 1;
+	/* 172.16.0.0      -   172.31.255.255  (172.16/12 prefix) */
+	if(COMPARE(addr, "172.")) {
+		int i = atoi(addr + 4);
+		if((16 <= i) && (i <= 31))
+			return 1;
+	}
+	return 0;
+}
+
 /* root description parsing */
 MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data)
 {
@@ -108,6 +128,7 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
 	int soapbodylen;
 	char * buf;
 	int n;
+	int status_code;
 
 	*bufsize = 0;
 	snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
@@ -211,11 +232,15 @@ char * simpleUPnPcommand2(int s, const char * url, const char * service,
 		return NULL;
 	}
 
-	buf = getHTTPResponse(s, bufsize);
+	buf = getHTTPResponse(s, bufsize, &status_code);
 #ifdef DEBUG
 	if(*bufsize > 0 && buf)
 	{
-		printf("SOAP Response :\n%.*s\n", *bufsize, buf);
+		printf("HTTP %d SOAP Response :\n%.*s\n", status_code, *bufsize, buf);
+	}
+	else
+	{
+		printf("HTTP %d, empty SOAP response. size=%d\n", status_code, *bufsize);
 	}
 #endif
 	closesocket(s);
@@ -527,7 +552,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
  *     3 = an UPnP device has been found but was not recognized as an IGD
  *
  * In any positive non zero return case, the urls and data structures
- * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
+ * passed as parameters are set. Dont forget to call FreeUPNPUrls(urls) to
  * free allocated memory.
  */
 MINIUPNP_LIBSPEC int
@@ -547,6 +572,9 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
 	int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */
 	int n_igd = 0;
 	char extIpAddr[16];
+	char myLanAddr[40];
+	int status_code = -1;
+
 	if(!devlist)
 	{
 #ifdef DEBUG
@@ -569,8 +597,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
 		/* we should choose an internet gateway device.
 		 * with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
 		desc[i].xml = miniwget_getaddr(dev->descURL, &(desc[i].size),
-		                               lanaddr, lanaddrlen,
-		                               dev->scope_id);
+		                               myLanAddr, sizeof(myLanAddr),
+		                               dev->scope_id, &status_code);
 #ifdef DEBUG
 		if(!desc[i].xml)
 		{
@@ -587,6 +615,8 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
 			{
 				desc[i].is_igd = 1;
 				n_igd++;
+				if(lanaddr)
+					strncpy(lanaddr, myLanAddr, lanaddrlen);
 			}
 		}
 	}
@@ -602,20 +632,25 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
 				parserootdesc(desc[i].xml, desc[i].size, data);
 				if(desc[i].is_igd || state >= 3 )
 				{
+				  int is_connected;
+
 				  GetUPNPUrls(urls, data, dev->descURL, dev->scope_id);
 
 				  /* in state 2 and 3 we dont test if device is connected ! */
 				  if(state >= 2)
 				    goto free_and_return;
+				  is_connected = UPNPIGD_IsConnected(urls, data);
 #ifdef DEBUG
 				  printf("UPNPIGD_IsConnected(%s) = %d\n",
-				     urls->controlURL,
-			         UPNPIGD_IsConnected(urls, data));
+				     urls->controlURL, is_connected);
 #endif
 				  /* checks that status is connected AND there is a external IP address assigned */
-				  if(UPNPIGD_IsConnected(urls, data)
-				     && (UPNP_GetExternalIPAddress(urls->controlURL,  data->first.servicetype, extIpAddr) == 0))
-					goto free_and_return;
+				  if(is_connected &&
+				     (UPNP_GetExternalIPAddress(urls->controlURL,  data->first.servicetype, extIpAddr) == 0)) {
+					if(!is_rfc1918addr(extIpAddr) && (extIpAddr[0] != '\0')
+					   && (0 != strcmp(extIpAddr, "0.0.0.0")))
+					  goto free_and_return;
+				  }
 				  FreeUPNPUrls(urls);
 				  if(data->second.servicetype[0] != '\0') {
 #ifdef DEBUG
@@ -627,14 +662,17 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
 				    memcpy(&data->first, &data->second, sizeof(struct IGDdatas_service));
 				    memcpy(&data->second, &data->tmp, sizeof(struct IGDdatas_service));
 				    GetUPNPUrls(urls, data, dev->descURL, dev->scope_id);
+				    is_connected = UPNPIGD_IsConnected(urls, data);
 #ifdef DEBUG
 				    printf("UPNPIGD_IsConnected(%s) = %d\n",
-				       urls->controlURL,
-			           UPNPIGD_IsConnected(urls, data));
+				       urls->controlURL, is_connected);
 #endif
-				    if(UPNPIGD_IsConnected(urls, data)
-				       && (UPNP_GetExternalIPAddress(urls->controlURL,  data->first.servicetype, extIpAddr) == 0))
-					  goto free_and_return;
+				    if(is_connected &&
+				       (UPNP_GetExternalIPAddress(urls->controlURL,  data->first.servicetype, extIpAddr) == 0)) {
+					  if(!is_rfc1918addr(extIpAddr) && (extIpAddr[0] != '\0')
+					     && (0 != strcmp(extIpAddr, "0.0.0.0")))
+					    goto free_and_return;
+				    }
 				    FreeUPNPUrls(urls);
 				  }
 				}
@@ -668,8 +706,9 @@ UPNP_GetIGDFromUrl(const char * rootdescurl,
 {
 	char * descXML;
 	int descXMLsize = 0;
+
 	descXML = miniwget_getaddr(rootdescurl, &descXMLsize,
-	   	                       lanaddr, lanaddrlen, 0);
+	                           lanaddr, lanaddrlen, 0, NULL);
 	if(descXML) {
 		memset(data, 0, sizeof(struct IGDdatas));
 		memset(urls, 0, sizeof(struct UPNPUrls));

+ 4 - 4
ext/miniupnpc/miniupnpc.h

@@ -1,8 +1,8 @@
-/* $Id: miniupnpc.h,v 1.48 2015/10/08 16:19:40 nanard Exp $ */
+/* $Id: miniupnpc.h,v 1.50 2016/04/19 21:06:21 nanard Exp $ */
 /* Project: miniupnp
  * http://miniupnp.free.fr/
  * Author: Thomas Bernard
- * Copyright (c) 2005-2015 Thomas Bernard
+ * Copyright (c) 2005-2016 Thomas Bernard
  * This software is subjects to the conditions detailed
  * in the LICENCE file provided within this distribution */
 #ifndef MINIUPNPC_H_INCLUDED
@@ -19,8 +19,8 @@
 #define UPNPDISCOVER_MEMORY_ERROR (-102)
 
 /* versions : */
-#define MINIUPNPC_VERSION	"1.9.20151026"
-#define MINIUPNPC_API_VERSION	15
+#define MINIUPNPC_VERSION	"2.0"
+#define MINIUPNPC_API_VERSION	16
 
 /* Source port:
    Using "1" as an alias for 1900 for backwards compatability

+ 0 - 15
ext/miniupnpc/miniupnpcstrings.h.cmake

@@ -1,15 +0,0 @@
-#ifndef MINIUPNPCSTRINGS_H_INCLUDED
-#define MINIUPNPCSTRINGS_H_INCLUDED
-
-#define OS_STRING "${CMAKE_SYSTEM_NAME}"
-#define MINIUPNPC_VERSION_STRING "${MINIUPNPC_VERSION}"
-
-#if 0
-/* according to "UPnP Device Architecture 1.0" */
-#define UPNP_VERSION_STRING "UPnP/1.0"
-#else
-/* according to "UPnP Device Architecture 1.1" */
-#define UPNP_VERSION_STRING "UPnP/1.1"
-#endif
-
-#endif

+ 52 - 19
ext/miniupnpc/miniwget.c

@@ -1,9 +1,10 @@
 #define _CRT_SECURE_NO_WARNINGS
-/* $Id: miniwget.c,v 1.72 2015/10/26 17:05:08 nanard Exp $ */
+
+/* $Id: miniwget.c,v 1.75 2016/01/24 17:24:36 nanard Exp $ */
 /* Project : miniupnp
  * Website : http://miniupnp.free.fr/
  * Author : Thomas Bernard
- * Copyright (c) 2005-2015 Thomas Bernard
+ * Copyright (c) 2005-2016 Thomas Bernard
  * This software is subject to the conditions detailed in the
  * LICENCE file provided in this distribution. */
 
@@ -49,12 +50,12 @@
 #define MIN(x,y) (((x)<(y))?(x):(y))
 #endif /* MIN */
 
-
 #ifdef _WIN32
 #define OS_STRING "Win32"
-#define MINIUPNPC_VERSION_STRING "1.9"
+#define MINIUPNPC_VERSION_STRING "2.0"
 #define UPNP_VERSION_STRING "UPnP/1.1"
 #endif
+
 #include "miniwget.h"
 #include "connecthostport.h"
 #include "receivedata.h"
@@ -70,7 +71,7 @@
  * to the length parameter.
  */
 void *
-getHTTPResponse(int s, int * size)
+getHTTPResponse(int s, int * size, int * status_code)
 {
 	char buf[2048];
 	int n;
@@ -88,7 +89,10 @@ getHTTPResponse(int s, int * size)
 	unsigned int content_buf_used = 0;
 	char chunksize_buf[32];
 	unsigned int chunksize_buf_index;
+	char * reason_phrase = NULL;
+	int reason_phrase_len = 0;
 
+	if(status_code) *status_code = -1;
 	header_buf = malloc(header_buf_len);
 	if(header_buf == NULL)
 	{
@@ -160,7 +164,7 @@ getHTTPResponse(int s, int * size)
 				continue;
 			/* parse header lines */
 			for(i = 0; i < endofheaders - 1; i++) {
-				if(colon <= linestart && header_buf[i]==':')
+				if(linestart > 0 && colon <= linestart && header_buf[i]==':')
 				{
 					colon = i;
 					while(i < (endofheaders-1)
@@ -171,7 +175,29 @@ getHTTPResponse(int s, int * size)
 				/* detecting end of line */
 				else if(header_buf[i]=='\r' || header_buf[i]=='\n')
 				{
-					if(colon > linestart && valuestart > colon)
+					if(linestart == 0 && status_code)
+					{
+						/* Status line
+						 * HTTP-Version SP Status-Code SP Reason-Phrase CRLF */
+						int sp;
+						for(sp = 0; sp < i; sp++)
+							if(header_buf[sp] == ' ')
+							{
+								if(*status_code < 0)
+									*status_code = atoi(header_buf + sp + 1);
+								else
+								{
+									reason_phrase = header_buf + sp + 1;
+									reason_phrase_len = i - sp - 1;
+									break;
+								}
+							}
+#ifdef DEBUG
+						printf("HTTP status code = %d, Reason phrase = %.*s\n",
+						       *status_code, reason_phrase_len, reason_phrase);
+#endif
+					}
+					else if(colon > linestart && valuestart > colon)
 					{
 #ifdef DEBUG
 						printf("header='%.*s', value='%.*s'\n",
@@ -342,7 +368,8 @@ static void *
 miniwget3(const char * host,
           unsigned short port, const char * path,
           int * size, char * addr_str, int addr_str_len,
-          const char * httpversion, unsigned int scope_id)
+          const char * httpversion, unsigned int scope_id,
+          int * status_code)
 {
 	char buf[2048];
     int s;
@@ -440,7 +467,7 @@ miniwget3(const char * host,
 			sent += n;
 		}
 	}
-	content = getHTTPResponse(s, size);
+	content = getHTTPResponse(s, size, status_code);
 	closesocket(s);
 	return content;
 }
@@ -449,18 +476,20 @@ miniwget3(const char * host,
  * Call miniwget3(); retry with HTTP/1.1 if 1.0 fails. */
 static void *
 miniwget2(const char * host,
-		  unsigned short port, const char * path,
-		  int * size, char * addr_str, int addr_str_len,
-          unsigned int scope_id)
+          unsigned short port, const char * path,
+          int * size, char * addr_str, int addr_str_len,
+          unsigned int scope_id, int * status_code)
 {
 	char * respbuffer;
 
 #if 1
 	respbuffer = miniwget3(host, port, path, size,
-	                       addr_str, addr_str_len, "1.1", scope_id);
+	                       addr_str, addr_str_len, "1.1",
+	                       scope_id, status_code);
 #else
 	respbuffer = miniwget3(host, port, path, size,
-	                       addr_str, addr_str_len, "1.0", scope_id);
+	                       addr_str, addr_str_len, "1.0",
+	                       scope_id, status_code);
 	if (*size == 0)
 	{
 #ifdef DEBUG
@@ -468,7 +497,8 @@ miniwget2(const char * host,
 #endif
 		free(respbuffer);
 		respbuffer = miniwget3(host, port, path, size,
-		                       addr_str, addr_str_len, "1.1", scope_id);
+		                       addr_str, addr_str_len, "1.1",
+		                       scope_id, status_code);
 	}
 #endif
 	return respbuffer;
@@ -593,7 +623,8 @@ parseURL(const char * url,
 }
 
 void *
-miniwget(const char * url, int * size, unsigned int scope_id)
+miniwget(const char * url, int * size,
+         unsigned int scope_id, int * status_code)
 {
 	unsigned short port;
 	char * path;
@@ -606,12 +637,13 @@ miniwget(const char * url, int * size, unsigned int scope_id)
 	printf("parsed url : hostname='%s' port=%hu path='%s' scope_id=%u\n",
 	       hostname, port, path, scope_id);
 #endif
-	return miniwget2(hostname, port, path, size, 0, 0, scope_id);
+	return miniwget2(hostname, port, path, size, 0, 0, scope_id, status_code);
 }
 
 void *
 miniwget_getaddr(const char * url, int * size,
-                 char * addr, int addrlen, unsigned int scope_id)
+                 char * addr, int addrlen, unsigned int scope_id,
+                 int * status_code)
 {
 	unsigned short port;
 	char * path;
@@ -626,5 +658,6 @@ miniwget_getaddr(const char * url, int * size,
 	printf("parsed url : hostname='%s' port=%hu path='%s' scope_id=%u\n",
 	       hostname, port, path, scope_id);
 #endif
-	return miniwget2(hostname, port, path, size, addr, addrlen, scope_id);
+	return miniwget2(hostname, port, path, size, addr, addrlen, scope_id, status_code);
 }
+

+ 5 - 5
ext/miniupnpc/miniwget.h

@@ -1,7 +1,7 @@
-/* $Id: miniwget.h,v 1.10 2015/07/21 13:16:55 nanard Exp $ */
+/* $Id: miniwget.h,v 1.12 2016/01/24 17:24:36 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
- * Copyright (c) 2005-2015 Thomas Bernard
+ * Copyright (c) 2005-2016 Thomas Bernard
  * This software is subject to the conditions detailed in the
  * LICENCE file provided in this distribution.
  * */
@@ -14,11 +14,11 @@
 extern "C" {
 #endif
 
-MINIUPNP_LIBSPEC void * getHTTPResponse(int s, int * size);
+MINIUPNP_LIBSPEC void * getHTTPResponse(int s, int * size, int * status_code);
 
-MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int);
+MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int, int *);
 
-MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int);
+MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int, int *);
 
 int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *);
 

+ 0 - 29
ext/miniupnpc/msvc/miniupnpc.sln

@@ -1,29 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniupnpc", "miniupnpc.vcproj", "{D28CE435-CB33-4BAE-8A52-C6EF915956F5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "upnpc-static", "upnpc-static.vcproj", "{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}"
-	ProjectSection(ProjectDependencies) = postProject
-		{D28CE435-CB33-4BAE-8A52-C6EF915956F5} = {D28CE435-CB33-4BAE-8A52-C6EF915956F5}
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.ActiveCfg = Debug|Win32
-		{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Debug|Win32.Build.0 = Debug|Win32
-		{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.ActiveCfg = Release|Win32
-		{D28CE435-CB33-4BAE-8A52-C6EF915956F5}.Release|Win32.Build.0 = Release|Win32
-		{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.ActiveCfg = Debug|Win32
-		{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Debug|Win32.Build.0 = Debug|Win32
-		{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.ActiveCfg = Release|Win32
-		{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

+ 0 - 283
ext/miniupnpc/msvc/miniupnpc.vcproj

@@ -1,283 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9,00"
-	Name="miniupnpc"
-	ProjectGUID="{D28CE435-CB33-4BAE-8A52-C6EF915956F5}"
-	RootNamespace="miniupnpc"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="196613"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
-			CharacterSet="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB;DEBUG"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="4"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB"
-				RuntimeLibrary="2"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Fichiers sources"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\connecthostport.c"
-				>
-			</File>
-			<File
-				RelativePath="..\igd_desc_parse.c"
-				>
-			</File>
-			<File
-				RelativePath="..\minisoap.c"
-				>
-			</File>
-			<File
-				RelativePath="..\minissdpc.c"
-				>
-			</File>
-			<File
-				RelativePath="..\miniupnpc.c"
-				>
-			</File>
-			<File
-				RelativePath="..\miniwget.c"
-				>
-			</File>
-			<File
-				RelativePath="..\minixml.c"
-				>
-			</File>
-			<File
-				RelativePath="..\portlistingparse.c"
-				>
-			</File>
-			<File
-				RelativePath="..\receivedata.c"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpcommands.c"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpdev.c"
-				>
-			</File>
-			<File
-				RelativePath="..\upnperrors.c"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpreplyparse.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Fichiers d&apos;en-tête"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath="..\connecthostport.h"
-				>
-			</File>
-			<File
-				RelativePath="..\declspec.h"
-				>
-			</File>
-			<File
-				RelativePath="..\igd_desc_parse.h"
-				>
-			</File>
-			<File
-				RelativePath="..\minisoap.h"
-				>
-			</File>
-			<File
-				RelativePath="..\minissdpc.h"
-				>
-			</File>
-			<File
-				RelativePath="..\miniupnpc.h"
-				>
-			</File>
-			<File
-				RelativePath="..\miniupnpcstrings.h"
-				>
-			</File>
-			<File
-				RelativePath="..\miniupnpctypes.h"
-				>
-			</File>
-			<File
-				RelativePath="..\miniwget.h"
-				>
-			</File>
-			<File
-				RelativePath="..\minixml.h"
-				>
-			</File>
-			<File
-				RelativePath="..\portlistingparse.h"
-				>
-			</File>
-			<File
-				RelativePath="..\receivedata.h"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpcommands.h"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpdev.h"
-				>
-			</File>
-			<File
-				RelativePath="..\upnperrors.h"
-				>
-			</File>
-			<File
-				RelativePath="..\upnpreplyparse.h"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Fichiers de ressources"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>

+ 0 - 195
ext/miniupnpc/msvc/upnpc-static.vcproj

@@ -1,195 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9,00"
-	Name="upnpc-static"
-	ProjectGUID="{469E1CF6-08A2-4B7B-A2AA-5BDB089857C1}"
-	RootNamespace="upnpcstatic"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="196613"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				PreprocessorDefinitions="_DEBUG;_CONSOLE;MINIUPNP_STATICLIB;DEBUG;_CRT_SECURE_NO_WARNINGS"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="3"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib IPHlpApi.Lib Debug\miniupnpc.lib"
-				LinkIncremental="2"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				EnableIntrinsicFunctions="true"
-				PreprocessorDefinitions="NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;MINIUPNP_STATICLIB"
-				RuntimeLibrary="2"
-				EnableFunctionLevelLinking="true"
-				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="ws2_32.lib IPHlpApi.Lib Release\miniupnpc.lib"
-				LinkIncremental="1"
-				GenerateDebugInformation="true"
-				SubSystem="1"
-				OptimizeReferences="2"
-				EnableCOMDATFolding="2"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Fichiers sources"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\upnpc.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Fichiers d&apos;en-tête"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-		</Filter>
-		<Filter
-			Name="Fichiers de ressources"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>

+ 4 - 4
ext/miniupnpc/receivedata.c

@@ -1,4 +1,4 @@
-/* $Id: receivedata.c,v 1.6 2014/11/13 13:51:52 nanard Exp $ */
+/* $Id: receivedata.c,v 1.7 2015/11/09 21:51:41 nanard Exp $ */
 /* Project : miniupnp
  * Website : http://miniupnp.free.fr/
  * Author : Thomas Bernard
@@ -40,7 +40,7 @@ receivedata(int socket,
             char * data, int length,
             int timeout, unsigned int * scope_id)
 {
-#if MINIUPNPC_GET_SRC_ADDR
+#ifdef MINIUPNPC_GET_SRC_ADDR
 	struct sockaddr_storage src_addr;
 	socklen_t src_addr_len = sizeof(src_addr);
 #endif	/* MINIUPNPC_GET_SRC_ADDR */
@@ -80,7 +80,7 @@ receivedata(int socket,
         return 0;
     }
 #endif	/* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */
-#if MINIUPNPC_GET_SRC_ADDR
+#ifdef MINIUPNPC_GET_SRC_ADDR
 	memset(&src_addr, 0, sizeof(src_addr));
 	n = recvfrom(socket, data, length, 0,
 	             (struct sockaddr *)&src_addr, &src_addr_len);
@@ -90,7 +90,7 @@ receivedata(int socket,
 	if(n<0) {
 		PRINT_SOCKET_ERROR("recv");
 	}
-#if MINIUPNPC_GET_SRC_ADDR
+#ifdef MINIUPNPC_GET_SRC_ADDR
 	if (src_addr.ss_family == AF_INET6) {
 		const struct sockaddr_in6 * src_addr6 = (struct sockaddr_in6 *)&src_addr;
 #ifdef DEBUG

+ 7 - 5
ext/miniupnpc/testminiwget.c

@@ -1,7 +1,7 @@
-/* $Id: testminiwget.c,v 1.4 2012/06/23 22:35:59 nanard Exp $ */
+/* $Id: testminiwget.c,v 1.5 2016/01/24 17:24:36 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
- * Copyright (c) 2005-2012 Thomas Bernard
+ * Copyright (c) 2005-2016 Thomas Bernard
  * This software is subject to the conditions detailed in the
  * LICENCE file provided in this distribution.
  * */
@@ -20,15 +20,17 @@ int main(int argc, char * * argv)
 	int size, writtensize;
 	FILE *f;
 	char addr[64];
+	int status_code = -1;
 
 	if(argc < 3) {
 		fprintf(stderr, "Usage:\t%s url file\n", argv[0]);
 		fprintf(stderr, "Example:\t%s http://www.google.com/ out.html\n", argv[0]);
 		return 1;
 	}
-	data = miniwget_getaddr(argv[1], &size, addr, sizeof(addr), 0);
-	if(!data) {
-		fprintf(stderr, "Error fetching %s\n", argv[1]);
+	data = miniwget_getaddr(argv[1], &size, addr, sizeof(addr), 0, &status_code);
+	if(!data || (status_code != 200)) {
+		if(data) free(data);
+		fprintf(stderr, "Error %d fetching %s\n", status_code, argv[1]);
 		return 1;
 	}
 	printf("local address : %s\n", addr);

+ 10 - 8
ext/miniupnpc/upnpc.c

@@ -1,7 +1,7 @@
-/* $Id: upnpc.c,v 1.112 2015/10/08 16:15:48 nanard Exp $ */
+/* $Id: upnpc.c,v 1.114 2016/01/22 15:04:23 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
- * Copyright (c) 2005-2015 Thomas Bernard
+ * Copyright (c) 2005-2016 Thomas Bernard
  * This software is subject to the conditions detailed in the
  * LICENCE file provided in this distribution. */
 
@@ -66,7 +66,7 @@ static void DisplayInfos(struct UPNPUrls * urls,
 	char connectionType[64];
 	char status[64];
 	char lastconnerr[64];
-	unsigned int uptime;
+	unsigned int uptime = 0;
 	unsigned int brUp, brDown;
 	time_t timenow, timestarted;
 	int r;
@@ -82,9 +82,11 @@ static void DisplayInfos(struct UPNPUrls * urls,
 	else
 		printf("Status : %s, uptime=%us, LastConnectionError : %s\n",
 		       status, uptime, lastconnerr);
-	timenow = time(NULL);
-	timestarted = timenow - uptime;
-	printf("  Time started : %s", ctime(&timestarted));
+	if(uptime > 0) {
+		timenow = time(NULL);
+		timestarted = timenow - uptime;
+		printf("  Time started : %s", ctime(&timestarted));
+	}
 	if(UPNP_GetLinkLayerMaxBitRates(urls->controlURL_CIF, data->CIF.servicetype,
 	                                &brDown, &brUp) != UPNPCOMMAND_SUCCESS) {
 		printf("GetLinkLayerMaxBitRates failed.\n");
@@ -538,7 +540,7 @@ int main(int argc, char ** argv)
 	char ** commandargv = 0;
 	int commandargc = 0;
 	struct UPNPDev * devlist = 0;
-	char lanaddr[64];	/* my ip address on the LAN */
+	char lanaddr[64] = "unset";	/* my ip address on the LAN */
 	int i;
 	const char * rootdescurl = 0;
 	const char * multicastif = 0;
@@ -560,7 +562,7 @@ int main(int argc, char ** argv)
 	}
 #endif
     printf("upnpc : miniupnpc library test client, version %s.\n", MINIUPNPC_VERSION_STRING);
-	printf(" (c) 2005-2015 Thomas Bernard.\n");
+	printf(" (c) 2005-2016 Thomas Bernard.\n");
     printf("Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/\n"
 	       "for more information.\n");
 	/* command line processing */

+ 4 - 3
ext/miniupnpc/upnpcommands.c

@@ -1,5 +1,6 @@
 #define _CRT_SECURE_NO_WARNINGS
-/* $Id: upnpcommands.c,v 1.46 2015/07/15 12:19:00 nanard Exp $ */
+
+/* $Id: upnpcommands.c,v 1.47 2016/03/07 12:26:48 nanard Exp $ */
 /* Project : miniupnp
  * Author : Thomas Bernard
  * Copyright (c) 2005-2015 Thomas Bernard
@@ -617,14 +618,14 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL,
 		protocol[3] = '\0';
 	}
 	p = GetValueFromNameValueList(&pdata, "NewInternalClient");
-	if(p && intClient)
+	if(p)
 	{
 		strncpy(intClient, p, 16);
 		intClient[15] = '\0';
 		r = 0;
 	}
 	p = GetValueFromNameValueList(&pdata, "NewInternalPort");
-	if(p && intPort)
+	if(p)
 	{
 		strncpy(intPort, p, 6);
 		intPort[5] = '\0';

+ 1 - 1
make-linux.mk

@@ -58,7 +58,7 @@ ifeq ($(ZT_OFFICIAL_RELEASE),1)
 endif
 
 ifeq ($(ZT_USE_MINIUPNPC),1)
-	DEFS+=-DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DOS_STRING=\"Linux\" -DMINIUPNPC_VERSION_STRING=\"1.9\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
+	DEFS+=-DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DOS_STRING=\"Linux\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
 	OBJS+=osdep/PortMapper.o
 
 	#ifeq ($(wildcard /usr/include/miniupnpc/miniupnpc.h),)

+ 1 - 1
make-mac.mk

@@ -42,7 +42,7 @@ ifeq ($(ZT_AUTO_UPDATE),1)
 endif
 
 ifeq ($(ZT_USE_MINIUPNPC),1)
-	DEFS+=-DMACOSX -DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -D_DARWIN_C_SOURCE -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -DOS_STRING=\"Darwin/15.0.0\" -DMINIUPNPC_VERSION_STRING=\"1.9\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
+	DEFS+=-DMACOSX -DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -D_DARWIN_C_SOURCE -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -DOS_STRING=\"Darwin/15.0.0\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
 	OBJS+=ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o ext/miniupnpc/connecthostport.o ext/miniupnpc/igd_desc_parse.o ext/miniupnpc/minisoap.o ext/miniupnpc/minissdpc.o ext/miniupnpc/miniupnpc.o ext/miniupnpc/miniwget.o ext/miniupnpc/minixml.o ext/miniupnpc/portlistingparse.o ext/miniupnpc/receivedata.o ext/miniupnpc/upnpcommands.o ext/miniupnpc/upnpdev.o ext/miniupnpc/upnperrors.o ext/miniupnpc/upnpreplyparse.o osdep/PortMapper.o
 endif