src/internet-stack/udp-socket-impl.cc
author Tom Henderson <tomh@tomh.org>
Wed, 08 Apr 2009 13:35:34 -0700
changeset 4372 d99061f1167c
parent 3956 0339a8ad5983
child 4375 db81fdcb06e7
permissions -rw-r--r--
Ipv4::ifIndex -> Ipv4::interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
    20
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
    21
#include "ns3/log.h"
729
b5e744285e92 rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
    22
#include "ns3/node.h"
1171
335886fe4ddd InetAddress -> InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1164
diff changeset
    23
#include "ns3/inet-socket-address.h"
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    24
#include "ns3/ipv4-route.h"
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    25
#include "ns3/ipv4.h"
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
    26
#include "ns3/udp-socket-factory.h"
3117
c8160bbb2085 Add SocketDefaults to store socket option attributes
Tom Henderson <tomh@tomh.org>
parents: 3113
diff changeset
    27
#include "ns3/trace-source-accessor.h"
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    28
#include "udp-socket-impl.h"
741
38ebb2fb16f5 udp.h -> udp-l4-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 729
diff changeset
    29
#include "udp-l4-protocol.h"
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    30
#include "ipv4-end-point.h"
3718
f22f8ab3f6f5 fix build with gcc 4.3.0
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3588
diff changeset
    31
#include <limits>
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    33
NS_LOG_COMPONENT_DEFINE ("UdpSocketImpl");
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
namespace ns3 {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
    37
static const uint32_t MAX_IPV4_UDP_DATAGRAM_SIZE = 65507;
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
    38
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
    39
// Add attributes generic to all UdpSockets to base class UdpSocket
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    40
TypeId
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    41
UdpSocketImpl::GetTypeId (void)
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    42
{
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    43
  static TypeId tid = TypeId ("ns3::UdpSocketImpl")
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    44
    .SetParent<UdpSocket> ()
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    45
    .AddConstructor<UdpSocketImpl> ()
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    46
    .AddTraceSource ("Drop", "Drop UDP packet due to receive buffer overflow",
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    47
                     MakeTraceSourceAccessor (&UdpSocketImpl::m_dropTrace))
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
    48
    .AddAttribute ("IcmpCallback", "Callback invoked whenever an icmp error is received on this socket.",
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
    49
                   CallbackValue (),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
    50
                   MakeCallbackAccessor (&UdpSocketImpl::m_icmpCallback),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
    51
                   MakeCallbackChecker ())
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    52
    ;
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    53
  return tid;
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    54
}
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    55
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    56
UdpSocketImpl::UdpSocketImpl ()
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
  : m_endPoint (0),
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    58
    m_node (0),
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    59
    m_udp (0),
646
f7475a7c5ae6 Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 607
diff changeset
    60
    m_errno (ERROR_NOTERROR),
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
    m_shutdownSend (false),
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
    m_shutdownRecv (false),
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
    63
    m_connected (false),
3123
fae57a467d54 undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents: 3122
diff changeset
    64
    m_rxAvailable (0)
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
    65
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    66
  NS_LOG_FUNCTION_NOARGS ();
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
    67
}
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
    68
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    69
UdpSocketImpl::~UdpSocketImpl ()
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    71
  NS_LOG_FUNCTION_NOARGS ();
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
    72
557
927a5bb6432a convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    73
  m_node = 0;
515
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    74
  if (m_endPoint != 0)
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    75
    {
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    76
      NS_ASSERT (m_udp != 0);
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    77
      /**
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    78
       * Note that this piece of code is a bit tricky:
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    79
       * when DeAllocate is called, it will call into
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    80
       * Ipv4EndPointDemux::Deallocate which triggers
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    81
       * a delete of the associated endPoint which triggers
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    82
       * in turn a call to the method ::Destroy below
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    83
       * will will zero the m_endPoint field.
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    84
       */
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    85
      NS_ASSERT (m_endPoint != 0);
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    86
      m_udp->DeAllocate (m_endPoint);
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    87
      NS_ASSERT (m_endPoint == 0);
e907146a191e fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 503
diff changeset
    88
    }
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 557
diff changeset
    89
  m_udp = 0;
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    92
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    93
UdpSocketImpl::SetNode (Ptr<Node> node)
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    94
{
3113
e6740c0582bf tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
    95
  NS_LOG_FUNCTION_NOARGS ();
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    96
  m_node = node;
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
    97
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    98
}
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
    99
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   100
UdpSocketImpl::SetUdp (Ptr<UdpL4Protocol> udp)
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
   101
{
3113
e6740c0582bf tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   102
  NS_LOG_FUNCTION_NOARGS ();
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
   103
  m_udp = udp;
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
   104
}
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
   105
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2574
diff changeset
   106
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   107
enum Socket::SocketErrno
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   108
UdpSocketImpl::GetErrno (void) const
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   109
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   110
  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
   111
  return m_errno;
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   112
}
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   113
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 646
diff changeset
   114
