xref: /openbsd-src/lib/libc/asr/getnetnamadr_async.c (revision b5afe7042216e17edcaa41735624e6dac1b122e3)
1*b5afe704Sschwarze /*	$OpenBSD: getnetnamadr_async.c,v 1.26 2018/04/28 15:16:49 schwarze Exp $	*/
2b44da627Seric /*
3b44da627Seric  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
4b44da627Seric  *
5b44da627Seric  * Permission to use, copy, modify, and distribute this software for any
6b44da627Seric  * purpose with or without fee is hereby granted, provided that the above
7b44da627Seric  * copyright notice and this permission notice appear in all copies.
8b44da627Seric  *
9b44da627Seric  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10b44da627Seric  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11b44da627Seric  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12b44da627Seric  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13b44da627Seric  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14b44da627Seric  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15b44da627Seric  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16b44da627Seric  */
1780f48568Seric 
18b44da627Seric #include <sys/types.h>
19b44da627Seric #include <sys/socket.h>
20b44da627Seric #include <arpa/inet.h>
21b44da627Seric #include <arpa/nameser.h>
22d216d6b1Seric #include <netdb.h>
23d216d6b1Seric #include <asr.h>
24b44da627Seric 
25b44da627Seric #include "asr_private.h"
26b44da627Seric 
275be03f8fSeric struct asr_query *
getnetbyname_async(const char * name,void * asr)285be03f8fSeric getnetbyname_async(const char *name, void *asr)
29b44da627Seric {
305be03f8fSeric 	struct asr_query *as;
31b44da627Seric 
32*b5afe704Sschwarze 	if ((as = gethostbyname_async(name, asr)) != NULL)
33*b5afe704Sschwarze 		as->as_flags |= ASYNC_GETNET;
34b44da627Seric 	return (as);
35b44da627Seric }
365826fd8cSguenther DEF_WEAK(getnetbyname_async);
37b44da627Seric 
385be03f8fSeric struct asr_query *
getnetbyaddr_async(in_addr_t net,int family,void * asr)395be03f8fSeric getnetbyaddr_async(in_addr_t net, int family, void *asr)
40b44da627Seric {
41*b5afe704Sschwarze 	struct in_addr	  in;
425be03f8fSeric 	struct asr_query *as;
43b44da627Seric 
44*b5afe704Sschwarze 	in.s_addr = htonl(net);
45*b5afe704Sschwarze 	as = gethostbyaddr_async(&in, sizeof(in), family, asr);
46*b5afe704Sschwarze 	if (as != NULL)
47*b5afe704Sschwarze 		as->as_flags |= ASYNC_GETNET;
48b44da627Seric 	return (as);
49b44da627Seric }
505826fd8cSguenther DEF_WEAK(getnetbyaddr_async);
51