src/devices/wifi/wifi-net-device.cc
changeset 2965 4b28e9740e3b
parent 2961 2bcb3435483b
child 3435 1d704c128f1f
child 3480 a920df6b9f02
child 3878 3b7d0c1fce02
equal deleted inserted replaced
2964:4e8cb1577144 2965:4b28e9740e3b
    37 WifiNetDevice::GetTypeId (void)
    37 WifiNetDevice::GetTypeId (void)
    38 {
    38 {
    39   static TypeId tid = TypeId ("ns3::WifiNetDevice")
    39   static TypeId tid = TypeId ("ns3::WifiNetDevice")
    40     .SetParent<NetDevice> ()
    40     .SetParent<NetDevice> ()
    41     .AddAttribute ("Channel", "The channel attached to this device",
    41     .AddAttribute ("Channel", "The channel attached to this device",
    42                    Pointer (),
    42                    PointerValue (),
    43                    MakePointerAccessor (&WifiNetDevice::DoGetChannel,
    43                    MakePointerAccessor (&WifiNetDevice::DoGetChannel,
    44                                         &WifiNetDevice::SetChannel),
    44                                         &WifiNetDevice::SetChannel),
    45                    MakePointerChecker<WifiChannel> ())
    45                    MakePointerChecker<WifiChannel> ())
    46     .AddAttribute ("Phy", "The PHY layer attached to this device.",
    46     .AddAttribute ("Phy", "The PHY layer attached to this device.",
    47                    Pointer (),
    47                    PointerValue (),
    48                    MakePointerAccessor (&WifiNetDevice::GetPhy,
    48                    MakePointerAccessor (&WifiNetDevice::GetPhy,
    49                                         &WifiNetDevice::SetPhy),
    49                                         &WifiNetDevice::SetPhy),
    50                    MakePointerChecker<WifiPhy> ())
    50                    MakePointerChecker<WifiPhy> ())
    51     .AddAttribute ("Mac", "The MAC layer attached to this device.",
    51     .AddAttribute ("Mac", "The MAC layer attached to this device.",
    52                    Pointer (),
    52                    PointerValue (),
    53                    MakePointerAccessor (&WifiNetDevice::GetMac,
    53                    MakePointerAccessor (&WifiNetDevice::GetMac,
    54                                         &WifiNetDevice::SetMac),
    54                                         &WifiNetDevice::SetMac),
    55                    MakePointerChecker<WifiMac> ())
    55                    MakePointerChecker<WifiMac> ())
    56     .AddAttribute ("RemoteStationManager", "The station manager attached to this device.",
    56     .AddAttribute ("RemoteStationManager", "The station manager attached to this device.",
    57                    Pointer (),
    57                    PointerValue (),
    58                    MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
    58                    MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
    59                                         &WifiNetDevice::GetRemoteStationManager),
    59                                         &WifiNetDevice::GetRemoteStationManager),
    60                    MakePointerChecker<WifiRemoteStationManager> ())
    60                    MakePointerChecker<WifiRemoteStationManager> ())
    61     .AddTraceSource ("Rx", "Received payload from the MAC layer.",
    61     .AddTraceSource ("Rx", "Received payload from the MAC layer.",
    62                      MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
    62                      MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
   205   return m_mac->GetAddress ();
   205   return m_mac->GetAddress ();
   206 }
   206 }
   207 bool 
   207 bool 
   208 WifiNetDevice::SetMtu (const uint16_t mtu)
   208 WifiNetDevice::SetMtu (const uint16_t mtu)
   209 {
   209 {
   210   Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
   210   UintegerValue maxMsduSize;
   211   if (mtu > maxMsduSize && mtu > 0)
   211   m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
       
   212   if (mtu > maxMsduSize.Get () || mtu == 0)
   212     {
   213     {
   213       return false;
   214       return false;
   214     }
   215     }
   215   m_mtu = mtu;
   216   m_mtu = mtu;
   216   return true;
   217   return true;
   218 uint16_t 
   219 uint16_t 
   219 WifiNetDevice::GetMtu (void) const
   220 WifiNetDevice::GetMtu (void) const
   220 {
   221 {
   221   if (m_mtu == 0)
   222   if (m_mtu == 0)
   222     {
   223     {
   223       Uinteger maxMsduSize = m_mac->GetAttribute ("MaxMsduSize");
   224       UintegerValue maxMsduSize;
   224       m_mtu = maxMsduSize;
   225       m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
       
   226       m_mtu = maxMsduSize.Get ();
   225     }
   227     }
   226   return m_mtu;
   228   return m_mtu;
   227 }
   229 }
   228 bool 
   230 bool 
   229 WifiNetDevice::IsLinkUp (void) const
   231 WifiNetDevice::IsLinkUp (void) const