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
uan-header-common.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19
*/
20
21
#include "
uan-header-common.h
"
22
#include "
uan-address.h
"
23
24
namespace
ns3 {
25
26
NS_OBJECT_ENSURE_REGISTERED
(UanHeaderCommon);
27
28
UanHeaderCommon::UanHeaderCommon
()
29
{
30
}
31
32
UanHeaderCommon::UanHeaderCommon
(
const
UanAddress
src,
const
UanAddress
dest, uint8_t type)
33
:
Header
(),
34
m_dest (dest),
35
m_src (src),
36
m_type (type)
37
{
38
39
}
40
41
TypeId
42
UanHeaderCommon::GetTypeId
(
void
)
43
{
44
static
TypeId
tid =
TypeId
(
"ns3::UanHeaderCommon"
)
45
.
SetParent
<
Header
> ()
46
.AddConstructor<UanHeaderCommon> ()
47
;
48
return
tid;
49
}
50
51
TypeId
52
UanHeaderCommon::GetInstanceTypeId
(
void
)
const
53
{
54
return
GetTypeId
();
55
}
56
UanHeaderCommon::~UanHeaderCommon
()
57
{
58
}
59
60
61
void
62
UanHeaderCommon::SetDest
(
UanAddress
dest)
63
{
64
m_dest
= dest;
65
}
66
void
67
UanHeaderCommon::SetSrc
(
UanAddress
src)
68
{
69
m_src
= src;
70
}
71
72
void
73
UanHeaderCommon::SetType
(uint8_t type)
74
{
75
m_type
= type;
76
}
77
78
UanAddress
79
UanHeaderCommon::GetDest
(
void
)
const
80
{
81
return
m_dest
;
82
}
83
UanAddress
84
UanHeaderCommon::GetSrc
(
void
)
const
85
{
86
return
m_src
;
87
}
88
uint8_t
89
UanHeaderCommon::GetType
(
void
)
const
90
{
91
return
m_type
;
92
}
93
94
// Inherrited methods
95
96
uint32_t
97
UanHeaderCommon::GetSerializedSize
(
void
)
const
98
{
99
return
1 + 1 + 1;
100
}
101
102
void
103
UanHeaderCommon::Serialize
(
Buffer::Iterator
start
)
const
104
{
105
start.
WriteU8
(
m_src
.
GetAsInt
());
106
start.
WriteU8
(
m_dest
.
GetAsInt
());
107
start.
WriteU8
(
m_type
);
108
}
109
110
uint32_t
111
UanHeaderCommon::Deserialize
(
Buffer::Iterator
start
)
112
{
113
Buffer::Iterator
rbuf =
start
;
114
115
m_src
=
UanAddress
(rbuf.
ReadU8
());
116
m_dest
=
UanAddress
(rbuf.
ReadU8
());
117
m_type
= rbuf.
ReadU8
();
118
119
return
rbuf.
GetDistanceFrom
(start);
120
}
121
122
void
123
UanHeaderCommon::Print
(std::ostream &os)
const
124
{
125
os <<
"UAN src="
<<
m_src
<<
" dest="
<<
m_dest
<<
" type="
<< (uint32_t)
m_type
;
126
}
127
128
129
130
131
}
// namespace ns3
src
uan
model
uan-header-common.cc
Generated on Tue May 14 2013 11:08:33 for ns-3 by
1.8.1.2