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:
52  static TypeId GetTypeId (void);
53 
54  Ipv4Interface ();
55  virtual ~Ipv4Interface();
56 
57  void SetNode (Ptr<Node> node);
58  void SetDevice (Ptr<NetDevice> device);
60 
64  Ptr<NetDevice> GetDevice (void) const;
68  Ptr<ArpCache> GetArpCache () const;
69 
77  void SetMetric (uint16_t metric);
78 
86  uint16_t GetMetric (void) const;
87 
96  bool IsUp (void) const;
97 
101  bool IsDown (void) const;
102 
106  void SetUp (void);
107 
111  void SetDown (void);
112 
116  bool IsForwarding (void) const;
117 
121  void SetForwarding (bool val);
122 
130  void Send (Ptr<Packet> p, Ipv4Address dest);
131 
137 
142  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
143 
147  uint32_t GetNAddresses (void) const;
148 
153  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
154 
163 
164 protected:
165  virtual void DoDispose (void);
166 private:
167  void DoSetup (void);
168  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
169  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
170  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
171 
172  bool m_ifup;
173  bool m_forwarding; // IN_DEV_FORWARD
174  uint16_t m_metric;
179 };
180 
181 } // namespace ns3
182 
183 #endif
void SetForwarding(bool val)
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
Ptr< ArpCache > m_cache
void SetNode(Ptr< Node > node)
std::list< Ipv4InterfaceAddress >::const_iterator Ipv4InterfaceAddressListCI
static TypeId GetTypeId(void)
std::list< Ipv4InterfaceAddress > Ipv4InterfaceAddressList
void SetDevice(Ptr< NetDevice > device)
Ipv4InterfaceAddressList m_ifaddrs
Ipv4InterfaceAddress GetAddress(uint32_t index) const
virtual ~Ipv4Interface()
bool IsDown(void) const
std::list< Ipv4InterfaceAddress >::iterator Ipv4InterfaceAddressListI
void SetArpCache(Ptr< ArpCache >)
uint16_t GetMetric(void) const
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
a class to store IPv4 address information on an interface
Ptr< NetDevice > GetDevice(void) const
void SetMetric(uint16_t metric)
a base class which provides memory management and object aggregation
Definition: object.h:63
tuple address
Definition: first.py:37
virtual void DoDispose(void)
uint32_t GetNAddresses(void) const
a unique identifier for an interface.
Definition: type-id.h:49
bool IsForwarding(void) const
bool IsUp(void) const