Blame lib/lwres/man/lwres_getaddrinfo.3

Packit Service ae04f2
.\" Copyright (C) 2000, 2001, 2003-2005, 2007, 2014-2016, 2018-2020 Internet Systems Consortium, Inc. ("ISC")
Packit Service ae04f2
.\" 
Packit Service ae04f2
.\" This Source Code Form is subject to the terms of the Mozilla Public
Packit Service ae04f2
.\" License, v. 2.0. If a copy of the MPL was not distributed with this
Packit Service ae04f2
.\" file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit Service ae04f2
.\"
Packit Service ae04f2
.hy 0
Packit Service ae04f2
.ad l
Packit Service ae04f2
'\" t
Packit Service ae04f2
.\"     Title: lwres_getaddrinfo
Packit Service ae04f2
.\"    Author: 
Packit Service ae04f2
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
Packit Service ae04f2
.\"      Date: 2007-06-18
Packit Service ae04f2
.\"    Manual: BIND9
Packit Service ae04f2
.\"    Source: ISC
Packit Service ae04f2
.\"  Language: English
Packit Service ae04f2
.\"
Packit Service ae04f2
.TH "LWRES_GETADDRINFO" "3" "2007\-06\-18" "ISC" "BIND9"
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * Define some portability stuff
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit Service ae04f2
.\" http://bugs.debian.org/507673
Packit Service ae04f2
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
Packit Service ae04f2
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Packit Service ae04f2
.ie \n(.g .ds Aq \(aq
Packit Service ae04f2
.el       .ds Aq '
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * set default formatting
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" disable hyphenation
Packit Service ae04f2
.nh
Packit Service ae04f2
.\" disable justification (adjust text to left margin only)
Packit Service ae04f2
.ad l
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.\" * MAIN CONTENT STARTS HERE *
Packit Service ae04f2
.\" -----------------------------------------------------------------
Packit Service ae04f2
.SH "NAME"
Packit Service ae04f2
lwres_getaddrinfo, lwres_freeaddrinfo \- socket address structure to host and service name
Packit Service ae04f2
.SH "SYNOPSIS"
Packit Service ae04f2
.sp
Packit Service ae04f2
.ft B
Packit Service ae04f2
.nf
Packit Service ae04f2
#include <lwres/netdb\&.h>
Packit Service ae04f2
.fi
Packit Service ae04f2
.ft
Packit Service ae04f2
.HP \w'int\ lwres_getaddrinfo('u
Packit Service ae04f2
.BI "int lwres_getaddrinfo(const\ char\ *" "hostname" ", const\ char\ *" "servname" ", const\ struct\ addrinfo\ *" "hints" ", struct\ addrinfo\ **" "res" ");"
Packit Service ae04f2
.HP \w'void\ lwres_freeaddrinfo('u
Packit Service ae04f2
.BI "void lwres_freeaddrinfo(struct\ addrinfo\ *" "ai" ");"
Packit Service ae04f2
.PP
Packit Service ae04f2
If the operating system does not provide a
Packit Service ae04f2
\fBstruct addrinfo\fR, the following structure is used:
Packit Service ae04f2
.PP
Packit Service ae04f2
.nf
Packit Service ae04f2
struct  addrinfo {
Packit Service ae04f2
        int             ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
Packit Service ae04f2
        int             ai_family;      /* PF_xxx */
Packit Service ae04f2
        int             ai_socktype;    /* SOCK_xxx */
Packit Service ae04f2
        int             ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
Packit Service ae04f2
        size_t          ai_addrlen;     /* length of ai_addr */
Packit Service ae04f2
        char            *ai_canonname;  /* canonical name for hostname */
Packit Service ae04f2
        struct sockaddr *ai_addr;       /* binary address */
Packit Service ae04f2
        struct addrinfo *ai_next;       /* next structure in linked list */
Packit Service ae04f2
};
Packit Service ae04f2
.fi
Packit Service ae04f2
.sp
Packit Service ae04f2
.SH "DESCRIPTION"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
is used to get a list of IP addresses and port numbers for host
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
and service
Packit Service ae04f2
\fIservname\fR\&. The function is the lightweight resolver\*(Aqs implementation of
Packit Service ae04f2
\fBgetaddrinfo()\fR
Packit Service ae04f2
as defined in RFC2133\&.
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fIservname\fR
Packit Service ae04f2
are pointers to null\-terminated strings or
Packit Service ae04f2
\fBNULL\fR\&.
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
is either a host name or a numeric host address string: a dotted decimal IPv4 address or an IPv6 address\&.
Packit Service ae04f2
\fIservname\fR
Packit Service ae04f2
is either a decimal port number or a service name as listed in
Packit Service ae04f2
/etc/services\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
\fIhints\fR
Packit Service ae04f2
is an optional pointer to a
Packit Service ae04f2
\fBstruct addrinfo\fR\&. This structure can be used to provide hints concerning the type of socket that the caller supports or wishes to use\&. The caller can supply the following structure elements in
Packit Service ae04f2
\fI*hints\fR:
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBai_family\fR
Packit Service ae04f2
.RS 4
Packit Service ae04f2
The protocol family that should be used\&. When
Packit Service ae04f2
\fBai_family\fR
Packit Service ae04f2
is set to
Packit Service ae04f2
\fBPF_UNSPEC\fR, it means the caller will accept any protocol family supported by the operating system\&.
Packit Service ae04f2
.RE
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBai_socktype\fR
Packit Service ae04f2
.RS 4
Packit Service ae04f2
denotes the type of socket \(em
Packit Service ae04f2
\fBSOCK_STREAM\fR,
Packit Service ae04f2
\fBSOCK_DGRAM\fR
Packit Service ae04f2
or
Packit Service ae04f2
\fBSOCK_RAW\fR
Packit Service ae04f2
\(em that is wanted\&. When
Packit Service ae04f2
\fBai_socktype\fR
Packit Service ae04f2
is zero the caller will accept any socket type\&.
Packit Service ae04f2
.RE
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBai_protocol\fR
Packit Service ae04f2
.RS 4
Packit Service ae04f2
indicates which transport protocol is wanted: IPPROTO_UDP or IPPROTO_TCP\&. If
Packit Service ae04f2
\fBai_protocol\fR
Packit Service ae04f2
is zero the caller will accept any protocol\&.
Packit Service ae04f2
.RE
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBai_flags\fR
Packit Service ae04f2
.RS 4
Packit Service ae04f2
Flag bits\&. If the
Packit Service ae04f2
\fBAI_CANONNAME\fR
Packit Service ae04f2
bit is set, a successful call to
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
will return a null\-terminated string containing the canonical name of the specified hostname in
Packit Service ae04f2
\fBai_canonname\fR
Packit Service ae04f2
of the first
Packit Service ae04f2
\fBaddrinfo\fR
Packit Service ae04f2
structure returned\&. Setting the
Packit Service ae04f2
\fBAI_PASSIVE\fR
Packit Service ae04f2
bit indicates that the returned socket address structure is intended for used in a call to
Packit Service ae04f2
\fBbind\fR(2)\&. In this case, if the hostname argument is a
Packit Service ae04f2
\fBNULL\fR
Packit Service ae04f2
pointer, then the IP address portion of the socket address structure will be set to
Packit Service ae04f2
\fBINADDR_ANY\fR
Packit Service ae04f2
for an IPv4 address or
Packit Service ae04f2
\fBIN6ADDR_ANY_INIT\fR
Packit Service ae04f2
for an IPv6 address\&.
Packit Service ae04f2
.sp
Packit Service ae04f2
When
Packit Service ae04f2
\fBai_flags\fR
Packit Service ae04f2
does not set the
Packit Service ae04f2
\fBAI_PASSIVE\fR
Packit Service ae04f2
bit, the returned socket address structure will be ready for use in a call to
Packit Service ae04f2
\fBconnect\fR(2)
Packit Service ae04f2
for a connection\-oriented protocol or
Packit Service ae04f2
\fBconnect\fR(2),
Packit Service ae04f2
\fBsendto\fR(2), or
Packit Service ae04f2
\fBsendmsg\fR(2)
Packit Service ae04f2
if a connectionless protocol was chosen\&. The IP address portion of the socket address structure will be set to the loopback address if
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
is a
Packit Service ae04f2
\fBNULL\fR
Packit Service ae04f2
pointer and
Packit Service ae04f2
\fBAI_PASSIVE\fR
Packit Service ae04f2
is not set in
Packit Service ae04f2
\fBai_flags\fR\&.
Packit Service ae04f2
.sp
Packit Service ae04f2
If
Packit Service ae04f2
\fBai_flags\fR
Packit Service ae04f2
is set to
Packit Service ae04f2
\fBAI_NUMERICHOST\fR
Packit Service ae04f2
it indicates that
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
should be treated as a numeric string defining an IPv4 or IPv6 address and no name resolution should be attempted\&.
Packit Service ae04f2
.RE
Packit Service ae04f2
.PP
Packit Service ae04f2
All other elements of the
Packit Service ae04f2
\fBstruct addrinfo\fR
Packit Service ae04f2
passed via
Packit Service ae04f2
\fIhints\fR
Packit Service ae04f2
must be zero\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
A
Packit Service ae04f2
\fIhints\fR
Packit Service ae04f2
of
Packit Service ae04f2
\fBNULL\fR
Packit Service ae04f2
is treated as if the caller provided a
Packit Service ae04f2
\fBstruct addrinfo\fR
Packit Service ae04f2
initialized to zero with
Packit Service ae04f2
\fBai_family\fRset to
Packit Service ae04f2
\fBPF_UNSPEC\fR\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
After a successful call to
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR,
Packit Service ae04f2
\fI*res\fR
Packit Service ae04f2
is a pointer to a linked list of one or more
Packit Service ae04f2
\fBaddrinfo\fR
Packit Service ae04f2
structures\&. Each
Packit Service ae04f2
\fBstruct addrinfo\fR
Packit Service ae04f2
in this list cn be processed by following the
Packit Service ae04f2
\fBai_next\fR
Packit Service ae04f2
pointer, until a
Packit Service ae04f2
\fBNULL\fR
Packit Service ae04f2
pointer is encountered\&. The three members
Packit Service ae04f2
\fBai_family\fR,
Packit Service ae04f2
\fBai_socktype\fR, and
Packit Service ae04f2
\fBai_protocol\fR
Packit Service ae04f2
in each returned
Packit Service ae04f2
\fBaddrinfo\fR
Packit Service ae04f2
structure contain the corresponding arguments for a call to
Packit Service ae04f2
\fBsocket\fR(2)\&. For each
Packit Service ae04f2
\fBaddrinfo\fR
Packit Service ae04f2
structure in the list, the
Packit Service ae04f2
\fBai_addr\fR
Packit Service ae04f2
member points to a filled\-in socket address structure of length
Packit Service ae04f2
\fBai_addrlen\fR\&.
Packit Service ae04f2
.PP
Packit Service ae04f2
All of the information returned by
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
is dynamically allocated: the addrinfo structures, and the socket address structures and canonical host name strings pointed to by the
Packit Service ae04f2
\fBaddrinfo\fRstructures\&. Memory allocated for the dynamically allocated structures created by a successful call to
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
is released by
Packit Service ae04f2
\fBlwres_freeaddrinfo()\fR\&.
Packit Service ae04f2
\fIai\fR
Packit Service ae04f2
is a pointer to a
Packit Service ae04f2
\fBstruct addrinfo\fR
Packit Service ae04f2
created by a call to
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR\&.
Packit Service ae04f2
.SH "RETURN VALUES"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
returns zero on success or one of the error codes listed in
Packit Service ae04f2
\fBgai_strerror\fR(3)
Packit Service ae04f2
if an error occurs\&. If both
Packit Service ae04f2
\fIhostname\fR
Packit Service ae04f2
and
Packit Service ae04f2
\fIservname\fR
Packit Service ae04f2
are
Packit Service ae04f2
\fBNULL\fR\fBlwres_getaddrinfo()\fR
Packit Service ae04f2
returns
Packit Service ae04f2
\fBEAI_NONAME\fR\&.
Packit Service ae04f2
.SH "SEE ALSO"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBlwres\fR(3),
Packit Service ae04f2
\fBlwres_getaddrinfo\fR(3),
Packit Service ae04f2
\fBlwres_freeaddrinfo\fR(3),
Packit Service ae04f2
\fBlwres_gai_strerror\fR(3),
Packit Service ae04f2
\fBRFC2133\fR(),
Packit Service ae04f2
\fBgetservbyname\fR(3),
Packit Service ae04f2
\fBbind\fR(2),
Packit Service ae04f2
\fBconnect\fR(2),
Packit Service ae04f2
\fBsendto\fR(2),
Packit Service ae04f2
\fBsendmsg\fR(2),
Packit Service ae04f2
\fBsocket\fR(2)\&.
Packit Service ae04f2
.SH "AUTHOR"
Packit Service ae04f2
.PP
Packit Service ae04f2
\fBInternet Systems Consortium, Inc\&.\fR
Packit Service ae04f2
.SH "COPYRIGHT"
Packit Service ae04f2
.br
Packit Service ae04f2
Copyright \(co 2000, 2001, 2003-2005, 2007, 2014-2016, 2018-2020 Internet Systems Consortium, Inc. ("ISC")
Packit Service ae04f2
.br