MdeModulePkg: Update IP4 stack drivers for classless address unicast check.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
Helper functions for configuring or getting the parameters relating to iSCSI.
|
||||
|
||||
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2016, 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
|
||||
@@ -727,7 +727,9 @@ IScsiFormCallback (
|
||||
case KEY_LOCAL_IP:
|
||||
IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
|
||||
if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
if (EFI_ERROR (Status) ||
|
||||
((Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
|
||||
!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
@@ -751,7 +753,10 @@ IScsiFormCallback (
|
||||
case KEY_GATE_WAY:
|
||||
IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);
|
||||
if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {
|
||||
if (EFI_ERROR (Status) ||
|
||||
((Gateway.Addr[0] != 0) &&
|
||||
(Private->Current->SessionConfigData.SubnetMask.Addr[0] != 0) &&
|
||||
!NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL(*(UINT32*)Private->Current->SessionConfigData.SubnetMask.Addr)))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
@@ -763,7 +768,7 @@ IScsiFormCallback (
|
||||
case KEY_TARGET_IP:
|
||||
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
|
||||
if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
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 = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
@@ -867,7 +872,7 @@ IScsiFormCallback (
|
||||
//
|
||||
if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {
|
||||
CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));
|
||||
if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
if (IP4_IS_UNSPECIFIED (NTOHL (HostIp.Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (HostIp.Addr[0]))) {
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user