|
|
1.1 root 1: /* actions1.c - VTPM: FSM sector 1 actions */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/vt/RCS/actions1.c,v 7.0 89/11/23 22:31:26 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/vt/RCS/actions1.c,v 7.0 89/11/23 22:31:26 mrose Rel $
9: *
10: *
11: * $Log: actions1.c,v $
12: * Revision 7.0 89/11/23 22:31:26 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: #include "vtpm.h"
29: #include "sector1.h"
30:
31: /************************************************************************/
32: /* This file contains the functions that are executed when the */
33: /* VT Protocol machine is in a Sector 1 state and a protocol */
34: /* event occurs. The state transition matrix is specified in */
35: /* Table 32 of ISO 9041 (July 1987 version). The actions which */
36: /* this collection of functions perform are specified in Table 33 */
37: /* of ISO 9041. */
38: /************************************************************************/
39:
40: extern int sd; /*Global Session Descriptor (ISODE) */
41:
42: #define invalid_result(str,pe) \
43: adios (NULLCP, "%s: invalid result (%s)", (str), \
44: pe_error ((p) -> pe_errno))
45:
46: int
47: a1_0(pe) /*NDQ-ntr in states 50B or 51Q (Release awaiting peer)*/
48: /*Also RTQ in state 51T (Release awaiting peer)*/
49: PE pe;
50: {
51: /*If quarantined data delivery were supported, we would do:
52: /* ++vnt;
53: /* enque(pe);
54: /*For now, only supporting simple or no delivery control, so give pe
55: /*to application here.
56: */
57:
58: vdatind(SEQUENCED,pe); /*Deliver the NDQ to application*/
59: return(OK);
60: }
61:
62:
63: int
64: a1_1(pe) /*NDQ-tr in states 50B or 51Q (Release Awaiting Peer)*/
65: PE pe;
66: {
67: /* Same comment as in a1_0 above */
68: vdatind(SEQUENCED,pe); /*Deliver the NDQ to application*/
69: vnt = 0;
70: return(OK);
71: }
72:
73:
74: int
75: a1_2(pe) /*VASSreq from user in state 01 (No Association)*/
76: PE pe;
77: {
78: dr_pm_st = DEFINED; /*Draft-VTE param. status = Defined
79: /*(SetVTPmS(P) in 9041) */
80: /*Set draft-VTE parameter values per profile (SetVTPmV(P) in 9041)*/
81:
82: asq(pe); /*Send the ASQ PDU*/
83:
84: vsmd = 0; /*Very TEMPORARY -- A-Mode only
85: Should be done in VT-user or application call
86: */
87: if(vsmd) state = S1_02S;
88: else state = S1_02B;
89: return(OK);
90: }
91:
92:
93: int
94: a1_3(pe) /*VASSrsp from user in state 03B (Associate -- Awaiting user)*/
95: PE pe;
96: {
97: PE p;
98: vrsl = -1;
99: for(p = first_member(pe); p; p = next_member(pe,p))
100: /*Step through elements in sequence*/
101: {
102: if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,2) )
103: /*If the result element*/
104: {
105: if( (vrsl = prim2num(p)) == NOTOK)
106: invalid_result ("a1_3", p);
107: break;
108: }
109: }
110: if(vrsl < 0) /*If no result field*/
111: adios(NULLCP, "a1_3: no result field");
112: if(vrsl == FAILURE)
113: {
114: clear_vte();
115: (void) asr(pe,FAILURE);
116: }
117: else
118: {
119: /*Set draft-VTE parameters according to list in primitive
120: /* (SetVTPmV(L) in 9041)
121: /*Set status of draft-VTE parameters above to defined
122: /* (SetVTPmSDe(L)
123: /*Set current VTE from draft VTE (SetCuVTE) */
124:
125: vena = TRUE; /*Current VTE agreed to*/
126: waca = TRUE;
127: (void) asr(pe,SUCCESS);
128: if(vrsl == SUCCESS)
129: {
130: sector = 5;
131: state = S5_400B;
132: }
133: else state = S1_10B;
134: }
135: return(OK);
136: }
137:
138:
139: int
140: a1_4(pe) /*VASSrsp from user in state 03S (Associate -- Awaiting user)*/
141: PE pe;
142: {
143: PE p;
144: vrsl = -1;
145: for(p = first_member(pe); p; p = next_member(pe,p))
146: /*Step through elements in sequence*/
147: {
148: if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,2) )
149: /*If the result element*/
150: {
151: if( (vrsl = prim2num(p)) == NOTOK)
152: invalid_result ("a1_4", p);
153: break;
154: }
155: }
156: if(vrsl < 0) /*If no result field*/
157: adios(NULLCP,"a1_4: no result field");
158: if(vrsl == FAILURE)
159: {
160: clear_vte(); /*Discard VTE (DisVTE)*/
161: (void) asr(pe,FAILURE); /*Send the ASR to peer*/
162: }
163: else
164: {
165: /*Set draft-VTE parameters according to list in primitive
166: /* (SetVTPmV(L) in 9041)
167: /*Set status of draft-VTE parameters above to defined
168: /* (SetVTPmSDe(L)
169: /*Set current VTE from draft VTE (SetCuVTE) */
170:
171: vena = TRUE; /*Current VTE agreed to*/
172: (void) asr(pe,SUCCESS);
173: if(vrsl == SUCCESS)
174: {
175: sector = 5;
176: if(vtok)state = S5_40T;
177: else state = S5_40N;
178: }
179: else
180: {
181: if(vtok) state = S1_10T;
182: else state = S1_10N;
183: }
184: }
185: return(OK);
186: }
187:
188:
189: /* ARGSUSED */
190: int
191: a1_5(pe) /*RTQ (Token Request) in state 10B
192: (Environment not agreed)*/
193: PE pe;
194: {
195: give_token(); /*Need a call to lower layer in ISODE to do this*/
196: return(OK);
197: }
198:
199:
200: /* ARGSUSED */
201: int
202: a1_6(pe) /*VGVTreq from user in 10T*/
203: PE pe;
204: {
205: give_token(); /*Need a call to lower layer in ISODE to do this*/
206: state = S1_10N;
207: return(OK);
208: }
209:
210:
211: /* ARGSUSED */
212: int
213: a1_7(pe) /*VRELreq from user in state 10B (Env. not agreed)*/
214: /*GTQ in 50B*/
215: PE pe;
216: {
217: if(vtok)
218: {
219: vt_disconnect(); /*May be only TEMP*/
220: state = S1_51Q;
221: }
222: else
223: {
224: request_token();
225: /*Need call to ISODE to request token*/
226: state = S1_50B;
227:
228: /*Probably need to release the NULL PE for VRELreq that got us here*/
229:
230: }
231: return(OK);
232: }
233:
234:
235: /* ARGSUSED */
236: int
237: a1_8(pe) /*VRELreq in 10T*/
238: PE pe;
239: {
240: vt_disconnect(); /*May be only TEMP--check function*/
241: state = S1_51T;
242:
243: /*Release NULL PE from VT USER*/
244:
245: return(OK);
246: }
247:
248: int
249: a1_9(pe) /*VRELrsp in 51R & 51N (Release -- Awaiting User)*/
250: PE pe;
251: {
252:
253:
254: /* vrsl = -1;
255: /* for(p = first_member(pe); p; p = next_member(pe,p) )
256: /* /*Get Result parameter*/
257: /* {
258: /* if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,0) )
259: /* {
260: /* if( (vrsl = prim2num(p)) == NOTOK)
261: /* invalid_result ("a1_9", p);
262: /* break;
263: /* }
264: /* }
265: /* if(vrsl < 0)
266: /* adios(NULLCP,"a1_9: no result field");
267: /*
268: /* we should look in the pdu and see what the result is, but
269: /* since we know our vt-user is an agreeable fellow, we can
270: /* assume success
271: */
272:
273: vrsl = SUCCESS;
274: if(vrsl == SUCCESS)
275: {
276: if(vns > 0) /*If data left to send*/
277: {
278: advise(LLOG_NOTICE,NULLCP, "Sending remaining data (a1_9() )");
279: send_all(); /*Send remaining data (NDQseq(Vns)-ntr)*/
280: vns = 0;
281: }
282: send_rlr(pe); /*Send the RLR which User built*/
283: clear_vte(); /*Erase the Environment*/
284: state = S1_01;
285: /* system("reset"); */
286: finalbye ();
287: advise(LLOG_NOTICE,NULLCP,"association released by terminal service");
288: (void)fflush (stdout);
289: exit(0);
290: }
291: else /*Result was failure*/
292: {
293: send_rlr(pe); /*Send the RLR*/
294: if(vena) /*If agreement on VTE*/
295: {
296: sector = 5;
297: if(vsmd) state = S5_40N; /*If S-Mode*/
298: else state = S5_400B;
299: }
300: else
301: {
302: if(vsmd) state = S1_10N;
303: else state = S1_10B;
304: }
305: }
306: return(OK);
307: }
308:
309:
310: /* ARGSUSED */
311: int
312: a1_10(pe) /*VRQTreq(request token) n state 10N*/
313: PE pe;
314: {
315: request_token(); /*TEMP -- Need an ISODE call to really do this
316: since there is no VTP PDU*/
317:
318: /*Probably need to free the NullPE that triggered this*/
319:
320: state = S1_10N; /*Should be here already. Do this to follow
321: the spec literally*/
322: return(OK);
323: }
324:
325:
326: /* ARGSUSED */
327: int
328: a1_11(pe) /*VSNEGreq (User Start Negotiation)*/
329: PE pe;
330: {
331:
332: /*MIN not implemented*/
333: /*Probably need to send back a negative Acknowledgement*/
334:
335: return(OK);
336: }
337:
338:
339: /* ARGSUSED */
340: int
341: a1_12(pe) /*VSNEGreq*/
342: PE pe;
343: {
344:
345: /*MIN not implemented*/
346: /*Probably need to send back a Negative Acknowledgement*/
347:
348: return(OK);
349: }
350:
351:
352: /* ARGSUSED */
353: int
354: a1_13(pe) /*VSWPreq (User Switch profile request)*/
355: PE pe;
356: {
357:
358: /*Switch Profile not implemented*/
359: /*Should probably send back a negative acknowledgement*/
360:
361: return(OK);
362: }
363:
364:
365: /* ARGSUSED */
366: int
367: a1_14(pe) /*VSWPreq*/
368: PE pe;
369: {
370:
371: /*Switch Profile not implented*/
372: /*Should Probably send back a negative acknowledgement*/
373:
374: return(OK);
375: }
376:
377:
378: int
379: a1_15(pe) /*ASR in state 2B (Assoc. awaiting target) */
380: PE pe;
381: {
382: PE p;
383:
384: vrsl = -1;
385: for(p = first_member(pe); p; p = next_member(pe,p) )
386: {
387: if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,2) )
388: {
389: if( (vrsl = prim2num(p)) == NOTOK)
390: invalid_result ("a1_15", p);
391: break;
392: }
393: }
394: if(vrsl < 0)
395: adios(NULLCP,"a1_15: no result field");
396: if(vrsl == FAILURE)
397: {
398: clear_vte();
399: state = S1_01;
400: return(FAILURE); /*Notify user of ASR (VASScnf)*/
401: }
402: else
403: {
404:
405: /*Set draft-VTE param. according to list in primitive or protocol
406: /*element (SetVTPmV(L)).
407: /*Set status of draft-VTE params. listed in primitive or protocol
408: /*element to defined (SetVTPmSDe(L))
409: /*Set current-VTE from draft-VTE (SetCuVTE) */
410:
411: vena = 1;
412: waci = 1;
413: if(vrsl == SUCCESS)
414: {
415: sector = 5;
416: state = S5_400B;
417: }
418: else state = S1_10B;
419: }
420: return(SUCCESS); /*Notify user of ASR (VASScnf)*/
421: }
422:
423: int
424: a1_16(pe) /*ASR in state 2S (Assoc. awaiting target) */
425: PE pe;
426: {
427: PE p;
428:
429: vrsl = -1;
430: for(p = first_member(pe); p; p = next_member(pe,p) )
431: {
432: if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,2) )
433: {
434: if( (vrsl = prim2num(p)) == NOTOK)
435: invalid_result ("a1_16", p);
436: break;
437: }
438: }
439: if(vrsl < 0)
440: adios(NULLCP,"a1_16: no result field");
441: if(vrsl == FAILURE)
442: {
443: clear_vte();
444: state = S1_01;
445: return(FAILURE); /*Notify user of ASR (VASScnf)*/
446: }
447: else
448: {
449:
450: /*Set draft-VTE param. according to list in primitive or protocol
451: /*element (SetVTPmV(L)).
452: /*Set status of draft-VTE params. listed in primitive or protocol
453: /*element to defined (SetVTPmSDe(L))
454: /*Set current-VTE from draft-VTE (SetCuVTE) */
455:
456: vena = 1;
457: if(vrsl == SUCCESS)
458: {
459: sector = 5;
460: if(vtok) state = S5_40T;
461: else state = S5_40N;
462: }
463: else
464: {
465: if(vtok) state = S1_10T;
466: else state = S1_10N;
467: }
468: }
469: return(SUCCESS); /*Notify user of ASR (VASScnf) */
470: }
471:
472:
473: int
474: a1_17(pe) /*ASQ in state 01 (No Association)*/
475: PE pe;
476: {
477:
478: int result;
479:
480: result = read_asq(pe); /*Unpack ASQ*/
481: if(result == PROFILE_NG)
482: {
483: (void)send_bad_asr(PROFILE_NG); /*Send Failure ASR with reason*/
484: return(NOTOK);
485: }
486: if(result == 0)
487: {
488: (void)send_bad_asr(0); /*Send failure ASR w/ no reason*/
489: return(NOTOK);
490: }
491:
492: /*SetVTPmS(P)*/
493: /*SetVTPmV(P)*/
494: dr_pm_st = DEFINED;
495: vsmd = 0;
496: vtok = 1; /*For Telnet & transparent profiles*/
497: if(vsmd) state = S1_03S; /*If S-Mode*/
498: else state = S1_03B;
499: result = vassind(pe); /*doesn't really use pe but for consistency
500: with version 1*/
501: return(result);
502: }
503:
504:
505: int
506: a1_18(pe) /*UDQ (uncontrolled data) in 51T (Release Awaiting Peer)*/
507: PE pe;
508: {
509: vdatind(SEQUENCED,pe); /*Want to do VDATind-h but this is all that's
510: now available*/
511: return(OK);
512: }
513:
514:
515: /* ARGSUSED */
516: int
517: a1_19(pe) /*GTQ in 10N or VRTQreq in 10T*/
518: PE pe;
519: {
520: vtok = TRUE;
521: vgvt_ind(); /*VGVTind -- Tell user we have token (as if he cares)*/
522: state = S1_10T;;
523: return(OK);
524: }
525:
526:
527: int
528: a1_20(pe) /*RLR (Release Response) in 51Q or 51T (Release Awaiting Peer)*/
529: PE pe;
530: {
531:
532: PE p;
533:
534: vrsl = -1;
535: for(p = first_member(pe); p; p = next_member(pe,p) )
536: {
537: if(PE_ID(p->pe_class,p->pe_id) == PE_ID(PE_CLASS_CONT,0) )
538: /*If result element*/
539: {
540: if( (vrsl = prim2num(p)) == NOTOK)
541: invalid_result ("a1_20", p);
542: break;
543: }
544: }
545: if(vrsl < 0) /*if no result field*/
546: adios(NULLCP,"a1_20: no result field");
547: if(vrsl == SUCCESS)
548: {
549: /*VRELcnf -- Confirm the release to user -- for now, use the
550: original mechanism (closing TELNET) -- should be changed
551: especially for forms mode*/
552:
553: vrelcnf();
554: if(vnt > 0)
555: /*Should never happen until Quarantined Delivery
556: supported*/
557: {
558: /*VDATind-n(Vnt)*/
559: vnt = 0;
560: }
561: clear_vte();
562: state = S1_01;
563: }
564: else /*Release Failed*/
565: {
566: if(vena)
567: {
568: sector = 5;
569: if(vsmd) state = S5_40T;
570: else state = S5_400B;
571: }
572: else
573: {
574: if(vsmd) state = S1_10T;
575: else state = S1_10B;
576: }
577: }
578: return(OK);
579: }
580:
581:
582: int
583: a1_21(pe) /*DLQ (Deliver Request) in 50B or 51Q (Release Awaiting Peer)*/
584: PE pe;
585: {
586: if( (vra = prim2flag(pe)) == NOTOK)
587: adios(NULLCP,"a1_21: incorrect DLQ");
588: if(vra)
589: {
590: vrsl = FAILURE;
591: vrea = COLL_DET;
592: /*VRELcnf required in spec but there's really nothing to tell
593: the user*/
594: }
595: if(vnt > 0) /*Should not happen unless Quarantine Delivery supported*/
596: {
597: /*VDATind-n(Vnt)*/
598: vnt = 0;
599: }
600: vdelind(pe,vra); /*Also irrelevant without Quarantine*/
601: if(vra)
602: {
603: sector = 5;
604: state = S5_402B;
605: }
606: return(OK);
607: }
608:
609:
610: /* ARGSUSED */
611: int
612: a1_22(pe) /*RLQ (Release Request) in 50B*/
613: PE pe;
614: {
615:
616: vrsl = FAILURE;
617: vrea = COLL_DET;
618: /*VRELcnf -- Confirm to user telling of failure due to collision --
619: but user can't do anything now anyway. */
620:
621: if(vnt > 0) /*Shouldn't happen without Quarantine Delivery Ctrl*/
622: {
623: /*VDATind-n(Vnt)*/
624: vnt = 0;
625: }
626: (void)vrelind(); /*Tell user that peer requested release*/
627: state = S1_51R;
628: return(OK);
629: }
630:
631:
632: /* ARGSUSED */
633: int
634: a1_23(pe) /*SNQ (Start negotiation) in 50B*/
635: PE pe;
636: {
637: /*Switch Negotiation not implemented.
638: Should probably send back negative acknowledgement. */
639:
640: return(OK);
641: }
642:
643:
644: /* ARGSUSED */
645: int
646: a1_24(pe) /*SPQ (Switch Profile Request) in state 50B*/
647: PE pe;
648: {
649: /*Profile Switch not implemented.
650: Should probably send back negative acknowledgement. */
651:
652: return(OK);
653: }
654:
655:
656: /* ARGSUSED */
657: int
658: a1_25(pe) /*RLQ (Release Request) in 10B (Environment not agreed) */
659: PE pe;
660: {
661: (void)vrelind();
662: state = S1_51R;
663: return(OK);
664: }
665:
666: /* ARGSUSED */
667: int
668: a1_26(pe) /*RLQ (Release Request) in state 10N*/
669: PE pe;
670: {
671: (void)vrelind();
672: state = S1_51R;
673: return(OK);
674:
675: }
676:
677:
678: /* ARGSUSED */
679: int
680: a1_27(pe) /*RTQ (Request Token) in state 10T*/
681: PE pe;
682: {
683: vrtq_ind(); /*Tell Application that peer requested token*/
684:
685: /*Probably some ISODE call to give token directly instead of telling
686: user */
687:
688: return(OK);
689: }
690:
691:
692: /* ARGSUSED */
693: int
694: a1_28(pe) /*SNQ (Start Negotiation) in 10N*/
695: PE pe;
696: {
697: /*MIN not implemented.
698: Need to return NAK. */
699:
700: return(OK);
701: }
702:
703:
704: /* ARGSUSED */
705: int
706: a1_29(pe) /*SNQ (Start Negotiation) in 10B*/
707: PE pe;
708: {
709: /*MIN not implemented.
710: Need to send NAK to peer. */
711:
712: return(OK);
713: }
714:
715:
716: /* ARGSUSED */
717: int
718: a1_30(pe) /*SPQ (Switch Profile Request) in 10B & 10N*/
719: PE pe;
720: {
721: /*Switch Profile not implemented.
722: Should send NAK to peer. */
723:
724: return(OK);
725: }
726:
727:
728: /* ARGSUSED */
729:
730: int
731: a1_100(pe) /*APQ (VT-P-ABORT -- Abort from VTPM) in any state*/
732: PE pe;
733: {
734: state = S1_01; /*For rigor*/
735: adios(NULLCP, "protocol abort -- association terminated");
736: }
737:
738:
739: /* ARGSUSED */
740:
741: int
742: a1_101(pe) /*AUQ (VT-U-ABORT -- Abort from VT User) in any state*/
743: PE pe;
744: {
745: state = S1_01;
746: adios(NULLCP,"user abort -- association terminated");
747: }
748:
749:
750:
751: /* ARGSUSED */
752: int
753: a1_102(pe) /*VUABreq (Abort by User) in any state*/
754: PE pe;
755: {
756:
757: PE pe_auq;
758: char *reason = "Association Closed by User";
759:
760: pe_auq = str2prim(reason,strlen(reason),PE_CLASS_CONT,AUQ_PDU);
761: if(pe_auq == NULLPE)
762: adios(NULLCP, "a1_102: AUQ build failure (out of memory)");
763: if(AcUAbortRequest(sd,&pe_auq,1,aci) == NOTOK)
764: acs_adios (&aci -> aci_abort, "A-ABORT.REQUEST");
765: state = S1_01;
766:
767: finalbye ();
768: exit(1);
769: }
770:
771:
772: /* ARGSUSED */
773: int
774: a1_103(pe) /*VTAB (Irrecoverable exception condition) in any state*/
775: PE pe;
776: {
777:
778: PE pe_apq;
779:
780: advise(LLOG_NOTICE,NULLCP, "Irrecoverable Exception Condition -- Aborting\n");
781: pe_apq = num2prim(1,PE_CLASS_CONT,APQ_PDU);
782: /*1 is value for Local Error. 0 if for Protocol
783: Error. Assume 1 for now. */
784: if(pe_apq == NULLPE)
785: adios(NULLCP,"a1_103: APQ build failure (out of memory)");
786: if(AcUAbortRequest(sd,&pe_apq,1,aci) == NOTOK)
787: acs_adios (&aci -> aci_abort, "A-ABORT.REQUEST");
788:
789: state = S1_01; /*For completeness*/
790:
791: finalbye ();
792: exit(1);
793: }
794:
795:
796: /* ARGSUSED */
797: int
798: a1_107(pe) /*Generic Action*/
799: PE pe;
800: {
801: /*Stay in this state*/
802: return(OK);
803: }
804:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.