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