src/node/simple-net-device.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 16 Jul 2008 16:06:50 +0100
changeset 3460 99698bc858e8
parent 3448 0bd851bb1225
child 3480 a920df6b9f02
permissions -rw-r--r--
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2833
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     2
/*
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     3
 * Copyright (c) 2008 INRIA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     4
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     7
 * published by the Free Software Foundation;
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     8
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    12
 * GNU General Public License for more details.
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    13
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    15
 * along with this program; if not, write to the Free Software
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    17
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2831
diff changeset
    19
 */
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "simple-net-device.h"
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "simple-channel.h"
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "node.h"
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "ns3/packet.h"
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
namespace ns3 {
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
TypeId 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
SimpleNetDevice::GetTypeId (void)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
  static TypeId tid = TypeId ("ns3::SimpleNetDevice")
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
    .SetParent<NetDevice> ()
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
    .AddConstructor<SimpleNetDevice> ()
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
    ;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
  return tid;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
SimpleNetDevice::SimpleNetDevice ()
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
  : m_channel (0),
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
    m_node (0),
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
    m_mtu (0xffff),
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
    m_name (""),
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
    m_ifIndex (0)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
{}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
SimpleNetDevice::Receive (Ptr<Packet> packet, uint16_t protocol, 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
			  Mac48Address to, Mac48Address from)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
{
3448
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    49
  NetDevice::PacketType packetType;
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    50
  if (to == m_address)
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    51
    {
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    52
      packetType = NetDevice::PACKET_HOST;
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    53
    }
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    54
  else if (to == Mac48Address::GetBroadcast ())
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
    {
3448
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    56
      packetType = NetDevice::PACKET_HOST;
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
    }
3448
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    58
  else
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    59
    {
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    60
      NS_FATAL_ERROR ("Weird packet destination " << to);
0bd851bb1225 Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3442
diff changeset
    61
    }
3460
99698bc858e8 New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3448
diff changeset
    62
  m_rxCallback (this, packet, protocol, from);
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
SimpleNetDevice::SetChannel (Ptr<SimpleChannel> channel)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  m_channel = channel;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
  m_channel->Add (this);
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
SimpleNetDevice::SetAddress (Mac48Address address)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  m_address = address;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
SimpleNetDevice::SetName(const std::string name)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
  m_name = name;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
std::string 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
SimpleNetDevice::GetName(void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  return m_name;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
SimpleNetDevice::SetIfIndex(const uint32_t index)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
  m_ifIndex = index;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
uint32_t 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
SimpleNetDevice::GetIfIndex(void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  return m_ifIndex;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
Ptr<Channel> 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
SimpleNetDevice::GetChannel (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
  return m_channel;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
Address 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
SimpleNetDevice::GetAddress (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
  return m_address;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
SimpleNetDevice::SetMtu (const uint16_t mtu)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
  m_mtu = mtu;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
  return true;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
uint16_t 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
SimpleNetDevice::GetMtu (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
  return m_mtu;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
SimpleNetDevice::IsLinkUp (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
  return true;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
SimpleNetDevice::SetLinkChangeCallback (Callback<void> callback)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
{}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
SimpleNetDevice::IsBroadcast (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
  return true;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
Address
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
SimpleNetDevice::GetBroadcast (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
SimpleNetDevice::IsMulticast (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
  return false;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
Address 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
SimpleNetDevice::GetMulticast (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
  return Mac48Address ("01:00:5e:00:00:00");
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
Address 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
SimpleNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
  return Mac48Address ("01:00:5e:00:00:00");
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
SimpleNetDevice::IsPointToPoint (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
  return false;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
SimpleNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
  Mac48Address to = Mac48Address::ConvertFrom (dest);
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
  m_channel->Send (packet, protocolNumber, to, m_address, this);
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
  return true;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
}
3442
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   164
bool 
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   165
SimpleNetDevice::SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   166
{
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   167
  Mac48Address to = Mac48Address::ConvertFrom (dest);
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   168
  Mac48Address from = Mac48Address::ConvertFrom (source);
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   169
  m_channel->Send (packet, protocolNumber, to, from, this);
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   170
  return true;
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   171
}
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   172
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
Ptr<Node> 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
SimpleNetDevice::GetNode (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
  return m_node;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   177
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   178
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
SimpleNetDevice::SetNode (Ptr<Node> node)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
  m_node = node;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
bool 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
SimpleNetDevice::NeedsArp (void) const
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
  return false;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
void 
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
SimpleNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
{
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
  m_rxCallback = cb;
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
}
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
2831
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   194
void
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   195
SimpleNetDevice::DoDispose (void)
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   196
{
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   197
  m_channel = 0;
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   198
  m_node = 0;
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   199
  NetDevice::DoDispose ();
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   200
}
8bb0479b0949 get rid of channel during dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2673
diff changeset
   201
2673
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
a70e0c7aaf56 SimpleChannel/SimpleNetDevice. Use them where needed.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
} // namespace ns3