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
ie-dot11s-id.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008,2009 IITP RAS
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: Kirill Andreev <andreev@iitp.ru>
19
*/
20
21
#include "
ie-dot11s-id.h
"
22
#include "ns3/assert.h"
23
24
namespace
ns3 {
25
namespace
dot11s {
26
27
IeMeshId::IeMeshId
()
28
{
29
for
(uint8_t i = 0; i < 32; i++)
30
{
31
m_meshId
[i] = 0;
32
}
33
}
34
IeMeshId::IeMeshId
(std::string
s
)
35
{
36
NS_ASSERT
(s.size () < 32);
37
const
char
*meshid = s.c_str ();
38
uint8_t len = 0;
39
while
(*meshid != 0 && len < 32)
40
{
41
m_meshId
[len] = *meshid;
42
meshid++;
43
len++;
44
}
45
NS_ASSERT
(len <= 32);
46
while
(len < 33)
47
{
48
m_meshId
[len] = 0;
49
len++;
50
}
51
}
52
WifiInformationElementId
53
IeMeshId::ElementId
()
const
54
{
55
return
IE11S_MESH_ID
;
56
}
57
bool
58
IeMeshId::IsEqual
(
IeMeshId
const
&o)
const
59
{
60
uint8_t i = 0;
61
while
(i < 32 &&
m_meshId
[i] == o.
m_meshId
[i] &&
m_meshId
[i] != 0)
62
{
63
i++;
64
}
65
if
(
m_meshId
[i] != o.
m_meshId
[i])
66
{
67
return
false
;
68
}
69
return
true
;
70
}
71
bool
72
IeMeshId::IsBroadcast
(
void
)
const
73
{
74
if
(
m_meshId
[0] == 0)
75
{
76
return
true
;
77
}
78
return
false
;
79
}
80
char
*
81
IeMeshId::PeekString
(
void
)
const
82
{
83
return
(
char
*)
m_meshId
;
84
}
85
uint8_t
86
IeMeshId::GetInformationFieldSize
(
void
)
const
87
{
88
uint8_t size = 0;
89
while
(
m_meshId
[size] != 0 && size < 32)
90
{
91
size++;
92
}
93
NS_ASSERT
(size <= 32);
94
return
size;
95
}
96
void
97
IeMeshId::SerializeInformationField
(
Buffer::Iterator
i)
const
98
{
99
uint8_t size = 0;
100
while
(
m_meshId
[size] != 0 && size < 32)
101
{
102
i.
WriteU8
(
m_meshId
[size]);
103
size++;
104
}
105
}
106
uint8_t
107
IeMeshId::DeserializeInformationField
(
Buffer::Iterator
start
, uint8_t length)
108
{
109
Buffer::Iterator
i =
start
;
110
NS_ASSERT
(length <= 32);
111
i.
Read
(
m_meshId
, length);
112
m_meshId
[length] = 0;
113
return
i.
GetDistanceFrom
(start);
114
}
115
void
116
IeMeshId::Print
(std::ostream& os)
const
117
{
118
os << std::endl <<
"<information_element id="
<<
ElementId
() <<
">"
<< std::endl;
119
os <<
"meshId = "
<<
PeekString
();
120
os <<
"</information_element>"
<< std::endl;
121
}
122
bool
123
operator==
(
const
IeMeshId
& a,
const
IeMeshId
& b)
124
{
125
bool
result (
true
);
126
uint8_t size = 0;
127
128
while
(size < 32)
129
{
130
result = result && (a.
m_meshId
[size] == b.
m_meshId
[size]);
131
if
(a.
m_meshId
[size] == 0)
132
{
133
return
result;
134
}
135
size++;
136
}
137
return
result;
138
}
139
std::ostream &
140
operator <<
(std::ostream &os,
const
IeMeshId
&a)
141
{
142
a.
Print
(os);
143
return
os;
144
}
145
146
std::istream &
operator >>
(std::istream &is,
IeMeshId
&a)
147
{
148
std::string str;
149
is >> str;
150
a =
IeMeshId
(str.c_str ());
151
return
is;
152
}
153
154
ATTRIBUTE_HELPER_CPP
(
IeMeshId
);
155
156
157
}
// namespace dot11s
158
}
// namespace ns3
ie-dot11s-id.h
ns3::dot11s::IeMeshId::PeekString
char * PeekString(void) const
Definition:
ie-dot11s-id.cc:81
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::dot11s::ATTRIBUTE_HELPER_CPP
ATTRIBUTE_HELPER_CPP(IeMeshId)
IE11S_MESH_ID
#define IE11S_MESH_ID
Definition:
mesh-information-element.h:45
visualizer.core.start
def start
Definition:
core.py:1482
ns3::dot11s::IeMeshId
a IEEE 802.11s Mesh ID 7.3.287 of 802.11s draft 3.0
Definition:
ie-dot11s-id.h:34
ns3::dot11s::operator==
bool operator==(const MeshHeader &a, const MeshHeader &b)
Definition:
dot11s-mac-header.cc:171
ns3::Buffer::Iterator::GetDistanceFrom
uint32_t GetDistanceFrom(Iterator const &o) const
Definition:
buffer.cc:807
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:98
s
Ptr< SampleEmitter > s
Definition:
double-probe-test-suite.cc:51
ns3::dot11s::IeMeshId::Print
virtual void Print(std::ostream &os) const
In addition, a subclass may optionally override the following...
Definition:
ie-dot11s-id.cc:116
ns3::dot11s::IeMeshId::DeserializeInformationField
virtual uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Definition:
ie-dot11s-id.cc:107
ns3::dot11s::IeMeshId::ElementId
virtual WifiInformationElementId ElementId() const
Own unique Element ID.
Definition:
ie-dot11s-id.cc:53
ns3::dot11s::IeMeshId::SerializeInformationField
virtual void SerializeInformationField(Buffer::Iterator i) const
Definition:
ie-dot11s-id.cc:97
ns3::dot11s::IeMeshId::GetInformationFieldSize
virtual uint8_t GetInformationFieldSize() const
Definition:
ie-dot11s-id.cc:86
ns3::dot11s::IeMeshId::IeMeshId
IeMeshId()
Definition:
ie-dot11s-id.cc:27
ns3::Buffer::Iterator::Read
void Read(uint8_t *buffer, uint32_t size)
Definition:
buffer.cc:1148
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:690
ns3::dot11s::IeMeshId::IsBroadcast
bool IsBroadcast(void) const
Definition:
ie-dot11s-id.cc:72
ns3::dot11s::IeMeshId::IsEqual
bool IsEqual(IeMeshId const &o) const
Definition:
ie-dot11s-id.cc:58
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
Definition:
wifi-information-element.h:41
ns3::dot11s::IeMeshId::m_meshId
uint8_t m_meshId[33]
Definition:
ie-dot11s-id.h:56
ns3::dot11s::operator<<
std::ostream & operator<<(std::ostream &os, const IeBeaconTiming &a)
Definition:
ie-dot11s-beacon-timing.cc:216
ns3::dot11s::operator>>
std::istream & operator>>(std::istream &is, IeMeshId &a)
Definition:
ie-dot11s-id.cc:146
src
mesh
model
dot11s
ie-dot11s-id.cc
Generated on Sat Nov 16 2013 16:17:47 for ns-3 by
1.8.5