1CNETDB(3) Common Library Functions CNETDB(3)
2
3
4
6 Cnetdb - LCG netdb utilities
7
9 #include <Cnetdb.h>
10
11 char *Cgetnetaddress(int sock, const void *sa, size_t salen, int *skey,
12 const char **numeric_out, const char **name_out, int flags, int
13 cflags);
14
15
17 Cnetdb provides several netdb like functions including Cgethostbyname,
18 Cgethostbyaddr, Cgetservbyname, Cgetnameinfo, Cgetaddrinfo, Cgai_str‐
19 error which behave in a somewhat similar way to their system netdb
20 counterparts. In addition Cnetdb provides a function called Cgetnetad‐
21 dress which is currently the only one documented here.
22
23 Cgetnetaddress returns a DNS domain name (often called a hostname)
24 given either a network socket, in which case the hostname corresponds
25 to the peer address of the socket, or a sockaddr structure. The name
26 will be returned as a numeric IP address and/or optionaly a DNS domain
27 name.
28
29 Exactly one of either sock or sa must be specified, the other should be
30 set to -1 or NULL respectively. If both are set the behaviour should be
31 considered undefined and may change in the future. If skey is NULL the
32 memory for pointers returned by Cgetnetaddress will be dynamically
33 allocated and it is the responsibility of the caller to free them when
34 done. If not NULL skey should point to an int which is initially set to
35 a value of -1. The memory used to store the results returned by Cgetne‐
36 taddress will be allocated internally and will be reused during subse‐
37 quent calls to Cgetnetaddress from the same thread and that share the
38 same value of skey.
39
40 If numeric_out or name_out are not NULL the char pointer which they
41 reference will be reset to a pointer to a character array containig the
42 numeric or domain name address to be returned by the function. The out‐
43 put will be NULL if the function is unable to find an IP or domain
44 name. flags accepts the same bitmaped flags that can be set for get‐
45 nameinfo(). cflags accepts bitmaped flags which are unique to Cgetne‐
46 taddress.
47
48 If NI_NUMERICHOST is specified in flags no attempt is made to obtain a
49 domain name. If NI_NAMEREQD is specified nothing is returned unless a
50 domain name address can be determined. NI_NUMERICHOST and NI_NAMEREQD
51 are mutually exclusive. Other flags options may be set and will have
52 the effect described for getnameinfo().
53
54 cflags may take the bitmaped flags CNA_WANTLOOPBACK, CNA_NOFWDLOOKUP
55 and CNA_FWDLOOKUP.
56
57 By default if the address to be returned is determined to be the loop‐
58 back address any domain name returned will be that of the local
59 machine. If CNA_WANTLOOPBACK is specified any domain name returned
60 will be that associated with the loopback address, usually local‐
61 host.localdomain.
62
63 A forward lookup verification of the domain name may be optionally
64 specified with the CNA_FWDLOOKUP flag. The forward lookup means that
65 one of the address to which a domain name resolves must match the
66 address passed to Cgetnetaddress. If the match failes the domain name
67 will be considered to not be available. By default, or if the option
68 CNA_NOFWDLOOKUP is passed in cflags, the forward lookup check is not
69 performed or required. The behavior if both CNA_FWDLOOKUP and
70 CNA_NOFWDLOOKUP are specified is undefined.
71
73 Cgetnetaddress() returns a pointer to the domain name, if available, or
74 otherwise to the numeric IP address, if available. If neither is
75 available NULL is returned.
76
78 gethostbyname(3), gethostbyaddr(3), getservbyname(3), getnameinfo(3),
79 getaddrinfo(3), gai_strerror(3)
80
81
83 LCG Grid Deployment Team and DPM Team <hep-service-dpm@cern.ch>
84
85
86
87LCG $Date: 2008/02/13 17:29:10 $ CNETDB(3)