Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115691
D12075.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
20 KB
Subscribers
None
D12075.diff
View Options
diff --git a/cmake/modules/FindNATPMP.cmake b/cmake/modules/FindNATPMP.cmake
new file mode 100644
--- /dev/null
+++ b/cmake/modules/FindNATPMP.cmake
@@ -0,0 +1,63 @@
+# Copyright (c) 2022 The Bitcoin developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#.rst
+# FindNATPMP
+# ----------
+#
+# Find the natpmp library. The following
+# components are available::
+# NATPMP
+#
+# This will define the following variables::
+#
+# NATPMP_FOUND - system has natpmp lib
+# NATPMP_INCLUDE_DIRS - the natpmp include directories
+# NATPMP_LIBRARIES - Libraries needed to use natpmp
+#
+# And the following imported target::
+#
+# NATPMP::natpmp
+#
+# There is currently no reliable way to find a version number for natpmp.
+# The last release on https://miniupnp.tuxfamily.org/files/ is 20150609, the
+# release number in the VERSION file in the repository is outdated (20120821).
+# We use a commit hash to fix the release in depends/packages/libnatpmp.mk to the
+# current tip of the repository, but the last released version works as well.
+
+include(BrewHelper)
+find_brew_prefix(_NATPMP_BREW_HINT libnatpmp)
+
+# Note that support for pkg-config has been added to the master branch of the repository
+# (https://github.com/miniupnp/libnatpmp/pull/19) but there is still no release including it
+# (https://miniupnp.tuxfamily.org/files/).
+find_package(PkgConfig)
+pkg_check_modules(PC_NATPMP QUIET natpmp)
+
+find_path(NATPMP_INCLUDE_DIR
+ NAMES natpmp.h
+ HINTS ${_NATPMP_BREW_HINT}
+ PATHS ${PC_NATPMP_INCLUDE_DIRS}
+)
+
+set(NATPMP_INCLUDE_DIRS "${NATPMP_INCLUDE_DIR}")
+mark_as_advanced(NATPMP_INCLUDE_DIR)
+
+if(NATPMP_INCLUDE_DIR)
+ include(ExternalLibraryHelper)
+ find_component(NATPMP natpmp
+ NAMES natpmp
+ HINTS ${_NATPMP_BREW_HINT}
+ PATHS ${PC_NATPMP_LIBRARY_DIRS}
+ INCLUDE_DIRS ${NATPMP_INCLUDE_DIRS}
+ )
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(NATPMP
+ REQUIRED_VARS
+ NATPMP_INCLUDE_DIR
+ REASON_FAILURE_MESSAGE "if the NAT-PMP feature is not required, it can be skipped by passing -DENABLE_NATPMP=OFF to the cmake command line"
+ HANDLE_COMPONENTS
+)
diff --git a/contrib/aur/bitcoin-abc-qt/PKGBUILD b/contrib/aur/bitcoin-abc-qt/PKGBUILD
--- a/contrib/aur/bitcoin-abc-qt/PKGBUILD
+++ b/contrib/aur/bitcoin-abc-qt/PKGBUILD
@@ -6,7 +6,7 @@
pkgdesc="Bitcoin ABC with bitcoind, bitcoin-cli, bitcoin-tx, bitcoin-seeder and bitcoin-qt"
arch=('i686' 'x86_64')
url="https://bitcoinabc.org"
-depends=('boost-libs' 'libevent' 'desktop-file-utils' 'qt5-base' 'protobuf' 'openssl' 'miniupnpc' 'zeromq' 'qrencode' 'jemalloc')
+depends=('boost-libs' 'libevent' 'desktop-file-utils' 'qt5-base' 'protobuf' 'openssl' 'miniupnpc' 'libnatpmp' 'zeromq' 'qrencode' 'jemalloc')
makedepends=('cmake' 'ninja' 'boost' 'qt5-tools' 'python' 'help2man' 'xorg-server-xvfb')
license=('MIT')
source=(https://github.com/Bitcoin-ABC/bitcoin-abc/archive/v$pkgver.tar.gz
diff --git a/contrib/aur/bitcoin-abc/PKGBUILD b/contrib/aur/bitcoin-abc/PKGBUILD
--- a/contrib/aur/bitcoin-abc/PKGBUILD
+++ b/contrib/aur/bitcoin-abc/PKGBUILD
@@ -6,7 +6,7 @@
pkgdesc="Bitcoin ABC with bitcoind, bitcoin-tx, bitcoin-seeder and bitcoin-cli"
arch=('i686' 'x86_64')
url="https://bitcoinabc.org"
-depends=('boost-libs' 'libevent' 'openssl' 'zeromq' 'miniupnpc' 'jemalloc')
+depends=('boost-libs' 'libevent' 'openssl' 'zeromq' 'miniupnpc' 'libnatpmp' 'jemalloc')
makedepends=('cmake' 'ninja' 'boost' 'python' 'help2man')
license=('MIT')
source=(https://github.com/Bitcoin-ABC/bitcoin-abc/archive/v$pkgver.tar.gz
diff --git a/contrib/debian/control b/contrib/debian/control
--- a/contrib/debian/control
+++ b/contrib/debian/control
@@ -12,6 +12,7 @@
libevent-dev,
libjemalloc-dev,
libminiupnpc-dev,
+ libnatpmp-dev,
libboost-filesystem-dev,
libboost-system-dev,
libboost-thread-dev,
diff --git a/contrib/utils/install-dependencies.sh b/contrib/utils/install-dependencies.sh
--- a/contrib/utils/install-dependencies.sh
+++ b/contrib/utils/install-dependencies.sh
@@ -44,6 +44,7 @@
libevent-dev
libjemalloc-dev
libminiupnpc-dev
+ libnatpmp-dev
libprotobuf-dev
libqrencode-dev
libqt5core5a
diff --git a/depends/Makefile b/depends/Makefile
--- a/depends/Makefile
+++ b/depends/Makefile
@@ -38,6 +38,7 @@
NO_WALLET ?=
NO_ZMQ ?=
NO_UPNP ?=
+NO_NATPMP ?=
NO_JEMALLOC ?=
FALLBACK_DOWNLOAD_PATH ?= https://download.bitcoinabc.org/depends-sources
@@ -137,13 +138,15 @@
wallet_packages_$(NO_WALLET) = $(bdb_packages_) $(sqlite_packages_)
upnp_packages_$(NO_UPNP) = $(upnp_packages)
+natpmp_packages_$(NO_NATPMP) = $(natpmp_packages)
+
zmq_packages_$(NO_ZMQ) = $(zmq_packages)
protobuf_packages_$(NO_PROTOBUF) = $(protobuf_packages)
jemalloc_packages_$(NO_JEMALLOC) = $(jemalloc_packages)
-packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_)
+packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_)
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
ifneq ($(protobuf_packages_),)
diff --git a/depends/README.md b/depends/README.md
--- a/depends/README.md
+++ b/depends/README.md
@@ -91,6 +91,7 @@
- `NO_BDB`: Don't download/build/cache BerkeleyDB
- `NO_SQLITE`: Don't download/build/cache SQLite
- `NO_UPNP`: Don't download/build/cache packages needed for enabling UPnP
+- `NO_NATPMP`: Don't download/build/cache packages needed for enabling NAT-PMP
- `NO_JEMALLOC`: Don't download/build/cache jemalloc
- `DEBUG`: Disable some optimizations and enable more runtime checking
- `NO_PROTOBUF`: Don't download/build/cache protobuf (used for BIP70 support)
diff --git a/depends/packages/libnatpmp.mk b/depends/packages/libnatpmp.mk
new file mode 100644
--- /dev/null
+++ b/depends/packages/libnatpmp.mk
@@ -0,0 +1,22 @@
+package=libnatpmp
+$(package)_version=07004b97cf691774efebe70404cf22201e4d330d
+$(package)_download_path=https://github.com/miniupnp/libnatpmp/archive
+$(package)_file_name=$($(package)_version).tar.gz
+$(package)_sha256_hash=9321953ceb39d07c25463e266e50d0ae7b64676bb3a986d932b18881ed94f1fb
+
+define $(package)_set_vars
+ $(package)_build_opts=CC="$($(package)_cc)"
+ $(package)_build_opts_mingw32=CPPFLAGS=-DNATPMP_STATICLIB
+ $(package)_build_opts_darwin=LIBTOOL="$($(package)_libtool)"
+ $(package)_build_env+=CFLAGS="$($(package)_cflags) $($(package)_cppflags)" AR="$($(package)_ar)"
+endef
+
+define $(package)_build_cmds
+ $(MAKE) -j$(JOBS) libnatpmp.a $($(package)_build_opts)
+endef
+
+define $(package)_stage_cmds
+ mkdir -p $($(package)_staging_prefix_dir)/include $($(package)_staging_prefix_dir)/lib &&\
+ install *.h $($(package)_staging_prefix_dir)/include &&\
+ install libnatpmp.a $($(package)_staging_prefix_dir)/lib
+endef
diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk
--- a/depends/packages/packages.mk
+++ b/depends/packages/packages.mk
@@ -18,6 +18,7 @@
zmq_packages=zeromq
upnp_packages=miniupnpc
+natpmp_packages=libnatpmp
darwin_native_packages = native_biplist native_ds_store native_mac_alias
diff --git a/doc/build-osx.md b/doc/build-osx.md
--- a/doc/build-osx.md
+++ b/doc/build-osx.md
@@ -21,7 +21,7 @@
Install dependencies:
- brew install berkeley-db boost cmake jemalloc libevent librsvg miniupnpc ninja openssl protobuf python qrencode qt@5 sqlite zeromq
+ brew install berkeley-db boost cmake jemalloc libevent librsvg miniupnpc libnatpmp ninja openssl protobuf python qrencode qt@5 sqlite zeromq
See [dependencies.md](dependencies.md) for a complete overview.
diff --git a/doc/build-unix.md b/doc/build-unix.md
--- a/doc/build-unix.md
+++ b/doc/build-unix.md
@@ -37,6 +37,7 @@
Library | Purpose | Description
------------|------------------|----------------------
miniupnpc | UPnP Support | Firewall-jumping support
+ libnatpmp | NAT-PMP Support | Firewall-jumping support
libdb | Berkeley DB | Wallet storage (only needed when wallet enabled)
libsqlite3 | SQLite 3 | Wallet storage (only needed when wallet enabled)
jemalloc | Memory allocator | Library to enhance the memory allocation and improve performances
@@ -110,9 +111,9 @@
See the section "Disable-wallet mode" to build Bitcoin ABC without wallet.
-Minipupnc dependencies (can be disabled by passing `-DENABLE_UPNP=OFF` on the cmake command line):
+Port mapping dependencies MiniUPnPc and NAT-PMP (can be disabled by passing `-DENABLE_UPNP=OFF` and `-DENABLE_NATPMP=OFF` on the cmake command line):
- sudo apt-get install libminiupnpc-dev
+ sudo apt-get install libminiupnpc-dev libnatpmp-dev
ZMQ dependencies (provides ZMQ API, can be disabled by passing `-DBUILD_BITCOIN_ZMQ=OFF` on the cmake command line):
@@ -143,9 +144,9 @@
sudo dnf install boost-devel cmake gcc-c++ libdb-cxx-devel libdb-devel libevent-devel ninja-build openssl-devel python3
-Minipupnc dependencies (can be disabled by passing `-DENABLE_UPNP=OFF` on the cmake command line):
+Port mapping dependencies MiniUPnPc and NAT-PMP (can be disabled by passing `-DENABLE_UPNP=OFF` and `-DENABLE_NATPMP=OFF` on the cmake command line):
- sudo dnf install miniupnpc-devel
+ sudo dnf install miniupnpc-devel libnatpmp-devel
ZMQ dependencies (can be disabled by passing `-DBUILD_BITCOIN_ZMQ=OFF` on the cmake command line):
@@ -174,11 +175,21 @@
[miniupnpc](https://miniupnp.tuxfamily.org) may be used for UPnP port mapping. It can be downloaded from [here](
https://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and
-turned off by default. See the cmake options for upnp behavior desired:
+turned off by default. See the cmake options for UPnP behavior desired:
ENABLE_UPNP Enable UPnP support (miniupnp required, default ON)
START_WITH_UPNP UPnP support turned on by default at runtime (default OFF)
+libnatpmp
+---------
+
+[libnatpmp](https://miniupnp.tuxfamily.org/libnatpmp.html) may be used for NAT-PMP port mapping. It can be downloaded
+from [here](https://miniupnp.tuxfamily.org/files/). NAT-PMP support is compiled in and
+turned off by default. See the configure options for NAT-PMP behavior desired:
+
+ ENABLE_NATPMP NAT-PMP support (libnatpmp required, default ON)
+ START_WITH_NATPMP NAT-PMP support turned on by default at runtime (default OFF)
+
Boost
-----
For documentation on building Boost look at their official documentation: http://www.boost.org/build/doc/html/bbv2/installation.html
diff --git a/doc/dependencies.md b/doc/dependencies.md
--- a/doc/dependencies.md
+++ b/doc/dependencies.md
@@ -16,6 +16,7 @@
| HarfBuzz-NG | | | | | |
| jemalloc | [5.2.1](https://github.com/jemalloc/jemalloc/releases) | 3.6.0 | | | |
| libevent | [2.1.11-stable](https://github.com/libevent/libevent/releases) | 2.0.22 | No | | |
+| libnatpmp | commit [07004b9...](https://github.com/miniupnp/libnatpmp/commit/07004b97cf691774efebe70404cf22201e4d330d) | | No | | |
| libpng | | | | | Yes |
| librsvg | | | | | |
| MiniUPnPc | [2.0.20180203](https://miniupnp.tuxfamily.org/files) | 1.9 | No | | |
@@ -39,6 +40,7 @@
#### Options passed to `cmake`
* MiniUPnPc is not needed with `-DENABLE_UPNP=OFF`.
+* MiniUPnPc is not needed with `-DENABLE_NATPMP=OFF`.
* Berkeley DB and SQLite are not needed with `-DBUILD_BITCOIN_WALLET=OFF`.
* protobuf is not needed with `-DENABLE_BIP70=OFF`.
* Qt is not needed with `-DBUILD_BITCOIN_QT=OFF`.
diff --git a/doc/productivity.md b/doc/productivity.md
--- a/doc/productivity.md
+++ b/doc/productivity.md
@@ -34,6 +34,7 @@
```sh
-DENABLE_UPNP=OFF
+-DENABLE_NATPMP=OFF
-DBUILD_BITCOIN_WALLET=OFF
-DBUILD_BITCOIN_QT=OFF
```
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,8 @@
option(ENABLE_QRCODE "Enable QR code display" ON)
option(ENABLE_UPNP "Enable UPnP support" ON)
option(START_WITH_UPNP "Make UPnP the default to map ports" OFF)
+option(ENABLE_NATPMP "Enable NAT-PMP support" ON)
+option(START_WITH_NATPMP "Make NAT-PMP the default to map ports" OFF)
option(ENABLE_CLANG_TIDY "Enable clang-tidy checks for Bitcoin ABC" OFF)
option(ENABLE_PROFILING "Select the profiling tool to use" OFF)
@@ -77,6 +79,7 @@
"-DBUILD_BITCOIN_QT=OFF"
"-DBUILD_BITCOIN_ZMQ=OFF"
"-DENABLE_QRCODE=OFF"
+ "-DENABLE_NATPMP=OFF"
"-DENABLE_UPNP=OFF"
"-DUSE_JEMALLOC=OFF"
"-DENABLE_CLANG_TIDY=OFF"
@@ -650,6 +653,18 @@
endif()
endif()
+if(ENABLE_NATPMP)
+ find_package(NATPMP REQUIRED)
+ target_link_libraries(server NATPMP::natpmp)
+
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+ target_compile_definitions(server
+ PUBLIC -DSTATICLIB
+ PUBLIC -DNATPMP_STATICLIB
+ )
+ endif()
+endif()
+
# Test suites.
add_subdirectory(test)
add_subdirectory(avalanche/test)
diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt
--- a/src/config/CMakeLists.txt
+++ b/src/config/CMakeLists.txt
@@ -248,6 +248,17 @@
set(USE_UPNP ${START_WITH_UPNP} CACHE INTERNAL "UPnP is enabled")
endif()
+# Try to find natpmp
+if(ENABLE_NATPMP)
+ # The expected behavior is as follow:
+ # - If NAT-PMP is enabled USE_NATPMP must be defined
+ # - If NAT-PMP should be a port map method, USE_NATPMP should be
+ # defined to 1, otherwise it should be defined to 0.
+ # - If both USE_UPNP and USE_NATPMP are defined to 1, UPnP is used first.
+ # If it fails, NAT-PMP is then used.
+ set(USE_NATPMP ${START_WITH_NATPMP} CACHE INTERNAL "NAT-PMP is enabled")
+endif()
+
if(ENABLE_DBUS_NOTIFICATIONS)
set(USE_DBUS 1)
endif()
diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in
--- a/src/config/bitcoin-config.h.cmake.in
+++ b/src/config/bitcoin-config.h.cmake.in
@@ -88,6 +88,13 @@
#cmakedefine01 USE_UPNP
#endif
+/* NAT-PMP support not compiled if undefined */
+#cmakedefine ENABLE_NATPMP
+#ifdef ENABLE_NATPMP
+/* Value (0 or 1) determines the NATPMP default state at startup. */
+#cmakedefine01 USE_NATPMP
+#endif
+
/* Define if QtDBus support should be enabled */
#cmakedefine USE_DBUS 1
diff --git a/src/mapport.h b/src/mapport.h
--- a/src/mapport.h
+++ b/src/mapport.h
@@ -15,6 +15,7 @@
enum MapPortProtoFlag : unsigned int {
NONE = 0x00,
UPNP = 0x01,
+ NAT_PMP = 0x02,
};
void StartMapPort(bool use_upnp);
diff --git a/src/mapport.cpp b/src/mapport.cpp
--- a/src/mapport.cpp
+++ b/src/mapport.cpp
@@ -17,6 +17,11 @@
#include <util/system.h>
#include <util/thread.h>
+#ifdef USE_NATPMP
+#include <compat.h>
+#include <natpmp.h>
+#endif // USE_NATPMP
+
#ifdef USE_UPNP
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
@@ -25,7 +30,7 @@
// compatibility with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages.
static_assert(MINIUPNPC_API_VERSION >= 10,
"miniUPnPc API version >= 10 assumed");
-#endif
+#endif // USE_UPNP
#include <atomic>
#include <cassert>
@@ -34,7 +39,7 @@
#include <string>
#include <thread>
-#ifdef USE_UPNP
+#if defined(USE_NATPMP) || defined(USE_UPNP)
static CThreadInterrupt g_mapport_interrupt;
static std::thread g_mapport_thread;
static std::atomic_uint g_mapport_target_proto{MapPortProtoFlag::NONE};
@@ -43,6 +48,126 @@
static constexpr auto PORT_MAPPING_REANNOUNCE_PERIOD{20min};
static constexpr auto PORT_MAPPING_RETRY_PERIOD{5min};
+#ifdef USE_NATPMP
+static uint16_t g_mapport_external_port = 0;
+static bool NatpmpInit(natpmp_t *natpmp) {
+ const int r_init = initnatpmp(natpmp, /* detect gateway automatically */ 0,
+ /* forced gateway - NOT APPLIED*/ 0);
+ if (r_init == 0) {
+ return true;
+ }
+ LogPrintf("natpmp: initnatpmp() failed with %d error.\n", r_init);
+ return false;
+}
+
+static bool NatpmpDiscover(natpmp_t *natpmp,
+ struct in_addr &external_ipv4_addr) {
+ const int r_send = sendpublicaddressrequest(natpmp);
+ if (r_send == 2 /* OK */) {
+ int r_read;
+ natpmpresp_t response;
+ do {
+ r_read = readnatpmpresponseorretry(natpmp, &response);
+ } while (r_read == NATPMP_TRYAGAIN);
+
+ if (r_read == 0) {
+ external_ipv4_addr = response.pnu.publicaddress.addr;
+ return true;
+ } else if (r_read == NATPMP_ERR_NOGATEWAYSUPPORT) {
+ LogPrintf("natpmp: The gateway does not support NAT-PMP.\n");
+ } else {
+ LogPrintf("natpmp: readnatpmpresponseorretry() for public address "
+ "failed with %d error.\n",
+ r_read);
+ }
+ } else {
+ LogPrintf("natpmp: sendpublicaddressrequest() failed with %d error.\n",
+ r_send);
+ }
+
+ return false;
+}
+
+static bool NatpmpMapping(natpmp_t *natpmp,
+ const struct in_addr &external_ipv4_addr,
+ uint16_t private_port, bool &external_ip_discovered) {
+ const uint16_t suggested_external_port =
+ g_mapport_external_port ? g_mapport_external_port : private_port;
+ const int r_send =
+ sendnewportmappingrequest(natpmp, NATPMP_PROTOCOL_TCP, private_port,
+ suggested_external_port, 3600 /*seconds*/);
+ if (r_send == 12 /* OK */) {
+ int r_read;
+ natpmpresp_t response;
+ do {
+ r_read = readnatpmpresponseorretry(natpmp, &response);
+ } while (r_read == NATPMP_TRYAGAIN);
+
+ if (r_read == 0) {
+ auto pm = response.pnu.newportmapping;
+ if (private_port == pm.privateport && pm.lifetime > 0) {
+ g_mapport_external_port = pm.mappedpublicport;
+ const CService external{external_ipv4_addr,
+ pm.mappedpublicport};
+ if (!external_ip_discovered && fDiscover) {
+ AddLocal(external, LOCAL_MAPPED);
+ external_ip_discovered = true;
+ }
+ LogPrintf(
+ "natpmp: Port mapping successful. External address = %s\n",
+ external.ToString());
+ return true;
+ } else {
+ LogPrintf("natpmp: Port mapping failed.\n");
+ }
+ } else if (r_read == NATPMP_ERR_NOGATEWAYSUPPORT) {
+ LogPrintf("natpmp: The gateway does not support NAT-PMP.\n");
+ } else {
+ LogPrintf("natpmp: readnatpmpresponseorretry() for port mapping "
+ "failed with %d error.\n",
+ r_read);
+ }
+ } else {
+ LogPrintf("natpmp: sendnewportmappingrequest() failed with %d error.\n",
+ r_send);
+ }
+
+ return false;
+}
+
+[[maybe_unused]] static bool ProcessNatpmp() {
+ bool ret = false;
+ natpmp_t natpmp;
+ struct in_addr external_ipv4_addr;
+ if (NatpmpInit(&natpmp) && NatpmpDiscover(&natpmp, external_ipv4_addr)) {
+ bool external_ip_discovered = false;
+ const uint16_t private_port = GetListenPort();
+ do {
+ ret = NatpmpMapping(&natpmp, external_ipv4_addr, private_port,
+ external_ip_discovered);
+ } while (ret &&
+ g_mapport_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD));
+ g_mapport_interrupt.reset();
+
+ const int r_send = sendnewportmappingrequest(
+ &natpmp, NATPMP_PROTOCOL_TCP, private_port, g_mapport_external_port,
+ /* remove a port mapping */ 0);
+ g_mapport_external_port = 0;
+ if (r_send == 12 /* OK */) {
+ LogPrintf("natpmp: Port mapping removed successfully.\n");
+ } else {
+ LogPrintf(
+ "natpmp: sendnewportmappingrequest(0) failed with %d error.\n",
+ r_send);
+ }
+ }
+
+ closenatpmp(&natpmp);
+ return ret;
+}
+#endif // USE_NATPMP
+
+#ifdef USE_UPNP
static bool ProcessUpnp() {
bool ret = false;
std::string port = strprintf("%u", GetListenPort());
@@ -121,6 +246,7 @@
return ret;
}
+#endif // USE_UPNP
static void ThreadMapPort() {
do {
@@ -173,7 +299,7 @@
}
}
-#else
+#else // #if defined(USE_NATPMP) || defined(USE_UPNP)
void StartMapPort(bool use_upnp) {
// Intentionally left blank.
}
@@ -183,4 +309,4 @@
void StopMapPort() {
// Intentionally left blank.
}
-#endif
+#endif // #if defined(USE_NATPMP) || defined(USE_UPNP)
diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -227,7 +227,7 @@
LOCAL_IF,
// address explicit bound to
LOCAL_BIND,
- // address reported by UPnP
+ // address reported by UPnP or NAT-PMP
LOCAL_MAPPED,
// address explicitly specified (-externalip=)
LOCAL_MANUAL,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:45 (3 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5177276
Default Alt Text
D12075.diff (20 KB)
Attached To
D12075: net: Add libnatpmp support
Event Timeline
Log In to Comment