46 if ((*i)->GetLocalPort() ==
port)
60 if ((*i)->GetLocalPort() ==
port && (*i)->GetLocalAddress() == addr &&
61 (*i)->GetBoundNetDevice() == boundNetDevice)
131 NS_LOG_FUNCTION(
this << localAddress << localPort << peerAddress << peerPort << boundNetDevice);
134 if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress &&
135 (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress &&
136 ((*i)->GetBoundNetDevice() == boundNetDevice || !(*i)->GetBoundNetDevice()))
142 auto endPoint =
new Ipv4EndPoint(localAddress, localPort);
143 endPoint->SetPeer(peerAddress, peerPort);
195 NS_LOG_FUNCTION(
this << daddr << dport << saddr << sport << incomingInterface);
202 NS_LOG_DEBUG(
"Looking up endpoint for destination address " << daddr <<
":" << dport);
214 <<
" because endpoint can not receive packets");
220 NS_LOG_LOGIC(
"Skipping endpoint " << &endP <<
" because endpoint dport "
222 <<
" does not match packet dport " << dport);
230 << &endP <<
" because endpoint is bound to specific device and"
232 << incomingInterface->GetDevice());
237 bool localAddressMatchesExact =
false;
238 bool localAddressIsAny =
false;
239 bool localAddressIsSubnetAny =
false;
250 localAddressMatchesExact =
true;
255 localAddressIsAny =
true;
260 for (
uint32_t i = 0; i < incomingInterface->GetNAddresses(); i++)
272 if (addrNetpart == daddrNetPart)
274 localAddressIsSubnetAny =
true;
280 if (!localAddressIsSubnetAny)
286 bool remotePortMatchesExact = endP->
GetPeerPort() == sport;
287 bool remotePortMatchesWildCard = endP->
GetPeerPort() == 0;
293 if (!(remotePortMatchesExact || remotePortMatchesWildCard))
297 if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
302 bool localAddressMatchesWildCard = localAddressIsAny || localAddressIsSubnetAny;
304 if (localAddressMatchesExact && remoteAddressMatchesExact && remotePortMatchesExact)
308 retval4.push_back(endP);
310 if (localAddressMatchesWildCard && remoteAddressMatchesExact && remotePortMatchesExact)
314 retval3.push_back(endP);
316 if (localAddressMatchesExact && remoteAddressMatchesWildCard && remotePortMatchesWildCard)
320 retval2.push_back(endP);
322 if (localAddressMatchesWildCard && remoteAddressMatchesWildCard &&
323 remotePortMatchesWildCard)
327 retval1.push_back(endP);
333 if (!retval4.empty())
337 else if (!retval3.empty())
341 else if (!retval2.empty())
351 "Too many endpoints - perhaps you created too many sockets without binding "
352 "them to different NetDevices.");
370 if ((*i)->GetLocalPort() != dport)
374 if ((*i)->GetLocalAddress() == daddr && (*i)->GetPeerPort() == sport &&
375 (*i)->GetPeerAddress() == saddr)
389 if (tmp < genericity)
Ipv4 addresses are stored in host order in this class.
Ipv4Address CombineMask(const Ipv4Mask &mask) const
Combine this address with a network mask.
static Ipv4Address GetAny()
uint16_t m_portFirst
The first ephemeral port.
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.
Ipv4Address GetLocalAddress() const
Get the local address.
uint16_t GetPeerPort() const
Get the peer port.
Ptr< NetDevice > GetBoundNetDevice() const
Returns socket's bound netdevice, if any.
uint16_t GetLocalPort() const
Get the local port.
bool IsRxEnabled() const
Checks if the endpoint can receive packets.
Ipv4Address GetPeerAddress() const
Get the peer address.
a class to store IPv4 address information on an interface
Ipv4Mask GetMask() const
Get the network mask.
Ipv4Address GetLocal() const
Get the local address.
uint16_t GetPrefixLength() const
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Every class exported by the ns3 library is enclosed in the ns3 namespace.