getnameinfo(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

getnameinfo(3c)

Standard C Library Functions                                   getnameinfo(3C)



NAME
       getnameinfo - get name information

SYNOPSIS
       #include <sys/socket.h>
       #include <netdb.h>

       int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
            char *restrict node, socklen_t nodelen,
            char *restrict service, socklen_t servicelen,
            int flags);

DESCRIPTION
       The  getnameinfo()  function translates a socket address to a node name
       and service location, all of which are defined as in getaddrinfo(3C).


       The sa argument points to a socket address structure to be  translated.
       If the socket address structure contains an IPv4-mapped IPv6 address or
       an IPv4-compatible IPv6 address, the implementation extracts the embed‐
       ded IPv4 address and lookup the node name for that IPv4 address.


       If  the node argument is non-NULL and the nodelen argument is non-zero,
       then the node argument points to a buffer able to contain up to nodelen
       characters  that receives the node name as a null-terminated string. If
       the node argument is NULL or the nodelen argument  is  zero,  the  node
       name is not returned. If the node's name cannot be located, the numeric
       form of the node's address is returned instead of its name.


       If the service argument is non-NULL and the servicelen argument is non-
       zero,  then  the service argument points to a buffer able to contain up
       to servicelen bytes that receives the service name as a null-terminated
       string.  If  the service argument is NULL or the servicelen argument is
       zero, the service name is not returned. If the service's name cannot be
       located, the numeric form of the service address (for example, its port
       number) is returned instead of its name. The function can  also  return
       the IPv6 zone-id in the form:

         <address>%<zone-id>



       as described in getaddrinfo(3C).


       The  flags  argument  is a flag that changes the default actions of the
       function. By default the fully-qualified domain  name  (FQDN)  for  the
       host is returned, but:

           o      If the flag bit NI_NOFQDN is set, only the node name portion
                  of the FQDN is returned for local hosts.


           o      If the flag bit NI_NUMERICHOST is set, the numeric  form  of
                  the  host's  address  is returned instead of its name, under
                  all circumstances.


           o      If the flag bit NI_NAMEREQD is set, an error is returned  if
                  the host's name cannot be located.


           o      If  the  flag bit NI_NUMERICSERV is set, the numeric form of
                  the service address is returned (for example, its port  num‐
                  ber) instead of its name, under all circumstances.


           o      If  the  flag  bit  NI_DGRAM is set, this indicates that the
                  service is a  datagram  service  (SOCK_DGRAM).  The  default
                  behavior  assumes  that  the  service  is  a  stream service
                  (SOCK_STREAM).



       These NI_* flags are defined in <netdb.h>.

RETURN VALUES
       A 0 return value for getnameinfo() indicates successful  completion;  a
       non-zero  return  value  indicates failure. The possible values for the
       failures are listed in the ERRORS section.


       Upon successful completion, getnameinfo() returns the node and  service
       names,  if  requested,  in the buffers provided. The returned names are
       always null-terminated strings.

ERRORS
       The getnameinfo() function will fail if:

       EAI_AGAIN       The name could not be resolved  at  this  time.  Future
                       attempts might succeed.


       EAI_BADFLAGS    The flags argument had an invalid value.


       EAI_FAIL        A non-recoverable error occurred.


       EAI_FAMILY      The  address  family  was not recognized or the address
                       length was invalid for the specified family.


       EAI_MEMORY      There was a memory allocation failure.


       EAI_NONAME      The name does not resolve for the supplied  parameters.
                       NI_NAMEREQD  is  set  and  the  host's  name  cannot be
                       located, or both nodename and servname were NULL.


       EAI_SYSTEM      A system error occurred. The error code can be found in
                       errno.


USAGE
       If the returned values are to be used as part of any further name reso‐
       lution (for example, passed to getaddrinfo()), applications should pro‐
       vide buffers large enough to store any result possible on the system.


       Given the IPv4-mapped IPv6 address "::ffff:1.2.3.4", the implementation
       performs a lookup as if the socket address structure contains the  IPv4
       address "1.2.3.4".

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelMT-Safe _  Stan‐
       dardSee standards(7).


SEE ALSO
       gai_strerror(3C),   getaddrinfo(3C),   getservbyname(3C),   socket(3C),
       attributes(7), standards(7)


       Gilligan, R. RFC 3493, Basic Socket Interface Extensions for IPv6. Net‐
       work Working Group. February 2003. https://tools.ietf.org/html/rfc3493

NOTES
       The  IPv6  unspecified  address  ("::")  and  the IPv6 loopback address
       ("::1") are not IPv4-compatible addresses. If the address is  the  IPv6
       unspecified  address ("::"), a lookup is not performed, and the EAI_NO‐
       NAME error is returned.


       The two NI_NUMERICxxx flags are required to support the  -n  flag  that
       many commands provide.


       The  NI_DGRAM  flag  is  required for the few AF_INET and AF_INET6 port
       numbers (for example, [512,514]) that represent different services  for
       UDP and TCP.

HISTORY
       The getnameinfo() function was added to Oracle Solaris in the Solaris 8
       release.



Oracle Solaris 11.4               20 Jan 2021                  getnameinfo(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3