diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-08-27 09:17:26 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-08-27 09:17:26 +0000 |
commit | e5e12de7d0a67111060c77723df39885c91a8ea5 (patch) | |
tree | 4a16a8e5a4b7c32a2c6bacfb71f065f86389dd3c /MdeModulePkg/Library | |
parent | 98376cc51df0c0bd92a3436ec3309401d98c84e3 (diff) | |
download | edk2-e5e12de7d0a67111060c77723df39885c91a8ea5.zip edk2-e5e12de7d0a67111060c77723df39885c91a8ea5.tar.gz edk2-e5e12de7d0a67111060c77723df39885c91a8ea5.tar.bz2 |
1. Sync the latest network stack. Add NetLibCreateIPv4DPathNode () in netlib library.
2. Fixed one porting bug in Udp4Impl.c
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3717 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 108 | ||||
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf | 2 |
2 files changed, 105 insertions, 5 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 0dff772..ddcd6c9 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -24,6 +24,7 @@ Abstract: #include <Protocol/ServiceBinding.h> #include <Protocol/SimpleNetwork.h> #include <Protocol/LoadedImage.h> +#include <Protocol/NicIp4Config.h> #include <Library/NetLib.h> #include <Library/BaseLib.h> @@ -838,11 +839,7 @@ NetLibDefaultUnload ( UINTN DeviceHandleCount; UINTN Index; EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; -#if (EFI_SPECIFICATION_VERSION >= 0x00020000) - EFI_COMPONENT_NAME2_PROTOCOL *ComponentName; -#else EFI_COMPONENT_NAME_PROTOCOL *ComponentName; -#endif EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration; EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics; @@ -1123,6 +1120,109 @@ NetLibGetMacString ( return EFI_SUCCESS; } +/** + Check the default address used by the IPv4 driver is static or dynamic (acquired + from DHCP). + + @param Controller The controller handle which has the NIC Ip4 Config Protocol + relative with the default address to judge. + + @retval TRUE If the default address is static. + @retval FALSE If the default address is acquired from DHCP. + +**/ +STATIC +BOOLEAN +NetLibDefaultAddressIsStatic ( + IN EFI_HANDLE Controller + ) +{ + EFI_STATUS Status; + EFI_NIC_IP4_CONFIG_PROTOCOL *NicIp4; + UINTN Len; + NIC_IP4_CONFIG_INFO *ConfigInfo; + BOOLEAN IsStatic; + + Status = gBS->HandleProtocol ( + Controller, + &gEfiNicIp4ConfigProtocolGuid, + (VOID **) &NicIp4 + ); + if (EFI_ERROR (Status)) { + return TRUE; + } + + Len = 0; + Status = NicIp4->GetInfo (NicIp4, &Len, NULL); + if (Status != EFI_BUFFER_TOO_SMALL) { + return TRUE; + } + + ConfigInfo = NetAllocatePool (Len); + if (ConfigInfo == NULL) { + return TRUE; + } + + IsStatic = TRUE; + Status = NicIp4->GetInfo (NicIp4, &Len, ConfigInfo); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC); + +ON_EXIT: + + NetFreePool (ConfigInfo); + + return IsStatic; +} + +/** + Create an IPv4 device path node. + + @param Node Pointer to the IPv4 device path node. + @param Controller The handle where the NIC IP4 config protocol resides. + @param LocalIp The local IPv4 address. + @param LocalPort The local port. + @param RemoteIp The remote IPv4 address. + @param RemotePort The remote port. + @param Protocol The protocol type in the IP header. + @param UseDefaultAddress Whether this instance is using default address or not. + + @retval None +**/ +VOID +NetLibCreateIPv4DPathNode ( + IN OUT IPv4_DEVICE_PATH *Node, + IN EFI_HANDLE Controller, + IN IP4_ADDR LocalIp, + IN UINT16 LocalPort, + IN IP4_ADDR RemoteIp, + IN UINT16 RemotePort, + IN UINT16 Protocol, + IN BOOLEAN UseDefaultAddress + ) +{ + Node->Header.Type = MESSAGING_DEVICE_PATH; + Node->Header.SubType = MSG_IPv4_DP; + SetDevicePathNodeLength (&Node->Header, 19); + + NetCopyMem (&Node->LocalIpAddress, &LocalIp, sizeof (EFI_IPv4_ADDRESS)); + NetCopyMem (&Node->RemoteIpAddress, &RemoteIp, sizeof (EFI_IPv4_ADDRESS)); + + Node->LocalPort = LocalPort; + Node->RemotePort = RemotePort; + + Node->Protocol = Protocol; + + if (!UseDefaultAddress) { + Node->StaticIpAddress = TRUE; + } else { + Node->StaticIpAddress = NetLibDefaultAddressIsStatic (Controller); + } +} + /** Find the UNDI/SNP handle from controller and protocol GUID. diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf index f247e61..2bd876e 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf @@ -54,4 +54,4 @@ [Protocols]
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
-
+ gEfiNicIp4ConfigProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|