~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to src/ip_filter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include "libtorrent/ip_filter.hpp"
36
36
#include <boost/utility.hpp>
37
 
//#include <iostream>
38
37
 
39
38
 
40
39
namespace libtorrent
46
45
                        TORRENT_ASSERT(last.is_v4());
47
46
                        m_filter4.add_rule(first.to_v4().to_bytes(), last.to_v4().to_bytes(), flags);
48
47
                }
 
48
#if TORRENT_USE_IPV6
49
49
                else if (first.is_v6())
50
50
                {
51
51
                        TORRENT_ASSERT(last.is_v6());
52
52
                        m_filter6.add_rule(first.to_v6().to_bytes(), last.to_v6().to_bytes(), flags);
53
53
                }
 
54
#endif
54
55
                else
55
56
                        TORRENT_ASSERT(false);
56
57
        }
59
60
        {
60
61
                if (addr.is_v4())
61
62
                        return m_filter4.access(addr.to_v4().to_bytes());
 
63
#if TORRENT_USE_IPV6
62
64
                TORRENT_ASSERT(addr.is_v6());
63
65
                return m_filter6.access(addr.to_v6().to_bytes());
 
66
#else
 
67
                return 0;
 
68
#endif
64
69
        }
65
70
 
66
71
        ip_filter::filter_tuple_t ip_filter::export_filter() const
67
72
        {
 
73
#if TORRENT_USE_IPV6
68
74
                return boost::make_tuple(m_filter4.export_filter<address_v4>()
69
75
                        , m_filter6.export_filter<address_v6>());
 
76
#else
 
77
                return boost::make_tuple(m_filter4.export_filter<address_v4>()
 
78
                        , std::vector<ip_range<address_v6> >());
 
79
#endif
70
80
        }
71
81
        
72
82
        void port_filter::add_rule(boost::uint16_t first, boost::uint16_t last, int flags)