From cd7b005519ade8ab6c97fcb21590b71b7d1be6e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:54:46 +0200 Subject: Adding upstream version 0.8.0. Signed-off-by: Daniel Baumann --- rtrlib/lib/convert_byte_order.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 rtrlib/lib/convert_byte_order.c (limited to 'rtrlib/lib/convert_byte_order.c') diff --git a/rtrlib/lib/convert_byte_order.c b/rtrlib/lib/convert_byte_order.c new file mode 100644 index 0000000..402c141 --- /dev/null +++ b/rtrlib/lib/convert_byte_order.c @@ -0,0 +1,34 @@ +/* + * 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/ + */ + +#include "convert_byte_order_private.h" + +#include +#include +#include + +uint16_t lrtr_convert_short(const enum target_byte_order tbo, const uint16_t value) +{ + if (tbo == TO_NETWORK_BYTE_ORDER) + return htons(value); + else if (tbo == TO_HOST_HOST_BYTE_ORDER) + return ntohs(value); + + assert(0); +} + +uint32_t lrtr_convert_long(const enum target_byte_order tbo, const uint32_t value) +{ + if (tbo == TO_NETWORK_BYTE_ORDER) + return htonl(value); + else if (tbo == TO_HOST_HOST_BYTE_ORDER) + return ntohl(value); + + assert(0); +} -- cgit v1.2.3