|
|
1.1 root 1: /* ro2ssinitiat.c - initiator */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/rosap/RCS/ro2ssinitiat.c,v 7.1 90/07/01 21:05:52 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/rosap/RCS/ro2ssinitiat.c,v 7.1 90/07/01 21:05:52 mrose Exp $
9: *
10: * Based on an TCP-based implementation by George Michaelson of University
11: * College London.
12: *
13: *
14: * $Log: ro2ssinitiat.c,v $
15: * Revision 7.1 90/07/01 21:05:52 mrose
16: * pepsy
17: *
18: * Revision 6.1 89/06/24 00:55:54 mrose
19: * reason
20: *
21: * Revision 6.0 89/03/18 23:42:16 mrose
22: * Release 5.0
23: *
24: */
25:
26: /*
27: * NOTICE
28: *
29: * Acquisition, use, and distribution of this module and related
30: * materials are subject to the restrictions of a license agreement.
31: * Consult the Preface in the User's Manual for the full terms of
32: * this agreement.
33: *
34: */
35:
36:
37: /* LINTLIBRARY */
38:
39: #include <stdio.h>
40: #include <signal.h>
41: #include "../acsap/OACS-types.h"
42: #include "ropkt.h"
43: #include "isoservent.h"
44: #include "tailor.h"
45:
46: /* RO-BEGIN.REQUEST */
47:
48: int RoBeginRequest (called, data, roc, roi)
49: struct RoSAPaddr *called;
50: PE data;
51: struct RoSAPconnect *roc;
52: struct RoSAPindication *roi;
53: {
54: SBV smask;
55: int result;
56:
57: isodetailor (NULLCP, 0);
58:
59: missingP (called);
60: missingP (roc);
61: bzero ((char *) roc, sizeof *roc);
62: missingP (roi);
63:
64: smask = sigioblock ();
65:
66: result = RoBeginRequestAux (called, data, roc, roi);
67:
68: (void) sigiomask (smask);
69:
70: return result;
71: }
72:
73: /* */
74:
75: static int RoBeginRequestAux (called, data, roc, roi)
76: struct RoSAPaddr *called;
77: PE data;
78: struct RoSAPconnect *roc;
79: struct RoSAPindication *roi;
80: {
81: int len,
82: result,
83: settings;
84: char *base;
85: #ifdef notdef
86: register struct isoservent *is;
87: #endif
88: PE pe;
89: register struct assocblk *acb;
90: struct SSAPref ref;
91: struct SSAPconnect scs;
92: register struct SSAPconnect *sc = &scs;
93: struct SSAPindication sis;
94: register struct SSAPindication *si = &sis;
95: register struct SSAPabort *sa = &si -> si_abort;
96: struct type_OACS_PConnect pcnnct;
97: struct type_OACS_DataTransferSyntax dts;
98: struct member_OACS_1 udata;
99: struct type_OACS_ConnectionData condata;
100: struct type_OACS_PAccept *paccpt;
101: struct type_OACS_PRefuse pref;
102:
103: if ((acb = newacblk ()) == NULL)
104: return rosaplose (roi, ROS_CONGEST, NULLCP, "out of memory");
105:
106: pcnnct.member_OACS_0 = &dts;
107: dts.parm = int_OACS_DataTransferSyntax_x409;
108: pcnnct.pUserData = &udata;
109: udata.optionals = 0;
110: udata.member_OACS_2 = &condata;
111: condata.offset = type_OACS_ConnectionData_open;
112: if (data)
113: condata.un.open = data;
114: else
115: /* Seems to be needed to make the responder happy. */
116: condata.un.open = pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM, PE_PRIM_NULL);
117: udata.applicationProtocol = (int) ntohs (called -> roa_port);
118: if (encode_OACS_PConnect (&pe, 1, 0, NULLCP, &pcnnct) == NOTOK) {
119: no_mem: ;
120: result = rosaplose (roi, ROS_CONGEST, NULLCP, "out of memory");
121: goto out1;
122: }
123:
124: PLOGP (rosap_log,OACS_PConnect, pe, "PConnect", 0);
125:
126: if (pe2ssdu (pe, &base, &len) == NOTOK)
127: goto no_mem;
128:
129: if (data)
130: (void) pe_extract (pe, data), data = NULLPE;
131: pe_free (pe);
132: pe = NULLPE;
133:
134: #ifdef notdef /* SEK doesn't like this */
135: if (called -> roa_addr.sa_selectlen == 0) {
136: if ((is = getisoserventbyname ("ros", "ssap")) == NULL) {
137: result = rosaplose (roi, ROS_ADDRESS, NULLCP,
138: "ssap/ros: unknown entity");
139: goto out2;
140: }
141: if (is -> is_selectlen > SSSIZE) { /* XXX */
142: result = rosaplose (roi, ROS_ADDRESS, NULLCP,
143: "ssap/ros: selector too long (%d octets)",
144: is -> is_selectlen);
145: goto out2;
146: }
147: bcopy (is -> is_selector, called -> roa_addr.sa_selector,
148: called -> roa_addr.sa_selectlen = is -> is_selectlen);
149: }
150: #endif
151:
152: acb -> acb_requirements = SR_BCSUBSET;
153: settings = 0;
154: #define dotoken(requires,shift,bit,type) \
155: { \
156: if (acb -> acb_requirements & requires) \
157: settings |= ST_INIT_VALUE << shift; \
158: }
159: dotokens ();
160: #undef dotoken
161:
162: bzero ((char *) &ref, sizeof ref); /* ECMA says don't encode this yet */
163: if (SConnRequest (&ref, NULLSA, &called -> roa_addr,
164: acb -> acb_requirements, settings, SERIAL_NONE, base, len,
165: NULLQOS, sc, si) == NOTOK) {
166: result = ss2roslose (NULLACB, roi, "SConnRequest", sa);
167: goto out2;
168: }
169: free (base);
170:
171: bzero ((char *) roc, sizeof *roc);
172:
173: if (sc -> sc_result == SC_ACCEPT) {
174: acb -> acb_fd = sc -> sc_sd;
175: acb -> acb_uabort = SUAbortRequest;
176: }
177: else
178: if (sc -> sc_result == SC_ABORT) {
179: acb -> acb_fd = NOTOK;
180:
181: (void) ss2rosabort (acb, sa, roi);
182:
183: roc -> roc_sd = NOTOK;
184: roc -> roc_result = ROS_ABORTED;
185:
186: return OK;
187: }
188:
189: if ((pe = ssdu2pe (sc -> sc_data, sc -> sc_cc, NULLCP, &result))
190: == NULLPE) {
191: if (sc -> sc_result != SC_ACCEPT) {
192: bzero ((char *) sa, sizeof *sa);
193: sa -> sa_reason = sc -> sc_result;
194: acb -> acb_fd = NOTOK;
195: (void) ss2roslose (acb, roi, "SConnRequest(pseudo)", sa);
196:
197: roc -> roc_sd = NOTOK;
198: roc -> roc_result = roi -> roi_preject.rop_reason;
199:
200: result = OK;
201: }
202: else
203: result = ropktlose (acb, roi, result != PS_ERR_NMEM ? ROS_PROTOCOL
204: : ROS_CONGEST, NULLCP, "%s", ps_error (result));
205: goto out1;
206: }
207:
208: SCFREE (sc);
209:
210: if (sc -> sc_result != SC_ACCEPT) {
211: if (parse_OACS_PRefuse (pe, 1, NULLIP, NULLVP, &pref) == NOTOK) {
212: result = pylose ();
213: goto out1;
214: }
215:
216: PLOGP (rosap_log,OACS_PRefuse, pe, "PRefuse", 1);
217:
218: pe_free (pe);
219:
220: freeacblk (acb);
221:
222: roc -> roc_sd = NOTOK;
223: switch (pref.parm) {
224: case REFUSE_BUSY:
225: roc -> roc_result = ROS_BUSY;
226: break;
227:
228: case REFUSE_VALIDATE:
229: roc -> roc_result = ROS_VALIDATE;
230: break;
231:
232: default:
233: roc -> roc_result = ROS_PROTOCOL;
234: break;
235: }
236:
237: return OK;
238: }
239:
240: acb -> acb_flags = ACB_CONN | ACB_ROS | ACB_INIT;
241: (void) RoSService (acb, roi);
242: if (!((acb -> acb_requirements = sc -> sc_requirements) & SR_DUPLEX)
243: && !(acb -> acb_requirements & SR_HALFDUPLEX)) {
244: result = ropktlose (acb, roi, ROS_PROTOCOL, NULLCP,
245: "desired session requirements denied");
246: goto out1;
247: }
248: if (acb -> acb_requirements & SR_HALFDUPLEX)
249: acb -> acb_flags |= ACB_TURN; /* it it is there we must have it */
250:
251: if (parse_OACS_PAccept (pe, 1, NULLIP, NULLVP, &paccpt) == NOTOK) {
252: result = pylose ();
253: goto out1;
254: }
255:
256: PLOGP (rosap_log,OACS_PAccept, pe, "PAccept", 1);
257:
258: roc -> roc_sd = acb -> acb_fd;
259: roc -> roc_result = ROS_ACCEPT;
260: if (paccpt -> pUserData -> member_OACS_5->offset
261: == type_OACS_ConnectionData_open) {
262: roc -> roc_data = pe_expunge (pe, paccpt -> pUserData
263: -> member_OACS_5 -> un.open);
264: } else
265: roc -> roc_data = NULLPE;
266:
267: free_OACS_PAccept (paccpt);
268: return OK;
269:
270: out2: ;
271: free (base);
272:
273: out1: ;
274: SCFREE (sc);
275: if (pe) {
276: if (data)
277: (void) pe_extract (pe, data);
278: pe_free (pe);
279: }
280: freeacblk (acb);
281:
282: return result;
283: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.