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

(-)ns-3-dev/examples/tcp-large-transfer.cc (-1 / +1 lines)
 Lines 204-210    Link Here 
204
      char m = toascii (97 + i % 26);
204
      char m = toascii (97 + i % 26);
205
      data[i] = m;
205
      data[i] = m;
206
    }
206
    }
207
    uint32_t amountSent = localSocket->Send (data, curSize);
207
    uint32_t amountSent = localSocket->Send (data, curSize, 0);
208
    if(amountSent < curSize)
208
    if(amountSent < curSize)
209
      {
209
      {
210
        std::cout << "Socket blocking, returning" << std::endl;
210
        std::cout << "Socket blocking, returning" << std::endl;
(-)ns-3-dev/src/applications/packet-sink/packet-sink.cc (-1 / +1 lines)
 Lines 105-111    Link Here 
105
  Ptr<Packet> packet;
105
  Ptr<Packet> packet;
106
  while (packet = socket->Recv ())
106
  while (packet = socket->Recv ())
107
    {
107
    {
108
      SocketRxAddressTag tag;
108
      SocketAddressTag tag;
109
      bool found;
109
      bool found;
110
      found = packet->FindFirstMatchingTag (tag);
110
      found = packet->FindFirstMatchingTag (tag);
111
      NS_ASSERT (found);
111
      NS_ASSERT (found);
(-)ns-3-dev/src/applications/udp-echo/udp-echo-client.cc (-1 / +1 lines)
 Lines 156-162    Link Here 
156
  Ptr<Packet> packet;
156
  Ptr<Packet> packet;
157
  while (packet = socket->Recv ())
157
  while (packet = socket->Recv ())
158
    {
158
    {
159
      SocketRxAddressTag tag;
159
      SocketAddressTag tag;
160
      bool found;
160
      bool found;
161
      found  = packet->FindFirstMatchingTag (tag);
161
      found  = packet->FindFirstMatchingTag (tag);
162
      NS_ASSERT (found);
162
      NS_ASSERT (found);
(-)ns-3-dev/src/applications/udp-echo/udp-echo-server.cc (-2 / +2 lines)
 Lines 97-103    Link Here 
97
  Ptr<Packet> packet;
97
  Ptr<Packet> packet;
98
  while (packet = socket->Recv ())
98
  while (packet = socket->Recv ())
99
    {
99
    {
100
      SocketRxAddressTag tag;
100
      SocketAddressTag tag;
101
      bool found;
101
      bool found;
102
      found = packet->FindFirstMatchingTag (tag); 
102
      found = packet->FindFirstMatchingTag (tag); 
103
      NS_ASSERT (found);
103
      NS_ASSERT (found);
 Lines 110-116    Link Here 
110
            address.GetIpv4());
110
            address.GetIpv4());
111
111
112
          NS_LOG_LOGIC ("Echoing packet");
112
          NS_LOG_LOGIC ("Echoing packet");
113
          socket->SendTo (packet, from);
113
          socket->SendTo (packet, 0, from);
114
        }
114
        }
115
    }
115
    }
116
}
116
}
(-)ns-3-dev/src/internet-node/tcp-socket-impl.cc (-10 / +24 lines)
 Lines 346-353    Link Here 
346
    }
346
    }
347
  return -1;
347
  return -1;
348
}
348
}
349
350
//p here is just data, no headers
349
int 
351
int 
350
TcpSocketImpl::Send (const Ptr<Packet> p) //p here is just data, no headers
352
TcpSocketImpl::Send (Ptr<Packet> p, uint32_t flags) 
351
{
353
{
352
  NS_LOG_FUNCTION (this << p);
354
  NS_LOG_FUNCTION (this << p);
353
  if (m_state == ESTABLISHED || m_state == SYN_SENT || m_state == CLOSE_WAIT)
355
  if (m_state == ESTABLISHED || m_state == SYN_SENT || m_state == CLOSE_WAIT)
 Lines 382-392    Link Here 
382
  }
384
  }
383
}
385
}
384
386
385
int TcpSocketImpl::Send (const uint8_t* buf, uint32_t size)
386
{
387
  return Send (Create<Packet> (buf, size));
388
}
389
390
int TcpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
387
int TcpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
391
{
388
{
392
  NS_LOG_FUNCTION (this << p << address);
389
  NS_LOG_FUNCTION (this << p << address);
 Lines 420-426    Link Here 
420
}
417
}
421
418
422
int 
419
int 
423
TcpSocketImpl::SendTo (Ptr<Packet> p, const Address &address)
420
TcpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
424
{
421
{
425
  NS_LOG_FUNCTION (this << address << p);
422
  NS_LOG_FUNCTION (this << address << p);
426
  if (!m_connected)
423
  if (!m_connected)
 Lines 430-436    Link Here 
430
    }
427
    }
431
  else
428
  else
432
    {
429
    {
433
      return Send (p); //drop the address according to BSD manpages
430
      return Send (p, flags); //drop the address according to BSD manpages
434
    }
431
    }
435
}
432
}
436
433
 Lines 532-537    Link Here 
532
  return m_rxAvailable;
529
  return m_rxAvailable;
533
}
530
}
534
531
532
Ptr<Packet>
533
TcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
534
  Address &fromAddress)
