Annotation of 43BSDReno/contrib/isode-beta/ssap/ssapresync1.c, revision 1.1.1.1

1.1       root        1: /* ssapresync.c - SPM: initiate resyncs */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssapresync1.c,v 7.0 89/11/23 22:25:41 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/ssap/RCS/ssapresync1.c,v 7.0 89/11/23 22:25:41 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       ssapresync1.c,v $
                     12:  * Revision 7.0  89/11/23  22:25:41  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 <signal.h>
                     32: #include "spkt.h"
                     33: 
                     34: /*    S-RESYNCHRONIZE.REQUEST */
                     35: 
                     36: #define        dotoken(requires,shift,bit,type) \
                     37: { \
                     38:     if (sb -> sb_requirements & requires) \
                     39:        switch (settings & (ST_MASK << shift)) { \
                     40:            case ST_INIT_VALUE << shift: \
                     41:            case ST_RESP_VALUE << shift: \
                     42:            case ST_CALL_VALUE << shift: \
                     43:                break; \
                     44:  \
                     45:            default: \
                     46:                return ssaplose (si, SC_PARAMETER, NULLCP, \
                     47:                        "improper choice of %s token setting",type); \
                     48:        } \
                     49: }
                     50: 
                     51: /*  */
                     52: 
                     53: int    SReSyncRequest (sd, type, ssn, settings, data, cc, si)
                     54: int    sd;
                     55: int    type,
                     56:        settings;
                     57: long   ssn;
                     58: char   *data;
                     59: int    cc;
                     60: struct SSAPindication *si;
                     61: {
                     62:     SBV            smask;
                     63:     int     result;
                     64:     register struct ssapblk *sb;
                     65: 
                     66:     switch (type) {
                     67:        case SYNC_RESTART: 
                     68:            break;
                     69: 
                     70:        case SYNC_ABANDON: 
                     71:            if (ssn != SERIAL_NONE)
                     72:                return ssaplose (si, SC_PARAMETER, NULLCP,
                     73:                        "serial number inappropriate");
                     74:            break;
                     75: 
                     76:        case SYNC_SET: 
                     77:            if (SERIAL_MIN > ssn || ssn > SERIAL_MAX + 1)
                     78:                return ssaplose (si, SC_PARAMETER, NULLCP,
                     79:                        "invalid serial number");
                     80:            break;
                     81: 
                     82:        default: 
                     83:            return ssaplose (si, SC_PARAMETER, NULLCP,
                     84:                    "improper choice of type setting");
                     85:     }
                     86:     missingP (si);
                     87: 
                     88:     smask = sigioblock ();
                     89: 
                     90:     ssapRsig (sb, sd);
                     91:     toomuchP (sb, data, cc, SN_SIZE, "resync");
                     92: 
                     93:     result = SReSyncRequestAux (sb, type, ssn, settings, data, cc, si);
                     94: 
                     95:     (void) sigiomask (smask);
                     96: 
                     97:     return result;
                     98: }
                     99: 
                    100: /*  */
                    101: 
                    102: static int  SReSyncRequestAux (sb, type, ssn, settings, data, cc, si)
                    103: register struct ssapblk *sb;
                    104: int    type,
                    105:        settings;
                    106: long   ssn;
                    107: char   *data;
                    108: int    cc;
                    109: register struct SSAPindication *si;
                    110: {
                    111:     int     result;
                    112: 
                    113:     if (!(sb -> sb_requirements & SR_RESYNC))
                    114:        return ssaplose (si, SC_OPERATION, NULLCP,
                    115:                "resynchronize service unavailable");
                    116: 
                    117:     if ((sb -> sb_requirements & SR_ACTIVITY)
                    118:            && !(sb -> sb_flags & SB_Vact))
                    119:        return ssaplose (si, SC_OPERATION, NULLCP,
                    120:                "no activity in progress");
                    121: 
                    122:     if ((sb -> sb_flags & SB_RA)
                    123:            && SDoCollideAux (sb -> sb_flags & SB_INIT ? 1 : 0, type, ssn,
                    124:                    sb -> sb_rs, sb -> sb_rsn) == NOTOK)
                    125:        return ssaplose (si, SC_OPERATION, NULLCP,
                    126:                "resync in progress takes precedence");
                    127: 
                    128:     switch (type) {
                    129:        case SYNC_RESTART: 
                    130:            if (sb -> sb_V_M < ssn || ssn < sb -> sb_V_R)
                    131:                return ssaplose (si, SC_OPERATION, NULLCP,
                    132:                        "bad choice for resync ssn, should be in [%d..%d]",
                    133:                        sb -> sb_V_R, sb -> sb_V_M);
                    134:            break;
                    135: 
                    136:        case SYNC_ABANDON: 
                    137:            ssn = sb -> sb_V_M;
                    138:            break;
                    139: 
                    140:        case SYNC_SET: 
                    141:            break;
                    142:     }
                    143: 
                    144:     dotokens ();
                    145: 
                    146:     if ((result = SWriteRequestAux (sb, SPDU_RS, data, cc, type, ssn,
                    147:                settings, NULLSD, NULLSD, NULLSR, si)) == NOTOK)
                    148:        freesblk (sb);
                    149:     else {
                    150:        sb -> sb_flags |= SB_RS, sb -> sb_flags &= ~(SB_RA | SB_EDACK | SB_ERACK);
                    151:        sb -> sb_rs = type;
                    152:        sb -> sb_rsn = ssn;
                    153:        sb -> sb_rsettings = sb -> sb_requirements & SR_TOKENS ? settings : 0;
                    154:     }
                    155: 
                    156:     return result;
                    157: }
                    158: 
                    159: #undef dotoken

unix.superglobalmegacorp.com

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