UEFI HII: Merge UEFI HII support changes from branch.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4599 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12
2008-01-21 14:39:56 +00:00
parent f79314fa8f
commit 93e3992d1e
139 changed files with 59162 additions and 382 deletions

View File

@@ -77,8 +77,8 @@
DevicePathLib
DebugLib
PrintLib
FrameworkHiiLib
FrameworkIfrSupportLib
HiiLib
IfrSupportLib
NetLib
[Protocols]
@@ -88,8 +88,8 @@
gEfiExtScsiPassThruProtocolGuid
gEfiDevicePathProtocolGuid
gEfiTcp4ServiceBindingProtocolGuid
gEfiFormCallbackProtocolGuid
gEfiFormBrowserProtocolGuid
gEfiHiiDatabaseProtocolGuid
gEfiHiiConfigAccessProtocolGuid
gEfiPciIoProtocolGuid
gEfiAcpiSupportProtocolGuid
gEfiDhcp4ProtocolGuid

View File

@@ -119,6 +119,7 @@ Returns:
{
EFI_STATUS Status;
ISCSI_SESSION *Session;
ISCSI_SESSION_CONFIG_DATA *ConfigData;
ISCSI_CHAP_AUTH_DATA *AuthData;
CHAR8 *Value;
UINT8 *Data;
@@ -136,6 +137,7 @@ Returns:
ASSERT (Conn->RspQue.BufNum != 0);
Session = Conn->Session;
ConfigData = &Session->ConfigData;
AuthData = &Session->AuthData;
Len = Conn->RspQue.BufSize;
@@ -151,7 +153,7 @@ Returns:
//
// Build the key-value list from the data segment of the Login Response.
//
KeyValueList = IScsiBuildKeyValueList ((CHAR8*)Data, Len);
KeyValueList = IScsiBuildKeyValueList (Data, Len);
if (KeyValueList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
@@ -317,6 +319,7 @@ Returns:
EFI_STATUS Status;
ISCSI_SESSION *Session;
ISCSI_LOGIN_REQUEST *LoginReq;
ISCSI_SESSION_CONFIG_DATA *ConfigData;
ISCSI_CHAP_AUTH_DATA *AuthData;
CHAR8 *Value;
CHAR8 ValueStr[256];
@@ -328,6 +331,7 @@ Returns:
ASSERT (Conn->CurrentStage == ISCSI_SECURITY_NEGOTIATION);
Session = Conn->Session;
ConfigData = &Session->ConfigData;
AuthData = &Session->AuthData;
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufGetByte (Pdu, 0, 0);
Status = EFI_SUCCESS;
@@ -383,7 +387,7 @@ Returns:
//
// CHAP_N=<N>
//
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_NAME, (CHAR8 *) &AuthData->AuthConfig.CHAPName);
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_NAME, (UINT8 *) &AuthData->AuthConfig.CHAPName);
//
// CHAP_R=<R>
//

View File

@@ -22,7 +22,7 @@ Abstract:
#define ISCSI_CHAP_AUTH_INFO_GUID \
{ \
0x786ec0ac, 0x65ae, 0x4d1b, 0xb1, 0x37, 0xd, 0x11, 0xa, 0x48, 0x37, 0x97 \
0x786ec0ac, 0x65ae, 0x4d1b, {0xb1, 0x37, 0xd, 0x11, 0xa, 0x48, 0x37, 0x97} \
}
extern EFI_GUID mIScsiCHAPAuthInfoGuid;

View File

@@ -22,6 +22,7 @@ Abstract:
EFI_GUID mVendorGuid = ISCSI_CONFIG_GUID;
BOOLEAN mIScsiDeviceListUpdated = FALSE;
UINTN mNumberOfIScsiDevices = 0;
ISCSI_FORM_CALLBACK_INFO *mCallbackInfo;
NET_LIST_ENTRY mIScsiConfigFormList = {
&mIScsiConfigFormList,
@@ -74,21 +75,9 @@ Returns:
--*/
{
EFI_FORM_BROWSER_PROTOCOL *FormBrowser;
EFI_STATUS Status;
EFI_INPUT_KEY Key;
CHAR16 Buffer[10];
Status = gBS->LocateProtocol (
&gEfiFormBrowserProtocolGuid,
NULL,
(VOID **)&FormBrowser
);
if (EFI_ERROR (Status)) {
return ;
}
FormBrowser->CreatePopUp (1, TRUE, 10, Buffer, &Key, Warning);
IfrLibCreatePopUp (1, &Key, Warning);
}
EFI_STATUS
@@ -335,42 +324,47 @@ Returns:
IScsiAsciiStrToUnicodeStr (AuthConfigData->ReverseCHAPSecret, IfrNvData->ReverseCHAPSecret);
}
EFI_STATUS
EFIAPI
IScsiFormNvRead (
IN EFI_FORM_CALLBACK_PROTOCOL * This,
IN CHAR16 *VariableName,
IN EFI_GUID * VendorGuid,
OUT UINT32 *Attributes OPTIONAL,
IN OUT UINTN *DataSize,
OUT VOID *Buffer
IScsiFormExtractConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Request,
OUT EFI_STRING *Progress,
OUT EFI_STRING *Results
)
/*++
Routine Description:
Routine Description:
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
NV read function for the iSCSI form callback protocol.
Arguments:
This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
Request - A null-terminated Unicode string in <ConfigRequest> format.
Progress - On return, points to a character in the Request string.
Points to the string's null terminator if request was successful.
Points to the most recent '&' before the first failing name/value
pair (or the beginning of the string if the failure is in the
first name/value pair) if the request was not successful.
Results - A null-terminated Unicode string in <ConfigAltResp> format which
has all values filled in for the names in the Request string.
String to be allocated by the called function.
Arguments:
This - The EFI form callback protocol instance.
VariableName - Name of the variable to read.
VendorGuid - Guid of the variable to read.
Attributes - The storage to get the attributes of the variable.
DataSize - The size of the buffer to store the variable.
Buffer - The buffer to store the variable to read.
Returns:
EFI_SUCCESS - The variable is read.
EFI_BUFFER_TOO_SMALL - The buffer provided is too small to hold the variable.
Returns:
EFI_SUCCESS - The Results is filled with the requested values.
EFI_OUT_OF_RESOURCES - Not enough memory to store the results.
EFI_INVALID_PARAMETER - Request is NULL, illegal syntax, or unknown name.
EFI_NOT_FOUND - Routing data doesn't match any storage in this driver.
--*/
{
EFI_STATUS Status;
CHAR8 InitiatorName[ISCSI_NAME_IFR_MAX_SIZE];
UINTN BufferSize;
ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
EFI_STATUS Status;
CHAR8 InitiatorName[ISCSI_NAME_IFR_MAX_SIZE];
UINTN BufferSize;
ISCSI_CONFIG_IFR_NVDATA *IfrNvData;
ISCSI_FORM_CALLBACK_INFO *Private;
EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
if (!mIScsiDeviceListUpdated) {
//
@@ -380,9 +374,14 @@ Returns:
mIScsiDeviceListUpdated = TRUE;
}
IfrNvData = (ISCSI_CONFIG_IFR_NVDATA *) Buffer;
BufferSize = ISCSI_NAME_IFR_MAX_SIZE;
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));
ASSERT (IfrNvData != NULL);
if (Private->Current != NULL) {
IScsiConvertDeviceConfigDataToIfrNvData (Private->Current, IfrNvData);
}
BufferSize = ISCSI_NAME_IFR_MAX_SIZE;
Status = gIScsiInitiatorName.Get (&gIScsiInitiatorName, &BufferSize, InitiatorName);
if (EFI_ERROR (Status)) {
IfrNvData->InitiatorName[0] = L'\0';
@@ -390,37 +389,82 @@ Returns:
IScsiAsciiStrToUnicodeStr (InitiatorName, IfrNvData->InitiatorName);
}
//
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
//
HiiConfigRouting = Private->ConfigRouting;
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
Status = HiiConfigRouting->BlockToConfig (
HiiConfigRouting,
Request,
(UINT8 *) IfrNvData,
BufferSize,
Results,
Progress
);
NetFreePool (IfrNvData);
return Status;
}
EFI_STATUS
EFIAPI
IScsiFormRouteConfig (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
)
/*++
Routine Description:
This function processes the results of changes in configuration.
Arguments:
This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
Configuration - A null-terminated Unicode string in <ConfigResp> format.
Progress - A pointer to a string filled in with the offset of the most
recent '&' before the first failing name/value pair (or the
beginning of the string if the failure is in the first
name/value pair) or the terminating NULL if all was successful.
Returns:
EFI_SUCCESS - The Results is processed successfully.
EFI_INVALID_PARAMETER - Configuration is NULL.
EFI_NOT_FOUND - Routing data doesn't match any storage in this driver.
--*/
{
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
IScsiFormCallback (
IN EFI_FORM_CALLBACK_PROTOCOL *This,
IN UINT16 KeyValue,
IN EFI_IFR_DATA_ARRAY *Data,
OUT EFI_HII_CALLBACK_PACKET **Packet
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID KeyValue,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
/*++
Routine Description:
Routine Description:
This function processes the results of changes in configuration.
The form callback function for iSCSI form callback protocol, it processes
the events tiggered in the UI and take some operations to update the form,
store the data, etc.
Arguments:
This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
Action - Specifies the type of action taken by the browser.
QuestionId - A unique value which is sent to the original exporting driver
so that it can identify the type of data to expect.
Type - The type of value for the question.
Value - A pointer to the data being sent to the original exporting driver.
ActionRequest - On return, points to the action requested by the callback function.
Arguments:
This - The EFI form callback protocol instance.
KeyValue - A unique value which is sent to the original exporting driver so that it
can identify the type of data to expect. The format of the data tends to
vary based on the op-code that geerated the callback.
Data - A pointer to the data being sent to the original exporting driver.
Returns:
EFI_SUCCESS - The data is valid and the correspondance operation is done.
EFI_INVALID_PARAMETER - The data is invalid.
Returns:
EFI_SUCCESS - The callback successfully handled the action.
EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the variable and its data.
EFI_DEVICE_ERROR - The variable could not be saved.
EFI_UNSUPPORTED - The specified Action is not supported by the callback.
--*/
{
@@ -440,8 +484,18 @@ Returns:
EFI_STATUS Status;
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
IfrNvData = (ISCSI_CONFIG_IFR_NVDATA *) Data->NvRamMap;
Status = EFI_SUCCESS;
//
// Retrive uncommitted data from Browser
//
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
IfrNvData = AllocateZeroPool (BufferSize);
ASSERT (IfrNvData != NULL);
Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) IfrNvData);
if (EFI_ERROR (Status)) {
gBS->FreePool (IfrNvData);
return Status;
}
switch (KeyValue) {
case KEY_INITIATOR_NAME:
@@ -633,7 +687,7 @@ Returns:
BufferSize,
&Private->Current->AuthConfigData
);
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
break;
default:
@@ -644,16 +698,9 @@ Returns:
ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (KeyValue - KEY_DEVICE_ENTRY_BASE));
ASSERT (ConfigFormEntry != NULL);
UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);
UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);
DeviceFormTitleToken = (STRING_REF) STR_ISCSI_DEVICE_FORM_TITLE;
Private->Hii->NewString (
Private->Hii,
NULL,
Private->RegisteredHandle,
&DeviceFormTitleToken,
PortString
);
IfrLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);
IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);
@@ -663,9 +710,19 @@ Returns:
break;
}
if (!EFI_ERROR (Status)) {
//
// Pass changed uncommitted data back to Form Browser
//
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);
Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);
}
NetFreePool (IfrNvData);
return Status;
}
EFI_STATUS
IScsiConfigUpdateForm (
IN EFI_HANDLE DriverBindingHandle,
@@ -695,28 +752,13 @@ Returns:
NET_LIST_ENTRY *Entry;
ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;
BOOLEAN EntryExisted;
EFI_HII_UPDATE_DATA *UpdateData;
EFI_STATUS Status;
EFI_FORM_CALLBACK_PROTOCOL *Callback;
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
EFI_HII_UPDATE_DATA UpdateData;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
CHAR16 PortString[128];
UINT16 FormIndex;
UINTN BufferSize;
//
// Get the EFI_FORM_CALLBACK_PROTOCOL.
//
Status = gBS->HandleProtocol (
DriverBindingHandle,
&gEfiFormCallbackProtocolGuid,
(VOID **)&Callback
);
if (EFI_ERROR (Status)) {
return Status;
}
CallbackInfo = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (Callback);
ConfigFormEntry = NULL;
EntryExisted = FALSE;
@@ -790,25 +832,13 @@ Returns:
// Compose the Port string and create a new STRING_REF.
//
UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);
CallbackInfo->Hii->NewString (
CallbackInfo->Hii,
NULL,
CallbackInfo->RegisteredHandle,
&ConfigFormEntry->PortTitleToken,
PortString
);
IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);
//
// Compose the help string of this port and create a new STRING_REF.
//
UnicodeSPrint (PortString, 128, L"Set the iSCSI parameters on port %s", ConfigFormEntry->MacString);
CallbackInfo->Hii->NewString (
CallbackInfo->Hii,
NULL,
CallbackInfo->RegisteredHandle,
&ConfigFormEntry->PortTitleHelpToken,
PortString
);
IfrLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);
NetListInsertTail (&mIScsiConfigFormList, &ConfigFormEntry->Link);
mNumberOfIScsiDevices++;
@@ -823,37 +853,11 @@ Returns:
//
// Allocate space for creation of Buffer
//
UpdateData = (EFI_HII_UPDATE_DATA *) NetAllocatePool (0x1000);
NetZeroMem (UpdateData, 0x1000);
//
// Flag update pending in FormSet
//
UpdateData->FormSetUpdate = TRUE;
//
// Register CallbackHandle data for FormSet
//
UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackInfo->CallbackHandle;
UpdateData->FormUpdate = FALSE;
UpdateData->FormTitle = 0;
//
// first of all, remove all the forms.
//
UpdateData->DataCount = 0xFF;
CallbackInfo->Hii->UpdateForm (
CallbackInfo->Hii,
CallbackInfo->RegisteredHandle,
(EFI_FORM_LABEL) DEVICE_ENTRY_LABEL,
FALSE,
UpdateData
);
UpdateData->DataCount = 1;
FormIndex = 0;
UpdateData.BufferSize = 0x1000;
UpdateData.Data = NetAllocateZeroPool (0x1000);
UpdateData.Offset = 0;
FormIndex = 0;
NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {
ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, ISCSI_CONFIG_FORM_ENTRY, Link);
@@ -861,23 +865,24 @@ Returns:
FORMID_DEVICE_FORM,
ConfigFormEntry->PortTitleToken,
ConfigFormEntry->PortTitleHelpToken,
EFI_IFR_FLAG_INTERACTIVE,
(UINT16) (KEY_DEVICE_ENTRY_BASE + FormIndex),
&UpdateData->Data
EFI_IFR_FLAG_CALLBACK,
KEY_DEVICE_ENTRY_BASE + FormIndex,
&UpdateData
);
CallbackInfo->Hii->UpdateForm (
CallbackInfo->Hii,
CallbackInfo->RegisteredHandle,
(EFI_FORM_LABEL) DEVICE_ENTRY_LABEL,
TRUE,
UpdateData
);
FormIndex++;
}
NetFreePool (UpdateData);
IfrLibUpdateForm (
mCallbackInfo->RegisteredHandle,
&mVendorGuid,
FORMID_MAIN_FORM,
DEVICE_ENTRY_LABEL,
FALSE,
&UpdateData
);
NetFreePool (UpdateData.Data);
return EFI_SUCCESS;
}
@@ -903,17 +908,14 @@ Returns:
--*/
{
EFI_STATUS Status;
EFI_HII_PROTOCOL *Hii;
EFI_HII_PACKAGES *PackageList;
EFI_HII_HANDLE HiiHandle;
EFI_HII_UPDATE_DATA *UpdateData;
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
EFI_GUID StringPackGuid = ISCSI_CONFIG_GUID;
EFI_STATUS Status;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID **)&Hii);
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, &HiiDatabase);
if (EFI_ERROR (Status)) {
return Status;;
return Status;
}
CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) NetAllocatePool (sizeof (ISCSI_FORM_CALLBACK_INFO));
@@ -922,59 +924,55 @@ Returns:
}
CallbackInfo->Signature = ISCSI_FORM_CALLBACK_INFO_SIGNATURE;
CallbackInfo->Hii = Hii;
CallbackInfo->HiiDatabase = HiiDatabase;
CallbackInfo->Current = NULL;
CallbackInfo->FormCallback.NvRead = IScsiFormNvRead;
CallbackInfo->FormCallback.NvWrite = NULL;
CallbackInfo->FormCallback.Callback = IScsiFormCallback;
CallbackInfo->ConfigAccess.ExtractConfig = IScsiFormExtractConfig;
CallbackInfo->ConfigAccess.RouteConfig = IScsiFormRouteConfig;
CallbackInfo->ConfigAccess.Callback = IScsiFormCallback;
//
// Install protocol interface
//
Status = gBS->InstallProtocolInterface (
&DriverBindingHandle,
&gEfiFormCallbackProtocolGuid,
EFI_NATIVE_INTERFACE,
&CallbackInfo->FormCallback
);
ASSERT_EFI_ERROR (Status);
CallbackInfo->CallbackHandle = DriverBindingHandle;
PackageList = PreparePackages (2, &StringPackGuid, iSCSIStrings, IScsiConfigDxeBin);
Status = Hii->NewPack (Hii, PackageList, &HiiHandle);
NetFreePool (PackageList);
CallbackInfo->RegisteredHandle = HiiHandle;
//
// Allocate space for creation of Buffer
//
UpdateData = (EFI_HII_UPDATE_DATA *) NetAllocatePool (0x1000);
ASSERT (UpdateData != NULL);
if (UpdateData == NULL) {
return EFI_OUT_OF_RESOURCES;
Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, &CallbackInfo->ConfigRouting);
if (EFI_ERROR (Status)) {
return Status;
}
NetZeroMem (UpdateData, 0x1000);
//
// Flag update pending in FormSet
// Create driver handle used by HII database
//
UpdateData->FormSetUpdate = TRUE;
Status = HiiLibCreateHiiDriverHandle (&CallbackInfo->DriverHandle);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Register CallbackHandle data for FormSet
// Install Config Access protocol to driver handle
//
UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackInfo->CallbackHandle;
UpdateData->FormUpdate = FALSE;
UpdateData->FormTitle = 0;
UpdateData->DataCount = 0x1;
Status = gBS->InstallProtocolInterface (
&CallbackInfo->DriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
EFI_NATIVE_INTERFACE,
&CallbackInfo->ConfigAccess
);
ASSERT_EFI_ERROR (Status);
//
// Publish our HII data
//
PackageList = PreparePackageList (2, &mVendorGuid, iSCSIStrings, IScsiConfigDxeBin);
ASSERT (PackageList != NULL);
Status = HiiDatabase->NewPackageList (
HiiDatabase,
PackageList,
CallbackInfo->DriverHandle,
&CallbackInfo->RegisteredHandle
);
NetFreePool (PackageList);
if (EFI_ERROR (Status)) {
return Status;
}
Hii->UpdateForm (Hii, HiiHandle, (EFI_FORM_LABEL) 0x1000, TRUE, UpdateData);
NetFreePool (UpdateData);
mCallbackInfo = CallbackInfo;
return Status;
}
@@ -1003,11 +1001,6 @@ Returns:
--*/
{
ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;
EFI_STATUS Status;
EFI_HII_PROTOCOL *Hii;
EFI_HII_UPDATE_DATA *UpdateData;
EFI_FORM_CALLBACK_PROTOCOL *FormCallback;
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;
while (!NetListIsEmpty (&mIScsiConfigFormList)) {
//
@@ -1021,54 +1014,25 @@ Returns:
IScsiConfigUpdateForm (DriverBindingHandle, ConfigFormEntry->Controller, FALSE);
}
Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID **)&Hii);
if (EFI_ERROR (Status)) {
return Status;
}
Status = gBS->HandleProtocol (DriverBindingHandle, &gEfiFormCallbackProtocolGuid, (VOID **)&FormCallback);
if (EFI_ERROR (Status)) {
return Status;
}
CallbackInfo = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (FormCallback);
//
// Remove HII package list
//
mCallbackInfo->HiiDatabase->RemovePackageList (
mCallbackInfo->HiiDatabase,
mCallbackInfo->RegisteredHandle
);
//
// remove the form.
//
UpdateData = (EFI_HII_UPDATE_DATA *) NetAllocatePool (0x1000);
ASSERT (UpdateData != NULL);
if (UpdateData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
NetZeroMem (UpdateData, 0x1000);
UpdateData->FormSetUpdate = FALSE;
UpdateData->FormCallbackHandle = 0;
UpdateData->FormUpdate = FALSE;
UpdateData->FormTitle = 0;
UpdateData->DataCount = 0xFF;
Hii->UpdateForm (Hii, CallbackInfo->RegisteredHandle, (EFI_FORM_LABEL) 0x1000, FALSE, UpdateData);
NetFreePool (UpdateData);
//
// Uninstall the EFI_FORM_CALLBACK_PROTOCOL.
// Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
//
gBS->UninstallProtocolInterface (
DriverBindingHandle,
&gEfiFormCallbackProtocolGuid,
FormCallback
mCallbackInfo->DriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
&mCallbackInfo->ConfigAccess
);
HiiLibDestroyHiiDriverHandle (mCallbackInfo->DriverHandle);
//
// Remove the package.
//
Hii->RemovePack (Hii, CallbackInfo->RegisteredHandle);
NetFreePool (CallbackInfo);
NetFreePool (mCallbackInfo);
return EFI_SUCCESS;
}

View File

@@ -21,12 +21,17 @@ Abstract:
#ifndef _ISCSI_CONFIG_H_
#define _ISCSI_CONFIG_H_
#include <Library/FrameworkHiiLib.h>
#include <Protocol/FrameworkFormBrowser.h>
#include <Protocol/FrameworkFormCallback.h>
#include <Library/FrameworkIfrSupportLib.h>
//#include "Tiano.h"
//#include "EfiDriverLib.h"
//#include "Base.h"
#include <Library/HiiLib.h>
#include <Library/IfrSupportLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
//#include "EfiPrintLib.h"
//#include EFI_PROTOCOL_DEFINITION (Hii)
//#include EFI_PROTOCOL_DEFINITION (FormBrowser)
//#include EFI_PROTOCOL_DEFINITION (FormCallback)
#include <Library/NetLib.h>
#include "IScsiConfigNVDataStruc.h"
@@ -44,7 +49,7 @@ extern UINT8 iSCSIStrings[];
CR ( \
Callback, \
ISCSI_FORM_CALLBACK_INFO, \
FormCallback, \
ConfigAccess, \
ISCSI_FORM_CALLBACK_INFO_SIGNATURE \
)
@@ -74,14 +79,15 @@ typedef struct _ISCSI_CONFIG_FORM_ENTRY {
} ISCSI_CONFIG_FORM_ENTRY;
typedef struct _ISCSI_FORM_CALLBACK_INFO {
UINTN Signature;
EFI_HANDLE CallbackHandle;
EFI_FORM_CALLBACK_PROTOCOL FormCallback;
UINT16 *KeyList;
VOID *FormBuffer;
EFI_HII_HANDLE RegisteredHandle;
EFI_HII_PROTOCOL *Hii;
ISCSI_CONFIG_FORM_ENTRY *Current;
UINTN Signature;
EFI_HANDLE DriverHandle;
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
UINT16 *KeyList;
VOID *FormBuffer;
EFI_HII_HANDLE RegisteredHandle;
ISCSI_CONFIG_FORM_ENTRY *Current;
} ISCSI_FORM_CALLBACK_INFO;
EFI_STATUS

View File

@@ -22,6 +22,8 @@
#include "IScsiConfigNVDataStruc.h"
#define EFI_NETWORK_DEVICE_CLASS 0x04
#define LABEL_END 0xffff
formset
guid = ISCSI_CONFIG_GUID,
title = STRING_TOKEN(STR_ISCSI_CONFIG_FORM_TITLE),
@@ -29,8 +31,11 @@ formset
class = EFI_NETWORK_DEVICE_CLASS,
subclass = 0x03,
varstore ISCSI_CONFIG_IFR_NVDATA,
name = ISCSI_CONFIG_IFR_NVDATA,
guid = ISCSI_CONFIG_GUID;
form formid = FORMID_MAIN_FORM,
title = STRING_TOKEN(STR_ISCSI_MAIN_FORM_TITLE); // note formid is a variable (for readability) (UINT16) - also added Form to the line to signify the Op-Code
title = STRING_TOKEN(STR_ISCSI_MAIN_FORM_TITLE);
string varid = ISCSI_CONFIG_IFR_NVDATA.InitiatorName,
prompt = STRING_TOKEN(STR_ISCSI_CONFIG_INIT_NAME),
@@ -42,6 +47,7 @@ formset
endstring;
label DEVICE_ENTRY_LABEL;
label LABEL_END;
endform;

