NetworkPkg: Add new macros and refine codes
v2: *refine some codes Add 2 macros in NetLib.h #define IP4_MASK_MAX 32 #define IP6_PREFIX_MAX 128 we will use these two macros to check the max mask/prefix length, instead of #define IP4_MASK_NUM 33 #define IP6_PREFIX_NUM 129 which means a valid number This will make the code readability and maintainability. Cc: Subramanian Sriram <sriram-s@hpe.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@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: Sriram Subramanian <sriram-s@@hpe.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/** @file
|
||||
The ICMPv6 handle routines to process the ICMPv6 control messages.
|
||||
|
||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
||||
|
||||
This program and the accompanying materials
|
||||
@@ -473,14 +473,14 @@ Ip6GetPrefix (
|
||||
UINT8 Mask;
|
||||
UINT8 Value;
|
||||
|
||||
ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_NUM));
|
||||
ASSERT ((Prefix != NULL) && (PrefixLength < IP6_PREFIX_MAX));
|
||||
|
||||
if (PrefixLength == 0) {
|
||||
ZeroMem (Prefix, sizeof (EFI_IPv6_ADDRESS));
|
||||
return ;
|
||||
}
|
||||
|
||||
if (PrefixLength >= IP6_PREFIX_NUM - 1) {
|
||||
if (PrefixLength >= IP6_PREFIX_MAX) {
|
||||
return ;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user