mirror of https://github.com/acidanthera/audk.git
update file header
update function header according coding style requirements: The enum shall be declared as a typedef with the name so update FieldIndex related code for IScsiDhcpExtractRootPath() git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6945 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a4e5d8adef
commit
8e29a12567
MdeModulePkg/Universal/Network/IScsiDxe
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/** @file
|
||||||
ISci DHCP related configuration routines.
|
ISci DHCP related configuration routines.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation
|
Copyright (c) 2004 - 2007, Intel Corporation.<BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -10,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
|
||||||
|
|
||||||
IScsiDhcp.c
|
|
||||||
|
|
||||||
Abstract:
|
|
||||||
|
|
||||||
IScsi DHCP related configuration routines.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "IScsiImpl.h"
|
#include "IScsiImpl.h"
|
||||||
|
@ -25,20 +17,14 @@ Abstract:
|
||||||
/**
|
/**
|
||||||
Extract the Root Path option and get the required target information.
|
Extract the Root Path option and get the required target information.
|
||||||
|
|
||||||
@param RootPath[in] The RootPath.
|
@param[in] RootPath The RootPath.
|
||||||
|
@param[in] Length Length of the RootPath option payload.
|
||||||
@param Length[in] Length of the RootPath option payload.
|
@param[in] ConfigNvData The iSCSI session configuration data read from nonvolatile device.
|
||||||
|
|
||||||
@param ConfigNvData[in] The iSCSI session configuration data read from nonvolatile device.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS All required information is extracted from the RootPath option.
|
@retval EFI_SUCCESS All required information is extracted from the RootPath option.
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND The RootPath is not an iSCSI RootPath.
|
@retval EFI_NOT_FOUND The RootPath is not an iSCSI RootPath.
|
||||||
|
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER The RootPath is mal-formatted.
|
@retval EFI_INVALID_PARAMETER The RootPath is mal-formatted.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiDhcpExtractRootPath (
|
IScsiDhcpExtractRootPath (
|
||||||
|
@ -52,7 +38,7 @@ IScsiDhcpExtractRootPath (
|
||||||
CHAR8 *TmpStr;
|
CHAR8 *TmpStr;
|
||||||
ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
|
ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];
|
||||||
ISCSI_ROOT_PATH_FIELD *Field;
|
ISCSI_ROOT_PATH_FIELD *Field;
|
||||||
UINT32 FieldIndex;
|
RP_FIELD_IDX FieldIndex;
|
||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -78,13 +64,13 @@ IScsiDhcpExtractRootPath (
|
||||||
TmpStr[Length] = '\0';
|
TmpStr[Length] = '\0';
|
||||||
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
FieldIndex = 0;
|
FieldIndex = RP_FIELD_IDX_SERVERNAME;
|
||||||
ZeroMem (&Fields[0], sizeof (Fields));
|
ZeroMem (&Fields[0], sizeof (Fields));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Extract the fields in the Root Path option string.
|
// Extract the fields in the Root Path option string.
|
||||||
//
|
//
|
||||||
for (FieldIndex = 0; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
|
for (FieldIndex = RP_FIELD_IDX_SERVERNAME; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {
|
||||||
if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
|
if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {
|
||||||
Fields[FieldIndex].Str = &TmpStr[Index];
|
Fields[FieldIndex].Str = &TmpStr[Index];
|
||||||
}
|
}
|
||||||
|
@ -110,18 +96,24 @@ IScsiDhcpExtractRootPath (
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||
|
for (FieldIndex = RP_FIELD_IDX_SERVERNAME; FieldIndex != RP_FIELD_IDX_TARGETNAME; FieldIndex = RP_FIELD_IDX_TARGETNAME) {
|
||||||
(Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||
|
if (Fields[FieldIndex].Str == NULL) {
|
||||||
(Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)
|
Status = EFI_INVALID_PARAMETER;
|
||||||
) {
|
goto ON_EXIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldIndex = RP_FIELD_IDX_PROTOCOL;
|
||||||
|
if (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the IP address of the target.
|
// Get the IP address of the target.
|
||||||
//
|
//
|
||||||
Field = &Fields[RP_FIELD_IDX_SERVERNAME];
|
FieldIndex = RP_FIELD_IDX_SERVERNAME;
|
||||||
|
Field = &Fields[FieldIndex];
|
||||||
Status = IScsiAsciiStrToIp (Field->Str, &ConfigNvData->TargetIp);
|
Status = IScsiAsciiStrToIp (Field->Str, &ConfigNvData->TargetIp);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
|
@ -129,7 +121,8 @@ IScsiDhcpExtractRootPath (
|
||||||
//
|
//
|
||||||
// Check the protocol type.
|
// Check the protocol type.
|
||||||
//
|
//
|
||||||
Field = &Fields[RP_FIELD_IDX_PROTOCOL];
|
FieldIndex = RP_FIELD_IDX_PROTOCOL;
|
||||||
|
Field = &Fields[FieldIndex];
|
||||||
if ((Field->Str != NULL) && ((*(Field->Str) - '0') != EFI_IP_PROTO_TCP)) {
|
if ((Field->Str != NULL) && ((*(Field->Str) - '0') != EFI_IP_PROTO_TCP)) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
|
@ -137,7 +130,8 @@ IScsiDhcpExtractRootPath (
|
||||||
//
|
//
|
||||||
// Get the port of the iSCSI target.
|
// Get the port of the iSCSI target.
|
||||||
//
|
//
|
||||||
Field = &Fields[RP_FIELD_IDX_PORT];
|
FieldIndex = RP_FIELD_IDX_PORT;
|
||||||
|
Field = &Fields[FieldIndex];
|
||||||
if (Field->Str != NULL) {
|
if (Field->Str != NULL) {
|
||||||
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
|
ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,7 +140,8 @@ IScsiDhcpExtractRootPath (
|
||||||
//
|
//
|
||||||
// Get the LUN.
|
// Get the LUN.
|
||||||
//
|
//
|
||||||
Field = &Fields[RP_FIELD_IDX_LUN];
|
FieldIndex = RP_FIELD_IDX_LUN;
|
||||||
|
Field = &Fields[FieldIndex];
|
||||||
if (Field->Str != NULL) {
|
if (Field->Str != NULL) {
|
||||||
Status = IScsiAsciiStrToLun (Field->Str, ConfigNvData->BootLun);
|
Status = IScsiAsciiStrToLun (Field->Str, ConfigNvData->BootLun);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
@ -158,8 +153,8 @@ IScsiDhcpExtractRootPath (
|
||||||
//
|
//
|
||||||
// Get the target iSCSI Name.
|
// Get the target iSCSI Name.
|
||||||
//
|
//
|
||||||
Field = &Fields[RP_FIELD_IDX_TARGETNAME];
|
FieldIndex = RP_FIELD_IDX_TARGETNAME;
|
||||||
|
Field = &Fields[FieldIndex];
|
||||||
if (AsciiStrLen (Field->Str) > ISCSI_NAME_MAX_SIZE - 1) {
|
if (AsciiStrLen (Field->Str) > ISCSI_NAME_MAX_SIZE - 1) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
|
@ -185,23 +180,17 @@ ON_EXIT:
|
||||||
The callback function registerd to the DHCP4 instance which is used to select
|
The callback function registerd to the DHCP4 instance which is used to select
|
||||||
the qualified DHCP OFFER.
|
the qualified DHCP OFFER.
|
||||||
|
|
||||||
@param This[in] The DHCP4 protocol.
|
@param[in] This The DHCP4 protocol.
|
||||||
|
@param[in] Context The context set when configuring the DHCP4 protocol.
|
||||||
@param Context[in] The context set when configuring the DHCP4 protocol.
|
@param[in] CurrentState The current state of the DHCP4 protocol.
|
||||||
|
@param[in] Dhcp4Event The event occurs in the current state.
|
||||||
@param CurrentState[in] The current state of the DHCP4 protocol.
|
@param[in] Packet The DHCP packet that is to be sent or already received.
|
||||||
|
@param[out] NewPacket The packet used to replace the above Packet.
|
||||||
@param Dhcp4Event[in] The event occurs in the current state.
|
|
||||||
|
|
||||||
@param Packet[in] The DHCP packet that is to be sent or already received.
|
|
||||||
|
|
||||||
@param NewPackt[out] The packet used to replace the above Packet.
|
|
||||||
|
|
||||||
@retval EFI_NOT_READY The DHCP OFFER packet doesn't match our requirements.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Either the DHCP OFFER is qualified or we're not intereseted
|
@retval EFI_SUCCESS Either the DHCP OFFER is qualified or we're not intereseted
|
||||||
in the Dhcp4Event.
|
in the Dhcp4Event.
|
||||||
|
@retval EFI_NOT_READY The DHCP OFFER packet doesn't match our requirements.
|
||||||
|
@retval Others Some unexpected error happened.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiDhcpSelectOffer (
|
IScsiDhcpSelectOffer (
|
||||||
|
@ -266,18 +255,13 @@ IScsiDhcpSelectOffer (
|
||||||
/**
|
/**
|
||||||
Parse the DHCP ACK to get the address configuration and DNS information.
|
Parse the DHCP ACK to get the address configuration and DNS information.
|
||||||
|
|
||||||
@param Dhcp4[in] The DHCP4 protocol.
|
@param[in] Dhcp4 The DHCP4 protocol.
|
||||||
|
@param[in] ConfigData The session configuration data.
|
||||||
@param ConfigData[in] The session configuration data.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
|
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
|
||||||
|
|
||||||
@retval EFI_NO_MAPPING DHCP failed to acquire address and other information.
|
@retval EFI_NO_MAPPING DHCP failed to acquire address and other information.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.
|
@retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR Some unexpected error happened.
|
@retval EFI_DEVICE_ERROR Some unexpected error happened.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiParseDhcpAck (
|
IScsiParseDhcpAck (
|
||||||
|
@ -362,20 +346,13 @@ IScsiParseDhcpAck (
|
||||||
/**
|
/**
|
||||||
Parse the DHCP ACK to get the address configuration and DNS information.
|
Parse the DHCP ACK to get the address configuration and DNS information.
|
||||||
|
|
||||||
@param Image[in] The handle of the driver image.
|
@param[in] Image The handle of the driver image.
|
||||||
|
@param[in] Controller The handle of the controller;
|
||||||
@param Controller[in] The handle of the controller;
|
@param[in] ConfigData The session configuration data.
|
||||||
|
|
||||||
@param ConfigData[in] The session configuration data.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
|
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||||
@retval EFI_NO_MAPPING DHCP failed to acquire address and other information.
|
@retval Others Some unexpected error happened.
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR Some unexpected error happened.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
IScsiDoDhcp (
|
IScsiDoDhcp (
|
||||||
|
|
Loading…
Reference in New Issue