/** @file
Implement IP6 pesudo interface.
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"
/**
Request Ip6OnFrameSentDpc as a DPC at TPL_CALLBACK.
@param[in] Event The transmit token's event.
@param[in] Context The Context which is pointed to the token.
**/
);
/**
Fileter function to cancel all the frame related to an IP instance.
@param[in] Frame The transmit request to test whether to cancel.
@param[in] Context The context which is the Ip instance that issued
the transmit.
@retval TRUE The frame belongs to this instance and is to be
removed.
@retval FALSE The frame doesn't belong to this instance.
**/
)
{
return TRUE;
}
return FALSE;
}
/**
Set the interface's address. This will trigger the DAD process for the
address to set. To set an already set address, the lifetimes wil be
updated to the new value passed in.
@param[in] Interface The interface to set the address.
@param[in] Ip6Addr The interface's to be assigned IPv6 address.
@param[in] IsAnycast If TRUE, the unicast IPv6 address is anycast.
Otherwise, it is not anycast.
@param[in] PrefixLength The prefix length of the Ip6Addr.
@param[in] ValidLifetime The valid lifetime for this address.
@param[in] PreferredLifetime The preferred lifetime for this address.
@param[in] DadCallback The caller's callback to trigger when DAD finishes.
This is an optional parameter that may be NULL.
@param[in] Context The context that will be passed to DadCallback.
This is an optional parameter that may be NULL.
@retval EFI_SUCCESS The interface is scheduled to be configured with
the specified address.
@retval EFI_OUT_OF_RESOURCES Failed to set the interface's address due to
lack of resources.
**/
)
{
//
// Update the lifetime.
//
if (DadCallback != NULL) {
}
return EFI_SUCCESS;
}
if (AddressInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
if (AddressInfo->PrefixLength == 0) {
//
// Find an appropriate prefix from on-link prefixes and update the prefixlength.
// Longest prefix match is used here.
//
break;
}
}
}
if (AddressInfo->PrefixLength == 0) {
//
// If the prefix length is still zero, try the autonomous prefixes.
// Longest prefix match is used here.
//
break;
}
}
}
if (AddressInfo->PrefixLength == 0) {
//
// BUGBUG: Stil fail, use 64 as the default prefix length.
//
}
//
// Node should delay joining the solicited-node mulitcast address by a random delay
// between 0 and MAX_RTR_SOLICITATION_DELAY (1 second).
// Thus queue the address to be processed in Duplicate Address Detection module
// after the delay time (in milliseconds).
//
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Create an IP6_INTERFACE.
@param[in] IpSb The IP6 service binding instance.
@param[in] LinkLocal If TRUE, the instance is created for link-local address.
Otherwise, it is not for a link-local address.
@return Point to the created IP6_INTERFACE, otherwise NULL.
**/
)
{
return NULL;
}
Interface->AddressCount = 0;
if (!LinkLocal) {
return Interface;
}
//
// Get the link local addr
//
goto ON_ERROR;
}
//
// Perform DAD - Duplicate Address Detection.
//
Status = Ip6SetAddress (
NULL,
);
goto ON_ERROR;
}
return Interface;
return NULL;
}
/**
Free the interface used by IpInstance. All the IP instance with
counted. All the frames that haven't been sent will be cancelled.
Because the IpInstance is optional, the caller must remove
IpInstance from the interface's instance list.
@param[in] Interface The interface used by the IpInstance.
@param[in] IpInstance The IP instance that free the interface. NULL if
the IP driver is releasing the default interface.
**/
)
{
//
// Remove all the pending transmit token related to this IP instance.
//
return;
}
//
// Destory the interface if this is the last IP instance.
// Remove all the system transmitted packets
// from this interface, cancel the receive request if exists.
//
}
}
}
/**
Create and wrap a transmit request into a newly allocated IP6_LINK_TX_TOKEN.
@param[in] Interface The interface to send out from.
@param[in] IpInstance The IpInstance that transmit the packet. NULL if
the packet is sent by the IP6 driver itself.
@param[in] Packet The packet to transmit
@param[in] CallBack Call back function to execute if transmission
finished.
@param[in] Context Opaque parameter to the callback.
@return The wrapped token if succeed or NULL.
**/
)
{
Token = AllocatePool (sizeof (IP6_LINK_TX_TOKEN) + (Packet->BlockOpNum - 1) * sizeof (EFI_MANAGED_NETWORK_FRAGMENT_DATA));
return NULL;
}
);
return NULL;
}
MnpTxData->HeaderLength = 0;
return Token;
}
/**
Free the link layer transmit token. It will close the event,
then free the memory used.
@param[in] Token Token to free.
**/
)
{
}
/**
Callback function when the received packet is freed.
Check Ip6OnFrameReceived for information.
@param[in] Context Points to EFI_MANAGED_NETWORK_RECEIVE_DATA.
**/
)
{
}
/**
Received a frame from MNP. Wrap it in net buffer then deliver
it to IP's input function. The ownship of the packet also
is transferred to IP. When Ip is finished with this packet, it
will call NetbufFree to release the packet, NetbufFree will
again call the Ip6RecycleFrame to signal MNP's event and free
the token used.
@param[in] Context Context for the callback.
**/
)
{
//
// First clear the interface's receive request in case the
// caller wants to call Ip6ReceiveFrame in the callback.
//
return ;
}
//
// Wrap the frame in a net buffer then deliever it to IP input.
// IP will reassemble the packet, and deliver it to upper layer
//
Packet = NetbufFromExt (&Netfrag, 1, IP6_MAX_HEADLEN, 0, Ip6RecycleFrame, Token->MnpToken.Packet.RxData);
return ;
}
}
/**
Request Ip6OnFrameReceivedDpc as a DPC at TPL_CALLBACK.
@param Event The receive event delivered to MNP for receive.
@param Context Context for the callback.
**/
)
{
//
// Request Ip6OnFrameReceivedDpc as a DPC at TPL_CALLBACK
//
}
/**
Request to receive the packet from the interface.
@param[in] CallBack Function to call when receive finished.
@param[in] IpSb Points to IP6 service binding instance.
@retval EFI_ALREADY_STARTED There is already a pending receive request.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive.
@retval EFI_SUCCESS The recieve request has been started.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return Status;
}
return EFI_SUCCESS;
}
/**
Callback funtion when frame transmission is finished. It will
call the frame owner's callback function to tell it the result.
@param[in] Context Context which points to the token.
**/
)
{
0,
);
}
/**
Request Ip6OnFrameSentDpc as a DPC at TPL_CALLBACK.
@param[in] Event The transmit token's event.
@param[in] Context Context which points to the token.
**/
)
{
//
// Request Ip6OnFrameSentDpc as a DPC at TPL_CALLBACK
//
}
/**
Send a frame from the interface. If the next hop is a multicast address,
it is transmitted immediately. If the next hop is a unicast,
and the NextHop's MAC is not known, it will perform address resolution.
If an error occurred, the CallBack won't be called. So, the caller
must test the return value, and take action when there is an error.
@param[in] Interface The interface to send the frame from
@param[in] IpInstance The IP child that request the transmission.
NULL if it is the IP6 driver itself.
@param[in] Packet The packet to transmit.
@param[in] NextHop The immediate destination to transmit the packet to.
@param[in] CallBack Function to call back when transmit finished.
@param[in] Context Opaque parameter to the callback.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame.
@retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop.
@retval EFI_SUCCESS The packet successfully transmitted.
**/
)
{
//
// Only when link local address is performing DAD, the interface could be used in unconfigured.
//
if (IpSb->LinkLocalOk) {
}
return EFI_OUT_OF_RESOURCES;
}
if (IP6_IS_MULTICAST (NextHop)) {
goto Error;
}
goto SendNow;
}
//
// If send to itself, directly send out
//
goto SendNow;
}
//
// If unicast, check the neighbor state.
//
}
switch (NeighborCache->State) {
case EfiNeighborStale:
//
// Fall through
//
case EfiNeighborReachable:
case EfiNeighborDelay:
case EfiNeighborProbe:
goto SendNow;
break;
default:
break;
}
//
// Have to do asynchronous ARP resolution. First check whether there is
// already a pending request.
//
if (ArpQue == NeighborCache) {
return EFI_SUCCESS;
}
}
//
// First frame requires ARP.
//
return EFI_SUCCESS;
//
// Insert the tx token into the SentFrames list before calling Mnp->Transmit.
// Remove it if the returned status is not EFI_SUCCESS.
//
goto Error;
}
return EFI_SUCCESS;
return Status;
}
/**
The heartbeat timer of IP6 service instance. It times out
all of its IP6 children's received-but-not-delivered and
transmitted-but-not-recycle packets.
@param[in] Event The IP6 service instance's heartbeat timer.
@param[in] Context The IP6 service instance.
**/
)
{
}