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 
136  bool AddAddress (Ipv4InterfaceAddress address);
137 
142  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
143 
147  uint32_t GetNAddresses (void) const;
148 
153  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
154 
155 protected:
156  virtual void DoDispose (void);
157 private:
158  void DoSetup (void);
159  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
160  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
161  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
162 
163  bool m_ifup;
164  bool m_forwarding; // IN_DEV_FORWARD
165  uint16_t m_metric;
170 };
171 
172 } // namespace ns3
173 
174 #endif