A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
wifi
model
ssid.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 "
ssid.h
"
22
23
namespace
ns3
{
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
59
&&
m_ssid
[i] == o.
m_ssid
[i]
60
&&
m_ssid
[i] != 0)
61
{
62
i++;
63
}
64
if
(
m_ssid
[i] != o.
m_ssid
[i])
65
{
66
return
false
;
67
}
68
return
true
;
69
}
70
71
bool
72
Ssid::IsBroadcast
(
void
)
const
73
{
74
if
(
m_ssid
[0] == 0)
75
{
76
return
true
;
77
}
78
return
false
;
79
}
80
81
char
*
82
Ssid::PeekString
(
void
)
const
83
{
84
//It is safe to return a pointer to the buffer because it is
85
//guaranteed to be zero-terminated.
86
return
(
char
*)
m_ssid
;
87
}
88
89
WifiInformationElementId
90
Ssid::ElementId
()
const
91
{
92
return
IE_SSID
;
93
}
94
95
uint8_t
96
Ssid::GetInformationFieldSize
()
const
97
{
98
return
m_length
;
99
}
100
101
void
102
Ssid::SerializeInformationField
(
Buffer::Iterator
start
)
const
103
{
104
NS_ASSERT
(
m_length
<= 32);
105
start
.Write (
m_ssid
,
m_length
);
106
}
107
108
uint8_t
109
Ssid::DeserializeInformationField
(
Buffer::Iterator
start
,
110
uint8_t length)
111
{
112
m_length
= length;
113
NS_ASSERT
(
m_length
<= 32);
114
start
.Read (
m_ssid
,
m_length
);
115
return
length;
116
}
117
118
ATTRIBUTE_HELPER_CPP
(
Ssid
);
119
128
std::ostream &
129
operator <<
(std::ostream &os,
const
Ssid
&
ssid
)
130
{
131
os <<
ssid
.PeekString ();
132
return
os;
133
}
134
143
std::istream &
operator >>
(std::istream &is,
Ssid
&
ssid
)
144
{
145
std::string str;
146
is >> str;
147
ssid
=
Ssid
(str.c_str ());
148
return
is;
149
}
150
151
}
//namespace ns3
ns3::Ssid::ElementId
WifiInformationElementId ElementId() const
Get the ElementID.
Definition:
ssid.cc:90
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition:
angles.cc:48
ns3::Ssid::m_ssid
uint8_t m_ssid[33]
Raw SSID value.
Definition:
ssid.h:103
ATTRIBUTE_HELPER_CPP
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
Definition:
attribute-helper.h:406
visualizer.core.start
def start()
Definition:
core.py:1844
ns3::Ssid::SerializeInformationField
void SerializeInformationField(Buffer::Iterator start) const
Get the information field size.
Definition:
ssid.cc:102
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:67
ns3::Ssid::Ssid
Ssid()
Definition:
ssid.cc:25
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
third.ssid
ssid
Definition:
third.py:93
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition:
angles.cc:42
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ssid::PeekString
char * PeekString(void) const
Peek the SSID.
Definition:
ssid.cc:82
ns3::Ssid::GetInformationFieldSize
uint8_t GetInformationFieldSize() const
Get the information field size.
Definition:
ssid.cc:96
ns3::Ssid
The IEEE 802.11 SSID Information Element.
Definition:
ssid.h:35
IE_SSID
#define IE_SSID
Here we have definition of all Information Element IDs in IEEE 802.11-2007.
Definition:
wifi-information-element.h:48
ns3::Ssid::IsEqual
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Definition:
ssid.cc:55
ssid.h
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Definition:
wifi-information-element.h:40
ns3::Ssid::m_length
uint8_t m_length
Length of the SSID.
Definition:
ssid.h:104
ns3::Ssid::IsBroadcast
bool IsBroadcast(void) const
Check if the SSID is broadcast.
Definition:
ssid.cc:72
ns3::Ssid::DeserializeInformationField
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Get the information field size.
Definition:
ssid.cc:109
Generated on Wed Nov 7 2018 10:02:14 for ns-3 by
1.8.14