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 PointerValue (), |
42 PointerValue (), |
43 MakePointerAccessor (&WifiNetDevice::DoGetChannel, |
43 MakePointerAccessor (&WifiNetDevice::DoGetChannel), |
44 &WifiNetDevice::SetChannel), |
|
45 MakePointerChecker<WifiChannel> ()) |
44 MakePointerChecker<WifiChannel> ()) |
46 .AddAttribute ("Phy", "The PHY layer attached to this device.", |
45 .AddAttribute ("Phy", "The PHY layer attached to this device.", |
47 PointerValue (), |
46 PointerValue (), |
48 MakePointerAccessor (&WifiNetDevice::GetPhy, |
47 MakePointerAccessor (&WifiNetDevice::GetPhy, |
49 &WifiNetDevice::SetPhy), |
48 &WifiNetDevice::SetPhy), |
79 m_mac->Dispose (); |
79 m_mac->Dispose (); |
80 m_phy->Dispose (); |
80 m_phy->Dispose (); |
81 m_stationManager->Dispose (); |
81 m_stationManager->Dispose (); |
82 m_mac = 0; |
82 m_mac = 0; |
83 m_phy = 0; |
83 m_phy = 0; |
84 m_channel = 0; |
|
85 m_stationManager = 0; |
84 m_stationManager = 0; |
86 // chain up. |
85 // chain up. |
87 NetDevice::DoDispose (); |
86 NetDevice::DoDispose (); |
88 } |
87 } |
|
88 |
|
89 void |
|
90 WifiNetDevice::CompleteConfig (void) |
|
91 { |
|
92 if (m_mac == 0 || |
|
93 m_phy == 0 || |
|
94 m_stationManager == 0 || |
|
95 m_node == 0 || |
|
96 m_configComplete) |
|
97 { |
|
98 return; |
|
99 } |
|
100 m_mac->SetWifiRemoteStationManager (m_stationManager); |
|
101 m_mac->SetWifiPhy (m_phy); |
|
102 m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this)); |
|
103 m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this)); |
|
104 m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); |
|
105 m_stationManager->SetupPhy (m_phy); |
|
106 m_configComplete = true; |
|
107 } |
89 |
108 |
90 void |
109 void |
91 WifiNetDevice::SetMac (Ptr<WifiMac> mac) |
110 WifiNetDevice::SetMac (Ptr<WifiMac> mac) |
92 { |
111 { |
93 m_mac = mac; |
112 m_mac = mac; |
94 if (m_mac != 0) |
113 CompleteConfig (); |
95 { |
|
96 if (m_stationManager != 0) |
|
97 { |
|
98 m_mac->SetWifiRemoteStationManager (m_stationManager); |
|
99 } |
|
100 if (m_phy != 0) |
|
101 { |
|
102 m_mac->SetWifiPhy (m_phy); |
|
103 } |
|
104 m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this)); |
|
105 m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this)); |
|
106 m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); |
|
107 } |
|
108 } |
114 } |
109 void |
115 void |
110 WifiNetDevice::SetPhy (Ptr<WifiPhy> phy) |
116 WifiNetDevice::SetPhy (Ptr<WifiPhy> phy) |
111 { |
117 { |
112 m_phy = phy; |
118 m_phy = phy; |
113 if (m_phy != 0) |
119 CompleteConfig (); |
114 { |
|
115 if (m_stationManager != 0) |
|
116 { |
|
117 m_stationManager->SetupPhy (m_phy); |
|
118 } |
|
119 if (m_mac != 0) |
|
120 { |
|
121 m_mac->SetWifiPhy (m_phy); |
|
122 } |
|
123 } |
|
124 } |
120 } |
125 void |
121 void |
126 WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager) |
122 WifiNetDevice::SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager) |
127 { |
123 { |
128 m_stationManager = manager; |
124 m_stationManager = manager; |
129 if (m_stationManager != 0) |
125 CompleteConfig (); |
130 { |
|
131 if (m_phy != 0) |
|
132 { |
|
133 m_stationManager->SetupPhy (m_phy); |
|
134 } |
|
135 if (m_mac != 0) |
|
136 { |
|
137 m_mac->SetWifiRemoteStationManager (m_stationManager); |
|
138 } |
|
139 } |
|
140 } |
|
141 void |
|
142 WifiNetDevice::SetChannel (Ptr<WifiChannel> channel) |
|
143 { |
|
144 m_channel = channel; |
|
145 } |
126 } |
146 Ptr<WifiMac> |
127 Ptr<WifiMac> |
147 WifiNetDevice::GetMac (void) const |
128 WifiNetDevice::GetMac (void) const |
148 { |
129 { |
149 return m_mac; |
130 return m_mac; |
180 return m_ifIndex; |
161 return m_ifIndex; |
181 } |
162 } |
182 Ptr<Channel> |
163 Ptr<Channel> |
183 WifiNetDevice::GetChannel (void) const |
164 WifiNetDevice::GetChannel (void) const |
184 { |
165 { |
185 return m_channel; |
166 return m_phy->GetChannel (); |
186 } |
167 } |
187 Ptr<WifiChannel> |
168 Ptr<WifiChannel> |
188 WifiNetDevice::DoGetChannel (void) const |
169 WifiNetDevice::DoGetChannel (void) const |
189 { |
170 { |
190 return m_channel; |
171 return m_phy->GetChannel (); |
191 } |
172 } |
192 Address |
173 Address |
193 WifiNetDevice::GetAddress (void) const |
174 WifiNetDevice::GetAddress (void) const |
194 { |
175 { |
195 return m_mac->GetAddress (); |
176 return m_mac->GetAddress (); |