A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
#include "
ssid.h
"
21
#include "ns3/assert.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
Ssid::Ssid
(std::string s)
34
{
35
NS_ASSERT
(s.size () < 32);
36
const
char
*ssid = s.c_str ();
37
uint8_t len = 0;
38
while
(*ssid != 0 && len < 32)
39
{
40
m_ssid
[len] = *ssid;
41
ssid++;
42
len++;
43
}
44
NS_ASSERT
(len <= 32);
45
m_length
= len;
46
while
(len < 33)
47
{
48
m_ssid
[len] = 0;
49
len++;
50
}
51
}
52
Ssid::Ssid
(
char
const
ssid[32], uint8_t length)
53
{
54
NS_ASSERT
(length <= 32);
55
uint8_t len = 0;
56
while
(len < length)
57
{
58
m_ssid
[len] = ssid[len];
59
len++;
60
}
61
m_length
= length;
62
while
(len < 33)
63
{
64
m_ssid
[len] = 0;
65
len++;
66
}
67
}
68
bool
69
Ssid::IsEqual
(
const
Ssid
& o)
const
70
{
71
uint8_t i = 0;
72
while
(i < 32
73
&&
m_ssid
[i] == o.
m_ssid
[i]
74
&&
m_ssid
[i] != 0)
75
{
76
i++;
77
}
78
if
(
m_ssid
[i] != o.
m_ssid
[i])
79
{
80
return
false
;
81
}
82
return
true
;
83
}
84
bool
85
Ssid::IsBroadcast
(
void
)
const
86
{
87
if
(
m_ssid
[0] == 0)
88
{
89
return
true
;
90
}
91
return
false
;
92
}
93
94
char
*
95
Ssid::PeekString
(
void
)
const
96
{
97
// it is safe to return a pointer to the buffer because it is
98
// guaranteed to be zero-terminated.
99
return
(
char
*)
m_ssid
;
100
}
101
102
WifiInformationElementId
103
Ssid::ElementId
()
const
104
{
105
return
IE_SSID
;
106
}
107
108
uint8_t
109
Ssid::GetInformationFieldSize
()
const
110
{
111
return
m_length
;
112
}
113
114
void
115
Ssid::SerializeInformationField
(
Buffer::Iterator
start
)
const
116
{
117
NS_ASSERT
(
m_length
<= 32);
118
start.
Write
(
m_ssid
,
m_length
);
119
}
120
uint8_t
121
Ssid::DeserializeInformationField
(
Buffer::Iterator
start
,
122
uint8_t length)
123
{
124
m_length
= length;
125
NS_ASSERT
(
m_length
<= 32);
126
start.
Read
(
m_ssid
,
m_length
);
127
return
length;
128
}
129
130
ATTRIBUTE_HELPER_CPP
(
Ssid
);
131
132
std::ostream &
133
operator <<
(std::ostream &os,
const
Ssid
&ssid)
134
{
135
os << ssid.
PeekString
();
136
return
os;
137
}
138
139
std::istream &
operator >>
(std::istream &is,
Ssid
&ssid)
140
{
141
std::string str;
142
is >> str;
143
ssid =
Ssid
(str.c_str ());
144
return
is;
145
}
146
147
148
}
// namespace ns3
src
wifi
model
ssid.cc
Generated on Tue May 14 2013 11:08:36 for ns-3 by
1.8.1.2