User Manual, Developers Guide and API Documentation

VirtualDNS.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/VirtualDNS.hpp>
00029 #include <WNS/module/Base.hpp>
00030 #include <WNS/logger/Logger.hpp>
00031 
00032 using namespace ip;
00033 
00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00035     VirtualDNS,
00036     wns::node::component::Interface,
00037     "ip.VDNS",
00038     wns::node::component::ConfigCreator);
00039 
00040 VirtualDNSService::VirtualDNSService():
00041     log("IP", "VDNS", wns::simulator::getMasterLogger())
00042 {
00043 }
00044 
00045 void
00046 VirtualDNSService::addSubnet(std::string zoneIdentifier,
00047                              VirtualDNS* server)
00048 {
00049     servers.insert(zoneIdentifier, server);
00050 }
00051 
00052 VirtualDNS*
00053 VirtualDNSService::getZoneManager(std::string zoneIdentifier)
00054 {
00055     return servers.find(zoneIdentifier);
00056 }
00057 
00058 VirtualDNS::VirtualDNS(wns::node::Interface* _node, const wns::pyconfig::View& _pyco) :
00059     wns::node::component::Component(_node, _pyco),
00060     log(_pyco.get("logger"))
00061 {
00062     TheDNSService::Instance().addSubnet(_pyco.get<std::string>("zoneIdentifier"),
00063                                         this);
00064 
00065     MESSAGE_BEGIN(NORMAL, log, m, "New DNS zone for ");
00066     m << _pyco.get<std::string>("zoneIdentifier");
00067     MESSAGE_END();
00068 }
00069 
00070 
00071 VirtualDNS::NLAddress
00072 VirtualDNS::request(DomainName name)
00073 {
00074     VirtualDNS::NLAddress ip = dnsLookup.find(name);
00075     MESSAGE_BEGIN(NORMAL, log, m, "Received request. Resolving ");
00076     m << name << " to ";
00077     m << ip;
00078     MESSAGE_END();
00079 
00080     return ip;
00081 }
00082 
00083 void
00084 VirtualDNS::bind(VirtualDNS::DomainName name, VirtualDNS::NLAddress ip)
00085 {
00086     MESSAGE_BEGIN(NORMAL, log, m, "Domain ");
00087     m << name << " is at " << ip;
00088     MESSAGE_END();
00089 
00090     dnsLookup.insert(name, ip);
00091 }
00092 
00093 void
00094 VirtualDNS::unbind(VirtualDNS::DomainName name)
00095 {
00096     MESSAGE_BEGIN(NORMAL, log, m, "Unbinding ");
00097     m << name;
00098     MESSAGE_END();
00099 
00100     dnsLookup.erase(name);
00101 }
00102 
00103 VirtualDNS::~VirtualDNS()
00104 {
00105 }
00106 
00107 void
00108 VirtualDNS::doStartup()
00109 {
00110     MESSAGE_SINGLE(NORMAL, log, "Starting VDNS Service.");
00111 }
00112 
00113 void
00114 VirtualDNS::onNodeCreated()
00115 {
00116 }
00117 
00118 void
00119 VirtualDNS::onWorldCreated()
00120 {
00121 }
00122 
00123 void
00124 VirtualDNS::onShutdown()
00125 {
00126 }
00127 
00128 
00129 

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