summaryrefslogtreecommitdiff
path: root/src/libc/arpainet.c
blob: 125a8550b3526030dd2e87be5c641c86a12b14b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <arpa/inet.h>

uint32_t htonl(uint32_t n) {
	return ((n & 0xFF000000) >> 24)
	     | ((n & 0x00FF0000) >>  8)
	     | ((n & 0x0000FF00) <<  8)
	     | ((n & 0x000000FF) << 24);
}

uint16_t htons(uint16_t n) {
	return (n >> 8) | (n << 8);
}

uint32_t ntohl(uint32_t n) {
	return htonl(n);
}

uint16_t ntohs(uint16_t n) {
	return htons(n);
}