'\" te .\" Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") .\" Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" Portions Copyright (c) 2009, Sun Microsystems Inc. All Rights Reserved. .TH inet_cidr_ntop 3RESOLV "11 Nov 2009" "SunOS 5.11" "Resolver Library Functions" .SH NAME inet_cidr_ntop, inet_cidr_pton \- network translation routines .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lresolv\fR \fB -lsocket \fR \fB -lnsl \fR [ \fIlibrary\fR...] #include #include #include #include \fBchar *\fR\fBinet_cidr_ntop\fR(\fBint\fR \fIaf\fR, \fBconst void *\fR\fIsrc\fR, \fBint\fR \fIbits\fR, \fBchar *\fR\fIdst\fR, \fBsize_t\fR \fIsize\fR); .fi .LP .nf \fBint\fR \fBinet_cidr_pton\fR(\fBint\fR \fIaf\fR, \fBconst char *\fR\fIsrc\fR, \fBvoid *\fR\fIdst\fR, \fBint *\fR\fIbits\fR); .fi .SH DESCRIPTION .sp .LP These routines are used for converting addresses to and from network and presentation forms with CIDR (Classless Inter-Domain Routing) representation, embedded net mask. .sp .LP The \fBinet_cidr_ntop()\fR function converts an address from network to presentation format. .sp .LP The \fIaf\fR parameter describes the type of address that is being passed in \fIsrc\fR. Currently only \fBAF_INET\fR is supported. .sp .LP The \fIsrc\fR parameter is an address in network byte order, its length is determined from \fIaf\fR. .sp .LP The \fIbits\fR parameter specifies the number of bits in the netmask unless it is -1 in which case the CIDR representation is omitted. .sp .LP The \fIdst\fR parameter is a caller supplied buffer of at least \fIsize\fR bytes. .sp .LP The \fBinet_cidr_ntop()\fR function returns \fIdst\fR on success or NULL. Check errno for reason. .sp .LP The \fBinet_cidr_pton()\fR function converts and address from presentation format, with optional CIDR representation, to network format. The resulting address is zero filled if there were insufficient bits in \fIsrc\fR. .sp .LP The \fIaf\fR parameter describes the type of address that is being passed in via \fIsrc\fR and determines the size of \fIdst\fR. .sp .LP The \fIsrc\fR parameter is an address in presentation format. .sp .LP The \fIbits\fR parameter returns the number of bits in the netmask or -1 if a CIDR representation was not supplied. .sp .LP The \fBinet_cidr_pton()\fR function returns 0 on success or -1 on error. Check \fBerrno\fR for reason. \fBENOENT\fR indicates an invalid netmask. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe .TE .SH SEE ALSO .sp .LP \fBIntro\fR(2), \fBattributes\fR(5)