View File

@@ -55,19 +55,19 @@ Abstract:
#define DEVICE_ENTRY_LABEL 0x1234
#define KEY_INITIATOR_NAME 0x01
#define KEY_DHCP_ENABLE 0x02
#define KEY_LOCAL_IP 0x03
#define KEY_SUBNET_MASK 0x04
#define KEY_GATE_WAY 0x05
#define KEY_TARGET_IP 0x06
#define KEY_CHAP_NAME 0x07
#define KEY_CHAP_SECRET 0x08
#define KEY_REVERSE_CHAP_NAME 0x09
#define KEY_REVERSE_CHAP_SECRET 0x0a
#define KEY_SAVE_CHANGES 0x0b
#define KEY_TARGET_NAME 0x0c
#define KEY_BOOT_LUN 0x0d
#define KEY_INITIATOR_NAME 0x101
#define KEY_DHCP_ENABLE 0x102
#define KEY_LOCAL_IP 0x103
#define KEY_SUBNET_MASK 0x104
#define KEY_GATE_WAY 0x105
#define KEY_TARGET_IP 0x106
#define KEY_CHAP_NAME 0x107
#define KEY_CHAP_SECRET 0x108
#define KEY_REVERSE_CHAP_NAME 0x109
#define KEY_REVERSE_CHAP_SECRET 0x10a
#define KEY_SAVE_CHANGES 0x10b
#define KEY_TARGET_NAME 0x10c
#define KEY_BOOT_LUN 0x10d
#define KEY_DEVICE_ENTRY_BASE 0x1000

