📄 u_idom.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1986 - 1997, All Rights Reserved. *//* *//* MODULE NAME : u_idom.c *//* PRODUCT(S) : MMSEASE *//* *//* MODULE DESCRIPTION : *//* This module contains user defined code to service domain *//* 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 *//* -------- --- ------ ------------------------------------------- *//* 09/03/97 RKR 01 Fixed some VM_ULDL code. *//* 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_pdom.h"#include "mms_vdom.h"#include "mms_vvmd.h"#include "userdefs.h"#include "mmsop_en.h"#include "gvaldefs.h"#include "scrndefs.h"#include "fkeydefs.h"#include "gen_list.h"#include "mem_chk.h"/************************************************************************//* For debug version, use a static pointer to avoid duplication of *//* __FILE__ strings. *//************************************************************************/#ifdef DEBUG_SISCOstatic ST_CHAR *thisFileName = __FILE__;#endif/************************************************************************//************************************************************************/static ST_BOOLEAN done; /* used for input loop control */static ST_INT tot_len; /* used for total string len */static ST_INT num; /* integer used for input *//************************************************************************//* mk_uldl_fname *//************************************************************************/#ifdef VM_ULDLST_VOID mk_uldl_fname (ST_CHAR *destfname, ST_CHAR *dname) {ST_INT len; len = strlen (dname); if (len > 8) len = 8; memcpy (destfname,dname,len); destfname[len] = 0; strcat (destfname,".DOM"); }#endif/************************************************************************//************************************************************************//* DOMAIN MANAGEMENT *//************************************************************************//************************************************************************//* INITIATE DOWNLOAD SEQUENCE *//************************************************************************/#if MMS_INIT_DWN_EN & RESP_ENST_VOID u_initdown_ind (MMSREQ_IND *req_info) {INITDOWN_REQ_INFO *ptr;ST_INT i;ST_CHAR **cap_ptr;DOWNLOAD_REQ_INFO dlreq;ST_CHAR fname[32];NAMED_DOM_CTRL *dom;ST_CHAR dname[MAX_IDENT_LEN+1];ST_INT chan; ptr = (INITDOWN_REQ_INFO *) req_info->req_info_ptr; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Initiate Download Sequence "); cap_ptr = (ST_CHAR **) (ptr + 1); printf ("\n Domain Name : %s", ptr->dname); printf ("\n Number of Capabilities : %d ", ptr->num_of_capab); for (i = 0; i < ptr->num_of_capab; i++, cap_ptr++) printf ("\n %d) %s ", i+1, *cap_ptr); printf ("\n Sharable : "); if ((ptr->sharable) & 0xff) printf ("TRUE"); else printf ("FALSE"); }#ifdef VM_ULDL/* If no other UL/DL activity on this channel, open the destination *//* file for the download data *//* If a domain of this name already exists, it can't be downloaded */ strcpy (dname, ptr->dname); if (m_vmd_select->dom_list) { dom = (NAMED_DOM_CTRL *) ms_find_named_ident ((NAMED_IDENT *)m_vmd_select->dom_list, dname); } else dom = NULL; if (dom) { printf ("\n Domain already exists, delete before downloading"); mp_err_resp (req_info,3,0); } else if (uldl_ctrl_tbl[req_info->chan].uldl_state != ULDL_IDLE) { printf ("\n ULDL State Not Idle for chan %d, value = %d", req_info->chan,uldl_ctrl_tbl[req_info->chan].uldl_state); mp_err_resp (req_info,3,0); } else { /* Create the domain */ dom = ms_add_named_domain (ptr, 0xFF); if (!dom) { printf ("\n Could not add domain %s, err = %d", dname,mms_op_err); ms_perror( mms_op_err ); mp_err_resp (req_info,3,0); } else /* Open the dest file */ { dom->deletable = SD_TRUE; /* he made us add it, so he can take it out */ strcpy (uldl_ctrl_tbl[req_info->chan].dname,dname); mk_uldl_fname (fname, dname); uldl_ctrl_tbl[req_info->chan].fptr = fopen (fname,"wb"); if (!uldl_ctrl_tbl[req_info->chan].fptr) { printf ("\n Could not open download dest file '%s'", fname); mp_err_resp (req_info,3,0); } else /* All is OK, start reading download data */ { uldl_ctrl_tbl[req_info->chan].dom = dom; dom->state = DOM_LOADING; uldl_ctrl_tbl[req_info->chan].uldl_state = DL_IN_PROGRESS; chan = req_info->chan; mp_initdown_resp (req_info); /* send the response */ /* Issue the first download segment request */ strcpy (dlreq.dname,dname); mp_download (chan,&dlreq); } } }#else mp_initdown_resp (req_info); /* send the response */#endif indic_info_wait (); /* allow user to see indic info */ }#endif/************************************************************************//* DOWNLOAD SEGMENT *//************************************************************************/#if MMS_DWN_LOAD_EN & RESP_ENST_VOID u_download_ind (MMSREQ_IND *req_info) {DOWNLOAD_RESP_INFO rsp_info;DOWNLOAD_REQ_INFO *ptr;ST_UCHAR ext_buf[100]; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Download Segment "); ptr = (DOWNLOAD_REQ_INFO *) req_info->req_info_ptr; printf ("\n Domain Name : %s ", ptr->dname); } /* create a default response */ strcpy (dest_buffer, "this is load data"); rsp_info.load_data_type = LOAD_DATA_NON_CODED; rsp_info.load_data_len = strlen (dest_buffer); rsp_info.load_data = (ST_UCHAR *)dest_buffer; rsp_info.more_follows = SD_TRUE; if (mms_debug_sel & MMS_LOG_USR_IND) { if (ask ("\n Do you want to send CODED Load Data? (y,n) (default = n) : ",0)) { rsp_info.load_data_type = LOAD_DATA_CODED; get_external_asn1 (ext_buf,&(rsp_info.load_data_len)); rsp_info.load_data = ext_buf; } else { rsp_info.load_data_type = LOAD_DATA_NON_CODED; printf ("\n\n For NON-CODED DATA, enter (HEX) : "); rsp_info.load_data_len = 0; rsp_info.load_data_len = input_hex ((ST_UCHAR *)dest_buffer,200); } if (!(ask (" Enter more follows (y=TRUE, n=FALSE) (default = TRUE) : ",1))) rsp_info.more_follows = SD_FALSE; } mp_download_resp (req_info, &rsp_info); /* send the response */ indic_info (); }#endif/************************************************************************//* TERMINATE DOWNLOAD SEQUENCE *//************************************************************************/ST_VOID list_error_info (ERR_INFO *);#if MMS_TERM_DWN_EN & RESP_ENST_VOID u_termdown_ind (MMSREQ_IND *req_info) {TERMDOWN_REQ_INFO *ptr;ERR_INFO *err_ptr; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Terminate Download Sequence "); ptr = (TERMDOWN_REQ_INFO *) req_info->req_info_ptr; printf ("\n Domain Name : %s ", ptr->dname); printf ("\n Discarded :"); if (ptr->discarded) { printf ("YES"); if (mms_chan_info[req_info->chan].version) /* IS */ { err_ptr = (ERR_INFO *) (ptr+1); list_error_info (err_ptr); } } else printf ("NO"); } mp_termdown_resp (req_info); /* send the response */ indic_info_wait (); /* allow user to see indic info */ }#endif/************************************************************************//* INITIATE UPLOAD SEQUENCE *//************************************************************************/#if MMS_INIT_UPL_EN & RESP_ENST_VOID u_initupl_ind (MMSREQ_IND *req_info) {INITUPL_RESP_INFO *rsp_info;INITUPL_REQ_INFO *ptr;ST_CHAR **cap_ptr;ST_CHAR fname[32];#if !defined (VM_ULDL)ST_CHAR *cap_str;ST_CHAR temp[20];#endif ptr = (INITUPL_REQ_INFO *) req_info->req_info_ptr; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Initiate Upload Sequence "); ptr = (INITUPL_REQ_INFO *) req_info->req_info_ptr; printf ("\n Domain Name : %s ", ptr->dname); }#ifdef VM_ULDL/* If no other UL/DL activity on this channel, open the destination *//* file for the download data */ if (uldl_ctrl_tbl[req_info->chan].uldl_state != ULDL_IDLE) { printf ("\n ULDL State Not Idle for chan %d, value = %d", req_info->chan,uldl_ctrl_tbl[req_info->chan].uldl_state); mp_err_resp (req_info,3,0); } else { strcpy (uldl_ctrl_tbl[req_info->chan].dname,ptr->dname); mk_uldl_fname (fname, ptr->dname); uldl_ctrl_tbl[req_info->chan].fptr = fopen (fname,"rb"); if (!uldl_ctrl_tbl[req_info->chan].fptr) { printf ("\n Could Not Open Uload Data File %s",fname); mp_err_resp (req_info,3,0); } else /* File open OK */ { uldl_ctrl_tbl[req_info->chan].uldl_state = UL_IN_PROGRESS; rsp_info = (INITUPL_RESP_INFO *) dest_buffer; rsp_info->ulsmid = req_info->chan; /* create a default response */ cap_ptr = (ST_CHAR **) (rsp_info + 1); rsp_info->num_of_capab = 2; *(cap_ptr++) = "VM UL Cap 1"; *(cap_ptr++) = "VM UL Cap 2"; mp_initupl_resp (req_info, rsp_info); /* send the response */ } }#else /* use first 2K for resp info */ rsp_info = (INITUPL_RESP_INFO *) dest_buffer; cap_ptr = (ST_CHAR **) (rsp_info + 1); cap_str = dest_buffer + 2048; /* use 3-10K for strings */ rsp_info->ulsmid = 123; /* 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; printf ("\n\n Enter Upload State Machine Id (default = 0) : "); rsp_info->ulsmid = 0; if (intget (&num)) rsp_info->ulsmid = (ST_INT32) num; done = SD_FALSE; 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 ST_INT32, last string was lost."); } } else done = SD_TRUE; /* set exit condition */ } } mp_initupl_resp (req_info, rsp_info); /* send the response */#endif indic_info (); }#endif/************************************************************************//* UPLOAD SEGMENT *//************************************************************************/#if MMS_UP_LOAD_EN & RESP_ENST_VOID u_upload_ind (MMSREQ_IND *req_info) {UPLOAD_RESP_INFO rsp_info;UPLOAD_REQ_INFO *ptr; if (mms_debug_sel & MMS_LOG_USR_IND) { indic_info_print (req_info,"Receive Upload Segment "); ptr = (UPLOAD_REQ_INFO *) req_info->req_info_ptr; printf ("\n Upload State Machine Id : %ld", ptr->ulsmid); }#ifdef VM_ULDL if (uldl_ctrl_tbl[req_info->chan].uldl_state != UL_IN_PROGRESS) mp_err_resp (req_info,3,0); else { rsp_info.load_data_len = fread (dest_buffer,1,256, uldl_ctrl_tbl[req_info->chan].fptr); rsp_info.load_data = (ST_UCHAR *)dest_buffer; if (rsp_info.load_data_len) rsp_info.more_follows = SD_TRUE; else rsp_info.more_follows = SD_FALSE; mp_upload_resp (req_info, &rsp_info); /* send the response */ }#else /* create a default response */ strcpy (dest_buffer, "this is a load data octet string"); rsp_info.load_data_len = strlen (dest_buffer); rsp_info.load_data = (ST_UCHAR *)dest_buffer; rsp_info.more_follows = SD_TRUE; if (mms_debug_sel & MMS_LOG_USR_IND) { if (ask ("\n Do you want to send CODED Load Data (y,n) (default = n) : ",0)) { rsp_info.load_data_type = LOAD_DATA_CODED; get_external_asn1 (ext_buf,&(rsp_info.load_data_len));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -