src/node/socket.cc
author Antti Mäkelä <zarhan@cc.hut.fi>
Tue, 15 Dec 2009 20:41:36 -0800
changeset 5856 7fd20c798a7d
parent 5720 92594e167a58
child 6393 f7e1f9dfa08d
permissions -rw-r--r--
bug 742: Implementation of SO_BINDTODEVICE
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     2
/*
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     3
 * Copyright (c) 2006 Georgia Tech Research Corporation
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     4
 *               2007 INRIA
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     5
 *
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     8
 * published by the Free Software Foundation;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
     9
 *
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    13
 * GNU General Public License for more details.
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    14
 *
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    15
 * You should have received a copy of the GNU General Public License
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    16
 * along with this program; if not, write to the Free Software
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    18
 *
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    19
 * Authors: George F. Riley<[email protected]>
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    20
 *          Mathieu Lacage <[email protected]>
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    21
 */
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    22
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
    23
#include "ns3/log.h"
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    24
#include "ns3/packet.h"
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    25
#include "node.h"
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include "socket.h"
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    27
#include "socket-factory.h"
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3276
diff changeset
    28
#include <limits>
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    29
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1499
diff changeset
    30
NS_LOG_COMPONENT_DEFINE ("Socket");
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
    34
Socket::Socket (void)
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
    35
{
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
    36
  m_boundnetdevice = 0;
3107
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
    37
  NS_LOG_FUNCTION_NOARGS ();
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
    38
}
ec3ed34b2470 API for SocketOptions class
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
    39
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
Socket::~Socket ()
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    41
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
    42
  NS_LOG_FUNCTION_NOARGS ();
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    43
}
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    45
Ptr<Socket> 
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    46
Socket::CreateSocket (Ptr<Node> node, TypeId tid)
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    47
{
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    48
  Ptr<Socket> s;
5720
92594e167a58 [aodv] Code style fixes proposed by Faker in his review
Pavel Boyko <boyko@iitp.ru>
parents: 5715
diff changeset
    49
  NS_ASSERT (node != 0);
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    50
  Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid);
5720
92594e167a58 [aodv] Code style fixes proposed by Faker in his review
Pavel Boyko <boyko@iitp.ru>
parents: 5715
diff changeset
    51
  NS_ASSERT (socketFactory != 0);
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    52
  s = socketFactory->CreateSocket ();
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    53
  NS_ASSERT (s != 0);
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    54
  return s;
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    55
}
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    56
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    57
void 
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    58
Socket::SetConnectCallback (
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    59
  Callback<void, Ptr<Socket> > connectionSucceeded,
3276
8869a79a391f Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents: 3269
diff changeset
    60
  Callback<void, Ptr<Socket> > connectionFailed)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
    62
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    63
  m_connectionSucceeded = connectionSucceeded;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    64
  m_connectionFailed = connectionFailed;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    65
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    66
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    67
void 
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    68
Socket::SetCloseCallbacks (
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    69
  Callback<void, Ptr<Socket> > normalClose,
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    70
  Callback<void, Ptr<Socket> > errorClose)
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    71
{
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    72
  NS_LOG_FUNCTION_NOARGS ();
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    73
  m_normalClose = normalClose;
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    74
  m_errorClose = errorClose;
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    75
}
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    76
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
    77
void 
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    78
Socket::SetAcceptCallback (
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    79
  Callback<bool, Ptr<Socket>, const Address &> connectionRequest,
3276
8869a79a391f Changes for bug 205, unlisted FIN bug
Craig Dowell <craigdo@ee.washington.edu>
parents: 3269
diff changeset
    80
  Callback<void, Ptr<Socket>, const Address&> newConnectionCreated)
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    81
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
    82
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    83
  m_connectionRequest = connectionRequest;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    84
  m_newConnectionCreated = newConnectionCreated;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    85
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
    86
3774
0e11474a0b92 Apply patch to fix bug 363
Craig Dowell <craigdo@ee.washington.edu>
parents: 3772
diff changeset
    87
