summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-28 20:01:57 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-29 18:07:17 (GMT)
commitdfccb5703c4d85ab1a54429016b103101bdc54ae (patch)
tree05ac257e6dc7609a5b02e94e59b52f44b74f123d /Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp
parent6cea7fdfea93e54543c6757909a8fae7348754fc (diff)
downloadswift-contrib-dfccb5703c4d85ab1a54429016b103101bdc54ae.zip
swift-contrib-dfccb5703c4d85ab1a54429016b103101bdc54ae.tar.bz2
File Transfer refactoring.
NAT traversal classes refactoring. Added beginnings of a NetworkTool.
Diffstat (limited to 'Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp')
-rw-r--r--Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp b/Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp
deleted file mode 100644
index 6fcc01a..0000000
--- a/Swiften/Network/UPnPNATTraversalForwardPortRequest.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Tobias Markmann
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#include "UPnPNATTraversalForwardPortRequest.h"
-
-#include <boost/format.hpp>
-
-#include <miniupnpc.h>
-#include <upnpcommands.h>
-#include <upnperrors.h>
-
-#include <Swiften/Base/foreach.h>
-#include <Swiften/Network/NetworkInterface.h>
-#include <Swiften/Network/PlatformNetworkEnvironment.h>
-
-namespace Swift {
-
-UPnPNATTraversalForwardPortRequest::UPnPNATTraversalForwardPortRequest(NATTraversalForwardPortRequest::PortMapping mapping, PlatformNATTraversalWorker* worker) : PlatformNATTraversalRequest(worker), mapping(mapping) {
-
-}
-
-UPnPNATTraversalForwardPortRequest::~UPnPNATTraversalForwardPortRequest() {
-
-}
-
-void UPnPNATTraversalForwardPortRequest::runBlocking() {
- boost::optional<PortMapping> result;
-
- UPNPDev* deviceList = 0;
- int error = 0;
- char lanAddrress[64];
-
- std::string publicPort = str(boost::format("%d") % mapping.publicPort);
- std::string localPort = str(boost::format("%d") % mapping.localPort);
- std::string internalClient = PlatformNetworkEnvironment().getLocalAddress().toString();
- std::string leaseSeconds = str(boost::format("%d") % mapping.leaseInSeconds);
- UPNPUrls urls;
- IGDdatas data;
-
- do {
- // find valid IGD
- deviceList = upnpDiscover(1500 /* timeout in ms */, 0, 0, 0, 0 /* do IPv6? */, &error);
- if (!deviceList) {
- break;
- }
-
- if (!UPNP_GetValidIGD(deviceList, &urls, &data, lanAddrress, sizeof(lanAddrress))) {
- break;
- }
-
- /*
- int ret = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
- if (ret != UPNPCOMMAND_SUCCESS) {
- break;
- }*/
-
- int ret = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, publicPort.c_str(), localPort.c_str(), internalClient.c_str(), 0, mapping.protocol == NATTraversalForwardPortRequest::PortMapping::TCP ? "TCP" : "UDP", 0, leaseSeconds.c_str());
- if (ret == UPNPCOMMAND_SUCCESS) {
- result = boost::optional<NATTraversalForwardPortRequest::PortMapping>(mapping);
- }
- } while(false);
-
- freeUPNPDevlist(deviceList); deviceList = 0;
-
- onResult(result);
-}
-
-}