1CNETDB(3) Common Library Functions
2CNETDB(3)
3
4
5
6[1mNAME[0m
7 [1mCnetdb [22m‐ LCG netdb utilities
8
9[1mSYNOPSIS[0m
10 [1m#include <Cnetdb.h>[0m
11
12 [1mchar *Cgetnetaddress(int [4m[22msock[24m[1m, const void
13*[4m[22msa[24m[1m, size_t [4m[22msalen[24m[1m, int
14*[4m[22mskey[24m[1m,[0m
15 [1mconst char **[4m[22mnumeric_out[24m[1m, const char
16**[4m[22mname_out[24m[1m, int [4m[22mflags[24m[1m, int[0m
17 [4mcflags[24m[1m);[0m
18
19
20[1mDESCRIPTION[0m
21 [1mCnetdb [22mprovides several netdb like functions in‐
22cluding Cgethostbyname,
23 Cgethostbyaddr, Cgetservbyname, Cgetnameinfo, Cgetaddrin‐
24fo, Cgai_str‐
25 error which behave in a somewhat similar way to their
26system netdb
27 counterparts. In addition Cnetdb provides a function
28called Cgetnetad‐
29 dress which is currently the only one documented here.
30
31 Cgetnetaddress returns a DNS domain name (often
32called a hostname)
33 given either a network socket, in which case the hostname
34corresponds
35 to the peer address of the socket, or a sockaddr struc‐
36ture. The name
37 will be returned as a numeric IP address and/or optionaly
38a DNS domain
39 name.
40
41 Exactly one of either [1msock [22mor [1msa [22mmust be
42specified, the other should be
43 set to ‐1 or NULL respectively. If both are set the behav‐
44iour should be
45 considered undefined and may change in the future. If
46[1mskey [22mis NULL the
47 memory for pointers returned by Cgetnetaddress will be
48dynamically
49 allocated and it is the responsibility of the caller to
50free them when
51 done. If not NULL [1mskey [22mshould point to an int which
52is initially set to
53 a value of ‐1. The memory used to store the results re‐
54turned by Cgetne‐
55 taddress will be allocated internally and will be reused
56during subse‐
57 quent calls to Cgetnetaddress from the same thread and
58that share the
59 same value of [1mskey[22m.
60
61 If [1mnumeric_out [22mor [1mname_out [22mare not NULL the
62char pointer which they
63 reference will be reset to a pointer to a character array
64containig the
65 numeric or domain name address to be returned by the func‐
66tion. The out‐
67 put will be NULL if the function is unable to find an
68IP or domain
69 name. [1mflags [22maccepts the same bitmaped flags that
70can be set for get‐
71 nameinfo(). [1mcflags [22maccepts bitmaped flags which
72are unique to Cgetne‐
73 taddress.
74
75 If [1mNI_NUMERICHOST [22mis specified in [1mflags [22mno
76attempt is made to obtain a
77 domain name. If [1mNI_NAMEREQD [22mis specified nothing
78is returned unless a
79 domain name address can be determined. [1mNI_NUMERICHOST
80[22mand [1mNI_NAMEREQD[0m
81 are mutually exclusive. Other [1mflags [22moptions may
82be set and will have
83 the effect described for getnameinfo().
84
85 [1mcflags [22mmay take the bitmaped flags [1mCNA_WANT‐
86LOOPBACK[22m, [1mCNA_NOFWDLOOKUP[0m
87 and [1mCNA_FWDLOOKUP[22m.
88
89 By default if the address to be returned is determined to
90be the loop‐
91 back address any domain name returned will be that
92of the local
93 machine. If [1mCNA_WANTLOOPBACK [22mis specified any
94domain name returned
95 will be that associated with the loopback address,
96usually local‐
97 host.localdomain.
98
99 A forward lookup verification of the domain name may
100be optionally
101 specified with the [1mCNA_FWDLOOKUP [22mflag. The forward
102lookup means that
103 one of the address to which a domain name resolves
104must match the
105 address passed to Cgetnetaddress. If the match failes the
106domain name
107 will be considered to not be available. By default, or
108if the option
109 [1mCNA_NOFWDLOOKUP [22mis passed in [1mcflags[22m, the
110forward lookup check is not
111 performed or required. The behavior if both [1mC‐
112NA_FWDLOOKUP [22mand
113 [1mCNA_NOFWDLOOKUP [22mare specified is undefined.
114
115[1mRETURN VALUE[0m
116 Cgetnetaddress() returns a pointer to the domain name, if
117available, or
118 otherwise to the numeric IP address, if available.
119If neither is
120 available NULL is returned.
121
122[1mSEE ALSO[0m
123 [1mgethostbyname[22m(3), [1mgethostbyaddr[22m(3), [1mget‐
124servbyname[22m(3), [1mgetnameinfo[22m(3),
125 [1mgetaddrinfo[22m(3), [1mgai_strerror[22m(3)
126
127
128[1mAUTHOR[0m
129 [1mLCG Grid Deployment [22mTeam and [1mDPM [22mTeam <hep‐
130service‐dpm@cern.ch>
131
132
133
134LCG $Date: 2008/02/13 17:29:10 $
135CNETDB(3)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198