User Manual, Developers Guide and API Documentation

UpperConvergence.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 
00028 #include <TCP/UpperConvergence.hpp>
00029 #include <TCP/Connection.hpp>
00030 #include <TCP/Service.hpp>
00031 
00032 
00033 using namespace tcp;
00034 
00035 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00036     UpperConvergence,
00037     wns::ldk::FunctionalUnit,
00038     "tcp.upperConvergence",
00039     wns::ldk::FUNConfigCreator);
00040 
00041 UpperConvergence::UpperConvergence(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& _pyco) :
00042     wns::ldk::CommandTypeSpecifier<>(_fun),
00043     wns::ldk::HasReceptor<>(),
00044     wns::ldk::HasConnector<>(),
00045     wns::ldk::HasDeliverer<>(),
00046     wns::ldk::Forwarding<UpperConvergence>(),
00047     wns::Cloneable<UpperConvergence>(),
00048     pyco(_pyco),
00049     logger(_pyco.get("logger")),
00050     tlService(NULL),
00051     tcpHeaderFU(NULL),
00052     tcpHeaderReader(NULL)
00053 {
00054     MESSAGE_SINGLE(NORMAL,  logger, "UpperConvergence started." );
00055 }
00056 
00057 UpperConvergence::~UpperConvergence()
00058 {
00059 }
00060 
00061 void
00062 UpperConvergence::onFUNCreated()
00063 {
00064     tcpHeaderFU = getFUN()->findFriend<TCPHeader*>("tcp.tcpHeader");
00065     assure(tcpHeaderFU, "No FU for the TCP Header available!");
00066     tcpHeaderReader = getFUN()->getCommandReader("tcp.tcpHeader");
00067     assure(tcpHeaderReader, "No reader for the TCP Header available!");
00068 } // onFUNCreated
00069 
00070 void
00071 UpperConvergence::sendData(const wns::service::tl::FlowID& _flowID, const wns::osi::PDUPtr& sdu)
00072 {
00073     MESSAGE_SINGLE(NORMAL, logger, "sendData.");
00074 
00075     wns::ldk::CompoundPtr compound(new wns::ldk::Compound(getFUN()->getProxy()->createCommandPool(), sdu));
00076 
00077     assure(tcpHeaderFU, "No FU for the TCP Header available!");
00078     tcpHeaderFU->activateCommand(compound->getCommandPool());
00079 
00080     assure(tcpHeaderReader, "No reader for the TCP Header available!");
00081     TCPCommand* tcpHeader = tcpHeaderReader->readCommand<TCPCommand>(compound->getCommandPool());
00082 
00083     tcpHeader->peer.flowID = _flowID;
00084 
00085     //forwarding to flow separator
00086     if (isAccepting(compound))
00087     {
00088         wns::ldk::Forwarding<UpperConvergence>::doSendData(compound);
00089     }
00090     else
00091     {
00092         // do nothing (throw away compound)
00093         assure(false, "TCP does not accept any data from upper layer.");
00094     }
00095 }
00096 
00097 void
00098 UpperConvergence::processIncoming(const wns::ldk::CompoundPtr& _compound)
00099 {
00100     assure(tcpHeaderReader, "No reader for the TCP Header available!");
00101     TCPCommand* tcpHeader = tcpHeaderReader->readCommand<TCPCommand>(_compound->getCommandPool());
00102 
00103     wns::service::tl::FlowID flowID = tcpHeader->peer.flowID;
00104 
00105     MESSAGE_SINGLE(NORMAL, logger, "processIncoming called for flow id: " << flowID);
00106 
00111     tlService->getConnection(flowID)->onData(_compound->getData());
00112 }
00113 
00114 void
00115 UpperConvergence::setTLService(Service* _tlService)
00116 {
00117     this->tlService = _tlService;
00118 }

Generated on Sun May 27 03:31:37 2012 for openWNS by  doxygen 1.5.5