TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip4If.c File Reference
#include "Ip4Impl.h"

Go to the source code of this file.

Functions

VOID EFIAPI Ip4OnFrameSentDpc (IN VOID *Context)
 
VOID EFIAPI Ip4OnFrameSent (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI Ip4OnArpResolvedDpc (IN VOID *Context)
 
VOID EFIAPI Ip4OnArpResolved (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI Ip4OnFrameReceivedDpc (IN VOID *Context)
 
VOID EFIAPI Ip4OnFrameReceived (IN EFI_EVENT Event, IN VOID *Context)
 
VOID Ip4CancelFrameArp (IN IP4_ARP_QUE *ArpQue, IN EFI_STATUS IoStatus, IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL, IN VOID *Context)
 
IP4_LINK_TX_TOKENIp4WrapLinkTxToken (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)
 
VOID Ip4FreeLinkTxToken (IN IP4_LINK_TX_TOKEN *Token)
 
IP4_ARP_QUEIp4CreateArpQue (IN IP4_INTERFACE *Interface, IN IP4_ADDR DestIp)
 
VOID Ip4FreeArpQue (IN IP4_ARP_QUE *ArpQue, IN EFI_STATUS IoStatus)
 
IP4_LINK_RX_TOKENIp4CreateLinkRxToken (IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context)
 
VOID Ip4FreeFrameRxToken (IN IP4_LINK_RX_TOKEN *Token)
 
VOID Ip4CancelFrames (IN IP4_INTERFACE *Interface, IN EFI_STATUS IoStatus, IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL, IN VOID *Context)
 
IP4_INTERFACEIp4CreateInterface (IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp, IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle)
 
EFI_STATUS Ip4SetAddress (IN OUT IP4_INTERFACE *Interface, IN IP4_ADDR IpAddr, IN IP4_ADDR SubnetMask)
 
BOOLEAN Ip4CancelInstanceFrame (IN IP4_LINK_TX_TOKEN *Frame, IN VOID *Context)
 
VOID Ip4CancelReceive (IN IP4_INTERFACE *Interface)
 
EFI_STATUS Ip4FreeInterface (IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL)
 
EFI_STATUS Ip4SendFrameToDefaultRoute (IN IP4_ARP_QUE *ArpQue)
 
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)
 
VOID EFIAPI Ip4RecycleFrame (IN VOID *Context)
 
EFI_STATUS Ip4ReceiveFrame (IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context)
 

Variables

EFI_MAC_ADDRESS mZeroMacAddress
 

Detailed Description

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.

Function Documentation

◆ Ip4CancelFrameArp()

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.

Parameters
[in]ArpQueARP frame to remove the frames from.
[in]IoStatusThe status returned to the cancelled frames' callback function.
[in]FrameToCancelFunction to select which frame to cancel.
[in]ContextOpaque parameter to the FrameToCancel.

Definition at line 388 of file Ip4If.c.

◆ Ip4CancelFrames()

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.

Parameters
[in]InterfaceInterface to remove the frames from.
[in]IoStatusThe transmit status returned to the frames' callback.
[in]FrameToCancelFunction to select the frame to cancel, NULL to select all.
[in]ContextOpaque parameters passed to FrameToCancel.

Definition at line 425 of file Ip4If.c.

◆ Ip4CancelInstanceFrame()

BOOLEAN Ip4CancelInstanceFrame ( IN IP4_LINK_TX_TOKEN Frame,
IN VOID *  Context 
)

Filter function to cancel all the frame related to an IP instance.

Parameters
[in]FrameThe transmit request to test whether to cancel
[in]ContextThe context which is the Ip instance that issued the transmit.
Return values
TRUEThe frame belongs to this instance and is to be removed
FALSEThe frame doesn't belong to this instance.

Definition at line 674 of file Ip4If.c.

◆ Ip4CancelReceive()

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.

Parameters
[in]InterfaceThe interface used by the IpInstance

Definition at line 699 of file Ip4If.c.

◆ Ip4CreateArpQue()

IP4_ARP_QUE * Ip4CreateArpQue ( IN IP4_INTERFACE Interface,
IN IP4_ADDR  DestIp 
)

Create an IP_ARP_QUE structure to request ARP service.

Parameters
[in]InterfaceThe interface to send ARP from.
[in]DestIpThe destination IP (host byte order) to request MAC for
Returns
Point to newly created IP4_ARP_QUE if succeed, otherwise NULL.

Definition at line 239 of file Ip4If.c.

◆ Ip4CreateInterface()

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.

Parameters
[in]MnpThe shared MNP child of this IP4 service binding instance.
[in]ControllerThe controller this IP4 service binding instance is installed. Most like the UNDI handle.
[in]ImageHandleThis driver's image handle.
Returns
Point to the created IP4_INTERFACE, otherwise NULL.

Definition at line 477 of file Ip4If.c.

◆ Ip4CreateLinkRxToken()

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

Parameters
[in]InterfaceThe interface to receive from
[in]IpInstanceThe instance that request the receive (NULL for IP4 driver itself)
[in]CallBackCall back function to execute when finished.
[in]ContextOpaque parameters to the callback
Returns
Point to created IP4_LINK_RX_TOKEN if succeed, otherwise NULL.

Definition at line 316 of file Ip4If.c.

◆ Ip4FreeArpQue()

VOID Ip4FreeArpQue ( IN IP4_ARP_QUE ArpQue,
IN EFI_STATUS  IoStatus 
)

Remove all the transmit requests queued on the ARP queue, then free it.

Parameters
[in]ArpQueArp queue to free
[in]IoStatusThe transmit status returned to transmit requests' callback.

Definition at line 287 of file Ip4If.c.

◆ Ip4FreeFrameRxToken()

VOID Ip4FreeFrameRxToken ( IN IP4_LINK_RX_TOKEN Token)

Free the link layer request token. It will close the event then free the memory used.

Parameters
[in]TokenRequest token to free.

Definition at line 366 of file Ip4If.c.

◆ Ip4FreeInterface()

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.

Parameters
[in]InterfaceThe interface used by the IpInstance.
[in]IpInstanceThe Ip instance that free the interface. NULL if the Ip driver is releasing the default interface.
Return values
EFI_SUCCESSThe interface use IpInstance is freed.

Definition at line 731 of file Ip4If.c.

◆ Ip4FreeLinkTxToken()

VOID Ip4FreeLinkTxToken ( IN IP4_LINK_TX_TOKEN Token)

Free the link layer transmit token. It will close the event then free the memory used.

Parameters
[in]TokenToken to free

Definition at line 218 of file Ip4If.c.

◆ Ip4OnArpResolved()

VOID EFIAPI Ip4OnArpResolved ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Request Ip4OnArpResolvedDpc as a DPC at TPL_CALLBACK.

Parameters
EventThe Arp request event.
ContextThe context of the callback, a point to the ARP queue.

Definition at line 966 of file Ip4If.c.

◆ Ip4OnArpResolvedDpc()

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.

Parameters
[in]ContextThe 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.

Parameters
[in]ContextThe context of the callback, a point to the ARP queue

Definition at line 881 of file Ip4If.c.

◆ Ip4OnFrameReceived()

VOID EFIAPI Ip4OnFrameReceived ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Request Ip4OnFrameReceivedDpc as a DPC at TPL_CALLBACK.

Parameters
EventThe receive event delivered to MNP for receive.
ContextContext for the callback.

Definition at line 1276 of file Ip4If.c.

◆ Ip4OnFrameReceivedDpc()

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.

Parameters
ContextContext for the callback.

Definition at line 1212 of file Ip4If.c.

◆ Ip4OnFrameSent()

VOID EFIAPI Ip4OnFrameSent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Request Ip4OnFrameSentDpc as a DPC at TPL_CALLBACK.

Parameters
[in]EventThe transmit token's event.
[in]ContextContext which is point to the token.

Definition at line 1017 of file Ip4If.c.

◆ Ip4OnFrameSentDpc()

VOID EFIAPI Ip4OnFrameSentDpc ( IN VOID *  Context)

Callback function when frame transmission is finished. It will call the frame owner's callback function to tell it the result.

Parameters
[in]ContextContext which is point to the token.

Definition at line 986 of file Ip4If.c.

◆ Ip4ReceiveFrame()

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.

Parameters
[in]InterfaceThe interface to receive the frames from.
[in]IpInstanceThe instance that requests the receive. NULL for the driver itself.
[in]CallBackFunction to call when receive finished.
[in]ContextOpaque parameter to the callback.
Return values
EFI_ALREADY_STARTEDThere is already a pending receive request.
EFI_OUT_OF_RESOURCESFailed to allocate resource to receive.
EFI_SUCCESSThe receive request has been started.
otherOther error occurs.

Definition at line 1303 of file Ip4If.c.

◆ Ip4RecycleFrame()

VOID EFIAPI Ip4RecycleFrame ( IN VOID *  Context)

Call back function when the received packet is freed. Check Ip4OnFrameReceived for information.

Parameters
ContextContext, which is the IP4_LINK_RX_TOKEN.

Definition at line 1186 of file Ip4If.c.

◆ Ip4SendFrame()

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.

Parameters
[in]InterfaceThe interface to send the frame from
[in]IpInstanceThe IP child that request the transmission. NULL if it is the IP4 driver itself.
[in]PacketThe packet to transmit.
[in]NextHopThe immediate destination to transmit the packet to.
[in]CallBackFunction to call back when transmit finished.
[in]ContextOpaque parameter to the call back.
[in]IpSbThe pointer to the IP4 service binding instance.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate resource to send the frame
EFI_NO_MAPPINGCan't resolve the MAC for the nexthop
EFI_SUCCESSThe packet is successfully transmitted.
otherOther error occurs.

Definition at line 1052 of file Ip4If.c.

◆ Ip4SendFrameToDefaultRoute()

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.

Parameters
[in]ArpQueThe ARP queue of a failed request.
Return values
EFI_SUCCESSAll the queued frames have been send to the default route.
OthersFailed to send the queued frames.

Definition at line 794 of file Ip4If.c.

◆ Ip4SetAddress()

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.

Parameters
InterfaceThe interface to set the address.
IpAddrThe interface's IP address.
SubnetMaskThe interface's netmask.
Return values
EFI_SUCCESSThe interface is configured with Ip/netmask pair, and a ARP is created for it.
OthersFailed to set the interface's address.

Definition at line 547 of file Ip4If.c.

◆ Ip4WrapLinkTxToken()

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.

Parameters
[in]InterfaceThe interface to send out to.
[in]IpInstanceThe IpInstance that transmit the packet. NULL if the packet is sent by the IP4 driver itself.
[in]PacketThe packet to transmit
[in]CallBackCall back function to execute if transmission finished.
[in]ContextOpaque parameter to the call back.
[in]IpSbThe pointer to the IP4 service binding instance.
Return values
TokenThe wrapped token if succeed
NULLThe wrapped token if NULL

Definition at line 141 of file Ip4If.c.

Variable Documentation

◆ mZeroMacAddress

EFI_MAC_ADDRESS mZeroMacAddress

Definition at line 15 of file Ip4If.c.