📄 u_ivmd.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1986 - 2002, All Rights Reserved. *//* *//* MODULE NAME : u_ivmd.c *//* PRODUCT(S) : MMSEASE *//* *//* MODULE DESCRIPTION : *//* This module contains user defined code to service vmd *//* management indications. These functions are invoked from *//* the 'mms_ind_serve' function, and should perform the request *//* action. *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 07/19/02 EJV 12 Changed version to 7.10 (Tru64 & Windows rel)*//* 09/21/01 EJV 11 Changed version to 7.08 (Sun Solaris 8 rel). *//* 03/21/01 EJV 10 Changed version to 7.07 (Tru64 UNIX release).*//* 10/20/00 EJV 09 Changed version to 7.06 (DEC UNIX release). *//* 10/12/00 EJV 08 Changed version to 7.051. *//* 09/06/00 RKR 07 Changed version to 7.05. *//* 04/19/00 EJV 22 Changed version to 7.04. *//* 01/05/99 EJV 05 Changed version to 7.03 *//* 04/13/98 RKR 04 Changed ver of Identify response *//* 03/19/98 RKR 03 Added example of how to send addtnl_err_info *//* 06/22/97 RKR 02 Compile warning cleanup *//* 05/16/97 RKR 01 Uncommented USE_MV_IDENT_RESP *//* 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 "mms_pvmd.h"#include "mms_vvmd.h"#include "userdefs.h"#include "mmsop_en.h"#include "gvaldefs.h"#include "scrndefs.h"#include "fkeydefs.h"#include "mem_chk.h"#include "mms_err.h"static ST_BOOLEAN done; /* used for input loop control */static ST_INT tot_len; /* used for total string len *//************************************************************************//* For debug version, use a static pointer to avoid duplication of *//* __FILE__ strings. *//************************************************************************/#ifdef DEBUG_SISCOstatic ST_CHAR *thisFileName = __FILE__;#endif /************************************************************************//************************************************************************//* VMD SUPPORT *//************************************************************************//************************************************************************//* STATUS *//************************************************************************/#if MMS_STATUS_EN & RESP_ENST_VOID u_status_ind (MMSREQ_IND *req_info) {STATUS_REQ_INFO *ptr1;STATUS_RESP_INFO respinfo;register ST_INT i;ST_INT temp; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Status "); ptr1 = (STATUS_REQ_INFO *) req_info->req_info_ptr; printf ("\n Extended Derivation requested : "); if (ptr1->extended) printf ("TRUE"); else printf ("FALSE"); } respinfo.logical_stat = 0; respinfo.physical_stat = 0; respinfo.local_detail_pres = SD_TRUE; respinfo.local_detail_len = 21; respinfo.local_detail[0] = 0x1E; respinfo.local_detail[1] = 0x2F; respinfo.local_detail[2] = 0xA3; if (mms_debug_sel & MMS_LOG_USR_IND) { printf ("\n\n (0:State-Changes, 1:No-Changes, 2:Limited-Services, 3:All-Services)"); printf ("\n Enter Logical Status (default = State-Changes) : "); temp = 0; intget (&temp); respinfo.logical_stat = temp; printf (" (0:Operational, 1:Partially, 2:Inoperable, 3:Needs-Commissioning)"); printf ("\n Enter Physical Status (default = Operational) : "); temp = 0; intget (&temp); respinfo.physical_stat = temp; respinfo.local_detail_pres = SD_FALSE; printf (" Enter # of bits in Local Detail Parameter (0 - 128) "); printf ("\n (default = 0, which results in the parameter being omitted) : "); temp = 0; intget (&temp); if (temp > 0 && temp <= 128) { respinfo.local_detail_pres = SD_TRUE; respinfo.local_detail_len = temp; for (i = 0; i < 16; ++i) respinfo.local_detail[i] = 0; printf (" Enter Local Detail (hex bytes)"); input_hex (respinfo.local_detail,16); } } mp_status_resp (req_info,&respinfo); indic_info (); /* allow user to see indic info */ }#endif/************************************************************************//* UNSOLICITED STATUS *//************************************************************************/#if MMS_USTATUS_EN & RESP_ENST_VOID u_ustatus_ind (MMSREQ_IND *req_info) {USTATUS_REQ_INFO *ptr2; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Unsolicited Status "); ptr2 = (USTATUS_REQ_INFO *) req_info->req_info_ptr; printf ("\n Logical Status : %d",ptr2->logical_stat); printf ("\n Physical Status : %d",ptr2->physical_stat); if (ptr2->local_detail_pres) { printf ("\n %d bit(s) of Local Detail present (in HEX) : ", ptr2->local_detail_len); list_bytes (ptr2->local_detail,(ptr2->local_detail_len-1)/8+1); } else printf ("\n No Local Detail present."); } indic_info_wait (); /* allow user to see indic info */ }#endif/************************************************************************//* GET NAMELIST *//************************************************************************/#if MMS_GETNAMES_EN & RESP_EN#define USE_MV_NAMELIST_RESP /* define to use the VM namelist resp */ST_VOID u_namelist_ind (MMSREQ_IND *req_info) {NAMELIST_REQ_INFO *ptr1;#if !defined (USE_MV_NAMELIST_RESP)NAMELIST_RESP_INFO *ptr2;ST_INT size;#endif#ifndef USE_MV_NAMELIST_RESP /* Only need these for primitive resp */ST_CHAR **nptr;static ST_CHAR name0[] = "jt";static ST_CHAR name1[] = "jon";static ST_CHAR name2[] = "ralph";static ST_CHAR name3[] = "herb";static ST_CHAR name4[] = "mike";#endif if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Get Name List "); ptr1 = (NAMELIST_REQ_INFO *) req_info->req_info_ptr; if (!ptr1->cs_objclass_pres) printf ("\n MMS Object Class : %d",ptr1->obj.mms_class); else { printf ("\n CS Object Class ASN.1 : "); list_bytes (ptr1->obj.cs.cs_class,ptr1->obj.cs.len); } printf ("\n Object Scope : %d",ptr1->objscope); if (ptr1->objscope == 1) printf ("\n Domain Name : %s",ptr1->dname); if (ptr1->cont_after_pres) printf ("\n Name to Continue After : %s",ptr1->continue_after); else printf ("\n No Name to Continue After."); }#ifndef USE_MV_NAMELIST_RESP /**** primitive response only ***********/ size = sizeof (NAMELIST_RESP_INFO) + sizeof (ST_CHAR *) * 5; ptr2 = (NAMELIST_RESP_INFO *) chk_calloc (1,size); ptr2->more_follows = SD_FALSE; ptr2->num_names = 5; nptr = (ST_CHAR **) (ptr2 +1); nptr[0] = name0; nptr[1] = name1; nptr[2] = name2; nptr[3] = name3; nptr[4] = name4; mp_namelist_resp (req_info,ptr2); chk_free (ptr2); /* Free info structure now that it's no */ /* longer needed. */#else /******* use virtual machine */ mv_namelist_resp (req_info); /* let VM respond */#endif indic_info_wait (); /* allow user to see indic info */ }#endif /************************************************************************//* IDENTIFY *//************************************************************************//* These are supposed to be mutually exclusive */#define USE_MV_IDENT_RESP/*#define ERROR_RESP_TEST*//*#define REJECT_RESP_TEST*/struct cc_tbl_struct { ST_INT16 class; ST_INT16 code; };#if defined (ERROR_RESP_TEST)struct cc_tbl_struct cc_tbl[] = { 0,0, 0,1, 0,2, 0,3, 0,4, 1,0, 1,1, 1,2, 1,3, 1,4, 2,0, 2,1, 2,2, 2,3, 2,4, 2,5, 2,6, 3,0, 3,1, 3,2, 3,3, 3,4, 3,5, 4,0, 4,1, 4,2, 4,3, 4,4, 4,5, 5,0, 5,1, 5,2, 5,3, 6,0, 6,1, 7,0, 7,1, 7,2, 7,3, 7,4, 8,0, 8,1, 8,2, 8,3, 8,4, 8,5, 8,6, 8,7, 9,0, 9,1, 10,0, 10,1, 10,2, 11,0, 11,1, 11,2, 11,3, 11,4, 11,5, 11,6, 11,7 };ST_INT num_cc = sizeof (cc_tbl)/sizeof (struct cc_tbl_struct);#endif#if defined (REJECT_RESP_TEST)struct cc_tbl_struct rej_cc_tbl[] = { 1,0, 1,1, 1,2, 1,3, 1,4, 1,5, 1,6, 1,7, 1,8, 1,9,#if 0 /* Can't really use these within a Indication */ 2,0, 2,1, 2,2, 2,3, 2,4, 2,5, 2,6, 3,0, 3,1, 3,2, 3,3, 3,4, 4,0, 4,1, 4,2, 4,3, 4,4, 5,0, 5,1, 5,2, 6,0, 6,1, 7,0, 7,1, 8,0, 8,1, 8,2, 8,3, 9,0, 9,1, 10,0, 10,1, 11,0, 11,1, 11,2#endif };ST_INT rej_num_cc = sizeof (rej_cc_tbl)/sizeof (struct cc_tbl_struct);#endifST_VOID u_ident_ind (MMSREQ_IND *req_info) {#if !defined (USE_MV_IDENT_RESP)MMS_OBJ_ID *obj;IDENT_RESP_INFO *ident;ST_INT i;ST_INT num_as;ST_UINT size;#endif#if defined (ERROR_RESP_TEST)static cc_index = 0;#endif#if defined (REJECT_RESP_TEST)static rej_cc_index = 0;REJECT_RESP_INFO reject_info;#endif if (mms_debug_sel & MMS_LOG_USR_IND) indic_info_print (req_info,"Identify");#if defined (REJECT_RESP_TEST) reject_info.invoke_known = SD_TRUE; reject_info.invoke = req_info->id; reject_info.rej_class = rej_cc_tbl[rej_cc_index].class; reject_info.rej_code = rej_cc_tbl[rej_cc_index].code; mp_reject_ind (req_info, &reject_info); rej_cc_index++; if (rej_cc_index >= rej_num_cc) rej_cc_index = 0; return;#endif#if defined (ERROR_RESP_TEST) adtnl_err_info.mod_pos_pres = SD_TRUE; adtnl_err_info.mod_pos = 77; adtnl_err_info.info_pres = SD_TRUE; adtnl_err_info.code_pres = SD_TRUE; adtnl_err_info.code = 80; adtnl_err_info.descr_pres = SD_TRUE; adtnl_err_info.descr = "Not compiled to send Identify-Response right now, We are sending ServiceError using all classes and codes"; adtnl_err_info.ssi_pres = SD_TRUE; adtnl_err_info.service = 7; adtnl_err_info.ss_error_val = 4770; mp_err_resp (req_info, cc_tbl[cc_index].class, cc_tbl[cc_index].code); adtnl_err_info.mod_pos_pres = SD_FALSE; adtnl_err_info.info_pres = SD_FALSE; adtnl_err_info.code_pres = SD_FALSE; adtnl_err_info.descr_pres = SD_FALSE; cc_index++; if (cc_index >= num_cc) cc_index = 0; return;#endif#ifdef USE_MV_IDENT_RESP mv_ident_resp (req_info);#else num_as = 0; if (mms_debug_sel & MMS_LOG_USR_IND) { printf ("\n Enter # of Abstract Syntax's to send (default = 0) : "); intget (&num_as); } size = sizeof (IDENT_RESP_INFO) + (sizeof (MMS_OBJ_ID) * num_as); ident = (IDENT_RESP_INFO *) chk_calloc (1,size); strcpy (ident->vend,"Vendor_ID"); strcpy (ident->model,"Model_II"); strcpy (ident->rev,"7.10"); ident->num_as = num_as; obj = (MMS_OBJ_ID *) (ident +1); /* point to first */ for (i = 0; i < num_as; ++i, ++obj) { obj->num_comps = 4; obj->comps[0] = 1; obj->comps[1] = 2; obj->comps[2] = 3; obj->comps[3] = 4; } mp_ident_resp (req_info,ident); chk_free (ident);#endif indic_info (); /* allow user to see indic info */ }/************************************************************************//* RENAME *//************************************************************************/#if MMS_RENAME_EN & RESP_ENST_VOID u_rename_ind (MMSREQ_IND *req_info) {RENAME_REQ_INFO *req_ptr; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Rename "); req_ptr = (RENAME_REQ_INFO *) req_info->req_info_ptr; if (!req_ptr->cs_objclass_pres) printf ("\n MMS Object class : %d",req_ptr->obj.mms_class); else { printf ("\n CS Object Class ASN.1 : "); list_bytes (req_ptr->obj.cs.cs_class,req_ptr->obj.cs.len); } printf ("\n Current Name : "); print_objname (&req_ptr->cur_name); printf ("\n New Identifier : %s", req_ptr->new_ident); } mp_rename_resp (req_info); /* send the response */ indic_info_wait (); /* allow user to see indic info */ }#endif /************************************************************************//* GET CAPABILITY LIST *//************************************************************************/#if MMS_GETCL_EN & RESP_ENST_VOID u_getcl_ind (MMSREQ_IND *req_info) {GETCL_RESP_INFO *rsp_info;GETCL_REQ_INFO *ptr;ST_CHAR **cap_ptr;ST_CHAR *cap_str;ST_CHAR temp[20]; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Get Capability List "); ptr = (GETCL_REQ_INFO *) req_info->req_info_ptr; printf ("\n Continue After Capability : "); if (ptr->cont_after_pres) printf ("%s", ptr->continue_after); else printf ("Not Present"); } /* use first 2K for resp info */ rsp_info = (GETCL_RESP_INFO *) dest_buffer; cap_ptr = (ST_CHAR **) (rsp_info + 1); cap_str = dest_buffer + 2048; /* use 3-10K for strings */ rsp_info->more_follows = SD_FALSE; /* create a default response */ rsp_info->num_of_capab = 3; strcpy (cap_str, "capability 1"); *cap_ptr++ = cap_str; cap_str += strlen (cap_str) + 1; strcpy (cap_str, "capability 2"); *cap_ptr++ = cap_str; cap_str += strlen (cap_str) + 1; strcpy (cap_str, "capability 3"); *cap_ptr++ = cap_str; if (mms_debug_sel & MMS_LOG_USR_IND) { tot_len = 0; cap_ptr = (ST_CHAR **) (rsp_info + 1); /* reinitialize buffer pointers */ cap_str = dest_buffer + 2048; rsp_info->num_of_capab = 0; done = SD_FALSE; printf ("\n\n"); while (!done) { printf (" Enter Capability String : (O) "); if (strget (temp)) { if ((tot_len += strlen (temp) + 1) < 8192) { rsp_info->num_of_capab++; strcpy (cap_str, temp); *cap_ptr = cap_str; cap_ptr++; cap_str += strlen (cap_str) + 1; } else { done = SD_TRUE; wait_msg ("\n Capabilities List too long, last string was lost "); } } else done = SD_TRUE; /* set exit condition */ } if (ask (" Enter More Follows (y:TRUE, n:FALSE) (default = TRUE) : ",1)) rsp_info->more_follows = SD_TRUE; else rsp_info->more_follows = SD_FALSE; } mp_getcl_resp (req_info, rsp_info); /* send the response */ indic_info (); /* allow user to see indic info */ }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -