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 #if defined(LIBC_SCCS) && !defined(lint)
19*9525b14bSRao Shoaib static const char rcsid[] = "$Id: irp_ho.c,v 1.3 2005/04/27 04:56:28 sra Exp $";
207c478bd9Sstevel@tonic-gate #endif /* LIBC_SCCS and not lint */
217c478bd9Sstevel@tonic-gate
227c478bd9Sstevel@tonic-gate /* Imports. */
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate #include "port_before.h"
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <syslog.h>
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/param.h>
297c478bd9Sstevel@tonic-gate #include <sys/socket.h>
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate #include <netinet/in.h>
327c478bd9Sstevel@tonic-gate #include <arpa/inet.h>
337c478bd9Sstevel@tonic-gate #include <arpa/nameser.h>
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate #include <ctype.h>
367c478bd9Sstevel@tonic-gate #include <errno.h>
377c478bd9Sstevel@tonic-gate #include <fcntl.h>
387c478bd9Sstevel@tonic-gate #include <netdb.h>
397c478bd9Sstevel@tonic-gate #include <resolv.h>
407c478bd9Sstevel@tonic-gate #include <stdio.h>
417c478bd9Sstevel@tonic-gate #include <stdlib.h>
427c478bd9Sstevel@tonic-gate #include <string.h>
437c478bd9Sstevel@tonic-gate #include <syslog.h>
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate #include <irs.h>
467c478bd9Sstevel@tonic-gate #include <irp.h>
477c478bd9Sstevel@tonic-gate #include <isc/irpmarshall.h>
487c478bd9Sstevel@tonic-gate #include <isc/memcluster.h>
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate #include "irs_p.h"
517c478bd9Sstevel@tonic-gate #include "dns_p.h"
527c478bd9Sstevel@tonic-gate #include "irp_p.h"
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate #include "port_after.h"
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate /* Definitions. */
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate #define MAXALIASES 35
597c478bd9Sstevel@tonic-gate #define MAXADDRS 35
607c478bd9Sstevel@tonic-gate #define Max(a,b) ((a) > (b) ? (a) : (b))
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate struct pvt {
647c478bd9Sstevel@tonic-gate struct irp_p *girpdata;
657c478bd9Sstevel@tonic-gate int warned;
667c478bd9Sstevel@tonic-gate struct hostent host;
677c478bd9Sstevel@tonic-gate };
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate /* Forward. */
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate static void ho_close(struct irs_ho *this);
727c478bd9Sstevel@tonic-gate static struct hostent * ho_byname(struct irs_ho *this, const char *name);
737c478bd9Sstevel@tonic-gate static struct hostent * ho_byname2(struct irs_ho *this, const char *name,
747c478bd9Sstevel@tonic-gate int af);
757c478bd9Sstevel@tonic-gate static struct hostent * ho_byaddr(struct irs_ho *this, const void *addr,
767c478bd9Sstevel@tonic-gate int len, int af);
777c478bd9Sstevel@tonic-gate static struct hostent * ho_next(struct irs_ho *this);
787c478bd9Sstevel@tonic-gate static void ho_rewind(struct irs_ho *this);
797c478bd9Sstevel@tonic-gate static void ho_minimize(struct irs_ho *this);
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate static void free_host(struct hostent *ho);
827c478bd9Sstevel@tonic-gate static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
837c478bd9Sstevel@tonic-gate const struct addrinfo *pai);
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate /* Public. */
867c478bd9Sstevel@tonic-gate
87*9525b14bSRao Shoaib /*%
887c478bd9Sstevel@tonic-gate * struct irs_ho * irs_irp_ho(struct irs_acc *this)
897c478bd9Sstevel@tonic-gate *
907c478bd9Sstevel@tonic-gate * Notes:
917c478bd9Sstevel@tonic-gate *
927c478bd9Sstevel@tonic-gate * Initializes the irp_ho module.
937c478bd9Sstevel@tonic-gate *
947c478bd9Sstevel@tonic-gate */
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate struct irs_ho *
irs_irp_ho(struct irs_acc * this)977c478bd9Sstevel@tonic-gate irs_irp_ho(struct irs_acc *this) {
987c478bd9Sstevel@tonic-gate struct irs_ho *ho;
997c478bd9Sstevel@tonic-gate struct pvt *pvt;
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate if (!(ho = memget(sizeof *ho))) {
1027c478bd9Sstevel@tonic-gate errno = ENOMEM;
1037c478bd9Sstevel@tonic-gate return (NULL);
1047c478bd9Sstevel@tonic-gate }
1057c478bd9Sstevel@tonic-gate memset(ho, 0x0, sizeof *ho);
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate if (!(pvt = memget(sizeof *pvt))) {
1087c478bd9Sstevel@tonic-gate memput(ho, sizeof *ho);
1097c478bd9Sstevel@tonic-gate errno = ENOMEM;
1107c478bd9Sstevel@tonic-gate return (NULL);
1117c478bd9Sstevel@tonic-gate }
1127c478bd9Sstevel@tonic-gate memset(pvt, 0, sizeof *pvt);
1137c478bd9Sstevel@tonic-gate pvt->girpdata = this->private;
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gate ho->private = pvt;
1167c478bd9Sstevel@tonic-gate ho->close = ho_close;
1177c478bd9Sstevel@tonic-gate ho->byname = ho_byname;
1187c478bd9Sstevel@tonic-gate ho->byname2 = ho_byname2;
1197c478bd9Sstevel@tonic-gate ho->byaddr = ho_byaddr;
1207c478bd9Sstevel@tonic-gate ho->next = ho_next;
1217c478bd9Sstevel@tonic-gate ho->rewind = ho_rewind;
1227c478bd9Sstevel@tonic-gate ho->minimize = ho_minimize;
1237c478bd9Sstevel@tonic-gate ho->addrinfo = ho_addrinfo;
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate return (ho);
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate /* Methods. */
1297c478bd9Sstevel@tonic-gate
130*9525b14bSRao Shoaib /*%
1317c478bd9Sstevel@tonic-gate * Closes down the module.
1327c478bd9Sstevel@tonic-gate *
1337c478bd9Sstevel@tonic-gate */
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate static void
ho_close(struct irs_ho * this)1367c478bd9Sstevel@tonic-gate ho_close(struct irs_ho *this) {
1377c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate ho_minimize(this);
1407c478bd9Sstevel@tonic-gate
1417c478bd9Sstevel@tonic-gate free_host(&pvt->host);
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate memput(pvt, sizeof *pvt);
1447c478bd9Sstevel@tonic-gate memput(this, sizeof *this);
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate * struct hostent * ho_byname(struct irs_ho *this, const char *name)
1517c478bd9Sstevel@tonic-gate *
1527c478bd9Sstevel@tonic-gate */
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate static struct hostent *
ho_byname(struct irs_ho * this,const char * name)1557c478bd9Sstevel@tonic-gate ho_byname(struct irs_ho *this, const char *name) {
1567c478bd9Sstevel@tonic-gate return (ho_byname2(this, name, AF_INET));
1577c478bd9Sstevel@tonic-gate }
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate * struct hostent * ho_byname2(struct irs_ho *this, const char *name, int af)
1657c478bd9Sstevel@tonic-gate *
1667c478bd9Sstevel@tonic-gate */
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate static struct hostent *
ho_byname2(struct irs_ho * this,const char * name,int af)1697c478bd9Sstevel@tonic-gate ho_byname2(struct irs_ho *this, const char *name, int af) {
1707c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
1717c478bd9Sstevel@tonic-gate struct hostent *ho = &pvt->host;
1727c478bd9Sstevel@tonic-gate char *body = NULL;
1737c478bd9Sstevel@tonic-gate size_t bodylen;
1747c478bd9Sstevel@tonic-gate int code;
1757c478bd9Sstevel@tonic-gate char text[256];
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate if (ho->h_name != NULL &&
1787c478bd9Sstevel@tonic-gate strcmp(name, ho->h_name) == 0 &&
1797c478bd9Sstevel@tonic-gate af == ho->h_addrtype) {
1807c478bd9Sstevel@tonic-gate return (ho);
1817c478bd9Sstevel@tonic-gate }
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
1847c478bd9Sstevel@tonic-gate return (NULL);
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate if (irs_irp_send_command(pvt->girpdata, "gethostbyname2 %s %s",
1887c478bd9Sstevel@tonic-gate name, ADDR_T_STR(af)) != 0)
1897c478bd9Sstevel@tonic-gate return (NULL);
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate if (irs_irp_get_full_response(pvt->girpdata, &code,
1927c478bd9Sstevel@tonic-gate text, sizeof text,
1937c478bd9Sstevel@tonic-gate &body, &bodylen) != 0) {
1947c478bd9Sstevel@tonic-gate return (NULL);
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate if (code == IRPD_GETHOST_OK) {
1987c478bd9Sstevel@tonic-gate free_host(ho);
1997c478bd9Sstevel@tonic-gate if (irp_unmarshall_ho(ho, body) != 0) {
2007c478bd9Sstevel@tonic-gate ho = NULL;
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate } else {
2037c478bd9Sstevel@tonic-gate ho = NULL;
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate if (body != NULL) {
2077c478bd9Sstevel@tonic-gate memput(body, bodylen);
2087c478bd9Sstevel@tonic-gate }
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate return (ho);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate
2137c478bd9Sstevel@tonic-gate
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate * struct hostent * ho_byaddr(struct irs_ho *this, const void *addr,
2177c478bd9Sstevel@tonic-gate * int len, int af)
2187c478bd9Sstevel@tonic-gate *
2197c478bd9Sstevel@tonic-gate */
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate static struct hostent *
ho_byaddr(struct irs_ho * this,const void * addr,int len,int af)2227c478bd9Sstevel@tonic-gate ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
2237c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2247c478bd9Sstevel@tonic-gate struct hostent *ho = &pvt->host;
2257c478bd9Sstevel@tonic-gate char *body = NULL;
2267c478bd9Sstevel@tonic-gate size_t bodylen;
2277c478bd9Sstevel@tonic-gate int code;
2287c478bd9Sstevel@tonic-gate char **p;
2297c478bd9Sstevel@tonic-gate char paddr[MAXPADDRSIZE];
2307c478bd9Sstevel@tonic-gate char text[256];
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate if (ho->h_name != NULL &&
2337c478bd9Sstevel@tonic-gate af == ho->h_addrtype &&
2347c478bd9Sstevel@tonic-gate len == ho->h_length) {
2357c478bd9Sstevel@tonic-gate for (p = ho->h_addr_list ; *p != NULL ; p++) {
2367c478bd9Sstevel@tonic-gate if (memcmp(*p, addr, len) == 0)
2377c478bd9Sstevel@tonic-gate return (ho);
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate
2417c478bd9Sstevel@tonic-gate if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
2427c478bd9Sstevel@tonic-gate return (NULL);
2437c478bd9Sstevel@tonic-gate }
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gate if (inet_ntop(af, addr, paddr, sizeof paddr) == NULL) {
2467c478bd9Sstevel@tonic-gate return (NULL);
2477c478bd9Sstevel@tonic-gate }
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gate if (irs_irp_send_command(pvt->girpdata, "gethostbyaddr %s %s",
2507c478bd9Sstevel@tonic-gate paddr, ADDR_T_STR(af)) != 0) {
2517c478bd9Sstevel@tonic-gate return (NULL);
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gate if (irs_irp_get_full_response(pvt->girpdata, &code,
2557c478bd9Sstevel@tonic-gate text, sizeof text,
2567c478bd9Sstevel@tonic-gate &body, &bodylen) != 0) {
2577c478bd9Sstevel@tonic-gate return (NULL);
2587c478bd9Sstevel@tonic-gate }
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gate if (code == IRPD_GETHOST_OK) {
2617c478bd9Sstevel@tonic-gate free_host(ho);
2627c478bd9Sstevel@tonic-gate if (irp_unmarshall_ho(ho, body) != 0) {
2637c478bd9Sstevel@tonic-gate ho = NULL;
2647c478bd9Sstevel@tonic-gate }
2657c478bd9Sstevel@tonic-gate } else {
2667c478bd9Sstevel@tonic-gate ho = NULL;
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate if (body != NULL) {
2707c478bd9Sstevel@tonic-gate memput(body, bodylen);
2717c478bd9Sstevel@tonic-gate }
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate return (ho);
2747c478bd9Sstevel@tonic-gate }
2757c478bd9Sstevel@tonic-gate
276*9525b14bSRao Shoaib /*%
2777c478bd9Sstevel@tonic-gate * The implementation for gethostent(3). The first time it's
2787c478bd9Sstevel@tonic-gate * called all the data is pulled from the remote(i.e. what
2797c478bd9Sstevel@tonic-gate * the maximum number of gethostent(3) calls would return)
2807c478bd9Sstevel@tonic-gate * and that data is cached.
2817c478bd9Sstevel@tonic-gate *
2827c478bd9Sstevel@tonic-gate */
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate static struct hostent *
ho_next(struct irs_ho * this)2857c478bd9Sstevel@tonic-gate ho_next(struct irs_ho *this) {
2867c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
2877c478bd9Sstevel@tonic-gate struct hostent *ho = &pvt->host;
2887c478bd9Sstevel@tonic-gate char *body;
2897c478bd9Sstevel@tonic-gate size_t bodylen;
2907c478bd9Sstevel@tonic-gate int code;
2917c478bd9Sstevel@tonic-gate char text[256];
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
2947c478bd9Sstevel@tonic-gate return (NULL);
2957c478bd9Sstevel@tonic-gate }
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gate if (irs_irp_send_command(pvt->girpdata, "gethostent") != 0) {
2987c478bd9Sstevel@tonic-gate return (NULL);
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate if (irs_irp_get_full_response(pvt->girpdata, &code,
3027c478bd9Sstevel@tonic-gate text, sizeof text,
3037c478bd9Sstevel@tonic-gate &body, &bodylen) != 0) {
3047c478bd9Sstevel@tonic-gate return (NULL);
3057c478bd9Sstevel@tonic-gate }
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate if (code == IRPD_GETHOST_OK) {
3087c478bd9Sstevel@tonic-gate free_host(ho);
3097c478bd9Sstevel@tonic-gate if (irp_unmarshall_ho(ho, body) != 0) {
3107c478bd9Sstevel@tonic-gate ho = NULL;
3117c478bd9Sstevel@tonic-gate }
3127c478bd9Sstevel@tonic-gate } else {
3137c478bd9Sstevel@tonic-gate ho = NULL;
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate if (body != NULL) {
3177c478bd9Sstevel@tonic-gate memput(body, bodylen);
3187c478bd9Sstevel@tonic-gate }
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate return (ho);
3217c478bd9Sstevel@tonic-gate }
3227c478bd9Sstevel@tonic-gate
323*9525b14bSRao Shoaib /*%
3247c478bd9Sstevel@tonic-gate * void ho_rewind(struct irs_ho *this)
3257c478bd9Sstevel@tonic-gate *
3267c478bd9Sstevel@tonic-gate */
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate static void
ho_rewind(struct irs_ho * this)3297c478bd9Sstevel@tonic-gate ho_rewind(struct irs_ho *this) {
3307c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
3317c478bd9Sstevel@tonic-gate char text[256];
3327c478bd9Sstevel@tonic-gate int code;
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate if (irs_irp_connection_setup(pvt->girpdata, &pvt->warned) != 0) {
3357c478bd9Sstevel@tonic-gate return;
3367c478bd9Sstevel@tonic-gate }
3377c478bd9Sstevel@tonic-gate
3387c478bd9Sstevel@tonic-gate if (irs_irp_send_command(pvt->girpdata, "sethostent") != 0) {
3397c478bd9Sstevel@tonic-gate return;
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gate code = irs_irp_read_response(pvt->girpdata, text, sizeof text);
3437c478bd9Sstevel@tonic-gate if (code != IRPD_GETHOST_SETOK) {
3447c478bd9Sstevel@tonic-gate if (irp_log_errors) {
3457c478bd9Sstevel@tonic-gate syslog(LOG_WARNING, "sethostent failed: %s", text);
3467c478bd9Sstevel@tonic-gate }
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate return;
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate
352*9525b14bSRao Shoaib /*%
3537c478bd9Sstevel@tonic-gate * void ho_minimize(struct irs_ho *this)
3547c478bd9Sstevel@tonic-gate *
3557c478bd9Sstevel@tonic-gate */
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate static void
ho_minimize(struct irs_ho * this)3587c478bd9Sstevel@tonic-gate ho_minimize(struct irs_ho *this) {
3597c478bd9Sstevel@tonic-gate struct pvt *pvt = (struct pvt *)this->private;
3607c478bd9Sstevel@tonic-gate
3617c478bd9Sstevel@tonic-gate free_host(&pvt->host);
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate irs_irp_disconnect(pvt->girpdata);
3647c478bd9Sstevel@tonic-gate }
3657c478bd9Sstevel@tonic-gate
366*9525b14bSRao Shoaib /*%
3677c478bd9Sstevel@tonic-gate * void free_host(struct hostent *ho)
3687c478bd9Sstevel@tonic-gate *
3697c478bd9Sstevel@tonic-gate */
3707c478bd9Sstevel@tonic-gate
3717c478bd9Sstevel@tonic-gate static void
free_host(struct hostent * ho)3727c478bd9Sstevel@tonic-gate free_host(struct hostent *ho) {
3737c478bd9Sstevel@tonic-gate char **p;
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate if (ho == NULL) {
3767c478bd9Sstevel@tonic-gate return;
3777c478bd9Sstevel@tonic-gate }
3787c478bd9Sstevel@tonic-gate
3797c478bd9Sstevel@tonic-gate if (ho->h_name != NULL)
3807c478bd9Sstevel@tonic-gate free(ho->h_name);
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate if (ho->h_aliases != NULL) {
3837c478bd9Sstevel@tonic-gate for (p = ho->h_aliases ; *p != NULL ; p++)
3847c478bd9Sstevel@tonic-gate free(*p);
3857c478bd9Sstevel@tonic-gate free(ho->h_aliases);
3867c478bd9Sstevel@tonic-gate }
3877c478bd9Sstevel@tonic-gate
3887c478bd9Sstevel@tonic-gate if (ho->h_addr_list != NULL) {
3897c478bd9Sstevel@tonic-gate for (p = ho->h_addr_list ; *p != NULL ; p++)
3907c478bd9Sstevel@tonic-gate free(*p);
3917c478bd9Sstevel@tonic-gate free(ho->h_addr_list);
3927c478bd9Sstevel@tonic-gate }
3937c478bd9Sstevel@tonic-gate }
3947c478bd9Sstevel@tonic-gate
3957c478bd9Sstevel@tonic-gate /* dummy */
3967c478bd9Sstevel@tonic-gate static struct addrinfo *
ho_addrinfo(struct irs_ho * this,const char * name,const struct addrinfo * pai)3977c478bd9Sstevel@tonic-gate ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
3987c478bd9Sstevel@tonic-gate {
3997c478bd9Sstevel@tonic-gate UNUSED(this);
4007c478bd9Sstevel@tonic-gate UNUSED(name);
4017c478bd9Sstevel@tonic-gate UNUSED(pai);
4027c478bd9Sstevel@tonic-gate return(NULL);
4037c478bd9Sstevel@tonic-gate }
404*9525b14bSRao Shoaib
405*9525b14bSRao Shoaib /*! \file */
406