From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3137081E0E for ; Tue, 17 Jan 2017 20:34:19 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 17 Jan 2017 20:34:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,247,1477983600"; d="scan'208";a="1114260324" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 17 Jan 2017 20:34:18 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 17 Jan 2017 20:34:18 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 17 Jan 2017 20:34:17 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Wed, 18 Jan 2017 12:34:13 +0800 From: "Wu, Jiaxin" To: "Zhang, Lubo" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [PATCH V2] NetworkPkg: Add dns support for target URL configuration in ISCSI. Thread-Index: AQHSa+HfNAdGVg2a40upx3Khf8ebzKE9sEOg Date: Wed, 18 Jan 2017 04:34:13 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416294A4D@SHSMSX103.ccr.corp.intel.com> References: <1484122079-3996-1-git-send-email-lubo.zhang@intel.com> In-Reply-To: <1484122079-3996-1-git-send-email-lubo.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmNmOTZmYzItYjM5OC00MDc3LWI0NzgtMWRlNGM5OGQyYTAyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ijg2Z1E4SVwvZ0s3bm1MZlVucGpvcTZSaEZSdG5CcGZmeGdXQktYUzlUcEl3PSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V2] NetworkPkg: Add dns support for target URL configuration in ISCSI. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jan 2017 04:34:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin Thanks, Jiaxin > -----Original Message----- > From: Zhang, Lubo > Sent: Wednesday, January 11, 2017 4:08 PM > To: edk2-devel@lists.01.org > Cc: Ye, Ting ; Fu, Siyuan ; Wu, J= iaxin > > Subject: [PATCH V2] NetworkPkg: Add dns support for target URL configurat= ion > in ISCSI. >=20 > 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. >=20 > Add DNS support for target URL directly configuration in UI. >=20 > 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:"":"":"":"":" > 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. >=20 > 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. >=20 > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Wu Jiaxin > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Zhang Lubo > --- > NetworkPkg/IScsiDxe/IScsiConfig.c | 78 +++-- > NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h | 10 +- > NetworkPkg/IScsiDxe/IScsiConfigStrings.uni | 5 +- > NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr | 10 +- > NetworkPkg/IScsiDxe/IScsiDhcp.c | 23 +- > NetworkPkg/IScsiDxe/IScsiDhcp6.c | 25 +- > NetworkPkg/IScsiDxe/IScsiDns.c | 435 > +++++++++++++++++++++++++++ > NetworkPkg/IScsiDxe/IScsiDns.h | 59 ++++ > NetworkPkg/IScsiDxe/IScsiDriver.c | 22 +- > NetworkPkg/IScsiDxe/IScsiDxe.inf | 22 +- > NetworkPkg/IScsiDxe/IScsiImpl.h | 8 +- > NetworkPkg/IScsiDxe/IScsiMisc.c | 90 +++++- > NetworkPkg/IScsiDxe/IScsiMisc.h | 21 +- > NetworkPkg/IScsiDxe/IScsiProto.c | 59 +++- > 14 files changed, 794 insertions(+), 73 deletions(-) > create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.c > create mode 100644 NetworkPkg/IScsiDxe/IScsiDns.h >=20 > diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c > b/NetworkPkg/IScsiDxe/IScsiConfig.c > index 57571ad..40ea75a 100644 > --- a/NetworkPkg/IScsiDxe/IScsiConfig.c > +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c > @@ -1,9 +1,9 @@ > /** @file > Helper functions for configuring or getting the parameters relating to= iSCSI. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -364,17 +364,19 @@ IScsiConvertAttemptConfigDataToIfrNvData ( > ) > { > ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData; > ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData; > EFI_IP_ADDRESS Ip; > + BOOLEAN DnsMode; >=20 > // > // Normal session configuration parameters. > // > SessionConfigData =3D &Attempt->SessionConfigData; > IfrNvData->Enabled =3D SessionConfigData->Enabled; > IfrNvData->IpMode =3D SessionConfigData->IpMode; > + DnsMode =3D SessionConfigData->DnsMode; >=20 > IfrNvData->InitiatorInfoFromDhcp =3D SessionConfigData- > >InitiatorInfoFromDhcp; > IfrNvData->TargetInfoFromDhcp =3D SessionConfigData- > >TargetInfoFromDhcp; > IfrNvData->TargetPort =3D SessionConfigData->TargetPort; >=20 > @@ -383,23 +385,37 @@ IScsiConvertAttemptConfigDataToIfrNvData ( > IScsiIpToStr (&Ip, FALSE, IfrNvData->LocalIp); > CopyMem (&Ip.v4, &SessionConfigData->SubnetMask, sizeof > (EFI_IPv4_ADDRESS)); > IScsiIpToStr (&Ip, FALSE, IfrNvData->SubnetMask); > CopyMem (&Ip.v4, &SessionConfigData->Gateway, sizeof > (EFI_IPv4_ADDRESS)); > IScsiIpToStr (&Ip, FALSE, IfrNvData->Gateway); > - CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof > (EFI_IPv4_ADDRESS)); > - IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp); > + if (SessionConfigData->TargetIp.v4.Addr[0] !=3D '\0') { > + CopyMem (&Ip.v4, &SessionConfigData->TargetIp, sizeof > (EFI_IPv4_ADDRESS)); > + IScsiIpToStr (&Ip, FALSE, IfrNvData->TargetIp); > + } > + > } else if (IfrNvData->IpMode =3D=3D IP_MODE_IP6) { > ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); > - IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp); > - IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp); > + if (SessionConfigData->TargetIp.v6.Addr[0] !=3D '\0') { > + IP6_COPY_ADDRESS (&Ip.v6, &SessionConfigData->TargetIp); > + IScsiIpToStr (&Ip, TRUE, IfrNvData->TargetIp); > + } > } >=20 > AsciiStrToUnicodeStrS ( > SessionConfigData->TargetName, > IfrNvData->TargetName, > sizeof (IfrNvData->TargetName) / sizeof (IfrNvData->TargetName[0]) > ); > + > + if (DnsMode) { > + AsciiStrToUnicodeStrS ( > + SessionConfigData->TargetUrl, > + IfrNvData->TargetIp, > + sizeof (IfrNvData->TargetIp) / sizeof (IfrNvData->TargetIp[0]) > + ); > + } > + > IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun); > IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId); >=20 > IfrNvData->ConnectRetryCount =3D SessionConfigData->ConnectRetryCount; > IfrNvData->ConnectTimeout =3D SessionConfigData->ConnectTimeout; > @@ -557,18 +573,30 @@ IScsiConvertIfrNvDataToAttemptConfigData ( > } > // > // Validate target configuration if DHCP isn't deployed. > // > if (!Attempt->SessionConfigData.TargetInfoFromDhcp && Attempt- > >SessionConfigData.IpMode < IP_MODE_AUTOCONFIG) { > - if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvData- > >IpMode)) { > - CreatePopUp ( > - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > - &Key, > - L"Target IP is invalid!", > - NULL > - ); > - return EFI_INVALID_PARAMETER; > + if (!Attempt->SessionConfigData.DnsMode) { > + if (!IpIsUnicast (&Attempt->SessionConfigData.TargetIp, IfrNvDat= a- > >IpMode)) { > + CreatePopUp ( > + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > + &Key, > + L"Target IP is invalid!", > + NULL > + ); > + return EFI_INVALID_PARAMETER; > + } > + } else { > + if (Attempt->SessionConfigData.TargetUrl[0] =3D=3D '\0') { > + CreatePopUp ( > + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > + &Key, > + L"iSCSI target Url should not be NULL!", > + NULL > + ); > + return EFI_INVALID_PARAMETER; > + } > } >=20 > // > // Validate iSCSI target name configuration again: > // The format of iSCSI target name is already verified in IScsiFor= mCallback() > when > @@ -2134,11 +2162,11 @@ IScsiFormCallback ( > ) > { > ISCSI_FORM_CALLBACK_INFO *Private; > UINTN BufferSize; > CHAR8 *IScsiName; > - CHAR8 IpString[IP_STR_MAX_SIZE]; > + CHAR8 IpString[ISCSI_NAME_MAX_SIZE]; > CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN]; > UINT64 Lun; > EFI_IP_ADDRESS HostIp; > EFI_IP_ADDRESS SubnetMask; > EFI_IP_ADDRESS Gateway; > @@ -2333,18 +2361,12 @@ IScsiFormCallback ( > break; >=20 > case KEY_IP_MODE: > switch (Value->u8) { > case IP_MODE_IP6: > - ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); > - IScsiIpToStr (&Private->Current->SessionConfigData.TargetIp, TRU= E, > IfrNvData->TargetIp); > - Private->Current->AutoConfigureMode =3D 0; > - break; > - > case IP_MODE_IP4: > ZeroMem (IfrNvData->TargetIp, sizeof (IfrNvData->TargetIp)); > - IScsiIpToStr (&Private->Current->SessionConfigData.TargetIp, FAL= SE, > IfrNvData->TargetIp); > Private->Current->AutoConfigureMode =3D 0; >=20 > break; > } >=20 > @@ -2406,19 +2428,19 @@ IScsiFormCallback ( > break; >=20 > case KEY_TARGET_IP: > UnicodeStrToAsciiStrS (IfrNvData->TargetIp, IpString, sizeof (IpSt= ring)); > Status =3D IScsiAsciiStrToIp (IpString, IfrNvData->IpMode, &HostIp= ); > - if (EFI_ERROR (Status) || IP4_IS_LOCAL_BROADCAST > (EFI_NTOHL(HostIp.v4)) || IP4_IS_UNSPECIFIED (EFI_NTOHL(HostIp.v4))) { > - CreatePopUp ( > - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, > - &Key, > - L"Invalid IP address!", > - NULL > - ); > - Status =3D EFI_INVALID_PARAMETER; > + if (EFI_ERROR (Status) || !IpIsUnicast (&HostIp, IfrNvData->IpMode= )) { > + // > + // The target is expressed in URL format or an invalid Ip address,= just save. > + // > + Private->Current->SessionConfigData.DnsMode =3D TRUE; > + ZeroMem (&Private->Current->SessionConfigData.TargetIp, sizeof > (Private->Current->SessionConfigData.TargetIp)); > + UnicodeStrToAsciiStrS (IfrNvData->TargetIp, Private->Current- > >SessionConfigData.TargetUrl, ISCSI_NAME_MAX_SIZE); > } else { > + Private->Current->SessionConfigData.DnsMode =3D FALSE; > CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp, > sizeof (HostIp)); > } >=20 > break; >=20 > diff --git a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h > b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h > index 56ebb50..5f22767 100644 > --- a/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h > +++ b/NetworkPkg/IScsiDxe/IScsiConfigNVDataStruc.h > @@ -1,9 +1,9 @@ > /** @file > Define NVData structures used by the iSCSI configuration component. >=20 > -Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -133,10 +133,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, EITHER EXPRESS OR IMPLIED. >=20 > #define ISID_CONFIGURABLE_MIN_LEN 6 > #define ISID_CONFIGURABLE_MAX_LEN 12 > #define ISID_CONFIGURABLE_STORAGE 13 >=20 > +/// > +/// Macro used for target Url. > +/// > +#define ISCSI_TARGET_URI_MIN_SIZE 0 > +#define ISCSI_TARGET_URI_MAX_SIZE 255 > + > #pragma pack(1) > typedef struct _ISCSI_CONFIG_IFR_NVDATA { > CHAR16 InitiatorName[ISCSI_NAME_MAX_SIZE]; > CHAR16 AttemptName[ATTEMPT_NAME_MAX_SIZE]; >=20 > @@ -152,11 +158,11 @@ typedef struct _ISCSI_CONFIG_IFR_NVDATA { > CHAR16 LocalIp[IP4_STR_MAX_SIZE]; > CHAR16 SubnetMask[IP4_STR_MAX_SIZE]; > CHAR16 Gateway[IP4_STR_MAX_SIZE]; >=20 > CHAR16 TargetName[ISCSI_NAME_MAX_SIZE]; > - CHAR16 TargetIp[IP_STR_MAX_SIZE]; > + CHAR16 TargetIp[ISCSI_TARGET_URI_MAX_SIZE]; > UINT16 TargetPort; > CHAR16 BootLun[ISCSI_LUN_STR_MAX_LEN]; >=20 > UINT8 AuthenticationType; >=20 > diff --git a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni > b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni > index 7a80fab..11e8b09 100644 > --- a/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni > +++ b/NetworkPkg/IScsiDxe/IScsiConfigStrings.uni > @@ -1,8 +1,8 @@ > // *++ > // > -// Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved. > +// Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. > // 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 ma= y be > found at > // http://opensource.org/licenses/bsd-license.php > // > @@ -61,11 +61,12 @@ > #string STR_ISCSI_LOCAL_MASK #language en-US " Initiator Sub= net > Mask" > #string STR_ISCSI_LOCAL_GATEWAY #language en-US " Gateway" > #string STR_ISCSI_IP_ADDRESS_HELP #language en-US "Enter IP addres= s in > dotted-decimal notation." > #string STR_ISCSI_TARGET_NAME #language en-US " Target Name" > #string STR_ISCSI_TARGET_NAME_HELP #language en-US "The worldwide > unique name of the target. Only iqn. format is accepted." > -#string STR_ISCSI_TARGET_IP_ADDRESS #language en-US " Target IP > Address" > +#string STR_ISCSI_TARGET_ADDRESS #language en-US " Target Addres= s" > +#string STR_ISCSI_TARGET_ADDRESS_HELP #language en-US "Enter Target > address in IPv4,IPv6 or URL format.You need to configure DNS server addre= ss in > advance if input a URL string." > #string STR_ISCSI_TARGET_PORT #language en-US " Target Port" > #string STR_ISCSI_BOOT_LUN #language en-US " Boot LUN" > #string STR_ISCSI_BOOT_LUN_HELP #language en-US "Hexadecimal > representation of the LU number. Examples are: 4752-3A4F-6b7e-2F99, 6734-= 9- > 156f-127, 4186-9" > #string STR_ISCSI_ENABLE_DHCP #language en-US "Enable DHCP" > #string STR_ISCSI_ENABLE_DHCP_ON_TARGET #language en-US "Get target > info via DHCP" > diff --git a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr > b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr > index db77c0f..c469a78 100644 > --- a/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr > +++ b/NetworkPkg/IScsiDxe/IScsiConfigVfr.vfr > @@ -1,9 +1,9 @@ > /** @file > VFR file used by the iSCSI configuration component. >=20 > -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -247,16 +247,16 @@ formset > minsize =3D ISCSI_NAME_IFR_MIN_SIZE, > maxsize =3D ISCSI_NAME_IFR_MAX_SIZE, > endstring; >=20 > string varid =3D ISCSI_CONFIG_IFR_NVDATA.TargetIp, > - prompt =3D STRING_TOKEN(STR_ISCSI_TARGET_IP_ADDRESS), > - help =3D STRING_TOKEN(STR_ISCSI_IP_ADDRESS_HELP), > + prompt =3D STRING_TOKEN(STR_ISCSI_TARGET_ADDRESS), > + help =3D STRING_TOKEN(STR_ISCSI_TARGET_ADDRESS_HELP), > flags =3D INTERACTIVE, > key =3D KEY_TARGET_IP, > - minsize =3D IP_MIN_SIZE, > - maxsize =3D IP_MAX_SIZE, > + minsize =3D ISCSI_TARGET_URI_MIN_SIZE, > + maxsize =3D ISCSI_TARGET_URI_MAX_SIZE, > endstring; >=20 > numeric varid =3D ISCSI_CONFIG_IFR_NVDATA.TargetPort, > prompt =3D STRING_TOKEN(STR_ISCSI_TARGET_PORT), > help =3D STRING_TOKEN(STR_ISCSI_TARGET_PORT), > diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp.c b/NetworkPkg/IScsiDxe/IScsiD= hcp.c > index 0e42805..43ae50b 100644 > --- a/NetworkPkg/IScsiDxe/IScsiDhcp.c > +++ b/NetworkPkg/IScsiDxe/IScsiDhcp.c > @@ -1,9 +1,9 @@ > /** @file > iSCSI DHCP4 related configuration routines. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -121,15 +121,28 @@ IScsiDhcpExtractRootPath ( > IpMode =3D ConfigNvData->IpMode; > } else { > IpMode =3D ConfigData->AutoConfigureMode; > } >=20 > - Status =3D IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); > - CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); > + // > + // Server name is expressed as domain name, just save it. > + // > + if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) !=3D '[')) { > + ConfigNvData->DnsMode =3D TRUE; > + if (Field->Len > sizeof (ConfigNvData->TargetUrl)) { > + return EFI_INVALID_PARAMETER; > + } > + CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); > + ConfigNvData->TargetUrl[Field->Len + 1] =3D '\0'; > + } else { > + ZeroMem(ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); > + Status =3D IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); > + CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); >=20 > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > + if (EFI_ERROR (Status)) { > + goto ON_EXIT; > + } > } > // > // Check the protocol type. > // > Field =3D &Fields[RP_FIELD_IDX_PROTOCOL]; > diff --git a/NetworkPkg/IScsiDxe/IScsiDhcp6.c > b/NetworkPkg/IScsiDxe/IScsiDhcp6.c > index 0cd0bd8..d3535d5 100644 > --- a/NetworkPkg/IScsiDxe/IScsiDhcp6.c > +++ b/NetworkPkg/IScsiDxe/IScsiDhcp6.c > @@ -1,9 +1,9 @@ > /** @file > iSCSI DHCP6 related configuration routines. >=20 > -Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -148,17 +148,30 @@ IScsiDhcp6ExtractRootPath ( > IpMode =3D ConfigNvData->IpMode; > } else { > IpMode =3D ConfigData->AutoConfigureMode; > } >=20 > - Status =3D IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); > - CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); > - > + // > + // Server name is expressed as domain name, just save it. > + // > + if ((!NET_IS_DIGIT (*(Field->Str))) && (*(Field->Str) !=3D '[')) { > + ConfigNvData->DnsMode =3D TRUE; > + if (Field->Len > sizeof (ConfigNvData->TargetUrl)) { > + return EFI_INVALID_PARAMETER; > + } > + CopyMem (&ConfigNvData->TargetUrl, Field->Str, Field->Len); > + ConfigNvData->TargetUrl[Field->Len + 1] =3D '\0'; > + } else { > + ZeroMem(&ConfigNvData->TargetUrl, sizeof (ConfigNvData->TargetUrl)); > + Status =3D IScsiAsciiStrToIp (Field->Str, IpMode, &Ip); > + CopyMem (&ConfigNvData->TargetIp, &Ip, sizeof (EFI_IP_ADDRESS)); >=20 > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > + if (EFI_ERROR (Status)) { > + goto ON_EXIT; > + } > } > + > // > // Check the protocol type. > // > Field =3D &Fields[RP_FIELD_IDX_PROTOCOL]; > if ((Field->Str !=3D NULL) && ((*(Field->Str) - '0') !=3D EFI_IP_PROTO= _TCP)) { > diff --git a/NetworkPkg/IScsiDxe/IScsiDns.c b/NetworkPkg/IScsiDxe/IScsiDn= s.c > new file mode 100644 > index 0000000..0ddfcbd > --- /dev/null > +++ b/NetworkPkg/IScsiDxe/IScsiDns.c > @@ -0,0 +1,435 @@ > +/** @file > + Perform DNS resolution based on UEFI DNS protocols. > + > +Copyright (c) 2017, Intel Corporation. All rights reserved.
> +This program and the accompanying materials > +are licensed and made available under the terms and conditions of the BS= D > License > +which accompanies this distribution. The full text of the license may b= e found > at > +http://opensource.org/licenses/bsd-license.php > + > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS > OR IMPLIED. > + > +**/ > + > +#include "IScsiImpl.h" > + > +/** > + Notify the callback function when an event is triggered. > + > + @param[in] Event The triggered event. > + @param[in] Context The opaque parameter to the function. > + > +**/ > +VOID > +EFIAPI > +IScsiCommonNotify ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + *((BOOLEAN *) Context) =3D TRUE; > +} > + > +/** > + Retrieve the host address using the EFI_DNS4_PROTOCOL. > + > + @param[in] Image The handle of the driver image. > + @param[in] Controller The handle of the controller. > + @param[in, out] NvData The Session config data structure. > + > + @retval EFI_SUCCESS Operation succeeded. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources. > + @retval EFI_DEVICE_ERROR An unexpected network error occurred. > + @retval Others Other errors as indicated. > + > +**/ > +EFI_STATUS > +IScsiDns4 ( > + IN EFI_HANDLE Image, > + IN EFI_HANDLE Controller, > + IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData > + ) > +{ > + EFI_STATUS Status; > + EFI_DNS4_PROTOCOL *Dns4; > + EFI_DNS4_CONFIG_DATA Dns4CfgData; > + EFI_DNS4_COMPLETION_TOKEN Token; > + BOOLEAN IsDone; > + EFI_HANDLE Dns4Handle; > + EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; > + EFI_IPv4_ADDRESS *DnsServerList; > + UINTN DnsServerListCount; > + UINTN DataSize; > + CHAR16 *HostName; > + > + DnsServerList =3D NULL; > + DnsServerListCount =3D 0; > + Dns4Handle =3D NULL; > + Dns4 =3D NULL; > + ZeroMem (&Token, sizeof (EFI_DNS4_COMPLETION_TOKEN)); > + > + // > + // Get DNS server list from EFI IPv4 Configuration II protocol. > + // > + Status =3D gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGui= d, > (VOID **) &Ip4Config2); > + if (!EFI_ERROR (Status)) { > + // > + // Get the required size. > + // > + DataSize =3D 0; > + Status =3D Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDnsS= erver, > &DataSize, NULL); > + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { > + DnsServerList =3D AllocatePool (DataSize); > + if (DnsServerList =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDn= sServer, > &DataSize, DnsServerList); > + if (EFI_ERROR (Status)) { > + FreePool (DnsServerList); > + DnsServerList =3D NULL; > + } else { > + DnsServerListCount =3D DataSize / sizeof (EFI_IPv4_ADDRESS); > + } > + } > + } > + > + > + // > + // Create a DNS child instance and get the protocol. > + // > + Status =3D NetLibCreateServiceChild ( > + Controller, > + Image, > + &gEfiDns4ServiceBindingProtocolGuid, > + &Dns4Handle > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + Status =3D gBS->OpenProtocol ( > + Dns4Handle, > + &gEfiDns4ProtocolGuid, > + (VOID **) &Dns4, > + Image, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + // > + // Configure DNS4 instance for the DNS server address and protocol. > + // > + ZeroMem (&Dns4CfgData, sizeof (Dns4CfgData)); > + Dns4CfgData.DnsServerListCount =3D DnsServerListCount; > + Dns4CfgData.DnsServerList =3D DnsServerList; > + Dns4CfgData.EnableDnsCache =3D TRUE; > + IP4_COPY_ADDRESS (&Dns4CfgData.StationIp, &NvData->LocalIp); > + IP4_COPY_ADDRESS (&Dns4CfgData.SubnetMask, &NvData->SubnetMask); > + Dns4CfgData.Protocol =3D EFI_IP_PROTO_UDP; > + Status =3D Dns4->Configure ( > + Dns4, > + &Dns4CfgData > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + // > + // Create event to set the is done flag when name resolution is finish= ed. > + // > + ZeroMem (&Token, sizeof (Token)); > + Status =3D gBS->CreateEvent ( > + EVT_NOTIFY_SIGNAL, > + TPL_NOTIFY, > + IScsiCommonNotify, > + &IsDone, > + &Token.Event > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + // > + // Start asynchronous name resolution. > + // > + Token.Status =3D EFI_NOT_READY; > + IsDone =3D FALSE; > + > + HostName =3D (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE); > + if (HostName =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + AsciiStrToUnicodeStrS ( > + NvData->TargetUrl, > + HostName, > + ISCSI_NAME_MAX_SIZE > + ); > + > + Status =3D Dns4->HostNameToIp (Dns4, HostName, &Token); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + while (!IsDone) { > + Dns4->Poll (Dns4); > + } > + > + // > + // Name resolution is done, check result. > + // > + Status =3D Token.Status; > + if (!EFI_ERROR (Status)) { > + if (Token.RspData.H2AData =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto Exit; > + } > + if (Token.RspData.H2AData->IpCount =3D=3D 0 || Token.RspData.H2AData= - > >IpList =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto Exit; > + } > + // > + // We just return the first IP address from DNS protocol. > + // > + IP4_COPY_ADDRESS (&NvData->TargetIp.v4, Token.RspData.H2AData- > >IpList); > + Status =3D EFI_SUCCESS; > + } > + > +Exit: > + > + if (Token.Event !=3D NULL) { > + gBS->CloseEvent (Token.Event); > + } > + if (Token.RspData.H2AData !=3D NULL) { > + if (Token.RspData.H2AData->IpList !=3D NULL) { > + FreePool (Token.RspData.H2AData->IpList); > + } > + FreePool (Token.RspData.H2AData); > + } > + > + if (Dns4 !=3D NULL) { > + Dns4->Configure (Dns4, NULL); > + > + gBS->CloseProtocol ( > + Dns4Handle, > + &gEfiDns4ProtocolGuid, > + Image, > + Controller > + ); > + } > + > + if (Dns4Handle !=3D NULL) { > + NetLibDestroyServiceChild ( > + Controller, > + Image, > + &gEfiDns4ServiceBindingProtocolGuid, > + Dns4Handle > + ); > + } > + > + return Status; > +} > + > +/** > + Retrieve the host address using the EFI_DNS6_PROTOCOL. > + > + @param[in] Image The handle of the driver image. > + @param[in] Controller The handle of the controller. > + @param[in, out] NvData The Session config data structure. > + > + @retval EFI_SUCCESS Operation succeeded. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources. > + @retval EFI_DEVICE_ERROR An unexpected network error occurred. > + @retval Others Other errors as indicated. > + > +**/ > +EFI_STATUS > +IScsiDns6 ( > + IN EFI_HANDLE Image, > + IN EFI_HANDLE Controller, > + IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData > + ) > +{ > + EFI_STATUS Status; > + EFI_DNS6_PROTOCOL *Dns6; > + EFI_DNS6_CONFIG_DATA Dns6ConfigData; > + EFI_DNS6_COMPLETION_TOKEN Token; > + EFI_HANDLE Dns6Handle; > + EFI_IP6_CONFIG_PROTOCOL *Ip6Config; > + EFI_IPv6_ADDRESS *DnsServerList; > + UINTN DnsServerListCount; > + UINTN DataSize; > + BOOLEAN IsDone; > + CHAR16 *HostName; > + > + DnsServerList =3D NULL; > + DnsServerListCount =3D 0; > + Dns6 =3D NULL; > + Dns6Handle =3D NULL; > + ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN)); > + > + // > + // Get DNS server list from EFI IPv6 Configuration protocol. > + // > + Status =3D gBS->HandleProtocol (Controller, &gEfiIp6ConfigProtocolGuid= , > (VOID **) &Ip6Config); > + if (!EFI_ERROR (Status)) { > + // > + // Get the required size. > + // > + DataSize =3D 0; > + Status =3D Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer= , > &DataSize, NULL); > + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { > + DnsServerList =3D AllocatePool (DataSize); > + if (DnsServerList =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServ= er, > &DataSize, DnsServerList); > + if (EFI_ERROR (Status)) { > + FreePool (DnsServerList); > + DnsServerList =3D NULL; > + } else { > + DnsServerListCount =3D DataSize / sizeof (EFI_IPv6_ADDRESS); > + } > + } > + } > + > + // > + // Create a DNSv6 child instance and get the protocol. > + // > + Status =3D NetLibCreateServiceChild ( > + Controller, > + Image, > + &gEfiDns6ServiceBindingProtocolGuid, > + &Dns6Handle > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + Status =3D gBS->OpenProtocol ( > + Dns6Handle, > + &gEfiDns6ProtocolGuid, > + (VOID **) &Dns6, > + Image, > + Controller, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + // > + // Configure DNS6 instance for the DNS server address and protocol. > + // > + ZeroMem (&Dns6ConfigData, sizeof (EFI_DNS6_CONFIG_DATA)); > + Dns6ConfigData.DnsServerCount =3D (UINT32)DnsServerListCount; > + Dns6ConfigData.DnsServerList =3D DnsServerList; > + Dns6ConfigData.EnableDnsCache =3D TRUE; > + Dns6ConfigData.Protocol =3D EFI_IP_PROTO_UDP; > + Status =3D Dns6->Configure ( > + Dns6, > + &Dns6ConfigData > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + Token.Status =3D EFI_NOT_READY; > + IsDone =3D FALSE; > + // > + // Create event to set the IsDone flag when name resolution is finish= ed. > + // > + Status =3D gBS->CreateEvent ( > + EVT_NOTIFY_SIGNAL, > + TPL_NOTIFY, > + IScsiCommonNotify, > + &IsDone, > + &Token.Event > + ); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + // > + // Start asynchronous name resolution. > + // > + HostName =3D (CHAR16 *) AllocateZeroPool (ISCSI_NAME_MAX_SIZE); > + if (HostName =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + AsciiStrToUnicodeStrS ( > + NvData->TargetUrl, > + HostName, > + ISCSI_NAME_MAX_SIZE > + ); > + Status =3D Dns6->HostNameToIp (Dns6, HostName, &Token); > + if (EFI_ERROR (Status)) { > + goto Exit; > + } > + > + while (!IsDone) { > + Dns6->Poll (Dns6); > + } > + > + // > + // Name resolution is done, check result. > + // > + Status =3D Token.Status; > + if (!EFI_ERROR (Status)) { > + if (Token.RspData.H2AData =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto Exit; > + } > + if (Token.RspData.H2AData->IpCount =3D=3D 0 || Token.RspData.H2AData= - > >IpList =3D=3D NULL) { > + Status =3D EFI_DEVICE_ERROR; > + goto Exit; > + } > + // > + // We just return the first IPv6 address from DNS protocol. > + // > + IP6_COPY_ADDRESS (&NvData->TargetIp.v6, Token.RspData.H2AData- > >IpList); > + Status =3D EFI_SUCCESS; > + } > + > +Exit: > + > + if (Token.Event !=3D NULL) { > + gBS->CloseEvent (Token.Event); > + } > + if (Token.RspData.H2AData !=3D NULL) { > + if (Token.RspData.H2AData->IpList !=3D NULL) { > + FreePool (Token.RspData.H2AData->IpList); > + } > + FreePool (Token.RspData.H2AData); > + } > + > + if (Dns6 !=3D NULL) { > + Dns6->Configure (Dns6, NULL); > + > + gBS->CloseProtocol ( > + Dns6Handle, > + &gEfiDns6ProtocolGuid, > + Image, > + Controller > + ); > + } > + > + if (Dns6Handle !=3D NULL) { > + NetLibDestroyServiceChild ( > + Controller, > + Image, > + &gEfiDns6ServiceBindingProtocolGuid, > + Dns6Handle > + ); > + } > + > + return Status; > +} > + > diff --git a/NetworkPkg/IScsiDxe/IScsiDns.h b/NetworkPkg/IScsiDxe/IScsiDn= s.h > new file mode 100644 > index 0000000..0b7ff86 > --- /dev/null > +++ b/NetworkPkg/IScsiDxe/IScsiDns.h > @@ -0,0 +1,59 @@ > +/** @file > + The header file of routines for IScsi driver to perform DNS > + resolution based on UEFI DNS protocols. > + > +Copyright (c) 2017, Intel Corporation. All rights reserved.
> +This program and the accompanying materials > +are licensed and made available under the terms and conditions of the BS= D > License > +which accompanies this distribution. The full text of the license may b= e found > at > +http://opensource.org/licenses/bsd-license.php > + > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS > OR IMPLIED. > + > +**/ > + > +#ifndef _ISCSI_DNS_H_ > +#define _ISCSI_DNS_H_ > + > +/** > + Retrieve the host address using the EFI_DNS4_PROTOCOL. > + > + @param[in] Image The handle of the driver image. > + @param[in] Controller The handle of the controller. > + @param[in, out] NvData The Session config data structure. > + > + @retval EFI_SUCCESS Operation succeeded. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources. > + @retval EFI_DEVICE_ERROR An unexpected network error occurred. > + @retval Others Other errors as indicated. > + > +**/ > +EFI_STATUS > +IScsiDns4 ( > + IN EFI_HANDLE Image, > + IN EFI_HANDLE Controller, > + IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData > + ); > + > +/** > + Retrieve the host address using the EFI_DNS6_PROTOCOL. > + > + @param[in] Image The handle of the driver image. > + @param[in] Controller The handle of the controller. > + @param[in, out] NvData The Session config data structure. > + > + @retval EFI_SUCCESS Operation succeeded. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate needed resources. > + @retval EFI_DEVICE_ERROR An unexpected network error occurred. > + @retval Others Other errors as indicated. > + > +**/ > +EFI_STATUS > +IScsiDns6 ( > + IN EFI_HANDLE Image, > + IN EFI_HANDLE Controller, > + IN OUT ISCSI_SESSION_CONFIG_NVDATA *NvData > + ); > + > +#endif > \ No newline at end of file > diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c > b/NetworkPkg/IScsiDxe/IScsiDriver.c > index ac10fa2..78c93ba 100644 > --- a/NetworkPkg/IScsiDxe/IScsiDriver.c > +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c > @@ -1,9 +1,9 @@ > /** @file > The entry point of IScsi driver. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -250,19 +250,23 @@ IScsiSupported ( > { > EFI_STATUS Status; > EFI_GUID *IScsiServiceBindingGuid; > EFI_GUID *TcpServiceBindingGuid; > EFI_GUID *DhcpServiceBindingGuid; > + EFI_GUID *DnsServiceBindingGuid; >=20 > if (IpVersion =3D=3D IP_VERSION_4) { > IScsiServiceBindingGuid =3D &gIScsiV4PrivateGuid; > TcpServiceBindingGuid =3D &gEfiTcp4ServiceBindingProtocolGuid; > DhcpServiceBindingGuid =3D &gEfiDhcp4ServiceBindingProtocolGuid; > + DnsServiceBindingGuid =3D &gEfiDns4ServiceBindingProtocolGuid; > + > } else { > IScsiServiceBindingGuid =3D &gIScsiV6PrivateGuid; > TcpServiceBindingGuid =3D &gEfiTcp6ServiceBindingProtocolGuid; > DhcpServiceBindingGuid =3D &gEfiDhcp6ServiceBindingProtocolGuid; > + DnsServiceBindingGuid =3D &gEfiDns6ServiceBindingProtocolGuid; > } >=20 > Status =3D gBS->OpenProtocol ( > ControllerHandle, > IScsiServiceBindingGuid, > @@ -303,11 +307,25 @@ IScsiSupported ( > ); > if (EFI_ERROR (Status)) { > return EFI_UNSUPPORTED; > } > } > - > + > + if (IScsiDnsIsConfigured (ControllerHandle)) { > + Status =3D gBS->OpenProtocol ( > + ControllerHandle, > + DnsServiceBindingGuid, > + NULL, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_TEST_PROTOCOL > + ); > + if (EFI_ERROR (Status)) { > + return EFI_UNSUPPORTED; > + } > + } > + > return EFI_SUCCESS; > } >=20 >=20 > /** > diff --git a/NetworkPkg/IScsiDxe/IScsiDxe.inf > b/NetworkPkg/IScsiDxe/IScsiDxe.inf > index 8952120..699ffd1 100644 > --- a/NetworkPkg/IScsiDxe/IScsiDxe.inf > +++ b/NetworkPkg/IScsiDxe/IScsiDxe.inf > @@ -2,11 +2,11 @@ > # Client-side iSCSI service. > # > # The iSCSI driver provides iSCSI service in the preboot environment an= d > supports > # booting over iSCSI. > # > -# Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
> +# Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> # 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 > # http://opensource.org/licenses/bsd-license.php > # > @@ -48,10 +48,12 @@ > IScsiConfigVfr.vfr > IScsiDhcp.c > IScsiDhcp.h > IScsiDhcp6.c > IScsiDhcp6.h > + IScsiDns.c > + IScsiDns.h > IScsiDriver.c > IScsiDriver.h > IScsiExtScsiPassThru.c > IScsiIbft.c > IScsiIbft.h > @@ -87,18 +89,24 @@ >=20 > [Protocols] > gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES ## > SystemTable > gEfiDriverBindingProtocolGuid ## SOMETIMES_PRODUCES > gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES > - gEfiDhcp4ProtocolGuid ## TO_START > - gEfiDhcp6ProtocolGuid ## TO_START > - gEfiDhcp4ServiceBindingProtocolGuid ## TO_START > - gEfiDhcp6ServiceBindingProtocolGuid ## TO_START > + gEfiDhcp4ProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDhcp6ProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDhcp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDhcp6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDns4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDns4ProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDns6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES > + gEfiDns6ProtocolGuid ## SOMETIMES_CONSUMES > + gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES > + gEfiIp6ConfigProtocolGuid ## SOMETIMES_CONSUMES > gEfiTcp4ProtocolGuid ## TO_START > - gEfiTcp6ProtocolGuid ## TO_START > + gEfiTcp6ProtocolGuid ## TO_START > gEfiTcp4ServiceBindingProtocolGuid ## TO_START > - gEfiTcp6ServiceBindingProtocolGuid ## TO_START > + gEfiTcp6ServiceBindingProtocolGuid ## TO_START > gEfiExtScsiPassThruProtocolGuid ## BY_START > gEfiHiiConfigAccessProtocolGuid ## PRODUCES > ## TO_START > ## PRODUCES > gEfiDevicePathProtocolGuid > diff --git a/NetworkPkg/IScsiDxe/IScsiImpl.h b/NetworkPkg/IScsiDxe/IScsiI= mpl.h > index af46871..741c497 100644 > --- a/NetworkPkg/IScsiDxe/IScsiImpl.h > +++ b/NetworkPkg/IScsiDxe/IScsiImpl.h > @@ -1,9 +1,9 @@ > /** @file > The shared head file for iSCSI driver. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -26,12 +26,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #include >=20 > #include > #include > #include > +#include > +#include > #include > #include > +#include > +#include >=20 > #include > #include > #include > #include > @@ -60,12 +64,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY > KIND, EITHER EXPRESS OR IMPLIED. > #include "IScsiDriver.h" > #include "IScsiProto.h" > #include "IScsiCHAP.h" > #include "IScsiDhcp.h" > #include "IScsiDhcp6.h" > + > #include "IScsiIbft.h" > #include "IScsiMisc.h" > +#include "IScsiDns.h" > #include "IScsiConfig.h" >=20 > #define ISCSI_AUTH_INITIAL 0 >=20 > #define ISCSI_SESSION_SIGNATURE SIGNATURE_32 ('I', 'S', 'S', 'N') > diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiM= isc.c > index 11a80f2..e8e8f9c 100644 > --- a/NetworkPkg/IScsiDxe/IScsiMisc.c > +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c > @@ -1,9 +1,9 @@ > /** @file > Miscellaneous routines for iSCSI driver. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -1000,10 +1000,98 @@ IScsiDhcpIsConfigured ( > FreePool (AttemptConfigOrder); > return FALSE; > } >=20 > /** > + 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 =3D IScsiGetVariableAndSize ( > + L"AttemptOrder", > + &gIScsiConfigGuid, > + &AttemptConfigOrderSize > + ); > + if (AttemptConfigOrder =3D=3D NULL || AttemptConfigOrderSize =3D=3D 0)= { > + return FALSE; > + } > + > + // > + // Get MAC address of this network device. > + // > + Status =3D NetLibGetMacAddress (Controller, &MacAddr, &HwAddressSize); > + if(EFI_ERROR (Status)) { > + return FALSE; > + } > + // > + // Get VLAN ID of this network device. > + // > + VlanId =3D NetLibGetVlanId (Controller); > + IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString= ); > + > + for (Index =3D 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Ind= ex++) { > + UnicodeSPrint ( > + AttemptName, > + (UINTN) 128, > + L"%s%d", > + MacString, > + (UINTN) AttemptConfigOrder[Index] > + ); > + Status =3D GetVariable2 ( > + AttemptName, > + &gEfiIScsiInitiatorNameProtocolGuid, > + (VOID**)&AttemptTmp, > + NULL > + ); > + if(AttemptTmp =3D=3D NULL || EFI_ERROR (Status)) { > + continue; > + } > + > + ASSERT (AttemptConfigOrder[Index] =3D=3D AttemptTmp->AttemptConfigIn= dex); > + > + if (AttemptTmp->SessionConfigData.Enabled =3D=3D 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. >=20 > @param[in] Private The iSCSI driver data. >=20 > @retval EFI_SUCCESS The configuration data is retrieved. > diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiM= isc.h > index 912a871..2c0fe07 100644 > --- a/NetworkPkg/IScsiDxe/IScsiMisc.h > +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h > @@ -1,9 +1,9 @@ > /** @file > Miscellaneous definitions for iSCSI driver. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -31,10 +31,11 @@ typedef struct _ISCSI_DRIVER_DATA > ISCSI_DRIVER_DATA; > /// > /// The ignored field StaticIpAddress's offset in old IPv6 Device Path > /// > #define IP6_OLD_IPADDRESS_OFFSET 42 >=20 > + > #pragma pack(1) > typedef struct _ISCSI_SESSION_CONFIG_NVDATA { > UINT16 TargetPort; > UINT8 Enabled; > UINT8 IpMode; > @@ -43,10 +44,11 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA { > EFI_IPv4_ADDRESS SubnetMask; > EFI_IP_ADDRESS Gateway; >=20 > BOOLEAN InitiatorInfoFromDhcp; > BOOLEAN TargetInfoFromDhcp; > + > CHAR8 TargetName[ISCSI_NAME_MAX_SIZE]; > EFI_IP_ADDRESS TargetIp; > UINT8 PrefixLength; > UINT8 BootLun[8]; >=20 > @@ -55,10 +57,13 @@ typedef struct _ISCSI_SESSION_CONFIG_NVDATA { > UINT8 IsId[6]; >=20 > BOOLEAN RedirectFlag; > UINT16 OriginalTargetPort; // The port of proxy/virtual= target. > EFI_IP_ADDRESS OriginalTargetIp; // The address of proxy/virt= ual target. > + > + BOOLEAN DnsMode; // Flag indicate whether the Target addres= s is > expressed as URL format. > + CHAR8 TargetUrl[ISCSI_TARGET_URI_MAX_SIZE]; >=20 > } ISCSI_SESSION_CONFIG_NVDATA; > #pragma pack() >=20 > /** > @@ -337,10 +342,24 @@ IScsiDhcpIsConfigured ( > IN EFI_HANDLE Controller, > IN UINT8 IpVersion > ); >=20 > /** > + 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 > + ); > + > +/** > Get the various configuration data of this iSCSI instance. >=20 > @param[in] Private The iSCSI driver data. >=20 > @retval EFI_SUCCESS Obtained the configuration of this instance. > diff --git a/NetworkPkg/IScsiDxe/IScsiProto.c > b/NetworkPkg/IScsiDxe/IScsiProto.c > index a67bbd5..1602a26 100644 > --- a/NetworkPkg/IScsiDxe/IScsiProto.c > +++ b/NetworkPkg/IScsiDxe/IScsiProto.c > @@ -1,9 +1,9 @@ > /** @file > The implementation of iSCSI protocol based on RFC3720. >=20 > -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > http://opensource.org/licenses/bsd-license.php >=20 > @@ -253,10 +253,27 @@ IScsiCreateConnection ( > // > Conn->MaxRecvDataSegmentLength =3D > DEFAULT_MAX_RECV_DATA_SEG_LEN; > Conn->HeaderDigest =3D IScsiDigestNone; > Conn->DataDigest =3D IScsiDigestNone; >=20 > + if (NvData->DnsMode) { > + // > + // perform dns process if target address expressed by domain name. > + // > + if (!Conn->Ipv6Flag) { > + Status =3D IScsiDns4 (Private->Image, Private->Controller, NvData)= ; > + } else { > + Status =3D IScsiDns6 (Private->Image, Private->Controller, NvData)= ; > + } > + > + if (EFI_ERROR(Status)) { > + DEBUG ((EFI_D_ERROR, "The configuration of Target address or DNS > server address is invalid!\n")); > + FreePool (Conn); > + return NULL; > + } > + } > + > if (!Conn->Ipv6Flag) { > Tcp4IoConfig =3D &TcpIoConfig.Tcp4IoConfigData; >=20 > CopyMem (&Tcp4IoConfig->LocalIp, &NvData->LocalIp, sizeof > (EFI_IPv4_ADDRESS)); > CopyMem (&Tcp4IoConfig->SubnetMask, &NvData->SubnetMask, sizeof > (EFI_IPv4_ADDRESS)); > @@ -1129,12 +1146,17 @@ IScsiUpdateTargetAddress ( > TargetAddress ++; >=20 > } else { > // > // The domainname of the target is presented in the format of a DN= S host > name. > - // Temporary not supported. > - continue; > + // > + IpStr =3D TargetAddress; > + > + while ((*TargetAddress !=3D '\0') && (*TargetAddress !=3D ':') && > (*TargetAddress !=3D ',')) { > + TargetAddress++; > + } > + NvData->DnsMode =3D TRUE; > } >=20 > // > // Save the origial user setting which specifies the proxy/virtual i= SCSI target. > // > @@ -1176,21 +1198,32 @@ IScsiUpdateTargetAddress ( > IpMode =3D NvData->IpMode; > } else { > IpMode =3D Session->ConfigData->AutoConfigureMode; > } >=20 > - Status =3D IScsiAsciiStrToIp ( > - IpStr, > - IpMode, > - &Session->ConfigData->SessionConfigData.TargetIp > - ); > - > - if (EFI_ERROR (Status)) { > - continue; > + if (NvData->DnsMode) { > + // > + // Target address is expressed as URL format, just save it and > + // do DNS resolution when creating a TCP connection. > + // > + if (AsciiStrSize (IpStr) > sizeof (Session->ConfigData- > >SessionConfigData.TargetUrl)){ > + return EFI_INVALID_PARAMETER; > + } > + CopyMem (&Session->ConfigData->SessionConfigData.TargetUrl, IpStr, > AsciiStrSize (IpStr)); > } else { > - NvData->RedirectFlag =3D TRUE; > - break; > + Status =3D IScsiAsciiStrToIp ( > + IpStr, > + IpMode, > + &Session->ConfigData->SessionConfigData.TargetIp > + ); > + > + if (EFI_ERROR (Status)) { > + continue; > + } else { > + NvData->RedirectFlag =3D TRUE; > + break; > + } > } > } >=20 > IScsiFreeKeyValueList (KeyValueList); >=20 > -- > 1.9.5.msysgit.1