Blame lib/lwres/man/lwres_getaddrinfo.html

Packit Service ae04f2
Packit Service ae04f2
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
<html lang="en">
Packit Service ae04f2
<head>
Packit Service ae04f2
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Packit Service ae04f2
<title>lwres_getaddrinfo</title>
Packit Service ae04f2
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
Packit Service ae04f2
</head>
Packit Service ae04f2
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
  
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2

Name

Packit Service ae04f2

Packit Service ae04f2
    lwres_getaddrinfo, 
Packit Service ae04f2
    lwres_freeaddrinfo
Packit Service ae04f2
     — socket address structure to host and service name
Packit Service ae04f2
  

Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2

Synopsis

Packit Service ae04f2
    
Packit Service ae04f2
#include <lwres/netdb.h>
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
int
Packit Service ae04f2
lwres_getaddrinfo(
Packit Service ae04f2
const char *hostname, 
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
 
Packit Service ae04f2
const char *servname, 
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
 
Packit Service ae04f2
const struct addrinfo *hints, 
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
 
Packit Service ae04f2
struct addrinfo **res);
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
 
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
void
Packit Service ae04f2
lwres_freeaddrinfo(
Packit Service ae04f2
struct addrinfo *ai);
Packit Service ae04f2
Packit Service ae04f2
 
Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
      If the operating system does not provide a
Packit Service ae04f2
      struct addrinfo,
Packit Service ae04f2
      the following structure is used:
Packit Service ae04f2
    

Packit Service ae04f2
    
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
Packit Service ae04f2

Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2

DESCRIPTION

Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    

lwres_getaddrinfo()

Packit Service ae04f2
      is used to get a list of IP addresses and port numbers for host
Packit Service ae04f2
      hostname and service
Packit Service ae04f2
      servname.
Packit Service ae04f2
Packit Service ae04f2
      The function is the lightweight resolver's implementation of
Packit Service ae04f2
      getaddrinfo() as defined in RFC2133.
Packit Service ae04f2
      hostname and
Packit Service ae04f2
      servname are pointers to null-terminated
Packit Service ae04f2
      strings or NULL.
Packit Service ae04f2
Packit Service ae04f2
      hostname is either a host name or a
Packit Service ae04f2
      numeric host address string: a dotted decimal IPv4 address or an
Packit Service ae04f2
      IPv6 address.  servname is either a
Packit Service ae04f2
      decimal port number or a service name as listed in
Packit Service ae04f2
      /etc/services.
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
    

hints

Packit Service ae04f2
      is an optional pointer to a
Packit Service ae04f2
      struct addrinfo.
Packit Service ae04f2
      This structure can be used to provide hints concerning the type of
Packit Service ae04f2
      socket
Packit Service ae04f2
      that the caller supports or wishes to use.
Packit Service ae04f2
      The caller can supply the following structure elements in
Packit Service ae04f2
      *hints:
Packit Service ae04f2
Packit Service ae04f2
      

Packit Service ae04f2
Packit Service ae04f2
ai_family
Packit Service ae04f2
Packit Service ae04f2
            

Packit Service ae04f2
              The protocol family that should be used.
Packit Service ae04f2
              When
Packit Service ae04f2
              ai_family
Packit Service ae04f2
              is set to
Packit Service ae04f2
              PF_UNSPEC,
Packit Service ae04f2
              it means the caller will accept any protocol family supported by
Packit Service ae04f2
              the
Packit Service ae04f2
              operating system.
Packit Service ae04f2
            

Packit Service ae04f2
          
Packit Service ae04f2
ai_socktype
Packit Service ae04f2
Packit Service ae04f2
            

Packit Service ae04f2
              denotes the type of socket —
Packit Service ae04f2
              SOCK_STREAM,
Packit Service ae04f2
              SOCK_DGRAM
Packit Service ae04f2
              or
Packit Service ae04f2
              SOCK_RAW
Packit Service ae04f2
              — that is wanted.
Packit Service ae04f2
              When
Packit Service ae04f2
              ai_socktype
Packit Service ae04f2
              is zero the caller will accept any socket type.
Packit Service ae04f2
            

Packit Service ae04f2
          
