A Discrete-Event Network Simulator
API
icmpv4-l4-protocol.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 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@cutebugs.net>
19  */
20 
21 #ifndef ICMPV4_L4_PROTOCOL_H
22 #define ICMPV4_L4_PROTOCOL_H
23 
24 #include "ip-l4-protocol.h"
25 #include "icmpv4.h"
26 #include "ns3/ipv4-address.h"
27 
28 namespace ns3 {
29 
30 class Node;
31 class Ipv4Interface;
32 class Ipv4Route;
33 
46 {
47 public:
52  static TypeId GetTypeId (void);
53  static const uint8_t PROT_NUMBER;
54 
56  virtual ~Icmpv4L4Protocol ();
57 
62  void SetNode (Ptr<Node> node);
63 
68  static uint16_t GetStaticProtocolNumber (void);
69 
74  virtual int GetProtocolNumber (void) const;
75 
84  Ipv4Header const &header,
85  Ptr<Ipv4Interface> incomingInterface);
86 
95  Ipv6Header const &header,
96  Ptr<Ipv6Interface> incomingInterface);
97 
104  void SendDestUnreachFragNeeded (Ipv4Header header, Ptr<const Packet> orgData, uint16_t nextHopMtu);
105 
111  void SendTimeExceededTtl (Ipv4Header header, Ptr<const Packet> orgData);
112 
118  void SendDestUnreachPort (Ipv4Header header, Ptr<const Packet> orgData);
119 
120  // From IpL4Protocol
123  // From IpL4Protocol
124  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
126 protected:
127  /*
128  * This function will notify other components connected to the node that a new stack member is now connected
129  * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
130  */
131  virtual void NotifyNewAggregate ();
132 private:
140  void HandleEcho (Ptr<Packet> p,
141  Icmpv4Header header,
142  Ipv4Address source,
143  Ipv4Address destination);
152  Icmpv4Header header,
153  Ipv4Address source,
154  Ipv4Address destination);
163  Icmpv4Header icmp,
164  Ipv4Address source,
165  Ipv4Address destination);
174  void SendDestUnreach (Ipv4Header header, Ptr<const Packet> orgData,
175  uint8_t code, uint16_t nextHopMtu);
184  void SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code);
195  void SendMessage (Ptr<Packet> packet, Ipv4Address source, Ipv4Address dest, uint8_t type, uint8_t code, Ptr<Ipv4Route> route);
205  void Forward (Ipv4Address source, Icmpv4Header icmp,
206  uint32_t info, Ipv4Header ipHeader,
207  const uint8_t payload[8]);
208 
209  virtual void DoDispose (void);
210 
213 };
214 
215 } // namespace ns3
216 
217 #endif /* ICMPV4_L4_PROTOCOL_H */
Packet header for IPv6.
Definition: ipv6-header.h:34
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
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
Base class for all the ICMP packet headers.
Definition: icmpv4.h:40
void SetNode(Ptr< Node > node)
Set the node the protocol is associated with.
RxStatus
Rx status codes.
void Forward(Ipv4Address source, Icmpv4Header icmp, uint32_t info, Ipv4Header ipHeader, const uint8_t payload[8])
Forward the message to an L4 protocol.
void SendDestUnreachFragNeeded(Ipv4Header header, Ptr< const Packet > orgData, uint16_t nextHopMtu)
Send a Destination Unreachable - Fragmentation needed ICMP error.
Packet header for IPv4.
Definition: ipv4-header.h:33
void SendTimeExceededTtl(Ipv4Header header, Ptr< const Packet > orgData)
Send a Time Exceeded ICMP error.
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual int GetProtocolNumber(void) const
Get the protocol number.
L4 Protocol abstract base class.
static TypeId GetTypeId(void)
Get the type ID.
void SendDestUnreachPort(Ipv4Header header, Ptr< const Packet > orgData)
Send a Time Exceeded ICMP error.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
IpL4Protocol::DownTargetCallback m_downTarget
callback to Ipv4::Send
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Receive method.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void DoDispose(void)
Destructor implementation.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
void SendDestUnreach(Ipv4Header header, Ptr< const Packet > orgData, uint8_t code, uint16_t nextHopMtu)
Send an ICMP Destination Unreachable packet.
This is the implementation of the ICMP protocol as described in RFC 792.
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
void HandleTimeExceeded(Ptr< Packet > p, Icmpv4Header icmp, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Time Exceeded packet.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
void SendMessage(Ptr< Packet > packet, Ipv4Address dest, uint8_t type, uint8_t code)
Send a generic ICMP packet.
void HandleEcho(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Echo packet.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
void HandleDestUnreach(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Destination Unreachable packet.