INET_NTOP(3)               POSIX Programmer's Manual              INET_NTOP(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       inet_ntop, inet_pton -- convert IPv4 and IPv6 addresses between binary
       and text form

SSYYNNOOPPSSIISS
       #include <arpa/inet.h>

       const char *inet_ntop(int _a_f, const void *restrict _s_r_c,
           char *restrict _d_s_t, socklen_t _s_i_z_e);
       int inet_pton(int _a_f, const char *restrict _s_r_c, void *restrict _d_s_t);

DDEESSCCRRIIPPTTIIOONN
       The _i_n_e_t___n_t_o_p() function shall convert a numeric address into a text
       string suitable for presentation. The _a_f argument shall specify the
       family of the address. This can be AF_INET or AF_INET6.  The _s_r_c
       argument points to a buffer holding an IPv4 address if the _a_f argument
       is AF_INET, or an IPv6 address if the _a_f argument is AF_INET6; the
       address must be in network byte order. The _d_s_t argument points to a
       buffer where the function stores the resulting text string; it shall
       not be NULL. The _s_i_z_e argument specifies the size of this buffer, which
       shall be large enough to hold the text string (INET_ADDRSTRLEN
       characters for IPv4, INET6_ADDRSTRLEN characters for IPv6).

       The _i_n_e_t___p_t_o_n() function shall convert an address in its standard text
       presentation form into its numeric binary form. The _a_f argument shall
       specify the family of the address. The AF_INET and AF_INET6 address
       families shall be supported. The _s_r_c argument points to the string
       being passed in. The _d_s_t argument points to a buffer into which the
       function stores the numeric address; this shall be large enough to hold
       the numeric address (32 bits for AF_INET, 128 bits for AF_INET6).

       If the _a_f argument of _i_n_e_t___p_t_o_n() is AF_INET, the _s_r_c string shall be
       in the standard IPv4 dotted-decimal form:

           dddddd..dddddd..dddddd..dddddd

       where ""dddddd"" is a one to three digit decimal number between 0 and 255
       (see _i_n_e_t___a_d_d_r()).  The _i_n_e_t___p_t_o_n() function does not accept other
       formats (such as the octal numbers, hexadecimal numbers, and fewer than
       four numbers that _i_n_e_t___a_d_d_r() accepts).

       If the _a_f argument of _i_n_e_t___p_t_o_n() is AF_INET6, the _s_r_c string shall be
       in one of the following standard IPv6 text forms:

        1. The preferred form is ""xx::xx::xx::xx::xx::xx::xx::xx"", where the ''xx''s are the
           hexadecimal values of the eight 16-bit pieces of the address.
           Leading zeros in individual fields can be omitted, but there shall
           be at least one numeral in every field.

        2. A string of contiguous zero fields in the preferred form can be
           shown as ""::::"".  The ""::::"" can only appear once in an address.
           Unspecified addresses (""00::00::00::00::00::00::00::00"") may be represented simply
           as ""::::"".

        3. A third form that is sometimes more convenient when dealing with a
           mixed environment of IPv4 and IPv6 nodes is ""xx::xx::xx::xx::xx::xx::dd..dd..dd..dd"",
           where the ''xx''s are the hexadecimal values of the six high-order
           16-bit pieces of the address, and the ''dd''s are the decimal values
           of the four low-order 8-bit pieces of the address (standard IPv4
           representation).

       NNoottee::     A more extensive description of the standard representations
                 of IPv6 addresses can be found in RFC 2373.

RREETTUURRNN VVAALLUUEE
       The _i_n_e_t___n_t_o_p() function shall return a pointer to the buffer
       containing the text string if the conversion succeeds, and NULL
       otherwise, and set _e_r_r_n_o to indicate the error.

       The _i_n_e_t___p_t_o_n() function shall return 1 if the conversion succeeds,
       with the address pointed to by _d_s_t in network byte order. It shall
       return 0 if the input is not a valid IPv4 dotted-decimal string or a
       valid IPv6 address string, or -1 with _e_r_r_n_o set to [[EEAAFFNNOOSSUUPPPPOORRTT]] if
       the _a_f argument is unknown.

EERRRROORRSS
       The _i_n_e_t___n_t_o_p() and _i_n_e_t___p_t_o_n() functions shall fail if:

       EEAAFFNNOOSSUUPPPPOORRTT
              The _a_f argument is invalid.

       EENNOOSSPPCC The size of the _i_n_e_t___n_t_o_p() result buffer is inadequate.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       The Base Definitions volume of POSIX.1-2008, <<aarrppaa__iinneett..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                         INET_NTOP(3)
