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
ipv4-packet-info-tag.h
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
#ifndef IPV4_PACKET_INFO_TAG_H
10
#define IPV4_PACKET_INFO_TAG_H
11
12
#include "ns3/ipv4-address.h"
13
#include "ns3/tag.h"
14
15
namespace
ns3
16
{
17
18
class
Node;
19
class
Packet;
20
21
/**
22
* \ingroup ipv4
23
*
24
* \brief This class implements Linux struct pktinfo
25
* in order to deliver ancillary information to the socket interface.
26
* This is used with socket option such as IP_PKTINFO, IP_RECVTTL,
27
* IP_RECVTOS. See linux manpage ip(7).
28
*
29
* See also SocketIpTosTag and SocketIpTtlTag
30
*
31
* The Tag does not carry the Local address (as it is not currently
32
* used to force a source address).
33
*
34
* This tag in the send direction is presently not enabled but we
35
* would accept a patch along those lines in the future.
36
*/
37
class
Ipv4PacketInfoTag
:
public
Tag
38
{
39
public
:
40
Ipv4PacketInfoTag
();
41
42
/**
43
* \brief Set the tag's address
44
*
45
* \param addr the address
46
*/
47
void
SetAddress
(
Ipv4Address
addr);
48
49
/**
50
* \brief Get the tag's address
51
*
52
* \returns the address
53
*/
54
Ipv4Address
GetAddress
()
const
;
55
56
/**
57
* \brief Set the tag's receiving interface
58
*
59
* \param ifindex the interface index
60
*/
61
void
SetRecvIf
(
uint32_t
ifindex);
62
/**
63
* \brief Get the tag's receiving interface
64
*
65
* \returns the interface index
66
*/
67
uint32_t
GetRecvIf
()
const
;
68
69
/**
70
* \brief Set the tag's Time to Live
71
* Implemented, but not used in the stack yet
72
* \param ttl the TTL
73
*/
74
void
SetTtl
(uint8_t ttl);
75
/**
76
* \brief Get the tag's Time to Live
77
* Implemented, but not used in the stack yet
78
* \returns the TTL
79
*/
80
uint8_t
GetTtl
()
const
;
81
82
/**
83
* \brief Get the type ID.
84
* \return the object TypeId
85
*/
86
static
TypeId
GetTypeId
();
87
TypeId
GetInstanceTypeId
()
const override
;
88
uint32_t
GetSerializedSize
()
const override
;
89
void
Serialize
(
TagBuffer
i)
const override
;
90
void
Deserialize
(
TagBuffer
i)
override
;
91
void
Print
(std::ostream& os)
const override
;
92
93
private
:
94
// Linux IP_PKTINFO ip(7) implementation
95
//
96
// struct in_pktinfo {
97
// unsigned int ipi_ifindex; /* Interface index */
98
// struct in_addr ipi_spec_dst; /* Local address */
99
// struct in_addr ipi_addr; /* Header Destination
100
// address */
101
// };
102
103
Ipv4Address
m_addr
;
//!< Header destination address
104
uint32_t
m_ifindex
;
//!< interface index
105
106
// Used for IP_RECVTTL, though not implemented yet.
107
uint8_t
m_ttl
;
//!< Time to Live
108
};
109
}
// namespace ns3
110
111
#endif
/* IPV4_PACKET_INFO_TAG_H */
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4PacketInfoTag
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
Definition
ipv4-packet-info-tag.h:38
ns3::Ipv4PacketInfoTag::Print
void Print(std::ostream &os) const override
Definition
ipv4-packet-info-tag.cc:118
ns3::Ipv4PacketInfoTag::m_ttl
uint8_t m_ttl
Time to Live.
Definition
ipv4-packet-info-tag.h:107
ns3::Ipv4PacketInfoTag::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ipv4-packet-info-tag.cc:72
ns3::Ipv4PacketInfoTag::SetRecvIf
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
Definition
ipv4-packet-info-tag.cc:44
ns3::Ipv4PacketInfoTag::Ipv4PacketInfoTag
Ipv4PacketInfoTag()
Definition
ipv4-packet-info-tag.cc:21
ns3::Ipv4PacketInfoTag::SetAddress
void SetAddress(Ipv4Address addr)
Set the tag's address.
Definition
ipv4-packet-info-tag.cc:30
ns3::Ipv4PacketInfoTag::GetTtl
uint8_t GetTtl() const
Get the tag's Time to Live Implemented, but not used in the stack yet.
Definition
ipv4-packet-info-tag.cc:65
ns3::Ipv4PacketInfoTag::GetRecvIf
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Definition
ipv4-packet-info-tag.cc:51
ns3::Ipv4PacketInfoTag::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
ipv4-packet-info-tag.cc:82
ns3::Ipv4PacketInfoTag::m_addr
Ipv4Address m_addr
Header destination address.
Definition
ipv4-packet-info-tag.h:103
ns3::Ipv4PacketInfoTag::Serialize
void Serialize(TagBuffer i) const override
Definition
ipv4-packet-info-tag.cc:96
ns3::Ipv4PacketInfoTag::SetTtl
void SetTtl(uint8_t ttl)
Set the tag's Time to Live Implemented, but not used in the stack yet.
Definition
ipv4-packet-info-tag.cc:58
ns3::Ipv4PacketInfoTag::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ipv4-packet-info-tag.cc:89
ns3::Ipv4PacketInfoTag::m_ifindex
uint32_t m_ifindex
interface index
Definition
ipv4-packet-info-tag.h:104
ns3::Ipv4PacketInfoTag::GetAddress
Ipv4Address GetAddress() const
Get the tag's address.
Definition
ipv4-packet-info-tag.cc:37
ns3::Ipv4PacketInfoTag::Deserialize
void Deserialize(TagBuffer i) override
Definition
ipv4-packet-info-tag.cc:107
ns3::TagBuffer
read and write tag data
Definition
tag-buffer.h:41
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
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
model
ipv4-packet-info-tag.h
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0