|
|
1.1 root 1: /* ssaprelease1.c - SPM: initiate release */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssaprelease1.c,v 7.0 89/11/23 22:25:34 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/ssap/RCS/ssaprelease1.c,v 7.0 89/11/23 22:25:34 mrose Rel $
9: *
10: *
11: * $Log: ssaprelease1.c,v $
12: * Revision 7.0 89/11/23 22:25:34 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: /* LINTLIBRARY */
29:
30: #include <stdio.h>
31: #include <signal.h>
32: #include "spkt.h"
33:
34: /* S-RELEASE.REQUEST */
35:
36: int SRelRequest (sd, data, cc, secs, sr, si)
37: int sd;
38: char *data;
39: int cc;
40: int secs;
41: struct SSAPrelease *sr;
42: struct SSAPindication *si;
43: {
44: SBV smask;
45: int result;
46: register struct ssapblk *sb;
47:
48: missingP (sr);
49: missingP (si);
50:
51: smask = sigioblock ();
52:
53: ssapPsig (sb, sd);
54: toomuchP (sb, data, cc, SF_SIZE, "release");
55:
56: result = SRelRequestAux (sb, data, cc, secs, sr, si);
57:
58: (void) sigiomask (smask);
59:
60: return result;
61: }
62:
63: /* */
64:
65: #define dotoken(requires,shift,bit,type) \
66: { \
67: if ((sb -> sb_requirements & requires) && !(sb -> sb_owned & bit)) \
68: return ssaplose (si, SC_OPERATION, NULLCP, \
69: "%s token not owned by you", type); \
70: }
71:
72:
73: static int SRelRequestAux (sb, data, cc, secs, sr, si)
74: register struct ssapblk *sb;
75: char *data;
76: int cc;
77: int secs;
78: struct SSAPrelease *sr;
79: struct SSAPindication *si;
80: {
81: register struct ssapkt *s;
82:
83: dotokens ();
84:
85: if (sb -> sb_flags & SB_CD)
86: return ssaplose (si, SC_OPERATION, NULLCP,
87: "capability data request in progress");
88: if (sb -> sb_flags & SB_CDA)
89: return ssaplose (si, SC_OPERATION, NULLCP,
90: "awaiting your capability data response");
91: if (sb -> sb_flags & SB_GTC)
92: return ssaplose (si, SC_OPERATION, NULLCP,
93: "give control request in progress");
94: if (sb -> sb_flags & SB_MAA)
95: return ssaplose (si, SC_OPERATION, "awaiting your majorsync response");
96: if (sb -> sb_flags & SB_RELEASE)
97: return ssaplose (si, SC_OPERATION, "release already in progress");
98:
99: if (sb -> sb_xspdu || sb -> sb_spdu)
100: return ssaplose (si, SC_WAITING, NULLCP, NULLCP);
101:
102: if ((s = newspkt (SPDU_FN)) == NULL)
103: return ssaplose (si, SC_CONGEST, NULLCP, "out of memory");
104: if (cc > 0) {
105: s -> s_mask |= SMASK_UDATA_PGI;
106: s -> s_udata = data, s -> s_ulen = cc;
107: }
108: else
109: s -> s_udata = NULL, s -> s_ulen = 0;
110:
111: sb -> sb_retry = s;
112:
113: return SRelRetryRequestAux (sb, secs, sr, si);
114: }
115:
116: #undef dotoken
117:
118: /* S-RELEASE-RETRY.REQUEST (pseudo) */
119:
120: int SRelRetryRequest (sd, secs, sr, si)
121: int sd;
122: int secs;
123: struct SSAPrelease *sr;
124: struct SSAPindication *si;
125: {
126: SBV smask;
127: int result;
128: register struct ssapblk *sb;
129:
130: missingP (sr);
131: missingP (si);
132:
133: smask = sigioblock ();
134:
135: if ((sb = findsblk (sd)) == NULL)
136: result = ssaplose (si, SC_PARAMETER, NULLCP,
137: "invalid session descriptor");
138: else
139: if (!(sb -> sb_flags & SB_RELEASE))
140: result = ssaplose (si, SC_OPERATION, "release not in progress");
141: else
142: result = SRelRetryRequestAux (sb, secs, sr, si);
143:
144: (void) sigiomask (smask);
145:
146: return result;
147: }
148:
149: /* */
150:
151: static int SRelRetryRequestAux (sb, secs, sr, si)
152: register struct ssapblk *sb;
153: int secs;
154: struct SSAPrelease *sr;
155: struct SSAPindication *si;
156: {
157: int code,
158: result;
159: register struct ssapkt *s;
160:
161: if (sb -> sb_flags & SB_RELEASE)
162: goto waiting;
163:
164: code = SPDU_FN;
165:
166: again: ;
167: if (((s = sb -> sb_retry) -> s_code = code) == SPDU_FN) {
168: s -> s_mask |= SMASK_FN_DISC;
169: s -> s_fn_disconnect = FN_DISC_RELEASE;
170: }
171:
172: result = spkt2sd (s, sb -> sb_fd, 0, si);
173:
174: if (s -> s_code == SPDU_FN) {
175: s -> s_mask &= ~(SMASK_UDATA_PGI | SMASK_FN_DISC);
176: s -> s_udata = NULL, s -> s_ulen = 0;
177: s -> s_fn_disconnect = 0;
178: }
179:
180: if (result == NOTOK)
181: goto out1;
182:
183: waiting: ;
184: if ((s = sb2spkt (sb, si, secs, NULLTX)) == NULL) {
185: register struct SSAPabort *sa = &si -> si_abort;
186:
187: if (sa -> sa_reason == SC_TIMER) {
188: sb -> sb_flags |= SB_RELEASE;
189:
190: return NOTOK;
191: }
192:
193: goto out2;
194: }
195:
196: bzero ((char *) sr, sizeof *sr);
197: switch (s -> s_code) {
198: case SPDU_FN:
199: freespkt (s);
200: code = SPDU_DN;
201: goto again;
202:
203: case SPDU_DN:
204: sr -> sr_affirmative = 1;
205: copySPKTdata (s, sr);
206: freespkt (s);
207: freesblk (sb);
208: return OK;
209:
210: case SPDU_NF:
211: if (!(sb -> sb_requirements & SR_RLS_EXISTS)
212: || !(sb -> sb_owned & ST_RLS_TOKEN))
213: goto bad_nf;
214: sr -> sr_affirmative = 0;
215: copySPKTdata (s, sr);
216: freespkt (s);
217: return OK;
218:
219: case SPDU_RS:
220: if (sb -> sb_spdu) /* XXX */
221: freespkt (sb -> sb_spdu);
222: sb -> sb_spdu = s;
223: return ssaplose (si, SC_WAITING, NULLCP, NULLCP);
224:
225: case SPDU_AB:
226: si -> si_type = SI_ABORT;
227: {
228: register struct SSAPabort *sa = &si -> si_abort;
229:
230: if (!(sa -> sa_peer = (s -> s_ab_disconnect & AB_DISC_USER)
231: ? 1 : 0))
232: sa -> sa_reason = SC_ABORT;
233: sa -> sa_info = s -> s_udata, sa -> sa_cc = s -> s_ulen;
234: sa -> sa_realinfo = s -> s_udata, s -> s_udata = NULL;
235: }
236: break;
237:
238: default:
239: bad_nf: ;
240: (void) spktlose (sb -> sb_fd, si, SC_PROTOCOL, NULLCP,
241: "session protocol mangled: not expecting 0x%x",
242: s -> s_code);
243: break;
244: }
245:
246: out2: ;
247: freespkt (s);
248: out1: ;
249: freesblk (sb);
250:
251: return NOTOK;
252: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.