A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-interface-container.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
7 */
8
10
11#include "ns3/names.h"
12#include "ns3/node-list.h"
13
14namespace ns3
15{
16
20
21void
23{
24 for (auto i = other.m_interfaces.begin(); i != other.m_interfaces.end(); i++)
25 {
26 m_interfaces.push_back(*i);
27 }
28}
29
32{
33 return m_interfaces.begin();
34}
35
38{
39 return m_interfaces.end();
40}
41
44{
45 return m_interfaces.size();
46}
47
50{
51 Ptr<Ipv4> ipv4 = m_interfaces[i].first;
52 uint32_t interface = m_interfaces[i].second;
53 return ipv4->GetAddress(interface, j).GetLocal();
54}
55
56void
58{
59 Ptr<Ipv4> ipv4 = m_interfaces[i].first;
60 uint32_t interface = m_interfaces[i].second;
61 ipv4->SetMetric(interface, metric);
62}
63
64void
66{
67 m_interfaces.emplace_back(ipv4, interface);
68}
69
70void
72{
73 Add(a.first, a.second);
74}
75
76void
77Ipv4InterfaceContainer::Add(std::string ipv4Name, uint32_t interface)
78{
79 Ptr<Ipv4> ipv4 = Names::Find<Ipv4>(ipv4Name);
80 m_interfaces.emplace_back(ipv4, interface);
81}
82
83std::pair<Ptr<Ipv4>, uint32_t>
85{
86 return m_interfaces[i];
87}
88
89} // namespace ns3
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::vector< std::pair< Ptr< Ipv4 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv4 smart pointer / Interface Index.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
void SetMetric(uint32_t i, uint16_t metric)
Set a metric for the given interface.
InterfaceVector m_interfaces
List of IPv4 stack and interfaces index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
Ipv4InterfaceContainer()
Create an empty Ipv4InterfaceContainer.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition names.h:443
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.