The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
byteorder.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file byteorder.h
5 * @brief network byte order (big endian) on the little-endian x86.
6 */
7
8#include "common/stdint.h"
9
10static inline uint16_t net_htons(uint16_t v)
11{
12 return __builtin_bswap16(v);
13}
14
15static inline uint16_t net_ntohs(uint16_t v)
16{
17 return __builtin_bswap16(v);
18}
19
20static inline uint32_t net_htonl(uint32_t v)
21{
22 return __builtin_bswap32(v);
23}
24
25static inline uint32_t net_ntohl(uint32_t v)
26{
27 return __builtin_bswap32(v);
28}
29
30/**
31 * an IPv4 address in network byte order from its four parts (a.b.c.d).
32 */
33#define NET_IPV4(a, b, c, d) \
34 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
unsigned int uint32_t
Definition fb.h:17
unsigned short uint16_t
Definition stdint.h:13