![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WiFiMAC (IEEE 802.11) * 00003 * This file is part of openWNS (open Wireless Network Simulator) 00004 * _____________________________________________________________________________ 00005 * 00006 * Copyright (C) 2004-2007 00007 * Chair of Communication Networks (ComNets) 00008 * Kopernikusstr. 16, D-52074 Aachen, Germany 00009 * phone: ++49-241-80-27910, 00010 * fax: ++49-241-80-22242 00011 * email: info@openwns.org 00012 * www: http://www.openwns.org 00013 * _____________________________________________________________________________ 00014 * 00015 * openWNS is free software; you can redistribute it and/or modify it under the 00016 * terms of the GNU Lesser General Public License version 2 as published by the 00017 * Free Software Foundation; 00018 * 00019 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00021 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00022 * details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ******************************************************************************/ 00028 00029 #include <WIMAC/helper/ContextProvider.hpp> 00030 #include <WIMAC/StationManager.hpp> 00031 #include <WIMAC/Component.hpp> 00032 #include <WNS/service/dll/Address.hpp> 00033 00034 using namespace wimac::helper::contextprovider; 00035 00036 00037 SourceAddress::SourceAddress(wns::ldk::fun::FUN* fun, std::string ucCommandName): 00038 wns::probe::bus::CommandContextProvider<wimac::UpperCommand>( 00039 fun, ucCommandName, "MAC.SourceId") 00040 { 00041 } 00042 00043 SourceAddress::~SourceAddress() 00044 { 00045 } 00046 00047 void 00048 SourceAddress::doVisitCommand(wns::probe::bus::IContext& c, const wimac::UpperCommand* command) const 00049 { 00050 if(command->peer.sourceMACAddress.isValid()) 00051 { 00052 c.insertInt(this->key, command->peer.sourceMACAddress.getInteger()); 00053 } 00054 } 00055 00056 TargetAddress::TargetAddress(wns::ldk::fun::FUN* fun, std::string ucCommandName): 00057 wns::probe::bus::CommandContextProvider<wimac::UpperCommand>( 00058 fun, ucCommandName, "MAC.TargetId") 00059 { 00060 } 00061 00062 TargetAddress::~TargetAddress() 00063 { 00064 } 00065 00066 void 00067 TargetAddress::doVisitCommand(wns::probe::bus::IContext& c, const wimac::UpperCommand* command) const 00068 { 00069 if(command->peer.sourceMACAddress.isValid()) 00070 { 00071 c.insertInt(this->key, command->peer.targetMACAddress.getInteger()); 00072 } 00073 } 00074 00075 00076 CallbackCommandContextProvider::CallbackCommandContextProvider(wns::ldk::fun::FUN* fun, 00077 std::string ucCommandName, 00078 const std::string& key, 00079 boost::function1<int, wimac::Component*> callback) 00080 : wns::probe::bus::CommandContextProvider<wimac::UpperCommand>(fun, ucCommandName, key), 00081 callback_(callback) 00082 {} 00083 00084 00085 void 00086 CallbackCommandContextProvider::doVisitCommand(wns::probe::bus::IContext& c, const wimac::UpperCommand* command) const 00087 { 00088 if (command->peer.sourceMACAddress.isValid()) 00089 { 00090 Component* component = TheStationManager::getInstance() 00091 ->getStationByID(command->peer.sourceMACAddress.getInteger()); 00092 int value = callback_(component); 00093 c.insertInt(getKey() + ".Source", value); 00094 } 00095 if (command->peer.targetMACAddress.isValid()) 00096 { 00097 Component* component = TheStationManager::getInstance() 00098 ->getStationByID(command->peer.targetMACAddress.getInteger()); 00099 int value = callback_(component); 00100 c.insertInt(getKey() + ".Target", value); 00101 } 00102 }
1.5.5