535
{
536
  NS_LOG_FUNCTION (this << maxSize << flags);
537
  Ptr<Packet> packet = Recv (maxSize, flags);
538
  if (packet != 0)
539
    {
540
      SocketAddressTag tag;
541
      bool found;
542
      found = packet->FindFirstMatchingTag (tag);
543
      NS_ASSERT (found);
544
      fromAddress = tag.GetAddress ();
545
    }
546
  return packet;
547
}
548
535
void
549
void
536
TcpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port)
550
TcpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port)
537
{
551
{
 Lines 1048-1054    Link Here 
1048
      m_nextRxSequence += s;           // Advance next expected sequence
1062
      m_nextRxSequence += s;           // Advance next expected sequence
1049
      //bytesReceived += s;       // Statistics
1063
      //bytesReceived += s;       // Statistics
1050
      NS_LOG_LOGIC("Case 1, advanced nrxs to " << m_nextRxSequence );
1064
      NS_LOG_LOGIC("Case 1, advanced nrxs to " << m_nextRxSequence );
1051
      SocketRxAddressTag tag;
1065
      SocketAddressTag tag;
1052
      tag.SetAddress (fromAddress);
1066
      tag.SetAddress (fromAddress);
1053
      p->AddTag (tag);
1067
      p->AddTag (tag);
1054
      //buffer this, it'll be read by call to Recv
1068
      //buffer this, it'll be read by call to Recv
 Lines 1106-1112    Link Here 
1106
          i->second = 0; // relase reference to already buffered
1120
          i->second = 0; // relase reference to already buffered
1107
        }
1121
        }
1108
      // Save for later delivery
1122
      // Save for later delivery
1109
      SocketRxAddressTag tag;
1123
      SocketAddressTag tag;
1110
      tag.SetAddress (fromAddress);
1124
      tag.SetAddress (fromAddress);
1111
      p->AddTag (tag);
1125
      p->AddTag (tag);
1112
      m_bufferedData[tcpHeader.GetSequenceNumber () ] = p;  
1126
      m_bufferedData[tcpHeader.GetSequenceNumber () ] = p;  
(-)ns-3-dev/src/internet-node/tcp-socket-impl.h (-6 / +6 lines)
 Lines 65-78    Link Here 
65
  virtual int ShutdownSend (void);
65
  virtual int ShutdownSend (void);
66
  virtual int ShutdownRecv (void);
66
  virtual int ShutdownRecv (void);
67
  virtual int Connect(const Address &address);
67
  virtual int Connect(const Address &address);
68
  virtual int Send (Ptr<Packet> p);
69
  virtual int Send (const uint8_t* buf, uint32_t size);
70
  virtual int SendTo(Ptr<Packet> p, const Address &address);
71
  virtual uint32_t GetTxAvailable (void) const;
72
  virtual int Listen(uint32_t queueLimit);
68
  virtual int Listen(uint32_t queueLimit);
73
69
  virtual uint32_t GetTxAvailable (void) const;
74
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
70
  virtual int Send (Ptr<Packet> p, uint32_t flags);
71
  virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address &toAddress);
75
  virtual uint32_t GetRxAvailable (void) const;
72
  virtual uint32_t GetRxAvailable (void) const;
73
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
74
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
75
    Address &fromAddress);
76
76
77
private:
77
private:
78
  friend class Tcp;
78
  friend class Tcp;
(-)ns-3-dev/src/internet-node/udp-socket-impl.cc (-16 / +33 lines)
 Lines 224-232    Link Here 
