Annotation of 43BSDReno/contrib/isode-beta/acsap/acsaprespond.c, revision 1.1

1.1     ! root        1: /* acsaprespond.c - ACPM: responder */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/acsap/RCS/acsaprespond.c,v 7.2 90/07/09 14:30:38 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/acsap/RCS/acsaprespond.c,v 7.2 90/07/09 14:30:38 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       acsaprespond.c,v $
        !            12:  * Revision 7.2  90/07/09  14:30:38  mrose
        !            13:  * sync
        !            14:  * 
        !            15:  * Revision 7.1  90/07/01  21:02:08  mrose
        !            16:  * pepsy
        !            17:  * 
        !            18:  * Revision 7.0  89/11/23  21:21:57  mrose
        !            19:  * Release 6.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 "ACS-types.h"
        !            38: #define        ACSE
        !            39: #include "acpkt.h"
        !            40: #include "tailor.h"
        !            41: 
        !            42: /*    A-ASSOCIATE.INDICATION */
        !            43: 
        !            44: int    AcInit (vecp, vec, acs, aci)
        !            45: int    vecp;
        !            46: char  **vec;
        !            47: struct AcSAPstart *acs;
        !            48: struct AcSAPindication *aci;
        !            49: {
        !            50:     register int    i;
        !            51:     int            ctx,
        !            52:            result;
        !            53:     register struct assocblk *acb;
        !            54:     register struct PSAPstart *ps;
        !            55:     struct PSAPindication   pis;
        !            56:     register struct PSAPindication *pi = &pis;
        !            57:     register struct PSAPabort  *pa = &pi -> pi_abort;
        !            58:     PE     pe;
        !            59:     struct type_ACS_ACSE__apdu *pdu;
        !            60:     register struct type_ACS_AARQ__apdu *aarq;
        !            61: 
        !            62:     isodetailor (NULLCP, 0);
        !            63: 
        !            64:     missingP (vec);
        !            65:     missingP (acs);
        !            66:     missingP (aci);
        !            67: 
        !            68:     ps = &acs -> acs_start;
        !            69:     if ((acb = newacblk ()) == NULL)
        !            70:        return acsaplose (aci, ACS_CONGEST, NULLCP, "out of memory");
        !            71: 
        !            72:     bzero ((char *) acs, sizeof *acs);
        !            73: 
        !            74:     if (PInit (vecp, vec, ps, pi) == NOTOK) {
        !            75:        (void) ps2acslose (acb, aci, "PInit", pa);
        !            76:        goto out1;
        !            77:     }
        !            78: 
        !            79:     acb -> acb_flags |= ACB_ACS;
        !            80:     acb -> acb_fd = ps -> ps_sd;
        !            81:     acb -> acb_sversion = ps -> ps_qos.qos_sversion;
        !            82:     acb -> acb_uabort = PUAbortRequest;
        !            83: 
        !            84:     pdu = NULL;
        !            85:     if (ps -> ps_ninfo < 1) {
        !            86:        (void) acsaplose (aci, ACS_PROTOCOL, NULLCP,
        !            87:                          "no user-data on P-CONNECT");
        !            88:        goto out2;
        !            89:     }
        !            90: 
        !            91:     result = decode_ACS_ACSE__apdu (pe = ps -> ps_info[0], 1, NULLIP, NULLVP,
        !            92:                                    &pdu);
        !            93: 
        !            94: #ifdef DEBUG
        !            95:     if (result == OK && (acsap_log -> ll_events & LLOG_PDUS))
        !            96:        pvpdu (acsap_log, print_ACS_ACSE__apdu_P, pe, "ACSE-apdu", 1);
        !            97: #endif
        !            98: 
        !            99:     ctx = pe -> pe_context;
        !           100: 
        !           101:     pe_free (pe);
        !           102:     pe = ps -> ps_info[0] = NULLPE;
        !           103:     
        !           104:     if (result == NOTOK) {
        !           105:        (void) acsaplose (aci, ACS_PROTOCOL, NULLCP, "%s", PY_pepy);
        !           106:        goto out2;
        !           107:     }
        !           108: 
        !           109:     if (pdu -> offset != type_ACS_ACSE__apdu_aarq) {
        !           110:        (void) acsaplose (aci, ACS_PROTOCOL, NULLCP,
        !           111:                          "unexpected PDU %d on P-CONNECT", pdu -> offset);
        !           112:        goto out2;
        !           113:     }
        !           114: 
        !           115:     aarq = pdu -> un.aarq;
        !           116: 
        !           117:     if ((acb -> acb_context = oid_cpy (aarq -> application__context__name))
        !           118:            == NULLOID) {
        !           119:        (void) acsaplose (aci, ACS_CONGEST, NULLCP, NULLCP);
        !           120:        goto out2;
        !           121:     }
        !           122: 
        !           123:     {
        !           124:        register OID    oid;
        !           125:        register struct PSAPcontext *pp;
        !           126: 
        !           127:        if ((oid = ode2oid (AC_ASN)) == NULLOID) {
        !           128:            (void) acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           129:                              "%s: unknown", AC_ASN);
        !           130:            goto out2;
        !           131:        }
        !           132: 
        !           133:        for (pp = ps -> ps_ctxlist.pc_ctx, i = ps -> ps_ctxlist.pc_nctx - 1;
        !           134:                 i >= 0;
        !           135:                 pp++, i--)
        !           136:            if (pp -> pc_id == ctx) {
        !           137:                if (oid_cmp (pp -> pc_asn, oid)) {
        !           138:                    (void) acsaplose (aci, ACS_PROTOCOL, NULLCP,
        !           139:                                      "wrong ASN for ACSE");
        !           140:                    goto out2;
        !           141:                }
        !           142:                if (pp -> pc_result != PC_ACCEPT) {
        !           143:                    (void) acsaplose (aci, ACS_PROTOCOL, NULLCP,
        !           144:                                      "PCI for ACSE not accepted");
        !           145:                    goto out2;
        !           146:                }
        !           147: 
        !           148:                acb -> acb_id = ctx;
        !           149:            }
        !           150:            else
        !           151:                if (acb -> acb_rosid == PE_DFLT_CTX)
        !           152:                    acb -> acb_rosid = pp -> pc_id;
        !           153: 
        !           154:        if (acb -> acb_id == PE_DFLT_CTX) {
        !           155:            (void) acsaplose (aci, ACS_PROTOCOL, NULLCP,
        !           156:                              "unable to find PCI for ACSE");
        !           157:            goto out2;
        !           158:        }
        !           159:     }
        !           160: 
        !           161:     acs -> acs_sd = acb -> acb_fd;
        !           162: 
        !           163:     if (apdu2info (acb, aci, aarq -> user__information, acs -> acs_info,
        !           164:                   &acs -> acs_ninfo) == NOTOK)
        !           165:        goto out2;
        !           166: 
        !           167:     acs -> acs_context = aarq -> application__context__name;
        !           168:     aarq -> application__context__name = NULLOID;
        !           169:     acs -> acs_callingtitle.aei_ap_title = aarq -> calling__AP__title;
        !           170:     aarq -> calling__AP__title = NULLPE;
        !           171:     acs -> acs_callingtitle.aei_ae_qualifier =
        !           172:        aarq -> calling__AE__qualifier;
        !           173:     aarq -> calling__AE__qualifier = NULLPE;
        !           174:     if (aarq -> calling__AP__invocation__id) {
        !           175:        acs -> acs_callingtitle.aei_ap_id =
        !           176:            aarq -> calling__AP__invocation__id -> parm;
        !           177:        acs -> acs_callingtitle.aei_flags |= AEI_AP_ID;
        !           178:     }
        !           179:     if (aarq -> calling__AE__invocation__id) {
        !           180:        acs -> acs_callingtitle.aei_ae_id =
        !           181:            aarq -> calling__AE__invocation__id -> parm;
        !           182:        acs -> acs_callingtitle.aei_flags |= AEI_AE_ID;
        !           183:     }
        !           184:     acs -> acs_calledtitle.aei_ap_title = aarq -> called__AP__title;
        !           185:     aarq -> called__AP__title = NULLPE;
        !           186:     acs -> acs_calledtitle.aei_ae_qualifier =
        !           187:        aarq -> called__AE__qualifier;
        !           188:     aarq -> called__AE__qualifier = NULLPE;
        !           189:     if (aarq -> called__AP__invocation__id) {
        !           190:        acs -> acs_calledtitle.aei_ap_id =
        !           191:            aarq -> called__AP__invocation__id -> parm;
        !           192:        acs -> acs_calledtitle.aei_flags |= AEI_AP_ID;
        !           193:     }
        !           194:     if (aarq -> called__AE__invocation__id) {
        !           195:        acs -> acs_calledtitle.aei_ae_id =
        !           196:            aarq -> called__AE__invocation__id -> parm;
        !           197:        acs -> acs_calledtitle.aei_flags |= AEI_AE_ID;
        !           198:     }
        !           199: 
        !           200:     for (i = ps -> ps_ninfo - 1; i >= 0; i--)
        !           201:        if (ps -> ps_info[i]) {
        !           202:            pe_free (ps -> ps_info[i]);
        !           203:            ps -> ps_info[i] = NULL;
        !           204:        }
        !           205:     ps -> ps_ninfo = 0;
        !           206: 
        !           207:     free_ACS_ACSE__apdu (pdu);
        !           208: 
        !           209:     return OK;
        !           210:     
        !           211: out2: ;
        !           212:     if (pdu)
        !           213:        free_ACS_ACSE__apdu (pdu);
        !           214: 
        !           215: /* XXX: should do AARE APDU, but can't given any useful info... */
        !           216:     (void) PConnResponse (ps -> ps_sd, PC_REJECTED, NULLPA, &ps -> ps_ctxlist,
        !           217:                          ps -> ps_defctxresult, 0, 0, SERIAL_NONE, 0,
        !           218:                          &ps -> ps_connect, NULLPEP, 0, &pis);
        !           219: 
        !           220:     PSFREE (ps);
        !           221: 
        !           222: out1: ;
        !           223:     freeacblk (acb);
        !           224: 
        !           225:     return NOTOK;
        !           226: }
        !           227: 
        !           228: /*    A-ASSOCIATE.RESPONSE */
        !           229: 
        !           230: int    AcAssocResponse (sd, status, reason, context, respondtitle,
        !           231:        respondaddr, ctxlist, defctxresult, prequirements, srequirements, isn,
        !           232:        settings, ref, data, ndata, aci)
        !           233: int    sd;
        !           234: int    status,
        !           235:        reason;
        !           236: OID    context;
        !           237: AEI    respondtitle;
        !           238: struct PSAPaddr *respondaddr;
        !           239: int    prequirements,
        !           240:        srequirements,
        !           241:        settings,
        !           242:        ndata;
        !           243: long   isn;
        !           244: struct PSAPctxlist *ctxlist;
        !           245: int    defctxresult;
        !           246: struct SSAPref *ref;
        !           247: PE     *data;
        !           248: struct AcSAPindication *aci;
        !           249: {
        !           250:     int            pstatus,
        !           251:            result;
        !           252:     PE     pe;
        !           253:     register struct assocblk   *acb;
        !           254:     struct PSAPindication pis;
        !           255:     register struct PSAPindication *pi = &pis;
        !           256:     register struct PSAPabort *pa = &pi -> pi_abort;
        !           257:     register struct type_ACS_AARE__apdu *pdu;
        !           258: 
        !           259:     if ((acb = findacblk (sd)) == NULL || (acb -> acb_flags & ACB_CONN))
        !           260:        return acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           261:                "invalid association descriptor");
        !           262:     switch (status) {
        !           263:        case ACS_ACCEPT: 
        !           264:            pstatus = PC_ACCEPT;
        !           265:            if (reason != ACS_USER_NULL) {
        !           266: bad_reason: ;
        !           267:                return acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           268:                                  "invalid value for reason parameter");
        !           269:            }
        !           270:            break;
        !           271: 
        !           272:        case ACS_PERMANENT: 
        !           273:        case ACS_TRANSIENT: 
        !           274:            pstatus = PC_REJECTED;
        !           275:            switch (reason) {
        !           276:                case ACS_USER_NOREASON:
        !           277:                case ACS_CONTEXT:
        !           278:                case ACS_CALLING_AP_TITLE:
        !           279:                case ACS_CALLING_AP_ID:
        !           280:                case ACS_CALLING_AE_QUAL:
        !           281:                case ACS_CALLING_AE_ID:
        !           282:                case ACS_CALLED_AP_TITLE:
        !           283:                case ACS_CALLED_AP_ID:
        !           284:                case ACS_CALLED_AE_QUAL:
        !           285:                case ACS_CALLED_AE_ID:
        !           286:                    break;
        !           287: 
        !           288:                default:
        !           289:                    goto bad_reason;
        !           290:            }
        !           291:            break;
        !           292: 
        !           293:        default: 
        !           294:            return acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           295:                    "bad value for status parameter");
        !           296:     }
        !           297: #ifdef notdef
        !           298:     missingP (context);
        !           299:     missingP (respondtitle);
        !           300: #endif
        !           301: 
        !           302: /* let presentation provider catch errors in presentation parameters */
        !           303: 
        !           304:     toomuchP (data, ndata, NACDATA, "initial");
        !           305:     if (data) {            /* XXX: probably should have a more intensive check... */
        !           306:        register int    i;
        !           307:        register PE    *pep;
        !           308: 
        !           309:        for (pep = data, i = ndata; i > 0; pep++, i--)
        !           310:            if ((*pep) -> pe_context == PE_DFLT_CTX)
        !           311:                return acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           312:                        "default context not allowed for user-data at slot %d",
        !           313:                                  pep - data);
        !           314:     }
        !           315:     missingP (aci);
        !           316: 
        !           317:     pe = NULLPE;
        !           318:     if ((pdu = (struct type_ACS_AARE__apdu *) calloc (1, sizeof *pdu))
        !           319:            == NULL) {
        !           320: no_mem: ;
        !           321:        (void) acsaplose (aci, ACS_CONGEST, NULLCP, "out of memory");
        !           322:        goto out2;
        !           323:     }
        !           324:     pdu -> application__context__name = context ? context : acb -> acb_context;
        !           325:     pdu -> result = status;
        !           326:     if ((pdu -> result__source__diagnostic = 
        !           327:                (struct type_ACS_Associate__source__diagnostic *) malloc
        !           328:          (sizeof (struct type_ACS_Associate__source__diagnostic))) == NULL)
        !           329:        goto no_mem;
        !           330:     pdu -> result__source__diagnostic -> offset =
        !           331:        type_ACS_Associate__source__diagnostic_acse__service__user;
        !           332:     pdu -> result__source__diagnostic -> un.acse__service__user =
        !           333:        reason - ACS_USER_BASE;
        !           334:     if (respondtitle) {
        !           335:        pdu -> responding__AP__title = respondtitle -> aei_ap_title;
        !           336:        pdu -> responding__AE__qualifier = respondtitle -> aei_ae_qualifier;
        !           337:        if (respondtitle -> aei_flags & AEI_AP_ID)
        !           338:            pdu -> responding__AP__invocation__id =
        !           339:                (struct type_ACS_AP__invocation__id *)
        !           340:                    &respondtitle -> aei_ap_id;
        !           341:        if (respondtitle -> aei_flags & AEI_AE_ID)
        !           342:            pdu -> responding__AE__invocation__id =
        !           343:                (struct type_ACS_AE__invocation__id *)
        !           344:                    &respondtitle -> aei_ae_id;
        !           345:     }
        !           346:     if (data
        !           347:            && ndata > 0
        !           348:            && (pdu -> user__information = info2apdu (acb, aci, data, ndata))
        !           349:                        == NULL)
        !           350:        goto out2;
        !           351: 
        !           352:     result = encode_ACS_AARE__apdu (&pe, 1, 0, NULLCP, pdu);
        !           353: 
        !           354:     free_ACS_Associate__source__diagnostic (pdu -> result__source__diagnostic);
        !           355:     if (pdu -> user__information)
        !           356:        free_ACS_Association__information (pdu -> user__information);
        !           357:     free ((char *) pdu);
        !           358:     pdu = NULL;
        !           359: 
        !           360:     if (result == NOTOK) {
        !           361:        (void) acsaplose (aci, ACS_CONGEST, NULLCP, "error encoding PDU: %s",
        !           362:                          PY_pepy);
        !           363:        goto out2;
        !           364:     }
        !           365: 
        !           366:     if (ctxlist) {
        !           367:        register int    i;
        !           368:        register struct PSAPcontext *pp;
        !           369: 
        !           370:        if (ctxlist -> pc_nctx > NPCTX) {
        !           371:            (void) acsaplose (aci, ACS_PARAMETER, NULLCP, "too many contexts");
        !           372:            goto out1;
        !           373:        }
        !           374: 
        !           375:        for (pp = ctxlist -> pc_ctx, i = ctxlist -> pc_nctx - 1;
        !           376:                    i >= 0;
        !           377:                    i--, pp++)
        !           378:            if (acb -> acb_id == pp -> pc_id) {
        !           379:                if (pp -> pc_result != PC_ACCEPT) {
        !           380:                    (void) acsaplose (aci, ACS_PARAMETER, NULLCP,
        !           381:                                      "PCI for ACSE not accepted");
        !           382:                    goto out1;
        !           383:                }
        !           384:            }
        !           385:            else
        !           386:                if (pp -> pc_result == PC_ACCEPT)
        !           387:                    acb -> acb_rosid = pp -> pc_id;
        !           388:     }
        !           389:     pe -> pe_context = acb -> acb_id;
        !           390: 
        !           391:     PLOGP (acsap_log,ACS_ACSE__apdu, pe, "AARE-apdu", 0);
        !           392: 
        !           393:     result = PConnResponse (acb -> acb_fd, pstatus, respondaddr,
        !           394:                ctxlist, defctxresult, prequirements, srequirements, isn,
        !           395:                settings, ref, &pe, 1, pi);
        !           396: 
        !           397:     pe_free (pe);
        !           398:     pe = NULLPE;
        !           399: 
        !           400:     if (result == NOTOK) {
        !           401:        (void) ps2acslose (acb, aci, "PConnResponse", pa);
        !           402:        if (PC_FATAL (pa -> pa_reason))
        !           403:            goto out2;
        !           404:        else
        !           405:            goto out1;
        !           406:     }
        !           407:     
        !           408:     if (status == ACS_ACCEPT)
        !           409:        acb -> acb_flags |= ACB_CONN;
        !           410:     else {
        !           411:        acb -> acb_fd = NOTOK;
        !           412:        freeacblk (acb);
        !           413:     }
        !           414: 
        !           415:     return OK;
        !           416:     
        !           417: out2: ;
        !           418:     freeacblk (acb);
        !           419: out1: ;
        !           420:     if (pdu) {
        !           421:        if (pdu -> result__source__diagnostic)
        !           422:            free_ACS_Associate__source__diagnostic (pdu -> result__source__diagnostic);
        !           423:        if (pdu -> user__information)
        !           424:            free_ACS_Association__information (pdu -> user__information);
        !           425:        free ((char *) pdu);
        !           426:     }
        !           427:     if (pe)
        !           428:        pe_free (pe);
        !           429: 
        !           430:     return NOTOK;
        !           431: }
        !           432:     

unix.superglobalmegacorp.com

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