fixed bug in UPnP and added functionality to grab router model

This commit is contained in:
Arvid Norberg 2007-12-22 16:47:46 +00:00
parent e38c0c9cdc
commit 1724ce5974
2 changed files with 18 additions and 3 deletions

View File

@ -77,6 +77,8 @@ public:
void close();
std::string router_model() { return m_model; }
private:
static address_v4 upnp_multicast_address;
@ -233,6 +235,8 @@ private:
connection_queue& m_cc;
std::string m_model;
#ifdef TORRENT_UPNP_LOGGING
std::ofstream m_log;
#endif

View File

@ -578,6 +578,7 @@ namespace
std::string top_tag;
std::string control_url;
char const* service_type;
std::string model;
};
void find_control_url(int type, char const* string, parse_state& state)
@ -591,6 +592,10 @@ namespace
{
state.top_tag = string;
}
else if (!strcmp(string, "modelName"))
{
state.top_tag = string;
}
}
else if (type == xml_end_tag)
{
@ -614,6 +619,10 @@ namespace
state.control_url = string;
if (state.found_service) state.exit = true;
}
else if (state.top_tag == "modelName")
{
state.model = string;
}
}
}
@ -663,10 +672,11 @@ void upnp::on_upnp_xml(asio::error_code const& e
parse_state s;
s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
, m_strand.wrap(bind(&find_control_url, _1, _2, boost::ref(s))));
, bind(&find_control_url, _1, _2, boost::ref(s)));
if (s.found_service)
{
d.service_namespace = s.service_type;
if (!s.model.empty()) m_model = s.model;
}
else
{
@ -674,10 +684,11 @@ void upnp::on_upnp_xml(asio::error_code const& e
// a PPP connection
s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
, m_strand.wrap(bind(&find_control_url, _1, _2, boost::ref(s))));
, bind(&find_control_url, _1, _2, boost::ref(s)));
if (s.found_service)
{
d.service_namespace = s.service_type;
if (!s.model.empty()) m_model = s.model;
}
else
{
@ -821,7 +832,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
error_code_parse_state s;
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
, m_strand.wrap(bind(&find_error_code, _1, _2, boost::ref(s))));
, bind(&find_error_code, _1, _2, boost::ref(s)));
#ifdef TORRENT_UPNP_LOGGING
if (s.error_code != -1)