1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2007,2008,2009 INRIA, UDcast
4 *
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
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20 * <amine.ismail@UDcast.com>
21 */
22
23 #include "mac-messages.h"
24 #include "ns3/address-utils.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/log.h"
27 #include "wimax-tlv.h"
28
29 namespace ns3 {
30
31 NS_LOG_COMPONENT_DEFINE ("MACMESSAGES");
32
33 NS_OBJECT_ENSURE_REGISTERED (ManagementMessageType);
34
ManagementMessageType(void)35 ManagementMessageType::ManagementMessageType (void)
36 : m_type (~0)
37 {
38 }
39
ManagementMessageType(uint8_t type)40 ManagementMessageType::ManagementMessageType (uint8_t type)
41 : m_type (type)
42 {
43 }
44
~ManagementMessageType(void)45 ManagementMessageType::~ManagementMessageType (void)
46 {
47 }
48
49 void
SetType(uint8_t type)50 ManagementMessageType::SetType (uint8_t type)
51 {
52 m_type = type;
53 }
54
55 uint8_t
GetType(void) const56 ManagementMessageType::GetType (void) const
57 {
58 return m_type;
59 }
60
61 std::string
GetName(void) const62 ManagementMessageType::GetName (void) const
63 {
64 return "Management Message Type";
65 }
66
67 TypeId
GetTypeId(void)68 ManagementMessageType::GetTypeId (void)
69 {
70 static TypeId tid =
71 TypeId ("ns3::ManagementMessageType")
72 .SetParent<Header> ()
73 .SetGroupName("Wimax")
74 .AddConstructor<ManagementMessageType> ()
75 ;
76 return tid;
77 }
78
79 TypeId
GetInstanceTypeId(void) const80 ManagementMessageType::GetInstanceTypeId (void) const
81 {
82 return GetTypeId ();
83 }
84
85 void
Print(std::ostream & os) const86 ManagementMessageType::Print (std::ostream &os) const
87 {
88 os << " management message type = " << (uint32_t) m_type;
89 }
90
91 uint32_t
GetSerializedSize(void) const92 ManagementMessageType::GetSerializedSize (void) const
93 {
94 return 1;
95 }
96
97 void
Serialize(Buffer::Iterator start) const98 ManagementMessageType::Serialize (Buffer::Iterator start) const
99 {
100 Buffer::Iterator i = start;
101 i.WriteU8 (m_type);
102 }
103
104 uint32_t
Deserialize(Buffer::Iterator start)105 ManagementMessageType::Deserialize (Buffer::Iterator start)
106 {
107 Buffer::Iterator i = start;
108 m_type = i.ReadU8 ();
109 return i.GetDistanceFrom (start);
110 }
111
112 // ---------------------------------------------------------------------
113
114 NS_OBJECT_ENSURE_REGISTERED (RngReq);
115
RngReq(void)116 RngReq::RngReq (void)
117 : m_reserved (0),
118 m_reqDlBurstProfile (0),
119 m_macAddress (Mac48Address ("00:00:00:00:00:00")),
120 m_rangingAnomalies (0)
121 {
122 }
123
~RngReq(void)124 RngReq::~RngReq (void)
125 {
126 }
127
128 void
SetReqDlBurstProfile(uint8_t reqDlBurstProfile)129 RngReq::SetReqDlBurstProfile (uint8_t reqDlBurstProfile)
130 {
131 m_reqDlBurstProfile = reqDlBurstProfile;
132 }
133
134 void
SetMacAddress(Mac48Address macAddress)135 RngReq::SetMacAddress (Mac48Address macAddress)
136 {
137 m_macAddress = macAddress;
138 }
139
140 void
SetRangingAnomalies(uint8_t rangingAnomalies)141 RngReq::SetRangingAnomalies (uint8_t rangingAnomalies)
142 {
143 m_rangingAnomalies = rangingAnomalies;
144 }
145
146 uint8_t
GetReqDlBurstProfile(void) const147 RngReq::GetReqDlBurstProfile (void) const
148 {
149 return m_reqDlBurstProfile;
150 }
151
152 Mac48Address
GetMacAddress(void) const153 RngReq::GetMacAddress (void) const
154 {
155 return m_macAddress;
156 }
157
158 uint8_t
GetRangingAnomalies(void) const159 RngReq::GetRangingAnomalies (void) const
160 {
161 return m_rangingAnomalies;
162 }
163
164 std::string
GetName(void) const165 RngReq::GetName (void) const
166 {
167 return "RNG-REQ";
168 }
169
170 TypeId
GetTypeId(void)171 RngReq::GetTypeId (void)
172 {
173 static TypeId tid = TypeId ("ns3::RngReq")
174 .SetParent<Header> ()
175 .SetGroupName("Wimax")
176 .AddConstructor<RngReq> ()
177 ;
178 return tid;
179 }
180
181 TypeId
GetInstanceTypeId(void) const182 RngReq::GetInstanceTypeId (void) const
183 {
184 return GetTypeId ();
185 }
186
187 void
Print(std::ostream & os) const188 RngReq::Print (std::ostream &os) const
189 {
190 os << " requested dl burst profile = " << (uint32_t) m_reqDlBurstProfile << ", mac address = " << m_macAddress
191 << ", ranging anomalies = " << (uint32_t) m_rangingAnomalies;
192 }
193
194 void
PrintDebug(void) const195 RngReq::PrintDebug (void) const
196 {
197 NS_LOG_DEBUG (" requested dl burst profile = " << (uint32_t) m_reqDlBurstProfile << ", mac address = "
198 << m_macAddress << ", ranging anomalies = "
199 << (uint32_t) m_rangingAnomalies);
200 }
201
202 uint32_t
GetSerializedSize(void) const203 RngReq::GetSerializedSize (void) const
204 {
205 return 1 + 1 + 6 + 1;
206 }
207
208 void
Serialize(Buffer::Iterator start) const209 RngReq::Serialize (Buffer::Iterator start) const
210 {
211 Buffer::Iterator i = start;
212 i.WriteU8 (m_reserved);
213 i.WriteU8 (m_reqDlBurstProfile);
214 WriteTo (i, m_macAddress);
215 i.WriteU8 (m_rangingAnomalies);
216 }
217
218 uint32_t
Deserialize(Buffer::Iterator start)219 RngReq::Deserialize (Buffer::Iterator start)
220 {
221 Buffer::Iterator i = start;
222 m_reserved = i.ReadU8 ();
223 m_reqDlBurstProfile = i.ReadU8 ();
224 ReadFrom (i, m_macAddress);
225 m_rangingAnomalies = i.ReadU8 ();
226
227 return i.GetDistanceFrom (start);
228 }
229
230 // ---------------------------------------------------------------------
231
232 NS_OBJECT_ENSURE_REGISTERED (RngRsp);
233
RngRsp(void)234 RngRsp::RngRsp (void)
235 : m_reserved (0),
236 m_timingAdjust (0),
237 m_powerLevelAdjust (0),
238 m_offsetFreqAdjust (0),
239 m_rangStatus (0),
240 m_dlFreqOverride (0),
241 m_ulChnlIdOverride (0),
242 m_dlOperBurstProfile (0),
243 m_macAddress (Mac48Address ("00:00:00:00:00:00")),
244 m_basicCid (),
245 m_primaryCid (),
246 m_aasBdcastPermission (0),
247 m_frameNumber (0),
248 m_initRangOppNumber (0),
249 m_rangSubchnl (0)
250 {
251 }
252
~RngRsp(void)253 RngRsp::~RngRsp (void)
254 {
255 }
256
257 void
SetTimingAdjust(uint32_t timingAdjust)258 RngRsp::SetTimingAdjust (uint32_t timingAdjust)
259 {
260 m_timingAdjust = timingAdjust;
261 }
262
263 void
SetPowerLevelAdjust(uint8_t powerLevelAdjust)264 RngRsp::SetPowerLevelAdjust (uint8_t powerLevelAdjust)
265 {
266 m_powerLevelAdjust = powerLevelAdjust;
267 }
268
269 void
SetOffsetFreqAdjust(uint32_t offsetFreqAdjust)270 RngRsp::SetOffsetFreqAdjust (uint32_t offsetFreqAdjust)
271 {
272 m_offsetFreqAdjust = offsetFreqAdjust;
273 }
274
275 void
SetRangStatus(uint8_t rangStatus)276 RngRsp::SetRangStatus (uint8_t rangStatus)
277 {
278 m_rangStatus = rangStatus;
279 }
280
281 void
SetDlFreqOverride(uint32_t dlFreqOverride)282 RngRsp::SetDlFreqOverride (uint32_t dlFreqOverride)
283 {
284 m_dlFreqOverride = dlFreqOverride;
285 }
286
287 void
SetUlChnlIdOverride(uint8_t ulChnlIdOverride)288 RngRsp::SetUlChnlIdOverride (uint8_t ulChnlIdOverride)
289 {
290 m_ulChnlIdOverride = ulChnlIdOverride;
291 }
292
293 void
SetDlOperBurstProfile(uint16_t dlOperBurstProfile)294 RngRsp::SetDlOperBurstProfile (uint16_t dlOperBurstProfile)
295 {
296 m_dlOperBurstProfile = dlOperBurstProfile;
297 }
298
299 void
SetMacAddress(Mac48Address macAddress)300 RngRsp::SetMacAddress (Mac48Address macAddress)
301 {
302 m_macAddress = macAddress;
303 }
304
305 void
SetBasicCid(Cid basicCid)306 RngRsp::SetBasicCid (Cid basicCid)
307 {
308 m_basicCid = basicCid;
309 }
310
311 void
SetPrimaryCid(Cid primaryCid)312 RngRsp::SetPrimaryCid (Cid primaryCid)
313 {
314 m_primaryCid = primaryCid;
315 }
316
317 void
SetAasBdcastPermission(uint8_t aasBdcastPermission)318 RngRsp::SetAasBdcastPermission (uint8_t aasBdcastPermission)
319 {
320 m_aasBdcastPermission = aasBdcastPermission;
321 }
322
323 void
SetFrameNumber(uint32_t frameNumber)324 RngRsp::SetFrameNumber (uint32_t frameNumber)
325 {
326 m_frameNumber = frameNumber;
327 }
328
329 void
SetInitRangOppNumber(uint8_t initRangOppNumber)330 RngRsp::SetInitRangOppNumber (uint8_t initRangOppNumber)
331 {
332 m_initRangOppNumber = initRangOppNumber;
333 }
334
335 void
SetRangSubchnl(uint8_t rangSubchnl)336 RngRsp::SetRangSubchnl (uint8_t rangSubchnl)
337 {
338 m_rangSubchnl = rangSubchnl;
339 }
340
341 uint32_t
GetTimingAdjust(void) const342 RngRsp::GetTimingAdjust (void) const
343 {
344 return m_timingAdjust;
345 }
346
347 uint8_t
GetPowerLevelAdjust(void) const348 RngRsp::GetPowerLevelAdjust (void) const
349 {
350 return m_powerLevelAdjust;
351 }
352
353 uint32_t
GetOffsetFreqAdjust(void) const354 RngRsp::GetOffsetFreqAdjust (void) const
355 {
356 return m_offsetFreqAdjust;
357 }
358
359 uint8_t
GetRangStatus(void) const360 RngRsp::GetRangStatus (void) const
361 {
362 return m_rangStatus;
363 }
364
365 uint32_t
GetDlFreqOverride(void) const366 RngRsp::GetDlFreqOverride (void) const
367 {
368 return m_dlFreqOverride;
369 }
370
371 uint8_t
GetUlChnlIdOverride(void) const372 RngRsp::GetUlChnlIdOverride (void) const
373 {
374 return m_ulChnlIdOverride;
375 }
376
377 uint16_t
GetDlOperBurstProfile(void) const378 RngRsp::GetDlOperBurstProfile (void) const
379 {
380 return m_dlOperBurstProfile;
381 }
382
383 Mac48Address
GetMacAddress(void) const384 RngRsp::GetMacAddress (void) const
385 {
386 return m_macAddress;
387 }
388
389 Cid
GetBasicCid(void) const390 RngRsp::GetBasicCid (void) const
391 {
392 return m_basicCid;
393 }
394
395 Cid
GetPrimaryCid(void) const396 RngRsp::GetPrimaryCid (void) const
397 {
398 return m_primaryCid;
399 }
400
401 uint8_t
GetAasBdcastPermission(void) const402 RngRsp::GetAasBdcastPermission (void) const
403 {
404 return m_aasBdcastPermission;
405 }
406
407 uint32_t
GetFrameNumber(void) const408 RngRsp::GetFrameNumber (void) const
409 {
410 return m_frameNumber;
411 }
412
413 uint8_t
GetInitRangOppNumber(void) const414 RngRsp::GetInitRangOppNumber (void) const
415 {
416 return m_initRangOppNumber;
417 }
418
419 uint8_t
GetRangSubchnl(void) const420 RngRsp::GetRangSubchnl (void) const
421 {
422 return m_rangSubchnl;
423 }
424
425 std::string
GetName(void) const426 RngRsp::GetName (void) const
427 {
428 return "RNG-RSP";
429 }
430
431 TypeId
GetTypeId(void)432 RngRsp::GetTypeId (void)
433 {
434 static TypeId tid = TypeId ("ns3::RngRsp")
435 .SetParent<Header> ()
436 .SetGroupName("Wimax")
437 .AddConstructor<RngRsp> ()
438 ;
439 return tid;
440 }
441
442 TypeId
GetInstanceTypeId(void) const443 RngRsp::GetInstanceTypeId (void) const
444 {
445 return GetTypeId ();
446 }
447
448 void
Print(std::ostream & os) const449 RngRsp::Print (std::ostream &os) const
450 {
451 os << " timing adjust = " << m_timingAdjust << ", power level adjust = " << (uint32_t) m_powerLevelAdjust
452 << ", offset freq adjust = " << m_offsetFreqAdjust << ", ranging status = " << (uint32_t) m_rangStatus
453 << ", dl freq override = " << m_dlFreqOverride << ", ul channel id override = " << (uint32_t) m_ulChnlIdOverride
454 << ", dl operational burst profile = " << (uint32_t) m_dlOperBurstProfile << ", mac address = " << m_macAddress
455 << ", basic cid = " << m_basicCid << ", primary management cid = " << m_primaryCid
456 << ", aas broadcast permission = " << (uint32_t) m_aasBdcastPermission << ", frame number = " << m_frameNumber
457 << ", initial ranging opportunity number = " << (uint32_t) m_initRangOppNumber << ", ranging subchannel = "
458 << (uint32_t) m_rangSubchnl;
459 }
460
461 uint32_t
GetSerializedSize(void) const462 RngRsp::GetSerializedSize (void) const
463 {
464 return 1 + 4 + 1 + 4 + 1 + 4 + 1 + 2 + 6 + 2 + 2 + 1 + 4 + 1 + 1;
465 }
466
467 void
Serialize(Buffer::Iterator start) const468 RngRsp::Serialize (Buffer::Iterator start) const
469 {
470 Buffer::Iterator i = start;
471 i.WriteU8 (m_reserved);
472 i.WriteU32 (m_timingAdjust);
473 i.WriteU8 (m_powerLevelAdjust);
474 i.WriteU32 (m_offsetFreqAdjust);
475 i.WriteU8 (m_rangStatus);
476 i.WriteU32 (m_dlFreqOverride);
477 i.WriteU8 (m_ulChnlIdOverride);
478 i.WriteU16 (m_dlOperBurstProfile);
479 WriteTo (i, m_macAddress);
480 i.WriteU16 (m_basicCid.GetIdentifier ());
481 i.WriteU16 (m_primaryCid.GetIdentifier ());
482 i.WriteU8 (m_aasBdcastPermission);
483 i.WriteU32 (m_frameNumber);
484 i.WriteU8 (m_initRangOppNumber);
485 i.WriteU8 (m_rangSubchnl);
486 }
487
488 uint32_t
Deserialize(Buffer::Iterator start)489 RngRsp::Deserialize (Buffer::Iterator start)
490 {
491 Buffer::Iterator i = start;
492 m_reserved = i.ReadU8 ();
493 m_timingAdjust = i.ReadU32 ();
494 m_powerLevelAdjust = i.ReadU8 ();
495 m_offsetFreqAdjust = i.ReadU32 ();
496 m_rangStatus = i.ReadU8 ();
497 m_dlFreqOverride = i.ReadU32 ();
498 m_ulChnlIdOverride = i.ReadU8 ();
499 m_dlOperBurstProfile = i.ReadU16 ();
500 ReadFrom (i, m_macAddress); // length (6) shall also be written in packet instead of hard coded, see ARP example
501 m_basicCid = i.ReadU16 ();
502 m_primaryCid = i.ReadU16 ();
503 m_aasBdcastPermission = i.ReadU8 ();
504 m_frameNumber = i.ReadU32 ();
505 m_initRangOppNumber = i.ReadU8 ();
506 m_rangSubchnl = i.ReadU8 ();
507
508 return i.GetDistanceFrom (start);
509 }
510
511 // ---------------------------------------------------------------------
512
513 NS_OBJECT_ENSURE_REGISTERED (DsaReq);
514
DsaReq(void)515 DsaReq::DsaReq (void)
516 : m_transactionId (0),
517 m_sfid (0),
518 m_cid (),
519 m_serviceFlow (ServiceFlow::SF_DIRECTION_DOWN)
520 {
521 }
522
DsaReq(ServiceFlow sf)523 DsaReq::DsaReq (ServiceFlow sf)
524 {
525 m_transactionId = 0;
526 m_serviceFlow = sf;
527 }
528
~DsaReq(void)529 DsaReq::~DsaReq (void)
530 {
531 }
532
533 void
SetTransactionId(uint16_t transactionId)534 DsaReq::SetTransactionId (uint16_t transactionId)
535 {
536 m_transactionId = transactionId;
537 }
538
539 uint16_t
GetTransactionId(void) const540 DsaReq::GetTransactionId (void) const
541 {
542 return m_transactionId;
543 }
544
545 void
SetSfid(uint32_t sfid)546 DsaReq::SetSfid (uint32_t sfid)
547 {
548 m_sfid = sfid;
549 }
550
551 uint32_t
GetSfid(void) const552 DsaReq::GetSfid (void) const
553 {
554 return m_sfid;
555 }
556
557 void
SetCid(Cid cid)558 DsaReq::SetCid (Cid cid)
559 {
560 m_cid = cid;
561 }
562
563 Cid
GetCid(void) const564 DsaReq::GetCid (void) const
565 {
566 return m_cid;
567 }
568
569
570 std::string
GetName(void) const571 DsaReq::GetName (void) const
572 {
573 return "DSA-REQ";
574 }
575
576 TypeId
GetTypeId(void)577 DsaReq::GetTypeId (void)
578 {
579 static TypeId tid = TypeId ("ns3::DsaReq")
580 .SetParent<Header> ()
581 .SetGroupName("Wimax")
582 .AddConstructor<DsaReq> ()
583 ;
584 return tid;
585 }
586
587 TypeId
GetInstanceTypeId(void) const588 DsaReq::GetInstanceTypeId (void) const
589 {
590 return GetTypeId ();
591 }
592
593 void
Print(std::ostream & os) const594 DsaReq::Print (std::ostream &os) const
595 {
596 os << " transaction id = " << (uint32_t) m_transactionId << ", m_sfid = " << m_sfid << ", cid = " << m_cid;
597 }
598
599 uint32_t
GetSerializedSize(void) const600 DsaReq::GetSerializedSize (void) const
601 {
602 Tlv t = m_serviceFlow.ToTlv ();
603 uint32_t size = 2 + t.GetSerializedSize ();
604 return size;
605 }
606
607 void
Serialize(Buffer::Iterator start) const608 DsaReq::Serialize (Buffer::Iterator start) const
609 {
610 Buffer::Iterator i = start;
611 i.WriteU16 (m_transactionId);
612 Tlv t = m_serviceFlow.ToTlv ();
613 t.Serialize (i);
614 }
615
616 uint32_t
Deserialize(Buffer::Iterator start)617 DsaReq::Deserialize (Buffer::Iterator start)
618 {
619 Buffer::Iterator i = start;
620 m_transactionId = i.ReadU16 ();
621 Tlv tlv;
622 uint32_t size = tlv.Deserialize (i);
623 m_serviceFlow = ServiceFlow (tlv);
624 return size + 2;
625 }
626
627 ServiceFlow
GetServiceFlow(void) const628 DsaReq::GetServiceFlow (void) const
629 {
630 return m_serviceFlow;
631 }
632
633 void
SetServiceFlow(ServiceFlow sf)634 DsaReq::SetServiceFlow (ServiceFlow sf)
635 {
636 m_serviceFlow = sf;
637 }
638
639 // ---------------------------------------------------------------------
640
641 NS_OBJECT_ENSURE_REGISTERED (DsaRsp);
642
DsaRsp(void)643 DsaRsp::DsaRsp (void)
644 : m_transactionId (0),
645 m_confirmationCode (0),
646 m_sfid (0),
647 m_cid ()
648 {
649 }
650
~DsaRsp(void)651 DsaRsp::~DsaRsp (void)
652 {
653 }
654
655 void
SetTransactionId(uint16_t transactionId)656 DsaRsp::SetTransactionId (uint16_t transactionId)
657 {
658 m_transactionId = transactionId;
659 }
660
661 uint16_t
GetTransactionId(void) const662 DsaRsp::GetTransactionId (void) const
663 {
664 return m_transactionId;
665 }
666
667 ServiceFlow
GetServiceFlow(void) const668 DsaRsp::GetServiceFlow (void) const
669 {
670 return m_serviceFlow;
671 }
672
673 void
SetServiceFlow(ServiceFlow sf)674 DsaRsp::SetServiceFlow (ServiceFlow sf)
675 {
676 m_serviceFlow = sf;
677 }
678
679 void
SetConfirmationCode(uint16_t confirmationCode)680 DsaRsp::SetConfirmationCode (uint16_t confirmationCode)
681 {
682 m_confirmationCode = confirmationCode;
683 }
684
685 uint16_t
GetConfirmationCode(void) const686 DsaRsp::GetConfirmationCode (void) const
687 {
688 return m_confirmationCode;
689 }
690
691 void
SetSfid(uint32_t sfid)692 DsaRsp::SetSfid (uint32_t sfid)
693 {
694 m_sfid = sfid;
695 }
696
697 uint32_t
GetSfid(void) const698 DsaRsp::GetSfid (void) const
699 {
700 return m_sfid;
701 }
702
703 void
SetCid(Cid cid)704 DsaRsp::SetCid (Cid cid)
705 {
706 m_cid = cid;
707 }
708
709 Cid
GetCid(void) const710 DsaRsp::GetCid (void) const
711 {
712 return m_cid;
713 }
714
715 std::string
GetName(void) const716 DsaRsp::GetName (void) const
717 {
718 return "DSA-RSP";
719 }
720
721 TypeId
GetTypeId(void)722 DsaRsp::GetTypeId (void)
723 {
724 static TypeId tid = TypeId ("ns3::DsaRsp")
725 .SetParent<Header> ()
726 .SetGroupName("Wimax")
727 .AddConstructor<DsaRsp> ()
728 ;
729 return tid;
730 }
731
732 TypeId
GetInstanceTypeId(void) const733 DsaRsp::GetInstanceTypeId (void) const
734 {
735 return GetTypeId ();
736 }
737
738 void
Print(std::ostream & os) const739 DsaRsp::Print (std::ostream &os) const
740 {
741 os << " transaction id = " << (uint32_t) m_transactionId << ", confirmation code = " << (uint32_t) m_confirmationCode
742 << ", m_sfid = " << m_sfid << ", cid = " << m_cid;
743 }
744
745 uint32_t
GetSerializedSize(void) const746 DsaRsp::GetSerializedSize (void) const
747 {
748 return 2 + 1 + m_serviceFlow.ToTlv ().GetSerializedSize ();
749 }
750
751
752 void
Serialize(Buffer::Iterator start) const753 DsaRsp::Serialize (Buffer::Iterator start) const
754 {
755 Buffer::Iterator i = start;
756
757 i.WriteU16 (m_transactionId);
758 i.WriteU8 (m_confirmationCode);
759 m_serviceFlow.ToTlv ().Serialize (i);
760 }
761
762 uint32_t
Deserialize(Buffer::Iterator start)763 DsaRsp::Deserialize (Buffer::Iterator start)
764 {
765 Buffer::Iterator i = start;
766
767 m_transactionId = i.ReadU16 ();
768 m_confirmationCode = i.ReadU8 ();
769 Tlv tlv;
770 uint32_t size = tlv.Deserialize (i);
771 m_serviceFlow = ServiceFlow (tlv);
772 return size + 3;
773 }
774
775 // ---------------------------------------------------------------------
776
777 NS_OBJECT_ENSURE_REGISTERED (DsaAck);
778
DsaAck(void)779 DsaAck::DsaAck (void)
780 : m_transactionId (0),
781 m_confirmationCode (0)
782 {
783 }
784
~DsaAck(void)785 DsaAck::~DsaAck (void)
786 {
787 }
788
789 void
SetTransactionId(uint16_t transactionId)790 DsaAck::SetTransactionId (uint16_t transactionId)
791 {
792 m_transactionId = transactionId;
793 }
794
795 uint16_t
GetTransactionId(void) const796 DsaAck::GetTransactionId (void) const
797 {
798 return m_transactionId;
799 }
800
801 void
SetConfirmationCode(uint16_t confirmationCode)802 DsaAck::SetConfirmationCode (uint16_t confirmationCode)
803 {
804 m_confirmationCode = confirmationCode;
805 }
806
807 uint16_t
GetConfirmationCode(void) const808 DsaAck::GetConfirmationCode (void) const
809 {
810 return m_confirmationCode;
811 }
812
813 std::string
GetName(void) const814 DsaAck::GetName (void) const
815 {
816 return "DSA-ACK";
817 }
818
819 TypeId
GetTypeId(void)820 DsaAck::GetTypeId (void)
821 {
822 static TypeId tid = TypeId ("ns3::DsaAck")
823 .SetParent<Header> ()
824 .SetGroupName("Wimax")
825 .AddConstructor<DsaAck> ()
826 ;
827 return tid;
828 }
829
830 TypeId
GetInstanceTypeId(void) const831 DsaAck::GetInstanceTypeId (void) const
832 {
833 return GetTypeId ();
834 }
835
836 void
Print(std::ostream & os) const837 DsaAck::Print (std::ostream &os) const
838 {
839 os << " transaction id = " << (uint32_t) m_transactionId << ", confirmation code = " << (uint32_t) m_confirmationCode;
840 }
841
842 uint32_t
GetSerializedSize(void) const843 DsaAck::GetSerializedSize (void) const
844 {
845 return 2 + 1;
846 }
847
848 void
Serialize(Buffer::Iterator start) const849 DsaAck::Serialize (Buffer::Iterator start) const
850 {
851 Buffer::Iterator i = start;
852 i.WriteU16 (m_transactionId);
853 i.WriteU8 (m_confirmationCode);
854 }
855
856 uint32_t
Deserialize(Buffer::Iterator start)857 DsaAck::Deserialize (Buffer::Iterator start)
858 {
859 Buffer::Iterator i = start;
860 m_transactionId = i.ReadU16 ();
861 m_confirmationCode = i.ReadU8 ();
862
863 return i.GetDistanceFrom (start);
864 }
865
866 } // namespace ns3
867