![]() |
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. 16, 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 <DLL/compoundSwitch/filter/FilterMACAddress.hpp> 00029 #include <DLL/UpperConvergence.hpp> 00030 00031 #include <WNS/pyconfig/View.hpp> 00032 #include <WNS/Assure.hpp> 00033 #include <WNS/logger/Logger.hpp> 00034 00035 using namespace dll::compoundSwitch::filter; 00036 00037 00038 STATIC_FACTORY_REGISTER_WITH_CREATOR(FilterMACAddress, 00039 dll::compoundSwitch::Filter, 00040 "dll.compoundSwitch.filter.FilterMACAddress", 00041 dll::compoundSwitch::CompoundSwitchConfigCreator); 00042 00043 FilterMACAddress::FilterMACAddress(CompoundSwitch* compoundSwitch, 00044 wns::pyconfig::View& config) : 00045 Filter(compoundSwitch, config), 00046 ucCommandName_(config.get<std::string>("upperConvergenceCommandName")), 00047 filterAddress_(config.get<wns::service::dll::UnicastAddress>("filterMACAddress")), 00048 filterTarget_(config.get<bool>("filterTarget")) 00049 { 00050 } // Filter 00051 00052 00053 00054 FilterMACAddress::~FilterMACAddress() 00055 { 00056 } // ~Filter 00057 00058 00059 00060 void 00061 FilterMACAddress::onFUNCreated() 00062 { 00063 } 00064 00065 bool 00066 FilterMACAddress::filter(const wns::ldk::CompoundPtr& compound) const 00067 { 00068 dll::UpperCommand* uc = compoundSwitch_->getFUN()->getCommandReader(ucCommandName_)->readCommand<dll::UpperCommand>(compound->getCommandPool()); 00069 00070 if(this->filterTarget_) 00071 { 00072 if(uc->peer.targetMACAddress == filterAddress_) 00073 { 00074 return true; 00075 } 00076 else 00077 { 00078 return false; 00079 } 00080 } 00081 else 00082 { 00083 if(uc->peer.sourceMACAddress == filterAddress_) 00084 { 00085 return true; 00086 } 00087 else 00088 { 00089 return false; 00090 } 00091 } 00092 }
1.5.5