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