2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _NETDB_ASYNC_H_
26 #define _NETDB_ASYNC_H_
28 #include <sys/cdefs.h>
29 #include <mach/mach.h>
32 #define gethostbyname_async_handle_reply gethostbyname_async_handleReply
33 #define gethostbyaddr_async_handle_reply gethostbyaddr_async_handleReply
34 #define getipnodebyaddr_async_handle_reply getipnodebyaddr_async_handleReply
35 #define getipnodebyname_async_handle_reply getipnodebyname_async_handleReply
37 /* SPI for parallel / fast getaddrinfo */
38 #define AI_PARALLEL 0x00000008
46 typedef void (*getaddrinfo_async_callback
)(int32_t status
, struct addrinfo
*res
, void *context
);
47 int32_t getaddrinfo_async_start(mach_port_t
*p
, const char *nodename
, const char *servname
, const struct addrinfo
*hints
, getaddrinfo_async_callback callback
, void *context
);
48 int32_t getaddrinfo_async_send(mach_port_t
*p
, const char *nodename
, const char *servname
, const struct addrinfo
*hints
);
49 int32_t getaddrinfo_async_receive(mach_port_t p
, struct addrinfo
**res
);
50 int32_t getaddrinfo_async_handle_reply(void *msg
);
51 void getaddrinfo_async_cancel(mach_port_t p
);
57 typedef void (*getnameinfo_async_callback
)(int32_t status
, char *host
, char *serv
, void *context
);
58 int32_t getnameinfo_async_start(mach_port_t
*p
, const struct sockaddr
*sa
, size_t salen
, int flags
, getnameinfo_async_callback callback
, void *context
);
59 int32_t getnameinfo_async_send(mach_port_t
*p
, const struct sockaddr
*sa
, size_t salen
, int flags
);
60 int32_t getnameinfo_async_receive(mach_port_t p
, char **host
, char **serv
);
61 int32_t getnameinfo_async_handle_reply(void *msg
);
62 void getnameinfo_async_cancel(mach_port_t p
);
67 typedef void (*dns_async_callback
)(int32_t status
, char *buf
, uint32_t len
, struct sockaddr
*from
, int fromlen
, void *context
);
68 int32_t dns_async_start(mach_port_t
*p
, const char *name
, uint16_t dnsclass
, uint16_t dnstype
, uint32_t do_search
, dns_async_callback callback
, void *context
);
69 int32_t dns_async_send(mach_port_t
*p
, const char *name
, uint16_t dnsclass
, uint16_t dnstype
, uint32_t do_search
);
70 int32_t dns_async_receive(mach_port_t p
, char **buf
, uint32_t *len
, struct sockaddr
**from
, uint32_t *fromlen
);
71 int32_t dns_async_handle_reply(void *msg
);
72 void dns_async_cancel(mach_port_t p
);
79 @typedef gethostbyaddr_async_callback
80 @discussion Type of the callback function used when a
81 gethostbyaddr_async_start() request is delivered.
82 @param hent The resolved host entry.
83 @param context The context provided when the request
86 typedef void (*gethostbyaddr_async_callback
)(struct hostent
*hent
, void *context
);
89 @function gethostbyaddr_async_start
90 @description Asynchronously resolves an Internet address
91 @param addr The address to be resolved.
92 @param len The length, in bytes, of the address.
94 @param callout The function to be called when the specified
95 address has been resolved.
96 @param context A user specified context which will be passed
97 to the callout function.
98 @result A mach reply port which will be sent a message when
99 the addr resolution has completed. This message
100 should be passed to the gethostbyaddr_async_handleReply
101 function. A NULL value indicates that no address
102 was specified or some other error occurred which
103 prevented the resolution from being started.
106 gethostbyaddr_async_start(const char *addr
, int len
, int type
, gethostbyaddr_async_callback callout
, void *context
);
109 @function gethostbyaddr_async_cancel
110 @description Cancel an asynchronous request currently in progress.
111 @param port The mach reply port associated with the request to be cancelled.
113 void gethostbyaddr_async_cancel(mach_port_t port
);
116 @function gethostbyaddr_async_handleReply
117 @description This function should be called with the Mach message sent
118 to the port returned by the call to gethostbyaddr_async_start.
119 The reply message will be interpreted and will result in a
120 call to the specified callout function.
121 @param replyMsg The Mach message.
123 void gethostbyaddr_async_handleReply(void *replyMsg
);
126 @typedef gethostbyname_async_callback
127 @discussion Type of the callback function used when a
128 gethostbyname_async_start() request is delivered.
129 @param hent The resolved host entry.
130 @param context The context provided when the request was initiated.
132 typedef void (*gethostbyname_async_callback
)(struct hostent
*hent
, void *context
);
135 @function gethostbyname_async_start
136 @description Asynchronously resolves a hostname
137 @param name The hostname to be resolved.
138 @param callout The function to be called when the specified
139 hostname has been resolved.
140 @param context A user specified context which will be passed
141 to the callout function.
142 @result A mach reply port which will be sent a message when
143 the name resolution has completed. This message
144 should be passed to the gethostbyname_async_handleReply
145 function. A NULL value indicates that no hostname
146 was specified or some other error occurred which
147 prevented the resolution from being started.
149 mach_port_t
gethostbyname_async_start(const char *name
, gethostbyname_async_callback callout
, void *context
);
152 @function gethostbyname_async_cancel
153 @description Cancel an asynchronous request currently in progress.
154 @param port The mach reply port associated with the request to be cancelled.
156 void gethostbyname_async_cancel(mach_port_t port
);
159 @function gethostbyname_async_handleReply
160 @description This function should be called with the Mach message sent
161 to the port returned by the call to gethostbyname_async_start.
162 The reply message will be interpreted and will result in a
163 call to the specified callout function.
164 @param replyMsg The Mach message.
166 void gethostbyname_async_handleReply(void *replyMsg
);
169 @typedef getipnodebyaddr_async_callback
170 @discussion Type of the callback function used when a
171 getipnodebyaddr_async_start() request is delivered.
172 @param hent The resolved host entry. If not NULL, the caller
173 must call freehostent() on the host entry.
174 @param error If error code if the resolved host entry is NULL
175 @param context The context provided when the request was initiated.
177 typedef void (*getipnodebyaddr_async_callback
)(struct hostent
*hent
, int error
, void *context
);
180 @function getipnodebyaddr_async_start
181 @description Asynchronously resolves an Internet address
182 @param addr The address to be resolved.
183 @param len The length, in bytes, of the address.
184 @param af The address family
186 @param callout The function to be called when the specified
187 address has been resolved.
188 @param context A user specified context which will be passed
189 to the callout function.
190 @result A mach reply port which will be sent a message when
191 the addr resolution has completed. This message
192 should be passed to the getipnodebyaddr_async_handleReply
193 function. A NULL value indicates that no address
194 was specified or some other error occurred which
195 prevented the resolution from being started.
197 mach_port_t
getipnodebyaddr_async_start(const void *addr
, size_t len
, int af
, int *error
, getipnodebyaddr_async_callback callout
, void *context
);
200 @function getipnodebyaddr_async_cancel
201 @description Cancel an asynchronous request currently in progress.
202 @param port The mach reply port associated with the request to be cancelled.
204 void getipnodebyaddr_async_cancel(mach_port_t port
);
207 @function getipnodebyaddr_async_handleReply
208 @description This function should be called with the Mach message sent
209 to the port returned by the call to getipnodebyaddr_async_start.
210 The reply message will be interpreted and will result in a
211 call to the specified callout function.
212 @param replyMsg The Mach message.
214 void getipnodebyaddr_async_handleReply(void *replyMsg
);
218 @typedef getipnodebyname_async_callback
219 @discussion Type of the callback function used when a
220 getipnodebyname_async_start() request is delivered.
221 @param hent The resolved host entry. If not NULL, the caller
222 must call freehostent() on the host entry.
223 @param error If error code if the resolved host entry is NULL
224 @param context The context provided when the request was initiated.
226 typedef void (*getipnodebyname_async_callback
)(struct hostent
*hent
, int error
, void *context
);
229 @function getipnodebyname_async_start
230 @description Asynchronously resolves a hostname
231 @param name The hostname to be resolved.
235 @param callout The function to be called when the specified
236 hostname has been resolved.
237 @param context A user specified context which will be passed
238 to the callout function.
239 @result A mach reply port which will be sent a message when
240 the name resolution has completed. This message
241 should be passed to the getipnodebyname_async_handleReply
242 function. A NULL value indicates that no hostname
243 was specified or some other error occurred which
244 prevented the resolution from being started.
246 mach_port_t
getipnodebyname_async_start(const char *name
, int af
, int flags
, int *error
, getipnodebyname_async_callback callout
, void *context
);
249 @function getipnodebyname_async_cancel
250 @description Cancel an asynchronous request currently in progress.
251 @param port The mach reply port associated with the request to be cancelled.
253 void getipnodebyname_async_cancel(mach_port_t port
);
256 @function getipnodebyname_async_handleReply
257 @description This function should be called with the Mach message sent
258 to the port returned by the call to getipnodebyname_async_start.
259 The reply message will be interpreted and will result in a
260 call to the specified callout function.
261 @param replyMsg The Mach message.
263 void getipnodebyname_async_handleReply(void *replyMsg
);
267 #endif /* !_NETDB_ASYNC_H_ */