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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
ssid.cc
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
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition:
angles.cc:49
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
ns3::Ssid::GetInformationFieldSize
uint8_t GetInformationFieldSize() const
Definition:
ssid.cc:109
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:43
ATTRIBUTE_HELPER_CPP
#define ATTRIBUTE_HELPER_CPP(type)
Definition:
attribute-helper.h:246
ns3::Ssid::SerializeInformationField
void SerializeInformationField(Buffer::Iterator start) const
Definition:
ssid.cc:115
ns3::Buffer::Iterator::Read
void Read(uint8_t *buffer, uint32_t size)
Definition:
buffer.cc:1148
ns3::Ssid
Definition:
ssid.h:35
ns3::Ssid::ElementId
WifiInformationElementId ElementId() const
Own unique Element ID.
Definition:
ssid.cc:103
ns3::Buffer::Iterator::Write
void Write(uint8_t const *buffer, uint32_t size)
Definition:
buffer.cc:978
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
Definition:
wifi-information-element.h:41
ns3::Ssid::DeserializeInformationField
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Definition:
ssid.cc:121
src
wifi
model
ssid.cc
Generated on Sun Mar 16 2014 11:25:12 for ns-3 by
1.8.6