void
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    88
Socket::SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    89
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
    90
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    91
  m_dataSent = dataSent;
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    92
}
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    93
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    94
void
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    95
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb)
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    96
{
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    97
  NS_LOG_FUNCTION_NOARGS ();
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
    98
  m_sendCb = sendCb;
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
    99
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   100
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   101
void 
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   102
Socket::SetRecvCallback (Callback<void, Ptr<Socket> > receivedData)
3097
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   103
{
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   104
  NS_LOG_FUNCTION_NOARGS ();
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   105
  m_receivedData = receivedData;
3097
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   106
}
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   107
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   108
int 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   109
Socket::Send (Ptr<Packet> p)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   110
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   111
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   112
  return Send (p, 0);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   113
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   114
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   115
int 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   116
Socket::Send (const uint8_t* buf, uint32_t size, uint32_t flags)
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   117
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   118
  NS_LOG_FUNCTION_NOARGS ();
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   119
  Ptr<Packet> p;
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   120
  if (buf)
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   121
    {
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   122
      p = Create<Packet> (buf, size);
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   123
    }
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   124
  else
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   125
    {
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   126
      p = Create<Packet> (size);
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   127
    }
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   128
  return Send (p, flags);
3103
91c6fce46125 overloaded Recv() method suggested by Gustavo
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   129
}
91c6fce46125 overloaded Recv() method suggested by Gustavo
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   130
3142
1842b2f747f7 Receive raw buffer variant
Tom Henderson <tomh@tomh.org>
parents: 3139
diff changeset
   131
int 
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   132
Socket::SendTo (const uint8_t* buf, uint32_t size, uint32_t flags,
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   133
                const Address &toAddress)
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   134
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   135
  NS_LOG_FUNCTION_NOARGS ();
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   136
  Ptr<Packet> p;
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   137
  if(buf)
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   138
    {
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   139
      p = Create<Packet> (buf, size);
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   140
    }
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   141
  else
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   142
    {
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   143
      p = Create<Packet> (size);
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   144
    }
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   145
  return SendTo (p, flags, toAddress);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   146
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   147
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   148
Ptr<Packet>
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   149
Socket::Recv (void)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   150
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   151
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   152
  return Recv (std::numeric_limits<uint32_t>::max(), 0);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   153
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   154
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   155
int 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   156
Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   157
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   158
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   159
  Ptr<Packet> p = Recv (size, flags); // read up to "size" bytes
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   160
  if (p == 0)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   161
    {
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   162
      return 0;
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   163
    }
4517
3530045a96da CopyData is more efficient than a PeekData+memcpy pair
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4357
diff changeset
   164
  p->CopyData (buf, p->GetSize ());
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   165
  return p->GetSize ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   166
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   167
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   168
Ptr<Packet>
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   169
Socket::RecvFrom (Address &fromAddress)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   170
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   171
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   172
  return RecvFrom (std::numeric_limits<uint32_t>::max(), 0, fromAddress);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   173
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   174
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   175
int 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   176
Socket::RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   177
                  Address &fromAddress)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   178
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   179
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   180
  Ptr<Packet> p = RecvFrom (size, flags, fromAddress); 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   181
  if (p == 0)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   182
    {
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   183
      return 0;
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   184
    }
4517
3530045a96da CopyData is more efficient than a PeekData+memcpy pair
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4357
diff changeset
   185
  p->CopyData (buf, p->GetSize ());
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   186
  return p->GetSize ();
2186
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   187
}
69ad6ed6ccf4 Add uint8_t* based API for sockets
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 1866
diff changeset
   188
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   189
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   190
void 
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   191
Socket::NotifyConnectionSucceeded (void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   193
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   194
  if (!m_connectionSucceeded.IsNull ())
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   195
    {
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   196
      m_connectionSucceeded (this);
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   197
    }
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   199
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   200
void 
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   201
Socket::NotifyConnectionFailed (void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   203
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   204
  if (!m_connectionFailed.IsNull ())
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   205
    {
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   206
      m_connectionFailed (this);
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   207
    }
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   209
5377
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   210
void 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   211
Socket::NotifyNormalClose (void)
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   212
{
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   213
  NS_LOG_FUNCTION_NOARGS ();
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   214
  if (!m_normalClose.IsNull ())
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   215
    {
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   216
      m_normalClose (this);
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   217
    }
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   218
}
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   219
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   220
void 
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   221
Socket::NotifyErrorClose (void)
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   222
{
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   223
  NS_LOG_FUNCTION_NOARGS ();
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   224
  if (!m_errorClose.IsNull ())
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   225
    {
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   226
      m_errorClose (this);
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   227
    }
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   228
}
c54b36fb7317 TCP bug fixes 424, 426, 559, 663, 664, 697
Josh Pelkey <jpelkey@gatech.edu>
parents: 4517
diff changeset
   229
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   230
bool 
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   231
Socket::NotifyConnectionRequest (const Address &from)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   233
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   234
  if (!m_connectionRequest.IsNull ())
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   235
    {
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   236
      return m_connectionRequest (this, from);
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   237
    }
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   238
  else
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   239
    {
2367
904e5739f955 Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2224
diff changeset
   240
      // accept all incoming connections by default.
904e5739f955 Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2224
diff changeset
   241
      // this way people writing code don't have to do anything
904e5739f955 Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2224
diff changeset
   242
      // special like register a callback that returns true
904e5739f955 Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2224
diff changeset
   243
      // just to get incoming connections
904e5739f955 Undo changes to the packet sink to accept incoming connections; change the default behavior of the socket connection request notifier instead
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2224
diff changeset
   244
      return true;
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   245
    }
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   247
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
void 
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   249
Socket::NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from)
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   250
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   251
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   252
  if (!m_newConnectionCreated.IsNull ())
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   253
    {
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   254
      m_newConnectionCreated (socket, from);
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   255
    }
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   256
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   257
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   258
void 
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   259
Socket::NotifyDataSent (uint32_t size)
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   260
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2367
diff changeset
   261
  NS_LOG_FUNCTION_NOARGS ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   262
  if (!m_dataSent.IsNull ())
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   263
    {
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   264
      m_dataSent (this, size);
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   265
    }
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   266
}
1499
93d51d757afa working one way echo app
Craig Dowell <craigdo@ee.washington.edu>
parents: 1265
diff changeset
   267
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   268
void 
2999
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   269
Socket::NotifySend (uint32_t spaceAvailable)
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   270
{
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   271
  NS_LOG_FUNCTION_NOARGS ();
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   272
  if (!m_sendCb.IsNull ())
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   273
    {
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   274
      m_sendCb (this, spaceAvailable);
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   275
    }
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   276
}
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   277
0b10920623bf bug 131 partial fix: split out Send and DataSent callbacks
Tom Henderson <tomh@tomh.org>
parents: 2983
diff changeset
   278
