Annotation of 43BSDReno/contrib/isode-beta/ssap/ssaplose.c, revision 1.1

1.1     ! root        1: /* ssaplose.c - SPM: you lose */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssaplose.c,v 7.0 89/11/23 22:25:29 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/ssap/RCS/ssaplose.c,v 7.0 89/11/23 22:25:29 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       ssaplose.c,v $
        !            12:  * Revision 7.0  89/11/23  22:25:29  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                               NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: /* LINTLIBRARY */
        !            29: 
        !            30: #include <stdio.h>
        !            31: #include <varargs.h>
        !            32: #include "spkt.h"
        !            33: #include "tailor.h"
        !            34: 
        !            35: /*  */
        !            36: 
        !            37: #ifndef        lint
        !            38: int    spktlose (va_alist)
        !            39: va_dcl
        !            40: {
        !            41:     int            reason,
        !            42:            result,
        !            43:            sd,
        !            44:            secs,
        !            45:            value;
        !            46:     register struct ssapblk *sb;
        !            47:     register struct ssapkt *s;
        !            48:     struct SSAPindication   sis;
        !            49:     register struct SSAPindication *si;
        !            50:     register struct SSAPabort *sa;
        !            51:     struct TSAPdata txs;
        !            52:     register struct TSAPdata   *tx = &txs;
        !            53:     struct TSAPdisconnect   tds;
        !            54:     register struct TSAPdisconnect *td = &tds;
        !            55:     va_list ap;
        !            56: 
        !            57:     va_start (ap);
        !            58: 
        !            59:     sd = va_arg (ap, int);
        !            60: 
        !            61:     si = va_arg (ap, struct SSAPindication *);
        !            62:     if (si == NULL)
        !            63:        si = &sis;
        !            64: 
        !            65:     reason = va_arg (ap, int);
        !            66:     value = reason & SC_REFUSE;
        !            67:     reason &= ~SC_REFUSE;
        !            68: 
        !            69:     result = _ssaplose (si, reason, ap);
        !            70: 
        !            71:     va_end (ap);
        !            72: 
        !            73:     if ((sa = &si -> si_abort) -> sa_cc > 0) {
        !            74:        SLOG (ssap_log, LLOG_EXCEPTIONS, NULLCP,
        !            75:              ("spktlose [%s] %*.*s", SErrString (sa -> sa_reason),
        !            76:               sa -> sa_cc, sa -> sa_cc, sa -> sa_data));
        !            77:     }
        !            78:     else
        !            79:        SLOG (ssap_log, LLOG_EXCEPTIONS, NULLCP,
        !            80:              ("spktlose [%s]", SErrString (sa -> sa_reason)));
        !            81: 
        !            82:     if (value && SC_OFFICIAL (reason)) {
        !            83:        if ((s = newspkt (SPDU_RF)) == NULL)
        !            84:            return result;
        !            85: 
        !            86:        s -> s_mask |= SMASK_RF_DISC;
        !            87:        s -> s_rf_disconnect |= RF_DISC_RELEASE;
        !            88: 
        !            89:        if (reason == SC_VERSION) {
        !            90:            s -> s_mask |= SMASK_RF_VRSN;
        !            91:            s -> s_rf_version = SB_ALLVRSNS;
        !            92:        }
        !            93: 
        !            94:        if (s -> s_rdata = malloc ((unsigned) (s -> s_rlen = 1)))
        !            95:            *s -> s_rdata = reason & 0xff;
        !            96: 
        !            97:        secs = RF_TIM;
        !            98:     }
        !            99:     else {
        !           100:        if ((s = newspkt (SPDU_AB)) == NULL)
        !           101:            return result;
        !           102: 
        !           103:        s -> s_mask |= SMASK_SPDU_AB | SMASK_AB_DISC;
        !           104:        s -> s_ab_disconnect = AB_DISC_RELEASE;
        !           105:        switch (reason) {
        !           106:            case SC_PROTOCOL: 
        !           107:            case SC_VERSION: 
        !           108:                s -> s_ab_disconnect |= AB_DISC_PROTO;
        !           109:                break;
        !           110: 
        !           111:            case SC_CONGEST: 
        !           112:            case SC_SSAPID: 
        !           113:                break;
        !           114: 
        !           115:            default: 
        !           116:                s -> s_ab_disconnect |= AB_DISC_UNKNOWN;
        !           117:                break;
        !           118:        }
        !           119: 
        !           120:        secs = AB_TIM;
        !           121:     }
        !           122: 
        !           123:     value = spkt2sd (s, sd,
        !           124:                (sb = findsblk (sd)) && (sb -> sb_flags & SB_EXPD), si);
        !           125: 
        !           126:     freespkt (s);
        !           127:     if (value == NOTOK)
        !           128:        return result;
        !           129: 
        !           130:     switch (TReadRequest (sd, tx, secs, td)) {
        !           131:        case OK:
        !           132:        default:
        !           133:            TXFREE (tx);
        !           134:            break;
        !           135: 
        !           136:        case NOTOK: 
        !           137:            break;
        !           138:     }
        !           139: 
        !           140:     return result;
        !           141: }
        !           142: #else
        !           143: /* VARARGS5 */
        !           144: 
        !           145: int    spktlose (sd, si, reason, what, fmt)
        !           146: int    sd,
        !           147:        reason;
        !           148: struct SSAPindication *si;
        !           149: char   *what,
        !           150:        *fmt;
        !           151: {
        !           152:     return spktlose (sd, si, reason, what, fmt);
        !           153: }
        !           154: #endif
        !           155: 
        !           156: /*  */
        !           157: 
        !           158: #ifndef        lint
        !           159: int    ssaplose (va_alist)
        !           160: va_dcl
        !           161: {
        !           162:     int            reason,
        !           163:            result;
        !           164:     struct SSAPindication *si;
        !           165:     va_list ap;
        !           166: 
        !           167:     va_start (ap);
        !           168: 
        !           169:     si = va_arg (ap, struct SSAPindication *);
        !           170:     reason = va_arg (ap, int);
        !           171: 
        !           172:     result = _ssaplose (si, reason, ap);
        !           173: 
        !           174:     va_end (ap);
        !           175: 
        !           176:     return result;
        !           177: }
        !           178: #else
        !           179: /* VARARGS4 */
        !           180: 
        !           181: int    ssaplose (si, reason, what, fmt)
        !           182: struct SSAPindication *si;
        !           183: int    reason;
        !           184: char   *what,
        !           185:        *fmt;
        !           186: {
        !           187:     return ssaplose (si, reason, what, fmt);
        !           188: }
        !           189: #endif
        !           190: 
        !           191: /*  */
        !           192: 
        !           193: #ifndef        lint
        !           194: static int  _ssaplose (si, reason, ap) /* what, fmt, args ... */
        !           195: register struct SSAPindication *si;
        !           196: int    reason;
        !           197: va_list        ap;
        !           198: {
        !           199:     register char  *bp;
        !           200:     char    buffer[BUFSIZ];
        !           201:     register struct SSAPabort *sa;
        !           202: 
        !           203:     if (si) {
        !           204:        bzero ((char *) si, sizeof *si);
        !           205:        si -> si_type = SI_ABORT;
        !           206:        sa = &si -> si_abort;
        !           207: 
        !           208:        asprintf (bp = buffer, ap);
        !           209:        bp += strlen (bp);
        !           210: 
        !           211:        sa -> sa_peer = 0;
        !           212:        sa -> sa_reason = reason;
        !           213:        copySSAPdata (buffer, bp - buffer, sa);
        !           214:     }
        !           215: 
        !           216:     return NOTOK;
        !           217: }
        !           218: #endif

unix.superglobalmegacorp.com

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