Annotation of 43BSDReno/contrib/isode-beta/rtsap/rt2psrespond.c, revision 1.1

1.1     ! root        1: /* rt2psrespond.c - RTPM: responder */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2psrespond.c,v 7.2 90/07/27 08:47:50 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/rtsap/RCS/rt2psrespond.c,v 7.2 90/07/27 08:47:50 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       rt2psrespond.c,v $
        !            12:  * Revision 7.2  90/07/27  08:47:50  mrose
        !            13:  * update
        !            14:  * 
        !            15:  * Revision 7.1  90/07/01  21:07:00  mrose
        !            16:  * pepsy
        !            17:  * 
        !            18:  * Revision 6.0  89/03/18  23:43:13  mrose
        !            19:  * Release 5.0
        !            20:  * 
        !            21:  */
        !            22: 
        !            23: /*
        !            24:  *                               NOTICE
        !            25:  *
        !            26:  *    Acquisition, use, and distribution of this module and related
        !            27:  *    materials are subject to the restrictions of a license agreement.
        !            28:  *    Consult the Preface in the User's Manual for the full terms of
        !            29:  *    this agreement.
        !            30:  *
        !            31:  */
        !            32: 
        !            33: 
        !            34: /* LINTLIBRARY */
        !            35: 
        !            36: #include <stdio.h>
        !            37: #include "RTS-types.h"
        !            38: #include "rtpkt.h"
        !            39: #include "tailor.h"
        !            40: 
        !            41: /*    RT-OPEN.INDICATION */
        !            42: 
        !            43: int    RtInit_Aux (vecp, vec, rts, rti, dctx)
        !            44: int    vecp;
        !            45: char  **vec;
        !            46: struct RtSAPstart *rts;
        !            47: struct RtSAPindication *rti;
        !            48: OID    dctx;
        !            49: {
        !            50:     int            ctx,
        !            51:            i;
        !            52:     register PE            pe;
        !            53:     register struct assocblk   *acb;
        !            54:     register struct PSAPstart *ps;
        !            55:     register struct AcSAPstart *acs;
        !            56:     struct AcSAPindication  acis;
        !            57:     register struct AcSAPindication  *aci = &acis;
        !            58:     register struct AcSAPabort *aca = &aci -> aci_abort;
        !            59:     struct type_RTS_RTSE__apdus *rtpdu;
        !            60:     struct type_RTS_RTORQapdu *prtorq;
        !            61: 
        !            62:     isodetailor (NULLCP, 0);
        !            63: 
        !            64:     missingP (vec);
        !            65:     missingP (rts);
        !            66:     missingP (rti);
        !            67: 
        !            68:     acs = &rts -> rts_start;
        !            69:     ps = &acs -> acs_start;
        !            70: 
        !            71:     bzero ((char *) rts, sizeof *rts);
        !            72: 
        !            73:     if (AcInit (vecp, vec, acs, aci) == NOTOK)
        !            74:        return acs2rtslose (NULLACB, rti, "AcInit", aca);
        !            75:     if ((acb = findacblk (acs -> acs_sd)) == NULLACB) {
        !            76:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, "ACSE mangled");
        !            77:        goto out;
        !            78:     }
        !            79:     acb -> acb_flags |= ACB_RTS;
        !            80:     acb -> acb_uabort = AcUAbortRequest;
        !            81:     SetPS2RtService (acb);
        !            82: 
        !            83:     acb -> acb_connect = ps -> ps_connect;     /* struct copy */
        !            84:     if ((ps -> ps_srequirements &= RTS_MYREQUIRE) != RTS_MYREQUIRE) {
        !            85:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
        !            86:                    "desired session requirements unavailable");
        !            87:        goto out;
        !            88:     }
        !            89:     acb -> acb_requirements = ps -> ps_srequirements;
        !            90: 
        !            91: #define dotoken(requires,shift,bit,type) \
        !            92: { \
        !            93:     if (acb -> acb_requirements & requires) \
        !            94:        switch (ps -> ps_settings & (ST_MASK << shift)) { \
        !            95:            case ST_INIT_VALUE << shift: \
        !            96:                acb -> acb_avail |= bit; \
        !            97:                break; \
        !            98:  \
        !            99:            case ST_RESP_VALUE << shift: \
        !           100:                acb -> acb_owned |= bit; \
        !           101:                acb -> acb_avail |= bit; \
        !           102:                break; \
        !           103:  \
        !           104:            default: \
        !           105:                (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, \
        !           106:                            "%s token management botched", type); \
        !           107:                goto out; \
        !           108:        } \
        !           109:     }
        !           110:     dotokens ();
        !           111: #undef dotoken
        !           112:     if (acb -> acb_owned != 0 && acb -> acb_owned != acb -> acb_avail) {
        !           113:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
        !           114:                "token management botched");
        !           115:        goto out;
        !           116:     }
        !           117:     if (acb -> acb_owned)
        !           118:        acb -> acb_flags |= ACB_TURN;
        !           119:     acb -> acb_settings = ps -> ps_settings;
        !           120:     acb -> acb_ssdusize = ps -> ps_ssdusize;
        !           121: 
        !           122:     if ((pe = acs -> acs_info[0]) == NULLPE) {
        !           123:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, NULLCP);
        !           124:        goto out;
        !           125:     }
        !           126:     if (decode_RTS_RTSE__apdus (pe, 1, NULLIP, NULLVP, &rtpdu) == NOTOK) {
        !           127:        (void) pylose ();
        !           128:        goto out;
        !           129:     }
        !           130: 
        !           131:     PLOGP (rtsap_log,RTS_RTORQapdu, pe, "RTORQapdu", 1);
        !           132: 
        !           133:     if (rtpdu -> offset != type_RTS_RTSE__apdus_rtorq__apdu) {
        !           134:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, "Unexpected PDU");
        !           135:        free_RTS_RTSE__apdus (rtpdu);
        !           136:        goto out;
        !           137:     }
        !           138: 
        !           139:     prtorq = rtpdu -> un.rtorq__apdu;
        !           140:     acb -> acb_ckpoint = acb -> acb_ssdusize >> 10;
        !           141:     if ((0 < prtorq -> checkpointSize
        !           142:                && prtorq -> checkpointSize < acb -> acb_ckpoint)
        !           143:            || acb -> acb_ckpoint <= 0)
        !           144:        acb -> acb_ckpoint = prtorq -> checkpointSize;
        !           145:     acb -> acb_window = prtorq -> windowSize;
        !           146: 
        !           147:     ctx = pe -> pe_context;
        !           148: 
        !           149:     {
        !           150:        register OID    oid;
        !           151:        register struct PSAPcontext *pp;
        !           152: 
        !           153:        if (dctx)
        !           154:            oid = dctx;
        !           155:        else if ((oid = ode2oid (RT_ASN)) == NULLOID) {
        !           156:            (void) rtsaplose (rti, RTS_PARAMETER, NULLCP,
        !           157:                              "%s: unknown", RT_ASN);
        !           158:            free_RTS_RTSE__apdus(rtpdu);
        !           159:            goto out;
        !           160:        }
        !           161: 
        !           162:        i = ps -> ps_ctxlist.pc_nctx - 1;
        !           163:        for (pp = ps -> ps_ctxlist.pc_ctx; i >= 0; i--, pp++)
        !           164:            if (pp -> pc_id == ctx) {
        !           165:                if (oid_cmp (pp -> pc_asn, oid)) {
        !           166:                    (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
        !           167:                                      "wrong ASN for RTSE (%s)",
        !           168:                                      sprintoid (pp -> pc_asn));
        !           169:                    free_RTS_RTSE__apdus(rtpdu);
        !           170:                    goto out;
        !           171:                }
        !           172:                if (pp -> pc_result != PC_ACCEPT) {
        !           173:                    (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
        !           174:                                      "PCI for RTSE not accepted");
        !           175:                    free_RTS_RTSE__apdus(rtpdu);
        !           176:                    goto out;
        !           177:                }
        !           178: 
        !           179:                acb -> acb_rtsid = ctx;
        !           180:            }
        !           181: 
        !           182:        if (acb -> acb_rtsid == PE_DFLT_CTX) {
        !           183:            (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
        !           184:                              "unable to find PCI for RTSE");
        !           185:            free_RTS_RTSE__apdus(rtpdu);
        !           186:            goto out;
        !           187:        }
        !           188:     }
        !           189: 
        !           190:     rts -> rts_sd = acb -> acb_fd;
        !           191:     if (prtorq -> dialogueMode == RTORQ_DM_TWA)
        !           192:        rts -> rts_mode = RTS_TWA, acb -> acb_flags |= ACB_TWA;
        !           193:     else
        !           194:        rts -> rts_mode = RTS_MONOLOGUE;
        !           195:     rts -> rts_turn = acb -> acb_flags & ACB_TURN ? RTS_RESPONDER
        !           196:            : RTS_INITIATOR;
        !           197:     if (prtorq -> connectionDataRQ -> offset == type_RTS_ConnectionData_open)
        !           198:        (void) pe_extract(pe, rts -> rts_data = prtorq -> connectionDataRQ
        !           199:                                                       -> un.open);
        !           200:     else
        !           201:        pe = NULLPE;
        !           202: 
        !           203:     for (i = acs -> acs_ninfo - 1; i >= 0; i--) 
        !           204:        if (acs -> acs_info[i]) {
        !           205:            pe_free (acs -> acs_info[i]);
        !           206:            acs -> acs_info[i] = NULLPE;
        !           207:        }
        !           208:     acs -> acs_ninfo = 0;
        !           209: 
        !           210:     free_RTS_RTSE__apdus(rtpdu);
        !           211:     if (dctx) oid_free (dctx);
        !           212:     return OK;
        !           213: 
        !           214: out: ;
        !           215: /* XXX: should do RTORQ APDU, but can't give any useful info... */
        !           216:     (void) AcAssocResponse (acs -> acs_sd, ACS_TRANSIENT, ACS_USER_NOREASON,
        !           217:                NULLOID, NULLAEI, NULLPA, &ps -> ps_ctxlist,
        !           218:                ps -> ps_defctxresult, 0, 0, SERIAL_NONE, 0, &ps -> ps_connect,
        !           219:                NULLPEP, 0, aci);
        !           220: 
        !           221:     ACSFREE (acs);
        !           222:     if (dctx) oid_free (dctx);
        !           223:     return NOTOK;    
        !           224: }
        !           225: 
        !           226: /*    RT-OPEN.RESPONSE */
        !           227: 
        !           228: int    RtOpenResponse (sd, status, context, respondtitle, respondaddr,
        !           229:        ctxlist, defctxresult, data, rti)
        !           230: int    sd,
        !           231:        status;
        !           232: AEI    respondtitle;
        !           233: OID    context;
        !           234: struct PSAPaddr *respondaddr;
        !           235: struct PSAPctxlist *ctxlist;
        !           236: int    defctxresult;
        !           237: PE     data;
        !           238: struct RtSAPindication *rti;
        !           239: {
        !           240:     int            result;
        !           241:     PE     pe,
        !           242:            p,
        !           243:            q;
        !           244:     register struct assocblk   *acb;
        !           245:     struct AcSAPindication acis;
        !           246:     register struct AcSAPindication *aci = &acis;
        !           247:     register struct AcSAPabort *aca = &aci -> aci_abort;
        !           248: 
        !           249:     if ((acb = findacblk (sd)) == NULL || (acb -> acb_flags & ACB_CONN))
        !           250:        return rtsaplose (rti, RTS_PARAMETER, NULLCP,
        !           251:                "invalid association descriptor");
        !           252:     if (!(acb -> acb_flags & ACB_ACS) || !(acb -> acb_flags & ACB_RTS))
        !           253:        return rtsaplose (rti, RTS_OPERATION, NULLCP,
        !           254:                "not an association descritor for RTS");
        !           255:     missingP (rti);
        !           256: 
        !           257:     if ((pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET))
        !           258:            == NULLPE) {
        !           259: no_mem: ;
        !           260:        (void) rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
        !           261:        goto out1;
        !           262:     }
        !           263:     switch (status) {
        !           264:        case ACS_ACCEPT:
        !           265: /* begin RTOAC APDU */
        !           266:            pe -> pe_class = PE_CLASS_CONT; pe -> pe_id = 17;
        !           267:            if (set_add (pe, num2prim (acb -> acb_ckpoint, PE_CLASS_CONT,
        !           268:                            RTOAC_CKPOINT)) == NOTOK
        !           269:                    || set_add (pe, num2prim (acb -> acb_window, PE_CLASS_CONT,
        !           270:                            RTOAC_WINDOW)) == NOTOK
        !           271:                    || set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
        !           272:                            RTOAC_CONNDATA)) == NOTOK
        !           273:                    || set_add (p, q = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
        !           274:                            RTOAC_CD_OPEN)) == NOTOK
        !           275:                    || set_add (q, data ? data : pe_alloc (PE_CLASS_UNIV,
        !           276:                            PE_FORM_PRIM, PE_PRIM_NULL)) == NOTOK)
        !           277:                goto no_mem;
        !           278: /* end RTOAC APDU */
        !           279:            break;
        !           280:            
        !           281:        default:
        !           282: /* begin RTORJ APDU */
        !           283:            pe -> pe_class = PE_CLASS_CONT; pe -> pe_id = 18;
        !           284:            if (set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
        !           285:                        RTORJ_USERDATA)) == NOTOK
        !           286:                    || set_add (p, data ? data : pe_alloc (PE_CLASS_UNIV,
        !           287:                            PE_FORM_PRIM, PE_PRIM_NULL)) == NOTOK)
        !           288:                goto no_mem;
        !           289: /* end RTORJ APDU */
        !           290:            break;
        !           291:     }
        !           292: 
        !           293:     if (ctxlist) {
        !           294:        register int    i;
        !           295:        register struct PSAPcontext *pp;
        !           296: 
        !           297:        if (ctxlist -> pc_nctx > NPCTX) {
        !           298:            (void) rtsaplose (rti, RTS_PARAMETER, NULLCP, "too many contexts");
        !           299:            goto out1;
        !           300:        }
        !           301: 
        !           302:        for (pp = ctxlist -> pc_ctx, i = ctxlist -> pc_nctx - 1;
        !           303:                    i >= 0;
        !           304:                    i--, pp++)
        !           305:            if (acb -> acb_rtsid == pp -> pc_id) {
        !           306:                if (pp -> pc_result != PC_ACCEPT) {
        !           307:                    (void) acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           308:                                      "PCI for RTSE not accepted");
        !           309:                    goto out1;
        !           310:                }
        !           311:            }
        !           312:     }
        !           313:     pe -> pe_context = acb -> acb_rtsid;
        !           314: 
        !           315: #ifdef DEBUG
        !           316:     if (rtsap_log -> ll_events & LLOG_PDUS)
        !           317:        if (status == ACS_ACCEPT)
        !           318:            pvpdu (rtsap_log, print_RTS_RTSE__apdus_P, pe, "RTOACapdu", 0);
        !           319:        else
        !           320:            pvpdu (rtsap_log, print_RTS_RTSE__apdus_P, pe, "RTORJapdu", 0);     
        !           321: #endif
        !           322: 
        !           323:     result = AcAssocResponse (acb -> acb_fd, status,
        !           324:                status != ACS_ACCEPT ? ACS_USER_NOREASON : ACS_USER_NULL,
        !           325:                context, respondtitle, respondaddr, ctxlist, defctxresult, 0,
        !           326:                acb -> acb_requirements, SERIAL_NONE, acb -> acb_settings,
        !           327:                &acb -> acb_connect, &pe, 1, aci);
        !           328: 
        !           329:     if (result == NOTOK) {
        !           330:        (void) acs2rtslose (acb, rti, "AcAssocResponse", aca);
        !           331:        if (ACS_FATAL (aca -> aca_reason))
        !           332:            goto out2;
        !           333:        else
        !           334:            goto out1;
        !           335:     }
        !           336: 
        !           337:     result = OK;
        !           338: 
        !           339: out2:
        !           340:     if (pe) {
        !           341:        if (data)
        !           342:            (void) pe_extract (pe, data);
        !           343:        pe_free (pe);
        !           344:     }
        !           345: 
        !           346:     return result;
        !           347: 
        !           348: out1: ;
        !           349:     (void) AcAssocResponse (acb -> acb_fd, ACS_TRANSIENT, ACS_USER_NOREASON,
        !           350:                NULLOID, NULLAEI, NULLPA, NULLPC, PC_ACCEPT, 0, 0, SERIAL_NONE,
        !           351:                0, &acb -> acb_connect, NULLPEP, 0, aci);
        !           352: 
        !           353:     result = NOTOK;
        !           354:     goto out2;
        !           355: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.