src/devices/bridge/bridge-net-device.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 07 Jul 2008 12:18:05 +0100
changeset 3448 0bd851bb1225
parent 3444 a6d76b454df4
child 3449 c3dcecc4825a
permissions -rw-r--r--
Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     2
/*
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     6
 *
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    10
 * GNU General Public License for more details.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    11
 *
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    15
 *
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    16
 * Author: Gustavo Carneiro  <gjc@inescporto.pt>
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    17
 */
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    18
#include "bridge-net-device.h"
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    19
#include "ns3/node.h"
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    20
#include "ns3/channel.h"
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    21
#include "ns3/packet.h"
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    22
#include "ns3/log.h"
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    23
#include "ns3/boolean.h"
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    24
#include "ns3/simulator.h"
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("BridgeNetDevice");
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
namespace ns3 {
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
TypeId
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    32
BridgeNetDevice::GetTypeId (void)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    33
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    34
  static TypeId tid = TypeId ("ns3::BridgeNetDevice")
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    35
    .SetParent<NetDevice> ()
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    36
    .AddConstructor<BridgeNetDevice> ()
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    37
    .AddAttribute ("EnableLearning",
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    38
                   "Enable the learning mode of the Learning Bridge",
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    39
                   BooleanValue (true),
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    40
                   MakeBooleanAccessor (&BridgeNetDevice::m_enableLearning),
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    41
                   MakeBooleanChecker ())
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    42
    .AddAttribute ("ExpirationTime",
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    43
                   "Time it takes for learned MAC state entry to expire.",
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    44
                   TimeValue (Seconds (30)),
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    45
                   MakeTimeAccessor (&BridgeNetDevice::m_expirationTime),
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    46
                   MakeTimeChecker ())
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    47
    ;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    48
  return tid;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    49
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    50
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    51
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    52
BridgeNetDevice::BridgeNetDevice ()
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    53
  : m_node (0),
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    54
    m_name (""),
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    55
    m_ifIndex (0),
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    56
    m_mtu (0xffff)
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    57
{}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    58
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    59
void
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: 3444
diff changeset
    60
BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<Packet> packet, uint16_t protocol,
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: 3444
diff changeset
    61
                                    Address const &src, Address const &dst, PacketType packetType)
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    62
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    63
  NS_LOG_FUNCTION_NOARGS ();
