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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Hajime Tazaki <tazaki@sfc.wide.ad.jp>
18 */
19
20#ifndef IPV4_PACKET_INFO_TAG_H
21#define IPV4_PACKET_INFO_TAG_H
22
23#include "ns3/ipv4-address.h"
24#include "ns3/tag.h"
25
26namespace ns3
27{
28
29class Node;
30class Packet;
31
32/**
33 * \ingroup ipv4
34 *
35 * \brief This class implements Linux struct pktinfo
36 * in order to deliver ancillary information to the socket interface.
37 * This is used with socket option such as IP_PKTINFO, IP_RECVTTL,
38 * IP_RECVTOS. See linux manpage ip(7).
39 *
40 * See also SocketIpTosTag and SocketIpTtlTag
41 *
42 * The Tag does not carry the Local address (as it is not currently
43 * used to force a source address).
44 *
45 * This tag in the send direction is presently not enabled but we
46 * would accept a patch along those lines in the future.
47 */
48class Ipv4PacketInfoTag : public Tag
49{
50 public:
52
53 /**
54 * \brief Set the tag's address
55 *
56 * \param addr the address
57 */
58 void SetAddress(Ipv4Address addr);
59
60 /**
61 * \brief Get the tag's address
62 *
63 * \returns the address
64 */
65 Ipv4Address GetAddress() const;
66
67 /**
68 * \brief Set the tag's receiving interface
69 *
70 * \param ifindex the interface index
71 */
72 void SetRecvIf(uint32_t ifindex);
73 /**
74 * \brief Get the tag's receiving interface
75 *
76 * \returns the interface index
77 */
78 uint32_t GetRecvIf() const;
79
80 /**
81 * \brief Set the tag's Time to Live
82 * Implemented, but not used in the stack yet
83 * \param ttl the TTL
84 */
85 void SetTtl(uint8_t ttl);
86 /**
87 * \brief Get the tag's Time to Live
88 * Implemented, but not used in the stack yet
89 * \returns the TTL
90 */
91 uint8_t GetTtl() const;
92
93 /**
94 * \brief Get the type ID.
95 * \return the object TypeId
96 */
97 static TypeId GetTypeId();
98 TypeId GetInstanceTypeId() const override;
99 uint32_t GetSerializedSize() const override;
100 void Serialize(TagBuffer i) const override;
101 void Deserialize(TagBuffer i) override;
102 void Print(std::ostream& os) const override;
103
104 private:
105 // Linux IP_PKTINFO ip(7) implementation
106 //
107 // struct in_pktinfo {
108 // unsigned int ipi_ifindex; /* Interface index */
109 // struct in_addr ipi_spec_dst; /* Local address */
110 // struct in_addr ipi_addr; /* Header Destination
111 // address */
112 // };
113
114 Ipv4Address m_addr; //!< Header destination address
115 uint32_t m_ifindex; //!< interface index
116
117 // Used for IP_RECVTTL, though not implemented yet.
118 uint8_t m_ttl; //!< Time to Live
119};
120} // namespace ns3
121
122#endif /* IPV4_PACKET_INFO_TAG_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
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:52
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.