Annotation of 43BSDReno/contrib/isode-beta/rtsap/rt2psinitiat.c, revision 1.1.1.1

1.1       root        1: /* rt2psinitiat.c - RTPM: initiator */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2psinitiat.c,v 7.2 90/07/27 08:47:46 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/rtsap/RCS/rt2psinitiat.c,v 7.2 90/07/27 08:47:46 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       rt2psinitiat.c,v $
                     12:  * Revision 7.2  90/07/27  08:47:46  mrose
                     13:  * update
                     14:  * 
                     15:  * Revision 7.1  90/07/01  21:06:52  mrose
                     16:  * pepsy
                     17:  * 
                     18:  * Revision 6.0  89/03/18  23:43:09  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 <signal.h>
                     38: #include "RTS-types.h"
                     39: #include "rtpkt.h"
                     40: #include "tailor.h"
                     41: 
                     42: /*    RT-OPEN.REQUEST */
                     43: 
                     44: int    RtOpenRequest2 (mode, turn, context, callingtitle, calledtitle,
                     45:        callingaddr, calledaddr, ctxlist, defctxname, data, qos, tctx,
                     46:        rtc, rti)
                     47: int    mode,
                     48:        turn;
                     49: OID    context;
                     50: AEI    callingtitle,
                     51:        calledtitle;
                     52: struct PSAPaddr *callingaddr,
                     53:                *calledaddr;
                     54: struct PSAPctxlist *ctxlist;
                     55: OID    defctxname;
                     56: PE     data;
                     57: struct QOStype *qos;
                     58: OID    tctx;
                     59: struct RtSAPconnect *rtc;
                     60: struct RtSAPindication *rti;
                     61: {
                     62:     SBV            smask;
                     63:        int result;
                     64: 
                     65:     isodetailor (NULLCP, 0);
                     66: 
                     67:     switch (mode) {
                     68:        case RTS_MONOLOGUE:
                     69:        case RTS_TWA:
                     70:            break;
                     71: 
                     72:        default:
                     73:            return rtsaplose (rti, RTS_PARAMETER, NULLCP,
                     74:                    "bad value for mode parameter");
                     75:     }
                     76:     switch (turn) {
                     77:        case RTS_INITIATOR:
                     78:        case RTS_RESPONDER:
                     79:            break;
                     80: 
                     81:        default:
                     82:            return rtsaplose (rti, RTS_PARAMETER, NULLCP,
                     83:                    "bad value for turn parameter");
                     84:     }
                     85:     if (!ctxlist) {
                     86:        static struct PSAPctxlist ctxs;
                     87: 
                     88:        ctxlist = &ctxs;
                     89:        bzero ((char *) ctxlist, sizeof *ctxlist);
                     90:     }
                     91:     missingP (rtc);
                     92:     bzero ((char *) rtc, sizeof *rtc);
                     93:     missingP (rti);
                     94: 
                     95:     smask = sigioblock ();
                     96: 
                     97:     result = RtOpenRequestAux (mode, turn, context, callingtitle, calledtitle,
                     98:        callingaddr, calledaddr, ctxlist, defctxname, data, qos, tctx,
                     99:        rtc, rti);
                    100: 
                    101:     (void) sigiomask (smask);
                    102: 
                    103:     return result;
                    104: }
                    105: 
                    106: 
                    107: /*  */
                    108: 
                    109: static int  RtOpenRequestAux (mode, turn, context, callingtitle, calledtitle, 
                    110:        callingaddr, calledaddr, ctxlist, defctxname, data, qos, tctx,
                    111:        rtc, rti)
                    112: int    mode,
                    113:        turn;
                    114: OID    context;
                    115: AEI    callingtitle,
                    116:        calledtitle;
                    117: struct PSAPaddr *callingaddr,
                    118:                *calledaddr;
                    119: struct PSAPctxlist *ctxlist;
                    120: OID    defctxname;
                    121: PE     data;
                    122: struct QOStype *qos;
                    123: OID    tctx;
                    124: struct RtSAPconnect *rtc;
                    125: struct RtSAPindication *rti;
                    126: {
                    127:     register int    i;
                    128:     int            result,
                    129:            requirements,
                    130:            offset,
                    131:            rtsid,
                    132:            settings;
                    133:     PE     pe,
                    134:            p,
                    135:            q;
                    136:     register struct assocblk *acb;
                    137:     struct SSAPref *sr;
                    138:     register struct PSAPcontext *pp;
                    139:     register struct AcSAPconnect *acc = &rtc -> rtc_connect;
                    140:     register struct PSAPconnect *pc = &acc -> acc_connect;
                    141:     struct AcSAPindication acis;
                    142:     register struct AcSAPindication *aci = &acis;
                    143:     register struct AcSAPabort *aca = &aci -> aci_abort;
                    144:     struct type_RTS_RTSE__apdus *rtpdu;
                    145:     struct type_RTS_RTOACapdu *prtoac;
                    146: 
                    147: /* begin RTORQ APDU */
                    148:     if ((pe = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS, 16)) == NULLPE) {
                    149: no_mem: ;
                    150:        result = rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
                    151:        goto out1;
                    152:     }
                    153:     if ((DEFAULT_CKPOINT != PCONN_CK_DFLT
                    154:                && set_add (pe, num2prim (DEFAULT_CKPOINT, PE_CLASS_CONT,
                    155:                                          RTORQ_CKPOINT)) == NOTOK)
                    156:            || (DEFAULT_WINDOW != PCONN_WD_DFLT
                    157:                        && set_add (pe, num2prim (DEFAULT_WINDOW,
                    158:                                                  PE_CLASS_CONT, RTORQ_WINDOW))
                    159:                                == NOTOK)
                    160:            || set_add (pe, num2prim (mode == RTS_TWA ? RTORQ_DM_TWA
                    161:                        : RTORQ_DM_MONO, PE_CLASS_CONT, RTORQ_DIALOGUE))
                    162:                    == NOTOK
                    163:            || set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    164:                    RTORQ_CONNDATA)) == NOTOK
                    165:            || set_add (p, q = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    166:                    RTORQ_CD_OPEN)) == NOTOK
                    167:            || set_add (q, data ? data : pe_alloc (PE_CLASS_CONT,
                    168:                    PE_FORM_PRIM, 0)) == NOTOK)
                    169:        goto no_mem;
                    170: /* end RTORQ APDU */
                    171: 
                    172:     requirements = RTS_MYREQUIRE;
                    173:     settings = 0;
                    174: #define dotoken(requires,shift,bit,type) \
                    175: { \
                    176:     if (requirements & requires) \
                    177:        if (turn == RTS_INITIATOR) \
                    178:            settings |= ST_INIT_VALUE << shift; \
                    179:        else \
                    180:            settings |= ST_RESP_VALUE << shift; \
                    181: }
                    182:     dotokens ();
                    183: #undef dotoken
                    184: 
                    185:     if ((sr = addr2ref (PLocalHostName ())) == NULL) {
                    186:        result = rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
                    187:        goto out1;
                    188:     }
                    189: 
                    190:     if (ctxlist -> pc_nctx >= NPCTX) {
                    191:        result = rtsaplose (rti, RTS_PARAMETER, NULLCP,
                    192:                            "too many contexts");
                    193:        goto out1;
                    194:     }
                    195:     {
                    196:        register int ctx;
                    197:        register OID oid;
                    198: 
                    199:        if (tctx)
                    200:                oid = tctx;     /* override standard context */
                    201:        else if ((oid = ode2oid (RT_ASN)) == NULLOID) {
                    202:            result = rtsaplose (rti, RTS_PARAMETER, NULLCP,
                    203:                                "%s: unknown", RT_ASN);
                    204:            goto out1;
                    205:        }
                    206: 
                    207:        i = ctxlist -> pc_nctx - 1, ctx = 1;
                    208:        for (pp = ctxlist -> pc_ctx; i >= 0; i--, pp++) {
                    209:            if (oid_cmp (pp -> pc_asn, oid) == 0) {
                    210:                rtsid = pp -> pc_id;
                    211:                offset = pp - ctxlist -> pc_ctx;
                    212: 
                    213:                pp = NULL;
                    214:                goto ready;
                    215:            }
                    216:            if (ctx <= pp -> pc_id)
                    217:                ctx = pp -> pc_id + 2;
                    218:        }
                    219:        pp -> pc_id = ctx;
                    220:        if ((pp -> pc_asn = oid_cpy (oid)) == NULLOID)
                    221:            goto no_mem;
                    222:        pp -> pc_atn = NULLOID;
                    223: 
                    224:        rtsid = pp -> pc_id;
                    225:        offset = -1;
                    226: 
                    227:        ctxlist -> pc_nctx++;
                    228:     }
                    229: ready: ;
                    230:     pe -> pe_context = rtsid;
                    231: 
                    232:     PLOGP (rtsap_log,RTS_RTSE__apdus, pe, "RTORQapdu", 0);
                    233: 
                    234:     result = AcAssocRequest (context, callingtitle, calledtitle, callingaddr,
                    235:            calledaddr, ctxlist, defctxname, 0, requirements,
                    236:            SERIAL_NONE, settings, sr, &pe, 1, qos, acc, aci);
                    237: 
                    238:     if (pp) {
                    239:        oid_free (pp -> pc_asn);
                    240:        pp -> pc_asn = NULLOID;
                    241:     }
                    242: 
                    243:     if (data)
                    244:        (void) pe_extract (pe, data);
                    245:     pe_free (pe);
                    246:     pe = NULLPE;
                    247: 
                    248:     if (result == NOTOK) {
                    249:        (void) acs2rtslose (NULLACB, rti, "AcAssocRequest", aca);
                    250:        goto out1;
                    251:     }
                    252: 
                    253:     if (acc -> acc_result == ACS_ACCEPT) {
                    254:        if ((acb = findacblk (acc -> acc_sd)) == NULLACB) {
                    255:            result = rtpktlose (NULLACB, rti, RTS_PROTOCOL, NULLCP, "ACSE mangled");
                    256:            goto out2;
                    257:        }
                    258:     }
                    259:     else
                    260:        if (acc -> acc_result == ACS_ABORTED) {
                    261:            (void) acs2rtsabort (acb = NULLACB, aca, rti);
                    262: 
                    263:            rtc -> rtc_sd = NOTOK;
                    264:            rtc -> rtc_result = RTS_ABORTED;
                    265: 
                    266:            result = OK;
                    267:            goto out2;
                    268:        }
                    269:        else
                    270:            acb = NULLACB;
                    271: 
                    272:     if ((pe = acc -> acc_info[0]) == NULLPE) {
                    273:        if (acc -> acc_result != ACS_ACCEPT) {
                    274:            aca -> aca_reason = acc -> acc_result;
                    275:            (void) acs2rtslose (acb, rti, "AcAssocRequest(pseudo)", aca);
                    276: 
                    277:            rtc -> rtc_sd = NOTOK;
                    278:            rtc -> rtc_result = rti -> rti_abort.rta_reason;
                    279: 
                    280:            result = OK;
                    281:        }
                    282:        else
                    283:            if (acb)
                    284:                result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, NULLCP);
                    285:            else
                    286:                result = rtsaplose (rti, RTS_PROTOCOL, NULLCP, NULLCP);
                    287:        goto out2;
                    288:     }
                    289: 
                    290:     if (acc -> acc_result != ACS_ACCEPT) {
                    291:        struct type_RTS_RTORJapdu *prtorj;
                    292: 
                    293:        if (decode_RTS_RTSE__apdus (pe, 1, NULLIP, NULLVP, &rtpdu) == NOTOK) {
                    294:            result = pylose ();
                    295:            goto out2;
                    296:        }
                    297: 
                    298:        PLOGP (rtsap_log,RTS_RTSE__apdus, pe, "RTORJapdu", 1);
                    299: 
                    300:        if (rtpdu -> offset != type_RTS_RTSE__apdus_rtorj__apdu) {
                    301:            result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
                    302:                                "Unexpected PDU");
                    303:            free_RTS_RTSE__apdus (rtpdu);
                    304:            goto out2;
                    305:        }
                    306:        prtorj = rtpdu -> un.rtorj__apdu;
                    307: 
                    308:        rtc -> rtc_sd = NOTOK;
                    309:        rtc -> rtc_result = RTS_REJECT;
                    310:        (void) pe_extract (pe, rtc -> rtc_data = prtorj -> userDataRJ);
                    311: 
                    312:        for (i = acc -> acc_ninfo - 1; i >= 0; i--) 
                    313:            if (acc -> acc_info[i]) {
                    314:                pe_free (acc -> acc_info[i]);
                    315:                acc -> acc_info[i] = NULLPE;
                    316:            }
                    317:        acc -> acc_ninfo = 0;
                    318: 
                    319:        free_RTS_RTSE__apdus (rtpdu);
                    320:        return OK;
                    321:     }
                    322: 
                    323:     acb -> acb_flags |= ACB_RTS | ACB_INIT;
                    324:     acb -> acb_uabort = AcUAbortRequest;
                    325:     SetPS2RtService (acb);
                    326:     if (turn == RTS_INITIATOR)
                    327:        acb -> acb_flags |= ACB_TURN;
                    328:     if (mode == RTS_TWA)
                    329:        acb -> acb_flags |= ACB_TWA;
                    330:     acb -> acb_connect = *sr;  /* struct copy */
                    331:     if ((acb -> acb_requirements = pc -> pc_srequirements) != RTS_MYREQUIRE) {
                    332:        result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
                    333:                    "desired session requirements denied");
                    334:        goto out2;
                    335:     }
                    336: #define dotoken(requires,shift,bit,type) \
                    337: { \
                    338:     if (acb -> acb_requirements & requires) \
                    339:        switch (pc -> pc_settings & (ST_MASK << shift)) { \
                    340:            case ST_INIT_VALUE << shift: \
                    341:                acb -> acb_owned |= bit; \
                    342:                acb -> acb_avail |= bit; \
                    343:                break; \
                    344:  \
                    345:            case ST_RESP_VALUE << shift: \
                    346:                acb -> acb_avail |= bit; \
                    347:                break; \
                    348:  \
                    349:            default: \
                    350:                result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, \
                    351:                            "%s token management botched", type); \
                    352:                goto out2; \
                    353:        } \
                    354: }
                    355:        dotokens ();
                    356: #undef dotoken
                    357:     switch (turn) {
                    358:        case RTS_INITIATOR:
                    359:            if (acb -> acb_owned == acb -> acb_avail)
                    360:                break;
                    361:            result = rtsaplose (rti, RTS_PROTOCOL, NULLCP,
                    362:                    "token management botched");
                    363:            goto out2;
                    364: 
                    365:        case RTS_RESPONDER:
                    366:            if (acb -> acb_owned == 0)
                    367:                break;
                    368:            result = rtsaplose (rti, RTS_PROTOCOL, NULLCP,
                    369:                    "token management botched");
                    370:            goto out2;
                    371:     }
                    372:     acb -> acb_ssdusize = pc -> pc_ssdusize;
                    373: 
                    374:     if (decode_RTS_RTSE__apdus (pe, 1, NULLIP, NULLVP, &rtpdu) == NOTOK) {
                    375:        result = pylose ();
                    376:        goto out3;
                    377:     }
                    378: 
                    379:     PLOGP (rtsap_log,RTS_RTSE__apdus, pe, "RTOACapdu", 1);
                    380: 
                    381:     if (rtpdu -> offset != type_RTS_RTSE__apdus_rtoac__apdu) {
                    382:        result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
                    383:                            "Unexpected PDU");
                    384:        goto out3;
                    385:     }
                    386: 
                    387:     prtoac = rtpdu -> un.rtoac__apdu;
                    388:     acb -> acb_ckpoint = prtoac->checkpointSize;
                    389:     acb -> acb_window = prtoac->windowSize;
                    390: 
                    391:     if ((i = offset) < 0)
                    392:        i = pc -> pc_ctxlist.pc_nctx - 1;
                    393:     pp = pc -> pc_ctxlist.pc_ctx + i;
                    394:     if (pp -> pc_id != rtsid) {
                    395:        result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
                    396:                            "RTSE PCI not found");
                    397:        goto out3;
                    398:     }
                    399:     if (pp -> pc_result != PC_ACCEPT) {
                    400:        result = rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
                    401:                            "RTSE PCI rejected");
                    402:        goto out3;
                    403:     }
                    404: 
                    405:     if (offset < 0)
                    406:        pc -> pc_ctxlist.pc_nctx--;
                    407:     acb -> acb_rtsid = rtsid;
                    408:        
                    409:     rtc -> rtc_sd = acb -> acb_fd;
                    410:     rtc -> rtc_result = RTS_ACCEPT;
                    411:     if (prtoac -> connectionDataAC -> offset == type_RTS_ConnectionData_open)
                    412:        rtc -> rtc_data = prtoac -> connectionDataAC -> un.open;
                    413:     else
                    414:        rtc -> rtc_data = NULL;
                    415:     (void) pe_extract (pe, rtc -> rtc_data);
                    416: 
                    417:     for (i = acc -> acc_ninfo - 1; i >= 0; i--) 
                    418:        if (acc -> acc_info[i]) {
                    419:            pe_free (acc -> acc_info[i]);
                    420:            acc -> acc_info[i] = NULLPE;
                    421:        }
                    422:     acc -> acc_ninfo = 0;
                    423: 
                    424:     free_RTS_RTSE__apdus (rtpdu);
                    425:     if (tctx) oid_free (tctx);
                    426:     return OK;
                    427: 
                    428: out3:
                    429:     free_RTS_RTSE__apdus (rtpdu);
                    430: out2: ;
                    431:     ACCFREE (acc);
                    432:     if (acb)
                    433:        freeacblk (acb);
                    434:        
                    435: out1: ;
                    436:     if (tctx) oid_free (tctx);
                    437:     if (pe) {
                    438:        if (data)
                    439:            (void) pe_extract (pe, data);
                    440:        pe_free (pe);
                    441:     }
                    442: 
                    443:     return result;
                    444: }

unix.superglobalmegacorp.com

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