Ptr<Node>
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   115
UdpSocketImpl::GetNode (void) const
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   117
  NS_LOG_FUNCTION_NOARGS ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
  return m_node;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   121
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   122
UdpSocketImpl::Destroy (void)
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   123
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   124
  NS_LOG_FUNCTION_NOARGS ();
557
927a5bb6432a convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
   125
  m_node = 0;
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   126
  m_endPoint = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 557
diff changeset
   127
  m_udp = 0;
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   128
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   129
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   130
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   131
UdpSocketImpl::FinishBind (void)
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   132
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   133
  NS_LOG_FUNCTION_NOARGS ();
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   134
  if (m_endPoint == 0)
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   135
    {
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   136
      return -1;
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   137
    }
3157
de8e4b4c662f Bug #154: Attach sockets to nodes. Patch by Rajib Bhattacharjea.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   138
  m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   139
  m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
3157
de8e4b4c662f Bug #154: Attach sockets to nodes. Patch by Rajib Bhattacharjea.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   140
  m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   141
  return 0;
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   142
}
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   143
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   145
UdpSocketImpl::Bind (void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   147
  NS_LOG_FUNCTION_NOARGS ();
499
8a469663f7ea implement properly the refcounting rules for the capability getters
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 496
diff changeset
   148
  m_endPoint = m_udp->Allocate ();
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   149
  return FinishBind ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   151
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
int 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   153
UdpSocketImpl::Bind (const Address &address)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   155
  NS_LOG_FUNCTION (this << address);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   156
1172
2e5b994330c7 add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1171
diff changeset
   157
  if (!InetSocketAddress::IsMatchingType (address))
2e5b994330c7 add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1171
diff changeset
   158
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
   159
      NS_LOG_ERROR ("Not IsMatchingType");
3846
265004d6dc15 apply patch for bug 390 (SocketImpl::Bind returns something other than -1)
raj.b@gatech.edu
parents: 3820
diff changeset
   160
      m_errno = ERROR_INVAL;
265004d6dc15 apply patch for bug 390 (SocketImpl::Bind returns something other than -1)
raj.b@gatech.edu
parents: 3820
diff changeset
   161
      return -1;
1172
2e5b994330c7 add InetSocketAddress::IsMatchingType and use it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1171
diff changeset
   162
    }
1207
a9f3610bbffa remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1204
diff changeset
   163
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   164
  Ipv4Address ipv4 = transport.GetIpv4 ();
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   165
  uint16_t port = transport.GetPort ();
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   166
  if (ipv4 == Ipv4Address::GetAny () && port == 0)
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   167
    {
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   168
      m_endPoint = m_udp->Allocate ();
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   169
    }
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   170
  else if (ipv4 == Ipv4Address::GetAny () && port != 0)
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   171
    {
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   172
      m_endPoint = m_udp->Allocate (port);
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   173
    }
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   174
  else if (ipv4 != Ipv4Address::GetAny () && port == 0)
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   175
    {
2608
408589d1dfff merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   176
      m_endPoint = m_udp->Allocate (ipv4);
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   177
    }
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   178
  else if (ipv4 != Ipv4Address::GetAny () && port != 0)
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   179
    {
2608
408589d1dfff merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   180
      m_endPoint = m_udp->Allocate (ipv4, port);
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   181
    }
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   182
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
   183
  return FinishBind ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
int 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   187
UdpSocketImpl::ShutdownSend (void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   189
  NS_LOG_FUNCTION_NOARGS ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
  m_shutdownSend = true;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
  return 0;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   193
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
int 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   195
UdpSocketImpl::ShutdownRecv (void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   197
  NS_LOG_FUNCTION_NOARGS ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
  m_shutdownRecv = false;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
  return 0;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1182
diff changeset
   202
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   203
UdpSocketImpl::Close(void)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   205
  NS_LOG_FUNCTION_NOARGS ();
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1182
diff changeset
   206
  return 0;
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
}
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   208
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1182
diff changeset
   209
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   210
UdpSocketImpl::Connect(const Address & address)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   212
  NS_LOG_FUNCTION (this << address);
1207
a9f3610bbffa remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1204
diff changeset
   213
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   214
  m_defaultAddress = transport.GetIpv4 ();
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   215
  m_defaultPort = transport.GetPort ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   216
  NotifyConnectionSucceeded ();
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
  m_connected = true;
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1429
diff changeset
   218
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1182
diff changeset
   219
  return 0;
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
}
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   221
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
int 
3772
f0d8608ab155 Remove queue limit from listen
Craig Dowell <craigdo@ee.washington.edu>
parents: 3718
diff changeset
   223
