From 53a62344ca791841ad0f9f377ecea317b3dec0db Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 31 Dec 2013 22:24:56 +0000 Subject: [PATCH] fix port mapping functions in session --- include/libtorrent/aux_/session_impl.hpp | 4 ++++ src/session.cpp | 5 +++-- src/session_impl.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index c9a5c9387..90510ea22 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -485,6 +485,10 @@ namespace libtorrent void stop_natpmp(); void stop_upnp(); + int add_port_mapping(int t, int external_port + , int local_port); + void delete_port_mapping(int handle); + int next_port(); void add_redundant_bytes(size_type b, int reason) diff --git a/src/session.cpp b/src/session.cpp index 0cbbddd34..8efb67402 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1163,12 +1163,13 @@ namespace libtorrent int session::add_port_mapping(protocol_type t, int external_port, int local_port) { - TORRENT_SYNC_CALL_RET3(add_port_forward, int, t, external_port, local_port); + TORRENT_SYNC_CALL_RET3(int, add_port_mapping, int(t), external_port, local_port); + return r; } void session::delete_port_mapping(int handle) { - TORRENT_ASYNC_CALL1(delete_port_forward, handle); + TORRENT_ASYNC_CALL1(delete_port_mapping, handle); } void session::stop_lsd() diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 5a2b67d77..d3f2a9a5f 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -6173,22 +6173,22 @@ retry: return u; } - int session_impl::add_port_mapping(protocol_type t, int external_port + int session_impl::add_port_mapping(int t, int external_port , int local_port) { int ret = 0; - if (m_upnp) ret = m_upnp->add_mapping(t, external_port - , internal_port); - if (m_natpmp) ret = m_natpmp->add_mapping(t, external_port - , internal_port); + if (m_upnp) ret = m_upnp->add_mapping((upnp::protocol_type)t, external_port + , local_port); + if (m_natpmp) ret = m_natpmp->add_mapping((natpmp::protocol_type)t, external_port + , local_port); return ret; } void session_impl::delete_port_mapping(int handle) { int ret = 0; - if (m_upnp) ret = m_upnp->delete_mapping(handle); - if (m_natpmp) ret = m_natpmp->delete_mapping(handle); + if (m_upnp) m_upnp->delete_mapping(handle); + if (m_natpmp) m_natpmp->delete_mapping(handle); } void session_impl::stop_lsd()