~ubuntu-branches/ubuntu/oneiric/libtorrent-rasterbar/oneiric

« back to all changes in this revision

Viewing changes to src/upnp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-08-10 12:57:25 UTC
  • mfrom: (1.3.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125725-i2o9iblow20w7qde
Tags: 0.15.1-0ubuntu1
* New upstream point release.

* New package libtorrent-rasterbar6 (bump up library soname). (LP: #615950)
 - Must Conflict/Replace libtorrent-rasterbar5 (= 0.15.0-0ubuntu1) or it will
   fail to install trying to overwrite '/usr/lib/libtorrent-rasterbar.so.6.0.0'

* Sync on git.debian.org/collab-maint/libtorrent-rasterbar.git:
 - debian/{control,rules}: Bump debhelper build-dep to (>= 7.4.10)
   and pass to dh in order to enable parallel build support.
 - debian/watch: Use googlecode.debian.net redirector.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
#include <boost/thread/mutex.hpp>
54
54
#include <cstdlib>
55
55
 
56
 
using boost::bind;
57
56
using namespace libtorrent;
58
57
 
59
58
static error_code ec;
68
67
        , m_retry_count(0)
69
68
        , m_io_service(ios)
70
69
        , m_socket(ios, udp::endpoint(address_v4::from_string("239.255.255.250", ec), 1900)
71
 
                , bind(&upnp::on_reply, self(), _1, _2, _3))
 
70
                , boost::bind(&upnp::on_reply, self(), _1, _2, _3))
72
71
        , m_broadcast_timer(ios)
73
72
        , m_refresh_timer(ios)
74
73
        , m_disabled(false)
147
146
 
148
147
        ++m_retry_count;
149
148
        m_broadcast_timer.expires_from_now(seconds(2 * m_retry_count), ec);
150
 
        m_broadcast_timer.async_wait(bind(&upnp::resend_request
 
149
        m_broadcast_timer.async_wait(boost::bind(&upnp::resend_request
151
150
                , self(), _1));
152
151
 
153
152
        log("broadcasting search for rootdevice", l);
284
283
                                log(msg, l);
285
284
                                if (d.upnp_connection) d.upnp_connection->close();
286
285
                                d.upnp_connection.reset(new http_connection(m_io_service
287
 
                                        , m_cc, bind(&upnp::on_upnp_xml, self(), _1, _2
 
286
                                        , m_cc, boost::bind(&upnp::on_upnp_xml, self(), _1, _2
288
287
                                        , boost::ref(d), _5)));
289
288
                                d.upnp_connection->get(d.url, seconds(30), 1);
290
289
#ifndef BOOST_NO_EXCEPTIONS
371
370
        {
372
371
                std::vector<ip_route> routes = enum_routes(m_io_service, ec);
373
372
                if (std::find_if(routes.begin(), routes.end()
374
 
                        , bind(&ip_route::gateway, _1) == from.address()) == routes.end())
 
373
                        , boost::bind(&ip_route::gateway, _1) == from.address()) == routes.end())
375
374
                {
376
375
                        // this upnp device is filtered because it's not in the
377
376
                        // list of configured routers
546
545
 
547
546
                                        if (d.upnp_connection) d.upnp_connection->close();
548
547
                                        d.upnp_connection.reset(new http_connection(m_io_service
549
 
                                                , m_cc, bind(&upnp::on_upnp_xml, self(), _1, _2
 
548
                                                , m_cc, boost::bind(&upnp::on_upnp_xml, self(), _1, _2
550
549
                                                , boost::ref(d), _5)));
551
550
                                        d.upnp_connection->get(d.url, seconds(30), 1);
552
551
#ifndef BOOST_NO_EXCEPTIONS
693
692
 
694
693
                if (d.upnp_connection) d.upnp_connection->close();
695
694
                d.upnp_connection.reset(new http_connection(m_io_service
696
 
                        , m_cc, bind(&upnp::on_upnp_map_response, self(), _1, _2
 
695
                        , m_cc, boost::bind(&upnp::on_upnp_map_response, self(), _1, _2
697
696
                        , boost::ref(d), i, _5), true
698
 
                        , bind(&upnp::create_port_mapping, self(), _1, boost::ref(d), i)));
 
697
                        , boost::bind(&upnp::create_port_mapping, self(), _1, boost::ref(d), i)));
699
698
 
700
699
                d.upnp_connection->start(d.hostname, to_string(d.port).elems
701
700
                        , seconds(10), 1);
704
703
        {
705
704
                if (d.upnp_connection) d.upnp_connection->close();
706
705
                d.upnp_connection.reset(new http_connection(m_io_service
707
 
                        , m_cc, bind(&upnp::on_upnp_unmap_response, self(), _1, _2
 
706
                        , m_cc, boost::bind(&upnp::on_upnp_unmap_response, self(), _1, _2
708
707
                        , boost::ref(d), i, _5), true
709
 
                        , bind(&upnp::delete_port_mapping, self(), boost::ref(d), i)));
 
708
                        , boost::bind(&upnp::delete_port_mapping, self(), boost::ref(d), i)));
710
709
                d.upnp_connection->start(d.hostname, to_string(d.port).elems
711
710
                        , seconds(10), 1);
712
711
        }
878
877
        parse_state s;
879
878
        s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
880
879
        xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
881
 
                , bind(&find_control_url, _1, _2, boost::ref(s)));
 
880
                , boost::bind(&find_control_url, _1, _2, boost::ref(s)));
882
881
        if (!s.control_url.empty())
883
882
        {
884
883
                d.service_namespace = s.service_type;
890
889
                // a PPP connection
891
890
                s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
892
891
                xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
893
 
                        , bind(&find_control_url, _1, _2, boost::ref(s)));
 
892
                        , boost::bind(&find_control_url, _1, _2, boost::ref(s)));
