-/*++\r
+/**\r
+ ISci DHCP related configuration routines.\r
\r
Copyright (c) 2004 - 2007, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
\r
Abstract:\r
\r
- iSCSI DHCP related configuration routines.\r
+ IScsi DHCP related configuration routines.\r
\r
---*/\r
+**/\r
\r
#include "IScsiImpl.h"\r
\r
-STATIC\r
-EFI_STATUS\r
-IScsiDhcpExtractRootPath (\r
- IN CHAR8 *RootPath,\r
- IN UINT8 Length,\r
- IN ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData\r
- )\r
-/*++\r
+/**\r
+ Extract the Root Path option and get the required target information.\r
\r
-Routine Description:\r
+ @param RootPath[in] The RootPath.\r
\r
- Extract the Root Path option and get the required target information.\r
- \r
-Arguments:\r
+ @param Length[in] Length of the RootPath option payload.\r
\r
- RootPath - The RootPath.\r
- Length - Length of the RootPath option payload.\r
- ConfigNvData - The iSCSI session configuration data read from nonvolatile device.\r
+ @param ConfigNvData[in] The iSCSI session configuration data read from nonvolatile device.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS All required information is extracted from the RootPath option.\r
\r
- EFI_SUCCESS - All required information is extracted from the RootPath option.\r
- EFI_NOT_FOUND - The RootPath is not an iSCSI RootPath.\r
- EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
- EFI_INVALID_PARAMETER - The RootPath is mal-formatted.\r
+ @retval EFI_NOT_FOUND The RootPath is not an iSCSI RootPath.\r
\r
---*/\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+\r
+ @retval EFI_INVALID_PARAMETER The RootPath is mal-formatted.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiDhcpExtractRootPath (\r
+ IN CHAR8 *RootPath,\r
+ IN UINT8 Length,\r
+ IN ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData\r
+ )\r
{\r
EFI_STATUS Status;\r
UINT8 IScsiRootPathIdLen;\r
//\r
IScsiRootPathIdLen = (UINT8) AsciiStrLen (ISCSI_ROOT_PATH_ID);\r
\r
- if ((Length <= IScsiRootPathIdLen) || (NetCompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {\r
+ if ((Length <= IScsiRootPathIdLen) || (CompareMem (RootPath, ISCSI_ROOT_PATH_ID, IScsiRootPathIdLen) != 0)) {\r
return EFI_NOT_FOUND;\r
}\r
//\r
RootPath += IScsiRootPathIdLen;\r
Length = (UINT8) (Length - IScsiRootPathIdLen);\r
\r
- TmpStr = (CHAR8 *) NetAllocatePool (Length + 1);\r
+ TmpStr = (CHAR8 *) AllocatePool (Length + 1);\r
if (TmpStr == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- NetCopyMem (TmpStr, RootPath, Length);\r
+ CopyMem (TmpStr, RootPath, Length);\r
TmpStr[Length] = '\0';\r
\r
Index = 0;\r
FieldIndex = 0;\r
- NetZeroMem (&Fields[0], sizeof (Fields));\r
+ ZeroMem (&Fields[0], sizeof (Fields));\r
\r
//\r
// Extract the fields in the Root Path option string.\r
goto ON_EXIT;\r
}\r
} else {\r
- NetZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));\r
+ ZeroMem (ConfigNvData->BootLun, sizeof (ConfigNvData->BootLun));\r
}\r
//\r
// Get the target iSCSI Name.\r
\r
ON_EXIT:\r
\r
- NetFreePool (TmpStr);\r
+ gBS->FreePool (TmpStr);\r
\r
return Status;\r
}\r
\r
-STATIC\r
+/**\r
+ The callback function registerd to the DHCP4 instance which is used to select\r
+ the qualified DHCP OFFER.\r
+ \r
+ @param This[in] The DHCP4 protocol.\r
+\r
+ @param Context[in] The context set when configuring the DHCP4 protocol.\r
+\r
+ @param CurrentState[in] The current state of the DHCP4 protocol.\r
+\r
+ @param Dhcp4Event[in] The event occurs in the current state.\r
+\r
+ @param Packet[in] The DHCP packet that is to be sent or already received. \r
+\r
+ @param NewPackt[out] The packet used to replace the above Packet.\r
+\r
+ @retval EFI_NOT_READY The DHCP OFFER packet doesn't match our requirements.\r
+\r
+ @retval EFI_SUCCESS Either the DHCP OFFER is qualified or we're not intereseted\r
+ in the Dhcp4Event.\r
+\r
+**/\r
EFI_STATUS\r
IScsiDhcpSelectOffer (\r
IN EFI_DHCP4_PROTOCOL * This,\r
IN EFI_DHCP4_PACKET * Packet, OPTIONAL\r
OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- The callback function registerd to the DHCP4 instance which is used to select\r
- the qualified DHCP OFFER.\r
- \r
-Arguments:\r
-\r
- This - The DHCP4 protocol.\r
- Context - The context set when configuring the DHCP4 protocol.\r
- CurrentState - The current state of the DHCP4 protocol.\r
- Dhcp4Event - The event occurs in the current state.\r
- Packet - The DHCP packet that is to be sent or already received.\r
- NewPackt - The packet used to replace the above Packet.\r
-\r
-Returns:\r
-\r
- EFI_NOT_READY - The DHCP OFFER packet doesn't match our requirements.\r
- EFI_SUCCESS - Either the DHCP OFFER is qualified or we're not intereseted\r
- in the Dhcp4Event.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
UINT32 OptionCount;\r
return EFI_NOT_READY;\r
}\r
\r
- OptionList = NetAllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));\r
+ OptionList = AllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));\r
if (OptionList == NULL) {\r
return EFI_NOT_READY;\r
}\r
\r
Status = This->Parse (This, Packet, &OptionCount, OptionList);\r
if (EFI_ERROR (Status)) {\r
- NetFreePool (OptionList);\r
+ gBS->FreePool (OptionList);\r
return EFI_NOT_READY;\r
}\r
\r
Status = EFI_NOT_READY;\r
}\r
\r
- NetFreePool (OptionList);\r
+ gBS->FreePool (OptionList);\r
\r
return Status;\r
}\r
\r
-EFI_STATUS\r
-IScsiParseDhcpAck (\r
- IN EFI_DHCP4_PROTOCOL *Dhcp4,\r
- IN ISCSI_SESSION_CONFIG_DATA *ConfigData\r
- )\r
-/*++\r
+/**\r
+ Parse the DHCP ACK to get the address configuration and DNS information.\r
\r
-Routine Description:\r
+ @param Dhcp4[in] The DHCP4 protocol.\r
\r
- Parse the DHCP ACK to get the address configuration and DNS information.\r
- \r
-Arguments:\r
+ @param ConfigData[in] The session configuration data.\r
\r
- Dhcp4 - The DHCP4 protocol.\r
- ConfigData - The session configuration data.\r
+ @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.\r
\r
-Returns:\r
+ @retval EFI_NO_MAPPING DHCP failed to acquire address and other information.\r
\r
- EFI_SUCCESS - The DNS information is got from the DHCP ACK.\r
- EFI_NO_MAPPING - DHCP failed to acquire address and other information.\r
- EFI_INVALID_PARAMETER - The DHCP ACK's DNS option is mal-formatted.\r
- EFI_DEVICE_ERROR - Some unexpected error happened.\r
+ @retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.\r
\r
---*/\r
+ @retval EFI_DEVICE_ERROR Some unexpected error happened.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiParseDhcpAck (\r
+ IN EFI_DHCP4_PROTOCOL *Dhcp4,\r
+ IN ISCSI_SESSION_CONFIG_DATA *ConfigData\r
+ )\r
{\r
EFI_STATUS Status;\r
EFI_DHCP4_MODE_DATA Dhcp4ModeData;\r
return EFI_NO_MAPPING;\r
}\r
\r
- NetCopyMem (&ConfigData->NvData.LocalIp, &Dhcp4ModeData.ClientAddress, sizeof (EFI_IPv4_ADDRESS));\r
- NetCopyMem (&ConfigData->NvData.SubnetMask, &Dhcp4ModeData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
- NetCopyMem (&ConfigData->NvData.Gateway, &Dhcp4ModeData.RouterAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->NvData.LocalIp, &Dhcp4ModeData.ClientAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->NvData.SubnetMask, &Dhcp4ModeData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->NvData.Gateway, &Dhcp4ModeData.RouterAddress, sizeof (EFI_IPv4_ADDRESS));\r
\r
OptionCount = 0;\r
OptionList = NULL;\r
return EFI_DEVICE_ERROR;\r
}\r
\r
- OptionList = NetAllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));\r
+ OptionList = AllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));\r
if (OptionList == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
Status = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket, &OptionCount, OptionList);\r
if (EFI_ERROR (Status)) {\r
- NetFreePool (OptionList);\r
+ gBS->FreePool (OptionList);\r
return EFI_DEVICE_ERROR;\r
}\r
\r
//\r
// Primary DNS server address.\r
//\r
- NetCopyMem (&ConfigData->PrimaryDns, &OptionList[Index]->Data[0], sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->PrimaryDns, &OptionList[Index]->Data[0], sizeof (EFI_IPv4_ADDRESS));\r
\r
if (OptionList[Index]->Length > 4) {\r
//\r
// Secondary DNS server address\r
//\r
- NetCopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[4], sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->SecondaryDns, &OptionList[Index]->Data[4], sizeof (EFI_IPv4_ADDRESS));\r
}\r
} else if (OptionList[Index]->OpCode == DHCP4_TAG_SERVER_ID) {\r
if (OptionList[Index]->Length != 4) {\r
break;\r
}\r
\r
- NetCopyMem (&ConfigData->DhcpServer, &OptionList[Index]->Data[0], sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&ConfigData->DhcpServer, &OptionList[Index]->Data[0], sizeof (EFI_IPv4_ADDRESS));\r
}\r
}\r
\r
- NetFreePool (OptionList);\r
+ gBS->FreePool (OptionList);\r
\r
return Status;\r
}\r
\r
-EFI_STATUS\r
-IScsiDoDhcp (\r
- IN EFI_HANDLE Image,\r
- IN EFI_HANDLE Controller,\r
- IN ISCSI_SESSION_CONFIG_DATA *ConfigData\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
Parse the DHCP ACK to get the address configuration and DNS information.\r
\r
-Arguments:\r
+ @param Image[in] The handle of the driver image.\r
+\r
+ @param Controller[in] The handle of the controller;\r
\r
- Image - The handle of the driver image.\r
- Controller - The handle of the controller;\r
- ConfigData - The session configuration data.\r
+ @param ConfigData[in] The session configuration data.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.\r
\r
- EFI_SUCCESS - The DNS information is got from the DHCP ACK.\r
- EFI_NO_MAPPING - DHCP failed to acquire address and other information.\r
- EFI_INVALID_PARAMETER - The DHCP ACK's DNS option is mal-formatted.\r
- EFI_DEVICE_ERROR - Some unexpected error happened.\r
+ @retval EFI_NO_MAPPING DHCP failed to acquire address and other information.\r
\r
---*/\r
+ @retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.\r
+\r
+ @retval EFI_DEVICE_ERROR Some unexpected error happened.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiDoDhcp (\r
+ IN EFI_HANDLE Image,\r
+ IN EFI_HANDLE Controller,\r
+ IN ISCSI_SESSION_CONFIG_DATA *ConfigData\r
+ )\r
{\r
EFI_HANDLE Dhcp4Handle;\r
EFI_DHCP4_PROTOCOL *Dhcp4;\r
goto ON_EXIT;\r
}\r
\r
- ParaList = NetAllocatePool (sizeof (EFI_DHCP4_PACKET_OPTION) + 3);\r
+ ParaList = AllocatePool (sizeof (EFI_DHCP4_PACKET_OPTION) + 3);\r
if (ParaList == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
ParaList->Data[2] = DHCP4_TAG_DNS;\r
ParaList->Data[3] = DHCP4_TAG_ROOT_PATH;\r
\r
- NetZeroMem (&Dhcp4ConfigData, sizeof (EFI_DHCP4_CONFIG_DATA));\r
+ ZeroMem (&Dhcp4ConfigData, sizeof (EFI_DHCP4_CONFIG_DATA));\r
Dhcp4ConfigData.OptionCount = 1;\r
Dhcp4ConfigData.OptionList = &ParaList;\r
\r
ON_EXIT:\r
\r
if (ParaList != NULL) {\r
- NetFreePool (ParaList);\r
+ gBS->FreePool (ParaList);\r
}\r
\r
if (Dhcp4 != NULL) {\r