Permalink
Browse files

Merge branch 'master' into qt

Conflicts:
	configure.ac
	lib/ivis_opengl/Makefile.am
	lib/ivis_opengl/glew/glew.vcxproj
	lib/ivis_opengl/glew/glew.vcxproj.filters
	lib/ivis_opengl/piedraw.cpp
	lib/ivis_opengl/piemode.cpp
	lib/ivis_opengl/piestate.cpp
	lib/ivis_opengl/screen.cpp
	lib/ivis_opengl/tex.cpp
	lib/sequence/Makefile.am
	macosx/Warzone.xcodeproj/project.pbxproj
	macosx/configs/Glew-All.xcconfig
	macosx/configs/QuesoGLC-All.xcconfig
	macosx/configs/Warzone-All.xcconfig
	src/Makefile.am
	src/texture.cpp
	win32/libs/Makefile
	win32/libs/glew/Makefile
	win32/libs/glew/patches/glew_pkgconfig.diff
  • Loading branch information...
2 parents 0fc0eee + c130ed0 commit 3f8cecb8419ac61715d0475030bff3dc8936114e @perim perim committed Apr 24, 2011
Showing with 1,134 additions and 2,176 deletions.
  1. +23 −23 lib/ivis_opengl/Makefile.am
  2. +3 −1 lib/ivis_opengl/piedraw.cpp
  3. +0 −1 lib/ivis_opengl/piemode.cpp
  4. +84 −1 lib/netplay/miniupnpc/Changelog.txt
  5. +1 −1 lib/netplay/miniupnpc/{LICENCE → LICENSE}
  6. +19 −14 lib/netplay/miniupnpc/Makefile.am
  7. +0 −74 lib/netplay/miniupnpc/Makefile.mingw
  8. +0 −145 lib/netplay/miniupnpc/Makefile.old
  9. +7 −5 lib/netplay/miniupnpc/README
  10. +223 −0 lib/netplay/miniupnpc/connecthostport.c
  11. +17 −0 lib/netplay/miniupnpc/connecthostport.h
  12. +1 −3 lib/netplay/miniupnpc/declspec.h
  13. +39 −38 lib/netplay/miniupnpc/igd_desc_parse.c
  14. +15 −17 lib/netplay/miniupnpc/igd_desc_parse.h
  15. +0 −52 lib/netplay/miniupnpc/man3/miniupnpc.3
  16. +0 −7 lib/netplay/miniupnpc/mingw32make.bat
  17. +15 −10 lib/netplay/miniupnpc/minisoap.c
  18. +2 −2 lib/netplay/miniupnpc/minisoap.h
  19. +12 −6 lib/netplay/miniupnpc/minissdpc.c
  20. +259 −116 lib/netplay/miniupnpc/miniupnpc.c
  21. +0 −31 lib/netplay/miniupnpc/miniupnpc.def
  22. +0 −2 lib/netplay/miniupnpc/miniupnpc.h
  23. +0 −494 lib/netplay/miniupnpc/miniupnpcmodule.c
  24. +1 −1 lib/netplay/miniupnpc/miniupnpcstrings.h
  25. +0 −15 lib/netplay/miniupnpc/miniupnpcstrings.h.in
  26. +295 −132 lib/netplay/miniupnpc/miniwget.c
  27. +3 −1 lib/netplay/miniupnpc/miniwget.h
  28. +0 −149 lib/netplay/miniupnpc/minixmlvalid.c
  29. +0 −52 lib/netplay/miniupnpc/pymoduletest.py
  30. +0 −15 lib/netplay/miniupnpc/setup.py
  31. +0 −15 lib/netplay/miniupnpc/setupmingw32.py
  32. +0 −57 lib/netplay/miniupnpc/testigddescparse.c
  33. +0 −88 lib/netplay/miniupnpc/testminixml.c
  34. +0 −84 lib/netplay/miniupnpc/testupnpigd.py
  35. +0 −44 lib/netplay/miniupnpc/testupnpreplyparse.c
  36. +0 −38 lib/netplay/miniupnpc/updateminiupnpcstrings.sh
  37. +0 −378 lib/netplay/miniupnpc/upnpc.c
  38. +52 −23 lib/netplay/miniupnpc/upnpcommands.c
  39. +3 −2 lib/netplay/miniupnpc/upnpcommands.h
  40. +6 −6 lib/netplay/netplay.cpp
  41. +11 −3 macosx/BuildBot/01_configure.sh
  42. +2 −2 macosx/configs/Project-All.xcconfig
  43. +1 −1 macosx/configs/Warzone-Debug.xcconfig
  44. +1 −1 macosx/configs/Warzone-Release.xcconfig
  45. +3 −3 pkg/nsis/warzone2100.nsi
  46. +2 −2 po/de.po
  47. +1 −0 src/display3d.cpp
  48. +29 −16 src/terrain.cpp
  49. +0 −1 win32/libs/glew/Makefile
  50. +2 −2 win32/libs/quesoglc/Makefile
  51. +2 −2 win32/libs/quesoglc/patches/glew_h_include_stdint_h.diff