UdpSocketImpl::Listen (void)
3213
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   224
{
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   225
  m_errno = Socket::ERROR_OPNOTSUPP;
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   226
  return -1;
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   227
}
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   228
08a0424399fb bug 203: Listen must be implemented for Udp and Packet sockets.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3157
diff changeset
   229
int 
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   230
UdpSocketImpl::Send (Ptr<Packet> p, uint32_t flags)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   232
  NS_LOG_FUNCTION (this << p << flags);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   233
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
  if (!m_connected)
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
    {
646
f7475a7c5ae6 Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 607
diff changeset
   236
      m_errno = ERROR_NOTCONN;
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
      return -1;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
    }
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   239
  return DoSend (p);
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
}
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   241
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   242
int 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   243
UdpSocketImpl::DoSend (Ptr<Packet> p)
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   244
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   245
  NS_LOG_FUNCTION (this << p);
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   246
  if (m_endPoint == 0)
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   247
    {
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   248
      if (Bind () == -1)
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   249
       {
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   250
          NS_ASSERT (m_endPoint == 0);
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   251
         return -1;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   252
       }
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   253
      NS_ASSERT (m_endPoint != 0);
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   254
    }
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   255
  if (m_shutdownSend)
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   256
    {
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   257
      m_errno = ERROR_SHUTDOWN;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   258
      return -1;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   259
    } 
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   260
  
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   261
  return DoSendTo (p, m_defaultAddress, m_defaultPort);
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   262
}
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   263
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   265
UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   266
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   267
  NS_LOG_FUNCTION (this << p << address);
1449
df86e6b876ef merge with trunk
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440 1318
diff changeset
   268
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   269
  if (!m_connected)
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   270
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
   271
      NS_LOG_LOGIC ("Not connected");
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   272
      InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   273
      Ipv4Address ipv4 = transport.GetIpv4 ();
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   274
      uint16_t port = transport.GetPort ();
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   275
      return DoSendTo (p, ipv4, port);
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   276
    }
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   277
  else
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   278
    {
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   279
      // connected UDP socket must use default addresses
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
   280
      NS_LOG_LOGIC ("Connected");
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   281
      return DoSendTo (p, m_defaultAddress, m_defaultPort);
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   282
    }
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   283
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   284
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   285
int
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   286
UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   287
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   288
  NS_LOG_FUNCTION (this << p << dest << port);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   289
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   290
  if (m_endPoint == 0)
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   291
    {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   292
      if (Bind () == -1)
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   293
	{
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
          NS_ASSERT (m_endPoint == 0);
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   295
	  return -1;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   296
	}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   297
      NS_ASSERT (m_endPoint != 0);
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
    }
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   299
  if (m_shutdownSend)
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   300
    {
646
f7475a7c5ae6 Rename the SocketErrno enumeration values, from ESOMETHING to ERROR_SOMETHING, to avoid conflict with errno #define's; fixes compilation in mingw32.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 607
diff changeset
   301
      m_errno = ERROR_SHUTDOWN;
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   302
      return -1;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   303
    }
1452
973c456d3684 socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents: 1450
diff changeset
   304
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   305
  if (p->GetSize () > GetTxAvailable () )
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   306
    {
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   307
      m_errno = ERROR_MSGSIZE;
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   308
      return -1;
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   309
    }
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   310
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 3956
diff changeset
   311
  uint32_t localInterface;
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
   312
  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
1452
973c456d3684 socket update broke multicast
Craig Dowell <craigdo@ee.washington.edu>
parents: 1450
diff changeset
   313
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   314
  // Locally override the IP TTL for this socket
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   315
  // We cannot directly modify the TTL at this stage, so we set a Packet tag
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   316
  // The destination can be either multicast, unicast/anycast, or
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   317
  // either all-hosts broadcast or limited (subnet-directed) broadcast.
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   318
  // For the latter two broadcast types, the TTL will later be set to one
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   319
  // irrespective of what is set in these socket options.  So, this tagging  
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   320
  // may end up setting the TTL of a limited broadcast packet to be
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   321
  // the same as a unicast, but it will be fixed further down the stack
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   322
  //NS_LOG_UNCOND ("IPttl: " << m_ipTtl);
