A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
ssid.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006 INRIA
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
*/
19
20
#include "
ssid.h
"
21
22
namespace
ns3
23
{
24
25
Ssid::Ssid
()
26
{
27
m_length
= 0;
28
for
(uint8_t i = 0; i < 33; i++)
29
{
30
m_ssid
[i] = 0;
31
}
32
}
33
34
Ssid::Ssid
(std::string s)
35
{
36
NS_ASSERT
(s.size() < 32);
37
const
char
*
ssid
= s.c_str();
38
uint8_t len = 0;
39
while
(*
ssid
!= 0 && len < 32)
40
{
41
m_ssid
[len] = *
ssid
;
42
ssid
++;
43
len++;
44
}
45
NS_ASSERT
(len <= 32);
46
m_length
= len;
47
while
(len < 33)
48
{
49
m_ssid
[len] = 0;
50
len++;
51
}
52
}
53
54
bool
55
Ssid::IsEqual
(
const
Ssid
& o)
const
56
{
57
uint8_t i = 0;
58
while
(i < 32 &&
m_ssid
[i] == o.
m_ssid
[i] &&
m_ssid
[i] != 0)
59
{
60
i++;
61
}
62
if
(
m_ssid
[i] != o.
m_ssid
[i])
63
{
64
return
false
;
65
}
66
return
true
;
67
}
68
69
bool
70
Ssid::IsBroadcast
()
const
71
{
72
if
(
m_ssid
[0] == 0)
73
{
74
return
true
;
75
}
76
return
false
;
77
}
78
79
char
*
80
Ssid::PeekString
()
const
81
{
82
// It is safe to return a pointer to the buffer because it is
83
// guaranteed to be zero-terminated.
84
return
(
char
*)
m_ssid
;
85
}
86
87
WifiInformationElementId
88
Ssid::ElementId
()
const
89
{
90
return
IE_SSID
;
91
}
92
93
uint16_t
94
Ssid::GetInformationFieldSize
()
const
95
{
96
return
m_length
;
97
}
98
99
void
100
Ssid::SerializeInformationField
(
Buffer::Iterator
start
)
const
101
{
102
NS_ASSERT
(
m_length
<= 32);
103
start
.Write(
m_ssid
,
m_length
);
104
}
105
106
uint16_t
107
Ssid::DeserializeInformationField
(
Buffer::Iterator
start
, uint16_t length)
108
{
109
m_length
= length;
110
NS_ASSERT
(
m_length
<= 32);
111
start
.Read(
m_ssid
,
m_length
);
112
return
length;
113
}
114
115
ATTRIBUTE_HELPER_CPP
(
Ssid
);
116
117
std::ostream&
118
operator<<
(std::ostream& os,
const
Ssid
&
ssid
)
119
{
120
os <<
ssid
.PeekString();
121
return
os;
122
}
123
124
std::istream&
125
operator>>
(std::istream& is,
Ssid
&
ssid
)
126
{
127
std::string str;
128
is >> str;
129
ssid
=
Ssid
(str);
130
return
is;
131
}
132
133
}
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Ssid
The IEEE 802.11 SSID Information Element.
Definition:
ssid.h:36
ns3::Ssid::GetInformationFieldSize
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Definition:
ssid.cc:94
ns3::Ssid::IsEqual
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition:
ssid.cc:55
ns3::Ssid::m_length
uint8_t m_length
Length of the SSID.
Definition:
ssid.h:82
ns3::Ssid::ElementId
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
Definition:
ssid.cc:88
ns3::Ssid::PeekString
char * PeekString() const
Peek the SSID.
Definition:
ssid.cc:80
ns3::Ssid::IsBroadcast
bool IsBroadcast() const
Check if the SSID is broadcast.
Definition:
ssid.cc:70
ns3::Ssid::m_ssid
uint8_t m_ssid[33]
Raw SSID value.
Definition:
ssid.h:81
ns3::Ssid::DeserializeInformationField
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition:
ssid.cc:107
ns3::Ssid::Ssid
Ssid()
Create SSID with broadcast SSID.
Definition:
ssid.cc:25
ns3::Ssid::SerializeInformationField
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition:
ssid.cc:100
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:129
ns3::ATTRIBUTE_HELPER_CPP
ATTRIBUTE_HELPER_CPP(Length)
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition:
angles.cc:153
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Definition:
wifi-information-element.h:45
third.ssid
ssid
Definition:
third.py:86
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:474
ssid.h
IE_SSID
#define IE_SSID
Here we have definition of all Information Element IDs in IEEE 802.11-2007.
Definition:
wifi-information-element.h:52
src
wifi
model
ssid.cc
Generated on Fri Mar 17 2023 12:40:20 for ns-3 by
1.9.3