void 
3097
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   279
Socket::NotifyDataRecv (void)
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   280
{
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   281
  NS_LOG_FUNCTION_NOARGS ();
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   282
  if (!m_receivedData.IsNull ())
3097
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   283
    {
3102
a225be367c1d more cleanup
Tom Henderson <tomh@tomh.org>
parents: 3100
diff changeset
   284
      m_receivedData (this);
3097
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   285
    }
1b1661bbfa33 Plumb in socket receive pull model, in parallel to existing Receive framework
Tom Henderson <tomh@tomh.org>
parents: 3000
diff changeset
   286
}
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   287
4357
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   288
void 
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   289
Socket::DoDispose (void)
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   290
{
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   291
  
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   292
  m_connectionSucceeded = MakeNullCallback<void,Ptr<Socket> > ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   293
  m_connectionFailed = MakeNullCallback<void,Ptr<Socket> > ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   294
  m_connectionRequest = MakeNullCallback<bool,Ptr<Socket>, const Address &> ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   295
  m_newConnectionCreated = MakeNullCallback<void,Ptr<Socket>, const Address &> ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   296
  m_dataSent = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   297
  m_sendCb = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   298
  m_receivedData = MakeNullCallback<void,Ptr<Socket> > ();
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   299
}
9c638ff9f732 actually reset callbacks in the socket's DoDispose method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3820
diff changeset
   300
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   301
void
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   302
Socket::BindToNetDevice (Ptr<NetDevice> netdevice)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   303
{
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   304
  if (netdevice != 0)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   305
    {
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   306
      bool found = false;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   307
      for (uint32_t i = 0; i < GetNode()->GetNDevices (); i++)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   308
        {
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   309
          if (GetNode()->GetDevice (i) == netdevice)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   310
            {
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   311
              found = true;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   312
              break;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   313
            }
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   314
        }
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   315
        NS_ASSERT_MSG (found, "Socket cannot be bound to a NetDevice not existing on the Node");
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   316
    }
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   317
  m_boundnetdevice = netdevice;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   318
  return;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   319
}
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   320
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   321
Ptr<NetDevice>
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   322
Socket::GetBoundNetDevice ()
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   323
{
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   324
  return m_boundnetdevice;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   325
}
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5720
diff changeset
   326
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   327
/***************************************************************
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   328
 *           Socket Tags
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   329
 ***************************************************************/
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   330
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   331
SocketAddressTag::SocketAddressTag ()  
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   332
{
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   333
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   334
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   335
void 
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   336
SocketAddressTag::SetAddress (Address addr)
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   337
{
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   338
  m_address = addr;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   339
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   340
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   341
Address 
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   342
SocketAddressTag::GetAddress (void) const
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   343
{
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   344
  return m_address;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   345
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   346
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   347
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   348
TypeId
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   349
SocketAddressTag::GetTypeId (void)
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   350
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   351
  static TypeId tid = TypeId ("ns3::SocketAddressTag")
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   352
    .SetParent<Tag> ()
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   353
    .AddConstructor<SocketAddressTag> ()
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   354
    ;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   355
  return tid;
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   356
}
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   357
TypeId
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   358
SocketAddressTag::GetInstanceTypeId (void) const
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   359
{
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   360
  return GetTypeId ();
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   361
}
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   362
uint32_t
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   363
SocketAddressTag::GetSerializedSize (void) const
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   364
{
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   365
  return m_address.GetSerializedSize ();
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   366
}
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   367
void
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   368
SocketAddressTag::Serialize (TagBuffer i) const
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   369
{
3167
644a220ad981 Fix off-by-2 errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3142
diff changeset
   370
  m_address.Serialize (i);
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   371
}
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   372
void
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   373
SocketAddressTag::Deserialize (TagBuffer i)
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   374
{
3167
644a220ad981 Fix off-by-2 errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3142
diff changeset
   375
  m_address.Deserialize (i);
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   376
}
3208
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   377
void
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   378
SocketAddressTag::Print (std::ostream &os) const
3208
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   379
{
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   380
  os << "address=" << m_address;
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   381
}
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   382
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   383
SocketIpTtlTag::SocketIpTtlTag ()  
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   384
{
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   385
}
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   386
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   387
void 
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   388
SocketIpTtlTag::SetTtl (uint8_t ttl)
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   389
{
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   390
  m_ttl = ttl;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   391
}
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   392
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   393
uint8_t 
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   394
SocketIpTtlTag::GetTtl (void) const
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   395
{
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   396
  return m_ttl;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   397
}
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   398
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   399
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   400
TypeId
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   401
SocketIpTtlTag::GetTypeId (void)
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   402
{
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   403
  static TypeId tid = TypeId ("ns3::SocketIpTtlTag")
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   404
    .SetParent<Tag> ()
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   405
    .AddConstructor<SocketIpTtlTag> ()
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   406
    ;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   407
  return tid;
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   408
}
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   409
TypeId
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   410
SocketIpTtlTag::GetInstanceTypeId (void) const
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   411
{
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   412
  return GetTypeId ();
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   413
}
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   414
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   415
uint32_t 
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   416
SocketIpTtlTag::GetSerializedSize (void) const
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   417
{ 
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   418
  return 1;
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   419
}
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   420
void 
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   421
SocketIpTtlTag::Serialize (TagBuffer i) const
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   422
{ 
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   423
  i.WriteU8 (m_ttl);
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   424
}
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   425
void 
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   426
SocketIpTtlTag::Deserialize (TagBuffer i)
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   427
{ 
3139
37deb9deaf0e Add tag serialize methods; add serialize routines to Address
Tom Henderson <tomh@tomh.org>
parents: 3138
diff changeset
   428
  m_ttl = i.ReadU8 ();
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   429
}
3208
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   430
void
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   431
SocketIpTtlTag::Print (std::ostream &os) const
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   432
{
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   433
  os << "Ttl=" << (uint32_t) m_ttl;
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3167
diff changeset
   434
}
3138
44711f06705e merge with ns-3-dev
Tom Henderson <tomh@tomh.org>
parents: 3127
diff changeset
   435
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3248
diff changeset
   436
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   437
SocketSetDontFragmentTag::SocketSetDontFragmentTag ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   438
{}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   439
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   440
SocketSetDontFragmentTag::Enable (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   441
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   442
  m_dontFragment = true;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   443
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   444
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   445
SocketSetDontFragmentTag::Disable (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   446
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   447
  m_dontFragment = false;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   448
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   449
bool 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   450
SocketSetDontFragmentTag::IsEnabled (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   451
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   452
  return m_dontFragment;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   453
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   454
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   455
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   456
SocketSetDontFragmentTag::GetTypeId (void)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   457
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   458
  static TypeId tid = TypeId ("ns3::SocketSetDontFragmentTag")
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   459
    .SetParent<Tag> ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   460
    .AddConstructor<SocketSetDontFragmentTag> ()
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   461
    ;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   462
  return tid;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   463
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   464
TypeId 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   465
SocketSetDontFragmentTag::GetInstanceTypeId (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   466
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   467
  return GetTypeId ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   468
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   469
uint32_t 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   470
SocketSetDontFragmentTag::GetSerializedSize (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   471
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   472
  return 1;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   473
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   474
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   475
SocketSetDontFragmentTag::Serialize (TagBuffer i) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   476
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   477
  i.WriteU8 (m_dontFragment?1:0);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   478
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   479
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   480
SocketSetDontFragmentTag::Deserialize (TagBuffer i)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   481
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   482
  m_dontFragment = (i.ReadU8 () == 1)?true:false;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   483
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   484
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   485
SocketSetDontFragmentTag::Print (std::ostream &os) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   486
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   487
  os << (m_dontFragment?"true":"false");
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   488
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3774
diff changeset
   489
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
}//namespace ns3