# HG changeset patch # User Andrey Mazo # Date 1261496088 -10800 # Node ID 0d842e422aa0835dcc79053287b6f5bd9380b627 # Parent ba2e675ac2290e2abae049bcf369325cf073a614 Bug 782: CreateTap () requires IP address in modes other than CONFIGURE_LOCAL. diff -r ba2e675ac229 -r 0d842e422aa0 src/devices/tap-bridge/tap-bridge.cc --- a/src/devices/tap-bridge/tap-bridge.cc Tue Dec 22 14:59:17 2009 +0300 +++ b/src/devices/tap-bridge/tap-bridge.cc Tue Dec 22 18:34:48 2009 +0300 @@ -357,6 +357,7 @@ // // We want to get as much of this stuff automagically as possible. // + // For CONFIGURE_LOCAL mode only: // is the IP address we are going to set in the newly // created Tap device on the Linux host. At the point in the simulation // where devices are coming up, we should have all of our IP addresses @@ -364,20 +365,39 @@ // the new Tap device from the IP address associated with the bridged // net device. // + + bool wantIp = (m_mode == CONFIGURE_LOCAL); + Ptr nd = GetBridgedNetDevice (); Ptr n = nd->GetNode (); Ptr ipv4 = n->GetObject (); - uint32_t index = ipv4->GetInterfaceForDevice (nd); - if (ipv4->GetNAddresses (index) > 1) + + if (wantIp + && (ipv4 == 0) + && m_tapIp.IsBroadcast () + && m_tapNetmask.IsEqual (Ipv4Mask::GetOnes ())) { - NS_LOG_WARN ("Underlying bridged NetDevice has multiple IP addresses; using first one."); + NS_FATAL_ERROR ("TapBridge::CreateTap(): Tap device IP configuration requested but neither IP address nor IP netmask is provided"); } - Ipv4Address ipv4Address = ipv4->GetAddress (index, 0).GetLocal (); - // - // The net mask is sitting right there next to the ipv4 address. - // - Ipv4Mask ipv4Mask = ipv4->GetAddress (index, 0).GetMask (); + // Some stub values to make tap-creator happy + Ipv4Address ipv4Address ("255.255.255.255"); + Ipv4Mask ipv4Mask ("255.255.255.255"); + + if (ipv4 != 0) + { + uint32_t index = ipv4->GetInterfaceForDevice (nd); + if (ipv4->GetNAddresses (index) > 1) + { + NS_LOG_WARN ("Underlying bridged NetDevice has multiple IP addresses; using first one."); + } + ipv4Address = ipv4->GetAddress (index, 0).GetLocal (); + + // + // The net mask is sitting right there next to the ipv4 address. + // + ipv4Mask = ipv4->GetAddress (index, 0).GetMask (); + } // // The MAC address should also already be assigned and waiting for us in