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
29
UanHeaderCommon::UanHeaderCommon
()
30
{
31
}
32
33
UanHeaderCommon::UanHeaderCommon
(
const
UanAddress
src,
const
UanAddress
dest, uint8_t type)
34
:
Header
(),
35
m_dest (dest),
36
m_src (src),
37
m_type (type)
38
{
39
40
}
41
42
TypeId
43
UanHeaderCommon::GetTypeId
(
void
)
44
{
45
static
TypeId
tid =
TypeId
(
"ns3::UanHeaderCommon"
)
46
.
SetParent
<
Header
> ()
47
.AddConstructor<UanHeaderCommon> ()
48
;
49
return
tid;
50
}
51
52
TypeId
53
UanHeaderCommon::GetInstanceTypeId
(
void
)
const
54
{
55
return
GetTypeId
();
56
}
57
UanHeaderCommon::~UanHeaderCommon
()
58
{
59
}
60
61
62
void
63
UanHeaderCommon::SetDest
(
UanAddress
dest)
64
{
65
m_dest
= dest;
66
}
67
void
68
UanHeaderCommon::SetSrc
(
UanAddress
src)
69
{
70
m_src
= src;
71
}
72
73
void
74
UanHeaderCommon::SetType
(uint8_t type)
75
{
76
m_type
= type;
77
}
78
79
UanAddress
80
UanHeaderCommon::GetDest
(
void
)
const
81
{
82
return
m_dest
;
83
}
84
UanAddress
85
UanHeaderCommon::GetSrc
(
void
)
const
86
{
87
return
m_src
;
88
}
89
uint8_t
90
UanHeaderCommon::GetType
(
void
)
const
91
{
92
return
m_type
;
93
}
94
95
// Inherrited methods
96
97
uint32_t
98
UanHeaderCommon::GetSerializedSize
(
void
)
const
99
{
100
return
1 + 1 + 1;
101
}
102
103
void
104
UanHeaderCommon::Serialize
(
Buffer::Iterator
start
)
const
105
{
106
start.
WriteU8
(
m_src
.
GetAsInt
());
107
start.
WriteU8
(
m_dest
.
GetAsInt
());
108
start.
WriteU8
(
m_type
);
109
}
110
111
uint32_t
112
UanHeaderCommon::Deserialize
(
Buffer::Iterator
start
)
113
{
114
Buffer::Iterator
rbuf =
start
;
115
116
m_src
=
UanAddress
(rbuf.
ReadU8
());
117
m_dest
=
UanAddress
(rbuf.
ReadU8
());
118
m_type
= rbuf.
ReadU8
();
119
120
return
rbuf.
GetDistanceFrom
(start);
121
}
122
123
void
124
UanHeaderCommon::Print
(std::ostream &os)
const
125
{
126
os <<
"UAN src="
<<
m_src
<<
" dest="
<<
m_dest
<<
" type="
<< (uint32_t)
m_type
;
127
}
128
129
130
131
132
}
// namespace ns3
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:42
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
visualizer.core.start
def start
Definition:
core.py:1482
ns3::UanHeaderCommon::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition:
uan-header-common.cc:112
ns3::UanHeaderCommon::GetType
uint8_t GetType(void) const
Get the header type value.
Definition:
uan-header-common.cc:90
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
ns3::UanHeaderCommon::Print
virtual void Print(std::ostream &os) const
Definition:
uan-header-common.cc:124
uan-address.h
ns3::UanAddress
A class used for addressing UAN MAC's.
Definition:
uan-address.h:40
ns3::UanHeaderCommon::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
uan-header-common.cc:98
ns3::UanHeaderCommon::m_dest
UanAddress m_dest
The destination address.
Definition:
uan-header-common.h:111
ns3::UanHeaderCommon::~UanHeaderCommon
virtual ~UanHeaderCommon()
Destructor.
Definition:
uan-header-common.cc:57
ns3::UanHeaderCommon::SetSrc
void SetSrc(UanAddress src)
Set the source address.
Definition:
uan-header-common.cc:68
ns3::UanHeaderCommon::UanHeaderCommon
UanHeaderCommon()
Default constructor.
Definition:
uan-header-common.cc:29
ns3::UanHeaderCommon::SetDest
void SetDest(UanAddress dest)
Set the destination address.
Definition:
uan-header-common.cc:63
ns3::UanHeaderCommon::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
uan-header-common.cc:43
ns3::UanHeaderCommon::m_type
uint8_t m_type
The type field.
Definition:
uan-header-common.h:113
ns3::UanHeaderCommon::Serialize
virtual void Serialize(Buffer::Iterator start) const
Definition:
uan-header-common.cc:104
ns3::UanAddress::GetAsInt
uint8_t GetAsInt(void) const
Convert to integer.
Definition:
uan-address.cc:63
ns3::UanHeaderCommon::GetDest
UanAddress GetDest(void) const
Get the destination address.
Definition:
uan-header-common.cc:80
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:690
ns3::UanHeaderCommon::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
uan-header-common.cc:53
uan-header-common.h
ns3::Buffer::Iterator::ReadU8
uint8_t ReadU8(void)
Definition:
buffer.h:819
ns3::UanHeaderCommon::SetType
void SetType(uint8_t type)
Set the header type.
Definition:
uan-header-common.cc:74
ns3::UanHeaderCommon::GetSrc
UanAddress GetSrc(void) const
Get the source address.
Definition:
uan-header-common.cc:85
ns3::UanHeaderCommon::m_src
UanAddress m_src
The source address.
Definition:
uan-header-common.h:112
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
src
uan
model
uan-header-common.cc
Generated on Sat Apr 19 2014 14:07:09 for ns-3 by
1.8.6