From 25a6745fe886e88fe175a50dcab4562c65b7cea3 Mon Sep 17 00:00:00 2001 From: Nickle Wang Date: Mon, 24 Jul 2023 21:03:04 +0800 Subject: RedfishPkg/RedfishDiscoverDxe: fix netmask check issue - Add NTOHL() for coverting IP address from EFI_IPv4_ADDRESS to IP4_ADDR so that IP4_IS_VALID_NETMASK() return correct value. - Add DumpIpv4Address() in RedfishDebugLib and print IP address when invalid IP or subnet mask address is detected. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez Reviewed-by: Igor Kulchytskyy Reviewed-by: Abner Chang --- .../Library/RedfishDebugLib/RedfishDebugLib.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'RedfishPkg/Library') diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c index 0b2a9a5c4e..efa9a5ca13 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c @@ -340,3 +340,29 @@ DumpRedfishResponse ( return EFI_SUCCESS; } + +/** + + This function dump the IPv4 address in given error level. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Ipv4Address IPv4 address to dump + + @retval EFI_SUCCESS IPv4 address string is printed. + @retval Others Errors occur. + +**/ +EFI_STATUS +DumpIpv4Address ( + IN UINTN ErrorLevel, + IN EFI_IPv4_ADDRESS *Ipv4Address + ) +{ + if (Ipv4Address == NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((ErrorLevel, "%d.%d.%d.%d\n", Ipv4Address->Addr[0], Ipv4Address->Addr[1], Ipv4Address->Addr[2], Ipv4Address->Addr[3])); + + return EFI_SUCCESS; +} -- cgit v1.2.3