View File

@@ -230,9 +230,9 @@ Returns:
Status = This->Parse (This, Packet, &OptionCount, NULL);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_NOT_READY;
return EFI_NOT_READY;
}
OptionList = NetAllocatePool (OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));
if (OptionList == NULL) {
@@ -437,7 +437,7 @@ Returns:
//
// Ask the server to reply with Netmask, Router, DNS and RootPath options.
//
ParaList->Length = (UINT8)(ConfigData->NvData.TargetInfoFromDhcp ? 4 : 3);
ParaList->OpCode = DHCP4_TAG_PARA_LIST;
ParaList->Length = ConfigData->NvData.TargetInfoFromDhcp ? 4 : 3;
ParaList->Data[0] = DHCP4_TAG_NETMASK;
ParaList->Data[1] = DHCP4_TAG_ROUTER;

View File

@@ -20,7 +20,9 @@ Abstract:
#ifndef _ISCSI_DHCP_H_
#define _ISCSI_DHCP_H_
#include <Protocol/Dhcp4.h>
//#include "Tiano.h"
//#include EFI_PROTOCOL_CONSUMER (Dhcp4)
#include "protocol\Dhcp4.h"
#define DHCP4_TAG_PARA_LIST 55
#define DHCP4_TAG_NETMASK 1

View File

@@ -101,7 +101,7 @@ Returns:
// Need expand the control section if more than 2 NIC/Target sections
// exist.
//
Control->Header.Length = (UINT16)(Control->Header.Length + (NumOffset - 4) * sizeof (UINT16));
Control->Header.Length += (UINT16) (NumOffset - 4) * sizeof (UINT16);
}
}
@@ -191,7 +191,7 @@ Returns:
//
// Get the identifier from the handle.
//
Status = gBS->HandleProtocol (Handle, &mIScsiPrivateGuid, (void **)&IScsiIdentifier);
Status = gBS->HandleProtocol (Handle, &mIScsiPrivateGuid, &IScsiIdentifier);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return ;
@@ -278,7 +278,7 @@ Returns:
Status = gBS->HandleProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
(void **)&DevicePath
&DevicePath
);
if (EFI_ERROR (Status)) {
return 0;
@@ -293,7 +293,7 @@ Returns:
return 0;
}
Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, (void **)&PciIo);
Status = gBS->HandleProtocol (PciIoHandle, &gEfiPciIoProtocolGuid, &PciIo);
if (EFI_ERROR (Status)) {
return 0;
}
@@ -333,7 +333,7 @@ Returns:
Status = gBS->HandleProtocol (
Controller,
&gEfiSimpleNetworkProtocolGuid,
(void **)&Snp
&Snp
);
ASSERT_EFI_ERROR (Status);
@@ -392,7 +392,7 @@ Returns:
SectionOffset = &Control->NIC0Offset;
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (Handles[Index], &mIScsiPrivateGuid, (void **)&IScsiIdentifier);
Status = gBS->HandleProtocol (Handles[Index], &mIScsiPrivateGuid, &IScsiIdentifier);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return ;
@@ -552,7 +552,7 @@ Returns:
EFI_ACPI_TABLE_VERSION Version;
UINT32 Signature;
Status = gBS->LocateProtocol (&gEfiAcpiSupportProtocolGuid, NULL, (void **)&AcpiSupport);
Status = gBS->LocateProtocol (&gEfiAcpiSupportProtocolGuid, NULL, &AcpiSupport);
if (EFI_ERROR (Status)) {
return ;
}
@@ -563,7 +563,7 @@ Returns:
Status = AcpiSupport->GetAcpiTable (
AcpiSupport,
Index,
(void **)&Table,
&Table,
&Version,
&TableHandle
);
@@ -613,7 +613,7 @@ Returns:
return ;
}
Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET;
Heap = (CHAR8 *) Table + IBFT_HEAP_OFFSET;
//
// Fill in the various section of the iSCSI Boot Firmware Table.

View File

