fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ksynch.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/debug.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/cmn_err.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/kmem.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef _SunOS_2_6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _RPC_TYPES_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef int enum_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef DS_DDICT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rpc/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SunOS_2_6 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsc_thread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "rdc_io.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "rdc_ioctl.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "rdc_prot.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize a netbuf suitable for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * describing an address
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteinit_rdc_netbuf(struct netbuf *nbuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->buf = kmem_zalloc(RDC_MAXADDR, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->maxlen = RDC_MAXADDR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->len = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free a netbuf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefree_rdc_netbuf(struct netbuf *nbuf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(nbuf) || !(nbuf->buf)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_PANIC, "Null netbuf in free_rdc_netbuf");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(nbuf->buf, nbuf->maxlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->buf = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->maxlen = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nbuf->len = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Duplicate a netbuf, must be followed by a free_rdc_netbuf().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedup_rdc_netbuf(const struct netbuf *from, struct netbuf *to)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte init_rdc_netbuf(to);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte to->len = from->len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (from->len > to->maxlen) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_WARN, "!dup_rdc_netbuf: from->len %d, to->maxlen %d",
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana from->len, to->maxlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(from->buf, to->buf, (size_t)from->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_print_svinfo(rdc_srv_t *svp, char *str)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc %s servinfo: %p\n", str, (void *) svp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->ri_knconf != NULL) {
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!knconf: semantics %d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->ri_knconf->knc_semantics);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "! protofmly %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->ri_knconf->knc_protofmly);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "! proto %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->ri_knconf->knc_proto);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "! rdev %lx",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->ri_knconf->knc_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < svp->ri_addr.len; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("%u ", svp->ri_addr.buf[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!\naddr: len %d buf %p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->ri_addr.len, (void *) svp->ri_addr.buf);
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!host: %s\n", svp->ri_hostname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_srv_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_create_svinfo(char *host, struct netbuf *svaddr, struct knetconfig *conf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_srv_t *nvp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hlen = strlen(host) + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (conf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (host == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp = kmem_zalloc(sizeof (*nvp), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_knconf = kmem_alloc(sizeof (*nvp->ri_knconf), KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_hostname = kmem_zalloc(hlen, KM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvp == NULL || nvp->ri_hostname == NULL || nvp->ri_knconf == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_destroy_svinfo(nvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_hostnamelen = hlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvp->ri_knconf->knc_protofmly == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_knconf->knc_proto == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_destroy_svinfo(nvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(nvp->ri_knconf->knc_protofmly, conf->knc_protofmly,
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana KNC_STRSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(nvp->ri_knconf->knc_proto, conf->knc_proto, KNC_STRSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dup_rdc_netbuf(svaddr, &nvp->ri_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvp->ri_secdata = NULL; /* For now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(nvp->ri_hostname, host, hlen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG_IP
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana rdc_print_svinfo(nvp, "!create");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (nvp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_destroy_svinfo(rdc_srv_t *svp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->ri_addr.buf && svp->ri_addr.maxlen)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_rdc_netbuf(&(svp->ri_addr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->ri_knconf->knc_protofmly)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf->knc_protofmly, KNC_STRSIZE + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->ri_knconf->knc_proto)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf->knc_proto, KNC_STRSIZE + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->ri_knconf)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp->ri_knconf, sizeof (*svp->ri_knconf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(svp, sizeof (*svp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_netbuf_toint(struct netbuf *nb)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nb->len > RDC_MAXADDR)
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_netbuf_toint: bad size %d", nb->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (nb->len) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(nb->buf, (char *)&ret, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 8:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 16:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 32:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&nb->buf[4], (char *)&ret, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
3270659f55e0928d6edec3d26217cc29398a8149Srikanth, Ramana cmn_err(CE_NOTE, "!rdc_netbuf_toint: size %d", nb->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}