A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-l3-click-protocol.h
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
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: George F. Riley <riley@ece.gatech.edu>
18// Author: Lalith Suresh <suresh.lalith@gmail.com>
19//
20
21#ifndef IPV4_L3_CLICK_PROTOCOL_H
22#define IPV4_L3_CLICK_PROTOCOL_H
23
24#include "ns3/ipv4-interface.h"
25#include "ns3/ipv4-routing-protocol.h"
26#include "ns3/ipv4.h"
27#include "ns3/log.h"
28#include "ns3/net-device.h"
29#include "ns3/packet.h"
30#include "ns3/traced-callback.h"
31
32namespace ns3
33{
34
35class Packet;
36class NetDevice;
37class Ipv4Interface;
38class Ipv4Address;
39class Ipv4Header;
40class Ipv4RoutingTableEntry;
41class Ipv4Route;
42class Node;
43class Socket;
44class Ipv4RawSocketImpl;
45class IpL4Protocol;
46class Icmpv4L4Protocol;
47
62{
63#ifdef NS3_CLICK
64 public:
65 static TypeId GetTypeId();
66
70 static const uint16_t PROT_NUMBER;
71
73 ~Ipv4L3ClickProtocol() override;
74
75 void Insert(Ptr<IpL4Protocol> protocol) override;
76 void Insert(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
77
78 void Remove(Ptr<IpL4Protocol> protocol) override;
79 void Remove(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
80
81 Ptr<IpL4Protocol> GetProtocol(int protocolNumber) const override;
82 Ptr<IpL4Protocol> GetProtocol(int protocolNumber, int32_t interfaceIndex) const override;
83
85
92 void SetDefaultTtl(uint8_t ttl);
93
104 void Send(Ptr<Packet> packet,
105 Ipv4Address source,
106 Ipv4Address destination,
107 uint8_t protocol,
108 Ptr<Ipv4Route> route) override;
109
118 void SendWithHeader(Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) override;
119
127 void SendDown(Ptr<Packet> packet, int ifid);
128
138 void Receive(Ptr<NetDevice> device,
140 uint16_t protocol,
141 const Address& from,
142 const Address& to,
143 NetDevice::PacketType packetType);
144
151 void LocalDeliver(Ptr<const Packet> p, const Ipv4Header& ip, uint32_t iif);
152
158 Ptr<Ipv4Interface> GetInterface(uint32_t i) const;
159
165 uint32_t AddIpv4Interface(Ptr<Ipv4Interface> interface);
166
171 void SetNode(Ptr<Node> node);
172
177 Ptr<Icmpv4L4Protocol> GetIcmp() const;
178
182 void SetupLoopback();
183
188 Ptr<Socket> CreateRawSocket() override;
189
194 void DeleteRawSocket(Ptr<Socket> socket) override;
195
196 // functions defined in base class Ipv4
197 void SetRoutingProtocol(Ptr<Ipv4RoutingProtocol> routingProtocol) override;
199
201
202 uint32_t AddInterface(Ptr<NetDevice> device) override;
203 uint32_t GetNInterfaces() const override;
204
205 int32_t GetInterfaceForAddress(Ipv4Address addr) const override;
206 int32_t GetInterfaceForPrefix(Ipv4Address addr, Ipv4Mask mask) const override;
208 bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const override;
209
210 bool AddAddress(uint32_t i, Ipv4InterfaceAddress address) override;
211 Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override;
212 uint32_t GetNAddresses(uint32_t interface) const override;
213 bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override;
214 bool RemoveAddress(uint32_t interfaceIndex, Ipv4Address address) override;
216 Ipv4Address dst,
218
219 void SetMetric(uint32_t i, uint16_t metric) override;
220 uint16_t GetMetric(uint32_t i) const override;
221 uint16_t GetMtu(uint32_t i) const override;
222 bool IsUp(uint32_t i) const override;
223 void SetUp(uint32_t i) override;
224 void SetDown(uint32_t i) override;
225 bool IsForwarding(uint32_t i) const override;
226 void SetForwarding(uint32_t i, bool val) override;
227 void SetPromisc(uint32_t i);
228
229 protected:
230 void DoDispose() override;
236 void NotifyNewAggregate() override;
237
238 private:
239 Ipv4Header BuildHeader(Ipv4Address source,
240 Ipv4Address destination,
241 uint8_t protocol,
242 uint16_t payloadSize,
243 uint8_t ttl,
244 bool mayFragment);
245
246 void SetIpForward(bool forward) override;
247 bool GetIpForward() const override;
248 void SetWeakEsModel(bool model) override;
249 bool GetWeakEsModel() const override;
250
251 typedef std::vector<Ptr<Ipv4Interface>> Ipv4InterfaceList;
255 typedef std::map<Ptr<const NetDevice>, uint32_t> Ipv4InterfaceReverseContainer;
256 typedef std::list<Ptr<Ipv4RawSocketImpl>> SocketList;
260 typedef std::pair<int, int32_t> L4ListKey_t;
264 typedef std::map<L4ListKey_t, Ptr<IpL4Protocol>> L4List_t;
265
266 Ptr<Ipv4RoutingProtocol> m_routingProtocol;
267 bool m_ipForward;
268 bool m_weakEsModel;
269 L4List_t m_protocols;
270 Ipv4InterfaceList m_interfaces;
271 Ipv4InterfaceReverseContainer
272 m_reverseInterfacesContainer;
273 uint8_t m_defaultTtl;
274 uint16_t m_identification;
275
276 Ptr<Node> m_node;
277
284
285 SocketList m_sockets;
286
287 std::vector<bool> m_promiscDeviceList;
288
289#endif /* NS3_CLICK */
290};
291
292} // namespace ns3
293
294#endif /* IPV4_L3_CLICK_ROUTING_H */
a polymophic address class
Definition: address.h:100
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
virtual int32_t GetInterfaceForAddress(Ipv4Address address) const =0
Return the interface number of the interface that has been assigned the specified IP address.
virtual bool GetIpForward() const =0
Get the IP forwarding state.
virtual void SetIpForward(bool forward)=0
Set or unset the IP forwarding state.
virtual void DeleteRawSocket(Ptr< Socket > socket)=0
Deletes a particular raw socket.
virtual bool IsForwarding(uint32_t interface) const =0
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol() const =0
Get the routing protocol to be used by this Ipv4 stack.
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.
virtual void SetWeakEsModel(bool model)=0
Set or unset the Weak Es Model.
virtual void Insert(Ptr< IpL4Protocol > protocol)=0
virtual uint32_t GetNAddresses(uint32_t interface) const =0
virtual void Remove(Ptr< IpL4Protocol > protocol)=0
virtual uint16_t GetMtu(uint32_t interface) const =0
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 bool GetWeakEsModel() const =0
Get the Weak Es Model status.
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...
static TypeId GetTypeId()
Get the type ID.
Definition: ipv4.cc:35
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 void SetDown(uint32_t interface)=0
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() const =0
virtual Ptr< Socket > CreateRawSocket()=0
Creates a raw socket.
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
Implement the Ipv4 layer specifically for Click nodes to allow a clean integration of Click.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:332
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.