32 : m_ephemeral (49152), m_portLast (65535), m_portFirst (49152)
54 if ((*i)->GetLocalPort () ==
port)
68 if ((*i)->GetLocalPort () ==
port &&
69 (*i)->GetLocalAddress () == addr &&
70 (*i)->GetBoundNetDevice () == boundNetDevice)
138 NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort << boundNetDevice);
141 if ((*i)->GetLocalPort () == localPort &&
142 (*i)->GetLocalAddress () == localAddress &&
143 (*i)->GetPeerPort () == peerPort &&
144 (*i)->GetPeerAddress () == peerAddress &&
145 ((*i)->GetBoundNetDevice () == boundNetDevice || (*i)->GetBoundNetDevice () == 0))
152 endPoint->
SetPeer (peerAddress, peerPort);
187 ret.push_back (endP);
203 NS_LOG_FUNCTION (
this << daddr << dport << saddr << sport << incomingInterface);
210 NS_LOG_DEBUG (
"Looking up endpoint for destination address " << daddr <<
":" << dport);
223 <<
" because endpoint can not receive packets");
230 <<
" because endpoint dport "
232 <<
" does not match packet dport " << dport);
240 <<
" because endpoint is bound to specific device and"
242 <<
" does not match packet device " << incomingInterface->
GetDevice ());
247 bool localAddressMatchesExact =
false;
248 bool localAddressIsAny =
false;
249 bool localAddressIsSubnetAny =
false;
259 localAddressMatchesExact =
true;
264 localAddressIsAny =
true;
269 for (uint32_t i = 0; i < incomingInterface->
GetNAddresses (); i++)
279 if (addrNetpart == daddrNetPart)
281 localAddressIsSubnetAny =
true;
287 if (!localAddressIsSubnetAny)
291 bool remotePortMatchesExact = endP->
GetPeerPort () == sport;
292 bool remotePortMatchesWildCard = endP->
GetPeerPort () == 0;
293 bool remoteAddressMatchesExact = endP->
GetPeerAddress () == saddr;
298 if (!(remotePortMatchesExact || remotePortMatchesWildCard))
300 if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
303 bool localAddressMatchesWildCard = localAddressIsAny || localAddressIsSubnetAny;
305 if (localAddressMatchesExact && remoteAddressMatchesExact && remotePortMatchesExact)
308 retval4.push_back (endP);
310 if (localAddressMatchesWildCard && remoteAddressMatchesExact && remotePortMatchesExact)
313 retval3.push_back (endP);
315 if (localAddressMatchesExact && remoteAddressMatchesWildCard && remotePortMatchesWildCard)
318 retval2.push_back (endP);
320 if (localAddressMatchesWildCard && remoteAddressMatchesWildCard && remotePortMatchesWildCard)
323 retval1.push_back (endP);
329 if (!retval4.empty ()) retval = retval4;
330 else if (!retval3.empty ()) retval = retval3;
331 else if (!retval2.empty ()) retval = retval2;
332 else retval = retval1;
334 NS_ABORT_MSG_IF (retval.size () > 1,
"Too many endpoints - perhaps you created too many sockets without binding them to different NetDevices.");
348 uint32_t genericity = 3;
352 if ((*i)->GetLocalPort () != dport)
356 if ((*i)->GetLocalAddress () == daddr &&
357 (*i)->GetPeerPort () == sport &&
358 (*i)->GetPeerAddress () == saddr)
372 if (tmp < genericity)
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny(void)
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
uint16_t m_portFirst
The first ephemeral port.
EndPoints m_endPoints
A list of IPv4 end points.
uint16_t m_portLast
The last ephemeral port.
EndPoints GetAllEndPoints(void)
Get the entire list of end points registered.
std::list< Ipv4EndPoint * > EndPoints
Container of the IPv4 endpoints.
Ipv4EndPoint * SimpleLookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport)
simple lookup for a match with all the parameters.
uint16_t AllocateEphemeralPort(void)
Allocate an ephemeral port.
bool LookupLocal(Ptr< NetDevice > boundNetDevice, Ipv4Address addr, uint16_t port)
Lookup for address and port.
Ipv4EndPoint * Allocate(void)
Allocate a Ipv4EndPoint.
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.
std::list< Ipv4EndPoint * >::iterator EndPointsI
Iterator to the container of the IPv4 endpoints.
bool LookupPortLocal(uint16_t port)
Lookup for port local.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove a end point.
A representation of an internet endpoint/connection.
uint16_t GetPeerPort(void)
Get the peer port.
Ipv4Address GetPeerAddress(void)
Get the peer address.
Ptr< NetDevice > GetBoundNetDevice(void)
Returns socket's bound netdevice, if any.
void SetPeer(Ipv4Address address, uint16_t port)
Set the peer information (address and port).
uint16_t GetLocalPort(void)
Get the local port.
bool IsRxEnabled(void)
Checks if the endpoint can receive packets.
Ipv4Address GetLocalAddress(void)
Get the local address.
a class to store IPv4 address information on an interface
Ipv4Mask GetMask(void) const
Get the network mask.
Ipv4Address GetLocal(void) const
Get the local address.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
uint32_t GetNAddresses(void) const
Ptr< NetDevice > GetDevice(void) const
uint16_t GetPrefixLength(void) const
#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.