Annotation of 43BSDReno/contrib/isode-beta/ftam/ftamprovider.c, revision 1.1

1.1     ! root        1: /* ftamprovider.c - implement the FTAM protocol */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamprovider.c,v 7.1 89/12/14 10:04:00 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/ftam/RCS/ftamprovider.c,v 7.1 89/12/14 10:04:00 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       ftamprovider.c,v $
        !            12:  * Revision 7.1  89/12/14  10:04:00  mrose
        !            13:  * bdt
        !            14:  * 
        !            15:  * Revision 7.0  89/11/23  21:53:45  mrose
        !            16:  * Release 6.0
        !            17:  * 
        !            18:  */
        !            19: 
        !            20: /*
        !            21:  *                               NOTICE
        !            22:  *
        !            23:  *    Acquisition, use, and distribution of this module and related
        !            24:  *    materials are subject to the restrictions of a license agreement.
        !            25:  *    Consult the Preface in the User's Manual for the full terms of
        !            26:  *    this agreement.
        !            27:  *
        !            28:  */
        !            29: 
        !            30: 
        !            31: /* LINTLIBRARY */
        !            32: 
        !            33: #include <stdio.h>
        !            34: #include <signal.h>
        !            35: #include "fpkt.h"
        !            36: 
        !            37: /*    DATA */
        !            38: 
        !            39: struct pair fclass_pairs[] = {
        !            40:     FCLASS_UNCONS, bit_FTAM_Service__Class_unconstrained__class,
        !            41:     FCLASS_MANAGE, bit_FTAM_Service__Class_management__class,
        !            42:     FCLASS_TRANSFER, bit_FTAM_Service__Class_transfer__class,
        !            43:     FCLASS_TM, bit_FTAM_Service__Class_transfer__and__management__class,
        !            44:     FCLASS_ACCESS, bit_FTAM_Service__Class_access__class,
        !            45: 
        !            46:     0, 0
        !            47: };
        !            48: 
        !            49: struct pair funit_pairs[] = {
        !            50:     FUNIT_READ, bit_FTAM_Functional__Units_read,
        !            51:     FUNIT_WRITE, bit_FTAM_Functional__Units_write,
        !            52:     FUNIT_ACCESS, bit_FTAM_Functional__Units_file__access,
        !            53:     FUNIT_LIMITED, bit_FTAM_Functional__Units_limited__file__management,
        !            54:     FUNIT_ENHANCED, bit_FTAM_Functional__Units_enhanced__file__management,
        !            55:     FUNIT_GROUPING, bit_FTAM_Functional__Units_grouping,
        !            56:     FUNIT_FADULOCK, bit_FTAM_Functional__Units_fadu__locking,
        !            57:     FUNIT_RECOVERY, bit_FTAM_Functional__Units_recovery,
        !            58:     FUNIT_RESTART, bit_FTAM_Functional__Units_restart__data__transfer,
        !            59: 
        !            60:     0, 0
        !            61: };
        !            62: 
        !            63: struct pair fattr_pairs[] = {
        !            64:     FATTR_STORAGE, bit_FTAM_Attribute__Groups_storage,
        !            65:     FATTR_SECURITY, bit_FTAM_Attribute__Groups_security,
        !            66:     FATTR_PRIVATE, bit_FTAM_Attribute__Groups_private,
        !            67: 
        !            68:     0, 0
        !            69: };
        !            70: 
        !            71: struct pair fname_pairs[] = {
        !            72:     FA_FILENAME, bit_FTAM_Attribute__Names_read__filename,
        !            73:     FA_ACTIONS, bit_FTAM_Attribute__Names_read__permitted__actions,
        !            74:     FA_CONTENTS, bit_FTAM_Attribute__Names_read__content__types,
        !            75:     FA_ACCOUNT, bit_FTAM_Attribute__Names_read__storage__account,
        !            76:     FA_DATE_CREATE, bit_FTAM_Attribute__Names_read__date__and__time__of__creation,
        !            77:     FA_DATE_MODIFY, bit_FTAM_Attribute__Names_read__date__and__time__of__last__modification,
        !            78:     FA_DATE_READ, bit_FTAM_Attribute__Names_read__date__and__time__of__last__read__access,
        !            79:     FA_DATE_ATTR, bit_FTAM_Attribute__Names_read__date__and__time__of__last__attribute__modification,
        !            80:     FA_ID_CREATE, bit_FTAM_Attribute__Names_read__identity__of__creator,
        !            81:     FA_ID_MODIFY, bit_FTAM_Attribute__Names_read__identity__of__last__modifier,
        !            82:     FA_ID_READ, bit_FTAM_Attribute__Names_read__identity__of__last__reader,
        !            83:     FA_ID_ATTR, bit_FTAM_Attribute__Names_read__identity__of__last__attribute__modifier,
        !            84:     FA_AVAILABILITY, bit_FTAM_Attribute__Names_read__file__availability,
        !            85:     FA_FILESIZE, bit_FTAM_Attribute__Names_read__filesize,
        !            86:     FA_FUTURESIZE, bit_FTAM_Attribute__Names_read__future__filesize,
        !            87:     FA_CONTROL, bit_FTAM_Attribute__Names_read__access__control,
        !            88:     FA_LEGAL, bit_FTAM_Attribute__Names_read__legal__qualifications,
        !            89:     FA_PRIVATE, bit_FTAM_Attribute__Names_read__private__use,
        !            90: 
        !            91:     0, 0
        !            92: };
        !            93: 
        !            94: struct pair fmode_pairs[] = {
        !            95:     FA_PERM_READ, bit_FTAM_processing__mode_f__read,
        !            96:     FA_PERM_INSERT, bit_FTAM_processing__mode_f__insert,
        !            97:     FA_PERM_REPLACE, bit_FTAM_processing__mode_f__replace,
        !            98:     FA_PERM_EXTEND, bit_FTAM_processing__mode_f__extend,
        !            99:     FA_PERM_ERASE, bit_FTAM_processing__mode_f__erase,
        !           100: 
        !           101:     0, 0
        !           102: };
        !           103: 
        !           104: struct pair frequested_pairs[] = {
        !           105:     FA_PERM_READ, bit_FTAM_Access__Request_read,
        !           106:     FA_PERM_INSERT, bit_FTAM_Access__Request_insert,
        !           107:     FA_PERM_REPLACE, bit_FTAM_Access__Request_replace,
        !           108:     FA_PERM_EXTEND, bit_FTAM_Access__Request_extend,
        !           109:     FA_PERM_ERASE, bit_FTAM_Access__Request_erase,
        !           110:     FA_PERM_READATTR, bit_FTAM_Access__Request_read__attribute,
        !           111:     FA_PERM_CHNGATTR, bit_FTAM_Access__Request_change__attribute,
        !           112:     FA_PERM_DELETE, bit_FTAM_Access__Request_delete,
        !           113: 
        !           114:     0, 0
        !           115: };
        !           116: 
        !           117: struct pair fpermitted_pairs[] = {
        !           118:     FA_PERM_READ, bit_FTAM_Permitted__Actions__Attribute_read,
        !           119:     FA_PERM_INSERT, bit_FTAM_Permitted__Actions__Attribute_insert,
        !           120:     FA_PERM_REPLACE, bit_FTAM_Permitted__Actions__Attribute_replace,
        !           121:     FA_PERM_EXTEND, bit_FTAM_Permitted__Actions__Attribute_extend,
        !           122:     FA_PERM_ERASE, bit_FTAM_Permitted__Actions__Attribute_erase,
        !           123:     FA_PERM_READATTR, bit_FTAM_Permitted__Actions__Attribute_read__attribute,
        !           124:     FA_PERM_CHNGATTR, bit_FTAM_Permitted__Actions__Attribute_change__attribute,
        !           125:     FA_PERM_DELETE, bit_FTAM_Permitted__Actions__Attribute_delete__file,
        !           126:     FA_PERM_TRAV, bit_FTAM_Permitted__Actions__Attribute_traversal,
        !           127:     FA_PERM_RVTRAV, bit_FTAM_Permitted__Actions__Attribute_reverse__traversal,
        !           128:     FA_PERM_RANDOM, bit_FTAM_Permitted__Actions__Attribute_random__order,
        !           129: 
        !           130:     0, 0
        !           131: };
        !           132: 
        !           133: 
        !           134: static int  once_only = 0;
        !           135: static struct ftamblk ftamque;
        !           136: static struct ftamblk *FSHead = &ftamque;
        !           137: 
        !           138: int    psDATAser (), psTOKENser (), psSYNCser (), psACTIVITYser (),
        !           139:        psREPORTser (), psFINISHser (), psABORTser ();
        !           140: 
        !           141: /*    F-WAIT.REQUEST (pseudo) */
        !           142: 
        !           143: int    FWaitRequest (sd, secs, fti)
        !           144: int    sd;
        !           145: int    secs;
        !           146: struct FTAMindication *fti;
        !           147: {
        !           148:     SBV            smask;
        !           149:     int     result;
        !           150:     register struct ftamblk *fsb;
        !           151: 
        !           152:     missingP (fti);
        !           153: 
        !           154:     smask = sigioblock ();
        !           155: 
        !           156:     ftamPsig (fsb, sd);
        !           157: 
        !           158:     result = FWaitRequestAux (fsb, secs, fti);
        !           159: 
        !           160:     (void) sigiomask (smask);
        !           161: 
        !           162:     return result;
        !           163: }
        !           164: 
        !           165: /*  */
        !           166: 
        !           167: int    FWaitRequestAux (fsb, secs, fti)
        !           168: register struct ftamblk *fsb;
        !           169: int    secs;
        !           170: struct FTAMindication *fti;
        !           171: {
        !           172:     int     result;
        !           173:     struct PSAPdata pxs;
        !           174:     register struct PSAPdata   *px = &pxs;
        !           175:     struct PSAPindication   pis;
        !           176:     register struct PSAPindication *pi = &pis;
        !           177: 
        !           178:     for (;;) {
        !           179:        if (fsb -> fsb_data.px_ninfo > 0) {
        !           180:            *px = fsb -> fsb_data;      /* struct copy */
        !           181:            bzero ((char *) &fsb -> fsb_data, sizeof fsb -> fsb_data);
        !           182:            goto do_data;
        !           183:        }
        !           184: 
        !           185:        switch (result = PReadRequest (fsb -> fsb_fd, px, secs, pi)) {
        !           186:            case NOTOK: 
        !           187:                return doPSabort (fsb, &pi -> pi_abort, fti);
        !           188: 
        !           189:            case OK: 
        !           190: do_data: ;
        !           191:                result = doPSdata (fsb, px, fti);
        !           192:                break;
        !           193: 
        !           194:            case DONE: 
        !           195:                switch (pi -> pi_type) {
        !           196:                    case PI_TOKEN: 
        !           197:                        result = doPStokens (fsb, &pi -> pi_token, fti);
        !           198:                        break;
        !           199: 
        !           200:                    case PI_SYNC: 
        !           201:                        result = doPSsync (fsb, &pi -> pi_sync, fti);
        !           202:                        break;
        !           203: 
        !           204:                    case PI_ACTIVITY: 
        !           205:                        result = doPSactivity (fsb, &pi -> pi_activity, fti);
        !           206:                        break;
        !           207: 
        !           208:                    case PI_REPORT: 
        !           209:                        result = doPSreport (fsb, &pi -> pi_report, fti);
        !           210:                        break;
        !           211: 
        !           212:                    case PI_FINISH: 
        !           213:                        result = doPSfinish (fsb, &pi -> pi_finish, fti);
        !           214:                        break;
        !           215: 
        !           216:                    default: 
        !           217:                        result = fpktlose (fsb, fti, FS_PRO_LOWFAIL, NULLCP,
        !           218:                                "unknown indication (0x%x) from presentation",
        !           219:                                pi -> pi_type);
        !           220:                        freefsblk (fsb);
        !           221:                        break;
        !           222:                }
        !           223:                break;
        !           224: 
        !           225:            default: 
        !           226:                result = fpktlose (fsb, fti, FS_PRO_LOWFAIL, NULLCP,
        !           227:                        "unexpected return from PReadRequest=%d", result);
        !           228:                freefsblk (fsb);
        !           229:                break;
        !           230:        }
        !           231: 
        !           232:        switch (result) {
        !           233:            case NOTOK: 
        !           234:                return NOTOK;
        !           235: 
        !           236:            case OK: 
        !           237:                break;
        !           238: 
        !           239:            case DONE: 
        !           240:                return OK;
        !           241:        }
        !           242:     }
        !           243: }
        !           244: 
        !           245: /*  */
        !           246: 
        !           247: static int  doPSdata (fsb, px, fti)
        !           248: register struct ftamblk   *fsb;
        !           249: register struct PSAPdata *px;
        !           250: struct FTAMindication *fti;
        !           251: {
        !           252:     int     next;
        !           253:     register int    i;
        !           254:     register PE        pe,
        !           255:                *pep;
        !           256:     register struct FTAMgroup  *ftg = &fti -> fti_group;
        !           257:     struct type_FTAM_PDU *pdu;
        !           258: 
        !           259:     fti -> fti_type = FTI_FINISH;              /* temporary for group */
        !           260:     bzero ((char *) ftg, sizeof *ftg);
        !           261:     pdu = NULL;
        !           262: 
        !           263:     next = 0;
        !           264:     for (pep = px -> px_info, i = px -> px_ninfo - 1; i >= 0; pep++, i--) {
        !           265:        if ((pe = *pep) == NULLPE)
        !           266:            continue;
        !           267: 
        !           268:        if (pe -> pe_context != fsb -> fsb_id)
        !           269:            goto got_fadu;
        !           270: 
        !           271:        switch (PE_ID (pe -> pe_class, pe -> pe_id)) {
        !           272:            case PE_ID (PE_CLASS_APPL, FADU_NODESCR):
        !           273:            case PE_ID (PE_CLASS_APPL, FADU_ENTERTREE):
        !           274:            case PE_ID (PE_CLASS_APPL, FADU_EXITREE):
        !           275:                pe -> pe_context = PE_DFLT_CTX;
        !           276: 
        !           277: got_fadu: ;
        !           278:                if (next < 0)
        !           279:                    goto copy_psdu;
        !           280:                next = 1;
        !           281:                break;
        !           282: 
        !           283:            default:
        !           284:                if (next > 0) {
        !           285:                    register struct PSAPdata *fx = &fsb -> fsb_data;
        !           286: 
        !           287: copy_psdu: ;
        !           288:                    fsbtrace (fsb, (fsb -> fsb_id,
        !           289:                                    "queueing possible BDT entries in PSDU",
        !           290:                                    NULLCP, NULLPE, -1));
        !           291:                    px -> px_ninfo -= (i + 1);
        !           292:                    do {
        !           293:                        fx -> px_info[fx -> px_ninfo++] = *pep;
        !           294:                        *pep++ = NULL;
        !           295:                    }
        !           296:                    while (--i >= 0);
        !           297:                    break;
        !           298:                }
        !           299:                next = -1;
        !           300:                break;
        !           301:        }
        !           302:     }
        !           303: 
        !           304:     if (next > 0) {
        !           305:        switch (fsb -> fsb_state) {
        !           306:            case FSB_DATAREAD: 
        !           307:                if (!(fsb -> fsb_flags & FSB_INIT)) {
        !           308: unexpected_fadu: ;
        !           309:                    (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !           310:                                "unexpected FADU; state=0x%x",
        !           311:                                fsb -> fsb_state);
        !           312:                    goto out;
        !           313:                }
        !           314:                break;
        !           315: 
        !           316:            case FSB_DATAWRITE: 
        !           317:                if (fsb -> fsb_flags & FSB_INIT)
        !           318:                    goto unexpected_fadu;
        !           319:                break;
        !           320: 
        !           321:            case FSB_DATACANCEL: 
        !           322:                fsbtrace (fsb, (fsb -> fsb_fd,
        !           323:                            "discarding FADU during CANCEL procedure",
        !           324:                            NULLCP, NULLPE, -1));
        !           325:                PXFREE (px);
        !           326:                return OK;
        !           327: 
        !           328:            default: 
        !           329:                goto unexpected_fadu;
        !           330:        }
        !           331: 
        !           332:        fti -> fti_type = FTI_DATA;
        !           333:        {
        !           334:            register struct PSAPdata   *fx = &fti -> fti_data;
        !           335: 
        !           336:            *fx = *px;          /* struct copy */
        !           337:        }
        !           338: 
        !           339:        return DONE;
        !           340:     }
        !           341: 
        !           342:     next = FTG_BEGIN;
        !           343:     for (pep = px -> px_info, i = px -> px_ninfo - 1; i >= 0; pep++, i--) {
        !           344:        if ((pe = *pep) == NULLPE)
        !           345:            continue;
        !           346:        if (decode_FTAM_PDU (pe, 1, NULLIP, NULLVP, &pdu) == NOTOK) {
        !           347:            (void) fpktlose (fsb, fti, FS_PRO_ERRMSG, NULLCP,
        !           348:                             "unable to parse PDU: %s", PY_pepy);
        !           349:            goto out;
        !           350:        }
        !           351:        fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.INDICATION", "FPDU", pe, 1));
        !           352: 
        !           353:        switch (pdu -> offset) {
        !           354:            case type_FTAM_PDU_f__begin__group__request:
        !           355:                if (fsb -> fsb_flags & FSB_INIT)
        !           356:                    goto unexpected_fpdu;
        !           357:                ftg -> ftg_threshold =
        !           358:                            pdu -> un.f__begin__group__request -> parm;
        !           359:                goto do_begin;
        !           360: 
        !           361:            case type_FTAM_PDU_f__begin__group__response:
        !           362:                if (!(fsb -> fsb_flags & FSB_INIT))
        !           363:                    goto unexpected_fpdu;
        !           364:        do_begin: ;
        !           365:                if (!(next & FTG_BEGIN))
        !           366:                    goto unexpected_fpdu;
        !           367:                if (!(fsb -> fsb_units & FUNIT_GROUPING)) {
        !           368:            no_grouping: ;
        !           369:                    (void) fpktlose (fsb, fti, FS_PRO_ERRFUNIT, NULLCP,
        !           370:                            "grouping not permitted");
        !           371:                    goto out;
        !           372:                }
        !           373:                ftg -> ftg_flags |= FTG_BEGIN;
        !           374:                next = FTG_SELECT | FTG_CREATE | FTG_CLOSE;
        !           375:                break;
        !           376: 
        !           377:            case type_FTAM_PDU_f__select__request:
        !           378:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_SELECT))
        !           379:                    goto unexpected_fpdu;
        !           380:                ftg -> ftg_flags |= FTG_SELECT;
        !           381:                {
        !           382:                    register struct FTAMselect *ftse = &ftg -> ftg_select;
        !           383:                    register struct type_FTAM_F__SELECT__request *req =
        !           384:                                                pdu -> un.f__select__request;
        !           385: 
        !           386:                    if (fpm2attr (fsb, req -> attributes, &ftse -> ftse_attrs,
        !           387:                                  fti) == NOTOK)
        !           388:                        goto out;
        !           389:                    ftse -> ftse_attrs.fa_present &= FA_SEL_ATTRS;
        !           390:                    if (fpm2bits (fsb, frequested_pairs,
        !           391:                                  req -> requested__access,
        !           392:                                  &ftse -> ftse_access, fti) == NOTOK)
        !           393:                        goto out;
        !           394:                    if ((fsb -> fsb_attrs & FATTR_SECURITY)
        !           395:                            && req -> access__passwords
        !           396:                            && fpm2pass (fsb, req -> access__passwords,
        !           397:                                         &ftse -> ftse_pwds, fti) == NOTOK)
        !           398:                        goto out;
        !           399:                    FCINIT (&ftse -> ftse_conctl);
        !           400:                    if ((fsb -> fsb_attrs & FATTR_STORAGE)
        !           401:                            && req -> concurrency__control
        !           402:                            && fpm2conctl (fsb, req -> concurrency__control,
        !           403:                                           &ftse -> ftse_conctl, fti) == NOTOK)
        !           404:                        goto out;
        !           405:                    if (req -> shared__ASE__information
        !           406:                            && fpm2shared (fsb,
        !           407:                                           req -> shared__ASE__information,
        !           408:                                           &ftse -> ftse_sharedASE, fti) == NOTOK)
        !           409:                        goto out;
        !           410:                    if (req -> account
        !           411:                            && (ftse -> ftse_account = qb2str (req -> account))
        !           412:                                        == NULL) {
        !           413: no_mem: ;
        !           414:                        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
        !           415:                                         "out of memory");
        !           416:                        goto out;
        !           417:                    }
        !           418:                }
        !           419:                next = FTG_RDATTR | FTG_CHATTR | FTG_OPEN | FTG_DESELECT
        !           420:                        | FTG_DELETE;
        !           421:                break;
        !           422: 
        !           423:            case type_FTAM_PDU_f__select__response:
        !           424:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_SELECT))
        !           425:                    goto unexpected_fpdu;
        !           426:                ftg -> ftg_flags |= FTG_SELECT;
        !           427:                {
        !           428:                    register struct FTAMselect *ftse = &ftg -> ftg_select;
        !           429:                    register struct type_FTAM_F__SELECT__response *rsp =
        !           430:                                                pdu -> un.f__select__response;
        !           431: 
        !           432:                    ftse -> ftse_state = rsp -> state__result
        !           433:                                            ? rsp -> state__result -> parm
        !           434:                                            : int_FTAM_State__Result_success;
        !           435:                    ftse -> ftse_action = rsp -> action__result
        !           436:                                            ? rsp -> action__result -> parm
        !           437:                                            : int_FTAM_Action__Result_success;
        !           438:                    if (fpm2attr (fsb, rsp  -> attributes, &ftse -> ftse_attrs,
        !           439:                                  fti) == NOTOK)
        !           440:                        goto out;
        !           441:                    ftse -> ftse_attrs.fa_present &= FA_SEL_ATTRS;
        !           442:                    if (rsp -> shared__ASE__information
        !           443:                            && fpm2shared (fsb,
        !           444:                                           rsp -> shared__ASE__information,
        !           445:                                           &ftse -> ftse_sharedASE, fti) == NOTOK)
        !           446:                        goto out;
        !           447:                    if (rsp -> diagnostic
        !           448:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           449:                                         ftse -> ftse_diags,
        !           450:                                         &ftse -> ftse_ndiag, fti) == NOTOK)
        !           451:                        goto out;
        !           452:                }
        !           453:                next = FTG_RDATTR | FTG_CHATTR | FTG_OPEN | FTG_DESELECT
        !           454:                        | FTG_DELETE | FTG_END;
        !           455:                break;
        !           456: 
        !           457:            case type_FTAM_PDU_f__create__request:
        !           458:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_CREATE))
        !           459:                    goto unexpected_fpdu;
        !           460:                if (!(fsb -> fsb_units & FUNIT_LIMITED)) {
        !           461:        no_limited: ;
        !           462:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !           463:                            "limited file management not permitted");
        !           464:                    goto out;
        !           465:                }
        !           466:                ftg -> ftg_flags |= FTG_CREATE;
        !           467:                {
        !           468:                    register struct FTAMcreate *ftce = &ftg -> ftg_create;
        !           469:                    register struct type_FTAM_F__CREATE__request *req =
        !           470:                                                pdu -> un.f__create__request;
        !           471: 
        !           472:                    ftce -> ftce_override = req -> override;
        !           473:                    if (fpm2attr (fsb, req -> initial__attributes,
        !           474:                                  &ftce -> ftce_attrs, fti) == NOTOK)
        !           475:                        goto out;
        !           476:                    if ((ftce -> ftce_attrs.fa_present &
        !           477:                                 (FA_FILENAME | FA_ACTIONS | FA_CONTENTS))
        !           478:                            != (FA_FILENAME | FA_ACTIONS | FA_CONTENTS)) {
        !           479:                        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
        !           480:                           "missing mandatory parameters in F-CREATE-request");
        !           481:                        goto out;
        !           482:                    }
        !           483:                    ftce -> ftce_attrs.fa_present &= FA_CRE_ATTRS;
        !           484:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           485:                        ftce -> ftce_attrs.fa_present &= ~FA_STORAGE;
        !           486:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           487:                        ftce -> ftce_attrs.fa_present &= ~FA_SECURITY;
        !           488:                    if (req->create__password) {/* both choices are qbufs... */
        !           489:                        register struct qbuf *qb =
        !           490:                                        req -> create__password -> un.graphic;
        !           491: 
        !           492:                        if ((ftce -> ftce_create = qb2str (qb)) == NULL)
        !           493:                            goto no_mem;
        !           494:                        ftce -> ftce_crelen = qb -> qb_len;
        !           495:                    }
        !           496:                    if (fpm2bits (fsb, frequested_pairs,
        !           497:                                  req -> requested__access,
        !           498:                                  &ftce -> ftce_access, fti) == NOTOK)
        !           499:                        goto out;
        !           500:                    if ((fsb -> fsb_attrs & FATTR_SECURITY)
        !           501:                            && req -> access__passwords
        !           502:                            && fpm2pass (fsb, req -> access__passwords,
        !           503:                                         &ftce -> ftce_pwds, fti) == NOTOK)
        !           504:                        goto out;
        !           505:                    FCINIT (&ftce -> ftce_conctl);
        !           506:                    if ((fsb -> fsb_attrs & FATTR_STORAGE)
        !           507:                            && req -> concurrency__control
        !           508:                            && fpm2conctl (fsb, req -> concurrency__control,
        !           509:                                           &ftce -> ftce_conctl, fti) == NOTOK)
        !           510:                        goto out;
        !           511:                    if (req -> shared__ASE__information
        !           512:                            && fpm2shared (fsb,
        !           513:                                           req -> shared__ASE__information,
        !           514:                                           &ftce -> ftce_sharedASE, fti) == NOTOK)
        !           515:                        goto out;
        !           516:                    if (req -> account
        !           517:                            && (ftce -> ftce_account = qb2str (req -> account))
        !           518:                                        == NULL)
        !           519:                        goto no_mem;
        !           520:                }
        !           521:                next = FTG_RDATTR | FTG_CHATTR | FTG_OPEN | FTG_DESELECT
        !           522:                        | FTG_DELETE;
        !           523:                break;
        !           524: 
        !           525:            case type_FTAM_PDU_f__create__response:
        !           526:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_CREATE))
        !           527:                    goto unexpected_fpdu;
        !           528:                if (!(fsb -> fsb_units & FUNIT_LIMITED))
        !           529:                    goto no_limited;
        !           530:                ftg -> ftg_flags |= FTG_CREATE;
        !           531:                {
        !           532:                    register struct FTAMcreate *ftce = &ftg -> ftg_create;
        !           533:                    register struct type_FTAM_F__CREATE__response *rsp =
        !           534:                                                pdu -> un.f__create__response;
        !           535: 
        !           536:                    ftce -> ftce_state = rsp -> state__result
        !           537:                                            ? rsp -> state__result -> parm
        !           538:                                            : int_FTAM_State__Result_success;
        !           539:                    ftce -> ftce_action = rsp -> action__result
        !           540:                                            ? rsp -> action__result -> parm
        !           541:                                            : int_FTAM_Action__Result_success;
        !           542:                    if (fpm2attr (fsb, rsp -> initial__attributes,
        !           543:                                  &ftce -> ftce_attrs, fti) == NOTOK)
        !           544:                        goto out;
        !           545:                    ftce -> ftce_attrs.fa_present &= FA_CRE_ATTRS;
        !           546:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           547:                        ftce -> ftce_attrs.fa_present &= ~FA_STORAGE;
        !           548:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           549:                        ftce -> ftce_attrs.fa_present &= ~FA_SECURITY;
        !           550:                    if (rsp -> shared__ASE__information
        !           551:                            && fpm2shared (fsb,
        !           552:                                           rsp -> shared__ASE__information,
        !           553:                                           &ftce -> ftce_sharedASE, fti) == NOTOK)
        !           554:                        goto out;
        !           555:                    if (rsp -> diagnostic
        !           556:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           557:                                         ftce -> ftce_diags,
        !           558:                                         &ftce -> ftce_ndiag, fti) == NOTOK)
        !           559:                        goto out;
        !           560:                }
        !           561:                next = FTG_RDATTR | FTG_CHATTR | FTG_OPEN | FTG_DESELECT
        !           562:                        | FTG_DELETE | FTG_END;
        !           563:                break;
        !           564: 
        !           565:            case type_FTAM_PDU_f__read__attrib__request:
        !           566:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_RDATTR))
        !           567:                    goto unexpected_fpdu;
        !           568:                if (!(fsb -> fsb_units & FUNIT_LIMITED))
        !           569:                    goto no_limited;
        !           570:                ftg -> ftg_flags |= FTG_RDATTR;
        !           571:                {
        !           572:                    register struct FTAMreadattr  *ftra = &ftg -> ftg_readattr;
        !           573:                    register struct type_FTAM_F__READ__ATTRIB__request *req =
        !           574:                                            pdu -> un.f__read__attrib__request;
        !           575: 
        !           576:                    if (fpm2bits (fsb, fname_pairs, req,
        !           577:                                     &ftra -> ftra_attrnames, fti) == NOTOK)
        !           578:                        goto out;
        !           579:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           580:                        ftra -> ftra_attrnames &= ~FA_STORAGE;
        !           581:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           582:                        ftra -> ftra_attrnames &= ~FA_SECURITY;
        !           583:                }
        !           584:                next = FTG_CHATTR | FTG_DESELECT | FTG_DELETE |
        !           585:                        ( ftg -> ftg_flags & ( FTG_SELECT | FTG_CREATE ) ?
        !           586:                          FTG_OPEN : FTG_NULL );
        !           587:                break;
        !           588: 
        !           589:            case type_FTAM_PDU_f__read__attrib__response:
        !           590:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_RDATTR))
        !           591:                    goto unexpected_fpdu;
        !           592:                if (!(fsb -> fsb_units & FUNIT_LIMITED))
        !           593:                    goto no_limited;
        !           594:                ftg -> ftg_flags |= FTG_RDATTR;
        !           595:                {
        !           596:                    register struct FTAMreadattr  *ftra = &ftg -> ftg_readattr;
        !           597:                    register struct type_FTAM_F__READ__ATTRIB__response *rsp =
        !           598:                                           pdu -> un.f__read__attrib__response;
        !           599: 
        !           600:                    ftra -> ftra_action = rsp -> action__result
        !           601:                                            ? rsp -> action__result -> parm
        !           602:                                            : int_FTAM_Action__Result_success;
        !           603:                    if (rsp -> attributes
        !           604:                            && fpm2attr (fsb, rsp -> attributes,
        !           605:                                         &ftra -> ftra_attrs, fti) == NOTOK)
        !           606:                        goto out;
        !           607:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           608:                        ftra -> ftra_attrs.fa_present &= ~FA_STORAGE;
        !           609:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           610:                        ftra -> ftra_attrs.fa_present &= ~FA_SECURITY;
        !           611:                    if (rsp -> diagnostic
        !           612:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           613:                                         ftra -> ftra_diags,
        !           614:                                         &ftra -> ftra_ndiag, fti) == NOTOK)
        !           615:                        goto out;
        !           616:                }
        !           617:                next = FTG_CHATTR | FTG_DESELECT | FTG_DELETE |
        !           618:                        ( ftg -> ftg_flags & ( FTG_SELECT | FTG_CREATE ) ?
        !           619:                          FTG_OPEN : FTG_NULL );
        !           620:                break;
        !           621: 
        !           622:            case type_FTAM_PDU_f__change__attrib__request:
        !           623:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_CHATTR))
        !           624:                    goto unexpected_fpdu;
        !           625:                if (!(fsb -> fsb_units & FUNIT_ENHANCED)) {
        !           626:            no_enhanced: ;
        !           627:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !           628:                            "enhanced file management not permitted");
        !           629:                    goto out;
        !           630:                }
        !           631:                ftg -> ftg_flags |= FTG_CHATTR;
        !           632:                {
        !           633:                    register struct FTAMchngattr  *ftca = &ftg -> ftg_chngattr;
        !           634:                    register struct type_FTAM_F__CHANGE__ATTRIB__request *req =
        !           635:                                          pdu -> un.f__change__attrib__request;
        !           636: 
        !           637:                    if (fpm2attr (fsb, req, &ftca -> ftca_attrs, fti) == NOTOK)
        !           638:                        goto out;
        !           639:                    if (ftca -> ftca_attrs.fa_present
        !           640:                                & ftca -> ftca_attrs.fa_novalue) {
        !           641:                        (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !           642:                                "attributes can not be changed to no value available");
        !           643:                        goto out;
        !           644:                    }
        !           645:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           646:                        ftca -> ftca_attrs.fa_present &= ~FA_STORAGE;
        !           647:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           648:                        ftca -> ftca_attrs.fa_present &= ~FA_SECURITY;
        !           649:                }
        !           650:                next = FTG_DESELECT | FTG_DELETE |
        !           651:                        ( ftg -> ftg_flags & ( FTG_SELECT | FTG_CREATE ) ?
        !           652:                          FTG_OPEN : FTG_NULL );
        !           653:                break;
        !           654: 
        !           655:            case type_FTAM_PDU_f__change__attrib__response:
        !           656:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_CHATTR))
        !           657:                    goto unexpected_fpdu;
        !           658:                if (!(fsb -> fsb_units & FUNIT_ENHANCED))
        !           659:                    goto no_enhanced;
        !           660:                ftg -> ftg_flags |= FTG_CHATTR;
        !           661:                {
        !           662:                    register struct FTAMchngattr  *ftca = &ftg -> ftg_chngattr;
        !           663:                    register struct type_FTAM_F__CHANGE__ATTRIB__response *rsp =
        !           664:                                         pdu -> un.f__change__attrib__response;
        !           665: 
        !           666:                    ftca -> ftca_action = rsp -> action__result
        !           667:                                            ? rsp -> action__result -> parm
        !           668:                                            : int_FTAM_Action__Result_success;
        !           669:                    if (rsp -> attributes
        !           670:                            && fpm2attr (fsb, rsp -> attributes,
        !           671:                                         &ftca -> ftca_attrs, fti) == NOTOK)
        !           672:                        goto out;
        !           673:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           674:                        ftca -> ftca_attrs.fa_present &= ~FA_STORAGE;
        !           675:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           676:                        ftca -> ftca_attrs.fa_present &= ~FA_SECURITY;
        !           677:                    if (rsp -> diagnostic
        !           678:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           679:                                         ftca -> ftca_diags,
        !           680:                                         &ftca -> ftca_ndiag, fti) == NOTOK)
        !           681:                        goto out;
        !           682:                    if (!(fsb -> fsb_attrs & FATTR_STORAGE))
        !           683:                        ftca -> ftca_attrs.fa_present &= ~FA_STORAGE;
        !           684:                    if (!(fsb -> fsb_attrs & FATTR_SECURITY))
        !           685:                        ftca -> ftca_attrs.fa_present &= ~FA_SECURITY;
        !           686:                }
        !           687:                next = FTG_DESELECT | FTG_DELETE |
        !           688:                        ( ftg -> ftg_flags & ( FTG_SELECT | FTG_CREATE ) ?
        !           689:                          FTG_OPEN : FTG_NULL );
        !           690:                break;
        !           691: 
        !           692:            case type_FTAM_PDU_f__open__request:
        !           693:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_OPEN))
        !           694:                    goto unexpected_fpdu;
        !           695:                ftg -> ftg_flags |= FTG_OPEN;
        !           696:                {
        !           697:                    register struct FTAMopen *ftop = &ftg -> ftg_open;
        !           698:                    register struct type_FTAM_F__OPEN__request *req =
        !           699:                                          pdu -> un.f__open__request;
        !           700: 
        !           701:                    if (req -> processing__mode) {
        !           702:                        if (fpm2bits (fsb, fmode_pairs,
        !           703:                                      req -> processing__mode,
        !           704:                                      &ftop -> ftop_mode, fti) == NOTOK)
        !           705:                            goto out;
        !           706:                    }
        !           707:                    else
        !           708:                        ftop -> ftop_mode = FA_PERM_READ;
        !           709:                    if (req -> contents__type -> offset
        !           710:                            == choice_FTAM_0_proposed) {
        !           711:                        register struct type_FTAM_Contents__Type__Attribute
        !           712:                            *proposed = req -> contents__type -> un.proposed;
        !           713: 
        !           714:                        ftop -> ftop_contents =
        !           715:                                proposed -> document__type__name;
        !           716:                        proposed -> document__type__name = NULLOID;
        !           717:                        if (proposed -> parameter
        !           718:                                && (ftop -> ftop_parameter =
        !           719:                                        pe_cpy (proposed -> parameter))
        !           720:                                                == NULLPE)
        !           721:                            goto no_mem;
        !           722:                    }
        !           723:                    FCINIT (&ftop -> ftop_conctl);
        !           724:                    if ((fsb -> fsb_attrs & FATTR_STORAGE)
        !           725:                            && req -> concurrency__control
        !           726:                            && fpm2conctl (fsb, req -> concurrency__control,
        !           727:                                           &ftop -> ftop_conctl, fti) == NOTOK)
        !           728:                        goto out;
        !           729:                    if (req -> shared__ASE__information
        !           730:                            && fpm2shared (fsb,
        !           731:                                           req -> shared__ASE__information,
        !           732:                                           &ftop -> ftop_sharedASE, fti) == NOTOK)
        !           733:                        goto out;
        !           734:                    if (fsb -> fsb_units & FUNIT_FADULOCK)
        !           735:                        ftop -> ftop_locking = req -> enable__fadu__locking;
        !           736:                }
        !           737:                next = FTG_END;
        !           738:                break;
        !           739: 
        !           740:            case type_FTAM_PDU_f__open__response:
        !           741:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_OPEN))
        !           742:                    goto unexpected_fpdu;
        !           743:                ftg -> ftg_flags |= FTG_OPEN;
        !           744:                {
        !           745:                    register struct FTAMopen *ftop = &ftg -> ftg_open;
        !           746:                    register struct type_FTAM_F__OPEN__response *rsp =
        !           747:                                          pdu -> un.f__open__response;
        !           748:                    register struct type_FTAM_Contents__Type__Attribute
        !           749:                                        *proposed = rsp -> contents__type;
        !           750: 
        !           751:                    ftop -> ftop_state = rsp -> state__result
        !           752:                                            ? rsp -> state__result -> parm
        !           753:                                            : int_FTAM_State__Result_success;
        !           754:                    ftop -> ftop_action = rsp -> action__result
        !           755:                                            ? rsp -> action__result -> parm
        !           756:                                            : int_FTAM_Action__Result_success;
        !           757:                    ftop -> ftop_contents = proposed -> document__type__name;
        !           758:                    proposed -> document__type__name = NULLOID;
        !           759:                    if (proposed -> parameter
        !           760:                            && (ftop -> ftop_parameter =
        !           761:                                    pe_cpy (proposed -> parameter)) == NULLPE)
        !           762:                        goto no_mem;
        !           763:                    FCINIT (&ftop -> ftop_conctl);
        !           764:                    if ((fsb -> fsb_attrs & FATTR_STORAGE)
        !           765:                            && rsp -> concurrency__control
        !           766:                            && fpm2conctl (fsb, rsp -> concurrency__control,
        !           767:                                           &ftop -> ftop_conctl, fti) == NOTOK)
        !           768:                        goto out;
        !           769:                    if (rsp -> shared__ASE__information
        !           770:                            && fpm2shared (fsb,
        !           771:                                           rsp -> shared__ASE__information,
        !           772:                                           &ftop -> ftop_sharedASE, fti) == NOTOK)
        !           773:                        goto out;
        !           774:                    if (rsp -> diagnostic
        !           775:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           776:                                         ftop -> ftop_diags,
        !           777:                                         &ftop -> ftop_ndiag, fti) == NOTOK)
        !           778:                        goto out;
        !           779:                }
        !           780:                next = FTG_END;
        !           781:                break;
        !           782: 
        !           783:            case type_FTAM_PDU_f__close__request:
        !           784:                if (fsb -> fsb_flags & FSB_INIT)
        !           785:                    goto unexpected_fpdu;
        !           786:                goto do_close;
        !           787:            case type_FTAM_PDU_f__close__response:
        !           788:                if (!(fsb -> fsb_flags & FSB_INIT))
        !           789:                    goto unexpected_fpdu;
        !           790:        do_close: ;
        !           791:                if (!(next & FTG_CLOSE))
        !           792:                    goto unexpected_fpdu;
        !           793:                ftg -> ftg_flags |= FTG_CLOSE;
        !           794:                {                       /* F-CLOSE-response is identical... */
        !           795:                    register struct FTAMclose *ftcl = &ftg -> ftg_close;
        !           796:                    register struct type_FTAM_F__CLOSE__request *req =
        !           797:                                          pdu -> un.f__close__request;
        !           798: 
        !           799:                    ftcl -> ftcl_action = req -> action__result
        !           800:                                            ? req -> action__result -> parm
        !           801:                                            : int_FTAM_Action__Result_success;
        !           802:                    if (req -> shared__ASE__information
        !           803:                            && fpm2shared (fsb,
        !           804:                                           req -> shared__ASE__information,
        !           805:                                           &ftcl -> ftcl_sharedASE, fti) == NOTOK)
        !           806:                        goto out;
        !           807:                    if (req -> diagnostic
        !           808:                            && fpm2diag (fsb, req -> diagnostic,
        !           809:                                         ftcl -> ftcl_diags,
        !           810:                                         &ftcl -> ftcl_ndiag, fti) == NOTOK)
        !           811:                        goto out;
        !           812:                }
        !           813:                next = FTG_RDATTR | FTG_CHATTR | FTG_DESELECT | FTG_DELETE;
        !           814:                break;
        !           815: 
        !           816:            case type_FTAM_PDU_f__deselect__request:
        !           817:                if ((fsb -> fsb_flags & FSB_INIT) || !(next & FTG_DESELECT))
        !           818:                    goto unexpected_fpdu;
        !           819:                ftg -> ftg_flags |= FTG_DESELECT;
        !           820:                {
        !           821:                    register struct FTAMdeselect  *ftde = &ftg -> ftg_deselect;
        !           822:                    register struct type_FTAM_F__DESELECT__request *req =
        !           823:                                          pdu -> un.f__deselect__request;
        !           824: 
        !           825:                    if (req
        !           826:                            && fpm2shared (fsb, req,
        !           827:                                           &ftde -> ftde_sharedASE, fti) == NOTOK)
        !           828:                        goto out;
        !           829:                }
        !           830:                next = FTG_END;
        !           831:                break;
        !           832: 
        !           833:            case type_FTAM_PDU_f__deselect__response:
        !           834:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_DESELECT))
        !           835:                    goto unexpected_fpdu;
        !           836:                ftg -> ftg_flags |= FTG_DESELECT;
        !           837:                {
        !           838:                    register struct FTAMdeselect  *ftde = &ftg -> ftg_deselect;
        !           839:                    register struct type_FTAM_F__DESELECT__response *rsp =
        !           840:                                          pdu -> un.f__deselect__response;
        !           841: 
        !           842:                    ftde -> ftde_action = rsp -> action__result
        !           843:                                            ? rsp -> action__result -> parm
        !           844:                                            : int_FTAM_Action__Result_success;
        !           845:                    if (rsp -> shared__ASE__information
        !           846:                            && fpm2shared (fsb,
        !           847:                                           rsp -> shared__ASE__information,
        !           848:                                           &ftde -> ftde_sharedASE, fti) == NOTOK)
        !           849:                        goto out;
        !           850:                    if (rsp -> charging
        !           851:                            && fpm2chrg (fsb, rsp -> charging,
        !           852:                                          &ftde -> ftde_charges, fti) == NOTOK)
        !           853:                        goto out;
        !           854:                    if (rsp -> diagnostic
        !           855:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           856:                                         ftde -> ftde_diags,
        !           857:                                         &ftde -> ftde_ndiag, fti) == NOTOK)
        !           858:                        goto out;
        !           859:                }
        !           860:                next = FTG_END;
        !           861:                break;
        !           862: 
        !           863:            case type_FTAM_PDU_f__delete__request:
        !           864:                if (fsb -> fsb_flags & FSB_INIT)
        !           865:                    goto unexpected_fpdu;
        !           866:                if (!(fsb -> fsb_units & FUNIT_LIMITED))
        !           867:                    goto no_limited;
        !           868:                ftg -> ftg_flags |= FTG_DELETE;
        !           869:                {
        !           870:                    register struct FTAMdelete  *ftxe = &ftg -> ftg_delete;
        !           871:                    register struct type_FTAM_F__DELETE__request *req =
        !           872:                                          pdu -> un.f__delete__request;
        !           873: 
        !           874:                    if (req
        !           875:                            && fpm2shared (fsb, req,
        !           876:                                           &ftxe -> ftxe_sharedASE, fti) == NOTOK)
        !           877:                        goto out;
        !           878:                }
        !           879:                next = FTG_END;
        !           880:                break;
        !           881: 
        !           882:            case type_FTAM_PDU_f__delete__response:
        !           883:                if (!(fsb -> fsb_flags & FSB_INIT) || !(next & FTG_DELETE))
        !           884:                    goto unexpected_fpdu;
        !           885:                if (!(fsb -> fsb_units & FUNIT_LIMITED))
        !           886:                    goto no_limited;
        !           887:                ftg -> ftg_flags |= FTG_DELETE;
        !           888:                {
        !           889:                    register struct FTAMdelete  *ftxe = &ftg -> ftg_delete;
        !           890:                    register struct type_FTAM_F__DELETE__response *rsp =
        !           891:                                          pdu -> un.f__delete__response;
        !           892: 
        !           893:                    ftxe -> ftxe_action = rsp -> action__result
        !           894:                                            ? rsp -> action__result -> parm
        !           895:                                            : int_FTAM_Action__Result_success;
        !           896:                    if (rsp -> shared__ASE__information
        !           897:                            && fpm2shared (fsb,
        !           898:                                           rsp -> shared__ASE__information,
        !           899:                                           &ftxe -> ftxe_sharedASE, fti) == NOTOK)
        !           900:                        goto out;
        !           901:                    if (rsp -> charging
        !           902:                            && fpm2chrg (fsb, rsp -> charging,
        !           903:                                          &ftxe -> ftxe_charges, fti) == NOTOK)
        !           904:                        goto out;
        !           905:                    if (rsp -> diagnostic
        !           906:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           907:                                         ftxe -> ftxe_diags,
        !           908:                                         &ftxe -> ftxe_ndiag, fti) == NOTOK)
        !           909:                        goto out;
        !           910:                }
        !           911:                next = FTG_END;
        !           912:                break;
        !           913: 
        !           914:            case type_FTAM_PDU_f__end__group__request:
        !           915:                if (fsb -> fsb_flags & FSB_INIT)
        !           916:                    goto unexpected_fpdu;
        !           917:                goto do_end;
        !           918:            case type_FTAM_PDU_f__end__group__response:
        !           919:                if (!(fsb -> fsb_flags & FSB_INIT))
        !           920:                    goto unexpected_fpdu;
        !           921:        do_end: ;
        !           922:                if (!(next & FTG_END))
        !           923:                    goto unexpected_fpdu;
        !           924:                if (!(fsb -> fsb_units & FUNIT_GROUPING))
        !           925:                    goto no_grouping;
        !           926:                ftg -> ftg_flags |= FTG_END;
        !           927:                next = 0;
        !           928:                break;
        !           929: 
        !           930:            case type_FTAM_PDU_f__locate__request:
        !           931:                if ((fsb -> fsb_flags & FSB_INIT)
        !           932:                        || fsb -> fsb_state != FSB_DATAIDLE
        !           933:                        || next != FTG_BEGIN)
        !           934:                    goto unexpected_fpdu;
        !           935:                if (!(fsb -> fsb_units & FUNIT_ACCESS)) {
        !           936:        no_access: ;
        !           937:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !           938:                            "file access not permitted");
        !           939:                    goto out;
        !           940:                }
        !           941:                fti -> fti_type = FTI_ACCESS;
        !           942:                {
        !           943:                    register struct FTAMaccess *ftac = &fti -> fti_access;
        !           944:                    register struct type_FTAM_F__LOCATE__request *req =
        !           945:                                          pdu -> un.f__locate__request;
        !           946: 
        !           947:                    ftac -> ftac_operation = FA_OPS_LOCATE;
        !           948:                    if (fpm2faduid (fsb,
        !           949:                                    req -> file__access__data__unit__identity,
        !           950:                                    &ftac -> ftac_identity, fti) == NOTOK)
        !           951:                        goto out;
        !           952:                    if (req -> fadu__lock)
        !           953:                        ftac -> ftac_locking = req -> fadu__lock -> parm;
        !           954:                }
        !           955:                next = 0;
        !           956:                break;
        !           957: 
        !           958:            case type_FTAM_PDU_f__locate__response:
        !           959:                if (!(fsb -> fsb_flags & FSB_INIT)
        !           960:                        || fsb -> fsb_state != FSB_LOCATE
        !           961:                        || next != FTG_BEGIN)
        !           962:                    goto unexpected_fpdu;
        !           963:                if (!(fsb -> fsb_units & FUNIT_ACCESS))
        !           964:                    goto no_access;
        !           965:                fti -> fti_type = FTI_ACCESS;
        !           966:                {
        !           967:                    register struct FTAMaccess *ftac = &fti -> fti_access;
        !           968:                    register struct type_FTAM_F__LOCATE__response *rsp =
        !           969:                                          pdu -> un.f__locate__response;
        !           970: 
        !           971:                    ftac -> ftac_operation = FA_OPS_LOCATE;
        !           972:                    ftac -> ftac_action = rsp -> action__result
        !           973:                                            ? rsp -> action__result -> parm
        !           974:                                            : int_FTAM_Action__Result_success;
        !           975:                    if (rsp -> file__access__data__unit__identity
        !           976:                            && fpm2faduid (fsb,
        !           977:                                           rsp -> file__access__data__unit__identity,
        !           978:                                           &ftac -> ftac_identity, fti)
        !           979:                                    == NOTOK)
        !           980:                        goto out;
        !           981:                    if (rsp -> diagnostic
        !           982:                            && fpm2diag (fsb, rsp -> diagnostic,
        !           983:                                         ftac -> ftac_diags,
        !           984:                                         &ftac -> ftac_ndiag, fti) == NOTOK)
        !           985:                        goto out;
        !           986:                }
        !           987:                next = 0;
        !           988:                break;
        !           989: 
        !           990:            case type_FTAM_PDU_f__erase__request:
        !           991:                if ((fsb -> fsb_flags & FSB_INIT)
        !           992:                        || fsb -> fsb_state != FSB_DATAIDLE
        !           993:                        || next != FTG_BEGIN)
        !           994:                    goto unexpected_fpdu;
        !           995:                if (!(fsb -> fsb_units & FUNIT_ACCESS))
        !           996:                    goto no_access;
        !           997:                fti -> fti_type = FTI_ACCESS;
        !           998:                {
        !           999:                    register struct FTAMaccess *ftac = &fti -> fti_access;
        !          1000:                    register struct type_FTAM_F__ERASE__request *req =
        !          1001:                                          pdu -> un.f__erase__request;
        !          1002: 
        !          1003:                    ftac -> ftac_operation = FA_OPS_ERASE;
        !          1004:                    if (fpm2faduid (fsb, req, &ftac -> ftac_identity, fti)
        !          1005:                            == NOTOK)
        !          1006:                        goto out;
        !          1007:                }
        !          1008:                next = 0;
        !          1009:                break;
        !          1010: 
        !          1011:            case type_FTAM_PDU_f__erase__response:
        !          1012:                if (!(fsb -> fsb_flags & FSB_INIT)
        !          1013:                        || fsb -> fsb_state != FSB_ERASE
        !          1014:                        || next != FTG_BEGIN)
        !          1015:                    goto unexpected_fpdu;
        !          1016:                if (!(fsb -> fsb_units & FUNIT_ACCESS))
        !          1017:                    goto no_access;
        !          1018:                fti -> fti_type = FTI_ACCESS;
        !          1019:                {
        !          1020:                    register struct FTAMaccess *ftac = &fti -> fti_access;
        !          1021:                    register struct type_FTAM_F__ERASE__response *rsp =
        !          1022:                                          pdu -> un.f__erase__response;
        !          1023: 
        !          1024:                    ftac -> ftac_operation = FA_OPS_ERASE;
        !          1025:                    ftac -> ftac_action = rsp -> action__result
        !          1026:                                            ? rsp -> action__result -> parm
        !          1027:                                            : int_FTAM_Action__Result_success;
        !          1028:                    if (rsp -> diagnostic
        !          1029:                            && fpm2diag (fsb, rsp -> diagnostic,
        !          1030:                                         ftac -> ftac_diags,
        !          1031:                                         &ftac -> ftac_ndiag, fti) == NOTOK)
        !          1032:                        goto out;
        !          1033:                }
        !          1034:                next = 0;
        !          1035:                break;
        !          1036: 
        !          1037:            case type_FTAM_PDU_f__read__request:
        !          1038:                if ((fsb -> fsb_flags & FSB_INIT)
        !          1039:                        || next != FTG_BEGIN
        !          1040:                        || fsb -> fsb_state != FSB_DATAIDLE)
        !          1041:                    goto unexpected_fpdu;
        !          1042:                if (!(fsb -> fsb_units & FUNIT_READ)) {
        !          1043:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1044:                            "reading not permitted");
        !          1045:                    goto out;
        !          1046:                }
        !          1047:                fti -> fti_type = FTI_READWRITE;
        !          1048:                {
        !          1049:                    register struct FTAMreadwrite *ftrw = &fti -> fti_readwrite;
        !          1050:                    register struct type_FTAM_F__READ__request *req =
        !          1051:                                                pdu -> un.f__read__request;
        !          1052: 
        !          1053:                    ftrw -> ftrw_operation = FA_OPS_READ;
        !          1054:                    if (fpm2faduid (fsb,
        !          1055:                                    req -> file__access__data__unit__identity,
        !          1056:                                    &ftrw -> ftrw_identity, fti) == NOTOK)
        !          1057:                        goto out;
        !          1058:                    if ((ftrw -> ftrw_context =
        !          1059:                                    req -> access__context -> access__context)
        !          1060:                            == FA_ACC_FL) {
        !          1061:                        if (req -> access__context -> optionals
        !          1062:                                & opt_FTAM_Access__Context_level__number)
        !          1063:                            ftrw -> ftrw_level =
        !          1064:                                    req -> access__context -> level__number;
        !          1065:                        else {
        !          1066:                            (void) fpktlose (fsb, fti, FS_PRO_ERRMSG, NULLCP,
        !          1067:                                 "level-number missing for access-context FL");
        !          1068:                            goto out;
        !          1069:                        }
        !          1070:                    }
        !          1071:                    else
        !          1072:                        ftrw -> ftrw_level = -1;
        !          1073: 
        !          1074:                    if ((fsb -> fsb_units & FUNIT_FADULOCK)
        !          1075:                            && req -> fadu__lock)
        !          1076:                        ftrw -> ftrw_locking = req -> fadu__lock -> parm;
        !          1077:                }
        !          1078:                next = 0;
        !          1079:                break;
        !          1080: 
        !          1081:            case type_FTAM_PDU_f__write__request:
        !          1082:                if ((fsb -> fsb_flags & FSB_INIT)
        !          1083:                        || next != FTG_BEGIN
        !          1084:                        || fsb -> fsb_state != FSB_DATAIDLE)
        !          1085:                    goto unexpected_fpdu;
        !          1086:                if (!(fsb -> fsb_units & FUNIT_WRITE)) {
        !          1087:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1088:                            "writing not permitted");
        !          1089:                    goto out;
        !          1090:                }
        !          1091:                fti -> fti_type = FTI_READWRITE;
        !          1092:                {
        !          1093:                    register struct FTAMreadwrite *ftrw = &fti -> fti_readwrite;
        !          1094:                    register struct type_FTAM_F__WRITE__request *req =
        !          1095:                                                pdu -> un.f__write__request;
        !          1096: 
        !          1097:                    ftrw -> ftrw_operation =
        !          1098:                                    req -> file__access__data__unit__operation;
        !          1099:                    if (fpm2faduid (fsb,
        !          1100:                                    req -> file__access__data__unit__identity,
        !          1101:                                    &ftrw -> ftrw_identity, fti) == NOTOK)
        !          1102:                        goto out;
        !          1103:                    if ((fsb -> fsb_units & FUNIT_FADULOCK)
        !          1104:                            && req -> fadu__lock)
        !          1105:                        ftrw -> ftrw_locking = req -> fadu__lock -> parm;
        !          1106:                }
        !          1107:                next = 0;
        !          1108:                break;
        !          1109: 
        !          1110:            case type_FTAM_PDU_f__data__end__request:
        !          1111:                switch (fsb -> fsb_state) {
        !          1112:                    case FSB_DATAREAD:
        !          1113:                        if (!(fsb -> fsb_flags & FSB_INIT))
        !          1114:                            goto unexpected_data_end;
        !          1115:                        break;
        !          1116: 
        !          1117:                    case FSB_DATAWRITE:
        !          1118:                        if (fsb -> fsb_flags & FSB_INIT)
        !          1119:                            goto unexpected_data_end;
        !          1120:                        break;
        !          1121: 
        !          1122:                    case FSB_DATACANCEL:
        !          1123:                        fsbtrace (fsb,
        !          1124:                            (fsb -> fsb_fd,
        !          1125:                           "discarding F-DATA-END during CANCEL procedure",
        !          1126:                                NULLCP, NULLPE, -1));
        !          1127:                        free_FTAM_PDU (pdu);
        !          1128:                        PXFREE (px);
        !          1129:                        return OK;
        !          1130:                        
        !          1131:                    default:
        !          1132: unexpected_data_end: ;
        !          1133:                        (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1134:                                    "unexpected data end; state=0x%x",
        !          1135:                                    fsb -> fsb_state);
        !          1136:                        goto out;
        !          1137:                }
        !          1138:                if (next != FTG_BEGIN)
        !          1139:                    goto unexpected_data_end;
        !          1140: 
        !          1141:                fti -> fti_type = FTI_DATAEND;
        !          1142:                {
        !          1143:                    register struct FTAMdataend *ftda = &fti -> fti_dataend;
        !          1144:                    register struct type_FTAM_F__DATA__END__request *req =
        !          1145:                                        pdu -> un.f__data__end__request;
        !          1146: 
        !          1147:                    ftda -> ftda_action = req -> action__result
        !          1148:                                            ?req -> action__result -> parm
        !          1149:                                            : int_FTAM_Action__Result_success;
        !          1150:                    if (req -> diagnostic
        !          1151:                            && fpm2diag (fsb, req -> diagnostic,
        !          1152:                                         ftda -> ftda_diags,
        !          1153:                                         &ftda -> ftda_ndiag, fti) == NOTOK)
        !          1154:                        goto out;
        !          1155:                }
        !          1156:                next = 0;
        !          1157:                break;
        !          1158: 
        !          1159:            case type_FTAM_PDU_f__cancel__request:
        !          1160:                switch (fsb -> fsb_state) {
        !          1161:                    case FSB_DATAREAD:
        !          1162:                    case FSB_DATAWRITE:
        !          1163:                    case FSB_DATAFIN1:
        !          1164:                    case FSB_DATAFIN2:
        !          1165:                        break;
        !          1166: 
        !          1167:                    case FSB_DATACANCEL:
        !          1168:                        fsb -> fsb_flags |= FSB_COLLIDE;
        !          1169:                        break;
        !          1170: 
        !          1171:                    default:
        !          1172:                        goto unexpected_fpdu;
        !          1173:                }
        !          1174:                goto do_cancel;
        !          1175:            case type_FTAM_PDU_f__cancel__response:
        !          1176:                if (fsb -> fsb_state != FSB_DATACANCEL)
        !          1177:                    goto unexpected_fpdu;
        !          1178:        do_cancel: ;
        !          1179:                if (next != FTG_BEGIN)
        !          1180:                    goto unexpected_fpdu;
        !          1181:                fti -> fti_type = FTI_CANCEL;
        !          1182:                {                       /* F-CANCEL-response is identical... */
        !          1183:                    register struct FTAMcancel *ftcn = &fti -> fti_cancel;
        !          1184:                    register struct type_FTAM_F__CANCEL__request *req =
        !          1185:                                                pdu -> un.f__cancel__request;
        !          1186: 
        !          1187:                    ftcn -> ftcn_action = req -> action__result
        !          1188:                                            ? req -> action__result -> parm
        !          1189:                                            : int_FTAM_Action__Result_success;
        !          1190:                    if (req -> shared__ASE__information
        !          1191:                            && fpm2shared (fsb,
        !          1192:                                           req -> shared__ASE__information,
        !          1193:                                           &ftcn -> ftcn_sharedASE, fti) == NOTOK)
        !          1194:                        goto out;
        !          1195:                    if (req -> diagnostic
        !          1196:                            && fpm2diag (fsb, req -> diagnostic,
        !          1197:                                         ftcn -> ftcn_diags,
        !          1198:                                         &ftcn -> ftcn_ndiag, fti) == NOTOK)
        !          1199:                        goto out;
        !          1200:                }
        !          1201:                next = 0;
        !          1202:                break;
        !          1203: 
        !          1204:            case type_FTAM_PDU_f__transfer__end__request:
        !          1205:                if ((fsb -> fsb_flags & FSB_INIT)
        !          1206:                        || next != FTG_BEGIN)
        !          1207:                    goto unexpected_fpdu;
        !          1208:                switch (fsb -> fsb_state) {
        !          1209:                    case FSB_DATAFIN1:
        !          1210:                        break;
        !          1211: 
        !          1212:                    case FSB_DATACANCEL:
        !          1213:                        fsbtrace (fsb,
        !          1214:                           (fsb -> fsb_fd,
        !          1215:                           "discarding F-TRANSFER-END during CANCEL procedure",
        !          1216:                                NULLCP, NULLPE, -1));
        !          1217:                        free_FTAM_PDU (pdu);
        !          1218:                        PXFREE (px);
        !          1219:                        return OK;
        !          1220:                        
        !          1221:                    default:
        !          1222:                        goto unexpected_fpdu;
        !          1223:                }
        !          1224:                fti -> fti_type = FTI_TRANSEND;
        !          1225:                {
        !          1226:                    register struct FTAMtransend *ftre = &fti -> fti_transend;
        !          1227:                    register struct type_FTAM_F__TRANSFER__END__request *req =
        !          1228:                                           pdu -> un.f__transfer__end__request;
        !          1229: 
        !          1230:                    if (req
        !          1231:                            && fpm2shared (fsb, req,
        !          1232:                                           &ftre -> ftre_sharedASE, fti) == NOTOK)
        !          1233:                        goto out;
        !          1234:                }
        !          1235:                next = 0;
        !          1236:                break;
        !          1237: 
        !          1238:            case type_FTAM_PDU_f__transfer__end__response:
        !          1239:                if (!(fsb -> fsb_flags & FSB_INIT)
        !          1240:                        || next != FTG_BEGIN
        !          1241:                        || fsb -> fsb_state != FSB_DATAFIN2)
        !          1242:                    goto unexpected_fpdu;
        !          1243:                fti -> fti_type = FTI_TRANSEND;
        !          1244:                {
        !          1245:                    register struct FTAMtransend *ftre = &fti -> fti_transend;
        !          1246:                    register struct type_FTAM_F__TRANSFER__END__response *rsp =
        !          1247:                                          pdu -> un.f__transfer__end__response;
        !          1248: 
        !          1249:                    ftre -> ftre_action = rsp -> action__result
        !          1250:                                            ? rsp -> action__result -> parm
        !          1251:                                            : int_FTAM_Action__Result_success;
        !          1252:                    if (rsp -> shared__ASE__information
        !          1253:                            && fpm2shared (fsb,
        !          1254:                                           rsp -> shared__ASE__information,
        !          1255:                                           &ftre -> ftre_sharedASE, fti) == NOTOK)
        !          1256:                        goto out;
        !          1257:                    if (rsp -> diagnostic
        !          1258:                            && fpm2diag (fsb, rsp -> diagnostic,
        !          1259:                                         ftre -> ftre_diags,
        !          1260:                                         &ftre -> ftre_ndiag, fti) == NOTOK)
        !          1261:                        goto out;
        !          1262:                }
        !          1263:                next = 0;
        !          1264:                break;
        !          1265: 
        !          1266:            default: 
        !          1267:        unexpected_fpdu: ;
        !          1268:                (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1269:                        "FPDU mismatch; expecting one of 0x%x, found tag %s/%d/0x%x; state=0x%x",
        !          1270:                        next, pe_classlist[pe -> pe_class], pe -> pe_form,
        !          1271:                        pe -> pe_id, fsb -> fsb_state);
        !          1272:                goto out;
        !          1273:        }
        !          1274: 
        !          1275:        free_FTAM_PDU (pdu);
        !          1276:        pdu = NULL;
        !          1277:     }
        !          1278: 
        !          1279:     if (next) {
        !          1280:        (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1281:                "missing FPDU(s) in group; expecting one of 0x%x next",
        !          1282:                next);
        !          1283:        goto out;
        !          1284:     }
        !          1285: 
        !          1286:     switch (fti -> fti_type) {
        !          1287:        case FTI_ACCESS:
        !          1288:            fsb -> fsb_state = (fsb -> fsb_flags & FSB_INIT) ? FSB_DATAIDLE
        !          1289:                                    : fti -> fti_access.ftac_operation
        !          1290:                                        == FA_OPS_LOCATE ? FSB_LOCATE
        !          1291:                                                         : FSB_ERASE;
        !          1292:            goto done;
        !          1293: 
        !          1294:        case FTI_READWRITE:
        !          1295:            fsb -> fsb_state = fti -> fti_readwrite.ftrw_operation
        !          1296:                                    == FA_OPS_READ ? FSB_DATAREAD
        !          1297:                                                   : FSB_DATAWRITE;
        !          1298:            goto done;
        !          1299: 
        !          1300:        case FTI_DATAEND:
        !          1301:            fsb -> fsb_state = FSB_DATAFIN1;
        !          1302:            goto done;
        !          1303: 
        !          1304:        case FTI_TRANSEND:
        !          1305:            fsb -> fsb_state = (fsb -> fsb_flags & FSB_INIT) ? FSB_DATAIDLE
        !          1306:                                        : FSB_DATAFIN2;
        !          1307:            goto done;
        !          1308: 
        !          1309:        case FTI_CANCEL:
        !          1310:            if (fsb -> fsb_flags & FSB_COLLIDE) {
        !          1311:                struct FTAMindication ftis;
        !          1312: 
        !          1313:                fsbtrace (fsb, (fsb -> fsb_fd, "resolving CANCEL collision",
        !          1314:                            NULLCP, NULLPE, -1));
        !          1315:                (void) FCancelResponseAux (fsb, fsb -> fsb_cancelaction,
        !          1316:                                           fsb -> fsb_cancelshared,
        !          1317:                                           fsb -> fsb_canceldiags,
        !          1318:                                           fsb -> fsb_cancelndiag,
        !          1319:                                           &ftis);
        !          1320: 
        !          1321:                fsb -> fsb_flags &= ~FSB_COLLIDE;
        !          1322:                fsb -> fsb_cancelaction = FACTION_PERM;
        !          1323:                if (fsb -> fsb_cancelshared) {
        !          1324:                    pe_free (fsb -> fsb_cancelshared);
        !          1325:                    fsb -> fsb_cancelshared = NULLPE;
        !          1326:                }
        !          1327:                fsb -> fsb_canceldiags = NULL;
        !          1328:                fsb -> fsb_cancelndiag = 0;
        !          1329:                FTCNFREE (&fti -> fti_cancel);
        !          1330:                PXFREE (px);
        !          1331:                return OK;
        !          1332:            }
        !          1333: 
        !          1334:            if (fsb -> fsb_flags & FSB_CANCEL) {
        !          1335:                fsb -> fsb_flags &= ~FSB_CANCEL;
        !          1336:                fsb -> fsb_state = FSB_DATAIDLE;
        !          1337:            }
        !          1338:            else
        !          1339:                fsb -> fsb_state = FSB_DATACANCEL;
        !          1340:            goto done;
        !          1341: 
        !          1342:        default:                /* a grouped request */
        !          1343:            break;
        !          1344:     }
        !          1345: 
        !          1346:     if (!(fsb -> fsb_flags & FSB_INIT)
        !          1347:            && ftg -> ftg_threshold != px -> px_ninfo - 2) {
        !          1348:        (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1349:                "threshold mismatch; expecting %d, found %d",
        !          1350:                px -> px_ninfo - 2, ftg -> ftg_threshold);
        !          1351:        goto out;
        !          1352:     }
        !          1353: 
        !          1354:     if (ftg -> ftg_flags & (FTG_SELECT | FTG_CREATE)) {
        !          1355:        if ((fsb -> fsb_flags & FSB_INIT)
        !          1356:                ? (fsb -> fsb_state == FSB_MANAGEMENT)
        !          1357:                : (ftg -> ftg_flags & (FTG_DESELECT | FTG_DELETE))) {
        !          1358:            if (!(fsb -> fsb_flags & FSB_INIT))
        !          1359:                switch (fsb -> fsb_class) {
        !          1360:                    case FCLASS_MANAGE:
        !          1361:                    case FCLASS_TM:
        !          1362:                    case FCLASS_ACCESS:
        !          1363:                        break;
        !          1364: 
        !          1365:                    default:
        !          1366:                        goto unexpected_group;
        !          1367:                }
        !          1368: 
        !          1369:            fti -> fti_type = FTI_MANAGEMENT;
        !          1370: 
        !          1371:            if (fsb -> fsb_flags & FSB_INIT) {
        !          1372:                if (ftg -> ftg_flags & ~fsb -> fsb_group) {
        !          1373:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1374:                            "management reply mismatch; expecting 0x%x, found 0x%x",
        !          1375:                            fsb -> fsb_group, ftg -> ftg_flags);
        !          1376:                    goto out;
        !          1377:                }
        !          1378:                fsb -> fsb_state = FSB_INITIALIZED;
        !          1379:            }
        !          1380:            else {
        !          1381:                if (fsb -> fsb_state != FSB_INITIALIZED)
        !          1382:                    goto unexpected_group;
        !          1383:                if ((ftg -> ftg_flags & FTG_SELECT)
        !          1384:                        ? ftg -> ftg_select.ftse_account
        !          1385:                        : ftg -> ftg_create.ftce_account)
        !          1386:                    fsb -> fsb_flags |= FSB_DECHARGE;
        !          1387:                else
        !          1388:                    fsb -> fsb_flags &= ~FSB_DECHARGE;
        !          1389:                fsb -> fsb_state = FSB_MANAGEMENT;
        !          1390:                fsb -> fsb_group = ftg -> ftg_flags;
        !          1391:            }
        !          1392: 
        !          1393:            goto done;
        !          1394:        }
        !          1395: 
        !          1396:        if ((fsb -> fsb_flags & FSB_INIT)
        !          1397:                ? (fsb -> fsb_state == FSB_BULKBEGIN)
        !          1398:                : (ftg -> ftg_flags & FTG_OPEN)) {
        !          1399:            if (!(fsb -> fsb_flags & FSB_INIT))
        !          1400:                switch (fsb -> fsb_class) {
        !          1401:                    case FCLASS_TRANSFER: 
        !          1402:                    case FCLASS_TM: 
        !          1403:                    case FCLASS_ACCESS: 
        !          1404:                        break;
        !          1405: 
        !          1406:                    default: 
        !          1407:                        goto unexpected_group;
        !          1408:                }
        !          1409: 
        !          1410:            fti -> fti_type = FTI_BULKBEGIN;
        !          1411: 
        !          1412:            if (fsb -> fsb_flags & FSB_INIT) {
        !          1413:                int     state;
        !          1414: 
        !          1415:                if (ftg -> ftg_flags & ~fsb -> fsb_group) {
        !          1416:                    (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1417:                            "bulk transfer reply mismatch; expecting 0x%x found 0x%x",
        !          1418:                            fsb -> fsb_group, ftg -> ftg_flags);
        !          1419:                    goto out;
        !          1420:                }
        !          1421:                if (ftg -> ftg_flags & FTG_SELECT)
        !          1422:                    state = ftg -> ftg_select.ftse_state;
        !          1423:                else
        !          1424:                    state = ftg -> ftg_create.ftce_state;
        !          1425:                if (state != FSTATE_SUCCESS
        !          1426:                        || ftg -> ftg_open.ftop_state != FSTATE_SUCCESS)
        !          1427:                    fsb -> fsb_state = FSB_INITIALIZED;
        !          1428:                else
        !          1429:                    fsb -> fsb_state = FSB_DATAIDLE;
        !          1430:            }
        !          1431:            else {
        !          1432:                if (fsb -> fsb_state != FSB_INITIALIZED)
        !          1433:                    goto unexpected_group;
        !          1434:                if ((ftg -> ftg_flags & FTG_SELECT)
        !          1435:                        ? ftg -> ftg_select.ftse_account
        !          1436:                        : ftg -> ftg_create.ftce_account)
        !          1437:                    fsb -> fsb_flags |= FSB_DECHARGE;
        !          1438:                else
        !          1439:                    fsb -> fsb_flags &= ~FSB_DECHARGE;
        !          1440:                fsb -> fsb_state = FSB_BULKBEGIN;
        !          1441:                fsb -> fsb_group = ftg -> ftg_flags;
        !          1442:            }
        !          1443: 
        !          1444:            goto done;
        !          1445:        }
        !          1446: 
        !          1447:        goto unexpected_group;
        !          1448:     }
        !          1449: 
        !          1450:     if (ftg -> ftg_flags & FTG_CLOSE) {
        !          1451:        switch (fsb -> fsb_class) {
        !          1452:            case FCLASS_TRANSFER: 
        !          1453:            case FCLASS_TM: 
        !          1454:            case FCLASS_ACCESS: 
        !          1455:                break;
        !          1456: 
        !          1457:            default: 
        !          1458:                goto unexpected_group;
        !          1459:        }
        !          1460: 
        !          1461:        fti -> fti_type = FTI_BULKEND;
        !          1462: 
        !          1463:        if (fsb -> fsb_flags & FSB_INIT) {
        !          1464:            if (fsb -> fsb_state != FSB_BULKEND)
        !          1465:                goto unexpected_group;
        !          1466:            if (ftg -> ftg_flags & ~fsb -> fsb_group) {
        !          1467:                (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1468:                        "bulk transfer reply mismatch; expecting 0x%x found 0x%x",
        !          1469:                        fsb -> fsb_group, ftg -> ftg_flags);
        !          1470:                goto out;
        !          1471:            }
        !          1472:            fsb -> fsb_state = FSB_INITIALIZED;
        !          1473:        }
        !          1474:        else {
        !          1475:            if (fsb -> fsb_state != FSB_DATAIDLE)
        !          1476:                goto unexpected_group;
        !          1477:            fsb -> fsb_state = FSB_BULKEND;
        !          1478:            fsb -> fsb_group = ftg -> ftg_flags;
        !          1479:        }
        !          1480: 
        !          1481:        goto done;
        !          1482:     }
        !          1483: 
        !          1484: unexpected_group: ;
        !          1485:     (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1486:                "unexpected group type 0x%x; state=0x%x", ftg -> ftg_flags,
        !          1487:                fsb -> fsb_state);
        !          1488:     goto out;
        !          1489: 
        !          1490: done: ;
        !          1491:     PXFREE (px);
        !          1492:     return DONE;
        !          1493: 
        !          1494: out: ;
        !          1495:     if (pdu)
        !          1496:        free_FTAM_PDU (pdu);
        !          1497:     switch (fti -> fti_type) {
        !          1498:        case FTI_ACCESS:
        !          1499:            FTACFREE (&fti -> fti_access);
        !          1500:            break;
        !          1501: 
        !          1502:        case FTI_READWRITE:
        !          1503:            FTRWFREE (&fti -> fti_readwrite);
        !          1504:            break;
        !          1505: 
        !          1506:        case FTI_TRANSEND:
        !          1507:            FTREFREE (&fti -> fti_transend);
        !          1508:            break;
        !          1509: 
        !          1510:        case FTI_CANCEL:
        !          1511:            FTCNFREE (&fti -> fti_cancel);
        !          1512:            break;
        !          1513: 
        !          1514:        case FTI_FINISH:
        !          1515:        case FTI_MANAGEMENT:
        !          1516:        case FTI_BULKBEGIN:
        !          1517:        case FTI_BULKEND:
        !          1518:            FTGFREE (ftg);
        !          1519:            break;
        !          1520: 
        !          1521:        default:
        !          1522:            break;
        !          1523:     }
        !          1524:     PXFREE (px);
        !          1525: 
        !          1526:     freefsblk (fsb);
        !          1527:     return NOTOK;
        !          1528: }
        !          1529: 
        !          1530: /*  */
        !          1531: 
        !          1532: static int  doPStokens (fsb, pt, fti)
        !          1533: register struct ftamblk   *fsb;
        !          1534: register struct PSAPtoken *pt;
        !          1535: struct FTAMindication *fti;
        !          1536: {
        !          1537:     (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1538:            "unexpected token indication (0x%x)", pt -> pt_type);
        !          1539:     PTFREE (pt);
        !          1540: 
        !          1541:     freefsblk (fsb);
        !          1542:     return NOTOK;
        !          1543: }
        !          1544: 
        !          1545: /*  */
        !          1546: 
        !          1547: static int  doPSsync (fsb, pn, fti)
        !          1548: register struct ftamblk   *fsb;
        !          1549: register struct PSAPsync *pn;
        !          1550: struct FTAMindication *fti;
        !          1551: {
        !          1552:     register int i;
        !          1553:     struct PSAPdata pxs;
        !          1554:     register struct PSAPdata *px = &pxs;
        !          1555: 
        !          1556:     switch (pn -> pn_type) {
        !          1557:        case SN_RESETCNF:
        !          1558:                break;
        !          1559:        case SN_RESETIND:
        !          1560:            if (pn -> pn_options == SYNC_ABANDON)
        !          1561:                break;          /* else fall */
        !          1562: 
        !          1563:        default:
        !          1564:            (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1565:                        "unexpected sync indication (0x%x)", pn -> pn_type);
        !          1566:            PNFREE (pn);
        !          1567: 
        !          1568:            freefsblk (fsb);
        !          1569:            return NOTOK;
        !          1570:     }
        !          1571: 
        !          1572:     fsb -> fsb_settings = pn -> pn_settings;
        !          1573: #define dotoken(requires,shift,bit,type) \
        !          1574: { \
        !          1575:     if (fsb -> fsb_srequirements & requires) \
        !          1576:        switch (fsb -> fsb_settings & (ST_MASK << shift)) { \
        !          1577:            default: \
        !          1578:                fsb -> fsb_settings &= ~(ST_MASK << shift); \
        !          1579:                fsb -> fsb_settings |= ST_INIT_VALUE << shift; \
        !          1580:  \
        !          1581:            case ST_INIT_VALUE << shift: \
        !          1582:                fsb -> fsb_owned |= bit; \
        !          1583:                fsb -> fsb_avail |= bit; \
        !          1584:                break; \
        !          1585:  \
        !          1586:            case ST_RESP_VALUE << shift: \
        !          1587:                fsb -> fsb_avail |= bit; \
        !          1588:                break; \
        !          1589:        } \
        !          1590: }
        !          1591:     dotokens ();
        !          1592: #undef dotoken
        !          1593: 
        !          1594:     if (pn -> pn_type == SN_RESETCNF && pn -> pn_ninfo == 0) {
        !          1595:        register struct FTAMcancel *ftcn = &fti -> fti_cancel;
        !          1596: 
        !          1597:        bzero ((char *) ftcn, sizeof *ftcn);
        !          1598:        ftcn -> ftcn_action = FACTION_SUCCESS;/* what else can be done? */
        !          1599: 
        !          1600:        fsb -> fsb_flags &= ~FSB_CANCEL;
        !          1601:        fsb -> fsb_state = FSB_DATAIDLE;
        !          1602: 
        !          1603:        PNFREE (pn);
        !          1604:        return DONE;
        !          1605:     }
        !          1606: 
        !          1607:     bzero ((char *) px, sizeof *px);
        !          1608:     for (i = pn -> pn_ninfo - 1; i >= 0; i--) {
        !          1609:        px -> px_info[i] = pn -> pn_info[i];
        !          1610:        pn -> pn_info[i] = NULLPE;
        !          1611:     }
        !          1612:     px -> px_ninfo = pn -> pn_ninfo;
        !          1613:     PNFREE (pn);
        !          1614: 
        !          1615:     return doPSdata (fsb, px, fti);
        !          1616: }
        !          1617: 
        !          1618: /*  */
        !          1619: 
        !          1620: static int  doPSactivity (fsb, pv, fti)
        !          1621: register struct ftamblk   *fsb;
        !          1622: register struct PSAPactivity *pv;
        !          1623: struct FTAMindication *fti;
        !          1624: {
        !          1625:     (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1626:            "unexpected activity indication (0x%x)", pv -> pv_type);
        !          1627:     PVFREE (pv);
        !          1628: 
        !          1629:     freefsblk (fsb);
        !          1630:     return NOTOK;
        !          1631: }
        !          1632: 
        !          1633: /*  */
        !          1634: 
        !          1635: static int  doPSreport (fsb, pp, fti)
        !          1636: register struct ftamblk   *fsb;
        !          1637: register struct PSAPreport *pp;
        !          1638: struct FTAMindication *fti;
        !          1639: {
        !          1640:     (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP,
        !          1641:            "unexpected exception report indication (0x%x)", pp -> pp_peer);
        !          1642:     PPFREE (pp);
        !          1643: 
        !          1644:     freefsblk (fsb);
        !          1645:     return NOTOK;
        !          1646: }
        !          1647: 
        !          1648: /*  */
        !          1649: 
        !          1650: static int  doPSfinish (fsb, pf, fti)
        !          1651: register struct ftamblk   *fsb;
        !          1652: register struct PSAPfinish *pf;
        !          1653: struct FTAMindication *fti;
        !          1654: {
        !          1655:     PE     pe;
        !          1656:     struct AcSAPindication  acis;
        !          1657:     register struct AcSAPabort *aca = &acis.aci_abort;
        !          1658:     register struct AcSAPfinish *acf = &acis.aci_finish;
        !          1659:     struct type_FTAM_PDU *pdu;
        !          1660:     register struct type_FTAM_F__TERMINATE__request *req;
        !          1661: 
        !          1662:     pdu = NULL;
        !          1663:     if ((fsb -> fsb_flags & FSB_INIT) || fsb -> fsb_state != FSB_INITIALIZED) {
        !          1664:        (void) fpktlose (fsb, fti, FS_ACS_MGMT, NULLCP,
        !          1665:                "association management botched");
        !          1666:        PFFREE (pf);
        !          1667:        goto out1;
        !          1668:     }
        !          1669: 
        !          1670:     if (AcFINISHser (fsb -> fsb_fd, pf, &acis) == NOTOK) {
        !          1671:        (void) acs2ftamlose (fsb, fti, "AcFINISHser", aca);
        !          1672:        goto out1;
        !          1673:     }
        !          1674: 
        !          1675:     if (acf -> acf_ninfo < 1 || (pe = acf -> acf_info[0]) == NULLPE) {
        !          1676:        (void) fpktlose (fsb, fti, FS_PRO_ERR, NULLCP, NULLCP);
        !          1677:        goto out2;
        !          1678:     }
        !          1679: 
        !          1680:     if (decode_FTAM_PDU (pe, 1, NULLIP, NULLVP, &pdu) == NOTOK) {
        !          1681:        (void) fpktlose (fsb, fti, FS_PRO_ERRMSG, NULLCP,
        !          1682:                         "unable to parse PDU: %s", PY_pepy);
        !          1683:        goto out2;
        !          1684:     }
        !          1685:     if (pdu -> offset != type_FTAM_PDU_f__terminate__request) {
        !          1686:        (void) fpktlose (fsb, fti, FS_PRO_ERRPROC, NULLCP,
        !          1687:                         "expecting F-TERMINATE-request, got %d",
        !          1688:                         pdu -> offset);
        !          1689:        goto out2;
        !          1690:     }
        !          1691:     req = pdu -> un.f__terminate__request;
        !          1692: 
        !          1693:     fsbtrace (fsb, (fsb -> fsb_fd, "A-RELEASE.INDICATION",
        !          1694:                "F-TERMINATE-request", pe, 1));
        !          1695: 
        !          1696:     ACFFREE (acf);
        !          1697: 
        !          1698:     fti -> fti_type = FTI_FINISH;
        !          1699:     {
        !          1700:        register struct FTAMfinish *ftf = &fti -> fti_finish;
        !          1701: 
        !          1702:        bzero ((char *) ftf, sizeof *ftf);
        !          1703:        if (req && fpm2shared (fsb, req, &ftf -> ftf_sharedASE, fti) == NOTOK)
        !          1704:            goto out2;
        !          1705:     }
        !          1706:     fsb -> fsb_flags |= FSB_FINN;
        !          1707: 
        !          1708:     free_FTAM_PDU (pdu);
        !          1709:     return DONE;
        !          1710: 
        !          1711: out2:  ;
        !          1712:     ACFFREE (acf);
        !          1713: out1:  ;
        !          1714:     if (pdu)
        !          1715:        free_FTAM_PDU (pdu);
        !          1716:     freefsblk (fsb);
        !          1717:     return NOTOK;
        !          1718: }
        !          1719: 
        !          1720: /*  */
        !          1721: 
        !          1722: static int  doPSabort (fsb, pa, fti)
        !          1723: register struct ftamblk *fsb;
        !          1724: register struct PSAPabort *pa;
        !          1725: struct FTAMindication *fti;
        !          1726: {
        !          1727:     struct AcSAPindication  acis;
        !          1728:     register struct AcSAPabort *aca = &acis.aci_abort;
        !          1729: 
        !          1730:     if (!pa -> pa_peer && pa -> pa_reason == PC_TIMER)
        !          1731:        return ftamlose (fti, FS_PRO_TIMEOUT, 0, NULLCP, NULLCP);
        !          1732: 
        !          1733:     if (AcABORTser (fsb -> fsb_fd, pa, &acis) == NOTOK) {
        !          1734:        (void) acs2ftamlose (fsb, fti, "AcABORTser", aca);
        !          1735:        fsb -> fsb_fd = NOTOK;
        !          1736:        freefsblk (fsb);
        !          1737: 
        !          1738:        return NOTOK;
        !          1739:     }
        !          1740: 
        !          1741:     return acs2ftamabort (fsb, aca, fti);
        !          1742: }
        !          1743: 
        !          1744: /*  */
        !          1745: 
        !          1746: static int  psDATAser (sd, px)
        !          1747: int    sd;
        !          1748: register struct PSAPdata *px;
        !          1749: {
        !          1750:     IFP            handler;
        !          1751:     register struct ftamblk   *fsb;
        !          1752:     struct FTAMindication  ftis;
        !          1753:     register struct FTAMindication *fti = &ftis;
        !          1754: 
        !          1755:     if ((fsb = findfsblk (sd)) == NULL)
        !          1756:        return;
        !          1757:     handler = fsb -> fsb_indication;
        !          1758: 
        !          1759:     if (doPSdata (fsb, px, fti) != OK)
        !          1760:        (*handler) (sd, fti);
        !          1761: }
        !          1762: 
        !          1763: /*  */
        !          1764: 
        !          1765: static int  psTOKENser (sd, pt)
        !          1766: int    sd;
        !          1767: register struct PSAPtoken *pt;
        !          1768: {
        !          1769:     IFP            handler;
        !          1770:     register struct ftamblk   *fsb;
        !          1771:     struct FTAMindication  ftis;
        !          1772:     register struct FTAMindication *fti = &ftis;
        !          1773: 
        !          1774:     if ((fsb = findfsblk (sd)) == NULL)
        !          1775:        return;
        !          1776:     handler = fsb -> fsb_indication;
        !          1777: 
        !          1778:     if (doPStokens (fsb, pt, fti) != OK)
        !          1779:        (*handler) (sd, fti);
        !          1780: }
        !          1781: 
        !          1782: /*  */
        !          1783: 
        !          1784: static int  psSYNCser (sd, pn)
        !          1785: int    sd;
        !          1786: register struct PSAPsync *pn;
        !          1787: {
        !          1788:     IFP            handler;
        !          1789:     register struct ftamblk   *fsb;
        !          1790:     struct FTAMindication  ftis;
        !          1791:     register struct FTAMindication *fti = &ftis;
        !          1792: 
        !          1793:     if ((fsb = findfsblk (sd)) == NULL)
        !          1794:        return;
        !          1795:     handler = fsb -> fsb_indication;
        !          1796: 
        !          1797:     if (doPSsync (fsb, pn, fti) != OK)
        !          1798:        (*handler) (sd, fti);
        !          1799: }
        !          1800: 
        !          1801: /*  */
        !          1802: 
        !          1803: static int  psACTIVITYser (sd, pv)
        !          1804: int    sd;
        !          1805: register struct PSAPactivity *pv;
        !          1806: {
        !          1807:     IFP            handler;
        !          1808:     register struct ftamblk   *fsb;
        !          1809:     struct FTAMindication  ftis;
        !          1810:     register struct FTAMindication *fti = &ftis;
        !          1811: 
        !          1812:     if ((fsb = findfsblk (sd)) == NULL)
        !          1813:        return;
        !          1814:     handler = fsb -> fsb_indication;
        !          1815: 
        !          1816:     if (doPSactivity (fsb, pv, fti) != OK)
        !          1817:        (*handler) (sd, fti);
        !          1818: }
        !          1819: 
        !          1820: /*  */
        !          1821: 
        !          1822: static int  psREPORTser (sd, pp)
        !          1823: int    sd;
        !          1824: register struct PSAPreport *pp;
        !          1825: {
        !          1826:     IFP            handler;
        !          1827:     register struct ftamblk   *fsb;
        !          1828:     struct FTAMindication  ftis;
        !          1829:     register struct FTAMindication *fti = &ftis;
        !          1830: 
        !          1831:     if ((fsb = findfsblk (sd)) == NULL)
        !          1832:        return;
        !          1833:     handler = fsb -> fsb_indication;
        !          1834: 
        !          1835:     if (doPSreport (fsb, pp, fti) != OK)
        !          1836:        (*handler) (sd, fti);
        !          1837: }
        !          1838: 
        !          1839: /*  */
        !          1840: 
        !          1841: static int  psFINISHser (sd, pf)
        !          1842: int    sd;
        !          1843: struct PSAPfinish *pf;
        !          1844: {
        !          1845:     IFP            handler;
        !          1846:     register struct ftamblk   *fsb;
        !          1847:     struct FTAMindication  ftis;
        !          1848:     register struct FTAMindication *fti = &ftis;
        !          1849: 
        !          1850:     if ((fsb = findfsblk (sd)) == NULL)
        !          1851:        return;
        !          1852:     handler = fsb -> fsb_indication;
        !          1853: 
        !          1854:     if (doPSfinish (fsb, pf, fti) != OK)
        !          1855:        (*handler) (sd, fti);
        !          1856: }
        !          1857: 
        !          1858: /*  */
        !          1859: 
        !          1860: static int  psABORTser (sd, pa)
        !          1861: int    sd;
        !          1862: register struct PSAPabort *pa;
        !          1863: {
        !          1864:     IFP            handler;
        !          1865:     register struct ftamblk   *fsb;
        !          1866:     struct FTAMindication  ftis;
        !          1867:     register struct FTAMindication *fti = &ftis;
        !          1868: 
        !          1869:     if ((fsb = findfsblk (sd)) == NULL)
        !          1870:        return;
        !          1871:     handler = fsb -> fsb_indication;
        !          1872: 
        !          1873:     if (doPSabort (fsb, pa, fti) != OK)
        !          1874:        (*handler) (sd, fti);
        !          1875: }
        !          1876: 
        !          1877: /*    define vector for INDICATION events */
        !          1878: 
        !          1879: #define        e(i)    (indication ? (i) : NULLIFP)
        !          1880: 
        !          1881: 
        !          1882: int    FSetIndications (sd, indication, fti)
        !          1883: int    sd;
        !          1884: IFP    indication;
        !          1885: struct FTAMindication *fti;
        !          1886: {
        !          1887:     SBV     smask;
        !          1888:     register struct ftamblk *fsb;
        !          1889:     struct PSAPindication   pis;
        !          1890:     register struct PSAPabort  *pa = &pis.pi_abort;
        !          1891: 
        !          1892:     missingP (fti);
        !          1893: 
        !          1894:     smask = sigioblock ();
        !          1895: 
        !          1896:     ftamPsig (fsb, sd);
        !          1897: 
        !          1898:     if (PSetIndications (fsb -> fsb_fd, e (psDATAser), e (psTOKENser),
        !          1899:                e (psSYNCser), e (psACTIVITYser), e (psREPORTser),
        !          1900:                e (psFINISHser), e (psABORTser), &pis) == NOTOK)
        !          1901:        switch (pa -> pa_reason) {
        !          1902:            case PC_WAITING: 
        !          1903:                (void) sigiomask (smask);
        !          1904:                return ftamlose (fti, FS_GEN_WAITING, 0, NULLCP, NULLCP);
        !          1905: 
        !          1906:            default: 
        !          1907:                (void) ps2ftamlose (fsb, fti, "PSetIndications", pa);
        !          1908:                freefsblk (fsb);
        !          1909:                (void) sigiomask (smask);
        !          1910:                return NOTOK;
        !          1911:        }
        !          1912: 
        !          1913:     if (fsb -> fsb_indication = indication)
        !          1914:        fsb -> fsb_flags |= FSB_ASYN;
        !          1915:     else
        !          1916:        fsb -> fsb_flags &= ~FSB_ASYN;
        !          1917: 
        !          1918:     (void) sigiomask (smask);
        !          1919: 
        !          1920:     return OK;
        !          1921: }
        !          1922: 
        !          1923: #undef e
        !          1924: 
        !          1925: /*    AcSAP interface */
        !          1926: 
        !          1927: int    acs2ftamlose (fsb, fti, event, aca)
        !          1928: register struct ftamblk *fsb;
        !          1929: struct FTAMindication *fti;
        !          1930: char   *event;
        !          1931: register struct AcSAPabort *aca;
        !          1932: {
        !          1933:     int     observer,
        !          1934:             reason;
        !          1935:     char   *cp,
        !          1936:             buffer[BUFSIZ];
        !          1937: 
        !          1938:     if (fsb && fsb -> fsb_trace && event) {
        !          1939:        cp = buffer;
        !          1940:        (void) sprintf (cp, "%s: %s", event, AcErrString (aca -> aca_reason));
        !          1941:        if (aca -> aca_cc > 0) {
        !          1942:            cp += strlen (cp);
        !          1943:            (void) sprintf (cp, " [%*.*s]", aca -> aca_cc, aca -> aca_cc,
        !          1944:                    aca -> aca_data);
        !          1945:        }
        !          1946: 
        !          1947:        fsbtrace (fsb, (fsb -> fsb_fd, buffer, NULLCP, NULLPE, -1));
        !          1948:     }
        !          1949: 
        !          1950:     cp = "";
        !          1951:     switch (aca -> aca_reason) {
        !          1952:        case ACS_ADDRESS: 
        !          1953:            reason = FS_PRO_LOWADDR;
        !          1954:            (void) sprintf (cp = buffer, " (%s)", AcErrString (ACS_ADDRESS));
        !          1955:            break;
        !          1956: 
        !          1957:        case ACS_REFUSED: 
        !          1958:            reason = FS_PRO_LOWFAIL;
        !          1959:            (void) sprintf (cp = buffer, " (%s)", AcErrString (ACS_REFUSED));
        !          1960:            break;
        !          1961: 
        !          1962:        default: 
        !          1963:            (void) sprintf (cp = buffer, " (%s at association control)",
        !          1964:                    AcErrString (aca -> aca_reason));
        !          1965:        case ACS_CONGEST: 
        !          1966:        case ACS_PARAMETER: 
        !          1967:        case ACS_OPERATION: 
        !          1968:        case ACS_PRESENTATION: 
        !          1969:            reason = FS_PRO_LOWFAIL;
        !          1970:            break;
        !          1971:     }
        !          1972: 
        !          1973:     if (fsb) {
        !          1974:        if (fsb -> fsb_flags & FSB_INIT)
        !          1975:            observer = EREF_IFPM;
        !          1976:        else
        !          1977:            observer = EREF_RFPM;
        !          1978:     }
        !          1979:     else
        !          1980:        observer = EREF_NONE;
        !          1981: 
        !          1982:     if (aca -> aca_cc > 0)
        !          1983:        return ftamoops (fti, reason, ACS_FATAL (aca -> aca_reason), observer,
        !          1984:                EREF_NONE, NULLCP, "%*.*s%s", aca -> aca_cc, aca -> aca_cc,
        !          1985:                aca -> aca_data, cp);
        !          1986:     else
        !          1987:        return ftamoops (fti, reason, ACS_FATAL (aca -> aca_reason), observer,
        !          1988:                EREF_NONE, NULLCP, "%s", *cp ? cp + 1 : cp);
        !          1989: }
        !          1990: 
        !          1991: /*  */
        !          1992: 
        !          1993: int    acs2ftamabort (fsb, aca, fti)
        !          1994: register struct ftamblk *fsb;
        !          1995: register struct AcSAPabort *aca;
        !          1996: struct FTAMindication *fti;
        !          1997: {
        !          1998:     int     peer;
        !          1999:     PE     pe;
        !          2000:     register struct FTAMabort  *fta = &fti -> fti_abort;
        !          2001:     struct type_FTAM_PDU *pdu;
        !          2002:     register struct type_FTAM_F__U__ABORT__request *req;
        !          2003: 
        !          2004:     pdu = NULL;
        !          2005:     if (aca -> aca_source != ACA_USER) {
        !          2006:        (void) acs2ftamlose (fsb, fti, NULLCP, aca);
        !          2007:        goto out;
        !          2008:     }
        !          2009: 
        !          2010:     if (aca -> aca_ninfo < 1 || (pe = aca -> aca_info[0]) == NULLPE) {
        !          2011:        (void) ftamlose (fti, FS_PRO_ERR, 1, NULLCP, NULLCP);
        !          2012:        goto out;
        !          2013:     }
        !          2014: 
        !          2015:     if (decode_FTAM_PDU (pe, 1, NULLIP, NULLVP, &pdu) == NOTOK) {
        !          2016:        (void) ftamlose (fti, FS_PRO_ERRMSG, 1, NULLCP,
        !          2017:                         "unable to parse PDU: %s", PY_pepy);
        !          2018:        goto out;
        !          2019:     }
        !          2020:     switch (pdu -> offset) {
        !          2021:        case type_FTAM_PDU_f__u__abort__request:
        !          2022:            peer = 1;
        !          2023:            req = pdu -> un.f__u__abort__request;
        !          2024:            break;
        !          2025: 
        !          2026:        case type_FTAM_PDU_f__p__abort__request:
        !          2027:            peer = 0;   /* F-P-ABORT-request is identical... */
        !          2028:            req = pdu -> un.f__u__abort__request;
        !          2029:            break;
        !          2030: 
        !          2031:        default:
        !          2032:            (void) ftamlose (fti, FS_PRO_ERRPROC, 1, NULLCP,
        !          2033:                             "expecting F-{U,P}-ABORT-request, got %d",
        !          2034:                             pdu -> offset);
        !          2035:            goto out;
        !          2036:     }
        !          2037:     fsbtrace (fsb, (fsb -> fsb_fd, "A-ABORT.INDICATION",
        !          2038:                    pdu -> offset != type_FTAM_PDU_f__u__abort__request
        !          2039:                        ? "F-P-ABORT-request" : "F-U-ABORT-request",
        !          2040:                    pe, 1));
        !          2041: 
        !          2042:     fti -> fti_type = FTI_ABORT;
        !          2043: 
        !          2044:     fta -> fta_peer = peer;
        !          2045:     fta -> fta_action = req -> action__result ? req -> action__result -> parm
        !          2046:                                              :int_FTAM_Action__Result_success;
        !          2047:     if (req -> diagnostic)
        !          2048:        (void) fpm2diag (fsb, req -> diagnostic, fta -> fta_diags,
        !          2049:                         &fta -> fta_ndiag, fti);
        !          2050: 
        !          2051: out: ;
        !          2052:     ACAFREE (aca);
        !          2053:     if (pdu)
        !          2054:        free_FTAM_PDU (pdu);
        !          2055: 
        !          2056:     fsb -> fsb_fd = NOTOK;
        !          2057:     freefsblk (fsb);
        !          2058: 
        !          2059:     return NOTOK;
        !          2060: }
        !          2061: 
        !          2062: /*    PSAP interface */
        !          2063: 
        !          2064: int    ps2ftamlose (fsb, fti, event, pa)
        !          2065: register struct ftamblk *fsb;
        !          2066: struct FTAMindication *fti;
        !          2067: char   *event;
        !          2068: register struct PSAPabort *pa;
        !          2069: {
        !          2070:     int     observer,
        !          2071:             reason;
        !          2072:     char   *cp,
        !          2073:             buffer[BUFSIZ];
        !          2074: 
        !          2075:     if (fsb && fsb -> fsb_trace && event) {
        !          2076:        cp = buffer;
        !          2077:        (void) sprintf (cp, "%s: %s", event, PErrString (pa -> pa_reason));
        !          2078:        if (pa -> pa_cc > 0) {
        !          2079:            cp += strlen (cp);
        !          2080:            (void) sprintf (cp, " [%*.*s]", pa -> pa_cc, pa -> pa_cc,
        !          2081:                    pa -> pa_data);
        !          2082:        }
        !          2083: 
        !          2084:        fsbtrace (fsb, (fsb -> fsb_fd, buffer, NULLCP, NULLPE, -1));
        !          2085:     }
        !          2086: 
        !          2087:     cp = "";
        !          2088:     switch (pa -> pa_reason) {
        !          2089:        case PC_PARAMETER: 
        !          2090:        case PC_OPERATION: 
        !          2091:        default:
        !          2092:            (void) sprintf (cp = buffer, " (%s at presentation)",
        !          2093:                    PErrString (pa -> pa_reason));
        !          2094:        case PC_CONGEST: 
        !          2095:        case PC_SESSION: 
        !          2096:            reason = FS_PRO_LOWFAIL;
        !          2097:            break;
        !          2098:     }
        !          2099: 
        !          2100:     if (fsb) {
        !          2101:        if (fsb -> fsb_flags & FSB_INIT)
        !          2102:            observer = EREF_IFPM;
        !          2103:        else
        !          2104:            observer = EREF_RFPM;
        !          2105:     }
        !          2106:     else
        !          2107:        observer = EREF_NONE;
        !          2108: 
        !          2109:     if (pa -> pa_cc > 0)
        !          2110:        return ftamoops (fti, reason, PC_FATAL (pa -> pa_reason), observer,
        !          2111:                EREF_NONE, NULLCP, "%*.*s%s", pa -> pa_cc, pa -> pa_cc,
        !          2112:                pa -> pa_data, cp);
        !          2113:     else
        !          2114:        return ftamoops (fti, reason, PC_FATAL (pa -> pa_reason), observer,
        !          2115:                EREF_NONE, NULLCP, "%s", *cp ? cp + 1 : cp);
        !          2116: }
        !          2117: 
        !          2118: /*    INTERNAL */
        !          2119: 
        !          2120: struct ftamblk *newfsblk () {
        !          2121:     register struct ftamblk *fsb;
        !          2122: 
        !          2123:     fsb = (struct ftamblk  *) calloc (1, sizeof *fsb);
        !          2124:     if (fsb == NULL)
        !          2125:        return NULL;
        !          2126: 
        !          2127:     fsb -> fsb_fd = NOTOK;
        !          2128: 
        !          2129:     if (once_only == 0) {
        !          2130:        FSHead -> fsb_forw = FSHead -> fsb_back = FSHead;
        !          2131:        once_only++;
        !          2132:     }
        !          2133: 
        !          2134:     insque (fsb, FSHead -> fsb_back);
        !          2135: 
        !          2136:     return fsb;
        !          2137: }
        !          2138: 
        !          2139: /*  */
        !          2140: 
        !          2141: freefsblk (fsb)
        !          2142: register struct ftamblk *fsb;
        !          2143: {
        !          2144:     register int    i;
        !          2145:     register struct PSAPcontext *pp;
        !          2146:     register struct FTAMcontent *fcont;
        !          2147: 
        !          2148:     if (fsb == NULL)
        !          2149:        return;
        !          2150: 
        !          2151:     if (fsb -> fsb_fd != NOTOK) {
        !          2152:        struct AcSAPindication  acis;
        !          2153: 
        !          2154:        fsbtrace (fsb, (fsb -> fsb_fd, "A-ABORT.REQUEST(discard)",
        !          2155:                NULLCP, NULLPE, 0));
        !          2156: 
        !          2157:        (void) AcUAbortRequest (fsb -> fsb_fd, NULLPEP, 0, &acis);
        !          2158:     }
        !          2159: 
        !          2160:     if (fsb -> fsb_context)
        !          2161:        oid_free (fsb -> fsb_context), fsb -> fsb_context = NULLOID;
        !          2162: 
        !          2163:     for (pp = fsb -> fsb_contexts.pc_ctx, i = fsb -> fsb_contexts.pc_nctx - 1;
        !          2164:            i >= 0; 
        !          2165:            pp++, i--) {
        !          2166:        if (pp -> pc_asn)
        !          2167:            oid_free (pp -> pc_asn);
        !          2168:     }
        !          2169:     fsb -> fsb_contexts.pc_nctx = 0;
        !          2170: 
        !          2171:     for (fcont = fsb -> fsb_contents.fc_contents,
        !          2172:                i = fsb -> fsb_contents.fc_ncontent - 1;
        !          2173:             i >= 0;
        !          2174:             fcont++, i--) {
        !          2175:        if (fcont -> fc_dtn)
        !          2176:            oid_free (fcont -> fc_dtn);
        !          2177:     }
        !          2178:     fsb -> fsb_contents.fc_ncontent = 0;
        !          2179: 
        !          2180:     PXFREE (&fsb -> fsb_data);
        !          2181: 
        !          2182:     if (fsb -> fsb_cancelshared)
        !          2183:        pe_free (fsb -> fsb_cancelshared);
        !          2184: 
        !          2185:     remque (fsb);
        !          2186: 
        !          2187:     free ((char *) fsb);
        !          2188: }
        !          2189: 
        !          2190: /*  */
        !          2191: 
        !          2192: struct ftamblk   *findfsblk (sd)
        !          2193: register int sd;
        !          2194: {
        !          2195:     register struct ftamblk *fsb;
        !          2196: 
        !          2197:     if (once_only == 0)
        !          2198:        return NULL;
        !          2199: 
        !          2200:     for (fsb = FSHead -> fsb_forw; fsb != FSHead; fsb = fsb -> fsb_forw)
        !          2201:        if (fsb -> fsb_fd == sd)
        !          2202:            return fsb;
        !          2203: 
        !          2204:     return NULL;
        !          2205: }

unix.superglobalmegacorp.com

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