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 (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/cmn_err.h>
  28 #include <sys/modctl.h>
  29 #include <sys/errno.h>
  30 
  31 #include <rpc/auth.h>
  32 #include <rpc/svc.h>
  33 
  34 #include <sys/nsctl/nsctl.h>
  35 #include <sys/nsctl/nsvers.h>
  36 #include "rdc_stub.h"
  37 
  38 static void null_dispatch(struct svc_req *req, SVCXPRT *xprt);
  39 static void (*dispatch)(struct svc_req *, SVCXPRT *) = null_dispatch;
  40 
  41 /*
  42  * Solaris module setup.
  43  */
  44 extern struct mod_ops mod_miscops;
  45 
  46 static struct modlmisc modlmisc = {
  47         &mod_miscops,   /* Type of module */
  48         "nws:Remote Mirror kRPC Stub:" ISS_VERSION_STR
  49 };
  50 
  51 static struct modlinkage modlinkage = {
  52         MODREV_1,
  53         &modlmisc,
  54         NULL
  55 };
  56 
  57 
  58 int
  59 _init(void)
  60 {
  61         return (mod_install(&modlinkage));
  62 }
  63 
  64 
  65 int
  66 _fini(void)
  67 {
  68         /* unload is forbidden */
  69         return (EBUSY);
  70 }
  71 
  72 
  73 int
  74 _info(struct modinfo *modinfop)
  75 {
  76         return (mod_info(&modlinkage, modinfop));
  77 }
  78 
  79 
  80 /*
  81  * rdcstub_dispatch is the place holder for rdcsrv_dispatch.
  82  * rdcsrv registers this function as kRPC dispatch function.
  83  * If rdcsrv is unloaded (uninstall package), then dispatch
  84  * is set to null_dispatch
  85  */
  86 void
  87 rdcstub_dispatch(struct svc_req *req, SVCXPRT *xprt)
  88 {
  89         (*dispatch)(req, xprt);
  90 }
  91 
  92 /* ARGSUSED */
  93 static void
  94 null_dispatch(struct svc_req *req, SVCXPRT *xprt)
  95 {
  96         svcerr_noproc(xprt);
  97 }
  98 
  99 void
 100 rdcstub_set_dispatch(void (*disp)(struct svc_req *, SVCXPRT *))
 101 {
 102         ASSERT(disp != NULL);
 103         dispatch = disp;
 104 }
 105 
 106 void
 107 rdcstub_unset_dispatch()
 108 {
 109         dispatch = null_dispatch;
 110 }