Avoid namespace clash with local ntohs/htons functions.

These are macros in MacOS X, which causes a clash when compiling
our local copies.  Instead of a local undef hack, this just explicitly
renames the local functions to indicate that we want to use this code
rather than the system equivalents (this improves reproducibility
across different architectures and development operating systems)

This fixes the build on MacOS X.