diff --git a/Makefile.common b/Makefile.common index 0313fbeaa0..3018d59bee 100644 --- a/Makefile.common +++ b/Makefile.common @@ -2228,27 +2228,6 @@ ifeq ($(HAVE_NETWORKING), 1) ifeq ($(HAVE_NETWORKGAMEPAD), 1) OBJ += cores/libretro-net-retropad/net_retropad_core.o endif - - ifeq ($(HAVE_BUILTINMINIUPNPC), 1) - HAVE_MINIUPNPC = 1 - DEFINES += -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR - INCLUDE_DIRS += -I$(DEPS_DIR) - OBJ += $(DEPS_DIR)/miniupnpc/igd_desc_parse.o \ - $(DEPS_DIR)/miniupnpc/upnpreplyparse.o \ - $(DEPS_DIR)/miniupnpc/upnpcommands.o \ - $(DEPS_DIR)/miniupnpc/upnperrors.o \ - $(DEPS_DIR)/miniupnpc/connecthostport.o \ - $(DEPS_DIR)/miniupnpc/portlistingparse.o \ - $(DEPS_DIR)/miniupnpc/receivedata.o \ - $(DEPS_DIR)/miniupnpc/upnpdev.o \ - $(DEPS_DIR)/miniupnpc/minissdpc.o \ - $(DEPS_DIR)/miniupnpc/miniwget.o \ - $(DEPS_DIR)/miniupnpc/miniupnpc.o \ - $(DEPS_DIR)/miniupnpc/minixml.o \ - $(DEPS_DIR)/miniupnpc/minisoap.o - else ifeq ($(HAVE_MINIUPNPC), 1) - LIBS += $(MINIUPNPC_LIBS) - endif endif ifneq ($(findstring FPGA,$(OS)),) diff --git a/deps/miniupnpc/Changelog.txt b/deps/miniupnpc/Changelog.txt deleted file mode 100644 index 76d947b202..0000000000 --- a/deps/miniupnpc/Changelog.txt +++ /dev/null @@ -1,684 +0,0 @@ -$Id: Changelog.txt,v 1.226 2016/12/16 08:57:19 nanard Exp $ -miniUPnP client Changelog. - -2016/11/11: - check strlen before memcmp in XML parsing portlistingparse.c - fix build under SOLARIS and CYGWIN - -2016/10/11: - Add python 3 compatibility to IGD test - -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() - -2015/10/25: - fix compilation with old macs - fix compilation with mingw32 (for Appveyor) - fix python module for python <= 2.3 - -2015/10/08: - Change sameport to localport - see https://github.com/miniupnp/miniupnp/pull/120 - increments API_VERSION to 15 - -2015/09/15: - Fix buffer overflow in igd_desc_parse.c/IGDstartelt() - Discovered by Aleksandar Nikolic of Cisco Talos - -2015/08/28: - move ssdpDiscoverDevices() to minissdpc.c - -2015/08/27: - avoid unix socket leak in getDevicesFromMiniSSDPD() - -2015/08/16: - Also accept "Up" as ConnectionStatus value - -2015/07/23: - split getDevicesFromMiniSSDPD - add ttl argument to upnpDiscover() functions - increments API_VERSION to 14 - -2015/07/22: - Read USN from SSDP messages. - -2015/07/15: - Check malloc/calloc - -2015/06/16: - update getDevicesFromMiniSSDPD() to process longer minissdpd - responses - -2015/05/22: - add searchalltypes param to upnpDiscoverDevices() - increments API_VERSION to 13 - -2015/04/30: - upnpc: output version on the terminal - -2015/04/27: - _BSD_SOURCE is deprecated in favor of _DEFAULT_SOURCE - fix CMakeLists.txt COMPILE_DEFINITIONS - fix getDevicesFromMiniSSDPD() not setting scope_id - improve -r command of upnpc command line tool - -2014/11/17: - search all : - upnpDiscoverDevices() / upnpDiscoverAll() functions - listdevices executable - increment API_VERSION to 12 - validate igd_desc_parse - -2014/11/13: - increment API_VERSION to 11 - -2014/11/05: - simplified function GetUPNPUrls() - -2014/09/11: - use remoteHost arg of DeletePortMapping - -2014/09/06: - Fix python3 build - -2014/07/01: - Fix parsing of IGD2 root descriptions - -2014/06/10: - rename LIBSPEC to MINIUPNP_LIBSPEC - -2014/05/15: - Add support for IGD2 AddAnyPortMapping and DeletePortMappingRange - -2014/02/05: - handle EINPROGRESS after connect() - -2014/02/03: - minixml now handle XML comments - -VERSION 1.9 : released 2014/01/31 - -2014/01/31: - added argument remoteHost to UPNP_GetSpecificPortMappingEntry() - increment API_VERSION to 10 - -2013/12/09: - --help and -h arguments in upnpc.c - -2013/10/07: - fixed potential buffer overrun in miniwget.c - Modified UPNP_GetValidIGD() to check for ExternalIpAddress - -2013/08/01: - define MAXHOSTNAMELEN if not already done - -2013/06/06: - update upnpreplyparse to allow larger values (128 chars instead of 64) - -2013/05/14: - Update upnpreplyparse to take into account "empty" elements - validate upnpreplyparse.c code with "make check" - -2013/05/03: - Fix Solaris build thanks to Maciej Małecki - -2013/04/27: - Fix testminiwget.sh for BSD - -2013/03/23: - Fixed Makefile for *BSD - -2013/03/11: - Update Makefile to use JNAerator version 0.11 - -2013/02/11: - Fix testminiwget.sh for use with dash - Use $(DESTDIR) in Makefile - -VERSION 1.8 : released 2013/02/06 - -2012/10/16: - fix testminiwget with no IPv6 support - -2012/09/27: - Rename all include guards to not clash with C99 - (7.1.3 Reserved identifiers). - -2012/08/30: - Added -e option to upnpc program (set description for port mappings) - -2012/08/29: - Python 3 support (thanks to Christopher Foo) - -2012/08/11: - Fix a memory link in UPNP_GetValidIGD() - Try to handle scope id in link local IPv6 URL under MS Windows - -2012/07/20: - Disable HAS_IP_MREQN on DragonFly BSD - -2012/06/28: - GetUPNPUrls() now inserts scope into link-local IPv6 addresses - -2012/06/23: - More error return checks in upnpc.c - #define MINIUPNPC_GET_SRC_ADDR enables receivedata() to get scope_id - parseURL() now parses IPv6 addresses scope - new parameter for miniwget() : IPv6 address scope - increment API_VERSION to 9 - -2012/06/20: - fixed CMakeLists.txt - -2012/05/29 - Improvements in testminiwget.sh - -VERSION 1.7 : released 2012/05/24 - -2012/05/01: - Cleanup settings of CFLAGS in Makefile - Fix signed/unsigned integer comparaisons - -2012/04/20: - Allow to specify protocol with TCP or UDP for -A option - -2012/04/09: - Only try to fetch XML description once in UPNP_GetValidIGD() - Added -ansi flag to compilation, and fixed C++ comments to ANSI C comments. - -2012/04/05: - minor improvements to minihttptestserver.c - -2012/03/15: - upnperrors.c returns valid error string for unrecognized error codes - -2012/03/08: - make minihttptestserver listen on loopback interface instead of 0.0.0.0 - -2012/01/25: - Maven installation thanks to Alexey Kuznetsov - -2012/01/21: - Replace WIN32 macro by _WIN32 - -2012/01/19: - Fixes in java wrappers thanks to Alexey Kuznetsov : - https://github.com/axet/miniupnp/tree/fix-javatest/miniupnpc - Make and install .deb packages (python) thanks to Alexey Kuznetsov : - https://github.com/axet/miniupnp/tree/feature-debbuild/miniupnpc - -2012/01/07: - The multicast interface can now be specified by name with IPv4. - -2012/01/02: - Install man page - -2011/11/25: - added header to Port Mappings list in upnpc.c - -2011/10/09: - Makefile : make clean now removes jnaerator generated files. - MINIUPNPC_VERSION in miniupnpc.h (updated by make) - -2011/09/12: - added rootdescURL to UPNPUrls structure. - -VERSION 1.6 : released 2011/07/25 - -2011/07/25: - Update doc for version 1.6 release - -2011/06/18: - Fix for windows in miniwget.c - -2011/06/04: - display remote host in port mapping listing - -2011/06/03: - Fix in make install : there were missing headers - -2011/05/26: - Fix the socket leak in miniwget thanks to Richard Marsh. - Permit to add leaseduration in -a command. Display lease duration. - -2011/05/15: - Try both LinkLocal and SiteLocal multicast address for SSDP in IPv6 - -2011/05/09: - add a test in testminiwget.sh. - more error checking in miniwget.c - -2011/05/06: - Adding some tool to test and validate miniwget.c - simplified and debugged miniwget.c - -2011/04/11: - moving ReceiveData() to a receivedata.c file. - parsing presentation url - adding IGD v2 WANIPv6FirewallControl commands - -2011/04/10: - update of miniupnpcmodule.c - comments in miniwget.c, update in testminiwget - Adding errors codes from IGD v2 - new functions in upnpc.c for IGD v2 - -2011/04/09: - Support for litteral ip v6 address in miniwget - -2011/04/08: - Adding support for urn:schemas-upnp-org:service:WANIPv6FirewallControl:1 - Updating APIVERSION - Supporting IPV6 in upnpDiscover() - Adding a -6 option to upnpc command line tool - -2011/03/18: - miniwget/parseURL() : return an error when url param is null. - fixing GetListOfPortMappings() - -2011/03/14: - upnpDiscover() now reporting an error code. - improvements in comments. - -2011/03/11: - adding miniupnpcstrings.h.cmake and CMakeLists.txt files. - -2011/02/15: - Implementation of GetListOfPortMappings() - -2011/02/07: - updates to minixml to support character data starting with spaces - minixml now support CDATA - upnpreplyparse treats specificaly - change in simpleUPnPcommand to return the buffer (simplification) - -2011/02/06: - Added leaseDuration argument to AddPortMapping() - Starting to implement GetListOfPortMappings() - -2011/01/11: - updating wingenminiupnpcstrings.c - -2011/01/04: - improving updateminiupnpcstrings.sh - -VERSION 1.5 : released 2011/01/01 - -2010/12/21: - use NO_GETADDRINFO macro to disable the use of getaddrinfo/freeaddrinfo - -2010/12/11: - Improvements on getHTTPResponse() code. - -2010/12/09: - new code for miniwget that handle Chunked transfer encoding - using getHTTPResponse() in SOAP call code - Adding MANIFEST.in for 'python setup.py bdist_rpm' - -2010/11/25: - changes to minissdpc.c to compile under Win32. - see http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=729 - -2010/09/17: - Various improvement to Makefile from Michał Górny - -2010/08/05: - Adding the script "external-ip.sh" from Reuben Hawkins - -2010/06/09: - update to python module to match modification made on 2010/04/05 - update to Java test code to match modification made on 2010/04/05 - all UPNP_* function now return an error if the SOAP request failed - at HTTP level. - -2010/04/17: - Using GetBestRoute() under win32 in order to find the - right interface to use. - -2010/04/12: - Retrying with HTTP/1.1 if HTTP/1.0 failed. see - http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1703 - -2010/04/07: - avoid returning duplicates in upnpDiscover() - -2010/04/05: - Create a connecthostport.h/.c with connecthostport() function - and use it in miniwget and miniupnpc. - Use getnameinfo() instead of inet_ntop or inet_ntoa - Work to make miniupnpc IPV6 compatible... - Add java test code. - Big changes in order to support device having both WANIPConnection - and WANPPPConnection. - -2010/04/04: - Use getaddrinfo() instead of gethostbyname() in miniwget. - -2010/01/06: - #define _DARWIN_C_SOURCE for Mac OS X - -2009/12/19: - Improve MinGW32 build - -2009/12/11: - adding a MSVC9 project to build the static library and executable - -2009/12/10: - Fixing some compilation stuff for Windows/MinGW - -2009/12/07: - adaptations in Makefile and updateminiupnpcstring.sh for AmigaOS - some fixes for Windows when using virtual ethernet adapters (it is the - case with VMWare installed). - -2009/12/04: - some fixes for AmigaOS compilation - Changed HTTP version to HTTP/1.0 for Soap too (to prevent chunked - transfer encoding) - -2009/12/03: - updating printIDG and testigddescparse.c for debug. - modifications to compile under AmigaOS - adding a testminiwget program - Changed miniwget to advertise itself as HTTP/1.0 to prevent chunked - transfer encoding - -2009/11/26: - fixing updateminiupnpcstrings.sh to take into account - which command that does not return an error code. - -VERSION 1.4 : released 2009/10/30 - -2009/10/16: - using Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS in python module. - -2009/10/10: - Some fixes for compilation under Solaris - compilation fixes : http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1464 - -2009/09/21: - fixing the code to ignore EINTR during connect() calls. - -2009/08/07: - Set socket timeout for connect() - Some cleanup in miniwget.c - -2009/08/04: - remove multiple redirections with -d in upnpc.c - Print textual error code in upnpc.c - Ignore EINTR during the connect() and poll() calls. - -2009/07/29: - fix in updateminiupnpcstrings.sh if OS name contains "/" - Sending a correct value for MX: field in SSDP request - -2009/07/20: - Change the Makefile to compile under Mac OS X - Fixed a stackoverflow in getDevicesFromMiniSSDPD() - -2009/07/09: - Compile under Haiku - generate miniupnpcstrings.h.in from miniupnpcstrings.h - -2009/06/04: - patching to compile under CygWin and cross compile for minGW - -VERSION 1.3 : - -2009/04/17: - updating python module - Use strtoull() when using C99 - -2009/02/28: - Fixed miniwget.c for compiling under sun - -2008/12/18: - cleanup in Makefile (thanks to Paul de Weerd) - minissdpc.c : win32 compatibility - miniupnpc.c : changed xmlns prefix from 'm' to 'u' - Removed NDEBUG (using DEBUG) - -2008/10/14: - Added the ExternalHost argument to DeletePortMapping() - -2008/10/11: - Added the ExternalHost argument to AddPortMapping() - Put a correct User-Agent: header in HTTP requests. - -VERSION 1.2 : - -2008/10/07: - Update docs - -2008/09/25: - Integrated sameport patch from Dario Meloni : Added a "sameport" - argument to upnpDiscover(). - -2008/07/18: - small modif to make Clang happy :) - -2008/07/17: - #define SOAPPREFIX "s" in miniupnpc.c in order to remove SOAP-ENV... - -2008/07/14: - include declspec.h in installation (to /usr/include/miniupnpc) - -VERSION 1.1 : - -2008/07/04: - standard options for install/ln instead of gnu-specific stuff. - -2008/07/03: - now builds a .dll and .lib with win32. (mingw32) - -2008/04/28: - make install now install the binary of the upnpc tool - -2008/04/27: - added testupnpigd.py - added error strings for miniupnpc "internal" errors - improved python module error/exception reporting. - -2008/04/23: - Completely rewrite igd_desc_parse.c in order to be compatible with - Linksys WAG200G - Added testigddescparse - updated python module - -VERSION 1.0 : - -2008/02/21: - put some #ifdef DEBUG around DisplayNameValueList() - -2008/02/18: - Improved error reporting in upnpcommands.c - UPNP_GetStatusInfo() returns LastConnectionError - -2008/02/16: - better error handling in minisoap.c - improving display of "valid IGD found" in upnpc.c - -2008/02/03: - Fixing UPNP_GetValidIGD() - improved make install :) - -2007/12/22: - Adding upnperrors.c/h to provide a strupnperror() function - used to translate UPnP error codes to string. - -2007/12/19: - Fixing getDevicesFromMiniSSDPD() - improved error reporting of UPnP functions - -2007/12/18: - It is now possible to specify a different location for MiniSSDPd socket. - working with MiniSSDPd is now more efficient. - python module improved. - -2007/12/16: - improving error reporting - -2007/12/13: - Try to improve compatibility by using HTTP/1.0 instead of 1.1 and - XML a bit different for SOAP. - -2007/11/25: - fixed select() call for linux - -2007/11/15: - Added -fPIC to CFLAG for better shared library code. - -2007/11/02: - Fixed a potential socket leak in miniwget2() - -2007/10/16: - added a parameter to upnpDiscover() in order to allow the use of another - interface than the default multicast interface. - -2007/10/12: - Fixed the creation of symbolic link in Makefile - -2007/10/08: - Added man page - -2007/10/02: - fixed memory bug in GetUPNPUrls() - -2007/10/01: - fixes in the Makefile - Added UPNP_GetIGDFromUrl() and adapted the sample program accordingly. - Added SONAME in the shared library to please debian :) - fixed MS Windows compilation (minissdpd is not available under MS Windows). - -2007/09/25: - small change to Makefile to be able to install in a different location - (default is /usr) - -2007/09/24: - now compiling both shared and static library - -2007/09/19: - Cosmetic changes on upnpc.c - -2007/09/02: - adapting to new miniSSDPd (release version ?) - -2007/08/31: - Usage of miniSSDPd to skip discovery process. - -2007/08/27: - fixed python module to allow compilation with Python older than Python 2.4 - -2007/06/12: - Added a python module. - -2007/05/19: - Fixed compilation under MinGW - -2007/05/15: - fixed a memory leak in AddPortMapping() - Added testupnpreplyparse executable to check the parsing of - upnp soap messages - minixml now ignore namespace prefixes. - -2007/04/26: - upnpc now displays external ip address with -s or -l - -2007/04/11: - changed MINIUPNPC_URL_MAXSIZE to 128 to accomodate the "BT Voyager 210" - -2007/03/19: - cleanup in miniwget.c - -2007/03/01: - Small typo fix... - -2007/01/30: - Now parsing the HTTP header from SOAP responses in order to - get content-length value. - -2007/01/29: - Fixed the Soap Query to speedup the HTTP request. - added some Win32 DLL stuff... - -2007/01/27: - Fixed some WIN32 compatibility issues - -2006/12/14: - Added UPNPIGD_IsConnected() function in miniupnp.c/.h - Added UPNP_GetValidIGD() in miniupnp.c/.h - cleaned upnpc.c main(). now using UPNP_GetValidIGD() - -2006/12/07: - Version 1.0-RC1 released - -2006/12/03: - Minor changes to compile under SunOS/Solaris - -2006/11/30: - made a minixml parser validator program - updated minixml to handle attributes correctly - -2006/11/22: - Added a -r option to the upnpc sample thanks to Alexander Hubmann. - -2006/11/19: - Cleanup code to make it more ANSI C compliant - -2006/11/10: - detect and display local lan address. - -2006/11/04: - Packets and Bytes Sent/Received are now unsigned int. - -2006/11/01: - Bug fix thanks to Giuseppe D'Angelo - -2006/10/31: - C++ compatibility for .h files. - Added a way to get ip Address on the LAN used to reach the IGD. - -2006/10/25: - Added M-SEARCH to the services in the discovery process. - -2006/10/22: - updated the Makefile to use makedepend, added a "make install" - update Makefile - -2006/10/20: - fixing the description url parsing thanks to patch sent by - Wayne Dawe. - Fixed/translated some comments. - Implemented a better discover process, first looking - for IGD then for root devices (as some devices only reply to - M-SEARCH for root devices). - -2006/09/02: - added freeUPNPDevlist() function. - -2006/08/04: - More command line arguments checking - -2006/08/01: - Added the .bat file to compile under Win32 with minGW32 - -2006/07/31: - Fixed the rootdesc parser (igd_desc_parse.c) - -2006/07/20: - parseMSEARCHReply() is now returning the ST: line as well - starting changes to detect several UPnP devices on the network - -2006/07/19: - using GetCommonLinkProperties to get down/upload bitrate - diff --git a/deps/miniupnpc/LICENSE b/deps/miniupnpc/LICENSE deleted file mode 100644 index 0816733704..0000000000 --- a/deps/miniupnpc/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -MiniUPnPc -Copyright (c) 2005-2016, 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. - diff --git a/deps/miniupnpc/MANIFEST.in b/deps/miniupnpc/MANIFEST.in deleted file mode 100644 index 54b86f95e3..0000000000 --- a/deps/miniupnpc/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include README -include miniupnpcmodule.c -include setup.py -include *.h -include libminiupnpc.a diff --git a/deps/miniupnpc/Makefile b/deps/miniupnpc/Makefile deleted file mode 100644 index aea07e7d52..0000000000 --- a/deps/miniupnpc/Makefile +++ /dev/null @@ -1,274 +0,0 @@ -# $Id: Makefile,v 1.134 2016/10/07 09:04:36 nanard Exp $ -# MiniUPnP Project -# http://miniupnp.free.fr/ -# http://miniupnp.tuxfamily.org/ -# https://github.com/miniupnp/miniupnp -# (c) 2005-2016 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 -ifeq ($(OS), NetBSD) -CFLAGS += -D_NETBSD_SOURCE -endif -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 - -ifeq (SunOS, $(OS)) - LDLIBS=-lsocket -lnsl -lresolv - CFLAGS += -D__EXTENSIONS__ - CFLAGS += -std=c99 -endif - -# APIVERSION is used to build SONAME -APIVERSION = 16 - -SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \ - upnpcommands.c upnpreplyparse.c \ - minixmlvalid.c minissdpc.c \ - upnperrors.c \ - connecthostport.c portlistingparse.c receivedata.c \ - upnpdev.c miniupnpcmodule.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) -ifeq (,$(findstring CYGWIN,$(OS))) -CFLAGS := -fPIC $(CFLAGS) -endif -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 - -ifneq ($(OS), AmigaOS) -EXECUTABLES := $(EXECUTABLES) upnpc-shared -endif - -LIBDIR ?= lib -# install directories -ifeq ($(strip $(PREFIX)),) -INSTALLPREFIX ?= /usr -else -INSTALLPREFIX ?= $(PREFIX) -endif -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 \ - updateversion -# validateminixml validateminiwget - -all: $(LIBRARY) $(EXECUTABLES) - -test: check - -check: validateminixml validateminiwget validateupnpreplyparse \ - validateportlistingparse validateigddescparse - -everything: all - -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 - -distclean: clean - -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: $(LIBRARY) - $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) - -upnpc-shared: $(SHAREDLIBRARY) - $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) - -minixmlvalid: minixml.o minixmlvalid.o - -miniupnpcstrings.h: miniupnpcstrings.h.in updateminiupnpcstrings.sh VERSION - $(SH) updateminiupnpcstrings.sh - -# 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 -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 -minixmlvalid.o: minixml.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 -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: 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 diff --git a/deps/miniupnpc/README b/deps/miniupnpc/README deleted file mode 100644 index 91535dbc8b..0000000000 --- a/deps/miniupnpc/README +++ /dev/null @@ -1,64 +0,0 @@ -Project: miniupnp -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-2016 Thomas Bernard -This software is subject to the conditions detailed in the -LICENSE file provided within this distribution. - - -* miniUPnP Client - miniUPnPc * - -To compile, simply run 'gmake' (could be 'make' on your system). -Under win32, to compile with MinGW, type "mingw32make.bat". -MS Visual C solution and project files are supplied in the msvc/ subdirectory. - -The compilation is known to work under linux, FreeBSD, -OpenBSD, MacOS X, AmigaOS and cygwin. -The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3. -upx (http://upx.sourceforge.net) is used to compress the win32 .exe files. - -To install the library and headers on the system use : -> su -> make install -> exit - -alternatively, to install into a specific location, use : -> INSTALLPREFIX=/usr/local make install - -upnpc.c is a sample client using the libminiupnpc. -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() -- UPNP_* (calling UPNP methods) - -Note : use #include etc... for the includes -and -lminiupnpc for the link - -Discovery process is speeded up when MiniSSDPd is running on the machine. - - -* Python module * - -you can build a python module with 'make pythonmodule' -and install it with 'make installpythonmodule'. -setup.py (and setupmingw32.py) are included in the distribution. - - -Feel free to contact me if you have any problem : -e-mail : miniupnp@free.fr - -If you are using libminiupnpc in your application, please -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 diff --git a/deps/miniupnpc/VERSION b/deps/miniupnpc/VERSION deleted file mode 100644 index cd5ac039d6..0000000000 --- a/deps/miniupnpc/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.0 diff --git a/deps/miniupnpc/apiversions.txt b/deps/miniupnpc/apiversions.txt deleted file mode 100644 index 9464a86759..0000000000 --- a/deps/miniupnpc/apiversions.txt +++ /dev/null @@ -1,172 +0,0 @@ -$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 - any other value between 2 and 65535 - Existing programs should be compatible - updated macro : - #define MINIUPNPC_API_VERSION 15 - -API version 14 -miniupnpc.h - add ttl argument to upnpDiscover() upnpDiscoverAll() upnpDiscoverDevice() - upnpDiscoverDevices() - getDevicesFromMiniSSDPD() : - connectToMiniSSDPD() / disconnectFromMiniSSDPD() - requestDevicesFromMiniSSDPD() / receiveDevicesFromMiniSSDPD() - updated macro : - #define MINIUPNPC_API_VERSION 14 - -API version 13 -miniupnpc.h: - add searchalltype param to upnpDiscoverDevices() function - updated macro : - #define MINIUPNPC_API_VERSION 13 - -API version 12 -miniupnpc.h : - add upnpDiscoverAll() / upnpDiscoverDevice() / upnpDiscoverDevices() - functions - updated macros : - #define MINIUPNPC_API_VERSION 12 - -API version 11 - -upnpreplyparse.h / portlistingparse.h : - removed usage of sys/queue.h / bsdqueue.h - -miniupnpc.h: - updated macros : - #define MINIUPNPC_API_VERSION 11 - -====================== miniUPnPc version 1.9 ====================== -API version 10 - -upnpcommands.h: - added argument remoteHost to UPNP_GetSpecificPortMappingEntry() - -miniupnpc.h: - updated macros : - #define MINIUPNPC_VERSION "1.9" - #define MINIUPNPC_API_VERSION 10 - -====================== miniUPnPc version 1.8 ====================== -API version 9 - -miniupnpc.h: - updated macros : - #define MINIUPNPC_VERSION "1.8" - #define MINIUPNPC_API_VERSION 9 - added "unsigned int scope_id;" to struct UPNPDev - added scope_id argument to GetUPNPUrls() - - - -====================== miniUPnPc version 1.7 ====================== -API version 8 - -miniupnpc.h : - add new macros : - #define MINIUPNPC_VERSION "1.7" - #define MINIUPNPC_API_VERSION 8 - add rootdescURL to struct UPNPUrls - - - -====================== miniUPnPc version 1.6 ====================== -API version 8 - -Adding support for IPv6. -igd_desc_parse.h : - struct IGDdatas_service : - add char presentationurl[MINIUPNPC_URL_MAXSIZE]; - struct IGDdatas : - add struct IGDdatas_service IPv6FC; -miniupnpc.h : - new macros : - #define UPNPDISCOVER_SUCCESS (0) - #define UPNPDISCOVER_UNKNOWN_ERROR (-1) - #define UPNPDISCOVER_SOCKET_ERROR (-101) - #define UPNPDISCOVER_MEMORY_ERROR (-102) - simpleUPnPcommand() prototype changed (but is normaly not used by API users) - add arguments ipv6 and error to upnpDiscover() : - struct UPNPDev * - upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock, int sameport, - int ipv6, - int * error); - add controlURL_6FC member to struct UPNPUrls : - struct UPNPUrls { - char * controlURL; - char * ipcondescURL; - char * controlURL_CIF; - char * controlURL_6FC; - }; - -upnpcommands.h : - add leaseDuration argument to UPNP_AddPortMapping() - add desc, enabled and leaseDuration arguments to UPNP_GetSpecificPortMappingEntry() - add UPNP_GetListOfPortMappings() function (IGDv2) - add IGDv2 IPv6 related functions : - UPNP_GetFirewallStatus() - UPNP_GetOutboundPinholeTimeout() - UPNP_AddPinhole() - UPNP_UpdatePinhole() - UPNP_DeletePinhole() - UPNP_CheckPinholeWorking() - UPNP_GetPinholePackets() - - - -====================== miniUPnPc version 1.5 ====================== -API version 5 - -new function : -int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); -new macro in upnpcommands.h : -#define UPNPCOMMAND_HTTP_ERROR - -====================== miniUPnPc version 1.4 ====================== -Same API as version 1.3 - -====================== miniUPnPc version 1.3 ====================== -API version 4 - -Use UNSIGNED_INTEGER type for -UPNP_GetTotalBytesSent(), UPNP_GetTotalBytesReceived(), -UPNP_GetTotalPacketsSent(), UPNP_GetTotalPacketsReceived() -Add remoteHost argument to UPNP_AddPortMapping() and UPNP_DeletePortMapping() - -====================== miniUPnPc version 1.2 ====================== -API version 3 - -added sameport argument to upnpDiscover() -struct UPNPDev * -upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock, int sameport); - -====================== miniUPnPc Version 1.1 ====================== -Same API as 1.0 - - -====================== miniUPnPc Version 1.0 ====================== -API version 2 - - -struct UPNPDev { - struct UPNPDev * pNext; - char * descURL; - char * st; - char buffer[2]; -}; -struct UPNPDev * upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock); - diff --git a/deps/miniupnpc/codelength.h b/deps/miniupnpc/codelength.h deleted file mode 100644 index ea0b005ffe..0000000000 --- a/deps/miniupnpc/codelength.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $Id: codelength.h,v 1.3 2011/07/30 13:10:05 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas BERNARD - * copyright (c) 2005-2015 Thomas Bernard - * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ -#ifndef CODELENGTH_H_INCLUDED -#define CODELENGTH_H_INCLUDED - -/* Encode length by using 7bit per Byte : - * Most significant bit of each byte specifies that the - * following byte is part of the code */ - -/* n : unsigned - * p : unsigned char * - */ -#define DECODELENGTH(n, p) n = 0; \ - do { n = (n << 7) | (*p & 0x7f); } \ - while((*(p++)&0x80) && (n<(1<<25))); - -/* n : unsigned - * READ : function/macro to read one byte (unsigned char) - */ -#define DECODELENGTH_READ(n, READ) \ - n = 0; \ - do { \ - unsigned char c; \ - READ(c); \ - n = (n << 7) | (c & 0x07f); \ - if(!(c&0x80)) break; \ - } while(n<(1<<25)); - -/* n : unsigned - * p : unsigned char * - * p_limit : unsigned char * - */ -#define DECODELENGTH_CHECKLIMIT(n, p, p_limit) \ - n = 0; \ - do { \ - if((p) >= (p_limit)) break; \ - n = (n << 7) | (*(p) & 0x7f); \ - } while((*((p)++)&0x80) && (n<(1<<25))); - - -/* n : unsigned - * p : unsigned char * - */ -#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ - if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ - if(n>=16384) *(p++) = (n >> 14) | 0x80; \ - if(n>=128) *(p++) = (n >> 7) | 0x80; \ - *(p++) = n & 0x7f; - -#endif /* CODELENGTH_H_INCLUDED */ diff --git a/deps/miniupnpc/connecthostport.c b/deps/miniupnpc/connecthostport.c deleted file mode 100644 index 06cba434ef..0000000000 --- a/deps/miniupnpc/connecthostport.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2010-2016 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. */ - -/* use getaddrinfo() or gethostbyname() - * uncomment the following line in order to use gethostbyname() */ -#ifdef NO_GETADDRINFO -#define USE_GETHOSTBYNAME -#endif - -#include -#include -#ifdef _WIN32 -#include -#include -#include -#define MAXHOSTNAMELEN 64 -#define snprintf _snprintf -#define herror -#define socklen_t int -#else /* #ifdef _WIN32 */ -#include -#include -#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT -#include -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ -#include -#include -#include -#ifndef closesocket -#define closesocket close -#endif -#include -#include -/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions - * during the connect() call */ -#define MINIUPNPC_IGNORE_EINTR -#ifndef USE_GETHOSTBYNAME -#include -#include -#endif /* #ifndef USE_GETHOSTBYNAME */ -#endif /* #else _WIN32 */ - -#if defined(__amigaos__) || defined(__amigaos4__) -#define herror(A) printf("%s\n", A) -#endif - -#include - -#include "connecthostport.h" - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -/* connecthostport() - * return a socket connected (TCP) to the host and port - * or -1 in case of error */ -int connecthostport(const char * host, unsigned short port, - unsigned int scope_id) -{ - int s, n; -#ifdef USE_GETHOSTBYNAME - struct sockaddr_in dest; - struct hostent *hp; -#else /* #ifdef USE_GETHOSTBYNAME */ - char tmp_host[MAXHOSTNAMELEN+1]; - char port_str[8]; - struct addrinfo *ai, *p; - struct addrinfo hints; -#endif /* #ifdef USE_GETHOSTBYNAME */ -#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT - struct timeval timeout; -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - -#ifdef USE_GETHOSTBYNAME - hp = gethostbyname(host); - if(hp == NULL) - { - herror(host); - return -1; - } - memcpy(&dest.sin_addr, hp->h_addr, sizeof(dest.sin_addr)); - memset(dest.sin_zero, 0, sizeof(dest.sin_zero)); - s = socket(PF_INET, SOCK_STREAM, 0); - if(s < 0) - return -1; -#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT - /* setting a 3 seconds timeout for the connect() call */ - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) - { - } - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0) - { - } -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - dest.sin_family = AF_INET; - dest.sin_port = htons(port); - n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in)); -#ifdef MINIUPNPC_IGNORE_EINTR - /* EINTR The system call was interrupted by a signal that was caught - * EINPROGRESS The socket is nonblocking and the connection cannot - * be completed immediately. */ - while(n < 0 && (errno == EINTR || errno == EINPROGRESS)) - { - socklen_t len; - fd_set wset; - int err; - FD_ZERO(&wset); - FD_SET(s, &wset); - if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) - continue; - /*len = 0;*/ - /*n = getpeername(s, NULL, &len);*/ - len = sizeof(err); - if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { - closesocket(s); - return -1; - } - if(err != 0) { - errno = err; - n = -1; - } - } -#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */ - if(n<0) - { - closesocket(s); - return -1; - } -#else /* #ifdef USE_GETHOSTBYNAME */ - /* use getaddrinfo() instead of gethostbyname() */ - memset(&hints, 0, sizeof(hints)); - /* hints.ai_flags = AI_ADDRCONFIG; */ -#ifdef AI_NUMERICSERV - hints.ai_flags = AI_NUMERICSERV; -#endif - hints.ai_socktype = SOCK_STREAM; - hints.ai_family = AF_UNSPEC; /* AF_INET, AF_INET6 or AF_UNSPEC */ - /* hints.ai_protocol = IPPROTO_TCP; */ - snprintf(port_str, sizeof(port_str), "%hu", port); - if(host[0] == '[') - { - /* literal ip v6 address */ - int i, j; - for(i = 0, j = 1; host[j] && (host[j] != ']') && i < MAXHOSTNAMELEN; i++, j++) - { - tmp_host[i] = host[j]; - if(0 == memcmp(host+j, "%25", 3)) /* %25 is just url encoding for '%' */ - j+=2; /* skip "25" */ - } - tmp_host[i] = '\0'; - } - else - { - strncpy(tmp_host, host, MAXHOSTNAMELEN); - } - tmp_host[MAXHOSTNAMELEN] = '\0'; - n = getaddrinfo_retro(tmp_host, port_str, &hints, &ai); - if(n != 0) - { -#ifdef _WIN32 - fprintf(stderr, "getaddrinfo() error : %d\n", n); -#else - fprintf(stderr, "getaddrinfo() error : %s\n", gai_strerror(n)); -#endif - return -1; - } - s = -1; - for(p = ai; p; p = p->ai_next) - { - s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - if(s < 0) - continue; - if(p->ai_addr->sa_family == AF_INET6 && scope_id > 0) { - struct sockaddr_in6 * addr6 = (struct sockaddr_in6 *)p->ai_addr; - addr6->sin6_scope_id = scope_id; - } -#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT - /* setting a 3 seconds timeout for the connect() call */ - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(struct timeval)) < 0) - { - } - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (const char *)&timeout, sizeof(struct timeval)) < 0) - { - } -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - n = connect(s, p->ai_addr, p->ai_addrlen); -#ifdef MINIUPNPC_IGNORE_EINTR - /* EINTR The system call was interrupted by a signal that was caught - * EINPROGRESS The socket is nonblocking and the connection cannot - * be completed immediately. */ - while(n < 0 && (errno == EINTR || errno == EINPROGRESS)) - { - socklen_t len; - fd_set wset; - int err; - FD_ZERO(&wset); - FD_SET(s, &wset); - if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) - continue; - /*len = 0;*/ - /*n = getpeername(s, NULL, &len);*/ - len = sizeof(err); - if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { - closesocket(s); - freeaddrinfo(ai); - return -1; - } - if(err != 0) { - errno = err; - n = -1; - } - } -#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */ - if(n < 0) - { - closesocket(s); - continue; - } - else - { - break; - } - } - freeaddrinfo(ai); - if(s < 0) - return -1; - if(n < 0) - return -1; -#endif /* #ifdef USE_GETHOSTBYNAME */ - return s; -} - diff --git a/deps/miniupnpc/connecthostport.h b/deps/miniupnpc/connecthostport.h deleted file mode 100644 index f3b2d2a842..0000000000 --- a/deps/miniupnpc/connecthostport.h +++ /dev/null @@ -1,18 +0,0 @@ -/* $Id: connecthostport.h,v 1.2 2012/06/23 22:32:33 nanard Exp $ */ -/* Project: miniupnp - * http://miniupnp.free.fr/ - * Author: Thomas Bernard - * Copyright (c) 2010-2012 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef CONNECTHOSTPORT_H_INCLUDED -#define CONNECTHOSTPORT_H_INCLUDED - -/* connecthostport() - * return a socket connected (TCP) to the host and port - * or -1 in case of error */ -int connecthostport(const char * host, unsigned short port, - unsigned int scope_id); - -#endif - diff --git a/deps/miniupnpc/igd_desc_parse.c b/deps/miniupnpc/igd_desc_parse.c deleted file mode 100644 index d2999ad011..0000000000 --- a/deps/miniupnpc/igd_desc_parse.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $Id: igd_desc_parse.c,v 1.17 2015/09/15 13:30:04 nanard Exp $ */ -/* Project : miniupnp - * http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2005-2015 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. */ - -#include "igd_desc_parse.h" -#include -#include - -/* Start element handler : - * update nesting level counter and copy element name */ -void IGDstartelt(void * d, const char * name, int l) -{ - struct IGDdatas * datas = (struct IGDdatas *)d; - if(l >= MINIUPNPC_URL_MAXSIZE) - l = MINIUPNPC_URL_MAXSIZE-1; - memcpy(datas->cureltname, name, l); - datas->cureltname[l] = '\0'; - datas->level++; - if( (l==7) && !memcmp(name, "service", l) ) { - datas->tmp.controlurl[0] = '\0'; - datas->tmp.eventsuburl[0] = '\0'; - datas->tmp.scpdurl[0] = '\0'; - datas->tmp.servicetype[0] = '\0'; - } -} - -#define COMPARE(str, cstr) (0==memcmp(str, cstr, sizeof(cstr) - 1)) - -/* End element handler : - * update nesting level counter and update parser state if - * service element is parsed */ -void IGDendelt(void * d, const char * name, int l) -{ - struct IGDdatas * datas = (struct IGDdatas *)d; - datas->level--; - /*printf("endelt %2d %.*s\n", datas->level, l, name);*/ - if( (l==7) && !memcmp(name, "service", l) ) - { - if(COMPARE(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) { - memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(COMPARE(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPv6FirewallControl:")) { - memcpy(&datas->IPv6FC, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(COMPARE(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPConnection:") - || COMPARE(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANPPPConnection:") ) { - if(datas->first.servicetype[0] == '\0') { - memcpy(&datas->first, &datas->tmp, sizeof(struct IGDdatas_service)); - } else { - memcpy(&datas->second, &datas->tmp, sizeof(struct IGDdatas_service)); - } - } - } -} - -/* Data handler : - * copy data depending on the current element name and state */ -void IGDdata(void * d, const char * data, int l) -{ - struct IGDdatas * datas = (struct IGDdatas *)d; - char * dstmember = 0; - /*printf("%2d %s : %.*s\n", - datas->level, datas->cureltname, l, data); */ - if( !strcmp(datas->cureltname, "URLBase") ) - dstmember = datas->urlbase; - else if( !strcmp(datas->cureltname, "presentationURL") ) - dstmember = datas->presentationurl; - else if( !strcmp(datas->cureltname, "serviceType") ) - dstmember = datas->tmp.servicetype; - else if( !strcmp(datas->cureltname, "controlURL") ) - dstmember = datas->tmp.controlurl; - else if( !strcmp(datas->cureltname, "eventSubURL") ) - dstmember = datas->tmp.eventsuburl; - else if( !strcmp(datas->cureltname, "SCPDURL") ) - dstmember = datas->tmp.scpdurl; -/* else if( !strcmp(datas->cureltname, "deviceType") ) - dstmember = datas->devicetype_tmp;*/ - if(dstmember) - { - if(l>=MINIUPNPC_URL_MAXSIZE) - l = MINIUPNPC_URL_MAXSIZE-1; - memcpy(dstmember, data, l); - dstmember[l] = '\0'; - } -} - -#ifdef DEBUG -void printIGD(struct IGDdatas * d) -{ - printf("urlbase = '%s'\n", d->urlbase); - printf("WAN Device (Common interface config) :\n"); - /*printf(" deviceType = '%s'\n", d->CIF.devicetype);*/ - printf(" serviceType = '%s'\n", d->CIF.servicetype); - printf(" controlURL = '%s'\n", d->CIF.controlurl); - printf(" eventSubURL = '%s'\n", d->CIF.eventsuburl); - printf(" SCPDURL = '%s'\n", d->CIF.scpdurl); - printf("primary WAN Connection Device (IP or PPP Connection):\n"); - /*printf(" deviceType = '%s'\n", d->first.devicetype);*/ - printf(" servicetype = '%s'\n", d->first.servicetype); - printf(" controlURL = '%s'\n", d->first.controlurl); - printf(" eventSubURL = '%s'\n", d->first.eventsuburl); - printf(" SCPDURL = '%s'\n", d->first.scpdurl); - printf("secondary WAN Connection Device (IP or PPP Connection):\n"); - /*printf(" deviceType = '%s'\n", d->second.devicetype);*/ - printf(" servicetype = '%s'\n", d->second.servicetype); - printf(" controlURL = '%s'\n", d->second.controlurl); - printf(" eventSubURL = '%s'\n", d->second.eventsuburl); - printf(" SCPDURL = '%s'\n", d->second.scpdurl); - printf("WAN IPv6 Firewall Control :\n"); - /*printf(" deviceType = '%s'\n", d->IPv6FC.devicetype);*/ - printf(" servicetype = '%s'\n", d->IPv6FC.servicetype); - printf(" controlURL = '%s'\n", d->IPv6FC.controlurl); - printf(" eventSubURL = '%s'\n", d->IPv6FC.eventsuburl); - printf(" SCPDURL = '%s'\n", d->IPv6FC.scpdurl); -} -#endif /* DEBUG */ - diff --git a/deps/miniupnpc/igd_desc_parse.h b/deps/miniupnpc/igd_desc_parse.h deleted file mode 100644 index 0de546b697..0000000000 --- a/deps/miniupnpc/igd_desc_parse.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $Id: igd_desc_parse.h,v 1.12 2014/11/17 17:19:13 nanard Exp $ */ -/* Project : miniupnp - * http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2005-2014 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ -#ifndef IGD_DESC_PARSE_H_INCLUDED -#define IGD_DESC_PARSE_H_INCLUDED - -/* Structure to store the result of the parsing of UPnP - * descriptions of Internet Gateway Devices */ -#define MINIUPNPC_URL_MAXSIZE (128) -struct IGDdatas_service { - char controlurl[MINIUPNPC_URL_MAXSIZE]; - char eventsuburl[MINIUPNPC_URL_MAXSIZE]; - char scpdurl[MINIUPNPC_URL_MAXSIZE]; - char servicetype[MINIUPNPC_URL_MAXSIZE]; - /*char devicetype[MINIUPNPC_URL_MAXSIZE];*/ -}; - -struct IGDdatas { - char cureltname[MINIUPNPC_URL_MAXSIZE]; - char urlbase[MINIUPNPC_URL_MAXSIZE]; - char presentationurl[MINIUPNPC_URL_MAXSIZE]; - int level; - /*int state;*/ - /* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */ - struct IGDdatas_service CIF; - /* "urn:schemas-upnp-org:service:WANIPConnection:1" - * "urn:schemas-upnp-org:service:WANPPPConnection:1" */ - struct IGDdatas_service first; - /* if both WANIPConnection and WANPPPConnection are present */ - struct IGDdatas_service second; - /* "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1" */ - struct IGDdatas_service IPv6FC; - /* tmp */ - struct IGDdatas_service tmp; -}; - -void IGDstartelt(void *, const char *, int); -void IGDendelt(void *, const char *, int); -void IGDdata(void *, const char *, int); -#ifdef DEBUG -void printIGD(struct IGDdatas *); -#endif /* DEBUG */ - -#endif /* IGD_DESC_PARSE_H_INCLUDED */ diff --git a/deps/miniupnpc/minisoap.c b/deps/miniupnpc/minisoap.c deleted file mode 100644 index 694b2dbecd..0000000000 --- a/deps/miniupnpc/minisoap.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $Id: minisoap.c,v 1.23 2014/11/04 22:31:55 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005-2015 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * - * Minimal SOAP implementation for UPnP protocol. - */ -#include -#include -#ifdef _WIN32 -#include -#include -#define snprintf _snprintf -#else -#include -#include -#include -#endif -#include "minisoap.h" -#include "miniupnpcstrings.h" - -/* only for malloc */ -#include - -/* httpWrite sends the headers and the body to the socket - * and returns the number of bytes sent */ -static int -httpWrite(int fd, const char * body, int bodysize, - const char * headers, int headerssize) -{ - int n = 0; - /*n = write(fd, headers, headerssize);*/ - /*if(bodysize>0) - n += write(fd, body, bodysize);*/ - /* Note : my old linksys router only took into account - * soap request that are sent into only one packet */ - char * p; - /* TODO: AVOID MALLOC, we could use writev() for that */ - p = (char*)malloc(headerssize+bodysize); - if(!p) - return -1; - memcpy(p, headers, headerssize); - memcpy(p+headerssize, body, bodysize); - /*n = write(fd, p, headerssize+bodysize);*/ - n = (int)send(fd, p, headerssize+bodysize, 0); - /* disable send on the socket */ - /* draytek routers dont seems to like that... */ - free(p); - return n; -} - -/* self explanatory */ -int soapPostSubmit(int fd, - const char * url, - const char * host, - unsigned short port, - const char * action, - const char * body, - const char * httpversion) -{ - int bodysize; - char headerbuf[512]; - int headerssize; - char portstr[8]; - bodysize = (int)strlen(body); - /* We are not using keep-alive HTTP connections. - * HTTP/1.1 needs the header Connection: close to do that. - * This is the default with HTTP/1.0 - * Using HTTP/1.1 means we need to support chunked transfer-encoding : - * When using HTTP/1.1, the router "BiPAC 7404VNOX" always use chunked - * transfer encoding. */ - /* Connection: Close is normally there only in HTTP/1.1 but who knows */ - portstr[0] = '\0'; - if(port != 80) - snprintf(portstr, sizeof(portstr), ":%hu", port); - headerssize = snprintf(headerbuf, sizeof(headerbuf), - "POST %s HTTP/%s\r\n" - "Host: %s%s\r\n" - "User-Agent: " OS_STRING ", " UPNP_VERSION_STRING ", MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" - "Content-Length: %d\r\n" - "Content-Type: text/xml\r\n" - "SOAPAction: \"%s\"\r\n" - "Connection: Close\r\n" - "Cache-Control: no-cache\r\n" /* ??? */ - "Pragma: no-cache\r\n" - "\r\n", - url, httpversion, host, portstr, bodysize, action); - if ((unsigned int)headerssize >= sizeof(headerbuf)) - return -1; -#ifdef DEBUG - /*printf("SOAP request : headersize=%d bodysize=%d\n", - headerssize, bodysize); - */ - printf("SOAP request : POST %s HTTP/%s - Host: %s%s\n", - url, httpversion, host, portstr); - printf("SOAPAction: \"%s\" - Content-Length: %d\n", action, bodysize); - printf("Headers :\n%s", headerbuf); - printf("Body :\n%s\n", body); -#endif - return httpWrite(fd, body, bodysize, headerbuf, headerssize); -} - - diff --git a/deps/miniupnpc/minisoap.h b/deps/miniupnpc/minisoap.h deleted file mode 100644 index 60554f5c39..0000000000 --- a/deps/miniupnpc/minisoap.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. */ -#ifndef MINISOAP_H_INCLUDED -#define MINISOAP_H_INCLUDED - -/*int httpWrite(int, const char *, int, const char *);*/ -int soapPostSubmit(int, const char *, const char *, unsigned short, - const char *, const char *, const char *); - -#endif - diff --git a/deps/miniupnpc/minissdpc.c b/deps/miniupnpc/minissdpc.c deleted file mode 100644 index 2a526d04e8..0000000000 --- a/deps/miniupnpc/minissdpc.c +++ /dev/null @@ -1,864 +0,0 @@ -/* $Id: minissdpc.c,v 1.32 2016/10/07 09:04:36 nanard Exp $ */ -/* vim: tabstop=4 shiftwidth=4 noexpandtab - * Project : miniupnp - * Web : http://miniupnp.free.fr/ - * Author : Thomas BERNARD - * copyright (c) 2005-2017 Thomas Bernard - * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ -/*#include */ -#include -#include -#include -#include -#if defined (__NetBSD__) -#include -#endif -#if defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__) -#ifdef _WIN32 -#include -#include -#include -#include -#include -#define snprintf _snprintf -#if !defined(_MSC_VER) -#include -#else /* !defined(_MSC_VER) */ -typedef unsigned short uint16_t; -#endif /* !defined(_MSC_VER) */ -#ifndef strncasecmp -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define strncasecmp _memicmp -#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#define strncasecmp memicmp -#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#endif /* #ifndef strncasecmp */ -#endif /* _WIN32 */ -#if defined(__amigaos__) || defined(__amigaos4__) -#include -#endif /* defined(__amigaos__) || defined(__amigaos4__) */ -#if defined(__amigaos__) -#define uint16_t unsigned short -#endif /* defined(__amigaos__) */ -/* Hack */ -#define UNIX_PATH_LEN 108 -struct sockaddr_un { - uint16_t sun_family; - char sun_path[UNIX_PATH_LEN]; -}; -#else /* defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__) */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef closesocket -#define closesocket close -#endif -#endif - -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) && !defined(__HAIKU__) -#define HAS_IP_MREQN -#endif - -#if !defined(HAS_IP_MREQN) && !defined(_WIN32) -#include -#if defined(__sun) || defined(__HAIKU__) -#include -#endif -#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 */ -struct ip_mreqn -{ - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_address; /* local IP address of interface */ - int imr_ifindex; /* Interface index */ -}; -#endif - -#if defined(__amigaos__) || defined(__amigaos4__) -/* Amiga OS specific stuff */ -#define TIMEVAL struct timeval -#endif - -#include "minissdpc.h" -#include "miniupnpc.h" -#include "receivedata.h" - -#include - -#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) - -#include "codelength.h" - -struct UPNPDev * -getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error) -{ - struct UPNPDev * devlist = NULL; - int s; - int res; - - s = connectToMiniSSDPD(socketpath); - if (s < 0) { - if (error) - *error = s; - return NULL; - } - res = requestDevicesFromMiniSSDPD(s, devtype); - if (res < 0) { - if (error) - *error = res; - } else { - devlist = receiveDevicesFromMiniSSDPD(s, error); - } - disconnectFromMiniSSDPD(s); - return devlist; -} - -/* macros used to read from unix socket */ -#define READ_BYTE_BUFFER(c) \ - if((int)bufferindex >= n) { \ - n = read(s, buffer, sizeof(buffer)); \ - if(n<=0) break; \ - bufferindex = 0; \ - } \ - c = buffer[bufferindex++]; - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif /* MIN */ - -#define READ_COPY_BUFFER(dst, len) \ - for(l = len, p = (unsigned char *)dst; l > 0; ) { \ - unsigned int lcopy; \ - if((int)bufferindex >= n) { \ - n = read(s, buffer, sizeof(buffer)); \ - if(n<=0) break; \ - bufferindex = 0; \ - } \ - lcopy = (unsigned int)MIN(l, (n - bufferindex)); \ - memcpy(p, buffer + bufferindex, lcopy); \ - l -= lcopy; \ - p += lcopy; \ - bufferindex += lcopy; \ - } - -#define READ_DISCARD_BUFFER(len) \ - for(l = len; l > 0; ) { \ - unsigned int lcopy; \ - if(bufferindex >= n) { \ - n = read(s, buffer, sizeof(buffer)); \ - if(n<=0) break; \ - bufferindex = 0; \ - } \ - lcopy = MIN(l, (n - bufferindex)); \ - l -= lcopy; \ - bufferindex += lcopy; \ - } - -int -connectToMiniSSDPD(const char * socketpath) -{ - int s; - struct sockaddr_un addr; -#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun) - struct timeval timeout; -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - - s = socket(AF_UNIX, SOCK_STREAM, 0); - if(s < 0) - { - /*syslog(LOG_ERR, "socket(unix): %m");*/ - perror("socket(unix)"); - return MINISSDPC_SOCKET_ERROR; - } -#if defined(MINIUPNPC_SET_SOCKET_TIMEOUT) && !defined(__sun) - /* setting a 3 seconds timeout */ - /* not supported for AF_UNIX sockets under Solaris */ - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) - { - perror("setsockopt SO_RCVTIMEO unix"); - } - timeout.tv_sec = 3; - timeout.tv_usec = 0; - if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0) - { - perror("setsockopt SO_SNDTIMEO unix"); - } -#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - if(!socketpath) - socketpath = "/var/run/minissdpd.sock"; - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path)); - /* TODO : check if we need to handle the EINTR */ - if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) - { - /*syslog(LOG_WARNING, "connect(\"%s\"): %m", socketpath);*/ - close(s); - return MINISSDPC_SOCKET_ERROR; - } - return s; -} - -int -disconnectFromMiniSSDPD(int s) -{ - if (close(s) < 0) - return MINISSDPC_SOCKET_ERROR; - return MINISSDPC_SUCCESS; -} - -int -requestDevicesFromMiniSSDPD(int s, const char * devtype) -{ - unsigned char buffer[256]; - unsigned char * p; - unsigned int l; - unsigned stsize = (unsigned)strlen(devtype); - if(stsize == 8 && 0 == memcmp(devtype, "ssdp:all", 8)) - { - buffer[0] = 3; /* request type 3 : everything */ - } - else - { - buffer[0] = 1; /* request type 1 : request devices/services by type */ - } - p = buffer + 1; - l = stsize; CODELENGTH(l, p); - if(p + stsize > buffer + sizeof(buffer)) - { - /* devtype is too long ! */ -#ifdef DEBUG - fprintf(stderr, "devtype is too long ! stsize=%u sizeof(buffer)=%u\n", - stsize, (unsigned)sizeof(buffer)); -#endif /* DEBUG */ - return MINISSDPC_INVALID_INPUT; - } - memcpy(p, devtype, stsize); - p += stsize; - if(write(s, buffer, p - buffer) < 0) - { - /*syslog(LOG_ERR, "write(): %m");*/ - perror("minissdpc.c: write()"); - return MINISSDPC_SOCKET_ERROR; - } - return MINISSDPC_SUCCESS; -} - -struct UPNPDev * -receiveDevicesFromMiniSSDPD(int s, int * error) -{ - struct UPNPDev * tmp; - struct UPNPDev * devlist = NULL; - unsigned char buffer[256]; - ssize_t n; - unsigned char * p; - unsigned char * url; - unsigned char * st; - unsigned int bufferindex; - unsigned int i, ndev; - unsigned int urlsize, stsize, usnsize, l; - - n = read(s, buffer, sizeof(buffer)); - if(n<=0) - { - perror("minissdpc.c: read()"); - if (error) - *error = MINISSDPC_SOCKET_ERROR; - return NULL; - } - ndev = buffer[0]; - bufferindex = 1; - for(i = 0; i < ndev; i++) - { - DECODELENGTH_READ(urlsize, READ_BYTE_BUFFER); - if(n<=0) { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - return devlist; - } -#ifdef DEBUG - printf(" urlsize=%u", urlsize); -#endif /* DEBUG */ - url = (unsigned char*)malloc(urlsize); - if(url == NULL) - { - if (error) - *error = MINISSDPC_MEMORY_ERROR; - return devlist; - } - READ_COPY_BUFFER(url, urlsize); - if(n<=0) - { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - goto free_url_and_return; - } - DECODELENGTH_READ(stsize, READ_BYTE_BUFFER); - if(n<=0) - { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - goto free_url_and_return; - } -#ifdef DEBUG - printf(" stsize=%u", stsize); -#endif /* DEBUG */ - st = (unsigned char*)malloc(stsize); - if (st == NULL) { - if (error) - *error = MINISSDPC_MEMORY_ERROR; - goto free_url_and_return; - } - READ_COPY_BUFFER(st, stsize); - if(n<=0) { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - goto free_url_and_st_and_return; - } - DECODELENGTH_READ(usnsize, READ_BYTE_BUFFER); - if(n<=0) { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - goto free_url_and_st_and_return; - } -#ifdef DEBUG - printf(" usnsize=%u\n", usnsize); -#endif /* DEBUG */ - tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize+usnsize); - if(tmp == NULL) { - if (error) - *error = MINISSDPC_MEMORY_ERROR; - goto free_url_and_st_and_return; - } - tmp->pNext = devlist; - tmp->descURL = tmp->buffer; - tmp->st = tmp->buffer + 1 + urlsize; - memcpy(tmp->buffer, url, urlsize); - tmp->buffer[urlsize] = '\0'; - memcpy(tmp->st, st, stsize); - tmp->buffer[urlsize+1+stsize] = '\0'; - free(url); - free(st); - url = NULL; - st = NULL; - tmp->usn = tmp->buffer + 1 + urlsize + 1 + stsize; - READ_COPY_BUFFER(tmp->usn, usnsize); - if(n<=0) { - if (error) - *error = MINISSDPC_INVALID_SERVER_REPLY; - goto free_tmp_and_return; - } - tmp->buffer[urlsize+1+stsize+1+usnsize] = '\0'; - tmp->scope_id = 0; /* default value. scope_id is not available with MiniSSDPd */ - devlist = tmp; - } - if (error) - *error = MINISSDPC_SUCCESS; - return devlist; - -free_url_and_st_and_return: - free(st); -free_url_and_return: - free(url); - return devlist; - -free_tmp_and_return: - free(tmp); - return devlist; -} - -#endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) */ - -/* parseMSEARCHReply() - * the last 4 arguments are filled during the parsing : - * - location/locationsize : "location:" field of the SSDP reply packet - * - st/stsize : "st:" field of the SSDP reply packet. - * The strings are NOT null terminated */ -static void -parseMSEARCHReply(const char * reply, int size, - const char * * location, int * locationsize, - const char * * st, int * stsize, - const char * * usn, int * usnsize) -{ - int a, b, i; - i = 0; - a = i; /* start of the line */ - b = 0; /* end of the "header" (position of the colon) */ - while(isin6_family = AF_INET6; - if(localport > 0 && localport < 65536) - p->sin6_port = htons((unsigned short)localport); - p->sin6_addr = in6addr_any; /* in6addr_any is not available with MinGW32 3.4.2 */ - } else { - struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_r; - p->sin_family = AF_INET; - if(localport > 0 && localport < 65536) - p->sin_port = htons((unsigned short)localport); - p->sin_addr.s_addr = INADDR_ANY; - } -#ifdef _WIN32 -/* This code could help us to use the right Network interface for - * SSDP multicast traffic */ -/* Get IP associated with the index given in the ip_forward struct - * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */ - if(!ipv6 - && (GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR)) { - DWORD dwRetVal = 0; - PMIB_IPADDRTABLE pIPAddrTable; - DWORD dwSize = 0; -#ifdef DEBUG - IN_ADDR IPAddr; -#endif - int i; -#ifdef DEBUG - printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop); -#endif - pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE)); - if(pIPAddrTable) { - if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { - free(pIPAddrTable); - pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize); - } - } - if(pIPAddrTable) { - dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 ); - if (dwRetVal == NO_ERROR) { -#ifdef DEBUG - printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries); -#endif - for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) { -#ifdef DEBUG - printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex); - IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr; - printf("\tIP Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); - IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask; - printf("\tSubnet Mask[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); - IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr; - printf("\tBroadCast[%d]: \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr); - printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize); - printf("\tType and State[%d]:", i); - printf("\n"); -#endif - if (pIPAddrTable->table[i].dwIndex == ip_forward.dwForwardIfIndex) { - /* Set the address of this interface to be used */ - struct in_addr mc_if; - memset(&mc_if, 0, sizeof(mc_if)); - mc_if.s_addr = pIPAddrTable->table[i].dwAddr; - setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)); - ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = pIPAddrTable->table[i].dwAddr; -#ifndef DEBUG - break; -#endif - } - } - } - free(pIPAddrTable); - pIPAddrTable = NULL; - } - } -#endif /* _WIN32 */ - -#ifdef _WIN32 - if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0) -#else - if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)) < 0) -#endif - { - if(error) - *error = MINISSDPC_SOCKET_ERROR; - closesocket(sudp); - return NULL; - } - -#ifdef _WIN32 - if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, (const char *)&_ttl, sizeof(_ttl)) < 0) -#else /* _WIN32 */ - if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) -#endif /* _WIN32 */ - { - /* not a fatal error */ - } - - if(multicastif) - { - if(ipv6) { -#if !defined(_WIN32) - /* according to MSDN, if_nametoindex() is supported since - * MS Windows Vista and MS Windows Server 2008. - * http://msdn.microsoft.com/en-us/library/bb408409%28v=vs.85%29.aspx */ - unsigned int ifindex = if_nametoindex(multicastif); /* eth0, etc. */ - if(setsockopt(sudp, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex)) < 0) - { - } -#else -#ifdef DEBUG - printf("Setting of multicast interface not supported in IPv6 under Windows.\n"); -#endif -#endif - } else { - struct in_addr mc_if; - mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */ - if(mc_if.s_addr != INADDR_NONE) - { - ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr; - if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0) - { - } - } else { -#ifdef HAS_IP_MREQN - /* was not an ip address, try with an interface name */ - struct ip_mreqn reqn; /* only defined with -D_BSD_SOURCE or -D_GNU_SOURCE */ - memset(&reqn, 0, sizeof(struct ip_mreqn)); - reqn.imr_ifindex = if_nametoindex(multicastif); - if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&reqn, sizeof(reqn)) < 0) - { - } -#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) - { - } - 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) - { - } -#else /* _WIN32 */ -#ifdef DEBUG - printf("Setting of multicast interface not supported with interface name.\n"); -#endif -#endif /* #ifdef HAS_IP_MREQN / !defined(_WIN32) */ - } - } - } - - /* Before sending the packed, we first "bind" in order to be able - * to receive the response */ - if (bind(sudp, (const struct sockaddr *)&sockudp_r, - ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) != 0) - { - if(error) - *error = MINISSDPC_SOCKET_ERROR; - closesocket(sudp); - return NULL; - } - - if(error) - *error = MINISSDPC_SUCCESS; - /* Calculating maximum response time in seconds */ - mx = ((unsigned int)delay) / 1000u; - if(mx == 0) { - mx = 1; - delay = 1000; - } - /* receiving SSDP response packet */ - for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) { - /* sending the SSDP M-SEARCH packet */ - n = snprintf(bufr, sizeof(bufr), - MSearchMsgFmt, - ipv6 ? - (linklocal ? "[" UPNP_MCAST_LL_ADDR "]" : "[" UPNP_MCAST_SL_ADDR "]") - : UPNP_MCAST_ADDR, - deviceTypes[deviceIndex], mx); - if ((unsigned int)n >= sizeof(bufr)) { - if(error) - *error = MINISSDPC_MEMORY_ERROR; - goto error; - } -#ifdef DEBUG - /*printf("Sending %s", bufr);*/ - printf("Sending M-SEARCH request to %s with ST: %s\n", - ipv6 ? - (linklocal ? "[" UPNP_MCAST_LL_ADDR "]" : "[" UPNP_MCAST_SL_ADDR "]") - : UPNP_MCAST_ADDR, - deviceTypes[deviceIndex]); -#endif -#ifdef NO_GETADDRINFO - /* the following code is not using getaddrinfo */ - /* emission */ - memset(&sockudp_w, 0, sizeof(struct sockaddr_storage)); - if(ipv6) { - struct sockaddr_in6 * p = (struct sockaddr_in6 *)&sockudp_w; - p->sin6_family = AF_INET6; - p->sin6_port = htons(SSDP_PORT); - inet_pton(AF_INET6, - linklocal ? UPNP_MCAST_LL_ADDR : UPNP_MCAST_SL_ADDR, - &(p->sin6_addr)); - } else { - struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_w; - p->sin_family = AF_INET; - p->sin_port = htons(SSDP_PORT); - p->sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR); - } - n = sendto(sudp, bufr, n, 0, &sockudp_w, - ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)); - if (n < 0) { - if(error) - *error = MINISSDPC_SOCKET_ERROR; - break; - } -#else /* #ifdef NO_GETADDRINFO */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; /* AF_INET6 or AF_INET */ - hints.ai_socktype = SOCK_DGRAM; - /*hints.ai_flags = */ - if ((rv = getaddrinfo_retro(ipv6 - ? (linklocal ? UPNP_MCAST_LL_ADDR : UPNP_MCAST_SL_ADDR) - : UPNP_MCAST_ADDR, - XSTR(SSDP_PORT), &hints, &servinfo)) != 0) { - if(error) - *error = MINISSDPC_SOCKET_ERROR; -#ifdef _WIN32 - fprintf(stderr, "getaddrinfo() failed: %d\n", rv); -#else - fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); -#endif - break; - } - for(p = servinfo; p; p = p->ai_next) { - n = (int)sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen); - if (n < 0) { -#ifdef DEBUG - char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; - if (getnameinfo(p->ai_addr, p->ai_addrlen, hbuf, sizeof(hbuf), sbuf, - sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) { - fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf); - } -#endif - continue; - } - } - freeaddrinfo(servinfo); - if(n < 0) { - if(error) - *error = MINISSDPC_SOCKET_ERROR; - break; - } -#endif /* #ifdef NO_GETADDRINFO */ - /* Waiting for SSDP REPLY packet to M-SEARCH - * if searchalltypes is set, enter the loop only - * when the last deviceType is reached */ - if(!searchalltypes || !deviceTypes[deviceIndex + 1]) do { - n = receivedata(sudp, bufr, sizeof(bufr), delay, &scope_id); - if (n < 0) { - /* error */ - if(error) - *error = MINISSDPC_SOCKET_ERROR; - goto error; - } else if (n == 0) { - /* no data or Time Out */ -#ifdef DEBUG - printf("NODATA or TIMEOUT\n"); -#endif /* DEBUG */ - if (devlist && !searchalltypes) { - /* found some devices, stop now*/ - if(error) - *error = MINISSDPC_SUCCESS; - goto error; - } - } else { - const char * descURL=NULL; - int urlsize=0; - const char * st=NULL; - int stsize=0; - const char * usn=NULL; - int usnsize=0; - parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize, &usn, &usnsize); - if(st&&descURL) { -#ifdef DEBUG - printf("M-SEARCH Reply:\n ST: %.*s\n USN: %.*s\n Location: %.*s\n", - stsize, st, usnsize, (usn?usn:""), urlsize, descURL); -#endif /* DEBUG */ - for(tmp=devlist; tmp; tmp = tmp->pNext) { - if(memcmp(tmp->descURL, descURL, urlsize) == 0 && - tmp->descURL[urlsize] == '\0' && - memcmp(tmp->st, st, stsize) == 0 && - tmp->st[stsize] == '\0' && - (usnsize == 0 || memcmp(tmp->usn, usn, usnsize) == 0) && - tmp->usn[usnsize] == '\0') - break; - } - /* at the exit of the loop above, tmp is null if - * no duplicate device was found */ - if(tmp) - continue; - tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize+usnsize); - if(!tmp) { - /* memory allocation error */ - if(error) - *error = MINISSDPC_MEMORY_ERROR; - goto error; - } - tmp->pNext = devlist; - tmp->descURL = tmp->buffer; - tmp->st = tmp->buffer + 1 + urlsize; - tmp->usn = tmp->st + 1 + stsize; - memcpy(tmp->buffer, descURL, urlsize); - tmp->buffer[urlsize] = '\0'; - memcpy(tmp->st, st, stsize); - tmp->buffer[urlsize+1+stsize] = '\0'; - if(usn != NULL) - memcpy(tmp->usn, usn, usnsize); - tmp->buffer[urlsize+1+stsize+1+usnsize] = '\0'; - tmp->scope_id = scope_id; - devlist = tmp; - } - } - } while(n > 0); - if(ipv6) { - /* switch linklocal flag */ - if(linklocal) { - linklocal = 0; - --deviceIndex; - } else { - linklocal = 1; - } - } - } -error: - closesocket(sudp); - return devlist; -} - diff --git a/deps/miniupnpc/minissdpc.h b/deps/miniupnpc/minissdpc.h deleted file mode 100644 index 167d897cb6..0000000000 --- a/deps/miniupnpc/minissdpc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $Id: minissdpc.h,v 1.6 2015/09/18 12:45:16 nanard Exp $ */ -/* Project: miniupnp - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * Author: Thomas Bernard - * Copyright (c) 2005-2015 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef MINISSDPC_H_INCLUDED -#define MINISSDPC_H_INCLUDED - -#include "miniupnpc_declspec.h" -#include "upnpdev.h" - -/* error codes : */ -#define MINISSDPC_SUCCESS (0) -#define MINISSDPC_UNKNOWN_ERROR (-1) -#define MINISSDPC_SOCKET_ERROR (-101) -#define MINISSDPC_MEMORY_ERROR (-102) -#define MINISSDPC_INVALID_INPUT (-103) -#define MINISSDPC_INVALID_SERVER_REPLY (-104) - -#ifdef __cplusplus -extern "C" { -#endif - -#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) - -MINIUPNP_LIBSPEC struct UPNPDev * -getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error); - -MINIUPNP_LIBSPEC int -connectToMiniSSDPD(const char * socketpath); - -MINIUPNP_LIBSPEC int -disconnectFromMiniSSDPD(int fd); - -MINIUPNP_LIBSPEC int -requestDevicesFromMiniSSDPD(int fd, const char * devtype); - -MINIUPNP_LIBSPEC struct UPNPDev * -receiveDevicesFromMiniSSDPD(int fd, int * error); - -#endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) */ - -MINIUPNP_LIBSPEC struct UPNPDev * -ssdpDiscoverDevices(const char * const deviceTypes[], - int delay, const char * multicastif, - int localport, - int ipv6, unsigned char ttl, - int * error, - int searchalltypes); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/deps/miniupnpc/miniupnpc.c b/deps/miniupnpc/miniupnpc.c deleted file mode 100644 index 3ed02b7a7a..0000000000 --- a/deps/miniupnpc/miniupnpc.c +++ /dev/null @@ -1,724 +0,0 @@ -/* $Id: miniupnpc.c,v 1.148 2016/01/24 17:24:36 nanard Exp $ */ -/* vim: tabstop=4 shiftwidth=4 noexpandtab - * Project : miniupnp - * Web : http://miniupnp.free.fr/ - * Author : Thomas BERNARD - * copyright (c) 2005-2016 Thomas Bernard - * This software is subjet to the conditions detailed in the - * provided LICENSE file. */ -#include -#include -#include -#ifdef _WIN32 -/* Win32 Specific includes and defines */ -#include -#include -#include -#include -#define snprintf _snprintf -#define strdup _strdup -#ifndef strncasecmp -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define strncasecmp _memicmp -#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#define strncasecmp memicmp -#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#endif /* #ifndef strncasecmp */ -#define MAXHOSTNAMELEN 64 -#else /* #ifdef _WIN32 */ -/* Standard POSIX includes */ -#include -#if defined(__amigaos__) && !defined(__amigaos4__) -/* Amiga OS 3 specific stuff */ -#define socklen_t int -#else -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#if !defined(__amigaos__) && !defined(__amigaos4__) -#include -#endif -#include -#include -#ifndef closesocket -#define closesocket close -#endif -#endif /* #else _WIN32 */ -#ifdef __GNU__ -#define MAXHOSTNAMELEN 64 -#endif - - -#include "miniupnpc.h" -#include "minissdpc.h" -#include "miniwget.h" -#include "minisoap.h" -#include "minixml.h" -#include "upnpcommands.h" -#include "connecthostport.h" - -/* compare the begining of a string with a constant string */ -#define COMPARE(str, cstr) (0==memcmp(str, cstr, sizeof(cstr) - 1)) - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#define SOAPPREFIX "s" -#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) -{ - struct xmlparser parser; - /* xmlparser object */ - parser.xmlstart = buffer; - parser.xmlsize = bufsize; - parser.data = data; - parser.starteltfunc = IGDstartelt; - parser.endeltfunc = IGDendelt; - parser.datafunc = IGDdata; - parser.attfunc = 0; - parsexml(&parser); -#ifdef DEBUG - printIGD(data); -#endif -} - -/* simpleUPnPcommand2 : - * not so simple ! - * return values : - * pointer - OK - * NULL - error */ -char * simpleUPnPcommand2(int s, const char * url, const char * service, - const char * action, struct UPNParg * args, - int * bufsize, const char * httpversion) -{ - char hostname[MAXHOSTNAMELEN+1]; - unsigned short port = 0; - char * path; - char soapact[128]; - char soapbody[2048]; - int soapbodylen; - char * buf; - int n; - int status_code; - - *bufsize = 0; - snprintf(soapact, sizeof(soapact), "%s#%s", service, action); - if(args==NULL) - { - soapbodylen = snprintf(soapbody, sizeof(soapbody), - "\r\n" - "<" SOAPPREFIX ":Envelope " - "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " - SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" - "<" SOAPPREFIX ":Body>" - "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">" - "" - "" - "\r\n", action, service, action); - if ((unsigned int)soapbodylen >= sizeof(soapbody)) - return NULL; - } - else - { - char * p; - const char * pe, * pv; - const char * const pend = soapbody + sizeof(soapbody); - soapbodylen = snprintf(soapbody, sizeof(soapbody), - "\r\n" - "<" SOAPPREFIX ":Envelope " - "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " - SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" - "<" SOAPPREFIX ":Body>" - "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">", - action, service); - if ((unsigned int)soapbodylen >= sizeof(soapbody)) - return NULL; - p = soapbody + soapbodylen; - while(args->elt) - { - if(p >= pend) /* check for space to write next byte */ - return NULL; - *(p++) = '<'; - - pe = args->elt; - while(p < pend && *pe) - *(p++) = *(pe++); - - if(p >= pend) /* check for space to write next byte */ - return NULL; - *(p++) = '>'; - - if((pv = args->val)) - { - while(p < pend && *pv) - *(p++) = *(pv++); - } - - if((p+2) > pend) /* check for space to write next 2 bytes */ - return NULL; - *(p++) = '<'; - *(p++) = '/'; - - pe = args->elt; - while(p < pend && *pe) - *(p++) = *(pe++); - - if(p >= pend) /* check for space to write next byte */ - return NULL; - *(p++) = '>'; - - args++; - } - if((p+4) > pend) /* check for space to write next 4 bytes */ - return NULL; - *(p++) = '<'; - *(p++) = '/'; - *(p++) = SERVICEPREFIX2; - *(p++) = ':'; - - pe = action; - while(p < pend && *pe) - *(p++) = *(pe++); - - strncpy(p, ">\r\n", - pend - p); - if(soapbody[sizeof(soapbody)-1]) /* strncpy pads buffer with 0s, so if it doesn't end in 0, could not fit full string */ - return NULL; - } - if(!parseURL(url, hostname, &port, &path, NULL)) return NULL; - if(s < 0) { - s = connecthostport(hostname, port, 0); - if(s < 0) { - /* failed to connect */ - return NULL; - } - } - - n = soapPostSubmit(s, path, hostname, port, soapact, soapbody, httpversion); - if(n<=0) { -#ifdef DEBUG - printf("Error sending SOAP request\n"); -#endif - closesocket(s); - return NULL; - } - - buf = (char*)getHTTPResponse(s, bufsize, &status_code); -#ifdef DEBUG - if(*bufsize > 0 && 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); - return buf; -} - -/* simpleUPnPcommand : - * not so simple ! - * return values : - * pointer - OK - * NULL - error */ -char * simpleUPnPcommand(int s, const char * url, const char * service, - const char * action, struct UPNParg * args, - int * bufsize) -{ - char * buf; - -#if 1 - buf = simpleUPnPcommand2(s, url, service, action, args, bufsize, "1.1"); -#else - buf = simpleUPnPcommand2(s, url, service, action, args, bufsize, "1.0"); - if (!buf || *bufsize == 0) - { -#if DEBUG - printf("Error or no result from SOAP request; retrying with HTTP/1.1\n"); -#endif - buf = simpleUPnPcommand2(s, url, service, action, args, bufsize, "1.1"); - } -#endif - return buf; -} - -/* upnpDiscoverDevices() : - * return a chained list of all devices found or NULL if - * no devices was found. - * It is up to the caller to free the chained list - * delay is in millisecond (poll). - * UDA v1.1 says : - * The TTL for the IP packet SHOULD default to 2 and - * SHOULD be configurable. */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevices(const char * const deviceTypes[], - int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error, - int searchalltypes) -{ - struct UPNPDev * tmp; - struct UPNPDev * devlist = 0; -#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) - int deviceIndex; -#endif /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ - - if(error) - *error = UPNPDISCOVER_UNKNOWN_ERROR; -#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) - /* first try to get infos from minissdpd ! */ - if(!minissdpdsock) - minissdpdsock = "/var/run/minissdpd.sock"; - for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) { - struct UPNPDev * minissdpd_devlist; - int only_rootdevice = 1; - minissdpd_devlist = getDevicesFromMiniSSDPD(deviceTypes[deviceIndex], - minissdpdsock, 0); - if(minissdpd_devlist) { -#ifdef DEBUG - printf("returned by MiniSSDPD: %s\t%s\n", - minissdpd_devlist->st, minissdpd_devlist->descURL); -#endif /* DEBUG */ - if(!strstr(minissdpd_devlist->st, "rootdevice")) - only_rootdevice = 0; - for(tmp = minissdpd_devlist; tmp->pNext != NULL; tmp = tmp->pNext) { -#ifdef DEBUG - printf("returned by MiniSSDPD: %s\t%s\n", - tmp->pNext->st, tmp->pNext->descURL); -#endif /* DEBUG */ - if(!strstr(tmp->st, "rootdevice")) - only_rootdevice = 0; - } - tmp->pNext = devlist; - devlist = minissdpd_devlist; - if(!searchalltypes && !only_rootdevice) - break; - } - } - for(tmp = devlist; tmp != NULL; tmp = tmp->pNext) { - /* We return what we have found if it was not only a rootdevice */ - if(!strstr(tmp->st, "rootdevice")) { - if(error) - *error = UPNPDISCOVER_SUCCESS; - return devlist; - } - } -#endif /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ - - /* direct discovery if minissdpd responses are not sufficient */ - { - struct UPNPDev * discovered_devlist; - discovered_devlist = ssdpDiscoverDevices(deviceTypes, delay, multicastif, localport, - ipv6, ttl, error, searchalltypes); - if(devlist == NULL) - devlist = discovered_devlist; - else { - for(tmp = devlist; tmp->pNext != NULL; tmp = tmp->pNext); - tmp->pNext = discovered_devlist; - } - } - return devlist; -} - -/* upnpDiscover() Discover IGD device */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error) -{ - static const char * const deviceList[] = { -#if 0 - "urn:schemas-upnp-org:device:InternetGatewayDevice:2", - "urn:schemas-upnp-org:service:WANIPConnection:2", -#endif - "urn:schemas-upnp-org:device:InternetGatewayDevice:1", - "urn:schemas-upnp-org:service:WANIPConnection:1", - "urn:schemas-upnp-org:service:WANPPPConnection:1", - "upnp:rootdevice", - /*"ssdp:all",*/ - 0 - }; - return upnpDiscoverDevices(deviceList, - delay, multicastif, minissdpdsock, localport, - ipv6, ttl, error, 0); -} - -/* upnpDiscoverAll() Discover all UPnP devices */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverAll(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error) -{ - static const char * const deviceList[] = { - /*"upnp:rootdevice",*/ - "ssdp:all", - 0 - }; - return upnpDiscoverDevices(deviceList, - delay, multicastif, minissdpdsock, localport, - ipv6, ttl, error, 0); -} - -/* upnpDiscoverDevice() Discover a specific device */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevice(const char * device, int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error) -{ - const char * const deviceList[] = { - device, - 0 - }; - return upnpDiscoverDevices(deviceList, - delay, multicastif, minissdpdsock, localport, - ipv6, ttl, error, 0); -} - -static char * -build_absolute_url(const char * baseurl, const char * descURL, - const char * url, unsigned int scope_id) -{ - int l, n; - char * s; - const char * base; - char * p; -#if defined(IF_NAMESIZE) && !defined(_WIN32) - char ifname[IF_NAMESIZE]; -#else /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - char scope_str[8]; -#endif /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - - if( (url[0] == 'h') - &&(url[1] == 't') - &&(url[2] == 't') - &&(url[3] == 'p') - &&(url[4] == ':') - &&(url[5] == '/') - &&(url[6] == '/')) - return strdup(url); - base = (baseurl[0] == '\0') ? descURL : baseurl; - n = (int)strlen(base); - if(n > 7) { - p = (char*)strchr(base + 7, '/'); - if(p) - n = (int)(p - base); - } - l = (int)(n + strlen(url) + 1); - if(url[0] != '/') - l++; - if(scope_id != 0) { -#if defined(IF_NAMESIZE) && !defined(_WIN32) - if(if_indextoname(scope_id, ifname)) { - l += 3 + strlen(ifname); /* 3 == strlen(%25) */ - } -#else /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - /* under windows, scope is numerical */ - l += 3 + snprintf(scope_str, sizeof(scope_str), "%u", scope_id); -#endif /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - } - s = (char*)malloc(l); - if(s == NULL) return NULL; - memcpy(s, base, n); - if(scope_id != 0) { - s[n] = '\0'; - if(0 == memcmp(s, "http://[fe80:", 13)) { - /* this is a linklocal IPv6 address */ - p = strchr(s, ']'); - if(p) { - /* insert %25 into URL */ -#if defined(IF_NAMESIZE) && !defined(_WIN32) - memmove(p + 3 + strlen(ifname), p, strlen(p) + 1); - memcpy(p, "%25", 3); - memcpy(p + 3, ifname, strlen(ifname)); - n += 3 + strlen(ifname); -#else /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - memmove(p + 3 + strlen(scope_str), p, strlen(p) + 1); - memcpy(p, "%25", 3); - memcpy(p + 3, scope_str, strlen(scope_str)); - n += 3 + strlen(scope_str); -#endif /* defined(IF_NAMESIZE) && !defined(_WIN32) */ - } - } - } - if(url[0] != '/') - s[n++] = '/'; - memcpy(s + n, url, l - n); - return s; -} - -/* Prepare the Urls for usage... - */ -MINIUPNP_LIBSPEC void -GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, - const char * descURL, unsigned int scope_id) -{ - /* strdup descURL */ - urls->rootdescURL = strdup(descURL); - - /* get description of WANIPConnection */ - urls->ipcondescURL = build_absolute_url(data->urlbase, descURL, - data->first.scpdurl, scope_id); - urls->controlURL = build_absolute_url(data->urlbase, descURL, - data->first.controlurl, scope_id); - urls->controlURL_CIF = build_absolute_url(data->urlbase, descURL, - data->CIF.controlurl, scope_id); - urls->controlURL_6FC = build_absolute_url(data->urlbase, descURL, - data->IPv6FC.controlurl, scope_id); - -#ifdef DEBUG - printf("urls->ipcondescURL='%s'\n", urls->ipcondescURL); - printf("urls->controlURL='%s'\n", urls->controlURL); - printf("urls->controlURL_CIF='%s'\n", urls->controlURL_CIF); - printf("urls->controlURL_6FC='%s'\n", urls->controlURL_6FC); -#endif -} - -MINIUPNP_LIBSPEC void -FreeUPNPUrls(struct UPNPUrls * urls) -{ - if(!urls) - return; - free(urls->controlURL); - urls->controlURL = 0; - free(urls->ipcondescURL); - urls->ipcondescURL = 0; - free(urls->controlURL_CIF); - urls->controlURL_CIF = 0; - free(urls->controlURL_6FC); - urls->controlURL_6FC = 0; - free(urls->rootdescURL); - urls->rootdescURL = 0; -} - -int -UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data) -{ - char status[64]; - unsigned int uptime; - status[0] = '\0'; - UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype, - status, &uptime, NULL); - if(0 == strcmp("Connected", status)) - return 1; - else if(0 == strcmp("Up", status)) /* Also accept "Up" */ - return 1; - else - return 0; -} - - -/* UPNP_GetValidIGD() : - * return values : - * -1 = Internal error - * 0 = NO IGD found - * 1 = A valid connected IGD has been found - * 2 = A valid IGD has been found but it reported as - * not connected - * 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. Dont forget to call FreeUPNPUrls(urls) to - * free allocated memory. - */ -MINIUPNP_LIBSPEC int -UPNP_GetValidIGD(struct UPNPDev * devlist, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen) -{ - struct xml_desc { - char * xml; - int size; - int is_igd; - } * desc = NULL; - struct UPNPDev * dev; - int ndev = 0; - int i; - 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 - printf("Empty devlist\n"); -#endif - return 0; - } - /* counting total number of devices in the list */ - for(dev = devlist; dev; dev = dev->pNext) - ndev++; - if(ndev > 0) - { - desc = (struct xml_desc*)calloc(ndev, sizeof(struct xml_desc)); - if(!desc) - return -1; /* memory allocation error */ - } - /* Step 1 : downloading descriptions and testing type */ - for(dev = devlist, i = 0; dev; dev = dev->pNext, i++) - { - /* we should choose an internet gateway device. - * with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */ - desc[i].xml = (char*)miniwget_getaddr(dev->descURL, &(desc[i].size), - myLanAddr, sizeof(myLanAddr), - dev->scope_id, &status_code); -#ifdef DEBUG - if(!desc[i].xml) - { - printf("error getting XML description %s\n", dev->descURL); - } -#endif - if(desc[i].xml) - { - memset(data, 0, sizeof(struct IGDdatas)); - memset(urls, 0, sizeof(struct UPNPUrls)); - parserootdesc(desc[i].xml, desc[i].size, data); - if(COMPARE(data->CIF.servicetype, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) - { - desc[i].is_igd = 1; - n_igd++; - if(lanaddr) - strncpy(lanaddr, myLanAddr, lanaddrlen); - } - } - } - /* iterate the list to find a device depending on state */ - for(state = 1; state <= 3; state++) - { - for(dev = devlist, i = 0; dev; dev = dev->pNext, i++) - { - if(desc[i].xml) - { - memset(data, 0, sizeof(struct IGDdatas)); - memset(urls, 0, sizeof(struct UPNPUrls)); - 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, is_connected); -#endif - /* checks that status is connected AND there is a external IP address assigned */ - 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 - printf("We tried %s, now we try %s !\n", - data->first.servicetype, data->second.servicetype); -#endif - /* swaping WANPPPConnection and WANIPConnection ! */ - memcpy(&data->tmp, &data->first, sizeof(struct IGDdatas_service)); - 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, is_connected); -#endif - 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); - } - } - memset(data, 0, sizeof(struct IGDdatas)); - } - } - } - state = 0; -free_and_return: - if(desc) { - for(i = 0; i < ndev; i++) { - if(desc[i].xml) { - free(desc[i].xml); - } - } - free(desc); - } - return state; -} - -/* UPNP_GetIGDFromUrl() - * Used when skipping the discovery process. - * return value : - * 0 - Not ok - * 1 - OK */ -int -UPNP_GetIGDFromUrl(const char * rootdescurl, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen) -{ - char * descXML; - int descXMLsize = 0; - - descXML = (char*)miniwget_getaddr(rootdescurl, &descXMLsize, - lanaddr, lanaddrlen, 0, NULL); - if(descXML) { - memset(data, 0, sizeof(struct IGDdatas)); - memset(urls, 0, sizeof(struct UPNPUrls)); - parserootdesc(descXML, descXMLsize, data); - free(descXML); - descXML = NULL; - GetUPNPUrls(urls, data, rootdescurl, 0); - return 1; - } else { - return 0; - } -} - diff --git a/deps/miniupnpc/miniupnpc.def b/deps/miniupnpc/miniupnpc.def deleted file mode 100644 index 60e0bbe423..0000000000 --- a/deps/miniupnpc/miniupnpc.def +++ /dev/null @@ -1,45 +0,0 @@ -LIBRARY -; miniupnpc library - miniupnpc - -EXPORTS -; miniupnpc - upnpDiscover - freeUPNPDevlist - parserootdesc - UPNP_GetValidIGD - UPNP_GetIGDFromUrl - GetUPNPUrls - FreeUPNPUrls -; miniwget - miniwget - miniwget_getaddr -; upnpcommands - UPNP_GetTotalBytesSent - UPNP_GetTotalBytesReceived - UPNP_GetTotalPacketsSent - UPNP_GetTotalPacketsReceived - UPNP_GetStatusInfo - UPNP_GetConnectionTypeInfo - UPNP_GetExternalIPAddress - UPNP_GetLinkLayerMaxBitRates - UPNP_AddPortMapping - UPNP_AddAnyPortMapping - UPNP_DeletePortMapping - UPNP_DeletePortMappingRange - UPNP_GetPortMappingNumberOfEntries - UPNP_GetSpecificPortMappingEntry - UPNP_GetGenericPortMappingEntry - UPNP_GetListOfPortMappings - UPNP_AddPinhole - UPNP_CheckPinholeWorking - UPNP_UpdatePinhole - UPNP_GetPinholePackets - UPNP_DeletePinhole - UPNP_GetFirewallStatus - UPNP_GetOutboundPinholeTimeout -; upnperrors - strupnperror -; portlistingparse - ParsePortListing - FreePortListing diff --git a/deps/miniupnpc/miniupnpc.h b/deps/miniupnpc/miniupnpc.h deleted file mode 100644 index 0b5b473295..0000000000 --- a/deps/miniupnpc/miniupnpc.h +++ /dev/null @@ -1,152 +0,0 @@ -/* $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-2016 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef MINIUPNPC_H_INCLUDED -#define MINIUPNPC_H_INCLUDED - -#include "miniupnpc_declspec.h" -#include "igd_desc_parse.h" -#include "upnpdev.h" - -/* error codes : */ -#define UPNPDISCOVER_SUCCESS (0) -#define UPNPDISCOVER_UNKNOWN_ERROR (-1) -#define UPNPDISCOVER_SOCKET_ERROR (-101) -#define UPNPDISCOVER_MEMORY_ERROR (-102) - -/* versions : */ -#define MINIUPNPC_VERSION "2.0" -#define MINIUPNPC_API_VERSION 16 - -/* Source port: - Using "1" as an alias for 1900 for backwards compatability - (presuming one would have used that for the "sameport" parameter) */ -#define UPNP_LOCAL_PORT_ANY 0 -#define UPNP_LOCAL_PORT_SAME 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* Structures definitions : */ -struct UPNParg { const char * elt; const char * val; }; - -char * -simpleUPnPcommand(int, const char *, const char *, - const char *, struct UPNParg *, - int *); - -/* upnpDiscover() - * discover UPnP devices on the network. - * The discovered devices are returned as a chained list. - * It is up to the caller to free the list with freeUPNPDevlist(). - * 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. - * "searchalltypes" parameter is useful when searching several types, - * if 0, the discovery will stop with the first type returning results. - * TTL should default to 2. */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverAll(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevice(const char * device, int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevices(const char * const deviceTypes[], - int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error, - int searchalltypes); - -/* parserootdesc() : - * parse root XML description of a UPnP device and fill the IGDdatas - * structure. */ -MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); - -/* structure used to get fast access to urls - * controlURL: controlURL of the WANIPConnection - * ipcondescURL: url of the description of the WANIPConnection - * controlURL_CIF: controlURL of the WANCommonInterfaceConfig - * controlURL_6FC: controlURL of the WANIPv6FirewallControl - */ -struct UPNPUrls { - char * controlURL; - char * ipcondescURL; - char * controlURL_CIF; - char * controlURL_6FC; - char * rootdescURL; -}; - -/* UPNP_GetValidIGD() : - * return values : - * 0 = NO IGD found - * 1 = A valid connected IGD has been found - * 2 = A valid IGD has been found but it reported as - * not connected - * 3 = an UPnP device has been found but was not recognized as an IGD - * - * In any non zero return case, the urls and data structures - * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to - * free allocated memory. - */ -MINIUPNP_LIBSPEC int -UPNP_GetValidIGD(struct UPNPDev * devlist, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen); - -/* UPNP_GetIGDFromUrl() - * Used when skipping the discovery process. - * When succeding, urls, data, and lanaddr arguments are set. - * return value : - * 0 - Not ok - * 1 - OK */ -MINIUPNP_LIBSPEC int -UPNP_GetIGDFromUrl(const char * rootdescurl, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen); - -MINIUPNP_LIBSPEC void -GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, - const char *, unsigned int); - -MINIUPNP_LIBSPEC void -FreeUPNPUrls(struct UPNPUrls *); - -/* return 0 or 1 */ -MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/deps/miniupnpc/miniupnpc_declspec.h b/deps/miniupnpc/miniupnpc_declspec.h deleted file mode 100644 index e0a624d275..0000000000 --- a/deps/miniupnpc/miniupnpc_declspec.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef MINIUPNPC_DECLSPEC_H_INCLUDED -#define MINIUPNPC_DECLSPEC_H_INCLUDED - -#if defined(__GNUC__) && __GNUC__ >= 4 -/* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */ -#define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default"))) -#else -#define MINIUPNP_LIBSPEC -#endif - -#endif /* MINIUPNPC_DECLSPEC_H_INCLUDED */ - diff --git a/deps/miniupnpc/miniupnpcstrings.h b/deps/miniupnpc/miniupnpcstrings.h deleted file mode 100644 index 68bf4293df..0000000000 --- a/deps/miniupnpc/miniupnpcstrings.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $Id: miniupnpcstrings.h.in,v 1.6 2014/11/04 22:31:55 nanard Exp $ */ -/* Project: miniupnp - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * Author: Thomas Bernard - * Copyright (c) 2005-2014 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef MINIUPNPCSTRINGS_H_INCLUDED -#define MINIUPNPCSTRINGS_H_INCLUDED - -#define OS_STRING "OS/version" -#define MINIUPNPC_VERSION_STRING "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 - diff --git a/deps/miniupnpc/miniupnpctypes.h b/deps/miniupnpc/miniupnpctypes.h deleted file mode 100644 index 307ce39699..0000000000 --- a/deps/miniupnpc/miniupnpctypes.h +++ /dev/null @@ -1,19 +0,0 @@ -/* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */ -/* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org - * Author : Thomas Bernard - * Copyright (c) 2011 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided within this distribution */ -#ifndef MINIUPNPCTYPES_H_INCLUDED -#define MINIUPNPCTYPES_H_INCLUDED - -#if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) -#define UNSIGNED_INTEGER unsigned long long -#define STRTOUI strtoull -#else -#define UNSIGNED_INTEGER unsigned int -#define STRTOUI strtoul -#endif - -#endif - diff --git a/deps/miniupnpc/miniwget.c b/deps/miniupnpc/miniwget.c deleted file mode 100644 index c1d60836b3..0000000000 --- a/deps/miniupnpc/miniwget.c +++ /dev/null @@ -1,663 +0,0 @@ -/* $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-2016 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. */ - -#include -#include -#include -#include -#ifdef _WIN32 -#include -#include -#include -#define MAXHOSTNAMELEN 64 -#define snprintf _snprintf -#define socklen_t int -#ifndef strncasecmp -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define strncasecmp _memicmp -#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#define strncasecmp memicmp -#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ -#endif /* #ifndef strncasecmp */ -#else /* #ifdef _WIN32 */ -#include -#include -#if defined(__amigaos__) && !defined(__amigaos4__) -#define socklen_t int -#else /* #if defined(__amigaos__) && !defined(__amigaos4__) */ -#include -#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */ -#include -#include -#include -#include -#include -#ifndef closesocket -#define closesocket close -#endif -#include -#endif /* #else _WIN32 */ -#ifdef __GNU__ -#define MAXHOSTNAMELEN 64 -#endif /* __GNU__ */ - -#ifndef MIN -#define MIN(x,y) (((x)<(y))?(x):(y)) -#endif /* MIN */ - - -#include "miniupnpcstrings.h" -#include "miniwget.h" -#include "connecthostport.h" -#include "receivedata.h" - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -/* - * Read a HTTP response from a socket. - * Process Content-Length and Transfer-encoding headers. - * return a pointer to the content buffer, which length is saved - * to the length parameter. - */ -void * -getHTTPResponse(int s, int * size, int * status_code) -{ - char buf[2048]; - int n; - int endofheaders = 0; - int chunked = 0; - int content_length = -1; - unsigned int chunksize = 0; - unsigned int bytestocopy = 0; - /* buffers : */ - char * header_buf; - unsigned int header_buf_len = 2048; - unsigned int header_buf_used = 0; - char * content_buf; - unsigned int content_buf_len = 2048; - unsigned int content_buf_used = 0; - char chunksize_buf[32]; - unsigned int chunksize_buf_index; -#ifdef DEBUG - char * reason_phrase = NULL; - int reason_phrase_len = 0; -#endif - - if(status_code) *status_code = -1; - header_buf = (char*)malloc(header_buf_len); - if(header_buf == NULL) - { -#ifdef DEBUG - fprintf(stderr, "%s: Memory allocation error\n", "getHTTPResponse"); -#endif /* DEBUG */ - *size = -1; - return NULL; - } - content_buf = (char*)malloc(content_buf_len); - if(content_buf == NULL) - { - free(header_buf); -#ifdef DEBUG - fprintf(stderr, "%s: Memory allocation error\n", "getHTTPResponse"); -#endif /* DEBUG */ - *size = -1; - return NULL; - } - chunksize_buf[0] = '\0'; - chunksize_buf_index = 0; - - while((n = receivedata(s, buf, 2048, 5000, NULL)) > 0) - { - if(endofheaders == 0) - { - int i; - int linestart=0; - int colon=0; - int valuestart=0; - if(header_buf_used + n > header_buf_len) { - char * tmp = (char*)realloc(header_buf, header_buf_used + n); - if(tmp == NULL) { - /* memory allocation error */ - free(header_buf); - free(content_buf); - *size = -1; - return NULL; - } - header_buf = tmp; - header_buf_len = header_buf_used + n; - } - memcpy(header_buf + header_buf_used, buf, n); - header_buf_used += n; - /* search for CR LF CR LF (end of headers) - * recognize also LF LF */ - i = 0; - while(i < ((int)header_buf_used-1) && (endofheaders == 0)) { - if(header_buf[i] == '\r') { - i++; - if(header_buf[i] == '\n') { - i++; - if(i < (int)header_buf_used && header_buf[i] == '\r') { - i++; - if(i < (int)header_buf_used && header_buf[i] == '\n') { - endofheaders = i+1; - } - } - } - } else if(header_buf[i] == '\n') { - i++; - if(header_buf[i] == '\n') { - endofheaders = i+1; - } - } - i++; - } - if(endofheaders == 0) - continue; - /* parse header lines */ - for(i = 0; i < endofheaders - 1; i++) { - if(linestart > 0 && colon <= linestart && header_buf[i]==':') - { - colon = i; - while(i < (endofheaders-1) - && (header_buf[i+1] == ' ' || header_buf[i+1] == '\t')) - i++; - valuestart = i + 1; - } - /* detecting end of line */ - else if(header_buf[i]=='\r' || header_buf[i]=='\n') - { - 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 - { -#ifdef DEBUG - reason_phrase = header_buf + sp + 1; - reason_phrase_len = i - sp - 1; -#endif - 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", - colon-linestart, header_buf+linestart, - i-valuestart, header_buf+valuestart); -#endif - if(0==strncasecmp(header_buf+linestart, "content-length", colon-linestart)) - { - content_length = atoi(header_buf+valuestart); -#ifdef DEBUG - printf("Content-Length: %d\n", content_length); -#endif - } - else if(0==strncasecmp(header_buf+linestart, "transfer-encoding", colon-linestart) - && 0==strncasecmp(header_buf+valuestart, "chunked", 7)) - { -#ifdef DEBUG - printf("chunked transfer-encoding!\n"); -#endif - chunked = 1; - } - } - while((i < (int)header_buf_used) && (header_buf[i]=='\r' || header_buf[i] == '\n')) - i++; - linestart = i; - colon = linestart; - valuestart = 0; - } - } - /* copy the remaining of the received data back to buf */ - n = header_buf_used - endofheaders; - memcpy(buf, header_buf + endofheaders, n); - /* if(headers) */ - } - if(endofheaders) - { - /* content */ - if(chunked) - { - int i = 0; - while(i < n) - { - if(chunksize == 0) - { - /* reading chunk size */ - if(chunksize_buf_index == 0) { - /* skipping any leading CR LF */ - if(i= '0' - && chunksize_buf[j] <= '9') - chunksize = (chunksize << 4) + (chunksize_buf[j] - '0'); - else - chunksize = (chunksize << 4) + ((chunksize_buf[j] | 32) - 'a' + 10); - } - chunksize_buf[0] = '\0'; - chunksize_buf_index = 0; - i++; - } else { - /* not finished to get chunksize */ - continue; - } -#ifdef DEBUG - printf("chunksize = %u (%x)\n", chunksize, chunksize); -#endif - if(chunksize == 0) - { -#ifdef DEBUG - printf("end of HTTP content - %d %d\n", i, n); - /*printf("'%.*s'\n", n-i, buf+i);*/ -#endif - goto end_of_stream; - } - } - bytestocopy = ((int)chunksize < (n - i))?chunksize:(unsigned int)(n - i); - if((content_buf_used + bytestocopy) > content_buf_len) - { - char * tmp; - if(content_length >= (int)(content_buf_used + bytestocopy)) { - content_buf_len = content_length; - } else { - content_buf_len = content_buf_used + bytestocopy; - } - tmp = (char*)realloc(content_buf, content_buf_len); - if(tmp == NULL) { - /* memory allocation error */ - free(content_buf); - free(header_buf); - *size = -1; - return NULL; - } - content_buf = tmp; - } - memcpy(content_buf + content_buf_used, buf + i, bytestocopy); - content_buf_used += bytestocopy; - i += bytestocopy; - chunksize -= bytestocopy; - } - } - else - { - /* not chunked */ - if(content_length > 0 - && (int)(content_buf_used + n) > content_length) { - /* skipping additional bytes */ - n = content_length - content_buf_used; - } - if(content_buf_used + n > content_buf_len) - { - char * tmp; - if(content_length >= (int)(content_buf_used + n)) { - content_buf_len = content_length; - } else { - content_buf_len = content_buf_used + n; - } - tmp = (char*)realloc(content_buf, content_buf_len); - if(tmp == NULL) { - /* memory allocation error */ - free(content_buf); - free(header_buf); - *size = -1; - return NULL; - } - content_buf = tmp; - } - memcpy(content_buf + content_buf_used, buf, n); - content_buf_used += n; - } - } - /* use the Content-Length header value if available */ - if(content_length > 0 && (int)content_buf_used >= content_length) - { -#ifdef DEBUG - printf("End of HTTP content\n"); -#endif - break; - } - } -end_of_stream: - free(header_buf); header_buf = NULL; - *size = content_buf_used; - if(content_buf_used == 0) - { - free(content_buf); - content_buf = NULL; - } - return content_buf; -} - -/* miniwget3() : - * do all the work. - * Return NULL if something failed. */ -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, - int * status_code) -{ - char buf[2048]; - int s; - int n; - int len; - int sent; - void * content; - - *size = 0; - s = connecthostport(host, port, scope_id); - if(s < 0) - return NULL; - - /* get address for caller ! */ - if(addr_str) - { - struct sockaddr_storage saddr; - socklen_t saddrlen; - - saddrlen = sizeof(saddr); - if(getsockname(s, (struct sockaddr *)&saddr, &saddrlen) < 0) - { - perror("getsockname"); - } - else - { -#if defined(__amigaos__) && !defined(__amigaos4__) - /* using INT WINAPI WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD); - * But his function make a string with the port : nn.nn.nn.nn:port */ -/* if(WSAAddressToStringA((SOCKADDR *)&saddr, sizeof(saddr), - NULL, addr_str, (DWORD *)&addr_str_len)) - { - printf("WSAAddressToStringA() failed : %d\n", WSAGetLastError()); - }*/ - /* the following code is only compatible with ip v4 addresses */ - strncpy(addr_str, inet_ntoa(((struct sockaddr_in *)&saddr)->sin_addr), addr_str_len); -#else -#if 0 - if(saddr.sa_family == AF_INET6) { - inet_ntop(AF_INET6, - &(((struct sockaddr_in6 *)&saddr)->sin6_addr), - addr_str, addr_str_len); - } else { - inet_ntop(AF_INET, - &(((struct sockaddr_in *)&saddr)->sin_addr), - addr_str, addr_str_len); - } -#endif - /* getnameinfo return ip v6 address with the scope identifier - * such as : 2a01:e35:8b2b:7330::%4281128194 */ - n = getnameinfo((const struct sockaddr *)&saddr, saddrlen, - addr_str, addr_str_len, - NULL, 0, - NI_NUMERICHOST | NI_NUMERICSERV); - if(n != 0) { -#ifdef _WIN32 - fprintf(stderr, "getnameinfo() failed : %d\n", n); -#else - fprintf(stderr, "getnameinfo() failed : %s\n", gai_strerror(n)); -#endif - } -#endif - } -#ifdef DEBUG - printf("address miniwget : %s\n", addr_str); -#endif - } - - len = snprintf(buf, sizeof(buf), - "GET %s HTTP/%s\r\n" - "Host: %s:%d\r\n" - "Connection: Close\r\n" - "User-Agent: " OS_STRING ", " UPNP_VERSION_STRING ", MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" - - "\r\n", - path, httpversion, host, port); - if ((unsigned int)len >= sizeof(buf)) - { - closesocket(s); - return NULL; - } - sent = 0; - /* sending the HTTP request */ - while(sent < len) - { - n = (int)send(s, buf+sent, len-sent, 0); - if(n < 0) - { - perror("send"); - closesocket(s); - return NULL; - } - else - { - sent += n; - } - } - content = getHTTPResponse(s, size, status_code); - closesocket(s); - return content; -} - -/* miniwget2() : - * 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, int * status_code) -{ - char * respbuffer; - -#if 1 - respbuffer = (char*)miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.1", - scope_id, status_code); -#else - respbuffer = (char*)miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.0", - scope_id, status_code); - if (*size == 0) - { -#ifdef DEBUG - printf("Retrying with HTTP/1.1\n"); -#endif - free(respbuffer); - respbuffer = miniwget3(host, port, path, size, - addr_str, addr_str_len, "1.1", - scope_id, status_code); - } -#endif - return respbuffer; -} - - - - -/* parseURL() - * arguments : - * url : source string not modified - * hostname : hostname destination string (size of MAXHOSTNAMELEN+1) - * port : port (destination) - * path : pointer to the path part of the URL - * - * Return values : - * 0 - Failure - * 1 - Success */ -int -parseURL(const char * url, - char * hostname, unsigned short * port, - char * * path, unsigned int * scope_id) -{ - char * p1, *p2, *p3; - if(!url) - return 0; - p1 = (char*)strstr(url, "://"); - if(!p1) - return 0; - p1 += 3; - if( (url[0]!='h') || (url[1]!='t') - ||(url[2]!='t') || (url[3]!='p')) - return 0; - memset(hostname, 0, MAXHOSTNAMELEN + 1); - if(*p1 == '[') - { - /* IP v6 : http://[2a00:1450:8002::6a]/path/abc */ - char * scope; - scope = strchr(p1, '%'); - p2 = strchr(p1, ']'); - if(p2 && scope && scope < p2 && scope_id) { - /* parse scope */ -#ifdef IF_NAMESIZE - char tmp[IF_NAMESIZE]; - int l; - scope++; - /* "%25" is just '%' in URL encoding */ - if(scope[0] == '2' && scope[1] == '5') - scope += 2; /* skip "25" */ - l = (int)(p2 - scope); - if(l >= IF_NAMESIZE) - l = IF_NAMESIZE - 1; - memcpy(tmp, scope, l); - tmp[l] = '\0'; - *scope_id = if_nametoindex(tmp); - if(*scope_id == 0) { - *scope_id = (unsigned int)strtoul(tmp, NULL, 10); - } -#else - /* under windows, scope is numerical */ - char tmp[8]; - int l; - scope++; - /* "%25" is just '%' in URL encoding */ - if(scope[0] == '2' && scope[1] == '5') - scope += 2; /* skip "25" */ - l = p2 - scope; - if(l >= sizeof(tmp)) - l = sizeof(tmp) - 1; - memcpy(tmp, scope, l); - tmp[l] = '\0'; - *scope_id = (unsigned int)strtoul(tmp, NULL, 10); -#endif - } - p3 = strchr(p1, '/'); - if(p2 && p3) - { - p2++; - strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p2-p1))); - if(*p2 == ':') - { - *port = 0; - p2++; - while( (*p2 >= '0') && (*p2 <= '9')) - { - *port *= 10; - *port += (unsigned short)(*p2 - '0'); - p2++; - } - } - else - { - *port = 80; - } - *path = p3; - return 1; - } - } - p2 = strchr(p1, ':'); - p3 = strchr(p1, '/'); - if(!p3) - return 0; - if(!p2 || (p2>p3)) - { - strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p3-p1))); - *port = 80; - } - else - { - strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p2-p1))); - *port = 0; - p2++; - while( (*p2 >= '0') && (*p2 <= '9')) - { - *port *= 10; - *port += (unsigned short)(*p2 - '0'); - p2++; - } - } - *path = p3; - return 1; -} - -void * -miniwget(const char * url, int * size, - unsigned int scope_id, int * status_code) -{ - unsigned short port; - char * path; - /* protocol://host:port/chemin */ - char hostname[MAXHOSTNAMELEN+1]; - *size = 0; - if(!parseURL(url, hostname, &port, &path, &scope_id)) - return NULL; -#ifdef DEBUG - 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, status_code); -} - -void * -miniwget_getaddr(const char * url, int * size, - char * addr, int addrlen, unsigned int scope_id, - int * status_code) -{ - unsigned short port; - char * path; - /* protocol://host:port/path */ - char hostname[MAXHOSTNAMELEN+1]; - *size = 0; - if(addr) - addr[0] = '\0'; - if(!parseURL(url, hostname, &port, &path, &scope_id)) - return NULL; -#ifdef DEBUG - 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, status_code); -} - diff --git a/deps/miniupnpc/miniwget.h b/deps/miniupnpc/miniwget.h deleted file mode 100644 index 0701494d0c..0000000000 --- a/deps/miniupnpc/miniwget.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id: miniwget.h,v 1.12 2016/01/24 17:24:36 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005-2016 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ -#ifndef MINIWGET_H_INCLUDED -#define MINIWGET_H_INCLUDED - -#include "miniupnpc_declspec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -MINIUPNP_LIBSPEC void * getHTTPResponse(int s, int * size, int * status_code); - -MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int, int *); - -MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int, int *); - -int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/deps/miniupnpc/minixml.c b/deps/miniupnpc/minixml.c deleted file mode 100644 index 1f2227343c..0000000000 --- a/deps/miniupnpc/minixml.c +++ /dev/null @@ -1,229 +0,0 @@ -/* $Id: minixml.c,v 1.10 2012/03/05 19:42:47 nanard Exp $ */ -/* minixml.c : the minimum size a xml parser can be ! */ -/* Project : miniupnp - * webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * Author : Thomas Bernard - -Copyright (c) 2005-2014, 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 -#include "minixml.h" - -/* parseatt : used to parse the argument list - * return 0 (false) in case of success and -1 (true) if the end - * of the xmlbuffer is reached. */ -static int parseatt(struct xmlparser * p) -{ - const char * attname; - int attnamelen; - const char * attvalue; - int attvaluelen; - while(p->xml < p->xmlend) - { - if(*p->xml=='/' || *p->xml=='>') - return 0; - if( !IS_WHITE_SPACE(*p->xml) ) - { - char sep; - attname = p->xml; - attnamelen = 0; - while(*p->xml!='=' && !IS_WHITE_SPACE(*p->xml) ) - { - attnamelen++; p->xml++; - if(p->xml >= p->xmlend) - return -1; - } - while(*(p->xml++) != '=') - { - if(p->xml >= p->xmlend) - return -1; - } - while(IS_WHITE_SPACE(*p->xml)) - { - p->xml++; - if(p->xml >= p->xmlend) - return -1; - } - sep = *p->xml; - if(sep=='\'' || sep=='\"') - { - p->xml++; - if(p->xml >= p->xmlend) - return -1; - attvalue = p->xml; - attvaluelen = 0; - while(*p->xml != sep) - { - attvaluelen++; p->xml++; - if(p->xml >= p->xmlend) - return -1; - } - } - else - { - attvalue = p->xml; - attvaluelen = 0; - while( !IS_WHITE_SPACE(*p->xml) - && *p->xml != '>' && *p->xml != '/') - { - attvaluelen++; p->xml++; - if(p->xml >= p->xmlend) - return -1; - } - } - /*printf("%.*s='%.*s'\n", - attnamelen, attname, attvaluelen, attvalue);*/ - if(p->attfunc) - p->attfunc(p->data, attname, attnamelen, attvalue, attvaluelen); - } - p->xml++; - } - return -1; -} - -/* parseelt parse the xml stream and - * call the callback functions when needed... */ -static void parseelt(struct xmlparser * p) -{ - int i; - const char * elementname; - while(p->xml < (p->xmlend - 1)) - { - if((p->xml + 4) <= p->xmlend && (0 == memcmp(p->xml, "", 3) != 0); - p->xml += 3; - } - else if((p->xml)[0]=='<' && (p->xml)[1]!='?') - { - i = 0; elementname = ++p->xml; - while( !IS_WHITE_SPACE(*p->xml) - && (*p->xml!='>') && (*p->xml!='/') - ) - { - i++; p->xml++; - if (p->xml >= p->xmlend) - return; - /* to ignore namespace : */ - if(*p->xml==':') - { - i = 0; - elementname = ++p->xml; - } - } - if(i>0) - { - if(p->starteltfunc) - p->starteltfunc(p->data, elementname, i); - if(parseatt(p)) - return; - if(*p->xml!='/') - { - const char * data; - i = 0; data = ++p->xml; - if (p->xml >= p->xmlend) - return; - while( IS_WHITE_SPACE(*p->xml) ) - { - i++; p->xml++; - if (p->xml >= p->xmlend) - return; - } - if(memcmp(p->xml, "xml += 9; - data = p->xml; - i = 0; - while(memcmp(p->xml, "]]>", 3) != 0) - { - i++; p->xml++; - if ((p->xml + 3) >= p->xmlend) - return; - } - if(i>0 && p->datafunc) - p->datafunc(p->data, data, i); - while(*p->xml!='<') - { - p->xml++; - if (p->xml >= p->xmlend) - return; - } - } - else - { - while(*p->xml!='<') - { - i++; p->xml++; - if ((p->xml + 1) >= p->xmlend) - return; - } - if(i>0 && p->datafunc && *(p->xml + 1) == '/') - p->datafunc(p->data, data, i); - } - } - } - else if(*p->xml == '/') - { - i = 0; elementname = ++p->xml; - if (p->xml >= p->xmlend) - return; - while((*p->xml != '>')) - { - i++; p->xml++; - if (p->xml >= p->xmlend) - return; - } - if(p->endeltfunc) - p->endeltfunc(p->data, elementname, i); - p->xml++; - } - } - else - { - p->xml++; - } - } -} - -/* the parser must be initialized before calling this function */ -void parsexml(struct xmlparser * parser) -{ - parser->xml = parser->xmlstart; - parser->xmlend = parser->xmlstart + parser->xmlsize; - parseelt(parser); -} - - diff --git a/deps/miniupnpc/minixml.h b/deps/miniupnpc/minixml.h deleted file mode 100644 index 19e6f513bf..0000000000 --- a/deps/miniupnpc/minixml.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $Id: minixml.h,v 1.6 2006/11/30 11:47:21 nanard Exp $ */ -/* minimal xml parser - * - * Project : miniupnp - * Website : http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ -#ifndef MINIXML_H_INCLUDED -#define MINIXML_H_INCLUDED -#define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n')) - -/* if a callback function pointer is set to NULL, - * the function is not called */ -struct xmlparser { - const char *xmlstart; - const char *xmlend; - const char *xml; /* pointer to current character */ - int xmlsize; - void * data; - void (*starteltfunc) (void *, const char *, int); - void (*endeltfunc) (void *, const char *, int); - void (*datafunc) (void *, const char *, int); - void (*attfunc) (void *, const char *, int, const char *, int); -}; - -/* parsexml() - * the xmlparser structure must be initialized before the call - * the following structure members have to be initialized : - * xmlstart, xmlsize, data, *func - * xml is for internal usage, xmlend is computed automatically */ -void parsexml(struct xmlparser *); - -#endif - diff --git a/deps/miniupnpc/portlistingparse.c b/deps/miniupnpc/portlistingparse.c deleted file mode 100644 index de596698aa..0000000000 --- a/deps/miniupnpc/portlistingparse.c +++ /dev/null @@ -1,171 +0,0 @@ -/* $Id: portlistingparse.c,v 1.9 2015/07/15 12:41:13 nanard Exp $ */ -/* MiniUPnP project - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2011-2016 Thomas Bernard - * This software is subject to the conditions detailed - * in the LICENCE file provided within the distribution */ -#include -#include -#ifdef DEBUG -#include -#endif /* DEBUG */ -#include "portlistingparse.h" -#include "minixml.h" - -/* list of the elements */ -static const struct { - const portMappingElt code; - const char * const str; -} elements[] = { - { PortMappingEntry, "PortMappingEntry"}, - { NewRemoteHost, "NewRemoteHost"}, - { NewExternalPort, "NewExternalPort"}, - { NewProtocol, "NewProtocol"}, - { NewInternalPort, "NewInternalPort"}, - { NewInternalClient, "NewInternalClient"}, - { NewEnabled, "NewEnabled"}, - { NewDescription, "NewDescription"}, - { NewLeaseTime, "NewLeaseTime"}, - { PortMappingEltNone, NULL} -}; - -/* Helper function */ -static UNSIGNED_INTEGER -my_atoui(const char * p, int l) -{ - UNSIGNED_INTEGER r = 0; - while(l > 0 && *p) - { - if(*p >= '0' && *p <= '9') - r = r*10 + (*p - '0'); - else - break; - p++; - l--; - } - return r; -} - -/* Start element handler */ -static void -startelt(void * d, const char * name, int l) -{ - int i; - struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; - pdata->curelt = PortMappingEltNone; - for(i = 0; elements[i].str; i++) - { - if(strlen(elements[i].str) == (size_t)l && memcmp(name, elements[i].str, l) == 0) - { - pdata->curelt = elements[i].code; - break; - } - } - if(pdata->curelt == PortMappingEntry) - { - struct PortMapping * pm; - pm = (struct PortMapping*)calloc(1, sizeof(struct PortMapping)); - if(pm == NULL) - { - /* malloc error */ -#ifdef DEBUG - fprintf(stderr, "%s: error allocating memory", - "startelt"); -#endif /* DEBUG */ - return; - } - pm->l_next = pdata->l_head; /* insert in list */ - pdata->l_head = pm; - } -} - -/* End element handler */ -static void -endelt(void * d, const char * name, int l) -{ - struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; - (void)name; - (void)l; - pdata->curelt = PortMappingEltNone; -} - -/* Data handler */ -static void portlisting_data(void * d, const char * data, int l) -{ - struct PortMapping * pm; - struct PortMappingParserData * pdata = (struct PortMappingParserData *)d; - pm = pdata->l_head; - if(!pm) - return; - if(l > 63) - l = 63; - switch(pdata->curelt) - { - case NewRemoteHost: - memcpy(pm->remoteHost, data, l); - pm->remoteHost[l] = '\0'; - break; - case NewExternalPort: - pm->externalPort = (unsigned short)my_atoui(data, l); - break; - case NewProtocol: - if(l > 3) - l = 3; - memcpy(pm->protocol, data, l); - pm->protocol[l] = '\0'; - break; - case NewInternalPort: - pm->internalPort = (unsigned short)my_atoui(data, l); - break; - case NewInternalClient: - memcpy(pm->internalClient, data, l); - pm->internalClient[l] = '\0'; - break; - case NewEnabled: - pm->enabled = (unsigned char)my_atoui(data, l); - break; - case NewDescription: - memcpy(pm->description, data, l); - pm->description[l] = '\0'; - break; - case NewLeaseTime: - pm->leaseTime = my_atoui(data, l); - break; - default: - break; - } -} - - -/* Parse the PortMappingList XML document for IGD version 2 - */ -void -ParsePortListing(const char * buffer, int bufsize, - struct PortMappingParserData * pdata) -{ - struct xmlparser parser; - - memset(pdata, 0, sizeof(struct PortMappingParserData)); - /* init xmlparser */ - parser.xmlstart = buffer; - parser.xmlsize = bufsize; - parser.data = pdata; - parser.starteltfunc = startelt; - parser.endeltfunc = endelt; - parser.datafunc = portlisting_data; - parser.attfunc = 0; - parsexml(&parser); -} - -void -FreePortListing(struct PortMappingParserData * pdata) -{ - struct PortMapping * pm; - while((pm = pdata->l_head) != NULL) - { - /* remove from list */ - pdata->l_head = pm->l_next; - free(pm); - } -} - diff --git a/deps/miniupnpc/portlistingparse.h b/deps/miniupnpc/portlistingparse.h deleted file mode 100644 index e3957a3f4c..0000000000 --- a/deps/miniupnpc/portlistingparse.h +++ /dev/null @@ -1,65 +0,0 @@ -/* $Id: portlistingparse.h,v 1.10 2014/11/01 10:37:32 nanard Exp $ */ -/* MiniUPnP project - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2011-2015 Thomas Bernard - * This software is subject to the conditions detailed - * in the LICENCE file provided within the distribution */ -#ifndef PORTLISTINGPARSE_H_INCLUDED -#define PORTLISTINGPARSE_H_INCLUDED - -#include "miniupnpc_declspec.h" -/* for the definition of UNSIGNED_INTEGER */ -#include "miniupnpctypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* sample of PortMappingEntry : - - 202.233.2.1 - 2345 - TCP - 2345 - 192.168.1.137 - 1 - dooom - 345 - - */ -typedef enum { PortMappingEltNone, - PortMappingEntry, NewRemoteHost, - NewExternalPort, NewProtocol, - NewInternalPort, NewInternalClient, - NewEnabled, NewDescription, - NewLeaseTime } portMappingElt; - -struct PortMapping { - struct PortMapping * l_next; /* list next element */ - UNSIGNED_INTEGER leaseTime; - unsigned short externalPort; - unsigned short internalPort; - char remoteHost[64]; - char internalClient[64]; - char description[64]; - char protocol[4]; - unsigned char enabled; -}; - -struct PortMappingParserData { - struct PortMapping * l_head; /* list head */ - portMappingElt curelt; -}; - -MINIUPNP_LIBSPEC void -ParsePortListing(const char * buffer, int bufsize, - struct PortMappingParserData * pdata); - -MINIUPNP_LIBSPEC void -FreePortListing(struct PortMappingParserData * pdata); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/deps/miniupnpc/receivedata.c b/deps/miniupnpc/receivedata.c deleted file mode 100644 index 2189984438..0000000000 --- a/deps/miniupnpc/receivedata.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $Id: receivedata.c,v 1.7 2015/11/09 21:51:41 nanard Exp $ */ -/* Project : miniupnp - * Website : http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2011-2014 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. */ - -#include -#include -#ifdef _WIN32 -#include -#include -#else /* _WIN32 */ -#include -#if defined(__amigaos__) && !defined(__amigaos4__) -#define socklen_t int -#else /* #if defined(__amigaos__) && !defined(__amigaos4__) */ -#include -#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */ -#include -#include -#if !defined(__amigaos__) && !defined(__amigaos4__) -#include -#endif /* !defined(__amigaos__) && !defined(__amigaos4__) */ -#include -#define MINIUPNPC_IGNORE_EINTR -#endif /* _WIN32 */ - -#include "receivedata.h" - -int -receivedata(int socket, - char * data, int length, - int timeout, unsigned int * scope_id) -{ -#ifdef MINIUPNPC_GET_SRC_ADDR - struct sockaddr_storage src_addr; - socklen_t src_addr_len = sizeof(src_addr); -#endif /* MINIUPNPC_GET_SRC_ADDR */ - int n; -#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) - /* using poll */ - struct pollfd fds[1]; /* for the poll */ -#ifdef MINIUPNPC_IGNORE_EINTR - do { -#endif /* MINIUPNPC_IGNORE_EINTR */ - fds[0].fd = socket; - fds[0].events = POLLIN; - n = poll(fds, 1, timeout); -#ifdef MINIUPNPC_IGNORE_EINTR - } while(n < 0 && errno == EINTR); -#endif /* MINIUPNPC_IGNORE_EINTR */ - if(n < 0) - return -1; - /* timeout */ - if(n == 0) - return 0; -#else /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ - /* using select under _WIN32 and amigaos */ - fd_set socketSet; - TIMEVAL timeval; - FD_ZERO(&socketSet); - FD_SET(socket, &socketSet); - timeval.tv_sec = timeout / 1000; - timeval.tv_usec = (timeout % 1000) * 1000; - n = select(FD_SETSIZE, &socketSet, NULL, NULL, &timeval); - if(n < 0) - return -1; - if(n == 0) - return 0; -#endif /* !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) */ -#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); -#else /* MINIUPNPC_GET_SRC_ADDR */ - n = (int)recv(socket, data, length, 0); -#endif /* 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 - printf("scope_id=%u\n", src_addr6->sin6_scope_id); -#endif /* DEBUG */ - if(scope_id) - *scope_id = src_addr6->sin6_scope_id; - } -#endif /* MINIUPNPC_GET_SRC_ADDR */ - return n; -} - diff --git a/deps/miniupnpc/receivedata.h b/deps/miniupnpc/receivedata.h deleted file mode 100644 index cb85c33177..0000000000 --- a/deps/miniupnpc/receivedata.h +++ /dev/null @@ -1,19 +0,0 @@ -/* $Id: receivedata.h,v 1.3 2012/06/23 22:34:47 nanard Exp $ */ -/* Project: miniupnp - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * Author: Thomas Bernard - * Copyright (c) 2011-2012 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef RECEIVEDATA_H_INCLUDED -#define RECEIVEDATA_H_INCLUDED - -/* Reads data from the specified socket. - * Returns the number of bytes read if successful, zero if no bytes were - * read or if we timed out. Returns negative if there was an error. */ -int receivedata(int socket, - char * data, int length, - int timeout, unsigned int * scope_id); - -#endif - diff --git a/deps/miniupnpc/updateminiupnpcstrings.sh b/deps/miniupnpc/updateminiupnpcstrings.sh deleted file mode 100755 index dde4354a8a..0000000000 --- a/deps/miniupnpc/updateminiupnpcstrings.sh +++ /dev/null @@ -1,53 +0,0 @@ -#! /bin/sh -# $Id: updateminiupnpcstrings.sh,v 1.7 2011/01/04 11:41:53 nanard Exp $ -# project miniupnp : http://miniupnp.free.fr/ -# (c) 2009 Thomas Bernard - -FILE=miniupnpcstrings.h -TMPFILE=miniupnpcstrings.h.tmp -TEMPLATE_FILE=${FILE}.in - -# detecting the OS name and version -OS_NAME=`uname -s` -OS_VERSION=`uname -r` -if [ -f /etc/debian_version ]; then - OS_NAME=Debian - OS_VERSION=`cat /etc/debian_version` -fi -# use lsb_release (Linux Standard Base) when available -LSB_RELEASE=`which lsb_release` -if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then - OS_NAME=`${LSB_RELEASE} -i -s` - OS_VERSION=`${LSB_RELEASE} -r -s` - case $OS_NAME in - Debian) - #OS_VERSION=`${LSB_RELEASE} -c -s` - ;; - Ubuntu) - #OS_VERSION=`${LSB_RELEASE} -c -s` - ;; - esac -fi - -# on AmigaOS 3, uname -r returns "unknown", so we use uname -v -if [ "$OS_NAME" = "AmigaOS" ]; then - if [ "$OS_VERSION" = "unknown" ]; then - OS_VERSION=`uname -v` - fi -fi - -echo "Detected OS [$OS_NAME] version [$OS_VERSION]" -MINIUPNPC_VERSION=`cat VERSION` -echo "MiniUPnPc version [${MINIUPNPC_VERSION}]" - -EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|" -#echo $EXPR -test -f ${FILE}.in -echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE." -sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE - -EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|" -echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE." -sed -e "$EXPR" < $TMPFILE > $FILE -rm $TMPFILE - diff --git a/deps/miniupnpc/upnpcommands.c b/deps/miniupnpc/upnpcommands.c deleted file mode 100644 index 017c5cdce6..0000000000 --- a/deps/miniupnpc/upnpcommands.c +++ /dev/null @@ -1,1240 +0,0 @@ -/* $Id: upnpcommands.c,v 1.46 2015/07/15 12:19:00 nanard Exp $ */ -/* vim: tabstop=4 shiftwidth=4 noexpandtab - * Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005-2017 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ -#include -#include -#include -#include "upnpcommands.h" -#include "miniupnpc.h" -#include "portlistingparse.h" - -static UNSIGNED_INTEGER -my_custom_atoui(const char * s) -{ - return s ? ((UNSIGNED_INTEGER)STRTOUI(s, NULL, 0)) : 0; -} - -/* - * */ -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesSent(const char * controlURL, - const char * servicetype) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - unsigned int r = 0; - char * p; - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetTotalBytesSent", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "NewTotalBytesSent"); - r = (unsigned)my_custom_atoui(p); - ClearNameValueList(&pdata); - return r; -} - -/* - * */ -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesReceived(const char * controlURL, - const char * servicetype) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - unsigned int r = 0; - char * p; - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetTotalBytesReceived", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "NewTotalBytesReceived"); - r = (unsigned)my_custom_atoui(p); - ClearNameValueList(&pdata); - return r; -} - -/* - * */ -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsSent(const char * controlURL, - const char * servicetype) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - unsigned int r = 0; - char * p; - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetTotalPacketsSent", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "NewTotalPacketsSent"); - r = (unsigned)my_custom_atoui(p); - ClearNameValueList(&pdata); - return r; -} - -/* - * */ -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsReceived(const char * controlURL, - const char * servicetype) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - unsigned int r = 0; - char * p; - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetTotalPacketsReceived", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived"); - r = (unsigned)my_custom_atoui(p); - ClearNameValueList(&pdata); - return r; -} - -/* UPNP_GetStatusInfo() call the corresponding UPNP method - * returns the current status and uptime */ -MINIUPNP_LIBSPEC int -UPNP_GetStatusInfo(const char * controlURL, - const char * servicetype, - char * status, - unsigned int * uptime, - char * lastconnerror) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - char * p; - char * up; - char * err; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!status && !uptime) - return UPNPCOMMAND_INVALID_ARGS; - - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetStatusInfo", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; - up = GetValueFromNameValueList(&pdata, "NewUptime"); - p = GetValueFromNameValueList(&pdata, "NewConnectionStatus"); - err = GetValueFromNameValueList(&pdata, "NewLastConnectionError"); - if(p && up) - ret = UPNPCOMMAND_SUCCESS; - - if(status) { - if(p){ - strncpy(status, p, 64 ); - status[63] = '\0'; - }else - status[0]= '\0'; - } - - if(uptime) { - if(up) - sscanf(up,"%u",uptime); - else - *uptime = 0; - } - - if(lastconnerror) { - if(err) { - strncpy(lastconnerror, err, 64 ); - lastconnerror[63] = '\0'; - } else - lastconnerror[0] = '\0'; - } - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - ClearNameValueList(&pdata); - return ret; -} - -/* UPNP_GetConnectionTypeInfo() call the corresponding UPNP method - * returns the connection type */ -MINIUPNP_LIBSPEC int -UPNP_GetConnectionTypeInfo(const char * controlURL, - const char * servicetype, - char * connectionType) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - char * p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!connectionType) - return UPNPCOMMAND_INVALID_ARGS; - - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetConnectionTypeInfo", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "NewConnectionType"); - /*p = GetValueFromNameValueList(&pdata, "NewPossibleConnectionTypes");*/ - /* PossibleConnectionTypes will have several values.... */ - if(p) { - strncpy(connectionType, p, 64 ); - connectionType[63] = '\0'; - ret = UPNPCOMMAND_SUCCESS; - } else - connectionType[0] = '\0'; - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - ClearNameValueList(&pdata); - return ret; -} - -/* UPNP_GetLinkLayerMaxBitRate() call the corresponding UPNP method. - * Returns 2 values: Downloadlink bandwidth and Uplink bandwidth. - * One of the values can be null - * Note : GetLinkLayerMaxBitRates belongs to WANPPPConnection:1 only - * We can use the GetCommonLinkProperties from WANCommonInterfaceConfig:1 */ -MINIUPNP_LIBSPEC int -UPNP_GetLinkLayerMaxBitRates(const char * controlURL, - const char * servicetype, - unsigned int * bitrateDown, - unsigned int * bitrateUp) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - char * down; - char * up; - char * p; - - if(!bitrateDown && !bitrateUp) - return UPNPCOMMAND_INVALID_ARGS; - - /* shouldn't we use GetCommonLinkProperties ? */ - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetCommonLinkProperties", 0, &bufsize))) { - /*"GetLinkLayerMaxBitRates", 0, &bufsize);*/ - return UPNPCOMMAND_HTTP_ERROR; - } - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - /*down = GetValueFromNameValueList(&pdata, "NewDownstreamMaxBitRate");*/ - /*up = GetValueFromNameValueList(&pdata, "NewUpstreamMaxBitRate");*/ - down = GetValueFromNameValueList(&pdata, "NewLayer1DownstreamMaxBitRate"); - up = GetValueFromNameValueList(&pdata, "NewLayer1UpstreamMaxBitRate"); - /*GetValueFromNameValueList(&pdata, "NewWANAccessType");*/ - /*GetValueFromNameValueList(&pdata, "NewPhysicalLinkStatus");*/ - if(down && up) - ret = UPNPCOMMAND_SUCCESS; - - if(bitrateDown) { - if(down) - sscanf(down,"%u",bitrateDown); - else - *bitrateDown = 0; - } - - if(bitrateUp) { - if(up) - sscanf(up,"%u",bitrateUp); - else - *bitrateUp = 0; - } - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - ClearNameValueList(&pdata); - return ret; -} - - -/* UPNP_GetExternalIPAddress() call the corresponding UPNP method. - * if the third arg is not null the value is copied to it. - * at least 16 bytes must be available - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR Either an UPnP error code or an unknown error. - * - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - */ -MINIUPNP_LIBSPEC int -UPNP_GetExternalIPAddress(const char * controlURL, - const char * servicetype, - char * extIpAdd) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - char * p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!extIpAdd || !controlURL || !servicetype) - return UPNPCOMMAND_INVALID_ARGS; - - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetExternalIPAddress", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - /*printf("external ip = %s\n", GetValueFromNameValueList(&pdata, "NewExternalIPAddress") );*/ - p = GetValueFromNameValueList(&pdata, "NewExternalIPAddress"); - if(p) { - strncpy(extIpAdd, p, 16 ); - extIpAdd[15] = '\0'; - ret = UPNPCOMMAND_SUCCESS; - } else - extIpAdd[0] = '\0'; - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration) -{ - struct UPNParg * AddPortMappingArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!inPort || !inClient || !proto || !extPort) - return UPNPCOMMAND_INVALID_ARGS; - - AddPortMappingArgs = (struct UPNParg*)calloc(9, sizeof(struct UPNParg)); - if(AddPortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - AddPortMappingArgs[0].elt = "NewRemoteHost"; - AddPortMappingArgs[0].val = remoteHost; - AddPortMappingArgs[1].elt = "NewExternalPort"; - AddPortMappingArgs[1].val = extPort; - AddPortMappingArgs[2].elt = "NewProtocol"; - AddPortMappingArgs[2].val = proto; - AddPortMappingArgs[3].elt = "NewInternalPort"; - AddPortMappingArgs[3].val = inPort; - AddPortMappingArgs[4].elt = "NewInternalClient"; - AddPortMappingArgs[4].val = inClient; - AddPortMappingArgs[5].elt = "NewEnabled"; - AddPortMappingArgs[5].val = "1"; - AddPortMappingArgs[6].elt = "NewPortMappingDescription"; - AddPortMappingArgs[6].val = desc?desc:"libminiupnpc"; - AddPortMappingArgs[7].elt = "NewLeaseDuration"; - AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0"; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "AddPortMapping", AddPortMappingArgs, - &bufsize); - free(AddPortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - /*DisplayNameValueList(buffer, bufsize);*/ - /*buffer[bufsize] = '\0';*/ - /*puts(buffer);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) { - /*printf("AddPortMapping errorCode = '%s'\n", resVal); */ - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } else { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration, - char * reservedPort) -{ - struct UPNParg * AddPortMappingArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!inPort || !inClient || !proto || !extPort) - return UPNPCOMMAND_INVALID_ARGS; - - AddPortMappingArgs = (struct UPNParg*)calloc(9, sizeof(struct UPNParg)); - if(AddPortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - AddPortMappingArgs[0].elt = "NewRemoteHost"; - AddPortMappingArgs[0].val = remoteHost; - AddPortMappingArgs[1].elt = "NewExternalPort"; - AddPortMappingArgs[1].val = extPort; - AddPortMappingArgs[2].elt = "NewProtocol"; - AddPortMappingArgs[2].val = proto; - AddPortMappingArgs[3].elt = "NewInternalPort"; - AddPortMappingArgs[3].val = inPort; - AddPortMappingArgs[4].elt = "NewInternalClient"; - AddPortMappingArgs[4].val = inClient; - AddPortMappingArgs[5].elt = "NewEnabled"; - AddPortMappingArgs[5].val = "1"; - AddPortMappingArgs[6].elt = "NewPortMappingDescription"; - AddPortMappingArgs[6].val = desc?desc:"libminiupnpc"; - AddPortMappingArgs[7].elt = "NewLeaseDuration"; - AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0"; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "AddAnyPortMapping", AddPortMappingArgs, - &bufsize); - free(AddPortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } else { - char *p; - - p = GetValueFromNameValueList(&pdata, "NewReservedPort"); - if(p) { - strncpy(reservedPort, p, 6); - reservedPort[5] = '\0'; - ret = UPNPCOMMAND_SUCCESS; - } else { - ret = UPNPCOMMAND_INVALID_RESPONSE; - } - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto, - const char * remoteHost) -{ - /*struct NameValueParserData pdata;*/ - struct UPNParg * DeletePortMappingArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!extPort || !proto) - return UPNPCOMMAND_INVALID_ARGS; - - DeletePortMappingArgs = (struct UPNParg*)calloc(4, sizeof(struct UPNParg)); - if(DeletePortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - DeletePortMappingArgs[0].elt = "NewRemoteHost"; - DeletePortMappingArgs[0].val = remoteHost; - DeletePortMappingArgs[1].elt = "NewExternalPort"; - DeletePortMappingArgs[1].val = extPort; - DeletePortMappingArgs[2].elt = "NewProtocol"; - DeletePortMappingArgs[2].val = proto; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "DeletePortMapping", - DeletePortMappingArgs, &bufsize); - free(DeletePortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } else { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, - const char * extPortStart, const char * extPortEnd, - const char * proto, - const char * manage) -{ - struct UPNParg * DeletePortMappingArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!extPortStart || !extPortEnd || !proto || !manage) - return UPNPCOMMAND_INVALID_ARGS; - - DeletePortMappingArgs = (struct UPNParg*)calloc(5, sizeof(struct UPNParg)); - if(DeletePortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - DeletePortMappingArgs[0].elt = "NewStartPort"; - DeletePortMappingArgs[0].val = extPortStart; - DeletePortMappingArgs[1].elt = "NewEndPort"; - DeletePortMappingArgs[1].val = extPortEnd; - DeletePortMappingArgs[2].elt = "NewProtocol"; - DeletePortMappingArgs[2].val = proto; - DeletePortMappingArgs[3].elt = "NewManage"; - DeletePortMappingArgs[3].val = manage; - - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "DeletePortMappingRange", - DeletePortMappingArgs, &bufsize); - free(DeletePortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } else { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_GetGenericPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * index, - char * extPort, - char * intClient, - char * intPort, - char * protocol, - char * desc, - char * enabled, - char * rHost, - char * duration) -{ - struct NameValueParserData pdata; - struct UPNParg * GetPortMappingArgs; - char * buffer; - int bufsize; - char * p; - int r = UPNPCOMMAND_UNKNOWN_ERROR; - if(!index) - return UPNPCOMMAND_INVALID_ARGS; - intClient[0] = '\0'; - intPort[0] = '\0'; - GetPortMappingArgs = (struct UPNParg*)calloc(2, sizeof(struct UPNParg)); - if(GetPortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - GetPortMappingArgs[0].elt = "NewPortMappingIndex"; - GetPortMappingArgs[0].val = index; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetGenericPortMappingEntry", - GetPortMappingArgs, &bufsize); - free(GetPortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - p = GetValueFromNameValueList(&pdata, "NewRemoteHost"); - if(p && rHost) - { - strncpy(rHost, p, 64); - rHost[63] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "NewExternalPort"); - if(p && extPort) - { - strncpy(extPort, p, 6); - extPort[5] = '\0'; - r = UPNPCOMMAND_SUCCESS; - } - p = GetValueFromNameValueList(&pdata, "NewProtocol"); - if(p && protocol) - { - strncpy(protocol, p, 4); - protocol[3] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "NewInternalClient"); - if(p) - { - strncpy(intClient, p, 16); - intClient[15] = '\0'; - r = 0; - } - p = GetValueFromNameValueList(&pdata, "NewInternalPort"); - if(p) - { - strncpy(intPort, p, 6); - intPort[5] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "NewEnabled"); - if(p && enabled) - { - strncpy(enabled, p, 4); - enabled[3] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription"); - if(p && desc) - { - strncpy(desc, p, 80); - desc[79] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "NewLeaseDuration"); - if(p && duration) - { - strncpy(duration, p, 16); - duration[15] = '\0'; - } - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - r = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &r); - } - ClearNameValueList(&pdata); - return r; -} - -MINIUPNP_LIBSPEC int -UPNP_GetPortMappingNumberOfEntries(const char * controlURL, - const char * servicetype, - unsigned int * numEntries) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - char* p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetPortMappingNumberOfEntries", 0, - &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; - } -#ifdef DEBUG - DisplayNameValueList(buffer, bufsize); -#endif - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - p = GetValueFromNameValueList(&pdata, "NewPortMappingNumberOfEntries"); - if(numEntries && p) { - *numEntries = 0; - sscanf(p, "%u", numEntries); - ret = UPNPCOMMAND_SUCCESS; - } - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - - ClearNameValueList(&pdata); - return ret; -} - -/* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping - * the result is returned in the intClient and intPort strings - * please provide 16 and 6 bytes of data */ -MINIUPNP_LIBSPEC int -UPNP_GetSpecificPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * extPort, - const char * proto, - const char * remoteHost, - char * intClient, - char * intPort, - char * desc, - char * enabled, - char * leaseDuration) -{ - struct NameValueParserData pdata; - struct UPNParg * GetPortMappingArgs; - char * buffer; - int bufsize; - char * p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!intPort || !intClient || !extPort || !proto) - return UPNPCOMMAND_INVALID_ARGS; - - GetPortMappingArgs = (struct UPNParg*)calloc(4, sizeof(struct UPNParg)); - if(GetPortMappingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - GetPortMappingArgs[0].elt = "NewRemoteHost"; - GetPortMappingArgs[0].val = remoteHost; - GetPortMappingArgs[1].elt = "NewExternalPort"; - GetPortMappingArgs[1].val = extPort; - GetPortMappingArgs[2].elt = "NewProtocol"; - GetPortMappingArgs[2].val = proto; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetSpecificPortMappingEntry", - GetPortMappingArgs, &bufsize); - free(GetPortMappingArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - p = GetValueFromNameValueList(&pdata, "NewInternalClient"); - if(p) { - strncpy(intClient, p, 16); - intClient[15] = '\0'; - ret = UPNPCOMMAND_SUCCESS; - } else - intClient[0] = '\0'; - - p = GetValueFromNameValueList(&pdata, "NewInternalPort"); - if(p) { - strncpy(intPort, p, 6); - intPort[5] = '\0'; - } else - intPort[0] = '\0'; - - p = GetValueFromNameValueList(&pdata, "NewEnabled"); - if(p && enabled) { - strncpy(enabled, p, 4); - enabled[3] = '\0'; - } - - p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription"); - if(p && desc) { - strncpy(desc, p, 80); - desc[79] = '\0'; - } - - p = GetValueFromNameValueList(&pdata, "NewLeaseDuration"); - if(p && leaseDuration) - { - strncpy(leaseDuration, p, 16); - leaseDuration[15] = '\0'; - } - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - - ClearNameValueList(&pdata); - return ret; -} - -/* UPNP_GetListOfPortMappings() - * - * Possible UPNP Error codes : - * 606 Action not Authorized - * 730 PortMappingNotFound - no port mapping is found in the specified range. - * 733 InconsistantParameters - NewStartPort and NewEndPort values are not - * consistent. - */ -MINIUPNP_LIBSPEC int -UPNP_GetListOfPortMappings(const char * controlURL, - const char * servicetype, - const char * startPort, - const char * endPort, - const char * protocol, - const char * numberOfPorts, - struct PortMappingParserData * data) -{ - struct NameValueParserData pdata; - struct UPNParg * GetListOfPortMappingsArgs; - const char * p; - char * buffer; - int bufsize; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!startPort || !endPort || !protocol) - return UPNPCOMMAND_INVALID_ARGS; - - GetListOfPortMappingsArgs = (struct UPNParg*)calloc(6, sizeof(struct UPNParg)); - if(GetListOfPortMappingsArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - GetListOfPortMappingsArgs[0].elt = "NewStartPort"; - GetListOfPortMappingsArgs[0].val = startPort; - GetListOfPortMappingsArgs[1].elt = "NewEndPort"; - GetListOfPortMappingsArgs[1].val = endPort; - GetListOfPortMappingsArgs[2].elt = "NewProtocol"; - GetListOfPortMappingsArgs[2].val = protocol; - GetListOfPortMappingsArgs[3].elt = "NewManage"; - GetListOfPortMappingsArgs[3].val = "1"; - GetListOfPortMappingsArgs[4].elt = "NewNumberOfPorts"; - GetListOfPortMappingsArgs[4].val = numberOfPorts?numberOfPorts:"1000"; - - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetListOfPortMappings", - GetListOfPortMappingsArgs, &bufsize); - free(GetListOfPortMappingsArgs); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - /*p = GetValueFromNameValueList(&pdata, "NewPortListing");*/ - /*if(p) { - printf("NewPortListing : %s\n", p); - }*/ - /*printf("NewPortListing(%d chars) : %s\n", - pdata.portListingLength, pdata.portListing);*/ - if(pdata.portListing) - { - /*struct PortMapping * pm; - int i = 0;*/ - ParsePortListing(pdata.portListing, pdata.portListingLength, - data); - ret = UPNPCOMMAND_SUCCESS; - /* - for(pm = data->head.lh_first; pm != NULL; pm = pm->entries.le_next) - { - printf("%2d %s %5hu->%s:%-5hu '%s' '%s'\n", - i, pm->protocol, pm->externalPort, pm->internalClient, - pm->internalPort, - pm->description, pm->remoteHost); - i++; - } - */ - /*FreePortListing(&data);*/ - } - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - ClearNameValueList(&pdata); - - /*printf("%.*s", bufsize, buffer);*/ - - return ret; -} - -/* IGD:2, functions for service WANIPv6FirewallControl:1 */ -MINIUPNP_LIBSPEC int -UPNP_GetFirewallStatus(const char * controlURL, - const char * servicetype, - int * firewallEnabled, - int * inboundPinholeAllowed) -{ - struct NameValueParserData pdata; - char * buffer; - int bufsize; - char * fe, *ipa, *p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!firewallEnabled || !inboundPinholeAllowed) - return UPNPCOMMAND_INVALID_ARGS; - - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetFirewallStatus", 0, &bufsize); - if(!buffer) { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - fe = GetValueFromNameValueList(&pdata, "FirewallEnabled"); - ipa = GetValueFromNameValueList(&pdata, "InboundPinholeAllowed"); - if(ipa && fe) - ret = UPNPCOMMAND_SUCCESS; - if(fe) - *firewallEnabled = (int)my_custom_atoui(fe); - /*else - *firewallEnabled = 0;*/ - if(ipa) - *inboundPinholeAllowed = (int)my_custom_atoui(ipa); - /*else - *inboundPinholeAllowed = 0;*/ - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) - { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - int * opTimeout) -{ - struct UPNParg * GetOutboundPinholeTimeoutArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - char * p; - int ret; - - if(!intPort || !intClient || !proto || !remotePort || !remoteHost) - return UPNPCOMMAND_INVALID_ARGS; - - GetOutboundPinholeTimeoutArgs = (struct UPNParg*)calloc(6, sizeof(struct UPNParg)); - if(GetOutboundPinholeTimeoutArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - GetOutboundPinholeTimeoutArgs[0].elt = "RemoteHost"; - GetOutboundPinholeTimeoutArgs[0].val = remoteHost; - GetOutboundPinholeTimeoutArgs[1].elt = "RemotePort"; - GetOutboundPinholeTimeoutArgs[1].val = remotePort; - GetOutboundPinholeTimeoutArgs[2].elt = "Protocol"; - GetOutboundPinholeTimeoutArgs[2].val = proto; - GetOutboundPinholeTimeoutArgs[3].elt = "InternalPort"; - GetOutboundPinholeTimeoutArgs[3].val = intPort; - GetOutboundPinholeTimeoutArgs[4].elt = "InternalClient"; - GetOutboundPinholeTimeoutArgs[4].val = intClient; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetOutboundPinholeTimeout", GetOutboundPinholeTimeoutArgs, &bufsize); - free(GetOutboundPinholeTimeoutArgs); - if(!buffer) - return UPNPCOMMAND_HTTP_ERROR; - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) - { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } - else - { - ret = UPNPCOMMAND_SUCCESS; - p = GetValueFromNameValueList(&pdata, "OutboundPinholeTimeout"); - if(p) - *opTimeout = (int)my_custom_atoui(p); - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_AddPinhole(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - const char * leaseTime, - char * uniqueID) -{ - struct UPNParg * AddPinholeArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - char * p; - int ret; - - if(!intPort || !intClient || !proto || !remoteHost || !remotePort || !leaseTime) - return UPNPCOMMAND_INVALID_ARGS; - - AddPinholeArgs = (struct UPNParg*)calloc(7, sizeof(struct UPNParg)); - if(AddPinholeArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - /* RemoteHost can be wilcarded */ - if(strncmp(remoteHost, "empty", 5)==0) - { - AddPinholeArgs[0].elt = "RemoteHost"; - AddPinholeArgs[0].val = ""; - } - else - { - AddPinholeArgs[0].elt = "RemoteHost"; - AddPinholeArgs[0].val = remoteHost; - } - AddPinholeArgs[1].elt = "RemotePort"; - AddPinholeArgs[1].val = remotePort; - AddPinholeArgs[2].elt = "Protocol"; - AddPinholeArgs[2].val = proto; - AddPinholeArgs[3].elt = "InternalPort"; - AddPinholeArgs[3].val = intPort; - if(strncmp(intClient, "empty", 5)==0) - { - AddPinholeArgs[4].elt = "InternalClient"; - AddPinholeArgs[4].val = ""; - } - else - { - AddPinholeArgs[4].elt = "InternalClient"; - AddPinholeArgs[4].val = intClient; - } - AddPinholeArgs[5].elt = "LeaseTime"; - AddPinholeArgs[5].val = leaseTime; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "AddPinhole", AddPinholeArgs, &bufsize); - free(AddPinholeArgs); - if(!buffer) - return UPNPCOMMAND_HTTP_ERROR; - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - p = GetValueFromNameValueList(&pdata, "UniqueID"); - if(p) - { - strncpy(uniqueID, p, 8); - uniqueID[7] = '\0'; - } - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) - { - /*printf("AddPortMapping errorCode = '%s'\n", resVal);*/ - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } - else - { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, - const char * uniqueID, - const char * leaseTime) -{ - struct UPNParg * UpdatePinholeArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!uniqueID || !leaseTime) - return UPNPCOMMAND_INVALID_ARGS; - - UpdatePinholeArgs = (struct UPNParg*)calloc(3, sizeof(struct UPNParg)); - if(UpdatePinholeArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - UpdatePinholeArgs[0].elt = "UniqueID"; - UpdatePinholeArgs[0].val = uniqueID; - UpdatePinholeArgs[1].elt = "NewLeaseTime"; - UpdatePinholeArgs[1].val = leaseTime; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "UpdatePinhole", UpdatePinholeArgs, &bufsize); - free(UpdatePinholeArgs); - if(!buffer) - return UPNPCOMMAND_HTTP_ERROR; - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) - { - /*printf("AddPortMapping errorCode = '%s'\n", resVal); */ - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } - else - { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID) -{ - /*struct NameValueParserData pdata;*/ - struct UPNParg * DeletePinholeArgs; - char * buffer; - int bufsize; - struct NameValueParserData pdata; - const char * resVal; - int ret; - - if(!uniqueID) - return UPNPCOMMAND_INVALID_ARGS; - - DeletePinholeArgs = (struct UPNParg*)calloc(2, sizeof(struct UPNParg)); - if(DeletePinholeArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - DeletePinholeArgs[0].elt = "UniqueID"; - DeletePinholeArgs[0].val = uniqueID; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "DeletePinhole", DeletePinholeArgs, &bufsize); - free(DeletePinholeArgs); - if(!buffer) - return UPNPCOMMAND_HTTP_ERROR; - /*DisplayNameValueList(buffer, bufsize);*/ - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - resVal = GetValueFromNameValueList(&pdata, "errorCode"); - if(resVal) - { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(resVal, "%d", &ret); - } - else - { - ret = UPNPCOMMAND_SUCCESS; - } - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, - const char * uniqueID, int * isWorking) -{ - struct NameValueParserData pdata; - struct UPNParg * CheckPinholeWorkingArgs; - char * buffer; - int bufsize; - char * p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!uniqueID) - return UPNPCOMMAND_INVALID_ARGS; - - CheckPinholeWorkingArgs = (struct UPNParg*)calloc(4, sizeof(struct UPNParg)); - if(CheckPinholeWorkingArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - CheckPinholeWorkingArgs[0].elt = "UniqueID"; - CheckPinholeWorkingArgs[0].val = uniqueID; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "CheckPinholeWorking", CheckPinholeWorkingArgs, &bufsize); - free(CheckPinholeWorkingArgs); - if(!buffer) - { - return UPNPCOMMAND_HTTP_ERROR; - } - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - p = GetValueFromNameValueList(&pdata, "IsWorking"); - if(p) - { - *isWorking = (int)my_custom_atoui(p); - ret = UPNPCOMMAND_SUCCESS; - } - else - *isWorking = 0; - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) - { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - - ClearNameValueList(&pdata); - return ret; -} - -MINIUPNP_LIBSPEC int -UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, - const char * uniqueID, int * packets) -{ - struct NameValueParserData pdata; - struct UPNParg * GetPinholePacketsArgs; - char * buffer; - int bufsize; - char * p; - int ret = UPNPCOMMAND_UNKNOWN_ERROR; - - if(!uniqueID) - return UPNPCOMMAND_INVALID_ARGS; - - GetPinholePacketsArgs = (struct UPNParg*)calloc(4, sizeof(struct UPNParg)); - if(GetPinholePacketsArgs == NULL) - return UPNPCOMMAND_MEM_ALLOC_ERROR; - GetPinholePacketsArgs[0].elt = "UniqueID"; - GetPinholePacketsArgs[0].val = uniqueID; - buffer = simpleUPnPcommand(-1, controlURL, servicetype, - "GetPinholePackets", GetPinholePacketsArgs, &bufsize); - free(GetPinholePacketsArgs); - if(!buffer) - return UPNPCOMMAND_HTTP_ERROR; - ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; - - p = GetValueFromNameValueList(&pdata, "PinholePackets"); - if(p) - { - *packets = (int)my_custom_atoui(p); - ret = UPNPCOMMAND_SUCCESS; - } - - p = GetValueFromNameValueList(&pdata, "errorCode"); - if(p) - { - ret = UPNPCOMMAND_UNKNOWN_ERROR; - sscanf(p, "%d", &ret); - } - - ClearNameValueList(&pdata); - return ret; -} - - diff --git a/deps/miniupnpc/upnpcommands.h b/deps/miniupnpc/upnpcommands.h deleted file mode 100644 index 55b7b060dc..0000000000 --- a/deps/miniupnpc/upnpcommands.h +++ /dev/null @@ -1,348 +0,0 @@ -/* $Id: upnpcommands.h,v 1.30 2015/07/15 12:21:28 nanard Exp $ */ -/* Miniupnp project : http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2005-2015 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided within this distribution */ -#ifndef UPNPCOMMANDS_H_INCLUDED -#define UPNPCOMMANDS_H_INCLUDED - -#include "upnpreplyparse.h" -#include "portlistingparse.h" -#include "miniupnpc_declspec.h" -#include "miniupnpctypes.h" - -/* MiniUPnPc return codes : */ -#define UPNPCOMMAND_SUCCESS (0) -#define UPNPCOMMAND_UNKNOWN_ERROR (-1) -#define UPNPCOMMAND_INVALID_ARGS (-2) -#define UPNPCOMMAND_HTTP_ERROR (-3) -#define UPNPCOMMAND_INVALID_RESPONSE (-4) -#define UPNPCOMMAND_MEM_ALLOC_ERROR (-5) - -#ifdef __cplusplus -extern "C" { -#endif - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesSent(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesReceived(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsSent(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsReceived(const char * controlURL, - const char * servicetype); - -/* UPNP_GetStatusInfo() - * status and lastconnerror are 64 byte buffers - * Return values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error code */ -MINIUPNP_LIBSPEC int -UPNP_GetStatusInfo(const char * controlURL, - const char * servicetype, - char * status, - unsigned int * uptime, - char * lastconnerror); - -/* UPNP_GetConnectionTypeInfo() - * argument connectionType is a 64 character buffer - * Return Values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error code */ -MINIUPNP_LIBSPEC int -UPNP_GetConnectionTypeInfo(const char * controlURL, - const char * servicetype, - char * connectionType); - -/* UPNP_GetExternalIPAddress() call the corresponding UPNP method. - * if the third arg is not null the value is copied to it. - * at least 16 bytes must be available - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR Either an UPnP error code or an unknown error. - * - * possible UPnP Errors : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. */ -MINIUPNP_LIBSPEC int -UPNP_GetExternalIPAddress(const char * controlURL, - const char * servicetype, - char * extIpAdd); - -/* UPNP_GetLinkLayerMaxBitRates() - * call WANCommonInterfaceConfig:1#GetCommonLinkProperties - * - * return values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. */ -MINIUPNP_LIBSPEC int -UPNP_GetLinkLayerMaxBitRates(const char* controlURL, - const char* servicetype, - unsigned int * bitrateDown, - unsigned int * bitrateUp); - -/* UPNP_AddPortMapping() - * if desc is NULL, it will be defaulted to "libminiupnpc" - * remoteHost is usually NULL because IGD don't support it. - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR. Either an UPnP error code or an unknown error. - * - * List of possible UPnP errors for AddPortMapping : - * errorCode errorDescription (short) - Description (long) - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization and - * the sender was not authorized. - * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be - * wild-carded - * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded - * 718 ConflictInMappingEntry - The port mapping entry specified conflicts - * with a mapping assigned previously to another client - * 724 SamePortValuesRequired - Internal and External port values - * must be the same - * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports - * permanent lease times on port mappings - * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard - * and cannot be a specific IP address or DNS name - * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and - * cannot be a specific port value - * 728 NoPortMapsAvailable - There are not enough free ports available to - * complete port mapping. - * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed - * due to conflict with other mechanisms. - * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded - */ -MINIUPNP_LIBSPEC int -UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration); - -/* UPNP_AddAnyPortMapping() - * if desc is NULL, it will be defaulted to "libminiupnpc" - * remoteHost is usually NULL because IGD don't support it. - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR. Either an UPnP error code or an unknown error. - * - * List of possible UPnP errors for AddPortMapping : - * errorCode errorDescription (short) - Description (long) - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization and - * the sender was not authorized. - * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be - * wild-carded - * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded - * 728 NoPortMapsAvailable - There are not enough free ports available to - * complete port mapping. - * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed - * due to conflict with other mechanisms. - * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded - */ -MINIUPNP_LIBSPEC int -UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration, - char * reservedPort); - -/* UPNP_DeletePortMapping() - * Use same argument values as what was used for AddPortMapping(). - * remoteHost is usually NULL because IGD don't support it. - * Return Values : - * 0 : SUCCESS - * NON ZERO : error. Either an UPnP error code or an undefined error. - * - * List of possible UPnP errors for DeletePortMapping : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 714 NoSuchEntryInArray - The specified value does not exist in the array */ -MINIUPNP_LIBSPEC int -UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto, - const char * remoteHost); - -/* UPNP_DeletePortRangeMapping() - * Use same argument values as what was used for AddPortMapping(). - * remoteHost is usually NULL because IGD don't support it. - * Return Values : - * 0 : SUCCESS - * NON ZERO : error. Either an UPnP error code or an undefined error. - * - * List of possible UPnP errors for DeletePortMapping : - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 730 PortMappingNotFound - This error message is returned if no port - * mapping is found in the specified range. - * 733 InconsistentParameters - NewStartPort and NewEndPort values are not consistent. */ -MINIUPNP_LIBSPEC int -UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, - const char * extPortStart, const char * extPortEnd, - const char * proto, - const char * manage); - -/* UPNP_GetPortMappingNumberOfEntries() - * not supported by all routers */ -MINIUPNP_LIBSPEC int -UPNP_GetPortMappingNumberOfEntries(const char* controlURL, - const char* servicetype, - unsigned int * num); - -/* UPNP_GetSpecificPortMappingEntry() - * retrieves an existing port mapping - * params : - * in extPort - * in proto - * in remoteHost - * out intClient (16 bytes) - * out intPort (6 bytes) - * out desc (80 bytes) - * out enabled (4 bytes) - * out leaseDuration (16 bytes) - * - * return value : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. - * - * List of possible UPnP errors for _GetSpecificPortMappingEntry : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 714 NoSuchEntryInArray - The specified value does not exist in the array. - */ -MINIUPNP_LIBSPEC int -UPNP_GetSpecificPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * extPort, - const char * proto, - const char * remoteHost, - char * intClient, - char * intPort, - char * desc, - char * enabled, - char * leaseDuration); - -/* UPNP_GetGenericPortMappingEntry() - * params : - * in index - * out extPort (6 bytes) - * out intClient (16 bytes) - * out intPort (6 bytes) - * out protocol (4 bytes) - * out desc (80 bytes) - * out enabled (4 bytes) - * out rHost (64 bytes) - * out duration (16 bytes) - * - * return value : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. - * - * Possible UPNP Error codes : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds - */ -MINIUPNP_LIBSPEC int -UPNP_GetGenericPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * index, - char * extPort, - char * intClient, - char * intPort, - char * protocol, - char * desc, - char * enabled, - char * rHost, - char * duration); - -/* UPNP_GetListOfPortMappings() Available in IGD v2 - * - * - * Possible UPNP Error codes : - * 606 Action not Authorized - * 730 PortMappingNotFound - no port mapping is found in the specified range. - * 733 InconsistantParameters - NewStartPort and NewEndPort values are not - * consistent. - */ -MINIUPNP_LIBSPEC int -UPNP_GetListOfPortMappings(const char * controlURL, - const char * servicetype, - const char * startPort, - const char * endPort, - const char * protocol, - const char * numberOfPorts, - struct PortMappingParserData * data); - -/* IGD:2, functions for service WANIPv6FirewallControl:1 */ -MINIUPNP_LIBSPEC int -UPNP_GetFirewallStatus(const char * controlURL, - const char * servicetype, - int * firewallEnabled, - int * inboundPinholeAllowed); - -MINIUPNP_LIBSPEC int -UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - int * opTimeout); - -MINIUPNP_LIBSPEC int -UPNP_AddPinhole(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - const char * leaseTime, - char * uniqueID); - -MINIUPNP_LIBSPEC int -UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, - const char * uniqueID, - const char * leaseTime); - -MINIUPNP_LIBSPEC int -UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID); - -MINIUPNP_LIBSPEC int -UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, - const char * uniqueID, int * isWorking); - -MINIUPNP_LIBSPEC int -UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, - const char * uniqueID, int * packets); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/deps/miniupnpc/upnpdev.c b/deps/miniupnpc/upnpdev.c deleted file mode 100644 index d89a9934c3..0000000000 --- a/deps/miniupnpc/upnpdev.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $Id: upnpdev.c,v 1.1 2015/08/28 12:14:19 nanard Exp $ */ -/* Project : miniupnp - * Web : http://miniupnp.free.fr/ - * Author : Thomas BERNARD - * copyright (c) 2005-2015 Thomas Bernard - * This software is subjet to the conditions detailed in the - * provided LICENSE file. */ -#include -#include "upnpdev.h" - -/* freeUPNPDevlist() should be used to - * free the chained list returned by upnpDiscover() */ -void freeUPNPDevlist(struct UPNPDev * devlist) -{ - struct UPNPDev * next; - while(devlist) - { - next = devlist->pNext; - free(devlist); - devlist = next; - } -} - diff --git a/deps/miniupnpc/upnpdev.h b/deps/miniupnpc/upnpdev.h deleted file mode 100644 index f49fbe17ca..0000000000 --- a/deps/miniupnpc/upnpdev.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $Id: upnpdev.h,v 1.1 2015/08/28 12:14:19 nanard Exp $ */ -/* Project : miniupnp - * Web : http://miniupnp.free.fr/ - * Author : Thomas BERNARD - * copyright (c) 2005-2015 Thomas Bernard - * This software is subjet to the conditions detailed in the - * provided LICENSE file. */ -#ifndef UPNPDEV_H_INCLUDED -#define UPNPDEV_H_INCLUDED - -#include "miniupnpc_declspec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct UPNPDev { - struct UPNPDev * pNext; - char * descURL; - char * st; - unsigned int scope_id; - char * usn; - char buffer[3]; -}; - -/* freeUPNPDevlist() - * free list returned by upnpDiscover() */ -MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); - - -#ifdef __cplusplus -} -#endif - - -#endif /* UPNPDEV_H_INCLUDED */ diff --git a/deps/miniupnpc/upnperrors.c b/deps/miniupnpc/upnperrors.c deleted file mode 100644 index 40a2e7857f..0000000000 --- a/deps/miniupnpc/upnperrors.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $Id: upnperrors.c,v 1.5 2011/04/10 11:19:36 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas BERNARD - * copyright (c) 2007 Thomas Bernard - * All Right reserved. - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ -#include -#include "upnperrors.h" -#include "upnpcommands.h" -#include "miniupnpc.h" - -const char * strupnperror(int err) -{ - const char * s = NULL; - switch(err) { - case UPNPCOMMAND_SUCCESS: - s = "Success"; - break; - case UPNPCOMMAND_UNKNOWN_ERROR: - s = "Miniupnpc Unknown Error"; - break; - case UPNPCOMMAND_INVALID_ARGS: - s = "Miniupnpc Invalid Arguments"; - break; - case UPNPCOMMAND_INVALID_RESPONSE: - s = "Miniupnpc Invalid response"; - break; - case UPNPDISCOVER_SOCKET_ERROR: - s = "Miniupnpc Socket error"; - break; - case UPNPDISCOVER_MEMORY_ERROR: - s = "Miniupnpc Memory allocation error"; - break; - case 401: - s = "Invalid Action"; - break; - case 402: - s = "Invalid Args"; - break; - case 501: - s = "Action Failed"; - break; - case 606: - s = "Action not authorized"; - break; - case 701: - s = "PinholeSpaceExhausted"; - break; - case 702: - s = "FirewallDisabled"; - break; - case 703: - s = "InboundPinholeNotAllowed"; - break; - case 704: - s = "NoSuchEntry"; - break; - case 705: - s = "ProtocolNotSupported"; - break; - case 706: - s = "InternalPortWildcardingNotAllowed"; - break; - case 707: - s = "ProtocolWildcardingNotAllowed"; - break; - case 708: - s = "WildcardNotPermittedInSrcIP"; - break; - case 709: - s = "NoPacketSent"; - break; - case 713: - s = "SpecifiedArrayIndexInvalid"; - break; - case 714: - s = "NoSuchEntryInArray"; - break; - case 715: - s = "WildCardNotPermittedInSrcIP"; - break; - case 716: - s = "WildCardNotPermittedInExtPort"; - break; - case 718: - s = "ConflictInMappingEntry"; - break; - case 724: - s = "SamePortValuesRequired"; - break; - case 725: - s = "OnlyPermanentLeasesSupported"; - break; - case 726: - s = "RemoteHostOnlySupportsWildcard"; - break; - case 727: - s = "ExternalPortOnlySupportsWildcard"; - break; - default: - s = "UnknownError"; - break; - } - return s; -} diff --git a/deps/miniupnpc/upnperrors.h b/deps/miniupnpc/upnperrors.h deleted file mode 100644 index 8499d9a1c9..0000000000 --- a/deps/miniupnpc/upnperrors.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id: upnperrors.h,v 1.2 2008/07/02 23:31:15 nanard Exp $ */ -/* (c) 2007-2015 Thomas Bernard - * All rights reserved. - * MiniUPnP Project. - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ -#ifndef UPNPERRORS_H_INCLUDED -#define UPNPERRORS_H_INCLUDED - -#include "miniupnpc_declspec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* strupnperror() - * Return a string description of the UPnP error code - * or NULL for undefinded errors */ -MINIUPNP_LIBSPEC const char * strupnperror(int err); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/deps/miniupnpc/upnpreplyparse.c b/deps/miniupnpc/upnpreplyparse.c deleted file mode 100644 index 30d2daba74..0000000000 --- a/deps/miniupnpc/upnpreplyparse.c +++ /dev/null @@ -1,197 +0,0 @@ -/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ -/* MiniUPnP project - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2015 Thomas Bernard - * This software is subject to the conditions detailed - * in the LICENCE file provided within the distribution */ - -#include -#include -#include - -#include "upnpreplyparse.h" -#include "minixml.h" - -static void -NameValueParserStartElt(void * d, const char * name, int l) -{ - struct NameValueParserData * data = (struct NameValueParserData *)d; - data->topelt = 1; - if(l>63) - l = 63; - memcpy(data->curelt, name, l); - data->curelt[l] = '\0'; - data->cdata = NULL; - data->cdatalen = 0; -} - -static void -NameValueParserEndElt(void * d, const char * name, int l) -{ - struct NameValueParserData * data = (struct NameValueParserData *)d; - struct NameValue * nv; - (void)name; - (void)l; - if(!data->topelt) - return; - if(strcmp(data->curelt, "NewPortListing") != 0) - { - int l; - /* standard case. Limited to n chars strings */ - l = data->cdatalen; - nv = (struct NameValue*)malloc(sizeof(struct NameValue)); - if(nv == NULL) - { - /* malloc error */ -#ifdef DEBUG - fprintf(stderr, "%s: error allocating memory", - "NameValueParserEndElt"); -#endif /* DEBUG */ - return; - } - if(l>=(int)sizeof(nv->value)) - l = sizeof(nv->value) - 1; - strncpy(nv->name, data->curelt, 64); - nv->name[63] = '\0'; - if(data->cdata != NULL) - { - memcpy(nv->value, data->cdata, l); - nv->value[l] = '\0'; - } - else - { - nv->value[0] = '\0'; - } - nv->l_next = data->l_head; /* insert in list */ - data->l_head = nv; - } - data->cdata = NULL; - data->cdatalen = 0; - data->topelt = 0; -} - -static void -NameValueParserGetData(void * d, const char * datas, int l) -{ - struct NameValueParserData * data = (struct NameValueParserData *)d; - if(strcmp(data->curelt, "NewPortListing") == 0) - { - /* specific case for NewPortListing which is a XML Document */ - data->portListing = (char*)malloc(l + 1); - if(!data->portListing) - { - /* malloc error */ -#ifdef DEBUG - fprintf(stderr, "%s: error allocating memory", - "NameValueParserGetData"); -#endif /* DEBUG */ - return; - } - memcpy(data->portListing, datas, l); - data->portListing[l] = '\0'; - data->portListingLength = l; - } - else - { - /* standard case. */ - data->cdata = datas; - data->cdatalen = l; - } -} - -void -ParseNameValue(const char * buffer, int bufsize, - struct NameValueParserData * data) -{ - struct xmlparser parser; - data->l_head = NULL; - data->portListing = NULL; - data->portListingLength = 0; - /* init xmlparser object */ - parser.xmlstart = buffer; - parser.xmlsize = bufsize; - parser.data = data; - parser.starteltfunc = NameValueParserStartElt; - parser.endeltfunc = NameValueParserEndElt; - parser.datafunc = NameValueParserGetData; - parser.attfunc = 0; - parsexml(&parser); -} - -void -ClearNameValueList(struct NameValueParserData * pdata) -{ - struct NameValue * nv; - if(pdata->portListing) - { - free(pdata->portListing); - pdata->portListing = NULL; - pdata->portListingLength = 0; - } - while((nv = pdata->l_head) != NULL) - { - pdata->l_head = nv->l_next; - free(nv); - } -} - -char * -GetValueFromNameValueList(struct NameValueParserData * pdata, - const char * Name) -{ - struct NameValue * nv; - char * p = NULL; - for(nv = pdata->l_head; - (nv != NULL) && (p == NULL); - nv = nv->l_next) - { - if(strcmp(nv->name, Name) == 0) - p = nv->value; - } - return p; -} - -#if 0 -/* useless now that minixml ignores namespaces by itself */ -char * -GetValueFromNameValueListIgnoreNS(struct NameValueParserData * pdata, - const char * Name) -{ - struct NameValue * nv; - char * p = NULL; - char * pname; - for(nv = pdata->head.lh_first; - (nv != NULL) && (p == NULL); - nv = nv->entries.le_next) - { - pname = strrchr(nv->name, ':'); - if(pname) - pname++; - else - pname = nv->name; - if(strcmp(pname, Name)==0) - p = nv->value; - } - return p; -} -#endif - -/* debug all-in-one function - * do parsing then display to stdout */ -#ifdef DEBUG -void -DisplayNameValueList(char * buffer, int bufsize) -{ - struct NameValueParserData pdata; - struct NameValue * nv; - ParseNameValue(buffer, bufsize, &pdata); - for(nv = pdata.l_head; - nv != NULL; - nv = nv->l_next) - { - printf("%s = %s\n", nv->name, nv->value); - } - ClearNameValueList(&pdata); -} -#endif /* DEBUG */ - diff --git a/deps/miniupnpc/upnpreplyparse.h b/deps/miniupnpc/upnpreplyparse.h deleted file mode 100644 index 6badd15b26..0000000000 --- a/deps/miniupnpc/upnpreplyparse.h +++ /dev/null @@ -1,63 +0,0 @@ -/* $Id: upnpreplyparse.h,v 1.19 2014/10/27 16:33:19 nanard Exp $ */ -/* MiniUPnP project - * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2013 Thomas Bernard - * This software is subject to the conditions detailed - * in the LICENCE file provided within the distribution */ - -#ifndef UPNPREPLYPARSE_H_INCLUDED -#define UPNPREPLYPARSE_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -struct NameValue { - struct NameValue * l_next; - char name[64]; - char value[128]; -}; - -struct NameValueParserData { - struct NameValue * l_head; - char curelt[64]; - char * portListing; - int portListingLength; - int topelt; - const char * cdata; - int cdatalen; -}; - -/* ParseNameValue() */ -void -ParseNameValue(const char * buffer, int bufsize, - struct NameValueParserData * data); - -/* ClearNameValueList() */ -void -ClearNameValueList(struct NameValueParserData * pdata); - -/* GetValueFromNameValueList() */ -char * -GetValueFromNameValueList(struct NameValueParserData * pdata, - const char * Name); - -#if 0 -/* GetValueFromNameValueListIgnoreNS() */ -char * -GetValueFromNameValueListIgnoreNS(struct NameValueParserData * pdata, - const char * Name); -#endif - -/* DisplayNameValueList() */ -#ifdef DEBUG -void -DisplayNameValueList(char * buffer, int bufsize); -#endif - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/griffin/griffin.c b/griffin/griffin.c index 59dc990fc1..641b2d5ed8 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1572,22 +1572,6 @@ XML #include "../database_info.c" #endif -#if defined(HAVE_BUILTINMINIUPNPC) -#include "../deps/miniupnpc/igd_desc_parse.c" -#include "../deps/miniupnpc/upnpreplyparse.c" -#include "../deps/miniupnpc/upnpcommands.c" -#include "../deps/miniupnpc/upnperrors.c" -#include "../deps/miniupnpc/connecthostport.c" -#include "../deps/miniupnpc/portlistingparse.c" -#include "../deps/miniupnpc/receivedata.c" -#include "../deps/miniupnpc/upnpdev.c" -#include "../deps/miniupnpc/minissdpc.c" -#include "../deps/miniupnpc/miniwget.c" -#include "../deps/miniupnpc/miniupnpc.c" -#include "../deps/miniupnpc/minixml.c" -#include "../deps/miniupnpc/minisoap.c" -#endif - /*============================================================ HTTP SERVER ============================================================ */ diff --git a/libretro-common/include/net/net_http.h b/libretro-common/include/net/net_http.h index 4b376653c3..c628a64569 100644 --- a/libretro-common/include/net/net_http.h +++ b/libretro-common/include/net/net_http.h @@ -42,7 +42,9 @@ bool net_http_connection_done(struct http_connection_t *conn); void net_http_connection_free(struct http_connection_t *conn); -void net_http_connection_set_user_agent(struct http_connection_t* conn, const char* user_agent); +void net_http_connection_set_user_agent(struct http_connection_t *conn, const char *user_agent); + +void net_http_connection_set_headers(struct http_connection_t *conn, const char *headers); const char *net_http_connection_url(struct http_connection_t *conn); diff --git a/libretro-common/include/net/net_natt.h b/libretro-common/include/net/net_natt.h index 78bb239fc3..03916deca6 100644 --- a/libretro-common/include/net/net_natt.h +++ b/libretro-common/include/net/net_natt.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2020 The RetroArch team +/* Copyright (C) 2010-2021 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_natt.h). @@ -25,56 +25,192 @@ #include #include +#include #include RETRO_BEGIN_DECLS -struct natt_status +enum natt_forward_type { - /* True if we've resolved an external IPv4 address */ - bool have_inet4; - /* External IPv4 address */ - struct sockaddr_in ext_inet4_addr; - -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) - /* True if we've resolved an external IPv6 address */ - bool have_inet6; - /* External IPv6 address */ - struct sockaddr_in6 ext_inet6_addr; -#endif + NATT_FORWARD_TYPE_NONE, + NATT_FORWARD_TYPE_ANY }; -/** - * Initialize global NAT traversal structures (must be called once to use other - * functions) */ -void natt_init(struct natt_status *status, - uint16_t port, enum socket_protocol proto); +/* Use this enum to implement a higher-level interface. */ +enum nat_traversal_status +{ + NAT_TRAVERSAL_STATUS_DISCOVERY, + NAT_TRAVERSAL_STATUS_SELECT_DEVICE, + NAT_TRAVERSAL_STATUS_QUERY_DEVICE, + NAT_TRAVERSAL_STATUS_EXTERNAL_ADDRESS, + NAT_TRAVERSAL_STATUS_OPEN, + NAT_TRAVERSAL_STATUS_OPENING, + NAT_TRAVERSAL_STATUS_OPENED, + NAT_TRAVERSAL_STATUS_CLOSE, + NAT_TRAVERSAL_STATUS_CLOSING, + NAT_TRAVERSAL_STATUS_CLOSED +}; + +struct natt_device +{ + char desc [512]; + char control [512]; + char service_type[512]; + struct sockaddr_in ext_addr; + bool busy; +}; + +struct natt_request +{ + struct natt_device *device; + struct sockaddr_in addr; + enum socket_protocol proto; + bool success; +}; + +struct nat_traversal_data +{ + size_t iface; + struct natt_request request; + enum natt_forward_type forward_type; + enum nat_traversal_status status; +}; + +typedef struct +{ + /* List of available network interfaces. */ + struct net_ifinfo interfaces; + + /* Device we are operating on. */ + struct natt_device device; + + /* Timeout for our discovery request. */ + retro_time_t timeout; + + /* File descriptor of the socket we are receiving discovery data. */ + int fd; +} natt_state_t; + +natt_state_t *natt_state_get_ptr(void); /** - * Uninitialize global NAT traversal structures */ -void natt_deinit(struct natt_status *status, - enum socket_protocol proto); - -/** Initialize a NAT traversal status object */ -bool natt_new(struct natt_status *status); - -/** Free a NAT traversal status object */ -void natt_free(struct natt_status *status); + * natt_init: + * + * Starts a multicast discovery for UPnP devices. + * Must be followed by natt_device_next. + * + * Returns: true if the discovery was started. + */ +bool natt_init(void); /** - * Make a port forwarding request when only the port is known. Forwards any - * address it can find. */ -bool natt_open_port_any(struct natt_status *status, uint16_t port, - enum socket_protocol proto); + * natt_deinit: + * + * Uninitializes NAT traversal. + * Call this when UPnP is no longer required and before + * natt_init. + * + */ +void natt_deinit(void); /** - * Request for a port forwarding to be removed/closed. */ -bool natt_close_port(struct natt_status *status, - enum socket_protocol proto); + * natt_interfaces_destroy: + * + * Free network interfaces data. + * Call this when you've choosen an appropriate interface, + * generally after a successful port forwarding. + * + */ +void natt_interfaces_destroy(void); -/** Check for port forwarding responses */ -bool natt_read(struct natt_status *status); +/** + * natt_device_next: + * + * @device : Pointer to a device object that will be written to. + * + * Grabs the next device that has reported in to our discovery. + * natt_init must be called before this function. + * + * Returns: true if we've retrieved a new device or + * if timeout has not yet been reached. If device->desc is not an empty string, + * a new device was retrieved. + */ +bool natt_device_next(struct natt_device *device); + +/** + * natt_device_end: + * + * Stop checking for new devices and close the discovery socket. + * Call this when you've choosen an appropriate device, + * generally after a successful port forwarding. + * + */ +void natt_device_end(void); + +/** + * natt_query_device: + * + * @device : Pointer to a device to query into. + * @block : Blocks until the HTTP task is finished. + * + * Query an IGD for its service type and control URL. + * Call this after retrieving a device from natt_device_next. + * + * Returns: true if the task was successfully started. + * If both device->service_type and device->control are not empty strings, + * the task completed successfully. + */ +bool natt_query_device(struct natt_device *device, bool block); + +/** + * natt_external_address: + * + * @device : Pointer to a device to retrieve its external address. + * @block : Blocks until the HTTP task is finished. + * + * Retrieve the external IP address of an IGD. + * natt_query_device must have been called first. + * + * Returns: true if the task was successfully started. + * If device->ext_addr.sin_family is AF_INET, + * the task completed successfully. + */ +bool natt_external_address(struct natt_device *device, bool block); + +/** + * natt_open_port: + * + * @device : Pointer to a device to forward a port. + * @request : Port forwarding request information. + * @forward_type : UPnP port forwarding command type. + * @block : Blocks until the HTTP task is finished. + * + * Forward a port. + * natt_external_address must have been called first. + * + * Returns: true if the task was successfully started. + * If request->success is true, the task completed successfully. + */ +bool natt_open_port(struct natt_device *device, + struct natt_request *request, enum natt_forward_type forward_type, + bool block); + +/** + * natt_close_port: + * + * @device : Pointer to a device to unforward a port. + * @request : Port unforwarding request information. + * @block : Blocks until the HTTP task is finished. + * + * Unforward a port. + * natt_open_port must have been called first. + * + * Returns: true if the task was successfully started. + * If request->success is true, the task completed successfully. + */ +bool natt_close_port(struct natt_device *device, + struct natt_request *request, bool block); RETRO_END_DECLS diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 261708e85b..0ed933ae60 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -82,7 +82,8 @@ struct http_connection_t char *methodcopy; char *contenttypecopy; char *postdatacopy; - char* useragentcopy; + char *useragentcopy; + char *headerscopy; struct http_socket_state_t sock_state; /* ptr alignment */ int port; }; @@ -509,6 +510,7 @@ struct http_connection_t *net_http_connection_new(const char *url, conn->contenttypecopy = NULL; conn->postdatacopy = NULL; conn->useragentcopy = NULL; + conn->headerscopy = NULL; conn->port = 0; conn->sock_state.fd = 0; conn->sock_state.ssl = false; @@ -659,17 +661,21 @@ void net_http_connection_free(struct http_connection_t *conn) if (conn->useragentcopy) free(conn->useragentcopy); + if (conn->headerscopy) + free(conn->headerscopy); + conn->urlcopy = NULL; conn->methodcopy = NULL; conn->contenttypecopy = NULL; conn->postdatacopy = NULL; conn->useragentcopy = NULL; + conn->headerscopy = NULL; free(conn); } void net_http_connection_set_user_agent( - struct http_connection_t* conn, const char* user_agent) + struct http_connection_t *conn, const char *user_agent) { if (conn->useragentcopy) free(conn->useragentcopy); @@ -677,6 +683,15 @@ void net_http_connection_set_user_agent( conn->useragentcopy = user_agent ? strdup(user_agent) : NULL; } +void net_http_connection_set_headers( + struct http_connection_t *conn, const char *headers) +{ + if (conn->headerscopy) + free(conn->headerscopy); + + conn->headerscopy = headers ? strdup(headers) : NULL; +} + const char *net_http_connection_url(struct http_connection_t *conn) { return conn->urlcopy; @@ -732,8 +747,11 @@ struct http_t *net_http_new(struct http_connection_t *conn) net_http_send_str(&conn->sock_state, &error, "\r\n"); + /* Pre-formatted headers */ + if (conn->headerscopy) + net_http_send_str(&conn->sock_state, &error, conn->headerscopy); /* This is not being set anywhere yet */ - if (conn->contenttypecopy) + else if (conn->contenttypecopy) { net_http_send_str(&conn->sock_state, &error, "Content-Type: "); net_http_send_str(&conn->sock_state, &error, conn->contenttypecopy); @@ -748,9 +766,12 @@ struct http_t *net_http_new(struct http_connection_t *conn) if (!conn->postdatacopy) goto error; - if (!conn->contenttypecopy) - net_http_send_str(&conn->sock_state, &error, - "Content-Type: application/x-www-form-urlencoded\r\n"); + if (!conn->headerscopy) + { + if (!conn->contenttypecopy) + net_http_send_str(&conn->sock_state, &error, + "Content-Type: application/x-www-form-urlencoded\r\n"); + } net_http_send_str(&conn->sock_state, &error, "Content-Length: "); diff --git a/libretro-common/net/net_natt.c b/libretro-common/net/net_natt.c index 94fc6cb2ed..15990a35f4 100644 --- a/libretro-common/net/net_natt.c +++ b/libretro-common/net/net_natt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2016-2020 The RetroArch team +/* Copyright (C) 2016-2021 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (net_natt.c). @@ -27,281 +27,759 @@ #include #include +#include +#include #include #include + +#include "../../tasks/tasks_internal.h" + #include -#if HAVE_MINIUPNPC -#include -#include -#include +static natt_state_t natt_st = {{0}, {{0}}, 0, -1}; -#if MINIUPNPC_API_VERSION < 16 -#undef HAVE_MINIUPNPC -#endif -#endif - -#if HAVE_MINIUPNPC -static struct IGDdatas data = {0}; -static struct UPNPUrls urls = {0}; -#endif - -/* - natt_open_port_any(ntsd->nat_traversal_state, - ntsd->port, SOCKET_PROTOCOL_TCP); -*/ - -void natt_init(struct natt_status *status, - uint16_t port, enum socket_protocol proto) +natt_state_t *natt_state_get_ptr(void) { -#if !defined(HAVE_SOCKET_LEGACY) && HAVE_MINIUPNPC - struct UPNPDev *devlist = - upnpDiscover(2000, NULL, NULL, 0, 0, 2, NULL); - struct UPNPDev *dev = devlist; + return &natt_st; +} - while (dev) +bool natt_init(void) +{ +#ifndef HAVE_SOCKET_LEGACY + static const char msearch[] = + "M-SEARCH * HTTP/1.1\r\n" + "HOST: 239.255.255.250:1900\r\n" + "MAN: \"ssdp:discover\"\r\n" + "MX: 2\r\n" + "ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\n"; + static struct sockaddr_in msearch_addr = {0}; + natt_state_t *st = &natt_st; + struct addrinfo *bind_addr = NULL; + + if (msearch_addr.sin_family != AF_INET) { - if (strstr(dev->st, "InternetGatewayDevice")) - { - int len; - char *desc = (char *) miniwget(dev->descURL, - &len, 0, NULL); + struct addrinfo *addr = NULL; + struct addrinfo hints = {0}; - if (desc) - { - memset(&data, 0, sizeof(data)); - FreeUPNPUrls(&urls); - - parserootdesc(desc, len, &data); - free(desc); - - GetUPNPUrls(&urls, &data, dev->descURL, 0); - - if(natt_open_port_any(status, port, proto)) - break; - } - } - - dev = dev->pNext; - } - - freeUPNPDevlist(devlist); -#endif -} - -void natt_deinit(struct natt_status *status, - enum socket_protocol proto) -{ -#if !defined(HAVE_SOCKET_LEGACY) && HAVE_MINIUPNPC - natt_close_port(status, proto); - natt_free(status); - - memset(&data, 0, sizeof(data)); - FreeUPNPUrls(&urls); -#endif -} - -bool natt_new(struct natt_status *status) -{ - memset(status, 0, sizeof(*status)); - return true; -} - -void natt_free(struct natt_status *status) -{ - /* Invalidate the state */ - memset(status, 0, sizeof(*status)); -} - -static bool natt_open_port(struct natt_status *status, - struct sockaddr *addr, socklen_t addrlen, enum socket_protocol proto) -{ -#if !defined(HAVE_SOCKET_LEGACY) && HAVE_MINIUPNPC - int r; - char host[256], ext_host[256], - port_str[6], ext_port_str[6]; - const char *proto_str = (proto == SOCKET_PROTOCOL_UDP) ? - "UDP" : "TCP"; - struct natt_status tmp = {0}; - struct addrinfo hints = {0}; - struct addrinfo *ext_addrinfo = NULL; - - /* if NAT traversal is uninitialized or unavailable, oh well */ - if (!status) - return false; - - if (string_is_empty(urls.controlURL)) - return false; - - /* figure out the internal info */ - if (getnameinfo(addr, addrlen, host, sizeof(host), - port_str, sizeof(port_str), NI_NUMERICHOST | NI_NUMERICSERV)) - return false; - - /* get the external IP */ - r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, - ext_host); - if (r) - return false; - - /* add the port mapping */ - r = UPNP_AddAnyPortMapping(urls.controlURL, data.first.servicetype, - port_str, port_str, host, "retroarch", - proto_str, NULL, "0", ext_port_str); - if (r) - { - /* try the older AddPortMapping */ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port_str, port_str, host, "retroarch", - proto_str, NULL, "0"); - if (r) + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; + if (getaddrinfo_retro("239.255.255.250", "1900", &hints, &addr)) return false; - - memcpy(ext_port_str, port_str, sizeof(ext_port_str)); + if (!addr) + return false; + memcpy(&msearch_addr, addr->ai_addr, sizeof(msearch_addr)); + freeaddrinfo_retro(addr); } - /* update the status */ - if (getaddrinfo_retro(ext_host, ext_port_str, - &hints, &ext_addrinfo) || !ext_addrinfo) + if (!net_ifinfo_new(&st->interfaces)) + goto failure; + if (!st->interfaces.size) + goto failure; + + st->fd = socket_init((void**) &bind_addr, 0, NULL, SOCKET_TYPE_DATAGRAM); + if (st->fd < 0) + goto failure; + if (!bind_addr) goto failure; - if (ext_addrinfo->ai_family == AF_INET && - ext_addrinfo->ai_addrlen >= sizeof(status->ext_inet4_addr)) { - status->have_inet4 = true; - memcpy(&status->ext_inet4_addr, ext_addrinfo->ai_addr, - sizeof(status->ext_inet4_addr)); - } -#if defined(AF_INET6) && !defined(_3DS) - else if (ext_addrinfo->ai_family == AF_INET6 && - ext_addrinfo->ai_addrlen >= sizeof(status->ext_inet6_addr)) - { - status->have_inet6 = true; - memcpy(&status->ext_inet6_addr, ext_addrinfo->ai_addr, - sizeof(status->ext_inet6_addr)); - } +#ifdef _WIN32 + unsigned long ttl; +#else + unsigned char ttl; #endif - else - { - freeaddrinfo_retro(ext_addrinfo); - goto failure; + ttl = 2; + setsockopt(st->fd, IPPROTO_IP, IP_MULTICAST_TTL, + (const char *) &ttl, sizeof(ttl)); } - freeaddrinfo_retro(ext_addrinfo); + if (!socket_bind(st->fd, bind_addr)) + goto failure; + + /* Broadcast a discovery request. */ + if (sendto(st->fd, msearch, sizeof(msearch) - 1, 0, + (struct sockaddr *) &msearch_addr, + sizeof(msearch_addr)) != sizeof(msearch) - 1) + goto failure; + + if (!socket_nonblock(st->fd)) + goto failure; + + /* 2 seconds */ + st->timeout = cpu_features_get_time_usec() + 2000000; + + freeaddrinfo_retro(bind_addr); return true; failure: - tmp.have_inet4 = true; - tmp.ext_inet4_addr.sin_family = AF_INET; - sscanf(ext_port_str, "%hu", &tmp.ext_inet4_addr.sin_port); - - natt_close_port(&tmp, proto); + /* Failed to broadcast. */ + freeaddrinfo_retro(bind_addr); + natt_deinit(); #endif return false; } -bool natt_open_port_any(struct natt_status *status, - uint16_t port, enum socket_protocol proto) +void natt_deinit(void) { -#if !defined(HAVE_SOCKET_LEGACY) && (!defined(SWITCH) || defined(HAVE_LIBNX)) - size_t i; - struct net_ifinfo list; - struct addrinfo *addr; - char port_str[6]; - struct addrinfo hints = {0}; +#ifndef HAVE_SOCKET_LEGACY + natt_state_t *st = &natt_st; - /* get our interfaces */ - if (!net_ifinfo_new(&list)) + natt_device_end(); + natt_interfaces_destroy(); + + /* This is faster than memsetting the whole thing. */ + *st->device.desc = '\0'; + *st->device.control = '\0'; + *st->device.service_type = '\0'; + memset(&st->device.ext_addr, 0, sizeof(st->device.ext_addr)); + st->device.busy = false; +#endif +} + +void natt_interfaces_destroy(void) +{ +#ifndef HAVE_SOCKET_LEGACY + natt_state_t *st = &natt_st; + + net_ifinfo_free(&st->interfaces); + memset(&st->interfaces, 0, sizeof(st->interfaces)); +#endif +} + +bool natt_device_next(struct natt_device *device) +{ +#ifndef HAVE_SOCKET_LEGACY + fd_set fds; + bool error; + char buf[2048]; + ssize_t recvd; + char *data; + size_t remaining; + struct timeval tv = {0}; + natt_state_t *st = &natt_st; + + if (!device) return false; - /* loop through them */ - snprintf(port_str, sizeof(port_str), "%hu", port); - for (i = 0; i < list.size; i++) + if (st->fd < 0) + return false; + + /* This is faster than memsetting the whole thing. */ + *device->desc = '\0'; + *device->control = '\0'; + *device->service_type = '\0'; + memset(&device->ext_addr, 0, sizeof(device->ext_addr)); + device->busy = false; + + /* Check our file descriptor to see if a device sent data to it. */ + FD_ZERO(&fds); + FD_SET(st->fd, &fds); + if (socket_select(st->fd + 1, &fds, NULL, NULL, &tv) < 0) + return false; + /* If there was no data, check for timeout. */ + if (!FD_ISSET(st->fd, &fds)) + return cpu_features_get_time_usec() < st->timeout; + + recvd = socket_receive_all_nonblocking(st->fd, &error, + buf, sizeof(buf)); + if (recvd <= 0) + return false; + + /* Parse the data we received. + We are only looking for the 'Location' HTTP header. */ + data = buf; + remaining = (size_t) recvd; + do { - struct net_ifinfo_entry *entry = &list.entries[i]; + char *lnbreak = (char *) memchr(data, '\n', remaining); + if (!lnbreak) + break; + *lnbreak++ = '\0'; - /* ignore localhost */ - if (string_is_equal(entry->host, "127.0.0.1")) - continue; - - /* ignore IPv6 for now */ - if (strchr(entry->host, ':')) - continue; - - addr = NULL; - if (getaddrinfo_retro(entry->host, port_str, &hints, &addr) || - !addr) - continue; - - /* make a request for this host */ - if (natt_open_port(status, addr->ai_addr, addr->ai_addrlen, - proto)) + /* This also gets rid of any trailing carriage return. */ + if (strcasecmp(string_trim_whitespace(data), "Location:")) { - freeaddrinfo_retro(addr); - net_ifinfo_free(&list); + char *location = string_trim_whitespace( + data + STRLEN_CONST("Location:")); - return true; + if (!string_is_empty(location) && + string_starts_with_case_insensitive(location, "http://")) + { + strlcpy(device->desc, location, + sizeof(device->desc)); + + return true; + } } - freeaddrinfo_retro(addr); - } + remaining -= (size_t)lnbreak - (size_t)data; + data = lnbreak; + } while (remaining); - net_ifinfo_free(&list); -#endif - - return false; -} - -bool natt_close_port(struct natt_status *status, - enum socket_protocol proto) -{ -#if !defined(HAVE_SOCKET_LEGACY) && HAVE_MINIUPNPC - const struct sockaddr *addr; - socklen_t addrlen; - char port_str[6]; - const char *proto_str = (proto == SOCKET_PROTOCOL_UDP) ? - "UDP" : "TCP"; - - if (!status) - return false; - - if (string_is_empty(urls.controlURL)) - return false; - - /* Grab our external port */ - if (status->have_inet4) - { - addr = (struct sockaddr *) &status->ext_inet4_addr; - addrlen = sizeof(status->ext_inet4_addr); - } -#if defined(AF_INET6) && !defined(_3DS) - else if (status->have_inet6) - { - addr = (struct sockaddr *) &status->ext_inet6_addr; - addrlen = sizeof(status->ext_inet6_addr); - } -#endif - else - return false; - - if (getnameinfo(addr, addrlen, NULL, 0, - port_str, sizeof(port_str), NI_NUMERICSERV)) - return false; - - /* Request the device to remove our port forwarding. */ - return !UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, - port_str, proto_str, NULL); + /* This is not a failure. + We just don't yet have a valid device to report. */ + return true; #else return false; #endif } -bool natt_read(struct natt_status *status) +void natt_device_end(void) { - /* MiniUPNPC is always synchronous, so there's nothing to read here. - * Reserved for future backends. */ +#ifndef HAVE_SOCKET_LEGACY + natt_state_t *st = &natt_st; + + if (st->fd >= 0) + { + socket_close(st->fd); + st->fd = -1; + } +#endif +} + +static bool build_control_url(rxml_node_t *control_url, + struct natt_device *device) +{ + if (string_is_empty(control_url->data)) + return false; + + /* Do we already have the full url? */ + if (string_starts_with_case_insensitive(control_url->data, "http://")) + { + strlcpy(device->control, control_url->data, + sizeof(device->control)); + } + else + { + /* We don't have a full url. + Build one using the desc url. */ + char *control_path; + + strlcpy(device->control, device->desc, + sizeof(device->control)); + + control_path = (char*) strchr(device->control + STRLEN_CONST("http://"), + '/'); + + if (control_path) + *control_path = '\0'; + if (control_url->data[0] != '/') + strlcat(device->control, "/", sizeof(device->control)); + strlcat(device->control, control_url->data, + sizeof(device->control)); + } + + return true; +} + +static bool parse_desc_node(rxml_node_t *node, + struct natt_device *device) +{ + rxml_node_t *child = node->children; + + if (!child) + return false; + + /* We only care for services. */ + if (string_is_equal_case_insensitive(node->name, "service")) + { + rxml_node_t *service_type = NULL; + rxml_node_t *control_url = NULL; + + do + { + if (string_is_equal_case_insensitive(child->name, "serviceType")) + service_type = child; + else if (string_is_equal_case_insensitive(child->name, "controlURL")) + control_url = child; + if (service_type && control_url) + break; + } while ((child = child->next)); + + if (!service_type || !control_url) + return false; + + /* These two are the only IGD service types we can work with. */ + if (!strstr(service_type->data, "WANIPConnection:1") && + !strstr(service_type->data, "WANPPPConnection:1")) + return false; + if (!build_control_url(control_url, device)) + return false; + + strlcpy(device->service_type, service_type->data, + sizeof(device->service_type)); + + return true; + } + + /* XML recursion */ + do + { + if (parse_desc_node(child, device)) + return true; + } while ((child = child->next)); + return false; } + +static void natt_query_device_cb(retro_task_t *task, void *task_data, + void *user_data, const char *error) +{ + char *xml; + rxml_document_t *document; + http_transfer_data_t *data = task_data; + struct natt_device *device = user_data; + + if (error) + goto done; + if (!data || !data->data || !data->len) + goto done; + if (data->status != 200) + goto done; + + xml = malloc(data->len + 1); + if (!xml) + goto done; + memcpy(xml, data->data, data->len); + xml[data->len] = '\0'; + + /* Parse the device's description XML. */ + document = rxml_load_document_string(xml); + if (document) + { + rxml_node_t *root = rxml_root_node(document); + if (root) + parse_desc_node(root, device); + + rxml_free_document(document); + } + + free(xml); + +done: + device->busy = false; +} + +bool natt_query_device(struct natt_device *device, bool block) +{ +#ifndef HAVE_SOCKET_LEGACY + if (!device) + return false; + + if (string_is_empty(device->desc)) + return false; + + if (device->busy) + return false; + device->busy = true; + + if (!task_push_http_transfer(device->desc, + true, NULL, natt_query_device_cb, device)) + { + device->busy = false; + return false; + } + + if (block) + task_queue_wait(NULL, NULL); + + return true; +#else + return false; +#endif +} + +static bool parse_external_address_node(rxml_node_t *node, + struct natt_device *device) +{ + if (string_is_equal_case_insensitive(node->name, "NewExternalIPAddress")) + { + struct addrinfo *addr = NULL; + struct addrinfo hints = {0}; + + if (string_is_empty(node->data)) + return false; + + hints.ai_family = AF_INET; + if (getaddrinfo_retro(node->data, "0", &hints, &addr)) + return false; + if (!addr) + return false; + memcpy(&device->ext_addr, addr->ai_addr, + sizeof(device->ext_addr)); + freeaddrinfo_retro(addr); + + return true; + } + else + { + /* XML recursion */ + rxml_node_t *child = node->children; + + do + { + if (parse_external_address_node(child, device)) + return true; + } while ((child = child->next)); + } + + return false; +} + +static void natt_external_address_cb(retro_task_t *task, void *task_data, + void *user_data, const char *error) +{ + char *xml; + rxml_document_t *document; + http_transfer_data_t *data = task_data; + struct natt_device *device = user_data; + + if (error) + goto done; + if (!data || !data->data || !data->len) + goto done; + if (data->status != 200) + goto done; + + xml = malloc(data->len + 1); + if (!xml) + goto done; + memcpy(xml, data->data, data->len); + xml[data->len] = '\0'; + + /* Parse the returned external ip address. */ + document = rxml_load_document_string(xml); + if (document) + { + rxml_node_t *root = rxml_root_node(document); + if (root) + parse_external_address_node(root, device); + + rxml_free_document(document); + } + + free(xml); + +done: + device->busy = false; +} + +static bool parse_open_port_node(rxml_node_t *node, + struct natt_request *request) +{ + if (string_is_equal_case_insensitive(node->name, "u:AddPortMappingResponse")) + { + request->success = true; + memcpy(&request->addr.sin_addr, &request->device->ext_addr.sin_addr, + sizeof(request->addr.sin_addr)); + + return true; + } + else if (string_is_equal_case_insensitive(node->name, "NewReservedPort")) + { + uint16_t ext_port = 0; + + if (string_is_empty(node->data)) + return false; + + sscanf(node->data, "%hu", &ext_port); + if (!ext_port) + return false; + + request->success = true; + request->addr.sin_port = htons(ext_port); + memcpy(&request->addr.sin_addr, &request->device->ext_addr.sin_addr, + sizeof(request->addr.sin_addr)); + + return true; + } + else + { + /* XML recursion */ + rxml_node_t *child = node->children; + + do + { + if (parse_open_port_node(child, request)) + return true; + } while ((child = child->next)); + } + + return false; +} + +static void natt_open_port_cb(retro_task_t *task, void *task_data, + void *user_data, const char *error) +{ + char *xml; + rxml_document_t *document; + http_transfer_data_t *data = task_data; + struct natt_request *request = user_data; + struct natt_device *device = request->device; + + request->success = false; + + if (error) + goto done; + if (!data || !data->data || !data->len) + goto done; + if (data->status != 200) + goto done; + + xml = malloc(data->len + 1); + if (!xml) + goto done; + memcpy(xml, data->data, data->len); + xml[data->len] = '\0'; + + /* Parse the device's port forwarding response. */ + document = rxml_load_document_string(xml); + if (document) + { + rxml_node_t *root = rxml_root_node(document); + if (root) + parse_open_port_node(root, request); + + rxml_free_document(document); + } + + free(xml); + +done: + device->busy = false; +} + +static void natt_close_port_cb(retro_task_t *task, void *task_data, + void *user_data, const char *error) +{ + http_transfer_data_t *data = task_data; + struct natt_request *request = user_data; + struct natt_device *device = request->device; + + request->success = false; + + if (error) + goto done; + if (!data || !data->data || !data->len) + goto done; + if (data->status != 200) + goto done; + + /* We don't need to do anything special here. + * Just clear up the request. */ + memset(request, 0, sizeof(*request)); + request->success = true; + +done: + device->busy = false; +} + +static bool natt_action(struct natt_device *device, + const char *action, const char *data, retro_task_callback_t cb, + struct natt_request *request) +{ + static const char headers_template[] = + "Content-Type: text/xml\r\n" + "SOAPAction: \"%s#%s\"\r\n"; + char headers[512]; + void *obj; + + snprintf(headers, sizeof(headers), headers_template, + device->service_type, action); + + if (request) + { + request->device = device; + obj = request; + } + else + obj = device; + + return task_push_http_post_transfer_with_headers(device->control, + data, true, NULL, headers, cb, obj) != NULL; +} + +bool natt_external_address(struct natt_device *device, bool block) +{ +#ifndef HAVE_SOCKET_LEGACY + static const char template[] = + "" + "" + "" + "" + "" + ""; + char buf[1024]; + + if (!device) + return false; + + if (string_is_empty(device->control)) + return false; + + if (device->busy) + return false; + device->busy = true; + + snprintf(buf, sizeof(buf), template, + device->service_type); + + if (!natt_action(device, "GetExternalIPAddress", buf, + natt_external_address_cb, NULL)) + { + device->busy = false; + return false; + } + + if (block) + task_queue_wait(NULL, NULL); + + return true; +#else + return false; +#endif +} + +bool natt_open_port(struct natt_device *device, + struct natt_request *request, enum natt_forward_type forward_type, + bool block) +{ +#ifndef HAVE_SOCKET_LEGACY + static const char template[] = + "" + "" + "" + "" + "" + "%s" + "%s" + "%s" + "%s" + "1" + "retroarch" + "0" + "" + "" + ""; + char buf[1024]; + const char *action; + char host[256], port[6]; + + if (!device || !request) + return false; + + if (string_is_empty(device->control)) + return false; + + if (device->ext_addr.sin_family != AF_INET) + return false; + + if (!request->addr.sin_port) + return false; + + if (getnameinfo((struct sockaddr *) &request->addr, + sizeof(request->addr), host, sizeof(host), + port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV)) + return false; + + if (device->busy) + return false; + device->busy = true; + + action = (forward_type == NATT_FORWARD_TYPE_ANY) ? + "AddAnyPortMapping" : "AddPortMapping"; + + snprintf(buf, sizeof(buf), template, + action, device->service_type, port, + (request->proto == SOCKET_PROTOCOL_UDP) ? + "UDP" : "TCP", + port, host, + action); + + if (!natt_action(device, action, buf, + natt_open_port_cb, request)) + { + device->busy = false; + return false; + } + + if (block) + task_queue_wait(NULL, NULL); + + return true; +#else + return false; +#endif +} + +bool natt_close_port(struct natt_device *device, + struct natt_request *request, bool block) +{ +#ifndef HAVE_SOCKET_LEGACY + static const char template[] = + "" + "" + "" + "" + "" + "%s" + "%s" + "" + "" + ""; + char buf[1024]; + char port[6]; + + if (!device || !request) + return false; + + if (string_is_empty(device->control)) + return false; + + if (device->ext_addr.sin_family != AF_INET) + return false; + + if (!request->addr.sin_port) + return false; + + if (getnameinfo((struct sockaddr *) &request->addr, + sizeof(request->addr), NULL, 0, + port, sizeof(port), NI_NUMERICSERV)) + return false; + + if (device->busy) + return false; + device->busy = true; + + snprintf(buf, sizeof(buf), template, + device->service_type, port, + (request->proto == SOCKET_PROTOCOL_UDP) ? + "UDP" : "TCP"); + + if (!natt_action(device, "DeletePortMapping", buf, + natt_close_port_cb, request)) + { + device->busy = false; + return false; + } + + if (block) + task_queue_wait(NULL, NULL); + + return true; +#else + return false; +#endif +} diff --git a/network/netplay/netplay.h b/network/netplay/netplay.h index d8412a6b93..bdee47b7b2 100644 --- a/network/netplay/netplay.h +++ b/network/netplay/netplay.h @@ -30,6 +30,7 @@ #include #include +#include #include #include "../../core.h" @@ -213,6 +214,8 @@ typedef struct bool has_set_netplay_ip_port; bool has_set_netplay_stateless_mode; bool has_set_netplay_check_frames; + /* NAT traversal info (if NAT traversal is used and serving) */ + struct nat_traversal_data nat_traversal_request; } net_driver_state_t; net_driver_state_t *networking_state_get_ptr(void); diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 2959de41a0..23bf1f0ba3 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -5530,44 +5530,25 @@ void netplay_handle_slaves(netplay_t *netplay) */ void netplay_announce_nat_traversal(netplay_t *netplay) { -#if !defined(HAVE_SOCKET_LEGACY) && HAVE_MINIUPNPC +#ifndef HAVE_SOCKET_LEGACY char msg[512], host[256], port[6]; - const char *dmsg = NULL; + const char *dmsg = NULL; + net_driver_state_t *net_st = &networking_driver_st; - if (netplay->nat_traversal_state.have_inet4) + if (net_st->nat_traversal_request.status == NAT_TRAVERSAL_STATUS_OPENED) { if (!getnameinfo( - (const struct sockaddr *) - &netplay->nat_traversal_state.ext_inet4_addr, - sizeof(netplay->nat_traversal_state.ext_inet4_addr), - host, sizeof(host), port, sizeof(port), - NI_NUMERICHOST | NI_NUMERICSERV)) + (struct sockaddr *) &net_st->nat_traversal_request.request.addr, + sizeof(net_st->nat_traversal_request.request.addr), + host, sizeof(host), port, sizeof(port), + NI_NUMERICHOST | NI_NUMERICSERV)) { snprintf(msg, sizeof(msg), "%s: %s:%s", msg_hash_to_str(MSG_PUBLIC_ADDRESS), host, port); dmsg = msg; } - - } -#ifdef HAVE_INET6 - else if (netplay->nat_traversal_state.have_inet6) - { - if (!getnameinfo( - (const struct sockaddr *) - &netplay->nat_traversal_state.ext_inet6_addr, - sizeof(netplay->nat_traversal_state.ext_inet6_addr), - host, sizeof(host), port, sizeof(port), - NI_NUMERICHOST | NI_NUMERICSERV)) - { - snprintf(msg, sizeof(msg), "%s: %s|%s", - msg_hash_to_str(MSG_PUBLIC_ADDRESS), - host, port); - dmsg = msg; - } - } -#endif else dmsg = msg_hash_to_str(MSG_UPNP_FAILED); @@ -5586,7 +5567,16 @@ void netplay_announce_nat_traversal(netplay_t *netplay) */ void netplay_init_nat_traversal(netplay_t *netplay) { - task_push_netplay_nat_traversal(&netplay->nat_traversal_state, netplay->tcp_port); + net_driver_state_t *net_st = &networking_driver_st; + + task_push_netplay_nat_traversal(&net_st->nat_traversal_request, netplay->tcp_port); +} + +void netplay_deinit_nat_traversal(void) +{ + net_driver_state_t *net_st = &networking_driver_st; + + task_push_netplay_nat_close(&net_st->nat_traversal_request); } static int init_tcp_connection(const struct addrinfo *res, @@ -6113,9 +6103,6 @@ void netplay_free(netplay_t *netplay) if (netplay->connections && netplay->connections != &netplay->one_connection) free(netplay->connections); - if (netplay->nat_traversal) - task_push_netplay_nat_close(&netplay->nat_traversal_state); - if (netplay->buffer) { for (i = 0; i < netplay->buffer_size; i++) @@ -7321,16 +7308,19 @@ static bool netplay_pre_frame( void deinit_netplay(void) { - net_driver_state_t *net_st = &networking_driver_st; + net_driver_state_t *net_st = &networking_driver_st; if (net_st->data) { + if (net_st->data->nat_traversal) + netplay_deinit_nat_traversal(); + netplay_free(net_st->data); net_st->netplay_enabled = false; net_st->netplay_is_client = false; net_st->is_mitm = false; + net_st->data = NULL; } - net_st->data = NULL; core_unset_netplay_callbacks(); } diff --git a/network/netplay/netplay_private.h b/network/netplay/netplay_private.h index ac8e85e336..710055697e 100644 --- a/network/netplay/netplay_private.h +++ b/network/netplay/netplay_private.h @@ -21,7 +21,6 @@ #include "netplay.h" #include -#include #include #include @@ -452,9 +451,6 @@ struct netplay struct retro_callbacks cbs; - /* NAT traversal info (if NAT traversal is used and serving) */ - struct natt_status nat_traversal_state; - struct delta_frame *buffer; size_t buffer_size; @@ -873,6 +869,8 @@ void netplay_announce_nat_traversal(netplay_t *netplay); */ void netplay_init_nat_traversal(netplay_t *netplay); +void netplay_deinit_nat_traversal(void); + /*************************************************************** * NETPLAY-KEYBOARD.C **************************************************************/ diff --git a/pkg/android/phoenix-common/jni/Android.mk b/pkg/android/phoenix-common/jni/Android.mk index c3a4b5b9ce..837b5c61cd 100644 --- a/pkg/android/phoenix-common/jni/Android.mk +++ b/pkg/android/phoenix-common/jni/Android.mk @@ -119,10 +119,6 @@ DEFINES += -DRARCH_MOBILE \ -DHAVE_UPDATE_ASSETS \ -DHAVE_UPDATE_CORES \ -DHAVE_CC_RESAMPLER \ - -DHAVE_MINIUPNPC \ - -DHAVE_BUILTINMINIUPNPC \ - -DMINIUPNPC_SET_SOCKET_TIMEOUT \ - -DMINIUPNPC_GET_SRC_ADDR \ -DHAVE_KEYMAPPER \ -DHAVE_NETWORKGAMEPAD \ -DHAVE_FLAC \ diff --git a/pkg/android/phoenix-legacy/msvc-2017-android.NativeActivity.vcxproj b/pkg/android/phoenix-legacy/msvc-2017-android.NativeActivity.vcxproj index 0fab597c45..d114ea785e 100644 --- a/pkg/android/phoenix-legacy/msvc-2017-android.NativeActivity.vcxproj +++ b/pkg/android/phoenix-legacy/msvc-2017-android.NativeActivity.vcxproj @@ -176,7 +176,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_CONFIGFILE;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -188,7 +188,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -200,7 +200,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -212,7 +212,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -224,7 +224,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -236,7 +236,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -248,7 +248,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled @@ -260,7 +260,7 @@ NotUsing CompileAsCpp $(SolutionDir)\..\..\..\libretro-common\include;$(SolutionDir)\..\..\..\deps;$(SolutionDir)\..\..\..\deps\libFLAC\include;$(SolutionDir)\..\..\..\deps\stb;$(SolutionDir)\..\..\..\deps\7zip;$(SolutionDir)\..\..\..\gfx\include;$(SolutionDir)\..\..\..\deps\glslang;$(SolutionDir)\..\..\..\deps\glslang\glslang\Public;$(SolutionDir)\..\..\..\deps\glslang\glslang\MachineIndependent;$(SolutionDir)\..\..\..\deps\glslang\glslang\SPIRV;$(SolutionDir)\..\..\..\deps\SPIRV-Cross;%(AdditionalIncludeDirectories) - HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_MINIUPNPC;HAVE_BUILTINMINIUPNPC;MINIUPNPC_SET_SOCKET_TIMEOUT;MINIUPNPC_GET_SRC_ADDR;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) + HAVE_OPENGLES2;RARCH_MOBILE;HAVE_GRIFFIN;HAVE_STB_VORBIS;HAVE_LANGEXTRA;ANDROID;HAVE_DYNAMIC;HAVE_OPENGL;HAVE_OVERLAY;HAVE_VIDEO_LAYOUT;HAVE_OPENGLES;HAVE_DYLIB;HAVE_EGL;HAVE_GLSL;HAVE_MENU;HAVE_RGUI;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;INLINE=inline;HAVE_THREADS;__LIBRETRO__;HAVE_RSOUND;HAVE_NETWORKGAMEPAD;HAVE_NETWORKING;RARCH_INTERNAL;HAVE_FILTERS_BUILTIN;HAVE_MATERIALUI;HAVE_XMB;HAVE_SHADERPIPELINE;HAVE_LIBRETRODB;HAVE_STB_FONT;HAVE_IMAGEVIEWER;HAVE_UPDATE_ASSETS;HAVE_CC_RESAMPLER;HAVE_KEYMAPPER;HAVE_FLAC;HAVE_DR_FLAC;HAVE_DR_MP3;HAVE_CHD;HAVE_RUNAHEAD;ENABLE_HLSL;WANT_IFADDRS;HAVE_7ZIP;HAVE_CHEEVOS;HAVE_SL;FLAC_PACKAGE_VERSION="\"retroarch\"";HAVE_LROUND;FLAC__HAS_OGG=0;__STDC_LIMIT_MACROS;%(PreprocessorDefinitions) Enabled diff --git a/pkg/apple/BaseConfig.xcconfig b/pkg/apple/BaseConfig.xcconfig index 2810627363..e5b613a457 100644 --- a/pkg/apple/BaseConfig.xcconfig +++ b/pkg/apple/BaseConfig.xcconfig @@ -3,7 +3,7 @@ // RetroArch // // -OTHER_CFLAGS = $(inherited) -DHAVE_RUNAHEAD -DHAVE_GRIFFIN -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_LROUND -DFLAC__HAS_OGG=0 -DHAVE_CHD -DHAVE_STB_VORBIS -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_ONLINE_UPDATER -DHAVE_LANGEXTRA -DRC_DISABLE_LUA -DHAVE_CHEEVOS -DHAVE_IMAGEVIEWER -DHAVE_IOHIDMANAGER -DHAVE_STB_FONT -DHAVE_RGUI -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_DSP_FILTER -DHAVE_VIDEO_FILTER -DHAVE_REWIND -DHAVE_SCREENSHOTS -DHAVE_CHEATS -DHAVE_GFX_WIDGETS -DOSX -DHAVE_CC_RESAMPLER -DHAVE_GLSL -DINLINE=inline -D__LIBRETRO__ -DHAVE_COREAUDIO -DHAVE_DYNAMIC -DHAVE_OVERLAY -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DHAVE_NETPLAYDISCOVERY -DRARCH_INTERNAL -DHAVE_THREADS -DHAVE_DYLIB -DHAVE_7ZIP -D_7ZIP_ST -DHAVE_MATERIALUI -DHAVE_HID -DHAVE_XMB -DHAVE_SHADERPIPELINE -DHAVE_MMAP -DHAVE_LIBRETRODB -DHAVE_GETOPT_LONG -DHAVE_METAL -DHAVE_COCOA_METAL -DHAVE_SLANG -DHAVE_GLSLANG -DHAVE_BUILTINGLSLANG -DHAVE_SPIRV_CROSS -DWANT_GLSLANG -DENABLE_HLSL -DGLSLANG_OSINCLUDE_UNIX -DMETAL_DEBUG -DHAVE_OPENGL -DHAVE_OZONE -DHAVE_EASTEREGG -DHAVE_GIT_VERSION -DHAVE_COREAUDIO3 -DHAVE_AUDIOMIXER -DHAVE_RWAV -DHAVE_NO_BUILTINZLIB -DHAVE_TRANSLATE -DHAVE_VIDEO_LAYOUT -DHAVE_COMMAND -DHAVE_NETWORK_CMD -DHAVE_ACCESSIBILITY -DHAVE_TRANSLATE -DHAVE_DISCORD -DHAVE_CORE_INFO_CACHE +OTHER_CFLAGS = $(inherited) -DHAVE_RUNAHEAD -DHAVE_GRIFFIN -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_LROUND -DFLAC__HAS_OGG=0 -DHAVE_CHD -DHAVE_STB_VORBIS -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_ONLINE_UPDATER -DHAVE_LANGEXTRA -DRC_DISABLE_LUA -DHAVE_CHEEVOS -DHAVE_IMAGEVIEWER -DHAVE_IOHIDMANAGER -DHAVE_STB_FONT -DHAVE_RGUI -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_DSP_FILTER -DHAVE_VIDEO_FILTER -DHAVE_REWIND -DHAVE_SCREENSHOTS -DHAVE_CHEATS -DHAVE_GFX_WIDGETS -DOSX -DHAVE_CC_RESAMPLER -DHAVE_GLSL -DINLINE=inline -D__LIBRETRO__ -DHAVE_COREAUDIO -DHAVE_DYNAMIC -DHAVE_OVERLAY -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DHAVE_NETPLAYDISCOVERY -DRARCH_INTERNAL -DHAVE_THREADS -DHAVE_DYLIB -DHAVE_7ZIP -D_7ZIP_ST -DHAVE_MATERIALUI -DHAVE_HID -DHAVE_XMB -DHAVE_SHADERPIPELINE -DHAVE_MMAP -DHAVE_LIBRETRODB -DHAVE_GETOPT_LONG -DHAVE_METAL -DHAVE_COCOA_METAL -DHAVE_SLANG -DHAVE_GLSLANG -DHAVE_BUILTINGLSLANG -DHAVE_SPIRV_CROSS -DWANT_GLSLANG -DENABLE_HLSL -DGLSLANG_OSINCLUDE_UNIX -DMETAL_DEBUG -DHAVE_OPENGL -DHAVE_OZONE -DHAVE_EASTEREGG -DHAVE_GIT_VERSION -DHAVE_COREAUDIO3 -DHAVE_AUDIOMIXER -DHAVE_RWAV -DHAVE_NO_BUILTINZLIB -DHAVE_TRANSLATE -DHAVE_VIDEO_LAYOUT -DHAVE_COMMAND -DHAVE_NETWORK_CMD -DHAVE_ACCESSIBILITY -DHAVE_TRANSLATE -DHAVE_DISCORD -DHAVE_CORE_INFO_CACHE SRCBASE = $(SRCROOT)/../.. DEPS_DIR = $(SRCBASE)/deps diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj index 304682ba6c..0692f0c662 100644 --- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj @@ -564,8 +564,6 @@ "-DFLAC__HAS_OGG=0", "-DHAVE_CHD", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -651,8 +649,6 @@ "-DFLAC__HAS_OGG=0", "-DHAVE_CHD", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_OSX107.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_OSX107.xcodeproj/project.pbxproj index 1153de9b90..6c0ba70869 100644 --- a/pkg/apple/RetroArch_OSX107.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_OSX107.xcodeproj/project.pbxproj @@ -566,8 +566,6 @@ "-DFLAC__HAS_OGG=0", "-DHAVE_CHD", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -654,8 +652,6 @@ "-DFLAC__HAS_OGG=0", "-DHAVE_CHD", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj index 3887a6a03a..c77178227f 100644 --- a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj @@ -295,8 +295,6 @@ "-DHAVE_COMMAND", "-DHAVE_NETWORK_CMD", "-DHAVE_GRIFFIN", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -389,8 +387,6 @@ "-DHAVE_COMMAND", "-DHAVE_NETWORK_CMD", "-DHAVE_GRIFFIN", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_iOS10.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS10.xcodeproj/project.pbxproj index bfdc017682..1ebb2f343a 100644 --- a/pkg/apple/RetroArch_iOS10.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS10.xcodeproj/project.pbxproj @@ -490,8 +490,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -595,8 +593,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -663,8 +659,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -766,8 +760,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -851,8 +843,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_iOS10_static.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS10_static.xcodeproj/project.pbxproj index 1a3a6966cf..fb75b78636 100644 --- a/pkg/apple/RetroArch_iOS10_static.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS10_static.xcodeproj/project.pbxproj @@ -494,8 +494,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -598,8 +596,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -666,8 +662,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -767,8 +761,6 @@ "-DHAVE_NETPLAYDISCOVERY", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -850,8 +842,6 @@ "-DHAVE_NETPLAYDISCOVERY", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_iOS11.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS11.xcodeproj/project.pbxproj index 05010aebf8..d7d432e87e 100644 --- a/pkg/apple/RetroArch_iOS11.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS11.xcodeproj/project.pbxproj @@ -640,8 +640,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -741,8 +739,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -872,8 +868,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1001,8 +995,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1101,8 +1093,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1185,8 +1175,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", diff --git a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj index 5be9d875fa..7cb302cebc 100644 --- a/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS11_Metal.xcodeproj/project.pbxproj @@ -1311,8 +1311,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1430,8 +1428,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1486,8 +1482,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1633,8 +1627,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1770,8 +1762,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1878,8 +1868,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -1954,8 +1942,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", diff --git a/pkg/apple/RetroArch_iOS11_static.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS11_static.xcodeproj/project.pbxproj index c86e8b924a..948743b15a 100644 --- a/pkg/apple/RetroArch_iOS11_static.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS11_static.xcodeproj/project.pbxproj @@ -494,8 +494,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -598,8 +596,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -666,8 +662,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -767,8 +761,6 @@ "-DHAVE_NETPLAYDISCOVERY", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -850,8 +842,6 @@ "-DHAVE_NETPLAYDISCOVERY", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_iOS6.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS6.xcodeproj/project.pbxproj index 3f0d60b009..8982f13358 100644 --- a/pkg/apple/RetroArch_iOS6.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS6.xcodeproj/project.pbxproj @@ -485,8 +485,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -588,8 +586,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -654,8 +650,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -754,8 +748,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -839,8 +831,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", diff --git a/pkg/apple/RetroArch_iOS8.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS8.xcodeproj/project.pbxproj index afb3ea1072..f3ee197198 100644 --- a/pkg/apple/RetroArch_iOS8.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS8.xcodeproj/project.pbxproj @@ -463,8 +463,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -549,8 +547,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -644,8 +640,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -749,8 +743,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", @@ -818,8 +810,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_UPDATE_CORES", "-DHAVE_ONLINE_UPDATER", diff --git a/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj index 5aabad3f63..44bcb53975 100644 --- a/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj @@ -484,8 +484,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -587,8 +585,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -655,8 +651,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -758,8 +752,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", @@ -843,8 +835,6 @@ "-DHAVE_TRANSLATE", "-DHAVE_GRIFFIN", "-DHAVE_STB_VORBIS", - "-DHAVE_MINIUPNPC", - "-DHAVE_BUILTINMINIUPNPC", "-DHAVE_UPDATE_ASSETS", "-DHAVE_ONLINE_UPDATER", "-DHAVE_LANGEXTRA", diff --git a/qb/config.libs.sh b/qb/config.libs.sh index e608bfa5f6..d2f35bc158 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -202,15 +202,12 @@ fi check_enabled NETWORKING CHEEVOS cheevos 'Networking is' false check_enabled NETWORKING DISCORD discord 'Networking is' false -check_enabled NETWORKING MINIUPNPC miniupnpc 'Networking is' false check_enabled NETWORKING SSL ssl 'Networking is' false check_enabled NETWORKING TRANSLATE OCR 'Networking is' false check_enabled NETWORKING HAVE_NETPLAYDISCOVERY 'Netplay discovery' 'Networking is' false check_enabled NETWORKING NETWORKGAMEPAD 'the networked game pad' 'Networking is' true -check_enabled MINIUPNPC BUILTINMINIUPNPC 'builtin miniupnpc' 'miniupnpc is' true -check_lib '' MINIUPNPC '-lminiupnpc' check_lib '' STDIN_CMD "$CLIB" fcntl if [ "$HAVE_NETWORK_CMD" = "yes" ] || [ "$HAVE_STDIN_CMD" = "yes" ]; then diff --git a/qb/config.params.sh b/qb/config.params.sh index 4e4ab1961c..e73c43c5df 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -64,9 +64,6 @@ HAVE_NETWORKGAMEPAD=auto # Networked game pad (plus baked-in core) C89_NETWORKGAMEPAD=no HAVE_NETPLAYDISCOVERY=yes # Add netplay discovery (room creation, etc.) HAVE_COMMAND=no # Network command interface, to remote control RA -HAVE_MINIUPNPC=auto # Mini UPnP client library (for NAT traversal) -HAVE_BUILTINMINIUPNPC=auto # Bake in Mini UPnP client library (for NAT traversal) -C89_BUILTINMINIUPNPC=no HAVE_D3D8=no # Direct3D 8 support HAVE_D3D9=auto # Direct3D 9 support C89_D3D9=no diff --git a/tasks/task_http.c b/tasks/task_http.c index f1040bf48f..5bf5b4ff43 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -406,10 +406,10 @@ void* task_push_http_transfer_file(const char* url, bool mute, } void* task_push_http_transfer_with_user_agent(const char *url, bool mute, - const char *type, const char* user_agent, + const char *type, const char *user_agent, retro_task_callback_t cb, void *user_data) { - struct http_connection_t* conn; + struct http_connection_t *conn; if (string_is_empty(url)) return NULL; @@ -425,6 +425,26 @@ void* task_push_http_transfer_with_user_agent(const char *url, bool mute, return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data); } +void* task_push_http_transfer_with_headers(const char *url, bool mute, + const char *type, const char *headers, + retro_task_callback_t cb, void *user_data) +{ + struct http_connection_t *conn; + + if (string_is_empty(url)) + return NULL; + + conn = net_http_connection_new(url, "GET", NULL); + if (!conn) + return NULL; + + if (headers != NULL) + net_http_connection_set_headers(conn, headers); + + /* assert: task_push_http_transfer_generic will free conn on failure */ + return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data); +} + void* task_push_http_post_transfer(const char *url, const char *post_data, bool mute, const char *type, retro_task_callback_t cb, void *user_data) @@ -438,7 +458,7 @@ void* task_push_http_post_transfer(const char *url, void* task_push_http_post_transfer_with_user_agent(const char *url, const char *post_data, bool mute, - const char *type, const char* user_agent, + const char *type, const char *user_agent, retro_task_callback_t cb, void *user_data) { struct http_connection_t* conn; @@ -457,6 +477,27 @@ void* task_push_http_post_transfer_with_user_agent(const char *url, return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data); } +void* task_push_http_post_transfer_with_headers(const char *url, + const char *post_data, bool mute, + const char *type, const char *headers, + retro_task_callback_t cb, void *user_data) +{ + struct http_connection_t* conn; + + if (string_is_empty(url)) + return NULL; + + conn = net_http_connection_new(url, "POST", post_data); + if (!conn) + return NULL; + + if (headers != NULL) + net_http_connection_set_headers(conn, headers); + + /* assert: task_push_http_transfer_generic will free conn on failure */ + return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data); +} + task_retriever_info_t *http_task_get_transfer_list(void) { task_retriever_data_t retrieve_data; diff --git a/tasks/task_netplay_nat_traversal.c b/tasks/task_netplay_nat_traversal.c index fc57706e62..1e9489effc 100644 --- a/tasks/task_netplay_nat_traversal.c +++ b/tasks/task_netplay_nat_traversal.c @@ -15,6 +15,8 @@ #include +#include + #include "tasks_internal.h" #ifdef HAVE_CONFIG_H @@ -25,39 +27,216 @@ #include #include "../network/netplay/netplay.h" -struct nat_traversal_state_data -{ - struct natt_status *nat_traversal_state; - uint16_t port; -}; - static void task_netplay_nat_traversal_handler(retro_task_t *task) { - struct nat_traversal_state_data *ntsd = - (struct nat_traversal_state_data *) task->task_data; + struct nat_traversal_data *data = task->task_data; + natt_state_t *natt_st = natt_state_get_ptr(); - if (natt_new(ntsd->nat_traversal_state)) - natt_init(ntsd->nat_traversal_state, ntsd->port, SOCKET_PROTOCOL_TCP); + /* Try again on the next call. */ + if (natt_st->device.busy) + return; + switch (data->status) + { + case NAT_TRAVERSAL_STATUS_DISCOVERY: + { + if (!natt_init()) + goto finished; + + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + } + break; + + case NAT_TRAVERSAL_STATUS_SELECT_DEVICE: + { + if (!natt_device_next(&natt_st->device)) + { + natt_deinit(); + goto finished; + } + if (!string_is_empty(natt_st->device.desc)) + data->status = NAT_TRAVERSAL_STATUS_QUERY_DEVICE; + } + break; + + case NAT_TRAVERSAL_STATUS_QUERY_DEVICE: + { + if (natt_query_device(&natt_st->device, false)) + data->status = NAT_TRAVERSAL_STATUS_EXTERNAL_ADDRESS; + else + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + } + break; + + case NAT_TRAVERSAL_STATUS_EXTERNAL_ADDRESS: + { + if (string_is_empty(natt_st->device.service_type)) + { + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + break; + } + if (natt_external_address(&natt_st->device, false)) + { + data->iface = 0; + data->forward_type = NATT_FORWARD_TYPE_ANY; + data->status = NAT_TRAVERSAL_STATUS_OPEN; + } + else + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + } + break; + + case NAT_TRAVERSAL_STATUS_OPEN: + { + size_t i; + struct addrinfo *addr = NULL; + struct net_ifinfo_entry *entry = NULL; + struct addrinfo hints = {0}; + + if (natt_st->device.ext_addr.sin_family != AF_INET) + { + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + break; + } + + /* Grab a suitable interface. */ + for (i = data->iface; i < natt_st->interfaces.size; i++) + { + struct net_ifinfo_entry *tmp_entry = + &natt_st->interfaces.entries[i]; + + /* Ignore localhost */ + if (string_is_equal(tmp_entry->host, "127.0.0.1")) + continue; + /* Ignore IPv6 */ + if (strchr(tmp_entry->host, ':')) + continue; + + entry = tmp_entry; + data->iface = i; + break; + } + + /* No more interfaces? */ + if (!entry) + { + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + break; + } + + if (getaddrinfo_retro(entry->host, NULL, &hints, &addr) || + !addr) + { + if (++data->iface < natt_st->interfaces.size) + data->forward_type = NATT_FORWARD_TYPE_ANY; + else + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + break; + } + + memcpy(&data->request.addr.sin_addr, + &((struct sockaddr_in *) addr->ai_addr)->sin_addr, + sizeof(data->request.addr.sin_addr)); + + freeaddrinfo_retro(addr); + + if (natt_open_port(&natt_st->device, + &data->request, data->forward_type, false)) + { + data->status = NAT_TRAVERSAL_STATUS_OPENING; + break; + } + if (data->forward_type == NATT_FORWARD_TYPE_ANY) + { + data->forward_type = NATT_FORWARD_TYPE_NONE; + break; + } + if (++data->iface < natt_st->interfaces.size) + data->forward_type = NATT_FORWARD_TYPE_ANY; + else + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + } + break; + + case NAT_TRAVERSAL_STATUS_OPENING: + { + if (data->request.success) + { + /* We no longer need these */ + natt_device_end(); + natt_interfaces_destroy(); + + data->status = NAT_TRAVERSAL_STATUS_OPENED; + goto finished; + } + if (data->forward_type == NATT_FORWARD_TYPE_ANY) + { + data->forward_type = NATT_FORWARD_TYPE_NONE; + data->status = NAT_TRAVERSAL_STATUS_OPEN; + break; + } + if (++data->iface < natt_st->interfaces.size) + { + data->forward_type = NATT_FORWARD_TYPE_ANY; + data->status = NAT_TRAVERSAL_STATUS_OPEN; + } + else + data->status = NAT_TRAVERSAL_STATUS_SELECT_DEVICE; + } + break; + default: + break; + } + + return; + +finished: task_set_progress(task, 100); task_set_finished(task, true); } static void task_netplay_nat_close_handler(retro_task_t *task) { - natt_deinit((struct natt_status *) task->task_data, - SOCKET_PROTOCOL_TCP); + struct nat_traversal_data *data = task->task_data; + natt_state_t *natt_st = natt_state_get_ptr(); + /* Try again on the next call. */ + if (natt_st->device.busy) + return; + + switch (data->status) + { + case NAT_TRAVERSAL_STATUS_CLOSE: + { + natt_close_port(&natt_st->device, &data->request, false); + + /* We will deinit NAT whether it succeeds or fails. */ + data->status = NAT_TRAVERSAL_STATUS_CLOSING; + } + break; + + case NAT_TRAVERSAL_STATUS_CLOSING: + { + natt_deinit(); + + data->status = NAT_TRAVERSAL_STATUS_CLOSED; + goto finished; + } + break; + default: + break; + } + + return; + +finished: task_set_progress(task, 100); task_set_finished(task, true); } static void netplay_nat_traversal_callback(retro_task_t *task, - void *task_data, - void *user_data, const char *error) + void *task_data, void *user_data, const char *error) { - free(task_data); - netplay_driver_ctl(RARCH_NETPLAY_CTL_FINISHED_NAT_TRAVERSAL, NULL); } @@ -77,10 +256,10 @@ static bool nat_task_queued(void *data) return task_queue_find(&find_data); } -bool task_push_netplay_nat_traversal(void *nat_traversal_state, uint16_t port) +bool task_push_netplay_nat_traversal(void *data, uint16_t port) { retro_task_t *task; - struct nat_traversal_state_data *ntsd; + struct nat_traversal_data *natt_data = data; /* Do not run more than one NAT task at a time. */ task_queue_wait(nat_task_queued, NULL); @@ -89,44 +268,49 @@ bool task_push_netplay_nat_traversal(void *nat_traversal_state, uint16_t port) if (!task) return false; - ntsd = (struct nat_traversal_state_data *) malloc(sizeof(*ntsd)); - if (!ntsd) - { - free(task); - return false; - } + natt_deinit(); - ntsd->nat_traversal_state = (struct natt_status *) nat_traversal_state; - ntsd->port = port; + natt_data->request.addr.sin_family = AF_INET; + natt_data->request.addr.sin_port = htons(port); + natt_data->request.proto = SOCKET_PROTOCOL_TCP; + natt_data->status = NAT_TRAVERSAL_STATUS_DISCOVERY; - task->handler = task_netplay_nat_traversal_handler; - task->callback = netplay_nat_traversal_callback; - task->task_data = ntsd; + task->handler = task_netplay_nat_traversal_handler; + task->callback = netplay_nat_traversal_callback; + task->task_data = data; task_queue_push(task); return true; } -bool task_push_netplay_nat_close(void *nat_traversal_state) +bool task_push_netplay_nat_close(void *data) { retro_task_t *task; + struct nat_traversal_data *natt_data = data; /* Do not run more than one NAT task at a time. */ task_queue_wait(nat_task_queued, NULL); + if (!natt_data->request.addr.sin_port) + return false; + task = task_init(); if (!task) return false; + natt_data->request.addr.sin_family = AF_INET; + natt_data->request.proto = SOCKET_PROTOCOL_TCP; + natt_data->status = NAT_TRAVERSAL_STATUS_CLOSE; + task->handler = task_netplay_nat_close_handler; - task->task_data = nat_traversal_state; + task->task_data = data; task_queue_push(task); return true; } #else -bool task_push_netplay_nat_traversal(void *nat_traversal_state, uint16_t port) { return false; } -bool task_push_netplay_nat_close(void *nat_traversal_state) { return false; } +bool task_push_netplay_nat_traversal(void *data, uint16_t port) { return false; } +bool task_push_netplay_nat_close(void *data) { return false; } #endif diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index d98d7be2e4..3cacd4e4f0 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -63,13 +63,19 @@ void *task_push_http_transfer(const char *url, bool mute, const char *type, retro_task_callback_t cb, void *userdata); void *task_push_http_transfer_with_user_agent(const char *url, bool mute, const char *type, - const char* user_agent, retro_task_callback_t cb, void *userdata); + const char *user_agent, retro_task_callback_t cb, void *userdata); + +void *task_push_http_transfer_with_headers(const char *url, bool mute, const char *type, + const char *headers, retro_task_callback_t cb, void *user_data); void *task_push_http_post_transfer(const char *url, const char *post_data, bool mute, const char *type, retro_task_callback_t cb, void *userdata); -void *task_push_http_post_transfer_with_user_agent(const char* url, const char* post_data, bool mute, - const char* type, const char* user_agent, retro_task_callback_t cb, void* user_data); +void *task_push_http_post_transfer_with_user_agent(const char *url, const char *post_data, bool mute, + const char *type, const char *user_agent, retro_task_callback_t cb, void *user_data); + +void *task_push_http_post_transfer_with_headers(const char *url, const char *post_data, bool mute, + const char *type, const char *headers, retro_task_callback_t cb, void *user_data); task_retriever_info_t *http_task_get_transfer_list(void); @@ -86,8 +92,8 @@ bool task_push_netplay_lan_scan(retro_task_callback_t cb); bool task_push_netplay_crc_scan(uint32_t crc, char* name, const char *hostname, const char *corename, const char* subsystem); -bool task_push_netplay_nat_traversal(void *nat_traversal_state, uint16_t port); -bool task_push_netplay_nat_close(void *nat_traversal_state); +bool task_push_netplay_nat_traversal(void *data, uint16_t port); +bool task_push_netplay_nat_close(void *data); /* Core updater tasks */