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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Hajime Tazaki <tazaki@sfc.wide.ad.jp>
7
*/
8
9
#include "
ipv6-packet-info-tag.h
"
10
11
#include "ns3/ipv6-address.h"
12
13
#include <stdint.h>
14
15
namespace
ns3
16
{
17
18
Ipv6PacketInfoTag::Ipv6PacketInfoTag
()
19
: m_addr(
Ipv6Address
()),
20
m_ifindex(0),
21
m_hoplimit(0),
22
m_tclass(0)
23
{
24
}
25
26
void
27
Ipv6PacketInfoTag::SetAddress
(
Ipv6Address
addr)
28
{
29
m_addr
= addr;
30
}
31
32
Ipv6Address
33
Ipv6PacketInfoTag::GetAddress
()
const
34
{
35
return
m_addr
;
36
}
37
38
void
39
Ipv6PacketInfoTag::SetRecvIf
(
uint32_t
ifindex)
40
{
41
m_ifindex
= ifindex;
42
}
43
44
uint32_t
45
Ipv6PacketInfoTag::GetRecvIf
()
const
46
{
47
return
m_ifindex
;
48
}
49
50
void
51
Ipv6PacketInfoTag::SetHoplimit
(uint8_t ttl)
52
{
53
m_hoplimit
= ttl;
54
}
55
56
uint8_t
57
Ipv6PacketInfoTag::GetHoplimit
()
const
58
{
59
return
m_hoplimit
;
60
}
61
62
void
63
Ipv6PacketInfoTag::SetTrafficClass
(uint8_t tclass)
64
{
65
m_tclass
= tclass;
66
}
67
68
uint8_t
69
Ipv6PacketInfoTag::GetTrafficClass
()
const
70
{
71
return
m_tclass
;
72
}
73
74
TypeId
75
Ipv6PacketInfoTag::GetTypeId
()
76
{
77
static
TypeId
tid =
TypeId
(
"ns3::Ipv6PacketInfoTag"
)
78
.
SetParent
<
Tag
>()
79
.SetGroupName(
"Internet"
)
80
.AddConstructor<
Ipv6PacketInfoTag
>();
81
return
tid;
82
}
83
84
TypeId
85
Ipv6PacketInfoTag::GetInstanceTypeId
()
const
86
{
87
return
GetTypeId
();
88
}
89
90
uint32_t
91
Ipv6PacketInfoTag::GetSerializedSize
()
const
92
{
93
return
16 +
sizeof
(uint8_t) +
sizeof
(uint8_t) +
sizeof
(uint8_t);
94
}
95
96
void
97
Ipv6PacketInfoTag::Serialize
(
TagBuffer
i)
const
98
{
99
uint8_t buf[16];
100
m_addr
.
Serialize
(buf);
101
i.
Write
(buf, 16);
102
i.
WriteU8
(
m_ifindex
);
103
i.
WriteU8
(
m_hoplimit
);
104
i.
WriteU8
(
m_tclass
);
105
}
106
107
void
108
Ipv6PacketInfoTag::Deserialize
(
TagBuffer
i)
109
{
110
uint8_t buf[16];
111
i.
Read
(buf, 16);
112
m_addr
=
Ipv6Address::Deserialize
(buf);
113
m_ifindex
= i.
ReadU8
();
114
m_hoplimit
= i.
ReadU8
();
115
m_tclass
= i.
ReadU8
();
116
}
117
118
void
119
Ipv6PacketInfoTag::Print
(std::ostream& os)
const
120
{
121
os <<
"Ipv6 PKTINFO [DestAddr: "
<<
m_addr
;
122
os <<
", RecvIf:"
<< (
uint32_t
)
m_ifindex
;
123
os <<
", TTL:"
<< (
uint32_t
)
m_hoplimit
;
124
os <<
", TClass:"
<< (
uint32_t
)
m_tclass
;
125
os <<
"] "
;
126
}
127
}
// namespace ns3
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6Address::Deserialize
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
Definition
ipv6-address.cc:227
ns3::Ipv6Address::Serialize
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
Definition
ipv6-address.cc:220
ns3::Ipv6PacketInfoTag
This class implements a tag that carries socket ancillary data to the socket interface.
Definition
ipv6-packet-info-tag.h:37
ns3::Ipv6PacketInfoTag::Deserialize
void Deserialize(TagBuffer i) override
Definition
ipv6-packet-info-tag.cc:108
ns3::Ipv6PacketInfoTag::Ipv6PacketInfoTag
Ipv6PacketInfoTag()
Definition
ipv6-packet-info-tag.cc:18
ns3::Ipv6PacketInfoTag::SetTrafficClass
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
Definition
ipv6-packet-info-tag.cc:63
ns3::Ipv6PacketInfoTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
ipv6-packet-info-tag.cc:85
ns3::Ipv6PacketInfoTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ipv6-packet-info-tag.cc:75
ns3::Ipv6PacketInfoTag::Print
void Print(std::ostream &os) const override
Definition
ipv6-packet-info-tag.cc:119
ns3::Ipv6PacketInfoTag::m_addr
Ipv6Address m_addr
the packet address (src or dst)
Definition
ipv6-packet-info-tag.h:126
ns3::Ipv6PacketInfoTag::Serialize
void Serialize(TagBuffer i) const override
Definition
ipv6-packet-info-tag.cc:97
ns3::Ipv6PacketInfoTag::m_tclass
uint8_t m_tclass
the Traffic Class
Definition
ipv6-packet-info-tag.h:129
ns3::Ipv6PacketInfoTag::m_ifindex
uint8_t m_ifindex
the Interface index
Definition
ipv6-packet-info-tag.h:127
ns3::Ipv6PacketInfoTag::GetAddress
Ipv6Address GetAddress() const
Get the tag's address.
Definition
ipv6-packet-info-tag.cc:33
ns3::Ipv6PacketInfoTag::SetRecvIf
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
Definition
ipv6-packet-info-tag.cc:39
ns3::Ipv6PacketInfoTag::SetHoplimit
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
Definition
ipv6-packet-info-tag.cc:51
ns3::Ipv6PacketInfoTag::GetHoplimit
uint8_t GetHoplimit() const
Get the tag's Hop Limit.
Definition
ipv6-packet-info-tag.cc:57
ns3::Ipv6PacketInfoTag::GetTrafficClass
uint8_t GetTrafficClass() const
Get the tag's Traffic Class.
Definition
ipv6-packet-info-tag.cc:69
ns3::Ipv6PacketInfoTag::m_hoplimit
uint8_t m_hoplimit
the Hop Limit
Definition
ipv6-packet-info-tag.h:128
ns3::Ipv6PacketInfoTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ipv6-packet-info-tag.cc:91
ns3::Ipv6PacketInfoTag::GetRecvIf
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Definition
ipv6-packet-info-tag.cc:45
ns3::Ipv6PacketInfoTag::SetAddress
void SetAddress(Ipv6Address addr)
Set the tag's address.
Definition
ipv6-packet-info-tag.cc:27
ns3::TagBuffer
read and write tag data
Definition
tag-buffer.h:41
ns3::TagBuffer::Read
void Read(uint8_t *buffer, uint32_t size)
Definition
tag-buffer.cc:172
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition
tag-buffer.h:161
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition
tag-buffer.h:185
ns3::TagBuffer::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition
tag-buffer.cc:118
ns3::Tag
tag a set of bytes in a packet
Definition
tag.h:28
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
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 Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0