|
841 |
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) |
841 |
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) |
842 |
{ |
842 |
{ |
843 |
NS_LOG_FUNCTION (this << maxSize << flags); |
843 |
NS_LOG_FUNCTION (this << maxSize << flags); |
844 |
if (m_deliveryQueue.empty () ) |
844 |
|
845 |
{ |
845 |
Address fromAddress; |
846 |
m_errno = ERROR_AGAIN; |
846 |
Ptr<Packet> packet = RecvFrom (maxSize, flags, fromAddress); |
847 |
return 0; |
847 |
return packet; |
848 |
} |
|
|
849 |
Ptr<Packet> p = m_deliveryQueue.front (); |
850 |
if (p->GetSize () <= maxSize) |
851 |
{ |
852 |
m_deliveryQueue.pop (); |
853 |
m_rxAvailable -= p->GetSize (); |
854 |
} |
855 |
else |
856 |
{ |
857 |
p = 0; |
858 |
} |
859 |
return p; |
860 |
} |
848 |
} |
861 |
|
849 |
|
862 |
Ptr<Packet> |
850 |
Ptr<Packet> |
|
864 |
Address &fromAddress) |
852 |
Address &fromAddress) |
865 |
{ |
853 |
{ |
866 |
NS_LOG_FUNCTION (this << maxSize << flags); |
854 |
NS_LOG_FUNCTION (this << maxSize << flags); |
867 |
Ptr<Packet> packet = Recv (maxSize, flags); |
855 |
|
868 |
if (packet != 0) |
856 |
if (m_deliveryQueue.empty () ) |
869 |
{ |
857 |
{ |
870 |
SocketAddressTag tag; |
858 |
m_errno = ERROR_AGAIN; |
871 |
bool found; |
859 |
return 0; |
872 |
found = packet->PeekPacketTag (tag); |
|
|
873 |
NS_ASSERT (found); |
874 |
fromAddress = tag.GetAddress (); |
875 |
} |
860 |
} |
876 |
return packet; |
861 |
Ptr<Packet> p = m_deliveryQueue.front ().first; |
|
|
862 |
fromAddress = m_deliveryQueue.front ().second; |
863 |
|
864 |
SocketAddressTag tag; |
865 |
tag.SetAddress (fromAddress); |
866 |
p->AddPacketTag (tag); |
867 |
|
868 |
if (p->GetSize () <= maxSize) |
869 |
{ |
870 |
m_deliveryQueue.pop (); |
871 |
m_rxAvailable -= p->GetSize (); |
872 |
} |
873 |
else |
874 |
{ |
875 |
p = 0; |
876 |
} |
877 |
return p; |
877 |
} |
878 |
} |
878 |
|
879 |
|
879 |
int |
880 |
int |
|
1034 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
1035 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
1035 |
{ |
1036 |
{ |
1036 |
Address address = InetSocketAddress (header.GetSource (), port); |
1037 |
Address address = InetSocketAddress (header.GetSource (), port); |
1037 |
SocketAddressTag tag; |
1038 |
m_deliveryQueue.push (std::make_pair (packet, address)); |
1038 |
tag.SetAddress (address); |
|
|
1039 |
packet->AddPacketTag (tag); |
1040 |
m_deliveryQueue.push (packet); |
1041 |
m_rxAvailable += packet->GetSize (); |
1039 |
m_rxAvailable += packet->GetSize (); |
1042 |
NotifyDataRecv (); |
1040 |
NotifyDataRecv (); |
1043 |
} |
1041 |
} |
|
1090 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
1088 |
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize) |
1091 |
{ |
1089 |
{ |
1092 |
Address address = Inet6SocketAddress (header.GetSourceAddress (), port); |
1090 |
Address address = Inet6SocketAddress (header.GetSourceAddress (), port); |
1093 |
SocketAddressTag tag; |
1091 |
m_deliveryQueue.push (std::make_pair (packet, address)); |
1094 |
tag.SetAddress (address); |
|
|
1095 |
packet->AddPacketTag (tag); |
1096 |
m_deliveryQueue.push (packet); |
1097 |
m_rxAvailable += packet->GetSize (); |
1092 |
m_rxAvailable += packet->GetSize (); |
1098 |
NotifyDataRecv (); |
1093 |
NotifyDataRecv (); |
1099 |
} |
1094 |
} |