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/NATPMPNATTraversalGetPublicIPRequest.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/NATPMPNATTraversalGetPublicIPRequest.cpp')
-rw-r--r--Swiften/Network/NATPMPNATTraversalGetPublicIPRequest.cpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/Swiften/Network/NATPMPNATTraversalGetPublicIPRequest.cpp b/Swiften/Network/NATPMPNATTraversalGetPublicIPRequest.cpp
deleted file mode 100644
index 0f6067d..0000000
--- a/Swiften/Network/NATPMPNATTraversalGetPublicIPRequest.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2011 Tobias Markmann
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-#include "NATPMPNATTraversalGetPublicIPRequest.h"
-
-#include <natpmp.h>
-
-#include <Swiften/Base/Log.h>
-
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-
-namespace Swift {
-
-NATPMPNATTraversalGetPublicIPRequest::NATPMPNATTraversalGetPublicIPRequest(PlatformNATTraversalWorker* worker) : PlatformNATTraversalRequest(worker) {
-
-}
-
-NATPMPNATTraversalGetPublicIPRequest::~NATPMPNATTraversalGetPublicIPRequest() {
-
-}
-
-/*
-TODO: a non-blocking solution should be possible too here
-void NATPMPNATTraversalGetPublicIPRequest::run() {
- // we can run directly since libnatpmp's API is asynchronous
- runBlocking();
-}*/
-
-void NATPMPNATTraversalGetPublicIPRequest::runBlocking() {
- boost::optional<HostAddress> result;
-
- natpmp_t natpmp;
- natpmpresp_t response;
- initnatpmp(&natpmp, 0, 0);
-
- do {
- if (sendpublicaddressrequest(&natpmp) != 2) {
- SWIFT_LOG(debug) << "Failed to send NAT-PMP public address request!" << std::endl;
- break;
- }
- int r = 0;
-
- do {
- fd_set fds;
- struct timeval timeout;
- FD_ZERO(&fds);
- FD_SET(natpmp.s, &fds);
- getnatpmprequesttimeout(&natpmp, &timeout);
- select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
- r = readnatpmpresponseorretry(&natpmp, &response);
- } while(r == NATPMP_TRYAGAIN);
-
- if (r == 0) {
- result = boost::optional<HostAddress>(HostAddress(reinterpret_cast<const unsigned char*>(&(response.pnu.publicaddress.addr)), 4));
- } else {
- SWIFT_LOG(debug) << "Inavlid NAT-PMP response." << std::endl;
- }
- } while(false);
- closenatpmp(&natpmp);
- onResult(result);
-}
-
-}