A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-end-point-demux.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef IPV4_END_POINT_DEMUX_H
10#define IPV4_END_POINT_DEMUX_H
11
12#include "ipv4-interface.h"
13
14#include "ns3/ipv4-address.h"
15
16#include <list>
17#include <stdint.h>
18
19namespace ns3
20{
21
22class Ipv4EndPoint;
23
24/**
25 * \ingroup ipv4
26 *
27 * \brief Demultiplexes packets to various transport layer endpoints
28 *
29 * This class serves as a lookup table to match partial or full information
30 * about a four-tuple to an ns3::Ipv4EndPoint. It internally contains a list
31 * of endpoints, and has APIs to add and find endpoints in this demux. This
32 * code is shared in common to TCP and UDP protocols in ns3. This demux
33 * sits between ns3's layer four and the socket layer
34 */
35
37{
38 public:
39 /**
40 * \brief Container of the IPv4 endpoints.
41 */
42 typedef std::list<Ipv4EndPoint*> EndPoints;
43
44 /**
45 * \brief Iterator to the container of the IPv4 endpoints.
46 */
47 typedef std::list<Ipv4EndPoint*>::iterator EndPointsI;
48
51
52 /**
53 * \brief Get the entire list of end points registered.
54 * \return list of Ipv4EndPoint
55 */
57
58 /**
59 * \brief Lookup for port local.
60 * \param port port to test
61 * \return true if a port local is in EndPoints, false otherwise
62 */
63 bool LookupPortLocal(uint16_t port);
64
65 /**
66 * \brief Lookup for address and port.
67 * \param boundNetDevice Bound NetDevice (if any)
68 * \param addr address to test
69 * \param port port to test
70 * \return true if there is a match in EndPoints, false otherwise
71 */
72 bool LookupLocal(Ptr<NetDevice> boundNetDevice, Ipv4Address addr, uint16_t port);
73
74 /**
75 * \brief lookup for a match with all the parameters.
76 *
77 * The function will return a list of most-matching EndPoints, in this order:
78 * -# Full match
79 * -# All but local address
80 * -# Only local port and local address match
81 * -# Only local port match
82 *
83 * EndPoint with disabled Rx are skipped.
84 *
85 * \param daddr destination address to test
86 * \param dport destination port to test
87 * \param saddr source address to test
88 * \param sport source port to test
89 * \param incomingInterface the incoming interface
90 * \return list of IPv4EndPoints (could be 0 element)
91 */
93 uint16_t dport,
94 Ipv4Address saddr,
95 uint16_t sport,
96 Ptr<Ipv4Interface> incomingInterface);
97
98 /**
99 * \brief simple lookup for a match with all the parameters.
100 * \param daddr destination address to test
101 * \param dport destination port to test
102 * \param saddr source address to test
103 * \param sport source port to test
104 * \return IPv4EndPoint (0 if not found)
105 */
107 uint16_t dport,
108 Ipv4Address saddr,
109 uint16_t sport);
110
111 /**
112 * \brief Allocate a Ipv4EndPoint.
113 * \return an empty Ipv4EndPoint instance
114 */
116
117 /**
118 * \brief Allocate a Ipv4EndPoint.
119 * \param address IPv4 address
120 * \return an Ipv4EndPoint instance
121 */
123
124 /**
125 * \brief Allocate a Ipv4EndPoint.
126 * \param boundNetDevice Bound NetDevice (if any)
127 * \param port local port
128 * \return an Ipv4EndPoint instance
129 */
130 Ipv4EndPoint* Allocate(Ptr<NetDevice> boundNetDevice, uint16_t port);
131
132 /**
133 * \brief Allocate a Ipv4EndPoint.
134 * \param boundNetDevice Bound NetDevice (if any)
135 * \param address local address
136 * \param port local port
137 * \return an Ipv4EndPoint instance
138 */
139 Ipv4EndPoint* Allocate(Ptr<NetDevice> boundNetDevice, Ipv4Address address, uint16_t port);
140
141 /**
142 * \brief Allocate a Ipv4EndPoint.
143 * \param boundNetDevice Bound NetDevice (if any)
144 * \param localAddress local address
145 * \param localPort local port
146 * \param peerAddress peer address
147 * \param peerPort peer port
148 * \return an Ipv4EndPoint instance
149 */
150 Ipv4EndPoint* Allocate(Ptr<NetDevice> boundNetDevice,
151 Ipv4Address localAddress,
152 uint16_t localPort,
153 Ipv4Address peerAddress,
154 uint16_t peerPort);
155
156 /**
157 * \brief Remove a end point.
158 * \param endPoint the end point to remove
159 */
160 void DeAllocate(Ipv4EndPoint* endPoint);
161
162 private:
163 /**
164 * \brief Allocate an ephemeral port.
165 * \returns the ephemeral port
166 */
167 uint16_t AllocateEphemeralPort();
168
169 /**
170 * \brief The ephemeral port.
171 */
172 uint16_t m_ephemeral;
173
174 /**
175 * \brief The last ephemeral port.
176 */
177 uint16_t m_portLast;
178
179 /**
180 * \brief The first ephemeral port.
181 */
182 uint16_t m_portFirst;
183
184 /**
185 * \brief A list of IPv4 end points.
186 */
188};
189
190} // namespace ns3
191
192#endif /* IPV4_END_POINTS_H */
Ipv4 addresses are stored in host order in this class.
Demultiplexes packets to various transport layer endpoints.
uint16_t m_portFirst
The first ephemeral port.
std::list< Ipv4EndPoint * >::iterator EndPointsI
Iterator to the container of the IPv4 endpoints.
uint16_t AllocateEphemeralPort()
Allocate an ephemeral port.
EndPoints m_endPoints
A list of IPv4 end points.
uint16_t m_portLast
The last ephemeral port.
Ipv4EndPoint * SimpleLookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport)
simple lookup for a match with all the parameters.
bool LookupLocal(Ptr< NetDevice > boundNetDevice, Ipv4Address addr, uint16_t port)
Lookup for address and port.
EndPoints GetAllEndPoints()
Get the entire list of end points registered.
uint16_t m_ephemeral
The ephemeral port.
EndPoints Lookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
lookup for a match with all the parameters.
bool LookupPortLocal(uint16_t port)
Lookup for port local.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove a end point.
Ipv4EndPoint * Allocate()
Allocate a Ipv4EndPoint.
std::list< Ipv4EndPoint * > EndPoints
Container of the IPv4 endpoints.
A representation of an internet endpoint/connection.
Smart pointer class similar to boost::intrusive_ptr.
uint16_t port
Definition dsdv-manet.cc:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.