From 972d2eee3a3518f18e0958e6f8a1b2ffafd6d39a Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 29 Oct 2020 15:57:00 -0400 Subject: outline stuff from arpa/inet.h --- src/arpa/inet/htonl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/arpa/inet/htonl.c (limited to 'src/arpa/inet/htonl.c') diff --git a/src/arpa/inet/htonl.c b/src/arpa/inet/htonl.c new file mode 100644 index 00000000..c17f2470 --- /dev/null +++ b/src/arpa/inet/htonl.c @@ -0,0 +1,16 @@ +#include + +uint32_t htonl(uint32_t hostlong) +{ + union { + uint32_t u; + unsigned char c[sizeof(uint32_t)]; + } u; + + u.c[0] = (hostlong >> 24) & 0xff; + u.c[1] = (hostlong >> 16) & 0xff; + u.c[2] = (hostlong >> 8) & 0xff; + u.c[3] = (hostlong) & 0xff; + + return u.u; +} -- cgit v1.2.1