00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 */ 00004 00005 00006 00007 00008 #include "libtorrent/ip_filter.hpp" 00009 #include <boost/utility.hpp> 00010 00011 namespace libtorrent 00012 { 00013 void ip_filter::add_rule(address first, address last, int flags) 00014 { 00015 if (first.is_v4()) 00016 { 00017 assert(last.is_v4()); 00018 m_filter4.add_rule(first.to_v4(), last.to_v4(), flags); 00019 } 00020 else if (first.is_v6()) 00021 { 00022 assert(last.is_v6()); 00023 m_filter6.add_rule(first.to_v6(), last.to_v6(), flags); 00024 } 00025 else 00026 assert(false); 00027 } 00028 00029 int ip_filter::access(address const& addr) const 00030 { 00031 if (addr.is_v4()) 00032 return m_filter4.access(addr.to_v4()); 00033 assert(addr.is_v6()); 00034 return m_filter6.access(addr.to_v6()); 00035 } 00036 00037 ip_filter::filter_tuple_t ip_filter::export_filter() const 00038 { 00039 return boost::make_tuple(m_filter4.export_filter() 00040 , m_filter6.export_filter()); 00041 } 00042 00043 00044 } 00045
1.5.6