From 364f4efa444150df3f074f563374dce1e153adc6 Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Fri, 8 Apr 2016 09:48:14 +0800 Subject: MdeModulePkg: Add new macros and refine codes Add 2 macros inNetLib.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 Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Sriram Subramanian --- MdeModulePkg/Include/Library/NetLib.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'MdeModulePkg/Include/Library') diff --git a/MdeModulePkg/Include/Library/NetLib.h b/MdeModulePkg/Include/Library/NetLib.h index b871a857f9..87f393e2de 100644 --- a/MdeModulePkg/Include/Library/NetLib.h +++ b/MdeModulePkg/Include/Library/NetLib.h @@ -52,6 +52,9 @@ typedef UINT16 TCP_PORTNO; #define IP4_MASK_NUM 33 #define IP6_PREFIX_NUM 129 +#define IP4_MASK_MAX 32 +#define IP6_PREFIX_MAX 128 + #define IP6_HOP_BY_HOP 0 #define IP6_DESTINATION 60 #define IP6_ROUTING 43 @@ -230,7 +233,7 @@ typedef struct { #define IP4_IS_MULTICAST(Ip) (((Ip) & 0xF0000000) == 0xE0000000) #define IP4_IS_LOCAL_BROADCAST(Ip) ((Ip) == 0xFFFFFFFF) #define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) == ((Ip2) & (NetMask))) -#define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != IP4_MASK_NUM) +#define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != (IP4_MASK_MAX + 1)) #define IP6_IS_MULTICAST(Ip6) (((Ip6)->Addr[0]) == 0xFF) -- cgit v1.2.3