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

1.1       root        1: /* ssapactitivity.c - SPM: activities */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssapactivity.c,v 7.0 89/11/23 22:25:22 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/ssap/RCS/ssapactivity.c,v 7.0 89/11/23 22:25:22 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       ssapactivity.c,v $
                     12:  * Revision 7.0  89/11/23  22:25:22  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-CONTROL-GIVE.REQUEST */
                     35: 
                     36: int    SGControlRequest (sd, si)
                     37: int    sd;
                     38: struct SSAPindication *si;
                     39: {
                     40:     SBV            smask;
                     41:     int     result;
                     42:     register struct ssapblk *sb;
                     43: 
                     44:     smask = sigioblock ();
                     45: 
                     46:     ssapPsig (sb, sd);
                     47: 
                     48:     result = SGControlRequestAux (sb, si);
                     49: 
                     50:     (void) sigiomask (smask);
                     51: 
                     52:     return result;
                     53: }
                     54: 
                     55: /*  */
                     56: 
                     57: static int  SGControlRequestAux (sb, si)
                     58: register struct ssapblk *sb;
                     59: register struct SSAPindication *si;
                     60: {
                     61:     int     result;
                     62:     register struct ssapkt *s;
                     63: 
                     64:     if (SDoActivityAux (sb, si, 1, 1) == NOTOK)
                     65:        return NOTOK;
                     66: 
                     67:     if (sb -> sb_flags & SB_GTC)
                     68:        return ssaplose (si, SC_OPERATION, NULLCP, "give control in progress");
                     69: 
                     70:     if ((s = newspkt (SPDU_GTC)) == NULL)
                     71:        return ssaplose (si, SC_CONGEST, NULLCP, "out of memory");
                     72: 
                     73:     if ((result = spkt2sd (s, sb -> sb_fd, 0, si)) == NOTOK)
                     74:        freesblk (sb);
                     75:     else {
                     76:        sb -> sb_owned = 0;
                     77:        sb -> sb_flags |= SB_GTC;
                     78:     }
                     79:     freespkt (s);
                     80: 
                     81:     return result;
                     82: }
                     83: 
                     84: /*    S-ACTIVITY-START.REQUEST */
                     85: 
                     86: int    SActStartRequest (sd, id, data, cc, si)
                     87: int    sd;
                     88: struct SSAPactid *id;
                     89: char   *data;
                     90: int    cc;
                     91: struct SSAPindication *si;
                     92: {
                     93:     SBV            smask;
                     94:     int     result;
                     95:     register struct ssapblk *sb;
                     96: 
                     97:     missingP (id);
                     98:     idmuchP (id);
                     99:     missingP (si);
                    100: 
                    101:     smask = sigioblock ();
                    102: 
                    103:     ssapPsig (sb, sd);
                    104:     toomuchP (sb, data, cc, SV_SIZE, "activity start");
                    105: 
                    106:     result = SActStartRequestAux (sb, id, data, cc, si);
                    107: 
                    108:     (void) sigiomask (smask);
                    109: 
                    110:     return result;
                    111: }
                    112: 
                    113: /*  */
                    114: 
                    115: static int  SActStartRequestAux (sb, id, data, cc, si)
                    116: register struct ssapblk *sb;
                    117: struct SSAPactid *id;
                    118: char   *data;
                    119: int    cc;
                    120: register struct SSAPindication *si;
                    121: {
                    122:     int result;
                    123: 
                    124:     if (SDoActivityAux (sb, si, 1, 0) == NOTOK)
                    125:        return NOTOK;
                    126: 
                    127:     if ((result = SWriteRequestAux (sb, SPDU_AS, data, cc, 0, 0L, 0, id,
                    128:                NULLSD, NULLSR, si)) == NOTOK)
                    129:        freesblk (sb);
                    130:     else {
                    131:        sb -> sb_V_A = sb -> sb_V_M = sb -> sb_V_R = 1;
                    132:        sb -> sb_flags |= SB_Vact;
                    133:     }
                    134: 
                    135:     return result;
                    136: }
                    137: 
                    138: /*    S-ACTIVITY-RESUME.REQUEST */
                    139: 
                    140: int    SActResumeRequest (sd, id, oid, ssn, ref, data, cc, si)
                    141: int    sd;
                    142: struct SSAPactid *id,
                    143:                 *oid;
                    144: long   ssn;
                    145: struct SSAPref *ref;
                    146: char   *data;
                    147: int    cc;
                    148: struct SSAPindication *si;
                    149: {
                    150:     SBV            smask;
                    151:     int     result;
                    152:     register struct ssapblk *sb;
                    153: 
                    154:     missingP (id);
                    155:     idmuchP (id);
                    156:     missingP (oid);
                    157:     idmuchP (oid);
                    158:     if (SERIAL_MIN > ssn || ssn > SERIAL_MAX)
                    159:        return ssaplose (si, SC_PARAMETER, NULLCP, "invalid serial number");
                    160: #ifdef notdef
                    161:     missingP (ref);
                    162: #endif
                    163:     if (ref)
                    164:        refmuchP (ref)
                    165:     missingP (si);
                    166: 
                    167:     smask = sigioblock ();
                    168: 
                    169:     ssapPsig (sb, sd);
                    170:     toomuchP (sb, data, cc, SV_SIZE, "activity resume");
                    171: 
                    172:     result = SActResumeRequestAux (sb, id, oid, ssn, ref, data, cc, si);
                    173: 
                    174:     (void) sigiomask (smask);
                    175: 
                    176:     return result;
                    177: }
                    178: 
                    179: /*  */
                    180: 
                    181: static int  SActResumeRequestAux (sb, id, oid, ssn, ref, data, cc, si)
                    182: register struct ssapblk *sb;
                    183: struct SSAPactid *id,
                    184:                 *oid;
                    185: long   ssn;
                    186: struct SSAPref *ref;
                    187: char   *data;
                    188: int    cc;
                    189: register struct SSAPindication *si;
                    190: {
                    191:     int            result;
                    192: 
                    193:     if (SDoActivityAux (sb, si, 1, 0) == NOTOK)
                    194:        return NOTOK;
                    195: 
                    196:     if ((result = SWriteRequestAux (sb, SPDU_AR, data, cc, 0, ssn, 0, id,
                    197:                oid, ref, si)) == NOTOK)
                    198:        freesblk (sb);
                    199:     else {
                    200:        sb -> sb_V_A = sb -> sb_V_M = ssn + 1;
                    201:        sb -> sb_V_R = 1;
                    202:        sb -> sb_flags |= SB_Vact;
                    203:     }
                    204: 
                    205:     return result;
                    206: }
                    207: 
                    208: /*    S-ACTIVITY-INTERRUPT.REQUEST */
                    209: 
                    210: int    SActIntrRequest (sd, reason, si)
                    211: int    sd;
                    212: int    reason;
                    213: struct SSAPindication *si;
                    214: {
                    215:     SBV            smask;
                    216:     int     result;
                    217:     register struct ssapblk *sb;
                    218: 
                    219:     if (!(SP_OK (reason)))
                    220:        return ssaplose (si, SC_PARAMETER, NULLCP, "invalid reason");
                    221:     missingP (si);
                    222: 
                    223:     smask = sigioblock ();
                    224: 
                    225:     ssapXsig (sb, sd);
                    226:     if (sb -> sb_flags & SB_MAP) {
                    227:        (void) sigsetmask (smask);
                    228:        return ssaplose (si, SC_OPERATION, NULLCP, "majorsync in progress");
                    229:     }
                    230: 
                    231:     result = SActIntrRequestAux (sb, reason, SPDU_AI, si);
                    232: 
                    233:     (void) sigiomask (smask);
                    234: 
                    235:     return result;
                    236: }
                    237: 
                    238: /*  */
                    239: 
                    240: static int  SActIntrRequestAux (sb, reason, type, si)
                    241: register struct ssapblk *sb;
                    242: int    reason,
                    243:        type;
                    244: register struct SSAPindication *si;
                    245: {
                    246:     int            result;
                    247: 
                    248:     if (!(sb -> sb_requirements & SR_ACTIVITY))
                    249:        return ssaplose (si, SC_OPERATION, NULLCP,
                    250:                "activity management service unavailable");
                    251:     if (!(sb -> sb_owned & ST_ACT_TOKEN))
                    252:        return ssaplose (si, SC_OPERATION, NULLCP,
                    253:                "activity token not owned by you");
                    254:     if (!(sb -> sb_flags & SB_Vact))
                    255:        return ssaplose (si, SC_OPERATION, NULLCP,
                    256:                "no activity in progress");
                    257:     if ((sb -> sb_flags & SB_RA)
                    258:            && SDoCollideAux (sb -> sb_flags & SB_INIT ? 1 : 0,
                    259:                        type == SPDU_AI ? SYNC_INTR : SYNC_DISC, 0L,
                    260:                        sb -> sb_rs, sb -> sb_rsn) == NOTOK)
                    261:        return ssaplose (si, SC_OPERATION, NULLCP,
                    262:                "resync in progress takes precedence");
                    263: 
                    264:     if ((result = SWriteRequestAux (sb, type, NULLCP, 0, reason, 0L, 0,
                    265:            NULLSD, NULLSD, NULLSR, si)) == NOTOK)
                    266:        freesblk (sb);
                    267:     else {
                    268:        sb -> sb_flags |= SB_AI, sb -> sb_flags &= ~(SB_RA | SB_EDACK | SB_ERACK);
                    269:        sb -> sb_rs = type == SPDU_AI ? SYNC_INTR : SYNC_DISC;
                    270:     }
                    271: 
                    272:     return result;
                    273: }
                    274: 
                    275: /*    S-ACTIVITY-INTERRUPT.RESPONSE */
                    276: 
                    277: int    SActIntrResponse (sd, si)
                    278: int    sd;
                    279: struct SSAPindication *si;
                    280: {
                    281:     SBV            smask;
                    282:     int     result;
                    283:     register struct ssapblk *sb;
                    284: 
                    285:     missingP (si);
                    286: 
                    287:     smask = sigioblock ();
                    288: 
                    289:     ssapAsig (sb, sd);
                    290: 
                    291:     result = SActIntrResponseAux (sb, SPDU_AIA, si);
                    292: 
                    293:     (void) sigiomask (smask);
                    294: 
                    295:     return result;
                    296: }
                    297: 
                    298: /*  */
                    299: 
                    300: static int  SActIntrResponseAux (sb, type, si)
                    301: register struct ssapblk *sb;
                    302: int    type;
                    303: register struct SSAPindication *si;
                    304: {
                    305:     int            result;
                    306: 
                    307:     if (!(sb -> sb_requirements & SR_ACTIVITY))
                    308:        return ssaplose (si, SC_OPERATION, NULLCP,
                    309:                "activity management service unavailable");
                    310:     if (!(sb -> sb_flags & SB_Vact))
                    311:        return ssaplose (si, SC_OPERATION, NULLCP,
                    312:                "no activity in progress");
                    313:     if (!(sb -> sb_flags & SB_AIA))
                    314:        return ssaplose (si, SC_OPERATION, NULLCP,
                    315:                "no activity interrupt/discard in progress");
                    316: 
                    317:     if ((result = SWriteRequestAux (sb, type, NULLCP, 0, 0, 0L, 0,
                    318:            NULLSD, NULLSD, NULLSR, si)) == NOTOK)
                    319:        freesblk (sb);
                    320:     else {
                    321:        sb -> sb_flags &= ~(SB_AIA | SB_Vact);
                    322:        sb -> sb_owned = 0;
                    323:     }
                    324: 
                    325:     return result;
                    326: }
                    327: 
                    328: /*    S-ACTIVITY-DISCARD.REQUEST */
                    329: 
                    330: int    SActDiscRequest (sd, reason, si)
                    331: int    sd;
                    332: int    reason;
                    333: struct SSAPindication *si;
                    334: {
                    335:     SBV            smask;
                    336:     int     result;
                    337:     register struct ssapblk *sb;
                    338: 
                    339:     if (!(SP_OK (reason)))
                    340:        return ssaplose (si, SC_PARAMETER, NULLCP, "invalid reason");
                    341:     missingP (si);
                    342: 
                    343:     smask = sigioblock ();
                    344: 
                    345:     ssapXsig (sb, sd);
                    346:     if (sb -> sb_flags & SB_MAP) {
                    347:        (void) sigsetmask (smask);
                    348:        return ssaplose (si, SC_OPERATION, NULLCP, "majorsync in progress");
                    349:     }
                    350: 
                    351:     result = SActIntrRequestAux (sb, reason, SPDU_AD, si);
                    352: 
                    353:     (void) sigiomask (smask);
                    354: 
                    355:     return result;
                    356: }
                    357: 
                    358: /*    S-ACTIVITY-DISCARD.RESPONSE */
                    359: 
                    360: int    SActDiscResponse (sd, si)
                    361: int    sd;
                    362: struct SSAPindication *si;
                    363: {
                    364:     SBV            smask;
                    365:     int     result;
                    366:     register struct ssapblk *sb;
                    367: 
                    368:     missingP (si);
                    369: 
                    370:     smask = sigioblock ();
                    371: 
                    372:     ssapAsig (sb, sd);
                    373: 
                    374:     result = SActIntrResponseAux (sb, SPDU_ADA, si);
                    375: 
                    376:     (void) sigiomask (smask);
                    377: 
                    378:     return result;
                    379: }
                    380: 
                    381: /*    S-ACTIVITY-END.REQUEST */
                    382: 
                    383: int    SActEndRequest (sd, ssn, data, cc, si)
                    384: int    sd;
                    385: long   *ssn;
                    386: char   *data;
                    387: int    cc;
                    388: struct SSAPindication *si;
                    389: {
                    390:     SBV            smask;
                    391:     int     result;
                    392:     register struct ssapblk *sb;
                    393: 
                    394:     missingP (ssn);
                    395:     missingP (si);
                    396: 
                    397:     smask = sigioblock ();
                    398: 
                    399:     ssapPsig (sb, sd);
                    400:     toomuchP (sb, data, cc, SV_SIZE, "activity end");
                    401: 
                    402:     result = SMajSyncRequestAux (sb, ssn, data, cc, 0, si);
                    403: 
                    404:     (void) sigiomask (smask);
                    405: 
                    406:     return result;
                    407: }
                    408: 
                    409: /*    S-ACTIVITY-END.RESPONSE */
                    410: 
                    411: int    SActEndResponse (sd, data, cc, si)
                    412: int    sd;
                    413: char   *data;
                    414: int    cc;
                    415: struct SSAPindication *si;
                    416: {
                    417:     SBV            smask;
                    418:     int     result;
                    419:     register struct ssapblk *sb;
                    420: 
                    421:     missingP (si);
                    422: 
                    423:     smask = sigioblock ();
                    424: 
                    425:     ssapPsig (sb, sd);
                    426:     toomuchP (sb, data, cc, SV_SIZE, "activity end");
                    427: 
                    428:     result = SMajSyncResponseAux (sb, data, cc, si);
                    429: 
                    430:     (void) sigiomask (smask);
                    431: 
                    432:     return result;
                    433: }

unix.superglobalmegacorp.com

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