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, NULL }
  54 };
  55 
  56 
  57 int
  58 _init(void)
  59 {
  60         return (mod_install(&modlinkage));
  61 }
  62 
  63 
  64 int
  65 _fini(void)
  66 {
  67         /* unload is forbidden */
  68         return (EBUSY);
  69 }
  70 
  71 
  72 int
  73 _info(struct modinfo *modinfop)
  74 {
  75         return (mod_info(&modlinkage, modinfop));
  76 }
  77 
  78 
  79 /*
  80  * rdcstub_dispatch is the place holder for rdcsrv_dispatch.
  81  * rdcsrv registers this function as kRPC dispatch function.
  82  * If rdcsrv is unloaded (uninstall package), then dispatch
  83  * is set to null_dispatch
  84  */
  85 void
  86 rdcstub_dispatch(struct svc_req *req, SVCXPRT *xprt)
  87 {
  88         (*dispatch)(req, xprt);
  89 }
  90 
  91 /* ARGSUSED */
  92 static void
  93 null_dispatch(struct svc_req *req, SVCXPRT *xprt)
  94 {
  95         svcerr_noproc(xprt);
  96 }
  97 
  98 void
  99 rdcstub_set_dispatch(void (*disp)(struct svc_req *, SVCXPRT *))
 100 {
 101         ASSERT(disp != NULL);
 102         dispatch = disp;
 103 }
 104 
 105 void
 106 rdcstub_unset_dispatch()
 107 {
 108         dispatch = null_dispatch;
 109 }