2007-07-23 11:17:39 +02:00
|
|
|
/** @file
|
2009-01-12 03:32:20 +01:00
|
|
|
IpIo Library.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2010-04-24 11:49:11 +02:00
|
|
|
Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials
|
2007-07-23 11:17:39 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
**/
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
#include <Uefi.h>
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
#include <Protocol/Udp4.h>
|
|
|
|
|
|
|
|
#include <Library/IpIoLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
2009-05-21 01:14:35 +02:00
|
|
|
#include <Library/BaseMemoryLib.h>
|
2007-07-23 11:17:39 +02:00
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
2009-05-21 01:14:35 +02:00
|
|
|
#include <Library/MemoryAllocationLib.h>
|
2009-07-12 00:51:51 +02:00
|
|
|
#include <Library/DpcLib.h>
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
|
2009-12-30 14:44:11 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED LIST_ENTRY mActiveIpIoList = {
|
2007-07-23 11:17:39 +02:00
|
|
|
&mActiveIpIoList,
|
|
|
|
&mActiveIpIoList
|
|
|
|
};
|
|
|
|
|
2009-12-30 14:44:11 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData = {
|
2007-07-23 11:17:39 +02:00
|
|
|
EFI_IP_PROTO_UDP,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2007-08-27 05:33:51 +02:00
|
|
|
{{0, 0, 0, 0}},
|
|
|
|
{{0, 0, 0, 0}},
|
2007-07-23 11:17:39 +02:00
|
|
|
0,
|
|
|
|
255,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2009-12-30 14:44:11 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData = {
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_IP_PROTO_UDP,
|
|
|
|
FALSE,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
|
|
|
|
0,
|
|
|
|
255,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2009-12-30 14:44:11 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED ICMP_ERROR_INFO mIcmpErrMap[10] = {
|
2009-10-27 03:45:43 +01:00
|
|
|
{FALSE, TRUE }, // ICMP_ERR_UNREACH_NET
|
|
|
|
{FALSE, TRUE }, // ICMP_ERR_UNREACH_HOST
|
|
|
|
{TRUE, TRUE }, // ICMP_ERR_UNREACH_PROTOCOL
|
|
|
|
{TRUE, TRUE }, // ICMP_ERR_UNREACH_PORT
|
|
|
|
{TRUE, TRUE }, // ICMP_ERR_MSGSIZE
|
|
|
|
{FALSE, TRUE }, // ICMP_ERR_UNREACH_SRCFAIL
|
|
|
|
{FALSE, TRUE }, // ICMP_ERR_TIMXCEED_INTRANS
|
|
|
|
{FALSE, TRUE }, // ICMP_ERR_TIMEXCEED_REASS
|
|
|
|
{FALSE, FALSE}, // ICMP_ERR_QUENCH
|
|
|
|
{FALSE, TRUE } // ICMP_ERR_PARAMPROB
|
2009-10-26 11:15:40 +01:00
|
|
|
};
|
|
|
|
|
2009-12-30 14:44:11 +01:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED ICMP_ERROR_INFO mIcmp6ErrMap[10] = {
|
2009-10-27 03:45:43 +01:00
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_NET
|
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_HOST
|
|
|
|
{TRUE, TRUE}, // ICMP6_ERR_UNREACH_PROTOCOL
|
|
|
|
{TRUE, TRUE}, // ICMP6_ERR_UNREACH_PORT
|
|
|
|
{TRUE, TRUE}, // ICMP6_ERR_PACKAGE_TOOBIG
|
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_TIMXCEED_HOPLIMIT
|
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_TIMXCEED_REASS
|
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_PARAMPROB_HEADER
|
|
|
|
{FALSE, TRUE}, // ICMP6_ERR_PARAMPROB_NEXHEADER
|
|
|
|
{FALSE, TRUE} // ICMP6_ERR_PARAMPROB_IPV6OPTION
|
2007-09-06 04:53:47 +02:00
|
|
|
};
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Notify function for IP transmit token.
|
|
|
|
|
|
|
|
@param[in] Context The context passed in by the event notifier.
|
|
|
|
|
|
|
|
**/
|
2007-11-20 06:42:23 +01:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IpIoTransmitHandlerDpc (
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Notify function for IP transmit token.
|
|
|
|
|
|
|
|
@param[in] Event The event signaled.
|
|
|
|
@param[in] Context The context passed in by the event notifier.
|
|
|
|
|
|
|
|
**/
|
2007-07-23 11:17:39 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IpIoTransmitHandler (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-01-12 03:32:20 +01:00
|
|
|
This function create an IP child ,open the IP protocol, and return the opened
|
2008-12-30 13:26:40 +01:00
|
|
|
IP protocol as Interface.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] ControllerHandle The controller handle.
|
|
|
|
@param[in] ImageHandle The image handle.
|
|
|
|
@param[in] ChildHandle Pointer to the buffer to save the IP child handle.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] IpVersion The version of the IP protocol to use, either
|
|
|
|
IPv4 or IPv6.
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[out] Interface Pointer used to get the IP protocol interface.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP child is created and the IP protocol
|
|
|
|
interface is retrieved.
|
|
|
|
@retval Others The required operation failed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
IpIoCreateIpChildOpenProtocol (
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_HANDLE *ChildHandle,
|
2009-10-30 06:11:38 +01:00
|
|
|
IN UINT8 IpVersion,
|
2007-07-23 11:17:39 +02:00
|
|
|
OUT VOID **Interface
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_GUID *ServiceBindingGuid;
|
|
|
|
EFI_GUID *IpProtocolGuid;
|
|
|
|
|
|
|
|
if (IpVersion == IP_VERSION_4) {
|
|
|
|
ServiceBindingGuid = &gEfiIp4ServiceBindingProtocolGuid;
|
|
|
|
IpProtocolGuid = &gEfiIp4ProtocolGuid;
|
|
|
|
} else if (IpVersion == IP_VERSION_6){
|
|
|
|
ServiceBindingGuid = &gEfiIp6ServiceBindingProtocolGuid;
|
|
|
|
IpProtocolGuid = &gEfiIp6ProtocolGuid;
|
|
|
|
} else {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// Create an IP child.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
Status = NetLibCreateServiceChild (
|
|
|
|
ControllerHandle,
|
|
|
|
ImageHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
ServiceBindingGuid,
|
2007-07-23 11:17:39 +02:00
|
|
|
ChildHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// Open the IP protocol installed on the *ChildHandle.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
*ChildHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
IpProtocolGuid,
|
2007-07-23 11:17:39 +02:00
|
|
|
Interface,
|
|
|
|
ImageHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// On failure, destroy the IP child.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
NetLibDestroyServiceChild (
|
|
|
|
ControllerHandle,
|
|
|
|
ImageHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
ServiceBindingGuid,
|
2007-07-23 11:17:39 +02:00
|
|
|
*ChildHandle
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-30 13:26:40 +01:00
|
|
|
This function close the previously openned IP protocol and destroy the IP child.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] ControllerHandle The controller handle.
|
|
|
|
@param[in] ImageHandle The image handle.
|
|
|
|
@param[in] ChildHandle The child handle of the IP child.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] IpVersion The version of the IP protocol to use, either
|
|
|
|
IPv4 or IPv6.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP protocol is closed and the relevant IP child
|
|
|
|
is destroyed.
|
|
|
|
@retval Others The required operation failed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
IpIoCloseProtocolDestroyIpChild (
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN EFI_HANDLE ChildHandle,
|
2009-10-30 06:11:38 +01:00
|
|
|
IN UINT8 IpVersion
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_GUID *ServiceBindingGuid;
|
|
|
|
EFI_GUID *IpProtocolGuid;
|
|
|
|
|
|
|
|
if (IpVersion == IP_VERSION_4) {
|
|
|
|
ServiceBindingGuid = &gEfiIp4ServiceBindingProtocolGuid;
|
|
|
|
IpProtocolGuid = &gEfiIp4ProtocolGuid;
|
|
|
|
} else if (IpVersion == IP_VERSION_6) {
|
|
|
|
ServiceBindingGuid = &gEfiIp6ServiceBindingProtocolGuid;
|
|
|
|
IpProtocolGuid = &gEfiIp6ProtocolGuid;
|
|
|
|
} else {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// Close the previously openned IP protocol.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
ChildHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
IpProtocolGuid,
|
2007-07-23 11:17:39 +02:00
|
|
|
ImageHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// Destroy the IP child.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
Status = NetLibDestroyServiceChild (
|
|
|
|
ControllerHandle,
|
|
|
|
ImageHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
ServiceBindingGuid,
|
2007-07-23 11:17:39 +02:00
|
|
|
ChildHandle
|
|
|
|
);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-10-26 11:15:40 +01:00
|
|
|
This function handles ICMPv4 packets. It is the worker function of
|
|
|
|
IpIoIcmpHandler.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in, out] Pkt Pointer to the ICMPv4 packet.
|
|
|
|
@param[in] Session Pointer to the net session of this ICMPv4 packet.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
@retval EFI_SUCCESS The ICMPv4 packet is handled successfully.
|
|
|
|
@retval EFI_ABORTED This type of ICMPv4 packet is not supported.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIoIcmpv4Handler (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN OUT NET_BUF *Pkt,
|
|
|
|
IN EFI_NET_SESSION_DATA *Session
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
IP4_ICMP_ERROR_HEAD *IcmpHdr;
|
|
|
|
EFI_IP4_HEADER *IpHdr;
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IcmpErr;
|
2007-07-23 11:17:39 +02:00
|
|
|
UINT8 *PayLoadHdr;
|
|
|
|
UINT8 Type;
|
|
|
|
UINT8 Code;
|
|
|
|
UINT32 TrimBytes;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
ASSERT (IpIo->IpVersion == IP_VERSION_4);
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
IcmpHdr = NET_PROTO_HDR (Pkt, IP4_ICMP_ERROR_HEAD);
|
|
|
|
IpHdr = (EFI_IP4_HEADER *) (&IcmpHdr->IpHead);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check the ICMP packet length.
|
|
|
|
//
|
|
|
|
if (Pkt->TotalSize < ICMP_ERRLEN (IpHdr)) {
|
|
|
|
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Type = IcmpHdr->Head.Type;
|
|
|
|
Code = IcmpHdr->Head.Code;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Analyze the ICMP Error in this ICMP pkt
|
|
|
|
//
|
|
|
|
switch (Type) {
|
|
|
|
case ICMP_TYPE_UNREACH:
|
|
|
|
switch (Code) {
|
|
|
|
case ICMP_CODE_UNREACH_NET:
|
|
|
|
case ICMP_CODE_UNREACH_HOST:
|
|
|
|
case ICMP_CODE_UNREACH_PROTOCOL:
|
|
|
|
case ICMP_CODE_UNREACH_PORT:
|
|
|
|
case ICMP_CODE_UNREACH_SRCFAIL:
|
2009-10-30 06:11:38 +01:00
|
|
|
IcmpErr = (UINT8) (ICMP_ERR_UNREACH_NET + Code);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_CODE_UNREACH_NEEDFRAG:
|
|
|
|
IcmpErr = ICMP_ERR_MSGSIZE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_CODE_UNREACH_NET_UNKNOWN:
|
|
|
|
case ICMP_CODE_UNREACH_NET_PROHIB:
|
|
|
|
case ICMP_CODE_UNREACH_TOSNET:
|
|
|
|
IcmpErr = ICMP_ERR_UNREACH_NET;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_CODE_UNREACH_HOST_UNKNOWN:
|
|
|
|
case ICMP_CODE_UNREACH_ISOLATED:
|
|
|
|
case ICMP_CODE_UNREACH_HOST_PROHIB:
|
|
|
|
case ICMP_CODE_UNREACH_TOSHOST:
|
|
|
|
IcmpErr = ICMP_ERR_UNREACH_HOST;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_TYPE_TIMXCEED:
|
|
|
|
if (Code > 1) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
IcmpErr = (UINT8) (Code + ICMP_ERR_TIMXCEED_INTRANS);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_TYPE_PARAMPROB:
|
|
|
|
if (Code > 1) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
IcmpErr = ICMP_ERR_PARAMPROB;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_TYPE_SOURCEQUENCH:
|
|
|
|
if (Code != 0) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
IcmpErr = ICMP_ERR_QUENCH;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Notify user the ICMP pkt only containing payload except
|
|
|
|
// IP and ICMP header
|
|
|
|
//
|
|
|
|
PayLoadHdr = (UINT8 *) ((UINT8 *) IpHdr + EFI_IP4_HEADER_LEN (IpHdr));
|
|
|
|
TrimBytes = (UINT32) (PayLoadHdr - (UINT8 *) IcmpHdr);
|
|
|
|
|
|
|
|
NetbufTrim (Pkt, TrimBytes, TRUE);
|
|
|
|
|
|
|
|
IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function handles ICMPv6 packets. It is the worker function of
|
|
|
|
IpIoIcmpHandler.
|
|
|
|
|
|
|
|
@param[in] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in, out] Pkt Pointer to the ICMPv6 packet.
|
|
|
|
@param[in] Session Pointer to the net session of this ICMPv6 packet.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The ICMPv6 packet is handled successfully.
|
|
|
|
@retval EFI_ABORTED This type of ICMPv6 packet is not supported.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
IpIoIcmpv6Handler (
|
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN OUT NET_BUF *Pkt,
|
|
|
|
IN EFI_NET_SESSION_DATA *Session
|
|
|
|
)
|
|
|
|
{
|
|
|
|
IP6_ICMP_ERROR_HEAD *IcmpHdr;
|
|
|
|
EFI_IP6_HEADER *IpHdr;
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IcmpErr;
|
2009-10-26 11:15:40 +01:00
|
|
|
UINT8 *PayLoadHdr;
|
|
|
|
UINT8 Type;
|
|
|
|
UINT8 Code;
|
|
|
|
UINT8 NextHeader;
|
|
|
|
UINT32 TrimBytes;
|
|
|
|
BOOLEAN Flag;
|
|
|
|
|
|
|
|
ASSERT (IpIo->IpVersion == IP_VERSION_6);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check the ICMPv6 packet length.
|
|
|
|
//
|
|
|
|
if (Pkt->TotalSize < sizeof (IP6_ICMP_ERROR_HEAD)) {
|
|
|
|
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
IcmpHdr = NET_PROTO_HDR (Pkt, IP6_ICMP_ERROR_HEAD);
|
|
|
|
Type = IcmpHdr->Head.Type;
|
|
|
|
Code = IcmpHdr->Head.Code;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Analyze the ICMPv6 Error in this ICMPv6 packet
|
|
|
|
//
|
|
|
|
switch (Type) {
|
|
|
|
case ICMP_V6_DEST_UNREACHABLE:
|
|
|
|
switch (Code) {
|
|
|
|
case ICMP_V6_NO_ROUTE_TO_DEST:
|
|
|
|
case ICMP_V6_BEYOND_SCOPE:
|
|
|
|
case ICMP_V6_ROUTE_REJECTED:
|
|
|
|
IcmpErr = ICMP6_ERR_UNREACH_NET;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_V6_COMM_PROHIBITED:
|
|
|
|
case ICMP_V6_ADDR_UNREACHABLE:
|
|
|
|
case ICMP_V6_SOURCE_ADDR_FAILED:
|
|
|
|
IcmpErr = ICMP6_ERR_UNREACH_HOST;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_V6_PORT_UNREACHABLE:
|
|
|
|
IcmpErr = ICMP6_ERR_UNREACH_PORT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_V6_PACKET_TOO_BIG:
|
|
|
|
if (Code >= 1) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
IcmpErr = ICMP6_ERR_PACKAGE_TOOBIG;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_V6_TIME_EXCEEDED:
|
|
|
|
if (Code > 1) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
IcmpErr = (UINT8) (ICMP6_ERR_TIMXCEED_HOPLIMIT + Code);
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ICMP_V6_PARAMETER_PROBLEM:
|
|
|
|
if (Code > 3) {
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
IcmpErr = (UINT8) (ICMP6_ERR_PARAMPROB_HEADER + Code);
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Notify user the ICMPv6 packet only containing payload except
|
|
|
|
// IPv6 basic header, extension header and ICMP header
|
|
|
|
//
|
|
|
|
|
|
|
|
IpHdr = (EFI_IP6_HEADER *) (&IcmpHdr->IpHead);
|
|
|
|
NextHeader = IpHdr->NextHeader;
|
|
|
|
PayLoadHdr = (UINT8 *) ((UINT8 *) IcmpHdr + sizeof (IP6_ICMP_ERROR_HEAD));
|
|
|
|
Flag = TRUE;
|
|
|
|
|
|
|
|
do {
|
|
|
|
switch (NextHeader) {
|
|
|
|
case EFI_IP_PROTO_UDP:
|
|
|
|
case EFI_IP_PROTO_TCP:
|
|
|
|
case EFI_IP_PROTO_ICMP:
|
|
|
|
case IP6_NO_NEXT_HEADER:
|
|
|
|
Flag = FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IP6_HOP_BY_HOP:
|
|
|
|
case IP6_DESTINATION:
|
|
|
|
//
|
|
|
|
// The Hdr Ext Len is 8-bit unsigned integer in 8-octet units, not including
|
|
|
|
// the first 8 octets.
|
|
|
|
//
|
|
|
|
NextHeader = *(PayLoadHdr);
|
|
|
|
PayLoadHdr = (UINT8 *) (PayLoadHdr + (*(PayLoadHdr + 1) + 1) * 8);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IP6_FRAGMENT:
|
|
|
|
//
|
|
|
|
// The Fragment Header Length is 8 octets.
|
|
|
|
//
|
|
|
|
NextHeader = *(PayLoadHdr);
|
|
|
|
PayLoadHdr = (UINT8 *) (PayLoadHdr + 8);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return EFI_ABORTED;
|
|
|
|
}
|
|
|
|
} while (Flag);
|
|
|
|
|
|
|
|
TrimBytes = (UINT32) (PayLoadHdr - (UINT8 *) IcmpHdr);
|
|
|
|
|
|
|
|
NetbufTrim (Pkt, TrimBytes, TRUE);
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
IpIo->PktRcvdNotify (EFI_ICMP_ERROR, IcmpErr, Session, Pkt, IpIo->RcvdContext);
|
2009-10-26 11:15:40 +01:00
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
/**
|
|
|
|
This function handles ICMP packets.
|
|
|
|
|
|
|
|
@param[in] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in, out] Pkt Pointer to the ICMP packet.
|
|
|
|
@param[in] Session Pointer to the net session of this ICMP packet.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The ICMP packet is handled successfully.
|
|
|
|
@retval EFI_ABORTED This type of ICMP packet is not supported.
|
|
|
|
@retval EFI_UNSUPPORTED The IP protocol version in IP_IO is not supported.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
IpIoIcmpHandler (
|
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN OUT NET_BUF *Pkt,
|
|
|
|
IN EFI_NET_SESSION_DATA *Session
|
|
|
|
)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
|
|
|
|
return IpIoIcmpv4Handler (IpIo, Pkt, Session);
|
|
|
|
|
|
|
|
} else if (IpIo->IpVersion == IP_VERSION_6) {
|
|
|
|
|
|
|
|
return IpIoIcmpv6Handler (IpIo, Pkt, Session);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
/**
|
2008-12-30 13:26:40 +01:00
|
|
|
Free function for receive token of IP_IO. It is used to
|
2007-07-23 11:17:39 +02:00
|
|
|
signal the recycle event to notify IP to recycle the
|
|
|
|
data buffer.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Event The event to be signaled.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
2010-04-17 01:24:45 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoExtFree (
|
|
|
|
IN VOID *Event
|
|
|
|
)
|
|
|
|
{
|
|
|
|
gBS->SignalEvent ((EFI_EVENT) Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create a send entry to wrap a packet before sending
|
|
|
|
out it through IP.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in, out] Pkt Pointer to the packet.
|
|
|
|
@param[in] Sender Pointer to the IP sender.
|
|
|
|
@param[in] Context Pointer to the context.
|
|
|
|
@param[in] NotifyData Pointer to the notify data.
|
|
|
|
@param[in] Dest Pointer to the destination IP address.
|
|
|
|
@param[in] Override Pointer to the overriden IP_IO data.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
@return Pointer to the data structure created to wrap the packet. If NULL,
|
2009-01-12 03:32:20 +01:00
|
|
|
@return resource limit occurred.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
IP_IO_SEND_ENTRY *
|
|
|
|
IpIoCreateSndEntry (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo,
|
|
|
|
IN OUT NET_BUF *Pkt,
|
2010-06-13 10:18:10 +02:00
|
|
|
IN IP_IO_IP_PROTOCOL Sender,
|
2009-01-12 03:32:20 +01:00
|
|
|
IN VOID *Context OPTIONAL,
|
|
|
|
IN VOID *NotifyData OPTIONAL,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN EFI_IP_ADDRESS *Dest OPTIONAL,
|
2009-01-12 03:32:20 +01:00
|
|
|
IN IP_IO_OVERRIDE *Override
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
IP_IO_SEND_ENTRY *SndEntry;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_EVENT Event;
|
2007-07-23 11:17:39 +02:00
|
|
|
EFI_STATUS Status;
|
2009-10-26 11:15:40 +01:00
|
|
|
NET_FRAGMENT *ExtFragment;
|
|
|
|
UINT32 FragmentCount;
|
|
|
|
IP_IO_OVERRIDE *OverrideData;
|
|
|
|
IP_IO_IP_TX_DATA *TxData;
|
|
|
|
EFI_IP4_TRANSMIT_DATA *Ip4TxData;
|
|
|
|
EFI_IP6_TRANSMIT_DATA *Ip6TxData;
|
|
|
|
|
|
|
|
if ((IpIo->IpVersion != IP_VERSION_4) && (IpIo->IpVersion != IP_VERSION_6)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Event = NULL;
|
|
|
|
TxData = NULL;
|
|
|
|
OverrideData = NULL;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Allocate resource for SndEntry
|
|
|
|
//
|
2008-02-14 10:40:22 +01:00
|
|
|
SndEntry = AllocatePool (sizeof (IP_IO_SEND_ENTRY));
|
2007-07-23 11:17:39 +02:00
|
|
|
if (NULL == SndEntry) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = gBS->CreateEvent (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
2008-02-14 10:40:22 +01:00
|
|
|
TPL_NOTIFY,
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoTransmitHandler,
|
|
|
|
SndEntry,
|
2009-10-26 11:15:40 +01:00
|
|
|
&Event
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2009-10-26 11:15:40 +01:00
|
|
|
goto ON_ERROR;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
FragmentCount = Pkt->BlockOpNum;
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// Allocate resource for TxData
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
TxData = (IP_IO_IP_TX_DATA *) AllocatePool (
|
|
|
|
sizeof (IP_IO_IP_TX_DATA) + sizeof (NET_FRAGMENT) * (FragmentCount - 1)
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
if (NULL == TxData) {
|
2009-10-26 11:15:40 +01:00
|
|
|
goto ON_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Build a fragment table to contain the fragments in the packet.
|
|
|
|
//
|
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
ExtFragment = (NET_FRAGMENT *) TxData->Ip4TxData.FragmentTable;
|
|
|
|
} else {
|
|
|
|
ExtFragment = (NET_FRAGMENT *) TxData->Ip6TxData.FragmentTable;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
NetbufBuildExt (Pkt, ExtFragment, &FragmentCount);
|
|
|
|
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// Allocate resource for OverrideData if needed
|
|
|
|
//
|
|
|
|
if (NULL != Override) {
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
OverrideData = AllocateCopyPool (sizeof (IP_IO_OVERRIDE), Override);
|
2007-07-23 11:17:39 +02:00
|
|
|
if (NULL == OverrideData) {
|
2009-10-26 11:15:40 +01:00
|
|
|
goto ON_ERROR;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
// Set other fields of TxData except the fragment table
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
Ip4TxData = &TxData->Ip4TxData;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
CopyMem (&Ip4TxData->DestinationAddress, Dest, sizeof (EFI_IPv4_ADDRESS));
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
Ip4TxData->OverrideData = &OverrideData->Ip4OverrideData;
|
|
|
|
Ip4TxData->OptionsLength = 0;
|
|
|
|
Ip4TxData->OptionsBuffer = NULL;
|
|
|
|
Ip4TxData->TotalDataLength = Pkt->TotalSize;
|
|
|
|
Ip4TxData->FragmentCount = FragmentCount;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set the fields of SndToken
|
|
|
|
//
|
|
|
|
SndEntry->SndToken.Ip4Token.Event = Event;
|
|
|
|
SndEntry->SndToken.Ip4Token.Packet.TxData = Ip4TxData;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Ip6TxData = &TxData->Ip6TxData;
|
|
|
|
|
|
|
|
if (Dest != NULL) {
|
|
|
|
CopyMem (&Ip6TxData->DestinationAddress, Dest, sizeof (EFI_IPv6_ADDRESS));
|
|
|
|
} else {
|
|
|
|
ZeroMem (&Ip6TxData->DestinationAddress, sizeof (EFI_IPv6_ADDRESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
Ip6TxData->OverrideData = &OverrideData->Ip6OverrideData;
|
|
|
|
Ip6TxData->DataLength = Pkt->TotalSize;
|
|
|
|
Ip6TxData->FragmentCount = FragmentCount;
|
|
|
|
Ip6TxData->ExtHdrsLength = 0;
|
|
|
|
Ip6TxData->ExtHdrs = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set the fields of SndToken
|
|
|
|
//
|
|
|
|
SndEntry->SndToken.Ip6Token.Event = Event;
|
|
|
|
SndEntry->SndToken.Ip6Token.Packet.TxData = Ip6TxData;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Set the fields of SndEntry
|
|
|
|
//
|
|
|
|
SndEntry->IpIo = IpIo;
|
2009-01-12 03:32:20 +01:00
|
|
|
SndEntry->Ip = Sender;
|
2007-07-23 11:17:39 +02:00
|
|
|
SndEntry->Context = Context;
|
|
|
|
SndEntry->NotifyData = NotifyData;
|
|
|
|
|
|
|
|
SndEntry->Pkt = Pkt;
|
|
|
|
NET_GET_REF (Pkt);
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
InsertTailList (&IpIo->PendingSndList, &SndEntry->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return SndEntry;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
ON_ERROR:
|
|
|
|
|
|
|
|
if (OverrideData != NULL) {
|
|
|
|
FreePool (OverrideData);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (TxData != NULL) {
|
|
|
|
FreePool (TxData);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (SndEntry != NULL) {
|
|
|
|
FreePool (SndEntry);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (Event != NULL) {
|
|
|
|
gBS->CloseEvent (Event);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroy the SndEntry.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function pairs with IpIoCreateSndEntry().
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] SndEntry Pointer to the send entry to be destroyed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
IpIoDestroySndEntry (
|
|
|
|
IN IP_IO_SEND_ENTRY *SndEntry
|
|
|
|
)
|
|
|
|
{
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_EVENT Event;
|
|
|
|
IP_IO_IP_TX_DATA *TxData;
|
|
|
|
IP_IO_OVERRIDE *Override;
|
|
|
|
|
|
|
|
if (SndEntry->IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
Event = SndEntry->SndToken.Ip4Token.Event;
|
|
|
|
TxData = (IP_IO_IP_TX_DATA *) SndEntry->SndToken.Ip4Token.Packet.TxData;
|
|
|
|
Override = (IP_IO_OVERRIDE *) TxData->Ip4TxData.OverrideData;
|
|
|
|
} else if (SndEntry->IpIo->IpVersion == IP_VERSION_6) {
|
|
|
|
Event = SndEntry->SndToken.Ip6Token.Event;
|
|
|
|
TxData = (IP_IO_IP_TX_DATA *) SndEntry->SndToken.Ip6Token.Packet.TxData;
|
|
|
|
Override = (IP_IO_OVERRIDE *) TxData->Ip6TxData.OverrideData;
|
|
|
|
} else {
|
|
|
|
return ;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
gBS->CloseEvent (Event);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
FreePool (TxData);
|
|
|
|
|
|
|
|
if (NULL != Override) {
|
|
|
|
FreePool (Override);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NetbufFree (SndEntry->Pkt);
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
RemoveEntryList (&SndEntry->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
FreePool (SndEntry);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Notify function for IP transmit token.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
2007-11-20 06:42:23 +01:00
|
|
|
IpIoTransmitHandlerDpc (
|
2007-07-23 11:17:39 +02:00
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
IP_IO *IpIo;
|
|
|
|
IP_IO_SEND_ENTRY *SndEntry;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_STATUS Status;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
SndEntry = (IP_IO_SEND_ENTRY *) Context;
|
|
|
|
|
|
|
|
IpIo = SndEntry->IpIo;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
Status = SndEntry->SndToken.Ip4Token.Status;
|
|
|
|
} else if (IpIo->IpVersion == IP_VERSION_6){
|
|
|
|
Status = SndEntry->SndToken.Ip6Token.Status;
|
|
|
|
} else {
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2009-03-25 06:39:56 +01:00
|
|
|
if ((IpIo->PktSentNotify != NULL) && (SndEntry->NotifyData != NULL)) {
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIo->PktSentNotify (
|
2009-10-26 11:15:40 +01:00
|
|
|
Status,
|
2007-07-23 11:17:39 +02:00
|
|
|
SndEntry->Context,
|
|
|
|
SndEntry->Ip,
|
|
|
|
SndEntry->NotifyData
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
IpIoDestroySndEntry (SndEntry);
|
|
|
|
}
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
|
2007-11-20 06:42:23 +01:00
|
|
|
/**
|
|
|
|
Notify function for IP transmit token.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Event The event signaled.
|
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-11-20 06:42:23 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IpIoTransmitHandler (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Request IpIoTransmitHandlerDpc as a DPC at TPL_CALLBACK
|
|
|
|
//
|
2009-07-12 00:51:51 +02:00
|
|
|
QueueDpc (TPL_CALLBACK, IpIoTransmitHandlerDpc, Context);
|
2007-11-20 06:42:23 +01:00
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
The dummy handler for the dummy IP receive token.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
2007-11-20 06:42:23 +01:00
|
|
|
IpIoDummyHandlerDpc (
|
2007-07-23 11:17:39 +02:00
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
IP_IO_IP_INFO *IpInfo;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_EVENT RecycleEvent;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
IpInfo = (IP_IO_IP_INFO *) Context;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if ((IpInfo->IpVersion != IP_VERSION_4) && (IpInfo->IpVersion != IP_VERSION_6)) {
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
RecycleEvent = NULL;
|
|
|
|
|
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4) {
|
|
|
|
Status = IpInfo->DummyRcvToken.Ip4Token.Status;
|
|
|
|
|
|
|
|
if (IpInfo->DummyRcvToken.Ip4Token.Packet.RxData != NULL) {
|
|
|
|
RecycleEvent = IpInfo->DummyRcvToken.Ip4Token.Packet.RxData->RecycleSignal;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Status = IpInfo->DummyRcvToken.Ip6Token.Status;
|
|
|
|
|
|
|
|
if (IpInfo->DummyRcvToken.Ip6Token.Packet.RxData != NULL) {
|
|
|
|
RecycleEvent = IpInfo->DummyRcvToken.Ip6Token.Packet.RxData->RecycleSignal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (EFI_ABORTED == Status) {
|
2007-11-20 06:42:23 +01:00
|
|
|
//
|
|
|
|
// The reception is actively aborted by the consumer, directly return.
|
|
|
|
//
|
|
|
|
return;
|
2009-10-26 11:15:40 +01:00
|
|
|
} else if (EFI_SUCCESS == Status) {
|
|
|
|
//
|
|
|
|
// Recycle the RxData.
|
|
|
|
//
|
|
|
|
ASSERT (RecycleEvent != NULL);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
gBS->SignalEvent (RecycleEvent);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
//
|
|
|
|
// Continue the receive.
|
|
|
|
//
|
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4) {
|
2010-06-13 10:18:10 +02:00
|
|
|
IpInfo->Ip.Ip4->Receive (
|
|
|
|
IpInfo->Ip.Ip4,
|
|
|
|
&IpInfo->DummyRcvToken.Ip4Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
IpInfo->Ip.Ip6->Receive (
|
|
|
|
IpInfo->Ip.Ip6,
|
|
|
|
&IpInfo->DummyRcvToken.Ip6Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-01-12 03:32:20 +01:00
|
|
|
This function add IpIoDummyHandlerDpc to the end of the DPC queue.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Event The event signaled.
|
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
2007-11-20 06:42:23 +01:00
|
|
|
IpIoDummyHandler (
|
2007-07-23 11:17:39 +02:00
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
2007-11-20 06:42:23 +01:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Request IpIoDummyHandlerDpc as a DPC at TPL_CALLBACK
|
|
|
|
//
|
2009-07-12 00:51:51 +02:00
|
|
|
QueueDpc (TPL_CALLBACK, IpIoDummyHandlerDpc, Context);
|
2007-11-20 06:42:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Notify function for the IP receive token, used to process
|
|
|
|
the received IP packets.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-11-20 06:42:23 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IpIoListenHandlerDpc (
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
2007-07-23 11:17:39 +02:00
|
|
|
{
|
|
|
|
IP_IO *IpIo;
|
|
|
|
EFI_STATUS Status;
|
2009-10-26 11:15:40 +01:00
|
|
|
IP_IO_IP_RX_DATA *RxData;
|
2007-07-23 11:17:39 +02:00
|
|
|
EFI_NET_SESSION_DATA Session;
|
|
|
|
NET_BUF *Pkt;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIo = (IP_IO *) Context;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
Status = IpIo->RcvToken.Ip4Token.Status;
|
|
|
|
RxData = (IP_IO_IP_RX_DATA *) IpIo->RcvToken.Ip4Token.Packet.RxData;
|
|
|
|
} else if (IpIo->IpVersion == IP_VERSION_6) {
|
|
|
|
Status = IpIo->RcvToken.Ip6Token.Status;
|
|
|
|
RxData = (IP_IO_IP_RX_DATA *) IpIo->RcvToken.Ip6Token.Packet.RxData;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2007-11-20 06:42:23 +01:00
|
|
|
if (EFI_ABORTED == Status) {
|
|
|
|
//
|
|
|
|
// The reception is actively aborted by the consumer, directly return.
|
|
|
|
//
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
if (((EFI_SUCCESS != Status) && (EFI_ICMP_ERROR != Status)) || (NULL == RxData)) {
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// @bug Only process the normal packets and the icmp error packets, if RxData is NULL
|
|
|
|
// @bug with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although
|
|
|
|
// @bug this should be a bug of the low layer (IP).
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
goto Resume;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == IpIo->PktRcvdNotify) {
|
|
|
|
goto CleanUp;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
|
|
|
if ((EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress) != 0) &&
|
2009-11-04 09:18:34 +01:00
|
|
|
!NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) {
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// The source address is not zero and it's not a unicast IP address, discard it.
|
|
|
|
//
|
|
|
|
goto CleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
// Create a netbuffer representing IPv4 packet
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
Pkt = NetbufFromExt (
|
2009-10-26 11:15:40 +01:00
|
|
|
(NET_FRAGMENT *) RxData->Ip4RxData.FragmentTable,
|
|
|
|
RxData->Ip4RxData.FragmentCount,
|
2007-07-23 11:17:39 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
IpIoExtFree,
|
2009-10-26 11:15:40 +01:00
|
|
|
RxData->Ip4RxData.RecycleSignal
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
if (NULL == Pkt) {
|
|
|
|
goto CleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create a net session
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
Session.Source.Addr[0] = EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress);
|
|
|
|
Session.Dest.Addr[0] = EFI_IP4 (RxData->Ip4RxData.Header->DestinationAddress);
|
|
|
|
Session.IpHdr.Ip4Hdr = RxData->Ip4RxData.Header;
|
2009-11-17 08:57:02 +01:00
|
|
|
Session.IpHdrLen = RxData->Ip4RxData.HeaderLength;
|
2009-10-26 11:15:40 +01:00
|
|
|
Session.IpVersion = IP_VERSION_4;
|
|
|
|
} else {
|
|
|
|
|
2009-11-04 09:18:34 +01:00
|
|
|
if (!NetIp6IsValidUnicast(&RxData->Ip6RxData.Header->SourceAddress)) {
|
2009-10-26 11:15:40 +01:00
|
|
|
goto CleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create a netbuffer representing IPv6 packet
|
|
|
|
//
|
|
|
|
Pkt = NetbufFromExt (
|
|
|
|
(NET_FRAGMENT *) RxData->Ip6RxData.FragmentTable,
|
|
|
|
RxData->Ip6RxData.FragmentCount,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
IpIoExtFree,
|
|
|
|
RxData->Ip6RxData.RecycleSignal
|
|
|
|
);
|
|
|
|
if (NULL == Pkt) {
|
|
|
|
goto CleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create a net session
|
|
|
|
//
|
|
|
|
CopyMem (
|
|
|
|
&Session.Source,
|
|
|
|
&RxData->Ip6RxData.Header->SourceAddress,
|
|
|
|
sizeof(EFI_IPv6_ADDRESS)
|
|
|
|
);
|
|
|
|
CopyMem (
|
|
|
|
&Session.Dest,
|
|
|
|
&RxData->Ip6RxData.Header->DestinationAddress,
|
|
|
|
sizeof(EFI_IPv6_ADDRESS)
|
|
|
|
);
|
|
|
|
Session.IpHdr.Ip6Hdr = RxData->Ip6RxData.Header;
|
2009-11-17 08:57:02 +01:00
|
|
|
Session.IpHdrLen = RxData->Ip6RxData.HeaderLength;
|
2009-10-26 11:15:40 +01:00
|
|
|
Session.IpVersion = IP_VERSION_6;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
if (EFI_SUCCESS == Status) {
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
IpIo->PktRcvdNotify (EFI_SUCCESS, 0, &Session, Pkt, IpIo->RcvdContext);
|
2007-07-23 11:17:39 +02:00
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Status is EFI_ICMP_ERROR
|
|
|
|
//
|
|
|
|
Status = IpIoIcmpHandler (IpIo, Pkt, &Session);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
NetbufFree (Pkt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goto Resume;
|
|
|
|
|
|
|
|
CleanUp:
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
if (IpIo->IpVersion == IP_VERSION_4){
|
|
|
|
gBS->SignalEvent (RxData->Ip4RxData.RecycleSignal);
|
|
|
|
} else {
|
|
|
|
gBS->SignalEvent (RxData->Ip6RxData.RecycleSignal);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
Resume:
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4){
|
2010-06-13 10:18:10 +02:00
|
|
|
IpIo->Ip.Ip4->Receive (IpIo->Ip.Ip4, &(IpIo->RcvToken.Ip4Token));
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
IpIo->Ip.Ip6->Receive (IpIo->Ip.Ip6, &(IpIo->RcvToken.Ip6Token));
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2007-11-20 06:42:23 +01:00
|
|
|
/**
|
2009-01-12 03:32:20 +01:00
|
|
|
This function add IpIoListenHandlerDpc to the end of the DPC queue.
|
2007-11-20 06:42:23 +01:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Event The event signaled.
|
|
|
|
@param[in] Context The context passed in by the event notifier.
|
2007-11-20 06:42:23 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
IpIoListenHandler (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK
|
|
|
|
//
|
2009-07-12 00:51:51 +02:00
|
|
|
QueueDpc (TPL_CALLBACK, IpIoListenHandlerDpc, Context);
|
2007-11-20 06:42:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
/**
|
|
|
|
Create a new IP_IO instance.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
This function uses IP4/IP6 service binding protocol in Controller to create
|
|
|
|
an IP4/IP6 child (aka IP4/IP6 instance).
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Image The image handle of the driver or application that
|
2008-12-30 13:26:40 +01:00
|
|
|
consumes IP_IO.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] Controller The controller handle that has IP4 or IP6 service
|
|
|
|
binding protocol installed.
|
|
|
|
@param[in] IpVersion The version of the IP protocol to use, either
|
|
|
|
IPv4 or IPv6.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2008-12-30 13:26:40 +01:00
|
|
|
@return Pointer to a newly created IP_IO instance, or NULL if failed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
IP_IO *
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoCreate (
|
|
|
|
IN EFI_HANDLE Image,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN EFI_HANDLE Controller,
|
2009-10-30 06:11:38 +01:00
|
|
|
IN UINT8 IpVersion
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
IP_IO *IpIo;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_EVENT Event;
|
|
|
|
|
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
IpIo = AllocateZeroPool (sizeof (IP_IO));
|
2007-07-23 11:17:39 +02:00
|
|
|
if (NULL == IpIo) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
InitializeListHead (&(IpIo->PendingSndList));
|
|
|
|
InitializeListHead (&(IpIo->IpList));
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIo->Controller = Controller;
|
|
|
|
IpIo->Image = Image;
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIo->IpVersion = IpVersion;
|
|
|
|
Event = NULL;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
Status = gBS->CreateEvent (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
2008-02-14 10:40:22 +01:00
|
|
|
TPL_NOTIFY,
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoListenHandler,
|
|
|
|
IpIo,
|
2009-10-26 11:15:40 +01:00
|
|
|
&Event
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ReleaseIpIo;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4) {
|
|
|
|
IpIo->RcvToken.Ip4Token.Event = Event;
|
|
|
|
} else {
|
|
|
|
IpIo->RcvToken.Ip6Token.Event = Event;
|
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// Create an IP child and open IP protocol
|
|
|
|
//
|
|
|
|
Status = IpIoCreateIpChildOpenProtocol (
|
|
|
|
Controller,
|
|
|
|
Image,
|
|
|
|
&IpIo->ChildHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
IpVersion,
|
2007-07-23 11:17:39 +02:00
|
|
|
(VOID **)&(IpIo->Ip)
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ReleaseIpIo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IpIo;
|
|
|
|
|
|
|
|
ReleaseIpIo:
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (Event != NULL) {
|
|
|
|
gBS->CloseEvent (Event);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
gBS->FreePool (IpIo);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Open an IP_IO instance for use.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function is called after IpIoCreate(). It is used for configuring the IP
|
|
|
|
instance and register the callbacks and their context data for sending and
|
|
|
|
receiving IP packets.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to an IP_IO instance that needs
|
|
|
|
to open.
|
|
|
|
@param[in] OpenData The configuration data and callbacks for
|
|
|
|
the IP_IO instance.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP_IO instance opened with OpenData
|
|
|
|
successfully.
|
|
|
|
@retval EFI_ACCESS_DENIED The IP_IO instance is configured, avoid to
|
|
|
|
reopen it.
|
|
|
|
@retval Others Error condition occurred.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoOpen (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo,
|
|
|
|
IN IP_IO_OPEN_DATA *OpenData
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IpVersion;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
if (IpIo->IsConfigured) {
|
|
|
|
return EFI_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpVersion = IpIo->IpVersion;
|
|
|
|
|
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// configure ip
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4){
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip4->Configure (
|
|
|
|
IpIo->Ip.Ip4,
|
|
|
|
&OpenData->IpConfigData.Ip4CfgData
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
|
|
|
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip6->Configure (
|
|
|
|
IpIo->Ip.Ip6,
|
|
|
|
&OpenData->IpConfigData.Ip6CfgData
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// @bug To delete the default route entry in this Ip, if it is:
|
|
|
|
// @bug (0.0.0.0, 0.0.0.0, 0.0.0.0). Delete this statement if Ip modified
|
|
|
|
// @bug its code
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4){
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip4->Routes (
|
|
|
|
IpIo->Ip.Ip4,
|
|
|
|
TRUE,
|
|
|
|
&mZeroIp4Addr,
|
|
|
|
&mZeroIp4Addr,
|
|
|
|
&mZeroIp4Addr
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
if (EFI_ERROR (Status) && (EFI_NOT_FOUND != Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IpIo->PktRcvdNotify = OpenData->PktRcvdNotify;
|
|
|
|
IpIo->PktSentNotify = OpenData->PktSentNotify;
|
|
|
|
|
|
|
|
IpIo->RcvdContext = OpenData->RcvdContext;
|
|
|
|
IpIo->SndContext = OpenData->SndContext;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4){
|
|
|
|
IpIo->Protocol = OpenData->IpConfigData.Ip4CfgData.DefaultProtocol;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
//
|
|
|
|
// start to listen incoming packet
|
|
|
|
//
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip4->Receive (
|
|
|
|
IpIo->Ip.Ip4,
|
|
|
|
&(IpIo->RcvToken.Ip4Token)
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-13 10:18:10 +02:00
|
|
|
IpIo->Ip.Ip4->Configure (IpIo->Ip.Ip4, NULL);
|
2009-10-26 11:15:40 +01:00
|
|
|
goto ErrorExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
IpIo->Protocol = OpenData->IpConfigData.Ip6CfgData.DefaultProtocol;
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip6->Receive (
|
|
|
|
IpIo->Ip.Ip6,
|
|
|
|
&(IpIo->RcvToken.Ip6Token)
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-13 10:18:10 +02:00
|
|
|
IpIo->Ip.Ip6->Configure (IpIo->Ip.Ip6, NULL);
|
2009-10-26 11:15:40 +01:00
|
|
|
goto ErrorExit;
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IpIo->IsConfigured = TRUE;
|
2008-02-14 10:40:22 +01:00
|
|
|
InsertTailList (&mActiveIpIoList, &IpIo->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
ErrorExit:
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Stop an IP_IO instance.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function is paired with IpIoOpen(). The IP_IO will be unconfigured and all
|
|
|
|
the pending send/receive tokens will be canceled.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to the IP_IO instance that needs to stop.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP_IO instance stopped successfully.
|
|
|
|
@retval Others Error condition occurred.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-12-30 13:26:40 +01:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoStop (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
IP_IO_IP_INFO *IpInfo;
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IpVersion;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
if (!IpIo->IsConfigured) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpVersion = IpIo->IpVersion;
|
|
|
|
|
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// Remove the IpIo from the active IpIo list.
|
|
|
|
//
|
2008-02-14 10:40:22 +01:00
|
|
|
RemoveEntryList (&IpIo->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Configure NULL Ip
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip4->Configure (IpIo->Ip.Ip4, NULL);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = IpIo->Ip.Ip6->Configure (IpIo->Ip.Ip6, NULL);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
IpIo->IsConfigured = FALSE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Detroy the Ip List used by IpIo
|
|
|
|
//
|
2007-07-25 09:35:03 +02:00
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
while (!IsListEmpty (&(IpIo->IpList))) {
|
2007-07-23 11:17:39 +02:00
|
|
|
IpInfo = NET_LIST_HEAD (&(IpIo->IpList), IP_IO_IP_INFO, Entry);
|
|
|
|
|
|
|
|
IpIoRemoveIp (IpIo, IpInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-01-12 03:32:20 +01:00
|
|
|
// All pending send tokens should be flushed by reseting the IP instances.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
2008-02-14 10:40:22 +01:00
|
|
|
ASSERT (IsListEmpty (&IpIo->PendingSndList));
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Close the receive event.
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4){
|
|
|
|
gBS->CloseEvent (IpIo->RcvToken.Ip4Token.Event);
|
|
|
|
} else {
|
|
|
|
gBS->CloseEvent (IpIo->RcvToken.Ip6Token.Event);
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroy an IP_IO instance.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function is paired with IpIoCreate(). The IP_IO will be closed first.
|
2009-01-13 09:48:19 +01:00
|
|
|
Resource will be freed afterwards. See IpIoCloseProtocolDestroyIpChild().
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to the IP_IO instance that needs to be
|
2008-12-30 13:26:40 +01:00
|
|
|
destroyed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP_IO instance destroyed successfully.
|
|
|
|
@retval Others Error condition occurred.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoDestroy (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Stop the IpIo.
|
|
|
|
//
|
|
|
|
IpIoStop (IpIo);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Close the IP protocol and destroy the child.
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIoCloseProtocolDestroyIpChild (
|
|
|
|
IpIo->Controller,
|
|
|
|
IpIo->Image,
|
|
|
|
IpIo->ChildHandle,
|
|
|
|
IpIo->IpVersion
|
|
|
|
);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
gBS->FreePool (IpIo);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Send out an IP packet.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function is called after IpIoOpen(). The data to be sent are wrapped in
|
|
|
|
Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
|
|
|
|
overriden by Sender. Other sending configs, like source address and gateway
|
|
|
|
address etc., are specified in OverrideData.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to an IP_IO instance used for sending IP
|
|
|
|
packet.
|
|
|
|
@param[in, out] Pkt Pointer to the IP packet to be sent.
|
|
|
|
@param[in] Sender The IP protocol instance used for sending.
|
2009-01-13 09:48:19 +01:00
|
|
|
@param[in] Context Optional context data.
|
|
|
|
@param[in] NotifyData Optional notify data.
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Dest The destination IP address to send this packet to.
|
|
|
|
@param[in] OverrideData The data to override some configuration of the IP
|
|
|
|
instance used for sending.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The operation is completed successfully.
|
|
|
|
@retval EFI_NOT_STARTED The IpIo is not configured.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoSend (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo,
|
|
|
|
IN OUT NET_BUF *Pkt,
|
|
|
|
IN IP_IO_IP_INFO *Sender OPTIONAL,
|
|
|
|
IN VOID *Context OPTIONAL,
|
|
|
|
IN VOID *NotifyData OPTIONAL,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN EFI_IP_ADDRESS *Dest,
|
2009-01-12 03:32:20 +01:00
|
|
|
IN IP_IO_OVERRIDE *OverrideData OPTIONAL
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2010-06-13 10:18:10 +02:00
|
|
|
IP_IO_IP_PROTOCOL Ip;
|
2007-07-23 11:17:39 +02:00
|
|
|
IP_IO_SEND_ENTRY *SndEntry;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
ASSERT ((IpIo->IpVersion != IP_VERSION_4) || (Dest != NULL));
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
if (!IpIo->IsConfigured) {
|
|
|
|
return EFI_NOT_STARTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ip = (NULL == Sender) ? IpIo->Ip : Sender->Ip;
|
|
|
|
|
|
|
|
//
|
|
|
|
// create a new SndEntry
|
|
|
|
//
|
|
|
|
SndEntry = IpIoCreateSndEntry (IpIo, Pkt, Ip, Context, NotifyData, Dest, OverrideData);
|
|
|
|
if (NULL == SndEntry) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Send this Packet
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpIo->IpVersion == IP_VERSION_4){
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip4->Transmit (
|
|
|
|
Ip.Ip4,
|
|
|
|
&SndEntry->SndToken.Ip4Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip6->Transmit (
|
|
|
|
Ip.Ip6,
|
|
|
|
&SndEntry->SndToken.Ip6Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
IpIoDestroySndEntry (SndEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cancel the IP transmit token which wraps this Packet.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in] Packet Pointer to the packet of NET_BUF to cancel.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoCancelTxToken (
|
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN VOID *Packet
|
|
|
|
)
|
|
|
|
{
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY *Node;
|
2007-07-23 11:17:39 +02:00
|
|
|
IP_IO_SEND_ENTRY *SndEntry;
|
2010-06-13 10:18:10 +02:00
|
|
|
IP_IO_IP_PROTOCOL Ip;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
ASSERT ((IpIo != NULL) && (Packet != NULL));
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
NET_LIST_FOR_EACH (Node, &IpIo->PendingSndList) {
|
|
|
|
|
|
|
|
SndEntry = NET_LIST_USER_STRUCT (Node, IP_IO_SEND_ENTRY, Entry);
|
|
|
|
|
|
|
|
if (SndEntry->Pkt == Packet) {
|
|
|
|
|
|
|
|
Ip = SndEntry->Ip;
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
if (IpIo->IpVersion == IP_VERSION_4) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip4->Cancel (
|
|
|
|
Ip.Ip4,
|
|
|
|
&SndEntry->SndToken.Ip4Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip6->Cancel (
|
|
|
|
Ip.Ip6,
|
|
|
|
&SndEntry->SndToken.Ip6Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add a new IP instance for sending data.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
The function is used to add the IP_IO to the IP_IO sending list. The caller
|
|
|
|
can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send
|
|
|
|
data.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to a IP_IO instance to add a new IP
|
|
|
|
instance for sending purpose.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2008-12-30 13:26:40 +01:00
|
|
|
@return Pointer to the created IP_IO_IP_INFO structure, NULL if failed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
IP_IO_IP_INFO *
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoAddIp (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO *IpIo
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
IP_IO_IP_INFO *IpInfo;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_EVENT Event;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
ASSERT (IpIo != NULL);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
IpInfo = AllocatePool (sizeof (IP_IO_IP_INFO));
|
2007-07-23 11:17:39 +02:00
|
|
|
if (IpInfo == NULL) {
|
2009-10-26 11:15:40 +01:00
|
|
|
return NULL;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Init this IpInfo, set the Addr and SubnetMask to 0 before we configure the IP
|
|
|
|
// instance.
|
|
|
|
//
|
2008-02-14 10:40:22 +01:00
|
|
|
InitializeListHead (&IpInfo->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
IpInfo->ChildHandle = NULL;
|
2009-10-26 11:15:40 +01:00
|
|
|
ZeroMem (&IpInfo->Addr, sizeof (IpInfo->Addr));
|
|
|
|
ZeroMem (&IpInfo->PreMask, sizeof (IpInfo->PreMask));
|
|
|
|
|
|
|
|
IpInfo->RefCnt = 1;
|
|
|
|
IpInfo->IpVersion = IpIo->IpVersion;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
// Create the IP instance and open the IP protocol.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
Status = IpIoCreateIpChildOpenProtocol (
|
|
|
|
IpIo->Controller,
|
|
|
|
IpIo->Image,
|
|
|
|
&IpInfo->ChildHandle,
|
2009-10-26 11:15:40 +01:00
|
|
|
IpInfo->IpVersion,
|
2007-07-25 07:32:10 +02:00
|
|
|
(VOID **) &IpInfo->Ip
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ReleaseIpInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create the event for the DummyRcvToken.
|
|
|
|
//
|
|
|
|
Status = gBS->CreateEvent (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
2008-02-14 10:40:22 +01:00
|
|
|
TPL_NOTIFY,
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoDummyHandler,
|
|
|
|
IpInfo,
|
2009-10-26 11:15:40 +01:00
|
|
|
&Event
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ReleaseIpChild;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4) {
|
|
|
|
IpInfo->DummyRcvToken.Ip4Token.Event = Event;
|
|
|
|
} else {
|
|
|
|
IpInfo->DummyRcvToken.Ip6Token.Event = Event;
|
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
|
|
|
// Link this IpInfo into the IpIo.
|
|
|
|
//
|
2008-02-14 10:40:22 +01:00
|
|
|
InsertTailList (&IpIo->IpList, &IpInfo->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return IpInfo;
|
|
|
|
|
|
|
|
ReleaseIpChild:
|
|
|
|
|
|
|
|
IpIoCloseProtocolDestroyIpChild (
|
|
|
|
IpIo->Controller,
|
|
|
|
IpIo->Image,
|
2009-10-26 11:15:40 +01:00
|
|
|
IpInfo->ChildHandle,
|
|
|
|
IpInfo->IpVersion
|
2007-07-23 11:17:39 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
ReleaseIpInfo:
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
gBS->FreePool (IpInfo);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-10-26 11:15:40 +01:00
|
|
|
Configure the IP instance of this IpInfo and start the receiving if IpConfigData
|
2007-07-23 11:17:39 +02:00
|
|
|
is not NULL.
|
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpInfo Pointer to the IP_IO_IP_INFO instance.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in, out] IpConfigData The IP configure data used to configure the IP
|
2009-01-12 03:32:20 +01:00
|
|
|
instance, if NULL the IP instance is reset. If
|
|
|
|
UseDefaultAddress is set to TRUE, and the configure
|
|
|
|
operation succeeds, the default address information
|
2009-10-26 11:15:40 +01:00
|
|
|
is written back in this IpConfigData.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@retval EFI_SUCCESS The IP instance of this IpInfo is configured successfully
|
|
|
|
or no need to reconfigure it.
|
|
|
|
@retval Others Configuration fails.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoConfigIp (
|
2009-01-12 03:32:20 +01:00
|
|
|
IN OUT IP_IO_IP_INFO *IpInfo,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN OUT VOID *IpConfigData OPTIONAL
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2010-06-13 10:18:10 +02:00
|
|
|
IP_IO_IP_PROTOCOL Ip;
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IpVersion;
|
2007-07-23 11:17:39 +02:00
|
|
|
EFI_IP4_MODE_DATA Ip4ModeData;
|
2009-10-26 11:15:40 +01:00
|
|
|
EFI_IP6_MODE_DATA Ip6ModeData;
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
ASSERT (IpInfo != NULL);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
if (IpInfo->RefCnt > 1) {
|
|
|
|
//
|
|
|
|
// This IP instance is shared, don't reconfigure it until it has only one
|
|
|
|
// consumer. Currently, only the tcp children cloned from their passive parent
|
2009-10-26 11:15:40 +01:00
|
|
|
// will share the same IP. So this cases only happens while IpConfigData is NULL,
|
2007-07-23 11:17:39 +02:00
|
|
|
// let the last consumer clean the IP instance.
|
|
|
|
//
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpVersion = IpInfo->IpVersion;
|
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
Ip = IpInfo->Ip;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip4->Configure (Ip.Ip4, IpConfigData);
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip6->Configure (Ip.Ip6, IpConfigData);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto OnExit;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpConfigData != NULL) {
|
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4){
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (((EFI_IP4_CONFIG_DATA *) IpConfigData)->UseDefaultAddress) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip4->GetModeData (
|
|
|
|
Ip.Ip4,
|
|
|
|
&Ip4ModeData,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
((EFI_IP4_CONFIG_DATA*) IpConfigData)->StationAddress = Ip4ModeData.ConfigData.StationAddress;
|
|
|
|
((EFI_IP4_CONFIG_DATA*) IpConfigData)->SubnetMask = Ip4ModeData.ConfigData.SubnetMask;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
CopyMem (
|
|
|
|
&IpInfo->Addr.Addr,
|
|
|
|
&((EFI_IP4_CONFIG_DATA *) IpConfigData)->StationAddress,
|
|
|
|
sizeof (IP4_ADDR)
|
|
|
|
);
|
|
|
|
CopyMem (
|
|
|
|
&IpInfo->PreMask.SubnetMask,
|
|
|
|
&((EFI_IP4_CONFIG_DATA *) IpConfigData)->SubnetMask,
|
|
|
|
sizeof (IP4_ADDR)
|
|
|
|
);
|
|
|
|
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip4->Receive (
|
|
|
|
Ip.Ip4,
|
|
|
|
&IpInfo->DummyRcvToken.Ip4Token
|
|
|
|
);
|
2007-07-23 11:17:39 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip4->Configure (Ip.Ip4, NULL);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
} else {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip6->GetModeData (
|
|
|
|
Ip.Ip6,
|
|
|
|
&Ip6ModeData,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
if (Ip6ModeData.IsConfigured) {
|
|
|
|
CopyMem (
|
|
|
|
&((EFI_IP6_CONFIG_DATA *) IpConfigData)->StationAddress,
|
|
|
|
&Ip6ModeData.ConfigData.StationAddress,
|
|
|
|
sizeof (EFI_IPv6_ADDRESS)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (Ip6ModeData.AddressList != NULL) {
|
|
|
|
FreePool (Ip6ModeData.AddressList);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ip6ModeData.GroupTable != NULL) {
|
|
|
|
FreePool (Ip6ModeData.GroupTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ip6ModeData.RouteTable != NULL) {
|
|
|
|
FreePool (Ip6ModeData.RouteTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ip6ModeData.NeighborCache != NULL) {
|
|
|
|
FreePool (Ip6ModeData.NeighborCache);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ip6ModeData.PrefixTable != NULL) {
|
|
|
|
FreePool (Ip6ModeData.PrefixTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ip6ModeData.IcmpTypeList != NULL) {
|
|
|
|
FreePool (Ip6ModeData.IcmpTypeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Status = EFI_NO_MAPPING;
|
|
|
|
goto OnExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyMem (
|
|
|
|
&IpInfo->Addr,
|
|
|
|
&Ip6ModeData.ConfigData.StationAddress,
|
|
|
|
sizeof (EFI_IPv6_ADDRESS)
|
|
|
|
);
|
|
|
|
|
2010-06-13 10:18:10 +02:00
|
|
|
Status = Ip.Ip6->Receive (
|
|
|
|
Ip.Ip6,
|
|
|
|
&IpInfo->DummyRcvToken.Ip6Token
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip.Ip6->Configure (Ip.Ip6, NULL);
|
2009-10-26 11:15:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
// The IP instance is reset, set the stored Addr and SubnetMask to zero.
|
2007-07-23 11:17:39 +02:00
|
|
|
//
|
2009-10-26 11:15:40 +01:00
|
|
|
ZeroMem (&IpInfo->Addr, sizeof (IpInfo->Addr));
|
|
|
|
ZeroMem (&IpInfo->PreMask, sizeof (IpInfo->PreMask));
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
OnExit:
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroy an IP instance maintained in IpIo->IpList for
|
|
|
|
sending purpose.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function pairs with IpIoAddIp(). The IpInfo is previously created by
|
|
|
|
IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance
|
|
|
|
will be dstroyed if the RefCnt is zero.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] IpIo Pointer to the IP_IO instance.
|
|
|
|
@param[in] IpInfo Pointer to the IpInfo to be removed.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoRemoveIp (
|
2008-12-30 13:26:40 +01:00
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN IP_IO_IP_INFO *IpInfo
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
2009-10-26 11:15:40 +01:00
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
UINT8 IpVersion;
|
2009-10-26 11:15:40 +01:00
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
ASSERT (IpInfo->RefCnt > 0);
|
|
|
|
|
|
|
|
NET_PUT_REF (IpInfo);
|
|
|
|
|
|
|
|
if (IpInfo->RefCnt > 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpVersion = IpIo->IpVersion;
|
|
|
|
|
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
RemoveEntryList (&IpInfo->Entry);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpVersion == IP_VERSION_4){
|
2010-06-13 10:18:10 +02:00
|
|
|
IpInfo->Ip.Ip4->Configure (
|
|
|
|
IpInfo->Ip.Ip4,
|
|
|
|
NULL
|
|
|
|
);
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIoCloseProtocolDestroyIpChild (
|
|
|
|
IpIo->Controller,
|
|
|
|
IpIo->Image,
|
|
|
|
IpInfo->ChildHandle,
|
|
|
|
IP_VERSION_4
|
|
|
|
);
|
|
|
|
|
|
|
|
gBS->CloseEvent (IpInfo->DummyRcvToken.Ip4Token.Event);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
} else {
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2010-06-13 10:18:10 +02:00
|
|
|
IpInfo->Ip.Ip6->Configure (
|
|
|
|
IpInfo->Ip.Ip6,
|
|
|
|
NULL
|
|
|
|
);
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
IpIoCloseProtocolDestroyIpChild (
|
|
|
|
IpIo->Controller,
|
|
|
|
IpIo->Image,
|
|
|
|
IpInfo->ChildHandle,
|
|
|
|
IP_VERSION_6
|
|
|
|
);
|
|
|
|
|
|
|
|
gBS->CloseEvent (IpInfo->DummyRcvToken.Ip6Token.Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (IpInfo);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Find the first IP protocol maintained in IpIo whose local
|
2009-10-26 11:15:40 +01:00
|
|
|
address is the same as Src.
|
2008-12-30 13:26:40 +01:00
|
|
|
|
|
|
|
This function is called when the caller needs the IpIo to send data to the
|
|
|
|
specified Src. The IpIo was added previously by IpIoAddIp().
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in, out] IpIo Pointer to the pointer of the IP_IO instance.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] IpVersion The version of the IP protocol to use, either
|
|
|
|
IPv4 or IPv6.
|
2009-01-12 03:32:20 +01:00
|
|
|
@param[in] Src The local IP address.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
@return Pointer to the IP protocol can be used for sending purpose and its local
|
2009-10-26 11:15:40 +01:00
|
|
|
address is the same with Src.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
IP_IO_IP_INFO *
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoFindSender (
|
2009-10-26 11:15:40 +01:00
|
|
|
IN OUT IP_IO **IpIo,
|
2009-10-30 06:11:38 +01:00
|
|
|
IN UINT8 IpVersion,
|
2009-10-26 11:15:40 +01:00
|
|
|
IN EFI_IP_ADDRESS *Src
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY *IpIoEntry;
|
2007-07-23 11:17:39 +02:00
|
|
|
IP_IO *IpIoPtr;
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY *IpInfoEntry;
|
2007-07-23 11:17:39 +02:00
|
|
|
IP_IO_IP_INFO *IpInfo;
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6));
|
|
|
|
|
2007-07-23 11:17:39 +02:00
|
|
|
NET_LIST_FOR_EACH (IpIoEntry, &mActiveIpIoList) {
|
|
|
|
IpIoPtr = NET_LIST_USER_STRUCT (IpIoEntry, IP_IO, Entry);
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (((*IpIo != NULL) && (*IpIo != IpIoPtr)) || (IpIoPtr->IpVersion != IpVersion)) {
|
2007-07-23 11:17:39 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
NET_LIST_FOR_EACH (IpInfoEntry, &IpIoPtr->IpList) {
|
|
|
|
IpInfo = NET_LIST_USER_STRUCT (IpInfoEntry, IP_IO_IP_INFO, Entry);
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IpInfo->IpVersion == IP_VERSION_4){
|
|
|
|
|
|
|
|
if (EFI_IP4_EQUAL (&IpInfo->Addr.v4, &Src->v4)) {
|
|
|
|
*IpIo = IpIoPtr;
|
|
|
|
return IpInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (EFI_IP6_EQUAL (&IpInfo->Addr.v6, &Src->v6)) {
|
|
|
|
*IpIo = IpIoPtr;
|
|
|
|
return IpInfo;
|
|
|
|
}
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// No match.
|
|
|
|
//
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-12-30 13:26:40 +01:00
|
|
|
Get the ICMP error map information.
|
|
|
|
|
|
|
|
The ErrorStatus will be returned. The IsHard and Notify are optional. If they
|
|
|
|
are not NULL, this routine will fill them.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-13 09:48:19 +01:00
|
|
|
@param[in] IcmpError IcmpError Type.
|
2009-10-26 11:15:40 +01:00
|
|
|
@param[in] IpVersion The version of the IP protocol to use,
|
2010-03-19 07:55:58 +01:00
|
|
|
either IPv4 or IPv6.
|
|
|
|
@param[out] IsHard If TRUE, indicates that it is a hard error.
|
|
|
|
@param[out] Notify If TRUE, SockError needs to be notified.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-01-12 03:32:20 +01:00
|
|
|
@return ICMP Error Status, such as EFI_NETWORK_UNREACHABLE.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2008-04-11 05:36:07 +02:00
|
|
|
EFIAPI
|
2007-07-23 11:17:39 +02:00
|
|
|
IpIoGetIcmpErrStatus (
|
2009-10-30 06:11:38 +01:00
|
|
|
IN UINT8 IcmpError,
|
|
|
|
IN UINT8 IpVersion,
|
2008-12-30 13:26:40 +01:00
|
|
|
OUT BOOLEAN *IsHard OPTIONAL,
|
|
|
|
OUT BOOLEAN *Notify OPTIONAL
|
2007-07-23 11:17:39 +02:00
|
|
|
)
|
|
|
|
{
|
2009-10-27 03:45:43 +01:00
|
|
|
if (IpVersion == IP_VERSION_4 ) {
|
2009-10-30 06:11:38 +01:00
|
|
|
ASSERT (IcmpError <= ICMP_ERR_PARAMPROB);
|
2007-08-23 04:19:41 +02:00
|
|
|
|
2009-10-27 03:45:43 +01:00
|
|
|
if (IsHard != NULL) {
|
|
|
|
*IsHard = mIcmpErrMap[IcmpError].IsHard;
|
|
|
|
}
|
2007-08-23 04:19:41 +02:00
|
|
|
|
2009-10-27 03:45:43 +01:00
|
|
|
if (Notify != NULL) {
|
|
|
|
*Notify = mIcmpErrMap[IcmpError].Notify;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (IcmpError) {
|
|
|
|
case ICMP_ERR_UNREACH_NET:
|
|
|
|
return EFI_NETWORK_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP_ERR_TIMXCEED_INTRANS:
|
|
|
|
case ICMP_ERR_TIMXCEED_REASS:
|
|
|
|
case ICMP_ERR_UNREACH_HOST:
|
|
|
|
return EFI_HOST_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP_ERR_UNREACH_PROTOCOL:
|
|
|
|
return EFI_PROTOCOL_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP_ERR_UNREACH_PORT:
|
|
|
|
return EFI_PORT_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP_ERR_MSGSIZE:
|
|
|
|
case ICMP_ERR_UNREACH_SRCFAIL:
|
|
|
|
case ICMP_ERR_QUENCH:
|
|
|
|
case ICMP_ERR_PARAMPROB:
|
|
|
|
return EFI_ICMP_ERROR;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2007-08-23 04:19:41 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
} else if (IpVersion == IP_VERSION_6) {
|
|
|
|
|
2009-10-30 06:11:38 +01:00
|
|
|
ASSERT (IcmpError <= ICMP6_ERR_PARAMPROB_IPV6OPTION);
|
2007-08-23 04:19:41 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
if (IsHard != NULL) {
|
|
|
|
*IsHard = mIcmp6ErrMap[IcmpError].IsHard;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Notify != NULL) {
|
|
|
|
*Notify = mIcmp6ErrMap[IcmpError].Notify;
|
|
|
|
}
|
2009-10-27 03:45:43 +01:00
|
|
|
|
|
|
|
switch (IcmpError) {
|
|
|
|
case ICMP6_ERR_UNREACH_NET:
|
|
|
|
return EFI_NETWORK_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP6_ERR_UNREACH_HOST:
|
|
|
|
case ICMP6_ERR_TIMXCEED_HOPLIMIT:
|
|
|
|
case ICMP6_ERR_TIMXCEED_REASS:
|
|
|
|
return EFI_HOST_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP6_ERR_UNREACH_PROTOCOL:
|
|
|
|
return EFI_PROTOCOL_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP6_ERR_UNREACH_PORT:
|
|
|
|
return EFI_PORT_UNREACHABLE;
|
|
|
|
|
|
|
|
case ICMP6_ERR_PACKAGE_TOOBIG:
|
|
|
|
case ICMP6_ERR_PARAMPROB_HEADER:
|
|
|
|
case ICMP6_ERR_PARAMPROB_NEXHEADER:
|
|
|
|
case ICMP6_ERR_PARAMPROB_IPV6OPTION:
|
|
|
|
return EFI_ICMP_ERROR;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Should never be here
|
|
|
|
//
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
2007-07-23 11:17:39 +02:00
|
|
|
|
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
/**
|
|
|
|
Refresh the remote peer's Neighbor Cache entries.
|
|
|
|
|
|
|
|
This function is called when the caller needs the IpIo to refresh the existing
|
|
|
|
IPv6 neighbor cache entries since the neighbor is considered reachable by the
|
|
|
|
node has recently received a confirmation that packets sent recently to the
|
|
|
|
neighbor were received by its IP layer.
|
|
|
|
|
|
|
|
@param[in] IpIo Pointer to an IP_IO instance
|
|
|
|
@param[in] Neighbor The IP address of the neighbor
|
|
|
|
@param[in] Timeout Time in 100-ns units that this entry will
|
|
|
|
remain in the neighbor cache. A value of
|
|
|
|
zero means that the entry is permanent.
|
|
|
|
A value of non-zero means that the entry is
|
|
|
|
dynamic and will be deleted after Timeout.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation is completed successfully.
|
|
|
|
@retval EFI_NOT_STARTED The IpIo is not configured.
|
|
|
|
@retval EFI_INVALID_PARAMETER Neighbor Address is invalid.
|
|
|
|
@retval EFI_NOT_FOUND The neighbor cache entry is not in the
|
|
|
|
neighbor table.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
|
2007-07-23 11:17:39 +02:00
|
|
|
|
2009-10-26 11:15:40 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
IpIoRefreshNeighbor (
|
|
|
|
IN IP_IO *IpIo,
|
|
|
|
IN EFI_IP_ADDRESS *Neighbor,
|
|
|
|
IN UINT32 Timeout
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_IP6_PROTOCOL *Ip;
|
|
|
|
|
|
|
|
if (!IpIo->IsConfigured || IpIo->IpVersion != IP_VERSION_6) {
|
|
|
|
return EFI_NOT_STARTED;
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|
2010-06-13 10:18:10 +02:00
|
|
|
Ip = IpIo->Ip.Ip6;
|
2009-10-26 11:15:40 +01:00
|
|
|
|
|
|
|
return Ip->Neighbors (Ip, FALSE, &Neighbor->v6, NULL, Timeout, TRUE);
|
2007-07-23 11:17:39 +02:00
|
|
|
}
|
|
|
|
|