Annotation of 43BSDReno/contrib/isode-beta/psap2/psapinitiate.c, revision 1.1

1.1     ! root        1: /* psapinitiate.c - PPM: initiator */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/psap2/RCS/psapinitiate.c,v 7.3 90/07/01 21:05:00 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/psap2/RCS/psapinitiate.c,v 7.3 90/07/01 21:05:00 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       psapinitiate.c,v $
        !            12:  * Revision 7.3  90/07/01  21:05:00  mrose
        !            13:  * pepsy
        !            14:  * 
        !            15:  * Revision 7.2  90/01/27  10:26:29  mrose
        !            16:  * touch-up
        !            17:  * 
        !            18:  * Revision 7.1  89/11/24  16:22:14  mrose
        !            19:  * sync
        !            20:  * 
        !            21:  * Revision 7.0  89/11/23  22:14:20  mrose
        !            22:  * Release 6.0
        !            23:  * 
        !            24:  */
        !            25: 
        !            26: /*
        !            27:  *                               NOTICE
        !            28:  *
        !            29:  *    Acquisition, use, and distribution of this module and related
        !            30:  *    materials are subject to the restrictions of a license agreement.
        !            31:  *    Consult the Preface in the User's Manual for the full terms of
        !            32:  *    this agreement.
        !            33:  *
        !            34:  */
        !            35: 
        !            36: 
        !            37: /* LINTLIBRARY */
        !            38: 
        !            39: #include <stdio.h>
        !            40: #include <signal.h>
        !            41: #include "PS-types.h"
        !            42: #include "ppkt.h"
        !            43: #include "isoservent.h"
        !            44: #include "tailor.h"
        !            45: 
        !            46: /*    P-(ASYN-)CONNECT.REQUEST */
        !            47: 
        !            48: int    PAsynConnRequest (calling, called, ctxlist, defctxname, prequirements,
        !            49:        srequirements, isn, settings, ref, data, ndata, qos, pc, pi, async)
        !            50: struct PSAPaddr *calling,
        !            51:                *called;
        !            52: int    prequirements,
        !            53:        srequirements,
        !            54:        settings,
        !            55:        ndata,
        !            56:        async;
        !            57: long   isn;
        !            58: struct PSAPctxlist *ctxlist;
        !            59: OID    defctxname;
        !            60: struct SSAPref *ref;
        !            61: PE    *data;
        !            62: struct QOStype *qos;
        !            63: struct PSAPconnect *pc;
        !            64: struct PSAPindication *pi;
        !            65: {
        !            66:     SBV     smask;
        !            67:     int     result;
        !            68: 
        !            69:     isodetailor (NULLCP, 0);
        !            70: 
        !            71: #ifdef notdef
        !            72:     missingP (calling);
        !            73: #endif
        !            74:     missingP (called);
        !            75: 
        !            76:     if (ctxlist && ctxlist -> pc_nctx > NPCTX)
        !            77:        return psaplose (pi, PC_PARAMETER, NULLCP,
        !            78:                "only %d proposed presentation contexts supported", NPCTX);
        !            79:     if (prequirements & ~PR_MYREQUIRE)
        !            80:        return psaplose (pi, PC_PARAMETER, NULLCP,
        !            81:                "presentation requirements settings not supported");
        !            82:     if ((prequirements & PR_RESTORATION)
        !            83:            && !(prequirements & PR_MANAGEMENT))
        !            84:        return psaplose (pi, PC_PARAMETER, NULLCP,
        !            85:            "context restoration service requires context management service");
        !            86: 
        !            87: /* let session provider catch errors in session parameters */
        !            88: 
        !            89:     toomuchP (data, ndata, NPDATA, "initial");
        !            90:     missingP (pc);
        !            91:     missingP (pi);
        !            92: 
        !            93:     smask = sigioblock ();
        !            94: 
        !            95:     result = PConnRequestAux (calling, called, ctxlist, defctxname,
        !            96:            prequirements, srequirements, isn, settings, ref, data, ndata,
        !            97:            qos, pc, pi, async);
        !            98: 
        !            99:     (void) sigiomask (smask);
        !           100: 
        !           101:     return result;
        !           102: }
        !           103: 
        !           104: /*  */
        !           105: 
        !           106: static int  PConnRequestAux (calling, called, ctxlist, defctxname,
        !           107:        prequirements, srequirements, isn, settings, ref, data, ndata, qos,
        !           108:        pc, pi, async)
        !           109: struct PSAPaddr *calling,
        !           110:                *called;
        !           111: int    prequirements,
        !           112:        srequirements,
        !           113:        settings,
        !           114:        ndata,
        !           115:        async;
        !           116: long   isn;
        !           117: struct PSAPctxlist *ctxlist;
        !           118: OID    defctxname;
        !           119: struct SSAPref *ref;
        !           120: PE    *data;
        !           121: struct QOStype *qos;
        !           122: struct PSAPconnect *pc;
        !           123: struct PSAPindication *pi;
        !           124: {
        !           125:     int            i,
        !           126:            len,
        !           127:            result;
        !           128:     PE     pe;
        !           129:     register struct psapblk *pb;
        !           130:     struct SSAPconnect scs;
        !           131:     register struct SSAPconnect *sc = &scs;
        !           132:     struct SSAPindication sis;
        !           133:     register struct SSAPindication *si = &sis;
        !           134:     register struct SSAPabort *sa = &si -> si_abort;
        !           135:     register struct type_PS_CP__type *pdu;
        !           136:     register struct element_PS_0 *normal;
        !           137: 
        !           138:     if ((pb = newpblk ()) == NULL)
        !           139:        return psaplose (pi, PC_CONGEST, NULLCP, "out of memory");
        !           140: 
        !           141:     pb -> pb_srequirements = pb -> pb_urequirements = srequirements;
        !           142: 
        !           143: #ifdef notdef
        !           144:     if (called -> pa_selectlen > 0) {
        !           145:        if (calling == NULLPA) {
        !           146:            static struct PSAPaddr pas;
        !           147: 
        !           148:            calling = &pas;
        !           149:            bzero ((char *) calling, sizeof *calling);
        !           150:        }
        !           151: 
        !           152:        if (calling -> pa_selectlen == 0) {
        !           153:            calling -> pa_port =
        !           154:                            htons ((u_short) (0x8000 | (getpid () & 0x7fff)));
        !           155:            calling -> pa_selectlen = sizeof calling -> pa_port;
        !           156:        }
        !           157:     }
        !           158: #endif
        !           159: 
        !           160:     pe = NULLPE;
        !           161:     if ((pdu = (struct type_PS_CP__type *) calloc (1, sizeof *pdu)) == NULL) {
        !           162: no_mem: ;
        !           163:        (void) psaplose (pi, PC_CONGEST, NULLCP, "out of memory");
        !           164:        goto out2;
        !           165:     }
        !           166:     if ((pdu -> mode = (struct type_PS_Mode__selector *)
        !           167:                            malloc (sizeof *pdu -> mode)) == NULL)
        !           168:        goto no_mem;
        !           169:     pdu -> mode -> parm = int_PS_Mode__selector_normal__mode;
        !           170:     if ((pdu -> normal__mode = (struct element_PS_0 *)
        !           171:                                    calloc (1, sizeof *pdu -> normal__mode))
        !           172:            == NULL)
        !           173:        goto no_mem;
        !           174:     normal = pdu -> normal__mode;
        !           175:     if (calling
        !           176:            && calling -> pa_selectlen > 0
        !           177:            && (normal -> calling = str2qb (calling -> pa_selector,
        !           178:                                            calling -> pa_selectlen, 1))
        !           179:                    == NULL)
        !           180:        goto no_mem;
        !           181:     if (called -> pa_selectlen > 0
        !           182:            && (normal -> called = str2qb (called -> pa_selector,
        !           183:                                            called -> pa_selectlen, 1))
        !           184:                    == NULL)
        !           185:        goto no_mem;
        !           186: 
        !           187:     if ((pb -> pb_asn = ode2oid (DFLT_ASN)) == NULLOID)  {
        !           188:        (void) psaplose (pi, PC_ABSTRACT, NULLCP, "%s: unknown", DFLT_ASN);
        !           189:        goto out2;
        !           190:     }
        !           191:     if ((pb -> pb_asn = oid_cpy (pb -> pb_asn)) == NULLOID)
        !           192:        goto no_mem;
        !           193:     if ((pb -> pb_atn = ode2oid (DFLT_ATN)) == NULLOID)  {
        !           194:        (void) psaplose (pi, PC_TRANSFER, NULLCP, "%s: unknown", DFLT_ATN);
        !           195:        goto out2;
        !           196:     }
        !           197:     if ((pb -> pb_atn = oid_cpy (pb -> pb_atn)) == NULLOID)
        !           198:        goto no_mem;
        !           199:     if ((pb -> pb_ber = oid_cpy (pb -> pb_atn)) == NULLOID)
        !           200:        goto no_mem;
        !           201: 
        !           202:     if (ctxlist && ctxlist -> pc_nctx > 0) {
        !           203:        register struct type_PS_Definition__list *cd,
        !           204:                                                **cp;
        !           205:        register struct PSAPcontext *pp,
        !           206:                                    *qp;
        !           207: 
        !           208:        cp = &normal -> context__list;
        !           209: 
        !           210:        i = ctxlist -> pc_nctx - 1;
        !           211:        for (pp = ctxlist -> pc_ctx, qp = pb -> pb_contexts;
        !           212:                i >= 0;
        !           213:                i--, pp++, qp++){
        !           214:            if (!((qp -> pc_id = pp -> pc_id) & 01)) {
        !           215:                (void) psaplose (pi, PC_PARAMETER, NULLCP,
        !           216:                            "only odd values allowed for context identifiers");
        !           217:                goto out2;
        !           218:            }
        !           219: 
        !           220:            if (pp -> pc_asn == NULLOID) {
        !           221:                (void) psaplose (pi, PC_PARAMETER, NULLCP,
        !           222:                            "no abstract syntax name given for context %d",
        !           223:                            pp -> pc_id);
        !           224:                goto out2;
        !           225:            }
        !           226:            if ((qp -> pc_asn = oid_cpy (pp -> pc_asn)) == NULLOID)
        !           227:                goto no_mem;
        !           228: 
        !           229:            if (pp -> pc_atn && !atn_is_ok (pb, pp -> pc_atn)) {
        !           230:                (void) psaplose (pi, PC_TRANSFER, NULLCP,
        !           231:                            "unknown transfer syntax name given for context %d",
        !           232:                            pp -> pc_id);
        !           233:                goto out2;
        !           234:            }
        !           235:            if ((qp -> pc_atn = oid_cpy (pp -> pc_atn ? pp -> pc_atn
        !           236:                        : pb -> pb_atn)) == NULLOID)
        !           237:                goto no_mem;
        !           238: 
        !           239:            if ((cd =(struct type_PS_Definition__list *)
        !           240:                        calloc (1, sizeof *cd)) == NULL)
        !           241:                goto no_mem;
        !           242:            *cp = cd;
        !           243:            cp = &cd -> next;
        !           244:            if ((cd -> element_PS_5 = (struct element_PS_6 *)
        !           245:                            calloc (1, sizeof *cd -> element_PS_5)) == NULL)
        !           246:                goto no_mem;
        !           247:            cd -> element_PS_5 -> identifier = qp -> pc_id;
        !           248:            if ((cd -> element_PS_5 -> abstract__syntax =
        !           249:                                oid_cpy (qp -> pc_asn)) == NULLOID
        !           250:                    || (cd -> element_PS_5 -> transfer__syntax__list =
        !           251:                            (struct element_PS_7 *)
        !           252:                                    calloc (1, sizeof (struct element_PS_7)))
        !           253:                            == NULL
        !           254:                    || (cd -> element_PS_5 -> transfer__syntax__list ->
        !           255:                                Transfer__syntax__name =
        !           256:                                        oid_cpy (qp -> pc_atn))
        !           257:                            == NULL)
        !           258:                goto no_mem;
        !           259: 
        !           260:            qp -> pc_result = PC_ACCEPT;
        !           261: 
        !           262:            pb -> pb_ncontext++;
        !           263:        }
        !           264:     }
        !           265: 
        !           266:     if (defctxname) {
        !           267:        oid_free (pb -> pb_asn);
        !           268:        if ((pb -> pb_asn = oid_cpy (defctxname)) == NULLOID
        !           269:                || (normal -> default__context =
        !           270:                        (struct type_PS_Context__name *)
        !           271:                            calloc (1, sizeof *normal -> default__context))
        !           272:                        == NULL
        !           273:                || (normal -> default__context -> abstract__syntax =
        !           274:                            oid_cpy (pb -> pb_asn)) == NULLOID
        !           275:                                /* perhaps should be user-definable */
        !           276:                || (normal -> default__context -> transfer__syntax =
        !           277:                            oid_cpy (pb -> pb_atn)) == NULLOID)
        !           278:            goto no_mem;
        !           279:     }
        !           280:     pb -> pb_result = PC_ACCEPT;
        !           281: 
        !           282:     if ((pb -> pb_prequirements = prequirements) != PR_MYREQUIRE) {
        !           283:        register struct pair *pp;
        !           284: 
        !           285:        if ((normal -> presentation__fu = prim2bit (pe_alloc (PE_CLASS_UNIV,
        !           286:                                                              PE_FORM_PRIM,
        !           287:                                                              PE_PRIM_BITS)))
        !           288:                 == NULL)
        !           289:            goto no_mem;
        !           290: 
        !           291:        for (pp = preq_pairs; pp -> p_mask; pp++)
        !           292:            if ((pb -> pb_prequirements & pp -> p_mask)
        !           293:                    && bit_on (normal -> presentation__fu, pp -> p_bitno)
        !           294:                            == NOTOK)
        !           295:            goto no_mem;
        !           296: 
        !           297:        if (bit2prim (normal -> presentation__fu) == NULLPE)
        !           298:           goto no_mem;
        !           299:     }
        !           300: 
        !           301:     if (pb -> pb_prequirements & PR_MANAGEMENT)
        !           302:        pb -> pb_srequirements |= SR_TYPEDATA;
        !           303:     if (pb -> pb_urequirements != pb -> pb_srequirements) {
        !           304:        register struct pair *pp;
        !           305: 
        !           306:        if ((normal -> session__fu = prim2bit (pe_alloc (PE_CLASS_UNIV,
        !           307:                                                         PE_FORM_PRIM,
        !           308:                                                         PE_PRIM_BITS)))
        !           309:                == NULL)
        !           310:            goto no_mem;
        !           311: 
        !           312:        for (pp = sreq_pairs; pp -> p_mask; pp++)
        !           313:            if ((pb -> pb_urequirements & pp -> p_mask)
        !           314:                    && bit_on (normal -> session__fu, pp -> p_bitno) == NOTOK)
        !           315:                goto no_mem;
        !           316: 
        !           317:        if (bit2prim (normal -> session__fu) == NULLPE)
        !           318:            goto no_mem;
        !           319:     }
        !           320: 
        !           321:     if (data
        !           322:            && ndata > 0
        !           323:            && (normal -> user__data = info2ppdu (pb, pi, data, ndata,
        !           324:                                                  PPDU_CP)) == NULL)
        !           325:        goto out2;   
        !           326: 
        !           327:     if (encode_PS_CP__type (&pe, 1, 0, NULLCP, pdu) == NOTOK) {
        !           328:        (void) psaplose (pi, PC_CONGEST, NULLCP, "error encoding PDU: %s",
        !           329:                         PY_pepy);
        !           330:        goto out2;
        !           331:     }
        !           332: 
        !           333:     PLOGP (psap2_log,PS_CP__type, pe, "CP-type", 0);
        !           334: 
        !           335:     if (pe2ssdu (pe, &pb -> pb_retry, &len) == NOTOK)
        !           336:        goto no_mem;
        !           337: 
        !           338:     free_PS_CP__type (pdu);
        !           339:     pdu = NULL;
        !           340: 
        !           341:     pe_free (pe);
        !           342:     pe = NULLPE;
        !           343: 
        !           344:     if ((result = SAsynConnRequest (ref, calling ? &calling -> pa_addr
        !           345:            : NULLSA, &called -> pa_addr, pb -> pb_srequirements, settings,
        !           346:            isn, pb -> pb_retry, len, qos, sc, si, async)) == NOTOK) {
        !           347:        (void) ss2pslose (NULLPB, pi, "SAsynConnRequest", sa);
        !           348:        goto out1;
        !           349:     }
        !           350: 
        !           351:     pb -> pb_fd = sc -> sc_sd;
        !           352: 
        !           353:     if (async) {
        !           354:        switch (result) {
        !           355:            case CONNECTING_1:
        !           356:            case CONNECTING_2:
        !           357:            pc -> pc_sd = pb -> pb_fd;
        !           358:            return result;
        !           359:        }
        !           360:     }
        !           361:     if ((result = PAsynRetryAux (pb, sc, si, pc, pi)) == DONE && !async)
        !           362:        result = OK;
        !           363:     return result;
        !           364: 
        !           365: out2: ;
        !           366:     if (pe)
        !           367:        pe_free (pe);
        !           368:     if (pdu)
        !           369:        free_PS_CP__type (pdu);
        !           370: 
        !           371: out1: ;
        !           372:     freepblk (pb);
        !           373: 
        !           374:     return NOTOK;
        !           375: }
        !           376: 
        !           377: /*    P-ASYN-RETRY.REQUEST (pseudo) */
        !           378: 
        !           379: int    PAsynRetryRequest (sd, pc, pi)
        !           380: int    sd;
        !           381: struct PSAPconnect *pc;
        !           382: struct PSAPindication *pi;
        !           383: {
        !           384:     SBV     smask;
        !           385:     int     result;
        !           386:     register struct psapblk *pb;
        !           387:     struct SSAPconnect  scs;
        !           388:     register struct SSAPconnect *sc = &scs;
        !           389:     struct SSAPindication sis;
        !           390:     register struct SSAPindication *si = &sis;
        !           391:     register struct SSAPabort *sa = &si -> si_abort;
        !           392: 
        !           393:     missingP (pc);
        !           394:     missingP (pi);
        !           395: 
        !           396:     smask = sigioblock ();
        !           397: 
        !           398:     if ((pb = findpblk (sd)) == NULL) {
        !           399:        (void) sigiomask (smask);
        !           400:        return psaplose (pi, PC_PARAMETER, NULLCP,
        !           401:                "invalid presentation descriptor");
        !           402:     }
        !           403:     if (pb -> pb_flags & PB_CONN) {
        !           404:        (void) sigiomask (smask);
        !           405:        return psaplose (pi, PC_OPERATION, NULLCP,
        !           406:                "presentation descriptor connected");
        !           407:     }
        !           408: 
        !           409:     switch (result = SAsynRetryRequest (pb -> pb_fd, sc, si)) {
        !           410:        case NOTOK: 
        !           411:            pb -> pb_fd = NOTOK;
        !           412:            (void) ss2pslose (pb, pi, "SAsynRetryRequest", sa);
        !           413:            freepblk (pb);
        !           414:            break;
        !           415: 
        !           416:        case CONNECTING_1:
        !           417:        case CONNECTING_2:
        !           418:            break;
        !           419: 
        !           420:        case DONE: 
        !           421:            result = PAsynRetryAux (pb, sc, si, pc, pi);
        !           422:            break;
        !           423:     }
        !           424: 
        !           425:     (void) sigiomask (smask);
        !           426: 
        !           427:     return result;
        !           428: }
        !           429: 
        !           430: /*  */
        !           431: 
        !           432: static int  PAsynRetryAux (pb, sc, si, pc, pi)
        !           433: register struct psapblk *pb;
        !           434: struct SSAPconnect *sc;
        !           435: struct SSAPindication *si;
        !           436: struct PSAPconnect *pc;
        !           437: struct PSAPindication *pi;
        !           438: {
        !           439:     int            i,
        !           440:            result;
        !           441:     PE     pe;
        !           442:     struct qbuf *qb;
        !           443:     register struct SSAPabort *sa = &si -> si_abort;
        !           444:     struct type_PS_CPA__type *cpa;
        !           445:     register struct element_PS_1 *cpa_normal;
        !           446:     struct type_PS_CPR__type *cpr;
        !           447:     register struct element_PS_2 *cpr_normal;
        !           448:     struct type_PS_ARP__PPDU *arp;
        !           449: 
        !           450:     pe = NULLPE;
        !           451: 
        !           452:     free (pb -> pb_retry);
        !           453:     pb -> pb_retry = NULL;
        !           454: 
        !           455:     bzero ((char *) pc, sizeof *pc);
        !           456: 
        !           457:     if (sc -> sc_result == SC_ABORT) {
        !           458:        (void) ss2psabort (pb, sa, pi);
        !           459: 
        !           460:        pc -> pc_sd = NOTOK;
        !           461:        pc -> pc_result = PC_ABORTED;
        !           462: 
        !           463:        return DONE;
        !           464:     }
        !           465: 
        !           466:     cpa = NULL, cpr = NULL, arp = NULL;
        !           467:     if ((pe = ssdu2pe (sc -> sc_data, sc -> sc_cc, NULLCP, &result))
        !           468:            == NULLPE) {
        !           469:        if (sc -> sc_result != SC_ACCEPT) {
        !           470:            bzero ((char *) sa, sizeof *sa);
        !           471:            sa -> sa_reason = sc -> sc_result;
        !           472:            pb -> pb_fd = NOTOK;
        !           473:            (void) ss2pslose (pb, pi, "SAsynConnRequest(pseudo)", sa);
        !           474:            
        !           475:            pc -> pc_sd = NOTOK;
        !           476:            pc -> pc_result = pi -> pi_abort.pa_reason;
        !           477: 
        !           478:            result = DONE;
        !           479:            goto out1;
        !           480:        }
        !           481:        else
        !           482:            (void) ppktlose (pb, pi, result != PS_ERR_NMEM ? PC_UNRECOGNIZED
        !           483:                    : PC_NOTSPECIFIED, sc -> sc_result == SC_ACCEPT ? PPDU_CPA
        !           484:                    : PPDU_CPR, NULLCP, "%s", ps_error (result));
        !           485:        goto out2;
        !           486:     }
        !           487: 
        !           488:     SCFREE (sc);
        !           489: 
        !           490:     if (sc -> sc_result == SC_ACCEPT) {
        !           491:        pb -> pb_flags |= PB_CONN;
        !           492: 
        !           493:        pb -> pb_srequirements = sc -> sc_requirements;
        !           494:        pb -> pb_urequirements &= pb -> pb_srequirements;
        !           495: 
        !           496: #define dotoken(requires,shift,bit,type) \
        !           497: { \
        !           498:        if (pb -> pb_srequirements & requires) \
        !           499:            switch (sc -> sc_settings & (ST_MASK << shift)) { \
        !           500:                case ST_INIT_VALUE << shift: \
        !           501:                    pb -> pb_owned |= bit; \
        !           502:                    pb -> pb_avail |= bit; \
        !           503:                    break; \
        !           504:  \
        !           505:                case ST_RESP_VALUE << shift: \
        !           506:                    pb -> pb_avail |= bit; \
        !           507:                    break; \
        !           508:            } \
        !           509: }
        !           510:        dotokens ();
        !           511: #undef dotoken
        !           512: 
        !           513:        pb -> pb_ssdusize = sc -> sc_ssdusize;
        !           514: 
        !           515:        if (decode_PS_CPA__type (pe, 1, NULLIP, NULLVP, &cpa) == NOTOK) {
        !           516:            (void) ppktlose (pb, pi, PC_UNRECOGNIZED, PPDU_CPA, NULLCP, "%s",
        !           517:                             PY_pepy);
        !           518:            goto out2;
        !           519:        }
        !           520: 
        !           521:        PLOGP (psap2_log,PS_CPA__type, pe, "CPA-type", 1);
        !           522: 
        !           523:        if (cpa -> mode -> parm != int_PS_Mode__selector_normal__mode) {
        !           524:            (void) ppktlose (pb, pi, PC_INVALID, PPDU_CPA, NULLCP,
        !           525:                        "X.410 mode mismatch");
        !           526:            goto out2;
        !           527:        }
        !           528:        cpa_normal = cpa -> normal__mode;
        !           529: 
        !           530:        pc -> pc_sd = pb -> pb_fd;
        !           531:     }
        !           532:     else {
        !           533:        if (sc -> sc_result == SC_NOTSPECIFIED) {
        !           534:            if (decode_PS_ARP__PPDU (pe, 1, NULLIP, NULLVP, &arp) == NOTOK) {
        !           535:                (void) ppktlose (pb, pi, PC_UNRECOGNIZED, PPDU_ARP, NULLCP,
        !           536:                                 "%s", PY_pepy);
        !           537:                goto out2;
        !           538:            }
        !           539: 
        !           540:            PLOGP (psap2_log,PS_ARP__PPDU, pe, "ARP-PPDU", 1);
        !           541: 
        !           542:            if (arp -> provider__reason) {
        !           543:                if ((result = arp -> provider__reason -> parm) == 0)
        !           544:                    result = PC_NOTSPECIFIED;
        !           545:                else
        !           546:                    result += PC_ABORT_BASE;
        !           547:            }
        !           548:            else
        !           549:                result = PC_NOTSPECIFIED;
        !           550: 
        !           551:            (void) psaplose (pi, result, NULLCP, NULLCP);
        !           552:            goto out2;
        !           553:        }
        !           554: 
        !           555:        if (decode_PS_CPR__type (pe, 1, NULLIP, NULLVP, &cpr) == NOTOK) {
        !           556:            (void) ppktlose (pb, pi, PC_UNRECOGNIZED, PPDU_CPR, NULLCP, "%s",
        !           557:                             PY_pepy);
        !           558:            goto out2;
        !           559:        }
        !           560: 
        !           561:        PLOGP (psap2_log,PS_CPR__type, pe, "CPR-type", 1);
        !           562: 
        !           563:        if (cpr -> offset != type_PS_CPR__type_normal__mode) {
        !           564:            (void) ppktlose (pb, pi, PC_INVALID, PPDU_CPR, NULLCP,
        !           565:                        "X.410 mode mismatch");
        !           566:            goto out2;
        !           567:        }
        !           568:        cpr_normal = cpr -> un.normal__mode;
        !           569: 
        !           570:        pc -> pc_sd = NOTOK;
        !           571:     }
        !           572: 
        !           573:     pb -> pb_responding.pa_addr = sc -> sc_responding; /* struct copy */
        !           574:     if (qb = cpa ? cpa_normal -> responding : cpr_normal -> responding) {
        !           575:        char   *base;
        !           576: 
        !           577:        if ((base = qb2str (qb)) == NULLCP
        !           578:                && sc -> sc_result == SC_ACCEPT) {
        !           579:            (void) ppktlose (pb, pi, PC_INVALID, PPDU_CPA, NULLCP,
        !           580:                        "malformed PSAP selector");
        !           581:            goto out2;
        !           582:        }
        !           583:        if (base) {
        !           584:            if (qb -> qb_len > sizeof pc -> pc_responding.pa_selector)
        !           585:                qb -> qb_len = sizeof pc -> pc_responding.pa_selector;
        !           586:            bcopy (base, pb -> pb_responding.pa_selector,
        !           587:                        pb -> pb_responding.pa_selectlen = qb -> qb_len);
        !           588:            free (base);
        !           589:        }
        !           590:     }
        !           591:     pc -> pc_responding = pb -> pb_responding; /* struct copy */
        !           592: 
        !           593:     {
        !           594:        register struct PSAPcontext *pp,
        !           595:                                    *qp;
        !           596:        register struct type_PS_Definition__result__list *lp,
        !           597:                                                         *mp;
        !           598: 
        !           599:        i = 0;
        !           600:        lp = cpa ? cpa_normal -> context__list : cpr_normal -> context__list;
        !           601:        for (mp = lp; mp; mp = mp -> next)
        !           602:            i++;
        !           603:        if (i != pb -> pb_ncontext && i != 0) {
        !           604:            if (sc -> sc_result != SC_ACCEPT) {
        !           605:                pc -> pc_ctxlist.pc_nctx = 0;
        !           606:                goto carry_on;
        !           607:            }
        !           608:        
        !           609:            (void) ppktlose (pb, pi, PC_INVALID, PPDU_CPA, NULLCP,
        !           610:                        "proposed/resulting presentation contexts mismatch");
        !           611:            goto out2;
        !           612:        }
        !           613: 
        !           614:        i = (pc -> pc_ctxlist.pc_nctx = pb -> pb_ncontext) - 1;
        !           615:        for (pp = pc -> pc_ctxlist.pc_ctx, qp = pb -> pb_contexts, mp = lp;
        !           616:                i >= 0;
        !           617:                i--, pp++, qp++) {
        !           618:            pp -> pc_id = qp -> pc_id;
        !           619:            pp -> pc_asn = pp -> pc_atn = NULLOID;
        !           620: 
        !           621:            if (lp == NULL) {
        !           622:                pp -> pc_result = PC_ACCEPT;
        !           623:                continue;
        !           624:            }
        !           625: 
        !           626:            switch (mp -> element_PS_12 -> result) {
        !           627:                case int_PS_result_acceptance:
        !           628:                                            /* assume they gave back ASN.1 */
        !           629:                default:
        !           630:                    pp -> pc_result = qp -> pc_result = PC_ACCEPT;
        !           631:                    break;
        !           632: 
        !           633:                case int_PS_result_user__rejection:
        !           634:                    pp -> pc_result = qp -> pc_result = PC_REJECTED;
        !           635:                    break;
        !           636: 
        !           637:                case int_PS_result_provider__rejection:
        !           638:                    if ((pp -> pc_result =
        !           639:                             mp -> element_PS_12 -> provider__reason) == 0) 
        !           640:                        pp -> pc_result = PC_NOTSPECIFIED;
        !           641:                    else
        !           642:                        pp -> pc_result += PC_REASON_BASE;
        !           643:                    qp -> pc_result = pp -> pc_result;
        !           644:                    break;
        !           645:            }
        !           646: 
        !           647:            mp = mp -> next;
        !           648:        }
        !           649: 
        !           650:        i = pb -> pb_ncontext - 1;
        !           651:        for (qp = pb -> pb_contexts + i; i >= 0; i--, qp--)
        !           652:            if (qp -> pc_result != PC_ACCEPT) {
        !           653:                register struct PSAPcontext *qqp;
        !           654: 
        !           655:                qqp = pb -> pb_contexts + --pb -> pb_ncontext;
        !           656:                if (qp -> pc_asn)
        !           657:                    oid_free (qp -> pc_asn);
        !           658:                if (qp -> pc_atn)
        !           659:                    oid_free (qp -> pc_atn);
        !           660:                if (qp != qqp)
        !           661:                    *qp = *qqp; /* struct copy */
        !           662:            }
        !           663:     }
        !           664: carry_on: ;
        !           665: 
        !           666:     if (cpr == NULL || cpr_normal -> default__context == NULL)
        !           667:        pc -> pc_defctxresult = PC_ACCEPT;
        !           668:     else
        !           669:         switch (cpr_normal -> default__context -> parm) {
        !           670:            case int_PS_Result_acceptance:
        !           671:            default:
        !           672:                pc -> pc_defctxresult = PC_ACCEPT;
        !           673:                break;
        !           674:                
        !           675:            case int_PS_Result_user__rejection:
        !           676:                pc -> pc_defctxresult = PC_REJECTED;
        !           677:                break;
        !           678:                
        !           679:            case int_PS_Result_provider__rejection:
        !           680:                pc -> pc_defctxresult = PC_NOTSPECIFIED;
        !           681:                break;
        !           682:        }
        !           683: 
        !           684:     if (ppdu2info (pb, pi, cpa ? cpa_normal -> user__data
        !           685:                               : cpr_normal -> user__data, pc -> pc_info,
        !           686:                   &pc -> pc_ninfo, cpa ? PPDU_CPA : PPDU_CPR) == NOTOK)
        !           687:        goto out2;
        !           688: 
        !           689:     if (sc -> sc_result == SC_ACCEPT) {
        !           690:        if (cpa_normal -> presentation__fu) {
        !           691:            register struct pair *pp;
        !           692: 
        !           693:            if (!(pb -> pb_srequirements & SR_TYPEDATA)) {
        !           694:                (void) bit_off (cpa_normal -> presentation__fu,
        !           695:                        bit_PS_Presentation__requirements_context__management);
        !           696:                (void) bit_off (cpa_normal -> presentation__fu,
        !           697:                                bit_PS_Presentation__requirements_restoration);
        !           698:            }
        !           699:            for (pp = preq_pairs; pp -> p_mask; pp++)
        !           700:                if (!(pb -> pb_prequirements & pp -> p_mask)) {
        !           701:                    if (bit_test (cpa_normal -> presentation__fu,
        !           702:                                  pp -> p_bitno) == 1) {
        !           703:                        (void) ppktlose (pb, pi, PC_INVALID, PPDU_CPA, NULLCP,
        !           704:                              "presentation-requirements negotiation botched");
        !           705:                        goto out2;
        !           706:                    }
        !           707:                }
        !           708:                else
        !           709:                    if (bit_test (cpa_normal -> presentation__fu,
        !           710:                                  pp -> p_bitno) < 1)
        !           711:                        pb -> pb_prequirements &= ~pp -> p_mask;
        !           712:        }
        !           713:        pc -> pc_prequirements = pb -> pb_prequirements;
        !           714: 
        !           715:        if (cpa_normal -> session__fu) {
        !           716:            register struct pair *pp;
        !           717: 
        !           718:            for (pp = preq_pairs; pp -> p_mask; pp++)
        !           719:                if (bit_test (cpa_normal -> session__fu, pp -> p_bitno) < 1)
        !           720:                    pb -> pb_urequirements &= ~pp -> p_mask;
        !           721:        }
        !           722:        pc -> pc_srequirements = pb -> pb_urequirements;
        !           723:        pc -> pc_settings = sc -> sc_settings;
        !           724:        pc -> pc_please = sc -> sc_please;
        !           725:        pc -> pc_isn = sc -> sc_isn;
        !           726: 
        !           727:        pc -> pc_connect = sc -> sc_connect;    /* struct copy */
        !           728: 
        !           729:        pc -> pc_ssdusize = sc -> sc_ssdusize;
        !           730: 
        !           731:        pc -> pc_qos = sc -> sc_qos;    /* struct copy */
        !           732: 
        !           733:        pc -> pc_result = PC_ACCEPT;
        !           734: 
        !           735:        free_PS_CPA__type (cpa);
        !           736:     }
        !           737:     else {
        !           738:        if (cpr_normal -> optionals & opt_PS_element_PS_2_reason)
        !           739:            pc -> pc_result = cpr_normal -> reason + PC_PROV_BASE;
        !           740:        else
        !           741:            pc -> pc_result = PC_NOTSPECIFIED;
        !           742: 
        !           743:        free_PS_CPR__type (cpr);
        !           744:        freepblk (pb);
        !           745:     }
        !           746: 
        !           747:     pe_free (pe);
        !           748: 
        !           749:     return DONE;
        !           750: 
        !           751: out2: ;
        !           752:     result = NOTOK;
        !           753:     if (pe)
        !           754:        pe_free (pe);
        !           755:     if (cpa)
        !           756:        free_PS_CPA__type (cpa);
        !           757:     if (cpr)
        !           758:        free_PS_CPR__type (cpr);
        !           759:     if (arp)
        !           760:        free_PS_ARP__PPDU (arp);
        !           761: 
        !           762: out1: ;
        !           763:     SCFREE (sc);
        !           764:     freepblk (pb);
        !           765: 
        !           766:     return result;
        !           767: }
        !           768: 
        !           769: /*    P-ASYN-NEXT.REQUEST (pseudo) */
        !           770: 
        !           771: int    PAsynNextRequest (sd, pc, pi)
        !           772: int    sd;
        !           773: struct PSAPconnect *pc;
        !           774: struct PSAPindication *pi;
        !           775: {
        !           776:     SBV     smask;
        !           777:     int     result;
        !           778:     register struct psapblk *pb;
        !           779:     struct SSAPconnect  scs;
        !           780:     register struct SSAPconnect *sc = &scs;
        !           781:     struct SSAPindication sis;
        !           782:     register struct SSAPindication *si = &sis;
        !           783:     register struct SSAPabort *sa = &si -> si_abort;
        !           784: 
        !           785:     missingP (pc);
        !           786:     missingP (pi);
        !           787: 
        !           788:     smask = sigioblock ();
        !           789: 
        !           790:     if ((pb = findpblk (sd)) == NULL) {
        !           791:        (void) sigiomask (smask);
        !           792:        return psaplose (pi, PC_PARAMETER, NULLCP,
        !           793:                "invalid presentation descriptor");
        !           794:     }
        !           795:     if (pb -> pb_flags & PB_CONN) {
        !           796:        (void) sigiomask (smask);
        !           797:        return psaplose (pi, PC_OPERATION, NULLCP,
        !           798:                "presentation descriptor connected");
        !           799:     }
        !           800: 
        !           801:     switch (result = SAsynNextRequest (pb -> pb_fd, sc, si)) {
        !           802:        case NOTOK: 
        !           803:            pb -> pb_fd = NOTOK;
        !           804:            (void) ss2pslose (pb, pi, "SAsynRetryRequest", sa);
        !           805:            freepblk (pb);
        !           806:            break;
        !           807: 
        !           808:        case CONNECTING_1:
        !           809:        case CONNECTING_2:
        !           810:            break;
        !           811: 
        !           812:        case DONE: 
        !           813:            result = PAsynRetryAux (pb, sc, si, pc, pi);
        !           814:            break;
        !           815:     }
        !           816: 
        !           817:     (void) sigiomask (smask);
        !           818: 
        !           819:     return result;
        !           820: }

unix.superglobalmegacorp.com

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