A Discrete-Event Network Simulator
API
erp-information.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Sébastien Deronne
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: Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "erp-information.h"
22 
23 namespace ns3 {
24 
26  : m_erpInformation (0),
27  m_erpSupported (0)
28 {
29 }
30 
33 {
34  return IE_ERP_INFORMATION;
35 }
36 
37 void
38 ErpInformation::SetErpSupported (uint8_t erpSupported)
39 {
40  m_erpSupported = erpSupported;
41 }
42 
43 void
44 ErpInformation::SetBarkerPreambleMode (uint8_t barkerPreambleMode)
45 {
46  m_erpInformation |= (barkerPreambleMode & 0x01) << 2;
47 }
48 
49 void
50 ErpInformation::SetUseProtection (uint8_t useProtection)
51 {
52  m_erpInformation |= (useProtection & 0x01) << 1;
53 }
54 
55 void
56 ErpInformation::SetNonErpPresent (uint8_t nonErpPresent)
57 {
58  m_erpInformation |= nonErpPresent & 0x01;
59 }
60 
61 uint8_t
63 {
64  return ((m_erpInformation >> 2) & 0x01);
65 }
66 
67 uint8_t
69 {
70  return ((m_erpInformation >> 1) & 0x01);
71 }
72 
73 uint8_t
75 {
76  return (m_erpInformation & 0x01);
77 }
78 
79 uint8_t
81 {
83  return 1;
84 }
85 
88 {
89  if (!m_erpSupported)
90  {
91  return i;
92  }
94 }
95 
96 uint16_t
98 {
99  if (!m_erpSupported)
100  {
101  return 0;
102  }
104 }
105 
106 void
108 {
109  if (m_erpSupported)
110  {
111  start.WriteU8 (m_erpInformation);
112  }
113 }
114 
115 uint8_t
117  uint8_t length)
118 {
120  m_erpInformation = i.ReadU8 ();
121  return length;
122 }
123 
132 std::ostream &
133 operator << (std::ostream &os, const ErpInformation &erpinformation)
134 {
135  os << bool (erpinformation.GetBarkerPreambleMode ())
136  << "|" << bool (erpinformation.GetUseProtection ())
137  << "|" << bool (erpinformation.GetNonErpPresent ());
138 
139  return os;
140 }
141 
142 } //namespace ns3
void SetErpSupported(uint8_t erpSupported)
Set the ERP supported field.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
uint16_t GetSerializedSize() const
Return the serialized size of this ErpInformation information element.
void SerializeInformationField(Buffer::Iterator start) const
Serialize the information field.
def start()
Definition: core.py:1844
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
void SetBarkerPreambleMode(uint8_t barkerPreambleMode)
Set the Barker_Preamble_Mode field in the ErpInformation information element.
iterator in a Buffer instance
Definition: buffer.h:98
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Get the information field size.
uint8_t m_erpInformation
ERP information.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetNonErpPresent(void) const
Return the Non_Erp_Present field in the ErpInformation information element.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
void SetUseProtection(uint8_t useProtection)
Set the Use_Protection field in the ErpInformation information element.
WifiInformationElementId ElementId() const
Get the element ID field.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA is an ERP STA...
uint8_t ReadU8(void)
Definition: buffer.h:1021
The ErpInformation Information ElementThis class knows how to serialise and deserialise the ErpInform...
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
bool m_erpSupported
This is used to decide whether this element should be added to the frame or not.
uint8_t GetBarkerPreambleMode(void) const
Return the Barker_Preamble_Mode field in the ErpInformation information element.
#define IE_ERP_INFORMATION
uint8_t GetInformationFieldSize() const
Get the information field size.
void SetNonErpPresent(uint8_t nonErpPresent)
Set the Non_Erp_Present field in the ErpInformation information element.
uint8_t GetUseProtection(void) const
Return the Use_Protection field in the ErpInformation information element.