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

Go to the source code of this file.

Functions

VOID EFIAPI Udp4CheckTimeout (IN EFI_EVENT Event, IN VOID *Context)
 
BOOLEAN Udp4FindInstanceByPort (IN LIST_ENTRY *InstanceList, IN EFI_IPv4_ADDRESS *Address, IN UINT16 Port)
 
VOID EFIAPI Udp4DgramSent (IN EFI_STATUS Status, IN VOID *Context, IN IP_IO_IP_PROTOCOL Sender, IN VOID *NotifyData)
 
VOID EFIAPI Udp4DgramRcvd (IN EFI_STATUS Status, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context)
 
EFI_STATUS EFIAPI Udp4CancelTokens (IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
 
BOOLEAN Udp4MatchDgram (IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_SESSION_DATA *Udp4Session)
 
VOID EFIAPI Udp4RecycleRxDataWrap (IN EFI_EVENT Event, IN VOID *Context)
 
UDP4_RXDATA_WRAPUdp4WrapRxData (IN UDP4_INSTANCE_DATA *Instance, IN NET_BUF *Packet, IN EFI_UDP4_RECEIVE_DATA *RxData)
 
UINTN Udp4EnqueueDgram (IN UDP4_SERVICE_DATA *Udp4Service, IN NET_BUF *Packet, IN EFI_UDP4_RECEIVE_DATA *RxData)
 
VOID Udp4DeliverDgram (IN UDP4_SERVICE_DATA *Udp4Service)
 
VOID Udp4Demultiplex (IN UDP4_SERVICE_DATA *Udp4Service, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet)
 
VOID Udp4IcmpHandler (IN UDP4_SERVICE_DATA *Udp4Service, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet)
 
VOID Udp4SendPortUnreach (IN IP_IO *IpIo, IN EFI_NET_SESSION_DATA *NetSession, IN VOID *Udp4Header)
 
EFI_STATUS Udp4CreateService (IN OUT UDP4_SERVICE_DATA *Udp4Service, IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle)
 
VOID Udp4CleanService (IN UDP4_SERVICE_DATA *Udp4Service)
 
VOID Udp4InitInstance (IN UDP4_SERVICE_DATA *Udp4Service, IN OUT UDP4_INSTANCE_DATA *Instance)
 
VOID Udp4CleanInstance (IN UDP4_INSTANCE_DATA *Instance)
 
EFI_STATUS Udp4Bind (IN LIST_ENTRY *InstanceList, IN OUT EFI_UDP4_CONFIG_DATA *ConfigData)
 
BOOLEAN Udp4IsReconfigurable (IN EFI_UDP4_CONFIG_DATA *OldConfigData, IN EFI_UDP4_CONFIG_DATA *NewConfigData)
 
VOID Udp4BuildIp4ConfigData (IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData)
 
EFI_STATUS Udp4ValidateTxToken (IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *TxToken)
 
EFI_STATUS EFIAPI Udp4TokenExist (IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
 
UINT16 Udp4Checksum (IN NET_BUF *Packet, IN UINT16 HeadSum)
 
EFI_STATUS Udp4RemoveToken (IN OUT NET_MAP *TokenMap, IN EFI_UDP4_COMPLETION_TOKEN *Token)
 
EFI_STATUS EFIAPI Udp4LeaveGroup (IN OUT NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
 
VOID Udp4FlushRcvdDgram (IN UDP4_INSTANCE_DATA *Instance)
 
EFI_STATUS Udp4InstanceCancelToken (IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL)
 
VOID Udp4InstanceDeliverDgram (IN UDP4_INSTANCE_DATA *Instance)
 
VOID Udp4ReportIcmpError (IN UDP4_INSTANCE_DATA *Instance)
 
VOID EFIAPI Udp4NetVectorExtFree (VOID *Context)
 

Variables

UINT16 mUdp4RandomPort
 

Detailed Description

The implementation of the Udp4 protocol.

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

Definition in file Udp4Impl.c.

Function Documentation

◆ Udp4Bind()

EFI_STATUS Udp4Bind ( IN LIST_ENTRY InstanceList,
IN OUT EFI_UDP4_CONFIG_DATA ConfigData 
)

This function tries to bind the udp instance according to the configured port allocation strategy.

Parameters
[in]InstanceListPointer to the head of the list linking the udp instances.
[in,out]ConfigDataPointer to the ConfigData of the instance to be bound. ConfigData->StationPort will be assigned with an available port value on success.
Return values
EFI_SUCCESSThe bound operation is completed successfully.
EFI_ACCESS_DENIEDThe <Address, Port> specified by the ConfigData is already used by other instance.
EFI_OUT_OF_RESOURCESNo available port resources.

Definition at line 566 of file Udp4Impl.c.

◆ Udp4BuildIp4ConfigData()

VOID Udp4BuildIp4ConfigData ( IN EFI_UDP4_CONFIG_DATA Udp4ConfigData,
IN OUT EFI_IP4_CONFIG_DATA Ip4ConfigData 
)

This function builds the Ip4 configdata from the Udp4ConfigData.

Parameters
[in]Udp4ConfigDataPointer to the EFI_UDP4_CONFIG_DATA.
[in,out]Ip4ConfigDataPointer to the EFI_IP4_CONFIG_DATA.

Definition at line 720 of file Udp4Impl.c.

◆ Udp4CancelTokens()

EFI_STATUS EFIAPI Udp4CancelTokens ( IN NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *Arg  OPTIONAL 
)

This function cancels the token specified by Arg in the Map. This is a callback used by Udp4InstanceCancelToken().

Parameters
[in]MapPointer to the NET_MAP.
[in]ItemPointer to the NET_MAP_ITEM.
[in]ArgPointer to the token to be cancelled, if NULL, the token specified by Item is cancelled.
Return values
EFI_SUCCESSThe token is cancelled if Arg is NULL or the token is not the same as that in the Item if Arg is not NULL.
EFI_ABORTEDArg is not NULL, and the token specified by Arg is cancelled.

Definition at line 1120 of file Udp4Impl.c.

◆ Udp4Checksum()

UINT16 Udp4Checksum ( IN NET_BUF Packet,
IN UINT16  HeadSum 
)

This function calculates the checksum for the Packet, utilizing the pre-calculated pseudo HeadSum to reduce some overhead.

Parameters
[in]PacketPointer to the NET_BUF contains the udp datagram.
[in]HeadSumChecksum of the pseudo header except the length field.
Return values
The16-bit checksum of this udp datagram.

Definition at line 922 of file Udp4Impl.c.

◆ Udp4CheckTimeout()

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

This function checks and timeouts the I/O datagrams holding by the corresponding service context.

Parameters
[in]EventThe event this function registered to.
[in]ContextThe context data registered during the creation of the Event.

Definition at line 386 of file Udp4Impl.c.

◆ Udp4CleanInstance()

VOID Udp4CleanInstance ( IN UDP4_INSTANCE_DATA Instance)

This function cleans the udp instance.

Parameters
[in]InstancePointer to the UDP4_INSTANCE_DATA to clean.

Definition at line 486 of file Udp4Impl.c.

◆ Udp4CleanService()

VOID Udp4CleanService ( IN UDP4_SERVICE_DATA Udp4Service)

Clean the Udp service context data.

Parameters
[in]Udp4ServicePointer to the UDP4_SERVICE_DATA.

Definition at line 355 of file Udp4Impl.c.

◆ Udp4CreateService()

EFI_STATUS Udp4CreateService ( IN OUT UDP4_SERVICE_DATA Udp4Service,
IN EFI_HANDLE  ImageHandle,
IN EFI_HANDLE  ControllerHandle 
)

Create the Udp service context data.

Parameters
[in,out]Udp4ServicePointer to the UDP4_SERVICE_DATA.
[in]ImageHandleThe image handle of this udp4 driver.
[in]ControllerHandleThe controller handle this udp4 driver binds on.
Return values
EFI_SUCCESSThe udp4 service context data is created and initialized.
EFI_OUT_OF_RESOURCESCannot allocate memory.
otherOther error occurs.

Definition at line 262 of file Udp4Impl.c.

◆ Udp4DeliverDgram()

VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA Udp4Service)

This function delivers the datagrams enqueued in the instances.

Parameters
[in]Udp4ServicePointer to the udp service context data.

Definition at line 1546 of file Udp4Impl.c.

◆ Udp4Demultiplex()

VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA Udp4Service,
IN EFI_NET_SESSION_DATA NetSession,
IN NET_BUF Packet 
)

This function demultiplexes the received udp datagram to the appropriate instances.

Parameters
[in]Udp4ServicePointer to the udp service context data.
[in]NetSessionPointer to the EFI_NET_SESSION_DATA abstracted from the received datagram.
[in]PacketPointer to the buffer containing the received udp datagram.

Definition at line 1581 of file Udp4Impl.c.

◆ Udp4DgramRcvd()

VOID EFIAPI Udp4DgramRcvd ( IN EFI_STATUS  Status,
IN UINT8  IcmpError,
IN EFI_NET_SESSION_DATA NetSession,
IN NET_BUF Packet,
IN VOID *  Context 
)

This function processes the received datagram passed up by the IpIo layer.

Parameters
[in]StatusThe status of this udp datagram.
[in]IcmpErrorThe IcmpError code, only available when Status is EFI_ICMP_ERROR.
[in]NetSessionPointer to the EFI_NET_SESSION_DATA.
[in]PacketPointer to the NET_BUF containing the received udp datagram.
[in]ContextPointer to the context data.

Definition at line 1022 of file Udp4Impl.c.

◆ Udp4DgramSent()

VOID EFIAPI Udp4DgramSent ( IN EFI_STATUS  Status,
IN VOID *  Context,
IN IP_IO_IP_PROTOCOL  Sender,
IN VOID *  NotifyData 
)

This function is the packet transmitting notify function registered to the IpIo interface. It's called to signal the udp TxToken when IpIo layer completes the transmitting of the udp datagram.

Parameters
[in]StatusThe completion status of the output udp datagram.
[in]ContextPointer to the context data.
[in]SenderSpecify a pointer of EFI_IP4_PROTOCOL for sending.
[in]NotifyDataPointer to the notify data.

Definition at line 985 of file Udp4Impl.c.

◆ Udp4EnqueueDgram()

UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA Udp4Service,
IN NET_BUF Packet,
IN EFI_UDP4_RECEIVE_DATA RxData 
)

