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 <sys/types.h>
19 #include <sys/socket.h>
20 #include <arpa/inet.h>
21 #include <arpa/nameser.h>
22 #include <netdb.h>
23 #include <asr.h>
24
25 #include "asr_private.h"
26
27 struct asr_query *
getnetbyname_async(const char * name,void * asr)28 getnetbyname_async(const char *name, void *asr)
29 {
30 struct asr_query *as;
31
32 if ((as = gethostbyname_async(name, asr)) != NULL)
33 as->as_flags |= ASYNC_GETNET;
34 return (as);
35 }
36 DEF_WEAK(getnetbyname_async);
37
38 struct asr_query *
getnetbyaddr_async(in_addr_t net,int family,void * asr)39 getnetbyaddr_async(in_addr_t net, int family, void *asr)
40 {
41 struct in_addr in;
42 struct asr_query *as;
43
44 in.s_addr = htonl(net);
45 as = gethostbyaddr_async(&in, sizeof(in), family, asr);
46 if (as != NULL)
47 as->as_flags |= ASYNC_GETNET;
48 return (as);
49 }
50 DEF_WEAK(getnetbyaddr_async);
51