A Discrete-Event Network Simulator
API
ipv4-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 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  * Authors:
19  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
20  * Tom Henderson <tomh@tomh.org>
21  */
22 #ifndef IPV4_INTERFACE_H
23 #define IPV4_INTERFACE_H
24 
25 #include <list>
26 #include "ns3/ptr.h"
27 #include "ns3/object.h"
28 
29 namespace ns3 {
30 
31 class NetDevice;
32 class Packet;
33 class Node;
34 class ArpCache;
35 class Ipv4InterfaceAddress;
36 class Ipv4Address;
37 class Ipv4Header;
38 class TrafficControlLayer;
39 
53 class Ipv4Interface : public Object
54 {
55 public:
60  static TypeId GetTypeId (void);
61 
62  Ipv4Interface ();
63  virtual ~Ipv4Interface();
64 
69  void SetNode (Ptr<Node> node);
74  void SetDevice (Ptr<NetDevice> device);
84  void SetArpCache (Ptr<ArpCache> arpCache);
85 
89  Ptr<NetDevice> GetDevice (void) const;
90 
94  Ptr<ArpCache> GetArpCache () const;
95 
103  void SetMetric (uint16_t metric);
104 
112  uint16_t GetMetric (void) const;
113 
122  bool IsUp (void) const;
123 
127  bool IsDown (void) const;
128 
132  void SetUp (void);
133 
137  void SetDown (void);
138 
142  bool IsForwarding (void) const;
143 
147  void SetForwarding (bool val);
148 
157  void Send (Ptr<Packet> p, const Ipv4Header & hdr, Ipv4Address dest);
158 
164 
169  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
170 
174  uint32_t GetNAddresses (void) const;
175 
180  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
181 
190 
191 protected:
192  virtual void DoDispose (void);
193 private:
201 
210 
214  void DoSetup (void);
215 
216 
220  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
221 
225  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
226 
230  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
231 
232 
233 
234  bool m_ifup;
236  uint16_t m_metric;
242 };
243 
244 } // namespace ns3
245 
246 #endif
ns3::Ipv4Interface::operator=
Ipv4Interface & operator=(const Ipv4Interface &o)
Assignment operator.
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::Ipv4Interface::m_tc
Ptr< TrafficControlLayer > m_tc
The associated TrafficControlLayer.
Definition: ipv4-interface.h:240
ns3::Ipv4Interface::m_node
Ptr< Node > m_node
The associated node.
Definition: ipv4-interface.h:238
ns3::Ipv4Interface::GetMetric
uint16_t GetMetric(void) const
Definition: ipv4-interface.cc:145
ns3::Ipv4Interface::IsUp
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
Definition: ipv4-interface.cc:171
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4Interface::m_metric
uint16_t m_metric
Interface metric.
Definition: ipv4-interface.h:236
ns3::Ipv4Interface::GetDevice
Ptr< NetDevice > GetDevice(void) const
Definition: ipv4-interface.cc:131
ns3::Ipv4Interface
The IPv4 representation of a network interface.
Definition: ipv4-interface.h:54
ns3::Ipv4Interface::SetArpCache
void SetArpCache(Ptr< ArpCache > arpCache)
Set ARP cache used by this interface.
Definition: ipv4-interface.cc:152
ns3::Ipv4Interface::GetArpCache
Ptr< ArpCache > GetArpCache() const
Definition: ipv4-interface.cc:159
ns3::Ipv4Interface::IsForwarding
bool IsForwarding(void) const
Definition: ipv4-interface.cc:199
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv4Interface::GetNAddresses
uint32_t GetNAddresses(void) const
Definition: ipv4-interface.cc:302
ns3::Ipv4Interface::m_ifup
bool m_ifup
The state of this interface.
Definition: ipv4-interface.h:234
ns3::Ipv4Interface::Ipv4InterfaceAddressListI
std::list< Ipv4InterfaceAddress >::iterator Ipv4InterfaceAddressListI
Const Container Iterator for the Ipv4InterfaceAddresses.
Definition: ipv4-interface.h:230
ns3::Ipv4Interface::DoSetup
void DoSetup(void)
Initialize interface.
Definition: ipv4-interface.cc:115
ns3::Ipv4Interface::IsDown
bool IsDown(void) const
Definition: ipv4-interface.cc:178
ns3::Ipv4Interface::SetMetric
void SetMetric(uint16_t metric)
Definition: ipv4-interface.cc:138
ns3::Ptr< Node >
ns3::Ipv4Interface::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: ipv4-interface.cc:81
ns3::Ipv4Interface::SetDown
void SetDown(void)
Disable this interface.
Definition: ipv4-interface.cc:192
ns3::Ipv4Interface::SetForwarding
void SetForwarding(bool val)
Definition: ipv4-interface.cc:206
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition: ipv4-interface-address.h:44
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::Ipv4Interface::Ipv4Interface
Ipv4Interface()
By default, Ipv4 interface are created in the "down" state with no IP addresses.
Definition: ipv4-interface.cc:63
ns3::Ipv4Interface::Send
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
Definition: ipv4-interface.cc:213
first.address
address
Definition: first.py:44
ns3::Ipv4Interface::SetUp
void SetUp(void)
Enable this interface.
Definition: ipv4-interface.cc:185
ns3::Ipv4Interface::Ipv4Interface
Ipv4Interface(const Ipv4Interface &o)
Copy constructor.
ns3::Ipv4Interface::RemoveAddress
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
Definition: ipv4-interface.cc:341
ns3::Ipv4Interface::AddAddress
bool AddAddress(Ipv4InterfaceAddress address)
Definition: ipv4-interface.cc:309
ns3::Ipv4Interface::GetAddress
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Definition: ipv4-interface.cc:317
ns3::Ipv4Interface::m_cache
Ptr< ArpCache > m_cache
ARP cache.
Definition: ipv4-interface.h:241
ns3::Ipv4Interface::Ipv4InterfaceAddressListCI
std::list< Ipv4InterfaceAddress >::const_iterator Ipv4InterfaceAddressListCI
Container Iterator for the Ipv4InterfaceAddresses.
Definition: ipv4-interface.h:225
ns3::Ipv4Interface::SetNode
void SetNode(Ptr< Node > node)
Set node associated with interface.
Definition: ipv4-interface.cc:92
ns3::Ipv4Interface::SetTrafficControl
void SetTrafficControl(Ptr< TrafficControlLayer > tc)
Set the TrafficControlLayer.
Definition: ipv4-interface.cc:108
ns3::Ipv4Interface::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: ipv4-interface.cc:42
ns3::Ipv4Interface::m_device
Ptr< NetDevice > m_device
The associated NetDevice.
Definition: ipv4-interface.h:239
ns3::Ipv4Interface::m_forwarding
bool m_forwarding
Forwarding state.
Definition: ipv4-interface.h:235
ns3::Ipv4Interface::~Ipv4Interface
virtual ~Ipv4Interface()
Definition: ipv4-interface.cc:75
ns3::Ipv4Interface::Ipv4InterfaceAddressList
std::list< Ipv4InterfaceAddress > Ipv4InterfaceAddressList
Container for the Ipv4InterfaceAddresses.
Definition: ipv4-interface.h:220
ns3::Ipv4Interface::SetDevice
void SetDevice(Ptr< NetDevice > device)
Set the NetDevice.
Definition: ipv4-interface.cc:100
ns3::Ipv4Interface::m_ifaddrs
Ipv4InterfaceAddressList m_ifaddrs
Address list.
Definition: ipv4-interface.h:237