This function enqueues the received datagram into the instances' receiving queues.

Parameters
[in]Udp4ServicePointer to the udp service context data.
[in]PacketPointer to the buffer containing the received datagram.
[in]RxDataPointer to the EFI_UDP4_RECEIVE_DATA of this datagram.
Returns
The times this datagram is enqueued.

Definition at line 1433 of file Udp4Impl.c.

◆ Udp4FindInstanceByPort()

BOOLEAN Udp4FindInstanceByPort ( IN LIST_ENTRY InstanceList,
IN EFI_IPv4_ADDRESS Address,
IN UINT16  Port 
)

This function finds the udp instance by the specified <Address, Port> pair.

Parameters
[in]InstanceListPointer to the head of the list linking the udp instances.
[in]AddressPointer to the specified IPv4 address.
[in]PortThe udp port number.
Return values
TRUEThe specified <Address, Port> pair is found.
FALSEOtherwise.

Definition at line 508 of file Udp4Impl.c.

◆ Udp4FlushRcvdDgram()

VOID Udp4FlushRcvdDgram ( IN UDP4_INSTANCE_DATA Instance)

This function removes all the Wrap datas in the RcvdDgramQue.

Parameters
[in]InstancePointer to the udp instance context data.

Definition at line 1170 of file Udp4Impl.c.

