2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * CDDL HEADER START
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * The contents of this file are subject to the terms of the
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Common Development and Distribution License (the "License").
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * You may not use this file except in compliance with the License.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * or http://www.opensolaris.org/os/licensing.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * See the License for the specific language governing permissions
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * and limitations under the License.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * When distributing Covered Code, include this CDDL HEADER in each
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * If applicable, add the following below this CDDL HEADER, with the
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * fields enclosed by brackets "[]" replaced with your own identifying
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * information: Portions Copyright [yyyy] [name of copyright owner]
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * CDDL HEADER END
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Use is subject to license terms.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Helper routines for nfsmapid and autod daemon
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * to translate hostname to IP address and Netinfo.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow syslog(LOG_ERR, "get_knconf: stat %s: %m", nconf->nc_device);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow k = (struct knetconfig *)malloc(sizeof (*k));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow bcopy(nconf->nc_protofmly, k->knc_protofmly, len);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Get the information needed for an NFSv4.x referral. This
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * information includes the netbuf, netname and knconfig.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowget_nfs4ref_info(char *host, int port, int nfsver)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fsl_retp = calloc(1, sizeof (struct nfs_fsl_info));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow syslog(LOG_ERR, "get_nfs4ref_info: no memory\n");
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fsl_retp->addr = resolve_netconf(host, NFS_PROGRAM, nfsver,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow &netconf, port, NULL, NULL, TRUE, NULL, &cstat);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (netconf == NULL || fsl_retp->addr == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fsl_retp->knconf_len = (sizeof (struct knetconfig) +
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow fsl_retp->netbuf_len = (sizeof (struct netbuf) +
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowfree_nfs4ref_info(struct nfs_fsl_info *fsl_retp)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowcleanup_tli_parms(struct t_bind *tbind, int fd)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowresolve_netconf(char *host, rpcprog_t prog, rpcvers_t nfsver,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow struct t_info *tinfo, caddr_t *fhp, bool_t direct_to_server,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow } /* while */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow nb = get_server_addr(host, NFS_PROGRAM, nfsver,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow nconf, port, NULL, NULL, TRUE, NULL, &cstat);
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowsetup_nb_parms(struct netconfig *nconf, struct t_bind *tbind,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow struct t_info *tinfo, char *hostname, int fd, bool_t direct_to_server,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow ushort_t port, rpcprog_t prog, rpcvers_t vers, bool_t file_handle)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (netdir_getbyname(nconf, &hs, &retaddrs) != ND_OK) {
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow memcpy(tbind->addr.buf, retaddrs->n_addrs->buf,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow tbind->addr.maxlen = retaddrs->n_addrs->maxlen;
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* LINTED pointer alignment */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (strcmp(nconf->nc_protofmly, NC_INET) == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow else if (strcmp(nconf->nc_protofmly, NC_INET6) == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (netdir_options(nconf, ND_SET_RESERVEDPORT, fd,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow /* LINTED pointer alignment */
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (strcmp(nconf->nc_protofmly, NC_INET) == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow else if (strcmp(nconf->nc_protofmly, NC_INET6) == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Sets up TLI interface and finds the address withe netdir_getbyname().
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * returns the address returned from the call.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow * Caller frees up the memory allocated here.
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlowget_server_addr(char *hostname, rpcprog_t prog, rpcvers_t vers,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow struct t_info *tinfo, caddr_t *fhp, bool_t direct_to_server,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (strncasecmp(nconf->nc_proto, NC_UDP, strlen(NC_UDP)) == 0)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if ((fd = t_open(nconf->nc_device, O_RDWR, tinfo)) < 0)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if ((tbind = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR)) == NULL)
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow if (setup_nb_parms(nconf, tbind, tinfo, hostname, fd, direct_to_server,
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow nb = (struct netbuf *)malloc(sizeof (struct netbuf));
2f172c55ef76964744bc62b4500ece87f3089b4dRobert Thurlow nb->buf = (char *)malloc(tbind->addr.maxlen);