equal
deleted
inserted
replaced
|
1 |
|
2 #include <vector> |
|
3 #include "ns3/ptr.h" |
|
4 #include "ns3/assert.h" |
|
5 #include "ns3/ipv4-address.h" |
|
6 #include "ns3/ipv4.h" |
|
7 #include "static-multicast-route-helper.h" |
|
8 |
|
9 namespace ns3 { |
|
10 |
|
11 StaticMulticastRouteHelper::StaticMulticastRouteHelper () |
|
12 { |
|
13 } |
|
14 |
|
15 void |
|
16 StaticMulticastRouteHelper::AddMulticastRoute ( |
|
17 Ptr<Node> n, |
|
18 Ipv4Address source, |
|
19 Ipv4Address group, |
|
20 Ptr<NetDevice> input, |
|
21 NetDeviceContainer output) |
|
22 { |
|
23 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> (); |
|
24 |
|
25 // We need to convert the NetDeviceContainer to an array of ifIndex |
|
26 std::vector<uint32_t> outputInterfaces; |
|
27 for (NetDeviceContainer::Iterator i = output.Begin (); i != output.End (); ++i) |
|
28 { |
|
29 Ptr<NetDevice> nd = *i; |
|
30 uint32_t oifIndex = ipv4->FindInterfaceForDevice (nd); |
|
31 outputInterfaces.push_back(oifIndex); |
|
32 } |
|
33 uint32_t iifIndex = ipv4->FindInterfaceForDevice (input); |
|
34 ipv4->AddMulticastRoute (source, group, iifIndex, outputInterfaces); |
|
35 } |
|
36 |
|
37 void |
|
38 StaticMulticastRouteHelper::SetDefaultMulticastRoute ( |
|
39 Ptr<Node> n, |
|
40 Ptr<NetDevice> nd) |
|
41 { |
|
42 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> (); |
|
43 uint32_t ifIndexSrc = ipv4->FindInterfaceForDevice (nd); |
|
44 ipv4->SetDefaultMulticastRoute (ifIndexSrc); |
|
45 } |
|
46 |
|
47 void |
|
48 StaticMulticastRouteHelper::JoinMulticastGroup ( |
|
49 Ptr<Node> n, |
|
50 Ipv4Address source, |
|
51 Ipv4Address group) |
|
52 { |
|
53 Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> (); |
|
54 ipv4->JoinMulticastGroup (source, group); |
|
55 } |
|
56 |
|
57 } // namespace ns3 |
|
58 |