src/node/udp-socket.cc
author Craig Dowell <craigdo@ee.washington.edu>
Wed, 29 Oct 2008 11:18:39 -0700
changeset 3820 c04ecfdce1ef
parent 3130 881cc06cd651
child 4472 e20a31541404
permissions -rw-r--r--
apply icmp patch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2007 INRIA
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * GNU General Public License for more details.
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 *
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 */
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
#include "ns3/object.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
#include "ns3/log.h"
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
#include "ns3/uinteger.h"
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    24
#include "ns3/boolean.h"
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
#include "ns3/trace-source-accessor.h"
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    26
#include "udp-socket.h"
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("UdpSocket");
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
namespace ns3 {
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    32
NS_OBJECT_ENSURE_REGISTERED (UdpSocket);
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
TypeId
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    35
UdpSocket::GetTypeId (void)
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
{
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    37
  static TypeId tid = TypeId ("ns3::UdpSocket")
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
    .SetParent<Socket> ()
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
    .AddAttribute ("RcvBufSize",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
                   "UdpSocket maximum receive buffer size (bytes)",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
                   UintegerValue (0xffffffffl),
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    42
                   MakeUintegerAccessor (&UdpSocket::GetRcvBufSize,
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    43
                                         &UdpSocket::SetRcvBufSize),
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
                   MakeUintegerChecker<uint32_t> ())
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
    .AddAttribute ("IpTtl",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
                   "socket-specific TTL for unicast IP packets (if non-zero)",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
                   UintegerValue (0),
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    48
                   MakeUintegerAccessor (&UdpSocket::GetIpTtl,
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    49
                                         &UdpSocket::SetIpTtl),
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
                   MakeUintegerChecker<uint32_t> ())
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
    .AddAttribute ("IpMulticastTtl",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
                   "socket-specific TTL for multicast IP packets (if non-zero)",
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
                   UintegerValue (0),
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    54
                   MakeUintegerAccessor (&UdpSocket::GetIpMulticastTtl,
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    55
                                         &UdpSocket::SetIpMulticastTtl),
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
                   MakeUintegerChecker<uint32_t> ())
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    57
    .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    58
                   BooleanValue (false),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    59
                   MakeBooleanAccessor (&UdpSocket::SetMtuDiscover,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    60
                                        &UdpSocket::GetMtuDiscover),
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3130
diff changeset
    61
                   MakeBooleanChecker ())
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
    ;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
  return tid;
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
}
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    66
UdpSocket::UdpSocket ()
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
{
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
  NS_LOG_FUNCTION_NOARGS ();
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
}
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
3130
881cc06cd651 rename UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents: 3129
diff changeset
    71
UdpSocket::~UdpSocket ()
3129
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
{
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
  NS_LOG_FUNCTION_NOARGS ();
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
}
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
17e0776b8815 Move UdpSocket to UdpSocketImpl
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
}; // namespace ns3