dsapwait.c
来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 1,224 行 · 第 1/2 页
C
1,224 行
/* dsapwait.c - DSAP: Deal with incoming activity */#ifndef lintstatic char *rcsid = "$Header: /xtel/isode/isode/dsap/net/RCS/dsapwait.c,v 9.0 1992/06/16 12:14:05 isode Rel $";#endif/* * $Header: /xtel/isode/isode/dsap/net/RCS/dsapwait.c,v 9.0 1992/06/16 12:14:05 isode Rel $ * * * $Log: dsapwait.c,v $ * Revision 9.0 1992/06/16 12:14:05 isode * Release 8.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 <signal.h>#include "logger.h"#include "quipu/util.h"#include "quipu/dsap.h"#include "../x500as/DAS-types.h"#include "../x500as/Quipu-types.h"extern LLog * log_dsap;extern unsigned watchdog_time;extern char * RoErrString();#ifdef PDU_DUMP#define DUMP_ARG "arg"#define DUMP_RES "res"#define DUMP_ERR "err"#endifstatic slack_watch_dog ();extern char dsa_mode;/* 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; case DS_CTX_INTERNET_DSP: result = IspWaitRequest (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);}static dsap_wait_err (str,roi,sd) char * str;struct RoSAPindication * roi;int sd;{int op;char * err;int cc = 0;char * data = NULLCP;char * xtype; switch (roi->roi_type) { case ROI_RESULT: op = roi->roi_result.ror_id; err = "received"; xtype = "result"; break; case ROI_ERROR: op = roi->roi_error.roe_id; err = "received"; xtype = "error"; break; case ROI_UREJECT: op = roi->roi_ureject.rou_id; err = RoErrString(roi->roi_ureject.rou_reason); xtype = "user reject"; break; case ROI_PREJECT: op = roi->roi_preject.rop_id; err = RoErrString(roi->roi_preject.rop_reason); cc = roi->roi_preject.rop_cc; data = roi->roi_preject.rop_data; xtype = "provider reject"; break; } if (cc) LLOG (log_dsap, LLOG_EXCEPTIONS, ("%s: cn=%d, op=%d %s (%s) %s", str, sd, op, xtype, err, data)); else LLOG (log_dsap, LLOG_EXCEPTIONS, ("%s: cn=%d, op=%d %s (%s)", str, sd, op, xtype, err)); switch (roi->roi_type) { case ROI_RESULT: RORFREE (&roi->roi_result); break; case ROI_ERROR: ROEFREE (&roi->roi_error); break; case ROI_UREJECT: /* no op */ break; case ROI_PREJECT: ROPFREE (&(roi->roi_preject)); break; } }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()")); watch_dog("RoWaitRequest (DAP)"); result = RoWaitRequest(sd, secs, roi); watch_dog_reset(); 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: dsap_wait_err ("DapRespWaitRequest",roi,sd); DRejectRequest (sd, ROS_RRP_UNRECOG, roi->roi_result.ror_id); return (dsaplose (di, DI_RESULT, NULLCP, "DAP responder cannot accept results")); case ROI_ERROR: dsap_wait_err ("DapRespWaitRequest",roi,sd); DRejectRequest (sd, ROS_REP_UNRECOG, roi->roi_error.roe_id); return (dsaplose (di, DI_RESULT, NULLCP, "DAP responder cannot accept errors")); case ROI_UREJECT: dsap_wait_err ("DapRespWaitRequest",roi,sd); return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject))); case ROI_PREJECT: dsap_wait_err ("DapRespWaitRequest",roi,sd); result = ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)); return result; 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()")); slack_watch_dog("RoWaitRequest (DSP)"); result = RoWaitRequest(sd, secs, roi); watch_dog_reset(); 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: dsap_wait_err ("DspWaitRequest",roi,sd); return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject))); case ROI_PREJECT: dsap_wait_err ("DspWaitRequest",roi,sd); result = ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)); return result; 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()")); slack_watch_dog("RoWaitRequest (QSP)"); result = RoWaitRequest(sd, secs, roi); watch_dog_reset(); 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: dsap_wait_err ("QspWaitRequest",roi,sd); return (ros2dsapreject(di, "ROI_UREJECT", &(roi->roi_ureject))); case ROI_PREJECT: dsap_wait_err ("QspWaitRequest",roi,sd); result = ros2dsaplose (di, "ROI_PREJECT", &(roi->roi_preject)); return result; 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); if (rox -> rox_nolinked == 0) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapDecodeInvoke: Linked operation (%d) %d",sd, rox -> rox_linkid)); DRejectRequest (sd, ROS_IP_LINKED, rox->rox_id); ROXFREE (rox); return (dsapreject (di, DP_INVOKE, -1, NULLCP, "Link op")); } di->di_type = DI_INVOKE; di->di_invoke.dx_id = rox->rox_id; switch(arg->arg_type = rox->rox_op) { case OP_READ : { struct ds_read_arg * dr; success = decode_DAS_ReadArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_rd = *dr; /* struct copy */ free ((char *) dr); } break; case OP_COMPARE : { struct ds_compare_arg * dr; success = decode_DAS_CompareArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_cm = *dr; /* struct copy */ free ((char *) dr); } break; case OP_ABANDON : { struct ds_abandon_arg * dr; success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_ab = *dr; /* struct copy */ free ((char *) dr); } break; case OP_LIST : { struct ds_list_arg * dr; success = decode_DAS_ListArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_ls = *dr; /* struct copy */ free ((char *) dr); } break; case OP_SEARCH : { struct ds_search_arg * dr; success = decode_DAS_SearchArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_sr = *dr; /* struct copy */ free ((char *) dr); } break; case OP_ADDENTRY : { struct ds_addentry_arg * dr; success = decode_DAS_AddEntryArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_ad = *dr; /* struct copy */ free ((char *) dr); } break; case OP_REMOVEENTRY : { struct ds_removeentry_arg * dr; success = decode_DAS_RemoveEntryArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_rm = *dr; /* struct copy */ free ((char *) dr); } break; case OP_MODIFYENTRY : { struct ds_modifyentry_arg * dr; success = decode_DAS_ModifyEntryArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_me = *dr; /* struct copy */ free ((char *) dr); } break; case OP_MODIFYRDN : { struct ds_modifyrdn_arg * dr; success = decode_DAS_ModifyRDNArgument(pe,1,NULLIP,NULLVP,&dr); arg->arg_mr = *dr; /* struct copy */ free ((char *) dr); } break; default: LLOG(log_dsap, LLOG_EXCEPTIONS, ("DapDecodeInvoke(%d): op id %d unknown!", sd, rox->rox_op)); DRejectRequest (sd, ROS_IP_UNRECOG, rox->rox_id); ROXFREE (rox); return (dsaplose (di, DP_INVOKE, NULLCP, "Unknown operation identifier")); } if (success == NOTOK) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DapDecodeInvoke(%d): Unable to parse argument",sd)); DRejectRequest (sd, ROS_IP_MISTYPED, rox->rox_id); ROXFREE (rox); 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; ROXFREE (rox); return(success);}int DspDecodeInvoke (sd, rox, di)int sd;struct RoSAPinvoke * rox;struct DSAPindication * di;{ int success; PE pe = rox->rox_args; di->di_type = DI_INVOKE; di->di_invoke.dx_id = rox->rox_id; if (rox -> rox_nolinked == 0) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspDecodeInvoke: Linked operation (%d) %d", sd,rox -> rox_linkid)); DRejectRequest (sd, ROS_IP_LINKED, rox->rox_id); ROXFREE (rox); return (dsapreject (di, DP_INVOKE, -1, NULLCP, "Link op")); } switch(rox->rox_op) { case OP_READ : { struct ds_op_arg * da; success = decode_DO_ChainedReadArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_COMPARE : { struct ds_op_arg * da; success = decode_DO_ChainedCompareArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_ABANDON : { struct ds_abandon_arg * ab; success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&ab); di->di_invoke.dx_arg.dca_dsarg.arg_ab = *ab; /* struct copy */ free ((char *)ab); } break; case OP_LIST : { struct ds_op_arg * da; success = decode_DO_ChainedListArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_SEARCH : { struct ds_op_arg * da; success = decode_DO_ChainedSearchArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_ADDENTRY : { struct ds_op_arg * da; success = decode_DO_ChainedAddEntryArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_REMOVEENTRY : { struct ds_op_arg * da; success = decode_DO_ChainedRemoveEntryArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_MODIFYENTRY : { struct ds_op_arg * da; success = decode_DO_ChainedModifyEntryArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; case OP_MODIFYRDN : { struct ds_op_arg * da; success = decode_DO_ChainedModifyRDNArgument(pe,1,NULLIP,NULLVP,&da); di->di_invoke.dx_arg = *da; /* struct copy */ free ((char *)da); } break; default: LLOG(log_dsap, LLOG_EXCEPTIONS, ("DspDecodeInvoke(%d): op id %d unknown!", sd, rox->rox_op)); DRejectRequest (sd, ROS_IP_UNRECOG, rox->rox_id); ROXFREE (rox); return (dsaplose (di, DP_INVOKE, NULLCP, "Unknown operation identifier")); } if (success == NOTOK) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspDecodeInvoke (%d): Unable to parse argument",sd)); DRejectRequest (sd, ROS_IP_MISTYPED, rox->rox_id); ROXFREE (rox); return (dsaplose (di, DP_INVOKE, NULLCP, "Undecodable argument")); } di->di_invoke.dx_arg.dca_dsarg.arg_type = rox->rox_op; ROXFREE (rox); return(success);}int DspDecodeResult (sd, ror, di)int sd;struct RoSAPresult * ror;struct DSAPindication * di;{ int success; PE pe = ror->ror_result; di->di_type = DI_RESULT;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?