socket update broke multicast

This commit is contained in:
Craig Dowell
2007-09-11 18:29:26 -07:00
parent 451a4762df
commit f894771e7d
7 changed files with 55 additions and 36 deletions

View File

@@ -36,10 +36,10 @@ Ipv4::~Ipv4 ()
{}
uint32_t
GetIfIndexByIpv4Address (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask)
Ipv4::GetIfIndexByAddress (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask)
{
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
NS_ASSERT_MSG (ipv4, "GetIfIndexByIpv4Address: No Ipv4 interface");
NS_ASSERT_MSG (ipv4, "Ipv4::GetIfIndexByAddress: No Ipv4 interface");
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++)
{
if (ipv4->GetAddress (i).CombineMask(amask) == a.CombineMask(amask) )
@@ -48,17 +48,26 @@ GetIfIndexByIpv4Address (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask)
}
}
// Mapping not found
NS_ASSERT_MSG (false, "GetIfIndexByIpv4Address failed");
NS_ASSERT_MSG (false, "Ipv4::GetIfIndexByAddress failed");
return 0;
}
//
// XXX BUGBUG I don't think this is really the right approach here. The call
// to GetRoute () filters down into Ipv4L3Protocol where it translates into
// a call into the Ipv4 static routing package. This bypasses any other
// routing packages. At a minimum, the name is misleading.
//
bool
GetIpv4RouteToDestination (Ptr<Node> node, Ipv4Route& route,
Ipv4Address a, Ipv4Mask amask)
Ipv4::GetRouteToDestination (
Ptr<Node> node,
Ipv4Route& route,
Ipv4Address a,
Ipv4Mask amask)
{
Ipv4Route tempRoute;
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
NS_ASSERT_MSG (ipv4, "GetIpv4RouteToDestination: No Ipv4 interface");
NS_ASSERT_MSG (ipv4, "Ipv4::GetRouteToDestination: No Ipv4 interface");
for (uint32_t i = 0; i < ipv4->GetNRoutes (); i++)
{
tempRoute = ipv4->GetRoute (i);
@@ -83,5 +92,4 @@ GetIpv4RouteToDestination (Ptr<Node> node, Ipv4Route& route,
return false;
}
} // namespace ns3

View File

@@ -105,6 +105,7 @@ public:
const Ipv4Header &ipHeader,
Packet packet,
RouteReplyCallback routeReply) = 0;
/**
* \brief Synchronously check to see if we can determine the interface index
* that will be used if a packet is sent to this destination.
@@ -395,6 +396,15 @@ public:
*/
virtual Ipv4Address GetSourceAddress (Ipv4Address destination) const = 0;
/**
* \param destination The IP address of a hypothetical destination.
* \param ifIndex filled in with the interface index that will be used to
* send a packet to the hypothetical destination.
* \returns True if a single interface can be identified, false otherwise.
*/
virtual bool GetIfIndexForDestination (Ipv4Address dest,
uint32_t &ifIndex) const = 0;
/**
* \param i index of ipv4 interface
* \returns the Maximum Transmission Unit (in bytes) associated
@@ -424,20 +434,18 @@ public:
* ignored during ipv4 forwarding.
*/
virtual void SetDown (uint32_t i) = 0;
};
/**
* Convenience functions (Doxygen still needed)
*
* Return the ifIndex corresponding to the Ipv4Address provided.
*/
uint32_t GetIfIndexByIpv4Address (Ptr<Node> node,
Ipv4Address a,
Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
static uint32_t GetIfIndexByAddress (Ptr<Node> node, Ipv4Address a,
Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
bool GetIpv4RouteToDestination (Ptr<Node> node, Ipv4Route& route,
Ipv4Address a,
Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
static bool GetRouteToDestination (Ptr<Node> node, Ipv4Route& route,
Ipv4Address a, Ipv4Mask amask = Ipv4Mask("255.255.255.255"));
};
} // namespace ns3