/** @file
Copyright (c) 2005 - 2009, 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 "Ip4Impl.h"
mIcmpClass[] = {
{1, ICMP_INVALID_MESSAGE},
{2, ICMP_INVALID_MESSAGE},
{6, ICMP_INVALID_MESSAGE},
{7, ICMP_INVALID_MESSAGE},
{9, ICMP_INVALID_MESSAGE},
{10, ICMP_INVALID_MESSAGE},
{14, ICMP_INVALID_MESSAGE},
};
};
/**
Process the ICMP redirect. Find the instance then update
its route cache.
All kinds of redirect is treated as host redirect as
specified by RFC1122 3.3.1.2:
"Since the subnet mask appropriate to the destination
address is generally not known, a Network Redirect
message SHOULD be treated identically to a Host Redirect
message;"
@param[in] IpSb The IP4 service binding instance that received
the packet.
@param[in] Head The IP head of the received ICMPpacket.
@param[in] Packet The content of the ICMP redirect packet with IP
head removed.
@param[in] Icmp The buffer to store the ICMP error message if
something is wrong.
@retval EFI_INVALID_PARAMETER The parameter is invalid
@retval EFI_SUCCESS Successfully updated the route caches
**/
)
{
//
// Find the interface whose IP address is the source of the
// orgianl IP packet.
//
//
// discard the packet if the new gateway address it specifies
// is not on the same connected net through which the Redirect
// arrived. (RFC1122 3.2.2.2).
//
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}
//
// Update each IP child's route cache on the interface.
//
continue;
}
//
// Only update the route cache's gateway if the source of the
// Redirect is the current first-hop gateway
//
}
}
NetbufFree (Packet);
return EFI_SUCCESS;
}
/**
Process the ICMP error packet. If it is an ICMP redirect packet,
update call Ip4ProcessIcmpRedirect to update the IP instance's
route cache, otherwise, deliver the packet to upper layer.
@param[in] IpSb The IP service that received the packet.
@param[in] Head The IP head of the ICMP error packet
@param[in] Packet The content of the ICMP error with IP head
removed.
@retval EFI_SUCCESS The ICMP error is processed successfully.
@retval EFI_INVALID_PARAMETER The packet is invalid
@retval Others Failed to process the packet.
**/
)
{
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}
//
// If it is an ICMP redirect error, update the route cache
// as RFC1122. Otherwise, demultiplex it to IP instances.
//
}
}
/**
Replay an ICMP echo request.
@param[in] IpSb The IP service that receivd the packet
@param[in] Head The IP head of the ICMP error packet
@param[in] Packet The content of the ICMP error with IP head
removed.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
@retval EFI_SUCCESS The ICMP Echo request is successfully answered.
@retval Others Failed to answer the ICMP echo request.
**/
)
{
//
// make a copy the packet, it is really a bad idea to
// send the MNP's buffer back to MNP.
//
goto ON_EXIT;
}
//
// Change the ICMP type to echo reply, exchange the source
// and destination, then send it. The source is updated to
// update is omitted.
//
//
// Ip4Output will select a source for us
//
IpSb,
NULL,
Data,
NULL,
0,
);
NetbufFree (Packet);
return Status;
}
/**
Process the ICMP query message. If it is an ICMP echo
request, answer 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 ICMP query packet
@param[in] Packet The content of the ICMP query with IP head
removed.
@retval EFI_INVALID_PARAMETER The packet is invalid
@retval EFI_SUCCESS The ICMP query message is processed
@retval Others Failed to process ICMP query.
**/
)
{
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}
}
}
/**
Handle the ICMP packet. First validate the message format,
then according to the message types, process it as query or
error packet.
@param[in] IpSb The IP service that receivd the packet
@param[in] Head The IP head of the ICMP query packet
@param[in] Packet The content of the ICMP query with IP head
removed.
@retval EFI_INVALID_PARAMETER The packet is malformated.
@retval EFI_SUCCESS The ICMP message is successfully processed.
@retval Others Failed to handle ICMP packet.
**/
)
{
goto DROP;
}
goto DROP;
}
goto DROP;
}
}
DROP:
NetbufFree (Packet);
return EFI_INVALID_PARAMETER;
}