224
}
224
}
225
225
226
int 
226
int 
227
UdpSocketImpl::Send (Ptr<Packet> p)
227
UdpSocketImpl::Send (Ptr<Packet> p, uint32_t flags)
228
{
228
{
229
  NS_LOG_FUNCTION (this << p);
229
  NS_LOG_FUNCTION (this << p << flags);
230
230
231
  if (!m_connected)
231
  if (!m_connected)
232
    {
232
    {
 Lines 239-245    Link Here 
239
int 
239
int 
240
UdpSocketImpl::DoSend (Ptr<Packet> p)
240
UdpSocketImpl::DoSend (Ptr<Packet> p)
241
{
241
{
242
  NS_LOG_FUNCTION_NOARGS ();
242
  NS_LOG_FUNCTION (this << p);
243
  if (m_endPoint == 0)
243
  if (m_endPoint == 0)
244
    {
244
    {
245
      if (Bind () == -1)
245
      if (Bind () == -1)
 Lines 380-398    Link Here 
380
}
380
}
381
381
382
int 
382
int 
383
UdpSocketImpl::SendTo (Ptr<Packet> p, const Address &address)
383
UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
384
{
384
{
385
  NS_LOG_FUNCTION (this << address << p);
385
  NS_LOG_FUNCTION (this << p << flags << address);
386
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
386
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
387
  Ipv4Address ipv4 = transport.GetIpv4 ();
387
  Ipv4Address ipv4 = transport.GetIpv4 ();
388
  uint16_t port = transport.GetPort ();
388
  uint16_t port = transport.GetPort ();
389
  return DoSendTo (p, ipv4, port);
389
  return DoSendTo (p, ipv4, port);
390
}
390
}
391
391
392
uint32_t
393
UdpSocketImpl::GetRxAvailable (void) const
394
{
395
  NS_LOG_FUNCTION_NOARGS ();
396
  // We separately maintain this state to avoid walking the queue 
397
  // every time this might be called
398
  return m_rxAvailable;
399
}
400
392
Ptr<Packet>
401
Ptr<Packet>
393
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags)
402
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags)
394
{
403
{
395
  NS_LOG_FUNCTION_NOARGS ();
404
  NS_LOG_FUNCTION (this << maxSize << flags);
396
  if (m_deliveryQueue.empty() )
405
  if (m_deliveryQueue.empty() )
397
    {
406
    {
398
      return 0;
407
      return 0;
 Lines 410-422    Link Here 
410
  return p;
419
  return p;
411
}
420
}
412
421
413
uint32_t
422
Ptr<Packet>
414
UdpSocketImpl::GetRxAvailable (void) const
423
UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, 
424
  Address &fromAddress)
415
{
425
{
416
  NS_LOG_FUNCTION_NOARGS ();
426
  NS_LOG_FUNCTION (this << maxSize << flags);
417
  // We separately maintain this state to avoid walking the queue 
427
  Ptr<Packet> packet = Recv (maxSize, flags);
418
  // every time this might be called
428
  if (packet != 0)
419
  return m_rxAvailable;
429
    {
430
      SocketAddressTag tag;
431
      bool found;
432
      found = packet->FindFirstMatchingTag (tag);
433
      NS_ASSERT (found);
434
      fromAddress = tag.GetAddress ();
435
    }
436
  return packet;
420
}
437
}
421
438
422
void 
439
void 
 Lines 431-437    Link Here 
431
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
448
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
432
    {
449
    {
433
      Address address = InetSocketAddress (ipv4, port);
450
      Address address = InetSocketAddress (ipv4, port);
434
      SocketRxAddressTag tag;
451
      SocketAddressTag tag;
435
      tag.SetAddress (address);
452
      tag.SetAddress (address);
436
      packet->AddTag (tag);
453
      packet->AddTag (tag);
437
      m_deliveryQueue.push (packet);
454
      m_deliveryQueue.push (packet);
 Lines 638-644    Link Here 
638
  // Unicast test
655
  // Unicast test
639
  m_receivedPacket = Create<Packet> ();
656
  m_receivedPacket = Create<Packet> ();
640
  m_receivedPacket2 = Create<Packet> ();
657
  m_receivedPacket2 = Create<Packet> ();
641
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 
658
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 0, 
642
    InetSocketAddress (Ipv4Address("10.0.0.1"), 1234)), 123);
659
    InetSocketAddress (Ipv4Address("10.0.0.1"), 1234)), 123);
643
  Simulator::Run ();
660
  Simulator::Run ();
644
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
661
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
 Lines 651-657    Link Here 
651
668
652
  m_receivedPacket = Create<Packet> ();
669
  m_receivedPacket = Create<Packet> ();
653
  m_receivedPacket2 = Create<Packet> ();
670
  m_receivedPacket2 = Create<Packet> ();
654
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 
671
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 0, 
655
    InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
672
    InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
656
  Simulator::Run ();
673
  Simulator::Run ();
657
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
674
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
 Lines 673-679    Link Here 
673
690
674
  m_receivedPacket = Create<Packet> ();
691
  m_receivedPacket = Create<Packet> ();
675
  m_receivedPacket2 = Create<Packet> ();
692
  m_receivedPacket2 = Create<Packet> ();
676
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo (Create<Packet> (123),
693
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo (Create<Packet> (123), 0,
677
InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
694
InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
678
  Simulator::Run ();
695
  Simulator::Run ();
679
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
696
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
(-)ns-3-dev/src/internet-node/udp-socket-impl.h (-4 / +5 lines)
 Lines 58-69    Link Here 
58
  virtual int ShutdownRecv (void);
58
  virtual int ShutdownRecv (void);
59
  virtual int Connect(const Address &address);
59
  virtual int Connect(const Address &address);
60
  virtual int Listen (uint32_t queueLimit);
60
  virtual int Listen (uint32_t queueLimit);
61
  virtual int Send (Ptr<Packet> p);
62
  virtual int SendTo (Ptr<Packet> p, const Address &address);
63
  virtual uint32_t GetTxAvailable (void) const;
61
  virtual uint32_t GetTxAvailable (void) const;
64
62
  virtual int Send (Ptr<Packet> p, uint32_t flags);
65
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
63
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &address);
66
  virtual uint32_t GetRxAvailable (void) const;
64
  virtual uint32_t GetRxAvailable (void) const;
65
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
66
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
67
    Address &fromAddress);
67
68
68
private:
69
private:
69
  // Attributes set through UdpSocket base class 
70
  // Attributes set through UdpSocket base class 
(-)ns-3-dev/src/node/packet-socket.cc (-9 / +25 lines)
 Lines 230-236    Link Here 
230
}
230
}
231
231
232
int
232
int
233
PacketSocket::Send (Ptr<Packet> p)
233
PacketSocket::Send (Ptr<Packet> p, uint32_t flags)
234
{
234
{
235
  NS_LOG_FUNCTION_NOARGS ();
235
  NS_LOG_FUNCTION_NOARGS ();
236
  if (m_state == STATE_OPEN ||
236
  if (m_state == STATE_OPEN ||
 Lines 239-245    Link Here 
239
      m_errno = ERROR_NOTCONN;
239
      m_errno = ERROR_NOTCONN;
240
      return -1;
240
      return -1;
241
    }
241
    }
242
  return SendTo (p, m_destAddr);
242
  return SendTo (p, flags, m_destAddr);
243
}
243
}
244
244
245
uint32_t
245
uint32_t
 Lines 275-281    Link Here 
275
}
275
}
276
276
277
int
277
int
278
PacketSocket::SendTo(Ptr<Packet> p, const Address &address)
278
PacketSocket::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
279
{
279
{
280
  NS_LOG_FUNCTION_NOARGS ();
280
  NS_LOG_FUNCTION_NOARGS ();
281
  PacketSocketAddress ad;
281
  PacketSocketAddress ad;
 Lines 361-367    Link Here 
361
361
362
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
362
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
363
    {
363
    {
364
      SocketRxAddressTag tag;
364
      SocketAddressTag tag;
365
      tag.SetAddress (address);
365
      tag.SetAddress (address);
366
      packet->AddTag (tag);
366
      packet->AddTag (tag);
367
      m_deliveryQueue.push (packet);
367
      m_deliveryQueue.push (packet);
 Lines 381-386    Link Here 
381
    }
381
    }
382
}
382
}
383
383
384
uint32_t
385
PacketSocket::GetRxAvailable (void) const
386
{
387
  NS_LOG_FUNCTION_NOARGS ();
388
  // We separately maintain this state to avoid walking the queue 
389
  // every time this might be called
390
  return m_rxAvailable;
391
}
392
384
Ptr<Packet> 
393
Ptr<Packet> 
385
PacketSocket::Recv (uint32_t maxSize, uint32_t flags)
394
PacketSocket::Recv (uint32_t maxSize, uint32_t flags)
386
{
395
{
 Lines 402-414    Link Here 
402
  return p;
411
  return p;
403
}
412
}
404
413
405
uint32_t
414
Ptr<Packet>
406
PacketSocket::GetRxAvailable (void) const
415
PacketSocket::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
407
{
416
{
408
  NS_LOG_FUNCTION_NOARGS ();
417
  NS_LOG_FUNCTION_NOARGS ();
409
  // We separately maintain this state to avoid walking the queue 
418
  Ptr<Packet> packet = Recv (maxSize, flags);
410
  // every time this might be called
419
  if (packet != 0)
411
  return m_rxAvailable;
420
    {
421
      SocketAddressTag tag;
422
      bool found;
423
      found = packet->FindFirstMatchingTag (tag);
424
      NS_ASSERT (found);
425
      fromAddress = tag.GetAddress ();
426
    }
427
  return packet;
412
}
428
}
413
429
414
}//namespace ns3
430
}//namespace ns3
(-)ns-3-dev/src/node/packet-socket.h (-5 / +5 lines)
 Lines 93-105    Link Here 
