32 : m_ephemeral (49152), m_portLast (65535), m_portFirst (49152)
54 if ((*i)->GetLocalPort () ==
port)
68 if ((*i)->GetLocalPort () == port &&
69 (*i)->GetLocalAddress () == addr)
136 NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
139 if ((*i)->GetLocalPort () == localPort &&
140 (*i)->GetLocalAddress () == localAddress &&
141 (*i)->GetPeerPort () == peerPort &&
142 (*i)->GetPeerAddress () == peerAddress)
144 NS_LOG_WARN (
"No way we can allocate this end-point.");
150 endPoint->
SetPeer (peerAddress, peerPort);
185 ret.push_back (endP);
201 NS_LOG_FUNCTION (
this << daddr << dport << saddr << sport << incomingInterface);
208 NS_LOG_DEBUG (
"Looking up endpoint for destination address " << daddr);
221 <<
" because endpoint can not receive packets");
228 <<
" because endpoint dport "
230 <<
" does not match packet dport " << dport);
238 <<
" because endpoint is bound to specific device and"
240 <<
" does not match packet device " << incomingInterface->
GetDevice ());
244 bool subnetDirected =
false;
246 for (uint32_t i = 0; i < incomingInterface->
GetNAddresses (); i++)
252 subnetDirected =
true;
253 incomingInterfaceAddr = addr.
GetLocal ();
256 bool isBroadcast = (daddr.
IsBroadcast () || subnetDirected ==
true);
257 NS_LOG_DEBUG (
"dest addr " << daddr <<
" broadcast? " << isBroadcast);
258 bool localAddressMatchesWildCard =
270 incomingInterfaceAddr);
273 if (!(localAddressMatchesExact || localAddressMatchesWildCard))
275 bool remotePeerMatchesExact = endP->
GetPeerPort () == sport;
276 bool remotePeerMatchesWildCard = endP->
GetPeerPort () == 0;
277 bool remoteAddressMatchesExact = endP->
GetPeerAddress () == saddr;
282 if (!(remotePeerMatchesExact || remotePeerMatchesWildCard))
284 if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
288 if (localAddressMatchesWildCard &&
289 remotePeerMatchesWildCard &&
290 remoteAddressMatchesWildCard)
292 retval1.push_back (endP);
294 if ((localAddressMatchesExact || (isBroadcast && localAddressMatchesWildCard))&&
295 remotePeerMatchesWildCard &&
296 remoteAddressMatchesWildCard)
298 retval2.push_back (endP);
300 if (localAddressMatchesWildCard &&
301 remotePeerMatchesExact &&
302 remoteAddressMatchesExact)
304 retval3.push_back (endP);
306 if (localAddressMatchesExact &&
307 remotePeerMatchesExact &&
308 remoteAddressMatchesExact)
310 retval4.push_back (endP);
315 if (!retval4.empty ())
return retval4;
316 if (!retval3.empty ())
return retval3;
317 if (!retval2.empty ())
return retval2;
331 uint32_t genericity = 3;
335 if ((*i)->GetLocalPort () != dport)
339 if ((*i)->GetLocalAddress () == daddr &&
340 (*i)->GetPeerPort () == sport &&
341 (*i)->GetPeerAddress () == saddr)
355 if (tmp < genericity)
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ipv4Mask GetMask(void) const
Get the network mask.
Ipv4Address GetLocal(void) const
Get the local address.
bool IsRxEnabled(void)
Checks if the endpoint can receive packets.
EndPoints GetAllEndPoints(void)
Get the entire list of end points registered.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint16_t m_ephemeral
The ephemeral port.
bool LookupPortLocal(uint16_t port)
Lookup for port local.
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
uint16_t m_portFirst
The first ephemeral port.
bool IsSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
Ipv4Address GetLocalAddress(void)
Get the local address.
bool IsBroadcast(void) const
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint16_t m_portLast
The last ephemeral port.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Ptr< NetDevice > GetBoundNetDevice(void)
Returns socket's bound netdevice, if any.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv4EndPoint * SimpleLookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport)
simple lookup for a match with all the parameters.
bool LookupLocal(Ipv4Address addr, uint16_t port)
Lookup for address and port.
void SetPeer(Ipv4Address address, uint16_t port)
Set the peer informations (address and port).
EndPoints Lookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
lookup for a match with all the parameters.
Ipv4 addresses are stored in host order in this class.
std::list< Ipv4EndPoint * > EndPoints
Container of the IPv4 endpoints.
a class to store IPv4 address information on an interface
uint16_t GetLocalPort(void)
Get the local port.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Ptr< NetDevice > GetDevice(void) const
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ipv4Address GetPeerAddress(void)
Get the peer address.
uint16_t GetPeerPort(void)
Get the peer port.
std::list< Ipv4EndPoint * >::iterator EndPointsI
Iterator to the container of the IPv4 endpoints.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove a end point.
EndPoints m_endPoints
A list of IPv4 end points.
uint32_t GetNAddresses(void) const
uint16_t AllocateEphemeralPort(void)
Allocate an ephemeral port.
A representation of an internet endpoint/connection.
Ipv4EndPoint * Allocate(void)
Allocate a Ipv4EndPoint.