A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
32namespace ns3
33{
34
35class Packet;
36class Ipv4Address;
37class Ipv4Interface;
38class Ipv6Address;
39class Ipv6Interface;
40class Ipv4Route;
41class Ipv6Route;
42
43/**
44 * \ingroup internet
45 *
46 * \brief L4 Protocol abstract base class.
47 *
48 * This is an abstract base class for layer four protocols which use IP as
49 * the network layer.
50 */
51class IpL4Protocol : public Object
52{
53 public:
54 /**
55 * \brief Rx status codes.
56 */
58 {
63 };
64
65 /**
66 * \brief Get the type ID.
67 * \return the object TypeId
68 */
69 static TypeId GetTypeId();
70
71 ~IpL4Protocol() override;
72
73 /**
74 * \brief Returns the protocol number of this protocol.
75 * \returns the protocol number.
76 */
77 virtual int GetProtocolNumber() const = 0;
78
79 /**
80 * \brief Called from lower-level layers to send the packet up in the stack.
81 * \param p packet to forward up
82 * \param header IPv4 Header information
83 * \param incomingInterface the Ipv4Interface on which the packet arrived
84 * \returns Rx status code
85 */
87 const Ipv4Header& header,
88 Ptr<Ipv4Interface> incomingInterface) = 0;
89
90 /**
91 * \brief Called from lower-level layers to send the packet up in the stack.
92 * \param p packet to forward up
93 * \param header IPv6 Header information
94 * \param incomingInterface the Ipv6Interface on which the packet arrived
95 * \returns Rx status code
96 */
98 const Ipv6Header& header,
99 Ptr<Ipv6Interface> incomingInterface) = 0;
100
101 /**
102 * \brief Called from lower-level layers to send the ICMP packet up in the stack.
103 * \param icmpSource the source address of the icmp message
104 * \param icmpTtl the ttl of the icmp message
105 * \param icmpType the 'type' field of the icmp message
106 * \param icmpCode the 'code' field of the icmp message
107 * \param icmpInfo extra information dependent on the icmp message
108 * generated by Icmpv4L4Protocol
109 * \param payloadSource the source address of the packet which triggered
110 * the icmp message
111 * \param payloadDestination the destination address of the packet which
112 * triggered the icmp message.
113 * \param payload the first 8 bytes of the packet payload
114 * which triggered the icmp message.
115 */
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
125 /**
126 * \brief Called from lower-level layers to send the ICMPv6 packet up in the stack.
127 * \param icmpSource the source address of the icmp message
128 * \param icmpTtl the ttl of the icmp message
129 * \param icmpType the 'type' field of the icmp message
130 * \param icmpCode the 'code' field of the icmp message
131 * \param icmpInfo extra information dependent on the icmp message
132 * generated by Icmpv6L4Protocol
133 * \param payloadSource the source address of the packet which triggered
134 * the icmp message
135 * \param payloadDestination the destination address of the packet which
136 * triggered the icmp message.
137 * \param payload the first 8 bytes of the packet payload
138 * which triggered the icmp message.
139 */
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
149 /**
150 * \brief callback to send packets over IPv4
151 */
154 /**
155 * \brief callback to send packets over IPv6
156 */
159
160 /**
161 * This method allows a caller to set the current down target callback
162 * set for this L4 protocol (IPv4 case)
163 *
164 * \param cb current Callback for the L4 protocol
165 */
166 virtual void SetDownTarget(DownTargetCallback cb) = 0;
167
168 /**
169 * This method allows a caller to set the current down target callback
170 * set for this L4 protocol (IPv6 case)
171 *
172 * \param cb current Callback for the L4 protocol
173 */
175
176 /**
177 * This method allows a caller to get the current down target callback
178 * set for this L4 protocol (IPv4 case)
179 *
180 * \return current Callback for the L4 protocol
181 */
183
184 /**
185 * This method allows a caller to get the current down target callback
186 * set for this L4 protocol (IPv6 case)
187 *
188 * \return current Callback for the L4 protocol
189 */
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
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.