A Discrete-Event Network Simulator
API
ipv6.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 
20 /* taken from src/node/ipv4.h and adapted to IPv6 */
21 
22 #ifndef IPV6_H
23 #define IPV6_H
24 
25 #include "ipv6-interface-address.h"
26 
27 #include "ns3/callback.h"
28 #include "ns3/ipv6-address.h"
29 #include "ns3/object.h"
30 #include "ns3/socket.h"
31 
32 #include <stdint.h>
33 
34 namespace ns3
35 {
36 
37 class Node;
38 class NetDevice;
39 class Packet;
40 class Ipv6RoutingProtocol;
41 class IpL4Protocol;
42 class Ipv6Route;
43 
81 class Ipv6 : public Object
82 {
83  public:
88  static TypeId GetTypeId();
89 
93  Ipv6();
94 
98  ~Ipv6() override;
99 
109  virtual void SetRoutingProtocol(Ptr<Ipv6RoutingProtocol> routingProtocol) = 0;
110 
117 
128  virtual uint32_t AddInterface(Ptr<NetDevice> device) = 0;
129 
134  virtual uint32_t GetNInterfaces() const = 0;
135 
150  virtual int32_t GetInterfaceForAddress(Ipv6Address address) const = 0;
151 
168  virtual int32_t GetInterfaceForPrefix(Ipv6Address address, Ipv6Prefix mask) const = 0;
169 
175  virtual Ptr<NetDevice> GetNetDevice(uint32_t interface) = 0;
176 
182  virtual int32_t GetInterfaceForDevice(Ptr<const NetDevice> device) const = 0;
183 
191  virtual bool AddAddress(uint32_t interface,
193  bool addOnLinkRoute = true) = 0;
194 
200  virtual uint32_t GetNAddresses(uint32_t interface) const = 0;
201 
212  virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const = 0;
213 
226  virtual bool RemoveAddress(uint32_t interface, uint32_t addressIndex) = 0;
227 
235  virtual bool RemoveAddress(uint32_t interface, Ipv6Address address) = 0;
236 
244  virtual void SetMetric(uint32_t interface, uint16_t metric) = 0;
245 
253  virtual uint16_t GetMetric(uint32_t interface) const = 0;
254 
261  virtual uint16_t GetMtu(uint32_t interface) const = 0;
262 
268  virtual void SetPmtu(Ipv6Address dst, uint32_t pmtu) = 0;
269 
276  virtual bool IsUp(uint32_t interface) const = 0;
277 
284  virtual void SetUp(uint32_t interface) = 0;
285 
292  virtual void SetDown(uint32_t interface) = 0;
293 
299  virtual bool IsForwarding(uint32_t interface) const = 0;
300 
308  virtual void SetForwarding(uint32_t interface, bool val) = 0;
309 
316  virtual Ipv6Address SourceAddressSelection(uint32_t interface, Ipv6Address dest) = 0;
317 
322  virtual void Insert(Ptr<IpL4Protocol> protocol) = 0;
323 
337  virtual void Insert(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) = 0;
338 
343  virtual void Remove(Ptr<IpL4Protocol> protocol) = 0;
344 
350  virtual void Remove(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) = 0;
351 
357  virtual Ptr<IpL4Protocol> GetProtocol(int protocolNumber) const = 0;
358 
365  virtual Ptr<IpL4Protocol> GetProtocol(int protocolNumber, int32_t interfaceIndex) const = 0;
366 
379  virtual void Send(Ptr<Packet> packet,
380  Ipv6Address source,
381  Ipv6Address destination,
382  uint8_t protocol,
383  Ptr<Ipv6Route> route) = 0;
384 
389  virtual void RegisterExtensions() = 0;
390 
395  virtual void RegisterOptions() = 0;
396 
400  static const uint32_t IF_ANY = 0xffffffff;
401 
402  private:
403  // Indirect the IPv6 attributes through private pure virtual methods
408  virtual void SetIpForward(bool forward) = 0;
409 
414  virtual bool GetIpForward() const = 0;
415 
420  virtual void SetMtuDiscover(bool mtuDiscover) = 0;
421 
426  virtual bool GetMtuDiscover() const = 0;
427 
434  virtual void SetStrongEndSystemModel(bool model) = 0;
441  virtual bool GetStrongEndSystemModel() const = 0;
442 };
443 
444 } // namespace ns3
445 
446 #endif /* IPV6_H */
Describes an IPv6 address.
Definition: ipv6-address.h:49
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Get IPv6 address on specified IPv6 interface.
virtual Ipv6Address SourceAddressSelection(uint32_t interface, Ipv6Address dest)=0
Choose the source address to use with destination address.
virtual Ptr< Ipv6RoutingProtocol > GetRoutingProtocol() const =0
Get the routing protocol to be used by this IPv6 stack.
~Ipv6() override
Destructor.
Definition: ipv6.cc:65
virtual void SetIpForward(bool forward)=0
Set IPv6 forwarding state.
static const uint32_t IF_ANY
Any interface magic number.
Definition: ipv6.h:400
virtual bool RemoveAddress(uint32_t interface, Ipv6Address address)=0
Remove the given address on named Ipv6 interface.
virtual void Send(Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route)=0
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.
virtual uint16_t GetMtu(uint32_t interface) const =0
Get MTU for the specified IPv6 interface.
virtual void SetPmtu(Ipv6Address dst, uint32_t pmtu)=0
Set the Path MTU for the specified IPv6 destination address.
virtual void SetMtuDiscover(bool mtuDiscover)=0
Set IPv6 MTU discover state.
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
Get the interface index of the specified NetDevice.
static TypeId GetTypeId()
Get the type ID.
Definition: ipv6.cc:34
virtual uint32_t GetNInterfaces() const =0
Get number of interfaces.
virtual bool IsUp(uint32_t interface) const =0
If the specified interface index is in "up" state.
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
virtual bool GetIpForward() const =0
Get IPv6 forwarding state.
virtual void RegisterExtensions()=0
Register the IPv6 Extensions.
virtual bool GetStrongEndSystemModel() const =0
Get the Strong End System Model status.
virtual int32_t GetInterfaceForPrefix(Ipv6Address address, Ipv6Prefix mask) const =0
Return the interface number of first interface found that has an IPv6 address within the prefix speci...
virtual uint16_t GetMetric(uint32_t interface) const =0
Get metric for the specified IPv6 interface.
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
Get the NetDevice of the specified interface number.
virtual bool IsForwarding(uint32_t interface) const =0
If the specified IPv6 interface has forwarding enabled.
virtual bool GetMtuDiscover() const =0
Get IPv6 MTU discover state.
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.
virtual void SetForwarding(uint32_t interface, bool val)=0
Set forwarding on specified IPv6 interface.
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber, int32_t interfaceIndex) const =0
Get L4 protocol by protocol number for the specified interface.
virtual void RegisterOptions()=0
Register the IPv6 Options.
virtual int32_t GetInterfaceForAddress(Ipv6Address address) const =0
Return the interface number of the interface that has been assigned the specified IP address.
virtual void SetRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol)=0
Register a new routing protocol to be used by this IPv6 stack.
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
Set metric on specified Ipv6 interface.
virtual void Insert(Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
Add a L4 protocol to a specific interface.
virtual void Remove(Ptr< IpL4Protocol > protocol)=0
Remove a L4 protocol.
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address, bool addOnLinkRoute=true)=0
Add an address on the specified IPv6 interface.
virtual uint32_t GetNAddresses(uint32_t interface) const =0
Get number of addresses on specified IPv6 interface.
virtual void Remove(Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
Remove a L4 protocol from a specific interface.
virtual bool RemoveAddress(uint32_t interface, uint32_t addressIndex)=0
Remove an address on specified IPv6 interface.
virtual void SetDown(uint32_t interface)=0
Set the interface into the "down" state.
Ipv6()
Constructor.
Definition: ipv6.cc:61
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const =0
Get L4 protocol by protocol number.
virtual void SetStrongEndSystemModel(bool model)=0
Set or unset the Strong End System Model.
virtual void Insert(Ptr< IpL4Protocol > protocol)=0
Add a L4 protocol.
IPv6 address associated with an interface.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
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:77
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.