14520Snw141292 /* 24520Snw141292 * CDDL HEADER START 34520Snw141292 * 44520Snw141292 * The contents of this file are subject to the terms of the 54520Snw141292 * Common Development and Distribution License (the "License"). 64520Snw141292 * You may not use this file except in compliance with the License. 74520Snw141292 * 84520Snw141292 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 94520Snw141292 * or http://www.opensolaris.org/os/licensing. 104520Snw141292 * See the License for the specific language governing permissions 114520Snw141292 * and limitations under the License. 124520Snw141292 * 134520Snw141292 * When distributing Covered Code, include this CDDL HEADER in each 144520Snw141292 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 154520Snw141292 * If applicable, add the following below this CDDL HEADER, with the 164520Snw141292 * fields enclosed by brackets "[]" replaced with your own identifying 174520Snw141292 * information: Portions Copyright [yyyy] [name of copyright owner] 184520Snw141292 * 194520Snw141292 * CDDL HEADER END 204520Snw141292 */ 214520Snw141292 /* 224520Snw141292 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 234520Snw141292 * Use is subject to license terms. 244520Snw141292 */ 254520Snw141292 264520Snw141292 #pragma ident "%Z%%M% %I% %E% SMI" 274520Snw141292 284520Snw141292 /* 294520Snw141292 * RPC service routines 304520Snw141292 * It was initially generated using rpcgen. 314520Snw141292 */ 324520Snw141292 334520Snw141292 #include "idmapd.h" 344520Snw141292 #include "idmap_prot.h" 354520Snw141292 #include <stdlib.h> 364520Snw141292 #include <signal.h> 374520Snw141292 #include <rpc/xdr.h> 384520Snw141292 #include <rpc/rpc.h> 394520Snw141292 #include <string.h> 404520Snw141292 #include <thread.h> 414520Snw141292 #include <synch.h> 424520Snw141292 434520Snw141292 444520Snw141292 /* ARGSUSED */ 454520Snw141292 int 464520Snw141292 _idmap_null_1(void *argp, void *result, struct svc_req *rqstp) 474520Snw141292 { 484520Snw141292 return (idmap_null_1_svc(result, rqstp)); 494520Snw141292 } 504520Snw141292 514520Snw141292 int 524520Snw141292 _idmap_get_mapped_ids_1(idmap_mapping_batch *argp, idmap_ids_res *result, 53*5696Snw141292 struct svc_req *rqstp) 54*5696Snw141292 { 554520Snw141292 return (idmap_get_mapped_ids_1_svc(*argp, result, rqstp)); 564520Snw141292 } 574520Snw141292 584520Snw141292 int 594520Snw141292 _idmap_list_mappings_1(idmap_list_mappings_1_argument *argp, 60*5696Snw141292 idmap_mappings_res *result, struct svc_req *rqstp) 61*5696Snw141292 { 62*5696Snw141292 return (idmap_list_mappings_1_svc(argp->lastrowid, 63*5696Snw141292 argp->limit, result, rqstp)); 644520Snw141292 } 654520Snw141292 664520Snw141292 int 674520Snw141292 _idmap_list_namerules_1(idmap_list_namerules_1_argument *argp, 68*5696Snw141292 idmap_namerules_res *result, struct svc_req *rqstp) 69*5696Snw141292 { 704520Snw141292 return (idmap_list_namerules_1_svc(argp->rule, argp->lastrowid, 71*5696Snw141292 argp->limit, result, rqstp)); 724520Snw141292 } 734520Snw141292 744520Snw141292 int 755064Sdm199847 _idmap_update_1(idmap_update_batch *argp, idmap_update_res *res, 76*5696Snw141292 struct svc_req *rqstp) 77*5696Snw141292 { 785064Sdm199847 return (idmap_update_1_svc(*argp, res, rqstp)); 794520Snw141292 } 804520Snw141292 814520Snw141292 int 824520Snw141292 _idmap_get_mapped_id_by_name_1(idmap_mapping *argp, 83*5696Snw141292 idmap_mappings_res *result, struct svc_req *rqstp) 84*5696Snw141292 { 854520Snw141292 return (idmap_get_mapped_id_by_name_1_svc(*argp, result, rqstp)); 864520Snw141292 } 874520Snw141292 884520Snw141292 894520Snw141292 void 904520Snw141292 idmap_prog_1(struct svc_req *rqstp, register SVCXPRT *transp) 914520Snw141292 { 924520Snw141292 union { 934520Snw141292 idmap_mapping_batch idmap_get_mapped_ids_1_arg; 944520Snw141292 idmap_list_mappings_1_argument idmap_list_mappings_1_arg; 954520Snw141292 idmap_list_namerules_1_argument idmap_list_namerules_1_arg; 964520Snw141292 idmap_update_batch idmap_update_1_arg; 974520Snw141292 idmap_mapping idmap_get_mapped_id_by_name_1_arg; 984520Snw141292 } argument; 994520Snw141292 union { 1004520Snw141292 idmap_ids_res idmap_get_mapped_ids_1_res; 1014520Snw141292 idmap_mappings_res idmap_list_mappings_1_res; 1024520Snw141292 idmap_namerules_res idmap_list_namerules_1_res; 1035064Sdm199847 idmap_update_res idmap_update_1_res; 1044520Snw141292 idmap_mappings_res idmap_get_mapped_id_by_name_1_res; 1054520Snw141292 } result; 1064520Snw141292 bool_t retval; 1074520Snw141292 xdrproc_t _xdr_argument, _xdr_result; 1084520Snw141292 bool_t (*local)(char *, void *, struct svc_req *); 1094520Snw141292 1104520Snw141292 (void) mutex_lock(&_svcstate_lock); 1114520Snw141292 _rpcsvccount++; 1124520Snw141292 (void) mutex_unlock(&_svcstate_lock); 1134520Snw141292 switch (rqstp->rq_proc) { 1144520Snw141292 case IDMAP_NULL: 1154520Snw141292 _xdr_argument = (xdrproc_t)xdr_void; 1164520Snw141292 _xdr_result = (xdrproc_t)xdr_void; 1174520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1184520Snw141292 _idmap_null_1; 1194520Snw141292 break; 1204520Snw141292 1214520Snw141292 case IDMAP_GET_MAPPED_IDS: 1224520Snw141292 _xdr_argument = (xdrproc_t)xdr_idmap_mapping_batch; 1234520Snw141292 _xdr_result = (xdrproc_t)xdr_idmap_ids_res; 1244520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1254520Snw141292 _idmap_get_mapped_ids_1; 1264520Snw141292 break; 1274520Snw141292 1284520Snw141292 case IDMAP_LIST_MAPPINGS: 1294520Snw141292 _xdr_argument = (xdrproc_t)xdr_idmap_list_mappings_1_argument; 1304520Snw141292 _xdr_result = (xdrproc_t)xdr_idmap_mappings_res; 1314520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1324520Snw141292 _idmap_list_mappings_1; 1334520Snw141292 break; 1344520Snw141292 1354520Snw141292 case IDMAP_LIST_NAMERULES: 1364520Snw141292 _xdr_argument = (xdrproc_t)xdr_idmap_list_namerules_1_argument; 1374520Snw141292 _xdr_result = (xdrproc_t)xdr_idmap_namerules_res; 1384520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1394520Snw141292 _idmap_list_namerules_1; 1404520Snw141292 break; 1414520Snw141292 1424520Snw141292 case IDMAP_UPDATE: 1434520Snw141292 _xdr_argument = (xdrproc_t)xdr_idmap_update_batch; 1445064Sdm199847 _xdr_result = (xdrproc_t)xdr_idmap_update_res; 1454520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1464520Snw141292 _idmap_update_1; 1474520Snw141292 break; 1484520Snw141292 1494520Snw141292 case IDMAP_GET_MAPPED_ID_BY_NAME: 1504520Snw141292 _xdr_argument = (xdrproc_t)xdr_idmap_mapping; 1514520Snw141292 _xdr_result = (xdrproc_t)xdr_idmap_mappings_res; 1524520Snw141292 local = (bool_t (*) (char *, void *, struct svc_req *)) 1534520Snw141292 _idmap_get_mapped_id_by_name_1; 1544520Snw141292 break; 1554520Snw141292 1564520Snw141292 default: 1574520Snw141292 svcerr_noproc(transp); 1584520Snw141292 (void) mutex_lock(&_svcstate_lock); 1594520Snw141292 _rpcsvccount--; 1604520Snw141292 _rpcsvcstate = _SERVED; 1614520Snw141292 (void) mutex_unlock(&_svcstate_lock); 1624520Snw141292 return; 1634520Snw141292 } 1644520Snw141292 (void) memset((char *)&argument, 0, sizeof (argument)); 1654520Snw141292 if (!svc_getargs(transp, _xdr_argument, (caddr_t)&argument)) { 1664520Snw141292 svcerr_decode(transp); 1674520Snw141292 (void) mutex_lock(&_svcstate_lock); 1684520Snw141292 _rpcsvccount--; 1694520Snw141292 _rpcsvcstate = _SERVED; 1704520Snw141292 (void) mutex_unlock(&_svcstate_lock); 1714520Snw141292 return; 1724520Snw141292 } 1734520Snw141292 retval = (bool_t)(*local)((char *)&argument, (void *)&result, rqstp); 1744520Snw141292 if (_xdr_result && retval > 0 && !svc_sendreply(transp, _xdr_result, 1754520Snw141292 (char *)&result)) { 1764520Snw141292 svcerr_systemerr(transp); 1774520Snw141292 } 1784520Snw141292 if (!svc_freeargs(transp, _xdr_argument, (caddr_t)&argument)) { 1794520Snw141292 idmapdlog(LOG_ERR, 1804520Snw141292 "unable to free RPC arguments"); 1814520Snw141292 exit(1); 1824520Snw141292 } 1834520Snw141292 if (_xdr_result != NULL) { 1844520Snw141292 if (!idmap_prog_1_freeresult(transp, _xdr_result, 1854520Snw141292 (caddr_t)&result)) 1864520Snw141292 idmapdlog(LOG_ERR, 1874520Snw141292 "unable to free RPC results"); 1884520Snw141292 1894520Snw141292 } 1904520Snw141292 (void) mutex_lock(&_svcstate_lock); 1914520Snw141292 _rpcsvccount--; 1924520Snw141292 _rpcsvcstate = _SERVED; 1934520Snw141292 (void) mutex_unlock(&_svcstate_lock); 1944520Snw141292 } 195