TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip4If.h File Reference

Go to the source code of this file.

Data Structures

struct  IP4_LINK_RX_TOKEN
 
struct  IP4_LINK_TX_TOKEN
 
struct  IP4_ARP_QUE
 
struct  _IP4_INTERFACE
 

Macros

#define IP4_FRAME_RX_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'R')
 
#define IP4_FRAME_TX_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'T')
 
#define IP4_FRAME_ARP_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'A')
 
#define IP4_INTERFACE_SIGNATURE   SIGNATURE_32 ('I', 'P', 'I', 'F')
 

Typedefs

typedef VOID(* IP4_FRAME_CALLBACK) (IN IP4_PROTOCOL *IpInstance OPTIONAL, IN NET_BUF *Packet, IN EFI_STATUS IoStatus, IN UINT32 LinkFlag, IN VOID *Context)
 
typedef BOOLEAN(* IP4_FRAME_TO_CANCEL) (IP4_LINK_TX_TOKEN *Frame, VOID *Context)
 

Functions

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)
 
EFI_STATUS Ip4FreeInterface (IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL)
 
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 Ip4CancelFrames (IN IP4_INTERFACE *Interface, IN EFI_STATUS IoStatus, IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL, IN VOID *Context)
 
VOID Ip4CancelReceive (IN IP4_INTERFACE *Interface)
 
EFI_STATUS Ip4ReceiveFrame (IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context)
 

Detailed Description

Definition for IP4 pseudo interface structure.

Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Ip4If.h.

Macro Definition Documentation

◆ IP4_FRAME_ARP_SIGNATURE

#define IP4_FRAME_ARP_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'A')

Definition at line 14 of file Ip4If.h.

◆ IP4_FRAME_RX_SIGNATURE

#define IP4_FRAME_RX_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'R')

Definition at line 12 of file Ip4If.h.

◆ IP4_FRAME_TX_SIGNATURE

#define IP4_FRAME_TX_SIGNATURE   SIGNATURE_32 ('I', 'P', 'F', 'T')

Definition at line 13 of file Ip4If.h.

◆ IP4_INTERFACE_SIGNATURE

#define IP4_INTERFACE_SIGNATURE   SIGNATURE_32 ('I', 'P', 'I', 'F')

Definition at line 15 of file Ip4If.h.

Typedef Documentation

◆ IP4_FRAME_CALLBACK

typedef VOID(* IP4_FRAME_CALLBACK) (IN IP4_PROTOCOL *IpInstance OPTIONAL, IN NET_BUF *Packet, IN EFI_STATUS IoStatus, IN UINT32 LinkFlag, IN VOID *Context)

This prototype is used by both receive and transmission. When receiving Netbuf is allocated by IP4_INTERFACE, and released by IP4. Flag shows whether the frame is received as link broadcast/multicast...

When transmitting, the Netbuf is from IP4, and provided to the callback as a reference. Flag isn't used.

Parameters
[in]IpInstanceThe instance that sent or received the packet. IpInstance can be NULL which means that it is the IP4 driver itself sending the packets. IP4 driver may send packets that don't belong to any instance, such as ICMP errors, ICMP echo responses, or IGMP packets. IpInstance is used as a tag in this module.
[in]PacketThe sent or received packet.
[in]IoStatusStatus of sending or receiving.
[in]LinkFlagIndicate if the frame is received as link broadcast/multicast. When transmitting, it is not used.
[in]ContextAdditional data for callback.
Return values
None.

Definition at line 41 of file Ip4If.h.

◆ IP4_FRAME_TO_CANCEL

typedef BOOLEAN(* IP4_FRAME_TO_CANCEL) (IP4_LINK_TX_TOKEN *Frame, VOID *Context)

Callback to select which frame to cancel. Caller can cancel a single frame, or all the frame from an IP instance.

Parameters
FrameThe sending frame to check for cancellation.
ContextAdditional data for callback.
Return values
TRUEThe sending of the frame should be cancelled.
FALSEDo not cancel the frame sending.

Definition at line 122 of file Ip4If.h.

Function Documentation

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.