2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
24 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
25 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 //%% (c) Copyright 1993, 1994 Novell, Inc.
27 //%% $TOG: mp_rpc_implement.C /main/9 1999/10/14 18:42:58 mgreess $
29 * mp_rpc_implement.C 1.40 29 Jul 1993
31 * mp_rpc_implement.cc -- implementation of RPC functions
33 * Copyright (c) 1990,1992 by Sun Microsystems, Inc.
35 * This file implements the RPC wrapper functions for each RPC
36 * procedure number. The responsibility of each wrapper is to decode and
37 * encode arguments and results and invoke the right methods
38 * corresponding to each activity.
46 #include <sys/param.h>
47 #include <sys/types.h>
52 #if defined(linux) || defined(CSRG_BASED)
53 /*# include <g++/minmax.h>*/
57 #include "tt_options.h"
58 #include "util/tt_xdr_version.h"
61 #include "mp/mp_global.h"
62 #include "mp_s_file.h"
63 #include "mp_s_file_utils.h"
66 #include "mp_s_message.h"
68 #include "mp_signature.h"
69 #include "mp/mp_arg.h"
70 #include "mp_s_msg_context.h"
71 #include "mp_s_pattern.h"
72 #include "mp_s_procid.h"
73 #include "mp/mp_rpc_fns.h"
74 #include "mp_rpc_implement.h"
75 #include "mp_s_session.h"
76 #include "mp/mp_xdr_functions.h"
77 #include "mp_s_xdr_functions.h"
78 #include "util/tt_trace.h"
79 #include "mp_typedb.h"
81 #if defined(OPT_SECURE_RPC)
83 static uid_t req_auth_uid;
84 static gid_t req_auth_gid;
85 static short req_auth_gidlen;
87 // authdes_getucred() in 4.x is declared to take int* instead of gid_t*
88 #if defined(OPT_BUG_SUNOS_4)
89 static int req_auth_gids[10];
91 static gid_t req_auth_gids[NGROUPS_MAX];
92 #endif /* OPT_BUG_SUNOS_4 */
94 #endif /* OPT_SECURE_RPC */
96 #if defined(OPT_BUG_SUNOS_4)
97 # define RPC_ARG_T char *
99 # define RPC_ARG_T caddr_t
100 #endif /* OPT_BUG_SUNOS_4 */
102 #if defined(OPT_BUG_SUNOS_5)
103 typedef (*Hack_getucred)(const struct authdes_cred *,
108 #endif /* OPT_BUG_SUNOS_5 */
110 void _tt_rpc_nullproc(SVCXPRT *);
111 void _tt_rpc_dispatch(SVCXPRT *);
112 void _tt_rpc_dispatch_with_context(SVCXPRT *);
113 void _tt_rpc_update_msg(SVCXPRT *);
114 void _tt_rpc_join_file(SVCXPRT *);
115 void _tt_rpc_quit_file(SVCXPRT *);
116 void _tt_rpc_join_session(SVCXPRT *);
117 void _tt_rpc_quit_session(SVCXPRT *);
118 void _tt_rpc_join_context(SVCXPRT *);
119 void _tt_rpc_quit_context(SVCXPRT *);
120 void _tt_rpc_next_message(SVCXPRT *);
121 void _tt_rpc_add_pattern(SVCXPRT *);
122 void _tt_rpc_add_pattern_with_context(SVCXPRT *);
123 void _tt_rpc_del_pattern(SVCXPRT *);
124 void _tt_rpc_declare_ptype(SVCXPRT *);
125 void _tt_rpc_set_fd_channel(SVCXPRT *);
126 void _tt_rpc_set_prop(SVCXPRT *);
127 void _tt_rpc_add_prop(SVCXPRT *);
128 void _tt_rpc_get_prop(SVCXPRT *);
129 void _tt_rpc_prop_count(SVCXPRT *);
130 void _tt_rpc_prop_name(SVCXPRT *);
131 void _tt_rpc_prop_names_count(SVCXPRT *);
132 void _tt_rpc_alloc_procid_key(SVCXPRT *);
133 void _tt_rpc_close_procid(SVCXPRT *);
134 void _tt_rpc_otype_deriveds_count(SVCXPRT *);
135 void _tt_rpc_otype_derived(SVCXPRT *);
136 void _tt_rpc_otype_base(SVCXPRT *);
137 void _tt_rpc_otype_is_derived(SVCXPRT *);
138 void _tt_rpc_otype_osig_count(SVCXPRT *);
139 void _tt_rpc_otype_hsig_count(SVCXPRT *);
140 void _tt_rpc_otype_osig_op(SVCXPRT *);
141 void _tt_rpc_otype_hsig_op(SVCXPRT *);
142 void _tt_rpc_otype_osig_args_count(SVCXPRT *);
143 void _tt_rpc_otype_hsig_args_count(SVCXPRT *);
144 void _tt_rpc_otype_osig_arg_mode(SVCXPRT *);
145 void _tt_rpc_otype_hsig_arg_mode(SVCXPRT *);
146 void _tt_rpc_otype_osig_arg_type(SVCXPRT *);
147 void _tt_rpc_otype_hsig_arg_type(SVCXPRT *);
148 void _tt_rpc_hdispatch(SVCXPRT *);
149 void _tt_rpc_hupdate_msg(SVCXPRT *);
150 void _tt_rpc_get_omap(SVCXPRT *);
151 void _tt_rpc_add_omap(SVCXPRT *);
152 void _tt_rpc_dispatch_2(SVCXPRT *);
153 void _tt_rpc_dispatch_2_with_context(SVCXPRT *);
154 void _tt_rpc_update_msg_2(SVCXPRT *);
155 void _tt_rpc_msgread_2(SVCXPRT *);
156 void _tt_rpc_vrfy_session(SVCXPRT *);
157 void _tt_rpc_dispatch_on_exit(SVCXPRT *);
158 void _tt_rpc_undeclare_ptype(SVCXPRT *);
159 void _tt_rpc_exists_ptype(SVCXPRT *);
160 void _tt_rpc_unblock_ptype(SVCXPRT *);
161 void _tt_rpc_load_types(SVCXPRT *);
164 typedef void (*_Tt_rpc_stub)(SVCXPRT *);
166 * Dispatch table for rpc procedures. Note that the position of the
167 * dispatch functions must correspond to the _Tt_rpc_procedure number
170 const _Tt_rpc_stub _tt_rpc_dispatch_table[TT_RPC_LAST] = {
171 0, /* 0 - TT_RPC_NULLPROC */
172 _tt_rpc_dispatch, /* 1 - TT_RPC_DISPATCH */
173 _tt_rpc_update_msg, /* 2 - TT_RPC_UPDATE_MSG */
174 _tt_rpc_join_file, /* 3 - TT_RPC_JOIN_FILE */
175 _tt_rpc_quit_file, /* 4 - TT_RPC_QUIT_FILE */
176 _tt_rpc_join_session, /* 5 - TT_RPC_JOIN_SESSION */
177 _tt_rpc_quit_session, /* 6 - TT_RPC_QUIT_SESSION */
178 _tt_rpc_next_message, /* 7 - TT_RPC_NEXT_MESSAGE */
179 _tt_rpc_add_pattern, /* 8 - TT_RPC_ADD_PATTERN */
180 _tt_rpc_del_pattern, /* 9 - TT_RPC_DEL_PATTERN */
181 _tt_rpc_declare_ptype, /* 10 - TT_RPC_DECLARE_PTYPE */
182 _tt_rpc_set_fd_channel, /* 11 - TT_RPC_SET_FD_CHANNEL */
183 _tt_rpc_set_prop, /* 12 - TT_RPC_SET_PROP */
184 _tt_rpc_add_prop, /* 13 - TT_RPC_ADD_PROP */
185 _tt_rpc_get_prop, /* 14 - TT_RPC_GET_PROP */
186 _tt_rpc_prop_count, /* 15 - TT_RPC_PROP_COUNT */
187 _tt_rpc_prop_name, /* 16 - TT_RPC_PROP_NAME */
188 _tt_rpc_prop_names_count, /* 17 - TT_RPC_PROP_NAMES_COUNT */
189 _tt_rpc_alloc_procid_key, /* 18 - TT_RPC_ALLOC_PROCID_KEY */
190 _tt_rpc_close_procid, /* 19 - TT_RPC_CLOSE_PROCID */
191 _tt_rpc_otype_deriveds_count, /* 20 - TT_RPC_OTYPE_DERIVEDS_COUNT */
192 _tt_rpc_otype_derived, /* 21 - TT_RPC_OTYPE_DERIVED */
193 _tt_rpc_otype_base, /* 22 - TT_RPC_OTYPE_BASE */
194 _tt_rpc_otype_is_derived, /* 23 - TT_RPC_OTYPE_IS_DERIVED */
195 _tt_rpc_otype_osig_count, /* 24 - TT_RPC_OTYPE_OSIG_COUNT */
196 _tt_rpc_otype_hsig_count, /* 25 - TT_RPC_OTYPE_HSIG_COUNT */
197 _tt_rpc_otype_osig_op, /* 26 - TT_RPC_OTYPE_OSIG_OP */
198 _tt_rpc_otype_hsig_op, /* 27 - TT_RPC_OTYPE_HSIG_OP */
199 _tt_rpc_otype_osig_args_count, /* 28 - TT_RPC_OTYPE_OSIG_ARGS_COUNT */
200 _tt_rpc_otype_hsig_args_count, /* 29 - TT_RPC_OTYPE_HSIG_ARGS_COUNT */
201 _tt_rpc_otype_osig_arg_mode, /* 30 - TT_RPC_OTYPE_OSIG_ARG_MODE */
202 _tt_rpc_otype_hsig_arg_mode, /* 31 - TT_RPC_OTYPE_HSIG_ARG_MODE */
203 _tt_rpc_otype_osig_arg_type, /* 32 - TT_RPC_OTYPE_OSIG_ARG_TYPE */
204 _tt_rpc_otype_hsig_arg_type, /* 33 - TT_RPC_OTYPE_HSIG_ARG_TYPE */
205 _tt_rpc_hdispatch, /* 34 - TT_RPC_HDISPATCH */
206 _tt_rpc_hupdate_msg, /* 35 - TT_RPC_HUPDATE_MSG */
207 _tt_rpc_dispatch_2, /* 36 - TT_RPC_DISPATCH_2 */
208 _tt_rpc_update_msg_2, /* 37 - TT_RPC_UPDATE_MSG_2 */
209 _tt_rpc_msgread_2, /* 38 - TT_RPC_MSGREAD_2 */
210 _tt_rpc_dispatch_on_exit, /* 39 - TT_RPC_DISPATCH_ON_EXIT */
211 _tt_rpc_undeclare_ptype, /* 40 - TT_RPC_UNDECLARE_PTYPE */
212 _tt_rpc_exists_ptype, /* 41 - TT_RPC_EXISTS_PTYPE */
213 _tt_rpc_unblock_ptype, /* 42 - TT_RPC_UNBLOCK_PTYPE */
214 _tt_rpc_join_context, /* 43 - TT_RPC_JOIN_CONTEXT */
215 _tt_rpc_quit_context, /* 44 - TT_RPC_QUIT_CONTEXT */
216 _tt_rpc_dispatch_with_context, /* 45 - TT_RPC_DISPATCH_WITH_CONTEXT */
217 _tt_rpc_dispatch_2_with_context,/* 46 - TT_RPC_DISPATCH_2_WITH_CONTEXT */
218 _tt_rpc_add_pattern_with_context,/* 47 - TT_RPC_ADD_PATTERN_WITH_CONTEXT */
219 _tt_rpc_load_types /* 48 - TT_RPC_LOAD_TYPES */
224 * Dispatch function invoked whenever an RPC request comes in.
227 _tt_service_rpc(svc_req *rqstp, SVCXPRT *transp)
229 _Tt_auth_level session_auth;
230 #if defined(OPT_SECURE_RPC)
231 authdes_cred *des_cred;
234 // Increment the counter for the number of RPC calls
235 // handled during the life of this process.
236 _tt_global->event_counter++;
239 // authenticate request
241 session_auth = _tt_s_mp->initial_s_session->auth_level();
242 switch (rqstp->rq_cred.oa_flavor) {
245 if (session_auth == _TT_AUTH_DES ||
246 session_auth == _TT_AUTH_ICEAUTH) {
247 svcerr_auth(transp, AUTH_TOOWEAK);
250 else if (session_auth == _TT_AUTH_UNIX) {
251 if (_tt_s_mp->unix_cred_chk_flag) {
253 // "authunix_parms" is now deprecated in
254 // favor of "authsys_parms", but
255 // "authsys_parms" does not exist on
256 // all platforms yet.
258 authunix_parms* sys_cred =
259 (authunix_parms *) rqstp->rq_clntcred;
260 if (sys_cred->aup_uid != geteuid()) {
261 svcerr_auth(transp, AUTH_BADCRED);
265 // else, we are not doing auth checking
269 #if defined(OPT_SECURE_RPC)
271 if (session_auth != _TT_AUTH_DES) {
272 svcerr_auth(transp, AUTH_TOOWEAK);
275 des_cred = (authdes_cred *)rqstp->rq_clntcred;
276 #if !defined(OPT_BUG_SUNOS_5)
277 if (! authdes_getucred(des_cred,
282 svcerr_auth(transp, AUTH_BADCRED);
285 Hack_getucred hack_getucred_p;
287 hack_getucred_p = (Hack_getucred)authdes_getucred;
288 if (! (*hack_getucred_p)(des_cred,
293 svcerr_auth(transp, AUTH_BADCRED);
295 #endif /* OPT_BUG_SUNOS_5 */
297 // Now that we have the credentials, make sure they
298 // are the right ones
300 if (req_auth_uid == geteuid() &&
301 req_auth_gid == getegid()) {
303 break; // else fall through to svcerr_weakauth
305 #endif /* OPT_SECURE_RPC */
307 if (session_auth == _TT_AUTH_ICEAUTH) {
308 _Tt_string clnt_cookie;
309 if (!_tt_svc_getargs(transp,
310 (xdrproc_t) tt_xdr_string,
311 (char *) &clnt_cookie)) {
312 svcerr_auth(transp, AUTH_BADCRED);
316 const _Tt_string &svr_cookie =
317 _tt_s_mp->initial_s_session->auth_cookie();
318 if (clnt_cookie != svr_cookie) {
319 svcerr_auth(transp, AUTH_BADCRED);
326 // dispatch request to appropiate dispatch function
330 // Set and reset xdr version on entry and exit. See tt_xdr_version.h
332 _Tt_xdr_version xvers((int)rqstp->rq_vers);
334 switch (rqstp->rq_proc) {
336 (void)svc_sendreply(transp, (xdrproc_t)xdr_void, 0);
338 case TT_RPC_VRFY_SESSION:
339 _tt_rpc_vrfy_session(transp);
342 if (rqstp->rq_proc >= 1 && rqstp->rq_proc < TT_RPC_LAST) {
343 (*_tt_rpc_dispatch_table[rqstp->rq_proc])(transp);
345 svcerr_noproc(transp);
352 * Called when a sender sends a message to the server.
353 * This original version of _tt_rpc_dispatch() is a synchronous RPC
354 * call, and it returns a _Tt_dispatch_reply_args, which contains
355 * dispatch status and file-scoped queuing info. The new version,
356 * _tt_rpc_dispatch_2(), is asynchronous and thus faster.
359 _tt_rpc_dispatch(SVCXPRT *transp)
361 _Tt_s_message_ptr msg;
362 _Tt_dispatch_reply_args args;
364 msg = new _Tt_s_message();
365 if (!_tt_svc_getargs(transp,
366 (xdrproc_t)tt_xdr_message,
368 svcerr_decode(transp);
373 _Tt_msg_trace trace( *msg, TTDR_MESSAGE_SEND );
375 // XXX Turn this off until we do TT_ERR_OVERFLOW right
377 //if (_tt_s_mp->active_messages > _tt_s_mp->max_active_messages)
380 args.status = TT_ERR_OVERFLOW;
382 // dispatch the message so that any information regarding
383 // scope, and queueing can be relayed back to the sender.
384 msg->dispatch( trace );
385 msg->qmsg_info(args.qmsg_info);
387 if (msg->scope() != TT_SESSION) {
388 // if no file-scope patterns exist for this file then
389 // return an error to allow the client to remove this
390 // session from the file's scope.
391 if (! _tt_s_mp->in_file_scope(msg->file())) {
392 args.status = TT_ERR_FILE;
395 if (!svc_sendreply(transp,
396 (xdrproc_t)tt_xdr_dispatch_reply_args,
401 if (args.status == TT_OK || args.status == TT_ERR_FILE) {
402 // now deliver the message
403 msg->deliver_to_observers_and_handlers( trace );
409 * Called when a sender sends a contextful message
413 _tt_rpc_dispatch_with_context(SVCXPRT *transp)
416 // In messages, xdr versioning for contexts isn't necessary,
417 // since a bitmask controls what fields of a _Tt_message get
418 // xdr'd. This separate RPC call exists only so that
419 // context-aware clients can tell whether a server understands
422 _tt_rpc_dispatch(transp);
427 * High-performance version of _tt_rpc_dispatch(). No information
428 * is relayed back to the calling client.
431 _tt_rpc_dispatch_2(SVCXPRT *transp)
433 _Tt_s_message_ptr msg;
435 msg = new _Tt_s_message();
436 if (!_tt_svc_getargs(transp,
437 (xdrproc_t)tt_xdr_message,
439 svcerr_decode(transp);
442 _Tt_msg_trace trace( *msg, TTDR_MESSAGE_SEND );
443 msg->dispatch( trace );
444 // XXX holtz 93/09/17 Should we really deliver() if dispatch() fails?
445 // Note: this applies to every dispatch() call in this file.
446 msg->deliver_to_observers_and_handlers( trace );
451 * Called when a sender sends a contextful session-scoped message
455 _tt_rpc_dispatch_2_with_context(SVCXPRT *transp)
458 // In messages, xdr versioning for contexts isn't necessary,
459 // since a bitmask controls what fields of a _Tt_message get
460 // xdr'd. This separate RPC call exists only so that
461 // context-aware clients can tell whether a server understands
464 _tt_rpc_dispatch_2(transp);
470 * Called when a handler or voter updates a message in any way (ie. state change)
473 _tt_update_msg(SVCXPRT *transp, int reply)
475 _Tt_s_procid_ptr proc;
478 if (!_tt_svc_getargs(transp,
479 (xdrproc_t)tt_xdr_update_args,
480 (char *)&(_tt_s_mp->update_args))) {
481 svcerr_decode(transp);
486 _Tt_message_ptr &msg = _tt_s_mp->update_args.message;
488 // We have to rummage around in the message to see which
489 // procid is talking to us.
491 if (! msg->handler().is_null()) {
493 // Assume the handler is the updater.
495 found = _tt_s_mp->find_proc(msg->handler(), proc, 0);
496 } else if (msg->message_class() == TT_OFFER) {
498 // Assume the last voter is the updater.
500 _Tt_procid_list_ptr proc_list;
501 switch (_tt_s_mp->update_args.newstate) {
503 proc_list = msg->rejecters();
506 proc_list = msg->accepters();
509 proc_list = msg->abstainers();
512 if ((! proc_list.is_null()) && (proc_list->count() > 0)) {
513 found = _tt_s_mp->find_proc(proc_list->bot(), proc, 0);
519 status = TT_ERR_PROCID;
522 if (reply && (! svc_sendreply(transp, (xdrproc_t)xdr_int,
523 (RPC_ARG_T)&status)))
528 if (status != TT_OK) {
531 if (msg->is_observer()) {
532 // Clears _handler when observer replies to START_MESSAGE
533 // XXX _handler is used to tell us which procid is talking
534 // to us, because nothing in the message tells us who
535 // is observing it. Ugly.
536 msg->clr_observer_procid();
538 proc->update_message(msg, _tt_s_mp->update_args.newstate);
543 * Called when a handler updates a message in any way (ie. state change)
546 _tt_rpc_update_msg(SVCXPRT *transp)
548 _tt_update_msg(transp, 1);
552 * Asynchronous, higher-performance version of _tt_rpc_update_msg()
555 _tt_rpc_update_msg_2(SVCXPRT *transp)
557 _tt_update_msg(transp, 0);
562 * Called when a process joins a file.
565 _tt_rpc_join_file(SVCXPRT *transp)
567 _Tt_file_join_args args;
568 _Tt_s_procid_ptr proc;
572 if (! _tt_svc_getargs(transp, (xdrproc_t)tt_xdr_file_join_args,
574 svcerr_decode(transp);
576 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
577 fptr = new _Tt_s_file(args.path);
578 status = fptr->s_join(proc);
580 status = TT_ERR_PROCID;
582 (void)svc_sendreply(transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status);
587 * Called when a process quits a file.
590 _tt_rpc_quit_file(SVCXPRT *transp)
592 _Tt_file_join_args args;
593 _Tt_s_procid_ptr proc;
597 if (! _tt_svc_getargs(transp, (xdrproc_t)tt_xdr_file_join_args,
599 svcerr_decode(transp);
602 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
603 fptr = new _Tt_s_file(args.path);
604 status = fptr->s_quit(proc);
606 status = TT_ERR_PROCID;
608 (void)svc_sendreply(transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status);
612 * Called when a procid joins a session.
615 _tt_rpc_join_session(SVCXPRT *transp)
617 _Tt_procid_ptr cproc;
618 _Tt_s_procid_ptr proc;
621 if (! _tt_svc_getargs(transp,
622 (xdrproc_t)tt_xdr_procid,
624 svcerr_decode(transp);
627 if (_tt_s_mp->find_proc(cproc, proc, 1)) {
628 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
629 if (cproc->start_token().len() != 0) {
630 sp->set_start_token(cproc->start_token());
632 status = _tt_s_mp->initial_s_session->s_join(proc);
634 status = TT_ERR_PROCID;
637 if (svc_sendreply(transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status) == 0) {
644 * Called when a procid quits a session.
647 _tt_rpc_quit_session(SVCXPRT *transp)
649 _Tt_procid_ptr cproc;
650 _Tt_s_procid_ptr proc;
653 if (! _tt_svc_getargs(transp,
654 (xdrproc_t)tt_xdr_procid,
656 svcerr_decode(transp);
659 if (_tt_s_mp->find_proc(cproc, proc, 1)) {
660 status = _tt_s_mp->initial_s_session->s_quit(proc);
662 status = TT_ERR_PROCID;
665 if (svc_sendreply(transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status) == 0) {
671 * Called when a procid wants to join a context.
674 _tt_rpc_join_context(SVCXPRT *transp)
676 _Tt_context_join_args args;
677 _Tt_s_procid_ptr proc;
680 if (! _tt_svc_getargs( transp, (xdrproc_t)tt_xdr_context_join_args,
683 svcerr_decode(transp);
685 if (_tt_s_mp->find_proc( args.procid, proc, 1 )) {
686 status = ((_Tt_s_msg_context &)*args.context).s_join( proc );
688 status = TT_ERR_PROCID;
690 svc_sendreply( transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status );
694 * Called when a procid wants to quit a context.
697 _tt_rpc_quit_context(SVCXPRT *transp)
699 _Tt_context_join_args args;
700 _Tt_s_procid_ptr proc;
703 if (! _tt_svc_getargs( transp, (xdrproc_t)tt_xdr_context_join_args,
706 svcerr_decode(transp);
708 if (_tt_s_mp->find_proc( args.procid, proc, 1 )) {
709 status = ((_Tt_s_msg_context &)*args.context).s_quit( proc );
711 status = TT_ERR_PROCID;
713 svc_sendreply( transp, (xdrproc_t)xdr_int, (RPC_ARG_T)&status );
718 * Called when a procid wants to retrieve the next undelivered message
722 _tt_rpc_next_message(SVCXPRT *transp)
724 _Tt_procid_ptr cproc;
725 _Tt_next_message_args args;
726 _Tt_s_procid_ptr proc;
728 if (! _tt_svc_getargs(transp,
729 (xdrproc_t)tt_xdr_procid,
731 svcerr_decode(transp);
734 // default is to tell client to clear fd, that way in case of
735 // any errors, at least the client won't loop.
736 args.clear_signal = 1;
737 args.msgs = (_Tt_message_list *)0;
738 if (_tt_s_mp->find_proc(cproc, proc, 0)) {
739 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
740 sp->next_message(args);
743 if (svc_sendreply(transp,
744 (xdrproc_t)tt_xdr_next_message_args,
745 (RPC_ARG_T)&args) == 0) {
752 * Called when a procid wants to register a new pattern.
755 _tt_rpc_add_pattern(SVCXPRT *transp)
757 _Tt_s_procid_ptr proc;
758 _Tt_s_add_pattern_args args;
761 if (! _tt_svc_getargs(transp,
762 (xdrproc_t)tt_s_xdr_add_pattern_args,
764 svcerr_decode(transp);
768 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
769 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
770 status = sp->add_pattern(args.pattern);
772 status = TT_ERR_PROCID;
775 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
782 * Called when a procid wants to register a new context-ful pattern.
785 _tt_rpc_add_pattern_with_context(SVCXPRT *transp)
788 // Contexts are only xdr'd in _Tt_patterns in xdr version 3 or
789 // later. The rpc protocol version number represents a floor
790 // for the xdr version number. Even though this rpc call was
791 // introduced into protocol version 2, it can be assumed that
792 // the caller is using at least xdr version 3.
794 // _Tt_xdr_version xvers( max(_tt_global->xdr_version(),
795 // TT_CONTEXTS_XDR_VERSION) );
796 if(_tt_global->xdr_version() > TT_CONTEXTS_XDR_VERSION) {
797 _Tt_xdr_version xvers(_tt_global->xdr_version() );
799 _Tt_xdr_version xvers(TT_CONTEXTS_XDR_VERSION);
802 _tt_rpc_add_pattern(transp);
807 * Called when a procid wants to unregister a pattern with the server.
810 _tt_rpc_del_pattern(SVCXPRT *transp)
812 _Tt_s_procid_ptr proc;
813 _Tt_s_del_pattern_args args;
816 if (! _tt_svc_getargs(transp,
817 (xdrproc_t)tt_s_xdr_del_pattern_args,
819 svcerr_decode(transp);
823 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
824 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
825 status = sp->del_pattern(args.pattern_id);
827 status = TT_ERR_PROCID;
830 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
838 * Called by a procid to declare a ptype.
841 _tt_rpc_declare_ptype(SVCXPRT *transp)
843 _Tt_declare_ptype_args args;
844 _Tt_s_procid_ptr proc;
847 if (! _tt_svc_getargs(transp,
848 (xdrproc_t)tt_xdr_declare_ptype_args,
850 svcerr_decode(transp);
854 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
855 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
856 status = sp->declare_ptype(args.ptid);
858 status = TT_ERR_PROCID;
861 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
867 * Called by a procid to undeclare a ptype.
870 _tt_rpc_undeclare_ptype(SVCXPRT *transp)
872 _Tt_declare_ptype_args args;
873 _Tt_s_procid_ptr proc;
876 if (! _tt_svc_getargs(transp,
877 (xdrproc_t)tt_xdr_declare_ptype_args,
879 svcerr_decode(transp);
883 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
884 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
885 status = sp->undeclare_ptype(args.ptid);
887 status = TT_ERR_PROCID;
890 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
896 * Called by a procid to test existence of a ptype.
899 _tt_rpc_exists_ptype(SVCXPRT *transp)
901 _Tt_declare_ptype_args args;
902 _Tt_s_procid_ptr proc;
905 if (! _tt_svc_getargs(transp,
906 (xdrproc_t)tt_xdr_declare_ptype_args,
908 svcerr_decode(transp);
912 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
913 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
914 status = sp->exists_ptype(args.ptid);
916 status = TT_ERR_PROCID;
919 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
926 * Called by a procid to unblock queued messages for its ptype.
929 _tt_rpc_unblock_ptype(SVCXPRT *transp)
931 _Tt_declare_ptype_args args;
932 _Tt_s_procid_ptr proc;
935 if (! _tt_svc_getargs(transp,
936 (xdrproc_t)tt_xdr_declare_ptype_args,
938 svcerr_decode(transp);
942 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
943 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
944 status = sp->unblock_ptype(args.ptid);
946 status = TT_ERR_PROCID;
949 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
955 * Called by a procid to load new types into its associated ttsession.
958 _tt_rpc_load_types(SVCXPRT *transp)
960 _Tt_load_types_args args;
964 if (! _tt_svc_getargs(transp,
965 (xdrproc_t)tt_xdr_load_types_args,
967 svcerr_decode(transp);
972 (char *)args.xdrtypes,
973 (u_int)args.xdrtypes.len(),
977 status = _Tt_typedb::merge_from(&xdrs,_tt_s_mp->tdb, junk);
980 _tt_s_mp->install_ptable(_tt_s_mp->tdb->ptable);
981 _tt_s_mp->install_otable(_tt_s_mp->tdb->otable);
984 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
992 * Called by a procid to notify the server of its fd signalling channel.
995 _tt_rpc_set_fd_channel(SVCXPRT *transp)
998 _Tt_s_procid_ptr proc;
1001 if (! _tt_svc_getargs(transp,
1002 (xdrproc_t)tt_xdr_fd_args,
1003 (char *)&fd_args)) {
1004 svcerr_decode(transp);
1008 if (_tt_s_mp->find_proc(fd_args.procid, proc, 1)) {
1011 status = TT_ERR_PROCID;
1015 // Note: it's important to reply immediately here because
1016 // setting up the channel involves connecting to the socket
1017 // on the client side so if we attempted to reply after
1018 // the operation then we would get deadlock.
1020 if (svc_sendreply(transp,
1022 (RPC_ARG_T)&status) == 0) {
1026 if (status == TT_OK) {
1027 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
1028 sp->set_start_token(fd_args.start_token);
1029 sp->set_fd_channel(fd_args.fd);
1035 * Set the value of a session property
1038 _tt_rpc_set_prop(SVCXPRT *transp)
1043 if (! _tt_svc_getargs(transp,
1044 (xdrproc_t)tt_xdr_prop_args,
1046 svcerr_decode(transp);
1050 status = _tt_s_mp->initial_s_session->s_setprop(args.prop, args.value);
1052 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
1058 * Add a value to a session property
1061 _tt_rpc_add_prop(SVCXPRT *transp)
1066 if (! _tt_svc_getargs(transp,
1067 (xdrproc_t)tt_xdr_prop_args,
1069 svcerr_decode(transp);
1073 status = _tt_s_mp->initial_s_session->s_addprop(args.prop, args.value);
1074 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
1080 * Get a value from a session property
1083 _tt_rpc_get_prop(SVCXPRT *transp)
1088 _Tt_rpc_result result;
1090 if (! _tt_svc_getargs(transp,
1091 (xdrproc_t)tt_xdr_prop_args,
1093 svcerr_decode(transp);
1098 if ((status = _tt_s_mp->initial_s_session->s_getprop(args.prop, args.num, value))
1100 result.status = status;
1101 result.str_val = "";
1104 result.status = TT_OK;
1105 result.str_val = value;
1108 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1109 (RPC_ARG_T)&result) == 0) {
1115 * Return the number of values for a session property
1118 _tt_rpc_prop_count(SVCXPRT *transp)
1122 _Tt_rpc_result result;
1124 if (! _tt_svc_getargs(transp,
1125 (xdrproc_t)tt_xdr_prop_args,
1127 svcerr_decode(transp);
1132 result.status = _tt_s_mp->initial_s_session->s_propcount(args.prop, cnt);
1133 result.str_val = "";
1134 if (result.status == TT_OK) {
1135 result.int_val = cnt;
1140 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1141 (RPC_ARG_T)&result) == 0) {
1147 * Return a session property name
1150 _tt_rpc_prop_name(SVCXPRT *transp)
1155 _Tt_rpc_result result;
1157 if (! _tt_svc_getargs(transp,
1158 (xdrproc_t)tt_xdr_prop_args,
1160 svcerr_decode(transp);
1164 if ((status = _tt_s_mp->initial_s_session->s_propname(args.num, prop))
1166 result.status = status;
1167 result.str_val = "";
1170 result.status = TT_OK;
1171 result.str_val = prop;
1175 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1176 (RPC_ARG_T)&result) == 0) {
1182 * Return the number of session properties
1185 _tt_rpc_prop_names_count(SVCXPRT *transp)
1189 _Tt_rpc_result result;
1191 if (! _tt_svc_getargs(transp,
1192 (xdrproc_t)tt_xdr_prop_args,
1194 svcerr_decode(transp);
1198 result.status = _tt_s_mp->initial_s_session->s_propnames_count(cnt);
1199 result.str_val = "";
1200 if (result.status == TT_OK) {
1201 result.int_val = cnt;
1206 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1207 (RPC_ARG_T)&result) == 0) {
1214 _tt_rpc_alloc_procid_key(SVCXPRT *transp)
1218 if (! _tt_svc_getargs(transp,(xdrproc_t)xdr_void,0)) {
1219 svcerr_decode(transp);
1223 result = _tt_s_mp->alloc_procid_key();
1225 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_string,
1226 (RPC_ARG_T)&result) == 0) {
1232 _tt_rpc_close_procid(SVCXPRT *transp)
1235 _Tt_s_procid_ptr rp;
1238 if (! _tt_svc_getargs(transp,
1239 (xdrproc_t)tt_xdr_procid,
1241 svcerr_decode(transp);
1243 if (_tt_s_mp->find_proc(p, rp, 0)) {
1244 status = _tt_s_mp->s_remove_procid(*rp);
1246 status = TT_ERR_PROCID;
1248 (void)svc_sendreply(transp,(xdrproc_t)xdr_int, (RPC_ARG_T)&status);
1252 _tt_rpc_vrfy_session(SVCXPRT *transp)
1256 if (! _tt_svc_getargs(transp, (xdrproc_t)xdr_void, 0)) {
1257 svcerr_decode(transp);
1260 if (_tt_global->xdr_version() == 1) {
1261 id = _tt_s_mp->initial_s_session->id();
1263 id = _tt_s_mp->initial_s_session->process_tree_id();
1265 if (!svc_sendreply(transp,
1266 (xdrproc_t)tt_xdr_string,
1268 svcerr_decode(transp);
1272 * Return the number of otypes derived from a base otype
1275 _tt_rpc_otype_deriveds_count(SVCXPRT *transp)
1277 _Tt_otype_args args;
1278 _Tt_rpc_result result;
1279 _Tt_otype_ptr base_otype;
1281 if (! _tt_svc_getargs(transp,
1282 (xdrproc_t)tt_xdr_otype_args,
1284 svcerr_decode(transp);
1288 result.str_val = "";
1289 base_otype = _tt_s_mp->otable->lookup(args.base_otid);
1290 if (base_otype.is_null()) {
1291 result.status = TT_ERR_OTYPE;
1293 result.int_val = base_otype->children()->count();
1294 result.status = TT_OK;
1297 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1298 (RPC_ARG_T)&result) == 0) {
1304 * Return the n'th otype derived from a base otype
1307 _tt_rpc_otype_derived(SVCXPRT *transp)
1309 _Tt_otype_args args;
1310 _Tt_rpc_result result;
1311 _Tt_string_list_ptr children;
1312 _Tt_otype_ptr base_otype;
1314 if (! _tt_svc_getargs(transp,
1315 (xdrproc_t)tt_xdr_otype_args,
1317 svcerr_decode(transp);
1321 result.str_val = "";
1322 base_otype = _tt_s_mp->otable->lookup(args.base_otid);
1323 if (base_otype.is_null()) {
1324 result.status = TT_ERR_OTYPE;
1326 children = base_otype->children();
1327 if (args.num<0 || children->count()<args.num) {
1328 result.status = TT_ERR_NUM;
1329 result.str_val = "";
1330 } else if (children->count()==args.num) {
1331 result.status = TT_OK;
1332 result.str_val = (char *)0;
1334 result.status = TT_OK;
1335 result.str_val = (*children)[args.num];
1338 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1339 (RPC_ARG_T)&result) == 0) {
1345 * Return the otype that is the base of a derived otype
1348 _tt_rpc_otype_base(SVCXPRT *transp)
1350 _Tt_otype_args args;
1351 _Tt_rpc_result result;
1352 _Tt_string_list_ptr parents;
1353 _Tt_otype_ptr derived_otype;
1355 if (! _tt_svc_getargs(transp,
1356 (xdrproc_t)tt_xdr_otype_args,
1358 svcerr_decode(transp);
1362 derived_otype = _tt_s_mp->otable->lookup(args.derived_otid);
1363 if (derived_otype.is_null()) {
1364 result.str_val = (char *)0;
1365 result.status = TT_ERR_OTYPE;
1367 parents = derived_otype->parents();
1368 if (parents.is_null() || parents->is_empty()) {
1369 result.status = TT_OK;
1370 result.str_val = (char *)0;
1372 result.status = TT_OK;
1373 result.str_val = parents->top();
1377 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1378 (RPC_ARG_T)&result) == 0) {
1384 * Return 1 iff the derived otype derives directly or indirectly from the
1388 _tt_rpc_otype_is_derived(SVCXPRT *transp)
1390 _Tt_otype_args args;
1391 _Tt_rpc_result result;
1392 _Tt_string_list_ptr parents;
1393 _Tt_otype_ptr derived_otype;
1395 if (! _tt_svc_getargs(transp,
1396 (xdrproc_t)tt_xdr_otype_args,
1398 svcerr_decode(transp);
1402 result.status = TT_OK;
1403 result.str_val = "";
1404 if (args.derived_otid==args.base_otid) {
1407 derived_otype = _tt_s_mp->otable->lookup(args.derived_otid);
1408 if (derived_otype.is_null()) {
1409 result.status = TT_ERR_OTYPE;
1411 parents = derived_otype->parents();
1413 _Tt_otype_ptr parent;
1414 while (!parents->is_empty()) {
1415 parent = _tt_s_mp->otable->
1416 lookup(parents->top());
1417 if (parent.is_null()) {
1419 } else if (parent->otid()==args.base_otid) {
1423 parents = parent->parents();
1428 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1429 (RPC_ARG_T)&result) == 0) {
1435 * Return the number of observer signatures for the specified otype
1438 _tt_rpc_otype_osig_count(SVCXPRT *transp)
1440 _Tt_otype_args args;
1441 _Tt_rpc_result result;
1442 _Tt_otype_ptr otype;
1444 if (! _tt_svc_getargs(transp,
1445 (xdrproc_t)tt_xdr_otype_args,
1447 svcerr_decode(transp);
1451 result.status = TT_OK;
1452 result.str_val = "";
1454 otype = _tt_s_mp->otable->lookup(args.base_otid);
1455 if (otype.is_null()) {
1456 result.status = TT_ERR_OTYPE;
1458 _Tt_signature_list_ptr sigs = otype->osigs();
1459 result.int_val = sigs->count();
1461 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1462 (RPC_ARG_T)&result) == 0) {
1468 * Return the number of handler signatures for the specified otype
1471 _tt_rpc_otype_hsig_count(SVCXPRT *transp)
1473 _Tt_otype_args args;
1474 _Tt_rpc_result result;
1475 _Tt_otype_ptr otype;
1477 if (! _tt_svc_getargs(transp,
1478 (xdrproc_t)tt_xdr_otype_args,
1480 svcerr_decode(transp);
1484 result.status = TT_OK;
1485 result.str_val = "";
1487 otype = _tt_s_mp->otable->lookup(args.base_otid);
1488 if (otype.is_null()) {
1489 result.status = TT_ERR_OTYPE;
1491 _Tt_signature_list_ptr sigs = otype->hsigs();
1492 result.int_val = sigs->count();
1494 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1495 (RPC_ARG_T)&result) == 0) {
1501 * Return the op for an observer signature of an otype
1504 _tt_rpc_otype_osig_op(SVCXPRT *transp)
1506 _Tt_otype_args args;
1507 _Tt_rpc_result result;
1508 _Tt_otype_ptr otype;
1510 if (! _tt_svc_getargs(transp,
1511 (xdrproc_t)tt_xdr_otype_args,
1513 svcerr_decode(transp);
1517 result.status = TT_OK;
1518 result.str_val = "";
1520 otype = _tt_s_mp->otable->lookup(args.base_otid);
1521 if (otype.is_null()) {
1522 result.status = TT_ERR_OTYPE;
1524 _Tt_signature_list_ptr sigs = otype->osigs();
1525 if (args.num < 0 || args.num >= sigs->count()) {
1526 result.status = TT_ERR_NUM;
1528 _Tt_signature_ptr sig = (*sigs)[args.num];
1529 result.str_val = sig->op();
1532 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1533 (RPC_ARG_T)&result) == 0) {
1539 * Return the op for a handler signature of an otype
1542 _tt_rpc_otype_hsig_op(SVCXPRT *transp)
1544 _Tt_otype_args args;
1545 _Tt_rpc_result result;
1546 _Tt_otype_ptr otype;
1548 if (! _tt_svc_getargs(transp,
1549 (xdrproc_t)tt_xdr_otype_args,
1551 svcerr_decode(transp);
1555 result.status = TT_OK;
1556 result.str_val = "";
1558 otype = _tt_s_mp->otable->lookup(args.base_otid);
1559 if (otype.is_null()) {
1560 result.status = TT_ERR_OTYPE;
1562 _Tt_signature_list_ptr sigs = otype->hsigs();
1563 if (args.num < 0 || args.num >= sigs->count()) {
1564 result.status = TT_ERR_NUM;
1566 _Tt_signature_ptr sig = (*sigs)[args.num];
1567 result.str_val = sig->op();
1570 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1571 (RPC_ARG_T)&result) == 0) {
1577 * Return the number of arguments of an observer signature of an otype
1580 _tt_rpc_otype_osig_args_count(SVCXPRT *transp)
1582 _Tt_otype_args args;
1583 _Tt_rpc_result result;
1584 _Tt_otype_ptr otype;
1586 if (! _tt_svc_getargs(transp,
1587 (xdrproc_t)tt_xdr_otype_args,
1589 svcerr_decode(transp);
1593 result.status = TT_OK;
1594 result.str_val = "";
1596 otype = _tt_s_mp->otable->lookup(args.base_otid);
1597 if (otype.is_null()) {
1598 result.status = TT_ERR_OTYPE;
1600 _Tt_signature_list_ptr sigs = otype->osigs();
1601 if (args.num < 0 || args.num >= sigs->count()) {
1602 result.status = TT_ERR_NUM;
1604 _Tt_signature_ptr sig = (*sigs)[args.num];
1605 _Tt_arg_list_ptr sargs = sig->args();
1606 result.int_val = sargs->count();
1609 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1610 (RPC_ARG_T)&result) == 0) {
1616 * Return the number of arguments of a handler signature of an otype
1619 _tt_rpc_otype_hsig_args_count(SVCXPRT *transp)
1621 _Tt_otype_args args;
1622 _Tt_rpc_result result;
1623 _Tt_otype_ptr otype;
1625 if (! _tt_svc_getargs(transp,
1626 (xdrproc_t)tt_xdr_otype_args,
1628 svcerr_decode(transp);
1632 result.status = TT_OK;
1633 result.str_val = "";
1635 otype = _tt_s_mp->otable->lookup(args.base_otid);
1636 if (otype.is_null()) {
1637 result.status = TT_ERR_OTYPE;
1639 _Tt_signature_list_ptr sigs = otype->hsigs();
1640 if (args.num < 0 || args.num >= sigs->count()) {
1641 result.status = TT_ERR_NUM;
1643 _Tt_signature_ptr sig = (*sigs)[args.num];
1644 _Tt_arg_list_ptr sargs = sig->args();
1645 result.int_val = sargs->count();
1648 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1649 (RPC_ARG_T)&result) == 0) {
1655 * Return the mode of the specified arg of an observer signature of an otype
1658 _tt_rpc_otype_osig_arg_mode(SVCXPRT *transp)
1660 _Tt_otype_args args;
1661 _Tt_rpc_result result;
1662 _Tt_otype_ptr otype;
1664 if (! _tt_svc_getargs(transp,
1665 (xdrproc_t)tt_xdr_otype_args,
1667 svcerr_decode(transp);
1671 result.status = TT_OK;
1672 result.str_val = "";
1674 otype = _tt_s_mp->otable->lookup(args.base_otid);
1675 if (otype.is_null()) {
1676 result.status = TT_ERR_OTYPE;
1678 _Tt_signature_list_ptr sigs = otype->osigs();
1679 if (args.num < 0 || args.num >= sigs->count()) {
1680 result.status = TT_ERR_NUM;
1682 _Tt_signature_ptr sig = (*sigs)[args.num];
1683 _Tt_arg_list_ptr sargs = sig->args();
1684 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1685 result.status = TT_ERR_NUM;
1687 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1688 result.int_val = (int)sarg->mode();
1692 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1693 (RPC_ARG_T)&result) == 0) {
1699 * Return the mode of the specified arg of a handler signature of an otype
1702 _tt_rpc_otype_hsig_arg_mode(SVCXPRT *transp)
1704 _Tt_otype_args args;
1705 _Tt_rpc_result result;
1706 _Tt_otype_ptr otype;
1708 if (! _tt_svc_getargs(transp,
1709 (xdrproc_t)tt_xdr_otype_args,
1711 svcerr_decode(transp);
1715 result.status = TT_OK;
1716 result.str_val = "";
1718 otype = _tt_s_mp->otable->lookup(args.base_otid);
1719 if (otype.is_null()) {
1720 result.status = TT_ERR_OTYPE;
1722 _Tt_signature_list_ptr sigs = otype->hsigs();
1723 if (args.num < 0 || args.num >= sigs->count()) {
1724 result.status = TT_ERR_NUM;
1726 _Tt_signature_ptr sig = (*sigs)[args.num];
1727 _Tt_arg_list_ptr sargs = sig->args();
1728 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1729 result.status = TT_ERR_NUM;
1731 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1732 result.int_val = (int)sarg->mode();
1736 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1737 (RPC_ARG_T)&result) == 0) {
1743 * Return the type of the specified arg of an observer signature of an otype
1746 _tt_rpc_otype_osig_arg_type(SVCXPRT *transp)
1748 _Tt_otype_args args;
1749 _Tt_rpc_result result;
1750 _Tt_otype_ptr otype;
1752 if (! _tt_svc_getargs(transp,
1753 (xdrproc_t)tt_xdr_otype_args,
1755 svcerr_decode(transp);
1759 result.status = TT_OK;
1760 result.str_val = "";
1762 otype = _tt_s_mp->otable->lookup(args.base_otid);
1763 if (otype.is_null()) {
1764 result.status = TT_ERR_OTYPE;
1766 _Tt_signature_list_ptr sigs = otype->osigs();
1767 if (args.num < 0 || args.num >= sigs->count()) {
1768 result.status = TT_ERR_NUM;
1770 _Tt_signature_ptr sig = (*sigs)[args.num];
1771 _Tt_arg_list_ptr sargs = sig->args();
1772 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1773 result.status = TT_ERR_NUM;
1775 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1776 result.str_val = sarg->type();
1780 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1781 (RPC_ARG_T)&result) == 0) {
1787 * Return the type of the specified arg of a handler signature of an otype
1790 _tt_rpc_otype_hsig_arg_type(SVCXPRT *transp)
1792 _Tt_otype_args args;
1793 _Tt_rpc_result result;
1794 _Tt_otype_ptr otype;
1796 if (! _tt_svc_getargs(transp,
1797 (xdrproc_t)tt_xdr_otype_args,
1799 svcerr_decode(transp);
1803 result.status = TT_OK;
1804 result.str_val = "";
1806 otype = _tt_s_mp->otable->lookup(args.base_otid);
1807 if (otype.is_null()) {
1808 result.status = TT_ERR_OTYPE;
1810 _Tt_signature_list_ptr sigs = otype->hsigs();
1811 if (args.num < 0 || args.num >= sigs->count()) {
1812 result.status = TT_ERR_NUM;
1814 _Tt_signature_ptr sig = (*sigs)[args.num];
1815 _Tt_arg_list_ptr sargs = sig->args();
1816 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1817 result.status = TT_ERR_NUM;
1819 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1820 result.str_val = sarg->type();
1824 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1825 (RPC_ARG_T)&result) == 0) {
1831 // Horizontal (inter-ttsession) dispatch
1834 _tt_rpc_hdispatch(SVCXPRT *transp)
1836 _Tt_s_message_ptr msg;
1837 _Tt_qmsg_info_ptr qm = (_Tt_qmsg_info *)0;
1838 _Tt_dispatch_reply_args args;
1840 msg = new _Tt_s_message();
1841 if (!_tt_svc_getargs(transp,
1842 (xdrproc_t)tt_xdr_message,
1844 svcerr_decode(transp);
1847 _Tt_msg_trace trace( *msg, TTDR_HDISPATCH );
1848 (void)msg->dispatch( trace );
1849 (void)msg->deliver_to_observers_and_handlers( trace );
1853 // Horizontal (inter-ttsession) update
1856 _tt_rpc_hupdate_msg(SVCXPRT *transp)
1858 _Tt_s_procid_ptr sender;
1859 _Tt_s_update_args args;
1861 if (!_tt_svc_getargs(transp,
1862 (xdrproc_t)tt_s_xdr_update_args,
1865 svcerr_decode(transp);
1868 if (! _tt_s_mp->find_proc(args.message->sender(), sender, 0)) {
1872 if ( (args.newstate == TT_FAILED)
1873 && (args.message->status() == TT_ERR_NO_MATCH)
1874 && (args.message->handler().is_null()))
1877 // No remote session could find a handler.
1878 // Simulate a rejection, and redeliver the message.
1879 // _tried prevents re-offers, but any new handler
1880 // will get a crack at the request, which is nice.
1881 // _rsessions will be empty, so if we again find no
1882 // handler, we will perform disposition instead of
1883 // hdispatch()ing to remote sessions.
1885 args.message->set_state(TT_SENT);
1886 args.message->set_status((int)TT_OK);
1887 _Tt_msg_trace trace( *args.message, TTDR_HUPDATE );
1888 if (args.message->indoctrinate( trace ) == TT_OK) {
1889 args.message->change_state( 0, TT_REJECTED, trace );
1892 args.message->set_state(args.newstate);
1893 // Tracing occurs inside ::add_message()
1894 sender->add_message(args.message);
1900 _tt_rpc_msgread_2(SVCXPRT *transp)
1902 #ifdef OPT_ADDMSG_DIRECT
1904 _Tt_s_procid_ptr rp;
1906 if (! _tt_svc_getargs(transp,
1907 (xdrproc_t)tt_xdr_procid,
1909 svcerr_decode(transp);
1911 if (_tt_s_mp->find_proc(p, rp, 0)) {
1915 svcerr_noproc(transp);
1916 #endif // OPT_ADDMSG_DIRECT
1921 * Called when a sender sends a message to the server for delivery on exit.
1924 _tt_rpc_dispatch_on_exit(SVCXPRT *transp)
1926 _Tt_s_message_ptr msg;
1927 _Tt_s_procid_ptr proc;
1928 _Tt_dispatch_reply_args args;
1930 msg = new _Tt_s_message();
1931 if (!_tt_svc_getargs(transp,
1932 (xdrproc_t)tt_xdr_message,
1934 svcerr_decode(transp);
1938 args.status = TT_OK;
1940 if (_tt_s_mp->find_proc(msg->sender(),proc, 0)) {
1941 (void)proc->add_on_exit_message(msg);
1943 args.status = TT_ERR_PROCID;
1946 if (!svc_sendreply(transp,
1947 (xdrproc_t)tt_xdr_dispatch_reply_args,
1948 (RPC_ARG_T)&args)) {