From 83cbd279b64f3081af5c06d50fa26e15a99fc066 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Sun, 30 Sep 2007 03:08:02 +0000 Subject: Update to support to produce Component Name and & Component Name 2 protocol based on Feature flag PcdComponentNameDisable & PcdComponentName2Disable. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4006 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Network/Udp4Dxe/ComponentName.c | 331 ++++++++---- .../Universal/Network/Udp4Dxe/Udp4Driver.c | 5 +- .../Universal/Network/Udp4Dxe/Udp4Driver.h | 140 ++--- MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h | 579 +++++++++++---------- 4 files changed, 603 insertions(+), 452 deletions(-) (limited to 'MdeModulePkg/Universal/Network/Udp4Dxe') diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c b/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c index b934765207..7fb1ce9bd7 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/ComponentName.c @@ -24,6 +24,45 @@ Abstract: // // EFI Component Name Functions // +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UdpComponentNameGetDriverName ( @@ -32,28 +71,108 @@ UdpComponentNameGetDriverName ( OUT CHAR16 **DriverName ); + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UdpComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ); + // // EFI Component Name Protocol // -EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName = { +EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName = { UdpComponentNameGetDriverName, UdpComponentNameGetControllerName, "eng" -}; + }; + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2 = { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UdpComponentNameGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UdpComponentNameGetControllerName, + "en" + }; + static EFI_UNICODE_STRING_TABLE mUdpDriverNameTable[] = { { - "eng", + "eng;en", L"UDP Network Service Driver" }, { @@ -62,6 +181,45 @@ static EFI_UNICODE_STRING_TABLE mUdpDriverNameTable[] = { } }; +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UdpComponentNameGetDriverName ( @@ -69,100 +227,93 @@ UdpComponentNameGetDriverName ( IN CHAR8 *Language, OUT CHAR16 **DriverName ) -/*++ +{ + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mUdpDriverNameTable, + DriverName, + (BOOLEAN)(This == &gUdp4ComponentName) + ); +} -Routine Description: +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. - Retrieves a Unicode string that is the user readable name of the EFI Driver. + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. -Arguments: + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - Language - A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - DriverName - A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. -Returns: + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. - EFI_SUCCES - The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - DriverName is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. ---*/ -{ - return LookupUnicodeString ( - Language, - gUdp4ComponentName.SupportedLanguages, - mUdpDriverNameTable, - DriverName - ); -} + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UdpComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ) -/*++ - -Routine Description: - - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - -Arguments: - - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - ControllerHandle - The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - ChildHandle - The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - Language - A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - ControllerName - A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language from the point of view of the driver specified - by This. - -Returns: - - EFI_SUCCESS - The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - ControllerName is NULL. - EFI_UNSUPPORTED - The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { return EFI_UNSUPPORTED; } diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c index dc6fd48ebf..7e2bc451ae 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c @@ -504,14 +504,13 @@ Returns: // // Install the Udp4DriverBinding and Udp4ComponentName protocols. // - Status = EfiLibInstallAllDriverProtocols ( + Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gUdp4DriverBinding, ImageHandle, &gUdp4ComponentName, - NULL, - NULL + &gUdp4ComponentName2 ); if (!EFI_ERROR (Status)) { // diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h index 59acb44452..2e0b7f33c8 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.h @@ -1,70 +1,70 @@ -/** @file - -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Udp4Driver.h - -Abstract: - - -**/ - -#ifndef _UDP4_DRIVER_H_ -#define _UDP4_DRIVER_H_ - -#include -#include -#include -#include -#include - -EFI_STATUS -EFIAPI -Udp4DriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4DriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4DriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -EFI_STATUS -EFIAPI -Udp4ServiceBindingCreateChild ( - IN EFI_SERVICE_BINDING_PROTOCOL *This, - IN EFI_HANDLE *ChildHandle - ); - -EFI_STATUS -EFIAPI -Udp4ServiceBindingDestroyChild ( - IN EFI_SERVICE_BINDING_PROTOCOL *This, - IN EFI_HANDLE ChildHandle - ); - -#endif - +/** @file + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Udp4Driver.h + +Abstract: + + +**/ + +#ifndef _UDP4_DRIVER_H_ +#define _UDP4_DRIVER_H_ + +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +Udp4DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ); + +EFI_STATUS +EFIAPI +Udp4ServiceBindingCreateChild ( + IN EFI_SERVICE_BINDING_PROTOCOL *This, + IN EFI_HANDLE *ChildHandle + ); + +EFI_STATUS +EFIAPI +Udp4ServiceBindingDestroyChild ( + IN EFI_SERVICE_BINDING_PROTOCOL *This, + IN EFI_HANDLE ChildHandle + ); + +#endif + diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h index 7825624090..bdc855b52c 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h @@ -1,299 +1,300 @@ -/** @file - -Copyright (c) 2006 - 2007, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Udp4Impl.h - -Abstract: - - EFI UDPv4 protocol implementation - - -**/ - -#ifndef _UDP4_IMPL_H_ -#define _UDP4_IMPL_H_ - +/** @file + +Copyright (c) 2006 - 2007, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Udp4Impl.h + +Abstract: + + EFI UDPv4 protocol implementation + + +**/ + +#ifndef _UDP4_IMPL_H_ +#define _UDP4_IMPL_H_ + #include #include #include - + #include #include #include #include #include #include -#include -#include -#include - -#include "Udp4Driver.h" - - -extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName; -extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding; -extern EFI_UDP4_PROTOCOL mUdp4Protocol; -extern UINT16 mUdp4RandomPort; - -#define ICMP_ERROR_PACKET_LENGTH 8 - -#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds - -#define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER) -#define UDP4_MAX_DATA_SIZE 65507 - -#define UDP4_PORT_KNOWN 1024 - -#define UDP4_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', '4') - -#define UDP4_SERVICE_DATA_FROM_THIS(a) \ - CR ( \ - (a), \ - UDP4_SERVICE_DATA, \ - ServiceBinding, \ - UDP4_SERVICE_DATA_SIGNATURE \ - ) - -typedef struct _UDP4_SERVICE_DATA_ { - UINT32 Signature; - EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; - EFI_HANDLE ImageHandle; - EFI_HANDLE ControllerHandle; - NET_LIST_ENTRY ChildrenList; - UINTN ChildrenNumber; - IP_IO *IpIo; - - EFI_EVENT TimeoutEvent; - - CHAR16 *MacString; -} UDP4_SERVICE_DATA; - -#define UDP4_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', 'I') - -#define UDP4_INSTANCE_DATA_FROM_THIS(a) \ - CR ( \ - (a), \ - UDP4_INSTANCE_DATA, \ - Udp4Proto, \ - UDP4_INSTANCE_DATA_SIGNATURE \ - ) - -typedef struct _UDP4_INSTANCE_DATA_ { - UINT32 Signature; - NET_LIST_ENTRY Link; - - UDP4_SERVICE_DATA *Udp4Service; - EFI_UDP4_PROTOCOL Udp4Proto; - EFI_UDP4_CONFIG_DATA ConfigData; - EFI_HANDLE ChildHandle; - BOOLEAN Configured; - BOOLEAN IsNoMapping; - - NET_MAP TxTokens; - NET_MAP RxTokens; - - NET_MAP McastIps; - - NET_LIST_ENTRY RcvdDgramQue; - NET_LIST_ENTRY DeliveredDgramQue; - - UINT16 HeadSum; - - EFI_STATUS IcmpError; - - IP_IO_IP_INFO *IpInfo; - - BOOLEAN Destroyed; -} UDP4_INSTANCE_DATA; - -typedef struct _UDP4_RXDATA_WRAP_ { - NET_LIST_ENTRY Link; - NET_BUF *Packet; - UINT32 TimeoutTick; - EFI_UDP4_RECEIVE_DATA RxData; -} UDP4_RXDATA_WRAP; - -EFI_STATUS -EFIAPI -Udp4GetModeData ( - IN EFI_UDP4_PROTOCOL *This, - OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL, - OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, - OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, - OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4Configure ( - IN EFI_UDP4_PROTOCOL *This, - IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4Groups ( - IN EFI_UDP4_PROTOCOL *This, - IN BOOLEAN JoinFlag, - IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4Routes ( - IN EFI_UDP4_PROTOCOL *This, - IN BOOLEAN DeleteRoute, - IN EFI_IPv4_ADDRESS *SubnetAddress, - IN EFI_IPv4_ADDRESS *SubnetMask, - IN EFI_IPv4_ADDRESS *GatewayAddress - ); - -EFI_STATUS -EFIAPI -Udp4Transmit ( - IN EFI_UDP4_PROTOCOL *This, - IN EFI_UDP4_COMPLETION_TOKEN *Token - ); - -EFI_STATUS -EFIAPI -Udp4Receive ( - IN EFI_UDP4_PROTOCOL *This, - IN EFI_UDP4_COMPLETION_TOKEN *Token - ); - -EFI_STATUS -EFIAPI -Udp4Cancel ( - IN EFI_UDP4_PROTOCOL *This, - IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL - ); - -EFI_STATUS -EFIAPI -Udp4Poll ( - IN EFI_UDP4_PROTOCOL *This - ); - -EFI_STATUS -Udp4CreateService ( - IN 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 UDP4_INSTANCE_DATA *Instance - ); - -VOID -Udp4CleanInstance ( - IN UDP4_INSTANCE_DATA *Instance - ); - -EFI_STATUS -Udp4Bind ( - IN NET_LIST_ENTRY *InstanceList, - IN 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 EFI_IP4_CONFIG_DATA *Ip4ConfigData - ); - -EFI_STATUS -Udp4ValidateTxToken ( - IN UDP4_INSTANCE_DATA *Instance, - IN EFI_UDP4_COMPLETION_TOKEN *TxToken - ); - -EFI_STATUS -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 NET_MAP *TokenMap, - IN EFI_UDP4_COMPLETION_TOKEN *Token - ); - -EFI_STATUS -Udp4LeaveGroup ( - IN NET_MAP *Map, - IN NET_MAP_ITEM *Item, - IN VOID *Arg OPTIONAL - ); - -VOID -Udp4FlushRxData ( - IN NET_LIST_ENTRY *RcvdDgramQue - ); - -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 -Udp4NetVectorExtFree ( - VOID *Context - ); - -EFI_STATUS -Udp4SetVariableData ( - IN UDP4_SERVICE_DATA *Udp4Service - ); - -VOID -Udp4ClearVariableData ( - IN UDP4_SERVICE_DATA *Udp4Service - ); - -#endif - +#include +#include +#include + +#include "Udp4Driver.h" + + +extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2; +extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding; +extern EFI_UDP4_PROTOCOL mUdp4Protocol; +extern UINT16 mUdp4RandomPort; + +#define ICMP_ERROR_PACKET_LENGTH 8 + +#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds + +#define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER) +#define UDP4_MAX_DATA_SIZE 65507 + +#define UDP4_PORT_KNOWN 1024 + +#define UDP4_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', '4') + +#define UDP4_SERVICE_DATA_FROM_THIS(a) \ + CR ( \ + (a), \ + UDP4_SERVICE_DATA, \ + ServiceBinding, \ + UDP4_SERVICE_DATA_SIGNATURE \ + ) + +typedef struct _UDP4_SERVICE_DATA_ { + UINT32 Signature; + EFI_SERVICE_BINDING_PROTOCOL ServiceBinding; + EFI_HANDLE ImageHandle; + EFI_HANDLE ControllerHandle; + NET_LIST_ENTRY ChildrenList; + UINTN ChildrenNumber; + IP_IO *IpIo; + + EFI_EVENT TimeoutEvent; + + CHAR16 *MacString; +} UDP4_SERVICE_DATA; + +#define UDP4_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', 'I') + +#define UDP4_INSTANCE_DATA_FROM_THIS(a) \ + CR ( \ + (a), \ + UDP4_INSTANCE_DATA, \ + Udp4Proto, \ + UDP4_INSTANCE_DATA_SIGNATURE \ + ) + +typedef struct _UDP4_INSTANCE_DATA_ { + UINT32 Signature; + NET_LIST_ENTRY Link; + + UDP4_SERVICE_DATA *Udp4Service; + EFI_UDP4_PROTOCOL Udp4Proto; + EFI_UDP4_CONFIG_DATA ConfigData; + EFI_HANDLE ChildHandle; + BOOLEAN Configured; + BOOLEAN IsNoMapping; + + NET_MAP TxTokens; + NET_MAP RxTokens; + + NET_MAP McastIps; + + NET_LIST_ENTRY RcvdDgramQue; + NET_LIST_ENTRY DeliveredDgramQue; + + UINT16 HeadSum; + + EFI_STATUS IcmpError; + + IP_IO_IP_INFO *IpInfo; + + BOOLEAN Destroyed; +} UDP4_INSTANCE_DATA; + +typedef struct _UDP4_RXDATA_WRAP_ { + NET_LIST_ENTRY Link; + NET_BUF *Packet; + UINT32 TimeoutTick; + EFI_UDP4_RECEIVE_DATA RxData; +} UDP4_RXDATA_WRAP; + +EFI_STATUS +EFIAPI +Udp4GetModeData ( + IN EFI_UDP4_PROTOCOL *This, + OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4Configure ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4Groups ( + IN EFI_UDP4_PROTOCOL *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4Routes ( + IN EFI_UDP4_PROTOCOL *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +EFI_STATUS +EFIAPI +Udp4Transmit ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token + ); + +EFI_STATUS +EFIAPI +Udp4Receive ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token + ); + +EFI_STATUS +EFIAPI +Udp4Cancel ( + IN EFI_UDP4_PROTOCOL *This, + IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +EFI_STATUS +EFIAPI +Udp4Poll ( + IN EFI_UDP4_PROTOCOL *This + ); + +EFI_STATUS +Udp4CreateService ( + IN 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 UDP4_INSTANCE_DATA *Instance + ); + +VOID +Udp4CleanInstance ( + IN UDP4_INSTANCE_DATA *Instance + ); + +EFI_STATUS +Udp4Bind ( + IN NET_LIST_ENTRY *InstanceList, + IN 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 EFI_IP4_CONFIG_DATA *Ip4ConfigData + ); + +EFI_STATUS +Udp4ValidateTxToken ( + IN UDP4_INSTANCE_DATA *Instance, + IN EFI_UDP4_COMPLETION_TOKEN *TxToken + ); + +EFI_STATUS +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 NET_MAP *TokenMap, + IN EFI_UDP4_COMPLETION_TOKEN *Token + ); + +EFI_STATUS +Udp4LeaveGroup ( + IN NET_MAP *Map, + IN NET_MAP_ITEM *Item, + IN VOID *Arg OPTIONAL + ); + +VOID +Udp4FlushRxData ( + IN NET_LIST_ENTRY *RcvdDgramQue + ); + +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 +Udp4NetVectorExtFree ( + VOID *Context + ); + +EFI_STATUS +Udp4SetVariableData ( + IN UDP4_SERVICE_DATA *Udp4Service + ); + +VOID +Udp4ClearVariableData ( + IN UDP4_SERVICE_DATA *Udp4Service + ); + +#endif + -- cgit v1.2.3