![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #include <IP/iptables/filters/SourceDestinationFilter.hpp> 00029 #include <IP/IPHeader.hpp> 00030 00031 #include <WNS/pyconfig/View.hpp> 00032 00033 using namespace ip::iptables::filters; 00034 00035 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00036 SourceDestinationFilter, 00037 FilterInterface, 00038 "sourceDestinationFilter", 00039 wns::PyConfigViewCreator); 00040 00041 SourceDestinationFilter::SourceDestinationFilter(const wns::pyconfig::View& _pyco): 00042 source(wns::service::nl::Address(_pyco.get<std::string>("source"))), 00043 sourceMask(wns::service::nl::Address(_pyco.get<std::string>("sourceMask"))), 00044 destination(wns::service::nl::Address(_pyco.get<std::string>("destination"))), 00045 destinationMask(wns::service::nl::Address(_pyco.get<std::string>("destinationMask"))) 00046 { 00047 } 00048 00049 SourceDestinationFilter::SourceDestinationFilter(wns::service::nl::Address _source, 00050 wns::service::nl::Address _sourceMask, 00051 wns::service::nl::Address _destination, 00052 wns::service::nl::Address _destinationMask) 00053 { 00054 source = _source; 00055 sourceMask = _sourceMask; 00056 destination = _destination; 00057 destinationMask = _destinationMask; 00058 } 00059 00060 bool 00061 SourceDestinationFilter::fires(const IPCommand* ipHeader) 00062 { 00063 return (source == (ipHeader->peer.source & sourceMask)) && (destination == (ipHeader->peer.destination & destinationMask)); 00064 } 00065 00066 bool 00067 SourceDestinationFilter::fires(const IPCommand* ipHeader, const wns::service::tl::IUDPHeader*) 00068 { 00069 return fires(ipHeader); 00070 } 00071 00072 bool 00073 SourceDestinationFilter::fires(const IPCommand* ipHeader, const wns::service::tl::ITCPHeader*) 00074 { 00075 return fires(ipHeader); 00076 } 00077 00078 bool 00079 SourceDestinationFilter::operator ==(const SourceDestinationFilter& other) const 00080 { 00081 return ((source == other.source) && 00082 (sourceMask == other.sourceMask) && 00083 (destination == other.destination) && 00084 (destinationMask == other.destinationMask)); 00085 }
1.5.5