A Discrete-Event Network Simulator
API
ipv4-interface-container.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
19  */
20 
21 #ifndef IPV4_INTERFACE_CONTAINER_H
22 #define IPV4_INTERFACE_CONTAINER_H
23 
24 #include <stdint.h>
25 #include <vector>
26 #include "ns3/ipv4.h"
27 #include "ns3/ipv4-address.h"
28 
29 namespace ns3 {
30 
55 {
56 public:
60  typedef std::vector<std::pair<Ptr<Ipv4>, uint32_t> >::const_iterator Iterator;
61 
66 
71  void Add (const Ipv4InterfaceContainer& other);
72 
93  Iterator Begin (void) const;
94 
115  Iterator End (void) const;
116 
138  uint32_t GetN (void) const;
139 
150  Ipv4Address GetAddress (uint32_t i, uint32_t j = 0) const;
151 
157  void SetMetric (uint32_t i, uint16_t metric);
158 
168  void Add (Ptr<Ipv4> ipv4, uint32_t interface);
169 
178  void Add (std::pair<Ptr<Ipv4>, uint32_t> ipInterfacePair);
179 
190  void Add (std::string ipv4Name, uint32_t interface);
191 
201  std::pair<Ptr<Ipv4>, uint32_t> Get (uint32_t i) const;
202 
203 private:
207  typedef std::vector<std::pair<Ptr<Ipv4>,uint32_t> > InterfaceVector;
208 
212  InterfaceVector m_interfaces;
213 };
214 
215 } // namespace ns3
216 
217 #endif /* IPV4_INTERFACE_CONTAINER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr and interface stored at the location specified by the index...
Ipv4InterfaceContainer()
Create an empty Ipv4InterfaceContainer.
holds a vector of std::pair of Ptr and interface index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
std::vector< std::pair< Ptr< Ipv4 >, uint32_t > > InterfaceVector
Container for pairs of Ipv4 smart pointer / Interface Index.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< std::pair< Ptr< Ipv4 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv4 smart pointer / Interface Index.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
void SetMetric(uint32_t i, uint16_t metric)
Set a metric for the given interface.
Iterator Begin(void) const
Get an iterator which refers to the first pair in the container.
InterfaceVector m_interfaces
List of IPv4 stack and interfaces index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const