From bba217a2a60ae67bbf1f3052abdf7924f3c95d3d Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 15:03:27 +0200 Subject: [PATCH 01/15] remove pthreads, successfully tested on gcc 4.9.1 without pthreads --- cmake/FindUnbound.cmake | 6 +++++- src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index af3382fff..6c3d15eae 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -37,7 +37,11 @@ FIND_PATH(UNBOUND_INCLUDE_DIR /usr/ ) -find_library(UNBOUND_LIBRARIES unbound) +if(STATIC) + find_library(UNBOUND_LIBRARIES libunbound.a) +else() + find_library(UNBOUND_LIBRARIES unbound) +endif() IF(UNBOUND_INCLUDE_DIR) MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5502cdb9..5f6d7551e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,13 +60,13 @@ add_library(cryptonote_core ${CRYPTONOTE_CORE}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 92c21dad9..14695ddd8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,16 +61,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") From 6b9a7fcd67f1f39ba1a22a39de55ef60ff6dde26 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 15:49:18 +0200 Subject: [PATCH 02/15] fixed unbound static lib on mingw as libunbound.dll.a --- cmake/FindUnbound.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index 6c3d15eae..032bcf45e 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -38,7 +38,11 @@ FIND_PATH(UNBOUND_INCLUDE_DIR ) if(STATIC) - find_library(UNBOUND_LIBRARIES libunbound.a) + if(MINGW) + find_library(UNBOUND_LIBRARIES libunbound.dll.a) + else() + find_library(UNBOUND_LIBRARIES libunbound.a) + endif() else() find_library(UNBOUND_LIBRARIES unbound) endif() From a3332e7e113e7238110e491e6774adc62b06cf6c Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 18:43:13 +0200 Subject: [PATCH 03/15] remove dangling upnp port mappings, updated miniupnpc --- external/miniupnpc/.gitignore | 25 +++ external/miniupnpc/CMakeLists.txt | 12 +- external/miniupnpc/Changelog.txt | 17 +- external/miniupnpc/LICENSE | 2 +- external/miniupnpc/MANIFEST.in | 0 external/miniupnpc/Makefile | 6 +- external/miniupnpc/Makefile.mingw | 4 +- external/miniupnpc/README | 0 external/miniupnpc/VERSION | 0 external/miniupnpc/apiversions.txt | 0 external/miniupnpc/bsdqueue.h | 0 external/miniupnpc/codelength.h | 2 +- external/miniupnpc/connecthostport.c | 3 +- external/miniupnpc/connecthostport.h | 2 +- external/miniupnpc/declspec.h | 10 +- external/miniupnpc/igd_desc_parse.c | 29 ++- external/miniupnpc/igd_desc_parse.h | 2 +- external/miniupnpc/java/.gitignore | 2 + external/miniupnpc/java/JavaBridgeTest.java | 0 external/miniupnpc/man3/miniupnpc.3 | 0 external/miniupnpc/mingw32make.bat | 0 external/miniupnpc/minihttptestserver.c | 173 ++++++++++++++++-- external/miniupnpc/minisoap.c | 0 external/miniupnpc/minisoap.h | 2 +- external/miniupnpc/minissdpc.c | 4 +- external/miniupnpc/minissdpc.h | 2 +- external/miniupnpc/miniupnpc.c | 21 ++- external/miniupnpc/miniupnpc.def | 2 + external/miniupnpc/miniupnpc.h | 20 +- external/miniupnpc/miniupnpcmodule.c | 83 ++++++++- external/miniupnpc/miniupnpcstrings.h.cmake | 0 external/miniupnpc/miniupnpcstrings.h.in | 2 +- external/miniupnpc/miniupnpctypes.h | 2 +- external/miniupnpc/miniwget.c | 10 +- external/miniupnpc/miniwget.h | 8 +- external/miniupnpc/minixml.c | 2 +- external/miniupnpc/minixml.h | 2 +- external/miniupnpc/minixmlvalid.c | 0 external/miniupnpc/msvc/miniupnpc.sln | 0 external/miniupnpc/msvc/miniupnpc.vcproj | 4 +- external/miniupnpc/msvc/upnpc-static.vcproj | 4 +- external/miniupnpc/portlistingparse.c | 0 external/miniupnpc/portlistingparse.h | 6 +- external/miniupnpc/receivedata.c | 7 +- external/miniupnpc/receivedata.h | 2 +- external/miniupnpc/setup.py | 16 +- external/miniupnpc/setupmingw32.py | 18 +- external/miniupnpc/testigddescparse.c | 0 external/miniupnpc/testminiwget.c | 0 external/miniupnpc/testminixml.c | 0 .../DeletePortMapping.namevalue | 0 .../testreplyparse/DeletePortMapping.xml | 0 .../GetExternalIPAddress.namevalue | 0 .../testreplyparse/GetExternalIPAddress.xml | 0 .../GetSpecificPortMappingEntryReq.namevalue | 0 .../GetSpecificPortMappingEntryReq.xml | 0 .../GetSpecificPortMappingEntryResp.namevalue | 0 .../GetSpecificPortMappingEntryResp.xml | 0 .../SetDefaultConnectionService.namevalue | 0 .../SetDefaultConnectionService.xml | 0 external/miniupnpc/testreplyparse/readme.txt | 0 external/miniupnpc/testupnpreplyparse.c | 0 external/miniupnpc/upnpc.c | 139 +++++++++----- external/miniupnpc/upnpcommands.c | 169 ++++++++++++++--- external/miniupnpc/upnpcommands.h | 114 +++++++++--- external/miniupnpc/upnperrors.c | 5 +- external/miniupnpc/upnperrors.h | 4 +- external/miniupnpc/upnpreplyparse.c | 0 external/miniupnpc/upnpreplyparse.h | 0 external/miniupnpc/wingenminiupnpcstrings.c | 2 +- src/p2p/net_node.inl | 12 +- 71 files changed, 729 insertions(+), 222 deletions(-) create mode 100644 external/miniupnpc/.gitignore mode change 100755 => 100644 external/miniupnpc/CMakeLists.txt mode change 100755 => 100644 external/miniupnpc/Changelog.txt mode change 100755 => 100644 external/miniupnpc/LICENSE mode change 100755 => 100644 external/miniupnpc/MANIFEST.in mode change 100755 => 100644 external/miniupnpc/Makefile mode change 100755 => 100644 external/miniupnpc/Makefile.mingw mode change 100755 => 100644 external/miniupnpc/README mode change 100755 => 100644 external/miniupnpc/VERSION mode change 100755 => 100644 external/miniupnpc/apiversions.txt mode change 100755 => 100644 external/miniupnpc/bsdqueue.h mode change 100755 => 100644 external/miniupnpc/codelength.h mode change 100755 => 100644 external/miniupnpc/connecthostport.c mode change 100755 => 100644 external/miniupnpc/connecthostport.h mode change 100755 => 100644 external/miniupnpc/declspec.h mode change 100755 => 100644 external/miniupnpc/igd_desc_parse.c mode change 100755 => 100644 external/miniupnpc/igd_desc_parse.h create mode 100644 external/miniupnpc/java/.gitignore mode change 100755 => 100644 external/miniupnpc/java/JavaBridgeTest.java mode change 100755 => 100644 external/miniupnpc/man3/miniupnpc.3 mode change 100755 => 100644 external/miniupnpc/mingw32make.bat mode change 100755 => 100644 external/miniupnpc/minihttptestserver.c mode change 100755 => 100644 external/miniupnpc/minisoap.c mode change 100755 => 100644 external/miniupnpc/minisoap.h mode change 100755 => 100644 external/miniupnpc/minissdpc.c mode change 100755 => 100644 external/miniupnpc/minissdpc.h mode change 100755 => 100644 external/miniupnpc/miniupnpc.c mode change 100755 => 100644 external/miniupnpc/miniupnpc.def mode change 100755 => 100644 external/miniupnpc/miniupnpc.h mode change 100755 => 100644 external/miniupnpc/miniupnpcmodule.c mode change 100755 => 100644 external/miniupnpc/miniupnpcstrings.h.cmake mode change 100755 => 100644 external/miniupnpc/miniupnpcstrings.h.in mode change 100755 => 100644 external/miniupnpc/miniupnpctypes.h mode change 100755 => 100644 external/miniupnpc/miniwget.c mode change 100755 => 100644 external/miniupnpc/miniwget.h mode change 100755 => 100644 external/miniupnpc/minixml.c mode change 100755 => 100644 external/miniupnpc/minixml.h mode change 100755 => 100644 external/miniupnpc/minixmlvalid.c mode change 100755 => 100644 external/miniupnpc/msvc/miniupnpc.sln mode change 100755 => 100644 external/miniupnpc/msvc/miniupnpc.vcproj mode change 100755 => 100644 external/miniupnpc/msvc/upnpc-static.vcproj mode change 100755 => 100644 external/miniupnpc/portlistingparse.c mode change 100755 => 100644 external/miniupnpc/portlistingparse.h mode change 100755 => 100644 external/miniupnpc/receivedata.c mode change 100755 => 100644 external/miniupnpc/receivedata.h mode change 100755 => 100644 external/miniupnpc/setup.py mode change 100755 => 100644 external/miniupnpc/setupmingw32.py mode change 100755 => 100644 external/miniupnpc/testigddescparse.c mode change 100755 => 100644 external/miniupnpc/testminiwget.c mode change 100755 => 100644 external/miniupnpc/testminixml.c mode change 100755 => 100644 external/miniupnpc/testreplyparse/DeletePortMapping.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/DeletePortMapping.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetExternalIPAddress.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetExternalIPAddress.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/SetDefaultConnectionService.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/SetDefaultConnectionService.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/readme.txt mode change 100755 => 100644 external/miniupnpc/testupnpreplyparse.c mode change 100755 => 100644 external/miniupnpc/upnpc.c mode change 100755 => 100644 external/miniupnpc/upnpcommands.c mode change 100755 => 100644 external/miniupnpc/upnpcommands.h mode change 100755 => 100644 external/miniupnpc/upnperrors.c mode change 100755 => 100644 external/miniupnpc/upnperrors.h mode change 100755 => 100644 external/miniupnpc/upnpreplyparse.c mode change 100755 => 100644 external/miniupnpc/upnpreplyparse.h mode change 100755 => 100644 external/miniupnpc/wingenminiupnpcstrings.c diff --git a/external/miniupnpc/.gitignore b/external/miniupnpc/.gitignore new file mode 100644 index 000000000..c5103d2bd --- /dev/null +++ b/external/miniupnpc/.gitignore @@ -0,0 +1,25 @@ +deb_dist/ +build/ +*.o +*.a +*.so +*.dll +*.dylib +Makefile.bak +miniupnpcstrings.h +pythonmodule +pythonmodule3 +upnpc-shared +upnpc-static +minihttptestserver +minixmlvalid +testminiwget +validateminiwget +validateminixml +java/miniupnpc_*.jar +_jnaerator.* +out.errors.txt +jnaerator-*.jar +miniupnpc.h.bak +testupnpreplyparse +validateupnpreplyparse diff --git a/external/miniupnpc/CMakeLists.txt b/external/miniupnpc/CMakeLists.txt old mode 100755 new mode 100644 index 74aaa0509..4631725ec --- a/external/miniupnpc/CMakeLists.txt +++ b/external/miniupnpc/CMakeLists.txt @@ -36,7 +36,7 @@ else (NOT WIN32) endif (NOT WIN32) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - add_definitions (-DMACOSX -D_DARWIN_C_SOURCE) + add_definitions (-D_DARWIN_C_SOURCE) endif () # Set compiler specific build flags @@ -86,16 +86,14 @@ endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS") if (WIN32) set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES - COMPILE_DEFINITIONS STATICLIB + COMPILE_DEFINITIONS MINIUPNP_STATICLIB COMPILE_DEFINITIONS MINIUPNP_EXPORTS ) endif (WIN32) if (WIN32) -# find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32) -# find_library (IPHLPAPI_LIBRARY NAMES iphlpapi) - set(WINSOCK2_LIBRARY ws2_32) - set(IPHLPAPI_LIBRARY iphlpapi) + find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32) + find_library (IPHLPAPI_LIBRARY NAMES iphlpapi) set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS}) #elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris") # find_library (SOCKET_LIBRARY NAMES socket) @@ -167,6 +165,8 @@ install (FILES igd_desc_parse.h upnpreplyparse.h upnperrors.h + miniupnpctypes.h + portlistingparse.h declspec.h DESTINATION include/miniupnpc ) diff --git a/external/miniupnpc/Changelog.txt b/external/miniupnpc/Changelog.txt old mode 100755 new mode 100644 index 53e9a112b..4bfd77cba --- a/external/miniupnpc/Changelog.txt +++ b/external/miniupnpc/Changelog.txt @@ -1,6 +1,21 @@ -$Id: Changelog.txt,v 1.193 2014/02/05 17:26:45 nanard Exp $ +$Id: Changelog.txt,v 1.198 2014/09/11 14:13:31 nanard Exp $ miniUPnP client Changelog. +2014/09/11: + use remoteHost arg of DeletePortMapping + +2014/09/06: + Fix python3 build + +2014/07/01: + Fix parsing of IGD2 root descriptions + +2014/06/10: + rename LIBSPEC to MINIUPNP_LIBSPEC + +2014/05/15: + Add support for IGD2 AddAnyPortMapping and DeletePortMappingRange + 2014/02/05: handle EINPROGRESS after connect() diff --git a/external/miniupnpc/LICENSE b/external/miniupnpc/LICENSE old mode 100755 new mode 100644 index ac89a7516..566f0c9e6 --- a/external/miniupnpc/LICENSE +++ b/external/miniupnpc/LICENSE @@ -1,5 +1,5 @@ MiniUPnPc -Copyright (c) 2005-2011, Thomas BERNARD +Copyright (c) 2005-2014, Thomas BERNARD All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/external/miniupnpc/MANIFEST.in b/external/miniupnpc/MANIFEST.in old mode 100755 new mode 100644 diff --git a/external/miniupnpc/Makefile b/external/miniupnpc/Makefile old mode 100755 new mode 100644 index eaf42f053..5713a8f0a --- a/external/miniupnpc/Makefile +++ b/external/miniupnpc/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.107 2014/01/31 14:19:12 nanard Exp $ +# $Id: Makefile,v 1.110 2014/09/06 08:24:12 nanard Exp $ # MiniUPnP Project # http://miniupnp.free.fr/ # http://miniupnp.tuxfamily.org/ @@ -85,7 +85,7 @@ LIBRARY = libminiupnpc.a ifeq ($(OS), Darwin) SHAREDLIBRARY = libminiupnpc.dylib SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib - CFLAGS := -DMACOSX -D_DARWIN_C_SOURCE $(CFLAGS) + CFLAGS := -D_DARWIN_C_SOURCE $(CFLAGS) else ifeq ($(JARSUFFIX), win32) SHAREDLIBRARY = miniupnpc.dll @@ -174,9 +174,11 @@ validateupnpreplyparse: testupnpreplyparse testupnpreplyparse.sh clean: $(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h + $(RM) $(EXECUTABLES_ADDTESTS) # clean python stuff $(RM) pythonmodule pythonmodule3 $(RM) validateminixml validateminiwget validateupnpreplyparse + $(RM) minihttptestserver minihttptestserver.o $(RM) -r build/ dist/ #python setup.py clean # clean jnaerator stuff diff --git a/external/miniupnpc/Makefile.mingw b/external/miniupnpc/Makefile.mingw old mode 100755 new mode 100644 index 60b3f1b15..7b00650fc --- a/external/miniupnpc/Makefile.mingw +++ b/external/miniupnpc/Makefile.mingw @@ -50,11 +50,11 @@ dll/upnpc.o: upnpc.o echo $@ generated with $< .c.o: - $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $< + $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< $(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o dll/$@ $< upnpc.o: - $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $< + $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< $(CC) $(CFLAGS) -c -o dll/$@ $< # --enable-stdcall-fixup diff --git a/external/miniupnpc/README b/external/miniupnpc/README old mode 100755 new mode 100644 diff --git a/external/miniupnpc/VERSION b/external/miniupnpc/VERSION old mode 100755 new mode 100644 diff --git a/external/miniupnpc/apiversions.txt b/external/miniupnpc/apiversions.txt old mode 100755 new mode 100644 diff --git a/external/miniupnpc/bsdqueue.h b/external/miniupnpc/bsdqueue.h old mode 100755 new mode 100644 diff --git a/external/miniupnpc/codelength.h b/external/miniupnpc/codelength.h old mode 100755 new mode 100644 index d342bd141..50d460679 --- a/external/miniupnpc/codelength.h +++ b/external/miniupnpc/codelength.h @@ -1,4 +1,4 @@ -/* $Id: codelength.h,v 1.4 2012/09/27 15:40:29 nanard Exp $ */ +/* $Id: codelength.h,v 1.3 2011/07/30 13:10:05 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2005-2011 Thomas Bernard diff --git a/external/miniupnpc/connecthostport.c b/external/miniupnpc/connecthostport.c old mode 100755 new mode 100644 index d66ae315f..98f72535d --- a/external/miniupnpc/connecthostport.c +++ b/external/miniupnpc/connecthostport.c @@ -1,4 +1,4 @@ -/* $Id: connecthostport.c,v 1.13 2014/03/31 12:36:36 nanard Exp $ */ +/* $Id: connecthostport.c,v 1.12 2014/02/05 17:26:46 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2010-2014 Thomas Bernard @@ -35,7 +35,6 @@ #ifndef USE_GETHOSTBYNAME #include #include -#include #endif /* #ifndef USE_GETHOSTBYNAME */ #endif /* #else _WIN32 */ diff --git a/external/miniupnpc/connecthostport.h b/external/miniupnpc/connecthostport.h old mode 100755 new mode 100644 index 56941d6fa..f3b2d2a84 --- a/external/miniupnpc/connecthostport.h +++ b/external/miniupnpc/connecthostport.h @@ -1,4 +1,4 @@ -/* $Id: connecthostport.h,v 1.3 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: connecthostport.h,v 1.2 2012/06/23 22:32:33 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ * Author: Thomas Bernard diff --git a/external/miniupnpc/declspec.h b/external/miniupnpc/declspec.h old mode 100755 new mode 100644 index 77299693b..560aa3a6c --- a/external/miniupnpc/declspec.h +++ b/external/miniupnpc/declspec.h @@ -1,19 +1,19 @@ #ifndef DECLSPEC_H_INCLUDED #define DECLSPEC_H_INCLUDED -#if defined(_WIN32) && !defined(STATICLIB) +#if defined(_WIN32) && !defined(MINIUPNP_STATICLIB) /* for windows dll */ #ifdef MINIUPNP_EXPORTS - #define LIBSPEC __declspec(dllexport) + #define MINIUPNP_LIBSPEC __declspec(dllexport) #else - #define LIBSPEC __declspec(dllimport) + #define MINIUPNP_LIBSPEC __declspec(dllimport) #endif #else #if defined(__GNUC__) && __GNUC__ >= 4 /* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */ - #define LIBSPEC __attribute__ ((visibility ("default"))) + #define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default"))) #else - #define LIBSPEC + #define MINIUPNP_LIBSPEC #endif #endif diff --git a/external/miniupnpc/igd_desc_parse.c b/external/miniupnpc/igd_desc_parse.c old mode 100755 new mode 100644 index 6c3e65677..0eaf21b6a --- a/external/miniupnpc/igd_desc_parse.c +++ b/external/miniupnpc/igd_desc_parse.c @@ -1,8 +1,8 @@ -/* $Id: igd_desc_parse.c,v 1.14 2011/04/11 09:19:24 nanard Exp $ */ +/* $Id: igd_desc_parse.c,v 1.15 2014/07/01 13:01:17 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard - * Copyright (c) 2005-2010 Thomas Bernard + * Copyright (c) 2005-2014 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -26,6 +26,8 @@ void IGDstartelt(void * d, const char * name, int l) } } +#define COMPARE(str, cstr) (0==memcmp(str, cstr, sizeof(cstr) - 1)) + /* End element handler : * update nesting level counter and update parser state if * service element is parsed */ @@ -36,23 +38,16 @@ void IGDendelt(void * d, const char * name, int l) /*printf("endelt %2d %.*s\n", datas->level, l, name);*/ if( (l==7) && !memcmp(name, "service", l) ) { - /* - if( datas->state < 1 - && !strcmp(datas->servicetype, - // "urn:schemas-upnp-org:service:WANIPConnection:1") ) - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) - datas->state ++; - */ - if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) { + if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) { memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1")) { + } else if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANIPv6FirewallControl:")) { memcpy(&datas->IPv6FC, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPConnection:1") - || 0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANPPPConnection:1") ) { + } else if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANIPConnection:") + || COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANPPPConnection:") ) { if(datas->first.servicetype[0] == '\0') { memcpy(&datas->first, &datas->tmp, sizeof(struct IGDdatas_service)); } else { diff --git a/external/miniupnpc/igd_desc_parse.h b/external/miniupnpc/igd_desc_parse.h old mode 100755 new mode 100644 index 0a49b019d..f5864b5c1 --- a/external/miniupnpc/igd_desc_parse.h +++ b/external/miniupnpc/igd_desc_parse.h @@ -1,4 +1,4 @@ -/* $Id: igd_desc_parse.h,v 1.11 2012/10/16 16:49:02 nanard Exp $ */ +/* $Id: igd_desc_parse.h,v 1.10 2011/04/11 09:19:24 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard diff --git a/external/miniupnpc/java/.gitignore b/external/miniupnpc/java/.gitignore new file mode 100644 index 000000000..8e9e79486 --- /dev/null +++ b/external/miniupnpc/java/.gitignore @@ -0,0 +1,2 @@ +*.class +*.jar diff --git a/external/miniupnpc/java/JavaBridgeTest.java b/external/miniupnpc/java/JavaBridgeTest.java old mode 100755 new mode 100644 diff --git a/external/miniupnpc/man3/miniupnpc.3 b/external/miniupnpc/man3/miniupnpc.3 old mode 100755 new mode 100644 diff --git a/external/miniupnpc/mingw32make.bat b/external/miniupnpc/mingw32make.bat old mode 100755 new mode 100644 diff --git a/external/miniupnpc/minihttptestserver.c b/external/miniupnpc/minihttptestserver.c old mode 100755 new mode 100644 index b71936117..fb779650b --- a/external/miniupnpc/minihttptestserver.c +++ b/external/miniupnpc/minihttptestserver.c @@ -1,7 +1,7 @@ -/* $Id: minihttptestserver.c,v 1.13 2012/05/29 13:03:07 nanard Exp $ */ +/* $Id: minihttptestserver.c,v 1.16 2014/04/01 15:08:28 nanard Exp $ */ /* Project : miniUPnP * Author : Thomas Bernard - * Copyright (c) 2011-2012 Thomas Bernard + * Copyright (c) 2011-2014 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ @@ -28,20 +28,20 @@ volatile sig_atomic_t child_to_wait_for = 0; */ void handle_signal_chld(int sig) { - printf("handle_signal_chld(%d)\n", sig); + (void)sig; + /* printf("handle_signal_chld(%d)\n", sig); */ ++child_to_wait_for; } /** * signal handler for SIGINT (CRTL C) */ -#if 0 void handle_signal_int(int sig) { - printf("handle_signal_int(%d)\n", sig); + (void)sig; + /* printf("handle_signal_int(%d)\n", sig); */ quit = 1; } -#endif /** * build a text/plain content of the specified length @@ -94,7 +94,8 @@ void build_crap(char * p, int n) * build chunked response. * return a malloc'ed buffer */ -char * build_chunked_response(int content_length, int * response_len) { +char * build_chunked_response(int content_length, int * response_len) +{ char * response_buffer; char * content_buffer; int buffer_length; @@ -141,7 +142,115 @@ char * build_chunked_response(int content_length, int * response_len) { return response_buffer; } -enum modes { MODE_INVALID, MODE_CHUNKED, MODE_ADDCRAP, MODE_NORMAL }; +/* favicon.ico generator */ +#ifdef OLD_HEADER +#define FAVICON_LENGTH (6 + 16 + 12 + 8 + 32 * 4) +#else +#define FAVICON_LENGTH (6 + 16 + 40 + 8 + 32 * 4) +#endif +void build_favicon_content(char * p, int n) +{ + int i; + if(n < FAVICON_LENGTH) + return; + /* header : 6 bytes */ + *p++ = 0; + *p++ = 0; + *p++ = 1; /* type : ICO */ + *p++ = 0; + *p++ = 1; /* number of images in file */ + *p++ = 0; + /* image directory (1 entry) : 16 bytes */ + *p++ = 16; /* width */ + *p++ = 16; /* height */ + *p++ = 2; /* number of colors in the palette. 0 = no palette */ + *p++ = 0; /* reserved */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ +#ifdef OLD_HEADER + *p++ = 12 + 8 + 32 * 4; /* bmp size */ +#else + *p++ = 40 + 8 + 32 * 4; /* bmp size */ +#endif + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 6 + 16; /* bmp offset */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + /* BMP */ +#ifdef OLD_HEADER + /* BITMAPCOREHEADER */ + *p++ = 12; /* size of this header */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16; /* width */ + *p++ = 0; /* " */ + *p++ = 16 * 2; /* height x 2 ! */ + *p++ = 0; /* " */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ +#else + /* BITMAPINFOHEADER */ + *p++ = 40; /* size of this header */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16; /* width */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16 * 2; /* height x 2 ! */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ + /* compression method, image size, ppm x, ppm y */ + /* colors in the palette ? */ + /* important colors */ + for(i = 4 * 6; i > 0; --i) + *p++ = 0; +#endif + /* palette */ + *p++ = 0; /* b */ + *p++ = 0; /* g */ + *p++ = 0; /* r */ + *p++ = 0; /* reserved */ + *p++ = 255; /* b */ + *p++ = 255; /* g */ + *p++ = 255; /* r */ + *p++ = 0; /* reserved */ + /* pixel data */ + for(i = 16; i > 0; --i) { + if(i & 1) { + *p++ = 0125; + *p++ = 0125; + } else { + *p++ = 0252; + *p++ = 0252; + } + *p++ = 0; + *p++ = 0; + } + /* Opacity MASK */ + for(i = 16 * 4; i > 0; --i) { + *p++ = 0; + } +} + +enum modes { + MODE_INVALID, MODE_CHUNKED, MODE_ADDCRAP, MODE_NORMAL, MODE_FAVICON +}; + const struct { const enum modes mode; const char * text; @@ -149,6 +258,7 @@ const struct { {MODE_CHUNKED, "chunked"}, {MODE_ADDCRAP, "addcrap"}, {MODE_NORMAL, "normal"}, + {MODE_FAVICON, "favicon.ico"}, {MODE_INVALID, NULL} }; @@ -201,6 +311,8 @@ void handle_http_connection(int c) request_buffer + request_len, sizeof(request_buffer) - request_len); if(n < 0) { + if(errno == EINTR) + continue; perror("read"); return; } else if(n==0) { @@ -219,6 +331,7 @@ void handle_http_connection(int c) } if(!headers_found) { /* error */ + printf("no HTTP header found in the request\n"); return; } printf("headers :\n%.*s", request_len, request_buffer); @@ -292,6 +405,8 @@ void handle_http_connection(int c) case MODE_ADDCRAP: response_len = content_length+256; response_buffer = malloc(response_len); + if(!response_buffer) + break; n = snprintf(response_buffer, response_len, "HTTP/1.1 200 OK\r\n" "Server: minihttptestserver\r\n" @@ -303,9 +418,27 @@ void handle_http_connection(int c) build_content(response_buffer + n, content_length); build_crap(response_buffer + n + content_length, CRAP_LENGTH); break; + case MODE_FAVICON: + content_length = FAVICON_LENGTH; + response_len = content_length + 256; + response_buffer = malloc(response_len); + if(!response_buffer) + break; + n = snprintf(response_buffer, response_len, + "HTTP/1.1 200 OK\r\n" + "Server: minihttptestserver\r\n" + "Content-Type: image/vnd.microsoft.icon\r\n" + "Content-Length: %d\r\n" + "\r\n", content_length); + /* image/x-icon */ + build_favicon_content(response_buffer + n, content_length); + response_len = content_length + n; + break; default: response_len = content_length+256; response_buffer = malloc(response_len); + if(!response_buffer) + break; n = snprintf(response_buffer, response_len, "HTTP/1.1 200 OK\r\n" "Server: minihttptestserver\r\n" @@ -338,6 +471,7 @@ int main(int argc, char * * argv) { int child = 0; int status; const char * expected_file_name = NULL; + struct sigaction sa; for(i = 1; i < argc; i++) { if(argv[i][0] == '-') { @@ -364,10 +498,21 @@ int main(int argc, char * * argv) { } srand(time(NULL)); - signal(SIGCHLD, handle_signal_chld); -#if 0 - signal(SIGINT, handle_signal_int); -#endif + + memset(&sa, 0, sizeof(struct sigaction)); + + /*signal(SIGCHLD, handle_signal_chld);*/ + sa.sa_handler = handle_signal_chld; + if(sigaction(SIGCHLD, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } + /*signal(SIGINT, handle_signal_int);*/ + sa.sa_handler = handle_signal_int; + if(sigaction(SIGINT, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } s = socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0); if(s < 0) { @@ -442,12 +587,12 @@ int main(int argc, char * * argv) { } --child_to_wait_for; } - /* TODO : add a select() call in order to handle the case - * when a signal is caught */ client_addrlen = sizeof(struct sockaddr_storage); c = accept(s, (struct sockaddr *)&client_addr, &client_addrlen); if(c < 0) { + if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) + continue; perror("accept"); return 1; } diff --git a/external/miniupnpc/minisoap.c b/external/miniupnpc/minisoap.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/minisoap.h b/external/miniupnpc/minisoap.h old mode 100755 new mode 100644 index 14c859d1e..60554f5c3 --- a/external/miniupnpc/minisoap.h +++ b/external/miniupnpc/minisoap.h @@ -1,4 +1,4 @@ -/* $Id: minisoap.h,v 1.5 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005 Thomas Bernard diff --git a/external/miniupnpc/minissdpc.c b/external/miniupnpc/minissdpc.c old mode 100755 new mode 100644 index c4913fb89..8b7421b00 --- a/external/miniupnpc/minissdpc.c +++ b/external/miniupnpc/minissdpc.c @@ -1,4 +1,4 @@ -/* $Id: minissdpc.c,v 1.16 2012/03/05 19:42:46 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.15 2012/01/21 13:30:31 nanard Exp $ */ /* Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD @@ -46,7 +46,7 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath) { struct UPNPDev * tmp; struct UPNPDev * devlist = NULL; - unsigned char buffer[2048]; + unsigned char buffer[4*1024]; /* is that enough ? */ ssize_t n; unsigned char * p; unsigned char * url; diff --git a/external/miniupnpc/minissdpc.h b/external/miniupnpc/minissdpc.h old mode 100755 new mode 100644 index 915b0026f..2516f487a --- a/external/miniupnpc/minissdpc.h +++ b/external/miniupnpc/minissdpc.h @@ -1,4 +1,4 @@ -/* $Id: minissdpc.h,v 1.2 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minissdpc.h,v 1.1 2007/08/31 15:15:33 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/external/miniupnpc/miniupnpc.c b/external/miniupnpc/miniupnpc.c old mode 100755 new mode 100644 index f661c2e6f..1da230f52 --- a/external/miniupnpc/miniupnpc.c +++ b/external/miniupnpc/miniupnpc.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.c,v 1.117 2014/01/31 14:19:13 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.116 2014/01/31 14:09:03 nanard Exp $ */ /* Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD @@ -6,7 +6,7 @@ * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #define __EXTENSIONS__ 1 -#if !defined(MACOSX) && !defined(__sun) +#if !defined(__APPLE__) && !defined(__sun) #if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) #ifndef __cplusplus #define _XOPEN_SOURCE 600 @@ -17,7 +17,7 @@ #endif #endif -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(MACOSX) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) +#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) #define HAS_IP_MREQN #endif @@ -70,6 +70,9 @@ /* Amiga OS specific stuff */ #define TIMEVAL struct timeval #endif +#ifdef __GNU__ +#define MAXHOSTNAMELEN 64 +#endif #if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN) @@ -106,7 +109,7 @@ struct ip_mreqn #define SERVICEPREFIX2 'u' /* root description parsing */ -LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) +MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) { struct xmlparser parser; /* xmlparser object */ @@ -335,7 +338,7 @@ parseMSEARCHReply(const char * reply, int size, * no devices was found. * It is up to the caller to free the chained list * delay is in millisecond (poll) */ -LIBSPEC struct UPNPDev * +MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int sameport, int ipv6, @@ -718,7 +721,7 @@ upnpDiscover(int delay, const char * multicastif, /* freeUPNPDevlist() should be used to * free the chained list returned by upnpDiscover() */ -LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist) +MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist) { struct UPNPDev * next; while(devlist) @@ -754,7 +757,7 @@ url_cpy_or_cat(char * dst, const char * src, int n) /* Prepare the Urls for usage... */ -LIBSPEC void +MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, const char * descURL, unsigned int scope_id) { @@ -844,7 +847,7 @@ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, #endif } -LIBSPEC void +MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls * urls) { if(!urls) @@ -891,7 +894,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data) * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to * free allocated memory. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, diff --git a/external/miniupnpc/miniupnpc.def b/external/miniupnpc/miniupnpc.def old mode 100755 new mode 100644 index 334335606..60e0bbe42 --- a/external/miniupnpc/miniupnpc.def +++ b/external/miniupnpc/miniupnpc.def @@ -24,7 +24,9 @@ EXPORTS UPNP_GetExternalIPAddress UPNP_GetLinkLayerMaxBitRates UPNP_AddPortMapping + UPNP_AddAnyPortMapping UPNP_DeletePortMapping + UPNP_DeletePortMappingRange UPNP_GetPortMappingNumberOfEntries UPNP_GetSpecificPortMappingEntry UPNP_GetGenericPortMappingEntry diff --git a/external/miniupnpc/miniupnpc.h b/external/miniupnpc/miniupnpc.h old mode 100755 new mode 100644 index 3af109cf1..304de90f2 --- a/external/miniupnpc/miniupnpc.h +++ b/external/miniupnpc/miniupnpc.h @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.h,v 1.35 2014/01/31 13:26:34 nanard Exp $ */ +/* $Id: miniupnpc.h,v 1.34 2014/01/31 13:18:25 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ * Author: Thomas Bernard @@ -18,7 +18,7 @@ #define UPNPDISCOVER_MEMORY_ERROR (-102) /* versions : */ -#define MINIUPNPC_VERSION "1.9.20140401" +#define MINIUPNPC_VERSION "1.9" #define MINIUPNPC_API_VERSION 10 #ifdef __cplusplus @@ -54,19 +54,19 @@ struct UPNPDev { * multicast interface for sending SSDP discover packets. * If sameport is not null, SSDP packets will be sent from the source port * 1900 (same as destination port) otherwise system assign a source port. */ -LIBSPEC struct UPNPDev * +MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int sameport, int ipv6, int * error); /* freeUPNPDevlist() * free list returned by upnpDiscover() */ -LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); +MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); /* parserootdesc() : * parse root XML description of a UPnP device and fill the IGDdatas * structure. */ -LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); +MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); /* structure used to get fast access to urls * controlURL: controlURL of the WANIPConnection @@ -94,7 +94,7 @@ struct UPNPUrls { * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to * free allocated memory. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, @@ -105,21 +105,21 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, * return value : * 0 - Not ok * 1 - OK */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen); -LIBSPEC void +MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *, unsigned int); -LIBSPEC void +MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls *); /* return 0 or 1 */ -LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); +MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); #ifdef __cplusplus diff --git a/external/miniupnpc/miniupnpcmodule.c b/external/miniupnpc/miniupnpcmodule.c old mode 100755 new mode 100644 index 4654c9870..ecddf7e84 --- a/external/miniupnpc/miniupnpcmodule.c +++ b/external/miniupnpc/miniupnpcmodule.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpcmodule.c,v 1.22 2014/01/31 13:18:25 nanard Exp $*/ +/* $Id: miniupnpcmodule.c,v 1.24 2014/06/10 09:48:11 nanard Exp $*/ /* Project : miniupnp * Author : Thomas BERNARD * website : http://miniupnp.tuxfamily.org/ @@ -6,7 +6,7 @@ * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include -#define STATICLIB +#define MINIUPNP_STATICLIB #include "structmember.h" #include "miniupnpc.h" #include "upnpcommands.h" @@ -265,6 +265,42 @@ Py_END_ALLOW_THREADS } } +/* AddAnyPortMapping(externalPort, protocol, internalHost, internalPort, desc, + * remoteHost) + * protocol is 'UDP' or 'TCP' */ +static PyObject * +UPnP_addanyportmapping(UPnPObject *self, PyObject *args) +{ + char extPort[6]; + unsigned short ePort; + char inPort[6]; + unsigned short iPort; + char reservedPort[6]; + const char * proto; + const char * host; + const char * desc; + const char * remoteHost; + const char * leaseDuration = "0"; + int r; + if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto, &host, &iPort, &desc, &remoteHost)) + return NULL; +Py_BEGIN_ALLOW_THREADS + sprintf(extPort, "%hu", ePort); + sprintf(inPort, "%hu", iPort); + r = UPNP_AddAnyPortMapping(self->urls.controlURL, self->data.first.servicetype, + extPort, inPort, host, desc, proto, + remoteHost, leaseDuration, reservedPort); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("i", atoi(reservedPort)); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } +} + + /* DeletePortMapping(extPort, proto, removeHost='') * proto = 'UDP', 'TCP' */ static PyObject * @@ -291,6 +327,37 @@ Py_END_ALLOW_THREADS } } +/* DeletePortMappingRange(extPort, proto, removeHost='') + * proto = 'UDP', 'TCP' */ +static PyObject * +UPnP_deleteportmappingrange(UPnPObject *self, PyObject *args) +{ + char extPortStart[6]; + unsigned short ePortStart; + char extPortEnd[6]; + unsigned short ePortEnd; + const char * proto; + unsigned char manage; + char manageStr[1]; + int r; + if(!PyArg_ParseTuple(args, "HHsb", &ePortStart, &ePortEnd, &proto, &manage)) + return NULL; +Py_BEGIN_ALLOW_THREADS + sprintf(extPortStart, "%hu", ePortStart); + sprintf(extPortEnd, "%hu", ePortEnd); + sprintf(manageStr, "%hhu", manage); + r = UPNP_DeletePortMappingRange(self->urls.controlURL, self->data.first.servicetype, + extPortStart, extPortEnd, proto, manageStr); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + Py_RETURN_TRUE; + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } +} + static PyObject * UPnP_getportmappingnumberofentries(UPnPObject *self) { @@ -429,9 +496,15 @@ static PyMethodDef UPnP_methods[] = { {"addportmapping", (PyCFunction)UPnP_addportmapping, METH_VARARGS, "add a port mapping" }, + {"addanyportmapping", (PyCFunction)UPnP_addanyportmapping, METH_VARARGS, + "add a port mapping, IGD to select alternative if necessary" + }, {"deleteportmapping", (PyCFunction)UPnP_deleteportmapping, METH_VARARGS, "delete a port mapping" }, + {"deleteportmappingrange", (PyCFunction)UPnP_deleteportmappingrange, METH_VARARGS, + "delete a range of port mappings" + }, {"getportmappingnumberofentries", (PyCFunction)UPnP_getportmappingnumberofentries, METH_NOARGS, "-- non standard --" }, @@ -526,7 +599,11 @@ initminiupnpc(void) UPnPType.tp_new = PyType_GenericNew; #endif if (PyType_Ready(&UPnPType) < 0) +#if PY_MAJOR_VERSION >= 3 + return 0; +#else return; +#endif #if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&moduledef); @@ -537,7 +614,7 @@ initminiupnpc(void) Py_INCREF(&UPnPType); PyModule_AddObject(m, "UPnP", (PyObject *)&UPnPType); - + #if PY_MAJOR_VERSION >= 3 return m; #endif diff --git a/external/miniupnpc/miniupnpcstrings.h.cmake b/external/miniupnpc/miniupnpcstrings.h.cmake old mode 100755 new mode 100644 diff --git a/external/miniupnpc/miniupnpcstrings.h.in b/external/miniupnpc/miniupnpcstrings.h.in old mode 100755 new mode 100644 index c32e3a133..93b8cbc66 --- a/external/miniupnpc/miniupnpcstrings.h.in +++ b/external/miniupnpc/miniupnpcstrings.h.in @@ -1,4 +1,4 @@ -/* $Id: miniupnpcstrings.h.in,v 1.5 2012/10/16 16:48:26 nanard Exp $ */ +/* $Id: miniupnpcstrings.h.in,v 1.4 2011/01/04 11:41:53 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/external/miniupnpc/miniupnpctypes.h b/external/miniupnpc/miniupnpctypes.h old mode 100755 new mode 100644 index 591c32fb6..307ce3969 --- a/external/miniupnpc/miniupnpctypes.h +++ b/external/miniupnpc/miniupnpctypes.h @@ -1,4 +1,4 @@ -/* $Id: miniupnpctypes.h,v 1.2 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */ /* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org * Author : Thomas Bernard * Copyright (c) 2011 Thomas Bernard diff --git a/external/miniupnpc/miniwget.c b/external/miniupnpc/miniwget.c old mode 100755 new mode 100644 index 813db9324..4a4a9393d --- a/external/miniupnpc/miniwget.c +++ b/external/miniupnpc/miniwget.c @@ -15,7 +15,6 @@ #include #include #define MAXHOSTNAMELEN 64 -#define MIN(x,y) (((x)<(y))?(x):(y)) #define snprintf _snprintf #define socklen_t int #ifndef strncasecmp @@ -40,9 +39,14 @@ #include #define closesocket close #endif /* #else _WIN32 */ -#if defined(__sun) || defined(sun) +#ifdef __GNU__ +#define MAXHOSTNAMELEN 64 +#endif /* __GNU__ */ + +#ifndef MIN #define MIN(x,y) (((x)<(y))?(x):(y)) -#endif +#endif /* MIN */ + #include "miniupnpcstrings.h" #include "miniwget.h" diff --git a/external/miniupnpc/miniwget.h b/external/miniupnpc/miniwget.h old mode 100755 new mode 100644 index 31bcea322..04a8de2db --- a/external/miniupnpc/miniwget.h +++ b/external/miniupnpc/miniwget.h @@ -1,4 +1,4 @@ -/* $Id: miniwget.h,v 1.8 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: miniwget.h,v 1.7 2012/06/23 22:35:59 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005-2012 Thomas Bernard @@ -14,11 +14,11 @@ extern "C" { #endif -LIBSPEC void * getHTTPResponse(int s, int * size); +MINIUPNP_LIBSPEC void * getHTTPResponse(int s, int * size); -LIBSPEC void * miniwget(const char *, int *, unsigned int); +MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int); -LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int); +MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int); int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); diff --git a/external/miniupnpc/minixml.c b/external/miniupnpc/minixml.c old mode 100755 new mode 100644 index 3e201ec2c..1f2227343 --- a/external/miniupnpc/minixml.c +++ b/external/miniupnpc/minixml.c @@ -1,4 +1,4 @@ -/* $Id: minixml.c,v 1.11 2014/02/03 15:54:12 nanard Exp $ */ +/* $Id: minixml.c,v 1.10 2012/03/05 19:42:47 nanard Exp $ */ /* minixml.c : the minimum size a xml parser can be ! */ /* Project : miniupnp * webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ diff --git a/external/miniupnpc/minixml.h b/external/miniupnpc/minixml.h old mode 100755 new mode 100644 index 9f43aa48c..19e6f513b --- a/external/miniupnpc/minixml.h +++ b/external/miniupnpc/minixml.h @@ -1,4 +1,4 @@ -/* $Id: minixml.h,v 1.7 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minixml.h,v 1.6 2006/11/30 11:47:21 nanard Exp $ */ /* minimal xml parser * * Project : miniupnp diff --git a/external/miniupnpc/minixmlvalid.c b/external/miniupnpc/minixmlvalid.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/msvc/miniupnpc.sln b/external/miniupnpc/msvc/miniupnpc.sln old mode 100755 new mode 100644 diff --git a/external/miniupnpc/msvc/miniupnpc.vcproj b/external/miniupnpc/msvc/miniupnpc.vcproj old mode 100755 new mode 100644 index 12a55aaff..ca7a0821a --- a/external/miniupnpc/msvc/miniupnpc.vcproj +++ b/external/miniupnpc/msvc/miniupnpc.vcproj @@ -41,7 +41,7 @@ controlURL, - data->first.servicetype, - externalIPAddress); - if(externalIPAddress[0]) - printf("ExternalIPAddress = %s\n", externalIPAddress); - else - printf("GetExternalIPAddress failed.\n"); - - r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype, - eport, iport, iaddr, description, - proto, 0, leaseDuration); + r = UPNP_GetExternalIPAddress(urls->controlURL, + data->first.servicetype, + externalIPAddress); if(r!=UPNPCOMMAND_SUCCESS) - printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", - eport, iport, iaddr, r, strupnperror(r)); + printf("GetExternalIPAddress failed.\n"); + else + printf("ExternalIPAddress = %s\n", externalIPAddress); + + if (addAny) { + r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype, + eport, iport, iaddr, description, + proto, 0, leaseDuration, reservedPort); + if(r==UPNPCOMMAND_SUCCESS) + eport = reservedPort; + else + printf("AddAnyPortMapping(%s, %s, %s) failed with code %d (%s)\n", + eport, iport, iaddr, r, strupnperror(r)); + } else { + r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype, + eport, iport, iaddr, description, + proto, 0, leaseDuration); + if(r!=UPNPCOMMAND_SUCCESS) + printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + eport, iport, iaddr, r, strupnperror(r)); + } r = UPNP_GetSpecificPortMappingEntry(urls->controlURL, - data->first.servicetype, - eport, proto, NULL/*remoteHost*/, - intClient, intPort, NULL/*desc*/, - NULL/*enabled*/, duration); + data->first.servicetype, + eport, proto, NULL/*remoteHost*/, + intClient, intPort, NULL/*desc*/, + NULL/*enabled*/, duration); if(r!=UPNPCOMMAND_SUCCESS) printf("GetSpecificPortMappingEntry() failed with code %d (%s)\n", r, strupnperror(r)); - - if(intClient[0]) { + else { printf("InternalIP:Port = %s:%s\n", intClient, intPort); printf("external %s:%s %s is redirected to internal %s:%s (duration=%s)\n", externalIPAddress, eport, proto, intClient, intPort, duration); @@ -283,8 +295,9 @@ static void SetRedirectAndTest(struct UPNPUrls * urls, static void RemoveRedirect(struct UPNPUrls * urls, struct IGDdatas * data, - const char * eport, - const char * proto) + const char * eport, + const char * proto, + const char * remoteHost) { int r; if(!proto || !eport) @@ -298,10 +311,36 @@ RemoveRedirect(struct UPNPUrls * urls, fprintf(stderr, "protocol invalid\n"); return; } - r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, 0); + r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, remoteHost); printf("UPNP_DeletePortMapping() returned : %d\n", r); } +static void +RemoveRedirectRange(struct UPNPUrls * urls, + struct IGDdatas * data, + const char * ePortStart, char const * ePortEnd, + const char * proto, const char * manage) +{ + int r; + + if (!manage) + manage = "0"; + + if(!proto || !ePortStart || !ePortEnd) + { + fprintf(stderr, "invalid arguments\n"); + return; + } + proto = protofix(proto); + if(!proto) + { + fprintf(stderr, "protocol invalid\n"); + return; + } + r = UPNP_DeletePortMappingRange(urls->controlURL, data->first.servicetype, ePortStart, ePortEnd, proto, manage); + printf("UPNP_DeletePortMappingRange() returned : %d\n", r); +} + /* IGD:2, functions for service WANIPv6FirewallControl:1 */ static void GetFirewallStatus(struct UPNPUrls * urls, struct IGDdatas * data) { @@ -546,10 +585,12 @@ int main(int argc, char ** argv) || (command == 'D' && commandargc<1)) { fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration]\n\t\tAdd port redirection\n", argv[0]); - fprintf(stderr, " \t%s [options] -d external_port protocol [port2 protocol2] [...]\n\t\tDelete port redirection\n", argv[0]); + fprintf(stderr, " \t%s [options] -d external_port protocol \n\t\tDelete port redirection\n", argv[0]); fprintf(stderr, " \t%s [options] -s\n\t\tGet Connection status\n", argv[0]); fprintf(stderr, " \t%s [options] -l\n\t\tList redirections\n", argv[0]); - fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings, IGD v2)\n", argv[0]); + fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings (for IGD:2 only)\n", argv[0]); + fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]); + fprintf(stderr, " \t%s [options] -N external_port_start external_port_end protocol [manage]\n\t\tDelete range of port redirections (for IGD:2 only)\n", argv[0]); fprintf(stderr, " \t%s [options] -r port1 protocol1 [port2 protocol2] [...]\n\t\tAdd all redirections to the current host\n", argv[0]); fprintf(stderr, " \t%s [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time\n\t\tAdd Pinhole (for IGD:2 only)\n", argv[0]); fprintf(stderr, " \t%s [options] -U uniqueID new_lease_time\n\t\tUpdate Pinhole (for IGD:2 only)\n", argv[0]); @@ -631,16 +672,28 @@ int main(int argc, char ** argv) break; case 'a': SetRedirectAndTest(&urls, &data, - commandargv[0], commandargv[1], - commandargv[2], commandargv[3], - (commandargc > 4)?commandargv[4]:"0", - description); + commandargv[0], commandargv[1], + commandargv[2], commandargv[3], + (commandargc > 4)?commandargv[4]:"0", + description, 0); break; case 'd': - for(i=0; i 2 ? commandargv[2] : NULL); + break; + case 'n': /* aNy */ + SetRedirectAndTest(&urls, &data, + commandargv[0], commandargv[1], + commandargv[2], commandargv[3], + (commandargc > 4)?commandargv[4]:"0", + description, 1); + break; + case 'N': + if (commandargc < 3) + fprintf(stderr, "too few arguments\n"); + + RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2], + commandargc > 3 ? commandargv[3] : NULL); break; case 's': GetConnectionStatus(&urls, &data); @@ -650,9 +703,9 @@ int main(int argc, char ** argv) { /*printf("port %s protocol %s\n", argv[i], argv[i+1]);*/ SetRedirectAndTest(&urls, &data, - lanaddr, commandargv[i], - commandargv[i], commandargv[i+1], "0", - description); + lanaddr, commandargv[i], + commandargv[i], commandargv[i+1], "0", + description, 0); } break; case 'A': diff --git a/external/miniupnpc/upnpcommands.c b/external/miniupnpc/upnpcommands.c old mode 100755 new mode 100644 index ad6978105..42dacebb0 --- a/external/miniupnpc/upnpcommands.c +++ b/external/miniupnpc/upnpcommands.c @@ -20,7 +20,7 @@ my_atoui(const char * s) /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesSent(const char * controlURL, const char * servicetype) { @@ -44,7 +44,7 @@ UPNP_GetTotalBytesSent(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesReceived(const char * controlURL, const char * servicetype) { @@ -68,7 +68,7 @@ UPNP_GetTotalBytesReceived(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsSent(const char * controlURL, const char * servicetype) { @@ -92,7 +92,7 @@ UPNP_GetTotalPacketsSent(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsReceived(const char * controlURL, const char * servicetype) { @@ -116,7 +116,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, /* UPNP_GetStatusInfo() call the corresponding UPNP method * returns the current status and uptime */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetStatusInfo(const char * controlURL, const char * servicetype, char * status, @@ -181,7 +181,7 @@ UPNP_GetStatusInfo(const char * controlURL, /* UPNP_GetConnectionTypeInfo() call the corresponding UPNP method * returns the connection type */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetConnectionTypeInfo(const char * controlURL, const char * servicetype, char * connectionType) @@ -224,7 +224,7 @@ UPNP_GetConnectionTypeInfo(const char * controlURL, * One of the values can be null * Note : GetLinkLayerMaxBitRates belongs to WANPPPConnection:1 only * We can use the GetCommonLinkProperties from WANCommonInterfaceConfig:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetLinkLayerMaxBitRates(const char * controlURL, const char * servicetype, unsigned int * bitrateDown, @@ -293,7 +293,7 @@ UPNP_GetLinkLayerMaxBitRates(const char * controlURL, * 402 Invalid Args - See UPnP Device Architecture section on Control. * 501 Action Failed - See UPnP Device Architecture section on Control. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetExternalIPAddress(const char * controlURL, const char * servicetype, char * extIpAdd) @@ -333,15 +333,15 @@ UPNP_GetExternalIPAddress(const char * controlURL, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration) + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration) { struct UPNParg * AddPortMappingArgs; char * buffer; @@ -394,7 +394,74 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int +UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration, + char * reservedPort) +{ + struct UPNParg * AddPortMappingArgs; + char * buffer; + int bufsize; + struct NameValueParserData pdata; + const char * resVal; + int ret; + + if(!inPort || !inClient || !proto || !extPort) + return UPNPCOMMAND_INVALID_ARGS; + + AddPortMappingArgs = calloc(9, sizeof(struct UPNParg)); + AddPortMappingArgs[0].elt = "NewRemoteHost"; + AddPortMappingArgs[0].val = remoteHost; + AddPortMappingArgs[1].elt = "NewExternalPort"; + AddPortMappingArgs[1].val = extPort; + AddPortMappingArgs[2].elt = "NewProtocol"; + AddPortMappingArgs[2].val = proto; + AddPortMappingArgs[3].elt = "NewInternalPort"; + AddPortMappingArgs[3].val = inPort; + AddPortMappingArgs[4].elt = "NewInternalClient"; + AddPortMappingArgs[4].val = inClient; + AddPortMappingArgs[5].elt = "NewEnabled"; + AddPortMappingArgs[5].val = "1"; + AddPortMappingArgs[6].elt = "NewPortMappingDescription"; + AddPortMappingArgs[6].val = desc?desc:"libminiupnpc"; + AddPortMappingArgs[7].elt = "NewLeaseDuration"; + AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0"; + if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, + "AddAnyPortMapping", AddPortMappingArgs, + &bufsize))) { + free(AddPortMappingArgs); + return UPNPCOMMAND_HTTP_ERROR; + } + ParseNameValue(buffer, bufsize, &pdata); + free(buffer); buffer = NULL; + resVal = GetValueFromNameValueList(&pdata, "errorCode"); + if(resVal) { + ret = UPNPCOMMAND_UNKNOWN_ERROR; + sscanf(resVal, "%d", &ret); + } else { + char *p; + + p = GetValueFromNameValueList(&pdata, "NewReservedPort"); + if(p) { + strncpy(reservedPort, p, 6); + reservedPort[5] = '\0'; + ret = UPNPCOMMAND_SUCCESS; + } else { + ret = UPNPCOMMAND_INVALID_RESPONSE; + } + } + ClearNameValueList(&pdata); + free(AddPortMappingArgs); + return ret; +} + +MINIUPNP_LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, const char * extPort, const char * proto, const char * remoteHost) @@ -438,7 +505,53 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int +UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, + const char * extPortStart, const char * extPortEnd, + const char * proto, + const char * manage) +{ + struct UPNParg * DeletePortMappingArgs; + char * buffer; + int bufsize; + struct NameValueParserData pdata; + const char * resVal; + int ret; + + if(!extPortStart || !extPortEnd || !proto || !manage) + return UPNPCOMMAND_INVALID_ARGS; + + DeletePortMappingArgs = calloc(5, sizeof(struct UPNParg)); + DeletePortMappingArgs[0].elt = "NewStartPort"; + DeletePortMappingArgs[0].val = extPortStart; + DeletePortMappingArgs[1].elt = "NewEndPort"; + DeletePortMappingArgs[1].val = extPortEnd; + DeletePortMappingArgs[2].elt = "NewProtocol"; + DeletePortMappingArgs[2].val = proto; + DeletePortMappingArgs[3].elt = "NewManage"; + DeletePortMappingArgs[3].val = manage; + + if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, + "DeletePortMappingRange", + DeletePortMappingArgs, &bufsize))) { + free(DeletePortMappingArgs); + return UPNPCOMMAND_HTTP_ERROR; + } + ParseNameValue(buffer, bufsize, &pdata); + free(buffer); buffer = NULL; + resVal = GetValueFromNameValueList(&pdata, "errorCode"); + if(resVal) { + ret = UPNPCOMMAND_UNKNOWN_ERROR; + sscanf(resVal, "%d", &ret); + } else { + ret = UPNPCOMMAND_SUCCESS; + } + ClearNameValueList(&pdata); + free(DeletePortMappingArgs); + return ret; +} + +MINIUPNP_LIBSPEC int UPNP_GetGenericPortMappingEntry(const char * controlURL, const char * servicetype, const char * index, @@ -533,7 +646,7 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL, return r; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPortMappingNumberOfEntries(const char * controlURL, const char * servicetype, unsigned int * numEntries) @@ -574,7 +687,7 @@ UPNP_GetPortMappingNumberOfEntries(const char * controlURL, /* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping * the result is returned in the intClient and intPort strings * please provide 16 and 6 bytes of data */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetSpecificPortMappingEntry(const char * controlURL, const char * servicetype, const char * extPort, @@ -666,7 +779,7 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL, * 733 InconsistantParameters - NewStartPort and NewEndPort values are not * consistent. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetListOfPortMappings(const char * controlURL, const char * servicetype, const char * startPort, @@ -748,7 +861,7 @@ UPNP_GetListOfPortMappings(const char * controlURL, } /* IGD:2, functions for service WANIPv6FirewallControl:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetFirewallStatus(const char * controlURL, const char * servicetype, int * firewallEnabled, @@ -792,7 +905,7 @@ UPNP_GetFirewallStatus(const char * controlURL, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -847,7 +960,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -926,7 +1039,7 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, const char * uniqueID, const char * leaseTime) @@ -968,7 +1081,7 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID) { /*struct NameValueParserData pdata;*/ @@ -1007,7 +1120,7 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, const char * uniqueID, int * isWorking) { @@ -1052,7 +1165,7 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, const char * uniqueID, int * packets) { diff --git a/external/miniupnpc/upnpcommands.h b/external/miniupnpc/upnpcommands.h old mode 100755 new mode 100644 index 93d9f3dd4..8034199ce --- a/external/miniupnpc/upnpcommands.h +++ b/external/miniupnpc/upnpcommands.h @@ -17,24 +17,25 @@ #define UPNPCOMMAND_UNKNOWN_ERROR (-1) #define UPNPCOMMAND_INVALID_ARGS (-2) #define UPNPCOMMAND_HTTP_ERROR (-3) +#define UPNPCOMMAND_INVALID_RESPONSE (-4) #ifdef __cplusplus extern "C" { #endif -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesSent(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesReceived(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsSent(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsReceived(const char * controlURL, const char * servicetype); @@ -43,7 +44,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, * Return values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error code */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetStatusInfo(const char * controlURL, const char * servicetype, char * status, @@ -55,7 +56,7 @@ UPNP_GetStatusInfo(const char * controlURL, * Return Values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error code */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetConnectionTypeInfo(const char * controlURL, const char * servicetype, char * connectionType); @@ -71,7 +72,7 @@ UPNP_GetConnectionTypeInfo(const char * controlURL, * possible UPnP Errors : * 402 Invalid Args - See UPnP Device Architecture section on Control. * 501 Action Failed - See UPnP Device Architecture section on Control. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetExternalIPAddress(const char * controlURL, const char * servicetype, char * extIpAdd); @@ -82,7 +83,7 @@ UPNP_GetExternalIPAddress(const char * controlURL, * return values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error Code. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetLinkLayerMaxBitRates(const char* controlURL, const char* servicetype, unsigned int * bitrateDown, @@ -121,15 +122,49 @@ UPNP_GetLinkLayerMaxBitRates(const char* controlURL, * due to conflict with other mechanisms. * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration); + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration); + +/* UPNP_AddAnyPortMapping() + * if desc is NULL, it will be defaulted to "libminiupnpc" + * remoteHost is usually NULL because IGD don't support it. + * + * Return values : + * 0 : SUCCESS + * NON ZERO : ERROR. Either an UPnP error code or an unknown error. + * + * List of possible UPnP errors for AddPortMapping : + * errorCode errorDescription (short) - Description (long) + * 402 Invalid Args - See UPnP Device Architecture section on Control. + * 501 Action Failed - See UPnP Device Architecture section on Control. + * 606 Action not authorized - The action requested REQUIRES authorization and + * the sender was not authorized. + * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be + * wild-carded + * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded + * 728 NoPortMapsAvailable - There are not enough free ports available to + * complete port mapping. + * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed + * due to conflict with other mechanisms. + * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded + */ +MINIUPNP_LIBSPEC int +UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration, + char * reservedPort); /* UPNP_DeletePortMapping() * Use same argument values as what was used for AddPortMapping(). @@ -143,14 +178,33 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, * 606 Action not authorized - The action requested REQUIRES authorization * and the sender was not authorized. * 714 NoSuchEntryInArray - The specified value does not exist in the array */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto, - const char * remoteHost); + const char * extPort, const char * proto, + const char * remoteHost); + +/* UPNP_DeletePortRangeMapping() + * Use same argument values as what was used for AddPortMapping(). + * remoteHost is usually NULL because IGD don't support it. + * Return Values : + * 0 : SUCCESS + * NON ZERO : error. Either an UPnP error code or an undefined error. + * + * List of possible UPnP errors for DeletePortMapping : + * 606 Action not authorized - The action requested REQUIRES authorization + * and the sender was not authorized. + * 730 PortMappingNotFound - This error message is returned if no port + * mapping is found in the specified range. + * 733 InconsistentParameters - NewStartPort and NewEndPort values are not consistent. */ +MINIUPNP_LIBSPEC int +UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, + const char * extPortStart, const char * extPortEnd, + const char * proto, + const char * manage); /* UPNP_GetPortMappingNumberOfEntries() * not supported by all routers */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num); @@ -178,7 +232,7 @@ UPNP_GetPortMappingNumberOfEntries(const char* controlURL, * and the sender was not authorized. * 714 NoSuchEntryInArray - The specified value does not exist in the array. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetSpecificPortMappingEntry(const char * controlURL, const char * servicetype, const char * extPort, @@ -212,7 +266,7 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL, * and the sender was not authorized. * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetGenericPortMappingEntry(const char * controlURL, const char * servicetype, const char * index, @@ -234,7 +288,7 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL, * 733 InconsistantParameters - NewStartPort and NewEndPort values are not * consistent. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetListOfPortMappings(const char * controlURL, const char * servicetype, const char * startPort, @@ -244,13 +298,13 @@ UPNP_GetListOfPortMappings(const char * controlURL, struct PortMappingParserData * data); /* IGD:2, functions for service WANIPv6FirewallControl:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetFirewallStatus(const char * controlURL, const char * servicetype, int * firewallEnabled, int * inboundPinholeAllowed); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -259,7 +313,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype const char * proto, int * opTimeout); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -269,19 +323,19 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * leaseTime, char * uniqueID); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, const char * uniqueID, const char * leaseTime); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, const char * uniqueID, int * isWorking); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, const char * uniqueID, int * packets); diff --git a/external/miniupnpc/upnperrors.c b/external/miniupnpc/upnperrors.c old mode 100755 new mode 100644 index 644098f0d..40a2e7857 --- a/external/miniupnpc/upnperrors.c +++ b/external/miniupnpc/upnperrors.c @@ -1,4 +1,4 @@ -/* $Id: upnperrors.c,v 1.6 2012/03/15 01:02:03 nanard Exp $ */ +/* $Id: upnperrors.c,v 1.5 2011/04/10 11:19:36 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2007 Thomas Bernard @@ -24,6 +24,9 @@ const char * strupnperror(int err) case UPNPCOMMAND_INVALID_ARGS: s = "Miniupnpc Invalid Arguments"; break; + case UPNPCOMMAND_INVALID_RESPONSE: + s = "Miniupnpc Invalid response"; + break; case UPNPDISCOVER_SOCKET_ERROR: s = "Miniupnpc Socket error"; break; diff --git a/external/miniupnpc/upnperrors.h b/external/miniupnpc/upnperrors.h old mode 100755 new mode 100644 index 077d6938b..b42c6424a --- a/external/miniupnpc/upnperrors.h +++ b/external/miniupnpc/upnperrors.h @@ -1,4 +1,4 @@ -/* $Id: upnperrors.h,v 1.4 2012/09/27 15:42:11 nanard Exp $ */ +/* $Id: upnperrors.h,v 1.2 2008/07/02 23:31:15 nanard Exp $ */ /* (c) 2007 Thomas Bernard * All rights reserved. * MiniUPnP Project. @@ -17,7 +17,7 @@ extern "C" { /* strupnperror() * Return a string description of the UPnP error code * or NULL for undefinded errors */ -LIBSPEC const char * strupnperror(int err); +MINIUPNP_LIBSPEC const char * strupnperror(int err); #ifdef __cplusplus } diff --git a/external/miniupnpc/upnpreplyparse.c b/external/miniupnpc/upnpreplyparse.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/upnpreplyparse.h b/external/miniupnpc/upnpreplyparse.h old mode 100755 new mode 100644 diff --git a/external/miniupnpc/wingenminiupnpcstrings.c b/external/miniupnpc/wingenminiupnpcstrings.c old mode 100755 new mode 100644 index ed289f4a2..fd9ee061d --- a/external/miniupnpc/wingenminiupnpcstrings.c +++ b/external/miniupnpc/wingenminiupnpcstrings.c @@ -1,4 +1,4 @@ -/* $Id: wingenminiupnpcstrings.c,v 1.3 2012/03/05 19:42:48 nanard Exp $ */ +/* $Id: wingenminiupnpcstrings.c,v 1.2 2011/01/11 15:31:13 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 08fd1d1e6..d08c224b5 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -48,9 +48,11 @@ #ifdef UPNP_STATIC #include #include + #include #else #include "miniupnpc.h" #include "upnpcommands.h" + #include "upnperrors.h" #endif #define NET_MAKE_IP(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4)))) @@ -324,8 +326,14 @@ namespace nodetool if (result == 1) { std::ostringstream portString; portString << m_listenning_port; - if (UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0") != 0) { - LOG_ERROR("UPNP_AddPortMapping failed."); + + // Delete the port mapping before we create it, just in case we have dangling port mapping from the daemon not being shut down correctly + UPNP_DeletePortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), "TCP", 0); + + int portMappingResult; + portMappingResult = UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0"); + if (portMappingResult != 0) { + LOG_ERROR("UPNP_AddPortMapping failed, error: " << strupnperror(portMappingResult)); } else { LOG_PRINT_GREEN("Added IGD port mapping.", LOG_LEVEL_0); } From 8c37823d45383bf7db333d699759e7df1c22631c Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 15:03:27 +0200 Subject: [PATCH 04/15] remove pthreads, successfully tested on gcc 4.9.1 without pthreads --- cmake/FindUnbound.cmake | 6 +++++- src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index af3382fff..6c3d15eae 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -37,7 +37,11 @@ FIND_PATH(UNBOUND_INCLUDE_DIR /usr/ ) -find_library(UNBOUND_LIBRARIES unbound) +if(STATIC) + find_library(UNBOUND_LIBRARIES libunbound.a) +else() + find_library(UNBOUND_LIBRARIES unbound) +endif() IF(UNBOUND_INCLUDE_DIR) MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5502cdb9..5f6d7551e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,13 +60,13 @@ add_library(cryptonote_core ${CRYPTONOTE_CORE}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 92c21dad9..14695ddd8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,16 +61,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") From 9130e411e12d923b33c14a09c21b2e23fae231ba Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 15:49:18 +0200 Subject: [PATCH 05/15] fixed unbound static lib on mingw as libunbound.dll.a --- cmake/FindUnbound.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index 6c3d15eae..032bcf45e 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -38,7 +38,11 @@ FIND_PATH(UNBOUND_INCLUDE_DIR ) if(STATIC) - find_library(UNBOUND_LIBRARIES libunbound.a) + if(MINGW) + find_library(UNBOUND_LIBRARIES libunbound.dll.a) + else() + find_library(UNBOUND_LIBRARIES libunbound.a) + endif() else() find_library(UNBOUND_LIBRARIES unbound) endif() From 18281f4d205d9e320fad23ac3c28b66ea4bb2ff7 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 18:43:13 +0200 Subject: [PATCH 06/15] remove dangling upnp port mappings, updated miniupnpc --- external/miniupnpc/.gitignore | 25 +++ external/miniupnpc/CMakeLists.txt | 12 +- external/miniupnpc/Changelog.txt | 17 +- external/miniupnpc/LICENSE | 2 +- external/miniupnpc/MANIFEST.in | 0 external/miniupnpc/Makefile | 6 +- external/miniupnpc/Makefile.mingw | 4 +- external/miniupnpc/README | 0 external/miniupnpc/VERSION | 0 external/miniupnpc/apiversions.txt | 0 external/miniupnpc/bsdqueue.h | 0 external/miniupnpc/codelength.h | 2 +- external/miniupnpc/connecthostport.c | 3 +- external/miniupnpc/connecthostport.h | 2 +- external/miniupnpc/declspec.h | 10 +- external/miniupnpc/igd_desc_parse.c | 29 ++- external/miniupnpc/igd_desc_parse.h | 2 +- external/miniupnpc/java/.gitignore | 2 + external/miniupnpc/java/JavaBridgeTest.java | 0 external/miniupnpc/man3/miniupnpc.3 | 0 external/miniupnpc/mingw32make.bat | 0 external/miniupnpc/minihttptestserver.c | 173 ++++++++++++++++-- external/miniupnpc/minisoap.c | 0 external/miniupnpc/minisoap.h | 2 +- external/miniupnpc/minissdpc.c | 4 +- external/miniupnpc/minissdpc.h | 2 +- external/miniupnpc/miniupnpc.c | 21 ++- external/miniupnpc/miniupnpc.def | 2 + external/miniupnpc/miniupnpc.h | 20 +- external/miniupnpc/miniupnpcmodule.c | 83 ++++++++- external/miniupnpc/miniupnpcstrings.h.cmake | 0 external/miniupnpc/miniupnpcstrings.h.in | 2 +- external/miniupnpc/miniupnpctypes.h | 2 +- external/miniupnpc/miniwget.c | 10 +- external/miniupnpc/miniwget.h | 8 +- external/miniupnpc/minixml.c | 2 +- external/miniupnpc/minixml.h | 2 +- external/miniupnpc/minixmlvalid.c | 0 external/miniupnpc/msvc/miniupnpc.sln | 0 external/miniupnpc/msvc/miniupnpc.vcproj | 4 +- external/miniupnpc/msvc/upnpc-static.vcproj | 4 +- external/miniupnpc/portlistingparse.c | 0 external/miniupnpc/portlistingparse.h | 6 +- external/miniupnpc/receivedata.c | 7 +- external/miniupnpc/receivedata.h | 2 +- external/miniupnpc/setup.py | 16 +- external/miniupnpc/setupmingw32.py | 18 +- external/miniupnpc/testigddescparse.c | 0 external/miniupnpc/testminiwget.c | 0 external/miniupnpc/testminixml.c | 0 .../DeletePortMapping.namevalue | 0 .../testreplyparse/DeletePortMapping.xml | 0 .../GetExternalIPAddress.namevalue | 0 .../testreplyparse/GetExternalIPAddress.xml | 0 .../GetSpecificPortMappingEntryReq.namevalue | 0 .../GetSpecificPortMappingEntryReq.xml | 0 .../GetSpecificPortMappingEntryResp.namevalue | 0 .../GetSpecificPortMappingEntryResp.xml | 0 .../SetDefaultConnectionService.namevalue | 0 .../SetDefaultConnectionService.xml | 0 external/miniupnpc/testreplyparse/readme.txt | 0 external/miniupnpc/testupnpreplyparse.c | 0 external/miniupnpc/upnpc.c | 139 +++++++++----- external/miniupnpc/upnpcommands.c | 169 ++++++++++++++--- external/miniupnpc/upnpcommands.h | 114 +++++++++--- external/miniupnpc/upnperrors.c | 5 +- external/miniupnpc/upnperrors.h | 4 +- external/miniupnpc/upnpreplyparse.c | 0 external/miniupnpc/upnpreplyparse.h | 0 external/miniupnpc/wingenminiupnpcstrings.c | 2 +- src/p2p/net_node.inl | 12 +- 71 files changed, 729 insertions(+), 222 deletions(-) create mode 100644 external/miniupnpc/.gitignore mode change 100755 => 100644 external/miniupnpc/CMakeLists.txt mode change 100755 => 100644 external/miniupnpc/Changelog.txt mode change 100755 => 100644 external/miniupnpc/LICENSE mode change 100755 => 100644 external/miniupnpc/MANIFEST.in mode change 100755 => 100644 external/miniupnpc/Makefile mode change 100755 => 100644 external/miniupnpc/Makefile.mingw mode change 100755 => 100644 external/miniupnpc/README mode change 100755 => 100644 external/miniupnpc/VERSION mode change 100755 => 100644 external/miniupnpc/apiversions.txt mode change 100755 => 100644 external/miniupnpc/bsdqueue.h mode change 100755 => 100644 external/miniupnpc/codelength.h mode change 100755 => 100644 external/miniupnpc/connecthostport.c mode change 100755 => 100644 external/miniupnpc/connecthostport.h mode change 100755 => 100644 external/miniupnpc/declspec.h mode change 100755 => 100644 external/miniupnpc/igd_desc_parse.c mode change 100755 => 100644 external/miniupnpc/igd_desc_parse.h create mode 100644 external/miniupnpc/java/.gitignore mode change 100755 => 100644 external/miniupnpc/java/JavaBridgeTest.java mode change 100755 => 100644 external/miniupnpc/man3/miniupnpc.3 mode change 100755 => 100644 external/miniupnpc/mingw32make.bat mode change 100755 => 100644 external/miniupnpc/minihttptestserver.c mode change 100755 => 100644 external/miniupnpc/minisoap.c mode change 100755 => 100644 external/miniupnpc/minisoap.h mode change 100755 => 100644 external/miniupnpc/minissdpc.c mode change 100755 => 100644 external/miniupnpc/minissdpc.h mode change 100755 => 100644 external/miniupnpc/miniupnpc.c mode change 100755 => 100644 external/miniupnpc/miniupnpc.def mode change 100755 => 100644 external/miniupnpc/miniupnpc.h mode change 100755 => 100644 external/miniupnpc/miniupnpcmodule.c mode change 100755 => 100644 external/miniupnpc/miniupnpcstrings.h.cmake mode change 100755 => 100644 external/miniupnpc/miniupnpcstrings.h.in mode change 100755 => 100644 external/miniupnpc/miniupnpctypes.h mode change 100755 => 100644 external/miniupnpc/miniwget.c mode change 100755 => 100644 external/miniupnpc/miniwget.h mode change 100755 => 100644 external/miniupnpc/minixml.c mode change 100755 => 100644 external/miniupnpc/minixml.h mode change 100755 => 100644 external/miniupnpc/minixmlvalid.c mode change 100755 => 100644 external/miniupnpc/msvc/miniupnpc.sln mode change 100755 => 100644 external/miniupnpc/msvc/miniupnpc.vcproj mode change 100755 => 100644 external/miniupnpc/msvc/upnpc-static.vcproj mode change 100755 => 100644 external/miniupnpc/portlistingparse.c mode change 100755 => 100644 external/miniupnpc/portlistingparse.h mode change 100755 => 100644 external/miniupnpc/receivedata.c mode change 100755 => 100644 external/miniupnpc/receivedata.h mode change 100755 => 100644 external/miniupnpc/setup.py mode change 100755 => 100644 external/miniupnpc/setupmingw32.py mode change 100755 => 100644 external/miniupnpc/testigddescparse.c mode change 100755 => 100644 external/miniupnpc/testminiwget.c mode change 100755 => 100644 external/miniupnpc/testminixml.c mode change 100755 => 100644 external/miniupnpc/testreplyparse/DeletePortMapping.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/DeletePortMapping.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetExternalIPAddress.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetExternalIPAddress.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryReq.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/GetSpecificPortMappingEntryResp.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/SetDefaultConnectionService.namevalue mode change 100755 => 100644 external/miniupnpc/testreplyparse/SetDefaultConnectionService.xml mode change 100755 => 100644 external/miniupnpc/testreplyparse/readme.txt mode change 100755 => 100644 external/miniupnpc/testupnpreplyparse.c mode change 100755 => 100644 external/miniupnpc/upnpc.c mode change 100755 => 100644 external/miniupnpc/upnpcommands.c mode change 100755 => 100644 external/miniupnpc/upnpcommands.h mode change 100755 => 100644 external/miniupnpc/upnperrors.c mode change 100755 => 100644 external/miniupnpc/upnperrors.h mode change 100755 => 100644 external/miniupnpc/upnpreplyparse.c mode change 100755 => 100644 external/miniupnpc/upnpreplyparse.h mode change 100755 => 100644 external/miniupnpc/wingenminiupnpcstrings.c diff --git a/external/miniupnpc/.gitignore b/external/miniupnpc/.gitignore new file mode 100644 index 000000000..c5103d2bd --- /dev/null +++ b/external/miniupnpc/.gitignore @@ -0,0 +1,25 @@ +deb_dist/ +build/ +*.o +*.a +*.so +*.dll +*.dylib +Makefile.bak +miniupnpcstrings.h +pythonmodule +pythonmodule3 +upnpc-shared +upnpc-static +minihttptestserver +minixmlvalid +testminiwget +validateminiwget +validateminixml +java/miniupnpc_*.jar +_jnaerator.* +out.errors.txt +jnaerator-*.jar +miniupnpc.h.bak +testupnpreplyparse +validateupnpreplyparse diff --git a/external/miniupnpc/CMakeLists.txt b/external/miniupnpc/CMakeLists.txt old mode 100755 new mode 100644 index 74aaa0509..4631725ec --- a/external/miniupnpc/CMakeLists.txt +++ b/external/miniupnpc/CMakeLists.txt @@ -36,7 +36,7 @@ else (NOT WIN32) endif (NOT WIN32) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - add_definitions (-DMACOSX -D_DARWIN_C_SOURCE) + add_definitions (-D_DARWIN_C_SOURCE) endif () # Set compiler specific build flags @@ -86,16 +86,14 @@ endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS") if (WIN32) set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES - COMPILE_DEFINITIONS STATICLIB + COMPILE_DEFINITIONS MINIUPNP_STATICLIB COMPILE_DEFINITIONS MINIUPNP_EXPORTS ) endif (WIN32) if (WIN32) -# find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32) -# find_library (IPHLPAPI_LIBRARY NAMES iphlpapi) - set(WINSOCK2_LIBRARY ws2_32) - set(IPHLPAPI_LIBRARY iphlpapi) + find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32) + find_library (IPHLPAPI_LIBRARY NAMES iphlpapi) set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS}) #elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris") # find_library (SOCKET_LIBRARY NAMES socket) @@ -167,6 +165,8 @@ install (FILES igd_desc_parse.h upnpreplyparse.h upnperrors.h + miniupnpctypes.h + portlistingparse.h declspec.h DESTINATION include/miniupnpc ) diff --git a/external/miniupnpc/Changelog.txt b/external/miniupnpc/Changelog.txt old mode 100755 new mode 100644 index 53e9a112b..4bfd77cba --- a/external/miniupnpc/Changelog.txt +++ b/external/miniupnpc/Changelog.txt @@ -1,6 +1,21 @@ -$Id: Changelog.txt,v 1.193 2014/02/05 17:26:45 nanard Exp $ +$Id: Changelog.txt,v 1.198 2014/09/11 14:13:31 nanard Exp $ miniUPnP client Changelog. +2014/09/11: + use remoteHost arg of DeletePortMapping + +2014/09/06: + Fix python3 build + +2014/07/01: + Fix parsing of IGD2 root descriptions + +2014/06/10: + rename LIBSPEC to MINIUPNP_LIBSPEC + +2014/05/15: + Add support for IGD2 AddAnyPortMapping and DeletePortMappingRange + 2014/02/05: handle EINPROGRESS after connect() diff --git a/external/miniupnpc/LICENSE b/external/miniupnpc/LICENSE old mode 100755 new mode 100644 index ac89a7516..566f0c9e6 --- a/external/miniupnpc/LICENSE +++ b/external/miniupnpc/LICENSE @@ -1,5 +1,5 @@ MiniUPnPc -Copyright (c) 2005-2011, Thomas BERNARD +Copyright (c) 2005-2014, Thomas BERNARD All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/external/miniupnpc/MANIFEST.in b/external/miniupnpc/MANIFEST.in old mode 100755 new mode 100644 diff --git a/external/miniupnpc/Makefile b/external/miniupnpc/Makefile old mode 100755 new mode 100644 index eaf42f053..5713a8f0a --- a/external/miniupnpc/Makefile +++ b/external/miniupnpc/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.107 2014/01/31 14:19:12 nanard Exp $ +# $Id: Makefile,v 1.110 2014/09/06 08:24:12 nanard Exp $ # MiniUPnP Project # http://miniupnp.free.fr/ # http://miniupnp.tuxfamily.org/ @@ -85,7 +85,7 @@ LIBRARY = libminiupnpc.a ifeq ($(OS), Darwin) SHAREDLIBRARY = libminiupnpc.dylib SONAME = $(basename $(SHAREDLIBRARY)).$(APIVERSION).dylib - CFLAGS := -DMACOSX -D_DARWIN_C_SOURCE $(CFLAGS) + CFLAGS := -D_DARWIN_C_SOURCE $(CFLAGS) else ifeq ($(JARSUFFIX), win32) SHAREDLIBRARY = miniupnpc.dll @@ -174,9 +174,11 @@ validateupnpreplyparse: testupnpreplyparse testupnpreplyparse.sh clean: $(RM) $(LIBRARY) $(SHAREDLIBRARY) $(EXECUTABLES) $(OBJS) miniupnpcstrings.h + $(RM) $(EXECUTABLES_ADDTESTS) # clean python stuff $(RM) pythonmodule pythonmodule3 $(RM) validateminixml validateminiwget validateupnpreplyparse + $(RM) minihttptestserver minihttptestserver.o $(RM) -r build/ dist/ #python setup.py clean # clean jnaerator stuff diff --git a/external/miniupnpc/Makefile.mingw b/external/miniupnpc/Makefile.mingw old mode 100755 new mode 100644 index 60b3f1b15..7b00650fc --- a/external/miniupnpc/Makefile.mingw +++ b/external/miniupnpc/Makefile.mingw @@ -50,11 +50,11 @@ dll/upnpc.o: upnpc.o echo $@ generated with $< .c.o: - $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $< + $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< $(CC) $(CFLAGS) -DMINIUPNP_EXPORTS -c -o dll/$@ $< upnpc.o: - $(CC) $(CFLAGS) -DSTATICLIB -c -o $@ $< + $(CC) $(CFLAGS) -DMINIUPNP_STATICLIB -c -o $@ $< $(CC) $(CFLAGS) -c -o dll/$@ $< # --enable-stdcall-fixup diff --git a/external/miniupnpc/README b/external/miniupnpc/README old mode 100755 new mode 100644 diff --git a/external/miniupnpc/VERSION b/external/miniupnpc/VERSION old mode 100755 new mode 100644 diff --git a/external/miniupnpc/apiversions.txt b/external/miniupnpc/apiversions.txt old mode 100755 new mode 100644 diff --git a/external/miniupnpc/bsdqueue.h b/external/miniupnpc/bsdqueue.h old mode 100755 new mode 100644 diff --git a/external/miniupnpc/codelength.h b/external/miniupnpc/codelength.h old mode 100755 new mode 100644 index d342bd141..50d460679 --- a/external/miniupnpc/codelength.h +++ b/external/miniupnpc/codelength.h @@ -1,4 +1,4 @@ -/* $Id: codelength.h,v 1.4 2012/09/27 15:40:29 nanard Exp $ */ +/* $Id: codelength.h,v 1.3 2011/07/30 13:10:05 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2005-2011 Thomas Bernard diff --git a/external/miniupnpc/connecthostport.c b/external/miniupnpc/connecthostport.c old mode 100755 new mode 100644 index d66ae315f..98f72535d --- a/external/miniupnpc/connecthostport.c +++ b/external/miniupnpc/connecthostport.c @@ -1,4 +1,4 @@ -/* $Id: connecthostport.c,v 1.13 2014/03/31 12:36:36 nanard Exp $ */ +/* $Id: connecthostport.c,v 1.12 2014/02/05 17:26:46 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2010-2014 Thomas Bernard @@ -35,7 +35,6 @@ #ifndef USE_GETHOSTBYNAME #include #include -#include #endif /* #ifndef USE_GETHOSTBYNAME */ #endif /* #else _WIN32 */ diff --git a/external/miniupnpc/connecthostport.h b/external/miniupnpc/connecthostport.h old mode 100755 new mode 100644 index 56941d6fa..f3b2d2a84 --- a/external/miniupnpc/connecthostport.h +++ b/external/miniupnpc/connecthostport.h @@ -1,4 +1,4 @@ -/* $Id: connecthostport.h,v 1.3 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: connecthostport.h,v 1.2 2012/06/23 22:32:33 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ * Author: Thomas Bernard diff --git a/external/miniupnpc/declspec.h b/external/miniupnpc/declspec.h old mode 100755 new mode 100644 index 77299693b..560aa3a6c --- a/external/miniupnpc/declspec.h +++ b/external/miniupnpc/declspec.h @@ -1,19 +1,19 @@ #ifndef DECLSPEC_H_INCLUDED #define DECLSPEC_H_INCLUDED -#if defined(_WIN32) && !defined(STATICLIB) +#if defined(_WIN32) && !defined(MINIUPNP_STATICLIB) /* for windows dll */ #ifdef MINIUPNP_EXPORTS - #define LIBSPEC __declspec(dllexport) + #define MINIUPNP_LIBSPEC __declspec(dllexport) #else - #define LIBSPEC __declspec(dllimport) + #define MINIUPNP_LIBSPEC __declspec(dllimport) #endif #else #if defined(__GNUC__) && __GNUC__ >= 4 /* fix dynlib for OS X 10.9.2 and Apple LLVM version 5.0 */ - #define LIBSPEC __attribute__ ((visibility ("default"))) + #define MINIUPNP_LIBSPEC __attribute__ ((visibility ("default"))) #else - #define LIBSPEC + #define MINIUPNP_LIBSPEC #endif #endif diff --git a/external/miniupnpc/igd_desc_parse.c b/external/miniupnpc/igd_desc_parse.c old mode 100755 new mode 100644 index 6c3e65677..0eaf21b6a --- a/external/miniupnpc/igd_desc_parse.c +++ b/external/miniupnpc/igd_desc_parse.c @@ -1,8 +1,8 @@ -/* $Id: igd_desc_parse.c,v 1.14 2011/04/11 09:19:24 nanard Exp $ */ +/* $Id: igd_desc_parse.c,v 1.15 2014/07/01 13:01:17 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard - * Copyright (c) 2005-2010 Thomas Bernard + * Copyright (c) 2005-2014 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -26,6 +26,8 @@ void IGDstartelt(void * d, const char * name, int l) } } +#define COMPARE(str, cstr) (0==memcmp(str, cstr, sizeof(cstr) - 1)) + /* End element handler : * update nesting level counter and update parser state if * service element is parsed */ @@ -36,23 +38,16 @@ void IGDendelt(void * d, const char * name, int l) /*printf("endelt %2d %.*s\n", datas->level, l, name);*/ if( (l==7) && !memcmp(name, "service", l) ) { - /* - if( datas->state < 1 - && !strcmp(datas->servicetype, - // "urn:schemas-upnp-org:service:WANIPConnection:1") ) - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) - datas->state ++; - */ - if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) { + if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) { memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1")) { + } else if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANIPv6FirewallControl:")) { memcpy(&datas->IPv6FC, &datas->tmp, sizeof(struct IGDdatas_service)); - } else if(0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANIPConnection:1") - || 0==strcmp(datas->tmp.servicetype, - "urn:schemas-upnp-org:service:WANPPPConnection:1") ) { + } else if(COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANIPConnection:") + || COMPARE(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANPPPConnection:") ) { if(datas->first.servicetype[0] == '\0') { memcpy(&datas->first, &datas->tmp, sizeof(struct IGDdatas_service)); } else { diff --git a/external/miniupnpc/igd_desc_parse.h b/external/miniupnpc/igd_desc_parse.h old mode 100755 new mode 100644 index 0a49b019d..f5864b5c1 --- a/external/miniupnpc/igd_desc_parse.h +++ b/external/miniupnpc/igd_desc_parse.h @@ -1,4 +1,4 @@ -/* $Id: igd_desc_parse.h,v 1.11 2012/10/16 16:49:02 nanard Exp $ */ +/* $Id: igd_desc_parse.h,v 1.10 2011/04/11 09:19:24 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard diff --git a/external/miniupnpc/java/.gitignore b/external/miniupnpc/java/.gitignore new file mode 100644 index 000000000..8e9e79486 --- /dev/null +++ b/external/miniupnpc/java/.gitignore @@ -0,0 +1,2 @@ +*.class +*.jar diff --git a/external/miniupnpc/java/JavaBridgeTest.java b/external/miniupnpc/java/JavaBridgeTest.java old mode 100755 new mode 100644 diff --git a/external/miniupnpc/man3/miniupnpc.3 b/external/miniupnpc/man3/miniupnpc.3 old mode 100755 new mode 100644 diff --git a/external/miniupnpc/mingw32make.bat b/external/miniupnpc/mingw32make.bat old mode 100755 new mode 100644 diff --git a/external/miniupnpc/minihttptestserver.c b/external/miniupnpc/minihttptestserver.c old mode 100755 new mode 100644 index b71936117..fb779650b --- a/external/miniupnpc/minihttptestserver.c +++ b/external/miniupnpc/minihttptestserver.c @@ -1,7 +1,7 @@ -/* $Id: minihttptestserver.c,v 1.13 2012/05/29 13:03:07 nanard Exp $ */ +/* $Id: minihttptestserver.c,v 1.16 2014/04/01 15:08:28 nanard Exp $ */ /* Project : miniUPnP * Author : Thomas Bernard - * Copyright (c) 2011-2012 Thomas Bernard + * Copyright (c) 2011-2014 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ @@ -28,20 +28,20 @@ volatile sig_atomic_t child_to_wait_for = 0; */ void handle_signal_chld(int sig) { - printf("handle_signal_chld(%d)\n", sig); + (void)sig; + /* printf("handle_signal_chld(%d)\n", sig); */ ++child_to_wait_for; } /** * signal handler for SIGINT (CRTL C) */ -#if 0 void handle_signal_int(int sig) { - printf("handle_signal_int(%d)\n", sig); + (void)sig; + /* printf("handle_signal_int(%d)\n", sig); */ quit = 1; } -#endif /** * build a text/plain content of the specified length @@ -94,7 +94,8 @@ void build_crap(char * p, int n) * build chunked response. * return a malloc'ed buffer */ -char * build_chunked_response(int content_length, int * response_len) { +char * build_chunked_response(int content_length, int * response_len) +{ char * response_buffer; char * content_buffer; int buffer_length; @@ -141,7 +142,115 @@ char * build_chunked_response(int content_length, int * response_len) { return response_buffer; } -enum modes { MODE_INVALID, MODE_CHUNKED, MODE_ADDCRAP, MODE_NORMAL }; +/* favicon.ico generator */ +#ifdef OLD_HEADER +#define FAVICON_LENGTH (6 + 16 + 12 + 8 + 32 * 4) +#else +#define FAVICON_LENGTH (6 + 16 + 40 + 8 + 32 * 4) +#endif +void build_favicon_content(char * p, int n) +{ + int i; + if(n < FAVICON_LENGTH) + return; + /* header : 6 bytes */ + *p++ = 0; + *p++ = 0; + *p++ = 1; /* type : ICO */ + *p++ = 0; + *p++ = 1; /* number of images in file */ + *p++ = 0; + /* image directory (1 entry) : 16 bytes */ + *p++ = 16; /* width */ + *p++ = 16; /* height */ + *p++ = 2; /* number of colors in the palette. 0 = no palette */ + *p++ = 0; /* reserved */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ +#ifdef OLD_HEADER + *p++ = 12 + 8 + 32 * 4; /* bmp size */ +#else + *p++ = 40 + 8 + 32 * 4; /* bmp size */ +#endif + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 6 + 16; /* bmp offset */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + /* BMP */ +#ifdef OLD_HEADER + /* BITMAPCOREHEADER */ + *p++ = 12; /* size of this header */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16; /* width */ + *p++ = 0; /* " */ + *p++ = 16 * 2; /* height x 2 ! */ + *p++ = 0; /* " */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ +#else + /* BITMAPINFOHEADER */ + *p++ = 40; /* size of this header */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16; /* width */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 16 * 2; /* height x 2 ! */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 0; /* " */ + *p++ = 1; /* color planes */ + *p++ = 0; /* " */ + *p++ = 1; /* bpp */ + *p++ = 0; /* " */ + /* compression method, image size, ppm x, ppm y */ + /* colors in the palette ? */ + /* important colors */ + for(i = 4 * 6; i > 0; --i) + *p++ = 0; +#endif + /* palette */ + *p++ = 0; /* b */ + *p++ = 0; /* g */ + *p++ = 0; /* r */ + *p++ = 0; /* reserved */ + *p++ = 255; /* b */ + *p++ = 255; /* g */ + *p++ = 255; /* r */ + *p++ = 0; /* reserved */ + /* pixel data */ + for(i = 16; i > 0; --i) { + if(i & 1) { + *p++ = 0125; + *p++ = 0125; + } else { + *p++ = 0252; + *p++ = 0252; + } + *p++ = 0; + *p++ = 0; + } + /* Opacity MASK */ + for(i = 16 * 4; i > 0; --i) { + *p++ = 0; + } +} + +enum modes { + MODE_INVALID, MODE_CHUNKED, MODE_ADDCRAP, MODE_NORMAL, MODE_FAVICON +}; + const struct { const enum modes mode; const char * text; @@ -149,6 +258,7 @@ const struct { {MODE_CHUNKED, "chunked"}, {MODE_ADDCRAP, "addcrap"}, {MODE_NORMAL, "normal"}, + {MODE_FAVICON, "favicon.ico"}, {MODE_INVALID, NULL} }; @@ -201,6 +311,8 @@ void handle_http_connection(int c) request_buffer + request_len, sizeof(request_buffer) - request_len); if(n < 0) { + if(errno == EINTR) + continue; perror("read"); return; } else if(n==0) { @@ -219,6 +331,7 @@ void handle_http_connection(int c) } if(!headers_found) { /* error */ + printf("no HTTP header found in the request\n"); return; } printf("headers :\n%.*s", request_len, request_buffer); @@ -292,6 +405,8 @@ void handle_http_connection(int c) case MODE_ADDCRAP: response_len = content_length+256; response_buffer = malloc(response_len); + if(!response_buffer) + break; n = snprintf(response_buffer, response_len, "HTTP/1.1 200 OK\r\n" "Server: minihttptestserver\r\n" @@ -303,9 +418,27 @@ void handle_http_connection(int c) build_content(response_buffer + n, content_length); build_crap(response_buffer + n + content_length, CRAP_LENGTH); break; + case MODE_FAVICON: + content_length = FAVICON_LENGTH; + response_len = content_length + 256; + response_buffer = malloc(response_len); + if(!response_buffer) + break; + n = snprintf(response_buffer, response_len, + "HTTP/1.1 200 OK\r\n" + "Server: minihttptestserver\r\n" + "Content-Type: image/vnd.microsoft.icon\r\n" + "Content-Length: %d\r\n" + "\r\n", content_length); + /* image/x-icon */ + build_favicon_content(response_buffer + n, content_length); + response_len = content_length + n; + break; default: response_len = content_length+256; response_buffer = malloc(response_len); + if(!response_buffer) + break; n = snprintf(response_buffer, response_len, "HTTP/1.1 200 OK\r\n" "Server: minihttptestserver\r\n" @@ -338,6 +471,7 @@ int main(int argc, char * * argv) { int child = 0; int status; const char * expected_file_name = NULL; + struct sigaction sa; for(i = 1; i < argc; i++) { if(argv[i][0] == '-') { @@ -364,10 +498,21 @@ int main(int argc, char * * argv) { } srand(time(NULL)); - signal(SIGCHLD, handle_signal_chld); -#if 0 - signal(SIGINT, handle_signal_int); -#endif + + memset(&sa, 0, sizeof(struct sigaction)); + + /*signal(SIGCHLD, handle_signal_chld);*/ + sa.sa_handler = handle_signal_chld; + if(sigaction(SIGCHLD, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } + /*signal(SIGINT, handle_signal_int);*/ + sa.sa_handler = handle_signal_int; + if(sigaction(SIGINT, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } s = socket(ipv6 ? AF_INET6 : AF_INET, SOCK_STREAM, 0); if(s < 0) { @@ -442,12 +587,12 @@ int main(int argc, char * * argv) { } --child_to_wait_for; } - /* TODO : add a select() call in order to handle the case - * when a signal is caught */ client_addrlen = sizeof(struct sockaddr_storage); c = accept(s, (struct sockaddr *)&client_addr, &client_addrlen); if(c < 0) { + if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) + continue; perror("accept"); return 1; } diff --git a/external/miniupnpc/minisoap.c b/external/miniupnpc/minisoap.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/minisoap.h b/external/miniupnpc/minisoap.h old mode 100755 new mode 100644 index 14c859d1e..60554f5c3 --- a/external/miniupnpc/minisoap.h +++ b/external/miniupnpc/minisoap.h @@ -1,4 +1,4 @@ -/* $Id: minisoap.h,v 1.5 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005 Thomas Bernard diff --git a/external/miniupnpc/minissdpc.c b/external/miniupnpc/minissdpc.c old mode 100755 new mode 100644 index c4913fb89..8b7421b00 --- a/external/miniupnpc/minissdpc.c +++ b/external/miniupnpc/minissdpc.c @@ -1,4 +1,4 @@ -/* $Id: minissdpc.c,v 1.16 2012/03/05 19:42:46 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.15 2012/01/21 13:30:31 nanard Exp $ */ /* Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD @@ -46,7 +46,7 @@ getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath) { struct UPNPDev * tmp; struct UPNPDev * devlist = NULL; - unsigned char buffer[2048]; + unsigned char buffer[4*1024]; /* is that enough ? */ ssize_t n; unsigned char * p; unsigned char * url; diff --git a/external/miniupnpc/minissdpc.h b/external/miniupnpc/minissdpc.h old mode 100755 new mode 100644 index 915b0026f..2516f487a --- a/external/miniupnpc/minissdpc.h +++ b/external/miniupnpc/minissdpc.h @@ -1,4 +1,4 @@ -/* $Id: minissdpc.h,v 1.2 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minissdpc.h,v 1.1 2007/08/31 15:15:33 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/external/miniupnpc/miniupnpc.c b/external/miniupnpc/miniupnpc.c old mode 100755 new mode 100644 index f661c2e6f..1da230f52 --- a/external/miniupnpc/miniupnpc.c +++ b/external/miniupnpc/miniupnpc.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.c,v 1.117 2014/01/31 14:19:13 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.116 2014/01/31 14:09:03 nanard Exp $ */ /* Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD @@ -6,7 +6,7 @@ * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #define __EXTENSIONS__ 1 -#if !defined(MACOSX) && !defined(__sun) +#if !defined(__APPLE__) && !defined(__sun) #if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) #ifndef __cplusplus #define _XOPEN_SOURCE 600 @@ -17,7 +17,7 @@ #endif #endif -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(MACOSX) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) +#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) #define HAS_IP_MREQN #endif @@ -70,6 +70,9 @@ /* Amiga OS specific stuff */ #define TIMEVAL struct timeval #endif +#ifdef __GNU__ +#define MAXHOSTNAMELEN 64 +#endif #if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN) @@ -106,7 +109,7 @@ struct ip_mreqn #define SERVICEPREFIX2 'u' /* root description parsing */ -LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) +MINIUPNP_LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) { struct xmlparser parser; /* xmlparser object */ @@ -335,7 +338,7 @@ parseMSEARCHReply(const char * reply, int size, * no devices was found. * It is up to the caller to free the chained list * delay is in millisecond (poll) */ -LIBSPEC struct UPNPDev * +MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int sameport, int ipv6, @@ -718,7 +721,7 @@ upnpDiscover(int delay, const char * multicastif, /* freeUPNPDevlist() should be used to * free the chained list returned by upnpDiscover() */ -LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist) +MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist) { struct UPNPDev * next; while(devlist) @@ -754,7 +757,7 @@ url_cpy_or_cat(char * dst, const char * src, int n) /* Prepare the Urls for usage... */ -LIBSPEC void +MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, const char * descURL, unsigned int scope_id) { @@ -844,7 +847,7 @@ GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, #endif } -LIBSPEC void +MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls * urls) { if(!urls) @@ -891,7 +894,7 @@ UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data) * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to * free allocated memory. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, diff --git a/external/miniupnpc/miniupnpc.def b/external/miniupnpc/miniupnpc.def old mode 100755 new mode 100644 index 334335606..60e0bbe42 --- a/external/miniupnpc/miniupnpc.def +++ b/external/miniupnpc/miniupnpc.def @@ -24,7 +24,9 @@ EXPORTS UPNP_GetExternalIPAddress UPNP_GetLinkLayerMaxBitRates UPNP_AddPortMapping + UPNP_AddAnyPortMapping UPNP_DeletePortMapping + UPNP_DeletePortMappingRange UPNP_GetPortMappingNumberOfEntries UPNP_GetSpecificPortMappingEntry UPNP_GetGenericPortMappingEntry diff --git a/external/miniupnpc/miniupnpc.h b/external/miniupnpc/miniupnpc.h old mode 100755 new mode 100644 index 3af109cf1..304de90f2 --- a/external/miniupnpc/miniupnpc.h +++ b/external/miniupnpc/miniupnpc.h @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.h,v 1.35 2014/01/31 13:26:34 nanard Exp $ */ +/* $Id: miniupnpc.h,v 1.34 2014/01/31 13:18:25 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ * Author: Thomas Bernard @@ -18,7 +18,7 @@ #define UPNPDISCOVER_MEMORY_ERROR (-102) /* versions : */ -#define MINIUPNPC_VERSION "1.9.20140401" +#define MINIUPNPC_VERSION "1.9" #define MINIUPNPC_API_VERSION 10 #ifdef __cplusplus @@ -54,19 +54,19 @@ struct UPNPDev { * multicast interface for sending SSDP discover packets. * If sameport is not null, SSDP packets will be sent from the source port * 1900 (same as destination port) otherwise system assign a source port. */ -LIBSPEC struct UPNPDev * +MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, const char * minissdpdsock, int sameport, int ipv6, int * error); /* freeUPNPDevlist() * free list returned by upnpDiscover() */ -LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); +MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); /* parserootdesc() : * parse root XML description of a UPnP device and fill the IGDdatas * structure. */ -LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); +MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); /* structure used to get fast access to urls * controlURL: controlURL of the WANIPConnection @@ -94,7 +94,7 @@ struct UPNPUrls { * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to * free allocated memory. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, @@ -105,21 +105,21 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, * return value : * 0 - Not ok * 1 - OK */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetIGDFromUrl(const char * rootdescurl, struct UPNPUrls * urls, struct IGDdatas * data, char * lanaddr, int lanaddrlen); -LIBSPEC void +MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *, unsigned int); -LIBSPEC void +MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls *); /* return 0 or 1 */ -LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); +MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); #ifdef __cplusplus diff --git a/external/miniupnpc/miniupnpcmodule.c b/external/miniupnpc/miniupnpcmodule.c old mode 100755 new mode 100644 index 4654c9870..ecddf7e84 --- a/external/miniupnpc/miniupnpcmodule.c +++ b/external/miniupnpc/miniupnpcmodule.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpcmodule.c,v 1.22 2014/01/31 13:18:25 nanard Exp $*/ +/* $Id: miniupnpcmodule.c,v 1.24 2014/06/10 09:48:11 nanard Exp $*/ /* Project : miniupnp * Author : Thomas BERNARD * website : http://miniupnp.tuxfamily.org/ @@ -6,7 +6,7 @@ * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include -#define STATICLIB +#define MINIUPNP_STATICLIB #include "structmember.h" #include "miniupnpc.h" #include "upnpcommands.h" @@ -265,6 +265,42 @@ Py_END_ALLOW_THREADS } } +/* AddAnyPortMapping(externalPort, protocol, internalHost, internalPort, desc, + * remoteHost) + * protocol is 'UDP' or 'TCP' */ +static PyObject * +UPnP_addanyportmapping(UPnPObject *self, PyObject *args) +{ + char extPort[6]; + unsigned short ePort; + char inPort[6]; + unsigned short iPort; + char reservedPort[6]; + const char * proto; + const char * host; + const char * desc; + const char * remoteHost; + const char * leaseDuration = "0"; + int r; + if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto, &host, &iPort, &desc, &remoteHost)) + return NULL; +Py_BEGIN_ALLOW_THREADS + sprintf(extPort, "%hu", ePort); + sprintf(inPort, "%hu", iPort); + r = UPNP_AddAnyPortMapping(self->urls.controlURL, self->data.first.servicetype, + extPort, inPort, host, desc, proto, + remoteHost, leaseDuration, reservedPort); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("i", atoi(reservedPort)); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } +} + + /* DeletePortMapping(extPort, proto, removeHost='') * proto = 'UDP', 'TCP' */ static PyObject * @@ -291,6 +327,37 @@ Py_END_ALLOW_THREADS } } +/* DeletePortMappingRange(extPort, proto, removeHost='') + * proto = 'UDP', 'TCP' */ +static PyObject * +UPnP_deleteportmappingrange(UPnPObject *self, PyObject *args) +{ + char extPortStart[6]; + unsigned short ePortStart; + char extPortEnd[6]; + unsigned short ePortEnd; + const char * proto; + unsigned char manage; + char manageStr[1]; + int r; + if(!PyArg_ParseTuple(args, "HHsb", &ePortStart, &ePortEnd, &proto, &manage)) + return NULL; +Py_BEGIN_ALLOW_THREADS + sprintf(extPortStart, "%hu", ePortStart); + sprintf(extPortEnd, "%hu", ePortEnd); + sprintf(manageStr, "%hhu", manage); + r = UPNP_DeletePortMappingRange(self->urls.controlURL, self->data.first.servicetype, + extPortStart, extPortEnd, proto, manageStr); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + Py_RETURN_TRUE; + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } +} + static PyObject * UPnP_getportmappingnumberofentries(UPnPObject *self) { @@ -429,9 +496,15 @@ static PyMethodDef UPnP_methods[] = { {"addportmapping", (PyCFunction)UPnP_addportmapping, METH_VARARGS, "add a port mapping" }, + {"addanyportmapping", (PyCFunction)UPnP_addanyportmapping, METH_VARARGS, + "add a port mapping, IGD to select alternative if necessary" + }, {"deleteportmapping", (PyCFunction)UPnP_deleteportmapping, METH_VARARGS, "delete a port mapping" }, + {"deleteportmappingrange", (PyCFunction)UPnP_deleteportmappingrange, METH_VARARGS, + "delete a range of port mappings" + }, {"getportmappingnumberofentries", (PyCFunction)UPnP_getportmappingnumberofentries, METH_NOARGS, "-- non standard --" }, @@ -526,7 +599,11 @@ initminiupnpc(void) UPnPType.tp_new = PyType_GenericNew; #endif if (PyType_Ready(&UPnPType) < 0) +#if PY_MAJOR_VERSION >= 3 + return 0; +#else return; +#endif #if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&moduledef); @@ -537,7 +614,7 @@ initminiupnpc(void) Py_INCREF(&UPnPType); PyModule_AddObject(m, "UPnP", (PyObject *)&UPnPType); - + #if PY_MAJOR_VERSION >= 3 return m; #endif diff --git a/external/miniupnpc/miniupnpcstrings.h.cmake b/external/miniupnpc/miniupnpcstrings.h.cmake old mode 100755 new mode 100644 diff --git a/external/miniupnpc/miniupnpcstrings.h.in b/external/miniupnpc/miniupnpcstrings.h.in old mode 100755 new mode 100644 index c32e3a133..93b8cbc66 --- a/external/miniupnpc/miniupnpcstrings.h.in +++ b/external/miniupnpc/miniupnpcstrings.h.in @@ -1,4 +1,4 @@ -/* $Id: miniupnpcstrings.h.in,v 1.5 2012/10/16 16:48:26 nanard Exp $ */ +/* $Id: miniupnpcstrings.h.in,v 1.4 2011/01/04 11:41:53 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/external/miniupnpc/miniupnpctypes.h b/external/miniupnpc/miniupnpctypes.h old mode 100755 new mode 100644 index 591c32fb6..307ce3969 --- a/external/miniupnpc/miniupnpctypes.h +++ b/external/miniupnpc/miniupnpctypes.h @@ -1,4 +1,4 @@ -/* $Id: miniupnpctypes.h,v 1.2 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */ /* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org * Author : Thomas Bernard * Copyright (c) 2011 Thomas Bernard diff --git a/external/miniupnpc/miniwget.c b/external/miniupnpc/miniwget.c old mode 100755 new mode 100644 index 813db9324..4a4a9393d --- a/external/miniupnpc/miniwget.c +++ b/external/miniupnpc/miniwget.c @@ -15,7 +15,6 @@ #include #include #define MAXHOSTNAMELEN 64 -#define MIN(x,y) (((x)<(y))?(x):(y)) #define snprintf _snprintf #define socklen_t int #ifndef strncasecmp @@ -40,9 +39,14 @@ #include #define closesocket close #endif /* #else _WIN32 */ -#if defined(__sun) || defined(sun) +#ifdef __GNU__ +#define MAXHOSTNAMELEN 64 +#endif /* __GNU__ */ + +#ifndef MIN #define MIN(x,y) (((x)<(y))?(x):(y)) -#endif +#endif /* MIN */ + #include "miniupnpcstrings.h" #include "miniwget.h" diff --git a/external/miniupnpc/miniwget.h b/external/miniupnpc/miniwget.h old mode 100755 new mode 100644 index 31bcea322..04a8de2db --- a/external/miniupnpc/miniwget.h +++ b/external/miniupnpc/miniwget.h @@ -1,4 +1,4 @@ -/* $Id: miniwget.h,v 1.8 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: miniwget.h,v 1.7 2012/06/23 22:35:59 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard * Copyright (c) 2005-2012 Thomas Bernard @@ -14,11 +14,11 @@ extern "C" { #endif -LIBSPEC void * getHTTPResponse(int s, int * size); +MINIUPNP_LIBSPEC void * getHTTPResponse(int s, int * size); -LIBSPEC void * miniwget(const char *, int *, unsigned int); +MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int); -LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int); +MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int); int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); diff --git a/external/miniupnpc/minixml.c b/external/miniupnpc/minixml.c old mode 100755 new mode 100644 index 3e201ec2c..1f2227343 --- a/external/miniupnpc/minixml.c +++ b/external/miniupnpc/minixml.c @@ -1,4 +1,4 @@ -/* $Id: minixml.c,v 1.11 2014/02/03 15:54:12 nanard Exp $ */ +/* $Id: minixml.c,v 1.10 2012/03/05 19:42:47 nanard Exp $ */ /* minixml.c : the minimum size a xml parser can be ! */ /* Project : miniupnp * webpage: http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ diff --git a/external/miniupnpc/minixml.h b/external/miniupnpc/minixml.h old mode 100755 new mode 100644 index 9f43aa48c..19e6f513b --- a/external/miniupnpc/minixml.h +++ b/external/miniupnpc/minixml.h @@ -1,4 +1,4 @@ -/* $Id: minixml.h,v 1.7 2012/09/27 15:42:10 nanard Exp $ */ +/* $Id: minixml.h,v 1.6 2006/11/30 11:47:21 nanard Exp $ */ /* minimal xml parser * * Project : miniupnp diff --git a/external/miniupnpc/minixmlvalid.c b/external/miniupnpc/minixmlvalid.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/msvc/miniupnpc.sln b/external/miniupnpc/msvc/miniupnpc.sln old mode 100755 new mode 100644 diff --git a/external/miniupnpc/msvc/miniupnpc.vcproj b/external/miniupnpc/msvc/miniupnpc.vcproj old mode 100755 new mode 100644 index 12a55aaff..ca7a0821a --- a/external/miniupnpc/msvc/miniupnpc.vcproj +++ b/external/miniupnpc/msvc/miniupnpc.vcproj @@ -41,7 +41,7 @@ controlURL, - data->first.servicetype, - externalIPAddress); - if(externalIPAddress[0]) - printf("ExternalIPAddress = %s\n", externalIPAddress); - else - printf("GetExternalIPAddress failed.\n"); - - r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype, - eport, iport, iaddr, description, - proto, 0, leaseDuration); + r = UPNP_GetExternalIPAddress(urls->controlURL, + data->first.servicetype, + externalIPAddress); if(r!=UPNPCOMMAND_SUCCESS) - printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", - eport, iport, iaddr, r, strupnperror(r)); + printf("GetExternalIPAddress failed.\n"); + else + printf("ExternalIPAddress = %s\n", externalIPAddress); + + if (addAny) { + r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype, + eport, iport, iaddr, description, + proto, 0, leaseDuration, reservedPort); + if(r==UPNPCOMMAND_SUCCESS) + eport = reservedPort; + else + printf("AddAnyPortMapping(%s, %s, %s) failed with code %d (%s)\n", + eport, iport, iaddr, r, strupnperror(r)); + } else { + r = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype, + eport, iport, iaddr, description, + proto, 0, leaseDuration); + if(r!=UPNPCOMMAND_SUCCESS) + printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + eport, iport, iaddr, r, strupnperror(r)); + } r = UPNP_GetSpecificPortMappingEntry(urls->controlURL, - data->first.servicetype, - eport, proto, NULL/*remoteHost*/, - intClient, intPort, NULL/*desc*/, - NULL/*enabled*/, duration); + data->first.servicetype, + eport, proto, NULL/*remoteHost*/, + intClient, intPort, NULL/*desc*/, + NULL/*enabled*/, duration); if(r!=UPNPCOMMAND_SUCCESS) printf("GetSpecificPortMappingEntry() failed with code %d (%s)\n", r, strupnperror(r)); - - if(intClient[0]) { + else { printf("InternalIP:Port = %s:%s\n", intClient, intPort); printf("external %s:%s %s is redirected to internal %s:%s (duration=%s)\n", externalIPAddress, eport, proto, intClient, intPort, duration); @@ -283,8 +295,9 @@ static void SetRedirectAndTest(struct UPNPUrls * urls, static void RemoveRedirect(struct UPNPUrls * urls, struct IGDdatas * data, - const char * eport, - const char * proto) + const char * eport, + const char * proto, + const char * remoteHost) { int r; if(!proto || !eport) @@ -298,10 +311,36 @@ RemoveRedirect(struct UPNPUrls * urls, fprintf(stderr, "protocol invalid\n"); return; } - r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, 0); + r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, remoteHost); printf("UPNP_DeletePortMapping() returned : %d\n", r); } +static void +RemoveRedirectRange(struct UPNPUrls * urls, + struct IGDdatas * data, + const char * ePortStart, char const * ePortEnd, + const char * proto, const char * manage) +{ + int r; + + if (!manage) + manage = "0"; + + if(!proto || !ePortStart || !ePortEnd) + { + fprintf(stderr, "invalid arguments\n"); + return; + } + proto = protofix(proto); + if(!proto) + { + fprintf(stderr, "protocol invalid\n"); + return; + } + r = UPNP_DeletePortMappingRange(urls->controlURL, data->first.servicetype, ePortStart, ePortEnd, proto, manage); + printf("UPNP_DeletePortMappingRange() returned : %d\n", r); +} + /* IGD:2, functions for service WANIPv6FirewallControl:1 */ static void GetFirewallStatus(struct UPNPUrls * urls, struct IGDdatas * data) { @@ -546,10 +585,12 @@ int main(int argc, char ** argv) || (command == 'D' && commandargc<1)) { fprintf(stderr, "Usage :\t%s [options] -a ip port external_port protocol [duration]\n\t\tAdd port redirection\n", argv[0]); - fprintf(stderr, " \t%s [options] -d external_port protocol [port2 protocol2] [...]\n\t\tDelete port redirection\n", argv[0]); + fprintf(stderr, " \t%s [options] -d external_port protocol \n\t\tDelete port redirection\n", argv[0]); fprintf(stderr, " \t%s [options] -s\n\t\tGet Connection status\n", argv[0]); fprintf(stderr, " \t%s [options] -l\n\t\tList redirections\n", argv[0]); - fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings, IGD v2)\n", argv[0]); + fprintf(stderr, " \t%s [options] -L\n\t\tList redirections (using GetListOfPortMappings (for IGD:2 only)\n", argv[0]); + fprintf(stderr, " \t%s [options] -n ip port external_port protocol [duration]\n\t\tAdd (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)\n", argv[0]); + fprintf(stderr, " \t%s [options] -N external_port_start external_port_end protocol [manage]\n\t\tDelete range of port redirections (for IGD:2 only)\n", argv[0]); fprintf(stderr, " \t%s [options] -r port1 protocol1 [port2 protocol2] [...]\n\t\tAdd all redirections to the current host\n", argv[0]); fprintf(stderr, " \t%s [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time\n\t\tAdd Pinhole (for IGD:2 only)\n", argv[0]); fprintf(stderr, " \t%s [options] -U uniqueID new_lease_time\n\t\tUpdate Pinhole (for IGD:2 only)\n", argv[0]); @@ -631,16 +672,28 @@ int main(int argc, char ** argv) break; case 'a': SetRedirectAndTest(&urls, &data, - commandargv[0], commandargv[1], - commandargv[2], commandargv[3], - (commandargc > 4)?commandargv[4]:"0", - description); + commandargv[0], commandargv[1], + commandargv[2], commandargv[3], + (commandargc > 4)?commandargv[4]:"0", + description, 0); break; case 'd': - for(i=0; i 2 ? commandargv[2] : NULL); + break; + case 'n': /* aNy */ + SetRedirectAndTest(&urls, &data, + commandargv[0], commandargv[1], + commandargv[2], commandargv[3], + (commandargc > 4)?commandargv[4]:"0", + description, 1); + break; + case 'N': + if (commandargc < 3) + fprintf(stderr, "too few arguments\n"); + + RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2], + commandargc > 3 ? commandargv[3] : NULL); break; case 's': GetConnectionStatus(&urls, &data); @@ -650,9 +703,9 @@ int main(int argc, char ** argv) { /*printf("port %s protocol %s\n", argv[i], argv[i+1]);*/ SetRedirectAndTest(&urls, &data, - lanaddr, commandargv[i], - commandargv[i], commandargv[i+1], "0", - description); + lanaddr, commandargv[i], + commandargv[i], commandargv[i+1], "0", + description, 0); } break; case 'A': diff --git a/external/miniupnpc/upnpcommands.c b/external/miniupnpc/upnpcommands.c old mode 100755 new mode 100644 index ad6978105..42dacebb0 --- a/external/miniupnpc/upnpcommands.c +++ b/external/miniupnpc/upnpcommands.c @@ -20,7 +20,7 @@ my_atoui(const char * s) /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesSent(const char * controlURL, const char * servicetype) { @@ -44,7 +44,7 @@ UPNP_GetTotalBytesSent(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesReceived(const char * controlURL, const char * servicetype) { @@ -68,7 +68,7 @@ UPNP_GetTotalBytesReceived(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsSent(const char * controlURL, const char * servicetype) { @@ -92,7 +92,7 @@ UPNP_GetTotalPacketsSent(const char * controlURL, /* * */ -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsReceived(const char * controlURL, const char * servicetype) { @@ -116,7 +116,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, /* UPNP_GetStatusInfo() call the corresponding UPNP method * returns the current status and uptime */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetStatusInfo(const char * controlURL, const char * servicetype, char * status, @@ -181,7 +181,7 @@ UPNP_GetStatusInfo(const char * controlURL, /* UPNP_GetConnectionTypeInfo() call the corresponding UPNP method * returns the connection type */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetConnectionTypeInfo(const char * controlURL, const char * servicetype, char * connectionType) @@ -224,7 +224,7 @@ UPNP_GetConnectionTypeInfo(const char * controlURL, * One of the values can be null * Note : GetLinkLayerMaxBitRates belongs to WANPPPConnection:1 only * We can use the GetCommonLinkProperties from WANCommonInterfaceConfig:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetLinkLayerMaxBitRates(const char * controlURL, const char * servicetype, unsigned int * bitrateDown, @@ -293,7 +293,7 @@ UPNP_GetLinkLayerMaxBitRates(const char * controlURL, * 402 Invalid Args - See UPnP Device Architecture section on Control. * 501 Action Failed - See UPnP Device Architecture section on Control. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetExternalIPAddress(const char * controlURL, const char * servicetype, char * extIpAdd) @@ -333,15 +333,15 @@ UPNP_GetExternalIPAddress(const char * controlURL, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration) + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration) { struct UPNParg * AddPortMappingArgs; char * buffer; @@ -394,7 +394,74 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int +UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration, + char * reservedPort) +{ + struct UPNParg * AddPortMappingArgs; + char * buffer; + int bufsize; + struct NameValueParserData pdata; + const char * resVal; + int ret; + + if(!inPort || !inClient || !proto || !extPort) + return UPNPCOMMAND_INVALID_ARGS; + + AddPortMappingArgs = calloc(9, sizeof(struct UPNParg)); + AddPortMappingArgs[0].elt = "NewRemoteHost"; + AddPortMappingArgs[0].val = remoteHost; + AddPortMappingArgs[1].elt = "NewExternalPort"; + AddPortMappingArgs[1].val = extPort; + AddPortMappingArgs[2].elt = "NewProtocol"; + AddPortMappingArgs[2].val = proto; + AddPortMappingArgs[3].elt = "NewInternalPort"; + AddPortMappingArgs[3].val = inPort; + AddPortMappingArgs[4].elt = "NewInternalClient"; + AddPortMappingArgs[4].val = inClient; + AddPortMappingArgs[5].elt = "NewEnabled"; + AddPortMappingArgs[5].val = "1"; + AddPortMappingArgs[6].elt = "NewPortMappingDescription"; + AddPortMappingArgs[6].val = desc?desc:"libminiupnpc"; + AddPortMappingArgs[7].elt = "NewLeaseDuration"; + AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0"; + if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, + "AddAnyPortMapping", AddPortMappingArgs, + &bufsize))) { + free(AddPortMappingArgs); + return UPNPCOMMAND_HTTP_ERROR; + } + ParseNameValue(buffer, bufsize, &pdata); + free(buffer); buffer = NULL; + resVal = GetValueFromNameValueList(&pdata, "errorCode"); + if(resVal) { + ret = UPNPCOMMAND_UNKNOWN_ERROR; + sscanf(resVal, "%d", &ret); + } else { + char *p; + + p = GetValueFromNameValueList(&pdata, "NewReservedPort"); + if(p) { + strncpy(reservedPort, p, 6); + reservedPort[5] = '\0'; + ret = UPNPCOMMAND_SUCCESS; + } else { + ret = UPNPCOMMAND_INVALID_RESPONSE; + } + } + ClearNameValueList(&pdata); + free(AddPortMappingArgs); + return ret; +} + +MINIUPNP_LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, const char * extPort, const char * proto, const char * remoteHost) @@ -438,7 +505,53 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int +UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, + const char * extPortStart, const char * extPortEnd, + const char * proto, + const char * manage) +{ + struct UPNParg * DeletePortMappingArgs; + char * buffer; + int bufsize; + struct NameValueParserData pdata; + const char * resVal; + int ret; + + if(!extPortStart || !extPortEnd || !proto || !manage) + return UPNPCOMMAND_INVALID_ARGS; + + DeletePortMappingArgs = calloc(5, sizeof(struct UPNParg)); + DeletePortMappingArgs[0].elt = "NewStartPort"; + DeletePortMappingArgs[0].val = extPortStart; + DeletePortMappingArgs[1].elt = "NewEndPort"; + DeletePortMappingArgs[1].val = extPortEnd; + DeletePortMappingArgs[2].elt = "NewProtocol"; + DeletePortMappingArgs[2].val = proto; + DeletePortMappingArgs[3].elt = "NewManage"; + DeletePortMappingArgs[3].val = manage; + + if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, + "DeletePortMappingRange", + DeletePortMappingArgs, &bufsize))) { + free(DeletePortMappingArgs); + return UPNPCOMMAND_HTTP_ERROR; + } + ParseNameValue(buffer, bufsize, &pdata); + free(buffer); buffer = NULL; + resVal = GetValueFromNameValueList(&pdata, "errorCode"); + if(resVal) { + ret = UPNPCOMMAND_UNKNOWN_ERROR; + sscanf(resVal, "%d", &ret); + } else { + ret = UPNPCOMMAND_SUCCESS; + } + ClearNameValueList(&pdata); + free(DeletePortMappingArgs); + return ret; +} + +MINIUPNP_LIBSPEC int UPNP_GetGenericPortMappingEntry(const char * controlURL, const char * servicetype, const char * index, @@ -533,7 +646,7 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL, return r; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPortMappingNumberOfEntries(const char * controlURL, const char * servicetype, unsigned int * numEntries) @@ -574,7 +687,7 @@ UPNP_GetPortMappingNumberOfEntries(const char * controlURL, /* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping * the result is returned in the intClient and intPort strings * please provide 16 and 6 bytes of data */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetSpecificPortMappingEntry(const char * controlURL, const char * servicetype, const char * extPort, @@ -666,7 +779,7 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL, * 733 InconsistantParameters - NewStartPort and NewEndPort values are not * consistent. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetListOfPortMappings(const char * controlURL, const char * servicetype, const char * startPort, @@ -748,7 +861,7 @@ UPNP_GetListOfPortMappings(const char * controlURL, } /* IGD:2, functions for service WANIPv6FirewallControl:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetFirewallStatus(const char * controlURL, const char * servicetype, int * firewallEnabled, @@ -792,7 +905,7 @@ UPNP_GetFirewallStatus(const char * controlURL, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -847,7 +960,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -926,7 +1039,7 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, const char * uniqueID, const char * leaseTime) @@ -968,7 +1081,7 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID) { /*struct NameValueParserData pdata;*/ @@ -1007,7 +1120,7 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, const char * uniqueID, int * isWorking) { @@ -1052,7 +1165,7 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, return ret; } -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, const char * uniqueID, int * packets) { diff --git a/external/miniupnpc/upnpcommands.h b/external/miniupnpc/upnpcommands.h old mode 100755 new mode 100644 index 93d9f3dd4..8034199ce --- a/external/miniupnpc/upnpcommands.h +++ b/external/miniupnpc/upnpcommands.h @@ -17,24 +17,25 @@ #define UPNPCOMMAND_UNKNOWN_ERROR (-1) #define UPNPCOMMAND_INVALID_ARGS (-2) #define UPNPCOMMAND_HTTP_ERROR (-3) +#define UPNPCOMMAND_INVALID_RESPONSE (-4) #ifdef __cplusplus extern "C" { #endif -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesSent(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesReceived(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsSent(const char * controlURL, const char * servicetype); -LIBSPEC UNSIGNED_INTEGER +MINIUPNP_LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsReceived(const char * controlURL, const char * servicetype); @@ -43,7 +44,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, * Return values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error code */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetStatusInfo(const char * controlURL, const char * servicetype, char * status, @@ -55,7 +56,7 @@ UPNP_GetStatusInfo(const char * controlURL, * Return Values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error code */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetConnectionTypeInfo(const char * controlURL, const char * servicetype, char * connectionType); @@ -71,7 +72,7 @@ UPNP_GetConnectionTypeInfo(const char * controlURL, * possible UPnP Errors : * 402 Invalid Args - See UPnP Device Architecture section on Control. * 501 Action Failed - See UPnP Device Architecture section on Control. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetExternalIPAddress(const char * controlURL, const char * servicetype, char * extIpAdd); @@ -82,7 +83,7 @@ UPNP_GetExternalIPAddress(const char * controlURL, * return values : * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR * or a UPnP Error Code. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetLinkLayerMaxBitRates(const char* controlURL, const char* servicetype, unsigned int * bitrateDown, @@ -121,15 +122,49 @@ UPNP_GetLinkLayerMaxBitRates(const char* controlURL, * due to conflict with other mechanisms. * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration); + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration); + +/* UPNP_AddAnyPortMapping() + * if desc is NULL, it will be defaulted to "libminiupnpc" + * remoteHost is usually NULL because IGD don't support it. + * + * Return values : + * 0 : SUCCESS + * NON ZERO : ERROR. Either an UPnP error code or an unknown error. + * + * List of possible UPnP errors for AddPortMapping : + * errorCode errorDescription (short) - Description (long) + * 402 Invalid Args - See UPnP Device Architecture section on Control. + * 501 Action Failed - See UPnP Device Architecture section on Control. + * 606 Action not authorized - The action requested REQUIRES authorization and + * the sender was not authorized. + * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be + * wild-carded + * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded + * 728 NoPortMapsAvailable - There are not enough free ports available to + * complete port mapping. + * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed + * due to conflict with other mechanisms. + * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded + */ +MINIUPNP_LIBSPEC int +UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, + const char * extPort, + const char * inPort, + const char * inClient, + const char * desc, + const char * proto, + const char * remoteHost, + const char * leaseDuration, + char * reservedPort); /* UPNP_DeletePortMapping() * Use same argument values as what was used for AddPortMapping(). @@ -143,14 +178,33 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, * 606 Action not authorized - The action requested REQUIRES authorization * and the sender was not authorized. * 714 NoSuchEntryInArray - The specified value does not exist in the array */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto, - const char * remoteHost); + const char * extPort, const char * proto, + const char * remoteHost); + +/* UPNP_DeletePortRangeMapping() + * Use same argument values as what was used for AddPortMapping(). + * remoteHost is usually NULL because IGD don't support it. + * Return Values : + * 0 : SUCCESS + * NON ZERO : error. Either an UPnP error code or an undefined error. + * + * List of possible UPnP errors for DeletePortMapping : + * 606 Action not authorized - The action requested REQUIRES authorization + * and the sender was not authorized. + * 730 PortMappingNotFound - This error message is returned if no port + * mapping is found in the specified range. + * 733 InconsistentParameters - NewStartPort and NewEndPort values are not consistent. */ +MINIUPNP_LIBSPEC int +UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, + const char * extPortStart, const char * extPortEnd, + const char * proto, + const char * manage); /* UPNP_GetPortMappingNumberOfEntries() * not supported by all routers */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num); @@ -178,7 +232,7 @@ UPNP_GetPortMappingNumberOfEntries(const char* controlURL, * and the sender was not authorized. * 714 NoSuchEntryInArray - The specified value does not exist in the array. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetSpecificPortMappingEntry(const char * controlURL, const char * servicetype, const char * extPort, @@ -212,7 +266,7 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL, * and the sender was not authorized. * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetGenericPortMappingEntry(const char * controlURL, const char * servicetype, const char * index, @@ -234,7 +288,7 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL, * 733 InconsistantParameters - NewStartPort and NewEndPort values are not * consistent. */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetListOfPortMappings(const char * controlURL, const char * servicetype, const char * startPort, @@ -244,13 +298,13 @@ UPNP_GetListOfPortMappings(const char * controlURL, struct PortMappingParserData * data); /* IGD:2, functions for service WANIPv6FirewallControl:1 */ -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetFirewallStatus(const char * controlURL, const char * servicetype, int * firewallEnabled, int * inboundPinholeAllowed); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -259,7 +313,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype const char * proto, int * opTimeout); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * remoteHost, const char * remotePort, @@ -269,19 +323,19 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype, const char * leaseTime, char * uniqueID); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, const char * uniqueID, const char * leaseTime); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, const char * uniqueID, int * isWorking); -LIBSPEC int +MINIUPNP_LIBSPEC int UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, const char * uniqueID, int * packets); diff --git a/external/miniupnpc/upnperrors.c b/external/miniupnpc/upnperrors.c old mode 100755 new mode 100644 index 644098f0d..40a2e7857 --- a/external/miniupnpc/upnperrors.c +++ b/external/miniupnpc/upnperrors.c @@ -1,4 +1,4 @@ -/* $Id: upnperrors.c,v 1.6 2012/03/15 01:02:03 nanard Exp $ */ +/* $Id: upnperrors.c,v 1.5 2011/04/10 11:19:36 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2007 Thomas Bernard @@ -24,6 +24,9 @@ const char * strupnperror(int err) case UPNPCOMMAND_INVALID_ARGS: s = "Miniupnpc Invalid Arguments"; break; + case UPNPCOMMAND_INVALID_RESPONSE: + s = "Miniupnpc Invalid response"; + break; case UPNPDISCOVER_SOCKET_ERROR: s = "Miniupnpc Socket error"; break; diff --git a/external/miniupnpc/upnperrors.h b/external/miniupnpc/upnperrors.h old mode 100755 new mode 100644 index 077d6938b..b42c6424a --- a/external/miniupnpc/upnperrors.h +++ b/external/miniupnpc/upnperrors.h @@ -1,4 +1,4 @@ -/* $Id: upnperrors.h,v 1.4 2012/09/27 15:42:11 nanard Exp $ */ +/* $Id: upnperrors.h,v 1.2 2008/07/02 23:31:15 nanard Exp $ */ /* (c) 2007 Thomas Bernard * All rights reserved. * MiniUPnP Project. @@ -17,7 +17,7 @@ extern "C" { /* strupnperror() * Return a string description of the UPnP error code * or NULL for undefinded errors */ -LIBSPEC const char * strupnperror(int err); +MINIUPNP_LIBSPEC const char * strupnperror(int err); #ifdef __cplusplus } diff --git a/external/miniupnpc/upnpreplyparse.c b/external/miniupnpc/upnpreplyparse.c old mode 100755 new mode 100644 diff --git a/external/miniupnpc/upnpreplyparse.h b/external/miniupnpc/upnpreplyparse.h old mode 100755 new mode 100644 diff --git a/external/miniupnpc/wingenminiupnpcstrings.c b/external/miniupnpc/wingenminiupnpcstrings.c old mode 100755 new mode 100644 index ed289f4a2..fd9ee061d --- a/external/miniupnpc/wingenminiupnpcstrings.c +++ b/external/miniupnpc/wingenminiupnpcstrings.c @@ -1,4 +1,4 @@ -/* $Id: wingenminiupnpcstrings.c,v 1.3 2012/03/05 19:42:48 nanard Exp $ */ +/* $Id: wingenminiupnpcstrings.c,v 1.2 2011/01/11 15:31:13 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author: Thomas Bernard diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 2953bdb7a..01fbaa497 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -48,9 +48,11 @@ #ifdef UPNP_STATIC #include #include + #include #else #include "miniupnpc.h" #include "upnpcommands.h" + #include "upnperrors.h" #endif #define NET_MAKE_IP(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4)))) @@ -326,8 +328,14 @@ namespace nodetool if (result == 1) { std::ostringstream portString; portString << m_listenning_port; - if (UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0") != 0) { - LOG_ERROR("UPNP_AddPortMapping failed."); + + // Delete the port mapping before we create it, just in case we have dangling port mapping from the daemon not being shut down correctly + UPNP_DeletePortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), "TCP", 0); + + int portMappingResult; + portMappingResult = UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0"); + if (portMappingResult != 0) { + LOG_ERROR("UPNP_AddPortMapping failed, error: " << strupnperror(portMappingResult)); } else { LOG_PRINT_GREEN("Added IGD port mapping.", LOG_LEVEL_0); } From 0e1b7c99996c968cccb2beb7aba4b267a30b115f Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 19:15:58 +0200 Subject: [PATCH 07/15] moved non-critical p2p errors to l2 --- contrib/epee/include/net/levin_protocol_handler_async.h | 2 +- contrib/epee/include/net/net_utils_base.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index e7fb32fe0..8ea6a6251 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -641,7 +641,7 @@ public: if(!m_pservice_endpoint->do_send(in_buff.data(), (int)in_buff.size())) { - LOG_ERROR("Failed to do_send()"); + LOG_ERROR_CC("Failed to do_send()"); return -1; } CRITICAL_REGION_END(); diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index f61a2a086..90e352787 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -143,7 +143,7 @@ namespace net_utils #define LOG_PRINT_CC_YELLOW(ct, message, log_level) LOG_PRINT_YELLOW("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message, log_level) #define LOG_PRINT_CC_CYAN(ct, message, log_level) LOG_PRINT_CYAN("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message, log_level) #define LOG_PRINT_CC_MAGENTA(ct, message, log_level) LOG_PRINT_MAGENTA("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message, log_level) -#define LOG_ERROR_CC(ct, message) LOG_PRINT_RED("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message, LOG_LEVEL_1) +#define LOG_ERROR_CC(ct, message) LOG_PRINT_RED("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message, LOG_LEVEL_2) #define LOG_PRINT_CC_L0(ct, message) LOG_PRINT_L0("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message) #define LOG_PRINT_CC_L1(ct, message) LOG_PRINT_L1("[" << epee::net_utils::print_connection_context_short(ct) << "]" << message) From 3e644c25c4cd90fb2fd4602a00389f11f7aee42e Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Tue, 30 Sep 2014 09:10:42 +0200 Subject: [PATCH 08/15] moved file checkpointing log output to log1 --- src/cryptonote_core/checkpoints_create.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cryptonote_core/checkpoints_create.cpp b/src/cryptonote_core/checkpoints_create.cpp index 808bc46a7..db1b83609 100644 --- a/src/cryptonote_core/checkpoints_create.cpp +++ b/src/cryptonote_core/checkpoints_create.cpp @@ -84,14 +84,14 @@ bool load_checkpoints_from_json(cryptonote::checkpoints& checkpoints, std::strin boost::system::error_code errcode; if (! (boost::filesystem::exists(json_hashfile_fullpath, errcode))) { - LOG_PRINT_L0("Blockchain checkpoints file not found"); + LOG_PRINT_L1("Blockchain checkpoints file not found"); return true; } - LOG_PRINT_L0("Adding checkpoints from blockchain hashfile"); + LOG_PRINT_L1("Adding checkpoints from blockchain hashfile"); uint64_t prev_max_height = checkpoints.get_max_height(); - LOG_PRINT_L0("Hard-coded max checkpoint height is " << prev_max_height); + LOG_PRINT_L1("Hard-coded max checkpoint height is " << prev_max_height); t_hash_json hashes; epee::serialization::load_t_from_json_file(hashes, json_hashfile_fullpath); for (std::vector::const_iterator it = hashes.hashlines.begin(); it != hashes.hashlines.end(); ) @@ -99,10 +99,10 @@ bool load_checkpoints_from_json(cryptonote::checkpoints& checkpoints, std::strin uint64_t height; height = it->height; if (height <= prev_max_height) { - LOG_PRINT_L0("ignoring checkpoint height " << height); + LOG_PRINT_L1("ignoring checkpoint height " << height); } else { std::string blockhash = it->hash; - LOG_PRINT_L0("Adding checkpoint height " << height << ", hash=" << blockhash); + LOG_PRINT_L1("Adding checkpoint height " << height << ", hash=" << blockhash); ADD_CHECKPOINT(height, blockhash); } ++it; @@ -150,7 +150,7 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints) if (avail && !valid) { - LOG_PRINT_L0("DNSSEC present and failed validation for query last url, and all other urls either failed validation or returned no records"); + LOG_PRINT_L0("WARNING: all checkpoints.moneropulse.net/org/co/se records failed DNSSEC validation and/or returned no records"); return true; } From 6f7ed13b72096ecb582ef4ab5553396b9335a134 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Tue, 30 Sep 2014 08:56:03 +0200 Subject: [PATCH 09/15] moved checkpoint log level --- src/cryptonote_core/checkpoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/checkpoints.cpp b/src/cryptonote_core/checkpoints.cpp index 25759792b..6a86302b6 100644 --- a/src/cryptonote_core/checkpoints.cpp +++ b/src/cryptonote_core/checkpoints.cpp @@ -69,7 +69,7 @@ namespace cryptonote if(it->second == h) { - LOG_PRINT_GREEN("CHECKPOINT PASSED FOR HEIGHT " << height << " " << h, LOG_LEVEL_0); + LOG_PRINT_GREEN("CHECKPOINT PASSED FOR HEIGHT " << height << " " << h, LOG_LEVEL_1); return true; }else { From e3d24002c11f211ca4b929e7eae9884190fe594b Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Thu, 2 Oct 2014 19:43:21 +0200 Subject: [PATCH 10/15] forgot to add connection context to log line --- contrib/epee/include/net/levin_protocol_handler_async.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index 8ea6a6251..e79768b04 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -641,7 +641,7 @@ public: if(!m_pservice_endpoint->do_send(in_buff.data(), (int)in_buff.size())) { - LOG_ERROR_CC("Failed to do_send()"); + LOG_ERROR_CC(m_connection_context, "Failed to do_send()"); return -1; } CRITICAL_REGION_END(); From 1d515b8af6eed2a30906a6682ae995051e4b6be8 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Fri, 3 Oct 2014 00:08:10 +0200 Subject: [PATCH 11/15] boost 1.56 kindly (and officially) patched in msys2 by Alexey Pavlov --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 72883cbd9..ee6ef0545 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Alternatively, it can be built in an easier and more automated fashion using Hom ### On Windows: -Dependencies: mingw-w64, msys2, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA), and 1.56 as it causes an internal compiler error on mingw-w64). +Dependencies: mingw-w64, msys2, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA)). **Preparing the Build Environment** @@ -90,8 +90,7 @@ pacman -Su --ignoregroup base pacman -Su ``` * For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated. -* Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-unbound` (note: in future, once the boost 1.56 mingw-w64 issues are fixed, you can add `mingw-w64-x86_64-boost` to that list to have it installed as well) -* Download the [boost 1.55 msys2 package](http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64/mingw-w64-x86_64-boost-1.55.0-7-any.pkg.tar.xz), and install it by running `pacman -U mingw-w64-x86_64-boost-1.55.0-7-any.pkg.tar.xz` +* Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-unbound mingw-w64-x86_64-boost` **Building** From 1663089b334166742674b705709f3705932e4785 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Fri, 3 Oct 2014 10:31:36 +0200 Subject: [PATCH 12/15] MoneroPulse log wording tweaks --- src/cryptonote_core/blockchain_storage.cpp | 4 ++-- src/cryptonote_core/checkpoints_create.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp index 6f1b4121c..5148ea634 100644 --- a/src/cryptonote_core/blockchain_storage.cpp +++ b/src/cryptonote_core/blockchain_storage.cpp @@ -1799,13 +1799,13 @@ void blockchain_storage::check_against_checkpoints(checkpoints& points, bool enf // if asked to enforce checkpoints, roll back to a couple of blocks before the checkpoint if (enforce) { - LOG_ERROR("Checkpoint failed when adding new checkpoints, rolling back!"); + LOG_ERROR("Local blockchain failed to pass a checkpoint, rolling back!"); std::list empty; rollback_blockchain_switching(empty, pt.first - 2); } else { - LOG_ERROR("Checkpoint failed when adding new checkpoints, this could be very bad."); + LOG_ERROR("WARNING: local blockchain failed to pass a MoneroPulse checkpoint, and you could be on a fork. You should either sync up from scratch, OR download a fresh blockchain bootstrap, OR enable checkpoint enforcing with the --enforce-dns-checkpointing command-line option"); } } } diff --git a/src/cryptonote_core/checkpoints_create.cpp b/src/cryptonote_core/checkpoints_create.cpp index db1b83609..140f8dae3 100644 --- a/src/cryptonote_core/checkpoints_create.cpp +++ b/src/cryptonote_core/checkpoints_create.cpp @@ -113,6 +113,7 @@ bool load_checkpoints_from_json(cryptonote::checkpoints& checkpoints, std::strin bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints) { + // All four MoneroPulse domains have DNSSEC on and valid static const std::vector dns_urls = { "checkpoints.moneropulse.se" , "checkpoints.moneropulse.org" , "checkpoints.moneropulse.net" @@ -144,13 +145,13 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints) if (records.size() == 0) { - LOG_PRINT_L1("Fetching checkpoints from DNS TXT records failed, no TXT records available."); + LOG_PRINT_L1("Fetching MoneroPulse checkpoints failed, no TXT records available."); return true; } if (avail && !valid) { - LOG_PRINT_L0("WARNING: all checkpoints.moneropulse.net/org/co/se records failed DNSSEC validation and/or returned no records"); + LOG_PRINT_L0("WARNING: MoneroPulse failed DNSSEC validation and/or returned no records"); return true; } From 2322a9442799dcb97afcacc978472080da820d95 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Fri, 3 Oct 2014 14:21:13 +0200 Subject: [PATCH 13/15] cleaned up OpenAlias messages in simplewallet --- src/simplewallet/simplewallet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index ef93a17b6..25a11d310 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -929,15 +929,15 @@ bool simple_wallet::transfer(const std::vector &args_) std::string dnssec_str; if (dnssec_ok) { - dnssec_str = "DNSSEC validation PASSED!"; + dnssec_str = "DNSSEC validation passed"; } else { - dnssec_str = "DNSSEC validation FAILED!"; + dnssec_str = "WARNING: DNSSEC validation was unsuccessful, this address may not be correct!"; } std::stringstream prompt; prompt << "For URL: " << url - << "," << dnssec_str << std::endl + << ", " << dnssec_str << std::endl << " Monero Address = " << addresses_from_dns[0] << std::endl << "Is this OK? (Y/n) " @@ -947,13 +947,13 @@ bool simple_wallet::transfer(const std::vector &args_) std::string confirm_dns_ok = command_line::input_line(prompt.str()); if (confirm_dns_ok != "Y" && confirm_dns_ok != "y" && confirm_dns_ok != "Yes" && confirm_dns_ok != "yes") { - fail_msg_writer() << "User terminated transfer request, disagreed with dns result from url: " << url; + fail_msg_writer() << "You have cancelled the transfer request"; return true; } } else { - fail_msg_writer() << "Failed to get a monero address from: " << local_args[i]; + fail_msg_writer() << "Failed to get a Monero address from: " << local_args[i]; return true; } } @@ -963,7 +963,7 @@ bool simple_wallet::transfer(const std::vector &args_) } else { - fail_msg_writer() << "wrong address: " << local_args[i]; + fail_msg_writer() << "Wrong address: " << local_args[i]; return true; } } From c4d6658f4cfe5c5b153f59b0619f6c4ad8a47496 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Fri, 3 Oct 2014 15:10:21 +0200 Subject: [PATCH 14/15] quick hacky fix for broken TXT reads --- src/common/dns_utils.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index 0376ab9a9..8c4038568 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -31,6 +31,10 @@ #include #include +#include +#include "include_base_utils.h" +using namespace epee; + namespace tools { @@ -206,7 +210,11 @@ std::vector DNSResolver::get_txt_record(const std::string& url, boo { for (size_t i=0; result.ptr->data[i] != NULL; i++) { - records.push_back(result.ptr->data[i]); + // plz fix this, but this does NOT work and spills over into parts of memory it shouldn't: records.push_back(result.ptr->data[i]); + char *restxt; + restxt = (char*) calloc(result.ptr->len[i]+1, 1); + memcpy(restxt, result.ptr->data[i]+1, result.ptr->len[i]-1); + records.push_back(restxt); } } } From 11605054549abf73a70f656913c0e81c2af5a1b8 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Fri, 3 Oct 2014 21:45:29 +0200 Subject: [PATCH 15/15] fixed checkpointing bug --- src/cryptonote_core/blockchain_storage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp index 5148ea634..4cca878db 100644 --- a/src/cryptonote_core/blockchain_storage.cpp +++ b/src/cryptonote_core/blockchain_storage.cpp @@ -1794,7 +1794,7 @@ void blockchain_storage::check_against_checkpoints(checkpoints& points, bool enf continue; } - if (!m_checkpoints.check_block(pt.first, get_block_hash(m_blocks[pt.first].bl))) + if (!points.check_block(pt.first, get_block_hash(m_blocks[pt.first].bl))) { // if asked to enforce checkpoints, roll back to a couple of blocks before the checkpoint if (enforce)