As IEEE define and use Integer64.
Add a function to order 64bits to network order.

Signed-off-by: Erez Geva <erez.geva....@siemens.com>
---
 util.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/util.h b/util.h
index 41e33d4..8a5444f 100644
--- a/util.h
+++ b/util.h
@@ -22,6 +22,7 @@
 
 #include <string.h>
 #include <time.h>
+#include <endian.h>
 
 #include "address.h"
 #include "ddt.h"
@@ -455,4 +456,26 @@ void parray_extend(void ***a, ...);
  */
 int rate_limited(int interval, time_t *last);
 
+/**
+ * Swap host order to network order of 64 bits unsigned integer.
+ *
+ * @param val       value to swap.
+ * @return          swaped value.
+ */
+static inline uint64_t htonll(uint64_t val)
+{
+       return htobe64(val);
+}
+
+/**
+ * Swap network order to host order of 64 bits unsigned integer.
+ *
+ * @param val       value to swap.
+ * @return          swaped value.
+ */
+static inline uint64_t ntohll(uint64_t val)
+{
+       return be64toh(val);
+}
+
 #endif
-- 
2.20.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to