User Manual, Developers Guide and API Documentation

VirtualARP.hpp

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 #ifndef IP_VIRTUALARP_HPP
00029 #define IP_VIRTUALARP_HPP
00030 
00031 #include <WNS/service/nl/Address.hpp>
00032 #include <WNS/service/dll/DataTransmission.hpp>
00033 #include <WNS/node/component/Component.hpp>
00034 #include <WNS/container/Registry.hpp>
00035 #include <WNS/ldk/fun/Main.hpp>
00036 #include <WNS/ldk/Layer.hpp>
00037 #include <WNS/logger/Logger.hpp>
00038 #include <WNS/Singleton.hpp>
00039 
00040 #include <WNS/Subject.hpp>
00041 
00042 namespace ip {
00043 
00044     class ResolveCallback
00045     {
00046     public:
00047         virtual ~ResolveCallback() {}
00048 
00049         virtual void
00050         onAddressResolved(wns::service::dll::UnicastAddress) = 0;
00051     };
00052 
00058     class VirtualARP:
00059             virtual public wns::ldk::Layer,
00060             public wns::node::component::Component
00061     {
00062     public:
00063         typedef wns::service::nl::Address NLAddress;
00064         typedef wns::service::dll::UnicastAddress DLLAddress;
00065         typedef wns::container::Registry<NLAddress, DLLAddress> ARPContainer;
00066 
00073         VirtualARP(
00074             wns::node::Interface* _node,
00075             const wns::pyconfig::View& _pyco);
00076 
00077         virtual void
00078         doStartup();
00079 
00083         virtual ~VirtualARP();
00084 
00085 
00086         void
00087         request(ResolveCallback& requester, NLAddress ip);
00088 
00089         void
00090         bind(DLLAddress macid, NLAddress ip);
00091 
00092         void
00093         unbind(NLAddress ip);
00094 
00099         virtual void
00100         onNodeCreated();
00101 
00105         virtual void
00106         onWorldCreated();
00107 
00108         virtual void
00109         onShutdown();
00110 
00111     private:
00112 
00113         class ResolveTimeout
00114         {
00115         public:
00116             ResolveTimeout(ResolveCallback& _requester, wns::service::dll::UnicastAddress _address) :
00117                 address(_address),
00118                 requester(_requester)
00119             {
00120             }
00121 
00122             void
00123             operator()()
00124             {
00125                 requester.onAddressResolved(address);
00126             }
00127 
00128         private:
00129             wns::service::dll::UnicastAddress address;
00130             ResolveCallback& requester;
00131         };
00132 
00133         simTimeType resolveDelay;
00134 
00138         wns::logger::Logger log;
00139 
00140         ARPContainer arpLookup;
00141     };
00142 
00143     class VirtualARPService {
00144 
00145     public:
00146         typedef wns::service::nl::Address Address;
00147 
00148         VirtualARPService();
00149 
00150         void
00151         addSubnet(std::string subnetIdentifier,
00152                   VirtualARP* server);
00153 
00154         VirtualARP*
00155         getZoneManager(std::string subnetIdentifier);
00156 
00157     private:
00158         wns::logger::Logger log;
00159 
00160         wns::container::Registry<std::string, VirtualARP*> servers;
00161     };
00162 
00163     typedef wns::SingletonHolder<VirtualARPService> TheARPService;
00164 
00165 } // ip
00166 #endif //_IP_VIRTUALARP_HPP
00167 
00168 

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