00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <vector>
00022 #include "ns3/ptr.h"
00023 #include "ns3/assert.h"
00024 #include "ns3/ipv4-address.h"
00025 #include "ns3/ipv4.h"
00026 #include "static-multicast-route-helper.h"
00027
00028 namespace ns3 {
00029
00030 StaticMulticastRouteHelper::StaticMulticastRouteHelper ()
00031 {
00032 }
00033
00034 void
00035 StaticMulticastRouteHelper::AddMulticastRoute (
00036 Ptr<Node> n,
00037 Ipv4Address source,
00038 Ipv4Address group,
00039 Ptr<NetDevice> input,
00040 NetDeviceContainer output)
00041 {
00042 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
00043
00044
00045 std::vector<uint32_t> outputInterfaces;
00046 for (NetDeviceContainer::Iterator i = output.Begin (); i != output.End (); ++i)
00047 {
00048 Ptr<NetDevice> nd = *i;
00049 uint32_t oifIndex = ipv4->FindInterfaceForDevice (nd);
00050 outputInterfaces.push_back(oifIndex);
00051 }
00052 uint32_t iifIndex = ipv4->FindInterfaceForDevice (input);
00053 ipv4->AddMulticastRoute (source, group, iifIndex, outputInterfaces);
00054 }
00055
00056 void
00057 StaticMulticastRouteHelper::SetDefaultMulticastRoute (
00058 Ptr<Node> n,
00059 Ptr<NetDevice> nd)
00060 {
00061 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
00062 uint32_t ifIndexSrc = ipv4->FindInterfaceForDevice (nd);
00063 ipv4->SetDefaultMulticastRoute (ifIndexSrc);
00064 }
00065
00066 void
00067 StaticMulticastRouteHelper::JoinMulticastGroup (
00068 Ptr<Node> n,
00069 Ipv4Address source,
00070 Ipv4Address group)
00071 {
00072 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
00073 ipv4->JoinMulticastGroup (source, group);
00074 }
00075
00076 }
00077