◆ Udp4IcmpHandler()

VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA Udp4Service,
IN UINT8  IcmpError,
IN EFI_NET_SESSION_DATA NetSession,
IN NET_BUF Packet 
)

This function handles the received Icmp Error message and demultiplexes it to the instance.

Parameters
[in]Udp4ServicePointer to the udp service context data.
[in]IcmpErrorThe icmp error code.
[in]NetSessionPointer to the EFI_NET_SESSION_DATA abstracted from the received Icmp Error packet.
[in]PacketPointer to the Icmp Error packet.

Definition at line 1774 of file Udp4Impl.c.

◆ Udp4InitInstance()

VOID Udp4InitInstance ( IN UDP4_SERVICE_DATA Udp4Service,
IN OUT UDP4_INSTANCE_DATA Instance 
)

This function initializes the new created udp instance.

Parameters
[in]Udp4ServicePointer to the UDP4_SERVICE_DATA.
[in,out]InstancePointer to the un-initialized UDP4_INSTANCE_DATA.

Definition at line 444 of file Udp4Impl.c.

◆ Udp4InstanceCancelToken()

EFI_STATUS Udp4InstanceCancelToken ( IN UDP4_INSTANCE_DATA Instance,
IN EFI_UDP4_COMPLETION_TOKEN *Token  OPTIONAL 
)

