A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv4-interface.h
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 #include "ns3/cognitive-packet-tags.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:
53  static TypeId GetTypeId (void);
54 
55  Ipv4Interface ();
56  virtual ~Ipv4Interface();
57 
58  void SetNode (Ptr<Node> node);
59  void SetDevice (Ptr<NetDevice> device);
60  void SetArpCache (Ptr<ArpCache>);
61 
65  Ptr<NetDevice> GetDevice (void) const;
69  Ptr<ArpCache> GetArpCache () const;
70 
78  void SetMetric (uint16_t metric);
79 
87  uint16_t GetMetric (void) const;
88 
97  bool IsUp (void) const;
98 
102  bool IsDown (void) const;
103 
107  void SetUp (void);
108 
112  void SetDown (void);
113 
117  bool IsForwarding (void) const;
118 
122  void SetForwarding (bool val);
123 
131  void Send (Ptr<Packet> p, Ipv4Address dest);
132 
137  bool AddAddress (Ipv4InterfaceAddress address);
138 
143  Ipv4InterfaceAddress GetAddress (uint32_t index) const;
144 
148  uint32_t GetNAddresses (void) const;
149 
154  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
155 
156 protected:
157  virtual void DoDispose (void);
158 private:
159  void DoSetup (void);
160  typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
161  typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
162  typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
163 
164  bool m_ifup;
165  bool m_forwarding; // IN_DEV_FORWARD
166  uint16_t m_metric;
167  Ipv4InterfaceAddressList m_ifaddrs;
168  Ptr<Node> m_node;
169  Ptr<NetDevice> m_device;
170  Ptr<ArpCache> m_cache;
171 };
172 
173 } // namespace ns3
174 
175 #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)
Ipv4InterfaceAddress GetAddress(uint32_t index) const
bool IsDown(void) const
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
virtual void DoDispose(void)
uint32_t GetNAddresses(void) const
a unique identifier for an interface.
Definition: type-id.h:44
bool IsForwarding(void) const
bool IsUp(void) const