A Discrete-Event Network Simulator
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
10
11#include "ns3/ipv6-address.h"
12
13#include <stdint.h>
14
15namespace ns3
16{
17
19 : m_addr(Ipv6Address()),
20 m_ifindex(0),
21 m_hoplimit(0),
22 m_tclass(0)
23{
24}
25
26void
31
34{
35 return m_addr;
36}
37
38void
40{
41 m_ifindex = ifindex;
42}
43
46{
47 return m_ifindex;
48}
49
50void
52{
53 m_hoplimit = ttl;
54}
55
56uint8_t
58{
59 return m_hoplimit;
60}
61
62void
64{
65 m_tclass = tclass;
66}
67
68uint8_t
73
76{
77 static TypeId tid = TypeId("ns3::Ipv6PacketInfoTag")
78 .SetParent<Tag>()
79 .SetGroupName("Internet")
80 .AddConstructor<Ipv6PacketInfoTag>();
81 return tid;
82}
83
89
92{
93 return 16 + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t);
94}
95
96void
98{
99 uint8_t buf[16];
100 m_addr.Serialize(buf);
101 i.Write(buf, 16);
104 i.WriteU8(m_tclass);
105}
106
107void
109{
110 uint8_t buf[16];
111 i.Read(buf, 16);
113 m_ifindex = i.ReadU8();
114 m_hoplimit = i.ReadU8();
115 m_tclass = i.ReadU8();
116}
117
118void
119Ipv6PacketInfoTag::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
Describes an IPv6 address.
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
This class implements a tag that carries socket ancillary data to the socket interface.
void Deserialize(TagBuffer i) override
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
Ipv6Address m_addr
the packet address (src or dst)
void Serialize(TagBuffer i) const override
uint8_t m_tclass
the Traffic Class
uint8_t m_ifindex
the Interface index
Ipv6Address GetAddress() const
Get the tag's address.
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
uint8_t GetHoplimit() const
Get the tag's Hop Limit.
uint8_t GetTrafficClass() const
Get the tag's Traffic Class.
uint8_t m_hoplimit
the Hop Limit
uint32_t GetSerializedSize() const override
uint32_t GetRecvIf() const
Get the tag's receiving interface.
void SetAddress(Ipv6Address addr)
Set the tag's address.
read and write tag data
Definition tag-buffer.h:41
void Read(uint8_t *buffer, uint32_t size)
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition tag-buffer.h:161
TAG_BUFFER_INLINE uint8_t ReadU8()
Definition tag-buffer.h:185
void Write(const uint8_t *buffer, uint32_t size)
tag a set of bytes in a packet
Definition tag.h:28
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Every class exported by the ns3 library is enclosed in the ns3 namespace.