|
|
1.1 root 1: /* acsapreleas2.c - ACPM: respond to release */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/acsap/RCS/acsapreleas2.c,v 7.1 90/07/01 21:02:04 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/acsap/RCS/acsapreleas2.c,v 7.1 90/07/01 21:02:04 mrose Exp $
9: *
10: *
11: * $Log: acsapreleas2.c,v $
12: * Revision 7.1 90/07/01 21:02:04 mrose
13: * pepsy
14: *
15: * Revision 7.0 89/11/23 21:21:55 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 "ACS-types.h"
36: #define ACSE
37: #include "acpkt.h"
38: #include "tailor.h"
39:
40: /* A-RELEASE.RESPONSE */
41:
42: int AcRelResponse (sd, status, reason, data, ndata, aci)
43: int sd;
44: int status,
45: reason;
46: PE *data;
47: int ndata;
48: struct AcSAPindication *aci;
49: {
50: SBV smask;
51: int code,
52: result;
53: register struct assocblk *acb;
54: PE pe;
55: struct PSAPindication pis;
56: register struct PSAPabort *pa = &pis.pi_abort;
57: register struct type_ACS_RLRE__apdu *pdu;
58:
59: switch (status) {
60: case ACS_ACCEPT:
61: code = SC_ACCEPT;
62: break;
63:
64: case ACS_REJECT:
65: code = SC_REJECTED;
66: break;
67:
68: default:
69: return acsaplose (aci, ACS_PARAMETER, NULLCP,
70: "invalid value for status parameter");
71: }
72: switch (reason) {
73: case ACR_NORMAL:
74: case ACR_NOTFINISHED:
75: case ACR_USERDEFINED:
76: break;
77:
78: default:
79: return acsaplose (aci, ACS_PARAMETER, NULLCP,
80: "invalid value for reason parameter");
81: }
82: toomuchP (data, ndata, NACDATA, "release");
83: if (data) { /* XXX: probably should have a more intensive check... */
84: register int i;
85: register PE *pep;
86:
87: for (pep = data, i = ndata; i > 0; pep++, i--)
88: if ((*pep) -> pe_context == PE_DFLT_CTX)
89: return acsaplose (aci, ACS_PARAMETER, NULLCP,
90: "default context not allowed for user-data at slot %d",
91: pep - data);
92: }
93: missingP (aci);
94:
95: smask = sigioblock ();
96:
97: acsapFsig (acb, sd);
98:
99: pe = NULLPE;
100: if ((pdu = (struct type_ACS_RLRE__apdu *) calloc (1, sizeof *pdu))
101: == NULL) {
102: (void) acsaplose (aci, ACS_CONGEST, NULLCP, "out of memory");
103: goto out2;
104: }
105: pdu -> optionals |= opt_ACS_RLRE__apdu_reason;
106: pdu -> reason = reason;
107: if (data
108: && ndata > 0
109: && (pdu -> user__information = info2apdu (acb, aci, data, ndata))
110: == NULL)
111: goto out2;
112:
113: result = encode_ACS_RLRE__apdu (&pe, 1, 0, NULLCP, pdu);
114:
115: free_ACS_RLRE__apdu (pdu);
116: pdu = NULL;
117:
118: if (result == NOTOK) {
119: (void) acsaplose (aci, ACS_CONGEST, NULLCP, "error encoding PDU: %s",
120: PY_pepy);
121: goto out2;
122: }
123: pe -> pe_context = acb -> acb_id;
124:
125: PLOGP (acsap_log,ACS_ACSE__apdu, pe, "RLRE-apdu", 0);
126:
127: if ((result = PRelResponse (acb -> acb_fd, code, &pe, 1, &pis)) == NOTOK) {
128: (void) ps2acslose (acb, aci, "PRelResponse", pa);
129: if (PC_FATAL (pa -> pa_reason))
130: goto out2;
131: else
132: goto out1;
133: }
134:
135: if (status == ACS_ACCEPT)
136: acb -> acb_fd = NOTOK;
137: else
138: acb -> acb_flags &= ~ACB_FINN;
139:
140: result = OK;
141:
142: out2: ;
143: if (result == NOTOK || status == ACS_ACCEPT)
144: freeacblk (acb);
145: out1: ;
146: if (pe)
147: pe_free (pe);
148: if (pdu)
149: free_ACS_RLRE__apdu (pdu);
150:
151: (void) sigiomask (smask);
152:
153: return result;
154: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.