A Discrete-Event Network Simulator
API
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 
26 namespace ns3
27 {
28 
29 class Node;
30 class Packet;
31 
48 class Ipv4PacketInfoTag : public Tag
49 {
50  public:
52 
58  void SetAddress(Ipv4Address addr);
59 
65  Ipv4Address GetAddress() const;
66 
72  void SetRecvIf(uint32_t ifindex);
78  uint32_t GetRecvIf() const;
79 
85  void SetTtl(uint8_t ttl);
91  uint8_t GetTtl() const;
92 
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 
115  uint32_t m_ifindex;
116 
117  // Used for IP_RECVTTL, though not implemented yet.
118  uint8_t m_ttl;
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.