/* psaprelease1.c - PPM: initiate release */
static char *rcsid
= "$Header: /f/osi/psap2-lpp/RCS/psaprelease1.c,v 7.3 91/02/22 09:38:09 mrose Interim $";
* $Header: /f/osi/psap2-lpp/RCS/psaprelease1.c,v 7.3 91/02/22 09:38:09 mrose Interim $
* Contributed by The Wollongong Group, Inc.
* $Log: psaprelease1.c,v $
* Revision 7.3 91/02/22 09:38:09 mrose
* Revision 7.2 90/07/01 21:05:28 mrose
* Revision 7.1 89/12/01 08:35:28 mrose
* Revision 7.0 89/11/23 22:15:56 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
/* \f P-RELEASE.REQUEST */
int PRelRequest (sd
, data
, ndata
, secs
, pr
, pi
)
struct PSAPindication
*pi
;
register struct psapblk
*pb
;
if (data
== NULL
|| ndata
<= 0 || data
[0] == NULLPE
|| ndata
> NPDATA_PS
)
return psaplose (pi
, PC_PARAMETER
, NULLCP
, "bad release user data");
if (data
[0] -> pe_context
!= PCI_ACSE
)
return psaplose (pi
, PC_PARAMETER
, NULLCP
,
"wrong context for release user data");
return psaplose (pi
, PC_PARAMETER
, NULLCP
,
"asynchronous release not supported");
if ((result
= PRelRequestAux (pb
, data
[0], pr
, pi
)) == DONE
)
(void) sigiomask (smask
);
static int PRelRequestAux (pb
, data
, pr
, pi
)
register struct psapblk
*pb
;
struct PSAPindication
*pi
;
struct type_PS_PDUs
*pdu
;
register struct type_PS_ReleaseRequest__PDU
*rr
;
if ((rr
= (struct type_PS_ReleaseRequest__PDU
*) malloc (sizeof *rr
))
result
= psaplose (pi
, PC_CONGEST
, NULLCP
, "out of memory");
rr
-> reference
= pb
-> pb_reliability
== LOW_QUALITY
? pb
-> pb_reference
result
= encode_PS_ReleaseRequest__PDU (&pb
-> pb_retry
, 1, 0, NULLCP
, rr
);
rr
-> user__data
= NULLPE
;
free_PS_ReleaseRequest__PDU (rr
);
(void) psaplose (pi
, PC_CONGEST
, NULLCP
, "error encoding PDU: %s",
switch (pb
-> pb_reliability
) {
PLOGP (psap2_log
,PS_PDUs
, pb
-> pb_retry
,
"ReleaseRequest-PDU", 0);
result
= pe2ps (ps
= pb
-> pb_stream
, pb
-> pb_retry
);
pe_free (pb
-> pb_retry
);
|| (pb
-> pb_response
= ps2pe (ps
)) == NULLPE
) {
result
= pslose (pi
, ps
-> ps_errno
);
pb
-> pb_tries
= pb
-> pb_maxtries
;
switch ((*pb
-> pb_retryfnx
) (pb
, PC_SESSION
, pi
)) {
result
= decode_PS_PDUs (pb
-> pb_response
, 1, NULLIP
, NULLVP
, &pdu
);
if (result
== OK
&& (psap2_log
-> ll_events
& LLOG_PDUS
))
pvpdu (psap2_log
, print_PS_PDUs_P
, pb
-> pb_response
, "PDU", 1);
if (pb
-> pb_reliability
== LOW_QUALITY
)
(void) ppktlose (pb
, pi
, PC_UNRECOGNIZED
, NULLRF
, NULLCP
,
"error decoding PDU: %s", PY_pepy
);
case type_PS_PDUs_releaseResponse
:
register struct type_PS_ReleaseResponse__PDU
*rp
=
pdu
-> un
.releaseResponse
;
if (pb
-> pb_reliability
== LOW_QUALITY
&& refcmp (pb
-> pb_reference
, rp
-> reference
)) {
(void) ppktlose (pb
, pi
, PC_SESSION
, rp
-> reference
,
NULLCP
, "reference mismatch");
pe
= rp
-> user__data
, rp
-> user__data
= NULLPE
;
pr
-> pr_affirmative
= 1;
(pr
-> pr_info
[0] = pe
) -> pe_context
= PCI_ACSE
;
register struct PSAPabort
*pa
= &pi
-> pi_abort
;
register struct type_PS_Abort__PDU
*ab
= pdu
-> un
.abort
;
if (pb
-> pb_reliability
== LOW_QUALITY
&& refcmp (pb
-> pb_reference
, ab
-> reference
))
switch (ab
-> reason
-> parm
) {
case int_PS_Abort__reason_reason__not__specified
:
result
= PC_NOTSPECIFIED
;
case int_PS_Abort__reason_unrecognized__ppdu
:
case int_PS_Abort__reason_unexpected__ppdu
:
case int_PS_Abort__reason_unrecognized__ppdu__parameter
:
- int_PS_Abort__reason_unrecognized__ppdu
);
case int_PS_Abort__reason_invalid__ppdu__parameter
:
case int_PS_Abort__reason_reference__mismatch
:
result
= psaplose (pi
, result
, NULLCP
, NULLCP
);
pe
= ab
-> user__data
, ab
-> user__data
= NULLPE
;
pi
-> pi_type
= PI_ABORT
;
bzero ((char *) pa
, sizeof *pa
);
pa
-> pa_reason
= PC_ABORTED
;
(pa
-> pa_info
[0] = pe
) -> pe_context
= PCI_ACSE
;
/* this works 'cause the "reference" is always the FIRST element */
result
= ppktlose (pb
, pi
, PC_SESSION
,
pdu
-> un
.connectResponse
-> reference
, NULLCP
,
"unexpected PDU %d", pdu
-> offset
);
free_PS_ReleaseRequest__PDU (rr
);
int PRelRetryRequest (sd
, secs
, pr
, pi
)
struct PSAPindication
*pi
;
return psaplose (pi
, PC_OPERATION
, "release not in progress");