src/devices/mesh/mesh-point-device.cc
author Pavel Boyko <boyko@iitp.ru>
Tue, 17 Mar 2009 10:56:45 +0300
changeset 4817 1257e4b82e17
parent 4815 4d5befafc0a5
child 4841 702fa974e205
permissions -rw-r--r--
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     2
/*
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     4
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     8
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    13
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    17
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
    19
 *         Pavel Boyko <boyko@iitp.ru>
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    20
 */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    21
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    22
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    23
#include "ns3/node.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    24
#include "ns3/channel.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    25
#include "ns3/packet.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    26
#include "ns3/log.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    27
#include "ns3/boolean.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    28
#include "ns3/simulator.h"
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
    29
#include "ns3/mesh-point-device.h"
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    30
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    31
NS_LOG_COMPONENT_DEFINE ("MeshPointDevice");
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    32
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    33
namespace ns3 {
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    34
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    35
NS_OBJECT_ENSURE_REGISTERED (MeshPointDevice);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    36
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    37
TypeId
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    38
MeshPointDevice::GetTypeId ()
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    39
{
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    40
  static TypeId tid = TypeId ("ns3::MeshPointDevice")
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    41
                      .SetParent<NetDevice> ()
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    42
                      .AddConstructor<MeshPointDevice> ()
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    43
                      ;
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    44
  // TODO Add station-level attributes here
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    45
  return tid;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    46
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    47
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    48
MeshPointDevice::MeshPointDevice () : m_ifIndex(0), m_mtu(1500)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    49
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    50
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    51
  m_channel = CreateObject<BridgeChannel> ();
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    52
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    53
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    54
MeshPointDevice::~MeshPointDevice()
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    55
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    56
  NS_LOG_FUNCTION_NOARGS ();
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    57
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    58
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    59
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    60
MeshPointDevice::DoDispose ()
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    61
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    62
  NS_LOG_FUNCTION_NOARGS ();
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    63
  for (std::vector< Ptr<NetDevice> >::iterator iter = m_ifaces.begin (); iter != m_ifaces.end (); iter++)
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    64
    *iter = 0;
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    65
  m_ifaces.clear ();
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    66
  m_node = 0;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    67
  NetDevice::DoDispose ();
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    68
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    69
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    70
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    71
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    72
// NetDevice interface implementation
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    73
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    74
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    75
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
    76
MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol,
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    77
                                       Address const &src, Address const &dst, PacketType packetType)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    78
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    79
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    80
  NS_LOG_DEBUG ("UID is " << packet->GetUid ());
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    81
  const Mac48Address src48 = Mac48Address::ConvertFrom (src);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    82
  const Mac48Address dst48 = Mac48Address::ConvertFrom (dst);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    83
  if (!m_promiscRxCallback.IsNull ())
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    84
    m_promiscRxCallback (this, packet, protocol, src, dst, packetType);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    85
  switch (packetType)
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    86
    {
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    87
    case PACKET_HOST:
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    88
      if (dst48 == m_address)
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    89
        m_rxCallback (this, packet, protocol, src);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    90
      break;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    91
    case PACKET_BROADCAST:
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    92
    case PACKET_MULTICAST:
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    93
      m_rxCallback (this, packet, protocol, src);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    94
    case PACKET_OTHERHOST:
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    95
      Forward (incomingPort, packet->Copy(), protocol, src48, dst48);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    96
      break;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
    97
    }
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    98
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    99
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   100
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   101
MeshPointDevice::Forward (Ptr<NetDevice> inport, Ptr<Packet> packet,
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   102
                             uint16_t protocol, const Mac48Address src, const Mac48Address dst)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   103
{
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   104
  // pass through routing protocol
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   105
  m_requestRoute(inport->GetIfIndex(), src, dst, packet, protocol, m_myResponse);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   106
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   107
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   108
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   109
MeshPointDevice::SetName(const std::string name)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   110
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   111
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   112
  m_name = name;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   113
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   114
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   115
std::string
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   116
MeshPointDevice::GetName() const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   117
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   118
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   119
  return m_name;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   120
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   121
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   122
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   123
MeshPointDevice::SetIfIndex(const uint32_t index)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   124
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   125
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   126
  m_ifIndex = index;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   127
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   128
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   129
uint32_t
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   130
MeshPointDevice::GetIfIndex() const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   131
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   132
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   133
  return m_ifIndex;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   134
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   135
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   136
Ptr<Channel>
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   137
MeshPointDevice::GetChannel () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   138
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   139
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   140
  return m_channel;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   141
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   142
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   143
Address
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   144
MeshPointDevice::GetAddress () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   145
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   146
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   147
  return m_address;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   148
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   149
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   150
bool
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   151
MeshPointDevice::SetMtu (const uint16_t mtu)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   152
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   153
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   154
  m_mtu = mtu;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   155
  return true;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   156
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   157
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   158
uint16_t
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   159
MeshPointDevice::GetMtu () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   160
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   161
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   162
  return m_mtu;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   163
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   164
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   165
bool
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   166
MeshPointDevice::IsLinkUp () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   167
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   168
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   169
  return true;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   170
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   171
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   172
void
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   173
MeshPointDevice::SetLinkChangeCallback (Callback<void> callback)
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   174
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   175
  // do nothing
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   176
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   177
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   178
bool
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   179
MeshPointDevice::IsBroadcast () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   180
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   181
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   182
  return true;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   183
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   184
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   185
Address
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   186
MeshPointDevice::GetBroadcast () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   187
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   188
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   189
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   190
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   191
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   192
bool
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   193
MeshPointDevice::IsMulticast () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   194
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   195
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   196
  return true;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   197
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   198
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   199
Address
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   200
MeshPointDevice::GetMulticast (Ipv4Address multicastGroup) const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   201
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   202
  NS_LOG_FUNCTION (this << multicastGroup);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   203
  Mac48Address multicast = Mac48Address::GetMulticast (multicastGroup);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   204
  return multicast;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   205
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   206
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   207
bool
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   208
MeshPointDevice::IsPointToPoint () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   209
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   210
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   211
  return false;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   212
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   213
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   214
bool
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   215
MeshPointDevice::IsBridge () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   216
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   217
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   218
  return false;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   219
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   220
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   221
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   222
bool
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   223
MeshPointDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   224
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   225
  const Mac48Address dst48 = Mac48Address::ConvertFrom (dest);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   226
  return m_requestRoute(m_ifIndex, m_address, dst48, packet, protocolNumber, m_myResponse);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   227
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   228
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   229
bool
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   230
MeshPointDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   231
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   232
  const Mac48Address src48 = Mac48Address::ConvertFrom (src);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   233
  const Mac48Address dst48 = Mac48Address::ConvertFrom (dest);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   234
  return m_requestRoute(m_ifIndex, src48, dst48, packet, protocolNumber, m_myResponse);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   235
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   236
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   237
Ptr<Node>
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   238
MeshPointDevice::GetNode () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   239
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   240
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   241
  return m_node;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   242
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   243
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   244
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   245
MeshPointDevice::SetNode (Ptr<Node> node)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   246
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   247
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   248
  m_node = node;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   249
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   250
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   251
bool
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   252
MeshPointDevice::NeedsArp () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   253
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   254
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   255
  return true;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   256
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   257
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   258
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   259
MeshPointDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   260
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   261
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   262
  m_rxCallback = cb;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   263
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   264
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   265
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   266
MeshPointDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   267
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   268
  NS_LOG_FUNCTION_NOARGS ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   269
  m_promiscRxCallback = cb;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   270
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   271
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   272
bool
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   273
MeshPointDevice::SupportsSendFrom () const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   274
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   275
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   276
  return true;
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   277
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   278
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   279
Address
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   280
MeshPointDevice::GetMulticast (Ipv6Address addr) const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   281
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   282
  NS_LOG_FUNCTION (this << addr);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   283
  return Mac48Address::GetMulticast (addr);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   284
}
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   285
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   286
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   287
// Interfaces
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   288
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   289
uint32_t
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   290
MeshPointDevice::GetNInterfaces () const
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   291
{
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   292
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   293
  return m_ifaces.size ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   294
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   295
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   296
Ptr<NetDevice>
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   297
MeshPointDevice::GetInterface (uint32_t n) const
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   298
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   299
  NS_ASSERT(m_ifaces.size () > n);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   300
  return m_ifaces[n];
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   301
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   302
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   303
void
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   304
MeshPointDevice::AddInterface (Ptr<NetDevice> iface)
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   305
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   306
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   307
  
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   308
  NS_ASSERT (iface != this);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   309
  if (!Mac48Address::IsMatchingType (iface->GetAddress ()))
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   310
    NS_FATAL_ERROR ("Device does not support eui 48 addresses: cannot be added to bridge.");
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   311
  if (!iface->SupportsSendFrom ())
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   312
    NS_FATAL_ERROR ("Device does not support SendFrom: cannot be added to bridge.");
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   313
  m_address = Mac48Address::ConvertFrom (iface->GetAddress ());
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   314
  
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   315
  NS_LOG_DEBUG ("RegisterProtocolHandler for " << iface->GetName ());
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   316
  m_node->RegisterProtocolHandler (MakeCallback (&MeshPointDevice::ReceiveFromDevice, this),
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   317
                                   0, iface, /*promiscuous = */true);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   318
  
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   319
  m_ifaces.push_back (iface);
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   320
  m_channel->AddChannel (iface->GetChannel ());
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   321
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   322
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   323
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   324
// Protocols
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   325
//-----------------------------------------------------------------------------
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   326
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   327
void
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   328
MeshPointDevice::SetRoutingProtocol(Ptr<MeshL2RoutingProtocol> protocol)
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   329
{
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   330
  NS_LOG_FUNCTION_NOARGS ();
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   331
  
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   332
  NS_ASSERT_MSG(PeekPointer(protocol->GetMeshPoint()) == this, "Routing protocol must be installed on mesh point to be usefull.");
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   333
  
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   334
  m_requestRoute = MakeCallback(&MeshL2RoutingProtocol::RequestRoute, protocol);
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   335
  m_myResponse = MakeCallback(&MeshPointDevice::DoSend, this);
4817
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   336
  
1257e4b82e17 L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents: 4815
diff changeset
   337
  return;
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   338
}
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   339
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   340
void
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   341
MeshPointDevice::DoSend(bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t outIface)
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   342
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   343
  if (!success)
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   344
    {
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   345
      NS_LOG_UNCOND("Resolve failed");
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   346
      //TODO: SendError callback
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   347
      return;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   348
    }
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   349
  
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   350
  // Ok, now I know the route, just SendFrom
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   351
  
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   352
  if (outIface != 0xffffffff)
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   353
    GetInterface(outIface)->SendFrom(packet, src, dst, protocol);
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   354
  else
4815
4d5befafc0a5 L2RoutingNetDevice refactored to MeshPointDevice
pavlo
parents: 4813
diff changeset
   355
    for (std::vector<Ptr<NetDevice> >::iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++)
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4809
diff changeset
   356
      (*i) -> SendFrom(packet, src, dst, protocol);
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   357
}
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   358
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   359
} // namespace ns3