/** @file
The ICMPv6 handle routines to process the ICMPv6 control messages.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Ip6Impl.h"
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
{
},
};
/**
Reply an ICMPv6 echo request.
@param[in] IpSb The IP service that received the packet.
@param[in] Head The IP head of the ICMPv6 informational message.
@param[in] Packet The content of the ICMPv6 message with the IP head
removed.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
@retval EFI_SUCCESS Successfully answered the ICMPv6 Echo request.
@retval Others Failed to answer the ICMPv6 Echo request.
**/
)
{
//
// make a copy the packet, it is really a bad idea to
// send the MNP's buffer back to MNP.
//
goto Exit;
}
//
// Change the ICMP type to echo reply, exchange the source
// and destination, then send it. The source is updated to
// update is omitted.
//
NetbufFree (Data);
goto Exit;
}
//
// Generate the IPv6 basic header
// If the Echo Reply is a response to a Echo Request sent to one of the node's unicast address,
// the Source address of the Echo Reply must be the same address.
//
}
//
// If source is unspecified, Ip6Output will select a source for us
//
IpSb,
NULL,
NULL,
Data,
NULL,
0,
);
Exit:
NetbufFree (Packet);
return Status;
}
/**
Process Packet Too Big message sent by a router in response to a packet that
it cannot forward because the packet is larger than the MTU of outgoing link.
Since this driver already uses IPv6 minimum link MTU as the maximum packet size,
if Packet Too Big message is still received, do not reduce the packet size, but
rather include a Fragment header in the subsequent packets.
@param[in] IpSb The IP service that received the packet.
@param[in] Head The IP head of the ICMPv6 error packet.
@param[in] Packet The content of the ICMPv6 error with the IP head
removed.
@retval EFI_SUCCESS The ICMPv6 error processed successfully.
@retval EFI_OUT_OF_RESOURCES Failed to finish the operation due to lack of
resource.
@retval EFI_NOT_FOUND The packet too big message is not sent to us.
**/
)
{
if (Mtu < IP6_MIN_LINK_MTU) {
//
// Normally the multicast address is considered to be on-link and not recorded
// in route table. Here it is added into the table since the MTU information
// need be recorded.
//
if (IP6_IS_MULTICAST (DestAddress)) {
if (RouteEntry == NULL) {
NetbufFree (Packet);
return EFI_OUT_OF_RESOURCES;
}
} else {
if (RouteEntry == NULL) {
NetbufFree (Packet);
return EFI_NOT_FOUND;
}
}
}
NetbufFree (Packet);
return EFI_SUCCESS;
}
/**
Process the ICMPv6 error packet, and deliver the packet to upper layer.
@param[in] IpSb The IP service that received the packet.
@param[in] Head The IP head of the ICMPv6 error packet.
@param[in] Packet The content of the ICMPv6 error with the IP head
removed.
@retval EFI_SUCCESS The ICMPv6 error processed successfully.
@retval EFI_INVALID_PARAMETER The packet is invalid.
@retval Others Failed to process the packet.
**/
)
{
//
// Check the validity of the packet
//
goto DROP;
}
}
//
// Notify the upper-layer process that an ICMPv6 eror message is received.
//
DROP:
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}
/**
Process the ICMPv6 informational messages. If it is an ICMPv6 echo
request, answer it. If it is a MLD message, trigger MLD routines to
process it. If it is a ND message, trigger ND routines to process it.
Otherwise, deliver it to upper layer.
@param[in] IpSb The IP service that receivd the packet.
@param[in] Head The IP head of the ICMPv6 informational packet.
@param[in] Packet The content of the ICMPv6 informational packet
with IP head removed.
@retval EFI_INVALID_PARAMETER The packet is invalid.
@retval EFI_SUCCESS The ICMPv6 informational message processed.
@retval Others Failed to process ICMPv6 informational message.
**/
)
{
case ICMP_V6_ECHO_REQUEST:
//
// If ICMPv6 echo, reply it
//
}
break;
case ICMP_V6_LISTENER_QUERY:
break;
case ICMP_V6_LISTENER_REPORT:
break;
case ICMP_V6_NEIGHBOR_SOLICIT:
break;
break;
case ICMP_V6_ROUTER_ADVERTISE:
break;
case ICMP_V6_REDIRECT:
break;
case ICMP_V6_ECHO_REPLY:
break;
default:
break;
}
return Status;
}
/**
Handle the ICMPv6 packet. First validate the message format,
then, according to the message types, process it as an informational packet or
an error packet.
@param[in] IpSb The IP service that received the packet.
@param[in] Head The IP head of the ICMPv6 packet.
@param[in] Packet The content of the ICMPv6 packet with IP head
removed.
@retval EFI_INVALID_PARAMETER The packet is malformated.
@retval EFI_SUCCESS The ICMPv6 message successfully processed.
@retval Others Failed to handle the ICMPv6 packet.
**/
)
{
//
// Check the validity of the incoming packet.
//
goto DROP;
}
//
// Make sure checksum is valid.
//
);
if (CheckSum != 0) {
goto DROP;
}
//
// According to the packet type, call corresponding process
//
} else {
}
DROP:
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}
/**
Retrieve the Prefix address according to the PrefixLength by clear the useless
bits.
@param[in] PrefixLength The prefix length of the prefix.
@param[in, out] Prefix On input, points to the original prefix address
with dirty bits; on output, points to the updated
address with useless bit clear.
**/
)
{
if (PrefixLength == 0) {
return ;
}
return ;
}
}
if (Bit > 0) {
}
}
/**
Check whether the DestinationAddress is an anycast address.
@param[in] IpSb The IP service that received the packet.
@param[in] DestinationAddress Points to the Destination Address of the packet.
@retval TRUE The DestinationAddress is anycast address.
@retval FALSE The DestinationAddress is not anycast address.
**/
)
{
//
// If the address is known as on-link or autonomous prefix, record it as
// anycast address.
//
do {
if (PrefixEntry != NULL) {
return TRUE;
}
}
} while (Flag);
return FALSE;
}
/**
Generate ICMPv6 error message and send it out to DestinationAddress. Currently
Destination Unreachable message, Time Exceeded message and Parameter Problem
message are supported.
@param[in] IpSb The IP service that received the packet.
@param[in] Packet The packet which invoking ICMPv6 error.
@param[in] SourceAddress If not NULL, points to the SourceAddress.
Otherwise, the IP layer will select a source address
according to the DestinationAddress.
@param[in] DestinationAddress Points to the Destination Address of the ICMPv6
error message.
@param[in] Type The type of the ICMPv6 message.
@param[in] Code The additional level of the ICMPv6 message.
@param[in] Pointer If not NULL, identifies the octet offset within
the invoking packet where the error was detected.
@retval EFI_INVALID_PARAMETER The packet is malformated.
@retval EFI_OUT_OF_RESOURCES There is no sufficient resource to complete the
operation.
@retval EFI_SUCCESS The ICMPv6 message was successfully sent out.
@retval Others Failed to generate the ICMPv6 packet.
**/
)
{
if (DestinationAddress == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// An ICMPv6 error message must not be originated as a result of receiving
// a packet whose source address does not uniquely identify a single node --
// e.g., the IPv6 Unspecified Address, an IPv6 multicast address, or an address
// known by the ICMP message originator to be an IPv6 anycast address.
//
) {
return EFI_INVALID_PARAMETER;
}
switch (Type) {
case ICMP_V6_DEST_UNREACHABLE:
case ICMP_V6_TIME_EXCEEDED:
break;
return EFI_INVALID_PARAMETER;
}
break;
default:
return EFI_INVALID_PARAMETER;
}
}
return EFI_OUT_OF_RESOURCES;
}
//
// Create the basic IPv6 header.
//
if (SourceAddress != NULL) {
} else {
}
//
// Fill in the ICMP error message head
//
IcmpHead = (IP6_ICMP_INFORMATION_HEAD *) NetbufAllocSpace (ErrorMsg, sizeof (IP6_ICMP_INFORMATION_HEAD), FALSE);
return EFI_OUT_OF_RESOURCES;
}
}
//
// Fill in the ICMP error message body
//
PayloadLen -= sizeof (IP6_ICMP_INFORMATION_HEAD);
}
//
// Transmit the packet
//
}