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
hwmp-tag.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
* Authors: Kirill Andreev <andreev@iitp.ru>
19
*/
20
21
#include "
hwmp-tag.h
"
22
23
namespace
ns3 {
24
namespace
dot11s {
25
26
NS_OBJECT_ENSURE_REGISTERED
(HwmpTag);
27
//Class HwmpTag:
28
HwmpTag::HwmpTag
() :
29
m_address (
Mac48Address
::GetBroadcast ()), m_ttl (0), m_metric (0), m_seqno (0)
30
{
31
}
32
33
HwmpTag::~HwmpTag
()
34
{
35
}
36
37
void
38
HwmpTag::SetAddress
(
Mac48Address
retransmitter)
39
{
40
m_address
= retransmitter;
41
}
42
43
Mac48Address
44
HwmpTag::GetAddress
()
45
{
46
return
m_address
;
47
}
48
49
void
50
HwmpTag::SetTtl
(uint8_t ttl)
51
{
52
m_ttl
= ttl;
53
}
54
55
uint8_t
56
HwmpTag::GetTtl
()
57
{
58
return
m_ttl
;
59
}
60
61
void
62
HwmpTag::SetMetric
(uint32_t metric)
63
{
64
m_metric
= metric;
65
}
66
67
uint32_t
68
HwmpTag::GetMetric
()
69
{
70
return
m_metric
;
71
}
72
73
void
74
HwmpTag::SetSeqno
(uint32_t seqno)
75
{
76
m_seqno
= seqno;
77
}
78
79
uint32_t
80
HwmpTag::GetSeqno
()
81
{
82
return
m_seqno
;
83
}
84
85
TypeId
86
HwmpTag::GetTypeId
()
87
{
88
static
TypeId
tid =
TypeId
(
"ns3::dot11s::HwmpTag"
).
SetParent
<
Tag
> ().AddConstructor<HwmpTag> ();
89
return
tid;
90
}
91
92
TypeId
93
HwmpTag::GetInstanceTypeId
()
const
94
{
95
return
GetTypeId
();
96
}
97
98
uint32_t
99
HwmpTag::GetSerializedSize
()
const
100
{
101
return
6
//address
102
+ 1
//ttl
103
+ 4
//metric
104
+ 4;
//seqno
105
}
106
107
void
108
HwmpTag::Serialize
(
TagBuffer
i)
const
109
{
110
uint8_t address[6];
111
int
j;
112
m_address
.
CopyTo
(address);
113
i.
WriteU8
(
m_ttl
);
114
i.
WriteU32
(
m_metric
);
115
i.
WriteU32
(
m_seqno
);
116
for
(j = 0; j < 6; j++)
117
{
118
i.
WriteU8
(address[j]);
119
}
120
}
121
122
void
123
HwmpTag::Deserialize
(
TagBuffer
i)
124
{
125
uint8_t address[6];
126
int
j;
127
m_ttl
= i.
ReadU8
();
128
m_metric
= i.
ReadU32
();
129
m_seqno
= i.
ReadU32
();
130
for
(j = 0; j < 6; j++)
131
{
132
address[j] = i.
ReadU8
();
133
}
134
m_address
.
CopyFrom
(address);
135
}
136
137
void
138
HwmpTag::Print
(std::ostream &os)
const
139
{
140
os <<
"address="
<<
m_address
;
141
os <<
"ttl="
<<
m_ttl
;
142
os <<
"metrc="
<<
m_metric
;
143
os <<
"seqno="
<<
m_seqno
;
144
}
145
void
146
HwmpTag::DecrementTtl
()
147
{
148
m_ttl
--;
149
}
150
}
// namespace dot11s
151
}
// namespace ns3
src
mesh
model
dot11s
hwmp-tag.cc
Generated on Tue May 14 2013 11:08:28 for ns-3 by
1.8.1.2