10Sstevel@tonic-gate /*
2*11038SRao.Shoaib@Sun.COM * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
30Sstevel@tonic-gate * Copyright (c) 1996,1999 by Internet Software Consortium.
40Sstevel@tonic-gate *
50Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software for any
60Sstevel@tonic-gate * purpose with or without fee is hereby granted, provided that the above
70Sstevel@tonic-gate * copyright notice and this permission notice appear in all copies.
80Sstevel@tonic-gate *
9*11038SRao.Shoaib@Sun.COM * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10*11038SRao.Shoaib@Sun.COM * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*11038SRao.Shoaib@Sun.COM * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12*11038SRao.Shoaib@Sun.COM * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*11038SRao.Shoaib@Sun.COM * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*11038SRao.Shoaib@Sun.COM * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15*11038SRao.Shoaib@Sun.COM * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
160Sstevel@tonic-gate */
170Sstevel@tonic-gate
180Sstevel@tonic-gate #if defined(LIBC_SCCS) && !defined(lint)
19*11038SRao.Shoaib@Sun.COM static const char rcsid[] = "$Id: gen_ho.c,v 1.5 2006/03/09 23:57:56 marka Exp $";
200Sstevel@tonic-gate #endif /* LIBC_SCCS and not lint */
210Sstevel@tonic-gate
220Sstevel@tonic-gate /* Imports */
230Sstevel@tonic-gate
240Sstevel@tonic-gate #include "port_before.h"
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate
280Sstevel@tonic-gate #include <netinet/in.h>
290Sstevel@tonic-gate #include <arpa/nameser.h>
300Sstevel@tonic-gate
310Sstevel@tonic-gate #include <errno.h>
320Sstevel@tonic-gate #include <stdlib.h>
330Sstevel@tonic-gate #include <netdb.h>
340Sstevel@tonic-gate #include <resolv.h>
350Sstevel@tonic-gate #include <stdio.h>
360Sstevel@tonic-gate #include <string.h>
370Sstevel@tonic-gate
380Sstevel@tonic-gate #include <isc/memcluster.h>
390Sstevel@tonic-gate #include <irs.h>
400Sstevel@tonic-gate
410Sstevel@tonic-gate #include "port_after.h"
420Sstevel@tonic-gate
430Sstevel@tonic-gate #include "irs_p.h"
440Sstevel@tonic-gate #include "gen_p.h"
450Sstevel@tonic-gate
460Sstevel@tonic-gate /* Definitions */
470Sstevel@tonic-gate
480Sstevel@tonic-gate struct pvt {
490Sstevel@tonic-gate struct irs_rule * rules;
500Sstevel@tonic-gate struct irs_rule * rule;
510Sstevel@tonic-gate struct irs_ho * ho;
520Sstevel@tonic-gate struct __res_state * res;
530Sstevel@tonic-gate void (*free_res)(void *);
540Sstevel@tonic-gate };
550Sstevel@tonic-gate
560Sstevel@tonic-gate /* Forwards */
570Sstevel@tonic-gate
580Sstevel@tonic-gate static void ho_close(struct irs_ho *this);
590Sstevel@tonic-gate static struct hostent * ho_byname(struct irs_ho *this, const char *name);
600Sstevel@tonic-gate static struct hostent * ho_byname2(struct irs_ho *this, const char *name,
610Sstevel@tonic-gate int af);
620Sstevel@tonic-gate static struct hostent * ho_byaddr(struct irs_ho *this, const void *addr,
630Sstevel@tonic-gate int len, int af);
640Sstevel@tonic-gate static struct hostent * ho_next(struct irs_ho *this);
650Sstevel@tonic-gate static void ho_rewind(struct irs_ho *this);
660Sstevel@tonic-gate static void ho_minimize(struct irs_ho *this);
670Sstevel@tonic-gate static struct __res_state * ho_res_get(struct irs_ho *this);
680Sstevel@tonic-gate static void ho_res_set(struct irs_ho *this,
690Sstevel@tonic-gate struct __res_state *res,
700Sstevel@tonic-gate void (*free_res)(void *));
710Sstevel@tonic-gate static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
720Sstevel@tonic-gate const struct addrinfo *pai);
730Sstevel@tonic-gate
740Sstevel@tonic-gate static int init(struct irs_ho *this);
750Sstevel@tonic-gate
760Sstevel@tonic-gate /* Exports */
770Sstevel@tonic-gate
780Sstevel@tonic-gate struct irs_ho *
irs_gen_ho(struct irs_acc * this)790Sstevel@tonic-gate irs_gen_ho(struct irs_acc *this) {
800Sstevel@tonic-gate struct gen_p *accpvt = (struct gen_p *)this->private;
810Sstevel@tonic-gate struct irs_ho *ho;
820Sstevel@tonic-gate struct pvt *pvt;
830Sstevel@tonic-gate
840Sstevel@tonic-gate if (!(pvt = memget(sizeof *pvt))) {
850Sstevel@tonic-gate errno = ENOMEM;
860Sstevel@tonic-gate return (NULL);
870Sstevel@tonic-gate }
880Sstevel@tonic-gate memset(pvt, 0, sizeof *pvt);
890Sstevel@tonic-gate if (!(ho = memget(sizeof *ho))) {
900Sstevel@tonic-gate memput(pvt, sizeof *pvt);
910Sstevel@tonic-gate errno = ENOMEM;
920Sstevel@tonic-gate return (NULL);
930Sstevel@tonic-gate }
940Sstevel@tonic-gate memset(ho, 0x5e, sizeof *ho);
950Sstevel@tonic-gate pvt->rules = accpvt->map_rules[irs_ho];
960Sstevel@tonic-gate pvt->rule = pvt->rules;
970Sstevel@tonic-gate ho->private = pvt;
980Sstevel@tonic-gate ho->close = ho_close;
990Sstevel@tonic-gate ho->byname = ho_byname;
1000Sstevel@tonic-gate ho->byname2 = ho_byname2;
1010Sstevel@tonic-gate ho->byaddr = ho_byaddr;
1020Sstevel@tonic-gate ho->next = ho_next;
1030Sstevel@tonic-gate ho->rewind = ho_rewind;
1040Sstevel@tonic-gate ho->minimize = ho_minimize;
1050Sstevel@tonic-gate ho->res_get = ho_res_get;
1060Sstevel@tonic-gate ho->res_set = ho_res_set;
1070Sstevel@tonic-gate ho->addrinfo = ho_addrinfo;
1080Sstevel@tonic-gate return (ho);
1090Sstevel@tonic-gate }
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate /* Methods. */
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate static void
ho_close(struct irs_ho * this)1140Sstevel@tonic-gate ho_close(struct irs_ho *this) {
1150Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
1160Sstevel@tonic-gate
1170Sstevel@tonic-gate ho_minimize(this);
1180Sstevel@tonic-gate if (pvt->res && pvt->free_res)
1190Sstevel@tonic-gate (*pvt->free_res)(pvt->res);
1200Sstevel@tonic-gate memput(pvt, sizeof *pvt);
1210Sstevel@tonic-gate memput(this, sizeof *this);
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate static struct hostent *
ho_byname(struct irs_ho * this,const char * name)1250Sstevel@tonic-gate ho_byname(struct irs_ho *this, const char *name) {
1260Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
1270Sstevel@tonic-gate struct irs_rule *rule;
1280Sstevel@tonic-gate struct hostent *rval;
1290Sstevel@tonic-gate struct irs_ho *ho;
1300Sstevel@tonic-gate int therrno = NETDB_INTERNAL;
1310Sstevel@tonic-gate int softerror = 0;
1320Sstevel@tonic-gate
1330Sstevel@tonic-gate if (init(this) == -1)
1340Sstevel@tonic-gate return (NULL);
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate for (rule = pvt->rules; rule; rule = rule->next) {
1370Sstevel@tonic-gate ho = rule->inst->ho;
1380Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
1390Sstevel@tonic-gate errno = 0;
1400Sstevel@tonic-gate rval = (*ho->byname)(ho, name);
1410Sstevel@tonic-gate if (rval != NULL)
1420Sstevel@tonic-gate return (rval);
1430Sstevel@tonic-gate if (softerror == 0 &&
1440Sstevel@tonic-gate pvt->res->res_h_errno != HOST_NOT_FOUND &&
1450Sstevel@tonic-gate pvt->res->res_h_errno != NETDB_INTERNAL) {
1460Sstevel@tonic-gate softerror = 1;
1470Sstevel@tonic-gate therrno = pvt->res->res_h_errno;
1480Sstevel@tonic-gate }
1490Sstevel@tonic-gate if (rule->flags & IRS_CONTINUE)
1500Sstevel@tonic-gate continue;
1510Sstevel@tonic-gate /*
1520Sstevel@tonic-gate * The value TRY_AGAIN can mean that the service
1530Sstevel@tonic-gate * is not available, or just that this particular name
1540Sstevel@tonic-gate * cannot be resolved now. We use the errno ECONNREFUSED
1550Sstevel@tonic-gate * to distinguish. If a lookup sets that errno when
1560Sstevel@tonic-gate * H_ERRNO is TRY_AGAIN, we continue to try other lookup
1570Sstevel@tonic-gate * functions, otherwise we return the TRY_AGAIN error.
1580Sstevel@tonic-gate */
1590Sstevel@tonic-gate if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
1600Sstevel@tonic-gate break;
1610Sstevel@tonic-gate }
1620Sstevel@tonic-gate if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
1630Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, therrno);
1640Sstevel@tonic-gate return (NULL);
1650Sstevel@tonic-gate }
1660Sstevel@tonic-gate
1670Sstevel@tonic-gate static struct hostent *
ho_byname2(struct irs_ho * this,const char * name,int af)1680Sstevel@tonic-gate ho_byname2(struct irs_ho *this, const char *name, int af) {
1690Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
1700Sstevel@tonic-gate struct irs_rule *rule;
1710Sstevel@tonic-gate struct hostent *rval;
1720Sstevel@tonic-gate struct irs_ho *ho;
1730Sstevel@tonic-gate int therrno = NETDB_INTERNAL;
1740Sstevel@tonic-gate int softerror = 0;
1750Sstevel@tonic-gate
1760Sstevel@tonic-gate if (init(this) == -1)
1770Sstevel@tonic-gate return (NULL);
1780Sstevel@tonic-gate
1790Sstevel@tonic-gate for (rule = pvt->rules; rule; rule = rule->next) {
1800Sstevel@tonic-gate ho = rule->inst->ho;
1810Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
1820Sstevel@tonic-gate errno = 0;
1830Sstevel@tonic-gate rval = (*ho->byname2)(ho, name, af);
1840Sstevel@tonic-gate if (rval != NULL)
1850Sstevel@tonic-gate return (rval);
1860Sstevel@tonic-gate if (softerror == 0 &&
1870Sstevel@tonic-gate pvt->res->res_h_errno != HOST_NOT_FOUND &&
1880Sstevel@tonic-gate pvt->res->res_h_errno != NETDB_INTERNAL) {
1890Sstevel@tonic-gate softerror = 1;
1900Sstevel@tonic-gate therrno = pvt->res->res_h_errno;
1910Sstevel@tonic-gate }
1920Sstevel@tonic-gate if (rule->flags & IRS_CONTINUE)
1930Sstevel@tonic-gate continue;
1940Sstevel@tonic-gate /*
1950Sstevel@tonic-gate * See the comments in ho_byname() explaining
1960Sstevel@tonic-gate * the interpretation of TRY_AGAIN and ECONNREFUSED.
1970Sstevel@tonic-gate */
1980Sstevel@tonic-gate if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
1990Sstevel@tonic-gate break;
2000Sstevel@tonic-gate }
2010Sstevel@tonic-gate if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
2020Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, therrno);
2030Sstevel@tonic-gate return (NULL);
2040Sstevel@tonic-gate }
2050Sstevel@tonic-gate
2060Sstevel@tonic-gate static struct hostent *
ho_byaddr(struct irs_ho * this,const void * addr,int len,int af)2070Sstevel@tonic-gate ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
2080Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2090Sstevel@tonic-gate struct irs_rule *rule;
2100Sstevel@tonic-gate struct hostent *rval;
2110Sstevel@tonic-gate struct irs_ho *ho;
2120Sstevel@tonic-gate int therrno = NETDB_INTERNAL;
2130Sstevel@tonic-gate int softerror = 0;
2140Sstevel@tonic-gate
2150Sstevel@tonic-gate
2160Sstevel@tonic-gate if (init(this) == -1)
2170Sstevel@tonic-gate return (NULL);
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate for (rule = pvt->rules; rule; rule = rule->next) {
2200Sstevel@tonic-gate ho = rule->inst->ho;
2210Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
2220Sstevel@tonic-gate errno = 0;
2230Sstevel@tonic-gate rval = (*ho->byaddr)(ho, addr, len, af);
2240Sstevel@tonic-gate if (rval != NULL)
2250Sstevel@tonic-gate return (rval);
2260Sstevel@tonic-gate if (softerror == 0 &&
2270Sstevel@tonic-gate pvt->res->res_h_errno != HOST_NOT_FOUND &&
2280Sstevel@tonic-gate pvt->res->res_h_errno != NETDB_INTERNAL) {
2290Sstevel@tonic-gate softerror = 1;
2300Sstevel@tonic-gate therrno = pvt->res->res_h_errno;
2310Sstevel@tonic-gate }
2320Sstevel@tonic-gate
2330Sstevel@tonic-gate if (rule->flags & IRS_CONTINUE)
2340Sstevel@tonic-gate continue;
2350Sstevel@tonic-gate /*
2360Sstevel@tonic-gate * See the comments in ho_byname() explaining
2370Sstevel@tonic-gate * the interpretation of TRY_AGAIN and ECONNREFUSED.
2380Sstevel@tonic-gate */
2390Sstevel@tonic-gate if (pvt->res->res_h_errno != TRY_AGAIN || errno != ECONNREFUSED)
2400Sstevel@tonic-gate break;
2410Sstevel@tonic-gate }
2420Sstevel@tonic-gate if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
2430Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, therrno);
2440Sstevel@tonic-gate return (NULL);
2450Sstevel@tonic-gate }
2460Sstevel@tonic-gate
2470Sstevel@tonic-gate static struct hostent *
ho_next(struct irs_ho * this)2480Sstevel@tonic-gate ho_next(struct irs_ho *this) {
2490Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2500Sstevel@tonic-gate struct hostent *rval;
2510Sstevel@tonic-gate struct irs_ho *ho;
2520Sstevel@tonic-gate
2530Sstevel@tonic-gate while (pvt->rule) {
2540Sstevel@tonic-gate ho = pvt->rule->inst->ho;
2550Sstevel@tonic-gate rval = (*ho->next)(ho);
2560Sstevel@tonic-gate if (rval)
2570Sstevel@tonic-gate return (rval);
2580Sstevel@tonic-gate if (!(pvt->rule->flags & IRS_CONTINUE))
2590Sstevel@tonic-gate break;
2600Sstevel@tonic-gate pvt->rule = pvt->rule->next;
2610Sstevel@tonic-gate if (pvt->rule) {
2620Sstevel@tonic-gate ho = pvt->rule->inst->ho;
2630Sstevel@tonic-gate (*ho->rewind)(ho);
2640Sstevel@tonic-gate }
2650Sstevel@tonic-gate }
2660Sstevel@tonic-gate return (NULL);
2670Sstevel@tonic-gate }
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate static void
ho_rewind(struct irs_ho * this)2700Sstevel@tonic-gate ho_rewind(struct irs_ho *this) {
2710Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2720Sstevel@tonic-gate struct irs_ho *ho;
2730Sstevel@tonic-gate
2740Sstevel@tonic-gate pvt->rule = pvt->rules;
2750Sstevel@tonic-gate if (pvt->rule) {
2760Sstevel@tonic-gate ho = pvt->rule->inst->ho;
2770Sstevel@tonic-gate (*ho->rewind)(ho);
2780Sstevel@tonic-gate }
2790Sstevel@tonic-gate }
2800Sstevel@tonic-gate
2810Sstevel@tonic-gate static void
ho_minimize(struct irs_ho * this)2820Sstevel@tonic-gate ho_minimize(struct irs_ho *this) {
2830Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2840Sstevel@tonic-gate struct irs_rule *rule;
2850Sstevel@tonic-gate
2860Sstevel@tonic-gate if (pvt->res)
2870Sstevel@tonic-gate res_nclose(pvt->res);
2880Sstevel@tonic-gate for (rule = pvt->rules; rule != NULL; rule = rule->next) {
2890Sstevel@tonic-gate struct irs_ho *ho = rule->inst->ho;
2900Sstevel@tonic-gate
2910Sstevel@tonic-gate (*ho->minimize)(ho);
2920Sstevel@tonic-gate }
2930Sstevel@tonic-gate }
2940Sstevel@tonic-gate
2950Sstevel@tonic-gate static struct __res_state *
ho_res_get(struct irs_ho * this)2960Sstevel@tonic-gate ho_res_get(struct irs_ho *this) {
2970Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2980Sstevel@tonic-gate
2990Sstevel@tonic-gate if (!pvt->res) {
3000Sstevel@tonic-gate struct __res_state *res;
3010Sstevel@tonic-gate res = (struct __res_state *)malloc(sizeof *res);
3020Sstevel@tonic-gate if (!res) {
3030Sstevel@tonic-gate errno = ENOMEM;
3040Sstevel@tonic-gate return (NULL);
3050Sstevel@tonic-gate }
3060Sstevel@tonic-gate memset(res, 0, sizeof *res);
3070Sstevel@tonic-gate ho_res_set(this, res, free);
3080Sstevel@tonic-gate }
3090Sstevel@tonic-gate
3100Sstevel@tonic-gate return (pvt->res);
3110Sstevel@tonic-gate }
3120Sstevel@tonic-gate
3130Sstevel@tonic-gate static void
ho_res_set(struct irs_ho * this,struct __res_state * res,void (* free_res)(void *))3140Sstevel@tonic-gate ho_res_set(struct irs_ho *this, struct __res_state *res,
3150Sstevel@tonic-gate void (*free_res)(void *)) {
3160Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
3170Sstevel@tonic-gate struct irs_rule *rule;
3180Sstevel@tonic-gate
3190Sstevel@tonic-gate if (pvt->res && pvt->free_res) {
3200Sstevel@tonic-gate res_nclose(pvt->res);
3210Sstevel@tonic-gate (*pvt->free_res)(pvt->res);
3220Sstevel@tonic-gate }
3230Sstevel@tonic-gate
3240Sstevel@tonic-gate pvt->res = res;
3250Sstevel@tonic-gate pvt->free_res = free_res;
3260Sstevel@tonic-gate
3270Sstevel@tonic-gate for (rule = pvt->rules; rule != NULL; rule = rule->next) {
3280Sstevel@tonic-gate struct irs_ho *ho = rule->inst->ho;
3290Sstevel@tonic-gate
3300Sstevel@tonic-gate (*ho->res_set)(ho, pvt->res, NULL);
3310Sstevel@tonic-gate }
3320Sstevel@tonic-gate }
3330Sstevel@tonic-gate
3340Sstevel@tonic-gate static struct addrinfo *
ho_addrinfo(struct irs_ho * this,const char * name,const struct addrinfo * pai)3350Sstevel@tonic-gate ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
3360Sstevel@tonic-gate {
3370Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
3380Sstevel@tonic-gate struct irs_rule *rule;
3390Sstevel@tonic-gate struct addrinfo *rval = NULL;
3400Sstevel@tonic-gate struct irs_ho *ho;
3410Sstevel@tonic-gate int therrno = NETDB_INTERNAL;
3420Sstevel@tonic-gate int softerror = 0;
3430Sstevel@tonic-gate
3440Sstevel@tonic-gate if (init(this) == -1)
3450Sstevel@tonic-gate return (NULL);
3460Sstevel@tonic-gate
3470Sstevel@tonic-gate for (rule = pvt->rules; rule; rule = rule->next) {
3480Sstevel@tonic-gate ho = rule->inst->ho;
3490Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
3500Sstevel@tonic-gate errno = 0;
351*11038SRao.Shoaib@Sun.COM if (ho->addrinfo == NULL) /*%< for safety */
3520Sstevel@tonic-gate continue;
3530Sstevel@tonic-gate rval = (*ho->addrinfo)(ho, name, pai);
3540Sstevel@tonic-gate if (rval != NULL)
3550Sstevel@tonic-gate return (rval);
3560Sstevel@tonic-gate if (softerror == 0 &&
3570Sstevel@tonic-gate pvt->res->res_h_errno != HOST_NOT_FOUND &&
3580Sstevel@tonic-gate pvt->res->res_h_errno != NETDB_INTERNAL) {
3590Sstevel@tonic-gate softerror = 1;
3600Sstevel@tonic-gate therrno = pvt->res->res_h_errno;
3610Sstevel@tonic-gate }
3620Sstevel@tonic-gate if (rule->flags & IRS_CONTINUE)
3630Sstevel@tonic-gate continue;
3640Sstevel@tonic-gate /*
3650Sstevel@tonic-gate * See the comments in ho_byname() explaining
3660Sstevel@tonic-gate * the interpretation of TRY_AGAIN and ECONNREFUSED.
3670Sstevel@tonic-gate */
3680Sstevel@tonic-gate if (pvt->res->res_h_errno != TRY_AGAIN ||
3690Sstevel@tonic-gate errno != ECONNREFUSED)
3700Sstevel@tonic-gate break;
3710Sstevel@tonic-gate }
3720Sstevel@tonic-gate if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
3730Sstevel@tonic-gate RES_SET_H_ERRNO(pvt->res, therrno);
3740Sstevel@tonic-gate return (NULL);
3750Sstevel@tonic-gate }
3760Sstevel@tonic-gate
3770Sstevel@tonic-gate static int
init(struct irs_ho * this)3780Sstevel@tonic-gate init(struct irs_ho *this) {
3790Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
3800Sstevel@tonic-gate
3810Sstevel@tonic-gate if (!pvt->res && !ho_res_get(this))
3820Sstevel@tonic-gate return (-1);
3830Sstevel@tonic-gate
384*11038SRao.Shoaib@Sun.COM if (((pvt->res->options & RES_INIT) == 0U) &&
3850Sstevel@tonic-gate (res_ninit(pvt->res) == -1))
3860Sstevel@tonic-gate return (-1);
3870Sstevel@tonic-gate
3880Sstevel@tonic-gate return (0);
3890Sstevel@tonic-gate }
390*11038SRao.Shoaib@Sun.COM
391*11038SRao.Shoaib@Sun.COM /*! \file */
392