User Manual, Developers Guide and API Documentation

TunnelExitComponent.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. 5, 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 <IP/tunnel/TunnelExitComponent.hpp>
00029 
00030 #include <WNS/TypeInfo.hpp>
00031 
00032 using namespace ip::tunnel;
00033 
00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00035     TunnelExitComponent,
00036     wns::node::component::Interface,
00037     "ip.tunnelExit",
00038     wns::node::component::ConfigCreator);
00039 
00040 TunnelExitComponent::TunnelExitComponent(wns::node::Interface* _node, const wns::pyconfig::View& _pyco):
00041     wns::node::component::Component(_node, _pyco),
00042     dllHandler(NULL),
00043     log(_pyco.get("logger"))
00044 {
00045 }
00046 
00047 void
00048 TunnelExitComponent::doStartup()
00049 {
00050     // We are a DLL
00051     addService(getConfig().get<std::string>("dllNotification"), this);
00052 }
00053 
00054 TunnelExitComponent::~TunnelExitComponent()
00055 {
00056 }
00057 
00058 void
00059 TunnelExitComponent::onNodeCreated()
00060 {
00061     MESSAGE_SINGLE(NORMAL, log, "Registering with IP for IPinIP Tunneling Protocol");
00062 
00063     std::string notname= getConfig().get<std::string>("ipNotification");
00064     wns::service::nl::Notification* notification = getService<wns::service::nl::Notification*>(notname);
00065     assure(notification, "No IP Notification could be found!");
00066 
00067     // We receive IP in IP encapsulated packets
00068     notification->registerHandler(wns::service::nl::IP, this);
00069 }
00070 
00071 void
00072 TunnelExitComponent::onWorldCreated()
00073 {
00074 }
00075 
00076 void
00077 TunnelExitComponent::onShutdown()
00078 {
00079 }
00080 
00081 void
00082 TunnelExitComponent::onData(wns::service::nl::Address /*_sourceIP*/, const wns::osi::PDUPtr& _pdu)
00083 {
00084 
00085     MESSAGE_SINGLE(NORMAL, log, "Got data from IP");
00086 
00087     assure(this->dllHandler, "No DLL handler set for delivering packets at tunnel exit");
00088 
00089 //  MESSAGE_SINGLE(NORMAL, log, "Type of getUserData() is : " << wns::TypeInfo::create(*(_pdu->getUserData())).demangled());
00090 
00091     // Unpack inner IP packet and reinject to IP
00092     this->dllHandler->onData(wns::osi::PDUPtr(_pdu));
00093 }
00094 
00095 void
00096 TunnelExitComponent::registerHandler(wns::service::dll::protocolNumber protocol, wns::service::dll::Handler* handler)
00097 {
00098     MESSAGE_SINGLE(NORMAL, log, "Got registration of DLL data handler from IP");
00099 
00100     assure(protocol == wns::service::dll::IP, "You tried to register a handler other than IP to an IP Tunnel interface");
00101 
00102     this->dllHandler = handler;
00103 }

Generated on Sat May 26 03:32:16 2012 for openWNS by  doxygen 1.5.5