Packit Service ae04f2
ai_protocol
Packit Service ae04f2
Packit Service ae04f2
            

Packit Service ae04f2
              indicates which transport protocol is wanted: IPPROTO_UDP or
Packit Service ae04f2
              IPPROTO_TCP.
Packit Service ae04f2
              If
Packit Service ae04f2
              ai_protocol
Packit Service ae04f2
              is zero the caller will accept any protocol.
Packit Service ae04f2
            

Packit Service ae04f2
          
Packit Service ae04f2
ai_flags
Packit Service ae04f2
Packit Service ae04f2
            

Packit Service ae04f2
              Flag bits.
Packit Service ae04f2
              If the
Packit Service ae04f2
              AI_CANONNAME
Packit Service ae04f2
              bit is set, a successful call to
Packit Service ae04f2
              lwres_getaddrinfo()
Packit Service ae04f2
              will return a null-terminated string containing the canonical
Packit Service ae04f2
              name
Packit Service ae04f2
              of the specified hostname in
Packit Service ae04f2
              ai_canonname
Packit Service ae04f2
              of the first
Packit Service ae04f2
              addrinfo
Packit Service ae04f2
              structure returned.
Packit Service ae04f2
              Setting the
Packit Service ae04f2
              AI_PASSIVE
Packit Service ae04f2
              bit indicates that the returned socket address structure is
Packit Service ae04f2
              intended
Packit Service ae04f2
              for used in a call to
Packit Service ae04f2
              
Packit Service ae04f2
                bind(2)
Packit Service ae04f2
              .
Packit Service ae04f2
Packit Service ae04f2
              In this case, if the hostname argument is a
Packit Service ae04f2
              NULL
Packit Service ae04f2
              pointer, then the IP address portion of the socket
Packit Service ae04f2
              address structure will be set to
Packit Service ae04f2
              INADDR_ANY
Packit Service ae04f2
              for an IPv4 address or
Packit Service ae04f2
              IN6ADDR_ANY_INIT
Packit Service ae04f2
              for an IPv6 address.
Packit Service ae04f2
            

Packit Service ae04f2
            

Packit Service ae04f2
              When
Packit Service ae04f2
              ai_flags
Packit Service ae04f2
              does not set the
Packit Service ae04f2
              AI_PASSIVE
Packit Service ae04f2
              bit, the returned socket address structure will be ready
Packit Service ae04f2
              for use in a call to
Packit Service ae04f2
              
Packit Service ae04f2
                connect(2)
Packit Service ae04f2
              
Packit Service ae04f2
              for a connection-oriented protocol or
Packit Service ae04f2
              
Packit Service ae04f2
                connect(2)
Packit Service ae04f2
              ,
Packit Service ae04f2
Packit Service ae04f2
              
Packit Service ae04f2
                sendto(2)
Packit Service ae04f2
              ,
Packit Service ae04f2
Packit Service ae04f2
              or
Packit Service ae04f2
              
Packit Service ae04f2
                sendmsg(2)
Packit Service ae04f2
              
Packit Service ae04f2
              if a connectionless protocol was chosen.
Packit Service ae04f2
              The IP address portion of the socket address structure will be
Packit Service ae04f2
              set to the loopback address if
Packit Service ae04f2
              hostname
Packit Service ae04f2
              is a
Packit Service ae04f2
              NULL
Packit Service ae04f2
              pointer and
Packit Service ae04f2
              AI_PASSIVE
Packit Service ae04f2
              is not set in
Packit Service ae04f2
              ai_flags.
Packit Service ae04f2
            

Packit Service ae04f2
            

Packit Service ae04f2
              If
Packit Service ae04f2
              ai_flags
Packit Service ae04f2
              is set to
Packit Service ae04f2
              AI_NUMERICHOST
Packit Service ae04f2
              it indicates that
Packit Service ae04f2
              hostname
Packit Service ae04f2
              should be treated as a numeric string defining an IPv4 or IPv6
Packit Service ae04f2
              address
Packit Service ae04f2
              and no name resolution should be attempted.
Packit Service ae04f2
            

Packit Service ae04f2
          
Packit Service ae04f2
Packit Service ae04f2

Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
      All other elements of the struct addrinfo passed
Packit Service ae04f2
      via hints must be zero.
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
      A hints of NULL is
Packit Service ae04f2
      treated as if
Packit Service ae04f2
      the caller provided a struct addrinfo initialized to zero
Packit Service ae04f2
      with ai_familyset to
Packit Service ae04f2
      PF_UNSPEC.
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
      After a successful call to
Packit Service ae04f2
      lwres_getaddrinfo(),
Packit Service ae04f2
      *res
Packit Service ae04f2
      is a pointer to a linked list of one or more
Packit Service ae04f2
      addrinfo
Packit Service ae04f2
      structures.
Packit Service ae04f2
      Each
Packit Service ae04f2
      struct addrinfo
Packit Service ae04f2
      in this list cn be processed by following
Packit Service ae04f2
      the
Packit Service ae04f2
      ai_next
Packit Service ae04f2
      pointer, until a
Packit Service ae04f2
      NULL
Packit Service ae04f2
      pointer is encountered.
Packit Service ae04f2
      The three members
Packit Service ae04f2
      ai_family,
Packit Service ae04f2
      ai_socktype,
Packit Service ae04f2
      and
Packit Service ae04f2
      ai_protocol
Packit Service ae04f2
      in each
Packit Service ae04f2
      returned
Packit Service ae04f2
      addrinfo
Packit Service ae04f2
      structure contain the corresponding arguments for a call to
Packit Service ae04f2
      
Packit Service ae04f2
        socket(2)
Packit Service ae04f2
      .
Packit Service ae04f2
      For each
Packit Service ae04f2
      addrinfo
Packit Service ae04f2
      structure in the list, the
Packit Service ae04f2
      ai_addr
Packit Service ae04f2
      member points to a filled-in socket address structure of length
Packit Service ae04f2
      ai_addrlen.
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
      All of the information returned by
Packit Service ae04f2
      lwres_getaddrinfo()
Packit Service ae04f2
      is dynamically allocated: the addrinfo structures, and the socket
Packit Service ae04f2
      address structures and canonical host name strings pointed to by the
Packit Service ae04f2
      addrinfostructures.
Packit Service ae04f2
      Memory allocated for the dynamically allocated structures created by
Packit Service ae04f2
      a successful call to
Packit Service ae04f2
      lwres_getaddrinfo()
Packit Service ae04f2
      is released by
Packit Service ae04f2
      lwres_freeaddrinfo().
Packit Service ae04f2
      ai
Packit Service ae04f2
      is a pointer to a
Packit Service ae04f2
      struct addrinfo
Packit Service ae04f2
      created by a call to
Packit Service ae04f2
      lwres_getaddrinfo().
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2

RETURN VALUES

Packit Service ae04f2
Packit Service ae04f2
Packit Service ae04f2
    

lwres_getaddrinfo()

Packit Service ae04f2
      returns zero on success or one of the error codes listed in
Packit Service ae04f2
      
Packit Service ae04f2
        gai_strerror(3)
Packit Service ae04f2
      
Packit Service ae04f2
      if an error occurs.  If both hostname and
Packit Service ae04f2
      servname are NULL
Packit Service ae04f2
      lwres_getaddrinfo() returns
Packit Service ae04f2
      EAI_NONAME.
Packit Service ae04f2
    

Packit Service ae04f2
  
Packit Service ae04f2
  
Packit Service ae04f2

SEE ALSO

Packit Service ae04f2
Packit Service ae04f2
    

Packit Service ae04f2
        lwres(3)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        lwres_getaddrinfo(3)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        lwres_freeaddrinfo(3)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        lwres_gai_strerror(3)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        RFC2133
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        getservbyname(3)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        bind(2)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        connect(2)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        sendto(2)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        sendmsg(2)
Packit Service ae04f2
      ,
Packit Service ae04f2
Packit Service ae04f2
      
Packit Service ae04f2
        socket(2)
Packit Service ae04f2
      .
Packit Service ae04f2
    

Packit Service ae04f2
Packit Service ae04f2
  
Packit Service ae04f2
</body>
Packit Service ae04f2
</html>