00001 // 00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00024 #include "RealworldDevice.h" 00025 00026 00027 void RealworldDevice::initialize(int stage) 00028 { 00029 00030 RealworldConnector::initialize(stage); 00031 00032 // register our interface entry in IRoutingTable 00033 if (stage == 0) { 00034 interfaceEntry = registerInterface(); 00035 } 00036 00037 } 00038 00039 InterfaceEntry *RealworldDevice::registerInterface() 00040 { 00041 InterfaceEntry *e = new InterfaceEntry(); 00042 00043 // interface name: our module name without special characters ([]) 00044 char *interfaceName = new char[strlen(getFullName())+1]; 00045 char *d=interfaceName; 00046 for (const char *s=getFullName(); *s; s++) 00047 if (isalnum(*s)) 00048 *d++ = *s; 00049 *d = '\0'; 00050 00051 e->setName(interfaceName); 00052 delete [] interfaceName; 00053 00054 // port: index of gate where our "netwIn" is connected (in IP) 00055 int outputPort = /*getParentModule()->*/gate("netwIn")->getPreviousGate()->getIndex(); 00056 e->setNodeOutputGateId(outputPort); 00057 00058 // generate a link-layer address to be used as interface token for IPv6 00059 InterfaceToken token(0, simulation.getUniqueNumber(), 64); 00060 e->setInterfaceToken(token); 00061 00062 // MTU: typical values are 576 (Internet de facto), 1500 (Ethernet-friendly), 00063 // 4000 (on some point-to-point links), 4470 (Cisco routers default, FDDI compatible) 00064 e->setMtu(mtu); 00065 00066 // capabilities 00067 e->setMulticast(true); 00068 e->setPointToPoint(true); 00069 00070 // add 00071 IInterfaceTable *ift = InterfaceTableAccess().get(); 00072 ift->addInterface(e, this); 00073 00074 return e; 00075 } 00076 00077
1.5.5