Cnetdb man page

CNETDB(3) Common Library Functions CNETDB(3)

[1mCnetdb [22m- LCG netdb utilities

[1m#include <Cnetdb.h>[0m

[1mchar *Cgetnetaddress(int [4m[22msock[24m[1m, const void *[4m[22msa[24m[1m, size_t [4m[22msalen[24m[1m, int *[4m[22mskey[24m[1m,[0m
[1mconst char **[4m[22mnumeric_out[24m[1m, const char **[4m[22mname_out[24m[1m, int [4m[22mflags[24m[1m, int[0m

[1mCnetdb [22mprovides several netdb like functions including Cgethostbyname,
Cgethostbyaddr, Cgetservbyname, Cgetnameinfo, Cgetaddrinfo, Cgai_str-
error which behave in a somewhat similar way to their system netdb
counterparts. In addition Cnetdb provides a function called Cgetnetad-
dress 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

Exactly one of either [1msock [22mor [1msa [22mmust 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 [1mskey [22mis 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 [1mskey [22mshould point to an int which is initially set to
a value of -1. The memory used to store the results returned by Cgetne-
taddress will be allocated internally and will be reused during subse-
quent calls to Cgetnetaddress from the same thread and that share the
same value of [1mskey[22m.

If [1mnumeric_out [22mor [1mname_out [22mare 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 out-
put will be NULL if the function is unable to find an IP or domain
name. [1mflags [22maccepts the same bitmaped flags that can be set for get-
nameinfo(). [1mcflags [22maccepts bitmaped flags which are unique to Cgetne-

If [1mNI_NUMERICHOST [22mis specified in [1mflags [22mno attempt is made to obtain a
domain name. If [1mNI_NAMEREQD [22mis specified nothing is returned unless a
domain name address can be determined. [1mNI_NUMERICHOST [22mand [1mNI_NAMEREQD[0m
are mutually exclusive. Other [1mflags [22moptions may be set and will have
the effect described for getnameinfo().

[1mcflags [22mmay take the bitmaped flags [1mCNA_WANTLOOPBACK[22m, [1mCNA_NOFWDLOOKUP[0m
and [1mCNA_FWDLOOKUP[22m.

By default if the address to be returned is determined to be the loop-
back address any domain name returned will be that of the local
machine. If [1mCNA_WANTLOOPBACK [22mis specified any domain name returned
will be that associated with the loopback address, usually local-

A forward lookup verification of the domain name may be optionally
specified with the [1mCNA_FWDLOOKUP [22mflag. 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
[1mCNA_NOFWDLOOKUP [22mis passed in [1mcflags[22m, the forward lookup check is not
performed or required. The behavior if both [1mCNA_FWDLOOKUP [22mand
[1mCNA_NOFWDLOOKUP [22mare specified is undefined.

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.

[1mSEE ALSO[0m
[1mgethostbyname[22m(3), [1mgethostbyaddr[22m(3), [1mgetservbyname[22m(3), [1mgetnameinfo[22m(3),
[1mgetaddrinfo[22m(3), [1mgai_strerror[22m(3)

[1mLCG Grid Deployment [22mTeam and [1mDPM [22mTeam <>

LCG $Date: 2008/02/13 17:29:10 $ CNETDB(3)