29 #include <IRoutingTable.h>
30 #include <IInterfaceTable.h>
31 #include <RoutingTable6.h>
32 #include <IPAddressResolver.h>
33 #include <IPv4InterfaceData.h>
34 #include <IPv6InterfaceData.h>
53 useIPv6 = par(
"useIPv6Addresses").boolValue();
62 channelTypesTx = cStringTokenizer(par(
"channelTypes"),
" ").asVector();
63 channelTypesRx = cStringTokenizer(par(
"channelTypesRx"),
" ").asVector();
85 error(
"this module doesn't handle messages, it runs only in initialize()");
90 Enter_Method(
"addOverlayNode()");
94 terminal.
interfaceTable = IPAddressResolver().interfaceTableOf(node);
97 terminal.
routingTable6 = IPAddressResolver().routingTable6Of(node);
100 terminal.
routingTable = IPAddressResolver().routingTableOf(node);
117 terminal.
IPAddress = IPvXAddress(IPv6Address(candidate.
d0, candidate.
d1, candidate.
d2, candidate.
d3));
122 bool ip_test =
false;
123 for (uint32 ipOffset =
lastIP + 1; ipOffset !=
lastIP; ipOffset++) {
124 if ( ipOffset == 0x10000) {
130 uint32_t ip = routerAddr + ipOffset;
134 if ( ((ip & 0xff) == 0) || ((ip & 0xff) == 0xff)
135 || ((ip & 0xff00) == 0xff00) ) {
156 opp_error (
"Error creating node: No available IP in access net!");
162 const char* ip_disp =
const_cast<char*
>
164 terminal.
module->getDisplayString().insertTag(
"t", 0);
165 terminal.
module->getDisplayString().setTagArg(
"t", 0, ip_disp);
166 terminal.
module->getDisplayString().setTagArg(
"t", 1,
"l");
180 cModuleType* pppInterfaceModuleType = cModuleType::get(
"inet.linklayer.ppp.PPPInterface");
193 cChannelType* channelTypeRx = cChannelType::find(
channelTypeRxStr.c_str() );
194 cChannelType* channelTypeTx = cChannelType::find(
channelTypeTxStr.c_str() );
195 if (!channelTypeRx || !channelTypeTx)
196 opp_error(
"Could not find Channel or ChannelRx Type. Most likely "
197 "parameter channelTypes does not match the channels defined "
200 terminal.
module->gate(
"pppg$o", 0)->connectTo(routerInGate,
202 routerOutGate->connectTo(terminal.
module->gate(
"pppg$i", 0),
210 cModule* netwModule =
router.
module->getSubmodule(
"networkLayer");
221 ipModule =
router.
module->getSubmodule(
"networkLayer")->getSubmodule(
"ipv6");
224 ipModule =
router.
module->getSubmodule(
"networkLayer")->getSubmodule(
"ip");
228 netwInGate->connectTo(ipIn);
230 cModule* arpModule = NULL;
233 arpModule =
router.
module->getSubmodule(
"networkLayer")->getSubmodule(
"neighbourDiscovery");
235 arpModule =
router.
module->getSubmodule(
"networkLayer")->getSubmodule(
"arp");
237 arpOut->connectTo(netwOutGate);
254 terminal.
module->callInitialize(i);
272 IPv6InterfaceData* interfaceData =
new IPv6InterfaceData;
273 interfaceData->setAdvSendAdvertisements(
true);
274 interfaceData->assignAddress(IPv6Address::formLinkLocalAddress(terminal.
remoteInterfaceEntry->getInterfaceToken()),
false, 0, 0);
279 terminal.
interfaceEntry->ipv6Data()->setAdvSendAdvertisements(
false);
281 terminal.
interfaceEntry->ipv6Data()->assignAddress(IPv6Address::formLinkLocalAddress(terminal.
interfaceEntry->getInterfaceToken()),
false, 0, 0);
282 terminal.
interfaceEntry->setMACAddress(MACAddress::generateAutoAddress());
301 IPv4InterfaceData* interfaceData =
new IPv4InterfaceData;
303 interfaceData->setNetmask(IPAddress::ALLONES_ADDRESS);
308 terminal.
interfaceEntry->ipv4Data()->setNetmask(IPAddress::ALLONES_ADDRESS);
315 IPRoute*
re =
new IPRoute();
317 re->setNetmask(IPAddress(IPAddress::ALLONES_ADDRESS));
319 re->setType(IPRoute::DIRECT);
320 re->setSource(IPRoute::MANUAL);
325 IPRoute* te =
new IPRoute();
326 te->setHost(IPAddress::UNSPECIFIED_ADDRESS);
327 te->setNetmask(IPAddress::UNSPECIFIED_ADDRESS);
330 te->setType(IPRoute::REMOTE);
331 te->setSource(IPRoute::MANUAL);
349 Enter_Method(
"getRandomNodeId()");
356 Enter_Method(
"removeOverlayNode()");
358 cModule* node = NULL;
370 if(node == NULL)
return NULL;
375 node->gate(
"pppg$o", 0)->disconnect();
376 node->gate(
"pppg$i", 0)->getPreviousGate()->disconnect();
379 ppp->gate(
"netwIn")->getPathStartGate()->disconnect();
380 ppp->gate(
"netwOut")->getNextGate()->disconnect();
395 for (
int i = 0; i < terminal.
routingTable6->getNumRoutes(); i++) {
398 ipv6Data()->getLinkLocalAddress()) {
407 if (route->getDestPrefix() == terminal.
IPAddress.get6()) {
428 Enter_Method(
"getOverlayNode()");
430 cModule* node = NULL;
444 sprintf(buf,
"1 terminal connected");
448 getDisplayString().setTagArg(
"t", 0, buf);
449 getDisplayString().setTagArg(
"t", 2,
"blue");
456 for (index = 0; index < owner->gateSize(name); index++) {
457 cGate *gate = type ==
cGate::NONE ? owner->gate(name, index) : owner->gateHalf(name, type, index);
458 if (!gate->isConnectedOutside()) {
463 owner->setGateSize(name, index + 2);
464 return type ==
cGate::NONE ? owner->gate(name, index + 1) : owner->gateHalf(name, type, index + 1);
470 for (
int i = 0; i< ift->getNumInterfaces(); i++) {
471 if (!ift->getInterface(i)->isLoopback()) {
472 if (ift->getInterface(i)->ipv6Data()->getNumAdvPrefixes() == 1)
473 return ift->getInterface(i)->ipv6Data()->getAdvPrefix(0).prefix;
475 opp_error(
"Prefix is not unique.");
478 return IPvXAddress();