@@ -37,7 +37,7 @@ Abstract:
#define ISCSI_SESSION_SIGNATURE EFI_SIGNATURE_32 ('I', 'S', 'S', 'N')
struct _ISCSI_SESSION {
typedef struct _ISCSI_SESSION {
UINT32 Signature;
ISCSI_SESSION_CONFIG_DATA ConfigData;
@@ -77,11 +77,11 @@ struct _ISCSI_SESSION {
BOOLEAN DataPDUInOrder;
BOOLEAN DataSequenceInOrder;
UINT8 ErrorRecoveryLevel;
};
} ISCSI_SESSION;
#define ISCSI_CONNECTION_SIGNATURE EFI_SIGNATURE_32 ('I', 'S', 'C', 'N')
struct _ISCSI_CONNECTION {
typedef struct _ISCSI_CONNECTION {
UINT32 Signature;
NET_LIST_ENTRY Link;
@@ -116,7 +116,7 @@ struct _ISCSI_CONNECTION {
UINT32 MaxRecvDataSegmentLength;
ISCSI_DIGEST_TYPE HeaderDigest;
ISCSI_DIGEST_TYPE DataDigest;
};
} ISCSI_CONNECTION;
#define ISCSI_DRIVER_DATA_SIGNATURE EFI_SIGNATURE_32 ('I', 'S', 'D', 'A')
@@ -142,7 +142,7 @@ struct _ISCSI_CONNECTION {
ISCSI_DRIVER_DATA_SIGNATURE \
)
struct _ISCSI_DRIVER_DATA {
typedef struct _ISCSI_DRIVER_DATA {
UINT32 Signature;
EFI_HANDLE Image;
EFI_HANDLE Controller;
@@ -156,6 +156,6 @@ struct _ISCSI_DRIVER_DATA {
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
ISCSI_SESSION Session;
};
} ISCSI_DRIVER_DATA;
#endif

View File

@@ -167,7 +167,7 @@ Returns:
Len++;
}
return (UINT8)(32 - Len);
return 32 - Len;
}
EFI_STATUS
@@ -196,7 +196,6 @@ Returns:
UINT32 Index;
CHAR8 *LunUnitStr[4];
CHAR8 Digit;
UINTN Temp;
NetZeroMem (Lun, 8);
NetZeroMem (LunUnitStr, sizeof (LunUnitStr));
@@ -204,7 +203,7 @@ Returns:
Index = 0;
LunUnitStr[0] = Str;
if (!IsHexDigit ((UINT8 *)&Digit, *Str)) {
if (!IsHexDigit (&Digit, *Str)) {
return EFI_INVALID_PARAMETER;
}
@@ -220,13 +219,13 @@ Returns:
Index++;
if (*(Str + 1) != '\0') {
if (!IsHexDigit ((UINT8 *)&Digit, *(Str + 1))) {
if (!IsHexDigit (&Digit, *(Str + 1))) {
return EFI_INVALID_PARAMETER;
}
LunUnitStr[Index] = Str + 1;
}
} else if (!IsHexDigit ((UINT8 *)&Digit, *Str)) {
} else if (!IsHexDigit (&Digit, *Str)) {
return EFI_INVALID_PARAMETER;
}
@@ -238,8 +237,7 @@ Returns:
return EFI_INVALID_PARAMETER;
}
Temp = AsciiStrHexToUintn (LunUnitStr[Index]);
*((UINT16 *) &Lun[Index * 2]) = HTONS (Temp);
*((UINT16 *) &Lun[Index * 2]) = HTONS (AsciiStrHexToUintn (LunUnitStr[Index]));
}
return EFI_SUCCESS;
@@ -472,7 +470,7 @@ Returns:
UINT32 Index;
for (Index = 0; Index < Len; Index++) {
Str[3 * Index] = NibbleToHexChar ((UINT8)(Mac->Addr[Index] >> 4));
Str[3 * Index] = NibbleToHexChar (Mac->Addr[Index] >> 4);
Str[3 * Index + 1] = NibbleToHexChar (Mac->Addr[Index]);
Str[3 * Index + 2] = L'-';
}
@@ -602,7 +600,7 @@ Returns:
} else {
Byte = BinBuffer[*BinLength - 1 - Index / 2];
Byte &= 0x0F;
Byte = (UINT8)(Byte | (Digit << 4));
Byte |= Digit << 4;
}
BinBuffer[*BinLength - 1 - Index / 2] = Byte;
@@ -811,7 +809,7 @@ Returns:
Status = gBS->HandleProtocol (
Private->Controller,
&gEfiSimpleNetworkProtocolGuid,
(void **)&Snp
&Snp
);
if (EFI_ERROR (Status)) {
return Status;
@@ -907,7 +905,7 @@ Returns:
Status = gBS->HandleProtocol (
Tcp4Io->Handle,
&gEfiDevicePathProtocolGuid,
(void **)&DevicePath
&DevicePath
);
if (EFI_ERROR (Status)) {
return NULL;
@@ -925,7 +923,7 @@ Returns:
) {
DPathNode->Ipv4.LocalPort = 0;
DPathNode->Ipv4.StaticIpAddress = (BOOLEAN)(!Session->ConfigData.NvData.InitiatorInfoFromDhcp);
DPathNode->Ipv4.StaticIpAddress = !Session->ConfigData.NvData.InitiatorInfoFromDhcp;
break;
}

View File

@@ -546,7 +546,7 @@ Returns:
//
// Allocate the space for the key-value pair.
//
Data = (CHAR8 *) NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
Data = NetbufAllocSpace (Pdu, TotalLen, NET_BUF_TAIL);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -668,7 +668,7 @@ Returns:
//
// Check whether we will issue the stage transition signal?
//
Conn->TransitInitiated = (BOOLEAN)ISCSI_FLAG_ON (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
Conn->TransitInitiated = ISCSI_FLAG_ON (LoginReq, ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT);
}
return Nbuf;
@@ -746,7 +746,7 @@ Returns:
// Process the TargetAddress key-value strings in the data segment to update the
// target address info.
//
Status = IScsiUpdateTargetAddress (Session, (CHAR8 *)DataSeg, DataSegLen);
Status = IScsiUpdateTargetAddress (Session, DataSeg, DataSegLen);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -765,11 +765,11 @@ Returns:
//
// The status is sucess, extract the wanted fields from the header segment.
//
Transit = (BOOLEAN)ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT);
Continue = (BOOLEAN)ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE);
Transit = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT);
Continue = ISCSI_FLAG_ON (LoginRsp, ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE);
CurrentStage = (UINT8)ISCSI_GET_CURRENT_STAGE (LoginRsp);
NextStage = (UINT8)ISCSI_GET_NEXT_STAGE (LoginRsp);
CurrentStage = ISCSI_GET_CURRENT_STAGE (LoginRsp);
NextStage = ISCSI_GET_NEXT_STAGE (LoginRsp);
LoginRsp->InitiatorTaskTag = NTOHL (LoginRsp->InitiatorTaskTag);
@@ -1283,7 +1283,7 @@ Returns:
return EFI_OUT_OF_RESOURCES;
}
NetbufQueCopy (&Conn->RspQue, 0, Len, (UINT8 *)Data);
NetbufQueCopy (&Conn->RspQue, 0, Len, Data);
Status = EFI_PROTOCOL_ERROR;
@@ -1352,7 +1352,7 @@ Returns:
goto ON_ERROR;
}
Session->InitialR2T = (BOOLEAN)(Session->InitialR2T || (AsciiStrCmp (Value, "Yes") == 0));
Session->InitialR2T = Session->InitialR2T || (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
//
// ImmediateData, result function is AND.
@@ -1362,7 +1362,7 @@ Returns:
goto ON_ERROR;
}
Session->ImmediateData = (BOOLEAN)(Session->ImmediateData && (AsciiStrCmp (Value, "Yes") == 0));
Session->ImmediateData = Session->ImmediateData && (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
//
// MaxRecvDataSegmentLength, result function is Mininum.
@@ -1422,7 +1422,7 @@ Returns:
goto ON_ERROR;
}
Session->DataPDUInOrder = (BOOLEAN)(Session->DataPDUInOrder || (AsciiStrCmp (Value, "Yes") == 0));
Session->DataPDUInOrder = Session->DataPDUInOrder || (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
//
// DataSequenceInorder, result function is OR.
@@ -1432,7 +1432,7 @@ Returns:
goto ON_ERROR;
}
Session->DataSequenceInOrder = (BOOLEAN)(Session->DataSequenceInOrder || (AsciiStrCmp (Value, "Yes") == 0));
Session->DataSequenceInOrder = Session->DataSequenceInOrder || (BOOLEAN) (AsciiStrCmp (Value, "Yes") == 0);
//
// DefaultTime2Wait, result function is Maximum.
@@ -1799,7 +1799,7 @@ Returns:
//
// Convert the upper-case characters to lower-case ones
//
Name[Index] = (CHAR8)(Name[Index] - 'A' + 'a');
Name[Index] = Name[Index] - 'A' + 'a';
}
if (!NET_IS_LOWER_CASE_CHAR (Name[Index]) &&
@@ -2048,7 +2048,7 @@ Returns:
//
// The CDB exceeds 16 bytes, an extended CDB AHS is required.
//
AHSLength = (UINT8)(AHSLength + (ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER)));
AHSLength += ISCSI_ROUNDUP (Packet->CdbLength - 16) + sizeof (ISCSI_ADDITIONAL_HEADER);
}
Length = sizeof (SCSI_COMMAND) + AHSLength;
@@ -2769,7 +2769,6 @@ Returns:
UINT8 *Data;
ISCSI_IN_BUFFER_CONTEXT InBufferContext;
UINT64 Timeout;
UINT8 *Buffer;
Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
Session = &Private->Session;
@@ -2815,8 +2814,7 @@ Returns:
}
XferContext = &Tcb->XferContext;
Buffer = NetbufGetByte (Pdu, 0, NULL);
XferContext->Offset = ISCSI_GET_DATASEG_LEN (Buffer);
XferContext->Offset = ISCSI_GET_DATASEG_LEN (NetbufGetByte (Pdu, 0, NULL));
//
// Transmit the SCSI Command PDU.

