|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 9176 (0x23d8)
Types: TextFile
Names: »conn_request.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z«
└─⟦de7628f85⟧
└─⟦this⟧ »isode-6.0/quipu/conn_request.c«
/* conn_request.c - Perform DSP BIND */
#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/conn_request.c,v 7.3 89/12/19 16:20:06 mrose Exp $";
#endif
/*
* $Header: /f/osi/quipu/RCS/conn_request.c,v 7.3 89/12/19 16:20:06 mrose Exp $
*
*
* $Log: conn_request.c,v $
* Revision 7.3 89/12/19 16:20:06 mrose
* sync
*
* Revision 7.2 89/11/27 10:30:09 mrose
* sync
*
* Revision 7.1 89/11/24 16:21:56 mrose
* sync
*
* Revision 7.0 89/11/23 22:16:55 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
/* LINTLIBRARY */
#include "acsap.h"
#include "rosap.h"
#include "tsap.h"
#include "quipu/util.h"
#include "quipu/connection.h"
extern time_t time();
Conn conn_alloc();
void conn_free();
extern LLog * log_dsap;
#ifndef NO_STATS
extern LLog * log_stat;
extern int dn_print();
#endif
extern PS opt;
extern OID acse_pci;
extern OID x500_da_ac;
extern OID x500_da_as;
extern OID x500_ds_ac;
extern OID x500_ds_as;
extern OID quipu_ds_ac;
extern OID quipu_ds_as;
extern struct PSAPctxlist * x500_da_pcdl;
extern struct PSAPctxlist * x500_ds_pcdl;
extern struct PSAPctxlist * quipu_ds_pcdl;
extern unsigned watchdog_time;
extern unsigned watchdog_delta;
/*
* conn_request uses the directory bind argument and context
* set up in the connection block to generate an asynchronous
* association request.
* If OK is returned the connection should be linked onto
* the global list.
* If NOTOK is returned the connection block should be freed,
* alerting all the operations requesting it.
*/
conn_request(cn)
register struct connection * cn;
{
struct ds_bind_arg *bind_arg;
PE data;
struct AcSAPconnect acc_s;
struct AcSAPconnect *acc = &acc_s;
struct AcSAPindication aci_s;
struct AcSAPindication *aci = &aci_s;
struct AcSAPabort *aca = &aci->aci_abort;
struct PSAPctxlist * pc;
OID app_ctx;
OID def_ctx;
int inv_ret;
DLOG(log_dsap, LLOG_TRACE, ("conn_request()"));
/*
* Build the BIND C-structure into a PE to send.
*/
bind_arg = &(cn->cn_init_act.ia_req);
if(encode_DAS_DirectoryBindArgument(&data, 0, 0, NULLCP, bind_arg) == OK)
{
DLOG(log_dsap, LLOG_TRACE, ("Calling another DSA!"));
LLOG(log_dsap, LLOG_NOTICE, ("conn_request: Calling: %s", paddr2str(&(cn->cn_addr),NULLNA)));
/*
* Set up the context list each time there is a call.
*/
pc = (struct PSAPctxlist *) smalloc(sizeof(struct PSAPctxlist));
switch(cn->cn_ctx)
{
case CN_CTX_X500_DAP:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Making a DAP connection"));
app_ctx = x500_da_ac;
def_ctx = x500_da_as;
(*pc) = (*(x500_da_pcdl)); /* structure assignment */
break;
case CN_CTX_X500_DSP:
LLOG(log_dsap, LLOG_TRACE, ("Making an X500 DSP connection"));
app_ctx = x500_ds_ac;
def_ctx = x500_ds_as;
(*pc) = (*(x500_ds_pcdl)); /* structure assignment */
break;
case CN_CTX_QUIPU_DSP:
LLOG(log_dsap, LLOG_TRACE, ("Making a QUIPU DSP connection"));
app_ctx = quipu_ds_ac;
def_ctx = quipu_ds_as;
(*pc) = (*(quipu_ds_pcdl)); /* structure assignment */
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown connection context"));
pe_free(data);
return(NOTOK);
}
data -> pe_context = cn->cn_context_id = 3;
watch_dog ("RyAsynBind");
inv_ret = RyAsynBind(app_ctx, &(cn->cn_addr), pc, def_ctx,
data, NOTOK, acc, aci,
(int) (watchdog_time - watchdog_delta),
cn->cn_ctx == CN_CTX_QUIPU_DSP);
watch_dog_reset ();
free ((char *)pc);
pe_free(data);
cn->cn_last_used = time ((time_t *)0);
switch(inv_ret)
{
case NOTOK:
DLOG(log_dsap, LLOG_NOTICE, ("A-ASSOCIATE.REQUEST ASYNC NOTOK!"));
ACAFREE(aca);
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog (log_stat, LLOG_NOTICE, "Failed (NOTOK)", dn_print, (caddr_t) cn->cn_what);
#endif
dsa_reliable (cn,FALSE,time((time_t *) 0));
return(NOTOK);
case DONE:
DLOG(log_dsap, LLOG_NOTICE, ("A-ASSOCIATE.REQUEST ASYNC DONE! (ad = %d)", acc->acc_sd));
cn->cn_ad = acc->acc_sd;
if ( (cn->cn_ad == NOTOK) || (SetROPS(cn->cn_ad) != OK))
{
ACCFREE(acc);
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog(log_stat, LLOG_NOTICE, "Failed (DONE)", dn_print, (caddr_t) cn->cn_what);
#endif
cn->cn_state = CN_FAILED;
dsa_reliable (cn,FALSE,time((time_t *) 0));
return(NOTOK);
}
if (conn_req_aux(cn, acc) == NOTOK) {
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog(log_stat, LLOG_NOTICE, "Failed (DONE 2)", dn_print, (caddr_t) cn->cn_what);
#endif
dsa_reliable (cn,FALSE,time((time_t *) 0));
return NOTOK;
}
return OK;
case CONNECTING_1:
DLOG (log_dsap,LLOG_NOTICE,("A-ASSOCIATE.REQUEST ASYNC CONNECTING_1 (ad = %d)", acc->acc_sd));
cn->cn_ad = acc->acc_sd;
ACCFREE(acc);
if(SetROPS(cn->cn_ad) != OK)
{
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog(log_stat, LLOG_NOTICE, "Failed (CONN_1)", dn_print, (caddr_t) cn->cn_what);
#endif
dsa_reliable (cn,FALSE,time((time_t *) 0));
return(NOTOK);
}
cn->cn_state = CN_CONNECTING1;
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog (log_stat, LLOG_NOTICE, "Trying (CONN_1)", dn_print, (caddr_t) cn->cn_what);
#endif
return(OK);
case CONNECTING_2:
DLOG (log_dsap,LLOG_NOTICE,("A-ASSOCIATE.REQUEST ASYNC CONNECTING_2 (ad = %d)", acc->acc_sd));
cn->cn_ad = acc->acc_sd;
ACCFREE(acc);
if(SetROPS(cn->cn_ad) != OK)
{
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog(log_stat, LLOG_NOTICE, "Failed (CONN_2)", dn_print, (caddr_t) cn->cn_what);
#endif
dsa_reliable (cn,FALSE,time((time_t *) 0));
return(NOTOK);
}
cn->cn_state = CN_CONNECTING2;
#ifndef NO_STATS
(void) dn_decode(cn->cn_what);
pslog (log_stat, LLOG_NOTICE, "Trying (CONN_2)", dn_print, (caddr_t) cn->cn_what);
#endif
return(OK);
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown return from RyAsynBind : %d", inv_ret));
return(NOTOK);
} /* switch inv_ret */
}
else
{
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unable to encode DirectoryBindArgument"));
return(NOTOK);
}
/* NOTREACHED */
}
/*
* conn_req_aux() is called to complete work started by conn_request().
* Current major complication is how to deal with an undecodable BindResult.
* If OK is returned, the connection is ready for action and any waiting
* operations should be sent.
* If NOTOK is returned the connection needs to be extracted, alerting any
* waiting operations in the process.
*/
conn_req_aux(cn, acc)
register struct connection * cn;
register struct AcSAPconnect * acc;
{
struct ds_bind_arg * bind_res;
struct ds_bind_error * bind_err;
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
ParseRyBindResponse(acc);
switch(acc->acc_result)
{
case ACS_ACCEPT:
DLOG(log_dsap, LLOG_NOTICE, ("A-ASSOCIATE.RETRY ASYNC ACCEPT"));
bind_res = &(cn->cn_init_act.ia_res);
if(decode_DAS_DirectoryBindResult(acc->acc_info[0], 1, NULLIP, NULLVP, bind_res) == OK)
{
cn->cn_state = CN_OPEN;
}
else
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unable to parse DirectoryBindResult"));
/* Need to get rid of this connection */
cn->cn_state = CN_FAILED;
}
break;
case ACS_PERMANENT:
/*
* Get the DirectoryBindError
*/
DLOG(log_dsap, LLOG_NOTICE, ("A-ASSOCIATE.RETRY ASYNC PERMANENT"));
cn->cn_state = CN_FAILED;
cn->cn_ad = 0;
bind_err = &(cn->cn_init_act.ia_err);
if(acc->acc_info != 0)
{
if(decode_DAS_DirectoryBindError(acc->acc_info[0], 1, NULLIP, NULLVP, bind_err) != OK)
{
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unable to decode DirectoryBindError"));
}
else
{
LLOG(log_dsap, LLOG_NOTICE, ("Received DirectoryBindError"));
}
}
else
{
LLOG(log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindError"));
}
default:
DLOG(log_dsap, LLOG_NOTICE, ("A-ASSOCIATE.RETRY ASYNC OTHER"));
cn->cn_state = CN_FAILED;
cn->cn_ad = 0;
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Association rejected: [%s]",
AcErrString(acc->acc_result)));
break;
} /* switch acc->acc_result */
if(cn->cn_state == CN_OPEN)
{
struct TSAPdisconnect td_s;
struct TSAPdisconnect *td = &td_s;
if (TSetQueuesOK (cn->cn_ad, 1, td) == NOTOK)
td_log (td, "TSetQueuesOK (outgoing)");
cn->cn_last_used = time((time_t *) 0);
dsa_reliable (cn,TRUE,cn->cn_last_used);
#ifndef NO_STATS
{
char buf [LINESIZE];
(void) sprintf (buf,"Bound using %s DSP context (%d)", cn->cn_ctx == CN_CTX_QUIPU_DSP ? "QUIPU" : "X500", cn->cn_ad);
(void) dn_decode(cn->cn_what);
pslog(log_stat, LLOG_NOTICE, buf, dn_print, (caddr_t) cn->cn_what);
}
#endif
return(OK);
}
return(NOTOK);
}