User Manual, Developers Guide and API Documentation

IpBinding.cpp

Go to the documentation of this file.
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 #include <CONSTANZE/IpBinding.hpp>
00028 #include <CONSTANZE/Generator.hpp>
00029 
00030 #include <WNS/StaticFactory.hpp>
00031 #include <WNS/module/Base.hpp>
00032 #include <WNS/service/nl/Address.hpp>
00033 
00034 using namespace constanze;
00035 
00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00037     constanze::IpBinding,
00038     constanze::Binding,
00039     "IpBinding",
00040     wns::PyConfigViewCreator);
00041 
00042 IpBinding::IpBinding(const wns::pyconfig::View& _pyco):
00043     pyco(_pyco),
00044     ipDataTransmission(NULL),
00045     dns(NULL),
00046     sourceDomainName(_pyco.get<wns::service::nl::FQDN>("sourceDomainName")),
00047     destinationDomainName(_pyco.get<wns::service::nl::FQDN>("destinationDomainName")),
00048     log(pyco.get("logger"))
00049 {
00050     MESSAGE_BEGIN(NORMAL, log, m, "New IpBinding created. DestinationIP="<<destinationDomainName);
00051     MESSAGE_END();
00052 }
00053 
00054 IpBinding::~IpBinding()
00055 {
00056 }
00057 
00058 void IpBinding::registerComponent(wns::node::component::Component* _component)
00059 {
00060     component = _component;
00061     ipDataTransmission =
00062       component->getService<wns::service::nl::Service*>(pyco.get<std::string>("ipDataTransmission"));
00063 
00064     dns =
00065       component->getService<wns::service::nl::DNSService*>(pyco.get<std::string>("dnsService"));
00066 }
00067 
00068 void IpBinding::sendData(const wns::osi::PDUPtr& _data){
00069     assure(dns!=NULL,"dns needed");
00070     wns::service::nl::Address sourceIpAddress(dns->lookup(sourceDomainName));
00071     wns::service::nl::Address destinationIpAddress(dns->lookup(destinationDomainName));
00072     ipDataTransmission->sendData(sourceIpAddress, destinationIpAddress, _data, wns::service::nl::Constanze);
00073 }
00074 
00075 void IpBinding::registerListener(constanze::Listener*)
00076 {
00077     // intentionally left empty
00078 }
00079 
00080 void IpBinding::initBinding(constanze::StartTrigger* _startTrigger)
00081 {
00082     _startTrigger->bindingReady();
00083 }
00084 
00085 void IpBinding::releaseBinding(constanze::StopTrigger* _stopTrigger)
00086 {
00087     _stopTrigger->bindingReady();
00088 }
00089 
00090 std::string IpBinding::printAddress() const
00091 {
00092     std::ostringstream tmp;
00093     tmp << destinationDomainName;
00094     return tmp.str();
00095 }

Generated on Thu May 24 03:32:15 2012 for openWNS by  doxygen 1.5.5