Liu's GetSockName patch
This commit is contained in:
@@ -57,6 +57,8 @@ PacketSocket::PacketSocket () : m_rxAvailable (0)
|
||||
m_shutdownSend = false;
|
||||
m_shutdownRecv = false;
|
||||
m_errno = ERROR_NOTERROR;
|
||||
m_isSingleDevice = false;
|
||||
m_device = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -429,4 +431,27 @@ PacketSocket::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
|
||||
return packet;
|
||||
}
|
||||
|
||||
int
|
||||
PacketSocket::GetSockName (Address &address) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
PacketSocketAddress ad = PacketSocketAddress::ConvertFrom(address);
|
||||
|
||||
ad.SetProtocol (m_protocol);
|
||||
if (m_isSingleDevice)
|
||||
{
|
||||
Ptr<NetDevice> device = m_node->GetDevice (ad.GetSingleDevice ());
|
||||
ad.SetPhysicalAddress(device->GetAddress());
|
||||
ad.SetSingleDevice (m_device);
|
||||
}
|
||||
else
|
||||
{
|
||||
ad.SetPhysicalAddress(Address());
|
||||
ad.SetAllDevices ();
|
||||
}
|
||||
address = ad;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
|
||||
Address &fromAddress);
|
||||
virtual int GetSockName (Address &address) const;
|
||||
|
||||
private:
|
||||
void ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet,
|
||||
|
||||
@@ -487,6 +487,10 @@ public:
|
||||
*/
|
||||
int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
|
||||
Address &fromAddress);
|
||||
/**
|
||||
* \returns the address name this socket is associated with.
|
||||
*/
|
||||
virtual int GetSockName (Address &address) const = 0;
|
||||
|
||||
protected:
|
||||
void NotifyConnectionSucceeded (void);
|
||||
|
||||
Reference in New Issue
Block a user