Annotation of 43BSDReno/contrib/isode-beta/psap2/psaprelease1.c, revision 1.1.1.1

1.1       root        1: /* psaprelease1.c - PPM: initiate release */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/psap2/RCS/psaprelease1.c,v 7.0 89/11/23 22:14:26 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/psap2/RCS/psaprelease1.c,v 7.0 89/11/23 22:14:26 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       psaprelease1.c,v $
                     12:  * Revision 7.0  89/11/23  22:14:26  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 "ppkt.h"
                     33: 
                     34: /*    P-RELEASE.REQUEST */
                     35: 
                     36: int    PRelRequest (sd, data, ndata, secs, pr, pi)
                     37: int    sd;
                     38: PE     *data;
                     39: int    ndata;
                     40: int    secs;
                     41: struct PSAPrelease *pr;
                     42: struct PSAPindication *pi;
                     43: {
                     44:     SBV            smask;
                     45:     int            result;
                     46:     register struct psapblk *pb;
                     47: 
                     48:     toomuchP (data, ndata, NPDATA, "release");
                     49:     missingP (pr);
                     50:     missingP (pi);
                     51: 
                     52:     smask = sigioblock ();
                     53: 
                     54:     psapPsig (pb, sd);
                     55: 
                     56:     switch (result = info2ssdu (pb, pi, data, ndata, &pb -> pb_realbase,
                     57:                                &pb -> pb_retry, &pb -> pb_len,
                     58:                                "P-RELEASE user-data", PPDU_NONE)) {
                     59:        case OK:
                     60:        default:
                     61:            result = PRelRetryRequestAux (pb, secs, pr, pi);
                     62:            goto out;
                     63: 
                     64:         case NOTOK:
                     65:            freepblk (pb), pb = NULLPB;
                     66:            break;
                     67: 
                     68:        case DONE:
                     69:            result = NOTOK;
                     70:            break;
                     71:     }
                     72: 
                     73:     if (pb) {
                     74:        if (pb -> pb_realbase)
                     75:            free (pb -> pb_realbase);
                     76:        else
                     77:            if (pb -> pb_retry)
                     78:                free (pb -> pb_retry);
                     79:        pb -> pb_realbase = pb -> pb_retry = NULL;
                     80:     }
                     81: 
                     82: out: ;
                     83:     (void) sigiomask (smask);
                     84: 
                     85:     return result;
                     86: }
                     87: 
                     88: /*    P-RELEASE-RETRY.REQUEST (pseudo) */
                     89: 
                     90: int    PRelRetryRequest (sd, secs, pr, pi)
                     91: int    sd;
                     92: int    secs;
                     93: struct PSAPrelease *pr;
                     94: struct PSAPindication *pi;
                     95: {
                     96:     SBV            smask;
                     97:     int            result;
                     98:     register struct psapblk *pb;
                     99: 
                    100:     missingP (pr);
                    101:     missingP (pi);
                    102: 
                    103:     smask = sigioblock ();
                    104: 
                    105:     if ((pb = findpblk (sd)) == NULL)
                    106:        result = psaplose (pi, PC_PARAMETER, NULLCP,
                    107:                           "invalid session descriptor");
                    108:     else
                    109:        if (!(pb -> pb_flags & PB_RELEASE))
                    110:            result = psaplose (pi, PC_OPERATION, "release not in progress");
                    111:        else
                    112:            result = PRelRetryRequestAux (pb, secs, pr, pi);
                    113: 
                    114:     (void) sigiomask (smask);
                    115: 
                    116:     return result;
                    117: }
                    118: 
                    119: /*  */
                    120: 
                    121: static int  PRelRetryRequestAux (pb, secs, pr, pi)
                    122: struct psapblk *pb;
                    123: int    secs;
                    124: struct PSAPrelease *pr;
                    125: struct PSAPindication *pi;
                    126: {
                    127:     int            result;
                    128:     char   *id = pb -> pb_flags & PB_RELEASE ? "SRelRetryRequest"
                    129:                                             : "SRelRequest";
                    130:     struct SSAPrelease   srs;
                    131:     register struct SSAPrelease   *sr = &srs;
                    132:     struct SSAPindication   sis;
                    133:     register struct SSAPabort  *sa = &sis.si_abort;
                    134: 
                    135:     bzero ((char *) sr, sizeof *sr);
                    136: 
                    137:     if ((result = (pb -> pb_flags & PB_RELEASE)
                    138:                        ? SRelRetryRequest (pb -> pb_fd, secs, sr, &sis)
                    139:                        : SRelRequest (pb -> pb_fd, pb -> pb_retry,
                    140:                                       pb -> pb_len, secs, sr, &sis))
                    141:            == NOTOK) {
                    142:        if (sa -> sa_reason == SC_TIMER) {
                    143:            pb -> pb_flags |= PB_RELEASE;
                    144: 
                    145:            return ss2pslose (NULLPB, pi, id, sa);
                    146:        }
                    147: 
                    148:        if (sa -> sa_peer) {
                    149:            (void) ss2psabort (pb, sa, pi);
                    150:            goto out1;
                    151:        }
                    152:        if (SC_FATAL (sa -> sa_reason)) {
                    153:            (void) ss2pslose (pb, pi, id, sa);
                    154:            goto out2;
                    155:        }
                    156:        else {
                    157:            (void) ss2pslose (NULLPB, pi, id, sa);
                    158:            goto out1;
                    159:        }
                    160:     }
                    161: 
                    162:     bzero ((char *) pr, sizeof *pr);
                    163: 
                    164:     if ((result = ssdu2info (pb, pi, sr -> sr_data, sr -> sr_cc, pr -> pr_info,
                    165:                &pr -> pr_ninfo, "P-RELEASE user-data", PPDU_NONE)) == NOTOK)
                    166:        goto out2;
                    167: 
                    168:     if (pr -> pr_affirmative = sr -> sr_affirmative) {
                    169:        pb -> pb_fd = NOTOK;
                    170:        result = OK;
                    171:     }
                    172:     else
                    173:        result = DONE;
                    174: 
                    175: out2: ;
                    176:     if (result == DONE)
                    177:        result = OK;
                    178:     else
                    179:        freepblk (pb), pb = NULLPB;
                    180: out1: ;
                    181:     SRFREE (sr);
                    182:     if (pb) {
                    183:        if (pb -> pb_realbase)
                    184:            free (pb -> pb_realbase);
                    185:        else
                    186:            if (pb -> pb_retry)
                    187:                free (pb -> pb_retry);
                    188:        pb -> pb_realbase = pb -> pb_retry = NULL;
                    189:     }
                    190: 
                    191:     return result;
                    192: }

unix.superglobalmegacorp.com

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