⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsavar.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//*   (c) Copyright Systems Integration Specialists Company, Inc.,	*//*      	  1986 - 2002, All Rights Reserved.		        *//*									*//* MODULE NAME : mmsavar.c						*//* PRODUCT(S)  : MMSEASE						*//*									*//* MODULE DESCRIPTION : 						*//*	This module contains functions to initiate the MMS variable	*//*	access services.  These functions are called from the		*//*	mainloop (check_key).						*//*									*//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE :				*//*									*//* MODIFICATION LOG :							*//*  Date     Who   Rev			Comments			*//* --------  ---  ------   -------------------------------------------	*//* 07/26/02  EJV     15    MMS_UTC_TIME: chg qflags value.		*//* 07/03/02  EJV     14    MMS_UTC_TIME: chg name usec to fraction.	*//* 12/20/01  EJV     13    Changed to use ASN1R				*//* 11/14/01  EJV     12    Added support for new MMS type UtcTime:	*//*			   ms_print_runtime: added case for RT_UTC_TIME	*//*			   arb_write_ctrl[]: added getWrUtc		*//* 12/17/98  DSF     11    Corrected handling of variable length of	*//*			   octet and bitstrings				*//* 05/27/98  IKE     10    Removed data conversion warnings when 	*//* 			   compiling in DOS platform			*//* 05/19/98  EJV     09    Corrected getWrInt16, getWrUInt16, getWrInt32*//*			   and getWrUInt32 for AIX and DigitalUnix.	*//* 01/28/98  EJV     08    Changed 1 arg to ST_INT32 getWrBt4, getWrBt6	*//*			   and made appropriate adj in functions.	*//* 10/20/97  DSF     07    No more M_USE_BSEARCH			*//* 09/11/97  MDE     06    MMS ARB user funs now return ST_RET		*//* 09/10/97  MDE     05    Changed BTOD print for new M_ARB_DATA_CTRL	*//* 09/05/97  MDE     04    Btod value get, typeless read changes	*//* 07/16/97  RKR     04    64 bit integer support			*//* 06/25/97  RKR     03    worked on get_alt_acc 			*//* 06/21/97  RKR     02    worked on get_arb_write_data			*//* 06/03/97  RKR     01    Added BSEARCH support for vars and varlists	*//* 04/15/97  DSF   7.00    MMSEASE 7.0 release. See MODL70.DOC for	*//*			   history.					*//************************************************************************/#include "glbtypes.h"#include "sysincs.h"#include "mms_usr.h"#include "userdefs.h"#include "fkeydefs.h"#include "mmsop_en.h"#include "gvaldefs.h"#include "scrndefs.h"#include "asn1defs.h"#include "mms_pvar.h"#include "mms_vvar.h"#include "mem_chk.h"/************************************************************************//* Variable Access PDU size estimation information			*//* #define EST_VA_SIZE */ST_VOID est_read_pdu_size (	ST_INT num_var,			READ_REQ_INFO *priminfo,		       	MV_READ_REQ_INFO *vminfo);ST_VOID est_write_pdu_size (ST_INT num_var,			VAR_ACC_SPEC *va_spec,			MV_WRITE_REQ_INFO *vm_data);ST_VOID est_info_pdu_size (	ST_INT num_var,			VAR_ACC_SPEC *va_spec,			MV_INFO_REQ_INFO *vm_data);ST_VOID  est_done (ST_LONG req_size, ST_LONG resp_size);/************************************************************************//* maximum size of hex data input string					*/static ST_INT max_input = 80;/************************************************************************//* For debug version, use a static pointer to avoid duplication of 	*//* __FILE__ strings.							*//************************************************************************/#ifdef DEBUG_SISCOstatic ST_CHAR *thisFileName = __FILE__;#endif/************************************************************************//* Functions used internally for user interface 			*//************************************************************************/ST_VOID do_read (ST_VOID)  {#if MMS_MV_READ_EN & REQ_ENST_INT chan;ST_INT num_var;READ_REQ_INFO *info;MV_READ_REQ_INFO *varlist;MV_READ_REQ_INFO *varptr;NAMED_TYPE *tptr;ST_CHAR  *dest;ST_INT i;OBJECT_NAME   object;  if (!get_chan (&chan))    {    (*menu_set_fun)();    return;    }/* use first 2K of user 'dest_buffer' for the VM req struct's, next 2K 	*//* for PRIM req struct, rest for for destination for response data.	*//* Use source_buf for misc. strings, etc..				*/  varlist = (MV_READ_REQ_INFO *) dest_buffer;  info	  = (READ_REQ_INFO *) ((ST_CHAR *)varlist+2048);  dest	  = (ST_CHAR *)info + 2048;/* zero out the destination area, so alternate access shows up better	*/  memset (dest, 0, 1000);  nxt_buf = source_buf;			/* for various 'get_xxx' fun's	*/  num_var = 0;  			/* default			*/  if (ask ("\n Do you want Variable Access Specification with Result (y,n) (default = n) : ", SD_FALSE))    info->spec_in_result = SD_TRUE;  else    info->spec_in_result = SD_FALSE;  printf ("\n");  if (!get_vaspec (&info->va_spec, SD_FALSE))    {    (*menu_set_fun)();    return;    }  printf ("\n Enter Response Interpretation information : ");  if (info->va_spec.var_acc_tag == VAR_ACC_VARLIST)    num_var = info->va_spec.num_of_variables;  else          /* this is a NameList and we think we may want 1 var    */    num_var = 1;  printf ("\n Enter number of variables expected in response (default = %d) : ",           num_var);  intget (&num_var);  varptr  = varlist;			/* working VM struct pointer	*/  for (i = 0; i < num_var; ++i)    {			/* get name, type & dest for each variable	*/    varptr->i.alt_acc_pres = SD_FALSE;  /* no alt access		*/    varptr->i.type = NULL;    varptr->i.data_ptr = NULL;    printf ("\n Select Named Type %d : ", i+1);    if (get_objname (&object))      {      if (tptr = ms_find_named_type_obj (&object,chan))        {        if (ask ("\n Do you want to use Alternate Access (y,n) (default = n) : ",SD_FALSE))          {          if (get_alt_acc (&varptr->i.alt_acc) == SD_SUCCESS)            varptr->i.alt_acc_pres = SD_TRUE;            }        varptr->i.type = tptr;		/* save type			*/        varptr->i.data_ptr = dest;	/* destination for resp data	*/        dest += tptr->blocked_len;	/* get next destination pos.	*/        varptr++;        }      else        {        if (ask (" Type Not Found. Do you want to Re-Enter (y,n) (default = y) :",SD_TRUE))          i--;                  else          {          (*menu_set_fun)();	  return;          }        }      }    else      {      if (ask (" Do you want to try again (y,n) (default = y) : ",SD_TRUE))        i--;                else if (ask (" Issue typeless read? (y,n) (default = n) : ",SD_FALSE))        varptr++;      else        {        (*menu_set_fun)();        return;        }      }    }/* Did we somehow try to read 0 variables                               */  if (num_var == 0)    {    (*menu_set_fun)();    return;    }#ifdef EST_VA_SIZE   if (ask ("\n Do you want to estimate the Size of PDU's (y,n) (default = n) :", SD_FALSE))    est_read_pdu_size (num_var,info,varlist);#endif	  			  if (!mv_read_variables (chan,num_var,info,varlist))    print_req_error ();  if (num_reps) 			/* if this an auto repeat -	*/    {    if (start_cont ())			/* wait for 1st to complete	*/      return;    num_outstanding = 1;    while (rep_count < num_reps)	/* if enough done -		*/      {      if (!mv_read_variables (chan,num_var,info,varlist))        break;      num_outstanding++;      if (cont_serve ()) 		/* if user hit a key		*/        return;      }    cont_done ();			/* display results		*/    }  (*menu_set_fun)();#endif  }/************************************************************************//************************************************************************//* send write								*//************************************************************************/ST_VOID do_write (ST_VOID)			/* GENERAL VM write		*/  {#if MMS_MV_WRITE_EN & REQ_EN ST_INT chan;ST_INT num_var;MV_WRITE_REQ_INFO *vm_data;MV_WRITE_REQ_INFO *vm_ptr;VAR_ACC_SPEC *va_spec;OBJECT_NAME obj;NAMED_TYPE *tptr;ST_CHAR  *source;ST_INT i;  if (!get_chan (&chan))    {    (*menu_set_fun)();    return;    }/* use 'dest_buffer' for the VM write request structure and the VA spec	*//* and use source_buf for write data					*/  vm_data = (MV_WRITE_REQ_INFO *) dest_buffer;  vm_ptr = vm_data;  va_spec = (VAR_ACC_SPEC *)(dest_buffer + 2000);  nxt_buf = source_buf;			/* for various 'get_xxx' fun's	*//* first have the user enter the variable access spec.			*/  printf ("\n");  if (!get_vaspec (va_spec, SD_FALSE))    {    (*menu_set_fun)();    return;    }/* now get the type and values for the data to be written		*/  printf ("\n Enter Write Data :");  if (va_spec->var_acc_tag == VAR_ACC_VARLIST)    num_var = va_spec->num_of_variables;  else          /* this is a NameList and we think we may write 1 var   */    num_var = 1;  printf ("\n Enter number of Write Data to send (default = %d) : ",           num_var);  intget (&num_var);  source = nxt_buf;                     /* pick up source again         */  for (i = 0; i < num_var; ++i,++vm_ptr)    {    printf ("\n Select Named Type %d : ", i+1);    if (get_objname (&obj))       {      if (tptr = ms_find_named_type_obj (&obj,chan))        {				/* valid type, get write data	*/        if (get_write_data (&obj,source,chan) == SD_SUCCESS)          {          vm_ptr->data_ptr = source;          vm_ptr->type = tptr;          if (ask ("\n Do you want to use Alternate Access (y,n) (default = n) : ",SD_FALSE))            {            if (get_alt_acc (&vm_ptr->alt_acc) == SD_SUCCESS)              vm_ptr->alt_acc_pres = SD_TRUE;              else              vm_ptr->alt_acc_pres = SD_FALSE;  /* no alt access		*/            }          else            vm_ptr->alt_acc_pres = SD_FALSE; /* no alt access		*/            source += tptr->blocked_len;          }        else          {          wait_msg ("\n Must enter data for each variable. Sorry!");          (*menu_set_fun)();          return;          }        }      else        {        wait_msg ("\n Undefined type. Sorry!");        (*menu_set_fun)();        return;        }      }    else      {      if (ask (" Do you want to try again (y,n) (default = y) : ",SD_TRUE))        i--;                else        {        (*menu_set_fun)();        return;        }      }    }/* Did we somehow try to read 0 variables                               */  if (num_var == 0)    {    (*menu_set_fun)();    return;    }#ifdef EST_VA_SIZE   if (ask ("\n Do you want to estimate size of PDU's (y,n) (default = n) : ", SD_FALSE))    est_write_pdu_size (num_var,va_spec,vm_data);#endif/* have required info from user, send the request			*/  if (!mv_write_variables (chan,num_var,va_spec,vm_data))    print_req_error ();  else    {    if (num_reps)			/* if this an auto repeat -	*/      {      if (start_cont ())		/* wait for 1st to complete	*/        return;      num_outstanding = 1;		/* we already sent 1		*/      while (rep_count < num_reps)	/* if enough done -		*/        {        if (!mv_write_variables (chan,num_var,va_spec,vm_data))          break;        num_outstanding++;        if (cont_serve ())		/* if user hit a key		*/          return;        }      cont_done ();			/* display results		*/      }    }  (*menu_set_fun)();#endif  }/************************************************************************//************************************************************************//* send information report						*//************************************************************************/ST_VOID do_info (ST_VOID)  {#if MMS_INFO_EN & REQ_ENST_INT chan;MV_INFO_REQ_INFO *vm_data;MV_INFO_REQ_INFO *vm_ptr;VAR_ACC_SPEC *va_spec;OBJECT_NAME obj;ST_CHAR  *source;ST_INT num_var;NAMED_TYPE *tptr;ST_INT i;  if (!get_chan (&chan))    {    (*menu_set_fun)();    return;    }/* use 'dest_buffer' for the VM info request structure and the VA spec,	*//* and use source_buf for info data					*/  vm_data = (MV_INFO_REQ_INFO *) dest_buffer;  vm_ptr = vm_data;  va_spec = (VAR_ACC_SPEC *) (dest_buffer + 2000);  nxt_buf = source_buf+500;/* first have the user enter the variable access spec.			*/  printf ("\n");  if (!get_vaspec (va_spec, SD_FALSE))    {    (*menu_set_fun)();    return;    }if (va_spec->var_acc_tag == VAR_ACC_NAMEDLIST)  {  if (mms_op_err = mv_info_nvlist (chan, &va_spec->vl_name))    print_req_error ();  }else  {/* now get the type and values for the data to be written		*/  printf ("\n Enter Information Report Data :");  if (va_spec->var_acc_tag == VAR_ACC_VARLIST)    num_var = va_spec->num_of_variables;  else          /* this is a NameList and we think we may write 1 var   */    num_var = 1;  printf ("\n Enter number of Write Data to send (default = %d) : ",           num_var);  intget (&num_var);  source  = nxt_buf;  for (i = 0; i < num_var; ++i)    {    printf ("\n Select Named Type %d : ", i+1);    if (get_objname (&obj))       {      if (tptr = ms_find_named_type_obj (&obj,chan))        {				/* valid type, get write data	*/        if (get_write_data (&obj,source,chan) == SD_SUCCESS)          {          vm_ptr->data_ptr = source;          vm_ptr->type = tptr;          if (ask ("\n Do you want to use Alternate Access (y,n) (default = n) : ",SD_FALSE))            {            if (get_alt_acc (&vm_ptr->alt_acc) == SD_SUCCESS)              vm_ptr->alt_acc_pres = SD_TRUE;              else              vm_ptr->alt_acc_pres = SD_FALSE;  /* no alt access		*/            }          else            vm_ptr->alt_acc_pres = SD_FALSE; /* no alt access		*/          source += tptr->blocked_len;          vm_ptr++;          }        else          {          wait_msg ("\n Must enter data for each variable. Sorry!");          (*menu_set_fun)();          return;          }        }      else        {        if (ask (" Type Not Found. Do you want to Re-Enter (y,n) (default = y) :",SD_TRUE))          i--;                  else          {          (*menu_set_fun)();	  return;          }        }      }    else      {      if (ask (" Do you want to try again (y,n) (default = y) : ",SD_TRUE))        i--;                else        {        (*menu_set_fun)();        return;        }      }    }#ifdef EST_VA_SIZE   if (ask ("\n Do you want to estimate size of PDU's (y,n) (default = n) : ", SD_FALSE))    est_info_pdu_size (num_var,va_spec,vm_data);#endif  if  (num_var > 0)    {    if (mms_op_err = mv_info_report (chan,va_spec,num_var,vm_data))      print_req_error ();    }  }	/* end "!VAR_ACC_NAMEDLIST"	*/  (*menu_set_fun)();#endif  }/************************************************************************//************************************************************************//*			do_getvar					*//* create and send a get variable access attributes request.		*//************************************************************************/ST_VOID do_getvar (ST_VOID)  {#if MMS_GETVAR_EN & REQ_ENGETVAR_REQ_INFO info;ST_INT chan;ST_INT num;ST_BOOLEAN data_entered;  if (!get_chan (&chan))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -