diff --git a/src/internet/model/ipv4-packet-info-tag.cc b/src/internet/model/ipv4-packet-info-tag.cc index 0fb73a764..f22b6dabe 100644 --- a/src/internet/model/ipv4-packet-info-tag.cc +++ b/src/internet/model/ipv4-packet-info-tag.cc @@ -30,7 +30,6 @@ NS_LOG_COMPONENT_DEFINE ("Ipv4PacketInfoTag"); Ipv4PacketInfoTag::Ipv4PacketInfoTag () : m_addr (Ipv4Address ()), - m_spec_dst (Ipv4Address ()), m_ifindex (0), m_ttl (0) { @@ -51,20 +50,6 @@ Ipv4PacketInfoTag::GetAddress (void) const return m_addr; } -void -Ipv4PacketInfoTag::SetLocalAddress (Ipv4Address addr) -{ - NS_LOG_FUNCTION (this << addr); - m_spec_dst = addr; -} - -Ipv4Address -Ipv4PacketInfoTag::GetLocalAddress (void) const -{ - NS_LOG_FUNCTION (this); - return m_spec_dst; -} - void Ipv4PacketInfoTag::SetRecvIf (uint32_t ifindex) { @@ -116,9 +101,7 @@ uint32_t Ipv4PacketInfoTag::GetSerializedSize (void) const { NS_LOG_FUNCTION (this); - return 4 + 4 - + sizeof (uint32_t) - + sizeof (uint8_t); + return 4 + sizeof (uint32_t) + sizeof (uint8_t); } void Ipv4PacketInfoTag::Serialize (TagBuffer i) const @@ -127,8 +110,6 @@ Ipv4PacketInfoTag::Serialize (TagBuffer i) const uint8_t buf[4]; m_addr.Serialize (buf); i.Write (buf, 4); - m_spec_dst.Serialize (buf); - i.Write (buf, 4); i.WriteU32 (m_ifindex); i.WriteU8 (m_ttl); } @@ -139,8 +120,6 @@ Ipv4PacketInfoTag::Deserialize (TagBuffer i) uint8_t buf[4]; i.Read (buf, 4); m_addr = Ipv4Address::Deserialize (buf); - i.Read (buf, 4); - m_spec_dst = Ipv4Address::Deserialize (buf); m_ifindex = i.ReadU32 (); m_ttl = i.ReadU8 (); } @@ -149,7 +128,6 @@ Ipv4PacketInfoTag::Print (std::ostream &os) const { NS_LOG_FUNCTION (this << &os); os << "Ipv4 PKTINFO [DestAddr: " << m_addr; - os << ", Local Address:" << m_spec_dst; os << ", RecvIf:" << (uint32_t) m_ifindex; os << ", TTL:" << (uint32_t) m_ttl; os << "] "; diff --git a/src/internet/model/ipv4-packet-info-tag.h b/src/internet/model/ipv4-packet-info-tag.h index 44ffc5983..0ffe6df75 100644 --- a/src/internet/model/ipv4-packet-info-tag.h +++ b/src/internet/model/ipv4-packet-info-tag.h @@ -38,6 +38,11 @@ class Packet; * This is used with socket option such as IP_PKTINFO, IP_RECVTTL, * IP_RECVTOS. See linux manpage ip(7). * + * See also SocketIpTosTag and SocketIpTtlTag + * + * The Tag does not carry the Local address (as it is not currently + * used to force a source address). + * * This tag in the send direction is presently not enabled but we * would accept a patch along those lines in the future. */ @@ -59,22 +64,6 @@ public: * \returns the address */ Ipv4Address GetAddress (void) const; - /** - * \brief Set the tag's \a local address - * - * This corresponds to "ipi_spec_dst" in struct in_pktinfo. - * Implemented, but not used in the stack yet - * \param addr the address - */ - void SetLocalAddress (Ipv4Address addr); - /** - * \brief Get the tag's \a local address - * - * This corresponds to "ipi_spec_dst" in struct in_pktinfo. - * Implemented, but not used in the stack yet - * \returns the address - */ - Ipv4Address GetLocalAddress (void) const; /** * \brief Set the tag's receiving interface @@ -124,7 +113,6 @@ private: // }; Ipv4Address m_addr; //!< Header destination address - Ipv4Address m_spec_dst; //!< Local address uint32_t m_ifindex; //!< interface index // Used for IP_RECVTTL, though not implemented yet. diff --git a/src/internet/model/ipv4-raw-socket-impl.cc b/src/internet/model/ipv4-raw-socket-impl.cc index 0459622cd..9c0d370c4 100644 --- a/src/internet/model/ipv4-raw-socket-impl.cc +++ b/src/internet/model/ipv4-raw-socket-impl.cc @@ -440,6 +440,8 @@ Ipv4RawSocketImpl::ForwardUp (Ptr p, Ipv4Header ipHeader, PtrRemovePacketTag (tag); + tag.SetAddress (ipHeader.GetDestination ()); + tag.SetTtl (ipHeader.GetTtl ()); tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ()); copy->AddPacketTag (tag); } diff --git a/src/internet/model/ipv6-packet-info-tag.h b/src/internet/model/ipv6-packet-info-tag.h index 1d28f7205..f7aaad058 100644 --- a/src/internet/model/ipv6-packet-info-tag.h +++ b/src/internet/model/ipv6-packet-info-tag.h @@ -37,6 +37,8 @@ class Packet; * data to the socket interface. This is used like * socket option of IP_PKTINFO/IPV6_PKTINFO in \RFC{3542} * + * See also SocketIpv6TclassTag and SocketIpv6HopLimitTag + * * This tag in the send direction is presently not enabled but we * would accept a patch along those lines in the future. To include * the nexthop in the send direction would increase the size of the diff --git a/src/internet/model/ipv6-raw-socket-impl.cc b/src/internet/model/ipv6-raw-socket-impl.cc index 2b2518d59..01e1bbbc5 100644 --- a/src/internet/model/ipv6-raw-socket-impl.cc +++ b/src/internet/model/ipv6-raw-socket-impl.cc @@ -437,6 +437,9 @@ bool Ipv6RawSocketImpl::ForwardUp (Ptr p, Ipv6Header hdr, PtrRemovePacketTag (tag); + tag.SetAddress (hdr.GetDestinationAddress ()); + tag.SetHoplimit (hdr.GetHopLimit ()); + tag.SetTrafficClass (hdr.GetTrafficClass ()); tag.SetRecvIf (device->GetIfIndex ()); copy->AddPacketTag (tag); } diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc index 236d038cb..c9b8e67c5 100644 --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -1011,6 +1011,8 @@ UdpSocketImpl::ForwardUp (Ptr packet, Ipv4Header header, uint16_t port, { Ipv4PacketInfoTag tag; packet->RemovePacketTag (tag); + tag.SetAddress (header.GetDestination ()); + tag.SetTtl (header.GetTtl ()); tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ()); packet->AddPacketTag (tag); } @@ -1068,6 +1070,9 @@ UdpSocketImpl::ForwardUp6 (Ptr packet, Ipv6Header header, uint16_t port, { Ipv6PacketInfoTag tag; packet->RemovePacketTag (tag); + tag.SetAddress (header.GetDestinationAddress ()); + tag.SetHoplimit (header.GetHopLimit ()); + tag.SetTrafficClass (header.GetTrafficClass ()); tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ()); packet->AddPacketTag (tag); }