Annotation of 43BSDReno/contrib/isode-beta/quipu/conn_request.c, revision 1.1

1.1     ! root        1: /* conn_request.c - Generate DSP BIND from connection block */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/quipu/RCS/conn_request.c,v 7.4 90/07/09 14:45:28 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/quipu/RCS/conn_request.c,v 7.4 90/07/09 14:45:28 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       conn_request.c,v $
        !            12:  * Revision 7.4  90/07/09  14:45:28  mrose
        !            13:  * sync
        !            14:  * 
        !            15:  * Revision 7.3  89/12/19  16:20:06  mrose
        !            16:  * sync
        !            17:  * 
        !            18:  * Revision 7.2  89/11/27  10:30:09  mrose
        !            19:  * sync
        !            20:  * 
        !            21:  * Revision 7.1  89/11/24  16:21:56  mrose
        !            22:  * sync
        !            23:  * 
        !            24:  * Revision 7.0  89/11/23  22:16:55  mrose
        !            25:  * Release 6.0
        !            26:  * 
        !            27:  */
        !            28: 
        !            29: /*
        !            30:  *                               NOTICE
        !            31:  *
        !            32:  *    Acquisition, use, and distribution of this module and related
        !            33:  *    materials are subject to the restrictions of a license agreement.
        !            34:  *    Consult the Preface in the User's Manual for the full terms of
        !            35:  *    this agreement.
        !            36:  *
        !            37:  */
        !            38: 
        !            39: 
        !            40: /* LINTLIBRARY */
        !            41: 
        !            42: #include "quipu/dsap.h"
        !            43: #include "tsap.h"
        !            44: #include "quipu/util.h"
        !            45: #include "quipu/connection.h"
        !            46: 
        !            47: extern time_t  timenow;
        !            48: 
        !            49: struct connection      * conn_alloc();
        !            50: void                     conn_free();
        !            51: 
        !            52: extern LLog    * log_dsap;
        !            53: #ifndef NO_STATS
        !            54: extern LLog * log_stat;
        !            55: extern int     dn_print();
        !            56: #endif
        !            57: 
        !            58: extern  PS      opt;
        !            59: extern unsigned watchdog_time;
        !            60: extern unsigned watchdog_delta;
        !            61: 
        !            62: /*
        !            63: *  conn_request uses the directory bind argument and context
        !            64: *  set up in the connection block to generate an asynchronous
        !            65: *  association request.
        !            66: *  If OK is returned the connection should be linked onto
        !            67: *  the global list.
        !            68: *  If NOTOK is returned the connection block should be freed,
        !            69: *  alerting all the operations requesting it.
        !            70: */
        !            71: conn_request(cn)
        !            72: register        struct connection       * cn;
        !            73: {
        !            74:     struct DSAPconnect         dc_s;
        !            75:     struct DSAPconnect         *dc = &dc_s;
        !            76:     struct DSAPindication        di_s;
        !            77:     struct DSAPindication      * di = &(di_s);
        !            78:     int                                  inv_ret;
        !            79: 
        !            80:     DLOG(log_dsap, LLOG_TRACE, ("conn_request()"));
        !            81:     LLOG(log_dsap, LLOG_NOTICE, ("conn_request: Calling: %s", paddr2str(&(cn->cn_addr),NULLNA)));
        !            82: 
        !            83:     switch(cn->cn_ctx)
        !            84:     {
        !            85:     case DS_CTX_X500_DAP:
        !            86:        LLOG(log_dsap, LLOG_EXCEPTIONS, ("Making DAP connections illegal for DSA"));
        !            87:        return(NOTOK);
        !            88: 
        !            89:     case DS_CTX_X500_DSP:
        !            90:        LLOG(log_dsap, LLOG_TRACE, ("Making an X500 DSP connection"));
        !            91:        watch_dog ("DspAsynBindRequest");
        !            92:        inv_ret = DspAsynBindRequest (&(cn->cn_addr), &(cn->cn_connect.cc_req),
        !            93:                        (int) (watchdog_time - watchdog_delta), dc, di, ROS_ASYNC);
        !            94:        watch_dog_reset ();
        !            95:        break;
        !            96: 
        !            97:     case DS_CTX_QUIPU_DSP:
        !            98:        LLOG(log_dsap, LLOG_TRACE, ("Making a QUIPU DSP connection"));
        !            99:        watch_dog ("QspAsynBindRequest");
        !           100:        inv_ret = QspAsynBindRequest (&(cn->cn_addr),
        !           101:                        &(cn->cn_connect.cc_req),
        !           102:                        (int) (watchdog_time - watchdog_delta), dc, di, ROS_ASYNC);
        !           103:        watch_dog_reset ();
        !           104:        break;
        !           105: 
        !           106:     default:
        !           107:        LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown connection context"));
        !           108:        return(NOTOK);
        !           109:     }
        !           110: 
        !           111:     cn->cn_last_used = timenow;
        !           112: 
        !           113:     switch(inv_ret)
        !           114:     {
        !           115:     case NOTOK:
        !           116:        DLOG(log_dsap, LLOG_NOTICE, ("ASYN BIND REQUEST NOTOK!"));
        !           117: #ifndef NO_STATS
        !           118:        pslog (log_stat, LLOG_NOTICE, "Failed (NOTOK)", dn_print, (caddr_t) cn->cn_dn);
        !           119: #endif
        !           120:        dsa_reliable (cn,FALSE,timenow);
        !           121:        return(NOTOK);
        !           122:     case DONE:
        !           123:        DLOG(log_dsap, LLOG_NOTICE, ("ASYN BIND REQUEST DONE! (ad = %d)", dc->dc_sd));
        !           124:        cn->cn_ad = dc->dc_sd;
        !           125:        if (cn->cn_ad == NOTOK)
        !           126:        {
        !           127:            DCFREE(dc);
        !           128: #ifndef NO_STATS
        !           129:            pslog(log_stat, LLOG_NOTICE, "Failed (DONE)", dn_print, (caddr_t) cn->cn_dn);
        !           130: #endif
        !           131:            cn->cn_state = CN_FAILED;
        !           132:            dsa_reliable (cn,FALSE,timenow);
        !           133:            return(NOTOK);
        !           134:        }
        !           135:        if (conn_req_aux(cn, dc) == NOTOK) {
        !           136: #ifndef NO_STATS
        !           137:            pslog(log_stat, LLOG_NOTICE, "Failed (DONE 2)", dn_print, (caddr_t) cn->cn_dn);
        !           138: #endif
        !           139:            dsa_reliable (cn,FALSE,timenow);
        !           140:            return NOTOK;
        !           141:        }
        !           142:        return OK;
        !           143:     case CONNECTING_1:
        !           144:        DLOG (log_dsap,LLOG_NOTICE,("ASYN BIND REQUEST CONNECTING_1 (ad = %d)", dc->dc_sd));
        !           145:        cn->cn_ad = dc->dc_sd;
        !           146:        DCFREE(dc);
        !           147:        cn->cn_state = CN_CONNECTING1;
        !           148: #ifndef NO_STATS
        !           149:        pslog (log_stat, LLOG_NOTICE, "Trying (CONN_1)", dn_print, (caddr_t) cn->cn_dn);
        !           150: #endif
        !           151:        return(OK);
        !           152: 
        !           153:     case CONNECTING_2:
        !           154:        DLOG (log_dsap,LLOG_NOTICE,("ASYN BIND REQUEST CONNECTING_2 (ad = %d)", dc->dc_sd));
        !           155:        cn->cn_ad = dc->dc_sd;
        !           156:        DCFREE(dc);
        !           157:        cn->cn_state = CN_CONNECTING2;
        !           158: #ifndef NO_STATS
        !           159:        pslog (log_stat, LLOG_NOTICE, "Trying (CONN_2)", dn_print, (caddr_t) cn->cn_dn);
        !           160: #endif
        !           161:        return(OK);
        !           162: 
        !           163:     default:
        !           164:        LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown return from DAsynBind : %d", inv_ret));
        !           165:        return(NOTOK);
        !           166:     } /* switch inv_ret */
        !           167:     /* NOTREACHED */
        !           168: }
        !           169: 
        !           170: /*
        !           171: * conn_req_aux() is called to complete work started by conn_request().
        !           172: * Current major complication is how to deal with an undecodable BindResult.
        !           173: * If OK is returned, the connection is ready for action and any waiting
        !           174: * operations should be sent.
        !           175: * If NOTOK is returned the connection needs to be extracted, alerting any
        !           176: * waiting operations in the process.
        !           177: */
        !           178: conn_req_aux(cn, dc)
        !           179: register        struct connection       * cn;
        !           180: register        struct DSAPconnect     * dc;
        !           181: {
        !           182: 
        !           183:     switch(dc->dc_result)
        !           184:     {
        !           185:        case DS_RESULT:
        !           186:            DLOG(log_dsap, LLOG_NOTICE, ("D-BIND.RETRY(ASYNC) RESULT"));
        !           187:            cn->cn_state = CN_OPEN;
        !           188:        break;
        !           189: 
        !           190:        case DS_ERROR:
        !           191:            /*
        !           192:            * Get the DirectoryBindError
        !           193:            */
        !           194:            DLOG(log_dsap, LLOG_NOTICE, ("D-BIND.RETRY(ASYNC) ERROR"));
        !           195:            cn->cn_state = CN_FAILED;
        !           196:            cn->cn_ad = 0;
        !           197:        break;
        !           198: 
        !           199:        default:
        !           200:            DLOG(log_dsap, LLOG_NOTICE, ("D-BIND.RETRY(ASYNC) OTHER"));
        !           201:            cn->cn_state = CN_FAILED;
        !           202:            cn->cn_ad = 0;
        !           203:            LLOG (log_dsap,LLOG_EXCEPTIONS,( "Association rejected"));
        !           204: /* ADT
        !           205:            LLOG (log_dsap,LLOG_EXCEPTIONS,( "Association rejected: [%s]",
        !           206:              DErrString(dc->dc_result)));
        !           207: */
        !           208:        break;
        !           209: 
        !           210:     } /* switch acc->acc_result */
        !           211: 
        !           212:     if(cn->cn_state == CN_OPEN)
        !           213:     {
        !           214:        struct TSAPdisconnect       td_s;
        !           215:        struct TSAPdisconnect       *td = &td_s;
        !           216: 
        !           217:        if (TSetQueuesOK (cn->cn_ad, 1, td) == NOTOK) 
        !           218:                td_log (td, "TSetQueuesOK (outgoing)");
        !           219: 
        !           220:        cn->cn_last_used = timenow;
        !           221:        dsa_reliable (cn,TRUE,cn->cn_last_used);
        !           222: #ifndef NO_STATS
        !           223:            {
        !           224:                char buf [LINESIZE];
        !           225:                (void) sprintf (buf,"Bound using %s DSP context (%d)", cn->cn_ctx == DS_CTX_QUIPU_DSP ? "QUIPU" : "X500", cn->cn_ad);
        !           226:                pslog(log_stat, LLOG_NOTICE, buf, dn_print, (caddr_t) cn->cn_dn);
        !           227:            }
        !           228: #endif
        !           229:        return(OK);
        !           230:     }
        !           231: 
        !           232:     return(NOTOK);
        !           233: }
        !           234: 

unix.superglobalmegacorp.com

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