![]() |
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 #include <IP/VirtualARP.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 VirtualARP, 00036 wns::node::component::Interface, 00037 "ip.VARP", 00038 wns::node::component::ConfigCreator); 00039 00040 VirtualARPService::VirtualARPService(): 00041 log("IP", "VARP", wns::simulator::getMasterLogger()) 00042 { 00043 MESSAGE_SINGLE(NORMAL, log, "Starting VARP Service."); 00044 } 00045 00046 void 00047 VirtualARPService::addSubnet(std::string subnetIdentifier, 00048 VirtualARP* server) 00049 { 00050 servers.insert(subnetIdentifier, server); 00051 } 00052 00053 VirtualARP* 00054 VirtualARPService::getZoneManager(std::string subnetIdentifier) 00055 { 00056 return servers.find(subnetIdentifier); 00057 } 00058 00059 VirtualARP::VirtualARP(wns::node::Interface* _node, const wns::pyconfig::View& _pyco) : 00060 wns::node::component::Component(_node, _pyco), 00061 resolveDelay(_pyco.get<simTimeType>("resolveDelay")), 00062 log(_pyco.get("logger")) 00063 { 00064 TheARPService::Instance().addSubnet(_pyco.get<std::string>("subnetIdentifier"), 00065 this); 00066 MESSAGE_BEGIN(NORMAL, log, m, "New ARP zone for "); 00067 m << _pyco.get<std::string>("subnetIdentifier"); 00068 MESSAGE_END(); 00069 } 00070 00071 00072 void 00073 VirtualARP::request(ResolveCallback& requester, NLAddress ip) 00074 { 00075 VirtualARP::DLLAddress macid = arpLookup.find(ip); 00076 MESSAGE_BEGIN(NORMAL, log, m, "Received request. Resolving "); 00077 m << ip << " to "; 00078 m << macid << " in t=" << resolveDelay; 00079 MESSAGE_END(); 00080 00081 wns::simulator::getEventScheduler()->scheduleDelay(ResolveTimeout(requester, macid), resolveDelay); 00082 } 00083 00084 void 00085 VirtualARP::bind(VirtualARP::DLLAddress macid, VirtualARP::NLAddress ip) 00086 { 00087 MESSAGE_BEGIN(NORMAL, log, m, "MAC address "); 00088 m << macid << " has " << ip; 00089 MESSAGE_END(); 00090 00091 arpLookup.insert(ip, macid); 00092 } 00093 00094 void 00095 VirtualARP::unbind(VirtualARP::NLAddress ip) 00096 { 00097 MESSAGE_BEGIN(NORMAL, log, m, "Unbinding "); 00098 m << ip; 00099 MESSAGE_END(); 00100 00101 arpLookup.erase(ip); 00102 } 00103 00104 VirtualARP::~VirtualARP() 00105 { 00106 } 00107 00108 void 00109 VirtualARP::doStartup() 00110 { 00111 } 00112 00113 void 00114 VirtualARP::onNodeCreated() 00115 { 00116 } 00117 00118 void 00119 VirtualARP::onWorldCreated() 00120 { 00121 } 00122 00123 void 00124 VirtualARP::onShutdown() 00125 { 00126 } 00127 00128 00129
1.5.5