3124
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   323
  if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   324
    {
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   325
      SocketIpTtlTag tag;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   326
      tag.SetTtl (m_ipMulticastTtl);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   327
      p->AddTag (tag);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   328
    }
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   329
  else if (m_ipTtl != 0 && !dest.IsMulticast () && !dest.IsBroadcast ())
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   330
    {
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   331
      SocketIpTtlTag tag;
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   332
      tag.SetTtl (m_ipTtl);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   333
      p->AddTag (tag);
473e59b5e141 Implement IPTTL socket option for UDP
Tom Henderson <tomh@tomh.org>
parents: 3123
diff changeset
   334
    }
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   335
  {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   336
    SocketSetDontFragmentTag tag;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   337
    bool found = p->FindFirstMatchingTag (tag);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   338
    if (!found)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   339
      {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   340
        if (m_mtuDiscover)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   341
          {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   342
            tag.Enable ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   343
          }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   344
        else
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   345
          {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   346
            tag.Disable ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   347
          }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   348
        p->AddTag (tag);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   349
      }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   350
  }
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   351
  //
3956
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   352
  // If dest is set to the limited broadcast address (all ones),
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   353
  // convert it to send a copy of the packet out of every 
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   354
  // interface as a subnet-directed broadcast.
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   355
  // Exception:  if the interface has a /32 address, there is no
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   356
  // valid subnet-directed broadcast, so send it as limited broadcast
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   357
  // Note also that some systems will only send limited broadcast packets
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   358
  // out of the "default" interface; here we send it out all interfaces
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   359
  //
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   360
  if (dest.IsBroadcast ())
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   361
    {
2299
0b9193f38f18 Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   362
      NS_LOG_LOGIC ("Limited broadcast start.");
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   363
      for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++ )
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   364
        {
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   365
          Ipv4Address addri = ipv4->GetAddress (i);
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   366
          Ipv4Mask maski = ipv4->GetNetworkMask (i);
3956
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   367
          if (maski == Ipv4Mask::GetOnes ())
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   368
            {
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   369
              // if the network mask is 255.255.255.255, do not convert dest
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   370
              NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << dest
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   371
                            << " (mask is " << maski << ")");
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   372
              m_udp->Send (p->Copy (), addri, dest,
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   373
                           m_endPoint->GetLocalPort (), port);
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   374
              NotifyDataSent (p->GetSize ());
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   375
              NotifySend (GetTxAvailable ());
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   376
            }
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   377
          else
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   378
            {
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   379
              // Convert to subnet-directed broadcast
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   380
              Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski);
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   381
              NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   382
                            << " (mask is " << maski << ")");
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   383
              m_udp->Send (p->Copy (), addri, bcast,
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   384
                           m_endPoint->GetLocalPort (), port);
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   385
              NotifyDataSent (p->GetSize ());
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   386
              NotifySend (GetTxAvailable ());
0339a8ad5983 Bug 400: allow /32 addresses to be used on IPv4 interfaces
Tom Henderson <tomh@tomh.org>
parents: 3846
diff changeset
   387
            }
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   388
        }
2299
0b9193f38f18 Some more udp socket debug messages
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   389
      NS_LOG_LOGIC ("Limited broadcast end.");
2912
843e6218834f Fix bug 168: Socket::SendTo does not return the number of bytes sent for udp sockets.
Liu Jian <liujatp@gmail.com>
parents: 2834
diff changeset
   390
      return p->GetSize();
1318
89b78e2d521e Fix for bug69: set local address correctly upon UDP connect; apply correct UDP connect() semantics (that sendto cannot override addresses on a connected socket); if destination is IPv4 limited broadcast address, convert to subnet-directed broadcast and send out on each interface; provide example csma-broadcast.cc script
Tom Henderson <tomh@tomh.org>
parents: 1317
diff changeset
   391
    }
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 3956
diff changeset
   392
  else if (ipv4->GetInterfaceForDestination(dest, localInterface))
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   393
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
   394
      NS_LOG_LOGIC ("Route exists");
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 3956
diff changeset
   395
      m_udp->Send (p->Copy (), ipv4->GetAddress (localInterface), dest,
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   396
		   m_endPoint->GetLocalPort (), port);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   397
      NotifyDataSent (p->GetSize ());
3776
362d7e1c12a6 Apply patch to fix bug 364
Craig Dowell <craigdo@ee.washington.edu>
parents: 3772
diff changeset
   398
      NotifySend (GetTxAvailable ());
