A Discrete-Event Network Simulator
API
ipv6-packet-info-tag.cc
Go to the documentation of this file.
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"
25
26namespace ns3 {
27
29 : m_addr (Ipv6Address ()),
30 m_ifindex (0),
31 m_hoplimit (0),
32 m_tclass (0)
33{
34}
35
36void
38{
39 m_addr = addr;
40}
41
44{
45 return m_addr;
46}
47
48void
50{
51 m_ifindex = ifindex;
52}
53
56{
57 return m_ifindex;
58}
59
60void
62{
63 m_hoplimit = ttl;
64}
65
66uint8_t
68{
69 return m_hoplimit;
70}
71
72void
74{
75 m_tclass = tclass;
76}
77
78uint8_t
80{
81 return m_tclass;
82}
83
84
87{
88 static TypeId tid = TypeId ("ns3::Ipv6PacketInfoTag")
89 .SetParent<Tag> ()
90 .SetGroupName ("Internet")
91 .AddConstructor<Ipv6PacketInfoTag> ()
92 ;
93 return tid;
94}
97{
98 return GetTypeId ();
99}
100
103{
104 return 16
105 + sizeof (uint8_t)
106 + sizeof (uint8_t)
107 + sizeof (uint8_t);
108}
109void
111{
112 uint8_t buf[16];
113 m_addr.Serialize (buf);
114 i.Write (buf, 16);
115 i.WriteU8 (m_ifindex);
117 i.WriteU8 (m_tclass);
118}
119void
121{
122 uint8_t buf[16];
123 i.Read (buf, 16);
125 m_ifindex = i.ReadU8 ();
126 m_hoplimit = i.ReadU8 ();
127 m_tclass = i.ReadU8 ();
128}
129void
130Ipv6PacketInfoTag::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
139
Describes an IPv6 address.
Definition: ipv6-address.h:50
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 SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
uint8_t GetHoplimit(void) const
Get the tag's Hop Limit.
Ipv6Address m_addr
the packet address (src or dst)
virtual void Serialize(TagBuffer i) const
Ipv6Address GetAddress(void) const
Get the tag's address.
uint8_t m_tclass
the Traffic Class
uint8_t m_ifindex
the Interface index
virtual void Print(std::ostream &os) const
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetTrafficClass(void) const
Get the tag's Traffic Class.
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
uint8_t m_hoplimit
the Hop Limit
uint32_t GetRecvIf(void) const
Get the tag's receiving interface.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t GetSerializedSize(void) const
virtual void Deserialize(TagBuffer i)
void SetAddress(Ipv6Address addr)
Set the tag's address.
read and write tag data
Definition: tag-buffer.h:52
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
tag a set of bytes in a packet
Definition: tag.h:37
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Every class exported by the ns3 library is enclosed in the ns3 namespace.