1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23/*
| 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23/*
|
29 * This file defines and implements the re-entrant enumeration routines for 30 * IPv6 hosts: sethostent6(), gethostent6(), and endhostent6(). 31 * They consult the switch policy directly and do not "share" their 32 * enumeration state nor the stayopen flag with the implentation of the 33 * more commonly used getipnodebyname()/getipnodebyaddr(). The latter 34 * follows a tortuous route in order to be consistent with netdir_getbyYY() 35 * (see getipnodebyname.c and netdir_inet.c). 36 */ 37 38#pragma ident "%Z%%M% %I% %E% SMI" 39
| 29 * This file defines and implements the re-entrant enumeration routines for 30 * IPv6 hosts: sethostent6(), gethostent6(), and endhostent6(). 31 * They consult the switch policy directly and do not "share" their 32 * enumeration state nor the stayopen flag with the implentation of the 33 * more commonly used getipnodebyname()/getipnodebyaddr(). The latter 34 * follows a tortuous route in order to be consistent with netdir_getbyYY() 35 * (see getipnodebyname.c and netdir_inet.c). 36 */ 37 38#pragma ident "%Z%%M% %I% %E% SMI" 39
|
40#include <sys/socket.h> 41#include <sys/types.h> 42#include <nss_dbdefs.h> 43#include "nss.h" 44 45static int ipnodes_stayopen; 46/* 47 * Unsynchronized, but it affects only 48 * efficiency, not correctness 49 */ 50 51static DEFINE_NSS_DB_ROOT(db_root); 52static DEFINE_NSS_GETENT(context); 53 54/* IPv6 wrapper for __str2hostent() */ 55int 56str2hostent6(const char *instr, int lenstr, void *ent, char *buffer, int buflen) 57{ 58 return (__str2hostent(AF_INET6, instr, lenstr, ent, buffer, buflen)); 59} 60 61void 62_nss_initf_ipnodes(nss_db_params_t *p) 63{ 64 p->name = NSS_DBNAM_IPNODES; 65 p->default_config = NSS_DEFCONF_IPNODES; 66} 67 68int 69__sethostent6(int stay) 70{ 71 ipnodes_stayopen |= stay; 72 nss_setent(&db_root, _nss_initf_ipnodes, &context); 73 return (0); 74} 75 76int 77__endhostent6(void) 78{ 79 ipnodes_stayopen = 0; 80 nss_endent(&db_root, _nss_initf_ipnodes, &context); 81 nss_delete(&db_root); 82 return (0); 83} 84 85struct hostent * 86__gethostent6(struct hostent *result, char *buffer, int buflen, int *h_errnop) 87{ 88 nss_XbyY_args_t arg; 89 nss_status_t res; 90 91 NSS_XbyY_INIT(&arg, result, buffer, buflen, str2hostent6); 92 res = nss_getent(&db_root, _nss_initf_ipnodes, 93 &context, &arg); 94 arg.status = res; 95 *h_errnop = arg.h_errno; 96 return ((struct hostent *)NSS_XbyY_FINI(&arg)); 97}
| 41#include <sys/socket.h> 42#include <sys/types.h> 43#include <nss_dbdefs.h> 44#include "nss.h" 45 46static int ipnodes_stayopen; 47/* 48 * Unsynchronized, but it affects only 49 * efficiency, not correctness 50 */ 51 52static DEFINE_NSS_DB_ROOT(db_root); 53static DEFINE_NSS_GETENT(context); 54 55/* IPv6 wrapper for __str2hostent() */ 56int 57str2hostent6(const char *instr, int lenstr, void *ent, char *buffer, int buflen) 58{ 59 return (__str2hostent(AF_INET6, instr, lenstr, ent, buffer, buflen)); 60} 61 62void 63_nss_initf_ipnodes(nss_db_params_t *p) 64{ 65 p->name = NSS_DBNAM_IPNODES; 66 p->default_config = NSS_DEFCONF_IPNODES; 67} 68 69int 70__sethostent6(int stay) 71{ 72 ipnodes_stayopen |= stay; 73 nss_setent(&db_root, _nss_initf_ipnodes, &context); 74 return (0); 75} 76 77int 78__endhostent6(void) 79{ 80 ipnodes_stayopen = 0; 81 nss_endent(&db_root, _nss_initf_ipnodes, &context); 82 nss_delete(&db_root); 83 return (0); 84} 85 86struct hostent * 87__gethostent6(struct hostent *result, char *buffer, int buflen, int *h_errnop) 88{ 89 nss_XbyY_args_t arg; 90 nss_status_t res; 91 92 NSS_XbyY_INIT(&arg, result, buffer, buflen, str2hostent6); 93 res = nss_getent(&db_root, _nss_initf_ipnodes, 94 &context, &arg); 95 arg.status = res; 96 *h_errnop = arg.h_errno; 97 return ((struct hostent *)NSS_XbyY_FINI(&arg)); 98}
|