# HG changeset patch # Parent 67134631ad73d7e84c04726682b457b8f917cbbf fix the problem on using IPv4 raw socket with ns-3-simu diff -r 67134631ad73 src/internet-stack/ipv4-l3-protocol.cc --- a/src/internet-stack/ipv4-l3-protocol.cc Sun Apr 04 22:34:42 2010 +0900 +++ b/src/internet-stack/ipv4-l3-protocol.cc Sun Apr 04 22:50:37 2010 +0900 @@ -545,8 +545,8 @@ // 4) packet is not broadcast, and is passed in with a route entry but route->GetGateway is not set (e.g., on-demand) // 5) packet is not broadcast, and route is NULL (e.g., a raw socket call, or ICMP) - // 1) packet is destined to limited broadcast address - if (destination.IsBroadcast ()) + // 1) packet is destined to limited broadcast address or link-local multicast address + if (destination.IsBroadcast () || destination.IsLocalMulticast ()) { NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 1: limited broadcast"); ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); diff -r 67134631ad73 src/node/ipv4-address.cc --- a/src/node/ipv4-address.cc Sun Apr 04 22:34:42 2010 +0900 +++ b/src/node/ipv4-address.cc Sun Apr 04 22:50:37 2010 +0900 @@ -240,6 +240,13 @@ return (m_address >= 0xe0000000 && m_address <= 0xefffffff); } +bool +Ipv4Address::IsLocalMulticast (void) const +{ + // Link-Local multicast address is 224.0.0.0/24 + return (m_address & 0xffffff00) == 0xe0000000; +} + void Ipv4Address::Serialize (uint8_t buf[4]) const { diff -r 67134631ad73 src/node/ipv4-address.h --- a/src/node/ipv4-address.h Sun Apr 04 22:34:42 2010 +0900 +++ b/src/node/ipv4-address.h Sun Apr 04 22:50:37 2010 +0900 @@ -112,6 +112,10 @@ */ bool IsMulticast (void) const; /** + * \return true only if address is in local multicast address scope, 224.0.0.0/24 + */ + bool IsLocalMulticast (void) const; + /** * \brief Combine this address with a network mask * * This method returns an IPv4 address that is this address combined diff -r 67134631ad73 src/routing/static-routing/ipv4-static-routing.cc --- a/src/routing/static-routing/ipv4-static-routing.cc Sun Apr 04 22:34:42 2010 +0900 +++ b/src/routing/static-routing/ipv4-static-routing.cc Sun Apr 04 22:50:37 2010 +0900 @@ -222,6 +222,20 @@ Ptr rtentry = 0; uint16_t longest_mask = 0; uint32_t shortest_metric = 0xffffffff; + /* when sending on local multicast, there have to be interface specified */ + if (dest.IsLocalMulticast ()) + { + NS_ASSERT_MSG (oif, "Try to send on link-local multicast address, and no interface index is given!"); + + rtentry = Create (); + rtentry->SetDestination (dest); + rtentry->SetGateway (Ipv4Address::GetZero ()); + rtentry->SetOutputDevice (oif); + rtentry->SetSource (m_ipv4->GetAddress (oif->GetIfIndex (), 0).GetLocal ()); + return rtentry; + } + + for (NetworkRoutesI i = m_networkRoutes.begin (); i != m_networkRoutes.end (); i++)