BSD 4_3_Net_2 development
[unix-history] / usr / src / contrib / isode / rtsap / rt2ssexec.c
CommitLineData
9e8e5516
C
1/* rt2ssexec.c - RTPM: exec */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2ssexec.c,v 7.2 91/02/22 09:42:29 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/rtsap/RCS/rt2ssexec.c,v 7.2 91/02/22 09:42:29 mrose Interim $
9 *
10 *
11 * $Log: rt2ssexec.c,v $
12 * Revision 7.2 91/02/22 09:42:29 mrose
13 * Interim 6.8
14 *
15 * Revision 7.1 90/07/01 21:07:08 mrose
16 * pepsy
17 *
18 * Revision 6.0 89/03/18 23:43:19 mrose
19 * Release 5.0
20 *
21 */
22
23/*
24 * NOTICE
25 *
26 * Acquisition, use, and distribution of this module and related
27 * materials are subject to the restrictions of a license agreement.
28 * Consult the Preface in the User's Manual for the full terms of
29 * this agreement.
30 *
31 */
32
33
34/* LINTLIBRARY */
35
36#include <stdio.h>
37#include "RTS-types.h"
38#include "OACS-types.h"
39#include "rtpkt.h"
40#include "isoservent.h"
41#include "tailor.h"
42
43/* \f SERVER only */
44
45int RtExec (ss, rti, arg1, arg2, hook, setperms)
46struct SSAPstart *ss;
47struct RtSAPindication *rti;
48char *arg1,
49 *arg2;
50IFP hook,
51 setperms;
52{
53 int result,
54 result2;
55 register struct isoservent *is;
56 register PE pe;
57 struct SSAPref ref;
58 struct SSAPindication sis;
59 register struct SSAPindication *si = &sis;
60 struct type_OACS_PConnect *pcon = NULL;
61
62 missingP (ss);
63 missingP (rti);
64 missingP (arg1);
65 missingP (arg2);
66
67 /* acsap_conntype = CN_OPEN, acsap_data = NULLPE; */
68 if ((pe = ssdu2pe (ss -> ss_data, ss -> ss_cc, NULLCP, &result)) == NULLPE
69 || parse_OACS_PConnect (pe, 1, NULLIP, NULLVP, &pcon) == NOTOK) {
70 if (pe)
71 pe_free (pe);
72 if (result == PS_ERR_NMEM) {
73 congest: ;
74 result = SC_CONGESTION, result2 = RTS_CONGEST;
75 }
76 else
77 result = SC_REJECTED, result2 = RTS_PROTOCOL;
78 goto out;
79 }
80
81 PLOGP (rtsap_log,OACS_PConnect, pe, "PConnect", 1);
82
83 pe_free (pe);
84
85 if (pcon -> pUserData -> member_OACS_2 -> offset
86 != type_OACS_ConnectionData_open) {
87 result = SC_REJECTED, result2 = RTS_ADDRESS;
88 goto out;
89 }
90 if (is = getisoserventbyport ("rtsap",
91 (u_short) htons ((u_short) pcon -> pUserData -> applicationProtocol))) {
92 *is -> is_tail++ = arg1;
93 *is -> is_tail++ = arg2;
94 *is -> is_tail = NULL;
95 }
96 else {
97 result = SC_REJECTED, result2 = RTS_ADDRESS;
98 goto out;
99 }
100
101 switch (hook ? (*hook) (is, rti) : OK) {
102 case NOTOK:
103 if (pcon)
104 free_OACS_PConnect(pcon);
105 return NOTOK;
106
107 case DONE:
108 if (pcon)
109 free_OACS_PConnect(pcon);
110 return OK;
111
112 case OK:
113 if (setperms)
114 (void) (*setperms) (is);
115 (void) execv (*is -> is_vec, is -> is_vec);/* fall */
116 SLOG (rtsap_log, LLOG_FATAL, *is -> is_vec, ("unable to exec"));
117 default:
118 goto congest;
119 }
120
121out: ;
122 if (pcon)
123 free_OACS_PConnect(pcon);
124 SSFREE (ss);
125
126 bzero ((char *) &ref, sizeof ref);
127 (void) SConnResponse (ss -> ss_sd, &ref, NULLSA, result, 0, 0,
128 SERIAL_NONE, NULLCP, 0, si);
129 return rtsaplose (rti, result2, NULLCP, NULLCP);
130}