|
|
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 n
Length: 9715 (0x25f3)
Types: TextFile
Names: »nw_ac_in_req.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/quipu/nw_ac_in_req.c«
/* nw_ac_in_req.c - */
#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/nw_ac_in_req.c,v 6.0 89/03/18 23:41:45 mrose Rel $";
#endif
/*
* $Header: /f/osi/quipu/RCS/nw_ac_in_req.c,v 6.0 89/03/18 23:41:45 mrose Rel $
*
*
* $Log: nw_ac_in_req.c,v $
* Revision 6.0 89/03/18 23:41:45 mrose
* Release 5.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 "acsap.h"
#include "rosap.h"
#include "quipu/util.h"
#include "quipu/connection.h"
extern LLog * log_dsap;
#ifndef NO_STATS
extern LLog * log_stat;
#endif
Conn conn_alloc();
void acs_log();
extern OID acse_pci;
extern OID x500_da_ac;
extern OID x500_ds_ac;
extern struct PSAPctxlist * x500_da_pcdl;
extern struct PSAPctxlist * x500_ds_pcdl;
int net_wait_init_request(vecp, vec)
int vecp;
char *vec[4];
{
Conn cn;
struct AcSAPstart * acs;
struct AcSAPindication aci_s;
struct AcSAPindication * aci = &aci_s;
struct AcSAPabort * aca = &(aci->aci_abort);
struct ds_bind_arg * bind_arg;
PE pe;
DLOG (log_dsap,LLOG_TRACE,( "net_wait_init_request()"));
acs = (struct AcSAPstart *) malloc(sizeof(struct AcSAPstart));
if(AcInit(vecp, vec, acs, aci) == OK) {
DLOG (log_dsap,LLOG_TRACE,( "net_wait_init_request() : AcInit() OK"));
/*
* Examine the argument vector.
*/
for(vec++; *vec; vec++)
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "unknown argument \"%s\"", *vec));
}
/*
* Log the arrival of a connection request.
*/
LLOG (log_dsap,LLOG_NOTICE,
("A-ASSOCIATE.INDICATION: <%d, %s, %s, %s, %d> <%s>",
acs->acs_sd, oid2ode(acs->acs_context),
sprintaei (&acs->acs_callingtitle),
sprintaei (&acs->acs_calledtitle), acs->acs_ninfo,
paddr2str (&(acs->acs_start.ps_calling), NULLNA)));
if(SetROPS(acs->acs_sd) == OK) {
cn = conn_alloc();
cn->cn_next = id_st.connlist;
id_st.connlist = cn;
cn->cn_ad = acs->acs_sd;
cn->cn_initiator = INITIATED_BY_THAT;
cn->cn_state = CN_STATE_INIT;
cn->cn_init_act.ia_acs = acs;
LLOG (log_dsap,LLOG_EXCEPTIONS,( "New association with ad %d", cn->cn_ad));
if(acs->acs_sd >= id_st.nads)
id_st.nads = acs->acs_sd + 1;
FD_SET (acs->acs_sd, &id_st.iads);
/*
Peel off the remote operations BIND tag. For the time being we continue
if it is not present even though this is in error
*/
if (acs->acs_info[0] != NULLPE) {
pe = pe_cpy (acs->acs_info[0]);
if (parse_Remote__Operations__Notation_BindArgumentValue (pe,
1, NULL, NULLCP, &acs->acs_info[0]) != OK) {
/* We continue here since we will fail later if this is bad */
LLOG (log_dsap, LLOG_EXCEPTIONS, ("parse_Remote__Operations__Notation_BindArgumentValue failed - continuing"));
} else
DLOG (log_dsap, LLOG_DEBUG, ("parse_Remote__Operations__Notation_BindArgumentValue OK"));
pe_free (pe);
} else {
LLOG (log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindArgument"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_PERMANENT;
cn->cn_init_act.ia_reason = ACS_USER_NOREASON;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
return(OK);
}
/*
* Check contexts.
*/
if(oid_cmp(acs->acs_context, x500_da_ac) == 0)
{
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("DAP association: %s",paddr2str(&(acs->acs_start.ps_calling),NULLNA)));
#endif
cn->cn_dsa = 0;
if(judge_ctxlist(&(acs->acs_start.ps_ctxlist), x500_da_pcdl) == 0)
{
cn->cn_context_id = find_ctx(&(acs->acs_start.ps_ctxlist), DIR_ACCESS_AS);
/*
* Check that the bind parameter is decodable.
*/
bind_arg = &(cn->cn_init_act.ia_req);
if(decode_DAS_DirectoryBindArgument(
acs->acs_info[0], 1, NULLCP, NULLIP, bind_arg) == OK)
{
DLOG(log_dsap,LLOG_DEBUG, ("DAP Bind decoded"));
cn->cn_init_act.ia_type = ACT_TYPE_REQ;
cn->cn_init_act.ia_status = ACS_ACCEPT;
cn->cn_init_act.ia_reason = ACS_USER_NULL;
cn->cn_init_act.ia_class = ACTIVITY_DSA_WORK;
cn->cn_what = NULLDN;
dn_decode(bind_arg->dba_dn);
cn->cn_who = bind_arg->dba_dn;
}
else
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unable to parse DBA"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_TRANSIENT;
cn->cn_init_act.ia_reason = ACS_PARAMETER;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
}
}
else
{
LLOG(log_dsap,LLOG_EXCEPTIONS, ("Unacceptable Abstract Syntaxes for DAP"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_TRANSIENT;
cn->cn_init_act.ia_reason = ACS_USER_NOREASON;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
}
}
else if(oid_cmp(acs->acs_context, x500_ds_ac) == 0)
{
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("DSP association: %s",paddr2str(&(acs->acs_start.ps_calling),NULLNA)));
#endif
cn->cn_dsa = 1;
if(judge_ctxlist(&(acs->acs_start.ps_ctxlist), x500_ds_pcdl) == 0)
{
cn->cn_context_id = find_ctx(&(acs->acs_start.ps_ctxlist), DIR_SYSTEM_AS);
/*
* Check that the bind parameter is decodable.
*/
bind_arg = &(cn->cn_init_act.ia_req);
if(decode_DAS_DirectoryBindArgument(
acs->acs_info[0], 1, NULLCP, NULLIP, bind_arg) == OK)
{
DLOG(log_dsap,LLOG_DEBUG, ("DSP Bind decoded"));
cn->cn_init_act.ia_type = ACT_TYPE_REQ;
cn->cn_init_act.ia_status = ACS_ACCEPT;
cn->cn_init_act.ia_reason = ACS_USER_NULL;
cn->cn_init_act.ia_class = ACTIVITY_DSA_WORK;
cn->cn_what = NULLDN;
dn_decode(bind_arg->dba_dn);
cn->cn_who = bind_arg->dba_dn;
}
else
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unable to parse DBA"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_TRANSIENT;
cn->cn_init_act.ia_reason = ACS_PARAMETER;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
}
}
else
{
LLOG(log_dsap,LLOG_EXCEPTIONS, ("Unacceptable Abstract Syntaxes for DSP"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_TRANSIENT;
cn->cn_init_act.ia_reason = ACS_USER_NOREASON;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
}
}
else
{
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unrecognised application context"));
cn->cn_init_act.ia_type = ACT_TYPE_RESP;
cn->cn_init_act.ia_resp.init_resp_type = RESP_TYPE_REJ;
cn->cn_init_act.ia_status = ACS_TRANSIENT;
cn->cn_init_act.ia_reason = ACS_CONTEXT;
cn->cn_init_act.ia_class = ACTIVITY_NET_SEND;
}
return(OK);
}
else
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Not sure what to do when SetROPS fails"));
DLOG (log_dsap,LLOG_NOTICE,( "Calling AcUAbort directly (no conn)"));
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("failed association: %s",paddr2str(&(acs->acs_start.ps_calling),NULLNA)));
#endif
(void) AcUAbortRequest(acs->acs_sd, NULLPEP, 0, aci);
ACSFREE(acs);
return(NOTOK);
}
}
else
{
LLOG (log_dsap,LLOG_EXCEPTIONS,( "net_wait_init_request() : AcInit() NOTOK"));
acs_log(aca, "initialization fails");
ACAFREE(aca);
return(NOTOK);
}
}
/* ARGSUSED */
judge_ctxlist(req_ctxlist, ok_ctxlist)
struct PSAPctxlist * req_ctxlist;
struct PSAPctxlist * ok_ctxlist;
{
int ctxlist_notok = 0;
int i;
int j;
OID ok_asn;
OID req_asn;
DLOG (log_dsap, LLOG_TRACE, ("Checking Context List"));
for(i=0; i<req_ctxlist->pc_nctx; i++)
{
DLOG (log_dsap, LLOG_DEBUG, ("Context (%d): id=%d, %s",
i,
req_ctxlist->pc_ctx[i].pc_id,
oid2ode (req_ctxlist->pc_ctx[i].pc_asn)));
if(req_ctxlist->pc_ctx[i].pc_result == PC_ACCEPT)
req_ctxlist->pc_ctx[i].pc_result = PC_REJECTED;
}
for(j=0; j<ok_ctxlist->pc_nctx; j++)
{
ok_asn = ok_ctxlist->pc_ctx[j].pc_asn;
for(i=0; i<req_ctxlist->pc_nctx; i++)
{
if((req_asn = req_ctxlist->pc_ctx[i].pc_asn) == NULLOID) {
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Reject: asn is NULLOID"));
continue;
}
if((oid_cmp(req_asn, ok_asn) == 0))
break;
}
if(i < req_ctxlist->pc_nctx) {
req_ctxlist->pc_ctx[i].pc_result = PC_ACCEPT;
} else {
LLOG (log_dsap, LLOG_EXCEPTIONS, ("Missing Context: %s", oid2ode (ok_asn)));
ctxlist_notok = 1;
}
}
#ifdef DEBUG
for(i=0; i<req_ctxlist->pc_nctx; i++)
{
LLOG(log_dsap, LLOG_DEBUG, ("ctx[%d] id = %d, res = %d.", i,
req_ctxlist->pc_ctx[i].pc_id,
req_ctxlist->pc_ctx[i].pc_result));
if(req_ctxlist->pc_ctx[i].pc_result == PC_REJECTED)
DLOG (log_dsap, LLOG_DEBUG, ("Context Rejected: id=%d, %s",
req_ctxlist->pc_ctx[i].pc_id,
oid2ode (req_ctxlist->pc_ctx[i].pc_asn)));
}
#endif
return(ctxlist_notok);
}
int find_ctx(pcdl, ctx_oid)
struct PSAPctxlist * pcdl;
OID ctx_oid;
{
int i;
for(i=0; i<pcdl->pc_nctx; i++)
{
if(oid_cmp(ctx_oid, pcdl->pc_ctx[i].pc_asn) == 0)
break;
}
if(i < pcdl->pc_nctx)
return(pcdl->pc_ctx[i].pc_id);
LLOG(log_dsap, LLOG_EXCEPTIONS, ("Couldn't find context identifier"));
return(NOTOK);
}