User Manual, Developers Guide and API Documentation

PathSelectionOverVPS.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiFiMac                                                                    *
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 <WIFIMAC/Layer2.hpp>
00030 #include <WIFIMAC/pathselection/PathSelectionOverVPS.hpp>
00031 #include <WNS/service/dll/StationTypes.hpp>
00032 
00033 using namespace wifimac::pathselection;
00034 
00035 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00036     wifimac::pathselection::PathSelectionOverVPS,
00037     wns::ldk::ManagementServiceInterface,
00038     "wifimac.pathselection.PathSelectionOverVPS",
00039     wns::ldk::MSRConfigCreator);
00040 
00041 PathSelectionOverVPS::PathSelectionOverVPS( wns::ldk::ManagementServiceRegistry* msr, const wns::pyconfig::View& config):
00042     wns::ldk::ManagementService(msr),
00043     logger(config.get("logger")),
00044     upperConvergenceName(config.get<std::string>("upperConvergenceName"))
00045 {
00046     MESSAGE_SINGLE(NORMAL, logger, " Created Service");
00047 }
00048 
00049 void
00050 PathSelectionOverVPS::onMSRCreated()
00051 {
00052     assure(getMSR()->getLayer<wifimac::Layer2*>()->getStationType() != wns::service::dll::StationTypes::UT(),
00053            "PathSelectionOverVPS cannot belong to a UT");
00054 
00055     assure(TheVPSService::Instance().getVPS(), "No virtual path selection service found");
00056 
00057     this->startObserving(getMSR()->getLayer<wifimac::Layer2*>()->getControlService<dll::services::control::Association>("ASSOCIATION"));
00058 
00059     if(getMSR()->getLayer<wifimac::Layer2*>()->getStationType() == wns::service::dll::StationTypes::AP())
00060     {
00061         TheVPSService::Instance().getVPS()->registerPortal(this->getMSR()->getLayer<wifimac::Layer2*>()->getDLLAddress(),
00062                                                            this->getMSR()->getLayer<wifimac::Layer2*>()->getFUN()
00063                                                            ->findFriend<dll::APUpperConvergence*>(upperConvergenceName));
00064     }
00065     else
00066     {
00067         TheVPSService::Instance().getVPS()->registerMP(this->getMSR()->getLayer<wifimac::Layer2*>()->getDLLAddress());
00068     }
00069 
00070 
00071     MESSAGE_SINGLE(NORMAL, logger, "Created.");
00072 }
00073 
00074 wns::service::dll::UnicastAddress
00075 PathSelectionOverVPS::getNextHop(const wns::service::dll::UnicastAddress current,
00076                                  const wns::service::dll::UnicastAddress finalDestination)
00077 {
00078     assure(current.isValid(), "Address current is not valid");
00079     assure(finalDestination.isValid(), "Address finalDestination is not valid");
00080 
00081     return(TheVPSService::Instance().getVPS()->getNextHop(current, finalDestination));
00082 }
00083 
00084 
00085 bool
00086 PathSelectionOverVPS::isMeshPoint(const wns::service::dll::UnicastAddress address) const
00087 {
00088     assure(address.isValid(), "Address is not valid");
00089 
00090     return(TheVPSService::Instance().getVPS()->isMeshPoint(address));
00091 }
00092 
00093 bool
00094 PathSelectionOverVPS::isPortal(const wns::service::dll::UnicastAddress address) const
00095 {
00096     assure(address.isValid(), "Address is not valid");
00097 
00098     return(TheVPSService::Instance().getVPS()->isPortal(address));
00099 }
00100 
00101 wns::service::dll::UnicastAddress
00102 PathSelectionOverVPS::getPortalFor(const wns::service::dll::UnicastAddress address)
00103 {
00104     assure(address.isValid(), "Address is not valid");
00105 
00106     return(TheVPSService::Instance().getVPS()->getPortalFor(address));
00107 }
00108 
00109 wns::service::dll::UnicastAddress
00110 PathSelectionOverVPS::getProxyFor(const wns::service::dll::UnicastAddress address)
00111 {
00112     assure(address.isValid(), "Address is not valid");
00113 
00114     return(TheVPSService::Instance().getVPS()->getProxyFor(address));
00115 }
00116 
00117 void
00118 PathSelectionOverVPS::registerProxy(const wns::service::dll::UnicastAddress server,
00119                     const wns::service::dll::UnicastAddress client)
00120 {
00121     assure(server.isValid(), "Address server is not valid");
00122     assure(client.isValid(), "Address client is not valid");
00123 
00124     TheVPSService::Instance().getVPS()->registerProxy(server, client);
00125 }
00126 
00127 void
00128 PathSelectionOverVPS::registerMP(const wns::service::dll::UnicastAddress address)
00129 {
00130     assure(address.isValid(), "Address is not valid");
00131 
00132     TheVPSService::Instance().getVPS()->registerMP(address);
00133 }
00134 
00135 void
00136 PathSelectionOverVPS::registerPortal(const wns::service::dll::UnicastAddress address,
00137                                      dll::APUpperConvergence* apUC)
00138 {
00139     assure(address.isValid(), "Address is not valid");
00140 
00141     TheVPSService::Instance().getVPS()->registerPortal(address, apUC);
00142 }
00143 
00144 void
00145 PathSelectionOverVPS::deRegisterProxy(const wns::service::dll::UnicastAddress server,
00146                                       const wns::service::dll::UnicastAddress client)
00147 {
00148     assure(server.isValid(), "Address is not valid");
00149     assure(client.isValid(), "Address is not valid");
00150 
00151     TheVPSService::Instance().getVPS()->deRegisterProxy(server, client);
00152 }
00153 
00154 void
00155 PathSelectionOverVPS::createPeerLink(const wns::service::dll::UnicastAddress myself,
00156                                      const wns::service::dll::UnicastAddress peer,
00157                                      const Metric linkMetric)
00158 {
00159     assure(myself.isValid(), "Address is not valid");
00160     assure(peer.isValid(), "Address is not valid");
00161 
00162     TheVPSService::Instance().getVPS()->createPeerLink(myself, peer, linkMetric);
00163 }
00164 void
00165 PathSelectionOverVPS::updatePeerLink(const wns::service::dll::UnicastAddress myself,
00166                                      const wns::service::dll::UnicastAddress peer,
00167                                      const Metric linkMetric)
00168 {
00169     assure(myself.isValid(), "Address is not valid");
00170     assure(peer.isValid(), "Address is not valid");
00171 
00172     TheVPSService::Instance().getVPS()->updatePeerLink(myself, peer, linkMetric);
00173 }
00174 
00175 void
00176 PathSelectionOverVPS::closePeerLink(const wns::service::dll::UnicastAddress myself,
00177                                     const wns::service::dll::UnicastAddress peer)
00178 {
00179     assure(myself.isValid(), "Address is not valid");
00180     assure(peer.isValid(), "Address is not valid");
00181 
00182     TheVPSService::Instance().getVPS()->closePeerLink(myself, peer);
00183 }
00184 
00185 void PathSelectionOverVPS::onAssociated(const wns::service::dll::UnicastAddress slave,
00186                                         const wns::service::dll::UnicastAddress master)
00187 {
00188     assure(slave.isValid(), "Slave address is not valid");
00189     assure(master.isValid(), "Master address is not valid");
00190 
00191     MESSAGE_SINGLE(NORMAL, logger, slave << " is associated to " << master << ", register as proxy");
00192     TheVPSService::Instance().getVPS()->registerProxy(master, slave);
00193 }
00194 
00195 void PathSelectionOverVPS::onDisassociated(const wns::service::dll::UnicastAddress slave,
00196                                            const wns::service::dll::UnicastAddress master)
00197 {
00198     assure(slave.isValid(), "Slave address is not valid");
00199     assure(master.isValid(), "Master address is not valid");
00200 
00201     TheVPSService::Instance().getVPS()->deRegisterProxy(master, slave);
00202 }
00203 
00204 

Generated on Fri May 25 03:32:14 2012 for openWNS by  doxygen 1.5.5