src/internet-stack/loopback-net-device.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 12 Jun 2009 13:44:19 -0700
changeset 4560 2f106fd728ab
parent 4472 e20a31541404
child 4578 88434ff8f0a5
permissions -rw-r--r--
Remove static routing dependencies in code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * Copyright (c) 2008 INRIA
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 *
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 */
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
#include "loopback-net-device.h"
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
#include "ns3/log.h"
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
#include "ns3/channel.h"
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
#include "ns3/node.h"
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
#include "ns3/packet.h"
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("LoopbackNetDevice");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
namespace ns3 {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
TypeId 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
LoopbackNetDevice::GetTypeId (void)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
  static TypeId tid = TypeId ("ns3::LoopbackNetDevice")
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
    .SetParent<NetDevice> ()
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
    .AddConstructor<LoopbackNetDevice> ()
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
    ;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
  return tid;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
LoopbackNetDevice::LoopbackNetDevice ()
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
  : m_node (0),
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
    m_mtu (0xffff),
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
    m_ifIndex (0),
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
    m_address (Mac48Address ("00:00:00:00:00:00"))
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
  NS_LOG_FUNCTION_NOARGS ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
LoopbackNetDevice::Receive (Ptr<Packet> packet, uint16_t protocol, 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
                            Mac48Address to, Mac48Address from)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
  NS_LOG_FUNCTION (packet << " " << protocol << " " << to << " " << from);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
  NetDevice::PacketType packetType;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
  if (to == m_address)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
    {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
      packetType = NetDevice::PACKET_HOST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
  else if (to.IsBroadcast ())
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
    {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
      packetType = NetDevice::PACKET_HOST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
  else if (to.IsGroup ())
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
    {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
      packetType = NetDevice::PACKET_MULTICAST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
  else 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
    {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
      packetType = NetDevice::PACKET_OTHERHOST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
  m_rxCallback (this, packet, protocol, from);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
  if (!m_promiscCallback.IsNull ())
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
    {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
      m_promiscCallback (this, packet, protocol, from, to, packetType);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
LoopbackNetDevice::SetIfIndex(const uint32_t index)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
  m_ifIndex = index;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
uint32_t 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
LoopbackNetDevice::GetIfIndex(void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
  return m_ifIndex;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    90
Ptr<Channel> 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    91
LoopbackNetDevice::GetChannel (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
  return 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
Address 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
LoopbackNetDevice::GetAddress (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
  return m_address;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
LoopbackNetDevice::SetMtu (const uint16_t mtu)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
  m_mtu = mtu;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
uint16_t 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
LoopbackNetDevice::GetMtu (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
  return m_mtu;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
LoopbackNetDevice::IsLinkUp (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
LoopbackNetDevice::SetLinkChangeCallback (Callback<void> callback)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
{}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
LoopbackNetDevice::IsBroadcast (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
Address
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
LoopbackNetDevice::GetBroadcast (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
  // This is typically set to all zeros rather than all ones in real systems
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
  return Mac48Address ("00:00:00:00:00:00");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   137
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
LoopbackNetDevice::IsMulticast (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
  // Multicast loopback will need to be supported for outgoing 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
  // datagrams but this will probably be handled in multicast sockets
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
  return false;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
Address 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
LoopbackNetDevice::GetMulticast (Ipv4Address multicastGroup) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
  return Mac48Address::GetMulticast (multicastGroup);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
Address LoopbackNetDevice::GetMulticast (Ipv6Address addr) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
	return Mac48Address::GetMulticast (addr);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   156
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   158
LoopbackNetDevice::IsPointToPoint (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
  return false;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
LoopbackNetDevice::IsBridge (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
  return false;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
LoopbackNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
  NS_LOG_FUNCTION (packet << " " << dest << " " << protocolNumber);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
  Mac48Address to = Mac48Address::ConvertFrom (dest);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
  NS_ASSERT_MSG (to == GetBroadcast () || to == m_address, "Invalid destination address");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   175
  Receive (packet, protocolNumber, to, m_address);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   178
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
LoopbackNetDevice::SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   181
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   182
  NS_LOG_FUNCTION (packet << " " << source << " " << dest << " " << protocolNumber);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
  Mac48Address to = Mac48Address::ConvertFrom (dest);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
  Mac48Address from = Mac48Address::ConvertFrom (source);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
  NS_ASSERT_MSG (to.IsBroadcast () || to == m_address, "Invalid destination address");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
  Receive (packet, protocolNumber, to, from);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   187
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   188
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
Ptr<Node> 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   191
LoopbackNetDevice::GetNode (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   192
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
  return m_node;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   194
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   197
LoopbackNetDevice::SetNode (Ptr<Node> node)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
  m_node = node;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   200
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   202
bool 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   203
LoopbackNetDevice::NeedsArp (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   204
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   205
  return false;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   206
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   208
void 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   209
LoopbackNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
  m_rxCallback = cb;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
void
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
LoopbackNetDevice::DoDispose (void)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
  m_node = 0;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
  NetDevice::DoDispose ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   220
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   221
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   222
void
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
LoopbackNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   224
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   225
  m_promiscCallback = cb;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   226
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   227
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   228
bool
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
LoopbackNetDevice::SupportsSendFrom (void) const
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
{
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
  return true;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
}
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
} // namespace ns3