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// SPDX-License-Identifier: GPL-2.0-only
5//
6// Author: George F. Riley<riley@ece.gatech.edu>
7//
8
9// NS3 - Layer 4 Protocol base class
10// George F. Riley, Georgia Tech, Spring 2007
11
12#ifndef IP_L4_PROTOCOL_H
13#define IP_L4_PROTOCOL_H
14
15#include "ipv4-header.h"
16#include "ipv6-header.h"
17
18#include "ns3/callback.h"
19#include "ns3/object.h"
20
21namespace ns3
22{
23
24class Packet;
25class Ipv4Address;
26class Ipv4Interface;
27class Ipv6Address;
28class Ipv6Interface;
29class Ipv4Route;
30class Ipv6Route;
31
32/**
33 * @ingroup internet
34 *
35 * @brief L4 Protocol abstract base class.
36 *
37 * This is an abstract base class for layer four protocols which use IP as
38 * the network layer.
39 */
40class IpL4Protocol : public Object
41{
42 public:
43 /**
44 * @brief Rx status codes.
45 */
53
54 /**
55 * @brief Get the type ID.
56 * @return the object TypeId
57 */
58 static TypeId GetTypeId();
59
60 ~IpL4Protocol() override;
61
62 /**
63 * @brief Returns the protocol number of this protocol.
64 * @returns the protocol number.
65 */
66 virtual int GetProtocolNumber() const = 0;
67
68 /**
69 * @brief Called from lower-level layers to send the packet up in the stack.
70 * @param p packet to forward up
71 * @param header IPv4 Header information
72 * @param incomingInterface the Ipv4Interface on which the packet arrived
73 * @returns Rx status code
74 */
76 const Ipv4Header& header,
77 Ptr<Ipv4Interface> incomingInterface) = 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 IPv6 Header information
83 * @param incomingInterface the Ipv6Interface on which the packet arrived
84 * @returns Rx status code
85 */
87 const Ipv6Header& header,
88 Ptr<Ipv6Interface> incomingInterface) = 0;
89
90 /**
91 * @brief Called from lower-level layers to send the ICMP packet up in the stack.
92 * @param icmpSource the source address of the icmp message
93 * @param icmpTtl the ttl of the icmp message
94 * @param icmpType the 'type' field of the icmp message
95 * @param icmpCode the 'code' field of the icmp message
96 * @param icmpInfo extra information dependent on the icmp message
97 * generated by Icmpv4L4Protocol
98 * @param payloadSource the source address of the packet which triggered
99 * the icmp message
100 * @param payloadDestination the destination address of the packet which
101 * triggered the icmp message.
102 * @param payload the first 8 bytes of the packet payload
103 * which triggered the icmp message.
104 */
105 virtual void ReceiveIcmp(Ipv4Address icmpSource,
106 uint8_t icmpTtl,
107 uint8_t icmpType,
108 uint8_t icmpCode,
109 uint32_t icmpInfo,
110 Ipv4Address payloadSource,
111 Ipv4Address payloadDestination,
112 const uint8_t payload[8]);
113
114 /**
115 * @brief Called from lower-level layers to send the ICMPv6 packet up in the stack.
116 * @param icmpSource the source address of the icmp message
117 * @param icmpTtl the ttl of the icmp message
118 * @param icmpType the 'type' field of the icmp message
119 * @param icmpCode the 'code' field of the icmp message
120 * @param icmpInfo extra information dependent on the icmp message
121 * generated by Icmpv6L4Protocol
122 * @param payloadSource the source address of the packet which triggered
123 * the icmp message
124 * @param payloadDestination the destination address of the packet which
125 * triggered the icmp message.
126 * @param payload the first 8 bytes of the packet payload
127 * which triggered the icmp message.
128 */
129 virtual void ReceiveIcmp(Ipv6Address icmpSource,
130 uint8_t icmpTtl,
131 uint8_t icmpType,
132 uint8_t icmpCode,
133 uint32_t icmpInfo,
134 Ipv6Address payloadSource,
135 Ipv6Address payloadDestination,
136 const uint8_t payload[8]);
137
138 /**
139 * @brief callback to send packets over IPv4
140 */
143 /**
144 * @brief callback to send packets over IPv6
145 */
148
149 /**
150 * This method allows a caller to set the current down target callback
151 * set for this L4 protocol (IPv4 case)
152 *
153 * @param cb current Callback for the L4 protocol
154 */
155 virtual void SetDownTarget(DownTargetCallback cb) = 0;
156
157 /**
158 * This method allows a caller to set the current down target callback
159 * set for this L4 protocol (IPv6 case)
160 *
161 * @param cb current Callback for the L4 protocol
162 */
164
165 /**
166 * This method allows a caller to get the current down target callback
167 * set for this L4 protocol (IPv4 case)
168 *
169 * @return current Callback for the L4 protocol
170 */
172
173 /**
174 * This method allows a caller to get the current down target callback
175 * set for this L4 protocol (IPv6 case)
176 *
177 * @return current Callback for the L4 protocol
178 */
180};
181
182} // Namespace ns3
183
184#endif
Callback template class.
Definition callback.h:422
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.
Packet header for IPv4.
Definition ipv4-header.h:23
Describes an IPv6 address.
Packet header for IPv6.
Definition ipv6-header.h:24
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.