BaseArp.cc

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