pkg: Clean up
functions: Encapsulate HOST_IP discovery routines

No functional changes, just improve code structure and readability.