Adds minimal support for NATPMP (and removes dependency on external UPnP library). Reference implementation in miniupnp/libnatpmp
.
WIP but aims to fix #11902 .
I assume libnatpmp should be subtree’d or we should still use the version linked-against in miniupnpc?
On January 28, 2018 8:15:18 PM UTC, Annanay Agarwal notifications@github.com wrote:
Adds minimal support for NATPMP (and removes dependency on external UPnP library). Reference implementation in
miniupnp/libnatpmp
.WIP but aims to fix #11902 . You can view, comment on, or merge this pull request online at:
– Commit Summary –
- Add basic NATPMP support, get gateway by file parsing, getpublicaddress, map public-private port
– File Changes –
A src/getgateway.c (570) A src/getgateway.h (47) A src/natpmp.c (354) A src/natpmp.h (182) M src/net.cpp (187) A src/wingettimeofday.c (60) A src/wingettimeofday.h (36)
– Patch Links –
https://github.com/bitcoin/bitcoin/pull/12288.patch https://github.com/bitcoin/bitcoin/pull/12288.diff
– You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/bitcoin/bitcoin/pull/12288
This PR just copies 6 files from libnatpmp into the repository. Perhaps this is a sufficiently low amount of code that we want to do this (like with tinyformat), but if so, putting them in a subdirectory together may be better.
I haven’t checked how much changes were necessary to them, but if it was 0, perhaps we can subtree but still build them directly from our build system (as opposed to building as a library and linking statically).
WIN32
macro, and others according to the coding guidelines like changing NULL
to nullptr
, etc.
libnatpmp seems to have been virtually unmaintained a while (last commit was Mar 15, 2016), so I think it doesn’t matter whether we use ‘subtree’. It might be easier to just include the (small) implementation files into our build system and see if we can maintain it ourselves, cutting out parts we don’t need.
At least now we don’t have to carry the .java
s.
putting them in a subdirectory together may be better.
I agree with that - whatever you do, please don’t put them in src/
root.
This is failing the travis build - did you perhaps forget to add natpmp.h
to the makefile, so that it’s not included in make dist?
0Making check in src
1make[1]: Entering directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
2make[2]: Entering directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
3 CXX libbitcoin_server_a-net.o
4 CXX libbitcoin_server_a-noui.o
5 CXX libbitcoin_server_a-pow.o
6 CXX libbitcoin_server_a-rest.o
7net.cpp:31:20: fatal error: natpmp.h: No such file or directory
8 #include <natpmp.h>
9 ^
10compilation terminated.
11make[2]: *** [libbitcoin_server_a-net.o] Error 1
12make[2]: *** Waiting for unfinished jobs....
13make[2]: Leaving directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
14make[1]: *** [check-recursive] Error 1
15make[1]: Leaving directory `/home/travis/build/bitcoin/bitcoin/build/bitcoin-i686-w64-mingw32/src'
16make: *** [check-recursive] Error 1
Merge branch 'natpmp-support' of https://github.com/annanay25/bitcoin into natpmp-support
Merge branch 'master' into natpmp-support
@laanwj ;
I’m a little confused with the name mangling happening here. The src/natpmp/*.c
files have extern "C"
in the function prototypes, which confirms no name mangling (confirmed this with nm src/natpmp/libbitcoin_server_a-natpmp.o | grep initnatpmp
), but C++ object files are looking for mangled function names?
but C++ object files are looking for mangled function names?
You need the extern “C” in the header, not in the implementation files.
124+extern "C" {
125+#endif
126+
127+/* initnatpmp()
128+ * initialize a natpmp_t object
129+ * With forcegw=1 the gateway is not detected automaticaly.
codespell
: automaticaly
1609- LogPrintf("No valid UPnP IGDs found\n");
1610- freeUPNPDevlist(devlist); devlist = nullptr;
1611- if (r != 0)
1612- FreeUPNPUrls(&urls);
1613+ LogPrintf("Mapped public port %hu protocol %s to local port %hu "
1614+ "liftime %u\n",
codespell
: liftime
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.