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

1.1     ! root        1: /* rt2ss.c - RTPM: SSAP interface */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2ss.c,v 7.2 90/07/01 21:07:02 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/rtsap/RCS/rt2ss.c,v 7.2 90/07/01 21:07:02 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       rt2ss.c,v $
        !            12:  * Revision 7.2  90/07/01  21:07:02  mrose
        !            13:  * pepsy
        !            14:  * 
        !            15:  * Revision 6.2  89/06/23  11:28:36  mrose
        !            16:  * touch-up
        !            17:  * 
        !            18:  * Revision 6.1  89/05/31  15:02:28  mrose
        !            19:  * sek
        !            20:  * 
        !            21:  * Revision 6.0  89/03/18  23:43:15  mrose
        !            22:  * Release 5.0
        !            23:  * 
        !            24:  */
        !            25: 
        !            26: /*
        !            27:  *                               NOTICE
        !            28:  *
        !            29:  *    Acquisition, use, and distribution of this module and related
        !            30:  *    materials are subject to the restrictions of a license agreement.
        !            31:  *    Consult the Preface in the User's Manual for the full terms of
        !            32:  *    this agreement.
        !            33:  *
        !            34:  */
        !            35: 
        !            36: 
        !            37: /* LINTLIBRARY */
        !            38: 
        !            39: #include <stdio.h>
        !            40: #include "RTS-types.h"
        !            41: #include "OACS-types.h"
        !            42: #include "rtpkt.h"
        !            43: #include "tailor.h"
        !            44: 
        !            45: /*    DATA */
        !            46: 
        !            47: #define        doSSabort       ss2rtsabort
        !            48: 
        !            49: 
        !            50: int    ssDATAser (), ssTOKENser (), ssSYNCser (), ssACTIVITYser (),
        !            51:        ssREPORTser (), ssFINISHser (), ssABORTser ();
        !            52: 
        !            53: 
        !            54: long   time ();
        !            55: 
        !            56: /*  */
        !            57: 
        !            58: int    rt2sspturn (acb, priority, rti)
        !            59: register struct assocblk *acb;
        !            60: int    priority;
        !            61: register struct RtSAPindication *rti;
        !            62: {
        !            63:     int     result,
        !            64:             len;
        !            65:     char   *base;
        !            66:     PE     pe;
        !            67:     struct SSAPindication   sis;
        !            68:     struct SSAPindication *si = &sis;
        !            69:     struct SSAPabort  *sa = &si -> si_abort;
        !            70: 
        !            71:     if (!(acb -> acb_flags & ACB_TWA))
        !            72:        return rtsaplose (rti, RTS_OPERATION, NULLCP,
        !            73:                "mode of association is monologue");
        !            74:     if (acb -> acb_flags & ACB_TURN)
        !            75:        return rtsaplose (rti, RTS_OPERATION, NULLCP, "turn owned by you");
        !            76: 
        !            77: /* begin Priority PSDU (pseudo) */
        !            78:     if ((pe = int2prim (priority)) == NULLPE)
        !            79:        return rtsaplose (rti, RTS_CONGEST, NULLCP, NULLCP);
        !            80: /* end Priority PSDU */
        !            81: 
        !            82:     PLOGP (rtsap_log,OACS_Priority, pe, "Priority", 0);
        !            83: 
        !            84:     result = pe2ssdu (pe, &base, &len);
        !            85:     pe_free (pe);
        !            86:     if (result == NOTOK)
        !            87:        return rtsaplose (rti, RTS_CONGEST, NULLCP, NULLCP);
        !            88: 
        !            89:     result = SPTokenRequest (acb -> acb_fd, ST_DAT_TOKEN, base, len, si);
        !            90:     free (base);
        !            91: 
        !            92:     if (result == NOTOK) {
        !            93:        (void) ss2rtslose (acb, rti, "SPTokenRequest", sa);
        !            94:        freeacblk (acb);
        !            95:     }
        !            96: 
        !            97:     return result;
        !            98: }
        !            99: 
        !           100: /*  */
        !           101: 
        !           102: int    rt2ssgturn (acb, rti)
        !           103: register struct assocblk *acb;
        !           104: register struct RtSAPindication *rti;
        !           105: {
        !           106:     struct SSAPindication   sis;
        !           107:     struct SSAPindication *si = &sis;
        !           108:     struct SSAPabort  *sa = &si -> si_abort;
        !           109: 
        !           110:     if (!(acb -> acb_flags & ACB_TWA))
        !           111:        return rtsaplose (rti, RTS_OPERATION, NULLCP,
        !           112:                "mode of association is monologue");
        !           113:     if (!(acb -> acb_flags & ACB_TURN))
        !           114:        return rtsaplose (rti, RTS_OPERATION, NULLCP, "turn not owned by you");
        !           115:     if (acb -> acb_flags & ACB_ACT)
        !           116:        return rtsaplose (rti, RTS_OPERATION, NULLCP, "transfer in progress");
        !           117: 
        !           118:     if (SGControlRequest (acb -> acb_fd, si) == NOTOK) {
        !           119:        (void) ss2rtslose (acb, rti, "SGControlRequest", sa);
        !           120:        freeacblk (acb);
        !           121:        return NOTOK;
        !           122:     }
        !           123: 
        !           124:     acb -> acb_flags &= ~(ACB_TURN | ACB_PLEASE);
        !           125: 
        !           126:     return OK;
        !           127: }
        !           128: 
        !           129: /*  */
        !           130: 
        !           131: int    rt2sstrans (acb, data, secs, rti)
        !           132: register struct assocblk *acb;
        !           133: register PE    data;
        !           134: int    secs;
        !           135: register struct RtSAPindication *rti;
        !           136: {
        !           137:     register int    cc,
        !           138:                     size;
        !           139:     int     result,
        !           140:             len;
        !           141:     long    clock,
        !           142:             limit;
        !           143:     register char  *dp;
        !           144:     char   *base;
        !           145:     PE     pe;
        !           146:     struct SSAPactid    ids;
        !           147:     register struct SSAPactid  *id = &ids;
        !           148:     struct SSAPindication   sis;
        !           149:     struct SSAPindication *si = &sis;
        !           150:     struct SSAPabort  *sa = &si -> si_abort;
        !           151:     struct RtSAPabort *rta = &rti -> rti_abort;
        !           152: 
        !           153:     if (!(acb -> acb_flags & ACB_TURN))
        !           154:        return rtsaplose (rti, RTS_OPERATION, NULLCP, "turn not owned by you");
        !           155:     if (acb -> acb_flags & ACB_ACT)
        !           156:        return rtsaplose (rti, RTS_OPERATION, NULLCP, "transfer in progress");
        !           157: 
        !           158:     if ((pe = int2prim (acb -> acb_actno)) == NULLPE)
        !           159:        return rtsaplose (rti, RTS_CONGEST, NULLCP, NULLCP);
        !           160:     result = pe2ssdu (pe, &base, &len);
        !           161:     pe_free (pe);
        !           162:     if (result == NOTOK)
        !           163:        return rtsaplose (rti, RTS_CONGEST, NULLCP, NULLCP);
        !           164:     bcopy (base, id -> sd_data, (int) (id -> sd_len = len));
        !           165:     free (base);
        !           166:     base = NULL;
        !           167: 
        !           168:     if (SActStartRequest (acb -> acb_fd, id, NULLCP, 0, si) == NOTOK) {
        !           169:        (void) ss2rtslose (acb, rti, "SActStartRequest", sa);
        !           170:        goto out;
        !           171:     }
        !           172: 
        !           173:     acb -> acb_flags |= ACB_ACT;
        !           174: 
        !           175:     if (data && pe2ssdu (data, &base, &len) == NOTOK) {
        !           176:        (void) rtsaplose (rti, RTS_CONGEST, NULLCP, NULLCP);
        !           177:        goto out;
        !           178:     }
        !           179: 
        !           180:     result = OK;
        !           181:     if (acb -> acb_ckpoint == 0) {
        !           182:        if (data == NULLPE) {
        !           183:            if ((*acb -> acb_downtrans) (acb -> acb_fd, &base, &len, 0, 0L,
        !           184:                                         0L, rti) == NOTOK) {
        !           185: bad_trans: ;
        !           186:                if (SActDiscRequest (acb -> acb_fd, SP_LOCAL, si) == NOTOK) {
        !           187:                    (void) ss2rtslose (acb, rti, "SActDiscRequest", sa);
        !           188:                    goto out;
        !           189:                }
        !           190:                goto done;
        !           191:            }
        !           192:            if (len == 0) {
        !           193:                base = NULL;
        !           194:                goto done;
        !           195:            }
        !           196:        }
        !           197: 
        !           198:        if (SDataRequest (acb -> acb_fd, base, len, si) == NOTOK) {
        !           199:            (void) ss2rtslose (acb, rti, "SDataRequest", sa);
        !           200:            goto out;
        !           201:        }
        !           202:     }
        !           203:     else {
        !           204:        size = acb -> acb_ckpoint << 10;        /* units of 1024 octets */
        !           205:        if (acb -> acb_ssdusize >= 0x0100)      /* at least  256 octets */
        !           206:            size = min (size, acb -> acb_ssdusize);
        !           207:        acb -> acb_ssn = acb -> acb_ack = 0L;
        !           208:        if (secs != NOTOK) {
        !           209:            (void) time (&limit);
        !           210:            limit += secs;
        !           211:        }
        !           212: 
        !           213:        if (data == NULLPE) {
        !           214:            if ((*acb -> acb_downtrans) (acb -> acb_fd, &base, &len, size,
        !           215:                                         acb -> acb_ssn, acb -> acb_ack,
        !           216:                                         rti) == NOTOK)
        !           217:                goto bad_trans;
        !           218:            if (len == 0) {
        !           219:                base = NULL;
        !           220:                goto done;
        !           221:            }
        !           222:        }
        !           223: 
        !           224:        dp = base, cc = min (len, size);
        !           225:        if (SDataRequest (acb -> acb_fd, dp, cc, si) == NOTOK) {
        !           226:            (void) ss2rtslose (acb, rti, "SDataRequest", sa);
        !           227:            goto out;
        !           228:        }
        !           229: 
        !           230:        for (dp += cc, len -= cc;
        !           231:                data == NULLPE || len > 0;
        !           232:                dp += cc, len -= cc) {
        !           233:            if (data == NULLPE && len == 0) {
        !           234:                if ((*acb -> acb_downtrans) (acb -> acb_fd, &base, &len, size,
        !           235:                                            acb -> acb_ssn, acb -> acb_ack,
        !           236:                                             rti) == NOTOK)
        !           237:                    goto bad_trans;
        !           238:                if (len == 0) {
        !           239:                    base = NULL;
        !           240:                    break;
        !           241:                }
        !           242:                dp = base;
        !           243:            }
        !           244: 
        !           245:            if (secs != NOTOK) {
        !           246:                (void) time (&clock);
        !           247:                if (limit < clock) {
        !           248:                    result = NOTOK;
        !           249:                    break;
        !           250:                }
        !           251:            }
        !           252: 
        !           253:            if (SMinSyncRequest (acb -> acb_fd, SYNC_CONFIRM,
        !           254:                        &acb -> acb_ssn, NULLCP, 0, si) == NOTOK) {
        !           255:                (void) ss2rtslose (acb, rti, "SMinSyncRequest", sa);
        !           256:                goto out;
        !           257:            }
        !           258: 
        !           259:            if (acb -> acb_ssn - acb -> acb_ack > acb -> acb_window) {
        !           260:                do {
        !           261:                    if (RtWaitRequestAux (acb, NOTOK, 1, rti) == NOTOK) {
        !           262:                        if (RTS_FATAL (rta -> rta_reason))
        !           263:                            acb = NULLACB;
        !           264:                        goto out;
        !           265:                    }
        !           266:                }
        !           267:                while (acb -> acb_ssn - acb -> acb_ack > acb -> acb_window);
        !           268: 
        !           269: #ifdef notdef
        !           270:            /* avoid silly window syndrome */
        !           271:                while (acb -> acb_ssn != acb -> acb_ack)
        !           272:                    if (RtWaitRequestAux (acb, OK, 1, rti) == NOTOK)
        !           273:                        if (rta -> rta_reason != RTS_TIMER) {
        !           274:                            if (RTS_FATAL (rta -> rta_reason))
        !           275:                                acb = NULLACB;
        !           276:                            goto out;
        !           277:                        }
        !           278:                        else
        !           279:                            break;
        !           280: #endif
        !           281:            }
        !           282: 
        !           283:            cc = min (len, size);
        !           284:            if (SDataRequest (acb -> acb_fd, dp, cc, si) == NOTOK) {
        !           285:                (void) ss2rtslose (acb, rti, "SDataRequest", sa);
        !           286:                goto out;
        !           287:            }
        !           288:        }
        !           289:     }
        !           290:     if (data)
        !           291:        free (base);
        !           292:     base = NULL;
        !           293: 
        !           294: done: ;
        !           295:     switch (result) {
        !           296:        case OK: 
        !           297:            if (SActEndRequest (acb -> acb_fd, &acb -> acb_ssn, NULLCP, 0,
        !           298:                        si) == NOTOK) {
        !           299:                (void) ss2rtslose (acb, rti, "SActEndRequest", sa);
        !           300:                goto out;
        !           301:            }
        !           302:            break;
        !           303: 
        !           304:        default: 
        !           305:            acb -> acb_flags |= ACB_TIMER;
        !           306:            if (SActDiscRequest (acb -> acb_fd, SP_LOCAL, si) == NOTOK) {
        !           307:                (void) ss2rtslose (acb, rti, "SActDiscRequest", sa);
        !           308:                goto out;
        !           309:            }
        !           310:            break;
        !           311:     }
        !           312: 
        !           313:     while (acb -> acb_flags & ACB_ACT)
        !           314:        if (RtWaitRequestAux (acb, NOTOK, 1, rti) == NOTOK) {
        !           315:            if (RTS_FATAL (rta -> rta_reason))
        !           316:                acb = NULLACB;
        !           317:            goto out;
        !           318:        }
        !           319: 
        !           320:     acb -> acb_flags &= ~ACB_TIMER;
        !           321:     acb -> acb_actno++;
        !           322: 
        !           323:     return result;
        !           324: 
        !           325: out: ;
        !           326:     if (data && base)
        !           327:        free (base);
        !           328:     if (acb)
        !           329:        freeacblk (acb);
        !           330: 
        !           331:     return NOTOK;
        !           332: }
        !           333: 
        !           334: /*  */
        !           335: 
        !           336: int    rt2sswait (acb, secs, trans, rti)
        !           337: register struct assocblk *acb;
        !           338: int     secs,
        !           339:        trans;
        !           340: register struct RtSAPindication *rti;
        !           341: {
        !           342:     int     result;
        !           343:     struct SSAPdata sxs;
        !           344:     register struct SSAPdata   *sx = &sxs;
        !           345:     struct SSAPindication   sis;
        !           346:     register struct SSAPindication *si = &sis;
        !           347: 
        !           348:     for (;;) {
        !           349:        switch (result = SReadRequest (acb -> acb_fd, sx, secs, si)) {
        !           350:            case NOTOK: 
        !           351:                return doSSabort (acb, &si -> si_abort, rti);
        !           352: 
        !           353:            case OK: 
        !           354:                if (doSSdata (acb, sx, rti) == NOTOK)
        !           355:                    return NOTOK;
        !           356:                continue;
        !           357: 
        !           358:            case DONE: 
        !           359:                switch (si -> si_type) {
        !           360:                    case SI_TOKEN: 
        !           361:                        if ((result = doSStoken (acb, &si -> si_token, trans,
        !           362:                                        rti)) != OK)
        !           363:                            return result;
        !           364:                        continue;
        !           365: 
        !           366:                    case SI_SYNC: 
        !           367:                        if ((result = doSSsync (acb, &si -> si_sync, rti)) != OK
        !           368:                                || trans)
        !           369:                            return result;
        !           370:                        continue;
        !           371: 
        !           372:                    case SI_ACTIVITY: 
        !           373:                        if ((result = doSSactivity (acb, &si -> si_activity, rti)) != OK
        !           374:                                || trans)
        !           375:                            return (result != DONE ? result : OK);
        !           376:                        continue;
        !           377: 
        !           378:                    case SI_REPORT: 
        !           379:                        if (doSSreport (acb, &si -> si_report, rti) == NOTOK)
        !           380:                            return NOTOK;
        !           381:                        continue;
        !           382: 
        !           383:                    case SI_FINISH: 
        !           384:                        return doSSfinish (acb, &si -> si_finish, rti);
        !           385: 
        !           386:                    default: 
        !           387:                        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           388:                                "unknown indication (0x%x) from session",
        !           389:                                si -> si_type);
        !           390:                        break;
        !           391:                }
        !           392:                break;
        !           393: 
        !           394:            default: 
        !           395:                (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           396:                        "unexpected return from SReadRequest=%d", result);
        !           397:                break;
        !           398:        }
        !           399:        break;
        !           400:     }
        !           401: 
        !           402:     freeacblk (acb);
        !           403:     return NOTOK;
        !           404: }
        !           405: 
        !           406: /*    define vectors for INDICATION events */
        !           407: 
        !           408: #define        e(i)    (indication ? (i) : NULLIFP)
        !           409: 
        !           410: 
        !           411: int    rt2ssasync (acb, indication, rti)
        !           412: register struct assocblk   *acb;
        !           413: IFP    indication;
        !           414: struct RtSAPindication *rti;
        !           415: {
        !           416:     struct SSAPindication   sis;
        !           417:     struct SSAPindication *si = &sis;
        !           418:     struct SSAPabort  *sa = &si -> si_abort;
        !           419: 
        !           420:     if (SSetIndications (acb -> acb_fd, e (ssDATAser), e (ssTOKENser),
        !           421:                e (ssSYNCser), e (ssACTIVITYser), e (ssREPORTser),
        !           422:                e (ssFINISHser), e (ssABORTser), si) == NOTOK)
        !           423:        switch (sa -> sa_reason) {
        !           424:            case SC_WAITING: 
        !           425:                return rtsaplose (rti, RTS_WAITING, NULLCP, NULLCP);
        !           426: 
        !           427:            default: 
        !           428:                (void) ss2rtslose (acb, rti, "SSetIndications", sa);
        !           429:                freeacblk (acb);
        !           430:                return NOTOK;
        !           431:        }
        !           432: 
        !           433:     if (acb -> acb_rtsindication = indication)
        !           434:        acb -> acb_flags |= ACB_ASYN;
        !           435:     else
        !           436:        acb -> acb_flags &= ~ACB_ASYN;
        !           437: 
        !           438:     return OK;
        !           439: }
        !           440: 
        !           441: #undef e
        !           442: 
        !           443: /*    map association descriptors for select() */
        !           444: 
        !           445: int    rt2ssmask (acb, mask, nfds, rti)
        !           446: register struct assocblk   *acb;
        !           447: fd_set *mask;
        !           448: int    *nfds;
        !           449: struct RtSAPindication *rti;
        !           450: {
        !           451:     struct SSAPindication   sis;
        !           452:     struct SSAPindication  *si = &sis;
        !           453:     struct SSAPabort   *sa = &si -> si_abort;
        !           454: 
        !           455:     if (SSelectMask (acb -> acb_fd, mask, nfds, si) == NOTOK)
        !           456:        switch (sa -> sa_reason) {
        !           457:            case SC_WAITING: 
        !           458:                return rtsaplose (rti, RTS_WAITING, NULLCP, NULLCP);
        !           459: 
        !           460:            default: 
        !           461:                (void) ss2rtslose (acb, rti, "SSelectMask", sa);
        !           462:                freeacblk (acb);
        !           463:                return NOTOK;
        !           464:        }
        !           465: 
        !           466:     return OK;
        !           467: }
        !           468: 
        !           469: /*    protocol-level abort */
        !           470: 
        !           471: int    rt2sslose (acb, result)
        !           472: register struct assocblk   *acb;
        !           473: int    result;
        !           474: {
        !           475:     int     len;
        !           476:     char   *base;
        !           477:     PE     pe;
        !           478:     struct SSAPindication   sis;
        !           479: 
        !           480:     base = NULL, len = 0;
        !           481: /* begin AbortInformation PSDU (pseudo) */
        !           482:     if (pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET)) {
        !           483:        if (set_add (pe, num2prim (result, PE_CLASS_CONT, 0)) != NOTOK)
        !           484:            (void) pe2ssdu (pe, &base, &len);
        !           485: 
        !           486:        PLOGP (rtsap_log,OACS_AbortInformation, pe, "AbortInformation",
        !           487:              0);
        !           488: 
        !           489: 
        !           490:        pe_free (pe);
        !           491:     }
        !           492: /* end AbortInformation PSDU */
        !           493: 
        !           494:     (void) SUAbortRequest (acb -> acb_fd, base, len, &sis);
        !           495:     if (!(acb -> acb_flags & ACB_STICKY))
        !           496:        acb -> acb_fd = NOTOK;
        !           497: 
        !           498:     if (base)
        !           499:        free (base);
        !           500: }
        !           501: 
        !           502: /*    SSAP interface */
        !           503: 
        !           504: static int  doSSdata (acb, sx, rti)
        !           505: register struct assocblk   *acb;
        !           506: register struct SSAPdata *sx;
        !           507: struct RtSAPindication *rti;
        !           508: {
        !           509:     register struct qbuf *qb;
        !           510:     struct SSAPindication   sis;
        !           511:     register struct SSAPindication *si = &sis;
        !           512:     register struct SSAPabort  *sa = &si -> si_abort;
        !           513: 
        !           514:     if (!(acb -> acb_flags & ACB_ACT)
        !           515:            || (acb -> acb_flags & ACB_TURN)
        !           516:            || sx -> sx_type != SX_NORMAL) {
        !           517:        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           518:                "unexpected data indication (0x%x)", sx -> sx_type);
        !           519:        goto out;
        !           520:     }
        !           521: 
        !           522:     if (acb -> acb_uptrans) {
        !           523:        if ((*acb -> acb_uptrans) (acb -> acb_fd, SI_DATA,
        !           524:                                   (caddr_t) &sx -> sx_qbuf, rti) == NOTOK)
        !           525:            goto congested;
        !           526: 
        !           527:        goto done;
        !           528:     }
        !           529: 
        !           530:     if (acb -> acb_len > 0) {
        !           531:        unsigned int    i;
        !           532:        register char  *cp,
        !           533:                       *dp;
        !           534: 
        !           535:        i = acb -> acb_len + sx -> sx_cc;
        !           536:        if (acb -> acb_realbase) {
        !           537:            if ((dp = malloc (i)) == NULL) {
        !           538:        congested: ;
        !           539:                if (SUReportRequest (acb -> acb_fd, SP_LOCAL, NULLCP, 0,
        !           540:                            si) == NOTOK) {
        !           541:                    (void) ss2rtslose (acb, rti, "SUReportRequest", sa);
        !           542:                    goto out;
        !           543:                }
        !           544:                FREEACB (acb);
        !           545:                goto done;
        !           546:            }
        !           547:            bcopy (acb -> acb_base, dp, acb -> acb_len);
        !           548:            free (acb -> acb_realbase), acb -> acb_realbase = NULL;
        !           549:        }
        !           550:        else
        !           551:            if ((dp = realloc (acb -> acb_base, i)) == NULL)
        !           552:                goto congested;
        !           553: 
        !           554:        cp = dp + acb -> acb_len;
        !           555:        for (qb = sx -> sx_qbuf.qb_forw;
        !           556:                qb != &sx -> sx_qbuf;
        !           557:                qb = qb -> qb_forw)
        !           558:            if (qb -> qb_len) {
        !           559:                bcopy (qb -> qb_data, cp, qb -> qb_len);
        !           560:                cp += qb -> qb_len;
        !           561:            }
        !           562:        acb -> acb_base = dp;
        !           563:        acb -> acb_len = i;
        !           564:     }
        !           565:     else {
        !           566:        if ((qb = sx -> sx_qbuf.qb_forw) != &sx -> sx_qbuf
        !           567:                && qb -> qb_forw == &sx -> sx_qbuf) {
        !           568:            remque (qb);
        !           569: 
        !           570:            acb -> acb_realbase = (char *) qb;
        !           571:            acb -> acb_base = qb -> qb_data;
        !           572:        }
        !           573:        else
        !           574:            acb -> acb_base = qb2str (&sx -> sx_qbuf);
        !           575: 
        !           576:        acb -> acb_len = sx -> sx_cc;
        !           577:     }
        !           578: done: ;
        !           579:     SXFREE (sx);
        !           580: 
        !           581:     return OK;
        !           582: 
        !           583: out: ;
        !           584:     SXFREE (sx);
        !           585: 
        !           586:     freeacblk (acb);
        !           587:     return NOTOK;
        !           588: }
        !           589: 
        !           590: /*  */
        !           591: 
        !           592: static int  doSStoken (acb, st, trans, rti)
        !           593: register struct assocblk   *acb;
        !           594: register struct SSAPtoken *st;
        !           595: int    trans;
        !           596: struct RtSAPindication *rti;
        !           597: {
        !           598:     int     result;
        !           599:     register PE            pe;
        !           600:     struct SSAPindication   sis;
        !           601:     register struct SSAPindication *si = &sis;
        !           602:     register struct SSAPabort  *sa = &si -> si_abort;
        !           603:     struct type_OACS_Priority  *priority;
        !           604: 
        !           605:     if (acb -> acb_flags & ACB_TWA)
        !           606:        switch (st -> st_type) {
        !           607:            case ST_CONTROL: 
        !           608:                STFREE (st);
        !           609:                if (acb -> acb_flags & ACB_ACT)
        !           610:                    break;
        !           611:                acb -> acb_owned = st -> st_owned;
        !           612:                acb -> acb_flags |= ACB_TURN;
        !           613: 
        !           614:                rti -> rti_type = RTI_TURN;
        !           615:                {
        !           616:                    register struct RtSAPturn  *rtu = &rti -> rti_turn;
        !           617: 
        !           618:                    rtu -> rtu_please = 0;
        !           619:                }
        !           620:                return DONE;
        !           621: 
        !           622:            case ST_PLEASE:
        !           623:                pe = ssdu2pe (st -> st_data, st -> st_cc, NULLCP, &result);
        !           624:                STFREE (st);
        !           625:                if (pe == NULLPE) {
        !           626:                    (void) rtpktlose (acb, rti, result != PS_ERR_NMEM
        !           627:                            ? RTS_PROTOCOL : RTS_CONGEST, NULLCP,
        !           628:                            ps_error (result));
        !           629:                    goto out;
        !           630:                }
        !           631:                result = parse_OACS_Priority(pe, 1, NULLIP, NULLVP, &priority);
        !           632: 
        !           633: #ifdef DEBUG
        !           634:                if (result != NOTOK && (rtsap_log -> ll_events & LLOG_PDUS))
        !           635:                    pvpdu (rtsap_log, print_OACS_Priority_P, pe, "Priority",
        !           636:                           1);
        !           637: #endif
        !           638: 
        !           639:                pe_free (pe);
        !           640:                if (result == NOTOK) {
        !           641:                    (void) pylose ();
        !           642:                    free_OACS_Priority(priority);
        !           643:                    goto out;
        !           644:                }
        !           645: 
        !           646:                if (trans) {
        !           647:                    if (acb -> acb_downtrans) {
        !           648:                        if ((*acb -> acb_downtrans) (acb -> acb_fd, NULLVP,
        !           649:                                                    NULLIP, priority -> parm,
        !           650:                                                    0L, 0L, rti) == NOTOK
        !           651:                                && SActIntrRequest (acb -> acb_fd, SP_LOCAL,
        !           652:                                                    si) == NOTOK) {
        !           653:                            (void) ss2rtslose (acb, rti, "SActIntrRequest",sa);
        !           654:                            free_OACS_Priority(priority);
        !           655:                            goto out;
        !           656:                        }
        !           657:                    }
        !           658:                    else {
        !           659:                        acb -> acb_flags |= ACB_PLEASE;
        !           660:                        acb -> acb_priority = priority -> parm;
        !           661:                    }
        !           662:                    free_OACS_Priority(priority);
        !           663:                    return OK;
        !           664:                }
        !           665: 
        !           666:                rti -> rti_type = RTI_TURN;
        !           667:                {
        !           668:                    register struct RtSAPturn  *rtu = &rti -> rti_turn;
        !           669: 
        !           670:                    rtu -> rtu_please = 1;
        !           671:                    rtu -> rtu_priority = priority -> parm;
        !           672:                }
        !           673:                free_OACS_Priority(priority);
        !           674:                return DONE;
        !           675: 
        !           676:            default: 
        !           677:                break;
        !           678:        }
        !           679:     (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           680:            "unexpected token indication (0x%x)", st -> st_type);
        !           681: 
        !           682: out: ;
        !           683:     STFREE (st);
        !           684: 
        !           685:     freeacblk (acb);
        !           686:     return NOTOK;
        !           687: }
        !           688: 
        !           689: /*  */
        !           690: 
        !           691: static int  doSSsync (acb, sn, rti)
        !           692: register struct assocblk   *acb;
        !           693: register struct SSAPsync *sn;
        !           694: struct RtSAPindication *rti;
        !           695: {
        !           696:     struct SSAPindication   sis;
        !           697:     register struct SSAPindication *si = &sis;
        !           698:     register struct SSAPabort  *sa = &si -> si_abort;
        !           699: 
        !           700:     SNFREE (sn);
        !           701:     
        !           702:     if (acb -> acb_flags & ACB_ACT)
        !           703:        switch (sn -> sn_type) {
        !           704:            case SN_MINORIND:   /* always confirm it */
        !           705:                if (acb -> acb_flags & ACB_TURN)
        !           706:                    break;
        !           707:                if (acb -> acb_uptrans) {
        !           708:                    if ((*acb -> acb_uptrans) (acb -> acb_fd, SI_SYNC,
        !           709:                                               (caddr_t) sn, rti) == NOTOK) {
        !           710:                        if (SUReportRequest (acb -> acb_fd, SP_LOCAL,
        !           711:                                             NULLCP, 0, si) == NOTOK) {
        !           712:                            (void) ss2rtslose (acb, rti, "SUReportRequest",sa);
        !           713:                            goto out;
        !           714:                        }
        !           715:                        return OK;
        !           716:                    }
        !           717:                }
        !           718:                if (SMinSyncResponse (acb -> acb_fd, sn -> sn_ssn,
        !           719:                            NULLCP, 0, si) == NOTOK) {
        !           720:                    (void) ss2rtslose (acb, rti, "SMinSyncResponse", sa);
        !           721:                    goto out;
        !           722:                }
        !           723:                return OK;
        !           724: 
        !           725:            case SN_MINORCNF: 
        !           726:                if (!(acb -> acb_flags & ACB_TURN))
        !           727:                    break;
        !           728:                acb -> acb_ack = sn -> sn_ssn;
        !           729:                return OK;
        !           730: 
        !           731:            default: 
        !           732:                break;
        !           733:        }
        !           734:     (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           735:            "unexpected sync indication (0x%x)", sn -> sn_type);
        !           736: 
        !           737: out: ;
        !           738:     freeacblk (acb);
        !           739: 
        !           740:     return NOTOK;
        !           741: }
        !           742: 
        !           743: /*  */
        !           744: 
        !           745: static int  doSSactivity (acb, sv, rti)
        !           746: register struct assocblk   *acb;
        !           747: register struct SSAPactivity *sv;
        !           748: struct RtSAPindication *rti;
        !           749: {
        !           750:     int     result;
        !           751:     register PE            pe;
        !           752:     struct SSAPindication   sis;
        !           753:     register struct SSAPindication *si = &sis;
        !           754:     register struct SSAPabort  *sa = &si -> si_abort;
        !           755: 
        !           756:     SVFREE (sv);
        !           757: 
        !           758:     switch (sv -> sv_type) {
        !           759:        case SV_START: 
        !           760:            if (acb -> acb_flags & (ACB_ACT | ACB_TURN))
        !           761:                break;
        !           762:            if (acb -> acb_uptrans) {
        !           763:                if ((*acb -> acb_uptrans) (acb -> acb_fd, SI_ACTIVITY,
        !           764:                                           (caddr_t) sv, rti) == NOTOK) {
        !           765:                    if (SUReportRequest (acb -> acb_fd, SP_LOCAL,
        !           766:                                         NULLCP, 0, si) == NOTOK) {
        !           767:                        (void) ss2rtslose (acb, rti, "SUReportRequest", sa);
        !           768:                        goto out;
        !           769:                    }
        !           770:                    return OK;
        !           771:                }
        !           772:            }
        !           773:            acb -> acb_flags |= ACB_ACT;
        !           774:            return OK;
        !           775: 
        !           776:        case SV_RESUME:         /* XXX: will support this later */
        !           777:            if (acb -> acb_flags & (ACB_ACT | ACB_TURN))
        !           778:                break;
        !           779:            if (SUReportRequest (acb -> acb_fd, SP_PROCEDURAL, NULLCP, 0,
        !           780:                        si) == NOTOK) {
        !           781:                (void) ss2rtslose (acb, rti, "SUReportRequest", sa);
        !           782:                goto out;
        !           783:            }
        !           784:            acb -> acb_flags |= ACB_ACT;
        !           785:            return OK;
        !           786: 
        !           787:        case SV_INTRIND: 
        !           788:        case SV_DISCIND: 
        !           789:            if (!(acb -> acb_flags & ACB_ACT)
        !           790:                    || (acb -> acb_flags & ACB_TURN))
        !           791:                break;
        !           792:            if (acb -> acb_uptrans)
        !           793:                (void) (*acb -> acb_uptrans) (acb -> acb_fd, SI_ACTIVITY,
        !           794:                                              (caddr_t) sv, rti);
        !           795:            if ((sv -> sv_type == SV_INTRIND
        !           796:                        ? SActIntrResponse (acb -> acb_fd, si)
        !           797:                        : SActDiscResponse (acb -> acb_fd, si)) == NOTOK) {
        !           798:                (void) ss2rtslose (acb, rti, sv -> sv_type == SV_INTRIND
        !           799:                        ? "SActIntrResponse" : "SActDiscResponse", sa);
        !           800:                goto out;
        !           801:            }
        !           802:            FREEACB (acb);
        !           803:            acb -> acb_flags &= ~ACB_ACT;
        !           804:            return OK;
        !           805: 
        !           806:        case SV_INTRCNF: 
        !           807:        case SV_DISCCNF: 
        !           808:            if (!(acb -> acb_flags & ACB_ACT)
        !           809:                    || !(acb -> acb_flags & ACB_TURN))
        !           810:                break;
        !           811:            acb -> acb_flags &= ~ACB_ACT;
        !           812:            (void) rtsaplose (rti, acb -> acb_flags & ACB_TIMER ? RTS_TIMER
        !           813:                    : RTS_TRANSFER, NULLCP, NULLCP);
        !           814:            return OK;
        !           815: 
        !           816:        case SV_ENDIND: 
        !           817:            if (!(acb -> acb_flags & ACB_ACT)
        !           818:                    || (acb -> acb_flags & ACB_TURN))
        !           819:                break;
        !           820:            if (acb -> acb_uptrans) {
        !           821:                if ((*acb -> acb_uptrans) (acb -> acb_fd, SI_ACTIVITY,
        !           822:                                           (caddr_t) sv, rti) == NOTOK) {
        !           823:                    if (SUReportRequest (acb -> acb_fd, SP_LOCAL, NULLCP, 0,
        !           824:                                         si) == NOTOK) {
        !           825:                        (void) ss2rtslose (acb, rti, "SUReportRequest", sa);
        !           826:                        goto out;
        !           827:                    }
        !           828: 
        !           829:                    return OK;
        !           830:                }
        !           831: 
        !           832:                pe = NULLPE;
        !           833:                goto end_it;
        !           834:            }
        !           835: 
        !           836:            if (acb -> acb_base) {
        !           837:                if (pe = ssdu2pe (acb -> acb_base, acb -> acb_len,
        !           838:                                  acb -> acb_realbase ? acb -> acb_realbase
        !           839:                                                      : acb -> acb_base,
        !           840:                                  &result))
        !           841:                    acb -> acb_realbase = acb -> acb_base = NULL;
        !           842:            }
        !           843:            else
        !           844:                pe = NULLPE, result = PS_ERR_EOF;
        !           845:            FREEACB (acb);
        !           846:            if (pe == NULLPE) {
        !           847:                if (result != PS_ERR_NMEM) {
        !           848:                    (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP, "%s",
        !           849:                            ps_error (result));
        !           850:                    goto out;
        !           851:                }
        !           852:                if (SUReportRequest (acb -> acb_fd, SP_LOCAL, NULLCP, 0, si)
        !           853:                        == NOTOK) {
        !           854:                    (void) ss2rtslose (acb, rti, "SUReportRequest", sa);
        !           855:                    goto out;
        !           856:                }
        !           857:                return OK;
        !           858:            }
        !           859: 
        !           860: end_it: ;
        !           861:            if (SActEndResponse (acb -> acb_fd, NULLCP, 0, si) == NOTOK) {
        !           862:                (void) ss2rtslose (acb, rti, "SActEndResponse", sa);
        !           863:                if (pe)
        !           864:                    pe_free (pe);
        !           865:                goto out;
        !           866:            }
        !           867:            acb -> acb_flags &= ~ACB_ACT;
        !           868: 
        !           869:            rti -> rti_type = RTI_TRANSFER;
        !           870:            {
        !           871:                register struct RtSAPtransfer  *rtt = &rti -> rti_transfer;
        !           872: 
        !           873:                rtt -> rtt_data = pe;
        !           874:            }
        !           875:            return DONE;
        !           876: 
        !           877:        case SV_ENDCNF: 
        !           878:            if (!(acb -> acb_flags & ACB_ACT)
        !           879:                    || !(acb -> acb_flags & ACB_TURN))
        !           880:                break;
        !           881:            acb -> acb_flags &= ~ACB_ACT;
        !           882:            return OK;
        !           883: 
        !           884:        default: 
        !           885:            break;
        !           886:     }
        !           887:     (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           888:            "unexpected activity indication (0x%x)", sv -> sv_type);
        !           889: 
        !           890: out: ;
        !           891:     freeacblk (acb);
        !           892:     return NOTOK;
        !           893: }
        !           894: 
        !           895: /*  */
        !           896: 
        !           897: static int  doSSreport (acb, sp, rti)
        !           898: register struct assocblk   *acb;
        !           899: register struct SSAPreport *sp;
        !           900: struct RtSAPindication *rti;
        !           901: {
        !           902:     struct SSAPindication   sis;
        !           903:     register struct SSAPindication *si = &sis;
        !           904:     register struct SSAPabort  *sa = &si -> si_abort;
        !           905: 
        !           906:     SPFREE (sp);
        !           907: 
        !           908:     if (!sp -> sp_peer) {
        !           909:        if (!(acb -> acb_flags & ACB_ACT))
        !           910:            goto out2;
        !           911: 
        !           912: /* XXX: should try lots of things here, based on how many checkpoints have
        !           913:        been acknowledged, but, for now we'll treate everything as severe... */
        !           914: 
        !           915:        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           916:                "unrecoverable provider-initiated exception report");
        !           917:        goto out1;
        !           918:     }
        !           919: 
        !           920:     if (!(acb -> acb_flags & ACB_ACT)
        !           921:            || !(acb -> acb_flags & ACB_TURN)) {
        !           922: out2: ;
        !           923:        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           924:                "unexpected exception report indication (0x%x)",
        !           925:                sp -> sp_peer);
        !           926:        goto out1;
        !           927:     }
        !           928: 
        !           929: /* XXX: should try lots of things here, based on pp_reason,
        !           930:        but, for now we'll treat everything as SP_NOREASON... */
        !           931: 
        !           932:     if (acb -> acb_uptrans)
        !           933:        (void) (*acb -> acb_uptrans) (acb -> acb_fd, SI_REPORT,
        !           934:                                      (caddr_t) sp, rti);
        !           935:     if (SActDiscRequest (acb -> acb_fd, SP_NOREASON, si) != NOTOK)
        !           936:        return OK;
        !           937:     (void) ss2rtslose (acb, rti, "SActDiscRequest", sa);
        !           938: 
        !           939: out1: ;
        !           940:     freeacblk (acb);
        !           941:     return NOTOK;
        !           942: }
        !           943: 
        !           944: /*  */
        !           945: 
        !           946: /* ARGSUSED */
        !           947: 
        !           948: static int  doSSfinish (acb, sf, rti)
        !           949: register struct assocblk   *acb;
        !           950: struct SSAPfinish *sf;
        !           951: struct RtSAPindication *rti;
        !           952: {
        !           953:     SFFREE (sf);
        !           954: 
        !           955:     if (((acb -> acb_flags & ACB_INIT) && (acb -> acb_flags & ACB_TWA))
        !           956:            || (acb -> acb_flags & ACB_TURN)) {
        !           957:        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           958:                "association management botched");
        !           959:        goto out;
        !           960:     }
        !           961: 
        !           962:     if (acb -> acb_flags & ACB_ACT) {
        !           963:        (void) rtpktlose (acb, rti, RTS_PROTOCOL, NULLCP,
        !           964:                "unexpected release indication");
        !           965:        goto out;
        !           966:     }
        !           967: 
        !           968:     acb -> acb_flags |= ACB_FINN;
        !           969:     rti -> rti_type = RTI_CLOSE;
        !           970:     {
        !           971:        register struct RtSAPclose *rtc = &rti -> rti_close;
        !           972: 
        !           973:        bzero ((char *) rtc, sizeof *rtc);
        !           974:     }
        !           975:     return DONE;
        !           976: 
        !           977: out: ;
        !           978:     freeacblk (acb);
        !           979:     return NOTOK;
        !           980: }
        !           981: 
        !           982: /*  */
        !           983: 
        !           984: int    ss2rtsabort (acb, sa, rti)
        !           985: register struct assocblk   *acb;
        !           986: register struct SSAPabort *sa;
        !           987: struct RtSAPindication *rti;
        !           988: {
        !           989:     int     result;
        !           990:     register PE            pe;
        !           991:     struct type_OACS_AbortInformation *pabi = 0;
        !           992: 
        !           993:     if (!sa -> sa_peer) {
        !           994:        if (sa -> sa_reason == SC_TIMER)
        !           995:            return rtsaplose (rti, RTS_TIMER, NULLCP, NULLCP);
        !           996: 
        !           997:        (void) ss2rtslose (acb, rti, NULLCP, sa);
        !           998:        goto out;
        !           999:     }
        !          1000: 
        !          1001:     if (sa -> sa_cc == 0) {
        !          1002:        (void) rtsaplose (rti, RTS_ABORTED, NULLCP, NULLCP);
        !          1003:        goto out;
        !          1004:     }
        !          1005: 
        !          1006:     if ((pe = ssdu2pe (sa -> sa_info, sa -> sa_cc, NULLCP, &result))
        !          1007:            == NULLPE) {
        !          1008:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, NULLCP);
        !          1009:        goto out;
        !          1010:     }
        !          1011:     /* acsap_abort = -1; */
        !          1012:     result = parse_OACS_AbortInformation (pe, 1, NULLIP, NULLVP, &pabi);
        !          1013: 
        !          1014: #ifdef DEBUG
        !          1015:     if (result != NOTOK && (rtsap_log -> ll_events & LLOG_PDUS))
        !          1016:        pvpdu (rtsap_log, print_OACS_AbortInformation_P, pe,
        !          1017:               "AbortInformation", 1);
        !          1018: #endif
        !          1019: 
        !          1020:     pe_free (pe);
        !          1021:     if (result == NOTOK) {
        !          1022:        (void) rtsaplose (rti, RTS_PROTOCOL, "%s", PY_pepy);
        !          1023:        free_OACS_AbortInformation (pabi);
        !          1024:        goto out;
        !          1025:     }
        !          1026:     if (pabi->member_OACS_6)
        !          1027:        result = pabi -> member_OACS_6 -> parm;
        !          1028:     else
        !          1029:        result = -1;
        !          1030:     switch (result) {
        !          1031:        case ABORT_LSP: 
        !          1032:        case ABORT_TMP: 
        !          1033:            result = RTS_REMOTE;
        !          1034:            break;
        !          1035: 
        !          1036:        default: 
        !          1037:            result = RTS_PROTOCOL;
        !          1038:            break;
        !          1039:     }
        !          1040:     (void) rtsaplose (rti, result, NULLCP, NULLCP);
        !          1041:     free_OACS_AbortInformation (pabi);
        !          1042: 
        !          1043: out: ;
        !          1044:     SAFREE (sa);
        !          1045:     if (!(acb -> acb_flags & ACB_STICKY))
        !          1046:        acb -> acb_fd = NOTOK;
        !          1047:     freeacblk (acb);
        !          1048: 
        !          1049:     return NOTOK;
        !          1050: }
        !          1051: 
        !          1052: /*  */
        !          1053: 
        !          1054: static int  ssDATAser (sd, sx)
        !          1055: int    sd;
        !          1056: register struct SSAPdata *sx;
        !          1057: {
        !          1058:     IFP            handler;
        !          1059:     register struct assocblk   *acb;
        !          1060:     struct RtSAPindication  rtis;
        !          1061:     register struct RtSAPindication *rti = &rtis;
        !          1062: 
        !          1063:     if ((acb = findacblk (sd)) == NULL)
        !          1064:        return;
        !          1065:     handler = acb -> acb_rtsindication;
        !          1066: 
        !          1067:     if (doSSdata (acb, sx, rti) != OK)
        !          1068:        (*handler) (sd, rti);
        !          1069: }
        !          1070: 
        !          1071: /*  */
        !          1072: 
        !          1073: static int  ssTOKENser (sd, st)
        !          1074: int    sd;
        !          1075: register struct SSAPtoken *st;
        !          1076: {
        !          1077:     IFP            handler;
        !          1078:     register struct assocblk   *acb;
        !          1079:     struct RtSAPindication  rtis;
        !          1080:     register struct RtSAPindication *rti = &rtis;
        !          1081: 
        !          1082:     if ((acb = findacblk (sd)) == NULL)
        !          1083:        return;
        !          1084:     handler = acb -> acb_rtsindication;
        !          1085: 
        !          1086:     if (doSStoken (acb, st, 0, rti) != OK)
        !          1087:        (*handler) (sd, rti);
        !          1088: }
        !          1089: 
        !          1090: /*  */
        !          1091: 
        !          1092: static int  ssSYNCser (sd, sn)
        !          1093: int    sd;
        !          1094: register struct SSAPsync *sn;
        !          1095: {
        !          1096:     IFP            handler;
        !          1097:     register struct assocblk   *acb;
        !          1098:     struct RtSAPindication  rtis;
        !          1099:     register struct RtSAPindication *rti = &rtis;
        !          1100: 
        !          1101:     if ((acb = findacblk (sd)) == NULL)
        !          1102:        return;
        !          1103:     handler = acb -> acb_rtsindication;
        !          1104: 
        !          1105:     if (doSSsync (acb, sn, rti) != OK)
        !          1106:        (*handler) (sd, rti);
        !          1107: }
        !          1108: 
        !          1109: /*  */
        !          1110: 
        !          1111: static int  ssACTIVITYser (sd, sv)
        !          1112: int    sd;
        !          1113: register struct SSAPactivity *sv;
        !          1114: {
        !          1115:     IFP            handler;
        !          1116:     register struct assocblk   *acb;
        !          1117:     struct RtSAPindication  rtis;
        !          1118:     register struct RtSAPindication *rti = &rtis;
        !          1119: 
        !          1120:     if ((acb = findacblk (sd)) == NULL)
        !          1121:        return;
        !          1122:     handler = acb -> acb_rtsindication;
        !          1123: 
        !          1124:     if (doSSactivity (acb, sv, rti) != OK)
        !          1125:        (*handler) (sd, rti);
        !          1126: }
        !          1127: 
        !          1128: /*  */
        !          1129: 
        !          1130: static int  ssREPORTser (sd, sp)
        !          1131: int    sd;
        !          1132: register struct SSAPreport *sp;
        !          1133: {
        !          1134:     IFP            handler;
        !          1135:     register struct assocblk   *acb;
        !          1136:     struct RtSAPindication  rtis;
        !          1137:     register struct RtSAPindication *rti = &rtis;
        !          1138: 
        !          1139:     if ((acb = findacblk (sd)) == NULL)
        !          1140:        return;
        !          1141:     handler = acb -> acb_rtsindication;
        !          1142: 
        !          1143:     if (doSSreport (acb, sp, rti) != OK)
        !          1144:        (*handler) (sd, rti);
        !          1145: }
        !          1146: 
        !          1147: /*  */
        !          1148: 
        !          1149: static int  ssFINISHser (sd, sf)
        !          1150: int    sd;
        !          1151: struct SSAPfinish *sf;
        !          1152: {
        !          1153:     IFP            handler;
        !          1154:     register struct assocblk   *acb;
        !          1155:     struct RtSAPindication  rtis;
        !          1156:     register struct RtSAPindication *rti = &rtis;
        !          1157: 
        !          1158:     if ((acb = findacblk (sd)) == NULL)
        !          1159:        return;
        !          1160:     handler = acb -> acb_rtsindication;
        !          1161: 
        !          1162:     (void) doSSfinish (acb, sf, rti);
        !          1163: 
        !          1164:     (*handler) (sd, rti);
        !          1165: }
        !          1166: 
        !          1167: /*  */
        !          1168: 
        !          1169: static int  ssABORTser (sd, sa)
        !          1170: int    sd;
        !          1171: register struct SSAPabort *sa;
        !          1172: {
        !          1173:     IFP            handler;
        !          1174:     register struct assocblk   *acb;
        !          1175:     struct RtSAPindication  rtis;
        !          1176:     register struct RtSAPindication *rti = &rtis;
        !          1177: 
        !          1178:     if ((acb = findacblk (sd)) == NULL)
        !          1179:        return;
        !          1180:     handler = acb -> acb_rtsindication;
        !          1181: 
        !          1182:     (void) doSSabort (acb, sa, rti);
        !          1183: 
        !          1184:     (*handler) (sd, rti);
        !          1185: }
        !          1186: 
        !          1187: /*  */
        !          1188: 
        !          1189: int    ss2rtslose (acb, rti, event, sa)
        !          1190: register struct assocblk *acb;
        !          1191: register struct RtSAPindication *rti;
        !          1192: char   *event;
        !          1193: register struct SSAPabort *sa;
        !          1194: {
        !          1195:     int     reason;
        !          1196:     char   *cp,
        !          1197:             buffer[BUFSIZ];
        !          1198: 
        !          1199:     if (event)
        !          1200:        SLOG (rtsap_log, LLOG_EXCEPTIONS, NULLCP,
        !          1201:              (sa -> sa_cc > 0 ? "%s: %s [%*.*s]": "%s: %s", event,
        !          1202:               SErrString (sa -> sa_reason), sa -> sa_cc, sa -> sa_cc,
        !          1203:               sa -> sa_data));
        !          1204: 
        !          1205:     cp = "";
        !          1206:     switch (sa -> sa_reason) {
        !          1207:        case SC_SSAPID: 
        !          1208:        case SC_SSUSER: 
        !          1209:        case SC_ADDRESS: 
        !          1210:            reason = RTS_ADDRESS;
        !          1211:            break;
        !          1212: 
        !          1213:        case SC_REFUSED:
        !          1214:            reason = RTS_REFUSED;
        !          1215:            break;
        !          1216: 
        !          1217:        case SC_CONGEST: 
        !          1218:            reason = RTS_CONGEST;
        !          1219:            break;
        !          1220: 
        !          1221:        default: 
        !          1222:            (void) sprintf (cp = buffer, " (%s at session)",
        !          1223:                    SErrString (sa -> sa_reason));
        !          1224:        case SC_TRANSPORT:
        !          1225:        case SC_ABORT:
        !          1226:            reason = RTS_SESSION;
        !          1227:            break;
        !          1228:     }
        !          1229: 
        !          1230:     if (sa -> sa_cc > 0)
        !          1231:        return rtpktlose (acb, rti, reason, NULLCP, "%*.*s%s",
        !          1232:                sa -> sa_cc, sa -> sa_cc, sa -> sa_data, cp);
        !          1233:     else
        !          1234:        return rtpktlose (acb, rti, reason, NULLCP, "%s", *cp ? cp + 1 : cp);
        !          1235: }

unix.superglobalmegacorp.com

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