A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv4.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef IPV4_H
21 #define IPV4_H
22 
23 #include <stdint.h>
24 #include "ns3/object.h"
25 #include "ns3/socket.h"
26 #include "ns3/callback.h"
27 #include "ns3/ip-l4-protocol.h"
28 #include "ns3/ipv4-address.h"
29 #include "ipv4-route.h"
30 #include "ipv4-interface-address.h"
31 
32 namespace ns3 {
33 
34 class Node;
35 class NetDevice;
36 class Packet;
37 class Ipv4RoutingProtocol;
38 
75 class Ipv4 : public Object
76 {
77 public:
82  static TypeId GetTypeId (void);
83  Ipv4 ();
84  virtual ~Ipv4 ();
85 
95  virtual void SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) = 0;
96 
102  virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (void) const = 0;
103 
113  virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0;
114 
118  virtual uint32_t GetNInterfaces (void) const = 0;
119 
135  virtual int32_t GetInterfaceForAddress (Ipv4Address address) const = 0;
136 
147  virtual void Send (Ptr<Packet> packet, Ipv4Address source,
148  Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route) = 0;
149 
158  virtual void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) = 0;
159 
166  virtual void Insert (Ptr<IpL4Protocol> protocol) = 0;
167 
188  virtual bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const = 0;
189 
206  virtual int32_t GetInterfaceForPrefix (Ipv4Address address,
207  Ipv4Mask mask) const = 0;
208 
213  virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0;
214 
219  virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0;
220 
226  virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
227 
232  virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
233 
242  virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
243 
254  virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
255 
263  virtual bool RemoveAddress (uint32_t interface, Ipv4Address address) = 0;
264 
302 
308  virtual void SetMetric (uint32_t interface, uint16_t metric) = 0;
309 
315  virtual uint16_t GetMetric (uint32_t interface) const = 0;
316 
322  virtual uint16_t GetMtu (uint32_t interface) const = 0;
323 
329  virtual bool IsUp (uint32_t interface) const = 0;
330 
337  virtual void SetUp (uint32_t interface) = 0;
338 
345  virtual void SetDown (uint32_t interface) = 0;
346 
351  virtual bool IsForwarding (uint32_t interface) const = 0;
352 
359  virtual void SetForwarding (uint32_t interface, bool val) = 0;
360 
369  virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber) const = 0;
370 
376  virtual Ptr<Socket> CreateRawSocket (void) = 0;
377 
383  virtual void DeleteRawSocket (Ptr<Socket> socket) = 0;
384 
385 
386  static const uint32_t IF_ANY = 0xffffffff;
387 
388 private:
389  // Indirect the Ipv4 attributes through private pure virtual methods
390 
395  virtual void SetIpForward (bool forward) = 0;
400  virtual bool GetIpForward (void) const = 0;
401 
408  virtual void SetWeakEsModel (bool model) = 0;
415  virtual bool GetWeakEsModel (void) const = 0;
416 };
417 
418 } // namespace ns3
419 
420 #endif /* IPV4_H */
static TypeId GetTypeId(void)
Get the type ID.
Definition: ipv4.cc:35
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
virtual int32_t GetInterfaceForPrefix(Ipv4Address address, Ipv4Mask mask) const =0
Return the interface number of first interface found that has an Ipv4 address within the prefix speci...
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual void SetWeakEsModel(bool model)=0
Set or unset the Weak Es Model.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
virtual void SetForwarding(uint32_t interface, bool val)=0
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const =0
Get the routing protocol to be used by this Ipv4 stack.
virtual bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const =0
Determine whether address and interface corresponding to received packet can be accepted for local de...
Packet header for IPv4.
Definition: ipv4-header.h:31
virtual bool GetIpForward(void) const =0
Get the IP forwarding state.
virtual void DeleteRawSocket(Ptr< Socket > socket)=0
Deletes a particular raw socket.
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const =0
Ipv4()
Definition: ipv4.cc:61
virtual void SetUp(uint32_t interface)=0
virtual uint16_t GetMetric(uint32_t interface) const =0
virtual void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)=0
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
virtual bool GetWeakEsModel(void) const =0
Get the Weak Es Model status.
virtual bool IsForwarding(uint32_t interface) const =0
virtual uint16_t GetMtu(uint32_t interface) const =0
virtual void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
virtual ~Ipv4()
Definition: ipv4.cc:66
virtual Ptr< Socket > CreateRawSocket(void)=0
Creates a raw socket.
virtual bool IsUp(uint32_t interface) const =0
virtual void SetIpForward(bool forward)=0
Set or unset the IP forwarding state.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void Insert(Ptr< IpL4Protocol > protocol)=0
a class to store IPv4 address information on an interface
virtual Ipv4InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
virtual uint32_t GetNAddresses(uint32_t interface) const =0
static const uint32_t IF_ANY
interface wildcard, meaning any interface
Definition: ipv4.h:386
virtual Ipv4Address SelectSourceAddress(Ptr< const NetDevice > device, Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope)=0
Return the first primary source address with scope less than or equal to the requested scope...
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual int32_t GetInterfaceForAddress(Ipv4Address address) const =0
Return the interface number of the interface that has been assigned the specified IP address...
a base class which provides memory management and object aggregation
Definition: object.h:63
virtual void SetDown(uint32_t interface)=0
tuple address
Definition: first.py:37
virtual bool RemoveAddress(uint32_t interface, uint32_t addressIndex)=0
Remove the address at addressIndex on named interface.
a unique identifier for an interface.
Definition: type-id.h:49
virtual uint32_t GetNInterfaces(void) const =0
virtual void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)=0
Register a new routing protocol to be used by this Ipv4 stack.