3443
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
    64
  NS_LOG_DEBUG ("UID is " << packet->GetUid ());
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    65
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
  Mac48Address src48 = Mac48Address::ConvertFrom (src);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    67
  Mac48Address dst48 = Mac48Address::ConvertFrom (dst);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    68
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: 3444
diff changeset
    69
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: 3444
diff changeset
    70
  switch (packetType)
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    71
    {
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: 3444
diff changeset
    72
    case 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: 3444
diff changeset
    73
      if (dst48 == 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: 3444
diff changeset
    74
        {
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: 3444
diff changeset
    75
          m_rxCallback (this, packet, protocol, src, dst, 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: 3444
diff changeset
    76
        }
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: 3444
diff changeset
    77
      break;
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    78
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: 3444
diff changeset
    79
    case PACKET_BROADCAST:
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: 3444
diff changeset
    80
    case PACKET_MULTICAST:
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: 3444
diff changeset
    81
      m_rxCallback (this, packet, protocol, src, dst, 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: 3444
diff changeset
    82
      ForwardBroadcast (incomingPort, packet, protocol, src48, dst48);
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: 3444
diff changeset
    83
      break;
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    84
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: 3444
diff changeset
    85
    case PACKET_OTHERHOST:
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    86
      ForwardUnicast (incomingPort, packet, protocol, src48, dst48);
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: 3444
diff changeset
    87
      break;
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    88
    }
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    89
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    90
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    91
void
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    92
BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    93
                                 uint16_t protocol, Mac48Address src, Mac48Address dst)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    94
{
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    95
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    96
                << ", packet=" << packet << ", protocol="<<protocol
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    97
                << ", src=" << src << ", dst=" << dst << ")");
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    98
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
    99
  Learn (src, incomingPort);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   100
  Ptr<NetDevice> outPort = GetLearnedState (dst);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   101
  if (outPort != NULL && outPort != incomingPort)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   102
    {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   103
      NS_LOG_LOGIC ("Learning bridge state says to use port `" << outPort->GetName () << "'");
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   104
      outPort->SendFrom (packet->Copy (), src, dst, protocol);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   105
    }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   106
  else
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   107
    {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   108
      NS_LOG_LOGIC ("No learned state: send through all ports");
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   109
      for (std::vector< Ptr<NetDevice> >::iterator iter = m_ports.begin ();
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   110
           iter != m_ports.end (); iter++)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   111
        {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   112
          Ptr<NetDevice> port = *iter;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   113
          if (port != incomingPort)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   114
            {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   115
              NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName ()
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   116
                            << " --> " << port->GetName ()
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   117
                            << " (UID " << packet->GetUid () << ").");
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   118
              port->SendFrom (packet->Copy (), src, dst, protocol);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   119
            }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   120
        }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   121
    }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   122
}
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   123
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   124
void
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   125
BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   126
                                        uint16_t protocol, Mac48Address src, Mac48Address dst)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   127
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   128
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   129
                << ", packet=" << packet << ", protocol="<<protocol
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   130
                << ", src=" << src << ", dst=" << dst << ")");
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   131
  Learn (src, incomingPort);
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   132
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   133
  for (std::vector< Ptr<NetDevice> >::iterator iter = m_ports.begin ();
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   134
         iter != m_ports.end (); iter++)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   135
    {
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   136
      Ptr<NetDevice> port = *iter;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   137
      if (port != incomingPort)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   138
        {
3443
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   139
          NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName ()
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   140
                        << " --> " << port->GetName ()
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   141
                        << " (UID " << packet->GetUid () << ").");
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   142
          port->SendFrom (packet->Copy (), src, dst, protocol);
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   143
        }
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   144
    }
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   145
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   146
3444
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   147
void BridgeNetDevice::Learn (Mac48Address source, Ptr<NetDevice> port)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   148
{
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   149
  if (m_enableLearning)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   150
    {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   151
      LearnedState &state = m_learnState[source];
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   152
      state.associatedPort = port;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   153
      state.expirationTime = Simulator::Now () + m_expirationTime;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   154
    }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   155
}
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   156
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   157
Ptr<NetDevice> BridgeNetDevice::GetLearnedState (Mac48Address source)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   158
{
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   159
  if (m_enableLearning)
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   160
    {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   161
      std::map<Mac48Address, LearnedState>::iterator iter =
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   162
        m_learnState.find (source);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   163
      if (iter != m_learnState.end ())
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   164
        {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   165
          LearnedState &state = iter->second;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   166
          if (state.expirationTime > Simulator::Now ())
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   167
            {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   168
              return state.associatedPort;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   169
            }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   170
          else
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   171
            {
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   172
              m_learnState.erase (iter);
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   173
            }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   174
        }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   175
    }
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   176
  return NULL;
a6d76b454df4 Add the 'learning' part of the Learning Bridge, with option to disable it and revert to dummy mode (hub-like).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3443
diff changeset
   177
}
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   178
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   179
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   180
BridgeNetDevice::AddBridgePort (Ptr<NetDevice> bridgePort)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   181
{
3443
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   182
  NS_ASSERT (bridgePort != this);
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   183
  if (m_address == Mac48Address ())
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   184
    {
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   185
      m_address = Mac48Address::ConvertFrom (bridgePort->GetAddress ());
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   186
    }
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   187
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: 3444
diff changeset
   188
  m_node->RegisterProtocolHandler (MakeCallback (&BridgeNetDevice::ReceiveFromDevice, this),
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: 3444
diff changeset
   189
                                   0, bridgePort);
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   190
  m_ports.push_back (bridgePort);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   191
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   192
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   193
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   194
BridgeNetDevice::SetName(const std::string name)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   195
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   196
  m_name = name;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   197
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   198
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   199
std::string 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   200
BridgeNetDevice::GetName(void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   201
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   202
  return m_name;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   203
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   204
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   205
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   206
BridgeNetDevice::SetIfIndex(const uint32_t index)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   207
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   208
  m_ifIndex = index;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   209
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   210
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   211
uint32_t 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   212
BridgeNetDevice::GetIfIndex(void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   213
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   214
  return m_ifIndex;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   215
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   216
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   217
Ptr<Channel> 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   218
BridgeNetDevice::GetChannel (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   219
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   220
  return 0;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   221
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   222
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   223
Address 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   224
BridgeNetDevice::GetAddress (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   225
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   226
  return m_address;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   227
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   228
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   229
bool 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   230
BridgeNetDevice::SetMtu (const uint16_t mtu)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   231
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   232
  m_mtu = mtu;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   233
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   234
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   235
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   236
uint16_t 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   237
BridgeNetDevice::GetMtu (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   238
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   239
  return m_mtu;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   240
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   241
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   242
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   243
bool 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   244
BridgeNetDevice::IsLinkUp (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   245
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   246
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   247
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   248
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   249
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   250
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   251
BridgeNetDevice::SetLinkChangeCallback (Callback<void> callback)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   252
{}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   253
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   254
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   255
bool 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   256
BridgeNetDevice::IsBroadcast (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   257
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   258
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   259
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   260
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   261
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   262
Address
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   263
BridgeNetDevice::GetBroadcast (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   264
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   265
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   266
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   267
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   268
bool
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   269
BridgeNetDevice::IsMulticast (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   270
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   271
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   272
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   273
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   274
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   275
Address
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   276
BridgeNetDevice::GetMulticast (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   277
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   278
  return Mac48Address ("01:00:5e:00:00:00");
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   279
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   280
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   281
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   282
Address
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   283
BridgeNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   284
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   285
 NS_LOG_FUNCTION (this << multicastGroup);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   286
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   287
// First, get the generic multicast address.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   288
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   289
  Address hardwareDestination = GetMulticast ();
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   290
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   291
  NS_LOG_LOGIC ("Device multicast address: " << hardwareDestination);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   292
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   293
// It's our address, and we know we're playing with an EUI-48 address here
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   294
// primarily since we know that by construction, but also since the parameter
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   295
// is an Ipv4Address.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   296
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   297
  Mac48Address etherAddr = Mac48Address::ConvertFrom (hardwareDestination);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   298
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   299
// We now have the multicast address in an abstract 48-bit container.  We 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   300
// need to pull it out so we can play with it.  When we're done, we have the 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   301
// high order bits in etherBuffer[0], etc.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   302
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   303
  uint8_t etherBuffer[6];
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   304
  etherAddr.CopyTo (etherBuffer);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   305
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   306
// Now we need to pull the raw bits out of the Ipv4 destination address.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   307
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   308
  uint8_t ipBuffer[4];
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   309
  multicastGroup.Serialize (ipBuffer);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   310
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   311
// RFC 1112 says that an Ipv4 host group address is mapped to an EUI-48
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   312
// multicast address by placing the low-order 23-bits of the IP address into 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   313
// the low-order 23 bits of the Ethernet multicast address 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   314
// 01-00-5E-00-00-00 (hex). 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   315
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   316
  etherBuffer[3] |= ipBuffer[1] & 0x7f;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   317
  etherBuffer[4] = ipBuffer[2];
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   318
  etherBuffer[5] = ipBuffer[3];
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   319
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   320
// Now, etherBuffer has the desired ethernet multicast address.  We have to
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   321
// suck these bits back into the Mac48Address,
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   322
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   323
  etherAddr.CopyFrom (etherBuffer);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   324
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   325
// Implicit conversion (operator Address ()) is defined for Mac48Address, so
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   326
// use it by just returning the EUI-48 address which is automagically converted
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   327
// to an Address.
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   328
//
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   329
  NS_LOG_LOGIC ("multicast address is " << etherAddr);
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   330
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   331
  return etherAddr;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   332
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   333
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   334
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   335
bool 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   336
BridgeNetDevice::IsPointToPoint (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   337
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   338
  return false;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   339
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   340
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   341
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   342
bool 
3443
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   343
BridgeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   344
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   345
  for (std::vector< Ptr<NetDevice> >::iterator iter = m_ports.begin ();
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   346
         iter != m_ports.end (); iter++)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   347
    {
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   348
      Ptr<NetDevice> port = *iter;
3443
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   349
      port->SendFrom (packet, m_address, dest, protocolNumber);
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   350
    }
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   351
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   352
  return true;
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   353
}
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   354
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   355
bool 
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   356
BridgeNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber)
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   357
{
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   358
  for (std::vector< Ptr<NetDevice> >::iterator iter = m_ports.begin ();
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   359
         iter != m_ports.end (); iter++)
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   360
    {
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   361
      Ptr<NetDevice> port = *iter;
9bb81eb18fed Use NetDevice::SendFrom where appropriate, in order to preserve source address of bridged mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3439
diff changeset
   362
      port->SendFrom (packet, src, dest, protocolNumber);
3439
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   363
    }
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   364
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   365
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   366
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   367
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   368
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   369
Ptr<Node> 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   370
BridgeNetDevice::GetNode (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   371
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   372
  return m_node;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   373
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   374
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   375
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   376
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   377
BridgeNetDevice::SetNode (Ptr<Node> node)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   378
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   379
  m_node = node;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   380
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   381
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   382
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   383
bool 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   384
BridgeNetDevice::NeedsArp (void) const
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   385
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   386
  return true;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   387
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   388
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   389
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   390
void 
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   391
BridgeNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   392
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   393
  m_rxCallback = cb;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   394
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   395
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   396
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   397
void
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   398
BridgeNetDevice::DoDispose (void)
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   399
{
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   400
  m_node = 0;
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   401
  NetDevice::DoDispose ();
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   402
}
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   403
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   404
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   405
a64d1da0d6bf Start of a BridgeNetDevice; for now does not yet do the 'learning' part, and does not preserve the source address of mac frames.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   406
} // namespace ns3