Annotation of 43BSDReno/contrib/isode-beta/rtsap/rt2ssrespond.c, revision 1.1.1.1

1.1       root        1: /* rt2ssrespond.c - RTPM: responder */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/rtsap/RCS/rt2ssrespond.c,v 7.2 90/07/27 08:48:01 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/rtsap/RCS/rt2ssrespond.c,v 7.2 90/07/27 08:48:01 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       rt2ssrespond.c,v $
                     12:  * Revision 7.2  90/07/27  08:48:01  mrose
                     13:  * update
                     14:  * 
                     15:  * Revision 7.1  90/07/01  21:07:16  mrose
                     16:  * pepsy
                     17:  * 
                     18:  * Revision 6.0  89/03/18  23:43:23  mrose
                     19:  * Release 5.0
                     20:  * 
                     21:  */
                     22: 
                     23: /*
                     24:  *                               NOTICE
                     25:  *
                     26:  *    Acquisition, use, and distribution of this module and related
                     27:  *    materials are subject to the restrictions of a license agreement.
                     28:  *    Consult the Preface in the User's Manual for the full terms of
                     29:  *    this agreement.
                     30:  *
                     31:  */
                     32: 
                     33: 
                     34: /* LINTLIBRARY */
                     35: 
                     36: #include <stdio.h>
                     37: #include "RTS-types.h"
                     38: #include "OACS-types.h"
                     39: #include "rtpkt.h"
                     40: #include "tailor.h"
                     41: 
                     42: /*    DATA */
                     43: 
                     44: extern int acsap_conntype;
                     45: 
                     46: /*    RT-BEGIN.INDICATION (X.410 OPEN.INDICATION) */
                     47: 
                     48: int    RtBInit (vecp, vec, rts, rti)
                     49: int    vecp;
                     50: char  **vec;
                     51: struct RtSAPstart *rts;
                     52: struct RtSAPindication *rti;
                     53: {
                     54:     int     len,
                     55:            result;
                     56:     char   *base;
                     57:     register struct assocblk   *acb;
                     58:     register PE        pe;
                     59:     struct SSAPref ref;
                     60:     struct SSAPstart    sss;
                     61:     register struct SSAPstart  *ss = &sss;
                     62:     struct SSAPindication   sis;
                     63:     register struct SSAPindication *si = &sis;
                     64:     register struct SSAPabort  *sa = &si -> si_abort;
                     65:     struct type_OACS_PConnect *pcon;
                     66:     int sc_reason = SC_CONGESTION;
                     67: 
                     68:     isodetailor (NULLCP, 0);
                     69: 
                     70:     missingP (vec);
                     71:     missingP (rts);
                     72:     missingP (rti);
                     73: 
                     74:     if ((acb = newacblk ()) == NULL)
                     75:        return rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
                     76:     acb -> acb_flags |= ACB_RTS;
                     77:     SetSS2RtService (acb);
                     78: 
                     79:     if (SInit (vecp, vec, ss, si) == NOTOK) {
                     80:        (void) ss2rtslose (acb, rti, "SInit", sa);
                     81:        goto out1;
                     82:     }
                     83: 
                     84:     acb -> acb_fd = ss -> ss_sd;
                     85:     acb -> acb_uabort = SUAbortRequest;
                     86: 
                     87:     base = NULLCP, len = 0;
                     88:     acb -> acb_connect = ss -> ss_connect;     /* struct copy */
                     89:     if ((ss -> ss_requirements &= RTS_MYREQUIRE) != RTS_MYREQUIRE) {
                     90:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
                     91:                    "desired session requirements unavailable");
                     92:        goto out2;
                     93:     }
                     94:     acb -> acb_requirements = ss -> ss_requirements;
                     95: 
                     96: #define dotoken(requires,shift,bit,type) \
                     97: { \
                     98:     if (acb -> acb_requirements & requires) \
                     99:        switch (ss -> ss_settings & (ST_MASK << shift)) { \
                    100:            case ST_INIT_VALUE << shift: \
                    101:                acb -> acb_avail |= bit; \
                    102:                break; \
                    103:  \
                    104:            case ST_RESP_VALUE << shift: \
                    105:                acb -> acb_owned |= bit; \
                    106:                acb -> acb_avail |= bit; \
                    107:                break; \
                    108:  \
                    109:            default: \
                    110:                (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP, \
                    111:                        "%s token management botched", type); \
                    112:                goto out2; \
                    113:        } \
                    114:     }
                    115:     dotokens ();
                    116: #undef dotoken
                    117:     if (acb -> acb_owned != 0 && acb -> acb_owned != acb -> acb_avail) {
                    118:        (void) rtsaplose (rti, RTS_PROTOCOL, NULLCP,
                    119:                "token management botched");
                    120:        goto out2;
                    121:     }
                    122:     if (acb -> acb_owned)
                    123:        acb -> acb_flags |= ACB_TURN;
                    124:     acb -> acb_settings = ss -> ss_settings;
                    125:     acb -> acb_ssdusize = ss -> ss_ssdusize;
                    126: 
                    127:     if ((pe = ssdu2pe (ss -> ss_data, ss -> ss_cc, NULLCP, &result))
                    128:            == NULLPE) {
                    129:        (void) rtsaplose (rti, result != PS_ERR_NMEM ? RTS_PROTOCOL
                    130:                : RTS_CONGEST, NULLCP, "%s", ps_error (result));
                    131:        goto out2;
                    132:     }
                    133: 
                    134:     SSFREE (ss);
                    135: 
                    136:     if (parse_OACS_PConnect (pe, 1, NULLIP, NULLVP, &pcon) == NOTOK) {
                    137:        (void) pylose ();
                    138:        pe_free (pe);
                    139:        goto out2;
                    140:     }
                    141: 
                    142:     PLOGP (rtsap_log,OACS_PConnect, pe, "PConnect", 1);
                    143: 
                    144:     if (pcon -> pUserData -> member_OACS_2->offset
                    145:            == type_OACS_ConnectionData_recover) {
                    146:        (void) rtsaplose (rti, RTS_CONGEST, NULLCP,
                    147:                          "rejecting attempted recovery");
                    148:        pe_free (pe);
                    149:        if ((pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET))
                    150:                && set_add (pe, num2prim (RTS_RECOVER, PE_CLASS_CONT,
                    151:                                          PREF_REASON)) != NOTOK) {
                    152:            PLOGP (rtsap_log,OACS_PRefuse, pe, "PRefuse", 0);
                    153:            if (pe2ssdu (pe, &base, &len) == NOTOK) {
                    154:                if (base)
                    155:                    free (base), base = NULL;
                    156:                len = 0;
                    157:            }
                    158:        }
                    159:        if (pe)
                    160:            pe_free (pe);
                    161:        free_OACS_PConnect(pcon);
                    162:        sc_reason = SC_REJECTED;
                    163:        goto out2;
                    164:     }
                    165: 
                    166:     acb -> acb_ckpoint = acb -> acb_ssdusize >> 10;
                    167:     if ((0 < pcon -> pUserData -> checkpointSize
                    168:        && pcon -> pUserData -> checkpointSize < acb -> acb_ckpoint)
                    169:            || acb -> acb_ckpoint <= 0)
                    170:        acb -> acb_ckpoint = pcon -> pUserData -> checkpointSize;
                    171:     acb -> acb_window = pcon -> pUserData -> windowSize;
                    172: 
                    173:     bzero ((char *) rts, sizeof *rts);
                    174:     rts -> rts_sd = acb -> acb_fd;
                    175:     rts -> rts_initiator.rta_addr = ss -> ss_calling;  /* struct copy */
                    176:     if (pcon->pUserData->dialogueMode == PCONN_DM_TWA)
                    177:        rts -> rts_mode = RTS_TWA, acb -> acb_flags |= ACB_TWA;
                    178:     else
                    179:        rts -> rts_mode = RTS_MONOLOGUE;
                    180:     rts -> rts_turn = acb -> acb_flags & ACB_TURN ? RTS_RESPONDER
                    181:            : RTS_INITIATOR;
                    182:     rts -> rts_port = htons ((u_short) pcon -> pUserData -> applicationProtocol);
                    183:     if (pcon -> pUserData -> member_OACS_2 -> offset
                    184:            == type_OACS_ConnectionData_open)
                    185:        rts->rts_data = pe_expunge(pe, pcon-> pUserData -> member_OACS_2
                    186:                                                        -> un.open);
                    187:     else
                    188:        rts -> rts_data = NULLPE;
                    189:     
                    190:     free_OACS_PConnect(pcon);
                    191:     return OK;
                    192: 
                    193: out2: ;
                    194:     bzero ((char *) &ref, sizeof ref);
                    195:     (void) SConnResponse (acb -> acb_fd, &ref, NULLSA, sc_reason, 0, 0,
                    196:            SERIAL_NONE, base, len, si);
                    197:     acb -> acb_fd = NOTOK;
                    198:     if (base)
                    199:        free (base);
                    200: 
                    201: out1: ;
                    202:     SSFREE (ss);
                    203:     freeacblk (acb);
                    204: 
                    205:     return NOTOK;
                    206: }
                    207: 
                    208: /*    RT-BEGIN.RESPONSE (X.410 OPEN.RESPONSE) */
                    209: 
                    210: int    RtBeginResponse (sd, status, data, rti)
                    211: int    sd;
                    212: int    status;
                    213: PE     data;
                    214: struct RtSAPindication *rti;
                    215: {
                    216:     int            len,
                    217:            result;
                    218:     char   *base;
                    219:     register PE        pe,
                    220:                p,
                    221:                q,
                    222:                r;
                    223:     register struct assocblk   *acb;
                    224:     struct SSAPref ref;
                    225:     struct SSAPindication sis;
                    226:     register struct SSAPindication *si = &sis;
                    227:     register struct SSAPabort *sa = &si -> si_abort;
                    228: 
                    229:     if ((acb = findacblk (sd)) == NULL || (acb -> acb_flags & ACB_CONN))
                    230:        return rtsaplose (rti, RTS_PARAMETER, NULLCP,
                    231:                "invalid association descriptor");
                    232:     if ((acb -> acb_flags & ACB_ACS) || !(acb -> acb_flags & ACB_RTS))
                    233:        return rtsaplose (rti, RTS_OPERATION, NULLCP,
                    234:                "not an association descriptor for RTS");
                    235:     switch (status) {
                    236:        case RTS_ACCEPT: 
                    237:            break;
                    238: 
                    239:        case RTS_MODE:
                    240:        case RTS_VALIDATE: 
                    241:        case RTS_BUSY: 
                    242:            if (data)
                    243:                return rtsaplose (rti, RTS_PARAMETER, NULLCP,
                    244:                        "user data not permitted when refusing association");
                    245:            break;
                    246: 
                    247:        default: 
                    248:            return rtsaplose (rti, RTS_PARAMETER, NULLCP,
                    249:                    "bad value for status parameter");
                    250:     }
                    251:     missingP (rti);
                    252: 
                    253:     base = NULLCP;
                    254:     switch (status) {
                    255:        case RTS_ACCEPT: 
                    256: /* begin PAccept PSDU */
                    257:            if ((pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET))
                    258:                    == NULLPE) {
                    259:        no_mem: ;
                    260:                (void) rtsaplose (rti, RTS_CONGEST, NULLCP, "out of memory");
                    261:                goto out1;
                    262:            }
                    263:            if (set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    264:                            PACC_DTS)) == NOTOK
                    265:                    || set_add (p, num2prim (SYN_X409, PE_CLASS_CONT,
                    266:                            DTS_SYNTAX)) == NOTOK
                    267:                    || set_add (pe, p = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    268:                            PACC_DATA)) == NOTOK
                    269:                    || set_add (p, num2prim (acb -> acb_ckpoint,
                    270:                            PE_CLASS_CONT, PACC_DATA_CK)) == NOTOK
                    271:                    || set_add (p, num2prim (acb -> acb_window,
                    272:                            PE_CLASS_CONT, PACC_DATA_WD)) == NOTOK
                    273:                    || set_add (p, q = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    274:                            PACC_DATA_CN)) == NOTOK
                    275:                    || set_add (q, r = pe_alloc (PE_CLASS_CONT, PE_FORM_CONS,
                    276:                            CN_OPEN)) == NOTOK
                    277:                    || set_add (r, data ? data : pe_alloc (PE_CLASS_UNIV,
                    278:                                                PE_FORM_PRIM, PE_PRIM_NULL))
                    279:                            == NOTOK)
                    280:                goto no_mem;
                    281: /* end PAccept PSDU */
                    282:            status = SC_ACCEPT;
                    283:            break;
                    284: 
                    285:        default: 
                    286: /* begin PRefuse PSDU */
                    287:            if ((pe = pe_alloc (PE_CLASS_UNIV, PE_FORM_CONS, PE_CONS_SET))
                    288:                    == NULLPE
                    289:                    || set_add (pe, num2prim (status, PE_CLASS_CONT,
                    290:                            PREF_REASON)) == NOTOK)
                    291:                goto no_mem;
                    292: /* end PRefuse PSDU */
                    293:            status = SC_REJECTED;
                    294:            break;
                    295:     }
                    296: 
                    297: #ifdef DEBUG
                    298:     if (rtsap_log -> ll_events & LLOG_PDUS)
                    299:        if (status == SC_ACCEPT)
                    300:            pvpdu (rtsap_log, print_OACS_PAccept_P, pe, "PAccept", 0);
                    301:        else
                    302:            pvpdu (rtsap_log, print_OACS_PRefuse_P, pe, "PRefuse", 0);
                    303: #endif
                    304: 
                    305:     if (pe2ssdu (pe, &base, &len) == NOTOK)
                    306:        goto no_mem;
                    307: 
                    308:     if (SConnResponse (acb -> acb_fd, &acb -> acb_connect, NULLSA, status,
                    309:                acb -> acb_requirements, acb -> acb_settings, SERIAL_NONE,
                    310:                base, len, si) == NOTOK) {
                    311:        acb -> acb_fd = NOTOK;
                    312:        (void) ss2rtslose (acb, rti, "SConnResponse", sa);
                    313:        goto out3;
                    314:     }
                    315: 
                    316:     if (status == SC_ACCEPT)
                    317:        acb -> acb_flags |= ACB_CONN;
                    318:     else {
                    319:        acb -> acb_fd = NOTOK;
                    320:        freeacblk (acb);
                    321:     }
                    322:     result = OK;
                    323: 
                    324: out2: ;
                    325:     if (pe) {
                    326:        if (data)
                    327:            (void) pe_extract (pe, data);
                    328:        pe_free (pe);
                    329:     }
                    330:     if (base)
                    331:        free (base);
                    332: 
                    333:     return result;
                    334: 
                    335: out1: ;
                    336:     bzero ((char *) &ref, sizeof ref);
                    337:     (void) SConnResponse (acb -> acb_fd, &ref, NULLSA, SC_CONGEST, 0, 0,
                    338:            SERIAL_NONE, NULLCP, 0, si);
                    339:     acb -> acb_fd = NOTOK;
                    340: out3: ;
                    341:     freeacblk (acb);
                    342:     result = NOTOK;
                    343:     goto out2;
                    344: }

unix.superglobalmegacorp.com

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