894
893
                if (!s.control_url.empty())
895
894
                {
896
895
                        d.service_namespace = s.service_type;
1041
1040
        error_code_t* end = error_codes + num_errors;
1042
1041
        error_code_t tmp = {ev, 0};
1043
1042
        error_code_t* e = std::lower_bound(error_codes, end, tmp
1044
 
                , bind(&error_code_t::code, _1) < bind(&error_code_t::code, _2));
 
1043
                , boost::bind(&error_code_t::code, _1) < boost::bind(&error_code_t::code, _2));
1045
1044
        if (e != end && e->code == ev)
1046
1045
        {
1047
1046
                return e->msg;
1119
1118
 
1120
1119
        error_code_parse_state s;
1121
1120
        xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
1122
 
                , bind(&find_error_code, _1, _2, boost::ref(s)));
 
1121
                , boost::bind(&find_error_code, _1, _2, boost::ref(s)));
1123
1122
 
1124
1123
        if (s.error_code != -1)
1125
1124
        {
1189
1188
                        {
1190
1189
                                error_code ec;
1191
1190
                                m_refresh_timer.expires_at(m.expires, ec);
1192
 
                                m_refresh_timer.async_wait(bind(&upnp::on_expire, self(), _1));
 
1191
                                m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
1193
1192
                        }
1194
1193
                }
1195
1194
                else
1208
1207
        error_code_t* end = error_codes + num_errors;
1209
1208
        error_code_t tmp = {code, 0};
1210
1209
        error_code_t* e = std::lower_bound(error_codes, end, tmp
1211
 
                , bind(&error_code_t::code, _1) < bind(&error_code_t::code, _2));
 
1210
                , boost::bind(&error_code_t::code, _1) < boost::bind(&error_code_t::code, _2));
1212
1211
        std::string error_string = "UPnP mapping error ";
1213
1212
        error_string += to_string(code).elems;
1214
1213
        if (e != end && e->code == code)
1299
1298
        {
1300
1299
                error_code ec;
1301
1300
                m_refresh_timer.expires_at(next_expire, ec);
1302
 
                m_refresh_timer.async_wait(bind(&upnp::on_expire, self(), _1));
 
1301
                m_refresh_timer.async_wait(boost::bind(&upnp::on_expire, self(), _1));
1303
1302
        }
1304
1303
}
1305
1304