mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 23:08:35 +00:00
Merge pull request #3291 from signalwire/libnatpmp-dev
[Core] Remove in-tree libnatpmp: use libnatpmp-dev on Linux and the windows-deps package on Windows
This commit is contained in:
1 parent
9039d5a82d
commit
f7ec023dc1
30 files changed
+107
-1530
No files matched your search
@@ -39,6 +39,7 @@ jobs:
|
|||||||
jpeg \
|
jpeg \
|
||||||
ldns \
|
ldns \
|
||||||
libks \
|
libks \
|
||||||
|
libnatpmp \
|
||||||
libpq@18 \
|
libpq@18 \
|
||||||
libsndfile \
|
libsndfile \
|
||||||
libtool \
|
libtool \
|
||||||
|
|||||||
@@ -297,6 +297,8 @@ libs/freetype-*/
|
|||||||
libs/freetype-*.zip
|
libs/freetype-*.zip
|
||||||
libs/miniupnpc-*/
|
libs/miniupnpc-*/
|
||||||
libs/miniupnpc-*.zip
|
libs/miniupnpc-*.zip
|
||||||
|
libs/libnatpmp-*/
|
||||||
|
libs/libnatpmp-*.zip
|
||||||
libs/SharpZipLib.*/
|
libs/SharpZipLib.*/
|
||||||
libs/SharpZipLib.*.nupkg
|
libs/SharpZipLib.*.nupkg
|
||||||
libs/nasm-*/
|
libs/nasm-*/
|
||||||
|
|||||||
@@ -1554,10 +1554,6 @@ Files: libs/libtpl-1.5/src/tpl.[ch]
|
|||||||
Copyright: 2005-2010, Troy D. Hanson
|
Copyright: 2005-2010, Troy D. Hanson
|
||||||
License: BSD-2-clause
|
License: BSD-2-clause
|
||||||
|
|
||||||
Files: libs/libnatpmp/*
|
|
||||||
Copyright: 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
License: ISC
|
|
||||||
|
|
||||||
Files: libs/libwebsockets/*
|
Files: libs/libwebsockets/*
|
||||||
Copyright: 2010-2011 Andy Green <andy@warmcat.com>
|
Copyright: 2010-2011 Andy Green <andy@warmcat.com>
|
||||||
License: LGPL
|
License: LGPL
|
||||||
|
|||||||
+1
-3
@@ -279,7 +279,7 @@ endif
|
|||||||
lib_LTLIBRARIES = libfreeswitch.la
|
lib_LTLIBRARIES = libfreeswitch.la
|
||||||
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(GUMBO_CFLAGS) $(FVAD_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE2_CFLAGS) $(SPEEX_CFLAGS) $(MINIUPNPC_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(SOFIA_SIP_CFLAGS) $(AM_CFLAGS) $(TPL_CFLAGS)
|
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(GUMBO_CFLAGS) $(FVAD_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE2_CFLAGS) $(SPEEX_CFLAGS) $(MINIUPNPC_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(SOFIA_SIP_CFLAGS) $(AM_CFLAGS) $(TPL_CFLAGS)
|
||||||
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined
|
libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined
|
||||||
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE2_LIBS) $(SPEEX_LIBS) $(MINIUPNPC_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS)
|
libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE2_LIBS) $(SPEEX_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS)
|
||||||
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
|
libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
if HAVE_PNG
|
if HAVE_PNG
|
||||||
@@ -430,8 +430,6 @@ libfreeswitch_la_SOURCES = \
|
|||||||
src/switch_vpx.c \
|
src/switch_vpx.c \
|
||||||
libs/libteletone/src/libteletone_detect.c \
|
libs/libteletone/src/libteletone_detect.c \
|
||||||
libs/libteletone/src/libteletone_generate.c \
|
libs/libteletone/src/libteletone_generate.c \
|
||||||
libs/libnatpmp/natpmp.c \
|
|
||||||
libs/libnatpmp/getgateway.c \
|
|
||||||
src/switch_uuidv7.c
|
src/switch_uuidv7.c
|
||||||
|
|
||||||
if ENABLE_CPP
|
if ENABLE_CPP
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
# in that same directory.
|
# in that same directory.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
RPMS=git gcc-c++ autoconf automake libtool wget ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre2-devel speex-devel miniupnpc-devel ldns-devel libedit-devel
|
RPMS=git gcc-c++ autoconf automake libtool wget ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre2-devel speex-devel miniupnpc-devel libnatpmp-devel ldns-devel libedit-devel
|
||||||
DEBS=git build-essential automake autoconf 'libtool-bin|libtool' wget uuid-dev zlib1g-dev 'libjpeg8-dev|libjpeg62-turbo-dev' libncurses5-dev libssl-dev libpcre2-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libspeexdsp-dev libsqlite3-dev libminiupnpc-dev perl libgdbm-dev libdb-dev bison libvlc-dev pkg-config
|
DEBS=git build-essential automake autoconf 'libtool-bin|libtool' wget uuid-dev zlib1g-dev 'libjpeg8-dev|libjpeg62-turbo-dev' libncurses5-dev libssl-dev libpcre2-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libspeexdsp-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev perl libgdbm-dev libdb-dev bison libvlc-dev pkg-config
|
||||||
|
|
||||||
freeswitch: deps has-git freeswitch.git/Makefile
|
freeswitch: deps has-git freeswitch.git/Makefile
|
||||||
cd freeswitch.git && make
|
cd freeswitch.git && make
|
||||||
|
|||||||
@@ -1347,6 +1347,11 @@ PKG_CHECK_MODULES([CURL], [libcurl >= 7.19])
|
|||||||
PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.00])
|
PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.00])
|
||||||
PKG_CHECK_MODULES([SPEEX], [speex >= 1.2rc1 speexdsp >= 1.2rc1])
|
PKG_CHECK_MODULES([SPEEX], [speex >= 1.2rc1 speexdsp >= 1.2rc1])
|
||||||
PKG_CHECK_MODULES([MINIUPNPC], [miniupnpc >= 2.1])
|
PKG_CHECK_MODULES([MINIUPNPC], [miniupnpc >= 2.1])
|
||||||
|
|
||||||
|
AC_CHECK_HEADER([natpmp.h], [], [AC_MSG_ERROR([no usable libnatpmp; please install libnatpmp devel package or equivalent])])
|
||||||
|
AC_CHECK_LIB([natpmp], [initnatpmp], [NATPMP_LIBS=-lnatpmp], [AC_MSG_ERROR([no usable libnatpmp; please install libnatpmp devel package or equivalent])])
|
||||||
|
AC_SUBST([NATPMP_LIBS])
|
||||||
|
|
||||||
PKG_CHECK_MODULES([LDNS], [libldns-fs >= 1.6.6],[
|
PKG_CHECK_MODULES([LDNS], [libldns-fs >= 1.6.6],[
|
||||||
AM_CONDITIONAL([HAVE_LDNS],[true])],[
|
AM_CONDITIONAL([HAVE_LDNS],[true])],[
|
||||||
PKG_CHECK_MODULES([LDNS], [libldns >= 1.6.6],[
|
PKG_CHECK_MODULES([LDNS], [libldns >= 1.6.6],[
|
||||||
|
|||||||
Vendored
+1
@@ -304,6 +304,7 @@ Build-Depends:
|
|||||||
libsqlite3-dev,
|
libsqlite3-dev,
|
||||||
libtiff5-dev,
|
libtiff5-dev,
|
||||||
libminiupnpc-dev (>= 2.1),
|
libminiupnpc-dev (>= 2.1),
|
||||||
|
libnatpmp-dev,
|
||||||
wget, pkg-config,
|
wget, pkg-config,
|
||||||
yasm,
|
yasm,
|
||||||
# core codecs
|
# core codecs
|
||||||
|
|||||||
Vendored
-4
@@ -1549,10 +1549,6 @@ Files: libs/libtpl-1.5/src/tpl.[ch]
|
|||||||
Copyright: 2005-2010, Troy D. Hanson
|
Copyright: 2005-2010, Troy D. Hanson
|
||||||
License: BSD-2-clause
|
License: BSD-2-clause
|
||||||
|
|
||||||
Files: libs/libnatpmp/*
|
|
||||||
Copyright: 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
License: ISC
|
|
||||||
|
|
||||||
Files: libs/libwebsockets/*
|
Files: libs/libwebsockets/*
|
||||||
Copyright: 2010-2011 Andy Green <andy@warmcat.com>
|
Copyright: 2010-2011 Andy Green <andy@warmcat.com>
|
||||||
License: LGPL
|
License: LGPL
|
||||||
|
|||||||
+1
-1
@@ -1240,7 +1240,7 @@ SEARCH_INCLUDES = YES
|
|||||||
# contain include files that are not input files but should be processed by
|
# contain include files that are not input files but should be processed by
|
||||||
# the preprocessor.
|
# the preprocessor.
|
||||||
|
|
||||||
INCLUDE_PATH =../libs/apr ../libs/apr-util ../libs/libnatpmp \
|
INCLUDE_PATH =../libs/apr ../libs/apr-util \
|
||||||
../libs/sofia-sip ../libs/spandsp \
|
../libs/sofia-sip ../libs/spandsp \
|
||||||
../libs/srtp ../libs/win32 ../libs/xmlrpc-c
|
../libs/srtp ../libs/win32 ../libs/xmlrpc-c
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ BuildRequires: spandsp4-devel >= 3.1.1
|
|||||||
BuildRequires: pcre2-devel
|
BuildRequires: pcre2-devel
|
||||||
BuildRequires: speex-devel
|
BuildRequires: speex-devel
|
||||||
BuildRequires: miniupnpc-devel >= 2.1
|
BuildRequires: miniupnpc-devel >= 2.1
|
||||||
|
BuildRequires: libnatpmp-devel
|
||||||
BuildRequires: sqlite-devel >= 3.6.20
|
BuildRequires: sqlite-devel >= 3.6.20
|
||||||
BuildRequires: libtiff-devel
|
BuildRequires: libtiff-devel
|
||||||
BuildRequires: libedit-devel
|
BuildRequires: libedit-devel
|
||||||
@@ -151,6 +152,7 @@ Requires: curl >= 7.19
|
|||||||
Requires: pcre2
|
Requires: pcre2
|
||||||
Requires: speex
|
Requires: speex
|
||||||
Requires: miniupnpc >= 2.1
|
Requires: miniupnpc >= 2.1
|
||||||
|
Requires: libnatpmp
|
||||||
Requires: sqlite >= 3.6.20
|
Requires: sqlite >= 3.6.20
|
||||||
Requires: libtiff
|
Requires: libtiff
|
||||||
Requires: libedit
|
Requires: libedit
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
$Id: Changelog.txt,v 1.14 2009/03/10 10:15:30 nanard Exp $
|
|
||||||
|
|
||||||
2009/03/10:
|
|
||||||
Trying to have windows get gateway working if not using DHCP
|
|
||||||
|
|
||||||
2009/02/27:
|
|
||||||
dont include declspec.h if not under WIN32.
|
|
||||||
|
|
||||||
2009/01/23:
|
|
||||||
Prefixed the libraries name with lib
|
|
||||||
|
|
||||||
2008/10/06:
|
|
||||||
Fixed a memory leak in getdefaultgateway() (USE_SYSCTL_NET_ROUTE)
|
|
||||||
|
|
||||||
2008/07/03:
|
|
||||||
Adding WIN32 code from Robbie Hanson
|
|
||||||
|
|
||||||
2008/06/30:
|
|
||||||
added a Solaris implementation for getgateway().
|
|
||||||
added a LICENCE file to the distribution
|
|
||||||
|
|
||||||
2008/05/29:
|
|
||||||
Anonymous unions are forbidden in ANSI C. That was causing problems with
|
|
||||||
non-GCC compilers.
|
|
||||||
|
|
||||||
2008/04/28:
|
|
||||||
introduced strnatpmperr()
|
|
||||||
improved natpmpc.c sample
|
|
||||||
make install now install the binary
|
|
||||||
|
|
||||||
2007/12/13:
|
|
||||||
Fixed getgateway.c for working under OS X ;)
|
|
||||||
Fixed values for NATPMP_PROTOCOL_TCP and NATPMP_PROTOCOL_UDP
|
|
||||||
|
|
||||||
2007/12/11:
|
|
||||||
Fixed getgateway.c for compilation under Mac OS X
|
|
||||||
|
|
||||||
2007/12/01:
|
|
||||||
added some comments in .h
|
|
||||||
|
|
||||||
2007/11/30:
|
|
||||||
implemented almost everything
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
Copyright (c) 2007-2008, 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.
|
|
||||||
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
# $Id: Makefile,v 1.7 2009/01/23 19:05:04 nanard Exp $
|
|
||||||
# This Makefile is designed for use with GNU make
|
|
||||||
# libnatpmp
|
|
||||||
# (c) 2007-2009 Thomas Bernard
|
|
||||||
# http://miniupnp.free.fr/libnatpmp.html
|
|
||||||
|
|
||||||
CC = gcc
|
|
||||||
INSTALL = install
|
|
||||||
|
|
||||||
# APIVERSION is used in soname
|
|
||||||
APIVERSION = 0
|
|
||||||
CFLAGS = -O -fPIC -Wall -DENABLE_STRNATPMPERR
|
|
||||||
|
|
||||||
LIBOBJS = natpmp.o getgateway.o
|
|
||||||
|
|
||||||
OBJS = $(LIBOBJS) testgetgateway.o natpmpc.o
|
|
||||||
|
|
||||||
STATICLIB = libnatpmp.a
|
|
||||||
SHAREDLIB = libnatpmp.so
|
|
||||||
SONAME = $(SHAREDLIB).$(APIVERSION)
|
|
||||||
|
|
||||||
HEADERS = natpmp.h
|
|
||||||
|
|
||||||
EXECUTABLES = testgetgateway natpmpc-shared natpmpc-static
|
|
||||||
|
|
||||||
INSTALLPREFIX ?= $(PREFIX)/usr
|
|
||||||
INSTALLDIRINC = $(INSTALLPREFIX)/include
|
|
||||||
INSTALLDIRLIB = $(INSTALLPREFIX)/lib
|
|
||||||
INSTALLDIRBIN = $(INSTALLPREFIX)/bin
|
|
||||||
|
|
||||||
.PHONY: all clean depend install cleaninstall
|
|
||||||
|
|
||||||
all: $(STATICLIB) $(SHAREDLIB) $(EXECUTABLES)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) $(OBJS) $(EXECUTABLES) $(STATICLIB) $(SHAREDLIB)
|
|
||||||
|
|
||||||
depend:
|
|
||||||
makedepend -f$(MAKEFILE_LIST) -Y $(OBJS:.o=.c) 2>/dev/null
|
|
||||||
|
|
||||||
install: $(HEADERS) $(STATICLIB) $(SHAREDLIB)
|
|
||||||
$(INSTALL) -d $(INSTALLDIRINC)
|
|
||||||
$(INSTALL) --mode=644 $(HEADERS) $(INSTALLDIRINC)
|
|
||||||
$(INSTALL) -d $(INSTALLDIRLIB)
|
|
||||||
$(INSTALL) --mode=644 $(STATICLIB) $(INSTALLDIRLIB)
|
|
||||||
$(INSTALL) --mode=644 $(SHAREDLIB) $(INSTALLDIRLIB)/$(SONAME)
|
|
||||||
$(INSTALL) --mode=755 natpmpc-shared $(INSTALLDIRBIN)/natpmpc
|
|
||||||
ln --symbolic --force $(SONAME) $(INSTALLDIRLIB)/$(SHAREDLIB)
|
|
||||||
|
|
||||||
cleaninstall:
|
|
||||||
$(RM) $(addprefix $(INSTALLDIRINC), $(HEADERS))
|
|
||||||
$(RM) $(INSTALLDIRLIB)/$(SONAME)
|
|
||||||
$(RM) $(INSTALLDIRLIB)/$(SHAREDLIB)
|
|
||||||
$(RM) $(INSTALLDIRLIB)/$(STATICLIB)
|
|
||||||
|
|
||||||
testgetgateway: testgetgateway.o getgateway.o
|
|
||||||
|
|
||||||
natpmpc-static: natpmpc.o $(STATICLIB)
|
|
||||||
$(CC) -o $@ $^
|
|
||||||
|
|
||||||
natpmpc-shared: natpmpc.o $(SHAREDLIB)
|
|
||||||
$(CC) -o $@ $^
|
|
||||||
|
|
||||||
$(STATICLIB): $(LIBOBJS)
|
|
||||||
$(AR) crs $@ $?
|
|
||||||
|
|
||||||
$(SHAREDLIB): $(LIBOBJS)
|
|
||||||
$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
|
|
||||||
|
|
||||||
# DO NOT DELETE
|
|
||||||
|
|
||||||
natpmp.o: natpmp.h getgateway.h
|
|
||||||
getgateway.o: getgateway.h
|
|
||||||
testgetgateway.o: getgateway.h
|
|
||||||
natpmpc.o: natpmp.h
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
@echo Compile getgateway
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR getgateway.c
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR testgetgateway.c
|
|
||||||
gcc -o testgetgateway getgateway.o testgetgateway.o -lws2_32
|
|
||||||
|
|
||||||
@echo Compile natpmp:
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR getgateway.c
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR natpmp.c
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DSTATICLIB -DENABLE_STRNATPMPERR natpmpc.c
|
|
||||||
gcc -c -Wall -Os -DWIN32 wingettimeofday.c
|
|
||||||
gcc -o natpmpc getgateway.o natpmp.o natpmpc.o wingettimeofday.o -lws2_32
|
|
||||||
|
|
||||||
@echo Create natpmp.dll:
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DENABLE_STRNATPMPERR -DNATPMP_EXPORTS getgateway.c
|
|
||||||
gcc -c -Wall -Os -DWIN32 -DENABLE_STRNATPMPERR -DNATPMP_EXPORTS natpmp.c
|
|
||||||
dllwrap -k --driver-name gcc --def natpmp.def --output-def natpmp.dll.def --implib natpmp.lib -o natpmp.dll getgateway.o natpmp.o wingettimeofday.o -lws2_32
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef __DECLSPEC_H__
|
|
||||||
#define __DECLSPEC_H__
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(STATICLIB)
|
|
||||||
#ifdef NATPMP_EXPORTS
|
|
||||||
#define LIBSPEC __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define LIBSPEC __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define LIBSPEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,425 +0,0 @@
|
|||||||
/* $Id: getgateway.c,v 1.13 2009/03/10 10:15:31 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
#include <sys/param.h>
|
|
||||||
#endif
|
|
||||||
/* There is no portable method to get the default route gateway.
|
|
||||||
* So below are three differents functions implementing this.
|
|
||||||
* Parsing /proc/net/route is for linux.
|
|
||||||
* sysctl is the way to access such informations on BSD systems.
|
|
||||||
* Many systems should provide route information through raw PF_ROUTE
|
|
||||||
* sockets. */
|
|
||||||
#ifdef __linux__
|
|
||||||
#define USE_PROC_NET_ROUTE
|
|
||||||
#undef USE_SOCKET_ROUTE
|
|
||||||
#undef USE_SYSCTL_NET_ROUTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BSD
|
|
||||||
#undef USE_PROC_NET_ROUTE
|
|
||||||
#define USE_SOCKET_ROUTE
|
|
||||||
#undef USE_SYSCTL_NET_ROUTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#undef USE_PROC_NET_ROUTE
|
|
||||||
#undef USE_SOCKET_ROUTE
|
|
||||||
#define USE_SYSCTL_NET_ROUTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ((defined(sun) || defined(__sun)) && defined(__SVR4))
|
|
||||||
#undef USE_PROC_NET_ROUTE
|
|
||||||
#define USE_SOCKET_ROUTE
|
|
||||||
#undef USE_SYSCTL_NET_ROUTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#undef USE_PROC_NET_ROUTE
|
|
||||||
#undef USE_SOCKET_ROUTE
|
|
||||||
#undef USE_SYSCTL_NET_ROUTE
|
|
||||||
#define USE_WIN32_CODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SYSCTL_NET_ROUTE
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SOCKET_ROUTE
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#endif
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <unknwn.h>
|
|
||||||
#include <winreg.h>
|
|
||||||
#define MAX_KEY_LENGTH 255
|
|
||||||
#define MAX_VALUE_LENGTH 16383
|
|
||||||
#endif
|
|
||||||
#include "getgateway.h"
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#define SUCCESS (0)
|
|
||||||
#define FAILED (-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_PROC_NET_ROUTE
|
|
||||||
int getdefaultgateway(in_addr_t * addr)
|
|
||||||
{
|
|
||||||
unsigned long d, g;
|
|
||||||
char buf[256];
|
|
||||||
int line = 0;
|
|
||||||
FILE * f;
|
|
||||||
char * p;
|
|
||||||
f = fopen("/proc/net/route", "r");
|
|
||||||
if(!f)
|
|
||||||
return FAILED;
|
|
||||||
while(fgets(buf, sizeof(buf), f)) {
|
|
||||||
if(line > 0) {
|
|
||||||
p = buf;
|
|
||||||
while(*p && !isspace(*p))
|
|
||||||
p++;
|
|
||||||
while(*p && isspace(*p))
|
|
||||||
p++;
|
|
||||||
if(sscanf(p, "%lx%lx", &d, &g)==2) {
|
|
||||||
if(d == 0) { /* default */
|
|
||||||
*addr = g;
|
|
||||||
fclose(f);
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
/* default route not found ! */
|
|
||||||
if(f)
|
|
||||||
fclose(f);
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
#endif /* #ifdef USE_PROC_NET_ROUTE */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_SYSCTL_NET_ROUTE
|
|
||||||
|
|
||||||
#define ROUNDUP(a) \
|
|
||||||
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
|
|
||||||
|
|
||||||
int getdefaultgateway(in_addr_t * addr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
/* net.route.0.inet.dump.0.0 ? */
|
|
||||||
int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET,
|
|
||||||
NET_RT_DUMP, 0, 0/*tableid*/};
|
|
||||||
#endif
|
|
||||||
/* net.route.0.inet.flags.gateway */
|
|
||||||
int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET,
|
|
||||||
NET_RT_FLAGS, RTF_GATEWAY};
|
|
||||||
size_t l;
|
|
||||||
char * buf, * p;
|
|
||||||
struct rt_msghdr * rt;
|
|
||||||
struct sockaddr * sa;
|
|
||||||
struct sockaddr * sa_tab[RTAX_MAX];
|
|
||||||
int i;
|
|
||||||
int r = FAILED;
|
|
||||||
if(sysctl(mib, sizeof(mib)/sizeof(int), 0, &l, 0, 0) < 0) {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
if(l>0) {
|
|
||||||
buf = malloc(l);
|
|
||||||
if(sysctl(mib, sizeof(mib)/sizeof(int), buf, &l, 0, 0) < 0) {
|
|
||||||
free(buf);
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
for(p=buf; p<buf+l; p+=rt->rtm_msglen) {
|
|
||||||
rt = (struct rt_msghdr *)p;
|
|
||||||
sa = (struct sockaddr *)(rt + 1);
|
|
||||||
for(i=0; i<RTAX_MAX; i++) {
|
|
||||||
if(rt->rtm_addrs & (1 << i)) {
|
|
||||||
sa_tab[i] = sa;
|
|
||||||
sa = (struct sockaddr *)((char *)sa + ROUNDUP(sa->sa_len));
|
|
||||||
} else {
|
|
||||||
sa_tab[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( ((rt->rtm_addrs & (RTA_DST|RTA_GATEWAY)) == (RTA_DST|RTA_GATEWAY))
|
|
||||||
&& sa_tab[RTAX_DST]->sa_family == AF_INET
|
|
||||||
&& sa_tab[RTAX_GATEWAY]->sa_family == AF_INET) {
|
|
||||||
if(((struct sockaddr_in *)sa_tab[RTAX_DST])->sin_addr.s_addr == 0) {
|
|
||||||
*addr = ((struct sockaddr_in *)(sa_tab[RTAX_GATEWAY]))->sin_addr.s_addr;
|
|
||||||
r = SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
#endif /* #ifdef USE_SYSCTL_NET_ROUTE */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_SOCKET_ROUTE
|
|
||||||
/* Thanks to Darren Kenny for this code */
|
|
||||||
#define NEXTADDR(w, u) \
|
|
||||||
if (rtm_addrs & (w)) {\
|
|
||||||
l = sizeof(struct sockaddr); memmove(cp, &(u), l); cp += l;\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define rtm m_rtmsg.m_rtm
|
|
||||||
|
|
||||||
struct {
|
|
||||||
struct rt_msghdr m_rtm;
|
|
||||||
char m_space[512];
|
|
||||||
} m_rtmsg;
|
|
||||||
|
|
||||||
int getdefaultgateway(in_addr_t *addr)
|
|
||||||
{
|
|
||||||
int s, seq, l, rtm_addrs, i;
|
|
||||||
pid_t pid;
|
|
||||||
struct sockaddr so_dst, so_mask;
|
|
||||||
char *cp = m_rtmsg.m_space;
|
|
||||||
struct sockaddr *gate = NULL, *sa;
|
|
||||||
struct rt_msghdr *msg_hdr;
|
|
||||||
|
|
||||||
pid = getpid();
|
|
||||||
seq = 0;
|
|
||||||
rtm_addrs = RTA_DST | RTA_NETMASK;
|
|
||||||
|
|
||||||
memset(&so_dst, 0, sizeof(so_dst));
|
|
||||||
memset(&so_mask, 0, sizeof(so_mask));
|
|
||||||
memset(&rtm, 0, sizeof(struct rt_msghdr));
|
|
||||||
|
|
||||||
rtm.rtm_type = RTM_GET;
|
|
||||||
rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
|
|
||||||
rtm.rtm_version = RTM_VERSION;
|
|
||||||
rtm.rtm_seq = ++seq;
|
|
||||||
rtm.rtm_addrs = rtm_addrs;
|
|
||||||
|
|
||||||
so_dst.sa_family = AF_INET;
|
|
||||||
so_mask.sa_family = AF_INET;
|
|
||||||
|
|
||||||
NEXTADDR(RTA_DST, so_dst);
|
|
||||||
NEXTADDR(RTA_NETMASK, so_mask);
|
|
||||||
|
|
||||||
rtm.rtm_msglen = l = cp - (char *)&m_rtmsg;
|
|
||||||
|
|
||||||
s = socket(PF_ROUTE, SOCK_RAW, 0);
|
|
||||||
|
|
||||||
if (write(s, (char *)&m_rtmsg, l) < 0) {
|
|
||||||
close(s);
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
|
|
||||||
} while (l > 0 && (rtm.rtm_seq != seq || rtm.rtm_pid != pid));
|
|
||||||
|
|
||||||
close(s);
|
|
||||||
|
|
||||||
msg_hdr = &rtm;
|
|
||||||
|
|
||||||
cp = ((char *)(msg_hdr + 1));
|
|
||||||
if (msg_hdr->rtm_addrs) {
|
|
||||||
for (i = 1; i; i <<= 1)
|
|
||||||
if (i & msg_hdr->rtm_addrs) {
|
|
||||||
sa = (struct sockaddr *)cp;
|
|
||||||
if (i == RTA_GATEWAY )
|
|
||||||
gate = sa;
|
|
||||||
|
|
||||||
cp += sizeof(struct sockaddr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (gate != NULL ) {
|
|
||||||
*addr = ((struct sockaddr_in *)gate)->sin_addr.s_addr;
|
|
||||||
return SUCCESS;
|
|
||||||
} else {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* #ifdef USE_SOCKET_ROUTE */
|
|
||||||
|
|
||||||
#ifdef USE_WIN32_CODE
|
|
||||||
int getdefaultgateway(in_addr_t * addr)
|
|
||||||
{
|
|
||||||
HKEY networkCardsKey;
|
|
||||||
HKEY networkCardKey;
|
|
||||||
HKEY interfacesKey;
|
|
||||||
HKEY interfaceKey;
|
|
||||||
DWORD i = 0;
|
|
||||||
DWORD numSubKeys = 0;
|
|
||||||
TCHAR keyName[MAX_KEY_LENGTH];
|
|
||||||
DWORD keyNameLength = MAX_KEY_LENGTH;
|
|
||||||
BYTE keyValue[MAX_VALUE_LENGTH];
|
|
||||||
DWORD keyValueLength = MAX_VALUE_LENGTH;
|
|
||||||
DWORD keyValueType = REG_SZ;
|
|
||||||
BYTE gatewayValue[MAX_VALUE_LENGTH];
|
|
||||||
DWORD gatewayValueLength = MAX_VALUE_LENGTH;
|
|
||||||
DWORD gatewayValueType = REG_MULTI_SZ;
|
|
||||||
int done = 0;
|
|
||||||
|
|
||||||
char networkCardsPath[] = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards";
|
|
||||||
char interfacesPath[] = "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces";
|
|
||||||
|
|
||||||
// The windows registry lists its primary network devices in the following location:
|
|
||||||
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
|
|
||||||
//
|
|
||||||
// Each network device has its own subfolder, named with an index, with various properties:
|
|
||||||
// -NetworkCards
|
|
||||||
// -5
|
|
||||||
// -Description = Broadcom 802.11n Network Adapter
|
|
||||||
// -ServiceName = {E35A72F8-5065-4097-8DFE-C7790774EE4D}
|
|
||||||
// -8
|
|
||||||
// -Description = Marvell Yukon 88E8058 PCI-E Gigabit Ethernet Controller
|
|
||||||
// -ServiceName = {86226414-5545-4335-A9D1-5BD7120119AD}
|
|
||||||
//
|
|
||||||
// The above service name is the name of a subfolder within:
|
|
||||||
// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces
|
|
||||||
//
|
|
||||||
// There may be more subfolders in this interfaces path than listed in the network cards path above:
|
|
||||||
// -Interfaces
|
|
||||||
// -{3a539854-6a70-11db-887c-806e6f6e6963}
|
|
||||||
// -DhcpIPAddress = 0.0.0.0
|
|
||||||
// -[more]
|
|
||||||
// -{E35A72F8-5065-4097-8DFE-C7790774EE4D}
|
|
||||||
// -DhcpIPAddress = 10.0.1.4
|
|
||||||
// -DhcpDefaultGateway = 10.0.1.1
|
|
||||||
// -[more]
|
|
||||||
// -{86226414-5545-4335-A9D1-5BD7120119AD}
|
|
||||||
// -DhcpIpAddress = 10.0.1.5
|
|
||||||
// -DhcpDefaultGateay = 10.0.1.1
|
|
||||||
// -[more]
|
|
||||||
//
|
|
||||||
// In order to extract this information, we enumerate each network card, and extract the ServiceName value.
|
|
||||||
// This is then used to open the interface subfolder, and attempt to extract a DhcpDefaultGateway value.
|
|
||||||
// Once one is found, we're done.
|
|
||||||
//
|
|
||||||
// It may be possible to simply enumerate the interface folders until we find one with a DhcpDefaultGateway value.
|
|
||||||
// However, the technique used is the technique most cited on the web, and we assume it to be more correct.
|
|
||||||
|
|
||||||
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predifined key
|
|
||||||
networkCardsPath, // Name of registry subkey to open
|
|
||||||
0, // Reserved - must be zero
|
|
||||||
KEY_READ, // Mask - desired access rights
|
|
||||||
&networkCardsKey)) // Pointer to output key
|
|
||||||
{
|
|
||||||
// Unable to open network cards keys
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Open registry key or predefined key
|
|
||||||
interfacesPath, // Name of registry subkey to open
|
|
||||||
0, // Reserved - must be zero
|
|
||||||
KEY_READ, // Mask - desired access rights
|
|
||||||
&interfacesKey)) // Pointer to output key
|
|
||||||
{
|
|
||||||
// Unable to open interfaces key
|
|
||||||
RegCloseKey(networkCardsKey);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out how many subfolders are within the NetworkCards folder
|
|
||||||
RegQueryInfoKey(networkCardsKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
//printf( "Number of subkeys: %u\n", (unsigned int)numSubKeys);
|
|
||||||
|
|
||||||
// Enumrate through each subfolder within the NetworkCards folder
|
|
||||||
for(i = 0; i < numSubKeys && !done; i++)
|
|
||||||
{
|
|
||||||
keyNameLength = MAX_KEY_LENGTH;
|
|
||||||
if(ERROR_SUCCESS == RegEnumKeyEx(networkCardsKey, // Open registry key
|
|
||||||
i, // Index of subkey to retrieve
|
|
||||||
keyName, // Buffer that receives the name of the subkey
|
|
||||||
&keyNameLength, // Variable that receives the size of the above buffer
|
|
||||||
NULL, // Reserved - must be NULL
|
|
||||||
NULL, // Buffer that receives the class string
|
|
||||||
NULL, // Variable that receives the size of the above buffer
|
|
||||||
NULL)) // Variable that receives the last write time of subkey
|
|
||||||
{
|
|
||||||
if(RegOpenKeyEx(networkCardsKey, keyName, 0, KEY_READ, &networkCardKey) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
keyValueLength = MAX_VALUE_LENGTH;
|
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(networkCardKey, // Open registry key
|
|
||||||
"ServiceName", // Name of key to query
|
|
||||||
NULL, // Reserved - must be NULL
|
|
||||||
&keyValueType, // Receives value type
|
|
||||||
keyValue, // Receives value
|
|
||||||
&keyValueLength)) // Receives value length in bytes
|
|
||||||
{
|
|
||||||
//printf("keyValue: %s\n", keyValue);
|
|
||||||
|
|
||||||
if(RegOpenKeyEx(interfacesKey, (char *)keyValue, 0, KEY_READ, &interfaceKey) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
gatewayValueLength = MAX_VALUE_LENGTH;
|
|
||||||
if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
|
|
||||||
"DhcpDefaultGateway", // Name of key to query
|
|
||||||
NULL, // Reserved - must be NULL
|
|
||||||
&gatewayValueType, // Receives value type
|
|
||||||
gatewayValue, // Receives value
|
|
||||||
&gatewayValueLength)) // Receives value length in bytes
|
|
||||||
{
|
|
||||||
// Check to make sure it's a string
|
|
||||||
if(gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ)
|
|
||||||
{
|
|
||||||
//printf("gatewayValue: %s\n", gatewayValue);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(ERROR_SUCCESS == RegQueryValueEx(interfaceKey, // Open registry key
|
|
||||||
"DefaultGateway", // Name of key to query
|
|
||||||
NULL, // Reserved - must be NULL
|
|
||||||
&gatewayValueType, // Receives value type
|
|
||||||
gatewayValue, // Receives value
|
|
||||||
&gatewayValueLength)) // Receives value length in bytes
|
|
||||||
{
|
|
||||||
// Check to make sure it's a string
|
|
||||||
if(gatewayValueType == REG_MULTI_SZ || gatewayValueType == REG_SZ)
|
|
||||||
{
|
|
||||||
//printf("gatewayValue: %s\n", gatewayValue);
|
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RegCloseKey(interfaceKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RegCloseKey(networkCardKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(interfacesKey);
|
|
||||||
RegCloseKey(networkCardsKey);
|
|
||||||
|
|
||||||
if(done)
|
|
||||||
{
|
|
||||||
*addr = inet_addr((char *)gatewayValue);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif /* #ifdef USE_WIN32_CODE */
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/* $Id: getgateway.h,v 1.3 2008/07/02 22:33:06 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#ifndef __GETGATEWAY_H__
|
|
||||||
#define __GETGATEWAY_H__
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
typedef unsigned __int32 uint32_t;
|
|
||||||
#else
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
#define in_addr_t uint32_t
|
|
||||||
#endif
|
|
||||||
#include "declspec.h"
|
|
||||||
|
|
||||||
/* getdefaultgateway() :
|
|
||||||
* return value :
|
|
||||||
* 0 : success
|
|
||||||
* -1 : failure */
|
|
||||||
LIBSPEC int getdefaultgateway(in_addr_t * addr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,371 +0,0 @@
|
|||||||
/* $Id: natpmp.c,v 1.8 2008/07/02 22:33:06 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
* http://miniupnp.free.fr/libnatpmp.html
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#ifdef __linux__
|
|
||||||
#ifndef _DEFAULT_SOURCE
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#endif
|
|
||||||
#define _BSD_SOURCE 1
|
|
||||||
#endif
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <Ws2tcpip.h>
|
|
||||||
#include <io.h>
|
|
||||||
#ifndef EWOULDBLOCK
|
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
|
||||||
#endif
|
|
||||||
#ifndef ECONNREFUSED
|
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int gettimeofday(struct timeval* p, void* tz /* IGNORED */) {
|
|
||||||
union {
|
|
||||||
long long ns100; /*time since 1 Jan 1601 in 100ns units */
|
|
||||||
FILETIME ft;
|
|
||||||
} _now;
|
|
||||||
|
|
||||||
GetSystemTimeAsFileTime( &(_now.ft) );
|
|
||||||
p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
|
|
||||||
p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#define closesocket close
|
|
||||||
#endif
|
|
||||||
#include "natpmp.h"
|
|
||||||
#include "getgateway.h"
|
|
||||||
|
|
||||||
int initnatpmp(natpmp_t * p)
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
u_long ioctlArg = 1;
|
|
||||||
#else
|
|
||||||
int flags;
|
|
||||||
#endif
|
|
||||||
struct sockaddr_in addr;
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
memset(p, 0, sizeof(natpmp_t));
|
|
||||||
p->s = socket(PF_INET, SOCK_DGRAM, 0);
|
|
||||||
if(p->s < 0)
|
|
||||||
return NATPMP_ERR_SOCKETERROR;
|
|
||||||
#ifdef WIN32
|
|
||||||
if(ioctlsocket(p->s, FIONBIO, &ioctlArg) == SOCKET_ERROR)
|
|
||||||
return NATPMP_ERR_FCNTLERROR;
|
|
||||||
#else
|
|
||||||
if((flags = fcntl(p->s, F_GETFL, 0)) < 0)
|
|
||||||
return NATPMP_ERR_FCNTLERROR;
|
|
||||||
if(fcntl(p->s, F_SETFL, flags | O_NONBLOCK) < 0)
|
|
||||||
return NATPMP_ERR_FCNTLERROR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(getdefaultgateway(&(p->gateway)) < 0)
|
|
||||||
return NATPMP_ERR_CANNOTGETGATEWAY;
|
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = htons(NATPMP_PORT);
|
|
||||||
addr.sin_addr.s_addr = p->gateway;
|
|
||||||
if(connect(p->s, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
|
||||||
return NATPMP_ERR_CONNECTERR;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int closenatpmp(natpmp_t * p)
|
|
||||||
{
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
if(closesocket(p->s) < 0)
|
|
||||||
return NATPMP_ERR_CLOSEERR;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendpendingrequest(natpmp_t * p)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
/* struct sockaddr_in addr;*/
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
/* memset(&addr, 0, sizeof(addr));
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = htons(NATPMP_PORT);
|
|
||||||
addr.sin_addr.s_addr = p->gateway;
|
|
||||||
r = (int)sendto(p->s, p->pending_request, p->pending_request_len, 0,
|
|
||||||
(struct sockaddr *)&addr, sizeof(addr));*/
|
|
||||||
r = (int)send(p->s, p->pending_request, p->pending_request_len, 0);
|
|
||||||
return (r<0) ? NATPMP_ERR_SENDERR : r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendnatpmprequest(natpmp_t * p)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
/* TODO : check if no request is allready pending */
|
|
||||||
p->has_pending_request = 1;
|
|
||||||
p->try_number = 1;
|
|
||||||
n = sendpendingrequest(p);
|
|
||||||
gettimeofday(&p->retry_time, NULL); // check errors !
|
|
||||||
p->retry_time.tv_usec += 250000; /* add 250ms */
|
|
||||||
if(p->retry_time.tv_usec >= 1000000) {
|
|
||||||
p->retry_time.tv_usec -= 1000000;
|
|
||||||
p->retry_time.tv_sec++;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout)
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
if(!p || !timeout)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
if(!p->has_pending_request)
|
|
||||||
return NATPMP_ERR_NOPENDINGREQ;
|
|
||||||
if(gettimeofday(&now, NULL) < 0)
|
|
||||||
return NATPMP_ERR_GETTIMEOFDAYERR;
|
|
||||||
timeout->tv_sec = p->retry_time.tv_sec - now.tv_sec;
|
|
||||||
timeout->tv_usec = p->retry_time.tv_usec - now.tv_usec;
|
|
||||||
if(timeout->tv_usec < 0) {
|
|
||||||
timeout->tv_usec += 1000000;
|
|
||||||
timeout->tv_sec--;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendpublicaddressrequest(natpmp_t * p)
|
|
||||||
{
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
//static const unsigned char request[] = { 0, 0 };
|
|
||||||
p->pending_request[0] = 0;
|
|
||||||
p->pending_request[1] = 0;
|
|
||||||
p->pending_request_len = 2;
|
|
||||||
// TODO: return 0 instead of sizeof(request) ??
|
|
||||||
return sendnatpmprequest(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sendnewportmappingrequest(natpmp_t * p, int protocol,
|
|
||||||
uint16_t privateport, uint16_t publicport,
|
|
||||||
uint32_t lifetime)
|
|
||||||
{
|
|
||||||
uint16_t *n;
|
|
||||||
uint32_t *m;
|
|
||||||
|
|
||||||
if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP))
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
p->pending_request[0] = 0;
|
|
||||||
p->pending_request[1] = (char)protocol;
|
|
||||||
p->pending_request[2] = 0;
|
|
||||||
p->pending_request[3] = 0;
|
|
||||||
n = (uint16_t *)(p->pending_request + 4); *n = htons(privateport);
|
|
||||||
n = (uint16_t *)(p->pending_request + 6); *n = htons(publicport);
|
|
||||||
m = (uint32_t *)(p->pending_request + 8); *m = htonl(lifetime);
|
|
||||||
|
|
||||||
//*((uint16_t *)(p->pending_request + 4)) = htons(privateport);
|
|
||||||
//*((uint16_t *)(p->pending_request + 6)) = htons(publicport);
|
|
||||||
//*((uint32_t *)(p->pending_request + 8)) = htonl(lifetime);
|
|
||||||
p->pending_request_len = 12;
|
|
||||||
return sendnatpmprequest(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
int readnatpmpresponse(natpmp_t * p, natpmpresp_t * response)
|
|
||||||
{
|
|
||||||
unsigned char buf[16];
|
|
||||||
struct sockaddr_in addr = {0};
|
|
||||||
socklen_t addrlen = sizeof(addr);
|
|
||||||
int n;
|
|
||||||
if(!p)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
n = recvfrom(p->s, (char *)buf, sizeof(buf), 0,
|
|
||||||
(struct sockaddr *)&addr, &addrlen);
|
|
||||||
if(n<0)
|
|
||||||
switch(errno) {
|
|
||||||
/*case EAGAIN:*/
|
|
||||||
case EWOULDBLOCK:
|
|
||||||
n = NATPMP_TRYAGAIN;
|
|
||||||
break;
|
|
||||||
case ECONNREFUSED:
|
|
||||||
n = NATPMP_ERR_NOGATEWAYSUPPORT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
n = NATPMP_ERR_RECVFROM;
|
|
||||||
}
|
|
||||||
/* check that addr is correct (= gateway) */
|
|
||||||
else if(addr.sin_addr.s_addr != p->gateway)
|
|
||||||
n = NATPMP_ERR_WRONGPACKETSOURCE;
|
|
||||||
else {
|
|
||||||
response->resultcode = ntohs(*((uint16_t *)(buf + 2)));
|
|
||||||
response->epoch = ntohl(*((uint32_t *)(buf + 4)));
|
|
||||||
if(buf[0] != 0)
|
|
||||||
n = NATPMP_ERR_UNSUPPORTEDVERSION;
|
|
||||||
else if(buf[1] < 128 || buf[1] > 130)
|
|
||||||
n = NATPMP_ERR_UNSUPPORTEDOPCODE;
|
|
||||||
else if(response->resultcode != 0) {
|
|
||||||
switch(response->resultcode) {
|
|
||||||
case 1:
|
|
||||||
n = NATPMP_ERR_UNSUPPORTEDVERSION;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
n = NATPMP_ERR_NOTAUTHORIZED;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
n = NATPMP_ERR_NETWORKFAILURE;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
n = NATPMP_ERR_OUTOFRESOURCES;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
n = NATPMP_ERR_UNSUPPORTEDOPCODE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
n = NATPMP_ERR_UNDEFINEDERROR;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
response->type = buf[1] & 0x7f;
|
|
||||||
if(buf[1] == 128)
|
|
||||||
//response->publicaddress.addr = *((uint32_t *)(buf + 8));
|
|
||||||
response->pnu.publicaddress.addr.s_addr = *((uint32_t *)(buf + 8));
|
|
||||||
else {
|
|
||||||
response->pnu.newportmapping.privateport = ntohs(*((uint16_t *)(buf + 8)));
|
|
||||||
response->pnu.newportmapping.mappedpublicport = ntohs(*((uint16_t *)(buf + 10)));
|
|
||||||
response->pnu.newportmapping.lifetime = ntohl(*((uint32_t *)(buf + 12)));
|
|
||||||
}
|
|
||||||
n = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
if(!p || !response)
|
|
||||||
return NATPMP_ERR_INVALIDARGS;
|
|
||||||
if(!p->has_pending_request)
|
|
||||||
return NATPMP_ERR_NOPENDINGREQ;
|
|
||||||
n = readnatpmpresponse(p, response);
|
|
||||||
if(n<0) {
|
|
||||||
if(n==NATPMP_TRYAGAIN) {
|
|
||||||
struct timeval now;
|
|
||||||
gettimeofday(&now, NULL); // check errors !
|
|
||||||
if(timercmp(&now, &p->retry_time, >=)) {
|
|
||||||
int delay, r;
|
|
||||||
if(p->try_number >= 9) {
|
|
||||||
return NATPMP_ERR_NOGATEWAYSUPPORT;
|
|
||||||
}
|
|
||||||
/*printf("retry! %d\n", p->try_number);*/
|
|
||||||
delay = 250 * (1<<p->try_number); // ms
|
|
||||||
/*for(i=0; i<p->try_number; i++)
|
|
||||||
delay += delay;*/
|
|
||||||
p->retry_time.tv_sec += (delay / 1000);
|
|
||||||
p->retry_time.tv_usec += (delay % 1000) * 1000;
|
|
||||||
if(p->retry_time.tv_usec >= 1000000) {
|
|
||||||
p->retry_time.tv_usec -= 1000000;
|
|
||||||
p->retry_time.tv_sec++;
|
|
||||||
}
|
|
||||||
p->try_number++;
|
|
||||||
r = sendpendingrequest(p);
|
|
||||||
if(r<0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p->has_pending_request = 0;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_STRNATPMPERR
|
|
||||||
const char * strnatpmperr(int r)
|
|
||||||
{
|
|
||||||
const char * s;
|
|
||||||
switch(r) {
|
|
||||||
case NATPMP_ERR_INVALIDARGS:
|
|
||||||
s = "invalid arguments";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_SOCKETERROR:
|
|
||||||
s = "socket() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_CANNOTGETGATEWAY:
|
|
||||||
s = "cannot get default gateway ip address";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_CLOSEERR:
|
|
||||||
#ifdef WIN32
|
|
||||||
s = "closesocket() failed";
|
|
||||||
#else
|
|
||||||
s = "close() failed";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_RECVFROM:
|
|
||||||
s = "recvfrom() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_NOPENDINGREQ:
|
|
||||||
s = "no pending request";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_NOGATEWAYSUPPORT:
|
|
||||||
s = "the gateway does not support nat-pmp";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_CONNECTERR:
|
|
||||||
s = "connect() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_WRONGPACKETSOURCE:
|
|
||||||
s = "packet not received from the default gateway";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_SENDERR:
|
|
||||||
s = "send() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_FCNTLERROR:
|
|
||||||
s = "fcntl() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_GETTIMEOFDAYERR:
|
|
||||||
s = "gettimeofday() failed";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_UNSUPPORTEDVERSION:
|
|
||||||
s = "unsupported nat-pmp version error from server";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_UNSUPPORTEDOPCODE:
|
|
||||||
s = "unsupported nat-pmp opcode error from server";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_UNDEFINEDERROR:
|
|
||||||
s = "undefined nat-pmp server error";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_NOTAUTHORIZED:
|
|
||||||
s = "not authorized";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_NETWORKFAILURE:
|
|
||||||
s = "network failure";
|
|
||||||
break;
|
|
||||||
case NATPMP_ERR_OUTOFRESOURCES:
|
|
||||||
s = "nat-pmp server out of resources";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
s = "Unknown libnatpmp error";
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
LIBRARY
|
|
||||||
; libnatpmp library
|
|
||||||
|
|
||||||
EXPORTS
|
|
||||||
initnatpmp
|
|
||||||
closenatpmp
|
|
||||||
sendpublicaddressrequest
|
|
||||||
sendnewportmappingrequest
|
|
||||||
getnatpmprequesttimeout
|
|
||||||
readnatpmpresponseorretry
|
|
||||||
strnatpmperr
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
/* $Id: natpmp.h,v 1.11 2009/02/27 22:38:05 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
* http://miniupnp.free.fr/libnatpmp.html
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#ifndef __NATPMP_H__
|
|
||||||
#define __NATPMP_H__
|
|
||||||
|
|
||||||
/* NAT-PMP Port as defined by the NAT-PMP draft */
|
|
||||||
#define NATPMP_PORT (5351)
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <winsock2.h>
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
typedef unsigned __int32 uint32_t;
|
|
||||||
typedef unsigned __int16 uint16_t;
|
|
||||||
#else
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
#define in_addr_t uint32_t
|
|
||||||
#include "declspec.h"
|
|
||||||
#else
|
|
||||||
#define LIBSPEC
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int s; /* socket */
|
|
||||||
in_addr_t gateway; /* default gateway (IPv4) */
|
|
||||||
int has_pending_request;
|
|
||||||
char pending_request[12];
|
|
||||||
int pending_request_len;
|
|
||||||
int try_number;
|
|
||||||
struct timeval retry_time;
|
|
||||||
} natpmp_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t type; /* NATPMP_RESPTYPE_* */
|
|
||||||
uint16_t resultcode; /* NAT-PMP response code */
|
|
||||||
uint32_t epoch; /* Seconds since start of epoch */
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
//in_addr_t addr;
|
|
||||||
struct in_addr addr;
|
|
||||||
} publicaddress;
|
|
||||||
struct {
|
|
||||||
uint16_t privateport;
|
|
||||||
uint16_t mappedpublicport;
|
|
||||||
uint32_t lifetime;
|
|
||||||
} newportmapping;
|
|
||||||
} pnu;
|
|
||||||
} natpmpresp_t;
|
|
||||||
|
|
||||||
/* possible values for type field of natpmpresp_t */
|
|
||||||
#define NATPMP_RESPTYPE_PUBLICADDRESS (0)
|
|
||||||
#define NATPMP_RESPTYPE_UDPPORTMAPPING (1)
|
|
||||||
#define NATPMP_RESPTYPE_TCPPORTMAPPING (2)
|
|
||||||
|
|
||||||
/* Values to pass to sendnewportmappingrequest() */
|
|
||||||
#define NATPMP_PROTOCOL_UDP (1)
|
|
||||||
#define NATPMP_PROTOCOL_TCP (2)
|
|
||||||
|
|
||||||
/* return values */
|
|
||||||
/* NATPMP_ERR_INVALIDARGS : invalid arguments passed to the function */
|
|
||||||
#define NATPMP_ERR_INVALIDARGS (-1)
|
|
||||||
/* NATPMP_ERR_SOCKETERROR : socket() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_SOCKETERROR (-2)
|
|
||||||
/* NATPMP_ERR_CANNOTGETGATEWAY : can't get default gateway IP */
|
|
||||||
#define NATPMP_ERR_CANNOTGETGATEWAY (-3)
|
|
||||||
/* NATPMP_ERR_CLOSEERR : close() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_CLOSEERR (-4)
|
|
||||||
/* NATPMP_ERR_RECVFROM : recvfrom() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_RECVFROM (-5)
|
|
||||||
/* NATPMP_ERR_NOPENDINGREQ : readnatpmpresponseorretry() called while
|
|
||||||
* no NAT-PMP request was pending */
|
|
||||||
#define NATPMP_ERR_NOPENDINGREQ (-6)
|
|
||||||
/* NATPMP_ERR_NOGATEWAYSUPPORT : the gateway does not support NAT-PMP */
|
|
||||||
#define NATPMP_ERR_NOGATEWAYSUPPORT (-7)
|
|
||||||
/* NATPMP_ERR_CONNECTERR : connect() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_CONNECTERR (-8)
|
|
||||||
/* NATPMP_ERR_WRONGPACKETSOURCE : packet not received from the network gateway */
|
|
||||||
#define NATPMP_ERR_WRONGPACKETSOURCE (-9)
|
|
||||||
/* NATPMP_ERR_SENDERR : send() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_SENDERR (-10)
|
|
||||||
/* NATPMP_ERR_FCNTLERROR : fcntl() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_FCNTLERROR (-11)
|
|
||||||
/* NATPMP_ERR_GETTIMEOFDAYERR : gettimeofday() failed. check errno for details */
|
|
||||||
#define NATPMP_ERR_GETTIMEOFDAYERR (-12)
|
|
||||||
|
|
||||||
/* */
|
|
||||||
#define NATPMP_ERR_UNSUPPORTEDVERSION (-14)
|
|
||||||
#define NATPMP_ERR_UNSUPPORTEDOPCODE (-15)
|
|
||||||
|
|
||||||
/* Errors from the server : */
|
|
||||||
#define NATPMP_ERR_UNDEFINEDERROR (-49)
|
|
||||||
#define NATPMP_ERR_NOTAUTHORIZED (-51)
|
|
||||||
#define NATPMP_ERR_NETWORKFAILURE (-52)
|
|
||||||
#define NATPMP_ERR_OUTOFRESOURCES (-53)
|
|
||||||
|
|
||||||
/* NATPMP_TRYAGAIN : no data available for the moment. try again later */
|
|
||||||
#define NATPMP_TRYAGAIN (-100)
|
|
||||||
|
|
||||||
/* initnatpmp()
|
|
||||||
* initialize a natpmp_t object
|
|
||||||
* Return values :
|
|
||||||
* 0 = OK
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_SOCKETERROR
|
|
||||||
* NATPMP_ERR_FCNTLERROR
|
|
||||||
* NATPMP_ERR_CANNOTGETGATEWAY
|
|
||||||
* NATPMP_ERR_CONNECTERR */
|
|
||||||
LIBSPEC int initnatpmp(natpmp_t * p);
|
|
||||||
|
|
||||||
/* closenatpmp()
|
|
||||||
* close resources associated with a natpmp_t object
|
|
||||||
* Return values :
|
|
||||||
* 0 = OK
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_CLOSEERR */
|
|
||||||
LIBSPEC int closenatpmp(natpmp_t * p);
|
|
||||||
|
|
||||||
/* sendpublicaddressrequest()
|
|
||||||
* send a public address NAT-PMP request to the network gateway
|
|
||||||
* Return values :
|
|
||||||
* 2 = OK (size of the request)
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_SENDERR */
|
|
||||||
LIBSPEC int sendpublicaddressrequest(natpmp_t * p);
|
|
||||||
|
|
||||||
/* sendnewportmappingrequest()
|
|
||||||
* send a new port mapping NAT-PMP request to the network gateway
|
|
||||||
* Arguments :
|
|
||||||
* protocol is either NATPMP_PROTOCOL_TCP or NATPMP_PROTOCOL_UDP,
|
|
||||||
* lifetime is in seconds.
|
|
||||||
* To remove a port mapping, set lifetime to zero.
|
|
||||||
* To remove all port mappings to the host, set lifetime and both ports
|
|
||||||
* to zero.
|
|
||||||
* Return values :
|
|
||||||
* 12 = OK (size of the request)
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_SENDERR */
|
|
||||||
LIBSPEC int sendnewportmappingrequest(natpmp_t * p, int protocol,
|
|
||||||
uint16_t privateport, uint16_t publicport,
|
|
||||||
uint32_t lifetime);
|
|
||||||
|
|
||||||
/* getnatpmprequesttimeout()
|
|
||||||
* fills the timeval structure with the timeout duration of the
|
|
||||||
* currently pending NAT-PMP request.
|
|
||||||
* Return values :
|
|
||||||
* 0 = OK
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_GETTIMEOFDAYERR
|
|
||||||
* NATPMP_ERR_NOPENDINGREQ */
|
|
||||||
LIBSPEC int getnatpmprequesttimeout(natpmp_t * p, struct timeval * timeout);
|
|
||||||
|
|
||||||
/* readnatpmpresponseorretry()
|
|
||||||
* fills the natpmpresp_t structure if possible
|
|
||||||
* Return values :
|
|
||||||
* 0 = OK
|
|
||||||
* NATPMP_TRYAGAIN
|
|
||||||
* NATPMP_ERR_INVALIDARGS
|
|
||||||
* NATPMP_ERR_NOPENDINGREQ
|
|
||||||
* NATPMP_ERR_NOGATEWAYSUPPORT
|
|
||||||
* NATPMP_ERR_RECVFROM
|
|
||||||
* NATPMP_ERR_WRONGPACKETSOURCE
|
|
||||||
* NATPMP_ERR_UNSUPPORTEDVERSION
|
|
||||||
* NATPMP_ERR_UNSUPPORTEDOPCODE
|
|
||||||
* NATPMP_ERR_NOTAUTHORIZED
|
|
||||||
* NATPMP_ERR_NETWORKFAILURE
|
|
||||||
* NATPMP_ERR_OUTOFRESOURCES
|
|
||||||
* NATPMP_ERR_UNSUPPORTEDOPCODE
|
|
||||||
* NATPMP_ERR_UNDEFINEDERROR */
|
|
||||||
LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * response);
|
|
||||||
|
|
||||||
#ifdef ENABLE_STRNATPMPERR
|
|
||||||
LIBSPEC const char * strnatpmperr(int t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
/* $Id: natpmpc.c,v 1.6 2008/07/02 22:33:06 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007-2008, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
* http://miniupnp.free.fr/libnatpmp.html
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <winsock2.h>
|
|
||||||
#else
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#include "natpmp.h"
|
|
||||||
|
|
||||||
void usage(FILE * out, const char * argv0)
|
|
||||||
{
|
|
||||||
fprintf(out, "Usage :\n");
|
|
||||||
fprintf(out, " %s\n", argv0);
|
|
||||||
fprintf(out, "\tdisplay the public IP address.\n");
|
|
||||||
fprintf(out, " %s -h\n", argv0);
|
|
||||||
fprintf(out, "\tdisplay this help screen.\n");
|
|
||||||
fprintf(out, " %s -a <public port> <private port> <protocol> [lifetime]\n", argv0);
|
|
||||||
fprintf(out, "\tadd a port mapping.\n");
|
|
||||||
fprintf(out, "\n In order to remove a mapping, set it with a lifetime of 0 seconds.\n");
|
|
||||||
fprintf(out, " To remove all mappings for your machine, use 0 as private port and lifetime.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sample code for using libnatpmp */
|
|
||||||
int main(int argc, char * * argv)
|
|
||||||
{
|
|
||||||
natpmp_t natpmp;
|
|
||||||
natpmpresp_t response;
|
|
||||||
int r;
|
|
||||||
int sav_errno;
|
|
||||||
struct timeval timeout;
|
|
||||||
fd_set fds;
|
|
||||||
int i;
|
|
||||||
int protocol = 0;
|
|
||||||
uint16_t privateport = 0;
|
|
||||||
uint16_t publicport = 0;
|
|
||||||
uint32_t lifetime = 3600;
|
|
||||||
int command = 0;
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
WSADATA wsaData;
|
|
||||||
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
|
|
||||||
if(nResult != NO_ERROR)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "WSAStartup() failed.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* argument parsing */
|
|
||||||
for(i=1; i<argc; i++) {
|
|
||||||
if(argv[i][0] == '-') {
|
|
||||||
switch(argv[i][1]) {
|
|
||||||
case 'h':
|
|
||||||
usage(stdout, argv[0]);
|
|
||||||
return 0;
|
|
||||||
case 'a':
|
|
||||||
command = 'a';
|
|
||||||
if(argc < i + 3) {
|
|
||||||
fprintf(stderr, "Not enough arguments for option -a\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
if(1 != sscanf(argv[i], "%hu", &publicport)) {
|
|
||||||
fprintf(stderr, "%s is not a correct 16bits unsigned integer\n", argv[i]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
if(1 != sscanf(argv[i], "%hu", &privateport)) {
|
|
||||||
fprintf(stderr, "%s is not a correct 16bits unsigned integer\n", argv[i]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
if(0 == strcasecmp(argv[i], "tcp"))
|
|
||||||
protocol = NATPMP_PROTOCOL_TCP;
|
|
||||||
else if(0 == strcasecmp(argv[i], "udp"))
|
|
||||||
protocol = NATPMP_PROTOCOL_UDP;
|
|
||||||
else {
|
|
||||||
fprintf(stderr, "%s is not a valid protocol\n", argv[i]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(argc >= i) {
|
|
||||||
i++;
|
|
||||||
if(1 != sscanf(argv[i], "%u", &lifetime)) {
|
|
||||||
fprintf(stderr, "%s is not a correct 32bits unsigned integer\n", argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "Unknown option %s\n", argv[i]);
|
|
||||||
usage(stderr, argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Unknown option %s\n", argv[i]);
|
|
||||||
usage(stderr, argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initnatpmp() */
|
|
||||||
r = initnatpmp(&natpmp);
|
|
||||||
printf("initnatpmp() returned %d (%s)\n", r, r?"FAILED":"SUCCESS");
|
|
||||||
if(r<0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* sendpublicaddressrequest() */
|
|
||||||
r = sendpublicaddressrequest(&natpmp);
|
|
||||||
printf("sendpublicaddressrequest returned %d (%s)\n",
|
|
||||||
r, r==2?"SUCCESS":"FAILED");
|
|
||||||
if(r<0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
do {
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(natpmp.s, &fds);
|
|
||||||
getnatpmprequesttimeout(&natpmp, &timeout);
|
|
||||||
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
|
|
||||||
r = readnatpmpresponseorretry(&natpmp, &response);
|
|
||||||
sav_errno = errno;
|
|
||||||
printf("readnatpmpresponseorretry returned %d (%s)\n",
|
|
||||||
r, r==0?"OK":(r==NATPMP_TRYAGAIN?"TRY AGAIN":"FAILED"));
|
|
||||||
if(r<0 && r!=NATPMP_TRYAGAIN) {
|
|
||||||
#ifdef ENABLE_STRNATPMPERR
|
|
||||||
fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n",
|
|
||||||
strnatpmperr(r));
|
|
||||||
#endif
|
|
||||||
fprintf(stderr, " errno=%d '%s'\n",
|
|
||||||
sav_errno, strerror(sav_errno));
|
|
||||||
}
|
|
||||||
} while(r==NATPMP_TRYAGAIN);
|
|
||||||
if(r<0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* TODO : check that response.type == 0 */
|
|
||||||
printf("Public IP address : %s\n", inet_ntoa(response.pnu.publicaddress.addr));
|
|
||||||
printf("epoch = %u\n", response.epoch);
|
|
||||||
|
|
||||||
if(command == 'a') {
|
|
||||||
/* sendnewportmappingrequest() */
|
|
||||||
r = sendnewportmappingrequest(&natpmp, protocol,
|
|
||||||
privateport, publicport,
|
|
||||||
lifetime);
|
|
||||||
printf("sendnewportmappingrequest returned %d (%s)\n",
|
|
||||||
r, r==12?"SUCCESS":"FAILED");
|
|
||||||
if(r < 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
do {
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(natpmp.s, &fds);
|
|
||||||
getnatpmprequesttimeout(&natpmp, &timeout);
|
|
||||||
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
|
|
||||||
r = readnatpmpresponseorretry(&natpmp, &response);
|
|
||||||
printf("readnatpmpresponseorretry returned %d (%s)\n",
|
|
||||||
r, r==0?"OK":(r==NATPMP_TRYAGAIN?"TRY AGAIN":"FAILED"));
|
|
||||||
} while(r==NATPMP_TRYAGAIN);
|
|
||||||
if(r<0) {
|
|
||||||
#ifdef ENABLE_STRNATPMPERR
|
|
||||||
fprintf(stderr, "readnatpmpresponseorretry() failed : %s\n",
|
|
||||||
strnatpmperr(r));
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Mapped public port %hu protocol %s to local port %hu "
|
|
||||||
"liftime %u\n",
|
|
||||||
response.pnu.newportmapping.mappedpublicport,
|
|
||||||
response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? "UDP" :
|
|
||||||
(response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" :
|
|
||||||
"UNKNOWN"),
|
|
||||||
response.pnu.newportmapping.privateport,
|
|
||||||
response.pnu.newportmapping.lifetime);
|
|
||||||
printf("epoch = %u\n", response.epoch);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = closenatpmp(&natpmp);
|
|
||||||
printf("closenatpmp() returned %d (%s)\n", r, r==0?"SUCCESS":"FAILED");
|
|
||||||
if(r<0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/* $Id: testgetgateway.c,v 1.4 2008/07/02 22:33:06 nanard Exp $ */
|
|
||||||
/* libnatpmp
|
|
||||||
* Copyright (c) 2007, Thomas BERNARD <miniupnp@free.fr>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <winsock2.h>
|
|
||||||
#else
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
#include "getgateway.h"
|
|
||||||
|
|
||||||
int main(int argc, char * * argv)
|
|
||||||
{
|
|
||||||
struct in_addr gatewayaddr;
|
|
||||||
int r;
|
|
||||||
#ifdef WIN32
|
|
||||||
uint32_t temp = 0;
|
|
||||||
r = getdefaultgateway(&temp);
|
|
||||||
gatewayaddr.S_un.S_addr = temp;
|
|
||||||
#else
|
|
||||||
r = getdefaultgateway(&(gatewayaddr.s_addr));
|
|
||||||
#endif
|
|
||||||
if(r>=0)
|
|
||||||
printf("default gateway : %s\n", inet_ntoa(gatewayaddr));
|
|
||||||
else
|
|
||||||
fprintf(stderr, "getdefaultgateway() failed\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Whitespace-only changes.
@@ -249,7 +249,7 @@ freeswitch_debian_source() {
|
|||||||
freeswitch_raspbian_source() {
|
freeswitch_raspbian_source() {
|
||||||
apt-get install -o Dpkg::Progress=1 -y autoconf automake devscripts gawk libjpeg-dev libncurses5-dev libtool-bin \
|
apt-get install -o Dpkg::Progress=1 -y autoconf automake devscripts gawk libjpeg-dev libncurses5-dev libtool-bin \
|
||||||
libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev \
|
libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev \
|
||||||
libspeexdsp-dev libsqlite3-dev libminiupnpc-dev libedit-dev libldns-dev libpq-dev libsndfile-dev libopus-dev liblua5.1-0-dev 2>&1 | \
|
libspeexdsp-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev libedit-dev libldns-dev libpq-dev libsndfile-dev libopus-dev liblua5.1-0-dev 2>&1 | \
|
||||||
awk -W interactive '/Progress/ { print }'| sed -u 's/[^0-9]//g' | dialog --gauge "Please wait.\n Installing Build Requirements..." 10 70 0
|
awk -W interactive '/Progress/ { print }'| sed -u 's/[^0-9]//g' | dialog --gauge "Please wait.\n Installing Build Requirements..." 10 70 0
|
||||||
build_fs
|
build_fs
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ wget -O - https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub
|
|||||||
|
|
||||||
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
|
echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" > /etc/apt/sources.list.d/freeswitch.list
|
||||||
|
|
||||||
apt-get update && apt-get install -y libtool libjpeg62-turbo-dev ntpdate libfreetype6-dev git-buildpackage doxygen yasm gdb git build-essential automake autoconf wget uuid-dev zlib1g-dev libncurses5-dev libssl-dev libpcre3-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libsqlite3-dev libminiupnpc-dev perl libgdbm-dev libdb-dev bison pkg-config ccache libpng16-dev libpng12-dev libopenal-dev libbroadvoice-dev libcodec2-dev libflite-dev libg7221-dev libilbc-dev libsilk-dev liblua5.2-dev libopus-dev libsndfile-dev libavformat-dev libavcodec-extra libswscale-dev libx264-dev libperl-dev unixodbc-dev libpq-dev libsctp-dev
|
apt-get update && apt-get install -y libtool libjpeg62-turbo-dev ntpdate libfreetype6-dev git-buildpackage doxygen yasm gdb git build-essential automake autoconf wget uuid-dev zlib1g-dev libncurses5-dev libssl-dev libpcre3-dev libcurl4-openssl-dev libldns-dev libedit-dev libspeexdsp-dev libsqlite3-dev libminiupnpc-dev libnatpmp-dev perl libgdbm-dev libdb-dev bison pkg-config ccache libpng16-dev libpng12-dev libopenal-dev libbroadvoice-dev libcodec2-dev libflite-dev libg7221-dev libilbc-dev libsilk-dev liblua5.2-dev libopus-dev libsndfile-dev libavformat-dev libavcodec-extra libswscale-dev libx264-dev libperl-dev unixodbc-dev libpq-dev libsctp-dev
|
||||||
|
|
||||||
cd /usr/src
|
cd /usr/src
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -36,7 +36,7 @@
|
|||||||
#include <miniupnpc/miniwget.h>
|
#include <miniupnpc/miniwget.h>
|
||||||
#include <miniupnpc/miniupnpc.h>
|
#include <miniupnpc/miniupnpc.h>
|
||||||
#include <miniupnpc/upnpcommands.h>
|
#include <miniupnpc/upnpcommands.h>
|
||||||
#include "../libs/libnatpmp/natpmp.h"
|
#include <natpmp.h>
|
||||||
|
|
||||||
#define MULTICAST_BUFFSIZE 65536
|
#define MULTICAST_BUFFSIZE 65536
|
||||||
#define IP_LEN 16
|
#define IP_LEN 16
|
||||||
@@ -170,7 +170,7 @@ static int get_pmp_pubaddr(char *pub_addr)
|
|||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
int pflags;
|
int pflags;
|
||||||
|
|
||||||
if ((r = initnatpmp(&natpmp)) < 0) {
|
if ((r = initnatpmp(&natpmp, 0, 0)) < 0) {
|
||||||
err = "init failed";
|
err = "init failed";
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ static switch_status_t switch_nat_add_mapping_pmp(switch_port_t port, switch_nat
|
|||||||
int r;
|
int r;
|
||||||
natpmp_t natpmp;
|
natpmp_t natpmp;
|
||||||
|
|
||||||
initnatpmp(&natpmp);
|
initnatpmp(&natpmp, 0, 0);
|
||||||
|
|
||||||
if (proto == SWITCH_NAT_TCP) {
|
if (proto == SWITCH_NAT_TCP) {
|
||||||
sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, port, port, 31104000);
|
sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, port, port, 31104000);
|
||||||
@@ -537,7 +537,7 @@ static switch_status_t switch_nat_del_mapping_pmp(switch_port_t port, switch_nat
|
|||||||
int r;
|
int r;
|
||||||
natpmp_t natpmp;
|
natpmp_t natpmp;
|
||||||
|
|
||||||
initnatpmp(&natpmp);
|
initnatpmp(&natpmp, 0, 0);
|
||||||
|
|
||||||
if (proto == SWITCH_NAT_TCP) {
|
if (proto == SWITCH_NAT_TCP) {
|
||||||
sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, port, port, 0);
|
sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, port, port, 0);
|
||||||
|
|||||||
@@ -7,15 +7,9 @@
|
|||||||
<ClCompile Include="..\..\src\switch_core.c">
|
<ClCompile Include="..\..\src\switch_core.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\libs\libnatpmp\getgateway.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\inet_pton.c">
|
<ClCompile Include="..\..\src\inet_pton.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\libs\libnatpmp\natpmp.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\switch_apr.c">
|
<ClCompile Include="..\..\src\switch_apr.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<Import Project="$(SolutionDir)\w32\speexdsp.props" Condition=" '$(speexdspVersionImported)' == '' " />
|
<Import Project="$(SolutionDir)\w32\speexdsp.props" Condition=" '$(speexdspVersionImported)' == '' " />
|
||||||
<Import Project="$(SolutionDir)\w32\freetype.props" Condition=" '$(freetypeVersionImported)' == '' " />
|
<Import Project="$(SolutionDir)\w32\freetype.props" Condition=" '$(freetypeVersionImported)' == '' " />
|
||||||
<Import Project="$(SolutionDir)\w32\miniupnpc.props" Condition=" '$(miniupnpcVersionImported)' == '' " />
|
<Import Project="$(SolutionDir)\w32\miniupnpc.props" Condition=" '$(miniupnpcVersionImported)' == '' " />
|
||||||
|
<Import Project="$(SolutionDir)\w32\libnatpmp.props" Condition=" '$(libnatpmpVersionImported)' == '' " />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
@@ -135,7 +136,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\"
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
@@ -185,7 +186,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\"
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
@@ -226,7 +227,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\"
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x86;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>switch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>switch.h</PrecompiledHeaderFile>
|
||||||
@@ -264,7 +265,7 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\"
|
|||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libteletone\src;..\..\libs\spandsp\src\msvc;..\..\libs\spandsp\src;..\..\libs\libtpl-1.5\src;..\..\libs\libtpl-1.5\src\win;..\..\libs\sofia-sip\libsofia-sip-ua\sdp;..\..\libs\sofia-sip\libsofia-sip-ua\su;..\..\libs\sofia-sip\win32;..\..\libs\libyuv\include;..\..\libs\libvpx;..\..\libs\win32\libvpx\include_x64;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;STATICLIB;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>CJSON_EXPORT_SYMBOLS;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;CRASH_PROT;TPL_NOLIB;LIBSOFIA_SIP_UA_STATIC;SWITCH_HAVE_YUV;SWITCH_HAVE_VPX;SWITCH_HAVE_PNG;SWITCH_HAVE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>switch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>switch.h</PrecompiledHeaderFile>
|
||||||
@@ -426,50 +427,6 @@ if not exist "$(OutDir)fonts" xcopy "$(SolutionDir)fonts\*.*" "$(OutDir)fonts\"
|
|||||||
<ClCompile Include="..\..\src\switch_jitterbuffer.c" />
|
<ClCompile Include="..\..\src\switch_jitterbuffer.c" />
|
||||||
<ClCompile Include="..\..\src\switch_xml.c" />
|
<ClCompile Include="..\..\src\switch_xml.c" />
|
||||||
<ClCompile Include="..\..\src\switch_xml_config.c" />
|
<ClCompile Include="..\..\src\switch_xml_config.c" />
|
||||||
<ClCompile Include="..\..\libs\libnatpmp\getgateway.c">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeaderFile>
|
|
||||||
<PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeaderOutputFile>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeaderFile>
|
|
||||||
<PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeaderOutputFile>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\libs\libnatpmp\natpmp.c">
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeaderFile>
|
|
||||||
<PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
</PrecompiledHeaderOutputFile>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeaderFile>
|
|
||||||
<PrecompiledHeaderOutputFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
</PrecompiledHeaderOutputFile>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\switch_utf8.c">
|
<ClCompile Include="..\..\src\switch_utf8.c">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets" />
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<libnatpmpVersion>20230423</libnatpmpVersion>
|
||||||
|
<libnatpmpBuildNumber>1</libnatpmpBuildNumber>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<libnatpmpVersionImported>true</libnatpmpVersionImported>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<BuildMacro Include="libnatpmpVersion">
|
||||||
|
<Value>$(libnatpmpVersion)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
<BuildMacro Include="libnatpmpBuildNumber">
|
||||||
|
<Value>$(libnatpmpBuildNumber)</Value>
|
||||||
|
</BuildMacro>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Project="libnatpmp-version.props" Condition=" '$(libnatpmpVersionImported)' == '' "/>
|
||||||
|
<Import Project="downloadpackage.task" Condition=" '$(downloadpackagetask_Imported)' == '' " />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros">
|
||||||
|
<libnatpmpLibDir>$(BaseDir)libs\libnatpmp-$(libnatpmpVersion)_$(libnatpmpBuildNumber)</libnatpmpLibDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Download Target.
|
||||||
|
Name must be unique.
|
||||||
|
By design, targets are executed only once per project.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
package: URI
|
||||||
|
|
||||||
|
expectfileordirectory: Skips the download and extraction if exists
|
||||||
|
|
||||||
|
outputfolder: Folder to store a downloaded file.
|
||||||
|
By default "$(BaseDir)libs", if empty
|
||||||
|
|
||||||
|
outputfilename: If not empty, overrides filename from URI.
|
||||||
|
.exe files don't get extracted
|
||||||
|
|
||||||
|
extractto: Folder to extract an archive to
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Target Name="libnatpmpBinariesDownloadTarget" BeforeTargets="CustomBuild" DependsOnTargets="7za">
|
||||||
|
<DownloadPackageTask
|
||||||
|
package="https://github.com/freeswitch/windows-deps/releases/download/libnatpmp-v$(libnatpmpVersion)_$(libnatpmpBuildNumber)/libnatpmp-$(libnatpmpVersion)_$(libnatpmpBuildNumber)-binaries-$(Platform.ToLower())-$(Configuration.ToLower()).zip"
|
||||||
|
expectfileordirectory="$(libnatpmpLibDir)\binaries\$(Platform)\$(Configuration)\natpmp.lib"
|
||||||
|
outputfolder=""
|
||||||
|
outputfilename=""
|
||||||
|
extractto="$(BaseDir)libs\"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
<Target Name="libnatpmpHeadersDownloadTarget" BeforeTargets="CustomBuild" DependsOnTargets="7za">
|
||||||
|
<DownloadPackageTask
|
||||||
|
package="https://github.com/freeswitch/windows-deps/releases/download/libnatpmp-v$(libnatpmpVersion)_$(libnatpmpBuildNumber)/libnatpmp-$(libnatpmpVersion)_$(libnatpmpBuildNumber)-headers.zip"
|
||||||
|
expectfileordirectory="$(libnatpmpLibDir)\include\natpmp.h"
|
||||||
|
outputfolder=""
|
||||||
|
outputfilename=""
|
||||||
|
extractto="$(BaseDir)libs\"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<ClCompile>
|
||||||
|
<AdditionalIncludeDirectories>$(libnatpmpLibDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>NATPMP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalLibraryDirectories>$(libnatpmpLibDir)\binaries\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>natpmp.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
</Project>
|
||||||
Reference in new issue
Block a user