A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-address.h"
27 #include "ns3/ipv4-interface-address.h"
28 #include "ns3/ptr.h"
29 #include "ns3/object.h"
30 
31 namespace ns3 {
32 
33 class NetDevice;
34 class Packet;
35 class Node;
36 class ArpCache;
37 
49 class Ipv4Interface : public Object
50 {
51 public:
56  static TypeId GetTypeId (void);
57 
58  Ipv4Interface ();
59  virtual ~Ipv4Interface();
60 
65  void SetNode (Ptr<Node> node);
70  void SetDevice (Ptr<NetDevice> device);
75  void SetArpCache (Ptr<ArpCache> arpCache);
76 
80  Ptr<NetDevice> GetDevice (void) const;
84  Ptr<ArpCache> GetArpCache () const;
85 
93  void SetMetric (uint16_t metric);
94 
102  uint16_t GetMetric (void) const;
103 
112  bool IsUp (void) const;
113 
117  bool IsDown (void) const;
118 
122  void SetUp (void);
123 
127  void SetDown (void);
128 
132  bool IsForwarding (void) const;
133 
137  void SetForwarding (bool val);
138 
146  void Send (Ptr<Packet> p, Ipv4Address dest);
147 
153 
158  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
159 
163  uint32_t GetNAddresses (void) const;
164 
169  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
170 
179 
180 protected:
181  virtual void DoDispose (void);
182 private:
186  void DoSetup (void);
187 
188 
192  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
193 
197  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
198 
202  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
203 
204 
205 
206  bool m_ifup;
208  uint16_t m_metric;
213 };
214 
215 } // namespace ns3
216 
217 #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, 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.
static TypeId GetTypeId(void)
Get the type ID.
std::list< Ipv4InterfaceAddress > Ipv4InterfaceAddressList
Container for the Ipv4InterfaceAddresses.
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
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:38
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:64
tuple address
Definition: first.py:37
void DoSetup(void)
Initialize interface.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
uint32_t GetNAddresses(void) const
a unique identifier for an interface.
Definition: type-id.h:49
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.