2912
843e6218834f Fix bug 168: Socket::SendTo does not return the number of bytes sent for udp sockets.
Liu Jian <liujatp@gmail.com>
parents: 2834
diff changeset
   399
      return p->GetSize();;
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   400
    }
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   401
  else
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   402
   {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1452
diff changeset
   403
      NS_LOG_ERROR ("ERROR_NOROUTETOHOST");
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   404
      m_errno = ERROR_NOROUTETOHOST;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   405
      return -1;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   406
   }
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   407
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   408
  return 0;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   409
}
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
   410
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   411
// XXX maximum message size for UDP broadcast is limited by MTU
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   412
// size of underlying link; we are not checking that now.
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   413
uint32_t
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   414
UdpSocketImpl::GetTxAvailable (void) const
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   415
{
3113
e6740c0582bf tweak UdpSocket buffer limit behavior
Tom Henderson <tomh@tomh.org>
parents: 3107
diff changeset
   416
  NS_LOG_FUNCTION_NOARGS ();
3122
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   417
  // No finite send buffer is modelled, but we must respect
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   418
  // the maximum size of an IP datagram (65535 bytes - headers).
dfa83ab5172d improve send semantics, documentation
Tom Henderson <tomh@tomh.org>
parents: 3120
diff changeset
   419
  return MAX_IPV4_UDP_DATAGRAM_SIZE;
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   420
}
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   421
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   422
int 
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   423
UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   424
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   425
  NS_LOG_FUNCTION (this << p << flags << address);
1207
a9f3610bbffa remove implicit conversion from Address to Eui48Address, to Ipv4Address and to InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1204
diff changeset
   426
  InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
1162
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   427
  Ipv4Address ipv4 = transport.GetIpv4 ();
10f9613bd9be convert Socket to use Address class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 742
diff changeset
   428
  uint16_t port = transport.GetPort ();
1264
577875bb5a65 split callback registration from socket operations in socket.h API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1186
diff changeset
   429
  return DoSendTo (p, ipv4, port);
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   430
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   431
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   432
uint32_t
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   433
UdpSocketImpl::GetRxAvailable (void) const
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   434
{
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   435
  NS_LOG_FUNCTION_NOARGS ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   436
  // We separately maintain this state to avoid walking the queue 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   437
  // every time this might be called
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   438
  return m_rxAvailable;
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   439
}
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   440
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   441
Ptr<Packet>
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   442
UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags)
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   443
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   444
  NS_LOG_FUNCTION (this << maxSize << flags);
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   445
  if (m_deliveryQueue.empty() )
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   446
    {
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   447
      m_errno = ERROR_AGAIN;
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   448
      return 0;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   449
    }
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   450
  Ptr<Packet> p = m_deliveryQueue.front ();
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   451
  if (p->GetSize () <= maxSize) 
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   452
    {
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   453
      m_deliveryQueue.pop ();
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   454
      m_rxAvailable -= p->GetSize ();
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   455
    }
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   456
  else
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   457
    {
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   458
      p = 0; 
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   459
    }
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   460
  return p;
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   461
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   462
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   463
Ptr<Packet>
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   464
UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, 
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   465
  Address &fromAddress)
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   466
{
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   467
  NS_LOG_FUNCTION (this << maxSize << flags);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   468
  Ptr<Packet> packet = Recv (maxSize, flags);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   469
  if (packet != 0)
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   470
    {
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   471
      SocketAddressTag tag;
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   472
      bool found;
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   473
      found = packet->FindFirstMatchingTag (tag);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   474
      NS_ASSERT (found);
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   475
      fromAddress = tag.GetAddress ();
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   476
    }
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   477
  return packet;
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   478
}
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   479
3778
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   480
int
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   481
UdpSocketImpl::GetSockName (Address &address) const
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   482
{
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   483
  NS_LOG_FUNCTION_NOARGS ();
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   484
  if (m_endPoint != 0)
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   485
    {
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   486
      address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort());
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   487
    }
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   488
  else
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   489
    {
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   490
      address = InetSocketAddress(Ipv4Address::GetZero(), 0);
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   491
    }
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   492
  return 0;
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   493
}
78c4c41557f3 Liu's GetSockName patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3776
diff changeset
   494
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   495
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   496
UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port)
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   497
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   498
  NS_LOG_FUNCTION (this << packet << ipv4 << port);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   499
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   500
  if (m_shutdownRecv)
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   501
    {
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   502
      return;
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   503
    }
