17c478bd9Sstevel@tonic-gate /*
2*9525b14bSRao Shoaib  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
37c478bd9Sstevel@tonic-gate  * Portions Copyright (c) 1996,1998 by Internet Software Consortium.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
67c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
77c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
87c478bd9Sstevel@tonic-gate  *
9*9525b14bSRao Shoaib  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10*9525b14bSRao Shoaib  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*9525b14bSRao Shoaib  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12*9525b14bSRao Shoaib  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*9525b14bSRao Shoaib  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*9525b14bSRao Shoaib  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15*9525b14bSRao Shoaib  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167c478bd9Sstevel@tonic-gate  */
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate /* Imports. */
197c478bd9Sstevel@tonic-gate 
207c478bd9Sstevel@tonic-gate #include "port_before.h"
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate #include <syslog.h>
237c478bd9Sstevel@tonic-gate #include <sys/types.h>
247c478bd9Sstevel@tonic-gate #include <sys/param.h>
257c478bd9Sstevel@tonic-gate #include <sys/socket.h>
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <netinet/in.h>
287c478bd9Sstevel@tonic-gate #include <arpa/inet.h>
297c478bd9Sstevel@tonic-gate #include <arpa/nameser.h>
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <ctype.h>
327c478bd9Sstevel@tonic-gate #include <errno.h>
337c478bd9Sstevel@tonic-gate #include <fcntl.h>
347c478bd9Sstevel@tonic-gate #include <netdb.h>
357c478bd9Sstevel@tonic-gate #include <resolv.h>
367c478bd9Sstevel@tonic-gate #include <stdio.h>
377c478bd9Sstevel@tonic-gate #include <stdlib.h>
387c478bd9Sstevel@tonic-gate #include <string.h>
397c478bd9Sstevel@tonic-gate #include <syslog.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #include <irs.h>
427c478bd9Sstevel@tonic-gate #include <irp.h>
437c478bd9Sstevel@tonic-gate #include <isc/irpmarshall.h>
447c478bd9Sstevel@tonic-gate #include <isc/memcluster.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include "irs_p.h"
477c478bd9Sstevel@tonic-gate #include "dns_p.h"
487c478bd9Sstevel@tonic-gate #include "irp_p.h"
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #include "port_after.h"
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /* Definitions. */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #define	MAXALIASES	35
557c478bd9Sstevel@tonic-gate #define	MAXADDRS	35
567c478bd9Sstevel@tonic-gate #define	Max(a,b)	((a) > (b) ? (a) : (b))
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate struct pvt {
607c478bd9Sstevel@tonic-gate 	struct irp_p	       *girpdata;
617c478bd9Sstevel@tonic-gate 	int			warned;
627c478bd9Sstevel@tonic-gate 	struct hostent		host;
637c478bd9Sstevel@tonic-gate };
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /* Forward. */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate static void		ho_close(struct irs_ho *this);
687c478bd9Sstevel@tonic-gate static struct hostent *	ho_byname(struct irs_ho *this, const char *name);
697c478bd9Sstevel@tonic-gate static struct hostent *	ho_byname2(struct irs_ho *this, const char *name,
707c478bd9Sstevel@tonic-gate 				   int af);
717c478bd9Sstevel@tonic-gate static struct hostent *	ho_byaddr(struct irs_ho *this, const void *addr,
727c478bd9Sstevel@tonic-gate 				  int len, int af);
737c478bd9Sstevel@tonic-gate static struct hostent *	ho_next(struct irs_ho *this);
747c478bd9Sstevel@tonic-gate static void		ho_rewind(struct irs_ho *this);
757c478bd9Sstevel@tonic-gate static void		ho_minimize(struct irs_ho *this);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate static void		free_host(struct hostent *ho);
787c478bd9Sstevel@tonic-gate static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
797c478bd9Sstevel@tonic-gate 				     const struct addrinfo *pai);
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /* Public. */
827c478bd9Sstevel@tonic-gate 
83*9525b14bSRao Shoaib /*%
847c478bd9Sstevel@tonic-gate  * struct irs_ho * irs_irp_ho(struct irs_acc *this)
857c478bd9Sstevel@tonic-gate  *
867c478bd9Sstevel@tonic-gate  * Notes:
877c478bd9Sstevel@tonic-gate  *
887c478bd9Sstevel@tonic-gate  *	Initializes the irp_ho module.
897c478bd9Sstevel@tonic-gate  *
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate struct irs_ho *
irs_irp_ho(struct irs_acc * this)937c478bd9Sstevel@tonic-gate irs_irp_ho(struct irs_acc *this) {
947c478bd9Sstevel@tonic-gate 	struct irs_ho *ho;
957c478bd9Sstevel@tonic-gate 	struct pvt *pvt;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	if (!(ho = memget(sizeof *ho))) {
987c478bd9Sstevel@tonic-gate 		errno = ENOMEM;
997c478bd9Sstevel@tonic-gate 		return (NULL);
1007c478bd9Sstevel@tonic-gate 	}
1017c478bd9Sstevel@tonic-gate 	memset(ho, 0x0, sizeof *ho);
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	if (!(pvt = memget(sizeof *pvt))) {
1047c478bd9Sstevel@tonic-gate 		memput(ho, sizeof *ho);
1057c478bd9Sstevel@tonic-gate 		errno = ENOMEM;
1067c478bd9Sstevel@tonic-gate 		return (NULL);
1077c478bd9Sstevel@tonic-gate 	}
1087c478bd9Sstevel@tonic-gate 	memset(pvt, 0, sizeof *pvt);
1097c478bd9Sstevel@tonic-gate 	pvt->girpdata = this->private;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 	ho->private = pvt;
1127c478bd9Sstevel@tonic-gate 	ho->close = ho_close;
1137c478bd9Sstevel@tonic-gate 	ho->byname = ho_byname;
1147c478bd9Sstevel@tonic-gate 	ho->byname2 = ho_byname2;
1157c478bd9Sstevel@tonic-gate 	ho->byaddr = ho_byaddr;
1167c478bd9Sstevel@tonic-gate 	ho->next = ho_next;
1177c478bd9Sstevel@tonic-gate 	ho->rewind = ho_rewind;
1187c478bd9Sstevel@tonic-gate 	ho->minimize = ho_minimize;
1197c478bd9Sstevel@tonic-gate 	ho->addrinfo = ho_addrinfo;
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	return (ho);
1227c478bd9Sstevel@tonic-gate }
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate /* Methods. */
1257c478bd9Sstevel@tonic-gate 
126*9525b14bSRao Shoaib /*%
1277c478bd9Sstevel@tonic-gate  *	Closes down the module.
1287c478bd9Sstevel@tonic-gate  *
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate static void
ho_close(struct irs_ho * this)1327c478bd9Sstevel@tonic-gate ho_close(struct irs_ho *this) {
1337c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate 	ho_minimize(this);
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 	free_host(&pvt->host);
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate 	memput(pvt, sizeof *pvt);
1407c478bd9Sstevel@tonic-gate 	memput(this, sizeof *this);
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * struct hostent * ho_byname(struct irs_ho *this, const char *name)
1477c478bd9Sstevel@tonic-gate  *
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate static struct hostent *
ho_byname(struct irs_ho * this,const char * name)1517c478bd9Sstevel@tonic-gate ho_byname(struct irs_ho *this, const char *name) {
1527c478bd9Sstevel@tonic-gate 	return (ho_byname2(this, name, AF_INET));
1537c478bd9Sstevel@tonic-gate }
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /*
1607c478bd9Sstevel@tonic-gate  * struct hostent * ho_byname2(struct irs_ho *this, const char *name, int af)
1617c478bd9Sstevel@tonic-gate  *
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate static struct hostent *
ho_byname2(struct irs_ho * this,const char * name,int af)1657c478bd9Sstevel@tonic-gate ho_byname2(struct irs_ho *this, const char *name, int af) {
1667c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
1677c478bd9Sstevel@tonic-gate 	struct hostent *ho = &pvt->host;
1687c478bd9Sstevel@tonic-gate 	char *body = NULL;
1697c478bd9Sstevel@tonic-gate 	size_t bodylen;
1707c478bd9Sstevel@tonic-gate 	int code;
1717c478bd9Sstevel@tonic-gate 	char text[256];
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	if (ho->h_name != NULL &&
1747c478bd9Sstevel@tonic-gate 	    strcmp(name, ho->h_name) == 0 &&
1757c478bd9Sstevel@tonic-gate 	    af == ho->h_addrtype) {
1767c478bd9Sstevel@tonic-gate 		return (ho);
1777c478bd9Sstevel@tonic-gate 	}
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 	if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
1807c478bd9Sstevel@tonic-gate 		return (NULL);
1817c478bd9Sstevel@tonic-gate 	}
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate 	if (irs_irp_send_command(pvt->girpdata, "gethostbyname2 %s %s",
1847c478bd9Sstevel@tonic-gate 				 name, ADDR_T_STR(af)) != 0)
1857c478bd9Sstevel@tonic-gate 		return (NULL);
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	if (irs_irp_get_full_response(pvt->girpdata, &code,
1887c478bd9Sstevel@tonic-gate 				      text, sizeof text,
1897c478bd9Sstevel@tonic-gate 				      &body, &bodylen) != 0) {
1907c478bd9Sstevel@tonic-gate 		return (NULL);
1917c478bd9Sstevel@tonic-gate 	}
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	if (code == IRPD_GETHOST_OK) {
1947c478bd9Sstevel@tonic-gate 		free_host(ho);
1957c478bd9Sstevel@tonic-gate 		if (irp_unmarshall_ho(ho, body) != 0) {
1967c478bd9Sstevel@tonic-gate 			ho = NULL;
1977c478bd9Sstevel@tonic-gate 		}
1987c478bd9Sstevel@tonic-gate 	} else {
1997c478bd9Sstevel@tonic-gate 		ho = NULL;
2007c478bd9Sstevel@tonic-gate 	}
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	if (body != NULL) {
2037c478bd9Sstevel@tonic-gate 		memput(body, bodylen);
2047c478bd9Sstevel@tonic-gate 	}
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 	return (ho);
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate /*
2127c478bd9Sstevel@tonic-gate  * struct hostent * ho_byaddr(struct irs_ho *this, const void *addr,
2137c478bd9Sstevel@tonic-gate  *			   int len, int af)
2147c478bd9Sstevel@tonic-gate  *
2157c478bd9Sstevel@tonic-gate  */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate static struct hostent *
ho_byaddr(struct irs_ho * this,const void * addr,int len,int af)2187c478bd9Sstevel@tonic-gate ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
2197c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
2207c478bd9Sstevel@tonic-gate 	struct hostent *ho = &pvt->host;
2217c478bd9Sstevel@tonic-gate 	char *body = NULL;
2227c478bd9Sstevel@tonic-gate 	size_t bodylen;
2237c478bd9Sstevel@tonic-gate 	int code;
2247c478bd9Sstevel@tonic-gate 	char **p;
2257c478bd9Sstevel@tonic-gate 	char paddr[MAXPADDRSIZE];
2267c478bd9Sstevel@tonic-gate 	char text[256];
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	if (ho->h_name != NULL &&
2297c478bd9Sstevel@tonic-gate 	    af == ho->h_addrtype &&
2307c478bd9Sstevel@tonic-gate 	    len == ho->h_length) {
2317c478bd9Sstevel@tonic-gate 		for (p = ho->h_addr_list ; *p != NULL ; p++) {
2327c478bd9Sstevel@tonic-gate 			if (memcmp(*p, addr, len) == 0)
2337c478bd9Sstevel@tonic-gate 				return (ho);
2347c478bd9Sstevel@tonic-gate 		}
2357c478bd9Sstevel@tonic-gate 	}
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 	if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
2387c478bd9Sstevel@tonic-gate 		return (NULL);
2397c478bd9Sstevel@tonic-gate 	}
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate 	if (inet_ntop(af, addr, paddr, sizeof paddr) == NULL) {
2427c478bd9Sstevel@tonic-gate 		return (NULL);
2437c478bd9Sstevel@tonic-gate 	}
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 	if (irs_irp_send_command(pvt->girpdata, "gethostbyaddr %s %s",
2467c478bd9Sstevel@tonic-gate 				 paddr, ADDR_T_STR(af)) != 0) {
2477c478bd9Sstevel@tonic-gate 		return (NULL);
2487c478bd9Sstevel@tonic-gate 	}
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	if (irs_irp_get_full_response(pvt->girpdata, &code,
2517c478bd9Sstevel@tonic-gate 				      text, sizeof text,
2527c478bd9Sstevel@tonic-gate 				      &body, &bodylen) != 0) {
2537c478bd9Sstevel@tonic-gate 		return (NULL);
2547c478bd9Sstevel@tonic-gate 	}
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	if (code == IRPD_GETHOST_OK) {
2577c478bd9Sstevel@tonic-gate 		free_host(ho);
2587c478bd9Sstevel@tonic-gate 		if (irp_unmarshall_ho(ho, body) != 0) {
2597c478bd9Sstevel@tonic-gate 			ho = NULL;
2607c478bd9Sstevel@tonic-gate 		}
2617c478bd9Sstevel@tonic-gate 	} else {
2627c478bd9Sstevel@tonic-gate 		ho = NULL;
2637c478bd9Sstevel@tonic-gate 	}
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	if (body != NULL) {
2667c478bd9Sstevel@tonic-gate 		memput(body, bodylen);
2677c478bd9Sstevel@tonic-gate 	}
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	return (ho);
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate 
272*9525b14bSRao Shoaib /*%
2737c478bd9Sstevel@tonic-gate  *	The implementation for gethostent(3). The first time it's
2747c478bd9Sstevel@tonic-gate  *	called all the data is pulled from the remote(i.e. what
2757c478bd9Sstevel@tonic-gate  *	the maximum number of gethostent(3) calls would return)
2767c478bd9Sstevel@tonic-gate  *	and that data is cached.
2777c478bd9Sstevel@tonic-gate  *
2787c478bd9Sstevel@tonic-gate  */
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate static struct hostent *
ho_next(struct irs_ho * this)2817c478bd9Sstevel@tonic-gate ho_next(struct irs_ho *this) {
2827c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
2837c478bd9Sstevel@tonic-gate 	struct hostent *ho = &pvt->host;
2847c478bd9Sstevel@tonic-gate 	char *body;
2857c478bd9Sstevel@tonic-gate 	size_t bodylen;
2867c478bd9Sstevel@tonic-gate 	int code;
2877c478bd9Sstevel@tonic-gate 	char text[256];
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate 	if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
2907c478bd9Sstevel@tonic-gate 		return (NULL);
2917c478bd9Sstevel@tonic-gate 	}
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	if (irs_irp_send_command(pvt->girpdata, "gethostent") != 0) {
2947c478bd9Sstevel@tonic-gate 		return (NULL);
2957c478bd9Sstevel@tonic-gate 	}
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	if (irs_irp_get_full_response(pvt->girpdata, &code,
2987c478bd9Sstevel@tonic-gate 				      text, sizeof text,
2997c478bd9Sstevel@tonic-gate 				      &body, &bodylen) != 0) {
3007c478bd9Sstevel@tonic-gate 		return (NULL);
3017c478bd9Sstevel@tonic-gate 	}
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	if (code == IRPD_GETHOST_OK) {
3047c478bd9Sstevel@tonic-gate 		free_host(ho);
3057c478bd9Sstevel@tonic-gate 		if (irp_unmarshall_ho(ho, body) != 0) {
3067c478bd9Sstevel@tonic-gate 			ho = NULL;
3077c478bd9Sstevel@tonic-gate 		}
3087c478bd9Sstevel@tonic-gate 	} else {
3097c478bd9Sstevel@tonic-gate 		ho = NULL;
3107c478bd9Sstevel@tonic-gate 	}
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	if (body != NULL) {
3137c478bd9Sstevel@tonic-gate 		memput(body, bodylen);
3147c478bd9Sstevel@tonic-gate 	}
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	return (ho);
3177c478bd9Sstevel@tonic-gate }
3187c478bd9Sstevel@tonic-gate 
319*9525b14bSRao Shoaib /*%
3207c478bd9Sstevel@tonic-gate  * void ho_rewind(struct irs_ho *this)
3217c478bd9Sstevel@tonic-gate  *
3227c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate static void
ho_rewind(struct irs_ho * this)3257c478bd9Sstevel@tonic-gate ho_rewind(struct irs_ho *this) {
3267c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
3277c478bd9Sstevel@tonic-gate 	char text[256];
3287c478bd9Sstevel@tonic-gate 	int code;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 	if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
3317c478bd9Sstevel@tonic-gate 		return;
3327c478bd9Sstevel@tonic-gate 	}
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 	if (irs_irp_send_command(pvt->girpdata, "sethostent") != 0) {
3357c478bd9Sstevel@tonic-gate 		return;
3367c478bd9Sstevel@tonic-gate 	}
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	code = irs_irp_read_response(pvt->girpdata, text, sizeof text);
3397c478bd9Sstevel@tonic-gate 	if (code != IRPD_GETHOST_SETOK) {
3407c478bd9Sstevel@tonic-gate 		if (irp_log_errors) {
3417c478bd9Sstevel@tonic-gate 			syslog(LOG_WARNING, "sethostent failed: %s", text);
3427c478bd9Sstevel@tonic-gate 		}
3437c478bd9Sstevel@tonic-gate 	}
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate 	return;
3467c478bd9Sstevel@tonic-gate }
3477c478bd9Sstevel@tonic-gate 
348*9525b14bSRao Shoaib /*%
3497c478bd9Sstevel@tonic-gate  * void ho_minimize(struct irs_ho *this)
3507c478bd9Sstevel@tonic-gate  *
3517c478bd9Sstevel@tonic-gate  */
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate static void
ho_minimize(struct irs_ho * this)3547c478bd9Sstevel@tonic-gate ho_minimize(struct irs_ho *this) {
3557c478bd9Sstevel@tonic-gate 	struct pvt *pvt = (struct pvt *)this->private;
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate 	free_host(&pvt->host);
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate 	irs_irp_disconnect(pvt->girpdata);
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate 
362*9525b14bSRao Shoaib /*%
3637c478bd9Sstevel@tonic-gate  * void free_host(struct hostent *ho)
3647c478bd9Sstevel@tonic-gate  *
3657c478bd9Sstevel@tonic-gate  */
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate static void
free_host(struct hostent * ho)3687c478bd9Sstevel@tonic-gate free_host(struct hostent *ho) {
3697c478bd9Sstevel@tonic-gate 	char **p;
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate 	if (ho == NULL) {
3727c478bd9Sstevel@tonic-gate 		return;
3737c478bd9Sstevel@tonic-gate 	}
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate 	if (ho->h_name != NULL)
3767c478bd9Sstevel@tonic-gate 		free(ho->h_name);
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate 	if (ho->h_aliases != NULL) {
3797c478bd9Sstevel@tonic-gate 		for (p = ho->h_aliases ; *p != NULL ; p++)
3807c478bd9Sstevel@tonic-gate 			free(*p);
3817c478bd9Sstevel@tonic-gate 		free(ho->h_aliases);
3827c478bd9Sstevel@tonic-gate 	}
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate 	if (ho->h_addr_list != NULL) {
3857c478bd9Sstevel@tonic-gate 		for (p = ho->h_addr_list ; *p != NULL ; p++)
3867c478bd9Sstevel@tonic-gate 			free(*p);
3877c478bd9Sstevel@tonic-gate 		free(ho->h_addr_list);
3887c478bd9Sstevel@tonic-gate 	}
3897c478bd9Sstevel@tonic-gate }
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate /* dummy */
3927c478bd9Sstevel@tonic-gate static struct addrinfo *
ho_addrinfo(struct irs_ho * this,const char * name,const struct addrinfo * pai)3937c478bd9Sstevel@tonic-gate ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
3947c478bd9Sstevel@tonic-gate {
3957c478bd9Sstevel@tonic-gate 	UNUSED(this);
3967c478bd9Sstevel@tonic-gate 	UNUSED(name);
3977c478bd9Sstevel@tonic-gate 	UNUSED(pai);
3987c478bd9Sstevel@tonic-gate 	return(NULL);
3997c478bd9Sstevel@tonic-gate }
400*9525b14bSRao Shoaib 
401*9525b14bSRao Shoaib /*! \file */
402