OK I tested the function and it reacts in all cases fine.
Even for fuzzed IPv6 addresses or strange input.
But one thing would need to be changed.
The preprocessor variable ENABLE_IPV6 would need to be replaced with WITH_IPV6.
WITH_IPV6 is being set if ENABLE_IPV6 is set in Cmake but ENABLE_IPV6 is not a constant in the preprocessor context.