|
|
BSD 4.3reno
/* dsapwait.c - DSAP: Deal with incoming activity */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/dsap/net/dsapwait.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/dsap/net/dsapwait.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
*
* $Log: dsapwait.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.0 90/07/26 14:46:04 mrose
* *** empty log message ***
*
*/
/*
* 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 "logger.h"
#include "quipu/util.h"
#include "quipu/dsap.h"
extern LLog * log_dsap;
#ifdef PDU_DUMP
#define DUMP_ARG "arg"
#define DUMP_RES "res"
#define DUMP_ERR "err"
#endif
/* ARGSUSED */
int DWaitRequest (ctx, sd, secs, di)
int ctx;
int sd;
int secs;
struct DSAPindication * di;
{
int result;
switch (ctx)
{
case DS_CTX_X500_DAP:
result = DapRespWaitRequest (sd, secs, di);
break;
case DS_CTX_X500_DSP:
result = DspWaitRequest (sd, secs, di);
break;
case DS_CTX_QUIPU_DSP:
result = QspWaitRequest (sd, secs, di);
break;
default:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DWaitRequest: unknown context id %d", ctx));
return (dsaplose (di, DA_APP_CONTEXT, "WAIT REQUEST"));
}
return (result);
}
int DapRespWaitRequest (sd, secs, di)
int sd;
int secs;
struct DSAPindication * di;
{
int result;
struct RoSAPindication roi_s;
struct RoSAPindication * roi = &(roi_s);
DLOG (log_dsap,LLOG_TRACE,( "DapRespWaitRequest()"));
result = RoWaitRequest(sd, secs, roi);
if (result == NOTOK)
{
if (roi->roi_preject.rop_reason == ROS_TIMER)
{
return (DONE);
}
if (ROS_FATAL (roi->roi_preject.rop_reason))
{
return (ros2dsaplose (di, "DapRespWaitRequest", &(roi->roi_preject)));
}
else
{
return (dsapreject (di, DP_ROS, -1, NULLCP, "DapRespWaitRequest: Non-fatal reject"));
}
}
switch(roi->roi_type)
{
case ROI_INVOKE:
return (DapDecodeInvoke (sd, &(roi->roi_invoke), di));
case ROI_RESULT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapRespWaitRequest: Result received"));
DRejectRequest (sd, ROS_RRP_UNRECOG, roi->roi_result.ror_id);
return (dsaplose (di, DI_RESULT, NULLCP, "DAP responder cannot accept results"));
case ROI_ERROR:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapRespWaitRequest: Error received"));
DRejectRequest (sd, ROS_REP_UNRECOG, roi->roi_error.roe_id);
return (dsaplose (di, DI_RESULT, NULLCP, "DAP responder cannot accept errors"));
case ROI_UREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapRespWaitRequest: Operation (%d) user rejected (%d)", roi->roi_ureject.rou_id, roi->roi_ureject.rou_reason));
return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject)));
case ROI_PREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapRespWaitRequest: Operation (%d) provider rejected", roi->roi_preject.rop_id));
return (ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)));
case ROI_FINISH:
/*
* Should be getting an RoBIND structure here.
* Currently this is simulated with RoUnBindInit, which
* will check that the user data in the release was used
* correctly even though no UnbindArgument is present.
* This is mapped up into D-UNBIND indication.
*/
return (DDecodeUnbind (sd, &(roi->roi_finish), di));
default:
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unknown indication type : %d", roi->roi_type));
return (dsaplose (di, DA_NO_REASON, NULLCP, NULLCP));
}
}
int DspWaitRequest (sd, secs, di)
int sd;
int secs;
struct DSAPindication * di;
{
int result;
struct RoSAPindication roi_s;
struct RoSAPindication * roi = &(roi_s);
DLOG (log_dsap,LLOG_TRACE,( "DspWaitRequest()"));
result = RoWaitRequest(sd, secs, roi);
if (result == NOTOK)
{
if (roi->roi_preject.rop_reason == ROS_TIMER)
{
return (DONE);
}
if (ROS_FATAL (roi->roi_preject.rop_reason))
{
return (ros2dsaplose (di, "DspRespWaitRequest", &(roi->roi_preject)));
}
else
{
return (dsapreject (di, DP_ROS, -1, NULLCP, "DspRespWaitRequest: Non-fatal reject"));
}
}
switch(roi->roi_type)
{
case ROI_INVOKE:
return (DspDecodeInvoke (sd, &(roi->roi_invoke), di));
case ROI_RESULT:
return (DspDecodeResult (sd, &(roi->roi_result), di));
case ROI_ERROR:
return (DDecodeError (sd, &(roi->roi_error), di));
case ROI_UREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspWaitRequest: Operation (%d) user rejected (%d)", roi->roi_ureject.rou_id, roi->roi_ureject.rou_reason));
return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject)));
case ROI_PREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspWaitRequest: Operation (%d) provider rejected", roi->roi_preject.rop_id));
return (ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)));
case ROI_FINISH:
/*
* Should be getting an RoBIND structure here.
* Currently this is simulated with RoUnBindInit, which
* will check that the user data in the release was used
* correctly even though no UnbindArgument is present.
* This is mapped up into D-UNBIND indication.
*/
return (DDecodeUnbind (sd, &(roi->roi_finish), di));
default:
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unknown indication type : %d", roi->roi_type));
return (dsaplose (di, DA_NO_REASON, NULLCP, NULLCP));
}
}
int QspWaitRequest (sd, secs, di)
int sd;
int secs;
struct DSAPindication * di;
{
int result;
struct RoSAPindication roi_s;
struct RoSAPindication * roi = &(roi_s);
DLOG (log_dsap,LLOG_TRACE,( "QspWaitRequest()"));
result = RoWaitRequest(sd, secs, roi);
if (result == NOTOK)
{
if (roi->roi_preject.rop_reason == ROS_TIMER)
{
return (DONE);
}
if (ROS_FATAL (roi->roi_preject.rop_reason))
{
return (ros2dsaplose (di, "QspRespWaitRequest", &(roi->roi_preject)));
}
else
{
return (dsapreject (di, DP_ROS, -1, NULLCP, "QspRespWaitRequest: Non-fatal reject"));
}
}
switch(roi->roi_type)
{
case ROI_INVOKE:
return (QspDecodeInvoke (sd, &(roi->roi_invoke), di));
case ROI_RESULT:
return (QspDecodeResult (sd, &(roi->roi_result), di));
case ROI_ERROR:
return (DDecodeError (sd, &(roi->roi_error), di));
case ROI_UREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspWaitRequest: Operation (%d) user rejected (%d)", roi->roi_ureject.rou_id, roi->roi_ureject.rou_reason));
return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject)));
case ROI_PREJECT:
LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspWaitRequest: Operation (%d) provider rejected", roi->roi_preject.rop_id));
return (ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)));
case ROI_FINISH:
/*
* Should be getting an RoBIND structure here.
* Currently this is simulated with RoUnBindInit, which
* will check that the user data in the release was used
* correctly even though no UnbindArgument is present.
* This is mapped up into D-UNBIND indication.
*/
return (DDecodeUnbind (sd, &(roi->roi_finish), di));
default:
LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unknown indication type : %d", roi->roi_type));
return (dsaplose (di, DA_NO_REASON, NULLCP, NULLCP));
}
}
int DapDecodeInvoke (sd, rox, di)
int sd;
struct RoSAPinvoke * rox;
struct DSAPindication * di;
{
int success;
PE pe = rox->rox_args;
struct ds_op_arg * dsarg = &(di->di_invoke.dx_arg);
struct chain_arg * charg = &(dsarg->dca_charg);
struct DSArgument * arg = &(dsarg->dca_dsarg);
di->di_type = DI_INVOKE;
di->di_invoke.dx_id = rox->rox_id;
switch(arg->arg_type = rox->rox_op)
{
case OP_READ :
success = decode_DAS_ReadArgument(pe,1,NULLIP,NULLVP,&(arg->arg_rd));
break;
case OP_COMPARE :
success = decode_DAS_CompareArgument(pe,1,NULLIP,NULLVP,&(arg->arg_cm));
break;
case OP_ABANDON :
success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&(arg->arg_ab));
break;
case OP_LIST :
success = decode_DAS_ListArgument(pe,1,NULLIP,NULLVP,&(arg->arg_ls));
break;
case OP_SEARCH :
success = decode_DAS_SearchArgument(pe,1,NULLIP,NULLVP,&(arg->arg_sr));
break;
case OP_ADDENTRY :
success = decode_DAS_AddEntryArgument(pe,1,NULLIP,NULLVP,&(arg->arg_ad));
break;
case OP_REMOVEENTRY :
success = decode_DAS_RemoveEntryArgument(pe,1,NULLIP,NULLVP,&(arg->arg_rm));
break;
case OP_MODIFYENTRY :
success = decode_DAS_ModifyEntryArgument(pe,1,NULLIP,NULLVP,&(arg->arg_me));
break;
case OP_MODIFYRDN :
success = decode_DAS_ModifyRDNArgument(pe,1,NULLIP,NULLVP,&(arg->arg_mr));
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("DapDecodeInvoke: op id %d unknown!", rox->rox_op));
DRejectRequest (sd, ROS_IP_UNRECOG, rox->rox_id);
return (dsaplose (di, DP_INVOKE, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapDecodeInvoke: Unable to parse argument"));
DRejectRequest (sd, ROS_IP_MISTYPED, rox->rox_id);
return (dsapreject (di, DP_INVOKE, -1, NULLCP, "Undecodable argument"));
}
charg->cha_originator = NULLDN;
charg->cha_target = NULLDN;
charg->cha_domaininfo = NULLPE;
charg->cha_trace = NULLTRACEINFO;
charg->cha_timelimit = NULLCP;
return(success);
}
int DspDecodeInvoke (sd, rox, di)
int sd;
struct RoSAPinvoke * rox;
struct DSAPindication * di;
{
int success;
PE pe = rox->rox_args;
struct ds_op_arg * arg = &(di->di_invoke.dx_arg);
di->di_type = DI_INVOKE;
di->di_invoke.dx_id = rox->rox_id;
switch(arg->dca_dsarg.arg_type = rox->rox_op)
{
case OP_READ :
success = decode_DO_ChainedReadArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_COMPARE :
success = decode_DO_ChainedCompareArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_ABANDON :
success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&(arg->dca_dsarg.arg_ab));
break;
case OP_LIST :
success = decode_DO_ChainedListArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_SEARCH :
success = decode_DO_ChainedSearchArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_ADDENTRY :
success = decode_DO_ChainedAddEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_REMOVEENTRY :
success = decode_DO_ChainedRemoveEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_MODIFYENTRY :
success = decode_DO_ChainedModifyEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_MODIFYRDN :
success = decode_DO_ChainedModifyRDNArgument(pe,1,NULLIP,NULLVP,arg);
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("DspDecodeInvoke: op id %d unknown!", rox->rox_op));
DRejectRequest (sd, ROS_IP_UNRECOG, rox->rox_id);
return (dsaplose (di, DP_INVOKE, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspDecodeInvoke: Unable to parse argument"));
DRejectRequest (sd, ROS_IP_MISTYPED, rox->rox_id);
return (dsaplose (di, DP_INVOKE, NULLCP, "Undecodable argument"));
}
return(success);
}
int DspDecodeResult (sd, ror, di)
int sd;
struct RoSAPresult * ror;
struct DSAPindication * di;
{
int success;
PE pe = ror->ror_result;
struct ds_op_res * res = &(di->di_result.dr_res);
di->di_type = DI_RESULT;
di->di_result.dr_id = ror->ror_id;
switch(res->dcr_dsres.result_type = ror->ror_op)
{
case OP_READ :
success = decode_DO_ChainedReadResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_COMPARE :
success = decode_DO_ChainedCompareResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_ABANDON :
success = decode_DAS_AbandonResult(pe,1,NULLIP,NULLVP,NULLCP);
break;
case OP_LIST :
success = decode_DO_ChainedListResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_SEARCH :
success = decode_DO_ChainedSearchResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_ADDENTRY :
success = decode_DO_ChainedAddEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_REMOVEENTRY :
success = decode_DO_ChainedRemoveEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_MODIFYENTRY :
success = decode_DO_ChainedModifyEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_MODIFYRDN :
success = decode_DO_ChainedModifyRDNResult(pe,1,NULLIP,NULLVP,res);
break;
default:
success = NOTOK;
LLOG(log_dsap, LLOG_EXCEPTIONS, ("DspDecodeResult: op id %d unknown!", ror->ror_op));
DRejectRequest (sd, ROS_RRP_UNRECOG, ror->ror_id);
return (dsaplose (di, DP_RESULT, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspDecodeResult: Unable to parse argument"));
DRejectRequest (sd, ROS_RRP_MISTYPED, ror->ror_id);
return (dsaplose (di, DP_RESULT, NULLCP, "Undecodable argument"));
}
return(success);
}
int QspDecodeInvoke (sd, rox, di)
int sd;
struct RoSAPinvoke * rox;
struct DSAPindication * di;
{
int success;
PE pe = rox->rox_args;
struct ds_op_arg * arg = &(di->di_invoke.dx_arg);
di->di_type = DI_INVOKE;
di->di_invoke.dx_id = rox->rox_id;
switch(arg->dca_dsarg.arg_type = rox->rox_op)
{
case OP_READ :
success = decode_DO_ChainedReadArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_COMPARE :
success = decode_DO_ChainedCompareArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_ABANDON :
success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&(arg->dca_dsarg.arg_ab));
break;
case OP_LIST :
success = decode_DO_ChainedListArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_SEARCH :
success = decode_DO_ChainedSearchArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_ADDENTRY :
success = decode_DO_ChainedAddEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_REMOVEENTRY :
success = decode_DO_ChainedRemoveEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_MODIFYENTRY :
success = decode_DO_ChainedModifyEntryArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_MODIFYRDN :
success = decode_DO_ChainedModifyRDNArgument(pe,1,NULLIP,NULLVP,arg);
break;
case OP_GETEDB :
success = decode_Quipu_GetEntryDataBlockArgument(pe,1,NULLIP,NULLVP,&(arg->dca_dsarg.arg_ge));
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("QspDecodeInvoke: op id %d unknown!", rox->rox_op));
DRejectRequest (sd, ROS_IP_UNRECOG, rox->rox_id);
return (dsaplose (di, DP_INVOKE, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspDecodeInvoke: Unable to parse argument"));
DRejectRequest (sd, ROS_IP_MISTYPED, rox->rox_id);
return (dsaplose (di, DP_INVOKE, NULLCP, "Undecodable argument"));
}
return (success);
}
int QspDecodeResult (sd, ror, di)
int sd;
struct RoSAPresult * ror;
struct DSAPindication * di;
{
int success;
PE pe = ror->ror_result;
struct ds_op_res * res = &(di->di_result.dr_res);
di->di_type = DI_RESULT;
di->di_result.dr_id = ror->ror_id;
switch(res->dcr_dsres.result_type = ror->ror_op)
{
case OP_READ :
success = decode_DO_ChainedReadResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_COMPARE :
success = decode_DO_ChainedCompareResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_ABANDON :
success = decode_DAS_AbandonResult(pe,1,NULLIP,NULLVP,NULLCP);
break;
case OP_LIST :
success = decode_DO_ChainedListResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_SEARCH :
success = decode_DO_ChainedSearchResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_ADDENTRY :
success = decode_DO_ChainedAddEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_REMOVEENTRY :
success = decode_DO_ChainedRemoveEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_MODIFYENTRY :
success = decode_DO_ChainedModifyEntryResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_MODIFYRDN :
success = decode_DO_ChainedModifyRDNResult(pe,1,NULLIP,NULLVP,res);
break;
case OP_GETEDB :
success = decode_Quipu_GetEntryDataBlockResult(pe,1,NULLIP,NULLVP,&(res->dcr_dsres.res_ge));
break;
default:
success = NOTOK;
LLOG(log_dsap, LLOG_EXCEPTIONS, ("QspDecodeResult: op id %d unknown!", ror->ror_op));
DRejectRequest (sd, ROS_RRP_UNRECOG, ror->ror_id);
return (dsaplose (di, DP_RESULT, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspDecodeResult: Unable to parse argument"));
DRejectRequest (sd, ROS_RRP_MISTYPED, ror->ror_id);
return (dsaplose (di, DP_RESULT, NULLCP, "Undecodable argument"));
}
return(success);
}
int DDecodeError (sd, roe, di)
int sd;
struct RoSAPerror * roe;
struct DSAPindication * di;
{
int success;
PE pe = roe->roe_param;
struct DSError * err = &(di->di_error.de_err);
#ifdef PDU_DUMP
pdu_dump (pe,DUMP_ERR,roe->roe_id);
#endif
di->di_type = DI_ERROR;
di->di_error.de_id = roe->roe_id;
switch(err->dse_type = roe->roe_error)
{
case DSE_ABANDON_FAILED :
success = decode_DAS_AbandonFailedParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_abandon_fail));
break;
case DSE_ATTRIBUTEERROR :
success = decode_DAS_AttributeErrorParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_attribute));
break;
case DSE_NAMEERROR :
success = decode_DAS_NameErrorParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_name));
break;
case DSE_REFERRAL :
success = decode_DAS_ReferralParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_referral));
break;
case DSE_SECURITYERROR :
success = decode_DAS_SecurityErrorParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_security));
break;
case DSE_SERVICEERROR :
success = decode_DAS_ServiceErrorParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_service));
break;
case DSE_UPDATEERROR :
success = decode_DAS_UpdateErrorParm(pe,1,NULLIP,NULLVP,&(err->dse_un.dse_un_update));
break;
case DSE_ABANDONED :
success = ((pe == NULLPE) ? OK : NOTOK);
break;
case DSE_DSAREFERRAL :
success = decode_DO_DSAReferralParm(pe, 1, NULLIP, NULLVP, &(err->dse_un.dse_un_referral));
break;
default:
LLOG(log_dsap, LLOG_EXCEPTIONS, ("DDecodeError: op id %d unknown!", roe->roe_error));
DRejectRequest (sd, ROS_REP_UNRECOG, roe->roe_id);
return (dsaplose (di, DP_ERROR, NULLCP, "Unknown operation identifier"));
}
if (success == NOTOK)
{
LLOG (log_dsap, LLOG_EXCEPTIONS, ("DDecodeError: Unable to parse argument"));
DRejectRequest (sd, ROS_RRP_MISTYPED, roe->roe_id);
return (dsaplose (di, DP_ERROR, NULLCP, "Undecodable argument"));
}
return(success);
}
int DDecodeUnbind (sd, acf, di)
int sd;
struct AcSAPfinish * acf;
struct DSAPindication * di;
{
struct RoNOTindication rni_s;
struct RoNOTindication * rni = &(rni_s);
if (RoUnBindInit (acf, rni) != OK)
return (ronot2dsaplose (di, "RoUnBindInit", rni));
if (acf->acf_ninfo != 0)
LLOG (log_dsap, LLOG_EXCEPTIONS, ("Unbind has argument present! sd=%d", sd));
di->di_type = DI_FINISH;
di->di_finish.df_reason = acf->acf_reason;
return (OK);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.