93
  virtual int ShutdownRecv (void);
93
  virtual int ShutdownRecv (void);
94
  virtual int Connect(const Address &address);
94
  virtual int Connect(const Address &address);
95
  virtual int Listen(uint32_t queueLimit);
95
  virtual int Listen(uint32_t queueLimit);
96
  virtual int Send (Ptr<Packet> p);
97
  virtual uint32_t GetTxAvailable (void) const;
96
  virtual uint32_t GetTxAvailable (void) const;
98
97
  virtual int Send (Ptr<Packet> p, uint32_t flags);
99
  virtual int SendTo(Ptr<Packet> p, const Address &address);
98
  virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address &toAddress);
100
101
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
102
  virtual uint32_t GetRxAvailable (void) const;
99
  virtual uint32_t GetRxAvailable (void) const;
100
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
101
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
102
    Address &fromAddress);
103
103
104
private:
104
private:
105
  void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
105
  void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
(-)ns-3-dev/src/node/socket.cc (-29 / +60 lines)
 Lines 40-52    Link Here 
40
  NS_LOG_FUNCTION_NOARGS ();
40
  NS_LOG_FUNCTION_NOARGS ();
41
}
41
}
42
42
43
void
44
Socket::SetCloseUnblocksCallback (Callback<void,Ptr<Socket> > closeUnblocks)
45
{
46
  NS_LOG_FUNCTION_NOARGS ();
47
  m_closeUnblocks = closeUnblocks;
48
}
49
50
Ptr<Socket> 
43
Ptr<Socket> 
51
Socket::CreateSocket (Ptr<Node> node, TypeId tid)
44
Socket::CreateSocket (Ptr<Node> node, TypeId tid)
52
{
45
{
 Lines 110-115    Link Here 
110
  m_receivedData = receivedData;
103
  m_receivedData = receivedData;
111
}
104
}
112
105
106
int 
107
Socket::Send (Ptr<Packet> p)
108
{
109
  NS_LOG_FUNCTION_NOARGS ();
110
  return Send (p, 0);
111
}
112
113
void
113
void
114
Socket::NotifyCloseUnblocks (void)
114
Socket::NotifyCloseUnblocks (void)
115
{
115
{
 Lines 125-131    Link Here 
125
  return 0; //XXX the base class version does nothing
125
  return 0; //XXX the base class version does nothing
126
}
126
}
127
127
128
int Socket::Send (const uint8_t* buf, uint32_t size)
128
int 
129
Socket::Send (const uint8_t* buf, uint32_t size, uint32_t flags)
129
{
130
{
130
  NS_LOG_FUNCTION_NOARGS ();
131
  NS_LOG_FUNCTION_NOARGS ();
131
  Ptr<Packet> p;
132
  Ptr<Packet> p;
 Lines 137-172    Link Here 
137
    {
138
    {
138
      p = Create<Packet> (size);
139
      p = Create<Packet> (size);
139
    }
140
    }
140
  return Send (p);
141
  return Send (p, flags);
142
}
143
144
int 
145
Socket::SendTo (const uint8_t* buf, uint32_t size, uint32_t flags,
146
                const Address &toAddress)
147
{
148
  NS_LOG_FUNCTION_NOARGS ();
149
  Ptr<Packet> p;
150
  if(buf)
151
    {
152
      p = Create<Packet> (buf, size);
153
    }
154
  else
155
    {
156
      p = Create<Packet> (size);
157
    }
158
  return SendTo (p, flags, toAddress);
141
}
159
}
142
160
143
Ptr<Packet>
161
Ptr<Packet>
144
Socket::Recv (void)
162
Socket::Recv (void)
145
{
163
{
164
  NS_LOG_FUNCTION_NOARGS ();
146
  return Recv (std::numeric_limits<uint32_t>::max(), 0);
165
  return Recv (std::numeric_limits<uint32_t>::max(), 0);
147
}
166
}
148
167
149
int 
168
int 
150
Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags)
169
Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags)
151
{
170
{
171
  NS_LOG_FUNCTION_NOARGS ();
152
  Ptr<Packet> p = Recv (size, flags); // read up to "size" bytes
172
  Ptr<Packet> p = Recv (size, flags); // read up to "size" bytes
173
  if (p == 0)
174
    {
175
      return 0;
176
    }
153
  memcpy (buf, p->PeekData (), p->GetSize());
177
  memcpy (buf, p->PeekData (), p->GetSize());
154
  return p->GetSize ();
178
  return p->GetSize ();
155
}
179
}
156
180
157
int Socket::SendTo (const uint8_t* buf, uint32_t size, const Address &address)
181
Ptr<Packet>
182
Socket::RecvFrom (Address &fromAddress)
158
{
183
{
159
  NS_LOG_FUNCTION_NOARGS ();
184
  NS_LOG_FUNCTION_NOARGS ();
160
  Ptr<Packet> p;
185
  return RecvFrom (std::numeric_limits<uint32_t>::max(), 0, fromAddress);
161
  if(buf)
186
}
162
    {
187
163
      p = Create<Packet> (buf, size);
188
int 
164
    }
189
Socket::RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
165
  else
190
                  Address &fromAddress)
