|
26 |
|
26 |
|
27 |
namespace ns3 { |
27 |
namespace ns3 { |
28 |
namespace dot11s { |
28 |
namespace dot11s { |
|
|
29 |
|
30 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkOpenFrame); |
31 |
|
32 |
PeerLinkOpenFrame::PeerLinkOpenFrame () : |
33 |
m_protocolVersion (IePeeringProtocol ()), |
34 |
m_capability (0), |
35 |
m_supportedRates (SupportedRates ()), |
36 |
m_meshId (IeMeshId ()), |
37 |
m_config (IeConfiguration ()) |
38 |
{} |
39 |
|
40 |
PeerLinkOpenFrame::PeerLinkOpenFrame (const IePeeringProtocol & protocol, |
41 |
uint16_t capability, |
42 |
const SupportedRates & supportedRates, |
43 |
const IeMeshId & meshId, |
44 |
const IeConfiguration & config) : |
45 |
m_protocolVersion (protocol), |
46 |
m_capability (capability), |
47 |
m_supportedRates (supportedRates), |
48 |
m_meshId (meshId), |
49 |
m_config (config) |
50 |
{} |
51 |
|
52 |
TypeId PeerLinkOpenFrame::GetTypeId () |
53 |
{ |
54 |
static TypeId tid = TypeId ("ns3::dot11s::PeerLinkOpenFrame") |
55 |
.SetParent<Header> () |
56 |
.AddConstructor<PeerLinkOpenFrame> (); |
57 |
return tid; |
58 |
} |
59 |
|
60 |
TypeId |
61 |
PeerLinkOpenFrame::GetInstanceTypeId () const |
62 |
{ |
63 |
return GetTypeId (); |
64 |
} |
65 |
void |
66 |
PeerLinkOpenFrame::Print (std::ostream &os) const |
67 |
{ |
68 |
|
69 |
} |
70 |
|
71 |
uint32_t |
72 |
PeerLinkOpenFrame::GetSerializedSize () const |
73 |
{ |
74 |
return m_protocolVersion.GetSerializedSize () |
75 |
+ 2 // capability |
76 |
+ m_supportedRates.GetSerializedSize () |
77 |
+ m_supportedRates.extended.GetSerializedSize () + |
78 |
+m_meshId.GetSerializedSize () |
79 |
+ m_config.GetSerializedSize (); |
80 |
} |
81 |
|
82 |
void |
83 |
PeerLinkOpenFrame::Serialize (Buffer::Iterator start) const |
84 |
{ |
85 |
Buffer::Iterator i = start; |
86 |
i = m_protocolVersion.Serialize (i); |
87 |
i.WriteHtolsbU16 (m_capability); |
88 |
i = m_supportedRates.Serialize (i); |
89 |
i = m_supportedRates.extended.Serialize (i); |
90 |
i = m_meshId.Serialize (i); |
91 |
i = m_config.Serialize (i); |
92 |
} |
93 |
|
94 |
uint32_t |
95 |
PeerLinkOpenFrame::Deserialize (Buffer::Iterator start) |
96 |
{ |
97 |
Buffer::Iterator i = start; |
98 |
//1. Read protocol: |
99 |
uint8_t id = i.ReadU8 (); |
100 |
uint8_t length = i.ReadU8 (); |
101 |
m_protocolVersion.DeserializeInformationField (i, length); |
102 |
i.Next (m_protocolVersion.GetInformationFieldSize ()); |
103 |
// 2. Read capability: |
104 |
m_capability = i.ReadLsbtohU16 (); |
105 |
// 3. read supported rates: |
106 |
i = m_supportedRates.Deserialize (i); |
107 |
i = m_supportedRates.extended.DeserializeIfPresent (i); |
108 |
// 4. read MESH ID |
109 |
id = i.ReadU8 (); |
110 |
length = i.ReadU8 (); |
111 |
m_meshId.DeserializeInformationField (i, length); |
112 |
i.Next (m_meshId.GetInformationFieldSize ()); |
113 |
// 5. Read Configuration: |
114 |
id = i.ReadU8 (); |
115 |
length = i.ReadU8 (); |
116 |
m_config.DeserializeInformationField (i, length); |
117 |
i.Next (m_config.GetInformationFieldSize ()); |
118 |
return i.GetDistanceFrom (start); |
119 |
} |
120 |
|
121 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkConfirmFrame); |
122 |
|
123 |
PeerLinkConfirmFrame::PeerLinkConfirmFrame () : |
124 |
m_protocolVersion (IePeeringProtocol ()), |
125 |
m_capability (0), |
126 |
m_aid (0), |
127 |
m_supportedRates (SupportedRates ()), |
128 |
m_config (IeConfiguration ()) |
129 |
{} |
130 |
|
131 |
PeerLinkConfirmFrame::PeerLinkConfirmFrame (const IePeeringProtocol & protocol, |
132 |
uint16_t capability, |
133 |
uint16_t assocId, |
134 |
const SupportedRates & supportedRates, |
135 |
const IeConfiguration & config) : |
136 |
m_protocolVersion (protocol), |
137 |
m_capability (capability), |
138 |
m_aid (assocId), |
139 |
m_supportedRates (supportedRates), |
140 |
m_config (config) |
141 |
{} |
142 |
|
143 |
TypeId PeerLinkConfirmFrame::GetTypeId () |
144 |
{ |
145 |
static TypeId tid = TypeId ("ns3::dot11s::PeerLinkConfirmFrame") |
146 |
.SetParent<Header> () |
147 |
.AddConstructor<PeerLinkConfirmFrame> (); |
148 |
return tid; |
149 |
} |
150 |
|
151 |
TypeId |
152 |
PeerLinkConfirmFrame::GetInstanceTypeId () const |
153 |
{ |
154 |
return GetTypeId (); |
155 |
} |
156 |
void |
157 |
PeerLinkConfirmFrame::Print (std::ostream &os) const |
158 |
{ |
159 |
|
160 |
} |
161 |
|
162 |
uint32_t |
163 |
PeerLinkConfirmFrame::GetSerializedSize () const |
164 |
{ |
165 |
return m_protocolVersion.GetSerializedSize () |
166 |
+ 2 // capability |
167 |
+ 2 // aid |
168 |
+ m_supportedRates.GetSerializedSize () |
169 |
+ m_supportedRates.extended.GetSerializedSize () + |
170 |
+m_config.GetSerializedSize (); |
171 |
} |
172 |
|
173 |
void |
174 |
PeerLinkConfirmFrame::Serialize (Buffer::Iterator start) const |
175 |
{ |
176 |
Buffer::Iterator i = start; |
177 |
i = m_protocolVersion.Serialize (i); |
178 |
i.WriteHtolsbU16 (m_capability); |
179 |
i.WriteHtolsbU16 (m_aid); |
180 |
i = m_supportedRates.Serialize (i); |
181 |
i = m_supportedRates.extended.Serialize (i); |
182 |
i = m_config.Serialize (i); |
183 |
} |
184 |
|
185 |
uint32_t |
186 |
PeerLinkConfirmFrame::Deserialize (Buffer::Iterator start) |
187 |
{ |
188 |
Buffer::Iterator i = start; |
189 |
//1. Read protocol: |
190 |
uint8_t id = i.ReadU8 (); |
191 |
uint8_t length = i.ReadU8 (); |
192 |
m_protocolVersion.DeserializeInformationField (i, length); |
193 |
i.Next (m_protocolVersion.GetInformationFieldSize ()); |
194 |
// 2. Read capability: |
195 |
m_capability = i.ReadLsbtohU16 (); |
196 |
// 3. Read AID |
197 |
m_aid = i.ReadLsbtohU16 (); |
198 |
// 4. read supported rates: |
199 |
i = m_supportedRates.Deserialize (i); |
200 |
i = m_supportedRates.extended.DeserializeIfPresent (i); |
201 |
// 5. Read Configuration: |
202 |
id = i.ReadU8 (); |
203 |
length = i.ReadU8 (); |
204 |
m_config.DeserializeInformationField (i, length); |
205 |
i.Next (m_config.GetInformationFieldSize ()); |
206 |
return i.GetDistanceFrom (start); |
207 |
} |
208 |
|
209 |
|
210 |
PeerLinkCloseFrame::PeerLinkCloseFrame () : |
211 |
m_protocolVersion (IePeeringProtocol ()), |
212 |
m_meshId (IeMeshId ()), |
213 |
m_reasonCode (0) |
214 |
{} |
215 |
PeerLinkCloseFrame::PeerLinkCloseFrame (const IePeeringProtocol & protocol, |
216 |
const IeMeshId & meshId, |
217 |
uint16_t reason) : |
218 |
m_protocolVersion (protocol), |
219 |
m_meshId (meshId), |
220 |
m_reasonCode (reason) |
221 |
{} |
222 |
|
223 |
TypeId |
224 |
PeerLinkCloseFrame::GetTypeId () |
225 |
{ |
226 |
static TypeId tid = TypeId ("ns3::dot11s::PeerLinkCloseFrame") |
227 |
.SetParent<Header> () |
228 |
.AddConstructor<PeerLinkCloseFrame> (); |
229 |
return tid; |
230 |
} |
231 |
|
232 |
TypeId |
233 |
PeerLinkCloseFrame::GetInstanceTypeId () const |
234 |
{ |
235 |
return GetTypeId (); |
236 |
} |
237 |
|
238 |
void |
239 |
PeerLinkCloseFrame::Print (std::ostream &os) const |
240 |
{ |
241 |
} |
242 |
|
243 |
uint32_t |
244 |
PeerLinkCloseFrame::GetSerializedSize () const |
245 |
{ |
246 |
return m_protocolVersion.GetSerializedSize () + |
247 |
m_meshId.GetSerializedSize () + |
248 |
2; |
249 |
} |
250 |
|
251 |
void |
252 |
PeerLinkCloseFrame::Serialize (Buffer::Iterator start) const |
253 |
{ |
254 |
Buffer::Iterator i = start; |
255 |
i = m_protocolVersion.Serialize (i); |
256 |
i = m_meshId.Serialize (i); |
257 |
i.WriteHtolsbU16 (m_reasonCode); |
258 |
} |
259 |
|
260 |
uint32_t |
261 |
PeerLinkCloseFrame::Deserialize (Buffer::Iterator start) |
262 |
{ |
263 |
Buffer::Iterator i = start; |
264 |
//1. Read protocol: |
265 |
uint8_t id = i.ReadU8 (); |
266 |
uint8_t length = i.ReadU8 (); |
267 |
m_protocolVersion.DeserializeInformationField (i, length); |
268 |
// 2. read MESH ID |
269 |
id = i.ReadU8 (); |
270 |
length = i.ReadU8 (); |
271 |
m_meshId.DeserializeInformationField (i, length); |
272 |
m_reasonCode = i.ReadLsbtohU16 (); |
273 |
return i.GetDistanceFrom (start); |
274 |
} |
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
29 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkFrameStart); |
297 |
NS_OBJECT_ENSURE_REGISTERED (PeerLinkFrameStart); |
30 |
|
298 |
|
31 |
PeerLinkFrameStart::PeerLinkFrameStart () : |
299 |
PeerLinkFrameStart::PeerLinkFrameStart () : |
|
82 |
retval.reasonCode = m_reasonCode; |
350 |
retval.reasonCode = m_reasonCode; |
83 |
return retval; |
351 |
return retval; |
84 |
} |
352 |
} |
|
|
353 |
|
85 |
TypeId |
354 |
TypeId |
86 |
PeerLinkFrameStart::GetTypeId () |
355 |
PeerLinkFrameStart::GetTypeId () |
87 |
{ |
356 |
{ |
|
172 |
PeerLinkFrameStart::Deserialize (Buffer::Iterator start) |
441 |
PeerLinkFrameStart::Deserialize (Buffer::Iterator start) |
173 |
{ |
442 |
{ |
174 |
Buffer::Iterator i = start; |
443 |
Buffer::Iterator i = start; |
|
|
444 |
std::cout << "m_subtype = " << (uint32_t)m_subtype << std::endl; |
175 |
NS_ASSERT (m_subtype < 3); |
445 |
NS_ASSERT (m_subtype < 3); |
176 |
{ |
446 |
{ |
177 |
uint8_t id = i.ReadU8 (); |
447 |
uint8_t id = i.ReadU8 (); |