57 if ((*i)->GetLocalPort() ==
port)
71 if ((*i)->GetLocalPort() ==
port && (*i)->GetLocalAddress() == addr &&
72 (*i)->GetBoundNetDevice() == boundNetDevice)
142 NS_LOG_FUNCTION(
this << localAddress << localPort << peerAddress << peerPort << boundNetDevice);
145 if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress &&
146 (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress &&
147 ((*i)->GetBoundNetDevice() == boundNetDevice || !(*i)->GetBoundNetDevice()))
153 auto endPoint =
new Ipv4EndPoint(localAddress, localPort);
154 endPoint->SetPeer(peerAddress, peerPort);
206 NS_LOG_FUNCTION(
this << daddr << dport << saddr << sport << incomingInterface);
213 NS_LOG_DEBUG(
"Looking up endpoint for destination address " << daddr <<
":" << dport);
225 <<
" because endpoint can not receive packets");
231 NS_LOG_LOGIC(
"Skipping endpoint " << &endP <<
" because endpoint dport "
233 <<
" does not match packet dport " << dport);
241 << &endP <<
" because endpoint is bound to specific device and"
248 bool localAddressMatchesExact =
false;
249 bool localAddressIsAny =
false;
250 bool localAddressIsSubnetAny =
false;
261 localAddressMatchesExact =
true;
266 localAddressIsAny =
true;
271 for (uint32_t i = 0; i < incomingInterface->
GetNAddresses(); i++)
283 if (addrNetpart == daddrNetPart)
285 localAddressIsSubnetAny =
true;
291 if (!localAddressIsSubnetAny)
297 bool remotePortMatchesExact = endP->
GetPeerPort() == sport;
298 bool remotePortMatchesWildCard = endP->
GetPeerPort() == 0;
304 if (!(remotePortMatchesExact || remotePortMatchesWildCard))
308 if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
313 bool localAddressMatchesWildCard = localAddressIsAny || localAddressIsSubnetAny;
315 if (localAddressMatchesExact && remoteAddressMatchesExact && remotePortMatchesExact)
319 retval4.push_back(endP);
321 if (localAddressMatchesWildCard && remoteAddressMatchesExact && remotePortMatchesExact)
325 retval3.push_back(endP);
327 if (localAddressMatchesExact && remoteAddressMatchesWildCard && remotePortMatchesWildCard)
331 retval2.push_back(endP);
333 if (localAddressMatchesWildCard && remoteAddressMatchesWildCard &&
334 remotePortMatchesWildCard)
338 retval1.push_back(endP);
344 if (!retval4.empty())
348 else if (!retval3.empty())
352 else if (!retval2.empty())
362 "Too many endpoints - perhaps you created too many sockets without binding "
363 "them to different NetDevices.");
377 uint32_t genericity = 3;
381 if ((*i)->GetLocalPort() != dport)
385 if ((*i)->GetLocalAddress() == daddr && (*i)->GetPeerPort() == sport &&
386 (*i)->GetPeerAddress() == saddr)
400 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.
uint32_t GetNAddresses() const
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Ptr< NetDevice > GetDevice() const
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.