3123
fae57a467d54 undo SocketDefaults class; plumb in new UdpSocket option attributes
Tom Henderson <tomh@tomh.org>
parents: 3122
diff changeset
   504
  if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   505
    {
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   506
      Address address = InetSocketAddress (ipv4, port);
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   507
      SocketAddressTag tag;
3105
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   508
      tag.SetAddress (address);
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   509
      packet->AddTag (tag);
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   510
      m_deliveryQueue.push (packet);
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   511
      m_rxAvailable += packet->GetSize ();
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   512
      NotifyDataRecv ();
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   513
    }
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   514
  else
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   515
    {
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   516
      // In general, this case should not occur unless the
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   517
      // receiving application reads data from this socket slowly
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   518
      // in comparison to the arrival rate
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   519
      //
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   520
      // drop and trace packet
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   521
      NS_LOG_WARN ("No receive buffer space available.  Drop.");
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   522
      m_dropTrace (packet);
682950a37ea6 Add GetTxBuffer; add some socket options; make limited UDP receive buffer functional
Tom Henderson <tomh@tomh.org>
parents: 3104
diff changeset
   523
    }
453
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   524
}
ddbb935800d8 remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   525
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   526
void
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   527
UdpSocketImpl::ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   528
                            uint8_t icmpType, uint8_t icmpCode,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   529
                            uint32_t icmpInfo)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   530
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   531
  NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType <<
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   532
                   (uint32_t)icmpCode << icmpInfo);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   533
  if (!m_icmpCallback.IsNull ())
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   534
    {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   535
      m_icmpCallback (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   536
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   537
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   538
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   539
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   540
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   541
UdpSocketImpl::SetRcvBufSize (uint32_t size)
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   542
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   543
  m_rcvBufSize = size;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   544
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   545
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   546
uint32_t 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   547
UdpSocketImpl::GetRcvBufSize (void) const
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   548
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   549
  return m_rcvBufSize;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   550
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   551
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   552
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   553
UdpSocketImpl::SetIpTtl (uint32_t ipTtl)
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   554
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   555
  m_ipTtl = ipTtl;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   556
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   557
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   558
uint32_t 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   559
UdpSocketImpl::GetIpTtl (void) const
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   560
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   561
  return m_ipTtl;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   562
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   563
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   564
void 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   565
UdpSocketImpl::SetIpMulticastTtl (uint32_t ipTtl)
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   566
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   567
  m_ipMulticastTtl = ipTtl;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   568
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   569
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   570
uint32_t 
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   571
UdpSocketImpl::GetIpMulticastTtl (void) const
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   572
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   573
  return m_ipMulticastTtl;
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   574
}
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   575
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   576
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   577
UdpSocketImpl::SetMtuDiscover (bool discover)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   578
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   579
  m_mtuDiscover = discover;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   580
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   581
bool 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   582
UdpSocketImpl::GetMtuDiscover (void) const
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   583
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   584
  return m_mtuDiscover;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   585
}
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   586
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3778
diff changeset
   587
1435
a70de165a25a set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents: 1434
diff changeset
   588
} //namespace ns3
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   589
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   590
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   591
#ifdef RUN_SELF_TESTS
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   592
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   593
#include "ns3/test.h"
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   594
#include "ns3/socket-factory.h"
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
   595
#include "ns3/udp-socket-factory.h"
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   596
#include "ns3/simulator.h"
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   597
#include "ns3/simple-channel.h"
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   598
#include "ns3/simple-net-device.h"
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   599
#include "ns3/drop-tail-queue.h"
2828
2344451f63c9 do not use InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2674
diff changeset
   600
#include "internet-stack.h"
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   601
#include <string>
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   602
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   603
namespace ns3 {
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   604
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   605
class UdpSocketImplTest: public Test
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   606
{
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   607
  Ptr<Packet> m_receivedPacket;
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   608
  Ptr<Packet> m_receivedPacket2;
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   609
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   610
public:
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   611
  virtual bool RunTests (void);
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   612
  UdpSocketImplTest ();
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   613
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   614
  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   615
  void ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from);
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   616
  void ReceivePkt (Ptr<Socket> socket);
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   617
  void ReceivePkt2 (Ptr<Socket> socket);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   618
};
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   619
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   620
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   621
UdpSocketImplTest::UdpSocketImplTest ()
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   622
  : Test ("UdpSocketImpl") 
