A Discrete-Event Network Simulator
API
ipv6-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
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  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #ifndef IPV6_INTERFACE_H
22 #define IPV6_INTERFACE_H
23 
24 #include <list>
25 #include "ns3/ptr.h"
26 #include "ns3/object.h"
27 #include "ipv6-interface-address.h"
28 
29 namespace ns3
30 {
31 
32 class NetDevice;
33 class Packet;
34 class Node;
35 class NdiscCache;
36 class Ipv6InterfaceAddress;
37 class Ipv6Address;
38 class Ipv6Header;
39 class TrafficControlLayer;
40 
51 class Ipv6Interface : public Object
52 {
53 public:
58  static TypeId GetTypeId ();
59 
63  Ipv6Interface ();
64 
68  virtual ~Ipv6Interface ();
69 
70  // Delete copy constructor and assignment operator to avoid misuse
71  Ipv6Interface (const Ipv6Interface &) = delete;
73 
78  void SetNode (Ptr<Node> node);
79 
84  void SetDevice (Ptr<NetDevice> device);
85 
91 
96  virtual Ptr<NetDevice> GetDevice () const;
97 
102  void SetMetric (uint16_t metric);
103 
108  uint16_t GetMetric () const;
109 
114  bool IsUp () const;
115 
120  bool IsDown () const;
121 
125  void SetUp ();
126 
130  void SetDown ();
131 
136  bool IsForwarding () const;
137 
142  void SetForwarding (bool forward);
143 
148  void SetCurHopLimit (uint8_t curHopLimit);
149 
154  uint8_t GetCurHopLimit () const;
155 
160  void SetBaseReachableTime (uint16_t baseReachableTime);
161 
166  uint16_t GetBaseReachableTime () const;
167 
172  void SetReachableTime (uint16_t reachableTime);
173 
178  uint16_t GetReachableTime () const;
179 
184  void SetRetransTimer (uint16_t retransTimer);
185 
190  uint16_t GetRetransTimer () const;
191 
201  void Send (Ptr<Packet> p, const Ipv6Header & hdr, Ipv6Address dest);
202 
208  bool AddAddress (Ipv6InterfaceAddress iface);
209 
215 
222 
228  Ipv6InterfaceAddress GetAddress (uint32_t index) const;
229 
236 
241  uint32_t GetNAddresses (void) const;
242 
248  Ipv6InterfaceAddress RemoveAddress (uint32_t index);
249 
258 
265 
271  void SetNsDadUid (Ipv6Address address, uint32_t uid);
272 
277 
278 
279 protected:
283  virtual void DoDispose ();
284 
285 private:
289  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> > Ipv6InterfaceAddressList;
290 
294  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> >::iterator Ipv6InterfaceAddressListI;
295 
299  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> >::const_iterator Ipv6InterfaceAddressListCI;
300 
304  void DoSetup ();
305 
310 
315 
319  bool m_ifup;
320 
325 
329  uint16_t m_metric;
330 
335 
340 
345 
350 
354  uint8_t m_curHopLimit;
355 
360 
365  uint16_t m_reachableTime;
366 
371  uint16_t m_retransTimer;
372 };
373 
374 } /* namespace ns3 */
375 
376 #endif /* IPV6_INTERFACE_H */
377 
Describes an IPv6 address.
Definition: ipv6-address.h:50
Packet header for IPv6.
Definition: ipv6-header.h:36
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 ?
virtual void DoDispose()
Dispose this object.
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.
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).
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.
virtual ~Ipv6Interface()
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.
uint32_t GetNAddresses(void) const
Get number of addresses on this IPv6 interface.
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 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:88
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.