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 
74  void SetNode (Ptr<Node> node);
75 
80  void SetDevice (Ptr<NetDevice> device);
81 
87 
92  virtual Ptr<NetDevice> GetDevice () const;
93 
98  void SetMetric (uint16_t metric);
99 
104  uint16_t GetMetric () const;
105 
110  bool IsUp () const;
111 
116  bool IsDown () const;
117 
121  void SetUp ();
122 
126  void SetDown ();
127 
132  bool IsForwarding () const;
133 
138  void SetForwarding (bool forward);
139 
144  void SetCurHopLimit (uint8_t curHopLimit);
145 
150  uint8_t GetCurHopLimit () const;
151 
156  void SetBaseReachableTime (uint16_t baseReachableTime);
157 
162  uint16_t GetBaseReachableTime () const;
163 
168  void SetReachableTime (uint16_t reachableTime);
169 
174  uint16_t GetReachableTime () const;
175 
180  void SetRetransTimer (uint16_t retransTimer);
181 
186  uint16_t GetRetransTimer () const;
187 
197  void Send (Ptr<Packet> p, const Ipv6Header & hdr, Ipv6Address dest);
198 
204  bool AddAddress (Ipv6InterfaceAddress iface);
205 
211 
218 
224  Ipv6InterfaceAddress GetAddress (uint32_t index) const;
225 
232 
237  uint32_t GetNAddresses (void) const;
238 
244  Ipv6InterfaceAddress RemoveAddress (uint32_t index);
245 
254 
261 
267  void SetNsDadUid (Ipv6Address address, uint32_t uid);
268 
273 
274 
275 protected:
279  virtual void DoDispose ();
280 
281 private:
288  Ipv6Interface (const Ipv6Interface &o);
289 
298 
302  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> > Ipv6InterfaceAddressList;
303 
307  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> >::iterator Ipv6InterfaceAddressListI;
308 
312  typedef std::list<std::pair<Ipv6InterfaceAddress, Ipv6Address> >::const_iterator Ipv6InterfaceAddressListCI;
313 
317  void DoSetup ();
318 
323 
328 
332  bool m_ifup;
333 
338 
342  uint16_t m_metric;
343 
348 
353 
358 
363 
367  uint8_t m_curHopLimit;
368 
373 
378  uint16_t m_reachableTime;
379 
384  uint16_t m_retransTimer;
385 };
386 
387 } /* namespace ns3 */
388 
389 #endif /* IPV6_INTERFACE_H */
390 
Ipv6InterfaceAddressList m_addresses
The addresses assigned to this interface.
bool m_ifup
The state of this interface.
Packet header for IPv6.
Definition: ipv6-header.h:34
bool AddAddress(Ipv6InterfaceAddress iface)
Add an IPv6 address.
void SetState(Ipv6Address address, Ipv6InterfaceAddress::State_e state)
Update state of an interface address.
void SetUp()
Enable this interface.
Ipv6InterfaceAddress GetLinkLocalAddress() const
Get link-local address from IPv6 interface.
bool m_forwarding
Forwarding state.
IPv6 address associated with an interface.
Ptr< NetDevice > m_device
NetDevice associated with this interface.
void SetDevice(Ptr< NetDevice > device)
Set the NetDevice.
bool IsForwarding() const
If the interface allows forwarding packets.
void SetReachableTime(uint16_t reachableTime)
Set the reachable time.
virtual Ptr< NetDevice > GetDevice() const
Get the NetDevice.
bool IsSolicitedMulticastAddress(Ipv6Address address) const
Checks if the address is a Solicited Multicast address for this interface.
void SetBaseReachableTime(uint16_t baseReachableTime)
Set the base reachable time.
uint16_t m_baseReachableTime
Base value used for computing the random reachable time value (in millisecond).
The IPv6 representation of a network interface.
void Send(Ptr< Packet > p, const Ipv6Header &hdr, Ipv6Address dest)
Send a packet through this interface.
void SetMetric(uint16_t metric)
Set the metric.
Ptr< Node > m_node
Node associated with this interface.
virtual ~Ipv6Interface()
Destructor.
void SetRetransTimer(uint16_t retransTimer)
Set the retransmission timer.
uint16_t m_retransTimer
Retransmission timer (in millisecond).
bool IsUp() const
Is the interface UP ?
static TypeId GetTypeId()
Get the type ID.
Ipv6InterfaceAddress m_linkLocalAddress
The link-local addresses assigned to this interface.
void SetTrafficControl(Ptr< TrafficControlLayer > tc)
Set the TrafficControlLayer.
void SetNsDadUid(Ipv6Address address, uint32_t uid)
Update NS DAD packet UID of an interface address.
void SetNode(Ptr< Node > node)
Set node associated with interface.
void SetForwarding(bool forward)
Set forwarding enabled or not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_curHopLimit
Current hop limit.
uint16_t GetReachableTime() const
Get the reachable time.
address
Definition: first.py:37
void SetCurHopLimit(uint8_t curHopLimit)
Set the current hop limit.
uint32_t GetNAddresses(void) const
Get number of addresses on this IPv6 interface.
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > >::const_iterator Ipv6InterfaceAddressListCI
Const Container Iterator for the Ipv6InterfaceAddresses.
Ipv6InterfaceAddress GetAddress(uint32_t index) const
Get an address from IPv6 interface.
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > >::iterator Ipv6InterfaceAddressListI
Container Iterator for the Ipv6InterfaceAddresses.
Describes an IPv6 address.
Definition: ipv6-address.h:49
uint16_t GetMetric() const
Get the metric.
State_e
State of an address associated with an interface.
void DoSetup()
Initialize interface.
uint16_t m_reachableTime
Reachable time (in millisecond).
uint16_t GetBaseReachableTime() const
Get the base reachable time.
uint8_t GetCurHopLimit() const
Get the current hop limit value.
Ipv6Interface & operator=(const Ipv6Interface &o)
Assignment operator.
Ipv6InterfaceAddress RemoveAddress(uint32_t index)
Remove an address from interface.
Ptr< NdiscCache > GetNdiscCache() const
A base class which provides memory management and object aggregation.
Definition: object.h:87
bool IsDown() const
Is the interface DOWN ?
virtual void DoDispose()
Dispose this object.
uint16_t m_metric
The metric.
Ptr< TrafficControlLayer > m_tc
TrafficControlLayer associated with this interface.
void SetDown()
Disable this interface.
a unique identifier for an interface.
Definition: type-id.h:58
Ipv6InterfaceAddress GetAddressMatchingDestination(Ipv6Address dst)
Get an address which is in the same network prefix as destination.
Ptr< NdiscCache > m_ndCache
Neighbor cache.
uint16_t GetRetransTimer() const
Get the retransmission timer.
std::list< std::pair< Ipv6InterfaceAddress, Ipv6Address > > Ipv6InterfaceAddressList
Container for the Ipv6InterfaceAddresses.
Ipv6Interface()
Constructs an Ipv6Interface.