72 lines
2.4 KiB
HTML
72 lines
2.4 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>hton(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>hton(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
hton, htons, htonl, ntohs, ntohl - host to network byte order conversion
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#define</STRONG> <STRONG>_MINIX_SOURCE</STRONG> <STRONG>1</STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><stddef.h></STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><sys/types.h></STRONG>
|
|
|
|
<STRONG>#include</STRONG> <STRONG><net/hton.h></STRONG>
|
|
|
|
<STRONG>u16_t</STRONG> <STRONG>htons(u16_t</STRONG> <EM>host</EM>_<EM>word</EM><STRONG>)</STRONG>
|
|
<STRONG>u32_t</STRONG> <STRONG>htonl(u32_t</STRONG> <EM>host</EM>_<EM>dword</EM><STRONG>)</STRONG>
|
|
<STRONG>u16_t</STRONG> <STRONG>ntohs(u16_t</STRONG> <EM>network</EM>_<EM>word</EM><STRONG>)</STRONG>
|
|
<STRONG>u32_t</STRONG> <STRONG>ntohl(u32_t</STRONG> <EM>network</EM>_<EM>dword</EM><STRONG>)</STRONG>
|
|
<STRONG>u16_t</STRONG> <STRONG>HTONS(u16_t</STRONG> <EM>host</EM>_<EM>word</EM><STRONG>)</STRONG>
|
|
<STRONG>u32_t</STRONG> <STRONG>HTONL(u32_t</STRONG> <EM>host</EM>_<EM>dword</EM><STRONG>)</STRONG>
|
|
<STRONG>u16_t</STRONG> <STRONG>NTOHS(u16_t</STRONG> <EM>network</EM>_<EM>word</EM><STRONG>)</STRONG>
|
|
<STRONG>u32_t</STRONG> <STRONG>NTOHL(u32_t</STRONG> <EM>network</EM>_<EM>dword</EM><STRONG>)</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
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. <STRONG>H</STRONG> means host byte order, <STRONG>n</STRONG> means network byte
|
|
order, <STRONG>s</STRONG> means a 16-bit quantity and <STRONG>l</STRONG> means a 32-bit quantity. Thus
|
|
<STRONG>htons</STRONG> 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.
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man4/ip.4.html">ip(4)</A></STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>AUTHOR</H2><PRE>
|
|
Philip Homburg (philip@cs.vu.nl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|