3127
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   623
{
f5971b43ee58 Add attributes to new abstract base class for UdpSocket
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
   624
}
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   625
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   626
void UdpSocketImplTest::ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from)
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   627
{
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   628
  m_receivedPacket = packet;
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   629
}
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   630
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   631
void UdpSocketImplTest::ReceivePacket2 (Ptr<Socket> socket, Ptr<Packet> packet, const Address &from)
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   632
{
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   633
  m_receivedPacket2 = packet;
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   634
}
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   635
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   636
void UdpSocketImplTest::ReceivePkt (Ptr<Socket> socket)
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   637
{
3145
16dd98873ec3 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 3130
diff changeset
   638
  uint32_t availableData;
16dd98873ec3 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 3130
diff changeset
   639
  availableData = socket->GetRxAvailable ();
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   640
  m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max(), 0);
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   641
  NS_ASSERT (availableData == m_receivedPacket->GetSize ());
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   642
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   643
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   644
void UdpSocketImplTest::ReceivePkt2 (Ptr<Socket> socket)
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   645
{
3145
16dd98873ec3 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 3130
diff changeset
   646
  uint32_t availableData;
16dd98873ec3 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 3130
diff changeset
   647
  availableData = socket->GetRxAvailable ();
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   648
  m_receivedPacket2 = socket->Recv (std::numeric_limits<uint32_t>::max(), 0);
3104
24d9d9aa0977 Implement GetRxAvailable ()
Tom Henderson <tomh@tomh.org>
parents: 3102
diff changeset
   649
  NS_ASSERT (availableData == m_receivedPacket2->GetSize ());
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   650
}
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   651
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   652
bool
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   653
UdpSocketImplTest::RunTests (void)
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   654
{
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   655
  bool result = true;
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   656
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   657
  // Create topology
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   658
  
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   659
  // Receiver Node
2828
2344451f63c9 do not use InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2674
diff changeset
   660
  Ptr<Node> rxNode = CreateObject<Node> ();
2344451f63c9 do not use InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2674
diff changeset
   661
  AddInternetStack (rxNode);
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   662
  Ptr<SimpleNetDevice> rxDev1, rxDev2;
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   663
  { // first interface
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   664
    rxDev1 = CreateObject<SimpleNetDevice> ();
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   665
    rxDev1->SetAddress (Mac48Address::Allocate ());
2503
e667dc0f350e merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2326 2501
diff changeset
   666
    rxNode->AddDevice (rxDev1);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   667
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   668
    uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   669
    ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.1"));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   670
    ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   671
    ipv4->SetUp (netdev_idx);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   672
  }
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   673
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   674
  { // second interface
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   675
    rxDev2 = CreateObject<SimpleNetDevice> ();
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2608
diff changeset
   676
    rxDev2->SetAddress (Mac48Address::Allocate ());
2503
e667dc0f350e merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2326 2501
diff changeset
   677
    rxNode->AddDevice (rxDev2);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   678
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   679
    uint32_t netdev_idx = ipv4->AddInterface (rxDev2);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   680
    ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.1.1"));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   681
    ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   682
    ipv4->SetUp (netdev_idx);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   683
  }
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   684
  
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   685
  // Sender Node
2828
2344451f63c9 do not use InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2674
diff changeset
   686
  Ptr<Node> txNode = CreateObject<Node> ();
2344451f63c9 do not use InternetNode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2674
diff changeset
   687
  AddInternetStack (txNode);
2674
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   688
  Ptr<SimpleNetDevice> txDev1;
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   689
  {
2674
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   690
    txDev1 = CreateObject<SimpleNetDevice> ();
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   691
    txDev1->SetAddress (Mac48Address::Allocate ());
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   692
    txNode->AddDevice (txDev1);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   693
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
2674
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   694
    uint32_t netdev_idx = ipv4->AddInterface (txDev1);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   695
    ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.0.2"));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   696
    ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   697
    ipv4->SetUp (netdev_idx);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   698
  }
2674
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   699
  Ptr<SimpleNetDevice> txDev2;
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   700
  {
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   701
    txDev2 = CreateObject<SimpleNetDevice> ();
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   702
    txDev2->SetAddress (Mac48Address::Allocate ());
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   703
    txNode->AddDevice (txDev2);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   704
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   705
    uint32_t netdev_idx = ipv4->AddInterface (txDev2);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   706
    ipv4->SetAddress (netdev_idx, Ipv4Address ("10.0.1.2"));
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   707
    ipv4->SetNetworkMask (netdev_idx, Ipv4Mask (0xffff0000U));
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   708
    ipv4->SetUp (netdev_idx);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   709
  }
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   710
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   711
  // link the two nodes
2674
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   712
  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   713
  rxDev1->SetChannel (channel1);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   714
  txDev1->SetChannel (channel1);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   715
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   716
  Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel> ();
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   717
  rxDev2->SetChannel (channel2);
41f943501ae7 Fix the udp socket unit test problem discovered by Mathieu.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2673
diff changeset
   718
  txDev2->SetChannel (channel2);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   719
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   720
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   721
  // Create the UDP sockets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
   722
  Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory> ();
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1520
diff changeset
   723
  Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket ();
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   724
  NS_TEST_ASSERT_EQUAL (rxSocket->Bind (InetSocketAddress (Ipv4Address ("10.0.0.1"), 1234)), 0);
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   725
  rxSocket->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt, this));
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   726
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   727
  Ptr<Socket> rxSocket2 = rxSocketFactory->CreateSocket ();
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   728
  rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt2, this));
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   729
  NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("10.0.1.1"), 1234)), 0);
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   730
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3124
diff changeset
   731
  Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory> ();
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1520
diff changeset
   732
  Ptr<Socket> txSocket = txSocketFactory->CreateSocket ();
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   733
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   734
  // ------ Now the tests ------------
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   735
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   736
  // Unicast test
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   737
  m_receivedPacket = Create<Packet> ();
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   738
  m_receivedPacket2 = Create<Packet> ();
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   739
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 0, 
3120
774b2637845e swap SendTo parameters
Tom Henderson <tomh@tomh.org>
parents: 3117
diff changeset
   740
    InetSocketAddress (Ipv4Address("10.0.0.1"), 1234)), 123);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   741
  Simulator::Run ();
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   742
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   743
  NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0); // second interface should receive it
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   744
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   745
  m_receivedPacket->RemoveAllTags ();
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   746
  m_receivedPacket2->RemoveAllTags ();
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   747
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   748
  // Simple broadcast test
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   749
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   750
  m_receivedPacket = Create<Packet> ();
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   751
  m_receivedPacket2 = Create<Packet> ();
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   752
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo ( Create<Packet> (123), 0, 
3120
774b2637845e swap SendTo parameters
Tom Henderson <tomh@tomh.org>
parents: 3117
diff changeset
   753
    InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   754
  Simulator::Run ();
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   755
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   756
  // second socket should not receive it (it is bound specifically to the second interface's address
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   757
  NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 0);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   758
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   759
  m_receivedPacket->RemoveAllTags ();
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   760
  m_receivedPacket2->RemoveAllTags ();
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   761
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   762
  // Broadcast test with multiple receiving sockets
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   763
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   764
  // When receiving broadcast packets, all sockets sockets bound to
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   765
  // the address/port should receive a copy of the same packet -- if
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   766
  // the socket address matches.
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   767
  rxSocket2->Dispose ();
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2305
diff changeset
   768
  rxSocket2 = rxSocketFactory->CreateSocket ();
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   769
  rxSocket2->SetRecvCallback (MakeCallback (&UdpSocketImplTest::ReceivePkt2, this));
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1520
diff changeset
   770
  NS_TEST_ASSERT_EQUAL (rxSocket2->Bind (InetSocketAddress (Ipv4Address ("0.0.0.0"), 1234)), 0);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   771
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   772
  m_receivedPacket = Create<Packet> ();
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   773
  m_receivedPacket2 = Create<Packet> ();
