4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
14 gethost(int family, char *name, i6addr_t *hostp)
20 bzero(hostp, sizeof(*hostp));
21 if (!strcmp(name, "test.host.dots")) {
22 if (family == AF_INET) {
23 hostp->in4.s_addr = htonl(0xfedcba98);
26 if (family == AF_INET6) {
27 hostp->i6[0] = htonl(0xfe80aa55);
28 hostp->i6[1] = htonl(0x12345678);
29 hostp->i6[2] = htonl(0x5a5aa5a5);
30 hostp->i6[3] = htonl(0xfedcba98);
36 if (!strcmp(name, "<thishost>"))
39 if (family == AF_INET) {
40 h = gethostbyname(name);
42 if ((h->h_addr != NULL) &&
43 (h->h_length == sizeof(addr))) {
44 bcopy(h->h_addr, (char *)&addr, sizeof(addr));
45 hostp->in4.s_addr = addr;
50 n = getnetbyname(name);
52 hostp->in4.s_addr = htonl(n->n_net & 0xffffffff);
57 if (family == AF_INET6) {
58 struct addrinfo hints, *res;
59 struct sockaddr_in6 *sin6;
61 bzero((char *)&hints, sizeof(hints));
62 hints.ai_family = PF_INET6;
64 getaddrinfo(name, NULL, &hints, &res);
66 sin6 = (struct sockaddr_in6 *)res->ai_addr;
67 hostp->in6 = sin6->sin6_addr;