Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cnetdb(3) [debian man page]

CNETDB(3)						     Common Library Functions							 CNETDB(3)

NAME
Cnetdb - LCG netdb utilities SYNOPSIS
#include <Cnetdb.h> char *Cgetnetaddress(int sock, const void *sa, size_t salen, int *skey, const char **numeric_out, const char **name_out, int flags, int cflags); DESCRIPTION
Cnetdb provides several netdb like functions including Cgethostbyname, Cgethostbyaddr, Cgetservbyname, Cgetnameinfo, Cgetaddrinfo, Cgai_strerror which behave in a somewhat similar way to their system netdb counterparts. In addition Cnetdb provides a function called Cgetnetaddress which is currently the only one documented here. Cgetnetaddress returns a DNS domain name (often called a hostname) given either a network socket, in which case the hostname corresponds to the peer address of the socket, or a sockaddr structure. The name will be returned as a numeric IP address and/or optionaly a DNS domain name. Exactly one of either sock or sa must be specified, the other should be set to -1 or NULL respectively. If both are set the behaviour should be considered undefined and may change in the future. If skey is NULL the memory for pointers returned by Cgetnetaddress will be dynamically allocated and it is the responsibility of the caller to free them when done. If not NULL skey should point to an int which is initially set to a value of -1. The memory used to store the results returned by Cgetnetaddress will be allocated internally and will be reused during subsequent calls to Cgetnetaddress from the same thread and that share the same value of skey. If numeric_out or name_out are not NULL the char pointer which they reference will be reset to a pointer to a character array containig the numeric or domain name address to be returned by the function. The output will be NULL if the function is unable to find an IP or domain name. flags accepts the same bitmaped flags that can be set for getnameinfo(). cflags accepts bitmaped flags which are unique to Cgetne- taddress. If NI_NUMERICHOST is specified in flags no attempt is made to obtain a domain name. If NI_NAMEREQD is specified nothing is returned unless a domain name address can be determined. NI_NUMERICHOST and NI_NAMEREQD are mutually exclusive. Other flags options may be set and will have the effect described for getnameinfo(). cflags may take the bitmaped flags CNA_WANTLOOPBACK, CNA_NOFWDLOOKUP and CNA_FWDLOOKUP. By default if the address to be returned is determined to be the loopback address any domain name returned will be that of the local machine. If CNA_WANTLOOPBACK is specified any domain name returned will be that associated with the loopback address, usually local- host.localdomain. A forward lookup verification of the domain name may be optionally specified with the CNA_FWDLOOKUP flag. The forward lookup means that one of the address to which a domain name resolves must match the address passed to Cgetnetaddress. If the match failes the domain name will be considered to not be available. By default, or if the option CNA_NOFWDLOOKUP is passed in cflags, the forward lookup check is not performed or required. The behavior if both CNA_FWDLOOKUP and CNA_NOFWDLOOKUP are specified is undefined. RETURN VALUE
Cgetnetaddress() returns a pointer to the domain name, if available, or otherwise to the numeric IP address, if available. If neither is available NULL is returned. SEE ALSO
gethostbyname(3), gethostbyaddr(3), getservbyname(3), getnameinfo(3), getaddrinfo(3), gai_strerror(3) AUTHOR
LCG Grid Deployment Team and DPM Team <hep-service-dpm@cern.ch> LCG
$Date: 2008/02/13 17:29:10 $ CNETDB(3)

Check Out this Related Man Page

LWRES_GETNAMEINFO(3)						       BIND9						      LWRES_GETNAMEINFO(3)

NAME
lwres_getnameinfo - lightweight resolver socket address structure to hostname and service name SYNOPSIS
#include <lwres/netdb.h> int lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); DESCRIPTION
This function is equivalent to the getnameinfo(3) function defined in RFC2133. lwres_getnameinfo() returns the hostname for the struct sockaddr sa which is salen bytes long. The hostname is of length hostlen and is returned via *host. The maximum length of the hostname is 1025 bytes: NI_MAXHOST. The name of the service associated with the port number in sa is returned in *serv. It is servlen bytes long. The maximum length of the service name is NI_MAXSERV - 32 bytes. The flags argument sets the following bits: NI_NOFQDN A fully qualified domain name is not required for local hosts. The local part of the fully qualified domain name is returned instead. NI_NUMERICHOST Return the address in numeric form, as if calling inet_ntop(), instead of a host name. NI_NAMEREQD A name is required. If the hostname cannot be found in the DNS and this flag is set, a non-zero error code is returned. If the hostname is not found and the flag is not set, the address is returned in numeric form. NI_NUMERICSERV The service name is returned as a digit string representing the port number. NI_DGRAM Specifies that the service being looked up is a datagram service, and causes getservbyport() to be called with a second argument of "udp" instead of its default of "tcp". This is required for the few ports (512-514) that have different services for UDP and TCP. RETURN VALUES
lwres_getnameinfo() returns 0 on success or a non-zero error code if an error occurs. SEE ALSO
RFC2133(), getservbyport(3), lwres(3), lwres_getnameinfo(3), lwres_getnamebyaddr(3). lwres_net_ntop(3). BUGS
RFC2133 fails to define what the nonzero return values of getnameinfo(3) are. COPYRIGHT
Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") Copyright (C) 2000, 2001 Internet Software Consortium. BIND9 Jun 30, 2000 LWRES_GETNAMEINFO(3)
Man Page