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/ipv4-header.h"
27 #include "ns3/ipv4-interface-address.h"
28 #include "ns3/ptr.h"
29 #include "ns3/object.h"
30 #include "ns3/traffic-control-layer.h"
31 
32 namespace ns3 {
33 
34 class NetDevice;
35 class Packet;
36 class Node;
37 class ArpCache;
38 
50 class Ipv4Interface : public Object
51 {
52 public:
57  static TypeId GetTypeId (void);
58 
59  Ipv4Interface ();
60  virtual ~Ipv4Interface();
61 
66  void SetNode (Ptr<Node> node);
71  void SetDevice (Ptr<NetDevice> device);
81  void SetArpCache (Ptr<ArpCache> arpCache);
82 
86  Ptr<NetDevice> GetDevice (void) const;
87 
91  Ptr<ArpCache> GetArpCache () const;
92 
100  void SetMetric (uint16_t metric);
101 
109  uint16_t GetMetric (void) const;
110 
119  bool IsUp (void) const;
120 
124  bool IsDown (void) const;
125 
129  void SetUp (void);
130 
134  void SetDown (void);
135 
139  bool IsForwarding (void) const;
140 
144  void SetForwarding (bool val);
145 
154  void Send (Ptr<Packet> p, const Ipv4Header & hdr, Ipv4Address dest);
155 
161 
166  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
167 
171  uint32_t GetNAddresses (void) const;
172 
177  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
178 
187 
188 protected:
189  virtual void DoDispose (void);
190 private:
194  void DoSetup (void);
195 
196 
200  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
201 
205  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
206 
210  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
211 
212 
213 
214  bool m_ifup;
216  uint16_t m_metric;
217  Ipv4InterfaceAddressList m_ifaddrs;
222 };
223 
224 } // namespace ns3
225 
226 #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.
Ptr< ArpCache > GetArpCache() const
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
bool AddAddress(Ipv4InterfaceAddress address)
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:31
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.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
virtual ~Ipv4Interface()
bool IsDown(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< Ipv4InterfaceAddress >::iterator Ipv4InterfaceAddressListI
Const Container Iterator for the Ipv4InterfaceAddresses.
Ptr< Node > m_node
The associated node.
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
Ptr< NetDevice > GetDevice(void) const
bool m_ifup
The state of this interface.
void SetMetric(uint16_t metric)
A base class which provides memory management and object aggregation.
Definition: object.h:87
tuple address
Definition: first.py:37
void DoSetup(void)
Initialize interface.
virtual void DoDispose(void)
Destructor implementation.
uint32_t GetNAddresses(void) const
a unique identifier for an interface.
Definition: type-id.h:58
bool IsForwarding(void) const
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
void SetUp(void)
Enable this interface.