src/devices/wifi/wifi-net-device.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 16 Jul 2008 16:06:50 +0100
changeset 3460 99698bc858e8
parent 3448 0bd851bb1225
child 3464 9e7bd353e7e7
permissions -rw-r--r--
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "wifi-net-device.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    21
#include "wifi-mac.h"
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "wifi-phy.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    23
#include "wifi-remote-station-manager.h"
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "wifi-channel.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    25
#include "ns3/llc-snap-header.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    26
#include "ns3/packet.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    27
#include "ns3/uinteger.h"
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    28
#include "ns3/pointer.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    29
#include "ns3/node.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    30
#include "ns3/trace-source-accessor.h"
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
2942
e37b7279e41e add missing registration macro call
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2935
diff changeset
    34
NS_OBJECT_ENSURE_REGISTERED (WifiNetDevice);
e37b7279e41e add missing registration macro call
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2935
diff changeset
    35
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    36
TypeId 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    37
WifiNetDevice::GetTypeId (void)
2053
012487e16e31 basic tracing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2010
diff changeset
    38
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2601
diff changeset
    39
  static TypeId tid = TypeId ("ns3::WifiNetDevice")
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    40
    .SetParent<NetDevice> ()
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    41
    .AddAttribute ("Channel", "The channel attached to this device",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
    42
                   PointerValue (),
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    43
                   MakePointerAccessor (&WifiNetDevice::DoGetChannel,
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    44
                                        &WifiNetDevice::SetChannel),
2935
c24722e09df2 use a specific type if you can
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    45
                   MakePointerChecker<WifiChannel> ())
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    46
    .AddAttribute ("Phy", "The PHY layer attached to this device.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
    47
                   PointerValue (),
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    48
                   MakePointerAccessor (&WifiNetDevice::GetPhy,
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    49
                                        &WifiNetDevice::SetPhy),
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    50
                   MakePointerChecker<WifiPhy> ())
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    51
    .AddAttribute ("Mac", "The MAC layer attached to this device.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
    52
                   PointerValue (),
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    53
                   MakePointerAccessor (&WifiNetDevice::GetMac,
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    54
                                        &WifiNetDevice::SetMac),
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    55
                   MakePointerChecker<WifiMac> ())
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    56
    .AddAttribute ("RemoteStationManager", "The station manager attached to this device.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
    57
                   PointerValue (),
2927
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    58
                   MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    59
                                        &WifiNetDevice::GetRemoteStationManager),