191
{
192
  NS_LOG_FUNCTION_NOARGS ();
193
  Ptr<Packet> p = RecvFrom (size, flags, fromAddress); 
194
  if (p == 0)
166
    {
195
    {
167
      p = Create<Packet> (size);
196
      return 0;
168
    }
197
    }
169
  return SendTo (p, address);
198
  memcpy (buf, p->PeekData (), p->GetSize());
199
  return p->GetSize ();
170
}
200
}
171
201
172
void 
202
void 
 Lines 281-334    Link Here 
281
 *           Socket Tags
311
 *           Socket Tags
282
 ***************************************************************/
312
 ***************************************************************/
283
313
284
SocketRxAddressTag::SocketRxAddressTag ()  
314
SocketAddressTag::SocketAddressTag ()  
285
{
315
{
286
}
316
}
287
317
288
void 
318
void 
289
SocketRxAddressTag::SetAddress (Address addr)
319
SocketAddressTag::SetAddress (Address addr)
290
{
320
{
291
  m_address = addr;
321
  m_address = addr;
292
}
322
}
293
323
294
Address 
324
Address 
295
SocketRxAddressTag::GetAddress (void) const
325
SocketAddressTag::GetAddress (void) const
296
{
326
{
297
  return m_address;
327
  return m_address;
298
}
328
}
299
329
300
330
301
TypeId
331
TypeId
302
SocketRxAddressTag::GetTypeId (void)
332
SocketAddressTag::GetTypeId (void)
303
{
333
{
304
  static TypeId tid = TypeId ("ns3::SocketRxAddressTag")
334
  static TypeId tid = TypeId ("ns3::SocketAddressTag")
305
    .SetParent<Tag> ()
335
    .SetParent<Tag> ()
306
    .AddConstructor<SocketRxAddressTag> ()
336
    .AddConstructor<SocketAddressTag> ()
307
    ;
337
    ;
308
  return tid;
338
  return tid;
309
}
339
}
310
TypeId
340
TypeId
311
SocketRxAddressTag::GetInstanceTypeId (void) const
341
SocketAddressTag::GetInstanceTypeId (void) const
312
{
342
{
313
  return GetTypeId ();
343
  return GetTypeId ();
314
}
344
}
315
uint32_t
345
uint32_t
316
SocketRxAddressTag::GetSerializedSize (void) const
346
SocketAddressTag::GetSerializedSize (void) const
317
{
347
{
318
  return m_address.GetSerializedSize ();
348
  return m_address.GetSerializedSize ();
319
}
349
}
320
void
350
void
321
SocketRxAddressTag::Serialize (TagBuffer i) const
351
SocketAddressTag::Serialize (TagBuffer i) const
322
{
352
{
323
  m_address.Serialize (i);
353
  m_address.Serialize (i);
324
}
354
}
325
void
355
void
326
SocketRxAddressTag::Deserialize (TagBuffer i)
356
SocketAddressTag::Deserialize (TagBuffer i)
327
{
357
{
328
  m_address.Deserialize (i);
358
  m_address.Deserialize (i);
329
}
359
}
330
void
360
void
331
SocketRxAddressTag::Print (std::ostream &os) const
361
SocketAddressTag::Print (std::ostream &os) const
332
{
362
{
333
  os << "address=" << m_address;
363
  os << "address=" << m_address;
334
}
364
}
 Lines 386-389    Link Here 
386
  os << "Ttl=" << (uint32_t) m_ttl;
416
  os << "Ttl=" << (uint32_t) m_ttl;
387
}
417
}
388
418
419
389
}//namespace ns3
420
}//namespace ns3
(-)ns-3-dev/src/node/socket.h (-57 / +202 lines)
 Lines 92-118    Link Here 
92
   * \param tid The TypeId of the socket to create
92
   * \param tid The TypeId of the socket to create
93
   */
93
   */
94
  static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
94
  static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
95
96
  /**
95
  /**
97
   * \return the errno associated to the last call which failed in this
96
   * \return the errno associated to the last call which failed in this
98
   *         socket. Each socket's errno is initialized to zero
97
   *         socket. Each socket's errno is initialized to zero
99
   *         when the socket is created.
98
   *         when the socket is created.
100
   */
99
   */
101
  virtual enum Socket::SocketErrno GetErrno (void) const = 0;
100
  virtual enum Socket::SocketErrno GetErrno (void) const = 0;
102
103
  /**
101
  /**
104
   * \returns the node this socket is associated with.
102
   * \returns the node this socket is associated with.
105
   */
103
   */
106
  virtual Ptr<Node> GetNode (void) const = 0;
104
  virtual Ptr<Node> GetNode (void) const = 0;
107
105
108
  void SetCloseUnblocksCallback (Callback<void, Ptr<Socket> > closeUnblocks);
109
110
  /**
106
  /**
111
   * \param closeCompleted Callback invoked when the close operation is
107
   * \param closeCompleted Callback invoked when the close operation is
112
   *        completed.
108
   *        completed.
113
   */
109
   */
114
  void SetCloseCallback (Callback<void, Ptr<Socket> > closeCompleted);
110
  void SetCloseCallback (Callback<void, Ptr<Socket> > closeCompleted);
115
116
  /**
111
  /**
117
   * \param connectionSucceeded this callback is invoked when the 
112
   * \param connectionSucceeded this callback is invoked when the 
118
   *        connection request initiated by the user is successfully 
113
   *        connection request initiated by the user is successfully 
 Lines 165-171    Link Here 
165
   *        user should check this return value to confirm that the
160
   *        user should check this return value to confirm that the
166
   *        callback is supported.
161
   *        callback is supported.
167
   */
162
   */
168
  virtual bool SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent);
163
  virtual bool SetDataSentCallback (Callback<void, Ptr<Socket>, 
164
                                    uint32_t> dataSent);
169
  /**
165
  /**
170
   * \brief Notify application when space in transmit buffer is added
166
   * \brief Notify application when space in transmit buffer is added
171
   *
167
   *
 Lines 242-253    Link Here 
242
  virtual int Listen (uint32_t queueLimit) = 0;
238
  virtual int Listen (uint32_t queueLimit) = 0;
243
239
244
  /**
240
  /**
241
   * \brief Returns the number of bytes which can be sent in a single call
242
   * to Send. 
243
   * 
244
   * For datagram sockets, this returns the number of bytes that
245
   * can be passed atomically through the underlying protocol.
246
   *
247
   * For stream sockets, this returns the available space in bytes
248
   * left in the transmit buffer.
249
   */
