NetworkPkg: Add dns support for target URL configuration in ISCSI.

v2:
*1. Add IScsiDnsIsConfigured function in IScsiSupported to check
attempt using DNS protocol or not.2. Fix wrongs typos in IScsiDns.c
and .uni file.3. define a macro for the length of target URL.4.
update the Copyright to 2017.

Add DNS support for target URL directly configuration in UI.

Besides, When we enable the option (Get target info via DHCP) ,
the dhcp server will return target info include the  rootpath,
like the format
"iscsi:"<servername>":"<protocol>":"<port>":"<LUN>":"<targetname>
According to the RFC 4173,the server name region is expressed as
IPv4(192.168.10.20 )or IPv6 ([2000:bbbb::3]) or domain name,
but currently we only support the IP address format.
To enable this feature, we can support both.

Another enhancement is that we can deal with the data received from
the iSCSI login response with an target redirection status,
in which contains the Target Address in the format
domainname[:port][,portal-group-tag] required by RFC 3720.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
This commit is contained in:
Zhang Lubo
2016-12-08 19:26:24 +08:00
committed by Jiaxin Wu
parent a409875592
commit eabc6e59b9
14 changed files with 794 additions and 73 deletions

View File

@@ -1,7 +1,7 @@
/** @file
Miscellaneous routines for iSCSI driver.
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
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
@@ -1001,6 +1001,94 @@ IScsiDhcpIsConfigured (
return FALSE;
}
/**
Check wheather the Controller handle is configured to use DNS protocol.
@param[in] Controller The handle of the controller.
@retval TRUE The handle of the controller need the Dns protocol.
@retval FALSE The handle of the controller does not need the Dns protocol.
**/
BOOLEAN
IScsiDnsIsConfigured (
IN EFI_HANDLE Controller
)
{
ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptTmp;
UINT8 *AttemptConfigOrder;
UINTN AttemptConfigOrderSize;
UINTN Index;
EFI_STATUS Status;
EFI_MAC_ADDRESS MacAddr;
UINTN HwAddressSize;
UINT16 VlanId;
CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
CHAR16 AttemptName[ISCSI_NAME_IFR_MAX_SIZE];
AttemptConfigOrder = IScsiGetVariableAndSize (
L"AttemptOrder",
&gIScsiConfigGuid,
&AttemptConfigOrderSize
);
if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {
return FALSE;
}
//
// Get MAC address of this network device.
//
Status = NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize);
if(EFI_ERROR (Status)) {
return FALSE;
}
//
// Get VLAN ID of this network device.
//
VlanId = NetLibGetVlanId (Controller);
IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);
for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
UnicodeSPrint (
AttemptName,
(UINTN) 128,
L"%s%d",
MacString,
(UINTN) AttemptConfigOrder[Index]
);
Status = GetVariable2 (
AttemptName,
&gEfiIScsiInitiatorNameProtocolGuid,
(VOID**)&AttemptTmp,
NULL
);
if(AttemptTmp == NULL || EFI_ERROR (Status)) {
continue;
}
ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);
if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {
FreePool (AttemptTmp);
continue;
}
if (AttemptTmp->SessionConfigData.DnsMode) {
FreePool (AttemptTmp);
FreePool (AttemptConfigOrder);
return TRUE;
} else {
FreePool (AttemptTmp);
continue;
}
}
FreePool (AttemptConfigOrder);
return FALSE;
}
/**
Get the various configuration data.