rdc_subr.c revision 3270659f55e0928d6edec3d26217cc29398a8149
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on 2.6 both dki_lock.h and rpc/types.h define bool_t so we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * define enum_t here as it is all we need from rpc/types.h
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * anyway and make it look like we included it. Yuck.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SunOS_2_6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize a netbuf suitable for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * describing an address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free a netbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_PANIC, "Null netbuf in free_rdc_netbuf");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Duplicate a netbuf, must be followed by a free_rdc_netbuf().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedup_rdc_netbuf(const struct netbuf *from, struct netbuf *to)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!dup_rdc_netbuf: from->len %d, to->maxlen %d",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc %s servinfo: %p\n", str, (void *) svp);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!\naddr: len %d buf %p\n",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!host: %s\n", svp->ri_hostname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize an rdc servinfo
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contains all the protocol we need to do a client rpc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A chain of rdc_srv_t indicates a one to many
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_create_svinfo(char *host, struct netbuf *svaddr, struct knetconfig *conf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_knconf = kmem_alloc(sizeof (*nvp->ri_knconf), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvp == NULL || nvp->ri_hostname == NULL || nvp->ri_knconf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)conf, (void *)nvp->ri_knconf, sizeof (*nvp->ri_knconf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_knconf->knc_protofmly = kmem_zalloc(KNC_STRSIZE + 1, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_knconf->knc_proto = kmem_zalloc(KNC_STRSIZE + 1, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(nvp->ri_knconf->knc_protofmly, conf->knc_protofmly,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(nvp->ri_knconf->knc_proto, conf->knc_proto, KNC_STRSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf->knc_protofmly, KNC_STRSIZE + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf->knc_proto, KNC_STRSIZE + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf, sizeof (*svp->ri_knconf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_netbuf_toint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns oldsytle ipv4 RDC ver 3 addresses for RPC protocol from netbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: This would never be called in the case of IPv6 and a program
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mismatch ie ver 3 to ver 4
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_netbuf_toint: bad size %d", nb->len);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_netbuf_toint: size %d", nb->len);