/* rt2psrespond.c - RTPM: responder */
static char *rcsid
= "$Header: /f/osi/rtsap/RCS/rt2psrespond.c,v 7.4 91/02/22 09:42:22 mrose Interim $";
* $Header: /f/osi/rtsap/RCS/rt2psrespond.c,v 7.4 91/02/22 09:42:22 mrose Interim $
* $Log: rt2psrespond.c,v $
* Revision 7.4 91/02/22 09:42:22 mrose
* Revision 7.3 90/10/23 20:44:07 mrose
* Revision 7.2 90/07/27 08:47:50 mrose
* Revision 7.1 90/07/01 21:07:00 mrose
* Revision 6.0 89/03/18 23:43:13 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 RT-OPEN.INDICATION */
int RtInit_Aux (vecp
, vec
, rts
, rti
, dctx
)
struct RtSAPindication
*rti
;
register struct assocblk
*acb
;
register struct PSAPstart
*ps
;
register struct AcSAPstart
*acs
;
struct AcSAPindication acis
;
register struct AcSAPindication
*aci
= &acis
;
register struct AcSAPabort
*aca
= &aci
-> aci_abort
;
struct type_RTS_RTSE__apdus
*rtpdu
;
struct type_RTS_RTORQapdu
*prtorq
;
bzero ((char *) rts
, sizeof *rts
);
if (AcInit (vecp
, vec
, acs
, aci
) == NOTOK
)
return acs2rtslose (NULLACB
, rti
, "AcInit", aca
);
if ((acb
= findacblk (acs
-> acs_sd
)) == NULLACB
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
, "ACSE mangled");
acb
-> acb_flags
|= ACB_RTS
;
acb
-> acb_uabort
= AcUAbortRequest
;
acb
-> acb_connect
= ps
-> ps_connect
; /* struct copy */
if ((ps
-> ps_srequirements
&= RTS_MYREQUIRE
) != RTS_MYREQUIRE
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
,
"desired session requirements unavailable");
acb
-> acb_requirements
= ps
-> ps_srequirements
;
#define dotoken(requires,shift,bit,type) \
if (acb -> acb_requirements & requires) \
switch (ps -> ps_settings & (ST_MASK << shift)) { \
case ST_INIT_VALUE << shift: \
acb -> acb_avail |= bit; \
case ST_RESP_VALUE << shift: \
acb -> acb_owned |= bit; \
acb -> acb_avail |= bit; \
(void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, \
"%s token management botched", type); \
if (acb
-> acb_owned
!= 0 && acb
-> acb_owned
!= acb
-> acb_avail
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
,
"token management botched");
acb
-> acb_flags
|= ACB_TURN
;
acb
-> acb_settings
= ps
-> ps_settings
;
acb
-> acb_ssdusize
= ps
-> ps_ssdusize
;
if ((pe
= acs
-> acs_info
[0]) == NULLPE
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
, NULLCP
);
if (decode_RTS_RTSE__apdus (pe
, 1, NULLIP
, NULLVP
, &rtpdu
) == NOTOK
) {
PLOGP (rtsap_log
,RTS_RTORQapdu
, pe
, "RTORQapdu", 1);
if (rtpdu
-> offset
!= type_RTS_RTSE__apdus_rtorq__apdu
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
, "Unexpected PDU");
free_RTS_RTSE__apdus (rtpdu
);
prtorq
= rtpdu
-> un
.rtorq__apdu
;
acb
-> acb_ckpoint
= acb
-> acb_ssdusize
>> 10;
if ((0 < prtorq
-> checkpointSize
&& prtorq
-> checkpointSize
< acb
-> acb_ckpoint
)
|| acb
-> acb_ckpoint
<= 0)
acb
-> acb_ckpoint
= prtorq
-> checkpointSize
;
acb
-> acb_window
= prtorq
-> windowSize
;
register struct PSAPcontext
*pp
;
else if ((oid
= ode2oid (RT_ASN
)) == NULLOID
) {
(void) rtsaplose (rti
, RTS_PARAMETER
, NULLCP
,
free_RTS_RTSE__apdus(rtpdu
);
i
= ps
-> ps_ctxlist
.pc_nctx
- 1;
for (pp
= ps
-> ps_ctxlist
.pc_ctx
; i
>= 0; i
--, pp
++)
if (pp
-> pc_id
== ctx
) {
if (oid_cmp (pp
-> pc_asn
, oid
)) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
,
"wrong ASN for RTSE (%s)",
sprintoid (pp
-> pc_asn
));
free_RTS_RTSE__apdus(rtpdu
);
if (pp
-> pc_result
!= PC_ACCEPT
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
,
"PCI for RTSE not accepted");
free_RTS_RTSE__apdus(rtpdu
);
if (acb
-> acb_rtsid
== PE_DFLT_CTX
) {
(void) rtsaplose (rti
, RTS_PROTOCOL
, NULLCP
,
"unable to find PCI for RTSE");
free_RTS_RTSE__apdus(rtpdu
);
rts
-> rts_sd
= acb
-> acb_fd
;
if (prtorq
-> dialogueMode
== RTORQ_DM_TWA
)
rts
-> rts_mode
= RTS_TWA
, acb
-> acb_flags
|= ACB_TWA
;
rts
-> rts_mode
= RTS_MONOLOGUE
;
rts
-> rts_turn
= acb
-> acb_flags
& ACB_TURN
? RTS_RESPONDER
if (prtorq
-> connectionDataRQ
-> offset
== type_RTS_ConnectionData_open
) {
(void) pe_extract(pe
, rts
-> rts_data
= prtorq
-> connectionDataRQ
rts
-> rts_data
-> pe_refcnt
++;
for (i
= acs
-> acs_ninfo
- 1; i
>= 0; i
--)
if (acs
-> acs_info
[i
]) {
pe_free (acs
-> acs_info
[i
]);
acs
-> acs_info
[i
] = NULLPE
;
free_RTS_RTSE__apdus(rtpdu
);
if (dctx
) oid_free (dctx
);
/* XXX: should do RTORQ APDU, but can't give any useful info... */
(void) AcAssocResponse (acs
-> acs_sd
, ACS_TRANSIENT
, ACS_USER_NOREASON
,
NULLOID
, NULLAEI
, NULLPA
, &ps
-> ps_ctxlist
,
ps
-> ps_defctxresult
, 0, 0, SERIAL_NONE
, 0, &ps
-> ps_connect
,
if (dctx
) oid_free (dctx
);
/* \f RT-OPEN.RESPONSE */
int RtOpenResponse (sd
, status
, context
, respondtitle
, respondaddr
,
ctxlist
, defctxresult
, data
, rti
)
struct PSAPaddr
*respondaddr
;
struct PSAPctxlist
*ctxlist
;
struct RtSAPindication
*rti
;
register struct assocblk
*acb
;
struct AcSAPindication acis
;
register struct AcSAPindication
*aci
= &acis
;
register struct AcSAPabort
*aca
= &aci
-> aci_abort
;
if ((acb
= findacblk (sd
)) == NULL
|| (acb
-> acb_flags
& ACB_CONN
))
return rtsaplose (rti
, RTS_PARAMETER
, NULLCP
,
"invalid association descriptor");
if (!(acb
-> acb_flags
& ACB_ACS
) || !(acb
-> acb_flags
& ACB_RTS
))
return rtsaplose (rti
, RTS_OPERATION
, NULLCP
,
"not an association descritor for RTS");
if ((pe
= pe_alloc (PE_CLASS_UNIV
, PE_FORM_CONS
, PE_CONS_SET
))
(void) rtsaplose (rti
, RTS_CONGEST
, NULLCP
, "out of memory");
pe
-> pe_class
= PE_CLASS_CONT
; pe
-> pe_id
= 17;
if (set_add (pe
, num2prim ((integer
) acb
-> acb_ckpoint
,
PE_CLASS_CONT
, RTOAC_CKPOINT
)) == NOTOK
|| set_add (pe
, num2prim ((integer
) acb
-> acb_window
,
|| set_add (pe
, p
= pe_alloc (PE_CLASS_CONT
, PE_FORM_CONS
,
RTOAC_CONNDATA
)) == NOTOK
|| set_add (p
, q
= pe_alloc (PE_CLASS_CONT
, PE_FORM_CONS
,
|| set_add (q
, data
? data
: pe_alloc (PE_CLASS_UNIV
,
PE_FORM_PRIM
, PE_PRIM_NULL
)) == NOTOK
)
pe
-> pe_class
= PE_CLASS_CONT
; pe
-> pe_id
= 18;
if (set_add (pe
, p
= pe_alloc (PE_CLASS_CONT
, PE_FORM_CONS
,
RTORJ_USERDATA
)) == NOTOK
|| set_add (p
, data
? data
: pe_alloc (PE_CLASS_UNIV
,
PE_FORM_PRIM
, PE_PRIM_NULL
)) == NOTOK
)
register struct PSAPcontext
*pp
;
if (ctxlist
-> pc_nctx
> NPCTX
) {
(void) rtsaplose (rti
, RTS_PARAMETER
, NULLCP
, "too many contexts");
for (pp
= ctxlist
-> pc_ctx
, i
= ctxlist
-> pc_nctx
- 1;
if (acb
-> acb_rtsid
== pp
-> pc_id
) {
if (pp
-> pc_result
!= PC_ACCEPT
) {
(void) acsaplose (aci
, ACS_PARAMETER
, NULLCP
,
"PCI for RTSE not accepted");
pe
-> pe_context
= acb
-> acb_rtsid
;
if (rtsap_log
-> ll_events
& LLOG_PDUS
)
if (status
== ACS_ACCEPT
)
pvpdu (rtsap_log
, print_RTS_RTSE__apdus_P
, pe
, "RTOACapdu", 0);
pvpdu (rtsap_log
, print_RTS_RTSE__apdus_P
, pe
, "RTORJapdu", 0);
result
= AcAssocResponse (acb
-> acb_fd
, status
,
status
!= ACS_ACCEPT
? ACS_USER_NOREASON
: ACS_USER_NULL
,
context
, respondtitle
, respondaddr
, ctxlist
, defctxresult
, 0,
acb
-> acb_requirements
, SERIAL_NONE
, acb
-> acb_settings
,
&acb
-> acb_connect
, &pe
, 1, aci
);
(void) acs2rtslose (acb
, rti
, "AcAssocResponse", aca
);
if (ACS_FATAL (aca
-> aca_reason
))
(void) pe_extract (pe
, data
);
(void) AcAssocResponse (acb
-> acb_fd
, ACS_TRANSIENT
, ACS_USER_NOREASON
,
NULLOID
, NULLAEI
, NULLPA
, NULLPC
, PC_ACCEPT
, 0, 0, SERIAL_NONE
,
0, &acb
-> acb_connect
, NULLPEP
, 0, aci
);