TianoCore EDK2 master
|
#include "Ip4Impl.h"
Go to the source code of this file.
Variables | |
EFI_MAC_ADDRESS | mZeroMacAddress |
Implement IP4 pseudo interface.
Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Ip4If.c.
VOID Ip4CancelFrameArp | ( | IN IP4_ARP_QUE * | ArpQue, |
IN EFI_STATUS | IoStatus, | ||
IN IP4_FRAME_TO_CANCEL FrameToCancel | OPTIONAL, | ||
IN VOID * | Context | ||
) |
Remove all the frames on the ARP queue that pass the FrameToCancel, that is, either FrameToCancel is NULL or it returns true for the frame.
[in] | ArpQue | ARP frame to remove the frames from. |
[in] | IoStatus | The status returned to the cancelled frames' callback function. |
[in] | FrameToCancel | Function to select which frame to cancel. |
[in] | Context | Opaque parameter to the FrameToCancel. |
VOID Ip4CancelFrames | ( | IN IP4_INTERFACE * | Interface, |
IN EFI_STATUS | IoStatus, | ||
IN IP4_FRAME_TO_CANCEL FrameToCancel | OPTIONAL, | ||
IN VOID * | Context | ||
) |
Remove all the frames on the interface that pass the FrameToCancel, either queued on ARP queues or that have already been delivered to MNP and not yet recycled.
[in] | Interface | Interface to remove the frames from. |
[in] | IoStatus | The transmit status returned to the frames' callback. |
[in] | FrameToCancel | Function to select the frame to cancel, NULL to select all. |
[in] | Context | Opaque parameters passed to FrameToCancel. |
BOOLEAN Ip4CancelInstanceFrame | ( | IN IP4_LINK_TX_TOKEN * | Frame, |
IN VOID * | Context | ||
) |
Filter function to cancel all the frame related to an IP instance.
[in] | Frame | The transmit request to test whether to cancel |
[in] | Context | The context which is the Ip instance that issued the transmit. |
TRUE | The frame belongs to this instance and is to be removed |
FALSE | The frame doesn't belong to this instance. |
VOID Ip4CancelReceive | ( | IN IP4_INTERFACE * | Interface | ) |
If there is a pending receive request, cancel it. Don't call the receive request's callback because this function can be only called if the instance or driver is tearing itself down. It doesn't make sense to call it back. But it is necessary to call the transmit token's callback to give it a chance to free the packet and update the upper layer's transmit request status, say that from the UDP.
[in] | Interface | The interface used by the IpInstance |
IP4_ARP_QUE * Ip4CreateArpQue | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_ADDR | DestIp | ||
) |
Create an IP_ARP_QUE structure to request ARP service.
[in] | Interface | The interface to send ARP from. |
[in] | DestIp | The destination IP (host byte order) to request MAC for |
IP4_INTERFACE * Ip4CreateInterface | ( | IN EFI_MANAGED_NETWORK_PROTOCOL * | Mnp, |
IN EFI_HANDLE | Controller, | ||
IN EFI_HANDLE | ImageHandle | ||
) |
Create an IP4_INTERFACE. Delay the creation of ARP instance until the interface is configured.
[in] | Mnp | The shared MNP child of this IP4 service binding instance. |
[in] | Controller | The controller this IP4 service binding instance is installed. Most like the UNDI handle. |
[in] | ImageHandle | This driver's image handle. |
IP4_LINK_RX_TOKEN * Ip4CreateLinkRxToken | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_PROTOCOL * | IpInstance, | ||
IN IP4_FRAME_CALLBACK | CallBack, | ||
IN VOID * | Context | ||
) |
Create a link layer receive token to wrap the receive request
[in] | Interface | The interface to receive from |
[in] | IpInstance | The instance that request the receive (NULL for IP4 driver itself) |
[in] | CallBack | Call back function to execute when finished. |
[in] | Context | Opaque parameters to the callback |
VOID Ip4FreeArpQue | ( | IN IP4_ARP_QUE * | ArpQue, |
IN EFI_STATUS | IoStatus | ||
) |
VOID Ip4FreeFrameRxToken | ( | IN IP4_LINK_RX_TOKEN * | Token | ) |
EFI_STATUS Ip4FreeInterface | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_PROTOCOL *IpInstance | OPTIONAL | ||
) |
Free the interface used by IpInstance. All the IP instance with the same Ip/Netmask pair share the same interface. It is reference counted. All the frames haven't been sent will be cancelled. Because the IpInstance is optional, the caller must remove IpInstance from the interface's instance list itself.
[in] | Interface | The interface used by the IpInstance. |
[in] | IpInstance | The Ip instance that free the interface. NULL if the Ip driver is releasing the default interface. |
EFI_SUCCESS | The interface use IpInstance is freed. |
VOID Ip4FreeLinkTxToken | ( | IN IP4_LINK_TX_TOKEN * | Token | ) |
VOID EFIAPI Ip4OnArpResolvedDpc | ( | IN VOID * | Context | ) |
Callback function when ARP request are finished. It will cancelled all the queued frame if the ARP requests failed. Or transmit them if the request succeed.
[in] | Context | The context of the callback, a point to the ARP queue |
Callback function when ARP request are finished. It will cancel all the queued frame if the ARP requests failed. Or transmit them if the request succeed.
[in] | Context | The context of the callback, a point to the ARP queue |
VOID EFIAPI Ip4OnFrameReceivedDpc | ( | IN VOID * | Context | ) |
Received a frame from MNP, wrap it in net buffer then deliver it to IP's input function. The ownship of the packet also transferred to IP. When Ip is finished with this packet, it will call NetbufFree to release the packet, NetbufFree will again call the Ip4RecycleFrame to signal MNP's event and free the token used.
Context | Context for the callback. |
VOID EFIAPI Ip4OnFrameSentDpc | ( | IN VOID * | Context | ) |
EFI_STATUS Ip4ReceiveFrame | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_PROTOCOL *IpInstance | OPTIONAL, | ||
IN IP4_FRAME_CALLBACK | CallBack, | ||
IN VOID * | Context | ||
) |
Request to receive the packet from the interface.
[in] | Interface | The interface to receive the frames from. |
[in] | IpInstance | The instance that requests the receive. NULL for the driver itself. |
[in] | CallBack | Function to call when receive finished. |
[in] | Context | Opaque parameter to the callback. |
EFI_ALREADY_STARTED | There is already a pending receive request. |
EFI_OUT_OF_RESOURCES | Failed to allocate resource to receive. |
EFI_SUCCESS | The receive request has been started. |
other | Other error occurs. |
VOID EFIAPI Ip4RecycleFrame | ( | IN VOID * | Context | ) |
Call back function when the received packet is freed. Check Ip4OnFrameReceived for information.
Context | Context, which is the IP4_LINK_RX_TOKEN. |
EFI_STATUS Ip4SendFrame | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_PROTOCOL *IpInstance | OPTIONAL, | ||
IN NET_BUF * | Packet, | ||
IN IP4_ADDR | NextHop, | ||
IN IP4_FRAME_CALLBACK | CallBack, | ||
IN VOID * | Context, | ||
IN IP4_SERVICE * | IpSb | ||
) |
Send a frame from the interface. If the next hop is broadcast or multicast address, it is transmitted immediately. If the next hop is a unicast, it will consult ARP to resolve the NextHop's MAC. If some error happened, the CallBack won't be called. So, the caller must test the return value, and take action when there is an error.
[in] | Interface | The interface to send the frame from |
[in] | IpInstance | The IP child that request the transmission. NULL if it is the IP4 driver itself. |
[in] | Packet | The packet to transmit. |
[in] | NextHop | The immediate destination to transmit the packet to. |
[in] | CallBack | Function to call back when transmit finished. |
[in] | Context | Opaque parameter to the call back. |
[in] | IpSb | The pointer to the IP4 service binding instance. |
EFI_OUT_OF_RESOURCES | Failed to allocate resource to send the frame |
EFI_NO_MAPPING | Can't resolve the MAC for the nexthop |
EFI_SUCCESS | The packet is successfully transmitted. |
other | Other error occurs. |
EFI_STATUS Ip4SendFrameToDefaultRoute | ( | IN IP4_ARP_QUE * | ArpQue | ) |
This function tries to send all the queued frames in ArpQue to the default gateway if the ARP resolve for direct destination address is failed when using /32 subnet mask.
[in] | ArpQue | The ARP queue of a failed request. |
EFI_SUCCESS | All the queued frames have been send to the default route. |
Others | Failed to send the queued frames. |
EFI_STATUS Ip4SetAddress | ( | IN OUT IP4_INTERFACE * | Interface, |
IN IP4_ADDR | IpAddr, | ||
IN IP4_ADDR | SubnetMask | ||
) |
Set the interface's address, create and configure the ARP child if necessary.
Interface | The interface to set the address. |
IpAddr | The interface's IP address. |
SubnetMask | The interface's netmask. |
EFI_SUCCESS | The interface is configured with Ip/netmask pair, and a ARP is created for it. |
Others | Failed to set the interface's address. |
IP4_LINK_TX_TOKEN * Ip4WrapLinkTxToken | ( | IN IP4_INTERFACE * | Interface, |
IN IP4_PROTOCOL *IpInstance | OPTIONAL, | ||
IN NET_BUF * | Packet, | ||
IN IP4_FRAME_CALLBACK | CallBack, | ||
IN VOID * | Context, | ||
IN IP4_SERVICE * | IpSb | ||
) |
Wrap a transmit request into a newly allocated IP4_LINK_TX_TOKEN.
[in] | Interface | The interface to send out to. |
[in] | IpInstance | The IpInstance that transmit the packet. NULL if the packet is sent by the IP4 driver itself. |
[in] | Packet | The packet to transmit |
[in] | CallBack | Call back function to execute if transmission finished. |
[in] | Context | Opaque parameter to the call back. |
[in] | IpSb | The pointer to the IP4 service binding instance. |
Token | The wrapped token if succeed |
NULL | The wrapped token if NULL |
EFI_MAC_ADDRESS mZeroMacAddress |