OLD | NEW |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005 INRIA | 3 * Copyright (c) 2005 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as· | 6 * it under the terms of the GNU General Public License version 2 as· |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 28 matching lines...) Expand all Loading... |
39 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) {std::clog << "[mac=" << m_low->Ge
tAddress () << "] ";} | 39 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) {std::clog << "[mac=" << m_low->Ge
tAddress () << "] ";} |
40 | 40 |
41 TypeId· | 41 TypeId· |
42 AdhocWifiMac::GetTypeId (void) | 42 AdhocWifiMac::GetTypeId (void) |
43 { | 43 { |
44 static TypeId tid = TypeId ("ns3::AdhocWifiMac") | 44 static TypeId tid = TypeId ("ns3::AdhocWifiMac") |
45 .SetParent<WifiMac> () | 45 .SetParent<WifiMac> () |
46 .AddConstructor<AdhocWifiMac> () | 46 .AddConstructor<AdhocWifiMac> () |
47 .AddAttribute ("DcaTxop", "The DcaTxop object", | 47 .AddAttribute ("DcaTxop", "The DcaTxop object", |
48 PointerValue (), | 48 PointerValue (), |
49 MakePointerAccessor (&AdhocWifiMac::DoGetDcaTxop), | 49 MakePointerAccessor (&AdhocWifiMac::GetDcaTxop, |
| 50 &AdhocWifiMac::SetDcaTxop), |
50 MakePointerChecker<DcaTxop> ())· | 51 MakePointerChecker<DcaTxop> ())· |
51 ; | 52 ; |
52 return tid; | 53 return tid; |
53 } | 54 } |
54 | 55 |
55 AdhocWifiMac::AdhocWifiMac () | 56 AdhocWifiMac::AdhocWifiMac () |
56 { | 57 { |
57 m_rxMiddle = new MacRxMiddle (); | 58 m_rxMiddle = new MacRxMiddle (); |
58 m_rxMiddle->SetForwardCallback (MakeCallback (&AdhocWifiMac::ForwardUp, this))
; | 59 m_rxMiddle->SetForwardCallback (MakeCallback (&AdhocWifiMac::ForwardUp, this))
; |
59 | 60 |
60 m_low = CreateObject<MacLow> (); | 61 m_low = CreateObject<MacLow> (); |
61 m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); | 62 m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); |
62 m_low->SetBssid (GetBssid ()); | 63 m_low->SetBssid (GetBssid ()); |
63 | 64 |
64 m_dcfManager = new DcfManager (); | 65 m_dcfManager = new DcfManager (); |
65 m_dcfManager->SetupLowListener (m_low); | 66 m_dcfManager->SetupLowListener (m_low); |
66 | |
67 m_dca = CreateObject<DcaTxop> (); | |
68 m_dca->SetLow (m_low); | |
69 m_dca->SetManager (m_dcfManager); | |
70 } | 67 } |
71 AdhocWifiMac::~AdhocWifiMac () | 68 AdhocWifiMac::~AdhocWifiMac () |
72 {} | 69 {} |
73 | 70 |
74 void | 71 void |
75 AdhocWifiMac::DoDispose (void) | 72 AdhocWifiMac::DoDispose (void) |
76 { | 73 { |
77 delete m_rxMiddle; | 74 delete m_rxMiddle; |
78 delete m_dcfManager; | 75 delete m_dcfManager; |
79 m_rxMiddle = 0; | 76 m_rxMiddle = 0; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return false; | 240 return false; |
244 } | 241 } |
245 | 242 |
246 void· | 243 void· |
247 AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr) | 244 AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr) |
248 { | 245 { |
249 NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 (
)); | 246 NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 (
)); |
250 m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ()); | 247 m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ()); |
251 } | 248 } |
252 Ptr<DcaTxop> | 249 Ptr<DcaTxop> |
253 AdhocWifiMac::DoGetDcaTxop(void) const | 250 AdhocWifiMac::GetDcaTxop(void) const |
254 { | 251 { |
255 return m_dca; | 252 return m_dca; |
256 } | 253 } |
257 | 254 |
| 255 void |
| 256 AdhocWifiMac::SetDcaTxop (Ptr<DcaTxop> dcaTxop) |
| 257 { |
| 258 m_dca = dcaTxop; |
| 259 m_dca->SetLow (m_low); |
| 260 m_dca->SetManager (m_dcfManager); |
| 261 } |
| 262 |
| 263 |
258 } // namespace ns3 | 264 } // namespace ns3 |
OLD | NEW |