2007-03-27 09:04:31 +02:00
|
|
|
/*
|
|
|
|
|
2018-04-09 09:04:33 +02:00
|
|
|
Copyright (c) 2007-2018, Arvid Norberg
|
2007-03-27 09:04:31 +02:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TORRENT_UPNP_HPP
|
|
|
|
#define TORRENT_UPNP_HPP
|
|
|
|
|
|
|
|
#include "libtorrent/socket.hpp"
|
2009-09-16 05:46:36 +02:00
|
|
|
#include "libtorrent/error_code.hpp"
|
2007-09-10 01:52:34 +02:00
|
|
|
#include "libtorrent/broadcast_socket.hpp"
|
2009-09-16 05:46:36 +02:00
|
|
|
#include "libtorrent/deadline_timer.hpp"
|
2014-07-06 21:18:00 +02:00
|
|
|
#include "libtorrent/enum_net.hpp"
|
|
|
|
#include "libtorrent/resolver.hpp"
|
2016-05-01 08:01:31 +02:00
|
|
|
#include "libtorrent/debug.hpp"
|
2017-10-10 14:25:12 +02:00
|
|
|
#include "libtorrent/string_util.hpp"
|
2016-09-16 15:53:17 +02:00
|
|
|
#include "libtorrent/aux_/portmap.hpp"
|
2017-01-09 15:32:52 +01:00
|
|
|
#include "libtorrent/aux_/vector.hpp"
|
2007-04-05 00:27:36 +02:00
|
|
|
|
2016-09-01 03:42:18 +02:00
|
|
|
#include <memory>
|
2016-08-13 03:31:55 +02:00
|
|
|
#include <functional>
|
2007-04-05 03:08:21 +02:00
|
|
|
#include <set>
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace libtorrent {
|
2017-10-09 01:21:19 +02:00
|
|
|
struct http_connection;
|
|
|
|
class http_parser;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
namespace upnp_errors
|
|
|
|
{
|
2013-08-05 08:08:10 +02:00
|
|
|
// error codes for the upnp_error_category. They hold error codes
|
|
|
|
// returned by UPnP routers when mapping ports
|
2009-06-12 18:40:38 +02:00
|
|
|
enum error_code_enum
|
|
|
|
{
|
2013-08-05 08:08:10 +02:00
|
|
|
// No error
|
2009-06-12 18:40:38 +02:00
|
|
|
no_error = 0,
|
2013-08-05 08:08:10 +02:00
|
|
|
// One of the arguments in the request is invalid
|
2009-06-12 18:40:38 +02:00
|
|
|
invalid_argument = 402,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The request failed
|
2009-06-12 18:40:38 +02:00
|
|
|
action_failed = 501,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The specified value does not exist in the array
|
2009-06-12 18:40:38 +02:00
|
|
|
value_not_in_array = 714,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The source IP address cannot be wild-carded, but
|
|
|
|
// must be fully specified
|
2009-06-12 18:40:38 +02:00
|
|
|
source_ip_cannot_be_wildcarded = 715,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The external port cannot be wildcarded, but must
|
|
|
|
// be specified
|
2009-06-12 18:40:38 +02:00
|
|
|
external_port_cannot_be_wildcarded = 716,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The port mapping entry specified conflicts with a
|
|
|
|
// mapping assigned previously to another client
|
2009-06-12 18:40:38 +02:00
|
|
|
port_mapping_conflict = 718,
|
2013-08-05 08:08:10 +02:00
|
|
|
// Internal and external port value must be the same
|
2009-06-12 18:40:38 +02:00
|
|
|
internal_port_must_match_external = 724,
|
2013-08-05 08:08:10 +02:00
|
|
|
// The NAT implementation only supports permanent
|
|
|
|
// lease times on port mappings
|
2009-06-12 18:40:38 +02:00
|
|
|
only_permanent_leases_supported = 725,
|
2013-08-05 08:08:10 +02:00
|
|
|
// RemoteHost must be a wildcard and cannot be a
|
2017-08-07 19:48:39 +02:00
|
|
|
// specific IP address or DNS name
|
2009-06-12 18:40:38 +02:00
|
|
|
remote_host_must_be_wildcard = 726,
|
2013-08-05 08:08:10 +02:00
|
|
|
// ExternalPort must be a wildcard and cannot be a
|
|
|
|
// specific port
|
2009-08-30 09:38:52 +02:00
|
|
|
external_port_must_be_wildcard = 727
|
2009-06-12 18:40:38 +02:00
|
|
|
};
|
2014-07-21 05:19:58 +02:00
|
|
|
|
|
|
|
// hidden
|
|
|
|
TORRENT_EXPORT boost::system::error_code make_error_code(error_code_enum e);
|
2009-06-12 18:40:38 +02:00
|
|
|
}
|
|
|
|
|
2014-11-29 10:12:44 +01:00
|
|
|
// the boost.system error category for UPnP errors
|
2016-10-02 21:27:50 +02:00
|
|
|
TORRENT_EXPORT boost::system::error_category& upnp_category();
|
|
|
|
|
2018-04-28 16:51:50 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2016-10-02 21:27:50 +02:00
|
|
|
TORRENT_DEPRECATED
|
|
|
|
inline boost::system::error_category& get_upnp_category()
|
|
|
|
{ return upnp_category(); }
|
|
|
|
#endif
|
2009-06-12 18:40:38 +02:00
|
|
|
|
2015-08-18 13:55:50 +02:00
|
|
|
struct parse_state
|
|
|
|
{
|
2016-12-17 23:50:03 +01:00
|
|
|
bool in_service = false;
|
2017-02-19 13:34:55 +01:00
|
|
|
std::vector<string_view> tag_stack;
|
2015-08-18 13:55:50 +02:00
|
|
|
std::string control_url;
|
|
|
|
std::string service_type;
|
|
|
|
std::string model;
|
|
|
|
std::string url_base;
|
2017-02-19 13:34:55 +01:00
|
|
|
bool top_tags(string_view str1, string_view str2)
|
2015-08-18 13:55:50 +02:00
|
|
|
{
|
2017-02-19 13:34:55 +01:00
|
|
|
auto i = tag_stack.rbegin();
|
2015-08-18 13:55:50 +02:00
|
|
|
if (i == tag_stack.rend()) return false;
|
2017-02-19 13:34:55 +01:00
|
|
|
if (!string_equal_no_case(*i, str2)) return false;
|
2015-08-18 13:55:50 +02:00
|
|
|
++i;
|
|
|
|
if (i == tag_stack.rend()) return false;
|
2017-02-19 13:34:55 +01:00
|
|
|
if (!string_equal_no_case(*i, str1)) return false;
|
2015-08-18 13:55:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-17 23:50:03 +01:00
|
|
|
struct error_code_parse_state
|
|
|
|
{
|
|
|
|
bool in_error_code = false;
|
|
|
|
bool exit = false;
|
|
|
|
int error_code = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ip_address_parse_state: error_code_parse_state
|
|
|
|
{
|
|
|
|
bool in_ip_address = false;
|
|
|
|
std::string ip_address;
|
|
|
|
};
|
|
|
|
|
2017-02-19 13:34:55 +01:00
|
|
|
TORRENT_EXTRA_EXPORT void find_control_url(int type, string_view, parse_state& state);
|
2015-08-18 13:55:50 +02:00
|
|
|
|
2017-02-19 13:34:55 +01:00
|
|
|
TORRENT_EXTRA_EXPORT void find_error_code(int type, string_view string
|
|
|
|
, error_code_parse_state& state);
|
2016-12-17 23:50:03 +01:00
|
|
|
|
2017-02-19 13:34:55 +01:00
|
|
|
TORRENT_EXTRA_EXPORT void find_ip_address(int type, string_view string
|
|
|
|
, ip_address_parse_state& state);
|
2016-12-17 23:50:03 +01:00
|
|
|
|
2013-09-14 12:08:31 +02:00
|
|
|
// TODO: support using the windows API for UPnP operations as well
|
2016-05-01 08:01:31 +02:00
|
|
|
struct TORRENT_EXTRA_EXPORT upnp final
|
2016-08-29 14:31:23 +02:00
|
|
|
: std::enable_shared_from_this<upnp>
|
2016-05-01 08:01:31 +02:00
|
|
|
, single_threaded
|
2007-03-27 09:04:31 +02:00
|
|
|
{
|
2014-10-03 22:56:57 +02:00
|
|
|
upnp(io_service& ios
|
2016-02-07 08:09:19 +01:00
|
|
|
, std::string const& user_agent
|
2016-09-16 15:53:17 +02:00
|
|
|
, aux::portmap_callback& cb
|
2015-01-06 09:08:49 +01:00
|
|
|
, bool ignore_nonrouters);
|
2007-04-01 01:23:30 +02:00
|
|
|
~upnp();
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2016-09-19 00:56:12 +02:00
|
|
|
void set_user_agent(std::string const& v) { m_user_agent = v; }
|
|
|
|
|
2015-08-16 18:21:39 +02:00
|
|
|
void start();
|
2008-06-20 18:14:10 +02:00
|
|
|
|
2013-08-08 04:57:07 +02:00
|
|
|
// Attempts to add a port mapping for the specified protocol. Valid protocols are
|
|
|
|
// ``upnp::tcp`` and ``upnp::udp`` for the UPnP class and ``natpmp::tcp`` and
|
|
|
|
// ``natpmp::udp`` for the NAT-PMP class.
|
2015-06-06 08:10:53 +02:00
|
|
|
//
|
2013-08-08 04:57:07 +02:00
|
|
|
// ``external_port`` is the port on the external address that will be mapped. This
|
|
|
|
// is a hint, you are not guaranteed that this port will be available, and it may
|
|
|
|
// end up being something else. In the portmap_alert_ notification, the actual
|
|
|
|
// external port is reported.
|
2015-06-06 08:10:53 +02:00
|
|
|
//
|
2013-08-08 04:57:07 +02:00
|
|
|
// ``local_port`` is the port in the local machine that the mapping should forward
|
|
|
|
// to.
|
2015-06-06 08:10:53 +02:00
|
|
|
//
|
2013-08-08 04:57:07 +02:00
|
|
|
// The return value is an index that identifies this port mapping. This is used
|
|
|
|
// to refer to mappings that fails or succeeds in the portmap_error_alert_ and
|
|
|
|
// portmap_alert_ respectively. If The mapping fails immediately, the return value
|
|
|
|
// is -1, which means failure. There will not be any error alert notification for
|
|
|
|
// mappings that fail with a -1 return value.
|
2017-08-31 00:49:49 +02:00
|
|
|
port_mapping_t add_mapping(portmap_protocol p, int external_port, tcp::endpoint local_ep);
|
2013-08-08 04:57:07 +02:00
|
|
|
|
|
|
|
// This function removes a port mapping. ``mapping_index`` is the index that refers
|
|
|
|
// to the mapping you want to remove, which was returned from add_mapping().
|
2017-08-31 00:49:49 +02:00
|
|
|
void delete_mapping(port_mapping_t mapping_index);
|
2013-08-08 04:57:07 +02:00
|
|
|
|
2017-08-31 00:49:49 +02:00
|
|
|
bool get_mapping(port_mapping_t mapping_index, tcp::endpoint& local_ep, int& external_port
|
2017-08-30 20:47:49 +02:00
|
|
|
, portmap_protocol& protocol) const;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2007-12-24 09:18:53 +01:00
|
|
|
void discover_device();
|
2007-03-27 09:04:31 +02:00
|
|
|
void close();
|
|
|
|
|
2017-06-20 18:31:34 +02:00
|
|
|
// This is only available for UPnP routers. If the model is advertised by
|
2013-08-08 04:57:07 +02:00
|
|
|
// the router, it can be queried through this function.
|
2008-04-06 21:17:58 +02:00
|
|
|
std::string router_model()
|
|
|
|
{
|
2016-05-01 08:01:31 +02:00
|
|
|
TORRENT_ASSERT(is_single_thread());
|
2008-04-06 21:17:58 +02:00
|
|
|
return m_model;
|
|
|
|
}
|
2007-12-22 17:47:46 +01:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
private:
|
2007-04-01 01:23:30 +02:00
|
|
|
|
2016-08-29 14:31:23 +02:00
|
|
|
std::shared_ptr<upnp> self() { return shared_from_this(); }
|
2015-01-06 09:08:49 +01:00
|
|
|
|
2014-03-10 07:47:01 +01:00
|
|
|
void map_timer(error_code const& ec);
|
2016-05-01 08:01:31 +02:00
|
|
|
void try_map_upnp(bool timer = false);
|
|
|
|
void discover_device_impl();
|
2007-05-04 08:47:32 +02:00
|
|
|
|
2008-05-03 18:05:42 +02:00
|
|
|
void resend_request(error_code const& e);
|
2018-01-14 20:54:01 +01:00
|
|
|
void on_reply(udp::endpoint const& from, span<char const> buffer);
|
2007-03-27 09:04:31 +02:00
|
|
|
|
|
|
|
struct rootdevice;
|
2017-08-31 00:49:49 +02:00
|
|
|
void next(rootdevice& d, port_mapping_t i);
|
|
|
|
void update_map(rootdevice& d, port_mapping_t i);
|
2008-04-06 21:17:58 +02:00
|
|
|
|
2008-05-03 18:05:42 +02:00
|
|
|
void on_upnp_xml(error_code const& e
|
2008-05-17 02:27:26 +02:00
|
|
|
, libtorrent::http_parser const& p, rootdevice& d
|
|
|
|
, http_connection& c);
|
2010-12-05 21:40:28 +01:00
|
|
|
void on_upnp_get_ip_address_response(error_code const& e
|
|
|
|
, libtorrent::http_parser const& p, rootdevice& d
|
|
|
|
, http_connection& c);
|
2008-05-03 18:05:42 +02:00
|
|
|
void on_upnp_map_response(error_code const& e
|
2007-03-30 18:57:55 +02:00
|
|
|
, libtorrent::http_parser const& p, rootdevice& d
|
2017-08-31 00:49:49 +02:00
|
|
|
, port_mapping_t mapping, http_connection& c);
|
2008-05-03 18:05:42 +02:00
|
|
|
void on_upnp_unmap_response(error_code const& e
|
2007-04-01 01:23:30 +02:00
|
|
|
, libtorrent::http_parser const& p, rootdevice& d
|
2017-08-31 00:49:49 +02:00
|
|
|
, port_mapping_t mapping, http_connection& c);
|
2008-05-03 18:05:42 +02:00
|
|
|
void on_expire(error_code const& e);
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2016-05-01 08:01:31 +02:00
|
|
|
void disable(error_code const& ec);
|
2017-08-31 00:49:49 +02:00
|
|
|
void return_error(port_mapping_t mapping, int code);
|
2016-06-23 07:23:59 +02:00
|
|
|
#ifndef TORRENT_DISABLE_LOGGING
|
2016-09-16 15:53:17 +02:00
|
|
|
bool should_log() const;
|
2016-06-23 07:23:59 +02:00
|
|
|
void log(char const* msg, ...) const TORRENT_FORMAT(2,3);
|
|
|
|
#endif
|
2007-04-01 01:23:30 +02:00
|
|
|
|
2010-12-05 21:40:28 +01:00
|
|
|
void get_ip_address(rootdevice& d);
|
2017-08-31 00:49:49 +02:00
|
|
|
void delete_port_mapping(rootdevice& d, port_mapping_t i);
|
|
|
|
void create_port_mapping(http_connection& c, rootdevice& d, port_mapping_t i);
|
2009-04-13 06:22:03 +02:00
|
|
|
void post(upnp::rootdevice const& d, char const* soap
|
2016-05-01 08:01:31 +02:00
|
|
|
, char const* soap_action);
|
2007-09-10 01:52:34 +02:00
|
|
|
|
2008-04-06 21:17:58 +02:00
|
|
|
int num_mappings() const { return int(m_mappings.size()); }
|
|
|
|
|
|
|
|
struct global_mapping_t
|
|
|
|
{
|
2017-08-30 20:47:49 +02:00
|
|
|
portmap_protocol protocol = portmap_protocol::none;
|
2016-09-18 16:11:56 +02:00
|
|
|
int external_port = 0;
|
2017-05-08 02:43:55 +02:00
|
|
|
tcp::endpoint local_ep;
|
2008-04-06 21:17:58 +02:00
|
|
|
};
|
|
|
|
|
2017-09-12 23:10:11 +02:00
|
|
|
struct mapping_t : aux::base_mapping
|
2007-03-27 09:04:31 +02:00
|
|
|
{
|
|
|
|
// the local port for this mapping. If this is set
|
|
|
|
// to 0, the mapping is not in use
|
2017-05-08 02:43:55 +02:00
|
|
|
tcp::endpoint local_ep;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2008-01-07 03:35:29 +01:00
|
|
|
// the number of times this mapping has failed
|
2016-09-18 16:11:56 +02:00
|
|
|
int failcount = 0;
|
2007-03-27 09:04:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rootdevice
|
|
|
|
{
|
2017-10-09 01:21:19 +02:00
|
|
|
rootdevice();
|
|
|
|
~rootdevice();
|
|
|
|
rootdevice(rootdevice const&);
|
|
|
|
rootdevice& operator=(rootdevice const&);
|
2017-10-10 14:25:12 +02:00
|
|
|
rootdevice(rootdevice&&);
|
|
|
|
rootdevice& operator=(rootdevice&&);
|
2008-04-06 21:17:58 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
// the interface url, through which the list of
|
|
|
|
// supported interfaces are fetched
|
|
|
|
std::string url;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
// the url to the WANIP or WANPPP interface
|
|
|
|
std::string control_url;
|
|
|
|
// either the WANIP namespace or the WANPPP namespace
|
2016-10-19 23:29:35 +02:00
|
|
|
std::string service_namespace;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2017-08-31 00:49:49 +02:00
|
|
|
aux::vector<mapping_t, port_mapping_t> mapping;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2008-10-14 09:19:46 +02:00
|
|
|
// this is the hostname, port and path
|
|
|
|
// component of the url or the control_url
|
|
|
|
// if it has been found
|
2007-03-27 09:04:31 +02:00
|
|
|
std::string hostname;
|
2016-09-18 16:11:56 +02:00
|
|
|
int port = 0;
|
2007-03-27 09:04:31 +02:00
|
|
|
std::string path;
|
2010-12-05 21:40:28 +01:00
|
|
|
address external_ip;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2017-08-03 12:57:15 +02:00
|
|
|
// there are routers that's don't support timed
|
|
|
|
// port maps, without returning error 725. It seems
|
|
|
|
// safer to always assume that we have to ask for
|
|
|
|
// permanent leases
|
|
|
|
int lease_duration = 0;
|
2016-09-18 16:11:56 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
// true if the device supports specifying a
|
|
|
|
// specific external port, false if it doesn't
|
2016-09-18 16:11:56 +02:00
|
|
|
bool supports_specific_external = true;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2016-09-18 16:11:56 +02:00
|
|
|
bool disabled = false;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2014-03-10 07:47:01 +01:00
|
|
|
// this is true if the IP of this device is not
|
|
|
|
// one of our default routes. i.e. it may be someone
|
|
|
|
// else's router, we just happen to have multicast
|
|
|
|
// enabled across networks
|
|
|
|
// this is only relevant if ignore_non_routers is set.
|
2016-09-18 16:11:56 +02:00
|
|
|
bool non_router = false;
|
2014-03-10 07:47:01 +01:00
|
|
|
|
2016-08-31 18:45:45 +02:00
|
|
|
mutable std::shared_ptr<http_connection> upnp_connection;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2014-01-19 20:45:50 +01:00
|
|
|
#if TORRENT_USE_ASSERTS
|
2016-09-18 16:11:56 +02:00
|
|
|
int magic = 1337;
|
2007-10-26 02:47:30 +02:00
|
|
|
#endif
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
bool operator<(rootdevice const& rhs) const
|
|
|
|
{ return url < rhs.url; }
|
|
|
|
};
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2008-06-20 18:14:10 +02:00
|
|
|
struct upnp_state_t
|
|
|
|
{
|
2017-08-31 00:49:49 +02:00
|
|
|
aux::vector<global_mapping_t, port_mapping_t> mappings;
|
2008-06-20 18:14:10 +02:00
|
|
|
std::set<rootdevice> devices;
|
|
|
|
};
|
|
|
|
|
2017-08-31 00:49:49 +02:00
|
|
|
aux::vector<global_mapping_t, port_mapping_t> m_mappings;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2016-09-19 00:56:12 +02:00
|
|
|
std::string m_user_agent;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
// the set of devices we've found
|
|
|
|
std::set<rootdevice> m_devices;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2016-09-16 15:53:17 +02:00
|
|
|
aux::portmap_callback& m_callback;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
|
|
|
// current retry count
|
|
|
|
int m_retry_count;
|
|
|
|
|
2008-05-03 18:05:42 +02:00
|
|
|
io_service& m_io_service;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
resolver m_resolver;
|
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
// the udp socket used to send and receive
|
|
|
|
// multicast messages on the network
|
2007-09-10 01:52:34 +02:00
|
|
|
broadcast_socket m_socket;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
|
|
|
// used to resend udp packets in case
|
|
|
|
// they time out
|
|
|
|
deadline_timer m_broadcast_timer;
|
|
|
|
|
|
|
|
// timer used to refresh mappings
|
|
|
|
deadline_timer m_refresh_timer;
|
2014-03-10 07:47:01 +01:00
|
|
|
|
|
|
|
// this timer fires one second after the last UPnP response. This is the
|
2017-08-07 19:48:39 +02:00
|
|
|
// point where we assume we have received most or all SSDP responses. If we
|
2014-03-10 07:47:01 +01:00
|
|
|
// are ignoring non-routers and at this point we still haven't received a
|
|
|
|
// response from a router UPnP device, we override the ignoring behavior and
|
|
|
|
// map them anyway.
|
|
|
|
deadline_timer m_map_timer;
|
2015-06-06 08:10:53 +02:00
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
bool m_disabled;
|
2007-04-01 01:23:30 +02:00
|
|
|
bool m_closing;
|
2008-05-13 06:59:56 +02:00
|
|
|
bool m_ignore_non_routers;
|
2007-03-27 09:04:31 +02:00
|
|
|
|
2007-12-22 17:47:46 +01:00
|
|
|
std::string m_model;
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
// cache of interfaces
|
|
|
|
mutable std::vector<ip_interface> m_interfaces;
|
2015-03-12 05:34:54 +01:00
|
|
|
mutable time_point m_last_if_update;
|
2007-03-27 09:04:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-21 05:19:58 +02:00
|
|
|
namespace boost { namespace system {
|
|
|
|
|
|
|
|
template<> struct is_error_code_enum<libtorrent::upnp_errors::error_code_enum>
|
|
|
|
{ static const bool value = true; };
|
|
|
|
|
|
|
|
} }
|
|
|
|
|
2007-03-27 09:04:31 +02:00
|
|
|
#endif
|