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 /* 27 * RPC service routines 28 * It was initially generated using rpcgen. 29 */ 30 31 #include "idmapd.h" 32 #include <rpcsvc/idmap_prot.h> 33 #include <stdlib.h> 34 #include <signal.h> 35 #include <rpc/xdr.h> 36 #include <rpc/rpc.h> 37 #include <string.h> 38 #include <thread.h> 39 #include <synch.h> 40 41 42 /* ARGSUSED */ 43 int 44 _idmap_null_1(void *argp, void *result, struct svc_req *rqstp) 45 { 46 return (idmap_null_1_svc(result, rqstp)); 47 } 48 49 int 50 _idmap_get_mapped_ids_1(idmap_mapping_batch *argp, idmap_ids_res *result, 51 struct svc_req *rqstp) 52 { 53 return (idmap_get_mapped_ids_1_svc(*argp, result, rqstp)); 54 } 55 56 int 57 _idmap_list_mappings_1(idmap_list_mappings_1_argument *argp, 58 idmap_mappings_res *result, struct svc_req *rqstp) 59 { 60 return (idmap_list_mappings_1_svc(argp->lastrowid, 61 argp->limit, argp->flag, result, rqstp)); 62 } 63 64 int 65 _idmap_list_namerules_1(idmap_list_namerules_1_argument *argp, 66 idmap_namerules_res *result, struct svc_req *rqstp) 67 { 68 return (idmap_list_namerules_1_svc(argp->rule, argp->lastrowid, 69 argp->limit, result, rqstp)); 70 } 71 72 int 73 _idmap_update_1(idmap_update_batch *argp, idmap_update_res *res, 74 struct svc_req *rqstp) 75 { 76 return (idmap_update_1_svc(*argp, res, rqstp)); 77 } 78 79 int 80 _idmap_get_mapped_id_by_name_1(idmap_mapping *argp, 81 idmap_mappings_res *result, struct svc_req *rqstp) 82 { 83 return (idmap_get_mapped_id_by_name_1_svc(*argp, result, rqstp)); 84 } 85 86 int 87 _idmap_get_prop_1(idmap_prop_type *argp, 88 idmap_prop_res *result, struct svc_req *rqstp) 89 { 90 return (idmap_get_prop_1_svc(*argp, result, rqstp)); 91 } 92 93 94 95 void 96 idmap_prog_1(struct svc_req *rqstp, register SVCXPRT *transp) 97 { 98 union { 99 idmap_mapping_batch idmap_get_mapped_ids_1_arg; 100 idmap_list_mappings_1_argument idmap_list_mappings_1_arg; 101 idmap_list_namerules_1_argument idmap_list_namerules_1_arg; 102 idmap_update_batch idmap_update_1_arg; 103 idmap_mapping idmap_get_mapped_id_by_name_1_arg; 104 idmap_prop_type idmap_get_prop_1_arg; 105 } argument; 106 union { 107 idmap_ids_res idmap_get_mapped_ids_1_res; 108 idmap_mappings_res idmap_list_mappings_1_res; 109 idmap_namerules_res idmap_list_namerules_1_res; 110 idmap_update_res idmap_update_1_res; 111 idmap_mappings_res idmap_get_mapped_id_by_name_1_res; 112 idmap_prop_res idmap_get_prop_1_res; 113 } result; 114 bool_t retval; 115 xdrproc_t _xdr_argument, _xdr_result; 116 bool_t (*local)(char *, void *, struct svc_req *); 117 118 (void) mutex_lock(&_svcstate_lock); 119 _rpcsvccount++; 120 (void) mutex_unlock(&_svcstate_lock); 121 switch (rqstp->rq_proc) { 122 case IDMAP_NULL: 123 _xdr_argument = (xdrproc_t)xdr_void; 124 _xdr_result = (xdrproc_t)xdr_void; 125 local = (bool_t (*) (char *, void *, struct svc_req *)) 126 _idmap_null_1; 127 break; 128 129 case IDMAP_GET_MAPPED_IDS: 130 _xdr_argument = (xdrproc_t)xdr_idmap_mapping_batch; 131 _xdr_result = (xdrproc_t)xdr_idmap_ids_res; 132 local = (bool_t (*) (char *, void *, struct svc_req *)) 133 _idmap_get_mapped_ids_1; 134 break; 135 136 case IDMAP_LIST_MAPPINGS: 137 _xdr_argument = (xdrproc_t)xdr_idmap_list_mappings_1_argument; 138 _xdr_result = (xdrproc_t)xdr_idmap_mappings_res; 139 local = (bool_t (*) (char *, void *, struct svc_req *)) 140 _idmap_list_mappings_1; 141 break; 142 143 case IDMAP_LIST_NAMERULES: 144 _xdr_argument = (xdrproc_t)xdr_idmap_list_namerules_1_argument; 145 _xdr_result = (xdrproc_t)xdr_idmap_namerules_res; 146 local = (bool_t (*) (char *, void *, struct svc_req *)) 147 _idmap_list_namerules_1; 148 break; 149 150 case IDMAP_UPDATE: 151 _xdr_argument = (xdrproc_t)xdr_idmap_update_batch; 152 _xdr_result = (xdrproc_t)xdr_idmap_update_res; 153 local = (bool_t (*) (char *, void *, struct svc_req *)) 154 _idmap_update_1; 155 break; 156 157 case IDMAP_GET_MAPPED_ID_BY_NAME: 158 _xdr_argument = (xdrproc_t)xdr_idmap_mapping; 159 _xdr_result = (xdrproc_t)xdr_idmap_mappings_res; 160 local = (bool_t (*) (char *, void *, struct svc_req *)) 161 _idmap_get_mapped_id_by_name_1; 162 break; 163 164 case IDMAP_GET_PROP: 165 _xdr_argument = (xdrproc_t)xdr_idmap_prop_type; 166 _xdr_result = (xdrproc_t)xdr_idmap_prop_res; 167 local = (bool_t (*) (char *, void *, struct svc_req *)) 168 _idmap_get_prop_1; 169 break; 170 171 default: 172 svcerr_noproc(transp); 173 (void) mutex_lock(&_svcstate_lock); 174 _rpcsvccount--; 175 _rpcsvcstate = _SERVED; 176 (void) mutex_unlock(&_svcstate_lock); 177 return; 178 } 179 (void) memset((char *)&argument, 0, sizeof (argument)); 180 if (!svc_getargs(transp, _xdr_argument, (caddr_t)&argument)) { 181 svcerr_decode(transp); 182 (void) mutex_lock(&_svcstate_lock); 183 _rpcsvccount--; 184 _rpcsvcstate = _SERVED; 185 (void) mutex_unlock(&_svcstate_lock); 186 return; 187 } 188 retval = (bool_t)(*local)((char *)&argument, (void *)&result, rqstp); 189 if (_xdr_result && retval > 0 && !svc_sendreply(transp, _xdr_result, 190 (char *)&result)) { 191 svcerr_systemerr(transp); 192 } 193 if (!svc_freeargs(transp, _xdr_argument, (caddr_t)&argument)) { 194 idmapdlog(LOG_ERR, 195 "unable to free RPC arguments"); 196 exit(1); 197 } 198 if (_xdr_result != NULL) { 199 if (!idmap_prog_1_freeresult(transp, _xdr_result, 200 (caddr_t)&result)) 201 idmapdlog(LOG_ERR, 202 "unable to free RPC results"); 203 204 } 205 (void) mutex_lock(&_svcstate_lock); 206 _rpcsvccount--; 207 _rpcsvcstate = _SERVED; 208 (void) mutex_unlock(&_svcstate_lock); 209 } 210