summaryrefslogtreecommitdiff
path: root/src/arpa/inet/htons.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-10-29 15:57:00 -0400
committerJakob Kaivo <jkk@ung.org>2020-10-29 15:57:00 -0400
commit972d2eee3a3518f18e0958e6f8a1b2ffafd6d39a (patch)
tree52fa9568b8c64e70ecbadc39ef63b35157731312 /src/arpa/inet/htons.c
parent097e3e2dc18091096fc846fcc15402accf906448 (diff)
outline stuff from arpa/inet.h
Diffstat (limited to 'src/arpa/inet/htons.c')
-rw-r--r--src/arpa/inet/htons.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/arpa/inet/htons.c b/src/arpa/inet/htons.c
new file mode 100644
index 00000000..b6be02ed
--- /dev/null
+++ b/src/arpa/inet/htons.c
@@ -0,0 +1,14 @@
+#include <arpa/inet.h>
+
+uint16_t htons(uint16_t hostshort)
+{
+ union {
+ uint16_t u;
+ unsigned char c[sizeof(uint16_t)];
+ } u;
+
+ u.c[0] = (hostshort >> 8) & 0xff;
+ u.c[1] = (hostshort) & 0xff;
+
+ return u.u;
+}