Skip to content
Snippets Groups Projects
Commit 3e89c0c5 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

contrib/pupnp: update to 1.14, cleanup

Change-Id: I76689a7312e3839aaee3fdac4fa760e0ca5dc109
parent 171e61b2
No related branches found
No related tags found
No related merge requests found
bcf6a806772187b681ba293be3b060f3da534f553056bf0d98d213869f6dc587ad7aa9dd06b0a232995198adc461b53861415198f7f2decda17fd19163a7a39f pupnp-edd037bf9b66637db42c08981c0e4ffeb6faadfa.tar.gz d7cf50e168aff2ef3ad08b4c383108d5044e4c9d2923088bb93423ee5fc555c32f0254f307cb86ea7c18197612cf2d2c6c681f82d99a6f01a68f86a21c6eecb7 pupnp-release-1.14.0.tar.gz
998ef22d2af8e4cbc7fa1f87613ae0aa840e636bb72a5656a97327b0820a46b2b3ed2f3200260c018b5339de2fc4be760d42a3c687e49c7fedb58c1ad2287699 pupnp-release-1.12.0.tar.gz \ No newline at end of file
\ No newline at end of file
From 438ace99538713fb1370411188e0f370069a1818 Mon Sep 17 00:00:00 2001
From: Konstantin Pavlov <thresh@videolan.org>
Date: Tue, 29 May 2012 10:18:40 +0400
Subject: [PATCH] Fix compile under mingw with IPv6 enabled.
---
upnp/src/genlib/miniserver/miniserver.c | 7 +++++++
upnp/src/ssdp/ssdp_server.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c
index af310ca..1ae422f 100644
--- a/upnp/src/genlib/miniserver/miniserver.c
+++ b/upnp/src/genlib/miniserver/miniserver.c
@@ -68,6 +68,13 @@
/*! . */
#define APPLICATION_LISTENING_PORT 49152
+/* IPV6_V6ONLY is missing from MinGW, hack taken from
+ * http://svn.apache.org/repos/asf/apr/apr/trunk/network_io/win32/sockopt.c
+ */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
struct mserv_request_t {
/*! Connection handle. */
SOCKET connfd;
diff --git a/upnp/src/ssdp/ssdp_server.c b/upnp/src/ssdp/ssdp_server.c
index 231c2c5..6a9c27f 100644
--- a/upnp/src/ssdp/ssdp_server.c
+++ b/upnp/src/ssdp/ssdp_server.c
@@ -69,6 +69,13 @@
#endif /* UPNP_ENABLE_IPV6 */
#endif /* INCLUDE_CLIENT_APIS */
+/* IPV6_V6ONLY is missing from MinGW, hack taken from
+ * http://svn.apache.org/repos/asf/apr/apr/trunk/network_io/win32/sockopt.c
+ */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
void RequestHandler();
enum Listener {
--
1.7.9.7
From 39f8e5f5379607166cf6e54d270590e1fd13c12f Mon Sep 17 00:00:00 2001
From: Eden Abitbol <eden.abitbol@savoirfairelinux.com>
Date: Mon, 3 Jun 2019 15:55:40 -0400
Subject: [PATCH] web server patch
---
upnp/src/api/upnpapi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c
index 9ddc7fb..d286092 100644
--- a/upnp/src/api/upnpapi.c
+++ b/upnp/src/api/upnpapi.c
@@ -383,13 +383,13 @@ static int UpnpInitPreamble(void)
return retVal;
}
+#ifdef INTERNAL_WEB_SERVER
#ifdef INCLUDE_DEVICE_APIS
#if EXCLUDE_SOAP == 0
SetSoapCallback(soap_device_callback);
#endif
#endif /* INCLUDE_DEVICE_APIS */
-#ifdef INTERNAL_WEB_SERVER
#if EXCLUDE_GENA == 0
SetGenaCallback(genaCallback);
#endif
--
2.17.1
# UPNP # UPNP
UPNP_VERSION := 1.12.0 UPNP_VERSION := 1.14.0
UPNP_URL := https://github.com/mrjimenez/pupnp/archive/release-$(UPNP_VERSION).tar.gz UPNP_URL := https://github.com/pupnp/pupnp/archive/release-$(UPNP_VERSION).tar.gz
PKGS += upnp PKGS += upnp
ifeq ($(call need_pkg,"libupnp >= 1.8.4"),) ifeq ($(call need_pkg,"libupnp >= 1.8.4"),)
...@@ -17,8 +17,6 @@ upnp: pupnp-release-$(UPNP_VERSION).tar.gz .sum-upnp ...@@ -17,8 +17,6 @@ upnp: pupnp-release-$(UPNP_VERSION).tar.gz .sum-upnp
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
$(APPLY) $(SRC)/upnp/libupnp-windows.patch $(APPLY) $(SRC)/upnp/libupnp-windows.patch
endif endif
$(APPLY) $(SRC)/upnp/libupnp-ipv6.patch
#$(APPLY) $(SRC)/upnp/miniserver.patch
$(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR) && mv config.guess config.sub $(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR) && mv config.guess config.sub
$(MOVE) $(MOVE)
......
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
namespace jami { namespace jami {
namespace upnp { namespace upnp {
// Action identifiers.
constexpr static const char* ACTION_ADD_PORT_MAPPING {"AddPortMapping"};
constexpr static const char* ACTION_DELETE_PORT_MAPPING {"DeletePortMapping"};
constexpr static const char* ACTION_GET_GENERIC_PORT_MAPPING_ENTRY {"GetGenericPortMappingEntry"};
constexpr static const char* ACTION_GET_STATUS_INFO {"GetStatusInfo"};
constexpr static const char* ACTION_GET_EXTERNAL_IP_ADDRESS {"GetExternalIPAddress"};
// Helper functions for xml parsing. // Helper functions for xml parsing.
static std::string static std::string
getElementText(IXML_Node* node) getElementText(IXML_Node* node)
...@@ -89,13 +96,7 @@ errorOnResponse(IXML_Document* doc) ...@@ -89,13 +96,7 @@ errorOnResponse(IXML_Document* doc)
PUPnP::PUPnP() PUPnP::PUPnP()
{ {
int upnp_err = UPNP_E_SUCCESS; int upnp_err = UpnpInit2(nullptr, 0);
#if UPNP_ENABLE_IPV6
upnp_err = UpnpInit2(nullptr, 0);
#else
upnp_err = UpnpInit(0, 0); // Deprecated function but fall back on it if IPv6 not enabled.
#endif
if (upnp_err != UPNP_E_SUCCESS) { if (upnp_err != UPNP_E_SUCCESS) {
JAMI_ERR("PUPnP: Can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err)); JAMI_ERR("PUPnP: Can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err));
...@@ -413,7 +414,7 @@ PUPnP::actionAddPortMappingAsync(const UPnPIGD& igd, const Mapping& mapping) ...@@ -413,7 +414,7 @@ PUPnP::actionAddPortMappingAsync(const UPnPIGD& igd, const Mapping& mapping)
} }
void void
PUPnP::processAddMapAction(const std::string& ctrlURL, IXML_Document* actionRequest) PUPnP::processAddMapAction(const std::string_view& ctrlURL, IXML_Document* actionRequest)
{ {
std::string portExternal(getFirstDocItem(actionRequest, "NewExternalPort")); std::string portExternal(getFirstDocItem(actionRequest, "NewExternalPort"));
std::string portInternal(getFirstDocItem(actionRequest, "NewInternalPort")); std::string portInternal(getFirstDocItem(actionRequest, "NewInternalPort"));
...@@ -446,7 +447,7 @@ PUPnP::processAddMapAction(const std::string& ctrlURL, IXML_Document* actionRequ ...@@ -446,7 +447,7 @@ PUPnP::processAddMapAction(const std::string& ctrlURL, IXML_Document* actionRequ
} }
void void
PUPnP::processRemoveMapAction(const std::string& ctrlURL, IXML_Document* actionRequest) PUPnP::processRemoveMapAction(const std::string_view& ctrlURL, IXML_Document* actionRequest)
{ {
std::string portExternal(getFirstDocItem(actionRequest, "NewExternalPort")); std::string portExternal(getFirstDocItem(actionRequest, "NewExternalPort"));
std::string protocol(getFirstDocItem(actionRequest, "NewProtocol")); std::string protocol(getFirstDocItem(actionRequest, "NewProtocol"));
...@@ -516,7 +517,7 @@ PUPnP::ctrlPtCallback(Upnp_EventType event_type, const void* event, void* user_d ...@@ -516,7 +517,7 @@ PUPnP::ctrlPtCallback(Upnp_EventType event_type, const void* event, void* user_d
} }
PUPnP::CtrlAction PUPnP::CtrlAction
PUPnP::getAction(char* xmlNode) PUPnP::getAction(const char* xmlNode)
{ {
if (strstr(xmlNode, ACTION_ADD_PORT_MAPPING)) { if (strstr(xmlNode, ACTION_ADD_PORT_MAPPING)) {
return CtrlAction::ADD_PORT_MAPPING; return CtrlAction::ADD_PORT_MAPPING;
...@@ -533,6 +534,11 @@ PUPnP::getAction(char* xmlNode) ...@@ -533,6 +534,11 @@ PUPnP::getAction(char* xmlNode)
} }
} }
inline std::string_view
viewFromUpnpString(const UpnpString* ustr) {
return {UpnpString_get_String(ustr), UpnpString_get_Length(ustr)};
}
int int
PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event) PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event)
{ {
...@@ -648,14 +654,10 @@ PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event) ...@@ -648,14 +654,10 @@ PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event)
case UPNP_CONTROL_ACTION_COMPLETE: { case UPNP_CONTROL_ACTION_COMPLETE: {
const UpnpActionComplete* a_event = (const UpnpActionComplete*) event; const UpnpActionComplete* a_event = (const UpnpActionComplete*) event;
if (UpnpActionComplete_get_ErrCode(a_event) == UPNP_E_SUCCESS) { if (UpnpActionComplete_get_ErrCode(a_event) == UPNP_E_SUCCESS) {
IXML_Document* actionRequest = UpnpActionComplete_get_ActionRequest(a_event); if (IXML_Document* actionRequest = UpnpActionComplete_get_ActionRequest(a_event)) {
if (actionRequest) { auto ctrlURL = viewFromUpnpString(UpnpActionComplete_get_CtrlUrl(a_event));
std::string ctrlURL(UpnpString_get_String(UpnpActionComplete_get_CtrlUrl(a_event))); if (const char* xmlbuff = ixmlPrintNode((IXML_Node*) actionRequest)) {
char* xmlbuff = ixmlPrintNode((IXML_Node*) actionRequest);
if (xmlbuff) {
switch (getAction(xmlbuff)) { switch (getAction(xmlbuff)) {
case CtrlAction::UNKNOWN:
break;
case CtrlAction::ADD_PORT_MAPPING: case CtrlAction::ADD_PORT_MAPPING:
processAddMapAction(ctrlURL, actionRequest); processAddMapAction(ctrlURL, actionRequest);
break; break;
...@@ -668,6 +670,7 @@ PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event) ...@@ -668,6 +670,7 @@ PUPnP::handleCtrlPtUPnPEvents(Upnp_EventType event_type, const void* event)
break; break;
case CtrlAction::GET_EXTERNAL_IP_ADDRESS: case CtrlAction::GET_EXTERNAL_IP_ADDRESS:
break; break;
case CtrlAction::UNKNOWN:
default: default:
break; break;
} }
......
...@@ -57,13 +57,6 @@ ...@@ -57,13 +57,6 @@
#include <memory> #include <memory>
#include <future> #include <future>
// Action identifiers.
constexpr static const char* ACTION_ADD_PORT_MAPPING {"AddPortMapping"};
constexpr static const char* ACTION_DELETE_PORT_MAPPING {"DeletePortMapping"};
constexpr static const char* ACTION_GET_GENERIC_PORT_MAPPING_ENTRY {"GetGenericPortMappingEntry"};
constexpr static const char* ACTION_GET_STATUS_INFO {"GetStatusInfo"};
constexpr static const char* ACTION_GET_EXTERNAL_IP_ADDRESS {"GetExternalIPAddress"};
namespace jami { namespace jami {
class IpAddr; class IpAddr;
} }
...@@ -116,15 +109,15 @@ public: ...@@ -116,15 +109,15 @@ public:
uint16_t port_internal, uint16_t port_internal,
PortType type) override; PortType type) override;
// Treats the reception of an add mapping action answer. // Treats the reception of an add mapping action answer.
void processAddMapAction(const std::string& ctrlURL, IXML_Document* actionRequest); void processAddMapAction(const std::string_view& ctrlURL, IXML_Document* actionRequest);
// Returns control point action callback based on xml node. // Returns control point action callback based on xml node.
CtrlAction getAction(char* xmlNode); CtrlAction getAction(const char* xmlNode);
// Removes a mapping. // Removes a mapping.
void requestMappingRemove(const Mapping& igdMapping) override; void requestMappingRemove(const Mapping& igdMapping) override;
// Treats the reception of a remove mapping action answer. // Treats the reception of a remove mapping action answer.
void processRemoveMapAction(const std::string& ctrlURL, IXML_Document* actionRequest); void processRemoveMapAction(const std::string_view& ctrlURL, IXML_Document* actionRequest);
// Removes all local mappings of IGD that we're added by the application. // Removes all local mappings of IGD that we're added by the application.
void removeAllLocalMappings(IGD* igd) override; void removeAllLocalMappings(IGD* igd) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment