00001 /* -*- mode:c++ -*- ******************************************************** 00002 * file: ArpHost.cc 00003 * 00004 * author: Daniel Willkomm, Jerome Rousselot 00005 * 00006 * copyright: (C) 2010 CSEM SA, Neuchatel, Switzerland. 00007 * (C) 2005 Telecommunication Networks Group (TKN) at 00008 * Technische Universitaet Berlin, Germany. 00009 * 00010 * This program is free software; you can redistribute it 00011 * and/or modify it under the terms of the GNU General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2 of the License, or (at your option) any later 00014 * version. 00015 * For further information see file COPYING 00016 * in the top level directory 00017 *************************************************************************** 00018 * part of: framework implementation developed by tkn 00019 ***************************************************************************/ 00020 00021 #include "ArpHost.h" 00022 00023 Define_Module(ArpHost); 00024 00025 void ArpHost::initialize(int stage) { 00026 BaseModule::initialize(stage); 00027 if(stage==0) { 00028 offset = par("offset"); 00029 } 00030 } 00031 00032 int ArpHost::getMacAddr(const int netwAddr) 00033 { 00034 if(debug) { 00035 Enter_Method("getMacAddr(%d)",netwAddr); 00036 } else { 00037 Enter_Method_Silent(); 00038 } 00039 // modification by Jerome Rousselot, CSEM 00040 // assumes that addresses are equal to host IDs 00041 // and that mac addresses == net addresses 00042 return netwAddr; 00043 // debugEV << "for host[" << simulation.getModule( netwAddr )->getParentModule()->getIndex() 00044 // << "]: netwAddr " << netwAddr << "; MAC address " 00045 // << simulation.getModule( netwAddr )->getParentModule()->getSubmodule( "nic" )->getId() <<endl; 00046 // return simulation.getModule(netwAddr)->getParentModule()->getSubmodule("nic")->getId(); 00047 } 00048 00049 int ArpHost::getNetwAddr(const int macAddr) 00050 { 00051 if(debug) { 00052 Enter_Method("getNetwAddr(%d)",macAddr); 00053 } else { 00054 Enter_Method_Silent(); 00055 } 00056 // modification by Jerome Rousselot, CSEM 00057 // assumes that addresses are equal to host IDs 00058 // and that mac addresses == net addresses 00059 return macAddr; 00060 // debugEV << "for host[" << simulation.getModule( macAddr )->getParentModule()->getIndex() 00061 // << "]: macAddr " << macAddr << "; netw address " 00062 // << simulation.getModule( macAddr )->getParentModule()->getSubmodule("nic")->getId() <<endl; 00063 // return simulation.getModule(macAddr)->getParentModule()->getSubmodule("netw")->getId(); 00064 } 00065 00066 int ArpHost::myNetwAddr(cModule* netw) { 00067 // modification by Jerome Rousselot, CSEM 00068 // assumes that addresses are equal to host index. 00069 // and that mac addresses == net addresses 00070 return netw->getParentModule()->getIndex()+offset; 00071 // return netw->getId(); 00072 } 00073 00074 int ArpHost::myMacAddr(cModule *mac) 00075 { 00076 // modification by Jerome Rousselot, CSEM 00077 // assumes that addresses are equal to host index. 00078 // and that mac addresses == net addresses 00079 return mac->getParentModule()->getParentModule()->getIndex()+offset; 00080 // return (mac->getParentModule())->getId(); 00081 }