diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index 72bb9dccb..3831bf527 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -272,11 +272,14 @@ void Icmpv6L4Protocol::Forward (Ipv6Address source, Icmpv6Header icmp, uint8_t nextHeader = ipHeader.GetNextHeader (); - Ptr l4 = ipv6->GetProtocol (nextHeader); - if (l4 != 0) + if (nextHeader != Icmpv6L4Protocol::PROT_NUMBER) { - l4->ReceiveIcmp (source, ipHeader.GetHopLimit (), icmp.GetType (), icmp.GetCode (), - info, ipHeader.GetSourceAddress (), ipHeader.GetDestinationAddress (), payload); + Ptr l4 = ipv6->GetProtocol (nextHeader); + if (l4 != 0) + { + l4->ReceiveIcmp (source, ipHeader.GetHopLimit (), icmp.GetType (), icmp.GetCode (), + info, ipHeader.GetSourceAddress (), ipHeader.GetDestinationAddress (), payload); + } } } diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index fbd9ddef7..a92579ab5 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -869,6 +869,7 @@ void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16 MakeCallback (&Ipv6L3Protocol::RouteInputError, this))) { NS_LOG_WARN ("No route found for forwarding packet. Drop."); + GetIcmpv6 ()->SendErrorDestinationUnreachable (p->Copy (), hdr.GetSourceAddress (), Icmpv6Header::ICMPV6_NO_ROUTE); m_dropTrace (hdr, packet, DROP_NO_ROUTE, m_node->GetObject (), interface); } } @@ -1027,9 +1028,8 @@ void Ipv6L3Protocol::IpForward (Ptr idev, Ptr rtentr { NS_LOG_WARN ("TTL exceeded. Drop."); m_dropTrace (ipHeader, packet, DROP_TTL_EXPIRED, m_node->GetObject (), 0); - // Do not reply to ICMPv6 or to multicast IPv6 address - if (ipHeader.GetNextHeader () != Icmpv6L4Protocol::PROT_NUMBER - && ipHeader.GetDestinationAddress ().IsMulticast () == false) + // Do not reply to multicast IPv6 address + if (ipHeader.GetDestinationAddress ().IsMulticast () == false) { packet->AddHeader (ipHeader); GetIcmpv6 ()->SendErrorTimeExceeded (packet, ipHeader.GetSourceAddress (), Icmpv6Header::ICMPV6_HOPLIMIT);