src/devices/wifi/wifi-net-device.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 09 Apr 2008 12:15:24 -0700
changeset 2927 73b47ce1d805
parent 2649 e7c7618c50a2
child 2935 c24722e09df2
permissions -rw-r--r--
get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
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
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    34
TypeId 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    35
WifiNetDevice::GetTypeId (void)
2053
012487e16e31 basic tracing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2010
diff changeset
    36
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2601
diff changeset
    37
  static TypeId tid = TypeId ("ns3::WifiNetDevice")
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    38
    .SetParent<NetDevice> ()
2551
5df02c95c679 make pac, phy, et al available through Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2530
diff changeset
    39
    .AddAttribute ("Channel", "XXX",
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
    40
                   Pointer (),
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
    41
                   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
    42
                                        &WifiNetDevice::SetChannel),
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
                   MakePointerChecker<Channel> ())
2551
5df02c95c679 make pac, phy, et al available through Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2530
diff changeset
    44
    .AddAttribute ("Phy", "XXX",
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
    45
                   Pointer (),
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
    46
                   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
    47
                                        &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
    48
                   MakePointerChecker<WifiPhy> ())
2551
5df02c95c679 make pac, phy, et al available through Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2530
diff changeset
    49
    .AddAttribute ("Mac", "XXX",
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
    50
                   Pointer (),
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
    51
                   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
    52
                                        &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
    53
                   MakePointerChecker<WifiMac> ())
2551
5df02c95c679 make pac, phy, et al available through Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2530
diff changeset
    54
    .AddAttribute ("RemoteStationManager", "XXX",
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
    55
                   Pointer (),
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
    56
                   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
    57
                                        &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
    58
                   MakePointerChecker<WifiRemoteStationManager> ())
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    59
    .AddTraceSource ("Rx", "XXX",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    60
                     MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    61
    .AddTraceSource ("Tx", "XXX",
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    62
                     MakeTraceSourceAccessor (&WifiNetDevice::m_txLogger))
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    63
    ;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    64
  return tid;
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
    65
}
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
    66
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    67
WifiNetDevice::WifiNetDevice ()
2562
01a2e3e1924d initialize properly mtu field.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2551
diff changeset
    68
  : m_mtu (0)
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    69
{}
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
WifiNetDevice::~WifiNetDevice ()
2002
32903f9a7315 add dispose methods in subclasses of WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
diff changeset
    71
{}
2530
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    72
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    73
void
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    74
WifiNetDevice::DoDispose (void)
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    75
{
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    76
  m_node = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    77
  m_mac->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    78
  m_phy->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    79
  m_stationManager->Dispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    80
  m_mac = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    81
  m_phy = 0;
2618
b2706c1a6c3b release the channel.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    82
  m_channel = 0;
2530
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    83
  m_stationManager = 0;
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    84
  // chain up.
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    85
  NetDevice::DoDispose ();
05f9cec44621 avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2528
diff changeset
    86
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    87
  
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
    88
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
    89
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
    90
{
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
  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
    92
  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
    93
    {
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_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
    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
          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
    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
      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
    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
          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
   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->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
   103
      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
   104
      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
   105
    }
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
}
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
   107
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
   108
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
   109
{
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
  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
   111
  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
   112
    {
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_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
   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
          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
   116
          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
   117
        }
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
      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
   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
          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
   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
      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
   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
          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
   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
    }
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
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
   129
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
   130
{
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
  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
   132
  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
   133
    {
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_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
   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
          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
   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
      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
   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
          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
   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
    }
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
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
   145
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
   146
{
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
  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
   148
  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
   149
    {
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
      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
   151
      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
   152
    }
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
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   154
Ptr<WifiMac> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   155
WifiNetDevice::GetMac (void) const
1998
41cd4e5694c2 dispose the channel from WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1995
diff changeset
   156
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   157
  return m_mac;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   158
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   159
Ptr<WifiPhy> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   160
WifiNetDevice::GetPhy (void) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   161
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   162
  return m_phy;
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
Ptr<WifiRemoteStationManager> 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   165
WifiNetDevice::GetRemoteStationManager (void) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   166
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   167
  return m_stationManager;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   168
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   169
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   170
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   171
WifiNetDevice::SetName(const std::string name)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   172
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   173
  m_name = 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
std::string 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   176
WifiNetDevice::GetName(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   177
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   178
  return m_name;
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
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   181
WifiNetDevice::SetIfIndex(const uint32_t index)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   182
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   183
  m_ifIndex = 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
uint32_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   186
WifiNetDevice::GetIfIndex(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   187
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   188
  return m_ifIndex;
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
Ptr<Channel> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   191
WifiNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   192
{
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
   193
  return m_channel;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   194
}
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
   195
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
   196
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
   197
{
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
  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
   199
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   200
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   201
WifiNetDevice::GetAddress (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   202
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   203
  return m_mac->GetAddress ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   204
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   205
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   206
WifiNetDevice::SetMtu (const uint16_t mtu)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   207
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   208
  Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   209
  if (mtu > maxMsduSize && mtu > 0)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   210
    {
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   211
      return false;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   212
    }
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   213
  m_mtu = mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   214
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   215
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   216
uint16_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   217
WifiNetDevice::GetMtu (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   218
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   219
  if (m_mtu == 0)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   220
    {
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   221
      Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   222
      m_mtu = maxMsduSize;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   223
    }
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   224
  return m_mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   225
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   226
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   227
WifiNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   228
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   229
  return m_phy != 0 && m_linkUp;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   230
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   231
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   232
WifiNetDevice::SetLinkChangeCallback (Callback<void> callback)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   233
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   234
  m_linkChange = callback;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   235
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   236
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   237
WifiNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   238
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   239
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   240
}
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   241
Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   242
WifiNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   243
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   244
  return Mac48Address::GetBroadcast ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   245
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   246
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   247
WifiNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   248
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   249
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   250
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   251
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   252
WifiNetDevice::GetMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   253
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   254
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   255
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   256
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   257
WifiNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   258
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   259
  return GetMulticast ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   260
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   261
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   262
WifiNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   263
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   264
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   265
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   266
bool 
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   267
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
   268
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   269
  NS_ASSERT (Mac48Address::IsMatchingType (dest));
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   270
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   271
  Mac48Address realTo = Mac48Address::ConvertFrom (dest);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   272
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   273
  LlcSnapHeader llc;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   274
  llc.SetType (protocolNumber);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   275
  packet->AddHeader (llc);
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
  m_txLogger (packet, realTo);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   278
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   279
  m_mac->Enqueue (packet, realTo);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   280
  return true;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   281
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   282
Ptr<Node> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   283
WifiNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   284
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   285
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   286
}
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
   287
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
   288
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
   289
{
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
   290
  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
   291
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   292
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   293
WifiNetDevice::NeedsArp (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 true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   296
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   297
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   298
WifiNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2292
diff changeset
   299
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   300
  m_forwardUp = cb;
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
   301
}
2151
7c63780653f2 add constructors to specify the address of a device
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2146
diff changeset
   302
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   303
void
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   304
WifiNetDevice::ForwardUp (Ptr<Packet> packet, const Mac48Address &from)
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   305
{
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
   306
  m_rxLogger (packet, from);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   307
  LlcSnapHeader llc;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   308
  packet->RemoveHeader (llc);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   309
  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
   310
}
2002
32903f9a7315 add dispose methods in subclasses of WifiNetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1999
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
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   313
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
   314
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   315
  m_linkUp = true;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   316
  if (!m_linkChange.IsNull ())
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   317
    {
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   318
      m_linkChange ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   319
    }
1956
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   320
}
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   321
void
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   322
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
   323
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   324
  m_linkUp = false;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   325
  if (!m_linkChange.IsNull ())
1964
041240a915f8 build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1956
diff changeset
   326
    {
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   327
      m_linkChange ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2510
diff changeset
   328
    }
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
   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
} // namespace ns3
e51ef0422485 missing file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   332