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 
65  // Delete copy constructor and assignment operator to avoid misuse
66  Ipv4Interface (const Ipv4Interface &) = delete;
68 
73  void SetNode (Ptr<Node> node);
78  void SetDevice (Ptr<NetDevice> device);
88  void SetArpCache (Ptr<ArpCache> arpCache);
89 
93  Ptr<NetDevice> GetDevice (void) const;
94 
98  Ptr<ArpCache> GetArpCache () const;
99 
107  void SetMetric (uint16_t metric);
108 
116  uint16_t GetMetric (void) const;
117 
126  bool IsUp (void) const;
127 
131  bool IsDown (void) const;
132 
136  void SetUp (void);
137 
141  void SetDown (void);
142 
146  bool IsForwarding (void) const;
147 
151  void SetForwarding (bool val);
152 
161  void Send (Ptr<Packet> p, const Ipv4Header & hdr, Ipv4Address dest);
162 
168 
173  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
174 
178  uint32_t GetNAddresses (void) const;
179 
184  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
185 
194 
195 protected:
196  virtual void DoDispose (void);
197 
198 private:
202  void DoSetup (void);
203 
204 
208  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
209 
213  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
214 
218  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
219 
220 
221 
222  bool m_ifup;
224  uint16_t m_metric;
230 };
231 
232 } // namespace ns3
233 
234 #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()
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.
Ipv4Interface(const Ipv4Interface &)=delete
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.
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
Ipv4Interface & operator=(const Ipv4Interface &)=delete
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.