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>
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 _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) );
797 _tt_rpc_add_pattern(transp);
802 * Called when a procid wants to unregister a pattern with the server.
805 _tt_rpc_del_pattern(SVCXPRT *transp)
807 _Tt_s_procid_ptr proc;
808 _Tt_s_del_pattern_args args;
811 if (! _tt_svc_getargs(transp,
812 (xdrproc_t)tt_s_xdr_del_pattern_args,
814 svcerr_decode(transp);
818 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
819 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
820 status = sp->del_pattern(args.pattern_id);
822 status = TT_ERR_PROCID;
825 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
833 * Called by a procid to declare a ptype.
836 _tt_rpc_declare_ptype(SVCXPRT *transp)
838 _Tt_declare_ptype_args args;
839 _Tt_s_procid_ptr proc;
842 if (! _tt_svc_getargs(transp,
843 (xdrproc_t)tt_xdr_declare_ptype_args,
845 svcerr_decode(transp);
849 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
850 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
851 status = sp->declare_ptype(args.ptid);
853 status = TT_ERR_PROCID;
856 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
862 * Called by a procid to undeclare a ptype.
865 _tt_rpc_undeclare_ptype(SVCXPRT *transp)
867 _Tt_declare_ptype_args args;
868 _Tt_s_procid_ptr proc;
871 if (! _tt_svc_getargs(transp,
872 (xdrproc_t)tt_xdr_declare_ptype_args,
874 svcerr_decode(transp);
878 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
879 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
880 status = sp->undeclare_ptype(args.ptid);
882 status = TT_ERR_PROCID;
885 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
891 * Called by a procid to test existence of a ptype.
894 _tt_rpc_exists_ptype(SVCXPRT *transp)
896 _Tt_declare_ptype_args args;
897 _Tt_s_procid_ptr proc;
900 if (! _tt_svc_getargs(transp,
901 (xdrproc_t)tt_xdr_declare_ptype_args,
903 svcerr_decode(transp);
907 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
908 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
909 status = sp->exists_ptype(args.ptid);
911 status = TT_ERR_PROCID;
914 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
921 * Called by a procid to unblock queued messages for its ptype.
924 _tt_rpc_unblock_ptype(SVCXPRT *transp)
926 _Tt_declare_ptype_args args;
927 _Tt_s_procid_ptr proc;
930 if (! _tt_svc_getargs(transp,
931 (xdrproc_t)tt_xdr_declare_ptype_args,
933 svcerr_decode(transp);
937 if (_tt_s_mp->find_proc(args.procid, proc, 1)) {
938 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
939 status = sp->unblock_ptype(args.ptid);
941 status = TT_ERR_PROCID;
944 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
950 * Called by a procid to load new types into its associated ttsession.
953 _tt_rpc_load_types(SVCXPRT *transp)
955 _Tt_load_types_args args;
959 if (! _tt_svc_getargs(transp,
960 (xdrproc_t)tt_xdr_load_types_args,
962 svcerr_decode(transp);
967 (char *)args.xdrtypes,
968 (u_int)args.xdrtypes.len(),
972 status = _Tt_typedb::merge_from(&xdrs,_tt_s_mp->tdb, junk);
975 _tt_s_mp->install_ptable(_tt_s_mp->tdb->ptable);
976 _tt_s_mp->install_otable(_tt_s_mp->tdb->otable);
979 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
987 * Called by a procid to notify the server of its fd signalling channel.
990 _tt_rpc_set_fd_channel(SVCXPRT *transp)
993 _Tt_s_procid_ptr proc;
996 if (! _tt_svc_getargs(transp,
997 (xdrproc_t)tt_xdr_fd_args,
999 svcerr_decode(transp);
1003 if (_tt_s_mp->find_proc(fd_args.procid, proc, 1)) {
1006 status = TT_ERR_PROCID;
1010 // Note: it's important to reply immediately here because
1011 // setting up the channel involves connecting to the socket
1012 // on the client side so if we attempted to reply after
1013 // the operation then we would get deadlock.
1015 if (svc_sendreply(transp,
1017 (RPC_ARG_T)&status) == 0) {
1021 if (status == TT_OK) {
1022 _Tt_s_procid *sp = (_Tt_s_procid *)proc.c_pointer();
1023 sp->set_start_token(fd_args.start_token);
1024 sp->set_fd_channel(fd_args.fd);
1030 * Set the value of a session property
1033 _tt_rpc_set_prop(SVCXPRT *transp)
1038 if (! _tt_svc_getargs(transp,
1039 (xdrproc_t)tt_xdr_prop_args,
1041 svcerr_decode(transp);
1045 status = _tt_s_mp->initial_s_session->s_setprop(args.prop, args.value);
1047 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
1053 * Add a value to a session property
1056 _tt_rpc_add_prop(SVCXPRT *transp)
1061 if (! _tt_svc_getargs(transp,
1062 (xdrproc_t)tt_xdr_prop_args,
1064 svcerr_decode(transp);
1068 status = _tt_s_mp->initial_s_session->s_addprop(args.prop, args.value);
1069 if (svc_sendreply(transp,(xdrproc_t)xdr_int,(RPC_ARG_T)&status) == 0) {
1075 * Get a value from a session property
1078 _tt_rpc_get_prop(SVCXPRT *transp)
1083 _Tt_rpc_result result;
1085 if (! _tt_svc_getargs(transp,
1086 (xdrproc_t)tt_xdr_prop_args,
1088 svcerr_decode(transp);
1093 if ((status = _tt_s_mp->initial_s_session->s_getprop(args.prop, args.num, value))
1095 result.status = status;
1096 result.str_val = "";
1099 result.status = TT_OK;
1100 result.str_val = value;
1103 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1104 (RPC_ARG_T)&result) == 0) {
1110 * Return the number of values for a session property
1113 _tt_rpc_prop_count(SVCXPRT *transp)
1117 _Tt_rpc_result result;
1119 if (! _tt_svc_getargs(transp,
1120 (xdrproc_t)tt_xdr_prop_args,
1122 svcerr_decode(transp);
1127 result.status = _tt_s_mp->initial_s_session->s_propcount(args.prop, cnt);
1128 result.str_val = "";
1129 if (result.status == TT_OK) {
1130 result.int_val = cnt;
1135 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1136 (RPC_ARG_T)&result) == 0) {
1142 * Return a session property name
1145 _tt_rpc_prop_name(SVCXPRT *transp)
1150 _Tt_rpc_result result;
1152 if (! _tt_svc_getargs(transp,
1153 (xdrproc_t)tt_xdr_prop_args,
1155 svcerr_decode(transp);
1159 if ((status = _tt_s_mp->initial_s_session->s_propname(args.num, prop))
1161 result.status = status;
1162 result.str_val = "";
1165 result.status = TT_OK;
1166 result.str_val = prop;
1170 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1171 (RPC_ARG_T)&result) == 0) {
1177 * Return the number of session properties
1180 _tt_rpc_prop_names_count(SVCXPRT *transp)
1184 _Tt_rpc_result result;
1186 if (! _tt_svc_getargs(transp,
1187 (xdrproc_t)tt_xdr_prop_args,
1189 svcerr_decode(transp);
1193 result.status = _tt_s_mp->initial_s_session->s_propnames_count(cnt);
1194 result.str_val = "";
1195 if (result.status == TT_OK) {
1196 result.int_val = cnt;
1201 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1202 (RPC_ARG_T)&result) == 0) {
1209 _tt_rpc_alloc_procid_key(SVCXPRT *transp)
1213 if (! _tt_svc_getargs(transp,(xdrproc_t)xdr_void,0)) {
1214 svcerr_decode(transp);
1218 result = _tt_s_mp->alloc_procid_key();
1220 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_string,
1221 (RPC_ARG_T)&result) == 0) {
1227 _tt_rpc_close_procid(SVCXPRT *transp)
1230 _Tt_s_procid_ptr rp;
1233 if (! _tt_svc_getargs(transp,
1234 (xdrproc_t)tt_xdr_procid,
1236 svcerr_decode(transp);
1238 if (_tt_s_mp->find_proc(p, rp, 0)) {
1239 status = _tt_s_mp->s_remove_procid(*rp);
1241 status = TT_ERR_PROCID;
1243 (void)svc_sendreply(transp,(xdrproc_t)xdr_int, (RPC_ARG_T)&status);
1247 _tt_rpc_vrfy_session(SVCXPRT *transp)
1251 if (! _tt_svc_getargs(transp, (xdrproc_t)xdr_void, 0)) {
1252 svcerr_decode(transp);
1255 if (_tt_global->xdr_version() == 1) {
1256 id = _tt_s_mp->initial_s_session->id();
1258 id = _tt_s_mp->initial_s_session->process_tree_id();
1260 if (!svc_sendreply(transp,
1261 (xdrproc_t)tt_xdr_string,
1263 svcerr_decode(transp);
1267 * Return the number of otypes derived from a base otype
1270 _tt_rpc_otype_deriveds_count(SVCXPRT *transp)
1272 _Tt_otype_args args;
1273 _Tt_rpc_result result;
1274 _Tt_otype_ptr base_otype;
1276 if (! _tt_svc_getargs(transp,
1277 (xdrproc_t)tt_xdr_otype_args,
1279 svcerr_decode(transp);
1283 result.str_val = "";
1284 base_otype = _tt_s_mp->otable->lookup(args.base_otid);
1285 if (base_otype.is_null()) {
1286 result.status = TT_ERR_OTYPE;
1288 result.int_val = base_otype->children()->count();
1289 result.status = TT_OK;
1292 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1293 (RPC_ARG_T)&result) == 0) {
1299 * Return the n'th otype derived from a base otype
1302 _tt_rpc_otype_derived(SVCXPRT *transp)
1304 _Tt_otype_args args;
1305 _Tt_rpc_result result;
1306 _Tt_string_list_ptr children;
1307 _Tt_otype_ptr base_otype;
1309 if (! _tt_svc_getargs(transp,
1310 (xdrproc_t)tt_xdr_otype_args,
1312 svcerr_decode(transp);
1316 result.str_val = "";
1317 base_otype = _tt_s_mp->otable->lookup(args.base_otid);
1318 if (base_otype.is_null()) {
1319 result.status = TT_ERR_OTYPE;
1321 children = base_otype->children();
1322 if (args.num<0 || children->count()<args.num) {
1323 result.status = TT_ERR_NUM;
1324 result.str_val = "";
1325 } else if (children->count()==args.num) {
1326 result.status = TT_OK;
1327 result.str_val = (char *)0;
1329 result.status = TT_OK;
1330 result.str_val = (*children)[args.num];
1333 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1334 (RPC_ARG_T)&result) == 0) {
1340 * Return the otype that is the base of a derived otype
1343 _tt_rpc_otype_base(SVCXPRT *transp)
1345 _Tt_otype_args args;
1346 _Tt_rpc_result result;
1347 _Tt_string_list_ptr parents;
1348 _Tt_otype_ptr derived_otype;
1350 if (! _tt_svc_getargs(transp,
1351 (xdrproc_t)tt_xdr_otype_args,
1353 svcerr_decode(transp);
1357 derived_otype = _tt_s_mp->otable->lookup(args.derived_otid);
1358 if (derived_otype.is_null()) {
1359 result.str_val = (char *)0;
1360 result.status = TT_ERR_OTYPE;
1362 parents = derived_otype->parents();
1363 if (parents.is_null() || parents->is_empty()) {
1364 result.status = TT_OK;
1365 result.str_val = (char *)0;
1367 result.status = TT_OK;
1368 result.str_val = parents->top();
1372 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1373 (RPC_ARG_T)&result) == 0) {
1379 * Return 1 iff the derived otype derives directly or indirectly from the
1383 _tt_rpc_otype_is_derived(SVCXPRT *transp)
1385 _Tt_otype_args args;
1386 _Tt_rpc_result result;
1387 _Tt_string_list_ptr parents;
1388 _Tt_otype_ptr derived_otype;
1390 if (! _tt_svc_getargs(transp,
1391 (xdrproc_t)tt_xdr_otype_args,
1393 svcerr_decode(transp);
1397 result.status = TT_OK;
1398 result.str_val = "";
1399 if (args.derived_otid==args.base_otid) {
1402 derived_otype = _tt_s_mp->otable->lookup(args.derived_otid);
1403 if (derived_otype.is_null()) {
1404 result.status = TT_ERR_OTYPE;
1406 parents = derived_otype->parents();
1408 _Tt_otype_ptr parent;
1409 while (!parents->is_empty()) {
1410 parent = _tt_s_mp->otable->
1411 lookup(parents->top());
1412 if (parent.is_null()) {
1414 } else if (parent->otid()==args.base_otid) {
1418 parents = parent->parents();
1423 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1424 (RPC_ARG_T)&result) == 0) {
1430 * Return the number of observer signatures for the specified otype
1433 _tt_rpc_otype_osig_count(SVCXPRT *transp)
1435 _Tt_otype_args args;
1436 _Tt_rpc_result result;
1437 _Tt_otype_ptr otype;
1439 if (! _tt_svc_getargs(transp,
1440 (xdrproc_t)tt_xdr_otype_args,
1442 svcerr_decode(transp);
1446 result.status = TT_OK;
1447 result.str_val = "";
1449 otype = _tt_s_mp->otable->lookup(args.base_otid);
1450 if (otype.is_null()) {
1451 result.status = TT_ERR_OTYPE;
1453 _Tt_signature_list_ptr sigs = otype->osigs();
1454 result.int_val = sigs->count();
1456 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1457 (RPC_ARG_T)&result) == 0) {
1463 * Return the number of handler signatures for the specified otype
1466 _tt_rpc_otype_hsig_count(SVCXPRT *transp)
1468 _Tt_otype_args args;
1469 _Tt_rpc_result result;
1470 _Tt_otype_ptr otype;
1472 if (! _tt_svc_getargs(transp,
1473 (xdrproc_t)tt_xdr_otype_args,
1475 svcerr_decode(transp);
1479 result.status = TT_OK;
1480 result.str_val = "";
1482 otype = _tt_s_mp->otable->lookup(args.base_otid);
1483 if (otype.is_null()) {
1484 result.status = TT_ERR_OTYPE;
1486 _Tt_signature_list_ptr sigs = otype->hsigs();
1487 result.int_val = sigs->count();
1489 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1490 (RPC_ARG_T)&result) == 0) {
1496 * Return the op for an observer signature of an otype
1499 _tt_rpc_otype_osig_op(SVCXPRT *transp)
1501 _Tt_otype_args args;
1502 _Tt_rpc_result result;
1503 _Tt_otype_ptr otype;
1505 if (! _tt_svc_getargs(transp,
1506 (xdrproc_t)tt_xdr_otype_args,
1508 svcerr_decode(transp);
1512 result.status = TT_OK;
1513 result.str_val = "";
1515 otype = _tt_s_mp->otable->lookup(args.base_otid);
1516 if (otype.is_null()) {
1517 result.status = TT_ERR_OTYPE;
1519 _Tt_signature_list_ptr sigs = otype->osigs();
1520 if (args.num < 0 || args.num >= sigs->count()) {
1521 result.status = TT_ERR_NUM;
1523 _Tt_signature_ptr sig = (*sigs)[args.num];
1524 result.str_val = sig->op();
1527 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1528 (RPC_ARG_T)&result) == 0) {
1534 * Return the op for a handler signature of an otype
1537 _tt_rpc_otype_hsig_op(SVCXPRT *transp)
1539 _Tt_otype_args args;
1540 _Tt_rpc_result result;
1541 _Tt_otype_ptr otype;
1543 if (! _tt_svc_getargs(transp,
1544 (xdrproc_t)tt_xdr_otype_args,
1546 svcerr_decode(transp);
1550 result.status = TT_OK;
1551 result.str_val = "";
1553 otype = _tt_s_mp->otable->lookup(args.base_otid);
1554 if (otype.is_null()) {
1555 result.status = TT_ERR_OTYPE;
1557 _Tt_signature_list_ptr sigs = otype->hsigs();
1558 if (args.num < 0 || args.num >= sigs->count()) {
1559 result.status = TT_ERR_NUM;
1561 _Tt_signature_ptr sig = (*sigs)[args.num];
1562 result.str_val = sig->op();
1565 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1566 (RPC_ARG_T)&result) == 0) {
1572 * Return the number of arguments of an observer signature of an otype
1575 _tt_rpc_otype_osig_args_count(SVCXPRT *transp)
1577 _Tt_otype_args args;
1578 _Tt_rpc_result result;
1579 _Tt_otype_ptr otype;
1581 if (! _tt_svc_getargs(transp,
1582 (xdrproc_t)tt_xdr_otype_args,
1584 svcerr_decode(transp);
1588 result.status = TT_OK;
1589 result.str_val = "";
1591 otype = _tt_s_mp->otable->lookup(args.base_otid);
1592 if (otype.is_null()) {
1593 result.status = TT_ERR_OTYPE;
1595 _Tt_signature_list_ptr sigs = otype->osigs();
1596 if (args.num < 0 || args.num >= sigs->count()) {
1597 result.status = TT_ERR_NUM;
1599 _Tt_signature_ptr sig = (*sigs)[args.num];
1600 _Tt_arg_list_ptr sargs = sig->args();
1601 result.int_val = sargs->count();
1604 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1605 (RPC_ARG_T)&result) == 0) {
1611 * Return the number of arguments of a handler signature of an otype
1614 _tt_rpc_otype_hsig_args_count(SVCXPRT *transp)
1616 _Tt_otype_args args;
1617 _Tt_rpc_result result;
1618 _Tt_otype_ptr otype;
1620 if (! _tt_svc_getargs(transp,
1621 (xdrproc_t)tt_xdr_otype_args,
1623 svcerr_decode(transp);
1627 result.status = TT_OK;
1628 result.str_val = "";
1630 otype = _tt_s_mp->otable->lookup(args.base_otid);
1631 if (otype.is_null()) {
1632 result.status = TT_ERR_OTYPE;
1634 _Tt_signature_list_ptr sigs = otype->hsigs();
1635 if (args.num < 0 || args.num >= sigs->count()) {
1636 result.status = TT_ERR_NUM;
1638 _Tt_signature_ptr sig = (*sigs)[args.num];
1639 _Tt_arg_list_ptr sargs = sig->args();
1640 result.int_val = sargs->count();
1643 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1644 (RPC_ARG_T)&result) == 0) {
1650 * Return the mode of the specified arg of an observer signature of an otype
1653 _tt_rpc_otype_osig_arg_mode(SVCXPRT *transp)
1655 _Tt_otype_args args;
1656 _Tt_rpc_result result;
1657 _Tt_otype_ptr otype;
1659 if (! _tt_svc_getargs(transp,
1660 (xdrproc_t)tt_xdr_otype_args,
1662 svcerr_decode(transp);
1666 result.status = TT_OK;
1667 result.str_val = "";
1669 otype = _tt_s_mp->otable->lookup(args.base_otid);
1670 if (otype.is_null()) {
1671 result.status = TT_ERR_OTYPE;
1673 _Tt_signature_list_ptr sigs = otype->osigs();
1674 if (args.num < 0 || args.num >= sigs->count()) {
1675 result.status = TT_ERR_NUM;
1677 _Tt_signature_ptr sig = (*sigs)[args.num];
1678 _Tt_arg_list_ptr sargs = sig->args();
1679 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1680 result.status = TT_ERR_NUM;
1682 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1683 result.int_val = (int)sarg->mode();
1687 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1688 (RPC_ARG_T)&result) == 0) {
1694 * Return the mode of the specified arg of a handler signature of an otype
1697 _tt_rpc_otype_hsig_arg_mode(SVCXPRT *transp)
1699 _Tt_otype_args args;
1700 _Tt_rpc_result result;
1701 _Tt_otype_ptr otype;
1703 if (! _tt_svc_getargs(transp,
1704 (xdrproc_t)tt_xdr_otype_args,
1706 svcerr_decode(transp);
1710 result.status = TT_OK;
1711 result.str_val = "";
1713 otype = _tt_s_mp->otable->lookup(args.base_otid);
1714 if (otype.is_null()) {
1715 result.status = TT_ERR_OTYPE;
1717 _Tt_signature_list_ptr sigs = otype->hsigs();
1718 if (args.num < 0 || args.num >= sigs->count()) {
1719 result.status = TT_ERR_NUM;
1721 _Tt_signature_ptr sig = (*sigs)[args.num];
1722 _Tt_arg_list_ptr sargs = sig->args();
1723 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1724 result.status = TT_ERR_NUM;
1726 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1727 result.int_val = (int)sarg->mode();
1731 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1732 (RPC_ARG_T)&result) == 0) {
1738 * Return the type of the specified arg of an observer signature of an otype
1741 _tt_rpc_otype_osig_arg_type(SVCXPRT *transp)
1743 _Tt_otype_args args;
1744 _Tt_rpc_result result;
1745 _Tt_otype_ptr otype;
1747 if (! _tt_svc_getargs(transp,
1748 (xdrproc_t)tt_xdr_otype_args,
1750 svcerr_decode(transp);
1754 result.status = TT_OK;
1755 result.str_val = "";
1757 otype = _tt_s_mp->otable->lookup(args.base_otid);
1758 if (otype.is_null()) {
1759 result.status = TT_ERR_OTYPE;
1761 _Tt_signature_list_ptr sigs = otype->osigs();
1762 if (args.num < 0 || args.num >= sigs->count()) {
1763 result.status = TT_ERR_NUM;
1765 _Tt_signature_ptr sig = (*sigs)[args.num];
1766 _Tt_arg_list_ptr sargs = sig->args();
1767 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1768 result.status = TT_ERR_NUM;
1770 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1771 result.str_val = sarg->type();
1775 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1776 (RPC_ARG_T)&result) == 0) {
1782 * Return the type of the specified arg of a handler signature of an otype
1785 _tt_rpc_otype_hsig_arg_type(SVCXPRT *transp)
1787 _Tt_otype_args args;
1788 _Tt_rpc_result result;
1789 _Tt_otype_ptr otype;
1791 if (! _tt_svc_getargs(transp,
1792 (xdrproc_t)tt_xdr_otype_args,
1794 svcerr_decode(transp);
1798 result.status = TT_OK;
1799 result.str_val = "";
1801 otype = _tt_s_mp->otable->lookup(args.base_otid);
1802 if (otype.is_null()) {
1803 result.status = TT_ERR_OTYPE;
1805 _Tt_signature_list_ptr sigs = otype->hsigs();
1806 if (args.num < 0 || args.num >= sigs->count()) {
1807 result.status = TT_ERR_NUM;
1809 _Tt_signature_ptr sig = (*sigs)[args.num];
1810 _Tt_arg_list_ptr sargs = sig->args();
1811 if (args.num2 < 0 || args.num2 >= sargs->count()) {
1812 result.status = TT_ERR_NUM;
1814 _Tt_arg_ptr sarg = (*sargs)[args.num2];
1815 result.str_val = sarg->type();
1819 if (svc_sendreply(transp, (xdrproc_t)tt_xdr_rpc_result,
1820 (RPC_ARG_T)&result) == 0) {
1826 // Horizontal (inter-ttsession) dispatch
1829 _tt_rpc_hdispatch(SVCXPRT *transp)
1831 _Tt_s_message_ptr msg;
1832 _Tt_qmsg_info_ptr qm = (_Tt_qmsg_info *)0;
1833 _Tt_dispatch_reply_args args;
1835 msg = new _Tt_s_message();
1836 if (!_tt_svc_getargs(transp,
1837 (xdrproc_t)tt_xdr_message,
1839 svcerr_decode(transp);
1842 _Tt_msg_trace trace( *msg, TTDR_HDISPATCH );
1843 (void)msg->dispatch( trace );
1844 (void)msg->deliver_to_observers_and_handlers( trace );
1848 // Horizontal (inter-ttsession) update
1851 _tt_rpc_hupdate_msg(SVCXPRT *transp)
1853 _Tt_s_procid_ptr sender;
1854 _Tt_s_update_args args;
1856 if (!_tt_svc_getargs(transp,
1857 (xdrproc_t)tt_s_xdr_update_args,
1860 svcerr_decode(transp);
1863 if (! _tt_s_mp->find_proc(args.message->sender(), sender, 0)) {
1867 if ( (args.newstate == TT_FAILED)
1868 && (args.message->status() == TT_ERR_NO_MATCH)
1869 && (args.message->handler().is_null()))
1872 // No remote session could find a handler.
1873 // Simulate a rejection, and redeliver the message.
1874 // _tried prevents re-offers, but any new handler
1875 // will get a crack at the request, which is nice.
1876 // _rsessions will be empty, so if we again find no
1877 // handler, we will perform disposition instead of
1878 // hdispatch()ing to remote sessions.
1880 args.message->set_state(TT_SENT);
1881 args.message->set_status((int)TT_OK);
1882 _Tt_msg_trace trace( *args.message, TTDR_HUPDATE );
1883 if (args.message->indoctrinate( trace ) == TT_OK) {
1884 args.message->change_state( 0, TT_REJECTED, trace );
1887 args.message->set_state(args.newstate);
1888 // Tracing occurs inside ::add_message()
1889 sender->add_message(args.message);
1895 _tt_rpc_msgread_2(SVCXPRT *transp)
1897 #ifdef OPT_ADDMSG_DIRECT
1899 _Tt_s_procid_ptr rp;
1901 if (! _tt_svc_getargs(transp,
1902 (xdrproc_t)tt_xdr_procid,
1904 svcerr_decode(transp);
1906 if (_tt_s_mp->find_proc(p, rp, 0)) {
1910 svcerr_noproc(transp);
1911 #endif // OPT_ADDMSG_DIRECT
1916 * Called when a sender sends a message to the server for delivery on exit.
1919 _tt_rpc_dispatch_on_exit(SVCXPRT *transp)
1921 _Tt_s_message_ptr msg;
1922 _Tt_s_procid_ptr proc;
1923 _Tt_dispatch_reply_args args;
1925 msg = new _Tt_s_message();
1926 if (!_tt_svc_getargs(transp,
1927 (xdrproc_t)tt_xdr_message,
1929 svcerr_decode(transp);
1933 args.status = TT_OK;
1935 if (_tt_s_mp->find_proc(msg->sender(),proc, 0)) {
1936 (void)proc->add_on_exit_message(msg);
1938 args.status = TT_ERR_PROCID;
1941 if (!svc_sendreply(transp,
1942 (xdrproc_t)tt_xdr_dispatch_reply_args,
1943 (RPC_ARG_T)&args)) {