This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
capability-information.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 INRIA
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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "capability-information.h"
22 #include "ns3/log.h"
23 
24 namespace ns3 {
25 
26 NS_LOG_COMPONENT_DEFINE ("CapabilityInformation");
27 
29  : m_capability (0)
30 {
31  NS_LOG_FUNCTION (this);
32 }
33 
34 void
36 {
37  NS_LOG_FUNCTION (this);
38  Set (0);
39  Clear (1);
40 }
41 
42 void
44 {
45  NS_LOG_FUNCTION (this);
46  Clear (0);
47  Set (1);
48 }
49 
50 void
52 {
53  NS_LOG_FUNCTION (this);
54  if (shortPreamble)
55  {
56  Set (5);
57  }
58 }
59 
60 bool
62 {
63  NS_LOG_FUNCTION (this);
64  return Is (0);
65 }
66 
67 bool
69 {
70  NS_LOG_FUNCTION (this);
71  return Is (1);
72 }
73 
74 bool
76 {
77  NS_LOG_FUNCTION (this);
78  return Is (5);
79 }
80 
81 void
83 {
84  NS_LOG_FUNCTION (this << static_cast<uint32_t> (n));
85  uint32_t mask = 1 << n;
86  m_capability |= mask;
87 }
88 
89 void
91 {
92  NS_LOG_FUNCTION (this << static_cast<uint32_t> (n));
93  uint32_t mask = 1 << n;
94  m_capability &= ~mask;
95 }
96 
97 bool
98 CapabilityInformation::Is (uint8_t n) const
99 {
100  NS_LOG_FUNCTION (this << static_cast<uint32_t> (n));
101  uint32_t mask = 1 << n;
102  return (m_capability & mask) == mask;
103 }
104 
105 uint32_t
107 {
108  NS_LOG_FUNCTION (this);
109  return 2;
110 }
111 
114 {
115  NS_LOG_FUNCTION (this << &start);
117  return start;
118 }
119 
122 {
123  NS_LOG_FUNCTION (this << &start);
124  m_capability = start.ReadLsbtohU16 ();
125  return start;
126 }
127 
128 } //namespace ns3
bool IsIbss(void) const
Check if the Independent BSS (IBSS) bit in the capability information field is set to 1...
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetIbss(void)
Set the Independent BSS (IBSS) bit in the capability information field.
Buffer::Iterator Deserialize(Buffer::Iterator start)
Deserialize capability information from the given buffer.
def start()
Definition: core.py:1482
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Buffer::Iterator Serialize(Buffer::Iterator start) const
Serialize capability information to the given buffer.
iterator in a Buffer instance
Definition: buffer.h:98
bool Is(uint8_t n) const
Check if bit n is set to 1.
void SetEss(void)
Set the Extended Service Set (ESS) bit in the capability information field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetShortPreamble(bool shortPreamble)
Set the short preamble bit in the capability information field.
void Set(uint8_t n)
Set bit n to 1.
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:910
bool IsEss(void) const
Check if the Extended Service Set (ESS) bit in the capability information field is set to 1...
uint32_t GetSerializedSize(void) const
Return the serialized size of capability information.
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1065
void Clear(uint8_t n)
Set bit n to 0.
bool IsShortPreamble(void) const
Check if the short preamble bit in the capability information field is set to 1.