3269
448134601b03 RecvFrom() expansion, add flags parameter to some Send calls
Tom Henderson <tomh@tomh.org>
parents: 3213
diff changeset
   774
  NS_TEST_ASSERT_EQUAL (txSocket->SendTo (Create<Packet> (123), 0,
3120
774b2637845e swap SendTo parameters
Tom Henderson <tomh@tomh.org>
parents: 3117
diff changeset
   775
InetSocketAddress (Ipv4Address("255.255.255.255"), 1234)), 123);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   776
  Simulator::Run ();
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   777
  NS_TEST_ASSERT_EQUAL (m_receivedPacket->GetSize (), 123);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   778
  NS_TEST_ASSERT_EQUAL (m_receivedPacket2->GetSize (), 123);
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   779
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   780
  m_receivedPacket->RemoveAllTags ();
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   781
  m_receivedPacket2->RemoveAllTags ();
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 3097
diff changeset
   782
1704
41c3142f4293 add missing call to Simulator::Destroy to cleanup after test
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   783
  Simulator::Destroy ();
41c3142f4293 add missing call to Simulator::Destroy to cleanup after test
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   784
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   785
  return result;
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   786
}
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   787
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
   788
static UdpSocketImplTest gUdpSocketImplTest;
1519
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   789
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   790
}; // namespace ns3
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   791
9b1cbc4c63f8 Add a couple of Udp socket unit tests: unicast (passing) and broadcast (failing, bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1511
diff changeset
   792
#endif /* RUN_SELF_TESTS */