From 0b89407eeb718643f933e9f2f958d1ca9f9a6495 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Fri, 13 Nov 2026 20:19:41 +0000 Subject: [PATCH 1/2] swoc: fix big-endian IPv4 network-order helpers The big-endian branch of swoc_ip_util.h never compiled: the parameter of is_link_local_network_order() is spelled inaddr_t. Nobody noticed because until #11186 BYTE_ORDER and LITTLE_ENDIAN were both undefined there, so the little-endian branch got picked on every platform. Now a big-endian build (FreeBSD/powerpc64, 10.1.5) stops with swoc_ip_util.h:96:41: error: unknown type name 'inaddr_t' While there, is_private_network_order() in the same branch called the link-local check instead of is_private_host_order(). --- code/include/swoc/swoc_ip_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/include/swoc/swoc_ip_util.h b/code/include/swoc/swoc_ip_util.h index 78016bf..c7ceded 100644 --- a/code/include/swoc/swoc_ip_util.h +++ b/code/include/swoc/swoc_ip_util.h @@ -93,12 +93,12 @@ inline bool is_loopback_network_order(in_addr_t addr) { return is_loopback_host_order(addr); } -inline bool is_link_local_network_order(inaddr_t addr) { +inline bool is_link_local_network_order(in_addr_t addr) { return is_link_local_host_order(addr); } inline bool is_private_network_order(in_addr_t addr) { - return is_link_local_host_order(addr); + return is_private_host_order(addr); } inline bool is_multicast_network_order(in_addr_t addr) { From 30bad9d7216baef4e03dddd71d4cb35fef18fa11 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Fri, 13 Nov 2026 23:18:56 +0100 Subject: [PATCH 2/2] swoc: fix test_ip.cc to work on big-endian The test_ip.cc checks for these helpers fed host-order values to the network-order functions and only held on little-endian. Convert with htonl() so they pass on either byte order. --- unit_tests/test_ip.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc index 28291b5..c3b217f 100644 --- a/unit_tests/test_ip.cc +++ b/unit_tests/test_ip.cc @@ -148,12 +148,12 @@ TEST_CASE("Basic IP", "[libswoc][ip]") { CHECK(ll4.is_link_local()); CHECK_FALSE(ll4.is_multicast()); CHECK(swoc::ip::is_link_local_host_order(ll4.host_order())); - CHECK_FALSE(swoc::ip::is_link_local_network_order(ll4.host_order())); + CHECK(swoc::ip::is_link_local_network_order(htonl(ll4.host_order()))); CHECK(swoc::ip::is_private_host_order(0xC0A8BADC)); - CHECK_FALSE(swoc::ip::is_private_network_order(0xC0A8BADC)); + CHECK(swoc::ip::is_private_network_order(htonl(0xC0A8BADC))); CHECK_FALSE(swoc::ip::is_private_host_order(0xDCBA8C0)); - CHECK(swoc::ip::is_private_network_order(0xDCBA8C0)); + CHECK_FALSE(swoc::ip::is_private_network_order(htonl(0x0DCBA8C0))); CHECK(IP4Addr(INADDR_LOOPBACK).is_loopback());