summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-12-24 17:44:23 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-12-24 17:44:33 +0100
commitff93091a1eb79d59f4939a3260a64a5d241c0937 (patch)
tree63c19684c1d44a186178d4dc4eda221e94da9739
parent429b1d985ff250598acaa9d4558d621917c3afd5 (diff)
Add missing htons
-rw-r--r--util/byteorder.c8
-rw-r--r--util/byteorder.h1
-rw-r--r--xen/net.c1
3 files changed, 10 insertions, 0 deletions
diff --git a/util/byteorder.c b/util/byteorder.c
index 18311972..0629b31e 100644
--- a/util/byteorder.c
+++ b/util/byteorder.c
@@ -36,6 +36,14 @@ uint32_t ntohl(uint32_t netlong) {
#endif
}
+uint16_t htons(uint16_t hostshort) {
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ return __builtin_bswap16(hostshort);
+#else
+ return hostshort;
+#endif
+}
+
uint32_t htonl(uint32_t hostlong) {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return __builtin_bswap32(hostlong);
diff --git a/util/byteorder.h b/util/byteorder.h
index 2b780ffe..fbec39e3 100644
--- a/util/byteorder.h
+++ b/util/byteorder.h
@@ -26,6 +26,7 @@
uint16_t ntohs(uint16_t netshort);
uint32_t ntohl(uint32_t netlong);
+uint16_t htons(uint16_t hostshort);
uint32_t htonl(uint32_t hostlong);
#endif /* _UTIL_BYTEORDER_H_ */
diff --git a/xen/net.c b/xen/net.c
index 51b031cd..bec61661 100644
--- a/xen/net.c
+++ b/xen/net.c
@@ -36,6 +36,7 @@
#include <xen/public/memory.h>
#include <string.h>
#include <util/atoi.h>
+#include <util/byteorder.h>
#include "evt.h"
#include "store.h"
#include "net.h"