Commit | Line | Data |
---|---|---|
9e8e5516 C |
1 | /* rt2ssreleas1.c - RTPM: initiate release */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2ssreleas1.c,v 7.1 91/02/22 09:42:31 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/rtsap/RCS/rt2ssreleas1.c,v 7.1 91/02/22 09:42:31 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: rt2ssreleas1.c,v $ | |
12 | * Revision 7.1 91/02/22 09:42:31 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 6.0 89/03/18 23:43:21 mrose | |
16 | * Release 5.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 | /* LINTLIBRARY */ | |
32 | ||
33 | #include <stdio.h> | |
34 | #include <signal.h> | |
35 | #include "rtpkt.h" | |
36 | ||
37 | /* \f RT-END.REQUEST (X.410 CLOSE.REQUEST) */ | |
38 | ||
39 | int RtEndRequest (sd, rti) | |
40 | int sd; | |
41 | struct RtSAPindication *rti; | |
42 | { | |
43 | SBV smask; | |
44 | int result; | |
45 | register struct assocblk *acb; | |
46 | ||
47 | missingP (rti); | |
48 | ||
49 | smask = sigioblock (); | |
50 | ||
51 | rtsapPsig (acb, sd); | |
52 | ||
53 | result = RtEndRequestAux (acb, rti); | |
54 | ||
55 | (void) sigiomask (smask); | |
56 | ||
57 | return result; | |
58 | } | |
59 | ||
60 | /* \f */ | |
61 | ||
62 | static int RtEndRequestAux (acb, rti) | |
63 | register struct assocblk *acb; | |
64 | struct RtSAPindication *rti; | |
65 | { | |
66 | int result; | |
67 | struct SSAPindication sis; | |
68 | register struct SSAPindication *si = &sis; | |
69 | register struct SSAPabort *sa = &si -> si_abort; | |
70 | struct SSAPrelease srs; | |
71 | register struct SSAPrelease *sr = &srs; | |
72 | ||
73 | if (acb -> acb_flags & ACB_ACS) | |
74 | return rtsaplose (rti, RTS_OPERATION, NULLCP, | |
75 | "not an association descriptor for RTS"); | |
76 | if (!(acb -> acb_flags & ACB_INIT) && (acb -> acb_flags & ACB_TWA)) | |
77 | return rtsaplose (rti, RTS_OPERATION, NULLCP, "not initiator"); | |
78 | if (!(acb -> acb_flags & ACB_TURN)) | |
79 | return rtsaplose (rti, RTS_OPERATION, NULLCP, "turn not owned by you"); | |
80 | if (acb -> acb_flags & ACB_ACT) | |
81 | return rtsaplose (rti, RTS_OPERATION, NULLCP, "transfer in progress"); | |
82 | if (acb -> acb_flags & ACB_PLEASE) | |
83 | return rtsaplose (rti, RTS_WAITING, NULLCP, NULLCP); | |
84 | ||
85 | if (SRelRequest (acb -> acb_fd, NULLCP, 0, NOTOK, sr, si) == NOTOK) { | |
86 | if (sa -> sa_peer) | |
87 | return ss2rtsabort (acb, sa, rti); | |
88 | ||
89 | result = ss2rtslose (acb, rti, "SRelRequest", sa); | |
90 | } | |
91 | else | |
92 | if (!sr -> sr_affirmative) | |
93 | result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, | |
94 | "other side refused to release connection"); | |
95 | else { | |
96 | acb -> acb_fd = NOTOK; | |
97 | result = OK; | |
98 | } | |
99 | ||
100 | acb -> acb_flags &= ~ACB_STICKY; | |
101 | freeacblk (acb); | |
102 | ||
103 | return result; | |
104 | } |