A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv4-interface-container.cc
1 #include "ipv4-interface-container.h"
2 #include "ns3/node-list.h"
3 #include "ns3/names.h"
4 
5 namespace ns3 {
6 
8 {
9 }
10 
11 void
13 {
14  for (InterfaceVector::const_iterator i = other.m_interfaces.begin (); i != other.m_interfaces.end (); i++)
15  {
16  m_interfaces.push_back (*i);
17  }
18 }
19 
20 Ipv4InterfaceContainer::Iterator
22 {
23  return m_interfaces.begin ();
24 }
25 
26 Ipv4InterfaceContainer::Iterator
28 {
29  return m_interfaces.end ();
30 }
31 
32 uint32_t
34 {
35  return m_interfaces.size ();
36 }
37 
39 Ipv4InterfaceContainer::GetAddress (uint32_t i, uint32_t j) const
40 {
41  Ptr<Ipv4> ipv4 = m_interfaces[i].first;
42  uint32_t interface = m_interfaces[i].second;
43  return ipv4->GetAddress (interface, j).GetLocal ();
44 }
45 
46 void
47 Ipv4InterfaceContainer::SetMetric (uint32_t i, uint16_t metric)
48 {
49  Ptr<Ipv4> ipv4 = m_interfaces[i].first;
50  uint32_t interface = m_interfaces[i].second;
51  ipv4->SetMetric (interface, metric);
52 }
53 void
54 Ipv4InterfaceContainer::Add (Ptr<Ipv4> ipv4, uint32_t interface)
55 {
56  m_interfaces.push_back (std::make_pair (ipv4, interface));
57 }
58 void Ipv4InterfaceContainer::Add (std::pair<Ptr<Ipv4>, uint32_t> a)
59 {
60  Add (a.first, a.second);
61 }
62 void
63 Ipv4InterfaceContainer::Add (std::string ipv4Name, uint32_t interface)
64 {
65  Ptr<Ipv4> ipv4 = Names::Find<Ipv4> (ipv4Name);
66  m_interfaces.push_back (std::make_pair (ipv4, interface));
67 }
68 
69 std::pair<Ptr<Ipv4>, uint32_t>
70 Ipv4InterfaceContainer::Get (uint32_t i) const
71 {
72  return m_interfaces[i];
73 }
74 
75 
76 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Iterator Begin(void) const
Get an iterator which refers to the first pair in the container.
void Add(Ipv4InterfaceContainer other)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const