summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-21 02:22:21 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-21 02:22:21 +0200
commit3c7b46a85aeb4b24ec3e381dd1b34ae5aa596271 (patch)
treea2baed954366f8cf8f03a73461bbbb781c335f91
parent02033873b7e52d6e0e9ea91e543ac9e06fb8c4a6 (diff)
downloadserenity-3c7b46a85aeb4b24ec3e381dd1b34ae5aa596271.zip
LibC: Add htonl() and ntohl().
-rw-r--r--LibC/arpa/inet.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/LibC/arpa/inet.h b/LibC/arpa/inet.h
index ee1de4fd7c..ec2292ef67 100644
--- a/LibC/arpa/inet.h
+++ b/LibC/arpa/inet.h
@@ -21,5 +21,16 @@ static inline uint16_t ntohs(uint16_t ns)
return htons(ns);
}
+static inline uint32_t htonl(uint32_t hs)
+{
+ uint8_t* s = (uint8_t*)&hs;
+ return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
+}
+
+static inline uint32_t ntohl(uint32_t ns)
+{
+ return htonl(ns);
+}
+
__END_DECLS