A Discrete-Event Network Simulator
API
ip-l4-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 //
19 
20 // NS3 - Layer 4 Protocol base class
21 // George F. Riley, Georgia Tech, Spring 2007
22 
23 #ifndef IP_L4_PROTOCOL_H
24 #define IP_L4_PROTOCOL_H
25 
26 #include "ipv4-header.h"
27 #include "ipv6-header.h"
28 
29 #include "ns3/callback.h"
30 #include "ns3/object.h"
31 
32 namespace ns3
33 {
34 
35 class Packet;
36 class Ipv4Address;
37 class Ipv4Interface;
38 class Ipv6Address;
39 class Ipv6Interface;
40 class Ipv4Route;
41 class Ipv6Route;
42 
51 class IpL4Protocol : public Object
52 {
53  public:
57  enum RxStatus
58  {
63  };
64 
69  static TypeId GetTypeId();
70 
71  ~IpL4Protocol() override;
72 
77  virtual int GetProtocolNumber() const = 0;
78 
87  const Ipv4Header& header,
88  Ptr<Ipv4Interface> incomingInterface) = 0;
89 
98  const Ipv6Header& header,
99  Ptr<Ipv6Interface> incomingInterface) = 0;
100 
116  virtual void ReceiveIcmp(Ipv4Address icmpSource,
117  uint8_t icmpTtl,
118  uint8_t icmpType,
119  uint8_t icmpCode,
120  uint32_t icmpInfo,
121  Ipv4Address payloadSource,
122  Ipv4Address payloadDestination,
123  const uint8_t payload[8]);
124 
140  virtual void ReceiveIcmp(Ipv6Address icmpSource,
141  uint8_t icmpTtl,
142  uint8_t icmpType,
143  uint8_t icmpCode,
144  uint32_t icmpInfo,
145  Ipv6Address payloadSource,
146  Ipv6Address payloadDestination,
147  const uint8_t payload[8]);
148 
159 
166  virtual void SetDownTarget(DownTargetCallback cb) = 0;
167 
174  virtual void SetDownTarget6(DownTargetCallback6 cb) = 0;
175 
182  virtual DownTargetCallback GetDownTarget() const = 0;
183 
190  virtual DownTargetCallback6 GetDownTarget6() const = 0;
191 };
192 
193 } // Namespace ns3
194 
195 #endif
Callback template class.
Definition: callback.h:438
L4 Protocol abstract base class.
virtual void SetDownTarget6(DownTargetCallback6 cb)=0
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack.
virtual RxStatus Receive(Ptr< Packet > p, const Ipv4Header &header, Ptr< Ipv4Interface > incomingInterface)=0
Called from lower-level layers to send the packet up in the stack.
~IpL4Protocol() override
virtual int GetProtocolNumber() const =0
Returns the protocol number of this protocol.
virtual DownTargetCallback GetDownTarget() const =0
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
Callback< void, Ptr< Packet >, Ipv4Address, Ipv4Address, uint8_t, Ptr< Ipv4Route > > DownTargetCallback
callback to send packets over IPv4
Callback< void, Ptr< Packet >, Ipv6Address, Ipv6Address, uint8_t, Ptr< Ipv6Route > > DownTargetCallback6
callback to send packets over IPv6
virtual void SetDownTarget(DownTargetCallback cb)=0
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
virtual DownTargetCallback6 GetDownTarget6() const =0
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
virtual RxStatus Receive(Ptr< Packet > p, const Ipv6Header &header, Ptr< Ipv6Interface > incomingInterface)=0
Called from lower-level layers to send the packet up in the stack.
static TypeId GetTypeId()
Get the type ID.
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
Describes an IPv6 address.
Definition: ipv6-address.h:49
Packet header for IPv6.
Definition: ipv6-header.h:35
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.