MirBSD manpage: inet_net(3), inet_net_ntop(3), inet_net_pton(3)

INET_NET(3)                BSD Programmer's Manual                 INET_NET(3)

NAME

     inet_net_ntop, inet_net_pton - Internet network number manipulation rou-
     tines

SYNOPSIS

     #include <sys/socket.h>
     #include <netinet/in.h>
     #include <arpa/inet.h>

     char *
     inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size);

     int
     inet_net_pton(int af, const char *src, void *dst, size_t size);

DESCRIPTION

     The inet_net_ntop() function converts an Internet network number from
     network format (usually a struct in_addr or some other binary form, in
     network byte order) to CIDR presentation format (suitable for external
     display purposes). bits is the number of bits in src that are the network
     number. It returns NULL if a system error occurs (in which case, errno
     will have been set), or it returns a pointer to the destination string.

     The inet_net_pton() function converts a presentation format Internet net-
     work number (that is, printable form as held in a character string) to
     network format (usually a struct in_addr or some other internal binary
     representation, in network byte order). It returns the number of bits
     (either computed based on the class, or specified with /CIDR), or -1 if a
     failure occurred (in which case errno will have been set. It will be set
     to ENOENT if the Internet network number was not valid).

     Caution: The dst field should be zeroed before calling inet_net_pton() as
     the function will only fill the number of bytes necessary to encode the
     network number in network byte order.

     The only value for af currently supported is AF_INET. size is the size of
     the result buffer dst.

NETWORK NUMBERS (IP VERSION 4)
     The external representation of Internet network numbers may be specified
     in one of the following forms:

           a
           a.b
           a.b.c
           a.b.c.d

     Any of the above four forms may have "/bits" appended where "bits" is in
     the range 0-32 and is used to explicitly specify the number of bits in
     the network address. When "/bits" is not specified the number of bits in
     the network address is calculated as the larger of the number of bits in
     the class to which the address belongs and the number of bits provided
     rounded up modulo 8. Examples:

           10           an 8-bit network number (class A), value 10.0.0.0.
           192          a 24-bit network number (class C), value 192.0.0.0.
           10.10        a 16-bit network number, value 10.10.0.0.
           10.1.2       a 24-bit network number, value 10.1.2.0.
           10.1.2.3     a 32-bit network number, value 10.1.2.3.
           10.1.2.3/24  a 24-bit network number (explicit), value 10.1.2.3.

     Note that when the number of bits is specified using "/bits" notation,
     the value of the address still includes all bits supplied in the external
     representation, even those bits which are the host part of an Internet
     address. Also, unlike inet_pton(3) where the external representation is
     assumed to be a host address, the external representation for
     inet_net_pton() is assumed to be a network address. Thus "10.1" is as-
     sumed to be "10.1.0.0" not "10.0.0.1"

     All numbers supplied as "parts" in a '.' notation may be decimal, octal,
     or hexadecimal, as specified in the C language (i.e., a leading 0x or 0X
     implies hexadecimal; otherwise, a leading 0 implies octal; otherwise, the
     number is interpreted as decimal).

SEE ALSO

     byteorder(3), inet(3), inet_pton(3), networks(5)

HISTORY

     The inet_net_ntop and inet_net_pton functions first appeared in BIND
     4.9.4.

MirBSD #10-current              June 18, 1997                                1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung