The OpenNET Project / Index page

[ новости /+++ | форум | wiki | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 ТемаНаборКатегория 
 
 [Cписок руководств | Печать]

getipnodebyname (3)
  • getipnodebyname (3) ( Solaris man: Библиотечные вызовы )
  • >> getipnodebyname (3) ( FreeBSD man: Библиотечные вызовы )
  • getipnodebyname (3) ( Русские man: Библиотечные вызовы )
  • getipnodebyname (3) ( Linux man: Библиотечные вызовы )

  • BSD mandoc
     

    NAME

    getipnodebyname
    
     
    getipnodebyaddr
    
     
    freehostent
    
     - nodename-to-address and address-to-nodename translation
    
    
     
    

    LIBRARY

    Lb libc
    
     
    

    SYNOPSIS

       #include <sys/types.h>
       #include <sys/socket.h>
       #include <netdb.h>
    struct hostent * getipnodebyname (const char *name int af int flags int *error_num);
    struct hostent * getipnodebyaddr (const void *src size_t len int af int *error_num);
    void freehostent (struct hostent *ptr);
     

    DESCRIPTION

    The getipnodebyname ();
    and getipnodebyaddr ();
    functions are very similar to gethostbyname(3), gethostbyname2(3) and gethostbyaddr(3). The functions cover all the functionalities provided by the older ones, and provide better interface to programmers. The functions require additional arguments, Fa af , and Fa flags , for specifying address family and operation mode. The additional arguments allow programmer to get address for a nodename, for specific address family (such as AF_INET or AF_INET6 ) The functions also require an additional pointer argument, Fa error_num to return the appropriate error code, to support thread safe error code returns.

    The type and usage of the return value, struct hostent is described in gethostbyname(3).

    For getipnodebyname (,);
    the Fa name argument can be either a node name or a numeric address string (i.e., a dotted-decimal IPv4 address or an IPv6 hex address). The Fa af argument specifies the address family, either AF_INET or AF_INET6 The Fa flags argument specifies the types of addresses that are searched for, and the types of addresses that are returned. We note that a special flags value of AI_DEFAULT (defined below) should handle most applications. That is, porting simple applications to use IPv6 replaces the call

       hptr = gethostbyname(name);
    

    with

       hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
    

    Applications desiring finer control over the types of addresses searched for and returned, can specify other combinations of the Fa flags argument.

    A Fa flags of 0 implies a strict interpretation of the Fa af argument:

    Other constants can be logically-ORed into the Fa flags argument, to modify the behavior of the function.

    The special flags value of AI_DEFAULT is defined as

       #define  AI_DEFAULT  (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
    

    We noted that the getipnodebyname ();
    function must allow the Fa name argument to be either a node name or a literal address string (i.e., a dotted-decimal IPv4 address or an IPv6 hex address). This saves applications from having to call inet_pton3 to handle literal address strings. When the Fa name argument is a literal address string, the Fa flags argument is always ignored.

    There are four scenarios based on the type of literal address string and the value of the Fa af argument. The two simple cases are when Fa name is a dotted-decimal IPv4 address and Fa af equals AF_INET or when Fa name is an IPv6 hex address and Fa af equals AF_INET6 The members of the returned hostent structure are: h_name points to a copy of the Fa name argument, h_aliases is a NULL pointer, h_addrtype is a copy of the Fa af argument, h_length is either 4 (for AF_INET or 16 (for AF_INET6 ) h_addr_list[0] is a pointer to the 4-byte or 16-byte binary address, and h_addr_list[1] is a NULL pointer.

    When Fa name is a dotted-decimal IPv4 address and Fa af equals AF_INET6 and AI_V4MAPPED is specified, an IPv4-mapped IPv6 address is returned: h_name points to an IPv6 hex address containing the IPv4-mapped IPv6 address, h_aliases is a NULL pointer, h_addrtype is AF_INET6 h_length is 16, h_addr_list[0] is a pointer to the 16-byte binary address, and h_addr_list[1] is a NULL pointer.

    It is an error when Fa name is an IPv6 hex address and Fa af equals AF_INET The function's return value is a NULL pointer and the value pointed to by Fa error_num equals HOST_NOT_FOUND

    The getipnodebyaddr ();
    function takes almost the same argument as gethostbyaddr(3), but adds a pointer to return an error number. Additionally it takes care of IPv4-mapped IPv6 addresses, and IPv4-compatible IPv6 addresses.

    The getipnodebyname ();
    and getipnodebyaddr ();
    functions dynamically allocate the structure to be returned to the caller. The freehostent ();
    function reclaims memory region allocated and returned by getipnodebyname ();
    or getipnodebyaddr (.);
     

    FILES

    /etc/hosts
    /etc/nsswitch.conf
    /etc/resolv.conf

     

    DIAGNOSTICS

    The getipnodebyname ();
    and getipnodebyaddr ();
    functions returns NULL on errors. The integer values pointed to by Fa error_num may then be checked to see whether this is a temporary failure or an invalid or unknown host. The meanings of each error code are described in gethostbyname(3).  

    SEE ALSO

    getaddrinfo(3), gethostbyaddr(3), gethostbyname(3), getnameinfo(3), hosts(5), nsswitch.conf5, services(5), hostname(7), named(8)

    R. Gilligan S. Thomson J. Bound W. Stevens Basic Socket Interface Extensions for IPv6 RFC2553 March 1999
     

    STANDARDS

    The getipnodebyname ();
    and getipnodebyaddr ();
    functions are documented in ``Basic Socket Interface Extensions for IPv6'' (RFC2553).  

    HISTORY

    The implementation first appeared in KAME advanced networking kit.  

    BUGS

    The getipnodebyname ();
    and getipnodebyaddr ();
    functions do not handle scoped IPv6 address properly. If you use these functions, your program will not be able to handle scoped IPv6 addresses. For IPv6 address manipulation, getaddrinfo (3);
    and getnameinfo (3);
    are recommended.

    The text was shamelessly copied from RFC2553.


     

    Index

    NAME
    LIBRARY
    SYNOPSIS
    DESCRIPTION
    FILES
    DIAGNOSTICS
    SEE ALSO
    STANDARDS
    HISTORY
    BUGS


    Поиск по тексту MAN-ов: 




    Партнёры:
    PostgresPro
    Inferno Solutions
    Hosting by Hoster.ru
    Хостинг:

    Закладки на сайте
    Проследить за страницей
    Created 1996-2024 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру