00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
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 }