A Discrete-Event Network Simulator
API
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/ipv4-address.h"
28#include "ipv4-route.h"
30
31namespace ns3 {
32
33class Node;
34class NetDevice;
35class Packet;
36class Ipv4RoutingProtocol;
37class IpL4Protocol;
38class Ipv4Header;
39
76class Ipv4 : public Object
77{
78public:
83 static TypeId GetTypeId (void);
84 Ipv4 ();
85 virtual ~Ipv4 ();
86
96 virtual void SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) = 0;
97
104
115
119 virtual uint32_t GetNInterfaces (void) const = 0;
120
137
148 virtual void Send (Ptr<Packet> packet, Ipv4Address source,
149 Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route) = 0;
150
159 virtual void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) = 0;
160
170 virtual void Insert (Ptr<IpL4Protocol> protocol) = 0;
171
185 virtual void Insert (Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) = 0;
186
193 virtual void Remove (Ptr<IpL4Protocol> protocol) = 0;
194
200 virtual void Remove (Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) = 0;
201
222 virtual bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const = 0;
223
241 Ipv4Mask mask) const = 0;
242
247 virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0;
248
254
260 virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
261
266 virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
267
276 virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
277
288 virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
289
297 virtual bool RemoveAddress (uint32_t interface, Ipv4Address address) = 0;
298
336
342 virtual void SetMetric (uint32_t interface, uint16_t metric) = 0;
343
349 virtual uint16_t GetMetric (uint32_t interface) const = 0;
350
356 virtual uint16_t GetMtu (uint32_t interface) const = 0;
357
363 virtual bool IsUp (uint32_t interface) const = 0;
364
371 virtual void SetUp (uint32_t interface) = 0;
372
379 virtual void SetDown (uint32_t interface) = 0;
380
385 virtual bool IsForwarding (uint32_t interface) const = 0;
386
393 virtual void SetForwarding (uint32_t interface, bool val) = 0;
394
402
411 virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber) const = 0;
412
419 virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber, int32_t interfaceIndex) const = 0;
420
426 virtual Ptr<Socket> CreateRawSocket (void) = 0;
427
433 virtual void DeleteRawSocket (Ptr<Socket> socket) = 0;
434
435
436 static const uint32_t IF_ANY = 0xffffffff;
437
438private:
439 // Indirect the Ipv4 attributes through private pure virtual methods
440
445 virtual void SetIpForward (bool forward) = 0;
450 virtual bool GetIpForward (void) const = 0;
451
458 virtual void SetWeakEsModel (bool model) = 0;
465 virtual bool GetWeakEsModel (void) const = 0;
466};
467
468} // namespace ns3
469
470#endif /* IPV4_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
virtual int32_t GetInterfaceForAddress(Ipv4Address address) const =0
Return the interface number of the interface that has been assigned the specified IP address.
virtual void SetIpForward(bool forward)=0
Set or unset the IP forwarding state.
Ipv4()
Definition: ipv4.cc:61
virtual void DeleteRawSocket(Ptr< Socket > socket)=0
Deletes a particular raw socket.
virtual bool IsForwarding(uint32_t interface) const =0
virtual void SetMetric(uint32_t interface, uint16_t metric)=0
virtual void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)=0
Register a new routing protocol to be used by this Ipv4 stack.
static TypeId GetTypeId(void)
Get the type ID.
Definition: ipv4.cc:34
virtual void SetWeakEsModel(bool model)=0
Set or unset the Weak Es Model.
virtual bool GetWeakEsModel(void) const =0
Get the Weak Es Model status.
virtual void Insert(Ptr< IpL4Protocol > protocol)=0
virtual uint32_t GetNAddresses(uint32_t interface) const =0
virtual Ptr< Socket > CreateRawSocket(void)=0
Creates a raw socket.
virtual void Remove(Ptr< IpL4Protocol > protocol)=0
virtual bool RemoveAddress(uint32_t interface, Ipv4Address address)=0
Remove the given address on named Ipv4 interface.
virtual uint16_t GetMtu(uint32_t interface) const =0
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const =0
Get the routing protocol to be used by this Ipv4 stack.
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 AddInterface(Ptr< NetDevice > device)=0
virtual void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)=0
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const =0
virtual void SetUp(uint32_t interface)=0
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 Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
virtual void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
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...
virtual void Insert(Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
Add a L4 protocol to a specific interface.
static const uint32_t IF_ANY
interface wildcard, meaning any interface
Definition: ipv4.h:436
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber, int32_t interfaceIndex) const =0
Get L4 protocol by protocol number for the specified interface.
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =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...
virtual ~Ipv4()
Definition: ipv4.cc:66
virtual void SetDown(uint32_t interface)=0
virtual bool GetIpForward(void) const =0
Get the IP forwarding state.
virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)=0
Choose the source address to use with destination address.
virtual bool RemoveAddress(uint32_t interface, uint32_t addressIndex)=0
Remove the address at addressIndex on named interface.
virtual uint16_t GetMetric(uint32_t interface) const =0
virtual bool AddAddress(uint32_t interface, Ipv4InterfaceAddress address)=0
virtual uint32_t GetNInterfaces(void) const =0
virtual void Remove(Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
Remove a L4 protocol from a specific interface.
virtual void SetForwarding(uint32_t interface, bool val)=0
virtual bool IsUp(uint32_t interface) const =0
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.