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:
200  Ipv4Interface (const Ipv4Interface &o);
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
void SetDown(void)
Disable this interface.
void SetForwarding(bool val)
Ipv4Interface()
By default, Ipv4 interface are created in the "down" state with no IP addresses.
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
The IPv4 representation of a network interface.
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
bool AddAddress(Ipv4InterfaceAddress address)
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Ptr< NetDevice > m_device
The associated NetDevice.
Ptr< ArpCache > m_cache
ARP cache.
void SetNode(Ptr< Node > node)
Set node associated with interface.
std::list< Ipv4InterfaceAddress >::const_iterator Ipv4InterfaceAddressListCI
Container Iterator for the Ipv4InterfaceAddresses.
bool m_forwarding
Forwarding state.
Packet header for IPv4.
Definition: ipv4-header.h:33
static TypeId GetTypeId(void)
Get the type ID.
void SetTrafficControl(Ptr< TrafficControlLayer > tc)
Set the TrafficControlLayer.
std::list< Ipv4InterfaceAddress > Ipv4InterfaceAddressList
Container for the Ipv4InterfaceAddresses.
Ptr< TrafficControlLayer > m_tc
The associated TrafficControlLayer.
void SetDevice(Ptr< NetDevice > device)
Set the NetDevice.
Ipv4InterfaceAddressList m_ifaddrs
Address list.
Ipv4Interface & operator=(const Ipv4Interface &o)
Assignment operator.
virtual ~Ipv4Interface()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:37
Ptr< NetDevice > GetDevice(void) const
Ptr< ArpCache > GetArpCache() const
bool IsForwarding(void) const
std::list< Ipv4InterfaceAddress >::iterator Ipv4InterfaceAddressListI
Const Container Iterator for the Ipv4InterfaceAddresses.
Ptr< Node > m_node
The associated node.
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
uint16_t GetMetric(void) const
uint16_t m_metric
Interface metric.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
void SetArpCache(Ptr< ArpCache > arpCache)
Set ARP cache used by this interface.
a class to store IPv4 address information on an interface
bool m_ifup
The state of this interface.
void SetMetric(uint16_t metric)
bool IsDown(void) const
A base class which provides memory management and object aggregation.
Definition: object.h:87
void DoSetup(void)
Initialize interface.
uint32_t GetNAddresses(void) const
virtual void DoDispose(void)
Destructor implementation.
a unique identifier for an interface.
Definition: type-id.h:58
void SetUp(void)
Enable this interface.