extensions
@@ -2462,6 +2464,39 @@ struct listen_failed_alert: alert
+
+
This alert is generated when a NAT router was successfully found but some
+part of the port mapping request failed. It contains a text message that
+may help the user figure out what is wrong. This alert is not generated in
+case it appears the client is not running on a NAT:ed network or if it
+appears there is no NAT router that can be remote controlled to add port
+mappings.
+
The alert is generated as severity warning, since it should be displayed
+to the user somehow, and could mean reduced preformance.
+
+struct portmap_error_alert: alert
+{
+ portmap_error_alert(const std::string& msg);
+ virtual std::auto_ptr<alert> clone() const;
+};
+
+
+
+
+
This alert is generated when a NAT router was successfully found and
+a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP
+capable router, this is typically generated once when mapping the TCP
+port and, if DHT is enabled, when the UDP port is mapped. This is merely
+an informational alert, and is generated at severity level info.
+
+struct portmap_alert: alert
+{
+ portmap_alert(const std::string& msg);
+ virtual std::auto_ptr<alert> clone() const;
+};
+
+
+
If the storage fails to read or write files that it needs access to, this alert is
generated and the torrent is paused. It is generated as severity level fatal.
diff --git a/docs/manual.rst b/docs/manual.rst
index bdb262069..1e047a7a7 100755
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -2503,6 +2503,43 @@ level ``fatal``.
virtual std::auto_ptr
clone() const;
};
+portmap_error_alert
+-------------------
+
+This alert is generated when a NAT router was successfully found but some
+part of the port mapping request failed. It contains a text message that
+may help the user figure out what is wrong. This alert is not generated in
+case it appears the client is not running on a NAT:ed network or if it
+appears there is no NAT router that can be remote controlled to add port
+mappings.
+
+The alert is generated as severity ``warning``, since it should be displayed
+to the user somehow, and could mean reduced preformance.
+
+::
+
+ struct portmap_error_alert: alert
+ {
+ portmap_error_alert(const std::string& msg);
+ virtual std::auto_ptr clone() const;
+ };
+
+portmap_alert
+-------------
+
+This alert is generated when a NAT router was successfully found and
+a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP
+capable router, this is typically generated once when mapping the TCP
+port and, if DHT is enabled, when the UDP port is mapped. This is merely
+an informational alert, and is generated at severity level ``info``.
+
+::
+
+ struct portmap_alert: alert
+ {
+ portmap_alert(const std::string& msg);
+ virtual std::auto_ptr clone() const;
+ };
file_error_alert
----------------
diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp
index 878185e42..5935b2415 100755
--- a/include/libtorrent/alert_types.hpp
+++ b/include/libtorrent/alert_types.hpp
@@ -249,6 +249,26 @@ namespace libtorrent
{ return std::auto_ptr(new listen_failed_alert(*this)); }
};
+ struct TORRENT_EXPORT portmap_error_alert: alert
+ {
+ portmap_error_alert(const std::string& msg)
+ : alert(alert::warning, msg)
+ {}
+
+ virtual std::auto_ptr clone() const
+ { return std::auto_ptr(new portmap_error_alert(*this)); }
+ };
+
+ struct TORRENT_EXPORT portmap_alert: alert
+ {
+ portmap_alert(const std::string& msg)
+ : alert(alert::info, msg)
+ {}
+
+ virtual std::auto_ptr clone() const
+ { return std::auto_ptr(new portmap_alert(*this)); }
+ };
+
struct TORRENT_EXPORT fastresume_rejected_alert: torrent_alert
{
fastresume_rejected_alert(torrent_handle const& h
diff --git a/src/session_impl.cpp b/src/session_impl.cpp
index 45404c7bc..330ac7ccc 100755
--- a/src/session_impl.cpp
+++ b/src/session_impl.cpp
@@ -1492,19 +1492,34 @@ namespace libtorrent { namespace detail
{
m_external_udp_port = udp_port;
m_dht_settings.service_port = udp_port;
- // TODO: generate successful port map alert
+ if (m_alerts.should_post(alert::info))
+ {
+ std::stringstream msg;
+ msg << "successfully mapped UDP port " << udp_port;
+ m_alerts.post_alert(portmap_alert(msg.str()));
+ }
}
#endif
if (tcp_port != 0)
{
m_external_listen_port = tcp_port;
- // TODO: generate successful port map alert
+ if (m_alerts.should_post(alert::info))
+ {
+ std::stringstream msg;
+ msg << "successfully mapped TCP port " << tcp_port;
+ m_alerts.post_alert(portmap_alert(msg.str()));
+ }
}
if (!errmsg.empty())
{
- // TODO: generate port map failure alert
+ if (m_alerts.should_post(alert::warning))
+ {
+ std::stringstream msg;
+ msg << "Error while mapping ports on NAT router: " << errmsg;
+ m_alerts.post_alert(portmap_error_alert(msg.str()));
+ }
}
}