OverSim
RealworldDevice.cc
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #include "RealworldDevice.h"
25 
26 
28 {
29 
31 
32  // register our interface entry in IRoutingTable
33  if (stage == 0) {
35  }
36 
37 }
38 
40 {
41  InterfaceEntry *e = new InterfaceEntry();
42 
43  // interface name: our module name without special characters ([])
44  char *interfaceName = new char[strlen(getFullName())+1];
45  char *d=interfaceName;
46  for (const char *s=getFullName(); *s; s++)
47  if (isalnum(*s))
48  *d++ = *s;
49  *d = '\0';
50 
51  e->setName(interfaceName);
52  delete [] interfaceName;
53 
54  // port: index of gate where our "netwIn" is connected (in IP)
55  int outputPort = /*getParentModule()->*/gate("netwIn")->getPreviousGate()->getIndex();
56  e->setNodeOutputGateId(outputPort);
57 
58  // generate a link-layer address to be used as interface token for IPv6
59  InterfaceToken token(0, simulation.getUniqueNumber(), 64);
60  e->setInterfaceToken(token);
61 
62  // MTU: typical values are 576 (Internet de facto), 1500 (Ethernet-friendly),
63  // 4000 (on some point-to-point links), 4470 (Cisco routers default, FDDI compatible)
64  e->setMtu(mtu);
65 
66  // capabilities
67  e->setMulticast(true);
68  e->setPointToPoint(true);
69 
70  // add
71  IInterfaceTable *ift = InterfaceTableAccess().get();
72  ift->addInterface(e, this);
73 
74  return e;
75 }
76 
77