66 lines
1.6 KiB
Groff
66 lines
1.6 KiB
Groff
|
|
|
|
HTON(3) Minix Programmer's Manual HTON(3)
|
|
|
|
|
|
NAME
|
|
hton, htons, htonl, ntohs, ntohl - host to network byte order conversion
|
|
|
|
SYNOPSIS
|
|
#define _MINIX_SOURCE 1
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <net/hton.h>
|
|
|
|
u16_t htons(u16_t host_word)
|
|
u32_t htonl(u32_t host_dword)
|
|
u16_t ntohs(u16_t network_word)
|
|
u32_t ntohl(u32_t network_dword)
|
|
u16_t HTONS(u16_t host_word)
|
|
u32_t HTONL(u32_t host_dword)
|
|
u16_t NTOHS(u16_t network_word)
|
|
u32_t NTOHL(u32_t network_dword)
|
|
|
|
DESCRIPTION
|
|
These macros convert 16-bit and 32-bit quantities to and from the network
|
|
byte order used by the TCP/IP protocols. The function of the macros is
|
|
encoded in their name. H means host byte order, n means network byte
|
|
order, s means a 16-bit quantity and l means a 32-bit quantity. Thus
|
|
htons converts a 16-bit quantity from host byte order to network byte
|
|
order. The difference between the lower case and upper case variants is
|
|
that the lower case variants evaluate the argument at most once and the
|
|
upper case variants can be used for constant folding. That is,
|
|
|
|
htonl(f(x))
|
|
|
|
will call f(x) at most once and
|
|
|
|
HTONS(0x10)
|
|
|
|
will be equivalent to 0x10 on a big-endian machine and 0x1000 on a
|
|
little-endian machine.
|
|
|
|
SEE ALSO
|
|
ip(4).
|
|
|
|
AUTHOR
|
|
Philip Homburg (philip@cs.vu.nl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1
|
|
|