diff -r 41489a849fc3 -r 143e2e1c5167 src/helper/static-multicast-route-helper.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/helper/static-multicast-route-helper.cc Sun Mar 30 14:04:57 2008 -0700 @@ -0,0 +1,58 @@ + +#include +#include "ns3/ptr.h" +#include "ns3/assert.h" +#include "ns3/ipv4-address.h" +#include "ns3/ipv4.h" +#include "static-multicast-route-helper.h" + +namespace ns3 { + +StaticMulticastRouteHelper::StaticMulticastRouteHelper () +{ +} + +void +StaticMulticastRouteHelper::AddMulticastRoute ( + Ptr n, + Ipv4Address source, + Ipv4Address group, + Ptr input, + NetDeviceContainer output) +{ + Ptr ipv4 = n->GetObject (); + + // We need to convert the NetDeviceContainer to an array of ifIndex + std::vector outputInterfaces; + for (NetDeviceContainer::Iterator i = output.Begin (); i != output.End (); ++i) + { + Ptr nd = *i; + uint32_t oifIndex = ipv4->FindInterfaceForDevice (nd); + outputInterfaces.push_back(oifIndex); + } + uint32_t iifIndex = ipv4->FindInterfaceForDevice (input); + ipv4->AddMulticastRoute (source, group, iifIndex, outputInterfaces); +} + +void +StaticMulticastRouteHelper::SetDefaultMulticastRoute ( + Ptr n, + Ptr nd) +{ + Ptr ipv4 = n->GetObject (); + uint32_t ifIndexSrc = ipv4->FindInterfaceForDevice (nd); + ipv4->SetDefaultMulticastRoute (ifIndexSrc); +} + +void +StaticMulticastRouteHelper::JoinMulticastGroup ( + Ptr n, + Ipv4Address source, + Ipv4Address group) +{ + Ptr ipv4 = n->GetObject (); + ipv4->JoinMulticastGroup (source, group); +} + +} // namespace ns3 +