|
|
| 27 |
namespace ns3 { |
27 |
namespace ns3 { |
| 28 |
|
28 |
|
| 29 |
SupportedRates::SupportedRates () |
29 |
SupportedRates::SupportedRates () |
| 30 |
: extended (this), |
30 |
: m_nRates (0) |
| 31 |
m_nRates (0) |
|
|
| 32 |
{ |
31 |
{ |
| 33 |
} |
32 |
} |
| 34 |
|
33 |
|
|
|
| 102 |
return (m_rates[i] & 0x7f) * 500000; |
101 |
return (m_rates[i] & 0x7f) * 500000; |
| 103 |
} |
102 |
} |
| 104 |
|
103 |
|
|
|
104 |
SupportedRatesIE::SupportedRatesIE (SupportedRates *rates) |
| 105 |
{ |
| 106 |
m_supportedRatesStore = rates; |
| 107 |
m_supportedRatesStoreReadOnly = rates; |
| 108 |
} |
| 109 |
|
| 110 |
SupportedRatesIE::SupportedRatesIE (const SupportedRates *rates) |
| 111 |
{ |
| 112 |
m_supportedRatesStoreReadOnly = rates; |
| 113 |
m_supportedRatesStore = NULL; |
| 114 |
} |
| 115 |
|
| 105 |
WifiInformationElementId |
116 |
WifiInformationElementId |
| 106 |
SupportedRates::ElementId () const |
117 |
SupportedRatesIE::ElementId () const |
| 107 |
{ |
118 |
{ |
| 108 |
return IE_SUPPORTED_RATES; |
119 |
return IE_SUPPORTED_RATES; |
| 109 |
} |
120 |
} |
| 110 |
uint8_t |
121 |
uint8_t |
| 111 |
SupportedRates::GetInformationFieldSize () const |
122 |
SupportedRatesIE::GetInformationFieldSize () const |
| 112 |
{ |
123 |
{ |
|
|
124 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 125 |
// happy to treat it as const in this method. |
| 126 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 113 |
// The Supported Rates Information Element contains only the first 8 |
127 |
// The Supported Rates Information Element contains only the first 8 |
| 114 |
// supported rates - the remainder appear in the Extended Supported |
128 |
// supported rates - the remainder appear in the Extended Supported |
| 115 |
// Rates Information Element. |
129 |
// Rates Information Element. |
| 116 |
return m_nRates > 8 ? 8 : m_nRates; |
130 |
return std::max((int)m_supportedRatesStoreReadOnly->m_nRates, 8); |
| 117 |
} |
131 |
} |
| 118 |
void |
132 |
void |
| 119 |
SupportedRates::SerializeInformationField (Buffer::Iterator start) const |
133 |
SupportedRatesIE::SerializeInformationField (Buffer::Iterator start) const |
| 120 |
{ |
134 |
{ |
|
|
135 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 136 |
// happy to treat it as const in this method. |
| 137 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 121 |
// The Supported Rates Information Element contains only the first 8 |
138 |
// The Supported Rates Information Element contains only the first 8 |
| 122 |
// supported rates - the remainder appear in the Extended Supported |
139 |
// supported rates - the remainder appear in the Extended Supported |
| 123 |
// Rates Information Element. |
140 |
// Rates Information Element. |
| 124 |
start.Write (m_rates, m_nRates > 8 ? 8 : m_nRates); |
141 |
start.Write (m_supportedRatesStoreReadOnly->m_rates, |
|
|
142 |
std::max((int)m_supportedRatesStoreReadOnly->m_nRates, 8)); |
| 125 |
} |
143 |
} |
| 126 |
uint8_t |
144 |
uint8_t |
| 127 |
SupportedRates::DeserializeInformationField (Buffer::Iterator start, |
145 |
SupportedRatesIE::DeserializeInformationField (Buffer::Iterator start, |
| 128 |
uint8_t length) |
146 |
uint8_t length) |
| 129 |
{ |
147 |
{ |
|
|
148 |
// Confirm that we have a pointer to a SupportedRates object that we |
| 149 |
// can modify (as opposed to one we have to treat as const). |
| 150 |
NS_ASSERT (m_supportedRatesStore); |
| 130 |
NS_ASSERT (length <= 8); |
151 |
NS_ASSERT (length <= 8); |
| 131 |
m_nRates = length; |
152 |
m_supportedRatesStore->m_nRates = length; |
| 132 |
start.Read (m_rates, m_nRates); |
153 |
start.Read (m_supportedRatesStore->m_rates, m_supportedRatesStore->m_nRates); |
| 133 |
return m_nRates; |
154 |
return m_supportedRatesStore->m_nRates; |
| 134 |
} |
155 |
} |
| 135 |
|
156 |
|
| 136 |
ExtendedSupportedRatesIE::ExtendedSupportedRatesIE () |
157 |
|
|
|
158 |
|
| 159 |
ExtendedSupportedRatesIE::ExtendedSupportedRatesIE (SupportedRates *rates) |
| 137 |
{ |
160 |
{ |
|
|
161 |
m_supportedRatesStore = rates; |
| 162 |
m_supportedRatesStoreReadOnly = rates; |
| 138 |
} |
163 |
} |
| 139 |
|
164 |
|
| 140 |
ExtendedSupportedRatesIE::ExtendedSupportedRatesIE (SupportedRates *sr) |
165 |
ExtendedSupportedRatesIE::ExtendedSupportedRatesIE (const SupportedRates *rates) |
| 141 |
{ |
166 |
{ |
| 142 |
m_supportedRates = sr; |
167 |
m_supportedRatesStoreReadOnly = rates; |
|
|
168 |
m_supportedRatesStore = NULL; |
| 143 |
} |
169 |
} |
| 144 |
|
170 |
|
| 145 |
WifiInformationElementId |
171 |
WifiInformationElementId |
|
|
| 151 |
uint8_t |
177 |
uint8_t |
| 152 |
ExtendedSupportedRatesIE::GetInformationFieldSize () const |
178 |
ExtendedSupportedRatesIE::GetInformationFieldSize () const |
| 153 |
{ |
179 |
{ |
|
|
180 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 181 |
// happy to treat it as const in this method. |
| 182 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 154 |
// If there are 8 or fewer rates then we don't need an Extended |
183 |
// If there are 8 or fewer rates then we don't need an Extended |
| 155 |
// Supported Rates IE and so could return zero here, but we're |
184 |
// Supported Rates IE and so could return zero here, but we're |
| 156 |
// overriding the GetSerializedSize() method, so if this function is |
185 |
// overriding the GetSerializedSize() method, so if this function is |
| 157 |
// invoked in that case then it indicates a programming error. Hence |
186 |
// invoked in that case then it indicates a programming error. Hence |
| 158 |
// we have an assertion on that condition. |
187 |
// we have an assertion on that condition. |
| 159 |
NS_ASSERT (m_supportedRates->m_nRates > 8); |
188 |
NS_ASSERT (m_supportedRatesStoreReadOnly->m_nRates > 8); |
| 160 |
|
189 |
|
| 161 |
// The number of rates we have beyond the initial 8 is the size of |
190 |
// The number of rates we have beyond the initial 8 is the size of |
| 162 |
// the information field. |
191 |
// the information field. |
| 163 |
return (m_supportedRates->m_nRates - 8); |
192 |
return (m_supportedRatesStoreReadOnly->m_nRates - 8); |
| 164 |
} |
193 |
} |
| 165 |
|
194 |
|
| 166 |
void |
195 |
void |
| 167 |
ExtendedSupportedRatesIE::SerializeInformationField (Buffer::Iterator start) const |
196 |
ExtendedSupportedRatesIE::SerializeInformationField (Buffer::Iterator start) const |
| 168 |
{ |
197 |
{ |
|
|
198 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 199 |
// happy to treat it as const in this method. |
| 200 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 169 |
// If there are 8 or fewer rates then there should be no Extended |
201 |
// If there are 8 or fewer rates then there should be no Extended |
| 170 |
// Supported Rates Information Element at all so being here would |
202 |
// Supported Rates Information Element at all so being here would |
| 171 |
// seemingly indicate a programming error. |
203 |
// seemingly indicate a programming error. |
|
|
| 173 |
// Our overridden version of the Serialize() method should ensure |
205 |
// Our overridden version of the Serialize() method should ensure |
| 174 |
// that this routine is never invoked in that case (by ensuring that |
206 |
// that this routine is never invoked in that case (by ensuring that |
| 175 |
// WifiInformationElement::Serialize() is not invoked). |
207 |
// WifiInformationElement::Serialize() is not invoked). |
| 176 |
NS_ASSERT (m_supportedRates->m_nRates > 8); |
208 |
NS_ASSERT (m_supportedRatesStoreReadOnly->m_nRates > 8); |
| 177 |
start.Write (m_supportedRates->m_rates + 8, m_supportedRates->m_nRates - 8); |
209 |
start.Write (m_supportedRatesStoreReadOnly->m_rates + 8, |
|
|
210 |
m_supportedRatesStoreReadOnly->m_nRates - 8); |
| 178 |
} |
211 |
} |
| 179 |
|
212 |
|
| 180 |
Buffer::Iterator |
213 |
Buffer::Iterator |
| 181 |
ExtendedSupportedRatesIE::Serialize (Buffer::Iterator start) const |
214 |
ExtendedSupportedRatesIE::Serialize (Buffer::Iterator start) const |
| 182 |
{ |
215 |
{ |
|
|
216 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 217 |
// happy to treat it as const in this method. |
| 218 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 183 |
// If there are 8 or fewer rates then we don't need an Extended |
219 |
// If there are 8 or fewer rates then we don't need an Extended |
| 184 |
// Supported Rates IE, so we don't serialise anything. |
220 |
// Supported Rates IE, so we don't serialise anything. |
| 185 |
if (m_supportedRates->m_nRates <= 8) |
221 |
if (m_supportedRatesStoreReadOnly->m_nRates <= 8) |
| 186 |
{ |
222 |
{ |
| 187 |
return start; |
223 |
return start; |
| 188 |
} |
224 |
} |
|
|
| 194 |
uint16_t |
230 |
uint16_t |
| 195 |
ExtendedSupportedRatesIE::GetSerializedSize () const |
231 |
ExtendedSupportedRatesIE::GetSerializedSize () const |
| 196 |
{ |
232 |
{ |
|
|
233 |
// Confirm that we have a pointer to a SupportedRates object. We're |
| 234 |
// happy to treat it as const in this method. |
| 235 |
NS_ASSERT (m_supportedRatesStoreReadOnly); |
| 197 |
// If there are 8 or fewer rates then we don't need an Extended |
236 |
// If there are 8 or fewer rates then we don't need an Extended |
| 198 |
// Supported Rates IE, so it's serialised length will be zero. |
237 |
// Supported Rates IE, so it's serialised length will be zero. |
| 199 |
if (m_supportedRates->m_nRates <= 8) |
238 |
if (m_supportedRatesStoreReadOnly->m_nRates <= 8) |
| 200 |
{ |
239 |
{ |
| 201 |
return 0; |
240 |
return 0; |
| 202 |
} |
241 |
} |
|
|
| 210 |
ExtendedSupportedRatesIE::DeserializeInformationField (Buffer::Iterator start, |
249 |
ExtendedSupportedRatesIE::DeserializeInformationField (Buffer::Iterator start, |
| 211 |
uint8_t length) |
250 |
uint8_t length) |
| 212 |
{ |
251 |
{ |
|
|
252 |
// Confirm that we have a pointer to a SupportedRates object that we |
| 253 |
// can modify (as opposed to one we have to treat as const). |
| 254 |
NS_ASSERT (m_supportedRatesStore); |
| 213 |
NS_ASSERT (length > 0); |
255 |
NS_ASSERT (length > 0); |
| 214 |
NS_ASSERT (m_supportedRates->m_nRates + length <= MAX_SUPPORTED_RATES); |
256 |
NS_ASSERT (m_supportedRatesStore->m_nRates + length <= MAX_SUPPORTED_RATES); |
| 215 |
start.Read (m_supportedRates->m_rates + m_supportedRates->m_nRates, length); |
257 |
start.Read (m_supportedRatesStore->m_rates + m_supportedRatesStore->m_nRates, |
| 216 |
m_supportedRates->m_nRates += length; |
258 |
length); |
|
|
259 |
m_supportedRatesStore->m_nRates += length; |
| 217 |
return length; |
260 |
return length; |
| 218 |
} |
261 |
} |
| 219 |
|
262 |
|