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