View
46 lib/ivis_opengl/Makefile.am
@@ -6,23 +6,23 @@ noinst_LIBRARIES = libivis_opengl.a
noinst_HEADERS = \
piematrix.h \
screen.h \
- bitimage.h \
- imd.h \
- ivi.h \
- ivisdef.h \
- jpeg_encoder.h \
- pieblitfunc.h \
- pieclip.h \
- piedef.h \
- piefunc.h \
- piemode.h \
- piepalette.h \
- piestate.h \
- pietypes.h \
- png_util.h \
- rendmode.h \
- tex.h \
- textdraw.h
+ bitimage.h \
+ imd.h \
+ ivi.h \
+ ivisdef.h \
+ jpeg_encoder.h \
+ pieblitfunc.h \
+ pieclip.h \
+ piedef.h \
+ piefunc.h \
+ piemode.h \
+ piepalette.h \
+ piestate.h \
+ pietypes.h \
+ png_util.h \
+ rendmode.h \
+ tex.h \
+ textdraw.h
libivis_opengl_a_SOURCES = \
ivi.cpp \
@@ -37,11 +37,11 @@ libivis_opengl_a_SOURCES = \
screen.cpp \
tex.cpp \
textdraw.cpp \
- bitimage.cpp \
- imd.cpp \
- imdload.cpp \
- jpeg_encoder.cpp \
- pieclip.cpp \
- png_util.cpp
+ bitimage.cpp \
+ imd.cpp \
+ imdload.cpp \
+ jpeg_encoder.cpp \
+ pieclip.cpp \
+ png_util.cpp
libivis_opengl_a_LIBADD = $(top_builddir)/lib/framework/libframework.a
View
4 lib/ivis_opengl/piedraw.cpp
@@ -20,9 +20,11 @@
/** \file
* Render routines for 3D coloured and shaded transparency rendering.
*/
+
+#include <string.h>
+
#include "lib/framework/frame.h"
#include "lib/framework/opengl.h"
-
#include "lib/ivis_opengl/ivisdef.h"
#include "lib/ivis_opengl/imd.h"
#include "lib/ivis_opengl/piefunc.h"
View
1 lib/ivis_opengl/piemode.cpp
@@ -26,7 +26,6 @@
*/
/***************************************************************************/
-
#include "lib/framework/frame.h"
#include "lib/framework/opengl.h"
#include "lib/framework/wzapp_c.h"
View
85 lib/netplay/miniupnpc/Changelog.txt
@@ -1,6 +1,89 @@
-$Id: Changelog.txt,v 1.95 2009/10/30 09:18:18 nanard Exp $
+$Id: Changelog.txt,v 1.125 2010/12/21 16:13:13 nanard Exp $
miniUPnP client Changelog.
+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:
View
2 lib/netplay/miniupnpc/LICENCE → lib/netplay/miniupnpc/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2008, Thomas BERNARD
+Copyright (c) 2005-2009, Thomas BERNARD
All rights reserved.
Redistribution and use in source and binary forms, with or without
View
33 lib/netplay/miniupnpc/Makefile.am
@@ -1,31 +1,36 @@
AM_CPPFLAGS = -DSTATICLIB $(SDL_CFLAGS) $(WZ_CPPFLAGS)
-AM_CFLAGS = -DSTATICLIB $(WZ_CFLAGS)
+AM_CFLAGS = -DSTATICLIB $(WZ_CFLAGS) -UDEBUG
noinst_LIBRARIES = libminiupnpc.a
noinst_HEADERS = \
+ bsdqueue.h \
+ codelength.h \
+ connecthostport.h \
+ declspec.h \
+ igd_desc_parse.h \
+ minisoap.h \
+ minissdpc.h \
miniupnpc.h \
miniupnpcstrings.h \
miniwget.h \
minixml.h \
- minisoap.h \
- minissdpc.h \
- codelength.h \
upnpcommands.h \
- igd_desc_parse.h \
- upnpreplyparse.h \
upnperrors.h \
- declspec.h \
- bsdqueue.h
+ upnpreplyparse.h
libminiupnpc_a_SOURCES = \
- miniwget.c \
- minixml.c \
+ connecthostport.c \
igd_desc_parse.c \
minisoap.c \
+ minissdpc.c \
miniupnpc.c \
- upnpreplyparse.c \
+ miniwget.c \
+ minixml.c \
upnpcommands.c \
- minissdpc.c \
- upnperrors.c
+ upnperrors.c \
+ upnpreplyparse.c
-EXTRA_DIST = LICENCE README
+EXTRA_DIST = \
+ Changelog.txt \
+ LICENSE \
+ README
View
74 lib/netplay/miniupnpc/Makefile.mingw
@@ -1,74 +0,0 @@
-# $Id: Makefile.mingw,v 1.9 2008/07/02 23:31:15 nanard Exp $
-# Miniupnp project.
-# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
-# (c) 2005-2008 Thomas Bernard
-CC = gcc
-#CFLAGS = -Wall -g -DDEBUG
-CFLAGS = -Wall -Os -DNDEBUG
-LDLIBS = -lws2_32
-# -lwsock32
-PYTHON=\utils\python25\python
-OBJS=miniwget.o minixml.o igd_desc_parse.o minisoap.o \
- miniupnpc.o upnpreplyparse.o upnpcommands.o upnperrors.o
-OBJSDLL=$(addprefix dll/, $(OBJS))
-
-all: init upnpc-static upnpc-shared testminixml libminiupnpc.a miniupnpc.dll
-
-init:
- mkdir dll
- echo "" > init
-
-clean:
- del upnpc testminixml *.o
- del dll/*.o
-
-libminiupnpc.a: $(OBJS)
- $(AR) cr $@ $?
-
-pythonmodule: libminiupnpc.a
- $(PYTHON) setupmingw32.py build --compiler=mingw32
- $(PYTHON) setupmingw32.py install --skip-build
-
-miniupnpc.dll: libminiupnpc.a $(OBJSDLL)
- dllwrap -k --driver-name gcc --def miniupnpc.def \
- --output-def miniupnpc.dll.def --implib miniupnpc.lib -o $@ \
- $(OBJSDLL) $(LDLIBS)
-
-miniupnpc.lib: miniupnpc.dll
- echo $@ generated with $<
-
-dll/upnpc.o: upnpc.o
- echo $@ generated with $<
-
-.c.o:
- $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $<
- $(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o dll/$@ $<
-
-upnpc.o:
- $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $<
- $(CC) $(CFLAGS) -c -o dll/$@ $<
-
-upnpc-static: upnpc.o libminiupnpc.a
- $(CC) -o $@ $^ $(LDLIBS)
-
-upnpc-shared: dll/upnpc.o miniupnpc.lib
- $(CC) -o $@ $^ $(LDLIBS)
-
-minixml.o: minixml.c minixml.h
-
-upnpc.o: upnpc.c miniwget.h minisoap.h miniupnpc.h igd_desc_parse.h upnpreplyparse.h upnpcommands.h
-
-miniwget.o: miniwget.c miniwget.h
-
-minisoap.o: minisoap.c minisoap.h
-
-miniupnpc.o: miniupnpc.c miniupnpc.h minisoap.h miniwget.h minixml.h
-
-igd_desc_parse.o: igd_desc_parse.c igd_desc_parse.h
-
-testminixml: minixml.o igd_desc_parse.o testminixml.c
-
-upnpreplyparse.o: upnpreplyparse.c upnpreplyparse.h minixml.h
-
-upnpcommands.o: upnpcommands.c upnpcommands.h upnpreplyparse.h miniupnpc.h
-
View
145 lib/netplay/miniupnpc/Makefile.old
@@ -1,145 +0,0 @@
-# $Id: Makefile,v 1.55 2009/10/10 19:15:34 nanard Exp $
-# MiniUPnP Project
-# http://miniupnp.free.fr/
-# (c) 2005-2009 Thomas Bernard
-# to install use :
-# $ PREFIX=/tmp/dummylocation make install
-# or
-# $ INSTALLPREFIX=/usr/local make install
-# or
-# make install (will go to /usr/bin, /usr/lib, etc...)
-OS = $(shell uname -s)
-CC ?= gcc
-#AR = gar
-#CFLAGS = -fPIC -O -Wall -g -DDEBUG
-CFLAGS ?= -fPIC -O -Wall -DNDEBUG -DMINIUPNPC_SET_SOCKET_TIMEOUT
-INSTALL = install
-SH = /bin/sh
-#following libs are needed on Solaris
-#LDLIBS=-lsocket -lnsl -lresolv
-
-# APIVERSION is used to build SONAME
-APIVERSION = 4
-
-SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \
- upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \
- minixmlvalid.c testupnpreplyparse.c minissdpc.c \
- upnperrors.c testigddescparse.c
-
-LIBOBJS = miniwget.o minixml.o igd_desc_parse.o minisoap.o \
- miniupnpc.o upnpreplyparse.o upnpcommands.o minissdpc.o \
- upnperrors.o
-
-OBJS = $(patsubst %.c,%.o,$(SRCS))
-
-# HEADERS to install
-HEADERS = miniupnpc.h miniwget.h upnpcommands.h igd_desc_parse.h \
- upnpreplyparse.h upnperrors.h declspec.h
-# library names
-LIBRARY = libminiupnpc.a
-ifeq ($(OS), Darwin)
- SHAREDLIBRARY = libminiupnpc.dylib
- SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib
-else
- SHAREDLIBRARY = libminiupnpc.so
- SONAME = $(SHAREDLIBRARY).$(APIVERSION)
-endif
-
-EXECUTABLES = upnpc-static upnpc-shared \
- testminixml minixmlvalid testupnpreplyparse \
- testigddescparse
-
-# install directories
-INSTALLPREFIX ?= $(PREFIX)/usr
-INSTALLDIRINC = $(INSTALLPREFIX)/include/miniupnpc
-INSTALLDIRLIB = $(INSTALLPREFIX)/lib
-INSTALLDIRBIN = $(INSTALLPREFIX)/bin
-
-.PHONY: install clean depend all installpythonmodule
-
-all: validateminixml $(LIBRARY) $(EXECUTABLES)
-
-pythonmodule: $(LIBRARY) miniupnpcmodule.c setup.py
- python setup.py build
- touch $@
-
-installpythonmodule: pythonmodule
- python setup.py install
-
-validateminixml: minixmlvalid
- @echo "minixml validation test"
- ./minixmlvalid
- touch $@
-
-clean:
- $(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h
- # clean python stuff
- $(RM) pythonmodule validateminixml
- $(RM) -r build/ dist/
- #python setup.py clean
-
-install: $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES)
- $(INSTALL) -d $(INSTALLDIRINC)
- $(INSTALL) -m 644 $(HEADERS) $(INSTALLDIRINC)
- $(INSTALL) -d $(INSTALLDIRLIB)
- $(INSTALL) -m 644 $(LIBRARY) $(INSTALLDIRLIB)
- $(INSTALL) -m 644 $(SHAREDLIBRARY) $(INSTALLDIRLIB)/$(SONAME)
- $(INSTALL) -d $(INSTALLDIRBIN)
- $(INSTALL) -m 755 upnpc-shared $(INSTALLDIRBIN)/upnpc
- ln -fs $(SONAME) $(INSTALLDIRLIB)/$(SHAREDLIBRARY)
-
-cleaninstall:
- $(RM) -r $(INSTALLDIRINC)
- $(RM) $(INSTALLDIRLIB)/$(LIBRARY)
- $(RM) $(INSTALLDIRLIB)/$(SHAREDLIBRARY)
-
-depend:
- makedepend -Y -- $(CFLAGS) -- $(SRCS) 2>/dev/null
-
-$(LIBRARY): $(LIBOBJS)
- $(AR) crs $@ $?
-
-$(SHAREDLIBRARY): $(LIBOBJS)
-ifeq ($(OS), Darwin)
- $(CC) -dynamiclib -Wl,-install_name,$(SONAME) -o $@ $^
-else
- $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
-endif
-
-upnpc-static: upnpc.o $(LIBRARY) $(LDLIBS)
- $(CC) -o $@ $^
-
-upnpc-shared: upnpc.o $(SHAREDLIBRARY) $(LDLIBS)
- $(CC) -o $@ $^
-
-testminixml: minixml.o igd_desc_parse.o testminixml.o
-
-minixmlvalid: minixml.o minixmlvalid.o
-
-testupnpreplyparse: testupnpreplyparse.o minixml.o upnpreplyparse.o
-
-testigddescparse: testigddescparse.o igd_desc_parse.o minixml.o
-
-miniupnpcstrings.h: miniupnpcstrings.h.in updateminiupnpcstrings.sh
- $(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 declspec.h igd_desc_parse.h minissdpc.h miniwget.h
-miniupnpc.o: minisoap.h minixml.h upnpcommands.h upnpreplyparse.h
-minixml.o: minixml.h
-minisoap.o: minisoap.h miniupnpcstrings.h
-miniwget.o: miniupnpc.h declspec.h igd_desc_parse.h miniupnpcstrings.h
-miniwget.o: miniwget.h
-upnpc.o: miniwget.h declspec.h miniupnpc.h igd_desc_parse.h upnpcommands.h
-upnpc.o: upnpreplyparse.h upnperrors.h
-upnpcommands.o: upnpcommands.h upnpreplyparse.h declspec.h miniupnpc.h
-upnpcommands.o: igd_desc_parse.h
-upnpreplyparse.o: upnpreplyparse.h minixml.h
-testminixml.o: minixml.h igd_desc_parse.h
-minixmlvalid.o: minixml.h
-testupnpreplyparse.o: upnpreplyparse.h
-minissdpc.o: minissdpc.h miniupnpc.h declspec.h igd_desc_parse.h codelength.h
-upnperrors.o: upnperrors.h declspec.h upnpcommands.h upnpreplyparse.h
-testigddescparse.o: igd_desc_parse.h minixml.h
View
12 lib/netplay/miniupnpc/README
@@ -1,20 +1,22 @@
Project: miniupnp
Project web page: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
Author: Thomas Bernard
-Copyright (c) 2005-2008 Thomas Bernard
+Copyright (c) 2005-2009 Thomas Bernard
This software is subject to the conditions detailed in the
-LICENCE file provided within this distribution.
+LICENSE file provided within this distribution.
For the comfort of Win32 users, bsdqueue.h is included in the distribution.
Its licence is included in the header of the file.
bsdqueue.h is a copy of the sys/queue.h of an OpenBSD system.
* miniupnp Client *
-To compile, simply run 'gmake' (could be 'make').
+To compile, simply run 'gmake' (could be 'make' on your system).
Under win32, to compile with MinGW, type "mingw32make.bat".
The compilation is known to work under linux, FreeBSD,
-OpenBSD, MacOS X and cygwin.
+OpenBSD, MacOS X, AmigaOS and cygwin.
+The official AmigaOS4.1 SDK was used for AmigaOS4 and GeekGadgets for AmigaOS3.
+
To install the library and headers on the system use :
> su
> make install
@@ -25,7 +27,7 @@ alternatively, to install in a specific location, use :
upnpc.c is a sample client using the libminiupnpc.
To use the libminiupnpc in your application, link it with
-libminiupnpc.a and use the following functions found in miniupnpc.h,
+libminiupnpc.a (or .so) and use the following functions found in miniupnpc.h,
upnpcommands.h and miniwget.h :
- upnpDiscover()
- miniwget()
View
223 lib/netplay/miniupnpc/connecthostport.c
@@ -0,0 +1,223 @@
+/* $Id: connecthostport.c,v 1.3 2010/12/21 16:13:14 nanard Exp $ */
+/* Project : miniupnp
+ * Author : Thomas Bernard
+ * Copyright (c) 2010 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 <string.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#define snprintf _snprintf
+#define herror
+#define socklen_t int
+#else /* #ifdef WIN32 */
+#include <unistd.h>
+#include <errno.h>
+#define closesocket close
+#include <netdb.h>
+/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
+ * during the connect() call */
+#define MINIUPNPC_IGNORE_EINTR
+#ifndef USE_GETHOSTBYNAME
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif /* #ifndef USE_GETHOSTBYNAME */
+#endif /* #else WIN32 */
+
+/* definition of PRINT_SOCKET_ERROR */
+#ifdef WIN32
+#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
+#else
+#define PRINT_SOCKET_ERROR(x) perror(x)
+#endif
+
+#if defined(__amigaos__) || defined(__amigaos4__)
+#define herror(A) printf("%s\n", A)
+#endif
+
+#include "connecthostport.h"
+
+/* 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)
+{
+ int s, n;
+#ifdef USE_GETHOSTBYNAME
+ struct sockaddr_in dest;
+ struct hostent *hp;
+#else /* #ifdef USE_GETHOSTBYNAME */
+ 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)
+ {
+ PRINT_SOCKET_ERROR("socket");
+ 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)
+ {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+ if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
+ {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+#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
+ while(n < 0 && errno == EINTR)
+ {
+ 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) {
+ PRINT_SOCKET_ERROR("getsockopt");
+ closesocket(s);
+ return -1;
+ }
+ if(err != 0) {
+ errno = err;
+ n = -1;
+ }
+ }
+#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
+ if(n<0)
+ {
+ PRINT_SOCKET_ERROR("connect");
+ 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);
+ n = getaddrinfo(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;
+#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)
+ {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+ if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
+ {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
+ n = connect(s, p->ai_addr, p->ai_addrlen);
+#ifdef MINIUPNPC_IGNORE_EINTR
+ while(n < 0 && errno == EINTR)
+ {
+ 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) {
+ PRINT_SOCKET_ERROR("getsockopt");
+ 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)
+ {
+ PRINT_SOCKET_ERROR("socket");
+ return -1;
+ }
+ if(n < 0)
+ {
+ PRINT_SOCKET_ERROR("connect");
+ return -1;
+ }
+#endif /* #ifdef USE_GETHOSTBYNAME */
+ return s;
+}
+
View
17 lib/netplay/miniupnpc/connecthostport.h
@@ -0,0 +1,17 @@
+/* $Id: connecthostport.h,v 1.1 2010/04/04 23:21:03 nanard Exp $ */
+/* Project: miniupnp
+ * http://miniupnp.free.fr/
+ * Author: Thomas Bernard
+ * Copyright (c) 2010 Thomas Bernard
+ * This software is subjects to the conditions detailed
+ * in the LICENCE file provided within this distribution */
+#ifndef __CONNECTHOSTPORT_H__
+#define __CONNECTHOSTPORT_H__
+
+/* 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);
+
+#endif
+
View
4 lib/netplay/miniupnpc/declspec.h
@@ -5,9 +5,7 @@
#ifdef MINIUPNP_EXPORTS
#define LIBSPEC __declspec(dllexport)
#else
-// NOTE: with the cross compiler, even if we have -DSTATICLIB, for some odd reason it still does this
-// #define LIBSPEC __declspec(dllimport) which is not what we want. So we hack the line like so.
- #define LIBSPEC
+ #define LIBSPEC __declspec(dllimport)
#endif
#else
#define LIBSPEC
View
77 lib/netplay/miniupnpc/igd_desc_parse.c
@@ -1,18 +1,15 @@
-/* $Id: igd_desc_parse.c,v 1.8 2008/04/23 11:51:06 nanard Exp $ */
+/* $Id: igd_desc_parse.c,v 1.11 2010/12/11 17:56:51 nanard Exp $ */
/* Project : miniupnp
* http://miniupnp.free.fr/
* Author : Thomas Bernard
- * Copyright (c) 2005-2008 Thomas Bernard
+ * Copyright (c) 2005-2010 Thomas Bernard
* This software is subject to the conditions detailed in the
- * LICENCE file provided in this distribution.
- * */
+ * LICENCE file provided in this distribution. */
+
#include "igd_desc_parse.h"
#include <stdio.h>
#include <string.h>
-/* TODO : rewrite this code so it correctly handle descriptions with
- * both WANIPConnection and/or WANPPPConnection */
-
/* Start element handler :
* update nesting level counter and copy element name */
void IGDstartelt(void * d, const char * name, int l)
@@ -22,10 +19,10 @@ void IGDstartelt(void * d, const char * name, int l)
datas->cureltname[l] = '\0';
datas->level++;
if( (l==7) && !memcmp(name, "service", l) ) {
- datas->controlurl_tmp[0] = '\0';
- datas->eventsuburl_tmp[0] = '\0';
- datas->scpdurl_tmp[0] = '\0';
- datas->servicetype_tmp[0] = '\0';
+ datas->tmp.controlurl[0] = '\0';
+ datas->tmp.eventsuburl[0] = '\0';
+ datas->tmp.scpdurl[0] = '\0';
+ datas->tmp.servicetype[0] = '\0';
}
}
@@ -46,20 +43,18 @@ void IGDendelt(void * d, const char * name, int l)
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"))
datas->state ++;
*/
- if(0==strcmp(datas->servicetype_tmp,
+ if(0==strcmp(datas->tmp.servicetype,
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) {
- memcpy(datas->controlurl_CIF, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->eventsuburl_CIF, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->scpdurl_CIF, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->servicetype_CIF, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE);
- } else if(0==strcmp(datas->servicetype_tmp,
+ memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service));
+ } else if(0==strcmp(datas->tmp.servicetype,
"urn:schemas-upnp-org:service:WANIPConnection:1")
- || 0==strcmp(datas->servicetype_tmp,
+ || 0==strcmp(datas->tmp.servicetype,
"urn:schemas-upnp-org:service:WANPPPConnection:1") ) {
- memcpy(datas->controlurl, datas->controlurl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->eventsuburl, datas->eventsuburl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->scpdurl, datas->scpdurl_tmp, MINIUPNPC_URL_MAXSIZE);
- memcpy(datas->servicetype, datas->servicetype_tmp, MINIUPNPC_URL_MAXSIZE);
+ 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));
+ }
}
}
}
@@ -75,13 +70,13 @@ void IGDdata(void * d, const char * data, int l)
if( !strcmp(datas->cureltname, "URLBase") )
dstmember = datas->urlbase;
else if( !strcmp(datas->cureltname, "serviceType") )
- dstmember = datas->servicetype_tmp;
+ dstmember = datas->tmp.servicetype;
else if( !strcmp(datas->cureltname, "controlURL") )
- dstmember = datas->controlurl_tmp;
+ dstmember = datas->tmp.controlurl;
else if( !strcmp(datas->cureltname, "eventSubURL") )
- dstmember = datas->eventsuburl_tmp;
+ dstmember = datas->tmp.eventsuburl;
else if( !strcmp(datas->cureltname, "SCPDURL") )
- dstmember = datas->scpdurl_tmp;
+ dstmember = datas->tmp.scpdurl;
/* else if( !strcmp(datas->cureltname, "deviceType") )
dstmember = datas->devicetype_tmp;*/
if(dstmember)
@@ -95,19 +90,25 @@ void IGDdata(void * d, const char * data, int l)
void printIGD(struct IGDdatas * d)
{
- printf("urlbase = %s\n", d->urlbase);
+ printf("urlbase = '%s'\n", d->urlbase);
printf("WAN Device (Common interface config) :\n");
- /*printf(" deviceType = %s\n", d->devicetype_CIF);*/
- printf(" serviceType = %s\n", d->servicetype_CIF);
- printf(" controlURL = %s\n", d->controlurl_CIF);
- printf(" eventSubURL = %s\n", d->eventsuburl_CIF);
- printf(" SCPDURL = %s\n", d->scpdurl_CIF);
- printf("WAN Connection Device (IP or PPP Connection):\n");
- /*printf(" deviceType = %s\n", d->devicetype);*/
- printf(" servicetype = %s\n", d->servicetype);
- printf(" controlURL = %s\n", d->controlurl);
- printf(" eventSubURL = %s\n", d->eventsuburl);
- printf(" SCPDURL = %s\n", d->scpdurl);
+ /*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);
}
View
32 lib/netplay/miniupnpc/igd_desc_parse.h
@@ -1,8 +1,8 @@
-/* $Id: igd_desc_parse.h,v 1.6 2008/04/23 11:51:07 nanard Exp $ */
+/* $Id: igd_desc_parse.h,v 1.7 2010/04/05 20:36:59 nanard Exp $ */
/* Project : miniupnp
* http://miniupnp.free.fr/
* Author : Thomas Bernard
- * Copyright (c) 2005-2008 Thomas Bernard
+ * Copyright (c) 2005-2010 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
* */
@@ -12,30 +12,28 @@
/* 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];
int level;
/*int state;*/
/* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */
- char controlurl_CIF[MINIUPNPC_URL_MAXSIZE];
- char eventsuburl_CIF[MINIUPNPC_URL_MAXSIZE];
- char scpdurl_CIF[MINIUPNPC_URL_MAXSIZE];
- char servicetype_CIF[MINIUPNPC_URL_MAXSIZE];
- /*char devicetype_CIF[MINIUPNPC_URL_MAXSIZE];*/
+ struct IGDdatas_service CIF;
/* "urn:schemas-upnp-org:service:WANIPConnection:1"
* "urn:schemas-upnp-org:service:WANPPPConnection:1" */
- 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_service first;
+ /* if both WANIPConnection and WANPPPConnection are present */
+ struct IGDdatas_service second;
/* tmp */
- char controlurl_tmp[MINIUPNPC_URL_MAXSIZE];
- char eventsuburl_tmp[MINIUPNPC_URL_MAXSIZE];
- char scpdurl_tmp[MINIUPNPC_URL_MAXSIZE];
- char servicetype_tmp[MINIUPNPC_URL_MAXSIZE];
- /*char devicetype_tmp[MINIUPNPC_URL_MAXSIZE];*/
+ struct IGDdatas_service tmp;
};
void IGDstartelt(void *, const char *, int);
View
52 lib/netplay/miniupnpc/man3/miniupnpc.3
@@ -1,52 +0,0 @@
-\" $Id: miniupnpc.3,v 1.2 2008/10/07 13:51:55 nanard Exp $
-.TH miniupnpc 3
-.SH NAME
-miniupnpc \- UPnP client library
-.SH SYNOPSIS
-.SH DESCRIPTION
-The miniupnpc library implement the UPnP protocol defined
-to dialog with Internet Gateway Devices. It also has
-the ability to use data gathered by minissdpd(1) about
-UPnP devices up on the network in order to skip the
-long UPnP device discovery process.
-.PP
-At first, upnpDiscover(3) has to be used to discover UPnP IGD present
-on the network. Then UPNP_GetValidIGD(3) to select the right one.
-Alternatively, UPNP_GetIGDFromUrl(3) could be used to bypass discovery
-process if the root description url of the device to use is known.
-Then all the UPNP_* functions can be used, such as
-UPNP_GetConnectionTypeInfo(3), UPNP_AddPortMapping(3), etc...
-.SH "HEADER FILES"
-.IP miniupnpc.h
-That's the main header file for the miniupnpc library API.
-It contains all the functions and structures related to device discovery.
-.IP upnpcommands.h
-This header file contain the UPnP IGD methods that are accessible
-through the miniupnpc API. The name of the C functions are matching
-the UPnP methods names. ie: GetGenericPortMappingEntry is
-UPNP_GetGenericPortMappingEntry.
-.SH "API FUNCTIONS"
-.IP "struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int sameport);"
-execute the discovery process.
-delay (in millisecond) is the maximum time for waiting any device response.
-If available, device list will be obtained from MiniSSDPd.
-Default path for minissdpd socket will be used if minissdpdsock argument is NULL.
-If multicastif is not NULL, it will be used instead of the default multicast interface for sending SSDP discover packets.
-If sameport is not null, SSDP packets will be sent from the source port 1900 (same as destination port) otherwise system assign a source port.
-.IP "void freeUPNPDevlist(struct UPNPDev * devlist);"
-free the list returned by upnpDiscover().
-.IP "int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);"
-browse the list of device returned by upnpDiscover(), find
-a live UPnP internet gateway device and fill structures passed as arguments
-with data used for UPNP methods invokation.
-.IP "int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen);"
-permit to bypass the upnpDiscover() call if the xml root description
-URL of the UPnP IGD is known.
-Fill structures passed as arguments
-with data used for UPNP methods invokation.
-.IP "void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);"
-.IP "void FreeUPNPUrls(struct UPNPUrls *);"
-
-.SH "SEE ALSO"
-minissdpd(1)
-.SH BUGS
View
7 lib/netplay/miniupnpc/mingw32make.bat
@@ -1,7 +0,0 @@
-@mingw32-make -f Makefile.mingw %1
-@if errorlevel 1 goto end
-@strip upnpc-static.exe
-@upx --best upnpc-static.exe
-@strip upnpc-shared.exe
-@upx --best upnpc-shared.exe
-:end
View
25 lib/netplay/miniupnpc/minisoap.c
@@ -1,7 +1,7 @@
-/* $Id: minisoap.c,v 1.16 2008/10/11 16:39:29 nanard Exp $ */
+/* $Id: minisoap.c,v 1.20 2010/12/11 17:56:51 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
- * Copyright (c) 2005 Thomas Bernard
+ * Copyright (c) 2005-2009 Thomas Bernard
* This software is subject to the conditions detailed in the
* LICENCE file provided in this distribution.
*
@@ -21,8 +21,6 @@
#include "minisoap.h"
#include "miniupnpcstrings.h"
-#undef DEBUG
-
/* only for malloc */
#include <stdlib.h>
@@ -77,7 +75,8 @@ int soapPostSubmit(int fd,
const char * host,
unsigned short port,
const char * action,
- const char * body)
+ const char * body,
+ const char * httpversion)
{
int bodysize;
char headerbuf[512];
@@ -86,14 +85,16 @@ int soapPostSubmit(int fd,
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 */
+ * 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/1.1\r\n"
-/* "POST %s HTTP/1.0\r\n"*/
+ "POST %s HTTP/%s\r\n"
"Host: %s%s\r\n"
"User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
"Content-Length: %d\r\n"
@@ -103,10 +104,14 @@ int soapPostSubmit(int fd,
"Cache-Control: no-cache\r\n" /* ??? */
"Pragma: no-cache\r\n"
"\r\n",
- url, host, portstr, bodysize, action);
+ url, httpversion, host, portstr, bodysize, action);
#ifdef DEBUG
- printf("SOAP request : headersize=%d bodysize=%d\n",
+ /*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("%s", headerbuf);*/
#endif
return httpWrite(fd, body, bodysize, headerbuf, headerssize);
View
4 lib/netplay/miniupnpc/minisoap.h
@@ -1,4 +1,4 @@
-/* $Id: minisoap.h,v 1.3 2006/11/19 22:32:34 nanard Exp $ */
+/* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2005 Thomas Bernard
@@ -9,7 +9,7 @@
/*int httpWrite(int, const char *, int, const char *);*/
int soapPostSubmit(int, const char *, const char *, unsigned short,
- const char *, const char *);
+ const char *, const char *, const char *);
#endif
View
18 lib/netplay/miniupnpc/minissdpc.c
@@ -1,4 +1,4 @@
-/* $Id: minissdpc.c,v 1.10 2009/09/21 12:57:42 nanard Exp $ */
+/* $Id: minissdpc.c,v 1.14 2010/11/25 09:57:25 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas BERNARD
* copyright (c) 2005-2009 Thomas Bernard
@@ -8,15 +8,22 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <sys/types.h>
+#if defined(WIN32) || defined(__amigaos__) || defined(__amigaos4__)
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
-// Warzone additions
-#include "lib/framework/types.h"
-typedef SSIZE_T ssize_t;
-// end WZ
+#include <winsock.h>
+#include <stdint.h>
+#endif
+#if defined(__amigaos__) || defined(__amigaos4__)
+#include <sys/socket.h>
+#endif
+#if defined(__amigaos__)
+#define uint16_t unsigned short
+#endif
/* Hack */
#define UNIX_PATH_LEN 108
struct sockaddr_un {
@@ -26,7 +33,6 @@ struct sockaddr_un {
#else
#include <sys/socket.h>
#include <sys/un.h>
-#include <unistd.h>
#endif
#include "minissdpc.h"
View
375 lib/netplay/miniupnpc/miniupnpc.c
@@ -1,9 +1,9 @@
-/* $Id: miniupnpc.c,v 1.66 2009/10/10 19:15:34 nanard Exp $ */
+/* $Id: miniupnpc.c,v 1.85 2010/12/21 16:13:14 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas BERNARD
- * copyright (c) 2005-2009 Thomas Bernard
+ * copyright (c) 2005-2010 Thomas Bernard
* This software is subjet to the conditions detailed in the
- * provided LICENCE file. */
+ * provided LICENSE file. */
#define __EXTENSIONS__ 1
#if !defined(MACOSX) && !defined(__sun)
#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__)
@@ -16,8 +16,6 @@
#endif
#endif
-#include "lib/framework/wzglobal.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -26,43 +24,52 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
+#include <iphlpapi.h>
#define snprintf _snprintf
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define strncasecmp _memicmp
-#else
+#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
#define strncasecmp memicmp
-#endif
+#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
#define MAXHOSTNAMELEN 64
-#else
+#else /* #ifdef WIN32 */
/* Standard POSIX includes */
#include <unistd.h>
+#if defined(__amigaos__) && !defined(__amigaos4__)
+/* Amiga OS 3 specific stuff */
+#define socklen_t int
+#else
#include <sys/select.h>
+#endif
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/param.h>
-#ifdef WZ_OS_MAC
-# undef _POSIX_C_SOURCE
-# include <netinet/in.h>
-#else
-# include <netinet/in.h>
-#endif
+#include <netinet/in.h>
#include <arpa/inet.h>
-#include <poll.h>
#include <netdb.h>
+#if !defined(__amigaos__) && !defined(__amigaos4__)
+#include <poll.h>
+#endif
#include <strings.h>
#include <errno.h>
#define closesocket close
#define MINIUPNPC_IGNORE_EINTR
-#endif
+#endif /* #else WIN32 */
#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
#include <sys/time.h>
#endif
+#if defined(__amigaos__) || defined(__amigaos4__)
+/* Amiga OS specific stuff */
+#define TIMEVAL struct timeval
+#endif
+
#include "miniupnpc.h"
#include "minissdpc.h"
#include "miniwget.h"
#include "minisoap.h"
#include "minixml.h"
#include "upnpcommands.h"
+#include "connecthostport.h"
#ifdef WIN32
#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError());
@@ -92,7 +99,9 @@ LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * d
#endif
}
-/* Content-length: nnn */
+#if 0
+/* getcontentlenfromline() : parse the Content-Length HTTP header line.
+ * Content-length: nnn */
static int getcontentlenfromline(const char * p, int n)
{
static const char contlenstr[] = "content-length";
@@ -127,6 +136,10 @@ static int getcontentlenfromline(const char * p, int n)
return a;
}
+/* getContentLengthAndHeaderLength()
+ * retrieve header length and content length from an HTTP response
+ * TODO : retrieve Transfer-Encoding: header value, in order to support
+ * HTTP/1.1, chunked transfer encoding must be supported. */
static void
getContentLengthAndHeaderLength(char * p, int n,
int * contentlen, int * headerlen)
@@ -155,29 +168,27 @@ getContentLengthAndHeaderLength(char * p, int n,
}
}
}
+#endif
-/* simpleUPnPcommand :
+/* simpleUPnPcommand2 :
* not so simple !
* return values :
* 0 - OK
* -1 - error */
-int simpleUPnPcommand(int s, const char * url, const char * service,
- const char * action, struct UPNParg * args,
- char * buffer, int * bufsize)
+static int simpleUPnPcommand2(int s, const char * url, const char * service,
+ const char * action, struct UPNParg * args,
+ char * buffer, int * bufsize, const char * httpversion)
{
- struct sockaddr_in dest;
char hostname[MAXHOSTNAMELEN+1];
unsigned short port = 0;
char * path;
char soapact[128];
char soapbody[2048];
char * buf;
- int buffree;
+ /*int buffree;*/
int n;
- int contentlen, headerlen; /* for the response */
-#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
- struct timeval timeout;
-#endif
+ /*int contentlen, headerlen;*/ /* for the response */
+
snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
if(args==NULL)
{
@@ -246,68 +257,15 @@ int simpleUPnPcommand(int s, const char * url, const char * service,
if(!parseURL(url, hostname, &port, &path)) return -1;
if(s<0)
{
- s = socket(PF_INET, SOCK_STREAM, 0);
- if(s<0)
- {
- PRINT_SOCKET_ERROR("socket");
- *bufsize = 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)
- {
- PRINT_SOCKET_ERROR("setsockopt");
- }
- timeout.tv_sec = 3;
- timeout.tv_usec = 0;
- if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
- {
- PRINT_SOCKET_ERROR("setsockopt");
- }
-#endif
- dest.sin_family = AF_INET;
- dest.sin_port = htons(port);
- dest.sin_addr.s_addr = inet_addr(hostname);
- n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr));
-#ifdef MINIUPNPC_IGNORE_EINTR
- while(n < 0 && errno == EINTR)
+ s = connecthostport(hostname, port);
+ if(s < 0)
{
- 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) {
- PRINT_SOCKET_ERROR("getsockopt");
- closesocket(s);
- return -1;
- }
- if(err != 0) {
- errno = err;
- n = -1;
- } else {
- n = 0;
- }
- }
-#endif
- if(n < 0)
- {
- PRINT_SOCKET_ERROR("connect");
- closesocket(s);
*bufsize = 0;
return -1;
}
}
- n = soapPostSubmit(s, path, hostname, port, soapact, soapbody);
+ n = soapPostSubmit(s, path, hostname, port, soapact, soapbody, httpversion);
if(n<=0) {
#ifdef DEBUG
printf("Error sending SOAP request\n");
@@ -316,6 +274,7 @@ int simpleUPnPcommand(int s, const char * url, const char * service,
return -1;
}
+#if 0
contentlen = -1;
headerlen = -1;
buf = buffer;
@@ -335,11 +294,56 @@ int simpleUPnPcommand(int s, const char * url, const char * service,
if(contentlen > 0 && headerlen > 0 && *bufsize >= contentlen+headerlen)
break;
}
-
+#endif
+ buf = getHTTPResponse(s, &n);
+ if(n > 0 && buf)
+ {
+#ifdef DEBUG
+ printf("SOAP Response :\n%.*s\n", n, buf);
+#endif
+ if(*bufsize > n)
+ {
+ memcpy(buffer, buf, n);
+ *bufsize = n;
+ }
+ else
+ {
+ memcpy(buffer, buf, *bufsize);
+ }
+ free(buf);
+ buf = 0;
+ }
closesocket(s);
return 0;
}
+/* simpleUPnPcommand :
+ * not so simple !
+ * return values :
+ * 0 - OK
+ * -1 - error */
+int simpleUPnPcommand(int s, const char * url, const char * service,
+ const char * action, struct UPNParg * args,
+ char * buffer, int * bufsize)
+{
+ int result;
+ /*int origbufsize = *bufsize;*/
+
+ result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.1");
+/*
+ result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.0");
+ if (result < 0 || *bufsize == 0)
+ {
+#if DEBUG
+ printf("Error or no result from SOAP request; retrying with HTTP/1.1\n");
+#endif
+ *bufsize = origbufsize;
+ result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.1");
+ }
+*/
+ return result;
+}
+
/* parseMSEARCHReply()
* the last 4 arguments are filled during the parsing :
* - location/locationsize : "location:" field of the SSDP reply packet
@@ -435,10 +439,19 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
char bufr[1536]; /* reception and emission buffer */
int sudp;
int n;
- struct sockaddr_in sockudp_r, sockudp_w;
+ struct sockaddr sockudp_r;
unsigned int mx;
+#ifdef NO_GETADDRINFO
+ struct sockaddr_in sockudp_w;
+#else
+ int rv;
+ struct addrinfo hints, *servinfo, *p;
+#endif
+#ifdef WIN32
+ MIB_IPFORWARDROW ip_forward;
+#endif
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
/* first try to get infos from minissdpd ! */
if(!minissdpdsock)
minissdpdsock = "/var/run/minissdpd.sock";
@@ -463,17 +476,79 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
PRINT_SOCKET_ERROR("socket");
return NULL;
}
- /* reception */
- memset(&sockudp_r, 0, sizeof(struct sockaddr_in));
- sockudp_r.sin_family = AF_INET;
- if(sameport)
- sockudp_r.sin_port = htons(PORT);
- sockudp_r.sin_addr.s_addr = INADDR_ANY;
- /* emission */
- memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
- sockudp_w.sin_family = AF_INET;
- sockudp_w.sin_port = htons(PORT);
- sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
+ /* reception */
+ memset(&sockudp_r, 0, sizeof(struct sockaddr));
+ if(0/*ipv6*/) {
+ struct sockaddr_in6 * p = (struct sockaddr_in6 *)&sockudp_r;
+ p->sin6_family = AF_INET6;
+ if(sameport)
+ p->sin6_port = htons(PORT);
+ p->sin6_addr = in6addr_any;//IN6ADDR_ANY_INIT;/*INADDR_ANY;*/
+ } else {
+ struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_r;
+ p->sin_family = AF_INET;
+ if(sameport)
+ p->sin_port = htons(PORT);
+ 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(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 (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
+ free(pIPAddrTable);
+ pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
+ }
+ if(pIPAddrTable) {
+ dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
+#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;
+ if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0) {
+ PRINT_SOCKET_ERROR("setsockopt");
+ }
+ ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = pIPAddrTable->table[i].dwAddr;
+#ifndef DEBUG
+ break;
+#endif
+ }
+ }
+ free(pIPAddrTable);
+ pIPAddrTable = NULL;
+ }
+ }
+#endif
#ifdef WIN32
if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0)
@@ -489,15 +564,18 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
{
struct in_addr mc_if;
mc_if.s_addr = inet_addr(multicastif);
- sockudp_r.sin_addr.s_addr = mc_if.s_addr;
+ if(0/*ipv6*/) {
+ } else {
+ ((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)
{
PRINT_SOCKET_ERROR("setsockopt");
}
}
/* Avant d'envoyer le paquet on bind pour recevoir la reponse */
- if (bind(sudp, (struct sockaddr *)&sockudp_r, sizeof(struct sockaddr_in)) != 0)
+ if (bind(sudp, &sockudp_r, 0/*ipv6*/?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in)) != 0)
{
PRINT_SOCKET_ERROR("bind");
closesocket(sudp);
@@ -515,13 +593,46 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
n = snprintf(bufr, sizeof(bufr),
MSearchMsgFmt, deviceList[deviceIndex++], mx);
/*printf("Sending %s", bufr);*/
+#ifdef NO_GETADDRINFO
+ /* the following code is not using getaddrinfo */
+ /* emission */
+ memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
+ sockudp_w.sin_family = AF_INET;
+ sockudp_w.sin_port = htons(PORT);
+ sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
n = sendto(sudp, bufr, n, 0,
(struct sockaddr *)&sockudp_w, sizeof(struct sockaddr_in));
if (n < 0) {
PRINT_SOCKET_ERROR("sendto");
closesocket(sudp);
return devlist;
}
+#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(UPNP_MCAST_ADDR, XSTR(PORT), &hints, &servinfo)) != 0) {
+#ifdef WIN32
+ fprintf(stderr, "getaddrinfo() failed: %d\n", rv);
+#else
+ fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
+#endif
+ return devlist;
+ }
+ for(p = servinfo; p; p = p->ai_next) {
+ n = sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen);
+ if (n < 0) {
+ PRINT_SOCKET_ERROR("sendto");
+ continue;
+ }
+ }
+ freeaddrinfo(servinfo);
+ if(n < 0) {
+ closesocket(sudp);
+ return devlist;
+ }
+#endif /* #ifdef NO_GETADDRINFO */
}
/* Waiting for SSDP REPLY packet to M-SEARCH */
n = ReceiveData(sudp, bufr, sizeof(bufr), delay);
@@ -545,8 +656,21 @@ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize);
if(st&&descURL)
{
- /*printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
- stsize, st, urlsize, descURL); */
+#ifdef DEBUG
+ printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
+ stsize, st, urlsize, descURL);
+#endif
+ 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')
+ 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);
tmp->pNext = devlist;
tmp->descURL = tmp->buffer;
@@ -609,9 +733,9 @@ LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
n1 = strlen(descURL);
n1 += 2; /* 1 byte more for Null terminator, 1 byte for '/' if needed */
n2 = n1; n3 = n1;
- n1 += strlen(data->scpdurl);
- n2 += strlen(data->controlurl);
- n3 += strlen(data->controlurl_CIF);
+ n1 += strlen(data->first.scpdurl);
+ n2 += strlen(data->first.controlurl);
+ n3 += strlen(data->CIF.controlurl);
urls->ipcondescURL = (char *)malloc(n1);
urls->controlURL = (char *)malloc(n2);
@@ -626,19 +750,19 @@ LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
strncpy(urls->controlURL, urls->ipcondescURL, n2);
strncpy(urls->controlURL_CIF, urls->ipcondescURL, n3);
- url_cpy_or_cat(urls->ipcondescURL, data->scpdurl, n1);
+ url_cpy_or_cat(urls->ipcondescURL, data->first.scpdurl, n1);
- url_cpy_or_cat(urls->controlURL, data->controlurl, n2);
+ url_cpy_or_cat(urls->controlURL, data->first.controlurl, n2);
- url_cpy_or_cat(urls->controlURL_CIF, data->controlurl_CIF, n3);
+ url_cpy_or_cat(urls->controlURL_CIF, data->CIF.controlurl, n3);
#ifdef DEBUG
- printf("urls->ipcondescURL='%s' %d n1=%d\n", urls->ipcondescURL,
- strlen(urls->ipcondescURL), n1);
- printf("urls->controlURL='%s' %d n2=%d\n", urls->controlURL,
- strlen(urls->controlURL), n2);
- printf("urls->controlURL_CIF='%s' %d n3=%d\n", urls->controlURL_CIF,
- strlen(urls->controlURL_CIF), n3);
+ printf("urls->ipcondescURL='%s' %u n1=%d\n", urls->ipcondescURL,
+ (unsigned)strlen(urls->ipcondescURL), n1);
+ printf("urls->controlURL='%s' %u n2=%d\n", urls->controlURL,
+ (unsigned)strlen(urls->controlURL), n2);
+ printf("urls->controlURL_CIF='%s' %u n3=%d\n", urls->controlURL_CIF,
+ (unsigned)strlen(urls->controlURL_CIF), n3);
#endif
}
@@ -659,7 +783,7 @@ FreeUPNPUrls(struct UPNPUrls * urls)
int ReceiveData(int socket, char * data, int length, int timeout)
{
int n;
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
struct pollfd fds[1]; /* for the poll */
#ifdef MINIUPNPC_IGNORE_EINTR
do {
@@ -711,7 +835,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
char status[64];
unsigned int uptime;
status[0] = '\0';
- UPNP_GetStatusInfo(urls->controlURL, data->servicetype,
+ UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype,
status, &uptime, NULL);
if(0 == strcmp("Connected", status))
{
@@ -768,7 +892,7 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
parserootdesc(descXML, descXMLsize, data);
free(descXML);
descXML = NULL;
- if(0==strcmp(data->servicetype_CIF,
+ if(0==strcmp(data->CIF.servicetype,
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")
|| state >= 3 )
{
@@ -782,6 +906,25 @@ UPNP_GetValidIGD(struct UPNPDev * devlist,
if((state >= 2) || UPNPIGD_IsConnected(urls, data))
return state;
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);
+#ifdef DEBUG
+ printf("UPNPIGD_IsConnected(%s) = %d\n",
+ urls->controlURL,
+ UPNPIGD_IsConnected(urls, data));
+#endif
+ if((state >= 2) || UPNPIGD_IsConnected(urls, data))
+ return state;
+ FreeUPNPUrls(urls);
+ }
}
memset(data, 0, sizeof(struct IGDdatas));
}
View
31 lib/netplay/miniupnpc/miniupnpc.def
@@ -1,31 +0,0 @@
-LIBRARY
-; miniupnpc library
-
-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_DeletePortMapping
- UPNP_GetPortMappingNumberOfEntries
- UPNP_GetSpecificPortMappingEntry
- UPNP_GetGenericPortMappingEntry
-; upnperrors
- strupnperror
View
2 lib/netplay/miniupnpc/miniupnpc.h
@@ -11,8 +11,6 @@
#include "declspec.h"
#include "igd_desc_parse.h"
-#undef DEBUG
-
#ifdef __cplusplus
extern "C" {
#endif
View
494 lib/netplay/miniupnpc/miniupnpcmodule.c
@@ -1,494 +0,0 @@
-/* $Id: miniupnpcmodule.c,v 1.14 2009/10/16 09:02:47 nanard Exp $*/
-/* Project : miniupnp
- * Author : Thomas BERNARD
- * website : http://miniupnp.tuxfamily.org/
- * copyright (c) 2007-2009 Thomas Bernard
- * This software is subjet to the conditions detailed in the
- * provided LICENCE file. */
-#include <Python.h>
-#define STATICLIB
-#include "structmember.h"
-#include "miniupnpc.h"
-#include "upnpcommands.h"
-#include "upnperrors.h"
-
-/* for compatibility with Python < 2.4 */
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-#endif
-
-#ifndef Py_RETURN_TRUE
-#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
-#endif
-
-#ifndef Py_RETURN_FALSE
-#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
-#endif
-
-typedef struct {
- PyObject_HEAD
- /* Type-specific fields go here. */
- struct UPNPDev * devlist;
- struct UPNPUrls urls;
- struct IGDdatas data;
- unsigned int discoverdelay; /* value passed to upnpDiscover() */
- char lanaddr[16]; /* our ip address on the LAN */
- char * multicastif;
- char * minissdpdsocket;
-} UPnPObject;
-
-static PyMemberDef UPnP_members[] = {
- {"lanaddr", T_STRING_INPLACE, offsetof(UPnPObject, lanaddr),
- READONLY, "ip address on the LAN"
- },
- {"discoverdelay", T_UINT, offsetof(UPnPObject, discoverdelay),
- 0/*READWRITE*/, "value in ms used to wait for SSDP responses"
- },
- /* T_STRING is allways readonly :( */
- {"multicastif", T_STRING, offsetof(UPnPObject, multicastif),
- 0, "IP of the network interface to be used for multicast operations"
- },
- {"minissdpdsocket", T_STRING, offsetof(UPnPObject, multicastif),
- 0, "path of the MiniSSDPd unix socket"
- },
- {NULL}
-};
-
-static void
-UPnPObject_dealloc(UPnPObject *self)
-{
- freeUPNPDevlist(self->devlist);
- FreeUPNPUrls(&self->urls);
- self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-UPnP_discover(UPnPObject *self)
-{
- struct UPNPDev * dev;
- int i;
- PyObject *res = NULL;
- if(self->devlist)
- {
- freeUPNPDevlist(self->devlist);
- self->devlist = 0;
- }
- Py_BEGIN_ALLOW_THREADS
- self->devlist = upnpDiscover((int)self->discoverdelay/*timeout in ms*/,
- 0/* multicast if*/,
- 0/*minissdpd socket*/,
- 0/*sameport flag*/);
- Py_END_ALLOW_THREADS
- /* Py_RETURN_NONE ??? */
- for(dev = self->devlist, i = 0; dev; dev = dev->pNext)
- i++;
- res = Py_BuildValue("i", i);
- return res;
-}
-
-static PyObject *
-UPnP_selectigd(UPnPObject *self)
-{
- int r;
-Py_BEGIN_ALLOW_THREADS
- r = UPNP_GetValidIGD(self->devlist, &self->urls, &self->data,
- self->lanaddr, sizeof(self->lanaddr));
-Py_END_ALLOW_THREADS
- if(r)
- {
- return Py_BuildValue("s", self->urls.controlURL);
- }
- else
- {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, "No UPnP device discovered");
- return NULL;
- }
-}
-
-static PyObject *
-UPnP_totalbytesent(UPnPObject *self)
-{
- UNSIGNED_INTEGER i;
-Py_BEGIN_ALLOW_THREADS
- i = UPNP_GetTotalBytesSent(self->urls.controlURL_CIF,
- self->data.servicetype_CIF);
-Py_END_ALLOW_THREADS
- return Py_BuildValue("I", i);
-}
-
-static PyObject *
-UPnP_totalbytereceived(UPnPObject *self)
-{
- UNSIGNED_INTEGER i;
-Py_BEGIN_ALLOW_THREADS
- i = UPNP_GetTotalBytesReceived(self->urls.controlURL_CIF,
- self->data.servicetype_CIF);
-Py_END_ALLOW_THREADS
- return Py_BuildValue("I", i);
-}
-
-static PyObject *
-UPnP_totalpacketsent(UPnPObject *self)
-{
- UNSIGNED_INTEGER i;
-Py_BEGIN_ALLOW_THREADS
- i = UPNP_GetTotalPacketsSent(self->urls.controlURL_CIF,
- self->data.servicetype_CIF);
-Py_END_ALLOW_THREADS
- return Py_BuildValue("I", i);
-}
-
-static PyObject *
-UPnP_totalpacketreceived(UPnPObject *self)
-{
- UNSIGNED_INTEGER i;
-Py_BEGIN_ALLOW_THREADS
- i = UPNP_GetTotalPacketsReceived(self->urls.controlURL_CIF,
- self->data.servicetype_CIF);
-Py_END_ALLOW_THREADS
- return Py_BuildValue("I", i);
-}
-
-static PyObject *
-UPnP_statusinfo(UPnPObject *self)
-{
- char status[64];
- char lastconnerror[64];
- unsigned int uptime = 0;
- int r;
- status[0] = '\0';
- lastconnerror[0] = '\0';
-Py_BEGIN_ALLOW_THREADS
- r = UPNP_GetStatusInfo(self->urls.controlURL, self->data.servicetype,
- status, &uptime, lastconnerror);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS) {
- return Py_BuildValue("(s,I,s)", status, uptime, lastconnerror);
- } else {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-static PyObject *
-UPnP_connectiontype(UPnPObject *self)
-{
- char connectionType[64];
- int r;
- connectionType[0] = '\0';
-Py_BEGIN_ALLOW_THREADS
- r = UPNP_GetConnectionTypeInfo(self->urls.controlURL,
- self->data.servicetype,
- connectionType);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS) {
- return Py_BuildValue("s", connectionType);
- } else {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-static PyObject *
-UPnP_externalipaddress(UPnPObject *self)
-{
- char externalIPAddress[16];
- int r;
- externalIPAddress[0] = '\0';
-Py_BEGIN_ALLOW_THREADS
- r = UPNP_GetExternalIPAddress(self->urls.controlURL,
- self->data.servicetype,
- externalIPAddress);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS) {
- return Py_BuildValue("s", externalIPAddress);
- } else {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-/* AddPortMapping(externalPort, protocol, internalHost, internalPort, desc,
- * remoteHost)
- * protocol is 'UDP' or 'TCP' */
-static PyObject *
-UPnP_addportmapping(UPnPObject *self, PyObject *args)
-{
- char extPort[6];
- unsigned short ePort;
- char inPort[6];
- unsigned short iPort;
- const char * proto;
- const char * host;
- const char * desc;
- const char * remoteHost;
- int r;
- if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto,
- &host, &iPort, &desc, &remoteHost))
- return NULL;
-Py_BEGIN_ALLOW_THREADS
- sprintf(extPort, "%hu", ePort);
- sprintf(inPort, "%hu", iPort);
- r = UPNP_AddPortMapping(self->urls.controlURL, self->data.servicetype,
- extPort, inPort, host, desc, proto, remoteHost);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS)
- {
- Py_RETURN_TRUE;
- }
- else
- {
- // TODO: RAISE an Exception. See upnpcommands.h for errors codes.
- // upnperrors.c
- //Py_RETURN_FALSE;
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-/* DeletePortMapping(extPort, proto, removeHost='')
- * proto = 'UDP', 'TCP' */
-static PyObject *
-UPnP_deleteportmapping(UPnPObject *self, PyObject *args)
-{
- char extPort[6];
- unsigned short ePort;
- const char * proto;
- const char * remoteHost = "";
- int r;
- if(!PyArg_ParseTuple(args, "Hs|z", &ePort, &proto, &remoteHost))
- return NULL;
-Py_BEGIN_ALLOW_THREADS
- sprintf(extPort, "%hu", ePort);
- r = UPNP_DeletePortMapping(self->urls.controlURL, self->data.servicetype,
- extPort, proto, remoteHost);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS) {
- Py_RETURN_TRUE;
- } else {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-static PyObject *
-UPnP_getportmappingnumberofentries(UPnPObject *self)
-{
- unsigned int n = 0;
- int r;
-Py_BEGIN_ALLOW_THREADS
- r = UPNP_GetPortMappingNumberOfEntries(self->urls.controlURL,
- self->data.servicetype,
- &n);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS) {
- return Py_BuildValue("I", n);
- } else {
- /* TODO: have our own exception type ! */
- PyErr_SetString(PyExc_Exception, strupnperror(r));
- return NULL;
- }
-}
-
-/* GetSpecificPortMapping(ePort, proto)
- * proto = 'UDP' or 'TCP' */
-static PyObject *
-UPnP_getspecificportmapping(UPnPObject *self, PyObject *args)
-{
- char extPort[6];
- unsigned short ePort;
- const char * proto;
- char intClient[16];
- char intPort[6];
- unsigned short iPort;
- if(!PyArg_ParseTuple(args, "Hs", &ePort, &proto))
- return NULL;
-Py_BEGIN_ALLOW_THREADS
- sprintf(extPort, "%hu", ePort);
- UPNP_GetSpecificPortMappingEntry(self->urls.controlURL,
- self->data.servicetype,
- extPort, proto,
- intClient, intPort);
-Py_END_ALLOW_THREADS
- if(intClient[0])
- {
- iPort = (unsigned short)atoi(intPort);
- return Py_BuildValue("(s,H)", intClient, iPort);
- }
- else
- {
- Py_RETURN_NONE;
- }
-}
-
-/* GetGenericPortMapping(index) */
-static PyObject *
-UPnP_getgenericportmapping(UPnPObject *self, PyObject *args)
-{
- int i, r;
- char index[8];
- char intClient[16];
- char intPort[6];
- unsigned short iPort;
- char extPort[6];
- unsigned short ePort;
- char protocol[4];
- char desc[80];
- char enabled[6];
- char rHost[64];
- char duration[16]; /* lease duration */
- unsigned int dur;
- if(!PyArg_ParseTuple(args, "i", &i))
- return NULL;
-Py_BEGIN_ALLOW_THREADS
- snprintf(index, sizeof(index), "%d", i);
- rHost[0] = '\0'; enabled[0] = '\0';
- duration[0] = '\0'; desc[0] = '\0';
- extPort[0] = '\0'; intPort[0] = '\0'; intClient[0] = '\0';
- r = UPNP_GetGenericPortMappingEntry(self->urls.controlURL,
- self->data.servicetype,
- index,
- extPort, intClient, intPort,
- protocol, desc, enabled, rHost,
- duration);
-Py_END_ALLOW_THREADS
- if(r==UPNPCOMMAND_SUCCESS)
- {
- ePort = (unsigned short)atoi(extPort);
- iPort = (unsigned short)atoi(intPort);
- dur = (unsigned int)strtoul(duration, 0, 0);
- return Py_BuildValue("(H,s,(s,H),s,s,s,I)",
- ePort, protocol, intClient, iPort,
- desc, enabled, rHost, dur);
- }
- else
- {
- Py_RETURN_NONE;
- }
-}
-
-/* miniupnpc.UPnP object Method Table */
-static PyMethodDef UPnP_methods[] = {
- {"discover", (PyCFunction)UPnP_discover, METH_NOARGS,
- "discover UPnP IGD devices on the network"
- },
- {"selectigd", (PyCFunction)UPnP_selectigd, METH_NOARGS,
- "select a valid UPnP IGD among discovered devices"
- },
- {"totalbytesent", (PyCFunction)UPnP_totalbytesent, METH_NOARGS,
- "return the total number of bytes sent by UPnP IGD"
- },
- {"totalbytereceived", (PyCFunction)UPnP_totalbytereceived, METH_NOARGS,
- "return the total number of bytes received by UPnP IGD"
- },
- {"totalpacketsent", (PyCFunction)UPnP_totalpacketsent, METH_NOARGS,
- "return the total number of packets sent by UPnP IGD"
- },
- {"totalpacketreceived", (PyCFunction)UPnP_totalpacketreceived, METH_NOARGS,
- "return the total number of packets received by UPnP IGD"
- },
- {"statusinfo", (PyCFunction)UPnP_statusinfo, METH_NOARGS,
- "return status and uptime"
- },
- {"connectiontype", (PyCFunction)UPnP_connectiontype, METH_NOARGS,
- "return IGD WAN connection type"
- },
- {"externalipaddress", (PyCFunction)UPnP_externalipaddress, METH_NOARGS,
- "return external IP address"
- },
- {"addportmapping", (PyCFunction)UPnP_addportmapping, METH_VARARGS,
- "add a port mapping"
- },
- {"deleteportmapping", (PyCFunction)UPnP_deleteportmapping, METH_VARARGS,
- "delete a port mapping"
- },
- {"getportmappingnumberofentries", (PyCFunction)UPnP_getportmappingnumberofentries, METH_NOARGS,
- "-- non standard --"
- },
- {"getspecificportmapping", (PyCFunction)UPnP_getspecificportmapping, METH_VARARGS,
- "get details about a specific port mapping entry"
- },
- {"getgenericportmapping", (PyCFunction)UPnP_getgenericportmapping, METH_VARARGS,
- "get all details about the port mapping at index"
- },
- {NULL} /* Sentinel */
-};
-
-static PyTypeObject UPnPType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "miniupnpc.UPnP", /*tp_name*/
- sizeof(UPnPObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)UPnPObject_dealloc,/*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "UPnP objects", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- UPnP_methods, /* tp_methods */
- UPnP_members, /* tp_members */
- 0, /* tp_getset */
- 0