|
|
1.1 root 1: /* psapexec.c - PPM: exec */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/psap2/RCS/psapexec.c,v 7.2 90/07/01 21:04:58 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/psap2/RCS/psapexec.c,v 7.2 90/07/01 21:04:58 mrose Exp $
9: *
10: *
11: * $Log: psapexec.c,v $
12: * Revision 7.2 90/07/01 21:04:58 mrose
13: * pepsy
14: *
15: * Revision 7.1 89/11/24 16:22:12 mrose
16: * sync
17: *
18: * Revision 7.0 89/11/23 22:14:19 mrose
19: * Release 6.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 "PS-types.h"
38: #include "ppkt.h"
39: #include "isoservent.h"
40: #include "tailor.h"
41:
42: /* SERVER only */
43:
44: int PExec (ss, pi, arg1, arg2, hook, setperms)
45: struct SSAPstart *ss;
46: struct PSAPindication *pi;
47: char *arg1,
48: *arg2;
49: IFP hook,
50: setperms;
51: {
52: int len,
53: result,
54: result2;
55: char *base;
56: register struct isoservent *is;
57: register struct psapblk *pb;
58: PE pe;
59: struct SSAPref ref;
60: struct SSAPindication sis;
61: register struct SSAPindication *si = &sis;
62: struct type_PS_CP__type *cp;
63: register struct element_PS_0 *cp_normal;
64: register struct type_PS_CPR__type *cpr;
65:
66: missingP (ss);
67: missingP (pi);
68: missingP (arg1);
69: missingP (arg2);
70:
71: cp = NULL, cpr = NULL;
72: pe = NULLPE;
73:
74: if ((pb = newpblk ()) == NULL)
75: goto congest;
76: pb -> pb_fd = ss -> ss_sd;
77:
78: if ((pe = ssdu2pe (ss -> ss_data, ss -> ss_cc, NULLCP, &result))
79: == NULLPE) {
80: if (result == PS_ERR_NMEM)
81: goto congest;
82:
83: (void) ppktlose (pb, pi, PC_PROTOCOL, PPDU_CP, NULLCP, "%s",
84: ps_error (result));
85: goto out1;
86: }
87:
88: if (decode_PS_CP__type (pe, 1, NULLIP, NULLVP, &cp) == NOTOK) {
89: (void) ppktlose (pb, pi, PC_UNRECOGNIZED, PPDU_CP, NULLCP, "%s",
90: PY_pepy);
91: goto out1;
92: }
93:
94: PLOGP (psap2_log,PS_CP__type, pe, "CP-type", 1);
95:
96: if (cp -> mode -> parm != int_PS_Mode__selector_normal__mode) {
97: (void) ppktlose (pb, pi, PC_INVALID, PPDU_CP, NULLCP,
98: "X.410-mode not supported");
99: goto out1;
100: }
101: cp_normal = cp -> normal__mode;
102:
103: pe_free (pe);
104: pe = NULLPE;
105:
106: if (cp_normal -> called == NULL)
107: base = NULL, len = 0;
108: else {
109: if ((base = qb2str (cp_normal -> called)) == NULLCP)
110: goto congest;
111: len = cp_normal -> called -> qb_len;
112: }
113:
114: switch (len) {
115: case 0:
116: is = NULL;
117: break;
118:
119: default:
120: is = getisoserventbyselector ("psap", base, len);
121: break;
122: }
123: if (base)
124: free (base);
125: if (is == NULL) {
126: result = SC_REJECTED, result2 = PC_ADDRESS;
127: goto out2;
128: }
129:
130: *is -> is_tail++ = arg1;
131: *is -> is_tail++ = arg2;
132: *is -> is_tail = NULL;
133:
134: switch (hook ? (*hook) (is, pi) : OK) {
135: case NOTOK:
136: return NOTOK;
137:
138: case DONE:
139: return OK;
140:
141: case OK:
142: default:
143: if (setperms)
144: (void) (*setperms) (is);
145: (void) execv (*is -> is_vec, is -> is_vec);
146: SLOG (psap2_log, LLOG_FATAL, *is -> is_vec,
147: ("unable to exec"));
148: break;
149: }
150:
151: congest: ;
152: result = SC_CONGESTION;
153: (void) psaplose (pi, result2 = PC_CONGEST, NULLCP, NULLCP);
154:
155: out2: ;
156: if (pe) {
157: pe_free (pe);
158: pe = NULLPE;
159: }
160:
161: if (cpr = (struct type_PS_CPR__type *) calloc (1, sizeof *cpr)) {
162: if (cp
163: && cp -> mode
164: && cp -> mode -> parm ==
165: int_PS_Mode__selector_x410__1984__mode) {
166: cpr -> offset = type_PS_CPR__type_x410__mode;
167: if (pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET)) {
168: cpr -> un.x410__mode = pe;
169: (void) set_add (pe, num2prim (result2 != PC_CONGEST ? 0 : 3,
170: PE_CLASS_CONT, 0));
171: }
172: }
173: else {
174: register struct element_PS_2 *cpr_normal;
175:
176: cpr -> offset = type_PS_CPR__type_normal__mode;
177: if (cpr_normal = (struct element_PS_2 *)
178: calloc (1, sizeof *cpr_normal)) {
179: cpr -> un.normal__mode = cpr_normal;
180: cpr_normal -> optionals |= opt_PS_element_PS_2_reason;
181: cpr_normal -> reason = result2 - PC_PROV_BASE;
182: }
183: }
184: }
185:
186: if (encode_PS_CPR__type (&pe, 1, 0, NULLCP, cpr) != NOTOK) {
187: PLOGP (psap2_log,PS_CPR__type, pe, "CPR-type", 0);
188:
189: if (pe)
190: (void) pe2ssdu (pe, &base, &len);
191: }
192: else
193: base = NULL, len = 0;
194:
195: bzero ((char *) &ref, sizeof ref);
196: (void) SConnResponse (ss -> ss_sd, &ref, NULLSA, result, 0, 0,
197: SERIAL_NONE, base, len, si);
198: if (base)
199: free (base);
200: (void) psaplose (pi, result2, NULLCP, NULLCP);
201:
202: out1: ;
203: SSFREE (ss);
204: if (pe)
205: pe_free (pe);
206: if (cp)
207: free_PS_CP__type (cp);
208: if (cpr)
209: free_PS_CPR__type (cpr);
210:
211: freepblk (pb);
212:
213: return NOTOK;
214: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.