View | Details | Raw Unified | Return to bug 231
Collapse All | Expand All

(-)a/src/internet/model/udp-socket-impl.cc (-17 / +26 lines)
 Lines 737-743    Link Here 
737
      m_errno = ERROR_AGAIN;
737
      m_errno = ERROR_AGAIN;
738
      return 0;
738
      return 0;
739
    }
739
    }
740
  Ptr<Packet> p = m_deliveryQueue.front ();
740
  DeliveryQueueElement e = m_deliveryQueue.front ();
741
  Ptr<Packet> p = e.packet;
741
  if (p->GetSize () <= maxSize) 
742
  if (p->GetSize () <= maxSize) 
742
    {
743
    {
743
      m_deliveryQueue.pop ();
744
      m_deliveryQueue.pop ();
 Lines 755-770    Link Here 
755
                         Address &fromAddress)
756
                         Address &fromAddress)
756
{
757
{
757
  NS_LOG_FUNCTION (this << maxSize << flags);
758
  NS_LOG_FUNCTION (this << maxSize << flags);
758
  Ptr<Packet> packet = Recv (maxSize, flags);
759
  if (m_deliveryQueue.empty ())
759
  if (packet != 0)
760
    {
760
    {
761
      SocketAddressTag tag;
761
      m_errno = ERROR_AGAIN;
762
      bool found;
762
      return 0;
763
      found = packet->PeekPacketTag (tag);
764
      NS_ASSERT (found);
765
      fromAddress = tag.GetAddress ();
766
    }
763
    }
767
  return packet;
764
  DeliveryQueueElement e = m_deliveryQueue.front ();
765
  Ptr<Packet> p = e.packet;
766
  if (p->GetSize () <= maxSize) 
767
    {
768
      m_deliveryQueue.pop ();
769
      m_rxAvailable -= p->GetSize ();
770
      fromAddress = e.socketAddress;
771
    }
772
  else
773
    {
774
      p = 0; 
775
    }
776
  return p;
768
}
777
}
769
778
770
int
779
int
 Lines 853-862    Link Here 
853
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
862
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
854
    {
863
    {
855
      Address address = InetSocketAddress (header.GetSource (), port);
864
      Address address = InetSocketAddress (header.GetSource (), port);
856
      SocketAddressTag tag;
865
      DeliveryQueueElement e;
857
      tag.SetAddress (address);
866
      e.packet = packet;
858
      packet->AddPacketTag (tag);
867
      e.socketAddress = address;
859
      m_deliveryQueue.push (packet);
868
      m_deliveryQueue.push (e);
860
      m_rxAvailable += packet->GetSize ();
869
      m_rxAvailable += packet->GetSize ();
861
      NotifyDataRecv ();
870
      NotifyDataRecv ();
862
    }
871
    }
 Lines 885-894    Link Here 
885
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
894
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
886
    {
895
    {
887
      Address address = Inet6SocketAddress (saddr, port);
896
      Address address = Inet6SocketAddress (saddr, port);
888
      SocketAddressTag tag;
897
      DeliveryQueueElement e;
889
      tag.SetAddress (address);
898
      e.packet = packet;
890
      packet->AddPacketTag (tag);
899
      e.socketAddress = address;      
891
      m_deliveryQueue.push (packet);
900
      m_deliveryQueue.push (e);
892
      m_rxAvailable += packet->GetSize ();
901
      m_rxAvailable += packet->GetSize ();
893
      NotifyDataRecv ();
902
      NotifyDataRecv ();
894
    }
903
    }
(-)a/src/internet/model/udp-socket-impl.h (-1 / +7 lines)
 Lines 133-139    Link Here 
133
  bool m_connected;
133
  bool m_connected;
134
  bool m_allowBroadcast;
134
  bool m_allowBroadcast;
135
135
136
  std::queue<Ptr<Packet> > m_deliveryQueue;
136
  struct DeliveryQueueElement
137
  {
138
    Ptr<Packet> packet;
139
    Address socketAddress;
140
  };
141
  
142
  std::queue<DeliveryQueueElement> m_deliveryQueue;
137
  uint32_t m_rxAvailable;
143
  uint32_t m_rxAvailable;
138
144
139
  // Socket attributes
145
  // Socket attributes

Return to bug 231