From ce904bae52300732bc1b6e8506c7aeea4d2989bc Mon Sep 17 00:00:00 2001 From: jgong5 Date: Tue, 18 Nov 2008 13:37:36 +0000 Subject: [PATCH] synced function header git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6608 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Network/Udp4Dxe/Udp4Driver.h | 84 ++++ .../Universal/Network/Udp4Dxe/Udp4Impl.c | 156 ++++++ .../Universal/Network/Udp4Dxe/Udp4Impl.h | 466 +++++++++++++++++- 3 files changed, 692 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h index 2e0b7f33c8..371216574a 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h @@ -27,6 +27,24 @@ Abstract: #include #include +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to test + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver supports this device + @retval EFI_ALREADY_STARTED This driver is already running on this device + @retval other This driver does not support this device + +**/ EFI_STATUS EFIAPI Udp4DriverBindingSupported ( @@ -35,6 +53,24 @@ Udp4DriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ); +/** + Start this driver on ControllerHandle. This service is called by the + EFI boot service ConnectController(). In order to make + drivers as small as possible, there are a few calling restrictions for + this service. ConnectController() must follow these + calling restrictions. If any other agent wishes to call Start() it + must also follow these calling restrictions. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to bind driver to + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver is added to ControllerHandle + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle + @retval other This driver does not support this device + +**/ EFI_STATUS EFIAPI Udp4DriverBindingStart ( @@ -43,6 +79,24 @@ Udp4DriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ); +/** + Stop this driver on ControllerHandle. This service is called by the + EFI boot service DisconnectController(). In order to + make drivers as small as possible, there are a few calling + restrictions for this service. DisconnectController() + must follow these calling restrictions. If any other agent wishes + to call Stop() it must also follow these calling restrictions. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to stop driver on + @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + @param ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval other This driver was not removed from this device + +**/ EFI_STATUS EFIAPI Udp4DriverBindingStop ( @@ -52,6 +106,21 @@ Udp4DriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer ); +/** + Creates a child handle with a set of I/O services. + + @param This Protocol instance pointer. + @param ChildHandle Pointer to the handle of the child to create. If it is NULL, + then a new handle is created. If it is not NULL, then the + I/O services are added to the existing child handle. + + @retval EFI_SUCCES The child handle was created with the I/O services + @retval EFI_INVALID_PARAMETER ChildHandle is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create + the child + @retval other The child handle was not created + +**/ EFI_STATUS EFIAPI Udp4ServiceBindingCreateChild ( @@ -59,6 +128,21 @@ Udp4ServiceBindingCreateChild ( IN EFI_HANDLE *ChildHandle ); +/** + Destroys a child handle with a set of I/O services. + + @param This Protocol instance pointer. + @param ChildHandle Handle of the child to destroy + + @retval EFI_SUCCES The I/O services were removed from the child handle + @retval EFI_UNSUPPORTED The child handle does not support the I/O services + that are being removed. + @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle. + @retval EFI_ACCESS_DENIED The child handle could not be destroyed because its + I/O services are being used. + @retval other The child handle was not destroyed + +**/ EFI_STATUS EFIAPI Udp4ServiceBindingDestroyChild ( diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c index d9372ba1b8..18ba7f4103 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c @@ -25,6 +25,17 @@ Abstract: UINT16 mUdp4RandomPort; +/** + This function checks and timeouts the I/O datagrams holding by the corresponding + service context. + + @param Event The event this function registered to. + @param Context The context data registered during the creation of + the Event. + + @return None. + +**/ VOID EFIAPI Udp4CheckTimeout ( @@ -32,6 +43,18 @@ Udp4CheckTimeout ( IN VOID *Context ); +/** + This function finds the udp instance by the specified pair. + + @param InstanceList Pointer to the head of the list linking the udp + instances. + @param Address Pointer to the specified IPv4 address. + @param Port The udp port number. + + @retval TRUE The specified pair is found. + @retval FALSE Otherwise. + +**/ BOOLEAN Udp4FindInstanceByPort ( IN LIST_ENTRY *InstanceList, @@ -39,6 +62,19 @@ Udp4FindInstanceByPort ( IN UINT16 Port ); +/** + 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. + + @param Status The completion status of the output udp datagram. + @param Context Pointer to the context data. + @param Sender Pointer to the Ip sender of the udp datagram. + @param NotifyData Pointer to the notify data. + + @return None. + +**/ VOID Udp4DgramSent ( IN EFI_STATUS Status, @@ -47,6 +83,20 @@ Udp4DgramSent ( IN VOID *NotifyData ); +/** + This function processes the received datagram passed up by the IpIo layer. + + @param Status The status of this udp datagram. + @param IcmpError The IcmpError code, only available when Status is + EFI_ICMP_ERROR. + @param NetSession Pointer to the EFI_NET_SESSION_DATA. + @param Packet Pointer to the NET_BUF containing the received udp + datagram. + @param Context Pointer to the context data. + + @return None. + +**/ VOID Udp4DgramRcvd ( IN EFI_STATUS Status, @@ -56,6 +106,22 @@ Udp4DgramRcvd ( IN VOID *Context ); +/** + This function cancels the token specified by Arg in the Map. This is a callback + used by Udp4InstanceCancelToken(). + + @param Map Pointer to the NET_MAP. + @param Item Pointer to the NET_MAP_ITEM. + @param Arg Pointer to the token to be cancelled, if NULL, + the token specified by Item is cancelled. + + @retval EFI_SUCCESS The token is cancelled if Arg is NULL or the token + is not the same as that in the Item if Arg is not + NULL. + @retval EFI_ABORTED Arg is not NULL, and the token specified by Arg is + cancelled. + +**/ EFI_STATUS Udp4CancelTokens ( IN NET_MAP *Map, @@ -63,12 +129,33 @@ Udp4CancelTokens ( IN VOID *Arg OPTIONAL ); +/** + This function matches the received udp datagram with the Instance. + + @param Instance Pointer to the udp instance context data. + @param Udp4Session Pointer to the EFI_UDP4_SESSION_DATA abstracted + from the received udp datagram. + + @retval TRUE The udp datagram matches the receiving requirments of the + udp Instance. + @retval FALSE Otherwise. + +**/ BOOLEAN Udp4MatchDgram ( IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_SESSION_DATA *Udp4Session ); +/** + This function removes the Wrap specified by Context and release relevant resources. + + @param Event The Event this notify function registered to. + @param Context Pointer to the context data. + + @return None. + +**/ VOID EFIAPI Udp4RecycleRxDataWrap ( @@ -76,6 +163,18 @@ Udp4RecycleRxDataWrap ( IN VOID *Context ); +/** + This function wraps the Packet and the RxData. + + @param Instance Pointer to the instance context data. + @param Packet Pointer to the buffer containing the received + datagram. + @param RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. + + @return Pointer to the structure wrapping the RxData and the Packet. + +**/ UDP4_RXDATA_WRAP * Udp4WrapRxData ( IN UDP4_INSTANCE_DATA *Instance, @@ -83,6 +182,18 @@ Udp4WrapRxData ( IN EFI_UDP4_RECEIVE_DATA *RxData ); +/** + This function enqueues the received datagram into the instances' receiving queues. + + @param Udp4Service Pointer to the udp service context data. + @param Packet Pointer to the buffer containing the received + datagram. + @param RxData Pointer to the EFI_UDP4_RECEIVE_DATA of this + datagram. + + @return The times this datagram is enqueued. + +**/ UINTN Udp4EnqueueDgram ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -90,11 +201,31 @@ Udp4EnqueueDgram ( IN EFI_UDP4_RECEIVE_DATA *RxData ); +/** + This function delivers the datagrams enqueued in the instances. + + @param Udp4Service Pointer to the udp service context data. + + @return None. + +**/ VOID Udp4DeliverDgram ( IN UDP4_SERVICE_DATA *Udp4Service ); +/** + This function demultiplexes the received udp datagram to the apropriate instances. + + @param Udp4Service Pointer to the udp service context data. + @param NetSession Pointer to the EFI_NET_SESSION_DATA abstrated from + the received datagram. + @param Packet Pointer to the buffer containing the received udp + datagram. + + @return None. + +**/ VOID Udp4Demultiplex ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -102,6 +233,19 @@ Udp4Demultiplex ( IN NET_BUF *Packet ); +/** + This function handles the received Icmp Error message and demultiplexes it to the + instance. + + @param Udp4Service Pointer to the udp service context data. + @param IcmpError The icmp error code. + @param NetSession Pointer to the EFI_NET_SESSION_DATA abstracted + from the received Icmp Error packet. + @param Packet Pointer to the Icmp Error packet. + + @return None. + +**/ VOID Udp4IcmpHandler ( IN UDP4_SERVICE_DATA *Udp4Service, @@ -110,6 +254,18 @@ Udp4IcmpHandler ( IN NET_BUF *Packet ); +/** + This function builds and sends out a icmp port unreachable message. + + @param IpIo Pointer to the IP_IO instance. + @param NetSession Pointer to the EFI_NET_SESSION_DATA of the packet + causes this icmp error message. + @param Udp4Header Pointer to the udp header of the datagram causes + this icmp error message. + + @return None. + +**/ VOID Udp4SendPortUnreach ( IN IP_IO *IpIo, diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h index 17f39410ae..ae68747159 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h @@ -125,6 +125,26 @@ typedef struct _UDP4_RXDATA_WRAP_ { EFI_UDP4_RECEIVE_DATA RxData; } UDP4_RXDATA_WRAP; +/** + Reads the current operational settings. + + The GetModeData() function copies the current operational settings of this EFI + UDPv4 Protocol instance into user-supplied buffers. This function is used + optionally to retrieve the operational mode data of underlying networks or + drivers. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param Udp4ConfigData Pointer to the buffer to receive the current configuration data. + @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure. + @param MnpConfigData Pointer to the managed network configuration data structure. + @param SnpModeData Pointer to the simple network mode data structure. + + @retval EFI_SUCCESS The mode data was read. + @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is + available because this instance has not been started. + @retval EFI_INVALID_PARAMETER This is NULL. + +**/ EFI_STATUS EFIAPI Udp4GetModeData ( @@ -135,6 +155,39 @@ Udp4GetModeData ( OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL ); +/** + Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4 + Protocol. + + The Configure() function is used to do the following: + * Initialize and start this instance of the EFI UDPv4 Protocol. + * Change the filtering rules and operational parameters. + * Reset this instance of the EFI UDPv4 Protocol. + Until these parameters are initialized, no network traffic can be sent or + received by this instance. This instance can be also reset by calling Configure() + with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting + queue are flushed and no traffic is allowed through this instance. + With different parameters in UdpConfigData, Configure() can be used to bind + this instance to specified port. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param UdpConfigData Pointer to the buffer to receive the current configuration data. + + @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: + @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured + and must be stopped/reset before it can be reconfigured. + @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE + and UdpConfigData.StationPort is already used by + other instance. + @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this + EFI UDPv4 Protocol instance. + @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance + was not opened. + +**/ EFI_STATUS EFIAPI Udp4Configure ( @@ -142,6 +195,35 @@ Udp4Configure ( IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL ); +/** + Joins and leaves multicast groups. + + The Groups() function is used to enable and disable the multicast group + filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all + currently joined groups are left. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one + or all multicast groups. + @param MulticastAddress Pointer to multicast group address to join or leave. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + - This is NULL. + - JoinFlag is TRUE and MulticastAddress is NULL. + - JoinFlag is TRUE and *MulticastAddress is not + a valid multicast address. + @retval EFI_ALREADY_STARTED The group address is already in the group table (when + JoinFlag is TRUE). + @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is + FALSE). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + +**/ EFI_STATUS EFIAPI Udp4Groups ( @@ -150,6 +232,44 @@ Udp4Groups ( IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL ); +/** + Adds and deletes routing table entries. + + The Routes() function adds a route to or deletes a route from the routing table. + Routes are determined by comparing the SubnetAddress with the destination IP + address and arithmetically AND-ing it with the SubnetMask. The gateway address + must be on the same subnet as the configured station address. + The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0. + The default route matches all destination IP addresses that do not match any + other routes. + A zero GatewayAddress is a nonroute. Packets are sent to the destination IP + address if it can be found in the Address Resolution Protocol (ARP) cache or + on the local subnet. One automatic nonroute entry will be inserted into the + routing table for outgoing packets that are addressed to a local subnet + (gateway address of 0.0.0.0). + Each instance of the EFI UDPv4 Protocol has its own independent routing table. + Instances of the EFI UDPv4 Protocol that use the default IP address will also + have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These + copies will be updated automatically whenever the IP driver reconfigures its + instances; as a result, the previous modification to these copies will be lost. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param DeleteRoute Set to TRUE to delete this route from the routing table. + Set to FALSE to add this route to the routing table. + @param SubnetAddress The destination network address that needs to be routed. + @param SubnetMask The subnet mask of SubnetAddress. + @param GatewayAddress The gateway IP address for this route. + + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + - RARP, etc.) is not finished yet. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table. + @retval EFI_NOT_FOUND This route is not in the routing table. + @retval EFI_ACCESS_DENIED The route is already defined in the routing table. + +**/ EFI_STATUS EFIAPI Udp4Routes ( @@ -160,6 +280,36 @@ Udp4Routes ( IN EFI_IPv4_ADDRESS *GatewayAddress ); +/** + Queues outgoing data packets into the transmit queue. + + The Transmit() function places a sending request to this instance of the EFI + UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever + the packet in the token is sent out or some errors occur, the Token.Event will + be signaled and Token.Status is updated. Providing a proper notification function + and context for the event will enable the user to receive the notification and + transmitting status. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param Token Pointer to the completion token that will be placed into the + transmit queue. + + @retval EFI_SUCCESS The data has been queued for transmission. + @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_ACCESS_DENIED The transmit completion token with the same + Token.Event was already in the transmit queue. + @retval EFI_NOT_READY The completion token could not be queued because the + transmit queue is full. + @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data. + @retval EFI_NOT_FOUND There is no route to the destination network or address. + @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet + size. Or the length of the IP header + UDP header + data + length is greater than MTU if DoNotFragment is TRUE. + +**/ EFI_STATUS EFIAPI Udp4Transmit ( @@ -167,6 +317,35 @@ Udp4Transmit ( IN EFI_UDP4_COMPLETION_TOKEN *Token ); +/** + Places an asynchronous receive request into the receiving queue. + + The Receive() function places a completion token into the receive packet queue. + This function is always asynchronous. + The caller must fill in the Token.Event field in the completion token, and this + field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol + driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event + is signaled. Providing a proper notification function and context for the event + will enable the user to receive the notification and receiving status. That + notification function is guaranteed to not be re-entered. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param Token Pointer to a token that is associated with the receive data + descriptor. + + @retval EFI_SUCCESS The receive completion token was cached. + @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.) + is not finished yet. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system + resources (usually memory). + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in + the receive queue. + @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full. + +**/ EFI_STATUS EFIAPI Udp4Receive ( @@ -174,6 +353,34 @@ Udp4Receive ( IN EFI_UDP4_COMPLETION_TOKEN *Token ); +/** + Aborts an asynchronous transmit or receive request. + + The Cancel() function is used to abort a pending transmit or receive request. + If the token is in the transmit or receive request queues, after calling this + function, Token.Status will be set to EFI_ABORTED and then Token.Event will be + signaled. If the token is not in one of the queues, which usually means that + the asynchronous operation has completed, this function will not signal the + token and EFI_NOT_FOUND is returned. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + @param Token Pointer to a token that has been issued by + EFI_UDP4_PROTOCOL.Transmit() or + EFI_UDP4_PROTOCOL.Receive().If NULL, all pending + tokens are aborted. + + @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event + was signaled. When Token is NULL, all pending requests are + aborted and their events are signaled. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance has not been started. + @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was + not found in the transmit or receive queue. It has either completed + or was not issued by Transmit() and Receive(). + +**/ EFI_STATUS EFIAPI Udp4Cancel ( @@ -181,59 +388,193 @@ Udp4Cancel ( IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL ); +/** + Polls for incoming data packets and processes outgoing data packets. + + The Poll() function can be used by network drivers and applications to increase + the rate that data packets are moved between the communications device and the + transmit and receive queues. + In some systems, the periodic timer event in the managed network driver may not + poll the underlying communications device fast enough to transmit and/or receive + all data packets without missing incoming packets or dropping outgoing packets. + Drivers and applications that are experiencing packet loss should try calling + the Poll() function more often. + + @param This Pointer to the EFI_UDP4_PROTOCOL instance. + + @retval EFI_SUCCESS Incoming or outgoing data was processed. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. + +**/ EFI_STATUS EFIAPI Udp4Poll ( IN EFI_UDP4_PROTOCOL *This ); +/** + Create the Udp service context data. + + @param Udp4Service Pointer to the UDP4_SERVICE_DATA. + @param ImageHandle The image handle of this udp4 driver. + @param ControllerHandle The controller handle this udp4 driver binds on. + + @retval EFI_SUCCESS The udp4 service context data is created and + initialized. + @retval EFI_OUT_OF_RESOURCES Cannot allocate memory. + @retval other Other error occurs. + +**/ EFI_STATUS Udp4CreateService ( - IN UDP4_SERVICE_DATA *Udp4Service, - IN EFI_HANDLE ImageHandle, - IN EFI_HANDLE ControllerHandle + IN OUT UDP4_SERVICE_DATA *Udp4Service, + IN EFI_HANDLE ImageHandle, + IN EFI_HANDLE ControllerHandle ); +/** + Clean the Udp service context data. + + @param Udp4Service Pointer to the UDP4_SERVICE_DATA. + + @return None. + +**/ VOID Udp4CleanService ( IN UDP4_SERVICE_DATA *Udp4Service ); +/** + This function intializes the new created udp instance. + + @param Udp4Service Pointer to the UDP4_SERVICE_DATA. + @param Instance Pointer to the un-initialized UDP4_INSTANCE_DATA. + + @return None. + +**/ VOID Udp4InitInstance ( - IN UDP4_SERVICE_DATA *Udp4Service, - IN UDP4_INSTANCE_DATA *Instance + IN UDP4_SERVICE_DATA *Udp4Service, + IN OUT UDP4_INSTANCE_DATA *Instance ); +/** + This function cleans the udp instance. + + @param Instance Pointer to the UDP4_INSTANCE_DATA to clean. + + @return None. + +**/ VOID Udp4CleanInstance ( IN UDP4_INSTANCE_DATA *Instance ); +/** + This function tries to bind the udp instance according to the configured port + allocation strategy. + + @param InstanceList Pointer to the head of the list linking the udp + instances. + @param ConfigData Pointer to the ConfigData of the instance to be + bound. ConfigData->StationPort will be assigned + with an available port value on success. + + @retval EFI_SUCCESS The bound operation is completed successfully. + @retval EFI_ACCESS_DENIED The specified by the ConfigData is + already used by other instance. + @retval EFI_OUT_OF_RESOURCES No available port resources. + +**/ EFI_STATUS Udp4Bind ( - IN LIST_ENTRY *InstanceList, - IN EFI_UDP4_CONFIG_DATA *ConfigData + IN LIST_ENTRY *InstanceList, + IN OUT EFI_UDP4_CONFIG_DATA *ConfigData ); +/** + This function is used to check whether the NewConfigData has any un-reconfigurable + parameters changed compared to the OldConfigData. + + @param OldConfigData Pointer to the current ConfigData the udp instance + uses. + @param NewConfigData Pointer to the new ConfigData. + + @retval TRUE The instance is reconfigurable. + @retval FALSE Otherwise. + +**/ BOOLEAN Udp4IsReconfigurable ( IN EFI_UDP4_CONFIG_DATA *OldConfigData, IN EFI_UDP4_CONFIG_DATA *NewConfigData ); +/** + This function builds the Ip4 configdata from the Udp4ConfigData. + + @param Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA. + @param Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA. + + @return None. + +**/ VOID Udp4BuildIp4ConfigData ( - IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, - IN EFI_IP4_CONFIG_DATA *Ip4ConfigData + IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, + IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData ); +/** + This function validates the TxToken, it returns the error code according to the spec. + + @param Instance Pointer to the udp instance context data. + @param TxToken Pointer to the token to be checked. + + @retval EFI_SUCCESS The TxToken is valid. + @retval EFI_INVALID_PARAMETER One 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. + @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP + packet size. + +**/ EFI_STATUS Udp4ValidateTxToken ( IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *TxToken ); +/** + This function checks whether the specified Token duplicates with the one in the Map. + + @param Map Pointer to the NET_MAP. + @param Item Pointer to the NET_MAP_ITEM contain the pointer to + the Token. + @param Context Pointer to the Token to be checked. + + @retval EFI_SUCCESS The Token specified by Context differs from the + one in the Item. + @retval EFI_ACCESS_DENIED The Token duplicates with the one in the Item. + +**/ EFI_STATUS Udp4TokenExist ( IN NET_MAP *Map, @@ -241,56 +582,153 @@ Udp4TokenExist ( IN VOID *Context ); +/** + This function calculates the checksum for the Packet, utilizing the pre-calculated + pseudo HeadSum to reduce some overhead. + + @param Packet Pointer to the NET_BUF contains the udp datagram. + @param HeadSum Checksum of the pseudo header execpt the length + field. + + @return The 16-bit checksum of this udp datagram. + +**/ UINT16 Udp4Checksum ( IN NET_BUF *Packet, IN UINT16 HeadSum ); +/** + This function removes the specified Token from the TokenMap. + + @param TokenMap Pointer to the NET_MAP containing the tokens. + @param Token Pointer to the Token to be removed. + + @retval EFI_SUCCESS The specified Token is removed from the TokenMap. + @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap. + +**/ EFI_STATUS Udp4RemoveToken ( - IN NET_MAP *TokenMap, - IN EFI_UDP4_COMPLETION_TOKEN *Token + IN OUT NET_MAP *TokenMap, + IN EFI_UDP4_COMPLETION_TOKEN *Token ); +/** + This function removes the multicast group specified by Arg from the Map. + + @param Map Pointer to the NET_MAP. + @param Item Pointer to the NET_MAP_ITEM. + @param Arg Pointer to the Arg, it's the pointer to a + multicast IPv4 Address. + + @retval EFI_SUCCESS The multicast address is removed. + @retval EFI_ABORTED The specified multicast address is removed and the + Arg is not NULL. + +**/ EFI_STATUS Udp4LeaveGroup ( - IN NET_MAP *Map, - IN NET_MAP_ITEM *Item, - IN VOID *Arg OPTIONAL + IN OUT NET_MAP *Map, + IN NET_MAP_ITEM *Item, + IN VOID *Arg OPTIONAL ); +/** + This function removes all the Wrap datas in the RcvdDgramQue. + + @param Instance Pointer to the udp instance context data. + + @return None. + +**/ VOID Udp4FlushRcvdDgram ( IN UDP4_INSTANCE_DATA *Instance ); +/** + Cancel Udp4 tokens from the Udp4 instance. + + @param Instance Pointer to the udp instance context data. + @param Token Pointer to the token to be canceled, if NULL, all + tokens in this instance will be cancelled. + + @retval EFI_SUCCESS The Token is cancelled. + @retval EFI_NOT_FOUND The Token is not found. + +**/ EFI_STATUS Udp4InstanceCancelToken ( IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL ); +/** + This function delivers the received datagrams for the specified instance. + + @param Instance Pointer to the instance context data. + + @return None. + +**/ VOID Udp4InstanceDeliverDgram ( IN UDP4_INSTANCE_DATA *Instance ); +/** + This function reports the received ICMP error. + + @param Instance Pointer to the udp instance context data. + + @return None. + +**/ VOID Udp4ReportIcmpError ( IN UDP4_INSTANCE_DATA *Instance ); +/** + This function is a dummy ext-free function for the NET_BUF created for the output + udp datagram. + + @param Context Pointer to the context data. + + @return None. + +**/ VOID Udp4NetVectorExtFree ( VOID *Context ); +/** + Set the Udp4 variable data. + + @param Udp4Service Udp4 service data. + + @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the + variable. + @retval EFI_SUCCESS Set variable successfully. + @retval other Set variable failed. + +**/ EFI_STATUS Udp4SetVariableData ( IN UDP4_SERVICE_DATA *Udp4Service ); +/** + Clear the variable and free the resource. + + @param Udp4Service Udp4 service data. + + @return None. + +**/ VOID Udp4ClearVariableData ( IN UDP4_SERVICE_DATA *Udp4Service