dsapwait.c
来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 1,224 行 · 第 1/2 页
C
1,224 行
di->di_result.dr_id = ror->ror_id; switch(ror->ror_op) { case OP_READ : { struct ds_op_res *op; success = decode_DO_ChainedReadResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_COMPARE : { struct ds_op_res *op; success = decode_DO_ChainedCompareResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_ABANDON : { struct ds_op_res *op; success = decode_DAS_AbandonResult(pe,1,NULLIP,NULLVP,&op); /* No result to copy */ free ((char *)op); } break; case OP_LIST : { struct ds_op_res *op; success = decode_DO_ChainedListResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_SEARCH : { struct ds_op_res *op; success = decode_DO_ChainedSearchResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_ADDENTRY : { struct ds_op_res *op; success = decode_DO_ChainedAddEntryResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_REMOVEENTRY : { struct ds_op_res *op; success = decode_DO_ChainedRemoveEntryResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_MODIFYENTRY : { struct ds_op_res *op; success = decode_DO_ChainedModifyEntryResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; case OP_MODIFYRDN : { struct ds_op_res *op; success = decode_DO_ChainedModifyRDNResult(pe,1,NULLIP,NULLVP,&op); di->di_result.dr_res = *op; /* struct copy */ free ((char *)op); } break; default: success = NOTOK; LLOG(log_dsap, LLOG_EXCEPTIONS, ("DspDecodeResult (%d): op id %d unknown!", ror->ror_op, sd)); DRejectRequest (sd, ROS_RRP_UNRECOG, ror->ror_id); RORFREE (ror); return (dsaplose (di, DP_RESULT, NULLCP, "Unknown operation identifier")); } if (success == NOTOK) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DspDecodeResult (%d): Unable to parse argument",sd)); DRejectRequest (sd, ROS_RRP_MISTYPED, ror->ror_id); RORFREE (ror); return (dsaplose (di, DP_RESULT, NULLCP, "Undecodable argument")); } di->di_result.dr_res.dcr_dsres.result_type = ror->ror_op; RORFREE (ror); return(success);}int QspDecodeInvoke (sd, rox, di)int sd;struct RoSAPinvoke * rox;struct DSAPindication * di;{ int success; PE pe = rox->rox_args; if (rox -> rox_nolinked == 0) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspDecodeInvoke: 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(rox->rox_op) { case OP_READ : { struct ds_op_arg *arg; success = decode_DO_ChainedReadArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_COMPARE : { struct ds_op_arg *arg; success = decode_DO_ChainedCompareArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_ABANDON : { struct ds_abandon_arg *arg; success = decode_DAS_AbandonArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg.dca_dsarg.arg_ab = *arg; /* struct copy */ free ((char *)arg); } break; case OP_LIST : { struct ds_op_arg *arg; success = decode_DO_ChainedListArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_SEARCH : { struct ds_op_arg *arg; success = decode_DO_ChainedSearchArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_ADDENTRY : { struct ds_op_arg *arg; success = decode_DO_ChainedAddEntryArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_REMOVEENTRY : { struct ds_op_arg *arg; success = decode_DO_ChainedRemoveEntryArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_MODIFYENTRY : { struct ds_op_arg *arg; success = decode_DO_ChainedModifyEntryArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_MODIFYRDN : { struct ds_op_arg *arg; success = decode_DO_ChainedModifyRDNArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg = *arg; /* struct copy */ free ((char *)arg); } break; case OP_GETEDB : { struct getedb_arg *arg; success = decode_Quipu_GetEntryDataBlockArgument(pe,1,NULLIP,NULLVP,&arg); di->di_invoke.dx_arg.dca_dsarg.arg_ge = *arg; /* struct copy */ free ((char *)arg); } break; default: LLOG(log_dsap, LLOG_EXCEPTIONS, ("QspDecodeInvoke (%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, ("QspDecodeInvoke (%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 QspDecodeResult (sd, ror, di)int sd;struct RoSAPresult * ror;struct DSAPindication * di;{ int success; PE pe = ror->ror_result; di->di_type = DI_RESULT; di->di_result.dr_id = ror->ror_id; switch(ror->ror_op) { case OP_READ : { struct ds_op_res *res; success = decode_DO_ChainedReadResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_COMPARE : { struct ds_op_res *res; success = decode_DO_ChainedCompareResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_ABANDON : { struct ds_op_res *res; success = decode_DAS_AbandonResult(pe,1,NULLIP,NULLVP,&res); /* NO result to copy !!! */ free ((char *)res); } break; case OP_LIST : { struct ds_op_res *res; success = decode_DO_ChainedListResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_SEARCH : { struct ds_op_res *res; success = decode_DO_ChainedSearchResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_ADDENTRY : { struct ds_op_res *res; success = decode_DO_ChainedAddEntryResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_REMOVEENTRY : { struct ds_op_res *res; success = decode_DO_ChainedRemoveEntryResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_MODIFYENTRY : { struct ds_op_res *res; success = decode_DO_ChainedModifyEntryResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_MODIFYRDN : { struct ds_op_res *res; success = decode_DO_ChainedModifyRDNResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res = *res; /* sturct copy */ free ((char *)res); } break; case OP_GETEDB : { struct getedb_result *res; success = decode_Quipu_GetEntryDataBlockResult(pe,1,NULLIP,NULLVP,&res); di->di_result.dr_res.dcr_dsres.res_ge = *res; /* sturct copy */ free ((char *)res); } break; default: success = NOTOK; LLOG(log_dsap, LLOG_EXCEPTIONS, ("QspDecodeResult (%d): op id %d unknown!", sd, ror->ror_op)); DRejectRequest (sd, ROS_RRP_UNRECOG, ror->ror_id); RORFREE (ror); return (dsaplose (di, DP_RESULT, NULLCP, "Unknown operation identifier")); } if (success == NOTOK) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("QspDecodeResult (%d): Unable to parse argument",sd)); DRejectRequest (sd, ROS_RRP_MISTYPED, ror->ror_id); RORFREE (ror); return (dsaplose (di, DP_RESULT, NULLCP, "Undecodable argument")); } di->di_result.dr_res.dcr_dsres.result_type = ror->ror_op; RORFREE (ror); 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 : { struct DSE_abandon_fail * de; success = decode_DAS_AbandonFailedParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_abandon_fail = *de; /* struct copy */ free ((char *)de); } break; case DSE_ATTRIBUTEERROR : { struct DSE_attribute * de; success = decode_DAS_AttributeErrorParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_attribute = *de; /* struct copy */ free ((char *)de); } break; case DSE_NAMEERROR : { struct DSE_name * de; success = decode_DAS_NameErrorParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_name = *de; /* struct copy */ free ((char *)de); } break; case DSE_REFERRAL : { struct DSE_referral * de; success = decode_DAS_ReferralParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_referral = *de; /* struct copy */ free ((char *)de); } break; case DSE_SECURITYERROR : { struct DSE_security * de; success = decode_DAS_SecurityErrorParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_security = *de; /* struct copy */ free ((char *)de); } break; case DSE_SERVICEERROR : { struct DSE_service * de; success = decode_DAS_ServiceErrorParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_service = *de; /* struct copy */ free ((char *)de); } break; case DSE_UPDATEERROR : { struct DSE_update * de; success = decode_DAS_UpdateErrorParm(pe,1,NULLIP,NULLVP,&de); err->dse_un.dse_un_update = *de; /* struct copy */ free ((char *)de); } break; case DSE_ABANDONED : success = ((pe == NULLPE) ? OK : NOTOK); break; case DSE_DSAREFERRAL : { struct DSE_referral * de; success = decode_DO_DSAReferralParm(pe, 1, NULLIP, NULLVP, &de); err->dse_un.dse_un_referral = *de; /* struct copy */ free ((char *)de); } break; default: LLOG(log_dsap, LLOG_EXCEPTIONS, ("DDecodeError (%d): op id %d unknown!",sd, roe->roe_error)); DRejectRequest (sd, ROS_REP_UNRECOG, roe->roe_id); ROEFREE (roe); return (dsaplose (di, DP_ERROR, NULLCP, "Unknown operation identifier")); } if (success == NOTOK) { LLOG (log_dsap, LLOG_EXCEPTIONS, ("DDecodeError (%d): Unable to parse argument",sd)); DRejectRequest (sd, ROS_RRP_MISTYPED, roe->roe_id); ROEFREE (roe); return (dsaplose (di, DP_ERROR, NULLCP, "Undecodable argument")); } ROEFREE (roe); return(success);}int DDecodeUnbind (sd, acf, di)int sd;struct AcSAPfinish * acf;struct DSAPindication * di;{ struct RoNOTindication rni_s; struct RoNOTindication * rni = &(rni_s); watch_dog("RoUnBindInit"); if (RoUnBindInit (sd, acf, rni) != OK) { watch_dog_reset(); return (ronot2dsaplose (di, "RoUnBindInit", rni)); } watch_dog_reset(); 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);}/* Isp == Qsp here */int IspWaitRequest (sd, secs, di)int sd;int secs;struct DSAPindication * di;{ return QspWaitRequest (sd, secs, di);}int IspDecodeInvoke (sd, rox, di)int sd;struct RoSAPinvoke * rox;struct DSAPindication * di;{ return QspDecodeInvoke (sd, rox, di);}int IspDecodeResult (sd, ror, di)int sd;struct RoSAPresult * ror;struct DSAPindication * di;{ return QspDecodeResult (sd, ror, di);}/* Watchdog stuff */IFP restart_fn = NULLIFP;static char * watch_dog_where;static watchdogfinal = FALSE;watch_dog_final(fn)SFP fn;{ watchdogfinal = TRUE; if (dsa_mode) { watch_dog_where = "FINAL"; (void) signal (SIGALRM, fn); (void) alarm (watchdog_time); }}/* ARGSUSED */static SFD watch_dog_activate (sd)int sd;{static char called = FALSE; if (!called) { if (restart_fn == NULLIFP) return; else { called = TRUE; LLOG (log_dsap, LLOG_FATAL, ("Watchdog activated in %s", watch_dog_where)); (*restart_fn)(-1); } } else LLOG (log_dsap, LLOG_FATAL, ("Repeated lower level blocking in %s", watch_dog_where)); exit(-1);}/* ARGSUSED */static SFD slack_watch_dog_activate (sd)int sd;{ LLOG (log_dsap, LLOG_EXCEPTIONS, ("Watchdog: blocking in %s, trying again...", watch_dog_where)); watch_dog (watch_dog_where);}watch_dog (where)char * where;{/* A simple timer to stop DSAs holding onto associations, due to a lower level failure.*/ if (watchdogfinal) return; if (dsa_mode) { watch_dog_where = where; (void) signal (SIGALRM, watch_dog_activate); (void) alarm (watchdog_time); }}static slack_watch_dog (where)char * where;{/* A simple timer to stop DSAs holding onto associations, due to a lower level failure. Give two chances: log a warning first time around.*/ if (watchdogfinal) return; if (dsa_mode) { watch_dog_where = where; (void) signal (SIGALRM, slack_watch_dog_activate); (void) alarm (watchdog_time); }}watch_dog_aux (where,secs)char * where;unsigned secs;{ if (watchdogfinal) return; if (dsa_mode) { watch_dog_where = where; (void) signal (SIGALRM, watch_dog_activate); (void) alarm (secs); }}watch_dog_reset (){ if (watchdogfinal) return; if (dsa_mode) { (void) signal (SIGALRM, SIG_IGN); (void) alarm ((unsigned) 0); }}watch_dog_final_reset (){ if (dsa_mode) { (void) signal (SIGALRM, SIG_IGN); (void) alarm ((unsigned) 0); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?