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
ipv6-packet-info-tag.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Hajime Tazaki
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: Hajime Tazaki <tazaki@sfc.wide.ad.jp>
19
*/
20
21
22
#include <stdint.h>
23
#include "ns3/ipv6-address.h"
24
#include "ipv6-packet-info-tag.h"
25
26
namespace
ns3 {
27
28
Ipv6PacketInfoTag::Ipv6PacketInfoTag ()
29
: m_addr (Ipv6Address ()),
30
m_ifindex (0),
31
m_hoplimit (0),
32
m_tclass (0)
33
{
34
}
35
36
void
37
Ipv6PacketInfoTag::SetAddress (Ipv6Address addr)
38
{
39
m_addr = addr;
40
}
41
42
Ipv6Address
43
Ipv6PacketInfoTag::GetAddress (
void
)
const
44
{
45
return
m_addr;
46
}
47
48
void
49
Ipv6PacketInfoTag::SetRecvIf (uint32_t ifindex)
50
{
51
m_ifindex = ifindex;
52
}
53
54
uint32_t
55
Ipv6PacketInfoTag::GetRecvIf (
void
)
const
56
{
57
return
m_ifindex;
58
}
59
60
void
61
Ipv6PacketInfoTag::SetHoplimit (uint8_t ttl)
62
{
63
m_hoplimit = ttl;
64
}
65
66
uint8_t
67
Ipv6PacketInfoTag::GetHoplimit (
void
)
const
68
{
69
return
m_hoplimit;
70
}
71
72
void
73
Ipv6PacketInfoTag::SetTrafficClass (uint8_t tclass)
74
{
75
m_tclass = tclass;
76
}
77
78
uint8_t
79
Ipv6PacketInfoTag::GetTrafficClass (
void
)
const
80
{
81
return
m_tclass;
82
}
83
84
85
TypeId
86
Ipv6PacketInfoTag::GetTypeId (
void
)
87
{
88
static
TypeId tid = TypeId (
"ns3::Ipv6PacketInfoTag"
)
89
.SetParent<Tag> ()
90
.AddConstructor<Ipv6PacketInfoTag> ()
91
;
92
return
tid;
93
}
94
TypeId
95
Ipv6PacketInfoTag::GetInstanceTypeId
(
void
)
const
96
{
97
return
GetTypeId ();
98
}
99
100
uint32_t
101
Ipv6PacketInfoTag::GetSerializedSize
(
void
)
const
102
{
103
return
16
104
+
sizeof
(uint8_t)
105
+
sizeof
(uint8_t)
106
+
sizeof
(uint8_t);
107
}
108
void
109
Ipv6PacketInfoTag::Serialize
(
TagBuffer
i)
const
110
{
111
uint8_t buf[16];
112
m_addr.
Serialize
(buf);
113
i.
Write
(buf, 16);
114
i.
WriteU8
(m_ifindex);
115
i.
WriteU8
(m_hoplimit);
116
i.
WriteU8
(m_tclass);
117
}
118
void
119
Ipv6PacketInfoTag::Deserialize
(
TagBuffer
i)
120
{
121
uint8_t buf[16];
122
i.
Read
(buf, 16);
123
m_addr =
Ipv6Address::Deserialize
(buf);
124
m_ifindex = i.
ReadU8
();
125
m_hoplimit = i.
ReadU8
();
126
m_tclass = i.
ReadU8
();
127
}
128
void
129
Ipv6PacketInfoTag::Print
(std::ostream &os)
const
130
{
131
os <<
"Ipv6 PKTINFO [DestAddr: "
<< m_addr;
132
os <<
", RecvIf:"
<< (uint32_t) m_ifindex;
133
os <<
", TTL:"
<< (uint32_t) m_hoplimit;
134
os <<
", TClass:"
<< (uint32_t) m_tclass;
135
os <<
"] "
;
136
}
137
}
// namespace ns3
138
ns3::TagBuffer::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:125
ns3::Ipv6PacketInfoTag::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Definition:
ipv6-packet-info-tag.cc:95
ns3::Ipv6PacketInfoTag::Print
virtual void Print(std::ostream &os) const
Definition:
ipv6-packet-info-tag.cc:129
ns3::Ipv6Address::Deserialize
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
Definition:
ipv6-address.cc:308
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition:
tag-buffer.h:179
ns3::Ipv6PacketInfoTag::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
ipv6-packet-info-tag.cc:101
ns3::Ipv6PacketInfoTag::Serialize
virtual void Serialize(TagBuffer i) const
Definition:
ipv6-packet-info-tag.cc:109
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:156
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:51
ns3::TagBuffer::Read
void Read(uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:176
ns3::Ipv6PacketInfoTag::Deserialize
virtual void Deserialize(TagBuffer i)
Definition:
ipv6-packet-info-tag.cc:119
ns3::Ipv6Address::Serialize
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
Definition:
ipv6-address.cc:302
src
internet
model
ipv6-packet-info-tag.cc
Generated on Sun Mar 16 2014 11:25:04 for ns-3 by
1.8.6