82 // Beacon shall not be dropeed. May be needed to another plugins |
82 // Beacon shall not be dropeed. May be needed to another plugins |
83 return true; |
83 return true; |
84 } |
84 } |
85 if (header.IsAction ()) |
85 if (header.IsAction ()) |
86 { |
86 { |
87 WifiMeshActionHeader actionHdr; |
87 WifiActionHeader actionHdr; |
88 packet->RemoveHeader (actionHdr); |
88 packet->RemoveHeader (actionHdr); |
89 WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
89 WifiActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
90 // If can not handle - just return; |
90 // If can not handle - just return; |
91 if (actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PEERING_MGT) |
91 if (actionHdr.GetCategory () != WifiActionHeader::MESH_PEERING_MGT) |
92 { |
92 { |
93 return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ()); |
93 return m_protocol->IsActiveLink (m_ifIndex, header.GetAddr2 ()); |
94 } |
94 } |
95 m_stats.rxMgt++; |
95 m_stats.rxMgt++; |
96 m_stats.rxMgtBytes += packet->GetSize (); |
96 m_stats.rxMgtBytes += packet->GetSize (); |
102 peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.peerLink); |
102 peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.peerLink); |
103 packet->RemoveHeader (peerFrame); |
103 packet->RemoveHeader (peerFrame); |
104 fields = peerFrame.GetFields (); |
104 fields = peerFrame.GetFields (); |
105 NS_ASSERT (fields.subtype == actionValue.peerLink); |
105 NS_ASSERT (fields.subtype == actionValue.peerLink); |
106 } |
106 } |
107 if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CLOSE) && !(m_parent->CheckSupportedRates ( |
107 if ((actionValue.peerLink != WifiActionHeader::PEER_LINK_CLOSE) && !(m_parent->CheckSupportedRates ( |
108 fields.rates))) |
108 fields.rates))) |
109 { |
109 { |
110 m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
110 m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
111 // Broken peer link frame - drop it |
111 // Broken peer link frame - drop it |
112 m_stats.brokenMgt++; |
112 m_stats.brokenMgt++; |
113 return false; |
113 return false; |
114 } |
114 } |
115 if ((actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CONFIRM) && !fields.meshId.IsEqual ( |
115 if ((actionValue.peerLink != WifiActionHeader::PEER_LINK_CONFIRM) && !fields.meshId.IsEqual ( |
116 *(m_protocol->GetMeshId ()))) |
116 *(m_protocol->GetMeshId ()))) |
117 { |
117 { |
118 m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
118 m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress); |
119 // Broken peer link frame - drop it |
119 // Broken peer link frame - drop it |
120 m_stats.brokenMgt++; |
120 m_stats.brokenMgt++; |
128 NS_ASSERT (peerElement != 0); |
128 NS_ASSERT (peerElement != 0); |
129 //Check taht frame subtype corresponds peer link subtype |
129 //Check taht frame subtype corresponds peer link subtype |
130 if (peerElement->SubtypeIsOpen ()) |
130 if (peerElement->SubtypeIsOpen ()) |
131 { |
131 { |
132 m_stats.rxOpen++; |
132 m_stats.rxOpen++; |
133 NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN); |
133 NS_ASSERT (actionValue.peerLink == WifiActionHeader::PEER_LINK_OPEN); |
134 } |
134 } |
135 if (peerElement->SubtypeIsConfirm ()) |
135 if (peerElement->SubtypeIsConfirm ()) |
136 { |
136 { |
137 m_stats.rxConfirm++; |
137 m_stats.rxConfirm++; |
138 NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM); |
138 NS_ASSERT (actionValue.peerLink == WifiActionHeader::PEER_LINK_CONFIRM); |
139 } |
139 } |
140 if (peerElement->SubtypeIsClose ()) |
140 if (peerElement->SubtypeIsClose ()) |
141 { |
141 { |
142 m_stats.rxClose++; |
142 m_stats.rxClose++; |
143 NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE); |
143 NS_ASSERT (actionValue.peerLink == WifiActionHeader::PEER_LINK_CLOSE); |
144 } |
144 } |
145 //Deliver Peer link management frame to protocol: |
145 //Deliver Peer link management frame to protocol: |
146 m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, *peerElement, |
146 m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, *peerElement, |
147 fields.config); |
147 fields.config); |
148 // if we can handle a frame - drop it |
148 // if we can handle a frame - drop it |
154 PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, |
154 PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, |
155 Mac48Address from, Mac48Address to) |
155 Mac48Address from, Mac48Address to) |
156 { |
156 { |
157 if (header.IsAction ()) |
157 if (header.IsAction ()) |
158 { |
158 { |
159 WifiMeshActionHeader actionHdr; |
159 WifiActionHeader actionHdr; |
160 packet->PeekHeader (actionHdr); |
160 packet->PeekHeader (actionHdr); |
161 WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
161 WifiActionHeader::ActionValue actionValue = actionHdr.GetAction (); |
162 if (actionHdr.GetCategory () == WifiMeshActionHeader::MESH_PEERING_MGT) |
162 if (actionHdr.GetCategory () == WifiActionHeader::MESH_PEERING_MGT) |
163 { |
163 { |
164 return true; |
164 return true; |
165 } |
165 } |
166 } |
166 } |
167 if (header.GetAddr1 ().IsGroup ()) |
167 if (header.GetAddr1 ().IsGroup ()) |
209 fields.meshId = *(m_protocol->GetMeshId ()); |
209 fields.meshId = *(m_protocol->GetMeshId ()); |
210 fields.config = meshConfig; |
210 fields.config = meshConfig; |
211 PeerLinkFrameStart plinkFrame; |
211 PeerLinkFrameStart plinkFrame; |
212 //Create an 802.11 frame header: |
212 //Create an 802.11 frame header: |
213 //Send management frame to MAC: |
213 //Send management frame to MAC: |
214 WifiMeshActionHeader actionHdr; |
214 WifiActionHeader actionHdr; |
215 if (peerElement.SubtypeIsOpen ()) |
215 if (peerElement.SubtypeIsOpen ()) |
216 { |
216 { |
217 m_stats.txOpen++; |
217 m_stats.txOpen++; |
218 WifiMeshActionHeader::ActionValue action; |
218 WifiActionHeader::ActionValue action; |
219 action.peerLink = WifiMeshActionHeader::PEER_LINK_OPEN; |
219 action.peerLink = WifiActionHeader::PEER_LINK_OPEN; |
220 fields.subtype = WifiMeshActionHeader::PEER_LINK_OPEN; |
220 fields.subtype = WifiActionHeader::PEER_LINK_OPEN; |
221 actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
221 actionHdr.SetAction (WifiActionHeader::MESH_PEERING_MGT, action); |
222 } |
222 } |
223 if (peerElement.SubtypeIsConfirm ()) |
223 if (peerElement.SubtypeIsConfirm ()) |
224 { |
224 { |
225 m_stats.txConfirm++; |
225 m_stats.txConfirm++; |
226 WifiMeshActionHeader::ActionValue action; |
226 WifiActionHeader::ActionValue action; |
227 action.peerLink = WifiMeshActionHeader::PEER_LINK_CONFIRM; |
227 action.peerLink = WifiActionHeader::PEER_LINK_CONFIRM; |
228 fields.aid = aid; |
228 fields.aid = aid; |
229 fields.subtype = WifiMeshActionHeader::PEER_LINK_CONFIRM; |
229 fields.subtype = WifiActionHeader::PEER_LINK_CONFIRM; |
230 actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
230 actionHdr.SetAction (WifiActionHeader::MESH_PEERING_MGT, action); |
231 } |
231 } |
232 if (peerElement.SubtypeIsClose ()) |
232 if (peerElement.SubtypeIsClose ()) |
233 { |
233 { |
234 m_stats.txClose++; |
234 m_stats.txClose++; |
235 WifiMeshActionHeader::ActionValue action; |
235 WifiActionHeader::ActionValue action; |
236 action.peerLink = WifiMeshActionHeader::PEER_LINK_CLOSE; |
236 action.peerLink = WifiActionHeader::PEER_LINK_CLOSE; |
237 fields.subtype = WifiMeshActionHeader::PEER_LINK_CLOSE; |
237 fields.subtype = WifiActionHeader::PEER_LINK_CLOSE; |
238 fields.reasonCode = peerElement.GetReasonCode (); |
238 fields.reasonCode = peerElement.GetReasonCode (); |
239 actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action); |
239 actionHdr.SetAction (WifiActionHeader::MESH_PEERING_MGT, action); |
240 } |
240 } |
241 plinkFrame.SetPlinkFrameStart (fields); |
241 plinkFrame.SetPlinkFrameStart (fields); |
242 packet->AddHeader (plinkFrame); |
242 packet->AddHeader (plinkFrame); |
243 packet->AddHeader (actionHdr); |
243 packet->AddHeader (actionHdr); |
244 m_stats.txMgt++; |
244 m_stats.txMgt++; |