4 * Copyright (C) 2012 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
13 int gethost(family, name, hostp)
22 if (!strcmp(name, "test.host.dots")) {
23 if (family == AF_INET) {
24 hostp->in4.s_addr = htonl(0xfedcba98);
27 if (family == AF_INET6) {
28 hostp->i6[0] = 0xfe80aa55;
29 hostp->i6[1] = 0x12345678;
30 hostp->i6[2] = 0x5a5aa5a5;
31 hostp->i6[3] = 0xfedcba98;
37 if (!strcmp(name, "<thishost>"))
40 if (family == AF_INET) {
41 h = gethostbyname(name);
43 if ((h->h_addr != NULL) &&
44 (h->h_length == sizeof(addr))) {
45 bcopy(h->h_addr, (char *)&addr, sizeof(addr));
46 hostp->in4.s_addr = addr;
51 n = getnetbyname(name);
53 hostp->in4.s_addr = htonl(n->n_net & 0xffffffff);
58 if (family == AF_INET6) {
59 struct addrinfo hints, *res;
60 struct sockaddr_in6 *sin6;
62 bzero((char *)&hints, sizeof(hints));
63 hints.ai_family = PF_INET6;
65 getaddrinfo(name, NULL, &hints, &res);
67 sin6 = (struct sockaddr_in6 *)res->ai_addr;
68 hostp->in6 = sin6->sin6_addr;