View File

@@ -119,8 +119,8 @@ typedef enum {
#define ISCSI_IMMEDIATE_ON(PduHdr) ((PduHdr)->OpCode & ISCSI_REQ_IMMEDIATE)
#define ISCSI_SET_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags |= (Flag))
#define ISCSI_CLEAR_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags &= ~(Flag))
#define ISCSI_FLAG_ON(PduHdr, Flag) ((((ISCSI_BASIC_HEADER *) (PduHdr))->Flags & (Flag)) == (BOOLEAN)(Flag))
#define ISCSI_SET_STAGES(PduHdr, Cur, Nxt) ((PduHdr)->Flags = (UINT8)(((PduHdr)->Flags)|(((Cur) << 2) | (Nxt))))
#define ISCSI_FLAG_ON(PduHdr, Flag) ((((ISCSI_BASIC_HEADER *) (PduHdr))->Flags & (Flag)) == (Flag))
#define ISCSI_SET_STAGES(PduHdr, Cur, Nxt) ((PduHdr)->Flags |= ((Cur) << 2 | (Nxt)))
#define ISCSI_GET_CURRENT_STAGE(PduHdr) (((PduHdr)->Flags >> 2) & 0x3)
#define ISCSI_GET_NEXT_STAGE(PduHdr) (((PduHdr)->Flags) & 0x3)
@@ -129,9 +129,9 @@ typedef enum {
#define HTON24(Dst, Src) \
do { \
(Dst)[0] = (UINT8)(((Src) >> 16) & 0xFF); \
(Dst)[1] = (UINT8)(((Src) >> 8) & 0xFF); \
(Dst)[2] = (UINT8)((Src) & 0xFF); \
(Dst)[0] = (UINT8) ((Src) >> 16) & 0xFF; \
(Dst)[1] = (UINT8) ((Src) >> 8) & 0xFF; \
(Dst)[2] = (UINT8) (Src) & 0xFF; \
} while (0);
#define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))