Cancel Udp4 tokens from the Udp4 instance.

Parameters
[in]InstancePointer to the udp instance context data.
[in]TokenPointer to the token to be canceled, if NULL, all tokens in this instance will be cancelled.
Return values
EFI_SUCCESSThe Token is cancelled.
EFI_NOT_FOUNDThe Token is not found.

Definition at line 1201 of file Udp4Impl.c.

◆ Udp4InstanceDeliverDgram()

VOID Udp4InstanceDeliverDgram ( IN UDP4_INSTANCE_DATA Instance)

This function delivers the received datagrams for the specified instance.

Parameters
[in]InstancePointer to the instance context data.

Definition at line 1483 of file Udp4Impl.c.

◆ Udp4IsReconfigurable()

BOOLEAN Udp4IsReconfigurable ( IN EFI_UDP4_CONFIG_DATA OldConfigData,
IN EFI_UDP4_CONFIG_DATA NewConfigData 
)

This function is used to check whether the NewConfigData has any un-reconfigurable parameters changed compared to the OldConfigData.

Parameters
[in]OldConfigDataPointer to the current ConfigData the udp instance uses.
[in]NewConfigDataPointer to the new ConfigData.
Return values
TRUEThe instance is reconfigurable.
FALSEOtherwise.

Definition at line 641 of file Udp4Impl.c.

◆ Udp4LeaveGroup()

EFI_STATUS EFIAPI Udp4LeaveGroup ( IN OUT NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *Arg  OPTIONAL 
)

This function removes the multicast group specified by Arg from the Map.

Parameters
[in,out]MapPointer to the NET_MAP.
[in]ItemPointer to the NET_MAP_ITEM.
[in]ArgPointer to the Arg, it's the pointer to a multicast IPv4 Address.
Return values
EFI_SUCCESSThe multicast address is removed.
EFI_ABORTEDThe specified multicast address is removed and the Arg is not NULL.

Definition at line 1069 of file Udp4Impl.c.

◆ Udp4MatchDgram()

BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA Instance,
IN EFI_UDP4_SESSION_DATA Udp4Session 
)

This function matches the received udp datagram with the Instance.

Parameters
[in]InstancePointer to the udp instance context data.
[in]Udp4SessionPointer to the EFI_UDP4_SESSION_DATA abstracted from the received udp datagram.
Return values
TRUEThe udp datagram matches the receiving requirements of the udp Instance.
FALSEOtherwise.

Definition at line 1256 of file Udp4Impl.c.

◆ Udp4NetVectorExtFree()

VOID EFIAPI Udp4NetVectorExtFree ( VOID *  Context)

This function is a dummy ext-free function for the NET_BUF created for the output udp datagram.

Parameters
[in]ContextPointer to the context data.

Definition at line 1882 of file Udp4Impl.c.

◆ Udp4RecycleRxDataWrap()

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

This function removes the Wrap specified by Context and release relevant resources.

Parameters
[in]EventThe Event this notify function registered to.
[in]ContextPointer to the context data.

Definition at line 1335 of file Udp4Impl.c.

◆ Udp4RemoveToken()

