|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T r
Length: 9653 (0x25b5)
Types: TextFile
Names: »rt2psinitiat.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/rtsap/rt2psinitiat.c«
/* rt2psinitiat.c - RTPM: initiator */
#ifndef lint
static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2psinitiat.c,v 7.0 89/11/23 22:22:21 mrose Rel $";
#endif
/*
* $Header: /f/osi/rtsap/RCS/rt2psinitiat.c,v 7.0 89/11/23 22:22:21 mrose Rel $
*
*
* $Log: rt2psinitiat.c,v $
* Revision 7.0 89/11/23 22:22:21 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* 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
* this agreement.
*
*/
/* LINTLIBRARY */
#include <stdio.h>
#include <signal.h>
#include "rtpkt.h"
#include "tailor.h"
/* \f
RT-OPEN.REQUEST */
int RtOpenRequest (mode, turn, context, callingtitle, calledtitle,
callingaddr, calledaddr, ctxlist, defctxname, data, qos,
rtc, rti)
int mode,
turn;
OID context;
AEI callingtitle,
calledtitle;
struct PSAPaddr *callingaddr,
*calledaddr;
struct PSAPctxlist *ctxlist;
OID defctxname;
PE data;
struct QOStype *qos;
struct RtSAPconnect *rtc;
struct RtSAPindication *rti;
{
SBV smask;
int result;
isodetailor (NULLCP, 0);
switch (mode) {
case RTS_MONOLOGUE:
case RTS_TWA:
break;
default:
return rtsaplose (rti, RTS_PARAMETER, NULLCP,
"bad value for mode parameter");
}
switch (turn) {
case RTS_INITIATOR:
case RTS_RESPONDER:
break;
default:
return rtsaplose (rti, RTS_PARAMETER, NULLCP,
"bad value for turn parameter");
}
if (!ctxlist) {
static struct PSAPctxlist ctxs;
ctxlist = &ctxs;
bzero ((char *) ctxlist, sizeof *ctxlist);
}
missingP (rtc);
bzero ((char *) rtc, sizeof *rtc);
missingP (rti);
smask = sigioblock ();
result = RtOpenRequestAux (mode, turn, context, callingtitle, calledtitle,
callingaddr, calledaddr, ctxlist, defctxname, data, qos, rtc, rti);
(void) sigiomask (smask);
return result;
}
/* \f
*/
static int RtOpenRequestAux (mode, turn, context, callingtitle, calledtitle,
callingaddr, calledaddr, ctxlist, defctxname, data, qos,
rtc, rti)
int mode,
turn;
OID context;
AEI callingtitle,
calledtitle;
struct PSAPaddr *callingaddr,
*calledaddr;
struct PSAPctxlist *ctxlist;
OID defctxname;
PE data;
struct QOStype *qos;
struct RtSAPconnect *rtc;
struct RtSAPindication *rti;
{
register int i;
int result,
requirements,
offset,
rtsid,
settings;
PE pe,
p,
q;
register struct assocblk *acb;
struct SSAPref *sr;
register struct PSAPcontext *pp;
register struct AcSAPconnect *acc = &rtc -> rtc_connect;
register struct PSAPconnect *pc = &acc -> acc_connect;
struct AcSAPindication acis;
register struct AcSAPindication *aci = &acis;
register struct AcSAPabort *aca = &aci -> aci_abort;
/* begin RTORQ APDU */
if ((pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET)) == NULLPE) {
no_mem: ;
result = rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
goto out1;
}
if ((DEFAULT_CKPOINT != PCONN_CK_DFLT
&& set_add (pe, num2prim (DEFAULT_CKPOINT, PE_CLASS_CONT,
RTORQ_CKPOINT)) == NOTOK)
|| (DEFAULT_WINDOW != PCONN_WD_DFLT
&& set_add (pe, num2prim (DEFAULT_WINDOW,
PE_CLASS_CONT, RTORQ_WINDOW))
== NOTOK)
|| set_add (pe, num2prim (mode == RTS_TWA ? RTORQ_DM_TWA
: RTORQ_DM_MONO, PE_CLASS_CONT, RTORQ_DIALOGUE))
== NOTOK
|| set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
RTORQ_CONNDATA)) == NOTOK
|| set_add (p, q = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
RTORQ_CD_OPEN)) == NOTOK
|| set_add (q, data ? data : pe_alloc (PE_CLASS_CONT,
PE_FORM_PRIM, 0)) == NOTOK)
goto no_mem;
/* end RTORQ APDU */
requirements = RTS_MYREQUIRE;
settings = 0;
#define dotoken(requires,shift,bit,type) \
{ \
if (requirements & requires) \
if (turn == RTS_INITIATOR) \
settings |= ST_INIT_VALUE << shift; \
else \
settings |= ST_RESP_VALUE << shift; \
}
dotokens ();
#undef dotoken
if ((sr = addr2ref (PLocalHostName ())) == NULL) {
result = rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
goto out1;
}
if (ctxlist -> pc_nctx >= NPCTX) {
result = rtsaplose (rti, RTS_PARAMETER, NULLCP,
"too many contexts");
goto out1;
}
{
register int ctx;
register OID oid;
if ((oid = ode2oid (RT_ASN)) == NULLOID) {
result = rtsaplose (rti, RTS_PARAMETER, NULLCP,
"%s: unknown", RT_ASN);
goto out1;
}
i = ctxlist -> pc_nctx - 1, ctx = 1;
for (pp = ctxlist -> pc_ctx; i >= 0; i--, pp++) {
if (oid_cmp (pp -> pc_asn, oid) == 0) {
rtsid = pp -> pc_id;
offset = pp - ctxlist -> pc_ctx;
pp = NULL;
goto ready;
}
if (ctx <= pp -> pc_id)
ctx = pp -> pc_id + 2;
}
pp -> pc_id = ctx;
if ((pp -> pc_asn = oid_cpy (oid)) == NULLOID)
goto no_mem;
pp -> pc_atn = NULLOID;
rtsid = pp -> pc_id;
offset = -1;
ctxlist -> pc_nctx++;
}
ready: ;
pe -> pe_context = rtsid;
PLOG (rtsap_log, print_RTS_RTORQapdu, pe, "RTORQapdu", 0);
result = AcAssocRequest (context, callingtitle, calledtitle, callingaddr,
calledaddr, ctxlist, defctxname, 0, requirements,
SERIAL_NONE, settings, sr, &pe, 1, qos, acc, aci);
if (pp) {
oid_free (pp -> pc_asn);
pp -> pc_asn = NULLOID;
}
if (data)
(void) pe_extract (pe, data);
pe_free (pe);
pe = NULLPE;
if (result == NOTOK) {
(void) acs2rtslose (NULLACB, rti, "AcAssocRequest", aca);
goto out1;
}
if (acc -> acc_result == ACS_ACCEPT) {
if ((acb = findacblk (acc -> acc_sd)) == NULLACB) {
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, "ACSE mangled");
goto out2;
}
}
else
if (acc -> acc_result == ACS_ABORTED) {
(void) acs2rtsabort (acb, aca, rti);
rtc -> rtc_sd = NOTOK;
rtc -> rtc_result = RTS_ABORTED;
result = OK;
goto out2;
}
else
acb = NULLACB;
if ((pe = acc -> acc_info[0]) == NULLPE) {
if (acc -> acc_result != ACS_ACCEPT) {
aca -> aca_reason = acc -> acc_result;
(void) acs2rtslose (acb, rti, "AcAssocRequest(pseudo)", aca);
rtc -> rtc_sd = NOTOK;
rtc -> rtc_result = rti -> rti_abort.rta_reason;
result = OK;
}
else
if (acb)
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, NULLCP);
else
result = rtsaplose (rti, RTS_PROTOCOL, NULLCP, NULLCP);
goto out2;
}
if (acc -> acc_result != ACS_ACCEPT) {
acsap_data = NULLPE;
if (parse_RTS_RTORJapdu (pe, 1, NULLIP, NULLVP, NULLCP) == NOTOK) {
result = pylose ();
goto out2;
}
PLOG (rtsap_log, print_RTS_RTORJapdu, pe, "RTORJapdu", 1);
rtc -> rtc_sd = NOTOK;
rtc -> rtc_result = RTS_REJECT;
(void) pe_extract (pe, rtc -> rtc_data = acsap_data);
for (i = acc -> acc_ninfo - 1; i >= 0; i--)
if (acc -> acc_info[i]) {
pe_free (acc -> acc_info[i]);
acc -> acc_info[i] = NULLPE;
}
acc -> acc_ninfo = 0;
return OK;
}
acb -> acb_flags |= ACB_RTS | ACB_INIT;
acb -> acb_uabort = AcUAbortRequest;
SetPS2RtService (acb);
if (turn == RTS_INITIATOR)
acb -> acb_flags |= ACB_TURN;
if (mode == RTS_TWA)
acb -> acb_flags |= ACB_TWA;
acb -> acb_connect = *sr; /* struct copy */
if ((acb -> acb_requirements = pc -> pc_srequirements) != RTS_MYREQUIRE) {
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
"desired session requirements denied");
goto out2;
}
#define dotoken(requires,shift,bit,type) \
{ \
if (acb -> acb_requirements & requires) \
switch (pc -> pc_settings & (ST_MASK << shift)) { \
case ST_INIT_VALUE << shift: \
acb -> acb_owned |= bit; \
acb -> acb_avail |= bit; \
break; \
\
case ST_RESP_VALUE << shift: \
acb -> acb_avail |= bit; \
break; \
\
default: \
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, \
"%s token management botched", type); \
goto out2; \
} \
}
dotokens ();
#undef dotoken
switch (turn) {
case RTS_INITIATOR:
if (acb -> acb_owned == acb -> acb_avail)
break;
result = rtsaplose (rti, RTS_PROTOCOL, NULLCP,
"token management botched");
goto out2;
case RTS_RESPONDER:
if (acb -> acb_owned == 0)
break;
result = rtsaplose (rti, RTS_PROTOCOL, NULLCP,
"token management botched");
goto out2;
}
acb -> acb_ssdusize = pc -> pc_ssdusize;
acsap_ckpoint = RTOAC_CK_DFLT, acsap_window = RTOAC_WD_DFLT;
acsap_data = NULLPE;
if (parse_RTS_RTOACapdu (pe, 1, NULLIP, NULLVP, NULLCP) == NOTOK) {
result = pylose ();
goto out2;
}
PLOG (rtsap_log, print_RTS_RTOACapdu, pe, "RTOACapdu", 1);
acb -> acb_ckpoint = acsap_ckpoint;
acb -> acb_window = acsap_window;
if ((i = offset) < 0)
i = pc -> pc_ctxlist.pc_nctx - 1;
pp = pc -> pc_ctxlist.pc_ctx + i;
if (pp -> pc_id != rtsid) {
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
"RTSE PCI not found");
goto out2;
}
if (pp -> pc_result != PC_ACCEPT) {
result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
"RTSE PCI rejected");
goto out2;
}
if (offset < 0)
pc -> pc_ctxlist.pc_nctx--;
acb -> acb_rtsid = rtsid;
rtc -> rtc_sd = acb -> acb_fd;
rtc -> rtc_result = RTS_ACCEPT;
(void) pe_extract (pe, rtc -> rtc_data = acsap_data);
for (i = acc -> acc_ninfo - 1; i >= 0; i--)
if (acc -> acc_info[i]) {
pe_free (acc -> acc_info[i]);
acc -> acc_info[i] = NULLPE;
}
acc -> acc_ninfo = 0;
return OK;
out2: ;
ACCFREE (acc);
if (acb)
freeacblk (acb);
out1: ;
if (pe) {
if (data)
(void) pe_extract (pe, data);
pe_free (pe);
}
return result;
}