Annotation of 43BSDReno/contrib/isode-beta/tsap/tsapstate.c, revision 1.1.1.1

1.1       root        1: /* tsapstate.c - TPM: hack state */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/tsap/RCS/tsapstate.c,v 7.2 90/03/23 17:31:54 mrose Exp $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/tsap/RCS/tsapstate.c,v 7.2 90/03/23 17:31:54 mrose Exp $
                      9:  *
                     10:  *
                     11:  * $Log:       tsapstate.c,v $
                     12:  * Revision 7.2  90/03/23  17:31:54  mrose
                     13:  * 8
                     14:  * 
                     15:  * Revision 7.1  90/03/22  08:38:12  mrose
                     16:  * touch-up
                     17:  * 
                     18:  * Revision 7.0  89/11/23  22:30:58  mrose
                     19:  * Release 6.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 <signal.h>
                     38: #include "tpkt.h"
                     39: 
                     40: /*  */
                     41: 
                     42: int    TSaveState (sd, vec, td)
                     43: int    sd;
                     44: char  **vec;
                     45: register struct TSAPdisconnect *td;
                     46: {
                     47:     SBV     smask;
                     48:     register struct tsapblk *tb;
                     49:     static char buffer[sizeof *tb * 2 + 1];
                     50: 
                     51:     missingP (vec);
                     52: 
                     53:     smask = sigioblock ();
                     54: 
                     55:     tsapPsig (tb, sd);
                     56: 
                     57:     if (tb -> tb_len > 0) {
                     58:        (void) sigiomask (smask);
                     59: 
                     60:        return tsaplose (td, DR_WAITING, NULLCP, NULLCP);
                     61:     }
                     62: 
                     63:     buffer[explode (buffer, (u_char *) tb, sizeof *tb)] = NULL;
                     64:     *vec++ = buffer;
                     65:     *vec = NULL;
                     66: 
                     67:     tb -> tb_fd = NOTOK;
                     68: 
                     69:     freetblk (tb);
                     70: 
                     71:     (void) sigiomask (smask);
                     72: 
                     73:     return OK;
                     74: }
                     75: 
                     76: /*  */
                     77: 
                     78: int    TRestoreState (buffer, ts, td)
                     79: char   *buffer;
                     80: register struct TSAPstart *ts;
                     81: register struct TSAPdisconnect *td;
                     82: {
                     83:     struct tsapblk  tbs;
                     84:     register struct tsapblk *tb;
                     85: 
                     86:     missingP (buffer);
                     87:     missingP (ts);
                     88: 
                     89:     if ((tb = newtblk ()) == NULL)
                     90:        return tsaplose (td, DR_CONGEST, NULLCP, "out of memory");
                     91: 
                     92:     if (implode ((u_char *) &tbs, buffer, strlen (buffer)) != sizeof tbs) {
                     93:        (void) tsaplose (td, DR_PARAMETER, NULLCP, "bad state vector");
                     94:        goto out1;
                     95:     }
                     96: 
                     97:     if (findtblk (tbs.tb_fd)) {
                     98:        (void) tsaplose (td, DR_PARAMETER, NULLCP, "transport descriptor active");
                     99:        goto out1;
                    100:     }
                    101:     tb -> tb_fd = tbs.tb_fd;
                    102:     tb -> tb_flags = tbs.tb_flags & (TB_CONN | TB_EXPD | TB_TP0 | TB_TP4);
                    103:     tb -> tb_srcref = tbs.tb_srcref;
                    104:     tb -> tb_dstref = tbs.tb_dstref;
                    105:     tb -> tb_initiating = tbs.tb_initiating;   /* struct copy */
                    106:     tb -> tb_responding = tbs.tb_responding;   /* struct copy */
                    107: 
                    108:     switch (tb -> tb_flags & (TB_TP0 | TB_TP4)) {
                    109: #ifdef TCP
                    110:        case TB_TCP: 
                    111:            (void) TTService (tb);
                    112:            break;
                    113: #endif
                    114: 
                    115: #ifdef X25
                    116:        case TB_X25: 
                    117:            (void) XTService (tb);
                    118:            break;
                    119: #endif
                    120: 
                    121: #ifdef BRIDGE_X25
                    122:        case TB_BRG:
                    123:            (void) BTService (tb);
                    124:            break;
                    125: #endif
                    126: 
                    127: #ifdef TP4
                    128:        case TB_TP4: 
                    129:            (void) tp4init (tb);
                    130:            break;
                    131: #endif
                    132: 
                    133:        default: 
                    134:            (void) tsaplose (td, DR_PARAMETER, NULLCP, "network type not set");
                    135:            tb -> tb_fd = NOTOK;
                    136:            goto out1;
                    137:     }
                    138: 
                    139:     tb -> tb_tsdusize = tbs.tb_tsdusize;
                    140: 
                    141:     bzero ((char *) ts, sizeof *ts);
                    142:     ts -> ts_sd = tb -> tb_fd;
                    143:     copyTSAPaddrX (&tb -> tb_initiating, &ts -> ts_calling);
                    144:     copyTSAPaddrX (&tb -> tb_responding, &ts -> ts_called);
                    145:     if (tb -> tb_flags & TB_EXPD)
                    146:        ts -> ts_expedited = 1;
                    147:     ts -> ts_tsdusize = tb -> tb_tsdusize;
                    148:     ts -> ts_qos = tb -> tb_qos;       /* struct copy */
                    149: 
                    150:     return OK;
                    151: 
                    152: out1: ;
                    153:     freetblk (tb);
                    154: 
                    155:     return NOTOK;
                    156: }

unix.superglobalmegacorp.com

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