A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv6-packet-info-tag.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Hajime Tazaki
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Authors: Hajime Tazaki <tazaki@sfc.wide.ad.jp>
18
*/
19
20
#include "
ipv6-packet-info-tag.h
"
21
22
#include "ns3/ipv6-address.h"
23
24
#include <stdint.h>
25
26
namespace
ns3
27
{
28
29
Ipv6PacketInfoTag::Ipv6PacketInfoTag
()
30
: m_addr(
Ipv6Address
()),
31
m_ifindex(0),
32
m_hoplimit(0),
33
m_tclass(0)
34
{
35
}
36
37
void
38
Ipv6PacketInfoTag::SetAddress
(
Ipv6Address
addr)
39
{
40
m_addr
= addr;
41
}
42
43
Ipv6Address
44
Ipv6PacketInfoTag::GetAddress
()
const
45
{
46
return
m_addr
;
47
}
48
49
void
50
Ipv6PacketInfoTag::SetRecvIf
(
uint32_t
ifindex)
51
{
52
m_ifindex
= ifindex;
53
}
54
55
uint32_t
56
Ipv6PacketInfoTag::GetRecvIf
()
const
57
{
58
return
m_ifindex
;
59
}
60
61
void
62
Ipv6PacketInfoTag::SetHoplimit
(uint8_t ttl)
63
{
64
m_hoplimit
= ttl;
65
}
66
67
uint8_t
68
Ipv6PacketInfoTag::GetHoplimit
()
const
69
{
70
return
m_hoplimit
;
71
}
72
73
void
74
Ipv6PacketInfoTag::SetTrafficClass
(uint8_t tclass)
75
{
76
m_tclass
= tclass;
77
}
78
79
uint8_t
80
Ipv6PacketInfoTag::GetTrafficClass
()
const
81
{
82
return
m_tclass
;
83
}
84
85
TypeId
86
Ipv6PacketInfoTag::GetTypeId
()
87
{
88
static
TypeId
tid =
TypeId
(
"ns3::Ipv6PacketInfoTag"
)
89
.
SetParent
<
Tag
>()
90
.SetGroupName(
"Internet"
)
91
.AddConstructor<
Ipv6PacketInfoTag
>();
92
return
tid;
93
}
94
95
TypeId
96
Ipv6PacketInfoTag::GetInstanceTypeId
()
const
97
{
98
return
GetTypeId
();
99
}
100
101
uint32_t
102
Ipv6PacketInfoTag::GetSerializedSize
()
const
103
{
104
return
16 +
sizeof
(uint8_t) +
sizeof
(uint8_t) +
sizeof
(uint8_t);
105
}
106
107
void
108
Ipv6PacketInfoTag::Serialize
(
TagBuffer
i)
const
109
{
110
uint8_t buf[16];
111
m_addr
.
Serialize
(buf);
112
i.
Write
(buf, 16);
113
i.
WriteU8
(
m_ifindex
);
114
i.
WriteU8
(
m_hoplimit
);
115
i.
WriteU8
(
m_tclass
);
116
}
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
129
void
130
Ipv6PacketInfoTag::Print
(std::ostream& os)
const
131
{
132
os <<
"Ipv6 PKTINFO [DestAddr: "
<<
m_addr
;
133
os <<
", RecvIf:"
<< (
uint32_t
)
m_ifindex
;
134
os <<
", TTL:"
<< (
uint32_t
)
m_hoplimit
;
135
os <<
", TClass:"
<< (
uint32_t
)
m_tclass
;
136
os <<
"] "
;
137
}
138
}
// namespace ns3
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:49
ns3::Ipv6Address::Deserialize
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
Definition:
ipv6-address.cc:232
ns3::Ipv6Address::Serialize
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
Definition:
ipv6-address.cc:225
ns3::Ipv6PacketInfoTag
This class implements a tag that carries socket ancillary data to the socket interface.
Definition:
ipv6-packet-info-tag.h:48
ns3::Ipv6PacketInfoTag::Deserialize
void Deserialize(TagBuffer i) override
Definition:
ipv6-packet-info-tag.cc:119
ns3::Ipv6PacketInfoTag::Ipv6PacketInfoTag
Ipv6PacketInfoTag()
Definition:
ipv6-packet-info-tag.cc:29
ns3::Ipv6PacketInfoTag::SetTrafficClass
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
Definition:
ipv6-packet-info-tag.cc:74
ns3::Ipv6PacketInfoTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
ipv6-packet-info-tag.cc:96
ns3::Ipv6PacketInfoTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
ipv6-packet-info-tag.cc:86
ns3::Ipv6PacketInfoTag::Print
void Print(std::ostream &os) const override
Definition:
ipv6-packet-info-tag.cc:130
ns3::Ipv6PacketInfoTag::m_addr
Ipv6Address m_addr
the packet address (src or dst)
Definition:
ipv6-packet-info-tag.h:137
ns3::Ipv6PacketInfoTag::Serialize
void Serialize(TagBuffer i) const override
Definition:
ipv6-packet-info-tag.cc:108
ns3::Ipv6PacketInfoTag::m_tclass
uint8_t m_tclass
the Traffic Class
Definition:
ipv6-packet-info-tag.h:140
ns3::Ipv6PacketInfoTag::m_ifindex
uint8_t m_ifindex
the Interface index
Definition:
ipv6-packet-info-tag.h:138
ns3::Ipv6PacketInfoTag::GetAddress
Ipv6Address GetAddress() const
Get the tag's address.
Definition:
ipv6-packet-info-tag.cc:44
ns3::Ipv6PacketInfoTag::SetRecvIf
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
Definition:
ipv6-packet-info-tag.cc:50
ns3::Ipv6PacketInfoTag::SetHoplimit
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
Definition:
ipv6-packet-info-tag.cc:62
ns3::Ipv6PacketInfoTag::GetHoplimit
uint8_t GetHoplimit() const
Get the tag's Hop Limit.
Definition:
ipv6-packet-info-tag.cc:68
ns3::Ipv6PacketInfoTag::GetTrafficClass
uint8_t GetTrafficClass() const
Get the tag's Traffic Class.
Definition:
ipv6-packet-info-tag.cc:80
ns3::Ipv6PacketInfoTag::m_hoplimit
uint8_t m_hoplimit
the Hop Limit
Definition:
ipv6-packet-info-tag.h:139
ns3::Ipv6PacketInfoTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
ipv6-packet-info-tag.cc:102
ns3::Ipv6PacketInfoTag::GetRecvIf
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Definition:
ipv6-packet-info-tag.cc:56
ns3::Ipv6PacketInfoTag::SetAddress
void SetAddress(Ipv6Address addr)
Set the tag's address.
Definition:
ipv6-packet-info-tag.cc:38
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::TagBuffer::Read
void Read(uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:183
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:172
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition:
tag-buffer.h:196
ns3::TagBuffer::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:129
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:39
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:936
uint32_t
ipv6-packet-info-tag.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
model
ipv6-packet-info-tag.cc
Generated on Sun Jul 2 2023 18:21:40 for ns-3 by
1.9.6