EFI_STATUS Udp4RemoveToken ( IN OUT NET_MAP TokenMap,
IN EFI_UDP4_COMPLETION_TOKEN Token 
)

This function removes the specified Token from the TokenMap.

Parameters
[in,out]TokenMapPointer to the NET_MAP containing the tokens.
[in]TokenPointer to the Token to be removed.
Return values
EFI_SUCCESSThe specified Token is removed from the TokenMap.
EFI_NOT_FOUNDThe specified Token is not found in the TokenMap.

Definition at line 948 of file Udp4Impl.c.

◆ Udp4ReportIcmpError()

VOID Udp4ReportIcmpError ( IN UDP4_INSTANCE_DATA Instance)

This function reports the received ICMP error.

Parameters
[in]InstancePointer to the udp instance context data.

Definition at line 1839 of file Udp4Impl.c.

◆ Udp4SendPortUnreach()

VOID Udp4SendPortUnreach ( IN IP_IO IpIo,
IN EFI_NET_SESSION_DATA NetSession,
IN VOID *  Udp4Header 
)

This function builds and sends out a icmp port unreachable message.

Parameters
[in]IpIoPointer to the IP_IO instance.
[in]NetSessionPointer to the EFI_NET_SESSION_DATA of the packet causes this icmp error message.
[in]Udp4HeaderPointer to the udp header of the datagram causes this icmp error message.

Definition at line 1674 of file Udp4Impl.c.

◆ Udp4TokenExist()

EFI_STATUS EFIAPI Udp4TokenExist ( IN NET_MAP Map,
IN NET_MAP_ITEM Item,
IN VOID *  Context 
)

This function checks whether the specified Token duplicates with the one in the Map.

Parameters
[in]MapPointer to the NET_MAP.
[in]ItemPointer to the NET_MAP_ITEM contain the pointer to the Token.
[in]ContextPointer to the Token to be checked.
Return values
EFI_SUCCESSThe Token specified by Context differs from the one in the Item.
EFI_ACCESS_DENIEDThe Token duplicates with the one in the Item.

Definition at line 887 of file Udp4Impl.c.

◆ Udp4ValidateTxToken()

EFI_STATUS Udp4ValidateTxToken ( IN UDP4_INSTANCE_DATA Instance,
IN EFI_UDP4_COMPLETION_TOKEN TxToken 
)

This function validates the TxToken, it returns the error code according to the spec.

Parameters
[in]InstancePointer to the udp instance context data.
[in]TxTokenPointer to the token to be checked.
Return values
EFI_SUCCESSThe TxToken is valid.
EFI_INVALID_PARAMETEROne or more of the following are TRUE: This is NULL. Token is NULL. Token.Event is NULL. Token.Packet.TxData is NULL. Token.Packet.TxData.FragmentCount is zero. Token.Packet.TxData.DataLength is not equal to the sum of fragment lengths. One or more of the Token.Packet.TxData.FragmentTable[]. FragmentLength fields is zero. One or more of the Token.Packet.TxData.FragmentTable[]. FragmentBuffer fields is NULL. Token.Packet.TxData. GatewayAddress is not a unicast IPv4 address if it is not NULL. One or more IPv4 addresses in Token.Packet.TxData. UdpSessionData are not valid unicast IPv4 addresses if the UdpSessionData is not NULL.
EFI_BAD_BUFFER_SIZEThe data length is greater than the maximum UDP packet size.

Definition at line 767 of file Udp4Impl.c.

◆ Udp4WrapRxData()

UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA Instance,
IN NET_BUF Packet,
IN EFI_UDP4_RECEIVE_DATA RxData 
)

This function wraps the Packet and the RxData.

Parameters
[in]InstancePointer to the instance context data.
[in]PacketPointer to the buffer containing the received datagram.
[in]RxDataPointer to the EFI_UDP4_RECEIVE_DATA of this datagram.
Returns
Pointer to the structure wrapping the RxData and the Packet.

Definition at line 1375 of file Udp4Impl.c.

Variable Documentation

◆ mUdp4RandomPort

UINT16 mUdp4RandomPort

Definition at line 11 of file Udp4Impl.c.