* [patch] ShellPkg: Add check logic for the gateway validity.
@ 2017-01-06 9:16 Zhang Lubo
2017-01-09 6:42 ` Ye, Ting
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zhang Lubo @ 2017-01-06 9:16 UTC (permalink / raw)
To: edk2-devel; +Cc: Santhapur Naveen, Ye Ting, Fu Siyuan, Wu Jiaxin
if we set a static IP using command
'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0'
The system says 'Failed to set address.' but using
'ifconfig -l', the static IP can be assigned successfully.
so we need to check the gateway validity before setting manual
address to keep the ifconfig -s command more consistent.
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Santhapur Naveen <naveens@amiindia.co.in>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
.../Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 19 ++++++++++++++++++-
.../UefiShellNetwork1CommandsLib.uni | 3 ++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 5e243d5..4db07b2 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1,10 +1,10 @@
/** @file
The implementation for Shell command ifconfig based on IP4Config2 protocol.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
http://opensource.org/licenses/bsd-license.php.
@@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo (
EFI_IP4_CONFIG2_POLICY Policy;
EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress;
UINTN DataSize;
EFI_IPv4_ADDRESS Gateway;
+ IP4_ADDR SubnetMask;
+ IP4_ADDR TempGateway;
EFI_IPv4_ADDRESS *Dns;
ARG_LIST *Tmp;
UINTN Index;
CONST CHAR16* TempString;
@@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo (
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
//
+ // Need to check the gateway validity before set Manual Address.
+ // In case we can set manual address but fail to configure Gateway.
+ //
+ CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof (IP4_ADDR));
+ CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR));
+ SubnetMask = NTOHL (SubnetMask);
+ TempGateway = NTOHL (TempGateway);
+ if ((SubnetMask != 0) &&
+ !NetIp4IsUnicast (TempGateway, SubnetMask)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg->Arg);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto ON_EXIT;
+ }
+
+ //
// Set manual config policy.
//
Policy = Ip4Config2PolicyStatic;
Status = IfCb->IfCfg->SetData (
IfCb->IfCfg,
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 4566cd1..d9bbb20 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
@@ -1,9 +1,9 @@
// /**
//
// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
-// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2010 - 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
// http://opensource.org/licenses/bsd-license.php
//
@@ -64,10 +64,11 @@
#string STR_IFCONFIG_LACK_OPTION #language en-US "Flags lack. Please type 'ifConfig -?' for help info.\n"
#string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack interface name.\n"
#string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack interface config option.\n"
#string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invalid interface name.\n"
#string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invalid ipv4 address: '%H%s%N'\n"
+#string STR_IFCONFIG_INVALID_GATEWAY #language en-US "Invalid gateway address: '%H%s%N'\n"
#string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed to set address.\n"
#string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H Routes (%d entries):\n"
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ShellPkg: Add check logic for the gateway validity.
2017-01-06 9:16 [patch] ShellPkg: Add check logic for the gateway validity Zhang Lubo
@ 2017-01-09 6:42 ` Ye, Ting
2017-01-09 7:11 ` Fu, Siyuan
2017-01-09 7:54 ` Wu, Jiaxin
2 siblings, 0 replies; 4+ messages in thread
From: Ye, Ting @ 2017-01-09 6:42 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org
Cc: Santhapur Naveen, Fu, Siyuan, Wu, Jiaxin
Reviewed-by: Ye Ting <ting.ye@intel.com>
-----Original Message-----
From: Zhang, Lubo
Sent: Friday, January 06, 2017 5:16 PM
To: edk2-devel@lists.01.org
Cc: Santhapur Naveen <naveens@amiindia.co.in>; Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [patch] ShellPkg: Add check logic for the gateway validity.
if we set a static IP using command
'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0'
The system says 'Failed to set address.' but using 'ifconfig -l', the static IP can be assigned successfully.
so we need to check the gateway validity before setting manual address to keep the ifconfig -s command more consistent.
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Santhapur Naveen <naveens@amiindia.co.in>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
.../Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 19 ++++++++++++++++++-
.../UefiShellNetwork1CommandsLib.uni | 3 ++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 5e243d5..4db07b2 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1,10 +1,10 @@
/** @file
The implementation for Shell command ifconfig based on IP4Config2 protocol.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
http://opensource.org/licenses/bsd-license.php.
@@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo (
EFI_IP4_CONFIG2_POLICY Policy;
EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress;
UINTN DataSize;
EFI_IPv4_ADDRESS Gateway;
+ IP4_ADDR SubnetMask;
+ IP4_ADDR TempGateway;
EFI_IPv4_ADDRESS *Dns;
ARG_LIST *Tmp;
UINTN Index;
CONST CHAR16* TempString;
@@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo (
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
//
+ // Need to check the gateway validity before set Manual Address.
+ // In case we can set manual address but fail to configure Gateway.
+ //
+ CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof (IP4_ADDR));
+ CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR));
+ SubnetMask = NTOHL (SubnetMask);
+ TempGateway = NTOHL (TempGateway);
+ if ((SubnetMask != 0) &&
+ !NetIp4IsUnicast (TempGateway, SubnetMask)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg->Arg);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto ON_EXIT;
+ }
+
+ //
// Set manual config policy.
//
Policy = Ip4Config2PolicyStatic;
Status = IfCb->IfCfg->SetData (
IfCb->IfCfg, diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 4566cd1..d9bbb20 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
+++ mandsLib.uni
@@ -1,9 +1,9 @@
// /**
//
// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR> -// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2010 - 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 // http://opensource.org/licenses/bsd-license.php
//
@@ -64,10 +64,11 @@
#string STR_IFCONFIG_LACK_OPTION #language en-US "Flags lack. Please type 'ifConfig -?' for help info.\n"
#string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack interface name.\n"
#string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack interface config option.\n"
#string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invalid interface name.\n"
#string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invalid ipv4 address: '%H%s%N'\n"
+#string STR_IFCONFIG_INVALID_GATEWAY #language en-US "Invalid gateway address: '%H%s%N'\n"
#string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed to set address.\n"
#string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H Routes (%d entries):\n"
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ShellPkg: Add check logic for the gateway validity.
2017-01-06 9:16 [patch] ShellPkg: Add check logic for the gateway validity Zhang Lubo
2017-01-09 6:42 ` Ye, Ting
@ 2017-01-09 7:11 ` Fu, Siyuan
2017-01-09 7:54 ` Wu, Jiaxin
2 siblings, 0 replies; 4+ messages in thread
From: Fu, Siyuan @ 2017-01-09 7:11 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org
Cc: Santhapur Naveen, Ye, Ting, Wu, Jiaxin
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
-----Original Message-----
From: Zhang, Lubo
Sent: 2017年1月6日 17:16
To: edk2-devel@lists.01.org
Cc: Santhapur Naveen <naveens@amiindia.co.in>; Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [patch] ShellPkg: Add check logic for the gateway validity.
if we set a static IP using command
'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0'
The system says 'Failed to set address.' but using 'ifconfig -l', the static IP can be assigned successfully.
so we need to check the gateway validity before setting manual address to keep the ifconfig -s command more consistent.
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Santhapur Naveen <naveens@amiindia.co.in>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
.../Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 19 ++++++++++++++++++-
.../UefiShellNetwork1CommandsLib.uni | 3 ++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 5e243d5..4db07b2 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -1,10 +1,10 @@
/** @file
The implementation for Shell command ifconfig based on IP4Config2 protocol.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 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
http://opensource.org/licenses/bsd-license.php.
@@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo (
EFI_IP4_CONFIG2_POLICY Policy;
EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress;
UINTN DataSize;
EFI_IPv4_ADDRESS Gateway;
+ IP4_ADDR SubnetMask;
+ IP4_ADDR TempGateway;
EFI_IPv4_ADDRESS *Dns;
ARG_LIST *Tmp;
UINTN Index;
CONST CHAR16* TempString;
@@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo (
ShellStatus = SHELL_INVALID_PARAMETER;
goto ON_EXIT;
}
//
+ // Need to check the gateway validity before set Manual Address.
+ // In case we can set manual address but fail to configure Gateway.
+ //
+ CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof (IP4_ADDR));
+ CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR));
+ SubnetMask = NTOHL (SubnetMask);
+ TempGateway = NTOHL (TempGateway);
+ if ((SubnetMask != 0) &&
+ !NetIp4IsUnicast (TempGateway, SubnetMask)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg->Arg);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto ON_EXIT;
+ }
+
+ //
// Set manual config policy.
//
Policy = Ip4Config2PolicyStatic;
Status = IfCb->IfCfg->SetData (
IfCb->IfCfg, diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
index 4566cd1..d9bbb20 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
+++ mandsLib.uni
@@ -1,9 +1,9 @@
// /**
//
// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR> -// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2010 - 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 // http://opensource.org/licenses/bsd-license.php
//
@@ -64,10 +64,11 @@
#string STR_IFCONFIG_LACK_OPTION #language en-US "Flags lack. Please type 'ifConfig -?' for help info.\n"
#string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack interface name.\n"
#string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack interface config option.\n"
#string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invalid interface name.\n"
#string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invalid ipv4 address: '%H%s%N'\n"
+#string STR_IFCONFIG_INVALID_GATEWAY #language en-US "Invalid gateway address: '%H%s%N'\n"
#string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US "Duplicate commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_CONFLICT_COMMAND #language en-US "Conflict commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US "Unknown commands. Bad command %H%s%N is skipped.\n"
#string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed to set address.\n"
#string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H Routes (%d entries):\n"
--
1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ShellPkg: Add check logic for the gateway validity.
2017-01-06 9:16 [patch] ShellPkg: Add check logic for the gateway validity Zhang Lubo
2017-01-09 6:42 ` Ye, Ting
2017-01-09 7:11 ` Fu, Siyuan
@ 2017-01-09 7:54 ` Wu, Jiaxin
2 siblings, 0 replies; 4+ messages in thread
From: Wu, Jiaxin @ 2017-01-09 7:54 UTC (permalink / raw)
To: Zhang, Lubo, edk2-devel@lists.01.org
Cc: Santhapur Naveen, Ye, Ting, Fu, Siyuan
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
> -----Original Message-----
> From: Zhang, Lubo
> Sent: Friday, January 6, 2017 5:16 PM
> To: edk2-devel@lists.01.org
> Cc: Santhapur Naveen <naveens@amiindia.co.in>; Ye, Ting
> <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>
> Subject: [patch] ShellPkg: Add check logic for the gateway validity.
>
> if we set a static IP using command
> 'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0'
> The system says 'Failed to set address.' but using
> 'ifconfig -l', the static IP can be assigned successfully.
> so we need to check the gateway validity before setting manual
> address to keep the ifconfig -s command more consistent.
>
> Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
> Cc: Santhapur Naveen <naveens@amiindia.co.in>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> .../Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 19
> ++++++++++++++++++-
> .../UefiShellNetwork1CommandsLib.uni | 3 ++-
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> index 5e243d5..4db07b2 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> @@ -1,10 +1,10 @@
> /** @file
> The implementation for Shell command ifconfig based on IP4Config2
> protocol.
>
> (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
> - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2006 - 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
> http://opensource.org/licenses/bsd-license.php.
> @@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo (
>
> EFI_IP4_CONFIG2_POLICY Policy;
> EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress;
> UINTN DataSize;
> EFI_IPv4_ADDRESS Gateway;
> + IP4_ADDR SubnetMask;
> + IP4_ADDR TempGateway;
> EFI_IPv4_ADDRESS *Dns;
> ARG_LIST *Tmp;
> UINTN Index;
>
> CONST CHAR16* TempString;
> @@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo (
> ShellStatus = SHELL_INVALID_PARAMETER;
> goto ON_EXIT;
> }
>
> //
> + // Need to check the gateway validity before set Manual Address.
> + // In case we can set manual address but fail to configure Gateway.
> + //
> + CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof
> (IP4_ADDR));
> + CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR));
> + SubnetMask = NTOHL (SubnetMask);
> + TempGateway = NTOHL (TempGateway);
> + if ((SubnetMask != 0) &&
> + !NetIp4IsUnicast (TempGateway, SubnetMask)) {
> + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg-
> >Arg);
> + ShellStatus = SHELL_INVALID_PARAMETER;
> + goto ON_EXIT;
> + }
> +
> + //
> // Set manual config policy.
> //
> Policy = Ip4Config2PolicyStatic;
> Status = IfCb->IfCfg->SetData (
> IfCb->IfCfg,
> diff --git
> a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
> mandsLib.uni
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
> mandsLib.uni
> index 4566cd1..d9bbb20 100644
> ---
> a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
> mandsLib.uni
> +++
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com
> mandsLib.uni
> @@ -1,9 +1,9 @@
> // /**
> //
> // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
> -// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. <BR>
> +// Copyright (c) 2010 - 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
> // http://opensource.org/licenses/bsd-license.php
> //
> @@ -64,10 +64,11 @@
> #string STR_IFCONFIG_LACK_OPTION #language en-US "Flags lack.
> Please type 'ifConfig -?' for help info.\n"
> #string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack
> interface name.\n"
> #string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack
> interface config option.\n"
> #string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invalid
> interface name.\n"
> #string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invalid
> ipv4 address: '%H%s%N'\n"
> +#string STR_IFCONFIG_INVALID_GATEWAY #language en-US "Invalid
> gateway address: '%H%s%N'\n"
> #string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US
> "Duplicate commands. Bad command %H%s%N is skipped.\n"
> #string STR_IFCONFIG_CONFLICT_COMMAND #language en-US
> "Conflict commands. Bad command %H%s%N is skipped.\n"
> #string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US
> "Unknown commands. Bad command %H%s%N is skipped.\n"
> #string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed to
> set address.\n"
> #string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H
> Routes (%d entries):\n"
> --
> 1.9.5.msysgit.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-09 7:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-06 9:16 [patch] ShellPkg: Add check logic for the gateway validity Zhang Lubo
2017-01-09 6:42 ` Ye, Ting
2017-01-09 7:11 ` Fu, Siyuan
2017-01-09 7:54 ` Wu, Jiaxin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox