A Discrete-Event Network Simulator
API
ipv6-interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2009 Strasbourg University
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  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18  */
19 
20 #ifndef IPV6_INTERFACE_H
21 #define IPV6_INTERFACE_H
22 
23 #include "ipv6-interface-address.h"
24 
25 #include "ns3/object.h"
26 #include "ns3/ptr.h"
27 
28 #include <list>
29 
30 namespace ns3
31 {
32 
33 class NetDevice;
34 class Packet;
35 class Node;
36 class NdiscCache;
37 class Ipv6InterfaceAddress;
38 class Ipv6Address;
39 class Ipv6Header;
40 class TrafficControlLayer;
41 
52 class Ipv6Interface : public Object
53 {
54  public:
59  static TypeId GetTypeId();
60 
64  Ipv6Interface();
65 
69  ~Ipv6Interface() override;
70 
71  // Delete copy constructor and assignment operator to avoid misuse
72  Ipv6Interface(const Ipv6Interface&) = delete;
74 
79  void SetNode(Ptr<Node> node);
80 
85  void SetDevice(Ptr<NetDevice> device);
86 
92 
97  virtual Ptr<NetDevice> GetDevice() const;
98 
103  void SetMetric(uint16_t metric);
104 
109  uint16_t GetMetric() const;
110 
115  bool IsUp() const;
116 
121  bool IsDown() const;
122 
126  void SetUp();
127 
131  void SetDown();
132 
137  bool IsForwarding() const;
138 
143  void SetForwarding(bool forward);
144 
149  void SetCurHopLimit(uint8_t curHopLimit);
150 
155  uint8_t GetCurHopLimit() const;
156 
161  void SetBaseReachableTime(uint16_t baseReachableTime);
162 
167  uint16_t GetBaseReachableTime() const;
168 
173  void SetReachableTime(uint16_t reachableTime);
174 
179  uint16_t GetReachableTime() const;
180 
185  void SetRetransTimer(uint16_t retransTimer);
186 
191  uint16_t GetRetransTimer() const;
192 
202  void Send(Ptr<Packet> p, const Ipv6Header& hdr, Ipv6Address dest);
203 
209  bool AddAddress(Ipv6InterfaceAddress iface);
210 
216 
223 
229  Ipv6InterfaceAddress GetAddress(uint32_t index) const;
230 
237 
242  uint32_t GetNAddresses() const;
243 
249  Ipv6InterfaceAddress RemoveAddress(uint32_t index);
250 
259 
266 
272  void SetNsDadUid(Ipv6Address address, uint32_t uid);
273 
278 
287  Callback<void, Ptr<Ipv6Interface>, Ipv6InterfaceAddress> removeAddressCallback);
288 
296  void AddAddressCallback(
297  Callback<void, Ptr<Ipv6Interface>, Ipv6InterfaceAddress> addAddressCallback);
298 
299  protected:
303  void DoDispose() override;
304 
305  private:
309  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address>> Ipv6InterfaceAddressList;
310 
314  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address>>::iterator
316 
320  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address>>::const_iterator
322 
326  void DoSetup();
327 
332 
337 
341  bool m_ifup;
342 
347 
351  uint16_t m_metric;
352 
357 
362 
367 
372 
376  uint8_t m_curHopLimit;
377 
382 
387  uint16_t m_reachableTime;
388 
393  uint16_t m_retransTimer;
394 
397 
400 };
401 
402 } /* namespace ns3 */
403 
404 #endif /* IPV6_INTERFACE_H */
Callback template class.
Definition: callback.h:438
Describes an IPv6 address.
Definition: ipv6-address.h:49
Packet header for IPv6.
Definition: ipv6-header.h:35
IPv6 address associated with an interface.
State_e
State of an address associated with an interface.
The IPv6 representation of a network interface.
Ipv6InterfaceAddress RemoveAddress(uint32_t index)
Remove an address from interface.
uint16_t GetBaseReachableTime() const
Get the base reachable time.
uint8_t m_curHopLimit
Current hop limit.
Ptr< NetDevice > m_device
NetDevice associated with this interface.
bool IsDown() const
Is the interface DOWN ?
Ptr< NdiscCache > m_ndCache
Neighbor cache.
Ipv6InterfaceAddress GetLinkLocalAddress() const
Get link-local address from IPv6 interface.
bool m_ifup
The state of this interface.
uint8_t GetCurHopLimit() const
Get the current hop limit value.
static TypeId GetTypeId()
Get the type ID.
Ipv6Interface(const Ipv6Interface &)=delete
Ipv6Interface()
Constructs an Ipv6Interface.
void SetRetransTimer(uint16_t retransTimer)
Set the retransmission timer.
void DoSetup()
Initialize interface.
void SetForwarding(bool forward)
Set forwarding enabled or not.
void SetReachableTime(uint16_t reachableTime)
Set the reachable time.
Ipv6InterfaceAddress GetAddressMatchingDestination(Ipv6Address dst)
Get an address which is in the same network prefix as destination.
void SetNode(Ptr< Node > node)
Set node associated with interface.
void SetDown()
Disable this interface.
bool IsForwarding() const
If the interface allows forwarding packets.
void RemoveAddressCallback(Callback< void, Ptr< Ipv6Interface >, Ipv6InterfaceAddress > removeAddressCallback)
This callback is set when an address is removed from an interface with auto-generated Ndisc cache and...
uint16_t GetReachableTime() const
Get the reachable time.
bool IsUp() const
Is the interface UP ?
bool m_forwarding
Forwarding state.
uint16_t m_metric
The metric.
uint16_t m_reachableTime
Reachable time (in millisecond).
uint32_t GetNAddresses() const
Get number of addresses on this IPv6 interface.
void DoDispose() override
Dispose this object.
Callback< void, Ptr< Ipv6Interface >, Ipv6InterfaceAddress > m_removeAddressCallback
remove address callback
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > >::const_iterator Ipv6InterfaceAddressListCI
Const Container Iterator for the Ipv6InterfaceAddresses.
bool IsSolicitedMulticastAddress(Ipv6Address address) const
Checks if the address is a Solicited Multicast address for this interface.
void SetCurHopLimit(uint8_t curHopLimit)
Set the current hop limit.
Ipv6InterfaceAddress GetAddress(uint32_t index) const
Get an address from IPv6 interface.
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > > Ipv6InterfaceAddressList
Container for the Ipv6InterfaceAddresses.
~Ipv6Interface() override
Destructor.
bool AddAddress(Ipv6InterfaceAddress iface)
Add an IPv6 address.
void SetUp()
Enable this interface.
void SetNsDadUid(Ipv6Address address, uint32_t uid)
Update NS DAD packet UID of an interface address.
uint16_t m_retransTimer
Retransmission timer (in millisecond).
void Send(Ptr< Packet > p, const Ipv6Header &hdr, Ipv6Address dest)
Send a packet through this interface.
Ipv6InterfaceAddressList m_addresses
The addresses assigned to this interface.
uint16_t GetRetransTimer() const
Get the retransmission timer.
uint16_t GetMetric() const
Get the metric.
void SetBaseReachableTime(uint16_t baseReachableTime)
Set the base reachable time.
Ptr< NdiscCache > GetNdiscCache() const
Ipv6InterfaceAddress m_linkLocalAddress
The link-local addresses assigned to this interface.
Ptr< Node > m_node
Node associated with this interface.
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > >::iterator Ipv6InterfaceAddressListI
Container Iterator for the Ipv6InterfaceAddresses.
Callback< void, Ptr< Ipv6Interface >, Ipv6InterfaceAddress > m_addAddressCallback
add address callback
void SetTrafficControl(Ptr< TrafficControlLayer > tc)
Set the TrafficControlLayer.
void SetMetric(uint16_t metric)
Set the metric.
uint16_t m_baseReachableTime
Base value used for computing the random reachable time value (in millisecond).
Ptr< TrafficControlLayer > m_tc
TrafficControlLayer associated with this interface.
Ipv6Interface & operator=(const Ipv6Interface &)=delete
void AddAddressCallback(Callback< void, Ptr< Ipv6Interface >, Ipv6InterfaceAddress > addAddressCallback)
This callback is set when an address is added from an interface with auto-generated Ndisc cache and i...
void SetDevice(Ptr< NetDevice > device)
Set the NetDevice.
virtual Ptr< NetDevice > GetDevice() const
Get the NetDevice.
void SetState(Ipv6Address address, Ipv6InterfaceAddress::State_e state)
Update state of an interface address.
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.