A Discrete-Event Network Simulator
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
15namespace ns3
16{
17
18class Node;
19class 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 */
37class Ipv4PacketInfoTag : public Tag
38{
39 public:
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 */
Ipv4 addresses are stored in host order in this class.
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
void Print(std::ostream &os) const override
uint8_t m_ttl
Time to Live.
static TypeId GetTypeId()
Get the type ID.
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
void SetAddress(Ipv4Address addr)
Set the tag's address.
uint8_t GetTtl() const
Get the tag's Time to Live Implemented, but not used in the stack yet.
uint32_t GetRecvIf() const
Get the tag's receiving interface.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Ipv4Address m_addr
Header destination address.
void Serialize(TagBuffer i) const override
void SetTtl(uint8_t ttl)
Set the tag's Time to Live Implemented, but not used in the stack yet.
uint32_t GetSerializedSize() const override
uint32_t m_ifindex
interface index
Ipv4Address GetAddress() const
Get the tag's address.
void Deserialize(TagBuffer i) override
read and write tag data
Definition tag-buffer.h:41
tag a set of bytes in a packet
Definition tag.h:28
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.