250
  virtual uint32_t GetTxAvailable (void) const = 0;
251
 
252
  /**
245
   * \brief Send data (or dummy data) to the remote host
253
   * \brief Send data (or dummy data) to the remote host
246
   *
254
   *
247
   * This function matches closely in semantics to the send() function
255
   * This function matches closely in semantics to the send() function
248
   * call in the standard C library (libc):
256
   * call in the standard C library (libc):
249
   *   ssize_t send (int s, const void *msg, size_t len, int flags);
257
   *   ssize_t send (int s, const void *msg, size_t len, int flags);
250
   * except that the function call is asynchronous.
258
   * except that the send I/O is asynchronous.  This is the
259
   * primary Send method at this low-level API and must be implemented 
260
   * by subclasses.
251
   * 
261
   * 
252
   * In a typical blocking sockets model, this call would block upon
262
   * In a typical blocking sockets model, this call would block upon
253
   * lack of space to hold the message to be sent.  In ns-3 at this
263
   * lack of space to hold the message to be sent.  In ns-3 at this
 Lines 272-367    Link Here 
272
   * split the Packet (based on information obtained from 
282
   * split the Packet (based on information obtained from 
273
   * GetTxAvailable) and reattempt to send the data.
283
   * GetTxAvailable) and reattempt to send the data.
274
   *
284
   *
285
   * The flags argument is formed by or'ing one or more of the values:     
286
   *        MSG_OOB        process out-of-band data 
287
   *        MSG_DONTROUTE  bypass routing, use direct interface 
288
   * These flags are _unsupported_ as of ns-3.1.  
289
   *
275
   * \param p ns3::Packet to send
290
   * \param p ns3::Packet to send
291
   * \param flags Socket control flags
276
   * \returns the number of bytes accepted for transmission if no error
292
   * \returns the number of bytes accepted for transmission if no error
277
   *          occurs, and -1 otherwise.
293
   *          occurs, and -1 otherwise.
294
   *
295
   * \see SetSendCallback
278
   */
296
   */
279
  virtual int Send (Ptr<Packet> p) = 0;
297
  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
280
  
298
281
  /**
299
  /**
282
   * \brief Returns the number of bytes which can be sent in a single call
300
   * \brief Send data to a specified peer.
283
   * to Send. 
301
   *
302
   * This method has similar semantics to Send () but subclasses may
303
   * want to provide checks on socket state, so the implementation is
304
   * pushed to subclasses.
305
   *
306
   * \param p packet to send
307
   * \param flags Socket control flags
308
   * \param toAddress IP Address of remote host
309
   * \returns -1 in case of error or the number of bytes copied in the 
310
   *          internal buffer and accepted for transmission.
311
   */
312
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, 
313
    const Address &toAddress) = 0;
314
315
  /**
316
   * Return number of bytes which can be returned from one or 
317
   * multiple calls to Recv.
318
   * Must be possible to call this method from the Recv callback.
319
   */
320
  virtual uint32_t GetRxAvailable (void) const = 0;
321
322
  /**
323
   * \brief Read data from the socket
324
   *
325
   * This function matches closely in semantics to the recv() function
326
   * call in the standard C library (libc):
327
   *   ssize_t recv (int s, void *buf, size_t len, int flags);
328
   * except that the receive I/O is asynchronous.  This is the
329
   * primary Recv method at this low-level API and must be implemented 
330
   * by subclasses.
284
   * 
331
   * 
285
   * For datagram sockets, this returns the number of bytes that
332
   * This method is normally used only on a connected socket.
286
   * can be passed atomically through the underlying protocol.
333
   * In a typical blocking sockets model, this call would block until
334
   * at least one byte is returned or the connection closes.  
335
   * In ns-3 at this API, the call returns immediately in such a case
336
   * and returns 0 if nothing is available to be read.
337
   * However, an application can set a callback, ns3::SetRecvCallback,
338
   * to be notified of data being available to be read
339
   * (when it conceptually unblocks); this is an asynchronous
340
   * I/O model for recv().
341
   * 
342
   * This variant of Recv() uses class ns3::Packet to encapsulate
343
   * data, rather than providing a raw pointer and length field.  
344
   * This allows an ns-3 application to attach tags if desired (such
345
   * as a flow ID) and may allow the simulator to avoid some data
346
   * copies.  Despite the appearance of receiving Packets on a stream
347
   * socket, just think of it as a fancy byte buffer with streaming
348
   * semantics.    
287
   *
349
   *
288
   * For stream sockets, this returns the available space in bytes
350
   * The semantics depend on the type of socket.  For a datagram socket,
289
   * left in the transmit buffer.
351
   * each Recv() returns the data from at most one Send(), and order
352
   * is not necessarily preserved.  For a stream socket, the bytes
353
   * are delivered in order, and on-the-wire packet boundaries are
354
   * not preserved.  
355
   * 
356
   * The flags argument is formed by or'ing one or more of the values:     
357
   *        MSG_OOB        process out-of-band data
358
   *        MSG_PEEK       peek at incoming message
359
   * These flags are _unsupported_ as of ns-3.1.  
360
   *
361
   * Some variants of Recv() are supported as additional API,
362
   * including RecvFrom(), overloaded Recv() without arguments,
363
   * and variants that use raw character buffers.
364
   *
365
   * \param maxSize reader will accept packet up to maxSize
366
   * \param flags Socket control flags
367
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
368
   * 0 if the socket cannot return a next in-sequence packet conforming
369
   * to the maxSize and flags.
370
   *
371
   * \see SetRecvCallback
290
   */
372
   */
291
  virtual uint32_t GetTxAvailable (void) const = 0;
