2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 2N/A/* All Rights Reserved */ 2N/A * Portions of this source code were derived from Berkeley 4.3 BSD 2N/A * under license from the Regents of the University of California. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * This is the library routines that do the name to address 2N/A/* messaging stuff. */ 2N/A int (*
opt)();
/* _netdir_options */ 2N/A char *(*
t2u)();
/* _taddr2uaddr */ 2N/A * xlate_lock protects xlate_list during updates only. The xlate_list linked 2N/A * list is pre-pended when new entries are added, so threads that are already 2N/A * using the list will continue correctly to the end of the list. 2N/A * This is the common data (global data) that is exported 2N/A * which no longer exists. This fixes the problem for applications 2N/A * that do not link directly with -lnsl but dlopen a shared object 2N/A * that has a NEEDED dependency on -lnsl and uses the netdir 2N/A /* if thr_get_storage fails we return the address of _nderror */ 2N/A * Adds a translator library to the xlate_list, but first check to see if 2N/A * it's already on the list. Must be called while holding xlate_lock. 2N/A * We have to be careful for the case of the same library being loaded 2N/A * We check for this case by looking at the gbn and name fields. 2N/A * If the gbn address is the same, but the names are different, then we 2N/A * have accidentally reloaded the library. We dlclose the new version, 2N/A * and then update 'translate' with the old versions of the symbols. 2N/A * into a bunch of netbufs that should connect you to that particular 2N/A * service. RPC uses it to contact the binder service (rpcbind). 2N/A * this routine calls a common interface _get_hostserv_inetnetdir_byname 2N/A * if it's called with a netconfig with "inet" type transports and 2N/A * which indicates the use of the switch. For non-inet transports or 2N/A * inet transports with nametoaddr libs specified, it simply calls 2N/A * the SVr4-classic netdir_getbyname, which loops through the libs. 2N/A * After all, any problem can be solved by one more layer of abstraction.. 2N/A * This routine when called with a netconfig with "inet6" type of transports 2N/A * returns pure IPv6 addresses only and if no IPv6 address is found it 2N/A * returns none - Bug Id. 4276329 2N/A * In code path of case NETDIR_BY, 2N/A * it also calls DOOR_GETIPNODEBYNAME_R. 2N/A * So af_family and flags are set to 2N/A * get V4 addresses only. 2N/A /* get both V4 & V6 addresses */ 2N/A * triples into a bunch of netbufs that should connect you to that particular 2N/A * service. RPC uses it to contact the binder service (rpcbind). 2N/A * It's either called by the real netdir_getbyname() interface above 2N/A char *
lr;
/* routines to try */ 2N/A int i;
/* counts the routines */ 2N/A /* If we didn't find it try loading it */ 2N/A /* add it to the list */ 2N/A * This routine is similar to the one above except that it tries to resolve 2N/A * the name by the address passed. 2N/A * This routine is similar to the one above except that it instructs the 2N/A * _get_hostserv_inetnetdir_byaddr not to do a service lookup. 2N/A * This routine is the svr4_classic routine for resolving a netbuf struct 2N/A * It's either called by the real netdir_getbyaddr() interface above 2N/A char *
lr;
/* routines to try */ 2N/A int i;
/* counts the routines */ 2N/A /* If we didn't find it try loading it */ 2N/A /* add it to the list */ 2N/A * This is the library routine to do transport specific stuff. 2N/A * The code is same as the other similar routines except that it does 2N/A * not bother to try whole bunch of routines since if the first 2N/A * libray cannot resolve the option, then no one can. 2N/A * If it gets a netconfig structure for inet transports with nametoddr libs, 2N/A * it simply calls the inet-specific built in implementation. 2N/A char *
lr;
/* routines to try */ 2N/A int i;
/* counts the routines */ 2N/A /* If we didn't find it try loading it */ 2N/A /* add it to the list */ 2N/A * This is the library routine for translating universal addresses to 2N/A * transport specific addresses. Again it uses the same code as above 2N/A * to search for the appropriate translation routine. Only it doesn't 2N/A * bother trying a whole bunch of routines since either the transport 2N/A * can translate it or it can't. 2N/A char *
lr;
/* routines to try */ 2N/A int i;
/* counts the routines */ 2N/A /* If we didn't find it try loading it */ 2N/A /* add it to the list */ 2N/A return (0);
/* No one works */ 2N/A * This is the library routine for translating transport specific 2N/A * addresses to universal addresses. Again it uses the same code as above 2N/A * to search for the appropriate translation routine. Only it doesn't 2N/A * bother trying a whole bunch of routines since either the transport 2N/A * can translate it or it can't. 2N/A char *
lr;
/* routines to try */ 2N/A char *x;
/* the answer */ 2N/A int i;
/* counts the routines */ 2N/A /* If we didn't find it try loading it */ 2N/A /* add it to the list */ 2N/A return (0);
/* No one works */ 2N/A * This is the routine that frees the objects that these routines allocate. 2N/A * XXX: We do NOT try to free all individual netbuf->buf 2N/A * pointers. Free only the first one since they are allocated 2N/A * using one calloc in 2N/A * This potentially causes memory leaks if a nametoaddr 2N/A * implementation -- from a third party -- has a different 2N/A * allocation scheme. 2N/A * load_xlate is a routine that will attempt to dynamically link in the 2N/A * file specified by the network configuration structure. 2N/A * We maintain a list of libraries we have loaded. Loading a library 2N/A * twice is double-plus ungood! 2N/A /* Resolve the getbyname symbol */ 2N/A "_netdir_getbyname");
2N/A /* resolve the getbyaddr symbol */ 2N/A "_netdir_getbyaddr");
2N/A /* resolve the taddr2uaddr symbol */ 2N/A /* resolve the uaddr2taddr symbol */ 2N/A /* resolve the netdir_options symbol */ 2N/A * Add this library to the list of loaded libraries. 2N/A * This is a routine that returns a string related to the current 2N/A * error in _nderror. 2N/A "n2a: symbol missing in shared object"),
2N/A "n2a: access denied for shared object"));
2N/A "n2a: attempt to free unknown object"));
2N/A "n2a: bad arguments passed to routine"));
2N/A * This is a routine that prints out strings related to the current 2N/A * error in _nderror. Like perror() it takes a string to print with a