![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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_VIRTUALDHCP_HPP 00029 #define IP_VIRTUALDHCP_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/Pool.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 namespace ip { 00041 00042 class DHCPAck 00043 { 00044 public: 00045 DHCPAck() 00046 { 00047 address = wns::service::nl::Address(); 00048 subnetMask = wns::service::nl::Address(); 00049 } 00050 00051 DHCPAck(wns::service::nl::Address address, 00052 wns::service::nl::Address subnetMask) 00053 { 00054 this->address = address; 00055 this->subnetMask = subnetMask; 00056 } 00057 00058 wns::service::nl::Address address; 00059 wns::service::nl::Address subnetMask; 00060 }; 00061 00067 class VirtualDHCP: 00068 virtual public wns::ldk::Layer, 00069 public wns::node::component::Component 00070 { 00071 typedef wns::service::nl::Address Address; 00072 typedef wns::service::dll::UnicastDataTransmission DLLDataTransmission; 00073 public: 00080 VirtualDHCP( 00081 wns::node::Interface* _node, 00082 const wns::pyconfig::View& _pyco); 00083 00087 virtual ~VirtualDHCP(); 00088 00089 virtual void 00090 doStartup(); 00091 00092 DHCPAck 00093 request(); 00094 00095 void 00096 release(Address); 00097 00102 virtual void 00103 onNodeCreated(); 00104 00108 virtual void 00109 onWorldCreated(); 00110 00111 virtual void 00112 onShutdown(); 00113 00114 private: 00115 00119 wns::logger::Logger log; 00120 00121 wns::container::Pool<Address> ipPool; 00122 00123 Address subnetMask; 00124 }; 00125 00126 class VirtualDHCPService { 00127 00128 public: 00129 typedef wns::service::nl::Address Address; 00130 00131 VirtualDHCPService(); 00132 00133 void 00134 addSubnet(std::string subnetIdentifier, 00135 VirtualDHCP* server); 00136 00137 VirtualDHCP* 00138 getZoneManager(std::string subnetIdentifier); 00139 00140 private: 00141 wns::logger::Logger log; 00142 00143 wns::container::Registry<std::string, VirtualDHCP*> servers; 00144 }; 00145 00146 typedef wns::SingletonHolder<VirtualDHCPService> TheDHCPService; 00147 00148 } // ip 00149 #endif //_IP_VIRTUALDHCP_HPP 00150 00151
1.5.5