blob: 402c141ce2487b85ffa10dd41bf52b5f31d4967b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 <arpa/inet.h>
#include <assert.h>
#include <inttypes.h>
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);
}
|