LEFT | RIGHT |
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) 2006, 2009 INRIA | 3 * Copyright (c) 2006, 2009 INRIA |
4 * Copyright (c) 2009 MIRKO BANCHI | 4 * Copyright (c) 2009 MIRKO BANCHI |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | 18 * |
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
20 * Mirko Banchi <mk.banchi@gmail.com> | 20 * Mirko Banchi <mk.banchi@gmail.com> |
21 */ | 21 */ |
22 | 22 |
| 23 #include "ns3/nstime.h" |
23 #include "ns3/address-utils.h" | 24 #include "ns3/address-utils.h" |
24 #include "wifi-mac-header.h" | 25 #include "wifi-mac-header.h" |
25 | 26 |
26 namespace ns3 { | 27 namespace ns3 { |
27 | 28 |
28 NS_OBJECT_ENSURE_REGISTERED (WifiMacHeader); | 29 NS_OBJECT_ENSURE_REGISTERED (WifiMacHeader); |
29 | 30 |
30 /// type enumeration | 31 /// type enumeration |
31 enum | 32 enum |
32 { | 33 { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 m_ctrlSubtype = 15; | 250 m_ctrlSubtype = 15; |
250 break; | 251 break; |
251 } | 252 } |
252 m_ctrlToDs = 0; | 253 m_ctrlToDs = 0; |
253 m_ctrlFromDs = 0; | 254 m_ctrlFromDs = 0; |
254 } | 255 } |
255 | 256 |
256 void | 257 void |
257 WifiMacHeader::SetDuration (Time duration) | 258 WifiMacHeader::SetDuration (Time duration) |
258 { | 259 { |
259 int64_t duration_us = (int64_t)ceil ((double)duration.GetNanoSeconds () / 1000
); | 260 int64_t duration_us = static_cast<int64_t>(ceil (static_cast<double> (duration
.GetNanoSeconds ()) / 1000)); |
260 NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff); | 261 NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff); |
261 m_duration = static_cast<uint16_t> (duration_us); | 262 m_duration = static_cast<uint16_t> (duration_us); |
262 } | 263 } |
263 | 264 |
264 void WifiMacHeader::SetId (uint16_t id) | 265 void WifiMacHeader::SetId (uint16_t id) |
265 { | 266 { |
266 m_duration = id; | 267 m_duration = id; |
267 } | 268 } |
268 | 269 |
269 void WifiMacHeader::SetSequenceNumber (uint16_t seq) | 270 void WifiMacHeader::SetSequenceNumber (uint16_t seq) |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 { | 656 { |
656 return (m_seqSeq << 4) | m_seqFrag; | 657 return (m_seqSeq << 4) | m_seqFrag; |
657 } | 658 } |
658 | 659 |
659 uint16_t | 660 uint16_t |
660 WifiMacHeader::GetSequenceNumber (void) const | 661 WifiMacHeader::GetSequenceNumber (void) const |
661 { | 662 { |
662 return m_seqSeq; | 663 return m_seqSeq; |
663 } | 664 } |
664 | 665 |
665 uint16_t | 666 uint8_t |
666 WifiMacHeader::GetFragmentNumber (void) const | 667 WifiMacHeader::GetFragmentNumber (void) const |
667 { | 668 { |
668 return m_seqFrag; | 669 return m_seqFrag; |
669 } | 670 } |
670 | 671 |
671 bool | 672 bool |
672 WifiMacHeader::IsRetry (void) const | 673 WifiMacHeader::IsRetry (void) const |
673 { | 674 { |
674 return (m_ctrlRetry == 1); | 675 return (m_ctrlRetry == 1); |
675 } | 676 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 { | 714 { |
714 NS_ASSERT (IsQosData ()); | 715 NS_ASSERT (IsQosData ()); |
715 return (m_amsduPresent == 1); | 716 return (m_amsduPresent == 1); |
716 } | 717 } |
717 | 718 |
718 uint8_t | 719 uint8_t |
719 WifiMacHeader::GetQosTid (void) const | 720 WifiMacHeader::GetQosTid (void) const |
720 { | 721 { |
721 NS_ASSERT (IsQosData ()); | 722 NS_ASSERT (IsQosData ()); |
722 return m_qosTid; | 723 return m_qosTid; |
723 } | |
724 | |
725 uint8_t | |
726 WifiMacHeader::GetQosTxopLimit (void) const | |
727 { | |
728 NS_ASSERT (IsQosData ()); | |
729 return (uint8_t)m_qosStuff; | |
730 } | 724 } |
731 | 725 |
732 uint16_t | 726 uint16_t |
733 WifiMacHeader::GetFrameControl (void) const | 727 WifiMacHeader::GetFrameControl (void) const |
734 { | 728 { |
735 uint16_t val = 0; | 729 uint16_t val = 0; |
736 val |= (m_ctrlType << 2) & (0x3 << 2); | 730 val |= (m_ctrlType << 2) & (0x3 << 2); |
737 val |= (m_ctrlSubtype << 4) & (0xf << 4); | 731 val |= (m_ctrlSubtype << 4) & (0xf << 4); |
738 val |= (m_ctrlToDs << 8) & (0x1 << 8); | 732 val |= (m_ctrlToDs << 8) & (0x1 << 8); |
739 val |= (m_ctrlFromDs << 9) & (0x1 << 9); | 733 val |= (m_ctrlFromDs << 9) & (0x1 << 9); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 FOO (QOSDATA_CFACK); | 865 FOO (QOSDATA_CFACK); |
872 FOO (QOSDATA_CFPOLL); | 866 FOO (QOSDATA_CFPOLL); |
873 FOO (QOSDATA_CFACK_CFPOLL); | 867 FOO (QOSDATA_CFACK_CFPOLL); |
874 FOO (QOSDATA_NULL); | 868 FOO (QOSDATA_NULL); |
875 FOO (QOSDATA_NULL_CFPOLL); | 869 FOO (QOSDATA_NULL_CFPOLL); |
876 FOO (QOSDATA_NULL_CFACK_CFPOLL); | 870 FOO (QOSDATA_NULL_CFACK_CFPOLL); |
877 default: | 871 default: |
878 return "ERROR"; | 872 return "ERROR"; |
879 } | 873 } |
880 #undef FOO | 874 #undef FOO |
881 #ifndef WIN32 | |
882 // needed to make gcc 4.0.1 ppc darwin happy. | 875 // needed to make gcc 4.0.1 ppc darwin happy. |
883 return "BIG_ERROR"; | 876 return "BIG_ERROR"; |
884 #endif | |
885 } | 877 } |
886 | 878 |
887 TypeId | 879 TypeId |
888 WifiMacHeader::GetTypeId (void) | 880 WifiMacHeader::GetTypeId (void) |
889 { | 881 { |
890 static TypeId tid = TypeId ("ns3::WifiMacHeader") | 882 static TypeId tid = TypeId ("ns3::WifiMacHeader") |
891 .SetParent<Header> () | 883 .SetParent<Header> () |
892 .SetGroupName ("Wifi") | 884 .SetGroupName ("Wifi") |
893 .AddConstructor<WifiMacHeader> () | 885 .AddConstructor<WifiMacHeader> () |
894 ; | 886 ; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 if (m_ctrlSubtype & 0x08) | 1093 if (m_ctrlSubtype & 0x08) |
1102 { | 1094 { |
1103 SetQosControl (i.ReadLsbtohU16 ()); | 1095 SetQosControl (i.ReadLsbtohU16 ()); |
1104 } | 1096 } |
1105 break; | 1097 break; |
1106 } | 1098 } |
1107 return i.GetDistanceFrom (start); | 1099 return i.GetDistanceFrom (start); |
1108 } | 1100 } |
1109 | 1101 |
1110 } //namespace ns3 | 1102 } //namespace ns3 |
LEFT | RIGHT |