Commit | Line | Data |
---|---|---|
9319b3c3 C |
1 | /* ssaprelease2.c - SPM: respond to release */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/ssap/RCS/ssaprelease2.c,v 7.1 91/02/22 09:45:57 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/ssap/RCS/ssaprelease2.c,v 7.1 91/02/22 09:45:57 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: ssaprelease2.c,v $ | |
12 | * Revision 7.1 91/02/22 09:45:57 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.0 89/11/23 22:25:36 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 | /* LINTLIBRARY */ | |
32 | ||
33 | #include <stdio.h> | |
34 | #include <signal.h> | |
35 | #include "spkt.h" | |
36 | ||
37 | /* \f S-RELEASE.RESPONSE */ | |
38 | ||
39 | int SRelResponse (sd, status, data, cc, si) | |
40 | int sd; | |
41 | int status, | |
42 | cc; | |
43 | char *data; | |
44 | struct SSAPindication *si; | |
45 | { | |
46 | SBV smask; | |
47 | int result; | |
48 | register struct ssapblk *sb; | |
49 | ||
50 | missingP (si); | |
51 | ||
52 | smask = sigioblock (); | |
53 | ||
54 | ssapFsig (sb, sd); | |
55 | toomuchP (sb, data, cc, SR_SIZE, "release"); | |
56 | ||
57 | result = SRelResponseAux (sb, status, data, cc, si); | |
58 | ||
59 | (void) sigiomask (smask); | |
60 | ||
61 | return result; | |
62 | } | |
63 | ||
64 | /* \f S-RELEASE.RESPONSE */ | |
65 | ||
66 | static int SRelResponseAux (sb, status, data, cc, si) | |
67 | register struct ssapblk *sb; | |
68 | int status, | |
69 | cc; | |
70 | char *data; | |
71 | struct SSAPindication *si; | |
72 | { | |
73 | int code, | |
74 | result; | |
75 | register struct ssapkt *s; | |
76 | ||
77 | switch (status) { | |
78 | case SC_ACCEPT: | |
79 | code = SPDU_DN; | |
80 | break; | |
81 | ||
82 | case SC_REJECTED: | |
83 | if (!(sb -> sb_requirements & SR_NEGOTIATED)) | |
84 | return ssaplose (si, SC_OPERATION, NULLCP, | |
85 | "negotiated release service unavailable"); | |
86 | if (!(sb -> sb_requirements & SR_RLS_EXISTS)) | |
87 | return ssaplose (si, SC_OPERATION, NULLCP, | |
88 | "release token unavailable"); | |
89 | if (sb -> sb_owned & ST_RLS_TOKEN) | |
90 | return ssaplose (si, SC_OPERATION, NULLCP, | |
91 | "release token owned by you"); | |
92 | ||
93 | code = SPDU_NF; | |
94 | break; | |
95 | ||
96 | default: | |
97 | return ssaplose (si, SC_PARAMETER, NULLCP, | |
98 | "invalid value for status parameter"); | |
99 | } | |
100 | ||
101 | if ((s = newspkt (code)) == NULL) | |
102 | return ssaplose (si, SC_CONGEST, NULLCP, "out of memory"); | |
103 | ||
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 | result = spkt2sd (s, sb -> sb_fd, 0, si); | |
111 | s -> s_mask &= ~SMASK_UDATA_PGI; | |
112 | s -> s_udata = NULL, s -> s_ulen = 0; | |
113 | ||
114 | freespkt (s); | |
115 | if (result == NOTOK || code == SPDU_DN) | |
116 | freesblk (sb); | |
117 | else | |
118 | sb -> sb_flags &= ~SB_FINN; | |
119 | ||
120 | return result; | |
121 | } |