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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 */
25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
27 /*
28 * Portions of this source code were derived from Berkeley
29 * 4.3 BSD under license from the Regents of the University of
30 * California.
31 */
32
33 /*
34 * svc.h, Server-side remote procedure call interface.
35 */
36
37 #ifndef _RPC_SVC_H
38 #define _RPC_SVC_H
39
40 #include <rpc/rpc_com.h>
41 #include <rpc/rpc_msg.h>
42 #include <sys/tihdr.h>
43 #include <sys/poll.h>
172 /* send reply */
173 bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
174 /* free mem allocated for args */
175 void (*xp_destroy)(SVCMASTERXPRT *);
176 /* destroy this struct */
177 int (*xp_dup)(struct svc_req *, caddr_t, int,
178 struct dupreq **, bool_t *);
179 /* check for dup */
180 void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
181 /* mark dup entry as completed */
182 int32_t *(*xp_getres)(SVCXPRT *, int);
183 /* get pointer to response buffer */
184 void (*xp_freeres)(SVCXPRT *);
185 /* destroy pre-serialized response */
186 void (*xp_clone_destroy)(SVCXPRT *);
187 /* destroy a clone xprt */
188 void (*xp_start)(SVCMASTERXPRT *);
189 /* `ready-to-receive' */
190 void (*xp_clone_xprt)(SVCXPRT *, SVCXPRT *);
191 /* transport specific clone function */
192 void (*xp_tattrs) (SVCXPRT *, int, void **);
193 };
194
195 #define SVC_TATTR_ADDRMASK 1
196
197 #else /* _KERNEL */
198 /*
199 * Service control requests
200 */
201 #define SVCGET_VERSQUIET 1
202 #define SVCSET_VERSQUIET 2
203 #define SVCGET_XID 4
204 #define SVCSET_KEEPALIVE 5
205 #define SVCSET_CONNMAXREC 6
206 #define SVCGET_CONNMAXREC 7
207 #define SVCGET_RECVERRHANDLER 8
208 #define SVCSET_RECVERRHANDLER 9
209
210 enum xprt_stat {
211 XPRT_DIED,
212 XPRT_MOREREQS,
515 #ifdef _KERNEL
516 #define svc_getcaller(x) (&(x)->xp_rtaddr.buf)
517 #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
518 #define svc_getnetid(x) ((x)->xp_netid)
519 #endif /* _KERNEL */
520
521 /*
522 * Operations defined on an SVCXPRT handle
523 */
524
525 #ifdef _KERNEL
526
527 #define SVC_GETADDRMASK(clone_xprt, attrflag, tattr) \
528 (*(clone_xprt)->xp_ops->xp_tattrs)((clone_xprt), (attrflag), (tattr))
529
530 #define SVC_CLONE_XPRT(src_xprt, dst_xprt) \
531 if ((src_xprt)->xp_ops->xp_clone_xprt) \
532 (*(src_xprt)->xp_ops->xp_clone_xprt) \
533 (src_xprt, dst_xprt)
534
535 #define SVC_RECV(clone_xprt, mp, msg) \
536 (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
537
538 /*
539 * PSARC 2003/523 Contract Private Interface
540 * SVC_GETARGS
541 * Changes must be reviewed by Solaris File Sharing
542 * Changes must be communicated to contract-2003-523@sun.com
543 */
544 #define SVC_GETARGS(clone_xprt, xargs, argsp) \
545 (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
546
547 #define SVC_REPLY(clone_xprt, msg) \
548 (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
549
550 #define SVC_FREEARGS(clone_xprt, xargs, argsp) \
551 (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
552
553 #define SVC_GETRES(clone_xprt, size) \
554 (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
711 * Transport registration/unregistration.
712 *
713 * xprt_register(xprt)
714 * const SVCXPRT *xprt;
715 *
716 * xprt_unregister(xprt)
717 * const SVCXPRT *xprt;
718 */
719 extern void xprt_register(const SVCXPRT *);
720 extern void xprt_unregister(const SVCXPRT *);
721 #else /* __STDC__ */
722 extern bool_t rpc_reg();
723 extern bool_t svc_reg();
724 extern bool_t svc_auth_reg();
725 extern void svc_unreg();
726 extern void xprt_register();
727 extern void xprt_unregister();
728 #endif /* __STDC__ */
729 #endif /* _KERNEL */
730
731
732 /*
733 * When the service routine is called, it must first check to see if it
734 * knows about the procedure; if not, it should call svcerr_noproc
735 * and return. If so, it should deserialize its arguments via
736 * SVC_GETARGS (defined above). If the deserialization does not work,
737 * svcerr_decode should be called followed by a return. Successful
738 * decoding of the arguments should be followed the execution of the
739 * procedure's code and a call to svc_sendreply.
740 *
741 * Also, if the service refuses to execute the procedure due to too-
742 * weak authentication parameters, svcerr_weakauth should be called.
743 * Note: do not confuse access-control failure with weak authentication!
744 *
745 * NB: In pure implementations of rpc, the caller always waits for a reply
746 * msg. This message is sent when svc_sendreply is called.
747 * Therefore pure service implementations should always call
748 * svc_sendreply even if the function logically returns void; use
749 * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows
750 * for the abuse of pure rpc via batched calling or pipelining. In the
|
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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2012 Marcel Telka <marcel@telka.sk>
24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
26 */
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
29 /*
30 * Portions of this source code were derived from Berkeley
31 * 4.3 BSD under license from the Regents of the University of
32 * California.
33 */
34
35 /*
36 * svc.h, Server-side remote procedure call interface.
37 */
38
39 #ifndef _RPC_SVC_H
40 #define _RPC_SVC_H
41
42 #include <rpc/rpc_com.h>
43 #include <rpc/rpc_msg.h>
44 #include <sys/tihdr.h>
45 #include <sys/poll.h>
174 /* send reply */
175 bool_t (*xp_freeargs)(SVCXPRT *, xdrproc_t, caddr_t);
176 /* free mem allocated for args */
177 void (*xp_destroy)(SVCMASTERXPRT *);
178 /* destroy this struct */
179 int (*xp_dup)(struct svc_req *, caddr_t, int,
180 struct dupreq **, bool_t *);
181 /* check for dup */
182 void (*xp_dupdone)(struct dupreq *, caddr_t, void (*)(), int, int);
183 /* mark dup entry as completed */
184 int32_t *(*xp_getres)(SVCXPRT *, int);
185 /* get pointer to response buffer */
186 void (*xp_freeres)(SVCXPRT *);
187 /* destroy pre-serialized response */
188 void (*xp_clone_destroy)(SVCXPRT *);
189 /* destroy a clone xprt */
190 void (*xp_start)(SVCMASTERXPRT *);
191 /* `ready-to-receive' */
192 void (*xp_clone_xprt)(SVCXPRT *, SVCXPRT *);
193 /* transport specific clone function */
194 void (*xp_tattrs)(SVCXPRT *, int, void **);
195 /* transport specific hold function */
196 void (*xp_hold)(queue_t *);
197 /* transport specific release function */
198 void (*xp_release)(queue_t *, mblk_t *, bool_t);
199 };
200
201 #define SVC_TATTR_ADDRMASK 1
202
203 #else /* _KERNEL */
204 /*
205 * Service control requests
206 */
207 #define SVCGET_VERSQUIET 1
208 #define SVCSET_VERSQUIET 2
209 #define SVCGET_XID 4
210 #define SVCSET_KEEPALIVE 5
211 #define SVCSET_CONNMAXREC 6
212 #define SVCGET_CONNMAXREC 7
213 #define SVCGET_RECVERRHANDLER 8
214 #define SVCSET_RECVERRHANDLER 9
215
216 enum xprt_stat {
217 XPRT_DIED,
218 XPRT_MOREREQS,
521 #ifdef _KERNEL
522 #define svc_getcaller(x) (&(x)->xp_rtaddr.buf)
523 #define svc_getaddrmask(x) (&(x)->xp_master->xp_addrmask)
524 #define svc_getnetid(x) ((x)->xp_netid)
525 #endif /* _KERNEL */
526
527 /*
528 * Operations defined on an SVCXPRT handle
529 */
530
531 #ifdef _KERNEL
532
533 #define SVC_GETADDRMASK(clone_xprt, attrflag, tattr) \
534 (*(clone_xprt)->xp_ops->xp_tattrs)((clone_xprt), (attrflag), (tattr))
535
536 #define SVC_CLONE_XPRT(src_xprt, dst_xprt) \
537 if ((src_xprt)->xp_ops->xp_clone_xprt) \
538 (*(src_xprt)->xp_ops->xp_clone_xprt) \
539 (src_xprt, dst_xprt)
540
541 #define SVC_HOLD(xprt) \
542 if ((xprt)->xp_ops->xp_hold) \
543 (*(xprt)->xp_ops->xp_hold)((xprt)->xp_wq)
544
545 #define SVC_RELE(xprt, mp, enable) \
546 if ((xprt)->xp_ops->xp_release) \
547 (*(xprt)->xp_ops->xp_release)((xprt)->xp_wq, (mp), (enable))
548
549 #define SVC_RECV(clone_xprt, mp, msg) \
550 (*(clone_xprt)->xp_ops->xp_recv)((clone_xprt), (mp), (msg))
551
552 /*
553 * PSARC 2003/523 Contract Private Interface
554 * SVC_GETARGS
555 * Changes must be reviewed by Solaris File Sharing
556 * Changes must be communicated to contract-2003-523@sun.com
557 */
558 #define SVC_GETARGS(clone_xprt, xargs, argsp) \
559 (*(clone_xprt)->xp_ops->xp_getargs)((clone_xprt), (xargs), (argsp))
560
561 #define SVC_REPLY(clone_xprt, msg) \
562 (*(clone_xprt)->xp_ops->xp_reply) ((clone_xprt), (msg))
563
564 #define SVC_FREEARGS(clone_xprt, xargs, argsp) \
565 (*(clone_xprt)->xp_ops->xp_freeargs)((clone_xprt), (xargs), (argsp))
566
567 #define SVC_GETRES(clone_xprt, size) \
568 (*(clone_xprt)->xp_ops->xp_getres)((clone_xprt), (size))
725 * Transport registration/unregistration.
726 *
727 * xprt_register(xprt)
728 * const SVCXPRT *xprt;
729 *
730 * xprt_unregister(xprt)
731 * const SVCXPRT *xprt;
732 */
733 extern void xprt_register(const SVCXPRT *);
734 extern void xprt_unregister(const SVCXPRT *);
735 #else /* __STDC__ */
736 extern bool_t rpc_reg();
737 extern bool_t svc_reg();
738 extern bool_t svc_auth_reg();
739 extern void svc_unreg();
740 extern void xprt_register();
741 extern void xprt_unregister();
742 #endif /* __STDC__ */
743 #endif /* _KERNEL */
744
745 #ifdef _KERNEL
746 /*
747 * Transport hold and release.
748 */
749 extern void rpcmod_hold(queue_t *);
750 extern void rpcmod_release(queue_t *, mblk_t *, bool_t);
751 extern void mir_svc_hold(queue_t *);
752 extern void mir_svc_release(queue_t *, mblk_t *, bool_t);
753 #endif /* _KERNEL */
754
755 /*
756 * When the service routine is called, it must first check to see if it
757 * knows about the procedure; if not, it should call svcerr_noproc
758 * and return. If so, it should deserialize its arguments via
759 * SVC_GETARGS (defined above). If the deserialization does not work,
760 * svcerr_decode should be called followed by a return. Successful
761 * decoding of the arguments should be followed the execution of the
762 * procedure's code and a call to svc_sendreply.
763 *
764 * Also, if the service refuses to execute the procedure due to too-
765 * weak authentication parameters, svcerr_weakauth should be called.
766 * Note: do not confuse access-control failure with weak authentication!
767 *
768 * NB: In pure implementations of rpc, the caller always waits for a reply
769 * msg. This message is sent when svc_sendreply is called.
770 * Therefore pure service implementations should always call
771 * svc_sendreply even if the function logically returns void; use
772 * xdr.h - xdr_void for the xdr routine. HOWEVER, connectionful rpc allows
773 * for the abuse of pure rpc via batched calling or pipelining. In the
|