2 * Copyright (C) 1993-2005 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
10 #pragma ident "%Z%%M% %I% %E% SMI"
14 int gethost(name
, hostp
, use_inet6
)
19 struct addrinfo hints
, *ai
;
23 if (!strcmp(name
, "test.host.dots")) {
24 hostp
->in4
.s_addr
= htonl(0xfedcba98);
28 if (!strcmp(name
, "<thishost>"))
31 bzero(&hints
, sizeof (hints
));
33 hints
.ai_family
= AF_INET
;
35 hints
.ai_family
= AF_INET6
;
37 error
= getaddrinfo(name
, NULL
, &hints
, &ai
);
39 if ((error
== 0) && (ai
!= NULL
) && (ai
->ai_addr
!= NULL
)) {
40 switch (ai
->ai_family
)
43 hostp
->in4
= ((struct sockaddr_in
*)
44 ai
->ai_addr
)->sin_addr
;
47 hostp
->in6
= ((struct sockaddr_in6
*)
48 ai
->ai_addr
)->sin6_addr
;
61 n
= getnetbyname(name
);
63 hostp
->in4
.s_addr
= htonl(n
->n_net
);