1 /* 2 * Copyright (c) 1990 Jan-Simon Pendry 3 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Jan-Simon Pendry at Imperial College, London. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)amq_svc.c 8.1 (Berkeley) 6/6/93 39 * $Id: amq_svc.c,v 1.3 1995/12/18 16:48:57 deraadt Exp $ 40 * 41 */ 42 43 #include "am.h" 44 #include "amq.h" 45 extern bool_t xdr_amq_mount_info_qelem(); 46 47 void 48 amq_program_1(rqstp, transp) 49 struct svc_req *rqstp; 50 SVCXPRT *transp; 51 { 52 union { 53 amq_string amqproc_mnttree_1_arg; 54 amq_string amqproc_umnt_1_arg; 55 amq_setopt amqproc_setopt_1_arg; 56 amq_string amqproc_mount_1_arg; 57 } argument; 58 char *result; 59 bool_t (*xdr_argument)(), (*xdr_result)(); 60 char *(*local)(); 61 62 switch (rqstp->rq_proc) { 63 case AMQPROC_NULL: 64 xdr_argument = xdr_void; 65 xdr_result = xdr_void; 66 local = (char *(*)()) amqproc_null_1; 67 break; 68 69 case AMQPROC_MNTTREE: 70 xdr_argument = xdr_amq_string; 71 xdr_result = xdr_amq_mount_tree_p; 72 local = (char *(*)()) amqproc_mnttree_1; 73 break; 74 75 case AMQPROC_UMNT: 76 xdr_argument = xdr_amq_string; 77 xdr_result = xdr_void; 78 local = (char *(*)()) amqproc_umnt_1; 79 break; 80 81 case AMQPROC_STATS: 82 xdr_argument = xdr_void; 83 xdr_result = xdr_amq_mount_stats; 84 local = (char *(*)()) amqproc_stats_1; 85 break; 86 87 case AMQPROC_EXPORT: 88 xdr_argument = xdr_void; 89 xdr_result = xdr_amq_mount_tree_list; 90 local = (char *(*)()) amqproc_export_1; 91 break; 92 93 case AMQPROC_SETOPT: 94 xdr_argument = xdr_amq_setopt; 95 xdr_result = xdr_int; 96 local = (char *(*)()) amqproc_setopt_1; 97 break; 98 99 case AMQPROC_GETMNTFS: 100 xdr_argument = xdr_void; 101 xdr_result = xdr_amq_mount_info_qelem; 102 local = (char *(*)()) amqproc_getmntfs_1; 103 break; 104 105 case AMQPROC_MOUNT: 106 xdr_argument = xdr_amq_string; 107 xdr_result = xdr_int; 108 local = (char *(*)()) amqproc_mount_1; 109 break; 110 111 case AMQPROC_GETVERS: 112 xdr_argument = xdr_void; 113 xdr_result = xdr_amq_string; 114 local = (char *(*)()) amqproc_getvers_1; 115 break; 116 117 default: 118 svcerr_noproc(transp); 119 return; 120 } 121 bzero((char *)&argument, sizeof(argument)); 122 if (!svc_getargs(transp, xdr_argument, (char *)&argument)) { 123 svcerr_decode(transp); 124 return; 125 } 126 result = (*local)(&argument, rqstp); 127 if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { 128 svcerr_systemerr(transp); 129 } 130 if (!svc_freeargs(transp, xdr_argument, (char *)&argument)) { 131 plog(XLOG_FATAL, "unable to free rpc arguments in amqprog_1"); 132 going_down(1); 133 } 134 } 135 136