373
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
374
375
  /**
376
   * \brief Read a single packet from the socket and retrieve the sender 
377
   * address.
378
   *
379
   * Calls Recv(maxSize, flags) with maxSize
380
   * implicitly set to maximum sized integer, and flags set to zero.
381
   *
382
   * This method has similar semantics to Recv () but subclasses may   
383
   * want to provide checks on socket state, so the implementation is   
384
   * pushed to subclasses.
385
   *
386
   * \param maxSize reader will accept packet up to maxSize
387
   * \param flags Socket control flags
388
   * \param fromAddress output parameter that will return the
389
   * address of the sender of the received packet, if any.  Remains
390
   * untouched if no packet is received.
391
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
392
   * 0 if the socket cannot return a next in-sequence packet.
393
   */
394
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,  
395
    Address &fromAddress) = 0;
292
396
397
  /////////////////////////////////////////////////////////////////////
398
  //   The remainder of these public methods are overloaded methods  //
399
  //   or variants of Send() and Recv(), and they are non-virtual    //
400
  /////////////////////////////////////////////////////////////////////
401
 
293
  /**
402
  /**
294
   * \brief Send data (or dummy data) to the remote host
403
   * \brief Send data (or dummy data) to the remote host
295
   * \param buf A pointer to a raw byte buffer of some data to send.  If this 
296
   * is 0, we send dummy data whose size is specified by the second parameter
297
   * \param size the number of bytes to copy from the buffer
298
   * 
404
   * 
299
   * This is provided so as to have an API which is closer in appearance 
405
   * Overloaded version of Send(..., flags) with flags set to zero.
300
   * to that of real network or BSD sockets.  
406
   *
407
   * \param p ns3::Packet to send
408
   * \returns the number of bytes accepted for transmission if no error
409
   *          occurs, and -1 otherwise.
301
   */
410
   */
302
  int Send (const uint8_t* buf, uint32_t size);
411
  int Send (Ptr<Packet> p);
303
  
412
304
  /**
413
  /**
305
   * \brief Send data to a specified peer.
414
   * \brief Send data (or dummy data) to the remote host
306
   * \param p packet to send
415
   * 
307
   * \param address IP Address of remote host
416
   * This method is provided so as to have an API which is closer in 
308
   * \returns -1 in case of error or the number of bytes copied in the 
417
   * appearance to that of real network or BSD sockets.  
309
   *          internal buffer and accepted for transmission.
418
   *
419
   * \param buf A pointer to a raw byte buffer of some data to send.  If 
420
   * this buffer is 0, we send dummy data whose size is specified by the 
421
   * second parameter
422
   * \param size the number of bytes to copy from the buffer
423
   * \param flags Socket control flags
310
   */
424
   */
311
  virtual int SendTo (Ptr<Packet> p, const Address &address) = 0;
425
  int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
426
  
312
427
313
  /**
428
  /**
314
   * \brief Send data to a specified peer.
429
   * \brief Send data to a specified peer.
315
   * \param buf A pointer to a raw byte buffer of some data to send.  If this 
430
   *
316
   * is 0, we send dummy data whose size is specified by the third parameter
431
   * This method is provided so as to have an API which is closer in 
432
   * appearance to that of real network or BSD sockets.  
433
   *
434
   * \param buf A pointer to a raw byte buffer of some data to send.  
435
   * If this is 0, we send dummy data whose size is specified by the 
436
   * third parameter
317
   * \param size the number of bytes to copy from the buffer
437
   * \param size the number of bytes to copy from the buffer
438
   * \param flags Socket control flags
318
   * \param address IP Address of remote host
439
   * \param address IP Address of remote host
319
   * \returns -1 in case of error or the number of bytes copied in the 
440
   * \returns -1 in case of error or the number of bytes copied in the 
320
   *          internal buffer and accepted for transmission.
441
   *          internal buffer and accepted for transmission.
321
   *
442
   *
322
   * This is provided so as to have an API which is closer in appearance 
323
   * to that of real network or BSD sockets.
324
   */
443
   */
325
  int SendTo (const uint8_t* buf, uint32_t size, const Address &address); 
444
  int SendTo (const uint8_t* buf, uint32_t size, uint32_t flags, 
445
              const Address &address); 
326
446
327
  /**
447
  /**
328
   * \brief Read a single packet from the socket
448
   * \brief Read a single packet from the socket
329
   * \param maxSize reader will accept packet up to maxSize
330
   * \param flags Socket recv flags
331
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
332
   * 0 if the socket cannot return a next in-sequence packet conforming
333
   * to the maxSize and flags.
334
   */
335
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
336
  /**
337
   * \brief Read a single packet from the socket
338
   *
449
   *
339
   *      Overloaded version of Recv(maxSize, flags) with maxSize
450
   * Overloaded version of Recv(maxSize, flags) with maxSize
340
   *      implicitly set to maximum sized integer, and flags set to zero.
451
   * implicitly set to maximum sized integer, and flags set to zero.
341
   *
452
   *
342
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
453
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
343
   * 0 if the socket cannot return a next in-sequence packet.
454
   * 0 if the socket cannot return a next in-sequence packet.
344
   */
455
   */
345
   Ptr<Packet> Recv (void);
456
   Ptr<Packet> Recv (void);
457
346
  /**
458
  /**
347
   * \brief Recv data (or dummy data) from the remote host
459
   * \brief Recv data (or dummy data) from the remote host
348
   * \param buf A pointer to a raw byte buffer to write the data to. 
460
   *
461
   * This method is provided so as to have an API which is closer in 
462
   * appearance to that of real network or BSD sockets.  
463
   * 
349
   * If the underlying packet was carring null (fake) data, this buffer
464
   * If the underlying packet was carring null (fake) data, this buffer
350
   * will be zeroed up to the length specified by the return value.
465
   * will be zeroed up to the length specified by the return value.
466
   *
467
   * \param buf A pointer to a raw byte buffer to write the data to. 
351
   * \param size Number of bytes (at most) to copy to buf
468
   * \param size Number of bytes (at most) to copy to buf
352
   * \param flags any flags to pass to the socket
469
   * \param flags any flags to pass to the socket
353
   * \returns number of bytes copied into buf
470
   * \returns number of bytes copied into buf
354
   * 
355
   * This is provided so as to have an API which is closer in appearance 
356
   * to that of real network or BSD sockets.  
357
   */
