A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-interface.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006,2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors:
18 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
19 * Tom Henderson <tomh@tomh.org>
20 */
21#ifndef IPV4_INTERFACE_H
22#define IPV4_INTERFACE_H
23
24#include "ns3/object.h"
25#include "ns3/ptr.h"
26
27#include <list>
28
29namespace ns3
30{
31
32class NetDevice;
33class Packet;
34class Node;
35class ArpCache;
36class Ipv4InterfaceAddress;
37class Ipv4Address;
38class Ipv4Header;
39class TrafficControlLayer;
40
54class Ipv4Interface : public Object
55{
56 public:
61 static TypeId GetTypeId();
62
64 ~Ipv4Interface() override;
65
66 // Delete copy constructor and assignment operator to avoid misuse
67 Ipv4Interface(const Ipv4Interface&) = delete;
69
74 void SetNode(Ptr<Node> node);
79 void SetDevice(Ptr<NetDevice> device);
89 void SetArpCache(Ptr<ArpCache> arpCache);
90
95
100
108 void SetMetric(uint16_t metric);
109
117 uint16_t GetMetric() const;
118
127 bool IsUp() const;
128
132 bool IsDown() const;
133
137 void SetUp();
138
142 void SetDown();
143
147 bool IsForwarding() const;
148
152 void SetForwarding(bool val);
153
162 void Send(Ptr<Packet> p, const Ipv4Header& hdr, Ipv4Address dest);
163
168 bool AddAddress(Ipv4InterfaceAddress address);
169
175
179 uint32_t GetNAddresses() const;
180
186
195
204 Callback<void, Ptr<Ipv4Interface>, Ipv4InterfaceAddress> removeAddressCallback);
205
214 Callback<void, Ptr<Ipv4Interface>, Ipv4InterfaceAddress> addAddressCallback);
215
216 protected:
217 void DoDispose() override;
218
219 private:
223 void DoSetup();
224
228 typedef std::list<Ipv4InterfaceAddress> Ipv4InterfaceAddressList;
229
233 typedef std::list<Ipv4InterfaceAddress>::const_iterator Ipv4InterfaceAddressListCI;
234
238 typedef std::list<Ipv4InterfaceAddress>::iterator Ipv4InterfaceAddressListI;
239
240 bool m_ifup;
242 uint16_t m_metric;
252};
253
254} // namespace ns3
255
256#endif
Callback template class.
Definition: callback.h:438
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
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.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetNAddresses() 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.
~Ipv4Interface() override
Ipv4Interface(const Ipv4Interface &)=delete
void RemoveAddressCallback(Callback< void, Ptr< Ipv4Interface >, Ipv4InterfaceAddress > removeAddressCallback)
This callback is set when an address is removed from an interface with auto-generated Arp cache and i...
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.
bool m_forwarding
Forwarding state.
std::list< Ipv4InterfaceAddress >::const_iterator Ipv4InterfaceAddressListCI
Container Iterator for the Ipv4InterfaceAddresses.
uint16_t GetMetric() const
Ptr< NetDevice > m_device
The associated NetDevice.
bool IsUp() const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
void SetUp()
Enable this interface.
Ptr< ArpCache > GetArpCache() const
void SetDevice(Ptr< NetDevice > device)
Set the NetDevice.
void DoSetup()
Initialize interface.
Ptr< NetDevice > GetDevice() const
Ipv4InterfaceAddressList m_ifaddrs
Address list.
Callback< void, Ptr< Ipv4Interface >, Ipv4InterfaceAddress > m_addAddressCallback
add address callback
uint16_t m_metric
Interface metric.
void SetDown()
Disable this interface.
bool IsForwarding() const
void AddAddressCallback(Callback< void, Ptr< Ipv4Interface >, Ipv4InterfaceAddress > addAddressCallback)
This callback is set when an address is added from an interface with auto-generated Arp cache and it ...
void DoDispose() override
Destructor implementation.
Ptr< ArpCache > m_cache
ARP cache.
Callback< void, Ptr< Ipv4Interface >, Ipv4InterfaceAddress > m_removeAddressCallback
remove address callback
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
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.
void SetForwarding(bool val)
Ipv4Interface & operator=(const Ipv4Interface &)=delete
void SetMetric(uint16_t metric)
Ipv4InterfaceAddress RemoveAddress(uint32_t index)
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.