summaryrefslogtreecommitdiffstats
path: root/rtrlib/lib/convert_byte_order_private.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
commitcd7b005519ade8ab6c97fcb21590b71b7d1be6e3 (patch)
treec611a8d0cd5e8f68f41b8c2d16ba580e0f40a38d /rtrlib/lib/convert_byte_order_private.h
parentInitial commit. (diff)
downloadlibrtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.tar.xz
librtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.zip
Adding upstream version 0.8.0.upstream/0.8.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rtrlib/lib/convert_byte_order_private.h')
-rw-r--r--rtrlib/lib/convert_byte_order_private.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/rtrlib/lib/convert_byte_order_private.h b/rtrlib/lib/convert_byte_order_private.h
new file mode 100644
index 0000000..839f82b
--- /dev/null
+++ b/rtrlib/lib/convert_byte_order_private.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of RTRlib.
+ *
+ * This file is subject to the terms and conditions of the MIT license.
+ * See the file LICENSE in the top level directory for more details.
+ *
+ * Website: http://rtrlib.realmv6.org/
+ */
+
+#ifndef LRTR_CONVERT_BYTE_ORDER_PRIVATE_H
+#define LRTR_CONVERT_BYTE_ORDER_PRIVATE_H
+
+#include <inttypes.h>
+
+/**
+ * @brief Target byte order for conversion.
+ */
+enum target_byte_order {
+ TO_NETWORK_BYTE_ORDER,
+ TO_HOST_HOST_BYTE_ORDER,
+};
+
+/**
+ * Converts the passed short value to the given target byte order.
+ * @param[in] tbo Target byte order.
+ * @param[in] value Input (uint16_t) for conversion.
+ * @result Converted uint16_t value.
+ */
+uint16_t lrtr_convert_short(const enum target_byte_order tbo, const uint16_t value);
+
+/**
+ * Converts the passed long value to the given target byte order.
+ * @param[in] tbo Target byte order.
+ * @param[in] value Input (uint32_t) for conversion.
+ * @result Converted uint32_t value.
+ */
+uint32_t lrtr_convert_long(const enum target_byte_order tbo, const uint32_t value);
+
+#endif /* LRTR_CONVERT_BYTE_ORDER_H */