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 
112  void SendTimeExceededTtl (Ipv4Header header, Ptr<const Packet> orgData, bool isFragment);
113 
119  void SendDestUnreachPort (Ipv4Header header, Ptr<const Packet> orgData);
120 
121  // From IpL4Protocol
124  // From IpL4Protocol
125  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
127 protected:
128  /*
129  * This function will notify other components connected to the node that a new stack member is now connected
130  * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
131  */
132  virtual void NotifyNewAggregate ();
133 private:
141  void HandleEcho (Ptr<Packet> p,
142  Icmpv4Header header,
143  Ipv4Address source,
144  Ipv4Address destination);
153  Icmpv4Header header,
154  Ipv4Address source,
155  Ipv4Address destination);
164  Icmpv4Header icmp,
165  Ipv4Address source,
166  Ipv4Address destination);
175  void SendDestUnreach (Ipv4Header header, Ptr<const Packet> orgData,
176  uint8_t code, uint16_t nextHopMtu);
185  void SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code);
196  void SendMessage (Ptr<Packet> packet, Ipv4Address source, Ipv4Address dest, uint8_t type, uint8_t code, Ptr<Ipv4Route> route);
206  void Forward (Ipv4Address source, Icmpv4Header icmp,
207  uint32_t info, Ipv4Header ipHeader,
208  const uint8_t payload[8]);
209 
210  virtual void DoDispose (void);
211 
214 };
215 
216 } // namespace ns3
217 
218 #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.
void Forward(Ipv4Address source, Icmpv4Header icmp, uint32_t info, Ipv4Header ipHeader, const uint8_t payload[8])
Forward the message to an L4 protocol.
virtual int GetProtocolNumber(void) const
Get the protocol number.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
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.
void SendTimeExceededTtl(Ipv4Header header, Ptr< const Packet > orgData, bool isFragment)
Send a Time Exceeded ICMP error.
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.
RxStatus
Rx status codes.
This is the implementation of the ICMP protocol as described in RFC 792.
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.
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...
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.