73b47ce1d805 get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2649
diff changeset
    60
                   MakePointerChecker<WifiRemoteStationManager> ())
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    61
    .AddTraceSource ("Rx", "Received payload from the MAC layer.",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    62
                     MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
2961
2bcb3435483b improve documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2942
diff changeset
    63
    .AddTraceSource ("Tx", "Send payload to the MAC layer.",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    64
                     MakeTraceSourceAccessor (&WifiNetDevice::m_txLogger))
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    65
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    66
  return tid;
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
    67
}
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
    68
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    69
WifiNetDevice::WifiNetDevice ()
2562
01a2e3e1924d initialize properly mtu field.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2551
diff changeset
    70
  : m_mtu (0)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    71
{}
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
WifiNetDevice::~WifiNetDevice ()
2002
32903f9a7315 add dispose methods in subclasses of WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
diff changeset
    73
{}
2530
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    74
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    75
void
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    76
WifiNetDevice::DoDispose (void)
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    77
{
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    78
  m_node = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    79
  m_mac->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    80
  m_phy->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    81
  m_stationManager->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    82
  m_mac = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    83
  m_phy = 0;
2618
b2706c1a6c3b release the channel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    84
  m_channel = 0;
2530
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    85
  m_stationManager = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    86
  // chain up.
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    87
  NetDevice::DoDispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    88
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    89
  
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    90
void 
2601
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    91
WifiNetDevice::SetMac (Ptr<WifiMac> mac)
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    92
{
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    93
  m_mac = mac;
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    94
  if (m_mac != 0)
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    95
    {
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    96
      if (m_stationManager != 0)
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    97
        {
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    98
          m_mac->SetWifiRemoteStationManager (m_stationManager);
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    99
        }
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   100
      if (m_phy != 0)
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   101
        {
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   102
          m_mac->SetWifiPhy (m_phy);
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   103
        }
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   104
      m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this));
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   105
      m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this));
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   106
      m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this));
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   107
    }
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
}
2620
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   109
void 
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   110
WifiNetDevice::SetPhy (Ptr<WifiPhy> phy)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   111
{
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   112
  m_phy = phy;
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   113
  if (m_phy != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   114
    {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   115
      if (m_channel != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   116
        {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   117
          m_channel->Add (this, m_phy);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   118
          m_phy->SetChannel (m_channel);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   119
        }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   120
      if (m_stationManager != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   121
        {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   122
          m_stationManager->SetupPhy (m_phy);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   123
        }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   124
      if (m_mac != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   125
        {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   126
          m_mac->SetWifiPhy (m_phy);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   127
        }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   128
    }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   129
}
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   130
void 
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   131
WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   132
{
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   133
  m_stationManager = manager;
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   134
  if (m_stationManager != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   135
    {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   136
      if (m_phy != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   137
        {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   138
          m_stationManager->SetupPhy (m_phy);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   139
        }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   140
      if (m_mac != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   141
        {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   142
          m_mac->SetWifiRemoteStationManager (m_stationManager);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   143
        }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   144
    }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   145
}
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   146
void 
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   147
WifiNetDevice::SetChannel (Ptr<WifiChannel> channel)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   148
{
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   149
  m_channel = channel;
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   150
  if (m_channel != 0 && m_phy != 0)
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   151
    {
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   152
      m_channel->Add (this, m_phy);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   153
      m_phy->SetChannel (m_channel);
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   154
    }
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   155
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   156
Ptr<WifiMac> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   157
WifiNetDevice::GetMac (void) const
1998
41cd4e5694c2 dispose the channel from WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1995
diff changeset
   158
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   159
  return m_mac;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   160
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   161
Ptr<WifiPhy> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   162
WifiNetDevice::GetPhy (void) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   163
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   164
  return m_phy;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   165
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   166
Ptr<WifiRemoteStationManager> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   167
WifiNetDevice::GetRemoteStationManager (void) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   168
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   169
  return m_stationManager;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   170
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   171
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   172
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   173
WifiNetDevice::SetName(const std::string name)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   174
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   175
  m_name = name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   176
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   177
std::string 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   178
WifiNetDevice::GetName(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   179
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   180
  return m_name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   181
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   182
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   183
WifiNetDevice::SetIfIndex(const uint32_t index)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   184
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   185
  m_ifIndex = index;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   186
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   187
uint32_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   188
WifiNetDevice::GetIfIndex(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   189
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   190
  return m_ifIndex;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   191
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   192
Ptr<Channel> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   193
WifiNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   194
{
2601
4297e8c61615 rework the Wifi API to not use a single WifiNetDevice::Setup method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   195
  return m_channel;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   196
}
2620
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   197
Ptr<WifiChannel> 
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   198
WifiNetDevice::DoGetChannel (void) const
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   199
{
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   200
  return m_channel;
0131b5889305 make sure that all the Setters can be invoked in any order without memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2618
diff changeset
   201
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   202
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   203
WifiNetDevice::GetAddress (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   204
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   205
  return m_mac->GetAddress ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   206
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   207
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   208
WifiNetDevice::SetMtu (const uint16_t mtu)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   209
{
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   210
  UintegerValue maxMsduSize;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   211
  m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   212
  if (mtu > maxMsduSize.Get () || mtu == 0)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   213
    {
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   214
      return false;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   215
    }
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   216
  m_mtu = mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   217
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   218
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   219
uint16_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   220
WifiNetDevice::GetMtu (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   221
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   222
  if (m_mtu == 0)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   223
    {
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   224
      UintegerValue maxMsduSize;
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   225
      m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2961
diff changeset
   226
      m_mtu = maxMsduSize.Get ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   227
    }
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   228
  return m_mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   229
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   230
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   231
WifiNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   232
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   233
  return m_phy != 0 && m_linkUp;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   234
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   235
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   236
WifiNetDevice::SetLinkChangeCallback (Callback<void> callback)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   237
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   238
  m_linkChange = callback;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   239
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   240
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   241
WifiNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   242
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   243
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   244
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   245
Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   246
WifiNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   247
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   248
  return Mac48Address::GetBroadcast ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   249
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   250
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   251
WifiNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   252
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   253
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   254
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   255
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   256
WifiNetDevice::GetMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   257
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   258
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   259
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   260
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   261
WifiNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   262
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   263
  return GetMulticast ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   264
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   265
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   266
WifiNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   267
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   268
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   269
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   270
bool 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   271
WifiNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   272
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   273
  NS_ASSERT (Mac48Address::IsMatchingType (dest));
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   274
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   275
  Mac48Address realTo = Mac48Address::ConvertFrom (dest);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   276
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   277
  LlcSnapHeader llc;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   278
  llc.SetType (protocolNumber);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   279
  packet->AddHeader (llc);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   280
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   281
  m_txLogger (packet, realTo);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   282
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   283
  m_mac->Enqueue (packet, realTo);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   284
  return true;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   285
}
3442
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   286
bool 
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   287
WifiNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   288
{
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   289
  NS_FATAL_ERROR ("WifiNetDevice::SendFrom not implemented.");
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   290
  return false;
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   291
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   292
Ptr<Node> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   293
WifiNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   294
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   295
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   296
}
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2562
diff changeset
   297
void 
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2562
diff changeset
   298
WifiNetDevice::SetNode (Ptr<Node> node)
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2562
diff changeset
   299
{
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2562
diff changeset
   300
  m_node = node;
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2562
diff changeset
   301
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   302
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   303
WifiNetDevice::NeedsArp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   304
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   305
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   306
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   307
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   308
WifiNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   309
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   310
  m_forwardUp = cb;
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
   311
}
2151
7c63780653f2 add constructors to specify the address of a device
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2146
diff changeset
   312
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   313
void
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   314
WifiNetDevice::ForwardUp (Ptr<Packet> packet, const Mac48Address &from)
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   315
{
2649
e7c7618c50a2 make sure the Rx trace event also gets the llc header to be symetric with the tx event.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2620
diff changeset
   316
  m_rxLogger (packet, from);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   317
  LlcSnapHeader llc;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   318
  packet->RemoveHeader (llc);
3460
99698bc858e8 New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3448
diff changeset
   319
  m_forwardUp (this, packet, llc.GetType (), from);
2350
0b54480c4fd1 Hook trace sources into the trace system. Add WifiTrace to give a 'simple' API to tracing wifi-specific sources.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2349
diff changeset
   320
}
2002
32903f9a7315 add dispose methods in subclasses of WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
diff changeset
   321
2151
7c63780653f2 add constructors to specify the address of a device
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2146
diff changeset
   322
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   323
WifiNetDevice::LinkUp (void)
2151
7c63780653f2 add constructors to specify the address of a device
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2146
diff changeset
   324
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   325
  m_linkUp = true;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   326
  if (!m_linkChange.IsNull ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   327
    {
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   328
      m_linkChange ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   329
    }
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   330
}
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   331
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   332
WifiNetDevice::LinkDown (void)
2350
0b54480c4fd1 Hook trace sources into the trace system. Add WifiTrace to give a 'simple' API to tracing wifi-specific sources.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2349
diff changeset
   333
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   334
  m_linkUp = false;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   335
  if (!m_linkChange.IsNull ())
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
   336
    {
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   337
      m_linkChange ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   338
    }
2350
0b54480c4fd1 Hook trace sources into the trace system. Add WifiTrace to give a 'simple' API to tracing wifi-specific sources.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2349
diff changeset
   339
}
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   340
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
} // namespace ns3
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   342