386BSD 0.1 development
[unix-history] / usr / othersrc / contrib / isode / vt / actions5.c
CommitLineData
a0be6343
WJ
1/* actions5.c - VTPM: FSM sector 5 actions */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/vt/RCS/actions5.c,v 7.1 91/02/22 09:47:54 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/vt/RCS/actions5.c,v 7.1 91/02/22 09:47:54 mrose Interim $
9 *
10 *
11 * $Log: actions5.c,v $
12 * Revision 7.1 91/02/22 09:47:54 mrose
13 * Interim 6.8
14 *
15 * Revision 7.0 89/11/23 22:31:27 mrose
16 * Release 6.0
17 *
18 */
19
20/*
21 * NOTICE
22 *
23 * Acquisition, use, and distribution of this module and related
24 * materials are subject to the restrictions of a license agreement.
25 * Consult the Preface in the User's Manual for the full terms of
26 * this agreement.
27 *
28 */
29
30
31#include "vtpm.h"
32#include "sector1.h"
33
34/************************************************************************/
35/* This file contains the functions that are executed when the */
36/* VT Protocol machine is in a Sector 5 state and a protocol */
37/* event occurs. The state transition matrix is specified in */
38/* Table 32 of ISO 9041 (July 1987 version). The actions which */
39/* this collection of functions perform are specified in Table 40 */
40/* of ISO 9041. */
41/************************************************************************/
42
43extern int sd; /*Global Session Descriptor (ISODE) */
44
45 /* xx1x xxxx = awaiting ack from peer i.e., 420 */
46 /* xxxx xx1x = awaiting ack from user */
47
48 /* T = got token, N = no got token */
49
50
51 /*
52 req: usr==>vtpm
53 ind: vtpm==>usr
54 */
55int
56ce_104(pe) /* common event 104 */
57PE pe;
58{
59 /* if (vnt > 0) */
60 if(pe != NULLPE) vdatind(SEQUENCED,pe);
61 vnt = 0;
62 return(OK);
63}
64
65int
66ce_105() /* common event 105 */
67{
68 /* if (vns > 0) for(... */
69 if(p_ondq != NULLPE)
70 (void)p_data(p_ondq); /* send NDQ */
71 vns = 0;
72 return(OK);
73}
74
75
76/* ARGSUSED */
77int
78a5_0(pe) /*VDATreq-sqtr in states 400B or 402B */
79 /* V data request addressing sequenced trigger co */
80PE pe;
81{
82 return(ce_105());
83/*
84 ==> SAMESTATE;
85*/
86}
87
88
89/* ARGSUSED */
90int
91a5_1(pe) /*VDATreq-n in states 400B, 402B or 40T */
92 /* V data request addressing sequenced trigger co */
93PE pe;
94{
95
96 /*
97 vns++;
98 ==> SAMESTATE
99 */
100 return(ce_105()); /*Autonomous Event to Ship it*/
101}
102
103
104int
105a5_2(pe) /*NDQ-tr in states 400B, 420B */
106PE pe;
107{
108 /*
109 vnt++;
110 */
111
112 return(ce_104(pe));
113 /*
114 ==> SAMESTATE
115 */
116}
117
118
119int
120a5_3(pe) /*NDQ-ntr in states 400B, 420B */
121PE pe;
122{
123 /*
124 vnt++;
125 */
126 /*
127 ==> SAMESTATE
128 */
129 return(ce_104(pe)); /*Autonomous Event to Deliver to User*/
130}
131
132int
133a5_5(pe) /* VBRKreq */
134PE pe;
135{
136 vtok = 0; /* giving the token away */
137 vnt = 0;
138 vns = 0;
139 /* vtkp was set in vbrkreq so it could be coded in to the pe */
140 (void)p_resync_req(pe,SYNC_RESTART); /* send break request */
141 state = S5_61;
142 return(OK);
143}
144
145int
146a5_6(pe) /* VBRKrsp in state 62 */
147PE pe;
148{
149 (void)p_resync_resp(pe); /* send out break response */
150 if (vsmd && vtok)
151 state = S5_40T;
152 else
153 if (vsmd)
154 state = S5_40N;
155 else {
156 vtkp = INITIATOR;
157 if (vtok)
158 vtkp = ACCEPTOR;
159 state = S5_400B;
160 }
161 return(OK);
162}
163
164int
165a5_9(pe) /*VDELreq in states 400B, 402B */
166PE pe;
167{
168 if (dcno) /* no delivery control */
169 {
170 advise(LLOG_DEBUG,NULLCP,"a5_9: dcno hasn't been set");
171 /* ==> SAMESTATE */
172 return(NOTOK);
173 }
174 (void)ce_105();
175 /* send out dlq */
176 /* this will be replace by the new-fangled pepy schtuff;
177 will use this now for compatability */
178
179 (void)p_data(pe);
180 state = (vra) ? state + 2 : state; /* pretty neeto eh? */
181 return(OK);
182}
183
184int
185a5_11(pe) /*HDQ request in 400B*/
186PE pe;
187{
188 (void) p_typed_data(pe);
189 return(OK);
190}
191
192/*ARGSUSED*/
193int
194a5_17(pe) /*VRELreq in states 400B */
195PE pe;
196{
197/* ce_105(); */
198 sector = 1;
199 if(vtok)
200 {
201 state = S1_51Q; /*Must change state first because
202 vt_disconnect gets RLR & calls
203 state machine again. */
204 vt_disconnect(); /*May be only TEMP*/
205 }
206 else
207 {
208 request_token();
209 /*Need call to ISODE to request token*/
210 state = S1_50B;
211 }
212
213 return(OK);
214}
215
216int
217a5_28(pe) /*UDQ request in 400B*/
218PE pe;
219{
220 (void) p_typed_data(pe);
221 return(OK);
222}
223
224int
225a5_31(pe) /* BKR in 61 */
226PE pe;
227{
228 if (vsmd && vtok) state = S5_40T;
229 else if (vsmd) state = S5_40N;
230 else state = S5_400B;
231 vbrkcnf(pe);
232 return(OK);
233}
234
235int
236a5_32(pe) /* BKQ could occur in any state except 62 */
237PE pe;
238{
239 vnt = 0;
240 vns = 0;
241 /*
242 vbrkind clears queues etc.
243 and then map the break character to user
244 and sets vtok to 1
245 (we should have received the token)
246 */
247 state = S5_62;
248 vbrkind(pe);
249 return(OK);
250}
251
252int
253a5_34(pe) /*UDQ in 400B*/
254PE pe;
255{
256 if(pe != NULLPE) vudatind(pe);
257 return(OK);
258}
259
260int
261a5_35(pe) /* DEL in states 400B, 420B */
262PE pe;
263{
264
265 if ((vra = prim2flag(pe)) == NOTOK)
266 adios("a5_35: bogus PDU (%s)", pe_error (pe -> pe_errno));
267 (void)ce_104(NULLPE);
268 vdelind(pe,vra);
269 state = (vra) ? state + 2 : state;
270 return(OK);
271}
272
273
274int
275a5_38(pe) /* RLQ in states 400B */
276PE pe;
277{
278
279 (void)ce_104(pe);
280 sector = 1;
281 state = S1_51R;
282 (void)vrelind();
283 return(OK);
284}
285
286int
287a5_106(pe)
288PE pe;
289{
290 if(pe != NULLPE) vhdatind(pe);
291 return(OK);
292}