A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
icmpv4-l4-protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 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@cutebugs.net>
18 */
19
20#ifndef ICMPV4_L4_PROTOCOL_H
21#define ICMPV4_L4_PROTOCOL_H
22
23#include "icmpv4.h"
24#include "ip-l4-protocol.h"
25
26#include "ns3/ipv4-address.h"
27
28namespace ns3
29{
30
31class Node;
32class Ipv4Interface;
33class Ipv4Route;
34
47{
48 public:
53 static TypeId GetTypeId();
54 static const uint8_t PROT_NUMBER;
55
57 ~Icmpv4L4Protocol() override;
58
63 void SetNode(Ptr<Node> node);
64
69 static uint16_t GetStaticProtocolNumber();
70
75 int GetProtocolNumber() const override;
76
85 const Ipv4Header& header,
86 Ptr<Ipv4Interface> incomingInterface) override;
87
96 const Ipv6Header& header,
97 Ptr<Ipv6Interface> incomingInterface) override;
98
106 Ptr<const Packet> orgData,
107 uint16_t nextHopMtu);
108
115 void SendTimeExceededTtl(Ipv4Header header, Ptr<const Packet> orgData, bool isFragment);
116
123
124 // From IpL4Protocol
127 // From IpL4Protocol
130
131 protected:
132 /*
133 * This function will notify other components connected to the node that a new stack member is
134 * now connected This will be used to notify Layer 3 protocol of layer 4 protocol stack to
135 * connect them together.
136 */
137 void NotifyNewAggregate() override;
138
139 private:
148 void HandleEcho(Ptr<Packet> p,
149 Icmpv4Header header,
150 Ipv4Address source,
151 Ipv4Address destination,
152 uint8_t tos);
161 Icmpv4Header header,
162 Ipv4Address source,
163 Ipv4Address destination);
172 Icmpv4Header icmp,
173 Ipv4Address source,
174 Ipv4Address destination);
183 void SendDestUnreach(Ipv4Header header,
184 Ptr<const Packet> orgData,
185 uint8_t code,
186 uint16_t nextHopMtu);
195 void SendMessage(Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code);
206 void SendMessage(Ptr<Packet> packet,
207 Ipv4Address source,
208 Ipv4Address dest,
209 uint8_t type,
210 uint8_t code,
211 Ptr<Ipv4Route> route);
221 void Forward(Ipv4Address source,
222 Icmpv4Header icmp,
223 uint32_t info,
224 Ipv4Header ipHeader,
225 const uint8_t payload[8]);
226
227 void DoDispose() override;
228
231};
232
233} // namespace ns3
234
235#endif /* ICMPV4_L4_PROTOCOL_H */
Base class for all the ICMP packet headers.
Definition: icmpv4.h:43
This is the implementation of the ICMP protocol as described in RFC 792.
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb) override
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
Ptr< Node > m_node
the node this protocol is associated with
void SendTimeExceededTtl(Ipv4Header header, Ptr< const Packet > orgData, bool isFragment)
Send a Time Exceeded ICMP error.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
void SetDownTarget(IpL4Protocol::DownTargetCallback cb) override
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
void HandleEcho(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination, uint8_t tos)
Handles an incoming ICMP Echo packet.
void SendDestUnreach(Ipv4Header header, Ptr< const Packet > orgData, uint8_t code, uint16_t nextHopMtu)
Send an ICMP Destination Unreachable packet.
void DoDispose() override
Destructor implementation.
IpL4Protocol::DownTargetCallback6 GetDownTarget6() const override
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
static TypeId GetTypeId()
Get the type ID.
void SetNode(Ptr< Node > node)
Set the node the protocol is associated with.
void SendDestUnreachPort(Ipv4Header header, Ptr< const Packet > orgData)
Send a Time Exceeded ICMP error.
static uint16_t GetStaticProtocolNumber()
Get the protocol number.
IpL4Protocol::RxStatus Receive(Ptr< Packet > p, const Ipv4Header &header, Ptr< Ipv4Interface > incomingInterface) override
Receive method.
IpL4Protocol::DownTargetCallback GetDownTarget() const override
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
void NotifyNewAggregate() override
Notify all Objects aggregated to this one of a new Object being aggregated.
void HandleTimeExceeded(Ptr< Packet > p, Icmpv4Header icmp, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Time Exceeded packet.
IpL4Protocol::DownTargetCallback m_downTarget
callback to Ipv4::Send
void SendDestUnreachFragNeeded(Ipv4Header header, Ptr< const Packet > orgData, uint16_t nextHopMtu)
Send a Destination Unreachable - Fragmentation needed ICMP error.
void SendMessage(Ptr< Packet > packet, Ipv4Address dest, uint8_t type, uint8_t code)
Send a generic ICMP packet.
void HandleDestUnreach(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Destination Unreachable packet.
int GetProtocolNumber() const override
Get the protocol number.
void Forward(Ipv4Address source, Icmpv4Header icmp, uint32_t info, Ipv4Header ipHeader, const uint8_t payload[8])
Forward the message to an L4 protocol.
L4 Protocol abstract base class.
RxStatus
Rx status codes.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Packet header for IPv6.
Definition: ipv6-header.h:35
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.