A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-end-point-demux.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18 */
19
20#ifndef IPV6_END_POINT_DEMUX_H
21#define IPV6_END_POINT_DEMUX_H
22
23#include "ipv6-interface.h"
24
25#include "ns3/ipv6-address.h"
26
27#include <list>
28#include <stdint.h>
29
30namespace ns3
31{
32
33class Ipv6EndPoint;
34
35/**
36 * \ingroup ipv6
37 *
38 * \brief Demultiplexer for end points.
39 */
41{
42 public:
43 /**
44 * \brief Container of the IPv6 endpoints.
45 */
46 typedef std::list<Ipv6EndPoint*> EndPoints;
47
48 /**
49 * \brief Iterator to the container of the IPv6 endpoints.
50 */
51 typedef std::list<Ipv6EndPoint*>::iterator EndPointsI;
52
55
56 /**
57 * \brief Lookup for port local.
58 * \param port port to test
59 * \return true if a port local is in EndPoints, false otherwise
60 */
61 bool LookupPortLocal(uint16_t port);
62
63 /**
64 * \brief Lookup for address and port.
65 * \param boundNetDevice Bound NetDevice (if any)
66 * \param addr address to test
67 * \param port port to test
68 * \return true if there is a match in EndPoints, false otherwise
69 */
70 bool LookupLocal(Ptr<NetDevice> boundNetDevice, Ipv6Address addr, uint16_t port);
71
72 /**
73 * \brief lookup for a match with all the parameters.
74 *
75 * The function will return a list of most-matching EndPoints, in this order:
76 * -# Full match
77 * -# All but local address
78 * -# Only local port and local address match
79 * -# Only local port match
80 *
81 * EndPoint with disabled Rx are skipped.
82 *
83 * \param dst destination address to test
84 * \param dport destination port to test
85 * \param src source address to test
86 * \param sport source port to test
87 * \param incomingInterface the incoming interface
88 * \return list of IPv6EndPoints (could be 0 element)
89 */
91 uint16_t dport,
92 Ipv6Address src,
93 uint16_t sport,
94 Ptr<Ipv6Interface> incomingInterface);
95
96 /**
97 * \brief Simple lookup for a four-tuple match.
98 * \param dst destination address to test
99 * \param dport destination port to test
100 * \param src source address to test
101 * \param sport source port to test
102 * \return match or 0 if not found
103 */
104 Ipv6EndPoint* SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport);
105
106 /**
107 * \brief Allocate a Ipv6EndPoint.
108 * \return an empty Ipv6EndPoint instance
109 */
111
112 /**
113 * \brief Allocate a Ipv6EndPoint.
114 * \param address IPv6 address
115 * \return an Ipv6EndPoint instance
116 */
118
119 /**
120 * \brief Allocate a Ipv6EndPoint.
121 * \param boundNetDevice Bound NetDevice (if any)
122 * \param port local port
123 * \return an Ipv6EndPoint instance
124 */
125 Ipv6EndPoint* Allocate(Ptr<NetDevice> boundNetDevice, uint16_t port);
126
127 /**
128 * \brief Allocate a Ipv6EndPoint.
129 * \param boundNetDevice Bound NetDevice (if any)
130 * \param address local address
131 * \param port local port
132 * \return an Ipv6EndPoint instance
133 */
134 Ipv6EndPoint* Allocate(Ptr<NetDevice> boundNetDevice, Ipv6Address address, uint16_t port);
135
136 /**
137 * \brief Allocate a Ipv6EndPoint.
138 * \param boundNetDevice Bound NetDevice (if any)
139 * \param localAddress local address
140 * \param localPort local port
141 * \param peerAddress peer address
142 * \param peerPort peer port
143 * \return an Ipv6EndPoint instance
144 */
145 Ipv6EndPoint* Allocate(Ptr<NetDevice> boundNetDevice,
146 Ipv6Address localAddress,
147 uint16_t localPort,
148 Ipv6Address peerAddress,
149 uint16_t peerPort);
150
151 /**
152 * \brief Remove a end point.
153 * \param endPoint the end point to remove
154 */
155 void DeAllocate(Ipv6EndPoint* endPoint);
156
157 /**
158 * \brief Get the entire list of end points registered.
159 * \return list of Ipv6EndPoint
160 */
161 EndPoints GetEndPoints() const;
162
163 private:
164 /**
165 * \brief Allocate a ephemeral port.
166 * \return a port
167 */
168 uint16_t AllocateEphemeralPort();
169
170 /**
171 * \brief The ephemeral port.
172 */
173 uint16_t m_ephemeral;
174
175 /**
176 * \brief The first ephemeral port.
177 */
178 uint16_t m_portFirst;
179
180 /**
181 * \brief The last ephemeral port.
182 */
183 uint16_t m_portLast;
184
185 /**
186 * \brief A list of IPv6 end points.
187 */
189};
190
191} /* namespace ns3 */
192
193#endif /* IPV6_END_POINT_DEMUX_H */
Describes an IPv6 address.
Definition: ipv6-address.h:49
Demultiplexer for end points.
EndPoints Lookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr< Ipv6Interface > incomingInterface)
lookup for a match with all the parameters.
Ipv6EndPoint * Allocate()
Allocate a Ipv6EndPoint.
bool LookupLocal(Ptr< NetDevice > boundNetDevice, Ipv6Address addr, uint16_t port)
Lookup for address and port.
EndPoints m_endPoints
A list of IPv6 end points.
uint16_t m_ephemeral
The ephemeral port.
std::list< Ipv6EndPoint * >::iterator EndPointsI
Iterator to the container of the IPv6 endpoints.
EndPoints GetEndPoints() const
Get the entire list of end points registered.
Ipv6EndPoint * SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport)
Simple lookup for a four-tuple match.
bool LookupPortLocal(uint16_t port)
Lookup for port local.
uint16_t AllocateEphemeralPort()
Allocate a ephemeral port.
uint16_t m_portFirst
The first ephemeral port.
uint16_t m_portLast
The last ephemeral port.
void DeAllocate(Ipv6EndPoint *endPoint)
Remove a end point.
std::list< Ipv6EndPoint * > EndPoints
Container of the IPv6 endpoints.
A representation of an IPv6 endpoint/connection.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
uint16_t port
Definition: dsdv-manet.cc:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.