|
|
BSD 4.3reno
/* conn_init.c - deal with incoming association requests */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/quipu/conn_init.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/quipu/conn_init.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
*
* $Log: conn_init.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.4 90/07/09 14:45:24 mrose
* sync
*
* Revision 7.3 90/03/15 11:18:42 mrose
* quipu-sync
*
* Revision 7.2 89/12/19 16:20:03 mrose
* sync
*
* Revision 7.1 89/11/24 16:21:53 mrose
* sync
*
* Revision 7.0 89/11/23 22:16:46 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.
*
*/
#include "quipu/dsap.h"
#include "tsap.h"
#include "quipu/util.h"
#include "quipu/connection.h"
extern LLog * log_dsap;
#ifndef NO_STATS
extern LLog * log_stat;
#endif
void ds_log();
struct connection * conn_alloc();
void acs_log();
extern time_t timenow;
conn_init(cn)
struct connection * cn;
{
int result;
char **vec;
struct DSAPstart * ds;
struct DSAPindication di_s;
struct DSAPindication * di = &di_s;
struct DSAPabort * da = &(di->di_abort);
struct TSAPdisconnect td_s;
struct TSAPdisconnect * td = &td_s;
DLOG (log_dsap,LLOG_TRACE,( "conn_init()"));
vec = cn->cn_start.cs_vec;
ds = &(cn->cn_start.cs_ds);
watch_dog ("DBindInit");
result = DBindInit (cn->cn_start.cs_vecp, vec, ds, di);
watch_dog_reset();
if (result != OK)
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "conn_init(): DBindInit() != OK"));
ds_log(da, "initialization fails");
conn_extract (cn);
free((char *)ds);
return;
}
DLOG (log_dsap,LLOG_TRACE,( "conn_init(): DBindInit() OK"));
/*
* Log the arrival of a connection request.
*/
LLOG (log_dsap,LLOG_NOTICE, ("Association (%d) from %s",
ds->ds_sd, paddr2str(&(ds->ds_start.acs_start.ps_calling),NULLNA)));
DLOG (log_dsap,LLOG_NOTICE, ("Context: %s; Caller: %s; Callee: %s.",
oid2ode(ds->ds_start.acs_context),
sprintaei (&ds->ds_start.acs_callingtitle),
sprintaei (&ds->ds_start.acs_calledtitle)));
cn->cn_ad = ds->ds_sd;
cn->cn_initiator = FALSE;
cn->cn_ctx = ds->ds_ctx;
cn->cn_dn = dn_cpy(ds->ds_bind_arg.dba_dn);
/*
* If we haven't returned yet then the protocol for binding has been
* satisfactorily completed.
* Now attempt to perform the ds_bind for the argument decoded, which
* can either succeed, fail or suspend waiting for a remote compare.
* If a remote compare has been scheduled then return, otherwise
* complete the connection initialisation by sending a bind result.
*/
if (TSetQueuesOK (cn->cn_ad, 1, td) == NOTOK)
td_log (td, "TSetQueuesOK (incoming)");
switch(ds_bind_init(cn))
{
case DS_OK:
conn_init_res(cn);
break;
case DS_ERROR_CONNECT:
conn_init_err(cn);
break;
case DS_CONTINUE:
cn->cn_state = CN_INDICATED;
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unexpected return by ds_bind_init"));
watch_dog ("DBindReject");
(void) DBindReject (ds, ACS_TRANSIENT, ACS_USER_NOREASON, di);
watch_dog_reset();
break;
}
}
conn_init_res(cn)
struct connection * cn;
{
int result;
struct DSAPindication di_s;
struct DSAPindication *di = &(di_s);
struct DSAPabort *da = &(di->di_abort);
struct DSAPstart * ds = &(cn->cn_start.cs_ds);
struct AcSAPstart * acs = &(ds->ds_start);
struct PSAPstart * ps = &(acs->acs_start);
DLOG(log_dsap,LLOG_TRACE, ("conn_init_res()"));
DLOG(log_dsap,LLOG_NOTICE, ("D-BIND.RESULT"));
#ifdef DEBUG
{
int i;
for(i=0; i<ps->ps_ctxlist.pc_nctx; i++)
{
DLOG(log_dsap, LLOG_DEBUG, ("ctx[%d] id = %d, res = %d.", i,
ps->ps_ctxlist.pc_ctx[i].pc_id,
ps->ps_ctxlist.pc_ctx[i].pc_result));
}
}
#endif
watch_dog ("DBindResult");
result = DBindResult (cn->cn_ad, acs->acs_context, NULLAEI, NULLPA,
&(ps->ps_ctxlist), ps->ps_defctxresult, PR_MYREQUIRE,
ps->ps_srequirements & (ROS_MYREQUIRE | SR_NEGOTIATED),
SERIAL_NONE, ps->ps_settings, &(ps->ps_connect),
&(cn->cn_start.cs_res), ds->ds_pctx_id, di);
watch_dog_reset();
if (result == OK)
{
cn->cn_state = CN_OPEN;
}
else
{
ds_log(da, "D-BIND.RESULT");
DLOG(log_dsap, LLOG_DEBUG, ("conn_init_res(): DBindResult failed, extracting conn"));
conn_extract(cn);
}
}
conn_init_err(cn)
struct connection * cn;
{
int result;
struct DSAPindication di_s;
struct DSAPindication *di = &di_s;
struct DSAPabort *da = &di->di_abort;
struct DSAPstart * ds = &(cn->cn_start.cs_ds);
struct AcSAPstart * acs = &(ds->ds_start);
struct PSAPstart * ps = &(acs->acs_start);
DLOG(log_dsap,LLOG_TRACE, ("conn_init_err()"));
DLOG(log_dsap,LLOG_NOTICE, ("D-BIND.ERROR"));
#ifdef DEBUG
{
int i;
for(i=0; i<ps->ps_ctxlist.pc_nctx; i++)
{
DLOG(log_dsap, LLOG_DEBUG, ("ctx[%d] id = %d, res = %d.", i,
ps->ps_ctxlist.pc_ctx[i].pc_id,
ps->ps_ctxlist.pc_ctx[i].pc_result));
}
}
#endif
watch_dog ("DBindError");
result = DBindError (cn->cn_ad, acs->acs_context, NULLAEI, NULLPA,
&(ps->ps_ctxlist), ps->ps_defctxresult, PR_MYREQUIRE,
ps->ps_srequirements & (ROS_MYREQUIRE | SR_NEGOTIATED),
SERIAL_NONE, ps->ps_settings, &(ps->ps_connect),
&(cn->cn_start.cs_err), ds->ds_pctx_id, di);
watch_dog_reset();
if (result == OK)
{
DLOG(log_dsap,LLOG_TRACE, ("status != ACS_ACCEPT"));
DLOG(log_dsap, LLOG_DEBUG, ("conn_init_err(): DBindError succeeded, extracting conn"));
conn_extract(cn);
}
else
{
ds_log(da, "D-BIND.ERROR");
DLOG(log_dsap, LLOG_DEBUG, ("conn_init_err(): DBindError failed, extracting conn"));
conn_extract(cn);
}
}
conn_pre_init(newfd, vecp, vec)
int newfd;
int vecp;
char **vec;
{
struct connection * cn;
cn = conn_alloc();
cn->cn_next = connlist;
connlist = cn;
conns_used++;
cn->cn_ad = newfd;
cn->cn_initiator = FALSE;
cn->cn_start.cs_vecp = vecp;
if (vec[0])
cn->cn_start.cs_svec[0] = cn->cn_start.cs_vec[0] = strdup (vec[0]);
if (vec[1])
cn->cn_start.cs_svec[1] = cn->cn_start.cs_vec[1] = strdup (vec[1]);
if (vec[2])
cn->cn_start.cs_svec[2] = cn->cn_start.cs_vec[2] = strdup (vec[2]);
if (vec[3])
cn->cn_start.cs_svec[3] = cn->cn_start.cs_vec[3] = strdup (vec[3]);
cn->cn_state = CN_OPENING;
cn->cn_last_used = timenow;
if (newfd == NOTOK)
conn_init (cn);
else
DLOG (log_dsap,LLOG_NOTICE, ("opening association on %d",newfd ));
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.