471
   */
358
  int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
472
  int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
473
359
  /**
474
  /**
360
   * Return number of bytes which can be returned from one or 
475
   * \brief Read a single packet from the socket and retrieve the sender 
361
   * multiple calls to Recv.
476
   * address.
362
   * Must be possible to call this method from the Recv callback.
477
   *
478
   * Calls RecvFrom (maxSize, flags, fromAddress) with maxSize
479
   * implicitly set to maximum sized integer, and flags set to zero.
480
   *
481
   * \param maxSize reader will accept packet up to maxSize
482
   * \param flags Socket control flags
483
   * \param fromAddress output parameter that will return the
484
   * address of the sender of the received packet, if any.  Remains
485
   * untouched if no packet is received.
486
   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
487
   * 0 if the socket cannot return a next in-sequence packet.
363
   */
488
   */
364
  virtual uint32_t GetRxAvailable (void) const = 0;
489
  Ptr<Packet> RecvFrom (Address &fromAddress);
490
491
  /**
492
   * \brief Read a single packet from the socket and retrieve the sender
493
   * address.
494
   *
495
   * This method is provided so as to have an API which is closer in 
496
   * appearance to that of real network or BSD sockets.  
497
   * 
498
   * \param buf A pointer to a raw byte buffer to write the data to. 
499
   * If the underlying packet was carring null (fake) data, this buffer
500
   * will be zeroed up to the length specified by the return value.
501
   * \param size Number of bytes (at most) to copy to buf
502
   * \param flags any flags to pass to the socket
503
   * \param fromAddress output parameter that will return the
504
   * address of the sender of the received packet, if any.  Remains
505
   * untouched if no packet is received.
506
   * \returns number of bytes copied into buf
507
   */
508
  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
509
                Address &fromAddress);
365
 
510
 
366
protected:
511
protected:
367
  void NotifyCloseUnblocks (void);
512
  void NotifyCloseUnblocks (void);
 Lines 391-403    Link Here 
391
};
536
};
392
537
393
/**
538
/**
394
 * \brief This class implements a tag that carries the source address
539
 * \brief This class implements a tag that carries an address
395
 * of a packet across the receiving socket interface.
540
 * of a packet across the socket interface.
396
 */
541
 */
397
class SocketRxAddressTag : public Tag
542
class SocketAddressTag : public Tag
398
{
543
{
399
public:
544
public:
400
  SocketRxAddressTag ();
545
  SocketAddressTag ();
401
  void SetAddress (Address addr);
546
  void SetAddress (Address addr);
402
  Address GetAddress (void) const;
547
  Address GetAddress (void) const;
403
548
(-)ns-3-dev/src/node/tcp-socket.h (-3 / +7 lines)
 Lines 58-68    Link Here 
58
  virtual int ShutdownSend (void) = 0;
58
  virtual int ShutdownSend (void) = 0;
59
  virtual int ShutdownRecv (void) = 0;
59
  virtual int ShutdownRecv (void) = 0;
60
  virtual int Connect (const Address &address) = 0;
60
  virtual int Connect (const Address &address) = 0;
61
  virtual int Send (Ptr<Packet> p) = 0;
62
  virtual uint32_t GetTxAvailable (void) const = 0;
61
  virtual uint32_t GetTxAvailable (void) const = 0;
63
  virtual int SendTo (Ptr<Packet> p, const Address &address) = 0;
62
  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
64
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
63
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, 
64
    const Address &toAddress) = 0;
65
  virtual uint32_t GetRxAvailable (void) const = 0;
65
  virtual uint32_t GetRxAvailable (void) const = 0;
66
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
67
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
68
    Address &fromAddress) = 0;
69
66
70
67
private:
71
private:
68
  // Indirect the attribute setting and getting through private virtual methods
72
  // Indirect the attribute setting and getting through private virtual methods
(-)ns-3-dev/src/node/udp-socket.h (-3 / +6 lines)
 Lines 57-67    Link Here 
57
  virtual int ShutdownSend (void) = 0;
57
  virtual int ShutdownSend (void) = 0;
58
  virtual int ShutdownRecv (void) = 0;
58
  virtual int ShutdownRecv (void) = 0;
59
  virtual int Connect (const Address &address) = 0;
59
  virtual int Connect (const Address &address) = 0;
60
  virtual int Send (Ptr<Packet> p) = 0;
61
  virtual uint32_t GetTxAvailable (void) const = 0;
60
  virtual uint32_t GetTxAvailable (void) const = 0;
62
  virtual int SendTo (Ptr<Packet> p, const Address &address) = 0;
61
  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
63
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
62
  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
63
    const Address &toAddress) = 0;
64
  virtual uint32_t GetRxAvailable (void) const = 0;
64
  virtual uint32_t GetRxAvailable (void) const = 0;
65
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
66
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
67
    Address &fromAddress) = 0;
65
68
66
private:
69
private:
67
  // Indirect the attribute setting and getting through private virtual methods
70
  // Indirect the attribute setting and getting through private virtual methods
(-)ns-3-dev/src/routing/olsr/olsr-agent-impl.cc (-1 / +1 lines)
 Lines 305-311    Link Here 
305
  Ptr<Packet> receivedPacket;
305
  Ptr<Packet> receivedPacket;
306
  receivedPacket = socket->Recv ();
306
  receivedPacket = socket->Recv ();
307
307
308
  SocketRxAddressTag tag;
308
  SocketAddressTag tag;
309
  bool found;
309
  bool found;
310
  found = receivedPacket->FindFirstMatchingTag (tag);
310
  found = receivedPacket->FindFirstMatchingTag (tag);
311
  NS_ASSERT (found);
311
  NS_ASSERT (found);

Return to bug 213