summaryrefslogtreecommitdiff
path: root/src/network/htonl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/htonl.c')
-rw-r--r--src/network/htonl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/htonl.c b/src/network/htonl.c
new file mode 100644
index 00000000..b21dace0
--- /dev/null
+++ b/src/network/htonl.c
@@ -0,0 +1,10 @@
+#include <netinet/in.h>
+
+uint32_t htonl(uint32_t n)
+{
+ union {
+ uint8_t b[4];
+ uint32_t i;
+ } u = { { n>>24, n>>16, n>>8, n } };
+ return u.i;
+}