自主协议库编译通过

This commit is contained in:
lnk
2026-06-15 15:48:16 +08:00
parent d3579a2aa7
commit 7205cb5cb9
621 changed files with 224958 additions and 48 deletions

160
mmslib/mvlu/c_concl.c Normal file
View File

@@ -0,0 +1,160 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : c_concl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_conclude */
/* _mvl_process_concl_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 01/30/06 GLB 16 Integrated porting changes for VMS */
/* 10/29/02 JRB 15 _mvla_send_concl: on err, set done & result in*/
/* req_pend. Helps if user doesn't chk return. */
/* 04/25/02 MDE 14 Added MLOG */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 03/07/01 JRB 12 Del LOCK on sync functs: caused deadlocks. */
/* 04/14/00 JRB 11 Lint cleanup. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Don't care numpend_req. Conclude is special. */
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 11/22/99 NAV 08 Add maxpend_req support */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 12/08/98 MDE 06 Cleanup on request control handling */
/* 11/17/98 MDE 05 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 11/16/98 MDE 03 Added mvl_concl, mvla_concl, call release */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mvl_defs.h"
#include "mvl_log.h"
#include "mloguser.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* mvl_conclude */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_conclude (MVL_NET_INFO *net_info)
{
MVL_REQ_PEND *req_out;
MVL_LOG_ERR0 ("Warning: Using obsolete function 'mvl_conclude', please use 'mvl_concl'");
return (mvl_concl (net_info, &req_out));
}
#endif
/************************************************************************/
/* mvl_concl */
/************************************************************************/
ST_RET mvl_concl (MVL_NET_INFO *net_info, MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_concl (net_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
/************************************************************************/
/* mvla_concl */
/************************************************************************/
ST_RET mvla_concl (MVL_NET_INFO *net_info, MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req;
*req_out = req = _mvl_get_req_ctrl (net_info, MMSOP_CONCLUDE);
if (!req)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_concl (net_info, req);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_concl */
/************************************************************************/
ST_RET _mvla_send_concl (MVL_NET_INFO *net_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
ST_UCHAR _conclude_pdu[2];
/* "\x8B\x00" == "\213\000", for old compilers ... */
_conclude_pdu[0]= (ST_UCHAR) 0x8b;
_conclude_pdu[1]= (ST_UCHAR) 0x00;
/* We can log here if so desired */
if ((mms_debug_sel & MMS_LOG_REQ) && ml_log_req_info_fun != NULL)
(*ml_log_req_info_fun) (0, MMSOP_CONCLUDE, NULL);
rc = _mvl_send_msg (_conclude_pdu, 2, net_info);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Conclude : _mvl_send_msg failed, rc = %x", rc);
req_pend->done = SD_TRUE; /* Helps if user doesn't chk return */
req_pend->result = rc;
}
/* invoke_id not sent on conclude, but set to -1 just to match up resp.*/
req_pend->invoke_id = (ST_UINT32) -1;
return (rc);
}
/************************************************************************/
/* _mvl_process_concl_conf */
/************************************************************************/
ST_VOID _mvl_process_concl_conf (MVL_REQ_PEND *req_pend)
{
_mvl_release (req_pend);
}

134
mmslib/mvlu/c_defvl.c Normal file
View File

@@ -0,0 +1,134 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_defvl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_defvlist */
/* mvla_defvlist */
/* _mvl_process_defvlist_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_defvlist */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_defvlist (
MVL_NET_INFO *net_info,
DEFVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_defvlist (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_defvlist */
/************************************************************************/
ST_RET mvla_defvlist (
MVL_NET_INFO *net_info,
DEFVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_DEF_VLIST);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_defvlist (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvl_send_defvlist */
/************************************************************************/
ST_RET _mvla_send_defvlist (MVL_NET_INFO *net_info,
DEFVLIST_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a defvlist request */
rc = mpl_defvlist (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_defvlist_conf */
/************************************************************************/
ST_VOID _mvl_process_defvlist_conf (MVL_REQ_PEND *req_pend)
{
/* Nothing to do. Common code takes care of setting req_pend->result. */
}

134
mmslib/mvlu/c_delvl.c Normal file
View File

@@ -0,0 +1,134 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_delvl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_delvlist */
/* mvla_delvlist */
/* _mvl_process_delvlist_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 11/01/01 JRB 12 Del LOCK on sync functs: caused deadlocks. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_delvlist */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_delvlist (
MVL_NET_INFO *net_info,
DELVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_delvlist (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_delvlist */
/************************************************************************/
ST_RET mvla_delvlist (
MVL_NET_INFO *net_info,
DELVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_DEL_VLIST);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_delvlist (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_delvlist */
/************************************************************************/
ST_RET _mvla_send_delvlist (MVL_NET_INFO *net_info,
DELVLIST_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a delvlist request */
rc = mpl_delvlist (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_delvlist_conf */
/************************************************************************/
ST_VOID _mvl_process_delvlist_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.delvlist.resp_info =
(DELVLIST_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

133
mmslib/mvlu/c_fclose.c Normal file
View File

@@ -0,0 +1,133 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_fclose.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_fclose */
/* mvla_fclose */
/* _mvl_process_fclose_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_fclose */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_fclose (
MVL_NET_INFO *net_info,
FCLOSE_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_fclose (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_fclose */
/************************************************************************/
ST_RET mvla_fclose (
MVL_NET_INFO *net_info,
FCLOSE_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_CLOSE);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_fclose (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_fclose */
/************************************************************************/
ST_RET _mvla_send_fclose (MVL_NET_INFO *net_info,
FCLOSE_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a fclose request */
rc = mpl_fclose (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_fclose_conf */
/************************************************************************/
ST_VOID _mvl_process_fclose_conf (MVL_REQ_PEND *req_pend)
{
/* Nothing to do. Common code takes care of setting req_pend->result. */
}

150
mmslib/mvlu/c_fdel.c Normal file
View File

@@ -0,0 +1,150 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_fdel.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_fdelete */
/* mvla_fdelete */
/* _mvl_process_fdelete_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_fdelete */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_fdelete (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_fdelete (net_info, filename, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_fdelete */
/************************************************************************/
ST_RET mvla_fdelete (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_DELETE);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_fdelete (net_info, filename, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_fdelete */
/************************************************************************/
/* Allocate FDELETE_REQ_INFO with "one" FILE_NAME entry after it. */
/* If need more than one FILE_NAME, must use "mpl_fdelete". */
#define FDELETE_REQ_INFO_SIZE (sizeof (FDELETE_REQ_INFO) + (1 * sizeof (FILE_NAME)))
ST_RET _mvla_send_fdelete (MVL_NET_INFO *net_info,
ST_CHAR *filename,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
FDELETE_REQ_INFO *req_info;
FILE_NAME *fname_idx;
ST_CHAR fdelete_req_info[FDELETE_REQ_INFO_SIZE];
/* Allocate FDELETE_REQ_INFO with "one" FILE_NAME entry after it. */
/* If need more than one FILE_NAME, must use "mpl_fdelete". */
req_info = (FDELETE_REQ_INFO *) fdelete_req_info;
req_info->num_of_fname = 1;
/* Point to the FILE_NAME structure and fill it in. */
fname_idx = (FILE_NAME *)(req_info + 1);
fname_idx->fn_len = strlen (filename);
fname_idx->fname = filename;
/* Build a fdelete request */
rc = mpl_fdelete (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_fdelete_conf */
/************************************************************************/
ST_VOID _mvl_process_fdelete_conf (MVL_REQ_PEND *req_pend)
{
/* Nothing to do. Common code takes care of setting req_pend->result. */
}

231
mmslib/mvlu/c_fdir.c Normal file
View File

@@ -0,0 +1,231 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_fdir.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_fdir */
/* mvla_fdir */
/* _mvl_process_fdir_conf */
/* */
/* WARNING: these functions were designed to be as easy as possible to */
/* use for MOST applications. They will work for any system where */
/* filenames can be represented as a single NULL terminated string. */
/* They do NOT support filenames with multiple parts or which contain */
/* If these features are needed, then the more complicated mpl_fdir */
/* must be used directly. */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_fdir */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_fdir (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_CHAR *ca_filename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_fdir (net_info, filename, ca_filename, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_fdir */
/************************************************************************/
ST_RET mvla_fdir (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_CHAR *ca_filename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_DIR);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_pend->u.fdir.resp_info = NULL; /* Confirm funct must allocate */
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_fdir (net_info, filename, ca_filename, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_fdir */
/************************************************************************/
/* Allocate FDIR_REQ_INFO with "one" FILE_NAME entry after it. */
/* If need more than one FILE_NAME, must use "mpl_fdir". */
#define FDIR_REQ_INFO_SIZE (sizeof (FDIR_REQ_INFO) + (2 * sizeof (FILE_NAME)))
ST_RET _mvla_send_fdir (MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_CHAR *ca_filename,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
FDIR_REQ_INFO *req_info;
FILE_NAME *fname_idx;
ST_CHAR fdir_req_info[FDIR_REQ_INFO_SIZE];
req_info = (FDIR_REQ_INFO *) fdir_req_info;
if (filename)
{
req_info->filespec_pres = SD_TRUE;
req_info->num_of_fs_fname = 1;
}
else
{
req_info->filespec_pres = SD_FALSE;
req_info->num_of_fs_fname = 0;
}
if (ca_filename)
{
req_info->cont_after_pres = SD_TRUE;
req_info->num_of_ca_fname = 1;
}
else
{
req_info->cont_after_pres = SD_FALSE;
req_info->num_of_ca_fname = 0;
}
/* Point to first FILE_NAME structure. */
fname_idx = (FILE_NAME *)(req_info + 1);
if (filename)
{
fname_idx->fn_len = strlen (filename);
fname_idx->fname = filename;
fname_idx++; /* point to next */
}
if (ca_filename)
{
fname_idx->fn_len = strlen (ca_filename);
fname_idx->fname = ca_filename;
fname_idx++; /* point to next */
}
/* Build a fdir request */
rc = mpl_fdir (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_fdir_conf */
/************************************************************************/
ST_VOID _mvl_process_fdir_conf (MVL_REQ_PEND *req_pend)
{
FDIR_DIR_ENT *dir_ent;
MVL_DIR_ENT *mvl_dir_ent;
MVL_FDIR_RESP_INFO *mvl_resp_info;
FDIR_RESP_INFO *resp_info;
ST_INT j;
ST_INT info_size;
resp_info = (FDIR_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
/* Allocate and fill in "req_pend->u.fdir.resp_info". */
/* CRITICAL: mvl_free_req_ctrl () must free it. */
info_size = sizeof (MVL_FDIR_RESP_INFO) +
resp_info->num_dir_ent * sizeof(MVL_DIR_ENT);
req_pend->u.fdir.resp_info =
(MVL_FDIR_RESP_INFO *) M_MALLOC (MSMEM_GEN, info_size);
mvl_resp_info = req_pend->u.fdir.resp_info; /* Local ptr to it. */
mvl_resp_info->num_dir_ent = resp_info->num_dir_ent;
mvl_resp_info->more_follows = resp_info->more_follows;
mvl_resp_info->dir_ent = (MVL_DIR_ENT *) (mvl_resp_info + 1);
if (resp_info->num_dir_ent)
{
dir_ent = (FDIR_DIR_ENT *)(resp_info + 1); /* point to first entry */
mvl_dir_ent = mvl_resp_info->dir_ent; /* point to first entry */
for (j = 0; j < resp_info->num_dir_ent; j++, mvl_dir_ent++)
{
mvl_dir_ent->fsize = dir_ent->fsize;
mvl_dir_ent->mtimpres = dir_ent->mtimpres;
mvl_dir_ent->mtime = dir_ent->mtime;
if (_mvl_concat_filename (mvl_dir_ent->filename, dir_ent->num_of_fname,
(FILE_NAME *)(dir_ent + 1), sizeof (mvl_dir_ent->filename)))
{
MVL_LOG_ERR0 ("Error: FileDirectory.Conf: can't process filename");
req_pend->result = SD_FAILURE;
return;
}
/* Point to next dir entry. */
dir_ent = (FDIR_DIR_ENT *) ((ST_CHAR *)dir_ent + sizeof (FDIR_DIR_ENT)
+ dir_ent->num_of_fname * sizeof (FILE_NAME));
}
}
}

460
mmslib/mvlu/c_fget.c Normal file
View File

@@ -0,0 +1,460 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2000 - 2000, All Rights Reserved */
/* */
/* MODULE NAME : c_fget.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvla_fget */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/03/08 JRB 09 Add static on "u_f*" functions. */
/* Chk fget_cnf_ptr before using. */
/* 11/12/07 MDE 08 Use _mvl_getpath for temp file path */
/* 01/30/06 GLB 07 Integrated porting changes for VMS */
/* 03/01/04 MDE 06 Free request for fget (file open) error */
/* 06/17/03 MDE 05 Now use _mvl_tmpnam */
/* 02/17/03 JRB 04 Del unused includes. */
/* 07/18/02 JRB 03 Del unused var. */
/* 03/25/02 MDE 02 Moved error/reject elements outside union */
/* 06/22/00 GLB 01 Created to do an asynchronous File Get. */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
static MVL_REQ_PEND *send_file_open (MVL_NET_INFO *NetInfo, ST_CHAR *src);
static MVL_REQ_PEND *send_file_read (MVL_NET_INFO *NetInfo,
MVL_FGET_REQ_INFO *u_file_info);
static MVL_REQ_PEND *send_file_close (MVL_NET_INFO *NetInfo,
MVL_FGET_REQ_INFO *u_file_info);
static ST_VOID u_fopen_done (MVL_REQ_PEND *req);
static ST_VOID u_fread_done (MVL_REQ_PEND *req);
static ST_VOID u_fclose_done (MVL_REQ_PEND *req);
/************************************************************************/
/* mvla_fget */
/* Perform an asynchronous file copy */
/************************************************************************/
ST_RET mvla_fget (
MVL_NET_INFO *net_info,
ST_CHAR *srcfilename,
ST_CHAR *destfilename,
MVL_FGET_REQ_INFO *fget_req_info)
{
MVL_REQ_PEND *req_out;
ST_CHAR tmpfile_path[MVL_MAX_TMPFILE_PATH];
/* save destination name for rename */
if (strlen (destfilename) <= MAX_FILE_NAME)
{
strcpy (fget_req_info->destfilename, destfilename);
}
else
{
MVL_LOG_NERR0 ("ERROR: mvla_fget: destination filename save failed ");
return (SD_FAILURE);
}
/* save source name for returning copy status */
if (strlen (srcfilename) <= MAX_FILE_NAME)
{
strcpy (fget_req_info->srcfilename, srcfilename);
}
else
{
MVL_LOG_NERR0 ("ERROR: mvla_fget: source filename save failed ");
return (SD_FAILURE);
}
/* Create a temporary file name to copy into. This prevents partially */
/* transferred files from hanging around and being accidently used */
/* Open the created temporary file. Send a file open request for the */
/* source file specified. */
_mvl_getpath (destfilename, tmpfile_path);
if (_mvl_tmpnam (fget_req_info->tempfilename, tmpfile_path) != SD_SUCCESS ||
(fget_req_info->fp = fopen(fget_req_info->tempfilename, "wb")) == NULL ||
(req_out = send_file_open (net_info, srcfilename)) == NULL)
{
if (fget_req_info->fp )
{
MVL_LOG_NERR1 ("ERROR: mvla_fget: fopen (%s) failed ",
fget_req_info->srcfilename);
if (fclose (fget_req_info->fp)!=0) /* close temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: fclose of temp file (%s) failed ",
fget_req_info->tempfilename);
}
if (remove (fget_req_info->tempfilename)!=0) /* get rid of temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: remove of temp file (%s) failed ",
fget_req_info->tempfilename);
}
}
else
{ /* no temp file created */
MVL_LOG_NERR0 ("ERROR: mvla_fget: temp file creation failed ");
}
return(SD_FAILURE);
}
else
{
req_out->v = fget_req_info;
return (SD_SUCCESS);
}
} /* mvla_fget */
/************************************************************************/
/* send_file_open */
/* Send a file open request to open source file on the other side */
/************************************************************************/
MVL_REQ_PEND *send_file_open (MVL_NET_INFO *NetInfo, ST_CHAR *src)
{
MVL_REQ_PEND *req= NULL;
if ((mvla_fopen(NetInfo, src, 0, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fopen_done;
}
return (req);
} /* send_file_open */
/************************************************************************/
/* u_fopen_done */
/* It was indicated that a file open request was made */
/* Confirm file open response that was received as a result of a request*/
/************************************************************************/
static ST_VOID u_fopen_done( MVL_REQ_PEND *req)
{
ST_RET ret;
MVL_REQ_PEND *freadreq= NULL;
MVL_FGET_REQ_INFO *fget_req_info;
FOPEN_RESP_INFO *resp_info;
ERR_INFO *err_ptr;
REJECT_RESP_INFO *rej_ptr;
fget_req_info = (MVL_FGET_REQ_INFO *) req->v;
ret = req->result;
if (ret == SD_SUCCESS) /* open of source file succeeded */
{
resp_info = req->u.fopen.resp_info;
fget_req_info ->frsmid = resp_info->frsmid;
fget_req_info ->fsize = resp_info->ent.fsize;
if ((freadreq = send_file_read (req->net_info, fget_req_info)) != NULL)
{
freadreq->v = fget_req_info;
}
else
{
MVL_LOG_NERR1 ("ERROR: u_fopen_done: send_file_read (%s) failed ",
fget_req_info->srcfilename);
ret = SD_FAILURE;
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
}
} /* file open succeeded */
else
{ /* file open failed */
MVL_LOG_NERR1 ("ERROR: u_fopen_done: mvla_fopen (%s) failed ",
fget_req_info->srcfilename);
if (req->result==MVL_ERR_CNF_REJ_ERR)
{
rej_ptr = (REJECT_RESP_INFO *) req->event->u.mms.dec_rslt.data_ptr;
MVLU_LOG_FLOW3 ("MMS REJECT \n detected_here = %d \n invoke_known = %d invoke = %d",
req->reject_info->detected_here,
req->reject_info->invoke_known,
req->reject_info->invoke);
MVLU_LOG_CFLOW3 ("pdu_type = %d \n rej_class = %d \n rej_code = %d",
req->reject_info->pdu_type,
req->reject_info->rej_class,
req->reject_info->rej_code);
}
if (req->result==MVL_ERR_CNF_ERR_OK)
{
err_ptr = (ERR_INFO *) req->event->u.mms.dec_rslt.data_ptr;
MVLU_LOG_FLOW2 ("MMS ERROR RESPONSE \n class = %d, code = %d",
req->error_info->eclass,
req->error_info->code);
}
if (fclose (fget_req_info->fp)!=0) /* close temporary file */
{
MVL_LOG_ERR1 ("ERROR: u_fopen_done: fclose of temp file (%s) failed ",
fget_req_info->tempfilename);
}
if (remove (fget_req_info->tempfilename)!=0) /* get rid of temporary file */
MVL_LOG_ERR1 ("ERROR: u_fopen_done: remove of temp file (%s) failed ",
fget_req_info->tempfilename);
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
} /* file open failed */
mvl_free_req_ctrl (req);
} /* u_fopen_done */
/************************************************************************/
/* send_file_read */
/* Send a file read request to copy a block of the source file data */
/************************************************************************/
MVL_REQ_PEND *send_file_read (MVL_NET_INFO *NetInfo,
MVL_FGET_REQ_INFO *fget_req_info)
{
MVL_REQ_PEND *req= NULL;
FREAD_REQ_INFO fread_req;
fread_req.frsmid = fget_req_info->frsmid;
if ((mvla_fread (NetInfo, &fread_req, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fread_done;
}
return (req);
} /* send_file_read */
/************************************************************************/
/* u_fread_done */
/* Confirm the file read response sent to indicate a read request */
/************************************************************************/
static ST_VOID u_fread_done( MVL_REQ_PEND *req)
{
ST_RET ret;
MVL_REQ_PEND *freadreq= NULL;
MVL_REQ_PEND *fclosereq= NULL;
MVL_FGET_REQ_INFO *fget_req_info;
FREAD_RESP_INFO *resp_info;
fget_req_info = (MVL_FGET_REQ_INFO *) req->v;
ret = req->result;
if (ret == SD_SUCCESS) /* read succeeded */
{
resp_info = req->u.fread.resp_info;
if ( fwrite (resp_info->filedata, sizeof(ST_CHAR), resp_info->fd_len, fget_req_info->fp)
== (unsigned) resp_info->fd_len )
{
if ( resp_info->more_follows == SD_TRUE)
{
if ((freadreq = send_file_read (req->net_info, fget_req_info)) != NULL)
{
freadreq->v = fget_req_info; /* if more file data request to read another block */
}
else
{ /* read failed */
MVL_LOG_NERR1 ("ERROR: u_fread_done: send_file_read (%s) failed ",
fget_req_info->srcfilename);
ret = SD_FAILURE;
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
}
} /* more file data to be copied */
else
{ /* no more file data to be copied */
if ((fclosereq = send_file_close (req->net_info, fget_req_info)) != NULL)
{
fclosereq->v = fget_req_info; /* no more file data so send a file close request */
}
else
{
MVL_LOG_NERR1 ("ERROR: u_fread_done: send_file_close (%s) failed ",
fget_req_info->srcfilename);
ret = SD_FAILURE;
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
}
}
} /* writing data to temp file succeeded */
else
{ /* write failed */
MVL_LOG_NERR0 ("ERROR: u_fread_done: fwrite failed ");
ret = SD_FAILURE;
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
} /* write failed */
} /* read of data in source file succeeded */
else
{ /* read failed so close and remove temp file */
MVL_LOG_NERR1 ("ERROR: u_fread_done: mvla_fread (%s) failed ",
fget_req_info->srcfilename);
if (fclose (fget_req_info->fp)!=0) /* close temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: fclose of temp file (%s) failed ",
fget_req_info->tempfilename);
}
if (remove (fget_req_info->tempfilename)!=0) /* get rid of temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: remove of temp file (%s) failed ",
fget_req_info->tempfilename);
}
/* stop copy file process and report error to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
} /* read failed */
mvl_free_req_ctrl (req);
} /* u_fread_done */
/************************************************************************/
/* send_file_close */
/* No more data to read from the source file so send a request to close */
/* the source file */
/************************************************************************/
MVL_REQ_PEND *send_file_close (MVL_NET_INFO *NetInfo,
MVL_FGET_REQ_INFO *fget_req_info)
{
MVL_REQ_PEND *req= NULL;
FCLOSE_REQ_INFO fclose_req;
fclose_req.frsmid = fget_req_info->frsmid;
if ((mvla_fclose (NetInfo, &fclose_req, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fclose_done;
}
return (req);
} /* send_file_close */
/************************************************************************/
/* u_fclose_done */
/* Confirm source file closed response */
/************************************************************************/
static ST_VOID u_fclose_done( MVL_REQ_PEND *req)
{
ST_RET ret;
MVL_FGET_REQ_INFO *fget_req_info;
fget_req_info = (MVL_FGET_REQ_INFO *) req->v;
ret = req->result;
if (ret == SD_SUCCESS) /* close of source file succeeded */
{
if (fclose (fget_req_info->fp)!=0) /* close the temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: fclose of temp file (%s) failed ",
fget_req_info->tempfilename);
}
/* Remove dest file so temp file can be renamed to it. */
/* NOTE: remove may fail if file did not already exist. */
remove (fget_req_info->destfilename);
/* rename the temporary file to become the requested destination file */
/* use the ANSI rename function if available on your OS */
/* otherwise use other function appropriate for your system */
if (rename (fget_req_info->tempfilename, fget_req_info->destfilename))
{
MVL_LOG_ERR1 ("ERROR: u_fclose_done: rename (%s) failed ",
fget_req_info->tempfilename);
if (remove (fget_req_info->tempfilename)!=0) /* cleanup useless file */
{
MVL_LOG_ERR1 ("ERROR: u_fclose_done: remove (%s) failed ",
fget_req_info->tempfilename);
}
ret = SD_FAILURE;
}
else
{
}
} /* close succeeded */
else
{ /* close failed */
MVL_LOG_NERR1 ("ERROR: u_fclose_done: mvla_fclose (%s) failed ",
fget_req_info->srcfilename);
if (fclose (fget_req_info->fp)!=0) /* close temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: fclose of temp file (%s) failed ",
fget_req_info->tempfilename);
}
if (remove (fget_req_info->tempfilename)!=0) /* get rid of temporary file */
{
MVL_LOG_ERR1 ("ERROR: mvla_fget: remove of temp file (%s) failed ",
fget_req_info->tempfilename);
}
}
/* copy file process complete so report done and status to user */
fget_req_info->fget_done = SD_TRUE;
fget_req_info->fget_error = ret;
if (fget_req_info->fget_cnf_ptr)
(*fget_req_info->fget_cnf_ptr)(fget_req_info);
mvl_free_req_ctrl (req);
} /* end u_fclose_done */

158
mmslib/mvlu/c_fopen.c Normal file
View File

@@ -0,0 +1,158 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_fopen.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_fopen */
/* mvla_fopen */
/* _mvl_process_fopen_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* Add missing S_LOCK_... */
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_fopen */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_fopen (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_UINT32 init_pos,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_fopen (net_info, filename, init_pos, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
else
printf("mvla_fopen(%s) fail...\n",filename);
return (rc);
}
#endif
/************************************************************************/
/* mvla_fopen */
/************************************************************************/
ST_RET mvla_fopen (
MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_UINT32 init_pos,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_OPEN);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_fopen (net_info, filename, init_pos, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_fopen */
/************************************************************************/
/* Allocate FOPEN_REQ_INFO with "one" FILE_NAME entry after it. */
/* If need more than one FILE_NAME, must use "mpl_fopen". */
#define FOPEN_REQ_INFO_SIZE (sizeof (FOPEN_REQ_INFO) + (1 * sizeof (FILE_NAME)))
ST_RET _mvla_send_fopen (MVL_NET_INFO *net_info,
ST_CHAR *filename,
ST_UINT32 init_pos,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
FOPEN_REQ_INFO *req_info;
FILE_NAME *fname_idx;
ST_CHAR fopen_req_info[FOPEN_REQ_INFO_SIZE];
/* Allocate FOPEN_REQ_INFO with "one" FILE_NAME entry after it. */
/* If need more than one FILE_NAME, must use "mpl_fopen". */
req_info = (FOPEN_REQ_INFO *) fopen_req_info;
req_info->init_pos = init_pos;
req_info->num_of_fname = 1;
/* Point to the FILE_NAME structure and fill it in. */
fname_idx = (FILE_NAME *)(req_info + 1);
fname_idx->fn_len = strlen (filename);
fname_idx->fname = filename;
/* Build a fopen request */
rc = mpl_fopen (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_fopen_conf */
/************************************************************************/
ST_VOID _mvl_process_fopen_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.fopen.resp_info =
(FOPEN_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

139
mmslib/mvlu/c_fread.c Normal file
View File

@@ -0,0 +1,139 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_fread.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_fread */
/* mvla_fread */
/* _mvl_process_fread_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_fread */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_fread (
MVL_NET_INFO *net_info,
FREAD_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_fread (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_fread */
/************************************************************************/
ST_RET mvla_fread (
MVL_NET_INFO *net_info,
FREAD_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_READ);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_fread (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_fread */
/************************************************************************/
ST_RET _mvla_send_fread (MVL_NET_INFO *net_info,
FREAD_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a fread request */
rc = mpl_fread (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_fread_conf */
/************************************************************************/
ST_VOID _mvl_process_fread_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.fread.resp_info =
(FREAD_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
/* NOTE: This function has the SIGNIFICANT advantage that it avoids */
/* allocating another buffer and copying the "filedata" which may be */
/* large. This can be done because the "event" is not freed until the */
/* user calls "mvl_free_req_ctrl" when they are done with the data. */
}

140
mmslib/mvlu/c_fren.c Normal file
View File

@@ -0,0 +1,140 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1999, All Rights Reserved */
/* */
/* MODULE NAME : c_fren.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_frename */
/* mvla_frename */
/* _mvl_process_frename_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 11/01/01 JRB 10 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 08 Del LOCK on sync functs: caused deadlocks. */
/* 01/21/00 MDE 07 Eliminated allocation */
/* 10/10/99 GLB 06 Created to accomodate file Rename */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_frename */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_frename (
MVL_NET_INFO *net_info,
ST_CHAR *curfilename,
ST_CHAR *newfilename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_frename (net_info, curfilename, newfilename, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_frename */
/************************************************************************/
/* Allocate FRENAME_REQ_INFO with 2 FILE_NAME entries after it. */
/* If need multiple FILE_NAME elements, must use "mpl_frename". */
#define FRENAME_REQ_INFO_SIZE (sizeof (FRENAME_REQ_INFO) + (2 * sizeof (FILE_NAME)))
ST_RET mvla_frename (
MVL_NET_INFO *net_info,
ST_CHAR *curfilename,
ST_CHAR *newfilename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
FRENAME_REQ_INFO *req_info;
FILE_NAME *fname_idx;
ST_CHAR frename_req_info[FRENAME_REQ_INFO_SIZE];
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_FILE_RENAME);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_info = (FRENAME_REQ_INFO *) frename_req_info;
req_info->num_of_cur_fname = 1;
req_info->num_of_new_fname = 1;
/* Point to the FILE_NAME structure and fill in the current FileName */
fname_idx = (FILE_NAME *)(req_info + 1);
fname_idx->fn_len = strlen (curfilename);
fname_idx->fname = curfilename;
/* move the pointer by 1 name and fill in the new FileName */
fname_idx++;
fname_idx->fn_len = strlen (newfilename);
fname_idx->fname = newfilename;
S_LOCK_COMMON_RESOURCES ();
/* Build a frename request */
rc = mpl_frename (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvl_process_frename_conf */
/************************************************************************/
ST_VOID _mvl_process_frename_conf (MVL_REQ_PEND *req_pend)
{
/* Nothing to do. Common code takes care of setting req_pend->result. */
}

133
mmslib/mvlu/c_getdom.c Normal file
View File

@@ -0,0 +1,133 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_getdom.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_getdom */
/* mvla_getdom */
/* _mvl_process_getdom_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 13 Enhanced filtered logging */
/* 11/01/01 JRB 12 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 10 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 09 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 07 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 06 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 05 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/17/98 MDE 03 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 02 Renamed internal functions (prefix '_') */
/* 10/01/98 DWL 01 Created from c_getvar.c */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_getdom */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_getdom (
MVL_NET_INFO *net_info,
GETDOM_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_getdom (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_getdom */
/************************************************************************/
ST_RET mvla_getdom (
MVL_NET_INFO *net_info,
GETDOM_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_GET_DOM_ATTR);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_getdom (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_getdom */
/************************************************************************/
ST_RET _mvla_send_getdom (MVL_NET_INFO *net_info,
GETDOM_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a getdom request */
rc = mpl_getdom (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_getdom_conf */
/************************************************************************/
ST_VOID _mvl_process_getdom_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.getdom.resp_info =
(GETDOM_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

133
mmslib/mvlu/c_getnam.c Normal file
View File

@@ -0,0 +1,133 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_getnam.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_getnam */
/* mvla_getnam */
/* _mvl_process_getnam_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 13 Enhanced filtered logging */
/* 11/01/01 JRB 12 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 10 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 09 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 07 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 06 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 05 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/17/98 MDE 03 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 02 Renamed internal functions (prefix '_') */
/* 10/01/98 DWL 01 Created from c_getdom.c */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_getnam */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_getnam (
MVL_NET_INFO *net_info,
NAMELIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_getnam (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_getnam */
/************************************************************************/
ST_RET mvla_getnam (
MVL_NET_INFO *net_info,
NAMELIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_GET_NAMLIST);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_getname (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_getname */
/************************************************************************/
ST_RET _mvla_send_getname (MVL_NET_INFO *net_info,
NAMELIST_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a getvar request */
rc = mpl_namelist (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_getnam_conf */
/************************************************************************/
ST_VOID _mvl_process_getnam_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.getnam.resp_info =
(NAMELIST_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

133
mmslib/mvlu/c_getvar.c Normal file
View File

@@ -0,0 +1,133 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_getvar.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_getvar */
/* mvla_getvar */
/* _mvl_process_getvar_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 13 Enhanced filtered logging */
/* 11/01/01 JRB 12 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 10 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 09 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 07 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 06 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 05 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/17/98 MDE 03 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 02 Renamed internal functions (prefix '_') */
/* 09/02/98 DWL 01 Created from c_jinit.c */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_getvar */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_getvar (
MVL_NET_INFO *net_info,
GETVAR_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_getvar (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_getvar */
/************************************************************************/
ST_RET mvla_getvar (
MVL_NET_INFO *net_info,
GETVAR_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_GET_VAR);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_getvar (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_getvar */
/************************************************************************/
ST_RET _mvla_send_getvar (MVL_NET_INFO *net_info,
GETVAR_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a getvar request */
rc = mpl_getvar (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_getvar_conf */
/************************************************************************/
ST_VOID _mvl_process_getvar_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.getvar.resp_info =
(GETVAR_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

135
mmslib/mvlu/c_getvla.c Normal file
View File

@@ -0,0 +1,135 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_getvla.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_getvlist */
/* mvla_getvlist */
/* _mvl_process_getvlist_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_getvlist */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_getvlist (
MVL_NET_INFO *net_info,
GETVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_getvlist (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_getvlist */
/************************************************************************/
ST_RET mvla_getvlist (
MVL_NET_INFO *net_info,
GETVLIST_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_GET_VLIST);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_getvlist (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_getvist */
/************************************************************************/
ST_RET _mvla_send_getvlist (MVL_NET_INFO *net_info,
GETVLIST_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a getvlist request */
rc = mpl_getvlist (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_getvlist_conf */
/* Set "req_pend->u.getvlist.resp_info" to POINT to response info. */
/************************************************************************/
ST_VOID _mvl_process_getvlist_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.getvlist.resp_info =
(GETVLIST_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

115
mmslib/mvlu/c_ident.c Normal file
View File

@@ -0,0 +1,115 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : c_ident.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_identify */
/* mvla_identify */
/* _mvl_process_ident_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 12 Enhanced filtered logging */
/* 11/01/01 JRB 11 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 10 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 09 Del LOCK on sync functs: caused deadlocks. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 11/17/98 MDE 06 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 04 Changes to allow compile under C++ */
/* 05/22/98 JRB 03 Pass (MVL_REQ_PEND**) to sync function also. */
/* Do not pass resp info ptr. Confirm sets it. */
/* 04/16/98 JRB 02 Conf func: Let caller do "common" stuff. */
/* Always set (*req_out) so user can always free*/
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* mvl_identify */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_identify (MVL_NET_INFO *net_info, MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_identify (net_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_identify */
/************************************************************************/
ST_RET mvla_identify (MVL_NET_INFO *net_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req;
*req_out = req = _mvl_get_req_ctrl (net_info, MMSOP_IDENTIFY);
if (!req)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
/* Build a identify request */
rc = mpl_ident();
if (rc == SD_SUCCESS)
mpl_req_log (req, NULL);
rc = _mvl_send_req (net_info, req, rc);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvl_process_ident_conf */
/************************************************************************/
ST_VOID _mvl_process_ident_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.ident.resp_info =
(IDENT_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

292
mmslib/mvlu/c_info.c Normal file
View File

@@ -0,0 +1,292 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : c_info.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_info_ind */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 02/25/04 MDE 16 Tweaked logging */
/* 10/28/03 JRB 15 Move mvl_free_comm_event call from */
/* mvl_info_data.. to _mvl_process_info_ind. */
/* mvl_info_data..: use num_va arg (ignored before)*/
/* 01/30/02 JRB 14 Del use of stack_sel. */
/* 06/22/00 MDE 13 Minor log change */
/* 01/21/00 MDE 12 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 11 Added SD_CONST modifiers */
/* 04/07/99 MDE 10 Added '#ifdef MVL_INFO_RPT_CLIENT' */
/* 02/22/99 JRB 09 BUG FIX: Don't access "va" if it is NULL. */
/* 01/08/99 JRB 08 Use new "bsearch" object model. */
/* 12/09/98 MDE 07 'mvl_info_rpt_rem_process' now frees event */
/* 11/16/98 MDE 06 Renamed internal functions (prefix '_') */
/* 07/10/98 JRB 05 Don't use net_info->rem_vmd for CLACSE, not set.*/
/* 06/30/98 MDE 04 Added more flexable CLient Info Rpt code */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES support */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
#ifdef MVL_INFO_RPT_CLIENT
/************************************************************************/
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_process_info_ind */
/* A info indication has been received, process it and respond */
/************************************************************************/
ST_VOID u_mvl_info_rpt_ind (MVL_COMM_EVENT *event);
ST_VOID _mvl_process_info_ind (MVL_COMM_EVENT *event)
{
INFO_REQ_INFO *info_ptr;
VAR_ACC_SPEC *va_spec;
/* Do a sanity check to make sure the number of data is correct */
info_ptr = (INFO_REQ_INFO *) event->u.mms.dec_rslt.data_ptr;
va_spec = &info_ptr->va_spec;
if (va_spec->var_acc_tag == VAR_ACC_VARLIST)
{
if (va_spec->num_of_variables != info_ptr->num_of_acc_result)
{
MVL_LOG_NERR2 ("InfoRpt Ind : NumVar (%d) vs. NumAccRslt (%d)mismatch",
va_spec->num_of_variables, info_ptr->num_of_acc_result);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
}
/* OK, just give the info report to the user. */
/* NOTE: User must finish processing the event in u_mvl_info_rpt_ind, */
/* because it is freed immediately after this function returns. */
u_mvl_info_rpt_ind (event);
_mvl_free_comm_event (event); /* done with this event, free it */
}
/************************************************************************/
/* mvl_info_data_to_local */
/************************************************************************/
/* This function is used to convert Info Report data to local format */
/* The user supplies a table of variable associations, which speify the */
/* data type, destination, and pre/post processing functions. */
/* This function free's the info report resources when the conversion */
/* are complete. */
ST_VOID mvl_info_data_to_local (MVL_COMM_EVENT *event,
ST_INT num_va,
MVL_VAR_ASSOC **info_va)
{
INFO_REQ_INFO *info_ptr;
ST_INT j;
ACCESS_RESULT *ar_ptr;
MVL_VAR_ASSOC *va;
RUNTIME_TYPE *rt;
ST_INT rt_len;
info_ptr = (INFO_REQ_INFO *) event->u.mms.dec_rslt.data_ptr;
ar_ptr = info_ptr->acc_rslt_list;
for (j = 0; j < num_va; ++j, ++ar_ptr)
{
va = info_va[j];
if (!va)
{
MVLU_LOG_FLOW1 ("InfoRpt Ind : No VA provided for AccessResult %d, ignoring", j);
continue;
}
if (ar_ptr->acc_rslt_tag == ACC_RSLT_SUCCESS)
{
/* Call the preprocessing function for this variable, if it exists */
if (va->proc && va->proc->pre_info)
(*va->proc->pre_info)(va, event->net_info);
/* convert data in read buffer to local representation */
/* and store in local buffer */
if (mvl_get_runtime (va->type_id, &rt, &rt_len) == SD_SUCCESS)
{
va->result = ms_asn1_to_local (rt,
rt_len,
ar_ptr->va_data.data,
ar_ptr->va_data.len,
(ST_CHAR *) va->data);
if (va->result != SD_SUCCESS)
{
MVL_LOG_NERR1 ("InfoRpt Ind : Data conversion error for variable '%s'",
va->name);
}
}
else /* bad type ID */
{
MVL_LOG_NERR1 ("InfoRpt Ind : Bad Type ID '%d'", va->type_id);
va->result = SD_FAILURE;
}
}
else /* access result == failure */
{
MVL_LOG_NERR0 ("InfoRpt Ind : Access Result == SD_FAILURE");
va->result = SD_FAILURE;
}
if ((va->result == SD_SUCCESS) && va->proc && va->proc->post_info)
{
(*va->proc->post_info)(va, event->net_info);
}
}
}
/************************************************************************/
/* mvl_info_rpt_rem_process */
/************************************************************************/
#if defined(MVL_REM_VMD_SUPPORT)
MVL_VMD_CTRL *(*u_mvl_get_rem_vmd_fun) (MVL_NET_INFO *net_info);
ST_VOID mvl_info_rpt_rem_process (MVL_COMM_EVENT *event)
{
INFO_REQ_INFO *info_ptr;
ST_INT i;
ST_INT j;
OBJECT_NAME *vobj;
VARIABLE_LIST *vl;
VAR_ACC_SPEC *va_spec;
MVL_VMD_CTRL *rem_vmd;
MVL_VAR_ASSOC **info_va;
ST_INT num_va;
MVL_NVLIST_CTRL *nvlist;
ST_CHAR *name;
/* To handle information reports, the user must have set up a remote */
/* VMD object control structure, and the MVL_NET_INFO must reference it. */
if (event->net_info->rem_vmd)
rem_vmd = (MVL_VMD_CTRL *) event->net_info->rem_vmd;
else
{
if (u_mvl_get_rem_vmd_fun)
rem_vmd = (*u_mvl_get_rem_vmd_fun) (event->net_info);
}
if (!rem_vmd)
{
MVL_LOG_NERR1 ("InfoRpt Ind : No rem_vmd for MVL_NET_INFO 0x%08lx",
event->net_info);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
/* We want to get a table of pointers to VARIABLE_ASSOCIATIONS so we */
/* can convert the received data to local format and tell the user */
/* about it. */
info_ptr = (INFO_REQ_INFO *) event->u.mms.dec_rslt.data_ptr;
va_spec = &info_ptr->va_spec;
if (va_spec->var_acc_tag == VAR_ACC_NAMEDLIST)
{
vobj = &va_spec->vl_name;
for (i = 0; i < rem_vmd->num_nvlist; ++i)
{ /* search for the NVL */
if (!strcmp(rem_vmd->nvlist_tbl[i].name, vobj->obj_name.vmd_spec))
{
/* Found the named variable list, create the response */
nvlist = rem_vmd->nvlist_tbl[i];
info_va = nvlist->entries;
num_va = nvlist->num_of_entries;
break;
}
}
if ((i >= rem_vmd->num_nvlist) ||
(num_va != info_ptr->num_of_acc_result))
{
MVL_LOG_NERR2 ("InfoRpt Ind : NumVar (%d) vs. NumAccRslt (%d)mismatch",
num_va, info_ptr->num_of_acc_result);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
}
else if (va_spec->var_acc_tag == VAR_ACC_VARLIST)
{
if (va_spec->num_of_variables != info_ptr->num_of_acc_result)
{
MVL_LOG_NERR2 ("InfoRpt Ind : NumVar (%d) vs. NumAccRslt (%d)mismatch",
va_spec->num_of_variables, info_ptr->num_of_acc_result);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
num_va = info_ptr->num_of_acc_result;
info_va =
(MVL_VAR_ASSOC **) M_CALLOC (MSEM_GEN, num_va, sizeof (MVL_VAR_ASSOC *));
vl = (VARIABLE_LIST *) (info_ptr + 1);
for (j = 0; j < info_ptr->num_of_acc_result; ++j, ++vl)
{
if (vl->var_spec.var_spec_tag == VA_SPEC_NAMED)
{
vobj = &vl->var_spec.vs.name;
name = vobj->obj_name.vmd_spec;
for (i = 0; i < rem_vmd->num_var_assoc; ++i)
{
if (!strcmp (rem_vmd->var_assoc_tbl[i].name, name))
{
info_va[j] = rem_vmd->var_assoc_tbl[i];
break;
}
}
if (i >= rem_vmd->num_var_assoc)
{
MVL_LOG_NERR1 ("InfoRpt Ind : Variable '%s' not found", name);
M_FREE (MSMEM_GEN, info_va);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
}
else
{
MVL_LOG_NERR0 ("InfoRpt Ind : VA Spec not named");
M_FREE (MSMEM_GEN, info_va);
_mvl_free_comm_event (event); /* All done with this event */
return;
}
}
}
mvl_info_data_to_local (event, num_va, info_va);
M_FREE (MSMEM_GEN, info_va);
_mvl_free_comm_event (event); /* All done with this event */
}
#endif /* MVL_REM_VMD_SUPPORT */
/************************************************************************/
#endif /* MVL_INFO_RPT_CLIENT */
/************************************************************************/

134
mmslib/mvlu/c_jinit.c Normal file
View File

@@ -0,0 +1,134 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_jinit.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_jinit */
/* mvla_jinit */
/* _mvl_process_jinit_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/26/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_jinit */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_jinit (
MVL_NET_INFO *net_info,
JINIT_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_jinit (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_jinit */
/************************************************************************/
ST_RET mvla_jinit (
MVL_NET_INFO *net_info,
JINIT_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_INIT_JOURNAL);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_jinit (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_jinit */
/************************************************************************/
ST_RET _mvla_send_jinit (MVL_NET_INFO *net_info,
JINIT_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a jinit request */
rc = mpl_jinit (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_jinit_conf */
/************************************************************************/
ST_VOID _mvl_process_jinit_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.jinit.resp_info =
(JINIT_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

202
mmslib/mvlu/c_jread.c Normal file
View File

@@ -0,0 +1,202 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_jread.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_jread */
/* mvla_jread */
/* _mvl_process_jread_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 15 Enhanced filtered logging */
/* 11/01/01 JRB 14 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 13 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 12 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 11 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 10 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 09 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 08 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 11/03/99 NAV 07 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 11/17/98 MDE 05 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 10/09/98 JRB 03 Chg MVL_CLI_JOURNAL_ENTRY to MVL_JOURNAL_ENTRY,*/
/* just like server (entry_id is now array */
/* instead of pointer). */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_jread */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_jread (
MVL_NET_INFO *net_info,
JREAD_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_jread (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_jread */
/************************************************************************/
ST_RET mvla_jread (
MVL_NET_INFO *net_info,
JREAD_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_READ_JOURNAL);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_pend->u.jread.resp_info = NULL; /* Confirm funct must allocate */
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_jread (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_jread */
/************************************************************************/
ST_RET _mvla_send_jread (MVL_NET_INFO *net_info,
JREAD_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a jread request */
rc = mpl_jread (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_jread_conf */
/* Set "req_pend->u.jread.resp_info" to POINT to response info. */
/************************************************************************/
ST_VOID _mvl_process_jread_conf (MVL_REQ_PEND *req_pend)
{
JREAD_RESP_INFO *jread_resp;
JOURNAL_ENTRY *jou_entry;
MVL_JREAD_RESP_INFO *mvl_jread_resp;
MVL_JOURNAL_ENTRY *mvl_jou_entry;
ST_INT j;
ST_INT info_size;
jread_resp = (JREAD_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
info_size = sizeof (MVL_JREAD_RESP_INFO) +
jread_resp->num_of_jou_entry * sizeof (MVL_JOURNAL_ENTRY);
/* Allocate and fill in "req_pend->u.jread.resp_info". */
/* CRITICAL: mvl_free_req_ctrl () must free it. */
req_pend->u.jread.resp_info =
(MVL_JREAD_RESP_INFO *) M_CALLOC (MSMEM_GEN, 1, info_size);
mvl_jread_resp = req_pend->u.jread.resp_info; /* Local ptr to it. */
mvl_jread_resp->num_of_jou_entry = jread_resp->num_of_jou_entry;
mvl_jread_resp->more_follows = jread_resp->more_follows;
mvl_jread_resp->jou_entry = (MVL_JOURNAL_ENTRY *) (mvl_jread_resp + 1);
if (mvl_jread_resp->num_of_jou_entry)
{
jou_entry = (JOURNAL_ENTRY *)(jread_resp + 1); /* point to first.*/
mvl_jou_entry = mvl_jread_resp->jou_entry; /* point to first.*/
for (j = 0; j < jread_resp->num_of_jou_entry; j++)
{
mvl_jou_entry->entry_id_len = jou_entry->entry_id_len;
memcpy (mvl_jou_entry->entry_id, jou_entry->entry_id, jou_entry->entry_id_len);
if (ms_asn1_to_appref (&mvl_jou_entry->orig_app, jou_entry->orig_ae,
jou_entry->orig_ae_len))
{
MVL_LOG_ERR0 ("Error: ReadJournal-Resp: orig_app decode failed");
}
memcpy (&mvl_jou_entry->occur_time, &jou_entry->ent_content.occur_time,
sizeof (MMS_BTOD));
mvl_jou_entry->entry_form_tag = jou_entry->ent_content.entry_form_tag;
if (mvl_jou_entry->entry_form_tag == 2) /* DATA */
{
mvl_jou_entry->ef.data.event_pres = jou_entry->ent_content.ef.data.event_pres;
memcpy (&mvl_jou_entry->ef.data.evcon_name,
&jou_entry->ent_content.ef.data.evcon_name, sizeof (OBJECT_NAME));
mvl_jou_entry->ef.data.cur_state = jou_entry->ent_content.ef.data.cur_state;
mvl_jou_entry->ef.data.list_of_var_pres = jou_entry->ent_content.ef.data.list_of_var_pres;
if (mvl_jou_entry->ef.data.list_of_var_pres)
{
mvl_jou_entry->ef.data.num_of_var = jou_entry->ent_content.ef.data.num_of_var;
mvl_jou_entry->ef.data.list_of_var = (VAR_INFO *)(jou_entry + 1);
}
}
else /* MUST BE ANNOTATION */
{
mvl_jou_entry->ef.annotation = jou_entry->ent_content.ef.annotation;
}
/* Point to next src and dst entry. */
jou_entry++;
if (mvl_jou_entry->entry_form_tag == 2 && /* DATA */
mvl_jou_entry->ef.data.list_of_var_pres)
jou_entry = (JOURNAL_ENTRY *) ( ((ST_CHAR *)jou_entry) +
mvl_jou_entry->ef.data.num_of_var * sizeof (VAR_INFO));
mvl_jou_entry++;
} /* end "loop" */
} /* end "if num_of_jou_entry" */
}

134
mmslib/mvlu/c_jstat.c Normal file
View File

@@ -0,0 +1,134 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_jstat.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_jstat */
/* mvla_jstat */
/* _mvl_process_jstat_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 14 Enhanced filtered logging */
/* 11/01/01 JRB 13 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 11 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 10 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 08 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 07 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 11/03/99 NAV 06 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/17/98 MDE 04 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 03/27/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_jstat */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_jstat (
MVL_NET_INFO *net_info,
JSTAT_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_jstat (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_jstat */
/************************************************************************/
ST_RET mvla_jstat (
MVL_NET_INFO *net_info,
JSTAT_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_STAT_JOURNAL);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_jstat (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_jstat */
/************************************************************************/
ST_RET _mvla_send_jstat (MVL_NET_INFO *net_info,
JSTAT_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a jstat request */
rc = mpl_jstat (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_jstat_conf */
/************************************************************************/
ST_VOID _mvl_process_jstat_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.jstat.resp_info =
(JSTAT_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

135
mmslib/mvlu/c_obtfi.c Normal file
View File

@@ -0,0 +1,135 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1999, All Rights Reserved */
/* */
/* MODULE NAME : c_obtfi.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_obtfile */
/* mvla_obtfile */
/* _mvl_process_obtfile_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 06 Enhanced filtered logging */
/* 11/01/01 JRB 05 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 04 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 03 Del LOCK on sync functs: caused deadlocks. */
/* 01/21/00 MDE 02 Eliminated an allocation */
/* 10/14/99 GLB 01 Created to add Obtain File function */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_obtfile */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_obtfile (
MVL_NET_INFO *net_info,
ST_CHAR *srcfilename,
ST_CHAR *destfilename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_obtfile (net_info, srcfilename, destfilename, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_obtfile */
/************************************************************************/
/* Allocate OBTFILE_REQ_INFO with "two" FILE_NAME entries after it. */
/* If need multiple FILE_NAME elements, must use "mpl_frename". */
#define OBTFILE_REQ_INFO_SIZE (sizeof (OBTFILE_REQ_INFO) + (2 * sizeof (FILE_NAME)))
ST_RET mvla_obtfile (
MVL_NET_INFO *net_info,
ST_CHAR *srcfilename,
ST_CHAR *destfilename,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
OBTFILE_REQ_INFO *req_info;
FILE_NAME *fname_idx;
ST_CHAR obtfile_req_info[OBTFILE_REQ_INFO_SIZE];
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_OBTAIN_FILE);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_info = (OBTFILE_REQ_INFO *) obtfile_req_info;
req_info->ar_title_pres = SD_FALSE;
req_info->num_of_src_fname = 1;
req_info->num_of_dest_fname = 1;
/* Point to the FILE_NAME structure and fill in the current FileName */
fname_idx = (FILE_NAME *)(req_info + 1);
fname_idx->fn_len = strlen (srcfilename);
fname_idx->fname = srcfilename;
/* move the pointer by 1 name and fill in the new FileName */
fname_idx++;
fname_idx->fn_len = strlen (destfilename);
fname_idx->fname = destfilename;
S_LOCK_COMMON_RESOURCES ();
/* Build a frename request */
rc = mpl_obtfile (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvl_process_obtfile_conf */
/************************************************************************/
ST_VOID _mvl_process_obtfile_conf (MVL_REQ_PEND *req_pend)
{
/* Nothing to do. Common code takes care of setting req_pend->result. */
}

243
mmslib/mvlu/c_read.c Normal file
View File

@@ -0,0 +1,243 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2004, All Rights Reserved */
/* */
/* MODULE NAME : c_read.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_read_variables */
/* mvla_read_variables */
/* _mvl_process_read_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 20 Enhanced filtered logging */
/* 08/09/04 JRB 19 Log if type_id invalid. */
/* 11/01/01 JRB 18 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 17 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 16 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 15 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 14 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 13 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 12 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 11 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 10 Added SD_CONST modifiers */
/* 12/08/98 MDE 09 Added client alternate access support */
/* 11/17/98 MDE 08 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 07 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 06 Minor lint cleanup */
/* 06/15/98 MDE 05 Changes to allow compile under C++ */
/* 05/22/98 JRB 04 Pass (MVL_REQ_PEND**) to sync function also. */
/* 04/16/98 JRB 03 Conf func: Let caller do "common" stuff. */
/* Always set (*req_out) so user can always free*/
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES support */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_read_variables (MVL_NET_INFO *net_info,
READ_REQ_INFO *read_info,
ST_INT num_data,
MVL_READ_RESP_PARSE_INFO *parse_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_read_variables (net_info, read_info, num_data, parse_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
ST_RET mvla_read_variables (MVL_NET_INFO *net_info,
READ_REQ_INFO *read_info,
ST_INT num_data,
MVL_READ_RESP_PARSE_INFO *parse_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_READ);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_pend->u.rd.parse_info = parse_info;
req_pend->u.rd.num_data = num_data;
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_read_variables (net_info, read_info, num_data, parse_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_read_variables */
/************************************************************************/
ST_RET _mvla_send_read_variables (MVL_NET_INFO *net_info,
READ_REQ_INFO *read_info,
ST_INT num_data,
MVL_READ_RESP_PARSE_INFO *parse_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
VARIABLE_LIST *vl;
ST_INT i;
#if defined(MVL_AA_SUPP)
if (read_info->va_spec.var_acc_tag == VAR_ACC_VARLIST)
{
vl = (VARIABLE_LIST *) (read_info + 1);
for (i = 0; i < num_data; ++i, ++vl)
{
if (parse_info[i].alt_acc_pres == SD_TRUE)
{
rc = _mvl_get_asn1_aa (parse_info[i].alt_acc, vl);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR0 ("Error creating ASN.1 encoded Alternate Access");
return (SD_FAILURE);
}
}
}
}
#endif
/* Build a read request */
rc = mpl_read (read_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, read_info);
#if defined(MVL_AA_SUPP)
_m_free_aa_asn1_buf ();
#endif
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
ST_VOID _mvl_process_read_conf (MVL_REQ_PEND *req)
{
ST_INT i;
RUNTIME_TYPE *rt;
ST_INT rt_len;
READ_RESP_INFO *read_info;
ACCESS_RESULT *ar_ptr;
MVL_READ_RESP_PARSE_INFO *parse_table;
ST_INT num_variables;
ST_BOOLEAN packed_save;
read_info = (READ_RESP_INFO *) req->event->u.mms.dec_rslt.data_ptr;
ar_ptr = read_info->acc_rslt_list;
/* retrieve parse information */
parse_table = req->u.rd.parse_info;
num_variables = req->u.rd.num_data;
/* just a sanity check */
if (num_variables != read_info->num_of_acc_result)
{
MVL_LOG_NERR0 ("Read Confirmation : num var != num result");
req->result = SD_FAILURE;
return;
}
/* For each variable returned in the read response ... */
for (i = 0; i < num_variables; ++i, ++ar_ptr, ++parse_table)
{ /* check for successfull read of this variable */
if (ar_ptr->acc_rslt_tag == ACC_RSLT_SUCCESS)
{
/* convert data in read buffer to local representation */
/* and store in local buffer */
if (mvl_get_runtime (parse_table->type_id,&rt, &rt_len) == SD_SUCCESS)
{
if (parse_table->descr_arr)
{
mvl_mod_arr_size (rt, parse_table->arr_size);
}
#if defined(MVL_AA_SUPP)
if (parse_table->alt_acc_pres == SD_TRUE &&
parse_table->alt_acc_type_aa == SD_FALSE)
{
packed_save = m_alt_acc_packed;
m_alt_acc_packed = parse_table->alt_acc_data_packed;
parse_table->result = ms_asn1_to_local_aa (rt, rt_len,
parse_table->alt_acc,
ar_ptr->va_data.data,
ar_ptr->va_data.len,
(ST_CHAR *) parse_table->dest);
m_alt_acc_packed = packed_save;
}
else /* No alternate access */
{
parse_table->result = ms_asn1_to_local (rt, rt_len,
ar_ptr->va_data.data,
ar_ptr->va_data.len,
(ST_CHAR *) parse_table->dest);
}
#else /* We don't support alternate access */
parse_table->result = ms_asn1_to_local (rt, rt_len,
ar_ptr->va_data.data,
ar_ptr->va_data.len,
(ST_CHAR *) parse_table->dest);
#endif /* #if defined(MVL_AA_SUPP) */
}
else /* bad type ID */
{
MVL_LOG_NERR2 ("Read Confirmation : type_id %d invalid for variable #%d", parse_table->type_id, i);
parse_table->result = SD_FAILURE;
}
}
else /* access result == failure */
parse_table->result = SD_FAILURE;
} /* for each variable */
}

133
mmslib/mvlu/c_status.c Normal file
View File

@@ -0,0 +1,133 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : c_status.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_status */
/* mvla_status */
/* _mvl_process_status_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 13 Enhanced filtered logging */
/* 11/01/01 JRB 12 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 10 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 09 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 07 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 06 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 05 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/17/98 MDE 03 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 02 Renamed internal functions (prefix '_') */
/* 10/05/98 DWL 01 Created from c_getnam.c */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* mvl_status */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_status (
MVL_NET_INFO *net_info,
STATUS_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_status (net_info, req_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_status */
/************************************************************************/
ST_RET mvla_status (
MVL_NET_INFO *net_info,
STATUS_REQ_INFO *req_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_STATUS);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
S_LOCK_COMMON_RESOURCES ();
rc = _mvla_send_status (net_info, req_info, req_pend);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_status */
/************************************************************************/
ST_RET _mvla_send_status (MVL_NET_INFO *net_info,
STATUS_REQ_INFO *req_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a getvar request */
rc = mpl_status (req_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, req_info);
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* _mvl_process_status_conf */
/************************************************************************/
ST_VOID _mvl_process_status_conf (MVL_REQ_PEND *req_pend)
{
req_pend->u.status.resp_info =
(STATUS_RESP_INFO *) req_pend->event->u.mms.dec_rslt.data_ptr;
}

322
mmslib/mvlu/c_write.c Normal file
View File

@@ -0,0 +1,322 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : c_write.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_write_variables */
/* mvla_write_variables */
/* _mvl_process_write_conf */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 24 Enhanced filtered logging */
/* 01/30/06 GLB 23 Integrated porting changes for VMS */
/* 07/16/02 JRB 22 Skip memmove to front of asn1_buf. */
/* Make sure num vars matches num data. */
/* _mvla_send..: Del unused args, make static. */
/* 03/06/02 JRB 21 Add S_UNLOCK.. before ALL returns. */
/* 02/25/02 MDE 20 Now get max PDU size from mvl_cfg_info */
/* 01/02/02 JRB 19 Converted to use ASN1R (re-entrant ASN1) */
/* 11/01/01 JRB 18 mvl_wait_req_done now returns ST_RET. */
/* 09/21/01 JRB 17 Alloc global bufs only once at startup. */
/* 03/07/01 JRB 16 Del LOCK on sync functs: caused deadlocks. */
/* 03/08/00 JRB 15 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* Del mvl_free_req_ctrl call. User must call. */
/* Del invoke_id, numpend_req: see mvl_send_req.*/
/* 01/21/00 MDE 14 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 13 Use '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 12 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/20/99 NAV 11 Add maxpend_req support to aynsc functions */
/* 09/13/99 MDE 10 Added SD_CONST modifiers */
/* 03/05/99 MDE 09 Fixed NVL write pointer arithmatic problem */
/* 12/08/98 MDE 08 Added client alternate access support */
/* 11/17/98 MDE 07 Now use MVL_ERR_COMM_SERVE_ACTIVE error code */
/* Use MVL_SYNC_REQ_INTERFACE */
/* 11/16/98 MDE 06 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 05 Changes to allow compile under C++ */
/* 05/22/98 JRB 04 Pass (MVL_REQ_PEND**) to sync function also. */
/* 04/16/98 JRB 03 Conf func: Let caller do "common" stuff. */
/* Always set (*req_out) so user can always free*/
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES support */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_acse.h"
#include "mvl_log.h"
static ST_RET _mvla_send_write_variables (MVL_NET_INFO *net_info,
WRITE_REQ_INFO *write_info,
MVL_REQ_PEND *req_pend);
static ST_RET w_get_asn1_data (MVL_WRITE_REQ_INFO *w_info,
ST_UCHAR *asn1_dest_buffer,
ST_INT asn1_buffer_len,
ST_INT *asn1_len_out);
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* mvl_write_variables */
/************************************************************************/
#if defined(MVL_SYNC_REQ_INTERFACE)
ST_RET mvl_write_variables (MVL_NET_INFO *net_info,
WRITE_REQ_INFO *write_info,
ST_INT num_data,
MVL_WRITE_REQ_INFO *w_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
if (_mvl_comm_serve_active == SD_TRUE)
{
MVL_LOG_NERR0 ("Error: mvl_comm_serv active");
return (MVL_ERR_COMM_SERVE_ACTIVE);
}
rc = mvla_write_variables (net_info, write_info, num_data, w_info, req_out);
if (rc == SD_SUCCESS)
rc = mvl_wait_req_done (*req_out);
return (rc);
}
#endif
/************************************************************************/
/* mvla_write_variables */
/************************************************************************/
ST_RET mvla_write_variables (MVL_NET_INFO *net_info,
WRITE_REQ_INFO *write_info,
ST_INT num_data,
MVL_WRITE_REQ_INFO *w_info,
MVL_REQ_PEND **req_out)
{
ST_RET rc;
MVL_REQ_PEND *req_pend;
VARIABLE_LIST *vl_ptr;
VAR_ACC_DATA *va_ptr;
ST_UCHAR *asn1_buf;
ST_INT asn1_len;
ST_INT asn1_buf_left;
ST_INT i;
*req_out = req_pend = _mvl_get_req_ctrl (net_info, MMSOP_WRITE);
if (!req_pend)
return (MVL_ERR_REQ_CONTROL);
req_pend->u.wr.w_info = w_info;
req_pend->u.wr.num_data = num_data;
S_LOCK_COMMON_RESOURCES ();
/* Make the write request operation specific data structure */
/* NOTE: Number of vars MUST match number of data. To be sure, */
/* overwrite values user entered. */
write_info->num_of_data = num_data;
write_info->va_spec.num_of_variables = num_data; /* only used if VARLIST*/
vl_ptr = (VARIABLE_LIST *) (write_info+1);
if (write_info->va_spec.var_acc_tag == VAR_ACC_NAMEDLIST)
write_info->va_data = (VAR_ACC_DATA *) (write_info + 1);
else
write_info->va_data = (VAR_ACC_DATA *) (vl_ptr +
write_info->va_spec.num_of_variables);
va_ptr = write_info->va_data;
/* encode the data */
asn1_buf = (ST_UCHAR *) M_MALLOC (MSMEM_ASN1_DATA_ENC, mvl_cfg_info->max_msg_size);
asn1_buf_left = mvl_cfg_info->max_msg_size;
for (i = 0; i < num_data; ++i, vl_ptr++, va_ptr++, w_info++)
{
rc = w_get_asn1_data(w_info,asn1_buf,asn1_buf_left,&asn1_len);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Write : w_get_asn1_data failed, ret = %x", rc);
S_UNLOCK_COMMON_RESOURCES ();
return(rc);
}
else
{
/* Data encoded at end of asn1_buf. Adjust len so next data */
/* encodes before this data. Save ptr and len. */
asn1_buf_left -= asn1_len; /* adjust buffer control vars */
va_ptr->len = asn1_len;
va_ptr->data = asn1_buf + asn1_buf_left;
#if defined(MVL_AA_SUPP)
if (w_info->alt_acc_pres)
{
rc = _mvl_get_asn1_aa (w_info[i].alt_acc, vl_ptr);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR0 ("Error creating ASN.1 encoded Alternate Access");
S_UNLOCK_COMMON_RESOURCES ();
return (SD_FAILURE);
}
}
#endif
}
}
rc = _mvla_send_write_variables (net_info, write_info, req_pend);
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
S_UNLOCK_COMMON_RESOURCES ();
return (rc);
}
/************************************************************************/
/* _mvla_send_write_variables */
/************************************************************************/
static ST_RET _mvla_send_write_variables (MVL_NET_INFO *net_info,
WRITE_REQ_INFO *write_info,
MVL_REQ_PEND *req_pend)
{
ST_RET rc;
/* Build a write request */
rc = mpl_write (write_info);
if (rc == SD_SUCCESS)
mpl_req_log (req_pend, write_info);
#if defined(MVL_AA_SUPP)
_m_free_aa_asn1_buf ();
#endif
rc = _mvl_send_req (net_info, req_pend, rc);
return (rc);
}
/************************************************************************/
/* w_get_asn1_data */
/************************************************************************/
/* This function is to provide ASN.1 encoded data, given the variable */
/* list element. */
static ST_RET w_get_asn1_data (MVL_WRITE_REQ_INFO *wr_info,
ST_UCHAR *asn1_dest_buffer,
ST_INT asn1_buffer_len,
ST_INT *asn1_len_out)
{
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_RET rc;
ST_UCHAR *asn1_start;
ST_INT asn1_len;
ST_BOOLEAN packed_save;
ASN1_ENC_CTXT localEncCtx; /* For readability, use "aCtx" to access this.*/
ASN1_ENC_CTXT *aCtx = &localEncCtx;
rc = mvl_get_runtime (wr_info->type_id,&rt, &num_rt);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Get ASN1 Data : mvl_get_runtime failed, rc = %x", rc);
return (rc); /* bad type id */
}
/* Check to see if this is an array with variable number of elements */
/* and modify the size if necessary - */
if (wr_info->arr)
mvl_mod_arr_size (rt, wr_info->num_el);
/* First we need to initialize the ASN.1 encode tools, then do the */
/* encode */
asn1r_strt_asn1_bld (aCtx, asn1_dest_buffer, asn1_buffer_len);
#if defined(MVL_AA_SUPP)
if (wr_info->alt_acc_pres &&
wr_info->alt_acc_type_aa == SD_FALSE)
{
packed_save = m_alt_acc_packed;
m_alt_acc_packed = wr_info->alt_acc_data_packed;
rc = ms_local_to_asn1_aa (aCtx, rt, num_rt, wr_info->alt_acc,
(ST_CHAR *) wr_info->local_data);
m_alt_acc_packed = packed_save;
}
else
rc = ms_local_to_asn1 (aCtx, rt, num_rt, (ST_CHAR *) wr_info->local_data);
#else
rc = ms_local_to_asn1 (aCtx, rt, num_rt, (ST_CHAR *) wr_info->local_data);
#endif /* #if defined(MVL_AA_SUPP) */
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Get ASN1 Data : ms_local_to_asn1 failed, rc = %x", rc);
return (rc); /* bad type id */
}
/* When the ASN.1 encode is complete, 'asn1_field_ptr' points 1 byte ahead */
/* of the start of the message. The ASN.1 message is build from back to */
/* front, so that is now we calculate the length of the PDU */
asn1_start = aCtx->asn1r_field_ptr+1;
asn1_len = (asn1_dest_buffer + asn1_buffer_len) - asn1_start;
*asn1_len_out = asn1_len;
return (rc);
}
/************************************************************************/
/* _mvl_process_write_conf */
/************************************************************************/
ST_VOID _mvl_process_write_conf (MVL_REQ_PEND *req)
{
ST_INT i;
WRITE_RESP_INFO *write_info;
WRITE_RESULT *wr_rslt;
ST_INT num_variables;
MVL_WRITE_REQ_INFO *w_info;
write_info = (WRITE_RESP_INFO *) req->event->u.mms.dec_rslt.data_ptr;
wr_rslt = (WRITE_RESULT *) (write_info+1);
/* retrieve output information */
w_info = req->u.wr.w_info;
num_variables = req->u.wr.num_data;
/* just a sanity check */
if (num_variables != write_info->num_of_result)
{
req->result = SD_FAILURE;
return;
}
/* For each variable returned in the write response ... */
for (i=0; i < num_variables; i++, wr_rslt++, w_info++)
{ /* check for successful write of this variable */
if (wr_rslt->resp_tag == WR_RSLT_SUCCESS)
w_info->result = SD_SUCCESS;
else /* bad type ID */
w_info->result = SD_FAILURE;
} /* for each variable */
}

1177
mmslib/mvlu/mvl61850.c Normal file

File diff suppressed because it is too large Load Diff

811
mmslib/mvlu/mvl61850_ctl.c Normal file
View File

@@ -0,0 +1,811 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2004-2005, All Rights Reserved. */
/* */
/* PROPRIETARY AND CONFIDENTIAL */
/* */
/* MODULE NAME : mvl61850_ctl.c */
/* PRODUCT(S) : MMSEASE */
/* */
/* MODULE DESCRIPTION : */
/* IEC 61850 Control Model Server functions. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl61850_sbo_create_sboname */
/* mvl61850_ctl_chk_sbo */
/* mvl61850_ctl_chk_sbow */
/* mvl61850_ctl_chk_state */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 07/23/08 JRB 17 Fix creation of CntrlObj string again. */
/* Fix CntrlObj size (129 char) in TDL. */
/* Send AddCause=3(select-failed) if already selected*/
/* 07/02/08 JRB 16 Repl cmd_executing w/ ctlState (more flexible)*/
/* Make sure SBO name <= MVL61850_MAX_OBJREF_LEN.*/
/* Fix CntrlObj string. Del unused var. */
/* 05/14/08 JRB 15 mvl61850_ctl_req_done: first chk (va!=NULL). */
/* 05/08/08 JRB 14 Handle sboClass=operate-many. For sbo-with- */
/* enhanced-sec, don't unselect until CmdTerm. */
/* 05/08/08 JRB 13 mvl61850_ctl_chk_state: set LastApplError. */
/* 05/06/08 JRB 12 Don't allow re-select until after command or */
/* sboTimeout (use new getSboCtrl function). */
/* Set default Error/AddCause if not already set*/
/* 03/03/08 JRB 11 Add mvl61850_ctl_req_done & fix it to NOT send*/
/* LastApplError for Oper if normal security. */
/* Find and save sboClass to use later. */
/* 02/26/07 JRB 10 initSboCtrl: add use_ms_timer arg. */
/* 02/21/07 JRB 09 Fix comment. */
/* 11/21/06 JRB 08 Add mvl61850_ctl_lastapplerror_send. */
/* 10/30/06 JRB 07 Use new mvl_vmd_* object handling functions. */
/* Fix check that ALL of Oper and ONLY Oper is */
/* being written. */
/* 04/17/06 JRB 06 Do NOT create LastApplError var at startup, */
/* but create temporary var only when needed. */
/* 09/12/05 JRB 05 Add mvl61850_ctl_chk_sbow. */
/* Add NERR log if Loc$stVal==TRUE. */
/* Chk ctlModel before SBO read or SBOw write. */
/* 07/11/05 JRB 04 Add mvl61850_ctl_command_termination. */
/* Add mvl61850_ctl_lastapplerror_create. */
/* 03/28/05 JRB 03 Don't allow SBO read if Loc$stVal==TRUE. */
/* 01/27/05 JRB 02 Del unused variable. */
/* 12/10/04 JRB 01 New. Moved 61850 Control code from mvlu_sbo.c*/
/* to this module. */
/* Add mvl61850_ctl_chk_sbo, mvl61850_ctl_chk_state.*/
/* Del leaf funct mvl61850_sbo_select_rd_ind. */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mvl_uca.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* getSboCtrl */
/* RETURNS: pointer to a structure from the global pool "sbo_pool" */
/* (same pool used by "initSboCtrl" for UCA controls). */
/* NOTE: On error, this function returns NULL. If LastApplError!=NULL, */
/* it also sets the Error and AddCause members of LastApplError. */
/************************************************************************/
static MVL_SBO_CTRL *getSboCtrl (MVL_NET_INFO *net_info,
ST_CHAR *sbo_name,
ST_INT8 ctlModel,
ST_UINT32 sboTimeout,
ST_INT8 sboClass,
MVL61850_LAST_APPL_ERROR *LastApplError)
{
ST_INT i;
MVL_SBO_CTRL *sboCtrl;
/* Stop now if name is too long (strcpy later would not be safe). */
if (strlen (sbo_name) >= sizeof (sboCtrl->sbo_var))
{
/* should NEVER happen */
MVL_LOG_ERR1 ("Error finding IEC 61850 Control object '%s'. Name too long",sbo_name);
return (NULL);
}
/* See if the element is already selected. */
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_TRUE && !strcmp (sboCtrl->sbo_var, sbo_name))
{
/* Already selected. Do not allow re-select until after timeout. */
/* DEBUG: change this to use defines for Error and AddCause? */
if (LastApplError != NULL)
{
LastApplError->Error = 1; /* Unknown */
if (sboCtrl->ctlState > MVL61850_CTLSTATE_UNSELECTED)
LastApplError->AddCause = 12; /* Command-already-in-execution */
else
LastApplError->AddCause = 3; /* Select-failed */
}
return (NULL);
}
}
/* The protected element is not selected, find unused SBO control */
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_FALSE)
break;
}
if (i >= MAX_NUM_SBO_PEND)
{
if (LastApplError != NULL)
{
LastApplError->Error = 1; /* Unknown */
LastApplError->AddCause = 0; /* Unknown */
}
return (NULL);
}
/* Found available SBO control, set the parameters. */
memset (sboCtrl, 0, sizeof (MVL_SBO_CTRL)); /* start w/ clean struct*/
sboCtrl->in_use = SD_TRUE;
sboCtrl->use_ms_timer = SD_TRUE; /* ALWAYS "ms" timer for 61850 */
sboCtrl->expire_time_ms = sGetMsTime () + sboTimeout;
sboCtrl->net_info = net_info;
/* NOTE: sbo_name length checked above, so this strcpy is safe. */
strcpy (sboCtrl->sbo_var, sbo_name);
sboCtrl->ctlModel = ctlModel;
sboCtrl->sboClass = sboClass;
return (sboCtrl);
}
/************************************************************************/
/* mvl61850_sbo_create_sboname */
/* Creates a name to return when an IEC 61850 SBO attribute is read. */
/* sboName must point to buffer of at least [MVL61850_MAX_OBJREF_LEN+1] char*/
/* NOTE: this name may also be passed to "mvlu_sbo_chk_state" */
/* to find the correct MVL_SBO_CTRL struct. */
/************************************************************************/
ST_VOID mvl61850_sbo_create_sboname (MVL_VAR_ASSOC *va, MVL_SCOPE *va_scope,
ST_CHAR *sboName)
{
ST_CHAR *tmp_ptr; /* use to find last '$' in var name */
/* Create ObjectReference for this variable. */
if (mvl61850_objref_create (va->name, va_scope, sboName) != SD_SUCCESS)
{ /* should NEVER happen */
MVL_LOG_ERR0 ("Can't generate SBO ObjectReference");
sboName [0] = '\0'; /* return empty string */
return;
}
/* Replace end of var name with name of protected element (Oper). */
/* Var name may end with Oper, SBO, Cancel, etc. Replace with "Oper". */
/* This is a waste if it already ends with "Oper", but it takes more */
/* code to check. */
if ((tmp_ptr = strrchr (sboName, '$')) != NULL && /* find last '$'*/
tmp_ptr - sboName + 5 <= MVL61850_MAX_OBJREF_LEN) /* room for Oper*/
strcpy (tmp_ptr+1, "Oper"); /* Write name of protected element (Oper) AFTER it.*/
else
{ /* should NEVER happen */
MVL_LOG_ERR1 ("Can't generate SBO ObjectReference from '%s' (too long to replace last comp with 'Oper')", sboName);
sboName [0] = '\0'; /* return empty string */
}
}
/************************************************************************/
/* mvl61850_mkname_ctlmodel */
/* Generate the "flattened" name of the "ctlModel" attribute that */
/* corresponds to the attribute passed as "var_name" arg. */
/* The var_name arg should always be of the following form: */
/* LNodeName$CO$yyy$Oper */
/* LNodeName$CO$yyy$SBO, etc. */
/* This funct generates a name like this ("LNodeName$" stripped off): */
/* CF$yyy$ctlModel */
/************************************************************************/
ST_RET mvl61850_mkname_ctlmodel (ST_CHAR *var_name, ST_CHAR *flatname, size_t flatname_len)
{
ST_RET retcode = SD_FAILURE;
ST_CHAR *firstdollar; /* ptr to first '$' in var name */
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
ST_INT prefixlen; /* len of first half of generated string */
ST_CHAR *suffix = "ctlModel";
firstdollar = strchr (var_name, '$'); /* find first '$' */
lastdollar = strrchr (var_name, '$'); /* find last '$' */
if (firstdollar && lastdollar)
{
prefixlen = lastdollar - firstdollar;
if (prefixlen + strlen (suffix) <= flatname_len)
{
strcpy (flatname, firstdollar+1); /* Copy text after first '$'*/
strncpy (flatname, "CF", 2); /* Replace CO at start with CF */
strcpy (flatname + prefixlen, suffix); /* Write new suffix after last '$'*/
retcode = SD_SUCCESS;
}
}
return (retcode);
}
/************************************************************************/
/* mvl61850_mkname_sbotimeout */
/* Generate the "flattened" name of the "sboTimeout" attribute that */
/* corresponds to the attribute passed as "var_name" arg. */
/* The var_name arg should always be of the following form: */
/* LNodeName$CO$yyy$SBO */
/* This funct generates a name like this ("LNodeName$" stripped off): */
/* CF$yyy$sboTimeout */
/************************************************************************/
ST_RET mvl61850_mkname_sbotimeout (ST_CHAR *var_name, ST_CHAR *flatname, size_t flatname_len)
{
ST_CHAR *firstdollar; /* ptr to first '$' in var name */
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
ST_INT prefixlen; /* len of first half of generated string */
ST_CHAR *suffix = "sboTimeout"; /* replacement text to put after last '$'*/
ST_RET retcode = SD_FAILURE;
firstdollar = strchr (var_name, '$'); /* find first '$' */
lastdollar = strrchr (var_name, '$'); /* find last '$' */
if (firstdollar && lastdollar)
{
prefixlen = lastdollar - firstdollar;
if (prefixlen + strlen (suffix) <= flatname_len) /* room to replace*/
{
strcpy (flatname, firstdollar+1); /* Copy text after first '$'*/
strncpy (flatname, "CF", 2); /* Replace CO at start with CF */
strcpy (flatname + prefixlen, suffix); /* Write new suffix after last '$'*/
retcode = SD_SUCCESS;
}
}
return (retcode);
}
/************************************************************************/
/* mvl61850_mkname_sboclass */
/* Generate the "flattened" name of the "sboClass" attribute that */
/* corresponds to the attribute passed as "var_name" arg. */
/* The var_name arg should always be of the following form: */
/* LNodeName$CO$yyy$SBO */
/* This funct generates a name like this ("LNodeName$" stripped off): */
/* CF$yyy$sboClass */
/************************************************************************/
ST_RET mvl61850_mkname_sboclass (ST_CHAR *var_name, ST_CHAR *flatname, size_t flatname_len)
{
ST_CHAR *firstdollar; /* ptr to first '$' in var name */
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
ST_INT prefixlen; /* len of first half of generated string */
ST_CHAR *suffix = "sboClass"; /* replacement text to put after last '$'*/
ST_RET retcode = SD_FAILURE;
firstdollar = strchr (var_name, '$'); /* find first '$' */
lastdollar = strrchr (var_name, '$'); /* find last '$' */
if (firstdollar && lastdollar)
{
prefixlen = lastdollar - firstdollar;
if (prefixlen + strlen (suffix) <= flatname_len) /* room to replace*/
{
strcpy (flatname, firstdollar+1); /* Copy text after first '$'*/
strncpy (flatname, "CF", 2); /* Replace CO at start with CF */
strcpy (flatname + prefixlen, suffix); /* Write new suffix after last '$'*/
retcode = SD_SUCCESS;
}
}
return (retcode);
}
/************************************************************************/
/* mvl61850_sboclass_find */
/* Find the corresponding 'sboClass' attribute for this variable and */
/* read its current value. */
/************************************************************************/
static ST_INT8 mvl61850_sboclass_find (MVL_VAR_ASSOC *va)
{
ST_CHAR sboClassName [MAX_IDENT_LEN+1]; /* "CF$...$sboClass" */
ST_INT8 sboClass;
if (mvl61850_mkname_sboclass (va->name, sboClassName, MAX_IDENT_LEN) != SD_SUCCESS ||
mvlu_get_leaf_val_int8 (va->base_va, sboClassName, &sboClass) != SD_SUCCESS)
sboClass = MVL61850_SBOCLASS_OPERATE_ONCE; /* set default value */
return (sboClass);
}
/************************************************************************/
/* mvl61850_ctl_chk_sbo */
/* This function should be called from "leaf" function when IEC 61850 */
/* "SBO" attribute is being read (i.e. performing Control Model 'Select'*/
/* Service). It checks if client is allowed to perform 'Select'. */
/* If 'Select' allowed, it reserves a MVL_SBO_CTRL struct and returns */
/* a ptr to it. */
/* RETURNS: ptr to struct if successful (sbo_var member of struct */
/* contains name to send in read response). */
/* NULL if failed. */
/* CRITICAL: if return is NOT NULL & caller decides not to allow */
/* 'Select', must pass this ptr to mvlu_sbo_ctrl_free. */
/************************************************************************/
MVL_SBO_CTRL *mvl61850_ctl_chk_sbo (MVLU_RD_VA_CTRL *mvluRdVaCtrl)
{
MVL_VAR_ASSOC *va;
ST_CHAR sboName[MVL61850_MAX_OBJREF_LEN+1];
MVL_SBO_CTRL *sboCtrl = NULL;
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
/* Init sboTimeout=0. If ..$CF$..$sboTimeout==0, or not found, set to default val.*/
ST_UINT32 sboTimeout = 0; /* SBO timeout value. */
ST_CHAR sboTimeoutName [MAX_IDENT_LEN+1]; /* "CF$...$sboTimeout" */
ST_BOOLEAN loc_stval;
ST_INT8 sboClass;
/* First take care of timeout housekeeping */
mvlu_sbo_chk_timers ();
/* find the name of the attribute being selected */
va = mvluRdVaCtrl->rdVaCtrl->va;
/* Check value of "ST$Loc$stVal". */
if (mvlu_get_leaf_val_boolean (va->base_va, "ST$Loc$stVal", &loc_stval)!=SD_SUCCESS)
loc_stval = SD_FALSE; /* if can't read ST$Loc$stVal, assume FALSE*/
if (loc_stval)
{
MVL_LOG_NERR1 ("Reading of '%s' not allowed: Local mode is set.", va->name);
return (NULL); /* error return */
}
/* Only perform "Select" if SBO is ONLY attribute being read. */
/* Check this by seeing if variable name ends with "$SBO". */
/* Point to where "$SBO" should be, then see if it's there. */
lastdollar = strrchr (va->name, '$'); /* find last '$' */
if (lastdollar != NULL && strcmp (lastdollar+1, "SBO") == 0)
{
ST_INT8 ctlModel;
ST_CHAR flatname [MAX_IDENT_LEN + 1]; /* attribute to find */
/* Generate "ctlModel" leaf name and try to read its value. */
/* CRITICAL: this only works if va->name checked first (i.e. it ends in "$SBO")*/
if (mvl61850_mkname_ctlmodel (va->name, flatname, MAX_IDENT_LEN) != SD_SUCCESS
|| mvlu_get_leaf_val_int8 (va->base_va, flatname, &ctlModel) != SD_SUCCESS)
ctlModel = MVL61850_CTLMODEL_STATUS_ONLY; /* can't read ctlModel. assume status-only*/
if (ctlModel != MVL61850_CTLMODEL_SBO_NORMAL)
{
MVL_LOG_NERR3 ("Reading of '%s' not allowed: ctlModel=%d, expected ctlModel=%d (sbo-with-normal-security)",
va->name, ctlModel, MVL61850_CTLMODEL_SBO_NORMAL);
return (NULL); /* error return */
}
/* Create sboName from var name. */
//mvl61850_sbo_create_sboname (va, &mvluRdVaCtrl->rdVaCtrl->va_scope, sboName);//lnk<6E><6B><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ԭǰ<D4AD>ó<EFBFBD><C3B3><EFBFBD>δʹ<CEB4><CAB9>
/* Find "sboTimeout" value. */
if (mvl61850_mkname_sbotimeout (va->name, sboTimeoutName, MAX_IDENT_LEN) != SD_SUCCESS ||
mvlu_get_leaf_val_uint32 (va->base_va, sboTimeoutName, &sboTimeout) != SD_SUCCESS ||
sboTimeout==0) /* ..$CF$..$sboTimeout==0, or not found */
sboTimeout = SBO_SELECT_TIMEOUT; /* set timeout to default val */
/* Find "sboClass" value. */
sboClass = mvl61850_sboclass_find (va);
/* Get a SBO control element */
sboCtrl = getSboCtrl (mvluRdVaCtrl->indCtrl->event->net_info,sboName,
ctlModel, sboTimeout, sboClass,
NULL); /* LastApplError not used*/
}
return (sboCtrl);
}
/************************************************************************/
/* mvl61850_ctl_chk_sbow */
/* This function should be called from "leaf" function when IEC 61850 */
/* an attribute inside the "SBOw" structure is being written */
/* (i.e. performing Control Model 'Select' Service for */
/* sbo-with-enhanced-security). */
/* It checks if client is allowed to perform 'Select'. */
/* If 'Select' allowed, it reserves a MVL_SBO_CTRL struct and returns */
/* a ptr to it. */
/* RETURNS: ptr to struct if successful (sbo_var member of struct */
/* contains name to send in read response). */
/* NULL if failed. */
/* CRITICAL: if return is NOT NULL & caller decides not to allow */
/* 'Select', caller must pass this ptr to mvlu_sbo_ctrl_free. */
/* NOTE: this is very similar to mvl61850_ctl_chk_sbo, but it is used */
/* when writing "SBOw" instead of when reading "SBO". */
/************************************************************************/
MVL_SBO_CTRL *mvl61850_ctl_chk_sbow (MVLU_WR_VA_CTRL *mvluWrVaCtrl)
{
MVL_VAR_ASSOC *va;
ST_CHAR sboName[MVL61850_MAX_OBJREF_LEN+1];
MVL_SBO_CTRL *sboCtrl = NULL;
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
/* Init sboTimeout=0. If ..$CF$..$sboTimeout==0, or not found, set to default val.*/
ST_UINT32 sboTimeout = 0; /* SBO timeout value. */
ST_CHAR sboTimeoutName [MAX_IDENT_LEN+1]; /* "CF$...$sboTimeout" */
ST_BOOLEAN loc_stval;
ST_INT8 sboClass;
/* First take care of timeout housekeeping */
mvlu_sbo_chk_timers ();
va = mvluWrVaCtrl->wrVaCtrl->va;
/* Check value of "ST$Loc$stVal". */
if (mvlu_get_leaf_val_boolean (va->base_va, "ST$Loc$stVal", &loc_stval)!=SD_SUCCESS)
{
loc_stval = SD_FALSE; /* if can't read ST$Loc$stVal, assume FALSE*/
}
if (loc_stval)
{
/* renxiaobao <20><><EFBFBD><EFBFBD>*/
mvluWrVaCtrl->wrVaCtrl->LastApplError.Error = 1; /* Unknown */
mvluWrVaCtrl->wrVaCtrl->LastApplError.AddCause = Blocked_CB; /* Blocked-by-switching-hierarchy */
MVL_LOG_NERR1 ("Writing of '%s' not allowed: Local mode is set.", va->name);
return (NULL); /* error return */
}
/* Only perform "Select" if entire SBOw is written & nothing else.*/
/* Check this by seeing if variable name ends with "$SBOw". */
/* Point to where "$SBOw" should be, then see if it's there. */
lastdollar = strrchr (va->name, '$'); /* find last '$' */
if (lastdollar != NULL && strcmp (lastdollar+1, "SBOw") == 0)
{
ST_INT8 ctlModel;
ST_CHAR flatname [MAX_IDENT_LEN + 1]; /* attribute to find */
/* Generate "ctlModel" leaf name and try to read its value. */
/* CRITICAL: this only works if va->name checked first (i.e. it ends in "$SBOw")*/
if (mvl61850_mkname_ctlmodel (va->name, flatname, MAX_IDENT_LEN) != SD_SUCCESS
|| mvlu_get_leaf_val_int8 (va->base_va, flatname, &ctlModel) != SD_SUCCESS)
{
ctlModel = MVL61850_CTLMODEL_STATUS_ONLY; /* can't read ctlModel. assume status-only*/
}
/*renxiaobao <20><><EFBFBD><EFBFBD>
// if (ctlModel != MVL61850_CTLMODEL_SBO_ENHANCED)*/
if ((ctlModel != MVL61850_CTLMODEL_SBO_ENHANCED)&&(ctlModel != MVL61850_CTLMODEL_SBO_NORMAL))
{
/* renxiaobao <20><><EFBFBD><EFBFBD>*/
mvluWrVaCtrl->wrVaCtrl->LastApplError.Error = 1; /* Unknown */
mvluWrVaCtrl->wrVaCtrl->LastApplError.AddCause = Blocked_by_Mode; /* Blocked-by-Mode */
MVL_LOG_NERR3 ("Writing of '%s' not allowed: ctlModel=%d, expected ctlModel=%d (sbo-with-enhanced-security)",
va->name, ctlModel, MVL61850_CTLMODEL_SBO_ENHANCED);
return (NULL);
}
/* Create sboName from var name. */
/* NOTE: the sboName is not really used for "SBOw", but the "initSboCtrl"*/
/* function (originally written only for "SBO") needs it. */
//mvl61850_sbo_create_sboname (va, &mvluWrVaCtrl->wrVaCtrl->va_scope, sboName);//lnk<6E><6B><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ԭǰ<D4AD>ó<EFBFBD><C3B3><EFBFBD>δʹ<CEB4><CAB9>
/* Find "sboTimeout" value. */
if (mvl61850_mkname_sbotimeout (va->name, sboTimeoutName, MAX_IDENT_LEN) != SD_SUCCESS ||
mvlu_get_leaf_val_uint32 (va->base_va, sboTimeoutName, &sboTimeout) != SD_SUCCESS ||
sboTimeout==0) /* ..$CF$..$sboTimeout==0, or not found */
{
/*renxiaobao <20><><EFBFBD><EFBFBD>*/
sboTimeout = SBO_SELECT_TIMEOUT*1000; /* set timeout to default val */
}
/* Find "sboClass" value. */
sboClass = mvl61850_sboclass_find (va);
/* Get a SBO control element */
sboCtrl = getSboCtrl (mvluWrVaCtrl->indCtrl->event->net_info, sboName,
ctlModel, sboTimeout, sboClass,
&mvluWrVaCtrl->wrVaCtrl->LastApplError);
}
return (sboCtrl);
}
/************************************************************************/
/* mvl61850_ctl_chk_state */
/* Check ctlModel, etc. to determine if control is right type & */
/* in right state. */
/* RETURNS: SD_SUCCESS if OK to perform Operate command. */
/* SD_FAILURE if NOT OK (also sets appropriate Error and */
/* AddCause members of LastApplError). */
/************************************************************************/
ST_RET mvl61850_ctl_chk_state (MVLU_WR_VA_CTRL *mvluWrVaCtrl)
{
MVL_VAR_ASSOC *base_var = mvluWrVaCtrl->wrVaCtrl->va->base_va;
ST_INT8 ctlModel;
ST_BOOLEAN loc_stval;
ST_CHAR flatname [MAX_IDENT_LEN + 1]; /* attribute to find */
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
MVL61850_LAST_APPL_ERROR *LastApplError;
/* renxiaobao 5.3<EFBFBD><EFBFBD>޸<EFBFBD>*/
/* Send this DAE in the MMS Write response on any error. If the Write */
/* succeeds, this value is ignored (i.e. not sent). */
mvluWrVaCtrl->wrVaCtrl->failure = ARE_OBJ_ACCESS_DENIED;
LastApplError = &mvluWrVaCtrl->wrVaCtrl->LastApplError;
/* Only allow "Operate" if writing ALL of "Oper" and ONLY "Oper". */
/* Check this by seeing if variable name ends with "$Oper". */
/* Point to where "$Oper" should be, then see if it's there. */
lastdollar = strrchr (mvluWrVaCtrl->wrVaCtrl->va->name, '$'); /* find last '$'*/
if (lastdollar == NULL || strcmp (lastdollar+1, "Oper") != 0)
{
/* LastApplError not sent in this case, so don't bother setting it. */
return (SD_FAILURE); /* ERROR: not writing ALL of Oper and ONLY Oper.*/
}
/* Check value of "ST$Loc$stVal". */
if (mvlu_get_leaf_val_boolean (base_var, "ST$Loc$stVal", &loc_stval)!=SD_SUCCESS)
{
loc_stval = SD_FALSE; /* if can't read ST$Loc$stVal, assume FALSE*/
}
if (loc_stval == SD_FALSE)
{
/* Generate "ctlModel" leaf name and try to read its value. */
if (mvl61850_mkname_ctlmodel (mvluWrVaCtrl->wrVaCtrl->va->name, flatname, MAX_IDENT_LEN) != SD_SUCCESS
|| mvlu_get_leaf_val_int8 (base_var, flatname, &ctlModel) != SD_SUCCESS)
{
ctlModel = MVL61850_CTLMODEL_STATUS_ONLY; /* can't read ctlModel. assume status-only*/
}
if (ctlModel == MVL61850_CTLMODEL_DIRECT_NORMAL||ctlModel == MVL61850_CTLMODEL_DIRECT_ENHANCED)
{
/* This is Direct control. */
/* OK. Nothing else to check. Continue to successful return. */
}
else if (ctlModel == MVL61850_CTLMODEL_SBO_NORMAL||ctlModel == MVL61850_CTLMODEL_SBO_ENHANCED)
{
/* This is SBO control. */
/* Chk sboCtrl (set by startElWrites if client writing "Oper"). */
if (!mvluWrVaCtrl->wrVaCtrl->sboCtrl)
{
LastApplError->Error = 1; /* Unknown*/
LastApplError->AddCause = 3; /* Select-failed*/
return (SD_FAILURE);
}
}
else
{
/* ctlModel="status-only" or invalid. */
LastApplError->Error = 1; /* Unknown*/
LastApplError->AddCause = 8; /* Blocked-by-mode*/
return (SD_FAILURE);
}
} /* end "if (loc_stval == SD_FALSE)" (i.e. "remote" mode) */
else
{ /* loc_stval == SD_TRUE (i.e. "local" mode) */
LastApplError->Error = 1; /* Unknown*/
LastApplError->AddCause = 8; /* Blocked-by-mode*/
return (SD_FAILURE);
}
/* Passed all checks. Allow the control operation. */
return (SD_SUCCESS);
}
/************************************************************************/
/* mvl61850_ctl_command_termination */
/* Called by user to send "Command Termination" request for controls */
/* with "Enhanced Security". */
/************************************************************************/
ST_RET mvl61850_ctl_command_termination (MVL_NET_INFO *net_info, ST_CHAR *oper_ref,
ST_RET status, MVL61850_LAST_APPL_ERROR *last_appl_error)
{
OBJECT_NAME nvl_obj; /* NVL object name */
MVL_NVLIST_CTRL *nvlist_ctrl;
ST_INT num_var;
OBJECT_NAME var_obj[2]; /* array of var object names (1 or 2 depending on status)*/
MVL_VAR_ASSOC *last_appl_var = NULL; /* var assoc for "LastApplError"*/
ST_RET ret;
ST_CHAR oper_ref_local[MAX_IDENT_LEN+1]; /* local copy of oper_ref arg */
MVL_SBO_CTRL *sboCtrl; /* ptr to SBO control if this is SBO */
ret = SD_SUCCESS; /* assume success */
/* Create tmp NVL used only for building this rpt. */
nvl_obj.object_tag = VMD_SPEC;
nvl_obj.obj_name.vmd_spec = "tmp_nvl_for_rpt";
/* Fill in var_obj array. */
num_var = 0;
if (status != SD_SUCCESS)
{ /* On error, include "LastApplError" in report. */
ST_INT type_id;
/* Create temporary VMD_SPEC "LastApplError" variable. */
/* If this fails, mvl_vmd_nvl_add will also fail later. */
type_id = mvl_typename_to_typeid ("LastApplErrorType");
if (type_id >= 0)
{
var_obj[num_var].object_tag = VMD_SPEC;
var_obj[num_var].obj_name.vmd_spec = "LastApplError";
/* NOTE: last_appl_error points to temporary data. This var must be deleted before returning*/
last_appl_var = mvl_vmd_var_add (&mvl_vmd, &var_obj[num_var],
NULL, /* (MVL_NET_INFO *) */
type_id,
last_appl_error, /* data ptr (saved in var->data) */
NULL, /* (MVL_VAR_PROC *) */
SD_FALSE); /* DO NOT copy the var name */
}
num_var++;
}
/* Add this control object (LN$FC$xxx$Oper) to "var_obj". */
var_obj[num_var].object_tag = DOM_SPEC; /* ALWAYS Domain specific*/
/* strtok modifies input buffer, so copy oper_ref to local buffer first. */
strcpy (oper_ref_local, oper_ref);
var_obj[num_var].domain_id = strtok (oper_ref_local, "/"); /*extract dom name*/
var_obj[num_var].obj_name.vmd_spec = strtok (NULL, "");
if (var_obj[num_var].obj_name.vmd_spec == NULL)
{
MVL_LOG_ERR1 ("Invalid ControlObjectReference '%s', cannot send CommandTermination", oper_ref);
ret = SD_FAILURE;
}
else
{
num_var++;
nvlist_ctrl = mvl_vmd_nvl_add (&mvl_vmd, &nvl_obj, NULL, /* net_info: not needed*/
num_var, var_obj, SD_TRUE); /* copy name */
/* Now send report */
if (nvlist_ctrl)
{
ret = mvl_info_variables (net_info, nvlist_ctrl, SD_TRUE); /* listOfVariables*/
mvl_vmd_nvl_remove (&mvl_vmd, &nvl_obj, NULL); /* done with tmp NVL */
}
else
ret = SD_FAILURE;
}
/* If temporary "LastApplError" var created, destroy it now. */
if (last_appl_var)
mvl_vmd_var_remove (&mvl_vmd, &var_obj[0], NULL); /* always first in "var_obj" array*/
sboCtrl = mvlu_sbo_chk_state (oper_ref, net_info);
if (sboCtrl != NULL
&& sboCtrl->ctlModel == MVL61850_CTLMODEL_SBO_ENHANCED)
{
/* ctlModel=sbo-with-enhanced-security. If sboClass=operate-once, */
/* "unselect" now (i.e. free sboCtrl), else go back to READY state. */
if (sboCtrl->sboClass == MVL61850_SBOCLASS_OPERATE_ONCE)
mvlu_sbo_ctrl_free (sboCtrl); /* like "UNSELECTED" state*/
else
sboCtrl->ctlState = MVL61850_CTLSTATE_READY;
}
return (ret);
}
/************************************************************************/
/* mvl61850_ctl_lastapplerror_create */
/* Create type to use later when "temporary" LastApplError var created. */
/************************************************************************/
ST_RET mvl61850_ctl_lastapplerror_create ()
{
ST_RET retcode = SD_SUCCESS;
ST_CHAR *LastApplErrorTdl = "{\
(CntrlObj)Vstring129,\
(Error)Byte,\
(Origin){(orCat)Byte,(orIdent)OVstring64},\
(ctlNum)Ubyte,\
(AddCause)Byte}";
/* Maybe this type was already created. If it does NOT exist, create it.*/
if (mvl_typename_to_typeid ("LastApplErrorType") < 0)
{
if (mvl_type_id_create_from_tdl ("LastApplErrorType",LastApplErrorTdl) < 0)
retcode = SD_FAILURE; /* create failed */
}
return (retcode);
}
/************************************************************************/
/* mvl61850_ctl_lastapplerror_send */
/* Called by user to send "LastApplError" information report. */
/************************************************************************/
ST_RET mvl61850_ctl_lastapplerror_send (MVL_NET_INFO *net_info,
MVL61850_LAST_APPL_ERROR *last_appl_error)
{
OBJECT_NAME nvl_obj; /* NVL object name */
MVL_NVLIST_CTRL *nvlist_ctrl;
ST_INT num_var;
OBJECT_NAME var_obj; /* temporary var object name */
MVL_VAR_ASSOC *last_appl_var = NULL; /* var assoc for "LastApplError"*/
ST_RET ret;
ST_INT type_id;
ret = SD_SUCCESS; /* assume success */
/* Create tmp NVL used only for building this rpt. */
nvl_obj.object_tag = VMD_SPEC;
nvl_obj.obj_name.vmd_spec = "tmp_nvl_for_rpt";
/* Fill in var_obj. */
num_var = 1;
/* Create temporary VMD_SPEC "LastApplError" variable. */
/* If this fails, mvl_vmd_nvl_add will also fail later. */
type_id = mvl_typename_to_typeid ("LastApplErrorType");
if (type_id >= 0)
{
var_obj.object_tag = VMD_SPEC;
var_obj.obj_name.vmd_spec = "LastApplError";
/* NOTE: last_appl_error points to temporary data. This var must be deleted before returning*/
last_appl_var = mvl_vmd_var_add (&mvl_vmd, &var_obj,
NULL, /* (MVL_NET_INFO *) */
type_id,
last_appl_error, /* data ptr (saved in var->data) */
NULL, /* (MVL_VAR_PROC *) */
SD_FALSE); /* DO NOT copy the var name */
nvlist_ctrl = mvl_vmd_nvl_add (&mvl_vmd, &nvl_obj, NULL, /* net_info: not needed*/
num_var, &var_obj, SD_TRUE); /* copy name */
/* Now send report */
if (nvlist_ctrl)
{
ret = mvl_info_variables (net_info, nvlist_ctrl, SD_TRUE); /* listOfVariables*/
mvl_vmd_nvl_remove (&mvl_vmd, &nvl_obj, NULL); /* done with tmp NVL */
}
else
ret = SD_FAILURE;
}
else
ret = SD_FAILURE;
/* If temporary "LastApplError" var created, destroy it now. */
if (last_appl_var)
mvl_vmd_var_remove (&mvl_vmd, &var_obj, NULL);
if (ret != SD_SUCCESS)
MVL_LOG_ERR0 ("Error sending LastApplError");
return (ret);
}
/************************************************************************/
/* mvl61850_ctl_req_done */
/* Do some necessary cleanup IF the MMS Write request represents an IEC */
/* 61850 control request. */
/* NOTE: For any other MMS Write request, this function does nothing. */
/************************************************************************/
ST_VOID mvl61850_ctl_req_done (MVLAS_WR_VA_CTRL *wrVaCtrl, MVL_NET_INFO *net_info)
{
ST_INT8 ctlModel;
ST_BOOLEAN send_lastappl = SD_FALSE;
ST_CHAR flatname [MAX_IDENT_LEN+1];
ST_CHAR *lastdollar; /* ptr to last '$' in variable name */
MVL_SBO_CTRL *sboCtrl; /* ptr to SBO control if this is SBO */
/* CRITICAL: make sure variable was found before doing anything else. */
if (wrVaCtrl->va == NULL)
return; /* var not found. Do nothing. */
lastdollar = strrchr (wrVaCtrl->va->name, '$'); /* find last '$'*/
/* If Write failed, and Var is IEC 61850 Oper, Cancel, or SBOw, */
/* must also send InformationReport containing LastApplError. */
if (wrVaCtrl->resp_tag == WR_RSLT_FAILURE)
{
/* Var name must end in $Oper, $Cancel, or $SBOw. */
if (lastdollar != NULL)
{
/* Send LastApplError if writing Cancel or SBOw. */
if (strcmp (lastdollar+1, "Cancel") == 0 ||
strcmp (lastdollar+1, "SBOw") == 0)
send_lastappl = SD_TRUE;
/* Send LastApplError if writing Oper AND Enhanced security. */
else if (strcmp (lastdollar+1, "Oper") == 0)
{
/* Generate "ctlModel" leaf name like "CF$...$ctlModel" from */
/* variable name "...$Oper" and try to read its value. */
if (mvl61850_mkname_ctlmodel (wrVaCtrl->va->name, flatname, MAX_IDENT_LEN) != SD_SUCCESS
|| mvlu_get_leaf_val_int8 (wrVaCtrl->va->base_va, flatname, &ctlModel) != SD_SUCCESS)
ctlModel = MVL61850_CTLMODEL_STATUS_ONLY; /* can't read ctlModel. assume status-only*/
/*renxiaobao <20><><EFBFBD><EFBFBD>
//if (ctlModel == MVL61850_CTLMODEL_DIRECT_ENHANCED ||
// ctlModel == MVL61850_CTLMODEL_SBO_ENHANCED) */
send_lastappl = SD_TRUE;
}
if (send_lastappl)
{
/* Construct & send LastApplError info report.*/
/* Fill in "LastApplError" structure. */
/* This function builds a string in "CntrlObj". */
/* If it fails, the string is empty. */
#if 1
mvl61850_objref_create (wrVaCtrl->va->name, &wrVaCtrl->va_scope, wrVaCtrl->LastApplError.CntrlObj);
#else /* OLD WAY (similar but CntrlObj always ended in '$Oper'). */
//mvl61850_sbo_create_sboname (wrVaCtrl->va, &wrVaCtrl->va_scope, wrVaCtrl->LastApplError.CntrlObj);//lnk<6E><6B><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ԭǰ<D4AD>ó<EFBFBD><C3B3><EFBFBD>δʹ<CEB4><CAB9>
#endif
/* Other members (Error, AddCause, Origin, ctlNum) already set by leaf functions.*/
/* If Error/AddCause not set yet, set default values. */
if (wrVaCtrl->LastApplError.Error == 0)
{
wrVaCtrl->LastApplError.Error = 1; /* Unknown */
wrVaCtrl->LastApplError.AddCause = 0; /* Unknown */
}
mvl61850_ctl_lastapplerror_send (net_info, &wrVaCtrl->LastApplError);
}
}
}
/* Do special cleanup for IEC 61850 SBO controls. */
/* If wrVaCtrl->sboCtrl != NULL, this var is SBO Oper or Cancel */
/* (see startElWrites), so do appropriate SBO cleanup. */
/* If this is a Cancel request, or if ctlModel=sbo-with-normal-security*/
/* AND sboClass=operate-once, we must "unselect" the control */
/* (i.e. free "sboCtrl"). */
sboCtrl = wrVaCtrl->sboCtrl;
if (sboCtrl != NULL)
{
if (strcmp (lastdollar+1, "Cancel") == 0
|| (sboCtrl->ctlModel == MVL61850_CTLMODEL_SBO_NORMAL
&& sboCtrl->sboClass == MVL61850_SBOCLASS_OPERATE_ONCE) )
{
/* NOTE: for sbo-with-enhanced-security, this is done AFTER CommandTerm.*/
mvlu_sbo_ctrl_free (sboCtrl);
wrVaCtrl->sboCtrl = NULL; /* reset this so free not done twice.*/
}
}
}

1367
mmslib/mvlu/mvl61850_rpt.c Normal file

File diff suppressed because it is too large Load Diff

24
mmslib/mvlu/mvl_buf.c Normal file
View File

@@ -0,0 +1,24 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1997, All Rights Reserved */
/* */
/* MODULE NAME : mvl_buf.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/23/99 MDE 04 Deleted contents, file is obsolete */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
/* OBSOLETE FILE */

532
mmslib/mvlu/mvl_dtyp.c Normal file
View File

@@ -0,0 +1,532 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2005, All Rights Reserved */
/* */
/* MODULE NAME : mvl_dtyp.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 01/19/05 JRB 08 Use mvlu_trim_branch_name from mvl_uca.c */
/* 12/19/02 JRB 07 Use ms_comp_name_find, ms_comp_name_pres. */
/* 11/19/02 RKR 06 Corrected size in cardinality function */
/* 02/27/02 JRB 05 Del unneeded prototypes & includes. */
/* 12/04/01 RKR 04 ported to QNX cleaned up errors and warnings */
/* 11/09/01 RKR 03 resorted the num_rt_blks */
/* 01/21/00 MDE 02 Now use MEM_SMEM for dynamic memory */
/* 10/05/99 RKR 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mms_pvmd.h"
#include "mms_err.h"
#include "mms_pcon.h"
#include "mvl_log.h"
#include "mvl_defs.h"
#include "mvl_uca.h" /* need mvlu_trim_branch_name */
#include "asn1defs.h"
#include "stime.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
static ST_UCHAR *create_bitstring (ST_INT num);
static ST_VOID set_bit ( ST_UCHAR *bptr, ST_INT i);
static ST_BOOLEAN ismember( ST_UCHAR *bptr,
ST_INT n);
static ST_VOID reSortRT (RUNTIME_TYPE *rt, ST_INT numRt);
static ST_VOID add_to_branch_name (ST_CHAR *branch_name, SD_CONST ST_CHAR *SD_CONST sub_branch_name);
static ST_INT cardinality (ST_UCHAR *bptr, ST_INT size);
static ST_VOID calc_offset_to_last (RUNTIME_TYPE *rt);
ST_VOID mvl_print_type( ST_CHAR *base_name, ST_INT typeIdIn);
#ifndef __ECOS
ST_BOOLEAN u_mvl_rt_element_supported (RUNTIME_TYPE *rt,
ST_CHAR *element_name,
ST_RTREF *ui, ST_CHAR *handle);
#endif
ST_VOID adjRtBlks( RUNTIME_TYPE *derived_type_table, ST_INT derived_count);
/************************************************************************/
/* mvl_derive_new_type */
/************************************************************************/
ST_RET mvl_derive_new_type (ST_CHAR *base_name, ST_INT typeIdIn, ST_INT *typeIdOut, ST_CHAR *handle)
{
ST_RET ret;
ST_RTREF rtrefs;
ST_UCHAR *membership;
ret = mvl_derive_type_members (base_name, typeIdIn, &membership, &rtrefs, handle );
mvl_print_derived_type (base_name, typeIdIn, membership, rtrefs);
ret = mvl_add_derived_type (base_name, typeIdIn, membership, rtrefs, typeIdOut);
return (ret);
}
/************************************************************************/
/* mvl_derive_type_members */
/************************************************************************/
ST_RET mvl_derive_type_members (ST_CHAR *base_name, ST_INT typeIdIn,
ST_UCHAR **membership, ST_RTREF *rtrefs, ST_CHAR *handle)
{
ST_RET ret = SD_FAILURE;
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_BOOLEAN exists;
ST_CHAR element_name[MAX_IDENT_LEN+1];
ST_CHAR branch_name[MAX_IDENT_LEN+1];
ST_RTREF *user_info;
ST_INT i;
ST_RTREF ui; /* let the user pass back widget of unknown purpose */
ST_UCHAR *bptr;
ret = mvl_get_runtime (typeIdIn, &rt, &num_rt);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("TypeId %d not found",typeIdIn);
return (ret);
}
bptr = create_bitstring (num_rt);
*membership = bptr;
user_info = (ST_RTREF *) M_CALLOC (MSMEM_GEN, num_rt, sizeof(ST_RTREF *));
*rtrefs = user_info;
for (i=0; i<num_rt; i++)
{
exists = SD_FALSE;
if ((rt[i].el_tag == RT_STR_START) && (ms_comp_name_pres(&rt[i])))
{
add_to_branch_name (branch_name, ms_comp_name_find(&rt[i]));
strcpy (element_name, branch_name);
}
else
{
if (ms_comp_name_pres(&rt[i]))
sprintf (element_name, "%s$%s", branch_name, ms_comp_name_find(&rt[i]));
else
{
if (i==0) /* This is the start of the entire RuntimeType */
{
strcpy (branch_name, base_name);
strcpy (element_name, branch_name);
}
else
element_name[0]=0; /* nobody home */
}
}
if (rt[i].el_tag == RT_STR_END)
{
strcpy( element_name, branch_name);
mvlu_trim_branch_name (branch_name);
}
ui = rt[i].mvluTypeInfo.ref;
#ifndef __ECOS
exists = u_mvl_rt_element_supported(&rt[i], element_name, &ui, handle);
#endif
if (exists)
{
set_bit (bptr, i);
user_info[i] = ui;
}
}
return (ret);
}
/************************************************************************/
/* mvl_add_derived_type */
/************************************************************************/
ST_RET mvl_add_derived_type( ST_CHAR *base_name, ST_INT typeIdIn,
ST_UCHAR *membership, ST_RTREF *rtrefs,
ST_INT *typeIdOut)
{
ST_RET ret;
ST_INT derived_elements;
RUNTIME_TYPE *derived_type_table;
ST_INT derived_count;
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_INT i;
ret = mvl_get_runtime (typeIdIn, &rt, &num_rt);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("TypeId %d not found",typeIdIn);
return (ret);
}
/* count how many elements are in the new type */
derived_elements = cardinality( membership, num_rt);
/* allocate a new RT type table about that large */
derived_type_table = (RUNTIME_TYPE *)M_CALLOC (MSMEM_GEN, derived_elements,
sizeof(RUNTIME_TYPE));
/* copy the elements marked as members of the new type into the new */
/* RT type table */
derived_count = 0;
for(i=0; i<num_rt; i++)
{
if (ismember (membership, i))
{
memcpy (&derived_type_table[derived_count], &rt[i], sizeof(RUNTIME_TYPE));
derived_type_table[derived_count].mvluTypeInfo.ref = rtrefs[i];
derived_count++;
}
}
M_FREE (MSMEM_GEN, membership);
M_FREE (MSMEM_GEN, rtrefs);
/* fix up the offsets. */
for (i=0; i<derived_count; i++)
{
calc_offset_to_last(&derived_type_table[i]);
}
/* fix up the number of RuntimeBlocks contained in arrays and structures */
adjRtBlks(derived_type_table,derived_count);
/* resort the UCA names so GNL will return sorted strings */
reSortRT (derived_type_table, derived_count);
/* we get to finally add a MVL type! */
ret = mvlu_add_rt_type (derived_type_table, derived_count, typeIdOut);
/*mvl_print_type (base_name, *typeIdOut);*/
return (ret);
}
/************************************************************************/
/* mvl_print_type */
/************************************************************************/
#if 0
ST_VOID mvl_print_type( ST_CHAR *base_name, ST_INT typeIdIn)
{
ST_RET ret;
ST_INT i;
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_CHAR element_name[MAX_IDENT_LEN+1];
ST_CHAR branch_name[MAX_IDENT_LEN+1];
ret = mvl_get_runtime (typeIdIn, &rt, &num_rt);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("TypeId %d not found",typeIdIn);
}
for (i=0; i<num_rt; i++)
{
if ((rt[i].el_tag == RT_STR_START) && (ms_comp_name_pres(&rt[i])))
{
add_to_branch_name (branch_name, ms_comp_name_find(&rt[i]));
strcpy( element_name, branch_name);
}
else
{
if (ms_comp_name_pres(&rt[i]))
sprintf( element_name, "%s$%s", branch_name, ms_comp_name_find(&rt[i]));
else
{
if ( i==0 ) /* This is the start of the entire RuntimeType */
{
strcpy( branch_name, base_name);
strcpy( element_name, branch_name);
}
else
element_name[0]=0; /* nobody home */
}
}
if (rt[i].el_tag == RT_STR_END)
{
strcpy( element_name, branch_name);
mvlu_trim_branch_name (branch_name);
}
_slogc (sLogCtrl,"RT %d '%s' - sortedNum %d",
i,element_name,rt[i].mvluTypeInfo.sortedNum);
}
}
#endif
/************************************************************************/
/* mvl_print_derived_type */
/************************************************************************/
ST_VOID mvl_print_derived_type( ST_CHAR *base_name, ST_INT typeIdIn,
ST_UCHAR *membership, ST_UCHAR **labels)
{
ST_RET ret;
ST_INT i;
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_CHAR element_name[MAX_IDENT_LEN+1];
ST_CHAR branch_name[MAX_IDENT_LEN+1];
ret = mvl_get_runtime (typeIdIn, &rt, &num_rt);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("TypeId %d not found",typeIdIn);
}
for (i=0; i<num_rt; i++)
{
if ((rt[i].el_tag == RT_STR_START) && (ms_comp_name_pres(&rt[i])))
{
add_to_branch_name (branch_name, ms_comp_name_find(&rt[i]));
strcpy( element_name, branch_name);
}
else
{
if (ms_comp_name_pres(&rt[i]))
sprintf( element_name, "%s$%s", branch_name, ms_comp_name_find(&rt[i]));
else
{
if ( i==0 ) /* This is the start of the entire RuntimeType */
{
strcpy( branch_name, base_name);
strcpy( element_name, branch_name);
}
else
element_name[0]=0; /* nobody home */
}
}
if (rt[i].el_tag == RT_STR_END)
{
strcpy( element_name, branch_name);
mvlu_trim_branch_name (branch_name);
}
/*if ( ismember( membership, i))
{
printf ( "\n RT %d element name '%s'",i,element_name);
_slogc (sLogCtrl,"RT %d '%s' - sortedNum %d",
i,element_name,rt[i].mvluTypeInfo.sortedNum);
}*/
}
}
/************************************************************************/
/* reSortRT */
/************************************************************************/
static ST_VOID reSortRT (RUNTIME_TYPE *rt, ST_INT numRt)
{
ST_INT highestSortNum;
ST_INT i;
ST_INT prevSortNum;
ST_INT newSortNum;
/* First find the highest 'used' sort number */
highestSortNum = 0;
for (i = 0; i < numRt; ++i)
{
if (rt[i].mvluTypeInfo.sortedNum > highestSortNum)
highestSortNum = rt[i].mvluTypeInfo.sortedNum;
}
newSortNum = 1;
/* compress the sort numbers */
for (prevSortNum = 1; prevSortNum <= highestSortNum; ++prevSortNum)
{
for (i = 0; i < numRt; ++i)
{
if (rt[i].mvluTypeInfo.sortedNum == prevSortNum)
{
rt[i].mvluTypeInfo.sortedNum = newSortNum;
++newSortNum;
break;
}
}
}
}
/************************************************************************/
/* adjRtBlks */
/************************************************************************/
ST_VOID adjRtBlks( RUNTIME_TYPE *derived_type_table, ST_INT derived_count)
{
RUNTIME_TYPE *nested[ASN1_MAX_LEVEL];
ST_INT i;
ST_INT curNestLevel;
RUNTIME_TYPE *start_rt_blk;
RUNTIME_TYPE *rt_ptr;
ST_INT num_rt;
curNestLevel = 0;
rt_ptr = derived_type_table;
for (i=0; i<derived_count; i++,rt_ptr++)
{
if ((rt_ptr->el_tag == RT_STR_START) ||
(rt_ptr->el_tag == RT_ARR_START))
{
nested[curNestLevel] = rt_ptr; /* remember where we started */
curNestLevel++;
}
else if ((rt_ptr->el_tag == RT_STR_END) ||
(rt_ptr->el_tag == RT_ARR_END))
{
curNestLevel--;
start_rt_blk = nested[curNestLevel];
num_rt = (rt_ptr - start_rt_blk - 1); /* figure out how many in between */
/*if (start_rt_blk->u.str.num_rt_blks != num_rt)
{
printf ("\n adjusting %s, was %d, is now %d",
ms_comp_name_find(start_rt_blk),
start_rt_blk->u.str.num_rt_blks,
num_rt);
}*/
start_rt_blk->u.str.num_rt_blks = num_rt;
rt_ptr->u.str.num_rt_blks = num_rt;
}
}
}
/************************************************************************/
/* add_to_branch_name */
/************************************************************************/
static ST_VOID add_to_branch_name (ST_CHAR *branch_name, SD_CONST ST_CHAR *SD_CONST sub_branch_name)
{
sprintf( branch_name, "%s$%s", branch_name, sub_branch_name);
}
/************************************************************************/
/* create_bitstring */
/************************************************************************/
static ST_UCHAR *create_bitstring (ST_INT n)
{
ST_INT i,j;
ST_UCHAR *s;
i = n / ( sizeof( ST_UCHAR ) * 8 );
j = n % ( sizeof( ST_UCHAR ) * 8 );
if (j)
i++; /* allocate an extra byte if string len ! a multiple of 8 */
s = (ST_UCHAR *)M_CALLOC (MSMEM_GEN, i, sizeof( ST_UCHAR));
return(s);
}
/************************************************************************/
/* set_bit */
/************************************************************************/
static ST_VOID set_bit (ST_UCHAR *s, ST_INT n)
{
ST_INT i,j;
ST_UCHAR k = 0x01; /* mask */
i = n / ( sizeof( ST_UCHAR ) * 8 );
j = n % ( sizeof( ST_UCHAR ) * 8 );
s[ i ] = s[ i ] | ( k << j );
}
/************************************************************************/
/* ismember */
/* This function returns 1 if element n belongs to Set s, 0 otherwise. */
/************************************************************************/
static ST_BOOLEAN ismember( ST_UCHAR *bptr,
ST_INT n)
{
ST_INT i,j;
ST_UCHAR k = 0x01; /* mask */
i = n / ( sizeof( ST_UCHAR ) * 8 );
j = n % ( sizeof( ST_UCHAR ) * 8 );
return( bptr[ i ] & ( k << j ));
}
/************************************************************************/
/* cardinality */
/************************************************************************/
static ST_INT cardinality (ST_UCHAR *bptr, ST_INT size)
{
ST_INT i, j, s, r, card;
ST_CHAR temp;
s = size / ( sizeof( ST_UCHAR ) * 8 );
r = size % ( sizeof( ST_UCHAR ) * 8 );
if (r)
s++;
card=0;
for ( i = 0; i < s; i++ )
{
for ( j = 0; j < 8 * sizeof( ST_UCHAR ); j++ )
{
temp = 0x01;
temp = temp << j;
if ( temp & bptr[ i ] )
card++;
}
}
return( card );
}
/************************************************************************/
/* calc_offset_to_last */
/************************************************************************/
/* This function would not be needed except that the UCA structure */
/* handling needs to know the size of each subelement too ... */
static ST_VOID calc_offset_to_last (RUNTIME_TYPE *rt)
{
ST_INT numUcaRt;
if (rt->el_tag == RT_ARR_END || rt->el_tag == RT_STR_END)
{
return;
}
if (rt->el_tag == RT_STR_START)
numUcaRt = rt->u.str.num_rt_blks+2;
else if (rt->el_tag == RT_ARR_START)
numUcaRt = rt->u.arr.num_rt_blks+2;
else
numUcaRt = 1;
/* Now we can find the size of this element and it's associates */
rt->offset_to_last = ms_get_blocked_length (rt, numUcaRt);
}

601
mmslib/mvlu/mvl_ijou.c Normal file
View File

@@ -0,0 +1,601 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 All Rights Reserved */
/* */
/* MODULE NAME : mvl_ijou.c */
/* PRODUCT(S) : Lean-T Stack */
/* */
/* MODULE DESCRIPTION : */
/* Functions to automatically build a ReadJournal response, */
/* assuming the Journal is modeled as a linked list of journal */
/* entries. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* u_mvl_start_jread */
/* u_mvl_get_next_jread_entry */
/* u_mvl_free_jread_entry */
/* u_mvl_end_jread */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/11/04 GLB 07 Remove "thisFileName" */
/* 04/14/00 JRB 06 Lint cleanup. */
/* 01/21/00 MDE 05 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 10/29/98 JRB 02 Delete unnecessary includes. */
/* 10/09/98 JRB 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mvl_defs.h"
/************************************************************************/
/* All the functions below, used for building the ReadJournal response, */
/* assume the Journal is modeled as a linked list of journal entries. */
/* They use SISCO functions to search the linked list. The user code */
/* must use the same linked list functions to add journal entries to */
/* the linked list (or remove them from the linked list). */
/************************************************************************/
/************************************************************************/
/* Static functions for building the JREAD response. */
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_time_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo);
static MVL_JOURNAL_ENTRY *find_je_start_time_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo);
static MVL_JOURNAL_ENTRY *find_je_start_entry (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo);
static MVL_JOURNAL_ENTRY *find_je_stop_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je);
static MVL_JOURNAL_ENTRY *find_je_stop_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je);
static MVL_JOURNAL_ENTRY *find_je_start_after_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je,
MVL_JOURNAL_ENTRY *stop_je);
static MVL_JOURNAL_ENTRY *find_je_start_after_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je,
MVL_JOURNAL_ENTRY *stop_je);
ST_BOOLEAN check_je_list_of_var (JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *je);
/************************************************************************/
/* Global variables for building the JREAD response. */
/************************************************************************/
MVL_JOURNAL_ENTRY *je_array [MAX_JREAD_RESP_ENTRIES]; /* array or pointers*/
ST_INT je_array_index; /* index into "je_array" */
ST_INT je_array_num_entries; /* # of entries in "je_array" */
ST_BOOLEAN jread_more_follows;
MVL_JOURNAL_ENTRY *stop_je; /* journal entry to stop with. */
/* NOT INCLUDED in response. */
/************************************************************************/
/************************************************************************/
ST_RET u_mvl_start_jread (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JREAD_BUF_CTRL *bufCtrl,
ST_VOID **usrHandleOut)
{
MVL_JOURNAL_ENTRY *je;
MVL_JOURNAL_ENTRY *start_je =jCtrl->entries; /* First entry that passes*/
/* "Range Start Spec." */
ST_BOOLEAN backwards = SD_FALSE;
ST_INT k;
/* Init global variables. */
je_array_index = 0;
je_array_num_entries = 0;
jread_more_follows = SD_TRUE; /* Assume "more_follows". */
if (reqInfo->range_start_pres
&& reqInfo->start_tag == 0 /* Use Starting time */
&& reqInfo->start_time.form != MMS_BTOD6)
{
printf ("\nERROR: ReadJournal request Starting Time illegal. Must be Btime6.");
return (SD_FAILURE);
}
if (reqInfo->range_stop_pres
&& reqInfo->stop_tag == 0 /* Use Stop time */
&& reqInfo->end_time.form != MMS_BTOD6)
{
printf ("\nERROR: ReadJournal request End Time illegal. Must be Btime6.");
return (SD_FAILURE);
}
if (reqInfo->sa_entry_pres
&& reqInfo->time_spec.form != MMS_BTOD6)
{
printf ("\nERROR: ReadJournal request Time Specification illegal. Must be Btime6.");
return (SD_FAILURE);
}
/* If "Number of Entries" is used and is negative, do reverse order. */
if (reqInfo->range_stop_pres
&& reqInfo->stop_tag != 0 /* Use "Number of Entries" */
&& reqInfo->num_of_entries < 0) /* Negative */
backwards = SD_TRUE; /* return entries in reverse order */
/* Process "Range Start Specification" */
if (reqInfo->range_start_pres)
{
if (reqInfo->start_tag == 0) /* Use Starting time */
{
if (reqInfo->range_stop_pres && reqInfo->stop_tag == 0)
{ /* Use "Ending Time" */
if (reqInfo->start_time.day > reqInfo->end_time.day ||
(reqInfo->start_time.day == reqInfo->end_time.day &&
reqInfo->start_time.ms > reqInfo->end_time.ms) )
{ /* Start time > End time */
backwards = SD_TRUE; /* return entries in reverse order */
}
}
if (backwards)
{
/* Set "start_je" to the first entry with time <= start time. */
/* Could be NULL if no entry found. */
start_je = find_je_start_time_backward (jCtrl, reqInfo);
}
else
{
/* Set "start_je" to the first entry with time >= start time. */
/* Could be NULL if no entry found. */
start_je = find_je_start_time_forward (jCtrl, reqInfo);
}
if (start_je == NULL)
return (SD_SUCCESS); /* None found. Return 0 entries */
}
else /* Use "Starting Entry" */
{
start_je = find_je_start_entry (jCtrl, reqInfo);
if (start_je == NULL)
return (SD_FAILURE); /* If no match, must send Negative resp.*/
if (reqInfo->range_stop_pres && reqInfo->stop_tag == 0)
{ /* Use "Ending Time" */
if (start_je->occur_time.day > reqInfo->end_time.day ||
(start_je->occur_time.day == reqInfo->end_time.day &&
start_je->occur_time.ms > reqInfo->end_time.ms) )
{ /* Entry time > End time */
backwards = SD_TRUE; /* return entries in reverse order */
}
}
}
} /* End processing "Range Start Specification". */
else
start_je = jCtrl->entries;
/* Process "Range Stop Specification" */
/* Set "stop_je" pointing to first entry past the "stop spec". */
if (backwards)
{ /* Search BACKWARD thru linked list */
stop_je = find_je_stop_backward (jCtrl, reqInfo, start_je);
}
else
{ /* Search FORWARD thru linked list */
stop_je = find_je_stop_forward (jCtrl, reqInfo, start_je);
}
/* Process "Entry to Start After" */
if (reqInfo->sa_entry_pres)
{ /* "Entry to Start After" specified. */
/* Scan linked list for "Start After Entry" and "Start After Time", */
/* up to "Range Stop", if specified. */
/* Adjust "start_entry" accordingly. */
if (backwards)
{ /* Search BACKWARD thru linked list */
start_je = find_je_start_after_backward (jCtrl, reqInfo, start_je, stop_je);
}
else
{ /* Search FORWARD thru linked list */
start_je = find_je_start_after_forward (jCtrl, reqInfo, start_je, stop_je);
} /* End "Search FORWARD thru linked list" */
}
else
; /* "Entry to Start After" NOT specified. Do nothing. */
/* End processing of "Entry to Start After" */
/* Now find all entries that pass the "List of Variables" filter */
/* and add them to an array of Journal entries to send in response. */
if (backwards)
{
for (je = start_je;
je != stop_je;
je = (MVL_JOURNAL_ENTRY *) list_find_prev ((DBL_LNK *) jCtrl->entries, (DBL_LNK *) je))
{
if (je_array_num_entries >= MAX_JREAD_RESP_ENTRIES)
break; /* Assume still more entries. */
/* If "List of Variables" specified, check if this entry matches.*/
if (check_je_list_of_var (reqInfo, je))
je_array[je_array_num_entries++] = je; /* Matched. */
} /* end "for" */
}
else
{ /* "!backwards" */
for (je = start_je;
je != stop_je;
je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries, je))
{
if (je_array_num_entries >= MAX_JREAD_RESP_ENTRIES)
break; /* Assume still more entries. */
/* If "List of Variables" specified, check if this entry matches.*/
if (check_je_list_of_var (reqInfo, je))
je_array[je_array_num_entries++] = je; /* Matched. */
} /* end "for" */
} /* End "!backwards" */
if (je == stop_je) /* End of linked list. */
jread_more_follows = SD_FALSE; /* No more entries */
/* We need to tell MVL how many entries and variables we have */
bufCtrl->numVarInfo = 0;
bufCtrl->numUsrEntries = je_array_num_entries;
for (k = 0; k < je_array_num_entries; k++)
{
je = je_array [k];
if (je->entry_form_tag == JE_FORM_DATA && je->ef.data.list_of_var_pres)
{ /* entry form is 'data' */
bufCtrl->numVarInfo += je->ef.data.num_of_var;
}
}
/* By default, MVL assumes "u_mvl_get_next_jread_entry" returns a */
/* pointer (*mvlJeDest) to persistent data. */
/* This is a valid assumption for the linked list implementation */
/* in this sample code. If you cannot point to persistent data, */
/* you must compile the MVL library and this code with */
/* MVL_JREAD_*_DYNAMIC defined and adjust the allocation to allow */
/* MVL enough space to copy the data. */
#if defined (MVL_JREAD_ENTRYID_DYNAMIC)
bufCtrl->entryIdBuf = M_MALLOC (MSMEM_GEN, 1000);
#endif
#if defined (MVL_JREAD_VARTAG_DYNAMIC)
bufCtrl->varTagBuf = M_MALLOC (MSMEM_GEN, 1000);
#endif
#if defined (MVL_JREAD_ANNOTATION_DYNAMIC)
bufCtrl->annotationBuf = M_MALLOC (MSMEM_GEN, 1000);
#endif
return (SD_SUCCESS);
}
/************************************************************************/
/************************************************************************/
ST_RET u_mvl_get_next_jread_entry (MVL_JOURNAL_CTRL *jCtrl,
ST_VOID *usrHandle,
ST_BOOLEAN *moreFollowsOut,
MVL_JOURNAL_ENTRY **mvlJeDest)
{
if (je_array_index >= je_array_num_entries)
return (SD_FAILURE); /* Should never happen. */
/* If last in "je_array", use "real more_follows value". */
if (je_array_index + 1 == je_array_num_entries)
*moreFollowsOut = jread_more_follows;
else
*moreFollowsOut = SD_TRUE; /* Not last in array, so always more. */
*mvlJeDest = je_array[je_array_index];
je_array_index++; /* Increment array index to next entry. */
return (SD_SUCCESS);
}
/************************************************************************/
ST_VOID u_mvl_free_jread_entry (MVL_JOURNAL_CTRL *jCtrl,
ST_VOID *usrHandle,
MVL_JOURNAL_ENTRY *mvlJe)
{
}
/************************************************************************/
ST_VOID u_mvl_end_jread (MVL_JOURNAL_CTRL *jCtrl,
ST_VOID *usrHandle,
MVL_JREAD_BUF_CTRL *bufCtrl,
JREAD_REQ_INFO *reqInfo)
{
/* Free up buffers allocated in "u_mvl_start_jread". */
#if defined (MVL_JREAD_ENTRYID_DYNAMIC)
M_FREE (MSMEM_GEN, bufCtrl->entryIdBuf);
#endif
#if defined (MVL_JREAD_VARTAG_DYNAMIC)
M_FREE (MSMEM_GEN, bufCtrl->varTagBuf);
#endif
#if defined (MVL_JREAD_ANNOTATION_DYNAMIC)
M_FREE (MSMEM_GEN, bufCtrl->annotationBuf);
#endif
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_time_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo)
{
MVL_JOURNAL_ENTRY *je;
for (je = jCtrl->entries;
je != NULL;
je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries, je))
{ /* Search entire linked list */
if (je->occur_time.day > reqInfo->start_time.day ||
(je->occur_time.day == reqInfo->start_time.day &&
je->occur_time.ms >= reqInfo->start_time.ms) )
break; /* entry time >= start time. Start here. */
} /* End "for" loop for time spec */
return (je); /* May be NULL if not found. */
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_time_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo)
{
MVL_JOURNAL_ENTRY *je;
for (je = (MVL_JOURNAL_ENTRY *) list_find_last ((DBL_LNK *) jCtrl->entries);
je != NULL;
je = (MVL_JOURNAL_ENTRY *) list_find_prev ((DBL_LNK *) jCtrl->entries, (DBL_LNK *) je))
{ /* Search entire linked list */
if (je->occur_time.day < reqInfo->start_time.day ||
(je->occur_time.day == reqInfo->start_time.day &&
je->occur_time.ms <= reqInfo->start_time.ms) )
break; /* entry time <= start time. Start here. */
} /* End "for" loop for time spec */
return (je); /* May be NULL if not found. */
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_entry (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo)
{
MVL_JOURNAL_ENTRY *je;
for (je = jCtrl->entries;
je != NULL;
je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries, je))
{
if (je->entry_id_len == reqInfo->start_entry_len &&
!memcmp (je->entry_id, reqInfo->start_entry, je->entry_id_len))
return (je); /* entry id == Starting Entry. Start here. */
} /* End "for" loop for "Starting Entry" */
return (NULL);
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_stop_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je)
{
MVL_JOURNAL_ENTRY *je;
MVL_JOURNAL_ENTRY *stop_je;
ST_INT num_entries;
if (reqInfo->range_stop_pres)
{
for (je = start_je, num_entries = 0;
je != NULL;
je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries, je),
num_entries++)
{
if (reqInfo->stop_tag == 0)
{ /* Use "Ending Time" */
if (je->occur_time.day > reqInfo->end_time.day ||
(je->occur_time.day == reqInfo->end_time.day &&
je->occur_time.ms > reqInfo->end_time.ms) )
{ /* Entry time > End time */
break; /* Found it. Done. */
}
}
else
{ /* Use "Number of entries" */
if (num_entries >= reqInfo->num_of_entries)
break; /* Found it. Done. */
}
} /* end "for" */
stop_je = je; /* May be NULL if not found. */
}
else
stop_je = NULL; /* No stop spec. Set to NULL (i.e. end of list) */
return (stop_je);
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_stop_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je)
{
MVL_JOURNAL_ENTRY *je;
MVL_JOURNAL_ENTRY *stop_je;
ST_INT num_entries;
if (reqInfo->range_stop_pres)
{
for (je = start_je, num_entries = 0;
je != NULL;
je = (MVL_JOURNAL_ENTRY *) list_find_prev ((DBL_LNK *) jCtrl->entries, (DBL_LNK *) je),
num_entries++)
{
if (reqInfo->stop_tag == 0)
{ /* Use "Ending Time" */
if (je->occur_time.day < reqInfo->end_time.day ||
(je->occur_time.day == reqInfo->end_time.day &&
je->occur_time.ms < reqInfo->end_time.ms) )
{ /* Entry time < End time */
break; /* Found it. Done. */
}
}
else
{ /* Use "Number of entries" ("0 -" converts neg to pos) */
if (num_entries >= (0 - reqInfo->num_of_entries) )
break; /* Found it. Done. */
}
} /* end "for" */
stop_je = je; /* May be NULL if not found. */
}
else
stop_je = NULL; /* No stop spec. Set to NULL (i.e. end of list) */
return (stop_je);
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_after_forward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je,
MVL_JOURNAL_ENTRY *stop_je)
{
MVL_JOURNAL_ENTRY *je;
MVL_JOURNAL_ENTRY *start_after_entry_je=NULL; /* First entry that passes*/
/* "Start After Entry Spec."*/
MVL_JOURNAL_ENTRY *start_after_time_je=NULL; /* First entry that passes*/
/* "Start After Time Spec."*/
/* The variables "start_after_entry_je" and/or "start_after_time_je"*/
/* will be set to non-NULL values if they are found. */
/* If one of them is found, adjust "start_entry" accordingly. */
for (je = start_je;
je != stop_je;
je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries, je))
{
/* Check for matching "entry_spec" */
if (je->entry_id_len == reqInfo->entry_spec_len &&
!memcmp (je->entry_id, reqInfo->entry_spec, je->entry_id_len))
{ /* entry spec matches */
start_after_entry_je = je;
break; /* Done checking. */
}
/* If haven't found matching "entry_spec" yet, check "time_spec". */
if (start_after_time_je == NULL)
{ /* "time_spec" match not found yet. */
if (je->occur_time.day > reqInfo->time_spec.day ||
(je->occur_time.day == reqInfo->time_spec.day &&
je->occur_time.ms > reqInfo->time_spec.ms) )
{ /* entry time > time spec. */
/* Save this but keep checking for matching "entry_spec". */
start_after_time_je = je; /* DO NOT "break" */
}
}
} /* end "for" */
/* If found match on Start After Entry, start with NEXT entry. */
/* If only found match on Start After Time, start with THAT entry.*/
if (start_after_entry_je)
start_je = (MVL_JOURNAL_ENTRY *) list_get_next (jCtrl->entries,
start_after_entry_je);
else if (start_after_time_je)
start_je = start_after_time_je;
else
start_je = NULL; /* Didn't find either. Return 0 entries.*/
return (start_je);
}
/************************************************************************/
/************************************************************************/
static MVL_JOURNAL_ENTRY *find_je_start_after_backward (MVL_JOURNAL_CTRL *jCtrl,
JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *start_je,
MVL_JOURNAL_ENTRY *stop_je)
{
MVL_JOURNAL_ENTRY *je;
MVL_JOURNAL_ENTRY *start_after_entry_je=NULL; /* First entry that passes*/
/* "Start After Entry Spec."*/
MVL_JOURNAL_ENTRY *start_after_time_je=NULL; /* First entry that passes*/
/* "Start After Time Spec."*/
/* The variables "start_after_entry_je" and/or "start_after_time_je" */
/* will be set to non-NULL values if they are found. */
/* If one of them is found, adjust "start_entry" accordingly. */
for (je = start_je;
je != stop_je;
je = (MVL_JOURNAL_ENTRY *) list_find_prev ((DBL_LNK *) jCtrl->entries, (DBL_LNK *) je))
{
/* Check for matching "entry_spec" */
if (je->entry_id_len == reqInfo->entry_spec_len &&
!memcmp (je->entry_id, reqInfo->entry_spec, je->entry_id_len))
{ /* entry spec matches */
start_after_entry_je = je;
break; /* Done checking. */
}
/* If haven't found matching "entry_spec" yet, check "time_spec". */
if (start_after_time_je == NULL)
{ /* "time_spec" match not found yet. */
if (je->occur_time.day < reqInfo->time_spec.day ||
(je->occur_time.day == reqInfo->time_spec.day &&
je->occur_time.ms < reqInfo->time_spec.ms) )
{ /* entry time < time spec. */
/* Save this but keep checking for matching "entry_spec". */
start_after_time_je = je; /* DO NOT "break" */
}
}
} /* end "for" */
/* If found match on Start After Entry, start with NEXT entry. */
/* If only found match on Start After Time, start with THAT entry.*/
if (start_after_entry_je)
start_je = (MVL_JOURNAL_ENTRY *) list_find_prev ((DBL_LNK *) jCtrl->entries,
(DBL_LNK *) start_after_entry_je);
else if (start_after_time_je)
start_je = start_after_time_je;
else
start_je = NULL; /* Didn't find either. Return 0 entries.*/
return (start_je);
}
/************************************************************************/
/************************************************************************/
ST_BOOLEAN check_je_list_of_var (JREAD_REQ_INFO *reqInfo,
MVL_JOURNAL_ENTRY *je)
{
ST_BOOLEAN retcode = SD_FALSE; /* No match. */
ST_INT j, k;
ST_CHAR **list_of_var;
if (reqInfo->list_of_var_pres)
{
list_of_var = (ST_CHAR **) (reqInfo + 1);
if (je->entry_form_tag == JE_FORM_DATA
&& je->ef.data.list_of_var_pres)
{
for (j = 0; j < reqInfo->num_of_var; j++)
{
for (k = 0; k < je->ef.data.num_of_var; k++)
{
if (!strcmp (je->ef.data.list_of_var[k].var_tag, list_of_var [j]))
retcode = SD_TRUE; /* Matched. */
} /* end "for" loop */
} /* end "for" loop */
}
} /* End "if (reqInfo->list_of_var_pres)" */
else
{ /* No "List of Variables" to check. This one must be OK.*/
retcode = SD_TRUE; /* Just as good as a match. */
}
return (retcode);
}

1131
mmslib/mvlu/mvl_obj.c Normal file

File diff suppressed because it is too large Load Diff

755
mmslib/mvlu/mvl_objb.c Normal file
View File

@@ -0,0 +1,755 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1999 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : mvl_objb.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Functions for maintaining arrays of "generic objects" */
/* using "bsearch". */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_obj_insert */
/* mvl_obj_delete */
/* mvl_obj_find */
/* mvl_obj_find_key */
/* mvl_vmd_dom_insert */
/* mvl_vmd_var_insert */
/* mvl_vmd_nvl_insert */
/* mvl_vmd_jou_insert */
/* mvl_vmd_dom_delete */
/* mvl_vmd_var_delete */
/* mvl_vmd_nvl_delete */
/* mvl_vmd_jou_delete */
/* mvl_vmd_find_dom */
/* mvl_vmd_find_var */
/* mvl_vmd_find_nvl */
/* mvl_vmd_find_jou */
/* mvl_vmd_dom_find_last */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 02/01/07 JRB 14 Fix function names in module header. */
/* 10/30/06 JRB 13 Add vmd_ctrl arg to several functions & chg */
/* prefix from "mvl_" to "mvl_vmd_". */
/* Also add net_info arg to "mvl_vmd_find_*" */
/* so global _mvl_curr_net_info not needed. */
/* Move all obj delete functs from mvl_obj.c to here.*/
/* 01/30/06 GLB 12 Integrated porting changes for VMS */
/* 04/11/05 CRM 11 Added mvl_dom_find_last */
/* 11/11/04 MDE 10 Check for 0 elements before calling bsearch */
/* 01/23/02 EJV 09 Added journals to domain: */
/* mvl_jou_insert - added DOM_SPEC case */
/* mvl_find_jou - added DOM_SPEC case */
/* mvl_sort_objs - added qsort dom->jou_tbl */
/* 04/14/00 JRB 08 Move sort & compare code FROM mvl_obj.c to */
/* here and make it ANSI compatible. */
/* 04/10/00 JRB 07 Fix usage of bsearch to be ANSI compatible. */
/* 09/15/99 JRB 06 Move mvl_obj_nosort here for DOS link */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 09/07/99 MDE 04 Changed MVL_VA_SCOPE to MVL_SCOPE, added */
/* scope to MVL_NVLIST_CTRL */
/* 04/07/99 MDE 03 Logging improvements */
/* 03/18/99 MDE 02 Enhanced dynamic object facilities */
/* 01/15/99 JRB 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
ST_BOOLEAN mvl_obj_nosort;
/************************************************************************/
/* Local functions. */
/************************************************************************/
int _mvl_obj_compare (const void *obj1, const void *obj2);
/************************************************************************/
/* Static variables. */
/************************************************************************/
/* NONE */
/************************************************************************/
/* mvl_obj_insert */
/* NOTE: newElement should point to a "real" structure that has already */
/* been allocated. This allows this function to work without */
/* caring about the size of the "real" structure. */
/* This function just adds the ptr to the array of ptrs. */
/************************************************************************/
ST_RET mvl_obj_insert (MVL_OBJ **elementTable,
ST_INT *numElement,
ST_INT maxElement,
MVL_OBJ *newElement)
{
MVL_OBJ **key;
if (*numElement >= maxElement)
{
MVL_LOG_ERR2 ("ERROR inserting '%s' object. Max num %d exceeded.",
newElement->name, maxElement);
return (SD_FAILURE); /* No more room in array. */
}
/* Check to see if we are bulk updating, and put at end if so */
if (mvl_obj_nosort || (*numElement == 0))
{
elementTable [(*numElement)++] = newElement; /* Add to end of array */
}
else
{
/* Make sure it's not already in array. Can't have duplicates. */
if (*numElement)
key = (MVL_OBJ **) bsearch (&newElement, elementTable, *numElement,
sizeof (MVL_OBJ *), _mvl_obj_compare);
else
key = NULL;
if (key != NULL)
{
MVL_LOG_ERR1 ("ERROR inserting '%s' object. Duplicate.",
newElement->name);
return (SD_FAILURE); /* Already in array. */
}
/* Add to array and resort. */
elementTable [(*numElement)++] = newElement; /* Add to end of array */
qsort (elementTable, *numElement, sizeof (MVL_OBJ *), _mvl_obj_compare);
}
return (SD_SUCCESS);
}
/************************************************************************/
/* mvl_obj_delete */
/************************************************************************/
MVL_OBJ *mvl_obj_delete (MVL_OBJ **elementTable,
ST_INT *numElement,
ST_CHAR *itemName)
{
MVL_OBJ *el;
MVL_OBJ **foundElement;
MVL_OBJ **destElement;
MVL_OBJ **endElement;
/* Locate the element of interest. We get a pointer into the array of */
/* element pointers if it is found. */
foundElement = mvl_obj_find_key (elementTable, *numElement, itemName);
if (!foundElement)
return (NULL);
el = *foundElement;
/* OK, now just move up the remaining pointers */
/* Array was sorted before, so it will still be sorted. */
destElement = foundElement;
endElement = elementTable + *numElement;
while (++destElement < endElement)
*(destElement-1) = *destElement;
--(*numElement);
/* Return the element for further work */
return (el);
}
/************************************************************************/
/* mvl_obj_find */
/* This function is used to locate an element that is referenced in a */
/* sorted table of element pointers. */
/************************************************************************/
MVL_OBJ *mvl_obj_find (MVL_OBJ **elementTable,
ST_INT numElement,
ST_CHAR *itemName)
{
MVL_OBJ **key;
/* First find just the "key". */
key = mvl_obj_find_key (elementTable, numElement, itemName);
/* If key != NULL, return "*key", else return NULL. */
if (key) /* "key" is pointer to pointer to structure. */
return (*key); /* "*key" is pointer to structure. */
return (NULL); /* Not found!! */
}
/************************************************************************/
/* mvl_obj_find_key */
/* This function is used to locate an element that is referenced in a */
/* sorted table of element pointers. */
/* This function only finds the key. Convenient for delete function. */
/************************************************************************/
MVL_OBJ **mvl_obj_find_key (MVL_OBJ **elementTable,
ST_INT numElement,
ST_CHAR *itemName)
{
MVL_OBJ **key;
MVL_OBJ TmpObj; /* Temporary object to search for. */
MVL_OBJ *pTmpObj; /* ptr to temp object. */
if (numElement == 0)
return (NULL);
/* Create a element from the itemName, such that a pointer to the */
/* element pointer can be passed to the search function. */
TmpObj.name = itemName;
pTmpObj = &TmpObj;
if (numElement)
key = (MVL_OBJ **) bsearch (&pTmpObj, elementTable, numElement,
sizeof (MVL_OBJ *), _mvl_obj_compare);
else
key = NULL;
return (key);
}
/************************************************************************/
/* mvl_vmd_dom_insert */
/************************************************************************/
ST_RET mvl_vmd_dom_insert (MVL_VMD_CTRL *vmd_ctrl, MVL_DOM_CTRL *dom)
{
/* Domain can only be VMD_SPEC, so this one is easy. */
return (mvl_obj_insert ((MVL_OBJ **) vmd_ctrl->dom_tbl,
&vmd_ctrl->num_dom, vmd_ctrl->max_num_dom,
(MVL_OBJ *) dom));
}
/************************************************************************/
/* mvl_vmd_var_insert */
/************************************************************************/
ST_RET mvl_vmd_var_insert (MVL_VMD_CTRL *vmd_ctrl, MVL_VAR_ASSOC *va, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
ST_RET retcode = SD_FAILURE;
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa_objs;
switch (obj->object_tag)
{
case VMD_SPEC:
retcode = mvl_obj_insert ((MVL_OBJ **) vmd_ctrl->var_assoc_tbl,
&vmd_ctrl->num_var_assoc, vmd_ctrl->max_num_var_assoc,
(MVL_OBJ *) va);
break;
case DOM_SPEC:
if ((dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id)))
retcode = mvl_obj_insert ((MVL_OBJ **) dom->var_assoc_tbl,
&dom->num_var_assoc, dom->max_num_var_assoc,
(MVL_OBJ *) va);
else
{
MVL_LOG_NERR1 ("Insert var: Domain '%s' not found", obj->domain_id);
}
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
retcode = mvl_obj_insert ((MVL_OBJ **) aa_objs->var_assoc_tbl,
&aa_objs->num_var_assoc, aa_objs->max_num_var_assoc,
(MVL_OBJ *) va);
}
else
MVL_LOG_ERR0 ("Association not known. Cannot insert Application Association-specific variable.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", obj->obj_name.vmd_spec);
break;
}
return (retcode);
}
/************************************************************************/
/* mvl_vmd_nvl_insert */
/************************************************************************/
ST_RET mvl_vmd_nvl_insert (MVL_VMD_CTRL *vmd_ctrl, MVL_NVLIST_CTRL *nvl, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
ST_RET retcode = SD_FAILURE;
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa_objs;
switch (obj->object_tag)
{
case VMD_SPEC:
retcode = mvl_obj_insert ((MVL_OBJ **) vmd_ctrl->nvlist_tbl,
&vmd_ctrl->num_nvlist, vmd_ctrl->max_num_nvlist,
(MVL_OBJ *) nvl);
nvl->nvl_scope.scope = VMD_SPEC;
break;
case DOM_SPEC:
if ((dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id)))
retcode = mvl_obj_insert ((MVL_OBJ **) dom->nvlist_tbl,
&dom->num_nvlist, dom->max_num_nvlist,
(MVL_OBJ *) nvl);
else
{
MVL_LOG_NERR1 ("Insert NVL: Domain '%s' not found", obj->domain_id);
}
nvl->nvl_scope.scope = DOM_SPEC;
nvl->nvl_scope.dom = dom;
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
retcode = mvl_obj_insert ((MVL_OBJ **) aa_objs->nvlist_tbl,
&aa_objs->num_nvlist, aa_objs->max_num_nvlist,
(MVL_OBJ *) nvl);
nvl->nvl_scope.scope = AA_SPEC;
}
else
MVL_LOG_ERR0 ("Association not known. Cannot insert Application Association-specific NVL.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", obj->obj_name.vmd_spec);
break;
}
return (retcode);
}
/************************************************************************/
/* mvl_vmd_jou_insert */
/************************************************************************/
ST_RET mvl_vmd_jou_insert (MVL_VMD_CTRL *vmd_ctrl, MVL_JOURNAL_CTRL *jou, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
ST_RET retcode = SD_FAILURE;
MVL_AA_OBJ_CTRL *aa_objs;
MVL_DOM_CTRL *dom;
switch (obj->object_tag)
{
case VMD_SPEC:
retcode = mvl_obj_insert ((MVL_OBJ **) vmd_ctrl->jou_tbl,
&vmd_ctrl->num_jou, vmd_ctrl->max_num_jou,
(MVL_OBJ *) jou);
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
retcode = mvl_obj_insert ((MVL_OBJ **) aa_objs->jou_tbl,
&aa_objs->num_jou, aa_objs->max_num_jou,
(MVL_OBJ *) jou);
}
else
MVL_LOG_ERR0 ("Association not known. Cannot insert Application Association-specific journal.");
break;
case DOM_SPEC:
dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (dom)
retcode = mvl_obj_insert ((MVL_OBJ **) dom->jou_tbl,
&dom->num_jou, dom->max_num_jou, (MVL_OBJ *) jou);
else
{
MVL_LOG_NERR1 ("Insert journal: Domain '%s' not found", obj->domain_id);
}
break;
default:
/* NOTE: DOM_SPEC illegal for journals. */
MVL_LOG_ERR1 ("Illegal scope for '%s'", obj->obj_name.vmd_spec);
break;
}
return (retcode);
}
/************************************************************************/
/* mvl_vmd_dom_delete */
/************************************************************************/
MVL_DOM_CTRL *mvl_vmd_dom_delete (MVL_VMD_CTRL *vmd_ctrl, ST_CHAR *dom_name)
{
MVL_DOM_CTRL *dom;
dom = (MVL_DOM_CTRL *) mvl_obj_delete ((MVL_OBJ **) vmd_ctrl->dom_tbl,
&vmd_ctrl->num_dom, dom_name);
return (dom);
}
/************************************************************************/
/* mvl_vmd_var_delete */
/************************************************************************/
MVL_VAR_ASSOC *mvl_vmd_var_delete (MVL_VMD_CTRL *vmd_ctrl, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_VAR_ASSOC *va;
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa_objs;
ST_CHAR *name;
va = NULL;
name = obj->obj_name.vmd_spec; /* We know this is a union ... */
switch (obj->object_tag)
{
case VMD_SPEC:
va = (MVL_VAR_ASSOC *) mvl_obj_delete ((MVL_OBJ **) vmd_ctrl->var_assoc_tbl,
&vmd_ctrl->num_var_assoc, name);
break;
case DOM_SPEC:
if ((dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id)))
va = (MVL_VAR_ASSOC *) mvl_obj_delete ((MVL_OBJ **) dom->var_assoc_tbl,
&dom->num_var_assoc, name);
else
{
MVL_LOG_NERR1 ("Delete var: Domain '%s' not found", obj->domain_id);
}
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
va = (MVL_VAR_ASSOC *) mvl_obj_delete ((MVL_OBJ **) aa_objs->var_assoc_tbl,
&aa_objs->num_var_assoc, name);
}
else
MVL_LOG_ERR0 ("Association not known. Cannot delete Application Association-specific variable.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (va);
}
/************************************************************************/
/* mvl_vmd_nvl_delete */
/************************************************************************/
MVL_NVLIST_CTRL *mvl_vmd_nvl_delete (MVL_VMD_CTRL *vmd_ctrl, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_NVLIST_CTRL *nvl = NULL;
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa_objs;
ST_CHAR *name;
name = obj->obj_name.vmd_spec; /* We know this is a union ... */
switch (obj->object_tag)
{
case VMD_SPEC:
nvl = (MVL_NVLIST_CTRL *) mvl_obj_delete ((MVL_OBJ **) vmd_ctrl->nvlist_tbl,
&vmd_ctrl->num_nvlist, name);
break;
case DOM_SPEC:
if ((dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id)))
nvl = (MVL_NVLIST_CTRL *) mvl_obj_delete ((MVL_OBJ **) dom->nvlist_tbl,
&dom->num_nvlist, name);
else
{
MVL_LOG_NERR1 ("Delete NVL: Domain '%s' not found", obj->domain_id);
}
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
nvl = (MVL_NVLIST_CTRL *) mvl_obj_delete ((MVL_OBJ **) aa_objs->nvlist_tbl,
&aa_objs->num_nvlist, name);
}
else
MVL_LOG_ERR0 ("Association not known. Cannot delete Application Association-specific NVL.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (nvl);
}
/************************************************************************/
/* mvl_vmd_jou_delete */
/************************************************************************/
MVL_JOURNAL_CTRL *mvl_vmd_jou_delete (MVL_VMD_CTRL *vmd_ctrl, OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_JOURNAL_CTRL *jou;
MVL_AA_OBJ_CTRL *aa_objs;
MVL_DOM_CTRL *dom;
ST_CHAR *name;
jou = NULL;
name = obj->obj_name.vmd_spec; /* We know this is a union ... */
switch (obj->object_tag)
{
case VMD_SPEC:
jou = (MVL_JOURNAL_CTRL *) mvl_obj_delete ((MVL_OBJ **) vmd_ctrl->jou_tbl,
&vmd_ctrl->num_jou, name);
break;
case AA_SPEC:
if (net_info)
{
aa_objs = net_info->aa_objs;
jou = (MVL_JOURNAL_CTRL *) mvl_obj_delete ((MVL_OBJ **) aa_objs->jou_tbl,
&aa_objs->num_jou, name);
}
else
MVL_LOG_ERR0 ("Association not known. Cannot delete Application Association-specific journal.");
break;
case DOM_SPEC:
dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (dom)
jou = (MVL_JOURNAL_CTRL *) mvl_obj_delete ((MVL_OBJ **) dom->jou_tbl,
&dom->num_jou, name);
else
{
MVL_LOG_NERR1 ("Delete journal: Domain '%s' not found", obj->domain_id);
}
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (jou);
}
/************************************************************************/
/* mvl_vmd_find_dom */
/************************************************************************/
MVL_DOM_CTRL *mvl_vmd_find_dom (MVL_VMD_CTRL *vmd_ctrl, ST_CHAR *name)
{
MVL_DOM_CTRL *result;
result = (MVL_DOM_CTRL *) mvl_obj_find ((MVL_OBJ **) vmd_ctrl->dom_tbl,
vmd_ctrl->num_dom, name);
return(result);
}
/************************************************************************/
/* mvl_vmd_dom_find_last */
/* Find the last domain. */
/************************************************************************/
MVL_DOM_CTRL *mvl_vmd_dom_find_last (MVL_VMD_CTRL *vmd_ctrl)
{
MVL_DOM_CTRL *dom;
if (vmd_ctrl->num_dom > 0)
dom = vmd_ctrl->dom_tbl [vmd_ctrl->num_dom-1];
else
dom = NULL; /* no more dynamically created domains. */
return (dom);
}
/************************************************************************/
/* mvl_vmd_find_var */
/* This function finds the 'variable association' for a particular var */
/* name. */
/************************************************************************/
MVL_VAR_ASSOC *mvl_vmd_find_var (MVL_VMD_CTRL *vmd_ctrl,
OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa;
ST_CHAR *name;
name = obj->obj_name.vmd_spec; /* We know this is a union ... */
switch (obj->object_tag)
{
case VMD_SPEC :
return ((MVL_VAR_ASSOC *) mvl_obj_find ((MVL_OBJ **) vmd_ctrl->var_assoc_tbl,
vmd_ctrl->num_var_assoc, name));
case DOM_SPEC :
dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (dom)
return ((MVL_VAR_ASSOC *) mvl_obj_find ((MVL_OBJ **) dom->var_assoc_tbl,
dom->num_var_assoc, name));
else
{
MVL_LOG_NERR1 ("Find Va: Domain '%s' not found", obj->domain_id);
}
break;
case AA_SPEC :
if (net_info)
{
aa = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
return ((MVL_VAR_ASSOC *) mvl_obj_find ((MVL_OBJ **) aa->var_assoc_tbl,
aa->num_var_assoc, name));
}
else
MVL_LOG_ERR0 ("Association not known. Cannot find Application Association-specific variable.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (NULL);
}
/************************************************************************/
/* mvl_vmd_find_nvl */
/************************************************************************/
MVL_NVLIST_CTRL *mvl_vmd_find_nvl (MVL_VMD_CTRL *vmd_ctrl,
OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_DOM_CTRL *dom;
MVL_AA_OBJ_CTRL *aa;
ST_CHAR *name;
/* Get the NVL name. We know this is a union ... */
name = obj->obj_name.vmd_spec;
switch (obj->object_tag)
{
case VMD_SPEC :
return ((MVL_NVLIST_CTRL *) mvl_obj_find ((MVL_OBJ **) vmd_ctrl->nvlist_tbl,
vmd_ctrl->num_nvlist, name));
case DOM_SPEC :
dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (dom)
return ((MVL_NVLIST_CTRL *) mvl_obj_find ((MVL_OBJ **) dom->nvlist_tbl,
dom->num_nvlist, name));
else
{
MVL_LOG_NERR1 ("Find NVL: Domain '%s' not found", obj->domain_id);
}
break;
case AA_SPEC :
if (net_info)
{
aa = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
return ((MVL_NVLIST_CTRL *) mvl_obj_find ((MVL_OBJ **) aa->nvlist_tbl,
aa->num_nvlist, name));
}
else
MVL_LOG_ERR0 ("Association not known. Cannot find Application Association-specific NVL.");
break;
default:
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (NULL);
}
/************************************************************************/
/* mvl_vmd_find_jou */
/* This function finds the 'journal control' corresponding to 'obj'. */
/************************************************************************/
MVL_JOURNAL_CTRL *mvl_vmd_find_jou (MVL_VMD_CTRL *vmd_ctrl,
OBJECT_NAME *obj,
MVL_NET_INFO *net_info) /* Only used if AA_SPEC */
{
MVL_AA_OBJ_CTRL *aa_objs;
MVL_DOM_CTRL *dom;
ST_CHAR *name;
name = obj->obj_name.vmd_spec; /* We know this is a union ... */
switch (obj->object_tag)
{
case VMD_SPEC :
return ((MVL_JOURNAL_CTRL *) mvl_obj_find ((MVL_OBJ **) vmd_ctrl->jou_tbl,
vmd_ctrl->num_jou, name));
break;
case AA_SPEC :
if (net_info)
{
aa_objs = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
return ((MVL_JOURNAL_CTRL *) mvl_obj_find ((MVL_OBJ **) aa_objs->jou_tbl,
aa_objs->num_jou, name));
}
else
MVL_LOG_ERR0 ("Association not known. Cannot find Application Association-specific journal.");
break;
case DOM_SPEC :
dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (dom)
return ((MVL_JOURNAL_CTRL *) mvl_obj_find ((MVL_OBJ **) dom->jou_tbl,
dom->num_jou, name));
else
{
MVL_LOG_NERR1 ("Find journal: Domain '%s' not found", obj->domain_id);
}
break;
default:
/* NOTE: DOM_SPEC is illegal for Journals. */
MVL_LOG_ERR1 ("Illegal scope for '%s'", name);
break;
}
return (NULL);
}
/************************************************************************/
/* mvl_sort_objs */
/************************************************************************/
ST_VOID mvl_sort_objs (ST_VOID)
{
ST_INT i;
MVL_DOM_CTRL *dom;
mvl_obj_nosort = SD_FALSE;
qsort (mvl_vmd.dom_tbl, mvl_vmd.num_dom, sizeof (MVL_OBJ *), _mvl_obj_compare);
qsort (mvl_vmd.var_assoc_tbl, mvl_vmd.num_var_assoc, sizeof (MVL_OBJ *), _mvl_obj_compare);
qsort (mvl_vmd.nvlist_tbl, mvl_vmd.num_nvlist, sizeof (MVL_OBJ *), _mvl_obj_compare);
qsort (mvl_vmd.jou_tbl, mvl_vmd.num_jou, sizeof (MVL_OBJ *), _mvl_obj_compare);
for (i = 0; i < mvl_vmd.num_dom; ++i)
{
dom = mvl_vmd.dom_tbl[i];
qsort (dom->var_assoc_tbl, dom->num_var_assoc, sizeof (MVL_OBJ *), _mvl_obj_compare);
qsort (dom->nvlist_tbl, dom->num_nvlist, sizeof (MVL_OBJ *), _mvl_obj_compare);
qsort (dom->jou_tbl, dom->num_jou, sizeof (MVL_OBJ *), _mvl_obj_compare);
}
}
/************************************************************************/
/* _mvl_obj_compare */
/************************************************************************/
int _mvl_obj_compare (const void *obj1, const void *obj2)
{
const MVL_OBJ **mvl_obj1 = (const MVL_OBJ **) obj1;
const MVL_OBJ **mvl_obj2 = (const MVL_OBJ **) obj2;
return (strcmp ((*mvl_obj1)->name, (*mvl_obj2)->name));
}

176
mmslib/mvlu/mvl_send.c Normal file
View File

@@ -0,0 +1,176 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : mvl_send.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 09/14/06 MDE 17 Log PDU when too large */
/* 05/01/03 MDE 16 Added buffer depletion logging _mvl_send_req */
/* 10/29/02 JRB 15 _mvl_send_req: on err, set done & result in */
/* req_pend. Helps if user doesn't chk return. */
/* 07/10/02 JRB 14 _mvl_send_req: call mvl_req_bufs_avail. */
/* 07/09/02 MDE 13 Add maxpend_ind support */
/* 01/30/02 JRB 12 Del use of stack_sel. */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 05/15/00 MDE 10 Added MMS statistics */
/* 03/08/00 JRB 09 _mvl_send_req: chk conn_active, */
/* chk & set numpend_req, set invoke_id. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 10/28/99 RKR 07 Modified _mvl_send_resp_i */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 12/09/98 JRB 05 Don't exceed negotiated PDU size. */
/* Change all NERR log macros to ERR. */
/* Free enc buf before _mvl_send_err_f. */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 11/16/98 MDE 03 Don't free request control if send error */
/* 05/14/98 JRB 02 Add _mvl_send_resp_i function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* _mvl_send_resp_i */
/* This function sends a response and frees the MVL_IND_PEND. */
/************************************************************************/
ST_VOID _mvl_send_resp_i (MVL_IND_PEND *indCtrl, ST_RET build_rc)
{
MVL_NET_INFO *net_info;
net_info = indCtrl->event->net_info;
_mvl_send_resp (indCtrl->event, build_rc);
list_unlink(&(net_info->pend_ind),indCtrl);
--net_info->numpend_ind;
M_FREE (MSMEM_IND_CTRL, indCtrl);
}
/************************************************************************/
/* _mvl_send_resp */
/************************************************************************/
ST_VOID _mvl_send_resp (MVL_COMM_EVENT *event, ST_RET build_rc)
{
ST_RET rc;
if (build_rc != SD_SUCCESS)
{ /* Free encode buf before "_mvl_send_err_f" because it allocs new buf.*/
MVL_LOG_ERR1 ("Response build error: rc = 0x%X", build_rc);
_mvl_send_err_f (event,7,2);
++mvl_mms_statistics.serverRespErr;
}
else if (mmsl_msg_len > event->net_info->max_pdu_size)
{ /* Free encode buf before "_mvl_send_err_f" because it allocs new buf.*/
MVL_LOG_ERR2 ("Response build error: exceeds negotiated PDU size %d %d",mmsl_msg_len, event->net_info->max_pdu_size);
printf("Response build error: exceeds negotiated PDU size %d %d\n",mmsl_msg_len, event->net_info->max_pdu_size);
_mvl_send_err_f (event,4,3); /* Don't exceed negotiated PDU size. */
++mvl_mms_statistics.serverRespErr;
}
else
{
rc = _mvl_send_msg (mmsl_msg_start,mmsl_msg_len,event->net_info);
if (rc != SD_SUCCESS)
{
MVL_LOG_ERR1 ("_mvl_send_msg error, rc = %x", rc);
}
else
++mvl_mms_statistics.serverRespOk;
_mvl_free_comm_event (event); /* done with this event */
}
}
/************************************************************************/
/* _mvl_send_req */
/************************************************************************/
ST_RET _mvl_send_req (MVL_NET_INFO *net_info,
MVL_REQ_PEND *req_pend, ST_RET build_rc)
{
ST_RET rc;
ST_INT bufsAvail;
if (build_rc != SD_SUCCESS)
{
MVL_LOG_ERR1 ("Request build error, rc = %x", build_rc);
rc = build_rc;
}
else if (net_info->conn_active == SD_FALSE)
{ /* Check conn_active before using net_info */
MVL_LOG_ERR0 ("Request send error: disconnected");
rc = MVL_ERR_CNF_DISCONNECTED;
}
else if (mmsl_msg_len > net_info->max_pdu_size)
{
MVL_LOG_ERR0 ("Request build error: exceeds negotiated PDU size");
printf("Request build error: exceeds negotiated PDU size");
rc = ASN1E_PDU_TOO_BIG;
}
#ifdef WIN32
else if (net_info->numpend_req >=(net_info->maxpend_req*4))
#else
else if (net_info->numpend_req >= net_info->maxpend_req)
#endif
{
MVL_LOG_ERR1 ("Too many requests outstanding (0x%08lx)", net_info);
rc = MVL_ERR_REQ_PEND_COUNT;
}
else if ((bufsAvail = mvl_req_bufs_avail (net_info)) <= 0)
{
MVL_LOG_ERR2 ("Not enough ACSE bufs to send confirmed request (%d, 0x%08lx)", bufsAvail, net_info);
rc = MVL_ERR_REQ_PEND_COUNT;
}
else
{
rc = _mvl_send_msg (mmsl_msg_start,mmsl_msg_len,net_info);
if (rc != SD_SUCCESS)
{
MVL_LOG_ERR1 ("_mvl_send_msg error, rc = %x", rc);
}
else
++mvl_mms_statistics.clientReq;
}
if (rc == SD_SUCCESS)
{
/* mmsl_invoke_id already incremented on encode, so subtract one. */
req_pend->invoke_id = mmsl_invoke_id - 1;
net_info->numpend_req++;
}
else
{
req_pend->done = SD_TRUE;
req_pend->result = rc;
}
return (rc);
}

1069
mmslib/mvlu/mvl_serv.c Normal file

File diff suppressed because it is too large Load Diff

322
mmslib/mvlu/mvl_typ2.c Normal file
View File

@@ -0,0 +1,322 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2000 - 2000, All Rights Reserved */
/* */
/* MODULE NAME : mvl_typ2.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* Dynamic type creation/destruction functions. */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* mvl_type_id_create */
/* mvl_type_id_destroy */
/* mvl_type_id_create_from_tdl */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 07/11/07 JRB 12 mvl_type_id_destroy2: Reset struct to all 0. */
/* 11/22/06 JRB 11 mvl_type_id_create_from_tdl: clean up on err.*/
/* 10/30/06 JRB 10 Replace static mvl_type_id_create2 with */
/* extern mvl_vmd_type_id_create which has */
/* vmd_ctrl arg. */
/* Add "mvl_vmd_type_id_destroy(_all)". */
/* Add mvl_type_count. */
/* 01/30/06 GLB 09 Integrated porting changes for VMS */
/* 04/11/05 CRM 08 Added mvl_type_id_destroy_all_dyn */
/* 03/14/05 CRM 07 Replaced _mvlu_num_dyn_types variable with */
/* mvl_max_dyn.types. */
/* 06/29/04 JRB 06 Add mvl_type_id_create_from_tdl. */
/* 09/18/03 JRB 05 mvl_type_id_create: Allow type_name==NULL. */
/* 03/13/03 JRB 04 Use static funcs mvl_type_id_create2/destroy2.*/
/* In create2, make sure name not already used. */
/* Call mvlu_proc_rt_type for UCA types. */
/* MVL_TYPE_CTRL: type_name is now array, copy to it*/
/* 11/11/02 JRB 03 Use NEW ms_runtime_create/destroy (new args).*/
/* 09/05/00 JRB 02 Use mvl_get_runtime_dyn to find runtime type.*/
/* 09/05/00 JRB 01 Created. Moved code here from "mvl_type.c". */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
#include "mvl_uca.h" /* need mvlu_proc_rt_type proto */
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* Static function prototypes. */
/************************************************************************/
static RUNTIME_CTRL *mvl_type_id_destroy2 (ST_INT typeId);
/************************************************************************/
/* mvl_type_id_create */
/* RETURNS: */
/* Type Id (or -1 on error) */
/* NOTE: Use "mvl_type_id_destroy" to destroy this object. */
/************************************************************************/
ST_INT mvl_type_id_create (ST_CHAR *type_name, ST_UCHAR *asn1_data, ST_UINT asn1_len)
{
RUNTIME_CTRL *rt_ctrl;
ST_INT TypeId = -1; /* assume failure */
rt_ctrl = ms_runtime_create (asn1_data, asn1_len,
(UINT_MAX/sizeof(RUNTIME_TYPE))-100);
if (rt_ctrl)
{ /* "runtime create" successful, do "step 2". */
TypeId = mvl_vmd_type_id_create (&mvl_vmd, /* assume global VMD */
type_name, rt_ctrl);
if (TypeId < 0) /* "step 2" failed, so destroy runtime just created.*/
ms_runtime_destroy (rt_ctrl);
}
return (TypeId);
}
/************************************************************************/
/* mvl_type_id_destroy */
/* Destroy object created by "mvl_type_id_create". */
/************************************************************************/
ST_VOID mvl_type_id_destroy (ST_INT TypeId)
{
RUNTIME_CTRL *rt_ctrl;
rt_ctrl = mvl_type_id_destroy2 (TypeId); /* remove it from list */
if (rt_ctrl)
ms_runtime_destroy (rt_ctrl); /* destroy it */
else
{
#ifndef WIN32
MVL_LOG_ERR1 ("mvl_type_id_destroy error: TypeId %d not dynamically created", TypeId);
#endif
}
}
/************************************************************************/
/* mvl_type_id_destroy_all_dyn */
/* Destroy dynamic type ids. */
/************************************************************************/
ST_RET mvl_type_id_destroy_all_dyn ()
{
ST_INT j;
ST_INT type_id_first_dyn; /* type_id of first dynamic type */
/* Loop through all dynamic types. */
type_id_first_dyn = mvl_num_types - mvl_max_dyn.types;
for (j = type_id_first_dyn; j < mvl_num_types; j++)
{
if (mvl_type_ctrl[j].num_rt != 0) /* != 0 indicates this type_id used.*/
mvl_type_id_destroy (j); /* destroy it. */
}
return (SD_SUCCESS); /* at present, no way to fail. */
}
/************************************************************************/
/* mvl_vmd_type_id_create */
/* Second step of creating type_id. */
/* RETURNS: */
/* Type Id (or -1 on error) */
/************************************************************************/
ST_INT mvl_vmd_type_id_create (MVL_VMD_CTRL *vmd_ctrl, ST_CHAR *type_name, RUNTIME_CTRL *rt_ctrl)
{
ST_INT typeId;
MVL_TYPE_CTRL *type_ctrl; /* ptr to current array element */
assert (vmd_ctrl); /* VMD must be valid */
/* This assertion fails if the global array mvl_type_ctrl is not initialized
* To avoid this, create dynamic types ONLY AFTER "mvl_init_type_ctrl"
* (in Foundry output "c" file) is called.
*/
assert (mvl_type_ctrl); /* make sure type control initialized */
/* If named, make sure name not too long & name not already used. */
if (type_name!=NULL)
{
if (strlen (type_name) >= sizeof (type_ctrl->type_name))
return (-1); /* type_name exceeds max allowed size */
for (typeId = 0; typeId < mvl_num_types; ++typeId)
{
type_ctrl = &mvl_type_ctrl[typeId]; /* ptr to array elem*/
if (type_ctrl->num_rt!=0 && type_ctrl->type_name!=NULL
&& strcmp (type_ctrl->type_name, type_name) == 0)
{
MVL_LOG_ERR1 ("Type creation error: name '%s' already in use", type_name);
return (-1); /* FAILED: name in use */
}
}
}
#if defined (MVL_UCA) /* do post-processing for UCA types. */
//if (mvlu_proc_rt_type (type_name, rt_ctrl, NULL))//lnk编译修改原前置程序未使用
if (0)//lnk编译修改原前置程序未使用
return (-1); /* FAILED: return invalid typeId */
#endif /* MVL_UCA */
/* Just search for a unused slot */
for (typeId = mvl_num_types - mvl_max_dyn.types; typeId < mvl_num_types; ++typeId)
{
type_ctrl = &mvl_type_ctrl[typeId]; /* ptr to array elem*/
if (type_ctrl->num_rt == 0)
{
if (type_name)
strcpy (type_ctrl->type_name, type_name); /* size checked above */
else
type_ctrl->type_name[0] = '\0'; /* unnamed type */
type_ctrl->rt_ctrl = rt_ctrl; /* no other func sets this*/
type_ctrl->rt = rt_ctrl->rt_first;
type_ctrl->num_rt = rt_ctrl->rt_num;
type_ctrl->data_size = rt_ctrl->rt_first->offset_to_last;
type_ctrl->vmd_ctrl = vmd_ctrl; /* save ptr to VMD using this type*/
return (typeId);
}
}
MVL_LOG_ERR0 ("mvl_type_id_create error: type array full");
return (-1); /* error, no slots available. Return invalid typeId. */
}
/************************************************************************/
/* mvl_type_id_destroy2 */
/* Second step of destroying type_id. */
/* Remove type from array, return pointer to it. */
/* NOTE: uses mvl_type_ctrl_find_dyn to make sure it's "dynamic" type. */
/************************************************************************/
static RUNTIME_CTRL *mvl_type_id_destroy2 (ST_INT typeId)
{
MVL_TYPE_CTRL *type_ctrl;
RUNTIME_CTRL *rt_ctrl = NULL; /* assume failure */
type_ctrl = mvl_type_ctrl_find_dyn (typeId);
if (type_ctrl)
{ /* save ptr to type, then remove it from array */
rt_ctrl = type_ctrl->rt_ctrl;
/* Reset the structure to all 0 so it is ready to be reused. */
/* NOTE: this should be a type created by mvl_vmd_type_id_create */
/* so rt_ctrl and vmd_ctrl should be set (not NULL). */
/* NOTE: this clears num_rt which indicates unused array entry. */
memset (type_ctrl, 0, sizeof (MVL_TYPE_CTRL));
}
return (rt_ctrl);
}
/************************************************************************/
/* mvl_type_id_create_from_tdl */
/************************************************************************/
ST_INT mvl_type_id_create_from_tdl (ST_CHAR *type_name, ST_CHAR *tdl)
{
ST_UCHAR *asn1_buf; /* tmp ASN.1 buffer. Alloc & free here. */
ST_INT asn1_len;
ST_INT type_id;
RUNTIME_CTRL *rt_ctrl;
/* Allocate minimum of 2000 bytes, more for long TDL. */
/* NOTE: may want to increase mininum to reduce memory fragmentation. */
asn1_len = max (2000, (2 * strlen (tdl))); /* initial len. Changed by ms_mk_asn1_type*/
asn1_buf = (ST_UCHAR *) chk_malloc (asn1_len);
if ((rt_ctrl = ms_tdl_to_runtime (tdl, asn1_buf, asn1_len)) == NULL)
{
MVL_LOG_ERR0 ("ms_tdl_to_runtime error");
type_id = -1; /* error */
}
else
{
/* Create MVL type_id. This function also performs post-processing */
/* on "rt_ctrl". */
type_id = mvl_vmd_type_id_create (&mvl_vmd, /* assume global VMD */
type_name, rt_ctrl);
if (type_id < 0)
ms_runtime_destroy (rt_ctrl); /* clean up on error */
}
if (type_id < 0)
MVL_LOG_ERR2 ("mvl_type_id_create_from_tdl: type creation failed for '%s', TDL=%s.", type_name, tdl);
chk_free (asn1_buf);
return (type_id);
}
/************************************************************************/
/* mvl_vmd_type_id_destroy */
/* Destroy type id, but only if it belongs to this VMD. */
/************************************************************************/
ST_RET mvl_vmd_type_id_destroy (MVL_VMD_CTRL *vmd_ctrl, ST_INT type_id)
{
assert (vmd_ctrl); /* VMD must be valid */
if (mvl_type_ctrl[type_id].num_rt != 0 /* != 0 indicates this type_id used.*/
&& mvl_type_ctrl[type_id].vmd_ctrl == vmd_ctrl) /* VMD matches */
{
mvl_type_id_destroy (type_id); /* destroy it. */
return (SD_SUCCESS);
}
else
return (SD_FAILURE);
}
/************************************************************************/
/* mvl_vmd_type_id_destroy_all */
/* Destroy all type ids for this VMD. */
/************************************************************************/
ST_RET mvl_vmd_type_id_destroy_all (MVL_VMD_CTRL *vmd_ctrl)
{
ST_INT type_id;
ST_INT num_destroyed = 0;
/* Try to destroy all types. If VMD doesn't match, destroy fails. */
/* Count how many times destroy succeeds. */
for (type_id = mvl_num_types - mvl_max_dyn.types; type_id < mvl_num_types; type_id++)
{
if (mvl_vmd_type_id_destroy (vmd_ctrl, type_id) == SD_SUCCESS)
num_destroyed++;
}
MVLU_LOG_FLOW1 ("Number of types destroyed for this VMD=%d", num_destroyed);
return (SD_SUCCESS); /* at present, no way to fail. */
}
/************************************************************************/
/* mvl_type_count */
/* Return the current number of types in use. */
/************************************************************************/
ST_INT mvl_type_count ()
{
ST_INT type_id;
ST_INT count = 0;
/* Try to destroy all types. If VMD doesn't match, destroy fails. */
/* Count how many times destroy succeeds. */
for (type_id = 0; type_id < mvl_num_types; type_id++)
{
if (mvl_type_ctrl[type_id].num_rt != 0) /* != 0 indicates this type_id used.*/
count++;
}
return (count);
}
/************************************************************************/
/* mvl_vmd_type_ctrl_find */
/* Find type_ctrl for this type id, but only if it belongs to this VMD. */
/************************************************************************/
MVL_TYPE_CTRL *mvl_vmd_type_ctrl_find (MVL_VMD_CTRL *vmd_ctrl, ST_INT type_id)
{
assert (vmd_ctrl); /* VMD must be valid */
if (mvl_type_ctrl[type_id].num_rt != 0 /* != 0 indicates this type_id used.*/
&& mvl_type_ctrl[type_id].vmd_ctrl == vmd_ctrl) /* VMD matches */
{
return (&mvl_type_ctrl[type_id]);
}
else
return (NULL); /* not found or doesn't belong to this VMD. */
}

266
mmslib/mvlu/mvl_type.c Normal file
View File

@@ -0,0 +1,266 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : mvl_type.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 07/11/07 JRB 17 mvlu_free_rt_type: Reset structure to all 0. */
/* 02/07/06 JRB 16 Log if max types exceeded. */
/* 03/14/05 CRM 15 Add mvl_max_dyn global struct & replace */
/* _mvlu_num_dyn_types with "mvl_max_dyn.types".*/
/* 09/18/03 JRB 14 mvl_get_runtime: chk for valid num_rt. */
/* 03/13/03 JRB 13 Add mvl_type_ctrl_find_dyn. */
/* Del mvlu_add_rt_type_x (not needed). */
/* 11/27/02 MDE 12 Added mvlu_add_rt_type_x, */
/* mvl_typeid_to_typename, */
/* mvl_typename_to_typeid */
/* 10/28/02 JRB 11 Del mvl_mk_rt_from_asn1, use ms_runtime_create*/
/* 10/06/00 MDE 10 Added _mvlu_num_dyn_types */
/* 09/05/00 JRB 09 Move mvl_type_id_* to new module. */
/* Add mvl_get_runtime_dyn. */
/* mvl_type_ctrl_find chk for "in use". */
/* 07/13/00 JRB 08 Add Dynamic type creation functions: */
/* mvl_type_id_create, mvl_type_id_destroy, */
/* mvl_type_ctrl_find. */
/* Move these functs from mvl_uca.c to here: */
/* mvlu_add_rt_type, mvlu_free_rt_type. */
/* 04/14/00 JRB 07 Del SD_CONST from mvl_get_runtime. */
/* 01/21/00 MDE 06 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 03 Minor lint cleanup */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* The user may set this to a positive value prior to calling */
/* 'mvl_init_mms_objs' to control the number allowed */
MVL_MAX_DYN mvl_max_dyn;
/************************************************************************/
/************************************************************************/
/* mvl_mod_arr_size */
/* TYPE HANDLING */
/* This function modifies the size of an array runtime element */
/************************************************************************/
ST_VOID mvl_mod_arr_size (RUNTIME_TYPE *rt, ST_RTINT num_elmnts)
{
ST_INT size_per_el;
/* Adjust the total size of the type, using scaling */
size_per_el = rt->offset_to_last/rt->u.arr.num_elmnts;
rt->offset_to_last = size_per_el * num_elmnts;
/* Now set the number of elements as desired */
rt->u.arr.num_elmnts = num_elmnts;
rt += (rt->u.arr.num_rt_blks + 1);
rt->u.arr.num_elmnts = num_elmnts;
}
/************************************************************************/
/* mvl_get_runtime */
/* This function returns runtime type information given the type id */
/************************************************************************/
ST_RET mvl_get_runtime (ST_INT type_id,
RUNTIME_TYPE **rt_out,
ST_INT *num_rt_out)
{
MVL_TYPE_CTRL *type_ctrl = &mvl_type_ctrl[type_id]; /* ptr to array elem*/
if (type_id >= 0 &&
type_id < mvl_num_types &&
type_ctrl->num_rt > 0)
{
/* Cast "rt" to remove SD_CONST. */
*rt_out = (RUNTIME_TYPE *) type_ctrl->rt;
*num_rt_out = type_ctrl->num_rt;
return (SD_SUCCESS);
}
return (MVL_ERR_RUNTIME_TYPE_ID);
}
/************************************************************************/
/* mvl_get_runtime_dyn */
/* This function returns runtime type information given the type id. */
/* It is the same as "mvl_get_runtime" except it only SUCCEEDS if the */
/* type was dynamically created. */
/************************************************************************/
ST_RET mvl_get_runtime_dyn (ST_INT type_id,
RUNTIME_TYPE **rt_out,
ST_INT *num_rt_out)
{
MVL_TYPE_CTRL *type_ctrl = &mvl_type_ctrl[type_id]; /* ptr to array elem*/
if (type_id >= mvl_num_types - mvl_max_dyn.types && /* dynamic type */
type_id < mvl_num_types &&
type_ctrl->num_rt > 0)
{
/* Cast "rt" to remove SD_CONST. */
*rt_out = (RUNTIME_TYPE *) type_ctrl->rt;
*num_rt_out = type_ctrl->num_rt;
return (SD_SUCCESS);
}
return (MVL_ERR_RUNTIME_TYPE_ID);
}
/************************************************************************/
/* mvl_type_ctrl_find */
/* Find the type ctrl structure corresponding to the type id. */
/* RETURNS: ptr to type ctrl structure (NULL on error) */
/* NOTE: Use "mvl_get_runtime*" if only the runtime type is needed. */
/************************************************************************/
MVL_TYPE_CTRL *mvl_type_ctrl_find (ST_INT TypeId)
{
MVL_TYPE_CTRL *type_ctrl;
if (TypeId < 0 ||
TypeId >= mvl_num_types ||
mvl_type_ctrl[TypeId].num_rt == 0) /* Array entry not in use.*/
type_ctrl = NULL;
else
type_ctrl = &mvl_type_ctrl [TypeId];
return (type_ctrl);
}
/************************************************************************/
/* mvl_type_ctrl_find_dyn */
/* Find the type ctrl structure corresponding to the type id. */
/* For "dynamic" types ONLY. */
/* RETURNS: ptr to type ctrl structure (NULL on error) */
/************************************************************************/
MVL_TYPE_CTRL *mvl_type_ctrl_find_dyn (ST_INT TypeId)
{
MVL_TYPE_CTRL *type_ctrl;
if (TypeId < mvl_num_types - mvl_max_dyn.types)
type_ctrl = NULL; /* NOT dynamic. Return error*/
else
type_ctrl = mvl_type_ctrl_find (TypeId); /* COULD BE dynamic, find it*/
return (type_ctrl);
}
/************************************************************************/
/* mvl_typeid_to_typename */
/************************************************************************/
ST_CHAR *mvl_typeid_to_typename (ST_INT type_id)
{
if (type_id >= 0 && type_id < mvl_num_types)
return (mvl_type_ctrl[type_id].type_name);
return ("unknown");
}
/************************************************************************/
/* mvl_typename_to_typeid */
/************************************************************************/
ST_INT mvl_typename_to_typeid (ST_CHAR *type_id_string)
{
ST_INT i;
MVL_TYPE_CTRL *type_ctrl;
for (i = 0; i < mvl_num_types; ++i)
{
type_ctrl = &mvl_type_ctrl[i];
if (mvl_type_ctrl[i].num_rt != 0 &&
mvl_type_ctrl[i].type_name != NULL &&
!strcmp (mvl_type_ctrl[i].type_name, type_id_string))
{
return (i);
}
}
return (-1);
}
/************************************************************************/
/************************************************************************/
/* MVLU UTILITY FUNCTIONS */
/************************************************************************/
/************************************************************************/
/* mvlu_add_rt_type */
/************************************************************************/
/* This function adds a RT type to the 'mvl_type_ctrl' table and */
/* returns ther type id for the new entry. */
MVL_TYPE_CTRL *temp_type_ctrl;
ST_RET mvlu_add_rt_type (RUNTIME_TYPE *rt, ST_INT numRt, ST_INT *typeIdOut)
{
ST_INT i;
ST_INT mvlu_type_id_base;
/* Just search for a unused slot */
mvlu_type_id_base = mvl_num_types - mvl_max_dyn.types;
for (i = mvlu_type_id_base; i < mvl_num_types; ++i)
{
if (mvl_type_ctrl[i].num_rt == 0)
{
mvl_type_ctrl[i].rt = rt;
mvl_type_ctrl[i].num_rt = numRt;
mvl_type_ctrl[i].data_size = rt->offset_to_last;
mvl_type_ctrl[i].type_name[0] = '\0'; /* name unknown */
*typeIdOut = i;
temp_type_ctrl =&mvl_type_ctrl[i];
return (SD_SUCCESS);
}
}
MVL_LOG_ERR1 ("Cannot add Runtime Type. Maximum number '%d' exceeded", mvl_num_types);
return (SD_FAILURE);
}
/************************************************************************/
/* mvlu_free_rt_type */
/************************************************************************/
/* This function free's slot in the 'mvl_type_ctrl' table, so that it */
/* will be available for future use by mvlu_add_rt_type */
ST_VOID mvlu_free_rt_type (ST_INT typeId)
{
MVL_TYPE_CTRL *type_ctrl;
if (typeId >= mvl_num_types - mvl_max_dyn.types)
{
/* Reset the structure to all 0 so it is ready to be reused. */
/* NOTE: this should be a type created by mvlu_add_rt_type */
/* so rt_ctrl and vmd_ctrl should be NULL. */
/* NOTE: this clears num_rt which indicates unused array entry. */
type_ctrl = &mvl_type_ctrl[typeId];
memset (type_ctrl, 0, sizeof (MVL_TYPE_CTRL));
}
}

2688
mmslib/mvlu/mvl_uca.c Normal file

File diff suppressed because it is too large Load Diff

400
mmslib/mvlu/mvl_var.c Normal file
View File

@@ -0,0 +1,400 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : mvl_var.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 10/30/06 JRB 31 Use new mvl_vmd_* object handling functions. */
/* _mvl_objname_to_va: add args. */
/* u_mvl_get_va_aa: add args. */
/* Elim use of global var "_mvl_curr_net_info". */
/* 01/30/06 GLB 30 Integrated porting changes for VMS */
/* 02/27/04 MDE 29 Log message correct */
/* 03/13/03 JRB 28 Add mvl_scope_set function. */
/* 12/12/02 JRB 27 Add net_info arg to mvl_get_va_asn1... and */
/* elim it's use of global _mvl_curr_net... */
/* 02/25/02 MDE 26 Now get max PDU size from mvl_cfg_info */
/* 01/02/02 JRB 25 Converted to use ASN1R (re-entrant ASN1) */
/* 10/25/00 JRB 24 Del u_mvl funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* 08/17/00 JRB 23 Don't clear va_to_free. Need value later. */
/* 03/08/00 JRB 22 Del #ifdef MVL_REQ_BUF_ENABLED: not used. */
/* 01/21/00 MDE 21 Now use MEM_SMEM for dynamic memory */
/* 01/21/00 MDE 20 Add '_mvl_get_req_buf' for MVL_REQ_BUF_EN.. */
/* 11/19/99 NAV 19 Add #ifdef MVL_REQ_BUF_ENABLED */
/* 10/22/99 NAV 18 Add a few utilities to copy structs */
/* 09/13/99 MDE 17 Added SD_CONST modifiers */
/* 09/07/99 MDE 16 Changed MVL_VA_SCOPE to MVL_SCOPE */
/* 01/20/99 JRB 15 Del mvl_find_*. Use new "bsearch" versions. */
/* Del _mvl_skip_uca_prefix (use va->flags). */
/* Del _mvl_destroy_nvl_ent.. (see mvl_nvl_de..)*/
/* 12/11/98 MDE 14 Removed scope references from VA */
/* 12/08/98 MDE 13 Added client alternate access support */
/* 11/16/98 MDE 12 Added '_mvl_destroy_nvl_entries' */
/* 11/16/98 MDE 11 Renamed internal functions (prefix '_') */
/* 11/10/98 MDE 10 Added 'mvl_get_va_asn1_data' (was in s_read) */
/* 09/21/98 MDE 09 Minor lint cleanup */
/* 07/21/98 MDE 08 Moved 'mvl_insert_nvlist' to mvl_dnvl.c */
/* 07/13/98 MDE 07 Fixed mvl_insert_nvlist bug when adding 1st */
/* 06/30/98 MDE 06 Corrected insert order for "_UCA_" names */
/* 06/15/98 MDE 05 Changes to allow compile under C++ */
/* 06/05/98 MDE 04 Added 'mvl_insert_nvlist' */
/* 01/06/98 RWM 03 Added Binary Search Capability */
/* 12/12/97 MDE 02 Moved mvl_vmd to rt_types.c */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_acse.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_objname_to_va */
/************************************************************************/
MVL_VAR_ASSOC *_mvl_objname_to_va (MVL_VMD_CTRL *vmd_ctrl,
MVL_NET_INFO *net_info,
ST_INT service,
OBJECT_NAME *obj,
MVL_SCOPE *va_scope_out,
ST_BOOLEAN alt_access_pres,
ALT_ACCESS *alt_acc,
ST_BOOLEAN *alt_access_done_out)
{
MVL_VAR_ASSOC *va;
/* By default, we don't modify the VA to handle alternate access */
if (alt_access_done_out != NULL)
*alt_access_done_out = SD_FALSE;
/* Let's find the variable association */
va = mvl_vmd_find_var (vmd_ctrl, obj, net_info);
if ((!va) || (va->flags & MVL_VAR_FLAG_UCA))
{
/* Could not find variable association, see if we can manufacture it */
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
/* May be able to manufacture it */
va = u_mvl_get_va_aa (vmd_ctrl, service, obj, net_info,
alt_access_pres, alt_acc,
alt_access_done_out);
if (va != NULL) /* Manufactured it, set flag ... */
va->va_to_free = va;
#endif /* defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS) */
}
/* OK, assuming we have the VA, set it's scope appropriately */
if (va && va_scope_out)
{
va_scope_out->scope = obj->object_tag;
if (va_scope_out->scope == DOM_SPEC)
{
va_scope_out->dom = mvl_vmd_find_dom (vmd_ctrl, obj->domain_id);
if (va_scope_out->dom == NULL)
{
MVL_LOG_NERR1 ("Warning : Variable object references non-existant domain '%s'",
obj->domain_id);
}
}
}
return (va);
}
/************************************************************************/
/* mvl_scope_set */
/* Use the OBJECT_NAME info to set the scope for any MMS object. */
/* This function fills in the struct pointed to by mvl_scope_out. */
/************************************************************************/
ST_VOID mvl_scope_set (OBJECT_NAME *obj, MVL_SCOPE *mvl_scope_out)
{
mvl_scope_out->scope = obj->object_tag;
if (mvl_scope_out->scope == DOM_SPEC)
{
mvl_scope_out->dom = mvl_vmd_find_dom (&mvl_vmd, obj->domain_id);
if (mvl_scope_out->dom == NULL)
MVL_LOG_NERR1 ("Warning : MMS object references nonexistent domain '%s'",
obj->domain_id);
}
}
/************************************************************************/
/* mvl_get_va_asn1_data */
/************************************************************************/
ST_RET mvl_get_va_asn1_data (MVL_NET_INFO *net_info, MVL_VAR_ASSOC *va,
ST_BOOLEAN alt_access_pres,
ALT_ACCESS *alt_acc,
ST_UCHAR *asn1_dest_buffer,
ST_INT asn1_buffer_len,
ST_INT *asn1_len_out)
{
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_RET rc;
ST_UCHAR *asn1_start;
ST_INT asn1_len;
ST_INT aa_mode;
ASN1_ENC_CTXT localEncCtx; /* For readability, use "aCtx" to access this.*/
ASN1_ENC_CTXT *aCtx = &localEncCtx;
aa_mode = MVL_USE_UNPACKED_AA;
if (va->proc && va->proc->pre_read_aa)
{
rc = (*va->proc->pre_read_aa)(&va, alt_access_pres, alt_acc,
net_info, &aa_mode);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Read: pre_read_aa returned %d", rc);
return (SD_FAILURE);
}
}
rc = mvl_get_runtime (va->type_id, &rt, &num_rt);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Read: mvl_get_runtime failed, rc = %x", rc);
return (rc); /* bad type id */
}
/* If we got here, we have a valid runtime and have resolved local */
/* data pointer and size. Go ahead and build the ASN.1 data element. */
/* First we need to initialize the ASN.1 encode tools, then do the */
/* encode */
asn1r_strt_asn1_bld (aCtx, asn1_dest_buffer, asn1_buffer_len);
#if defined(MVL_AA_SUPP)
if (alt_access_pres == SD_FALSE || aa_mode == MVL_USE_NO_AA)
{
rc = ms_local_to_asn1 (aCtx, rt, num_rt, (ST_CHAR *) va->data);
}
else
{
if (aa_mode == MVL_USE_PACKED_AA)
m_alt_acc_packed = SD_TRUE;
else
m_alt_acc_packed = SD_FALSE;
rc = ms_local_to_asn1_aa (aCtx, rt, num_rt, alt_acc, (ST_CHAR *) va->data);
}
#else
rc = ms_local_to_asn1 (aCtx, rt, num_rt, (ST_CHAR *) va->data);
#endif
/* When the ASN.1 encode is complete, 'asn1_field_ptr' points 1 byte ahead */
/* of the start of the message. The ASN.1 message is build from back to */
/* front, so that is now we calculate the length of the PDU */
if (rc == SD_SUCCESS)
{
asn1_start = aCtx->asn1r_field_ptr+1;
asn1_len = (asn1_dest_buffer + asn1_buffer_len) - asn1_start;
memmove (asn1_dest_buffer,asn1_start,asn1_len);
*asn1_len_out = asn1_len;
if (va->proc && va->proc->post_read_aa)
{
(*va->proc->post_read_aa)(va, alt_access_pres, alt_acc,
net_info);
}
}
else
{
MVL_LOG_NERR1 ("Local to ASN1 data conversion error: 0x%04x", rc);
}
return (rc);
}
/************************************************************************/
/************************************************************************/
#if defined(MVL_AA_SUPP)
/************************************************************************/
/************************************************************************/
/************************************************************************/
/* _mvl_get_asn1_aa */
/************************************************************************/
ST_RET _mvl_get_asn1_aa (ALT_ACCESS *alt_acc, VARIABLE_LIST *vl)
{
ST_UCHAR *aa_buf;
ST_INT aa_buf_size;
ST_UCHAR *asn1_start;
ST_INT asn1_len;
ASN1_ENC_CTXT localEncCtx; /* For readability, use "aCtx" to access this.*/
ASN1_ENC_CTXT *aCtx = &localEncCtx;
aa_buf = _m_get_aa_asn1_buf (&aa_buf_size);
asn1r_strt_asn1_bld (aCtx, aa_buf, aa_buf_size);
if (ms_aa_to_asn1 (aCtx, alt_acc))
{
_m_free_aa_asn1_buf ();
return (SD_FAILURE);
}
else
{
asn1_start = aCtx->asn1r_field_ptr+1;
asn1_len = (aa_buf + aa_buf_size) - asn1_start;
vl->alt_access.len = asn1_len;
vl->alt_access.data = asn1_start;
vl->alt_access_pres = SD_TRUE;
_m_set_aa_asn1_buf_end (asn1_start -1);
}
return (SD_SUCCESS);
}
/************************************************************************/
static ST_UCHAR *aa_buffer_head;
static ST_UCHAR *aa_buffer_end;
/************************************************************************/
/* _m_get_aa_asn1_buf */
/************************************************************************/
ST_UCHAR *_m_get_aa_asn1_buf (ST_INT *size_out)
{
ST_UCHAR *ret;
if (!aa_buffer_head)
{
aa_buffer_head = (ST_UCHAR *) M_MALLOC (MSMEM_AA_ENCODE, mvl_cfg_info->max_msg_size);
aa_buffer_end = aa_buffer_head + mvl_cfg_info->max_msg_size -1;
}
*size_out = aa_buffer_end - aa_buffer_head + 1;
ret = aa_buffer_head;
return (ret);
}
/************************************************************************/
/* _m_set_aa_asn1_buf_end */
/************************************************************************/
ST_VOID _m_set_aa_asn1_buf_end (ST_UCHAR *new_end)
{
aa_buffer_end = new_end;
}
/************************************************************************/
/* _m_free_aa_asn1_buf */
/************************************************************************/
ST_VOID _m_free_aa_asn1_buf (ST_VOID)
{
if (aa_buffer_head)
{
M_FREE (MSMEM_AA_ENCODE, aa_buffer_head);
aa_buffer_head = NULL;
}
}
#endif /* #if defined(MVL_AA_SUPP) */
/************************************************************************/
/* mvl_get_descr_local_addr */
/* DESCRIBED VARIABLE ASSOCIATION */
/* Addresses are in the form : */
/* "baseaddr:xxx" */
/* where xxx is the element offset from the base address. */
/************************************************************************/
/************************************************************************/
#if defined (MVL_DESCR_SUPP)
/************************************************************************/
ST_RET mvl_get_descr_local_addr (VAR_ACC_ADDR *addr,
RUNTIME_TYPE *rt,
ST_INT num_rt,
ST_CHAR **data_out,
ST_INT *data_size_out)
{
ST_INT i;
MVL_DESCR_ADDR_ASSOC *d;
ST_INT base_name_len;
ST_INT offset;
ST_INT num_offset;
ST_INT num_elmnts;
/* We only support symbolic addresses */
if (addr->addr_tag != SYM_ADDR)
{
MVL_LOG_NERR0 ("Get Described Local Address : Only Symbolic Addresses are supported");
return (MVL_ERR_NOT_SYM_ADDR);
}
/* Find the matching described variable association */
d = mvl_vmd.descr_addr_assoc_tbl;
for (i = 0; i < mvl_vmd.num_descr_addr; ++i, ++d)
{
base_name_len = strlen (d->base_name);
if (!strncmp (d->base_name, addr->addr.sym_addr, base_name_len))
{
/* Check for offset from base element */
if (base_name_len == strlen (addr->addr.sym_addr))
offset = 0;
else
{
num_offset = atoi (&addr->addr.sym_addr[base_name_len + 1]);
if (num_offset) /* :1 is first element */
num_offset--;
offset = d->data_size * num_offset;
}
if (rt->el_tag != RT_ARR_START) /* if not array */
{
*data_out = (ST_CHAR *) d->data + offset;
*data_size_out = d->data_size;
return (SD_SUCCESS);
}
else /* this is an array */
{
num_elmnts = rt->u.arr.num_elmnts; /* get number of elements */
if (num_elmnts + num_offset > d->max_elmnts)
{
MVL_LOG_NERR0 ("Get Described Local Address : Invalid array element count");
return (MVL_ERR_ARRAY_ELEMENT_CNT);
}
*data_out = (ST_CHAR *) d->data + offset;
*data_size_out = d->data_size * num_elmnts;
return (SD_SUCCESS);
}
break;
}
}
MVL_LOG_NERR0 ("Get Described Local Address : Could not get Local Address");
return (MVL_ERR_LOCAL_ADDRESS);
}
/************************************************************************/
#endif /* #if defined (MVL_DESCR_SUPP) */
/************************************************************************/

2570
mmslib/mvlu/mvlu_rpt.c Normal file

File diff suppressed because it is too large Load Diff

422
mmslib/mvlu/mvlu_rt.c Normal file
View File

@@ -0,0 +1,422 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1997-2001, All Rights Reserved */
/* */
/* MODULE NAME : mvlu_rt.c */
/* PRODUCT(S) : */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* main */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 01/18/08 JRB 11 We allow up to 15 char LNName (sclparse.c), */
/* so max flatname must be MAX_IDENT_LEN-15. */
/* 07/20/07 JRB 10 Flatnames must be shorter to add LNName later*/
/* 11/22/06 JRB 09 Free bufs if _mvlu_build_uca_name_tbl fails. */
/* 01/30/06 GLB 09 Integrated porting changes for VMS */
/* 03/11/04 GLB 08 Added "#ifdef DEBUG_SISCO" for "thisFileName" */
/* 09/18/03 JRB 07 Allow array of structures. */
/* DON'T allow array of arrays (return error). */
/* 05/02/03 JRB 06 switch(rt->el_tag): Use default for most cases*/
/* 04/29/03 JRB 05 Chg several functions to return ST_RET. */
/* 04/24/03 JRB 04 Use MAX_IDENT_LEN define. */
/* 03/13/03 JRB 03 mvlu_proc_rt_type: Chg to use RUNTIME_CTRL. */
/* MVLU_UCA_NAME_CTRL: Chg ucaName member from */
/* ptr to array (saves allocs). */
/* 12/11/02 JRB 02 Use new mvl_uca.h */
/* 11/14/02 MDE 01 New module, extracted fo_uca.c */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "gen_list.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mem_chk.h"
#include "mvl_uca.h"
/************************************************************************/
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* STATIC VARIABLES */
#define MAX_PREFIX_LEN 200
#define MAX_NEST_LEVEL 50
static ST_CHAR *namePrefix[MAX_NEST_LEVEL];
static ST_INT nestLevel;
/************************************************************************/
/* STATIC FUNCTIONS */
static ST_RET _mvlu_set_rt_sort_num (ST_CHAR *typeName,
RUNTIME_TYPE *rt, ST_INT numRt,
MVLU_UCA_NAME_CTRL **ucaNamesOut);
static ST_VOID _mvlu_set_rt_size (RUNTIME_TYPE *rt) ;
static ST_VOID _mvlu_set_rt_offset (RUNTIME_TYPE *rt, ST_INT numRt);
static ST_RET _mvlu_build_uca_name_tbl (RUNTIME_TYPE *rt, ST_INT rt_num,
MVLU_UCA_NAME_CTRL *mvluFoundryInfo);
static ST_RET _mvlu_save_rt_uca_name (ST_INT nestLevel, RUNTIME_TYPE *rt,
MVLU_UCA_NAME_CTRL *mvluFoundryInfo);
static ST_VOID _mvlu_sort_uca_names (MVLU_UCA_NAME_CTRL *ucaNames,
RUNTIME_TYPE *rt, ST_INT numRt);
/************************************************************************/
/************************************************************************/
/* mvlu_proc_rt_type */
/************************************************************************/
ST_RET mvlu_proc_rt_type (ST_CHAR *typeName, RUNTIME_CTRL *rt_ctrl,
MVLU_UCA_NAME_CTRL **ucaNamesOut)
{
RUNTIME_TYPE *rt;
ST_INT i;
ST_RET ret;
/* Set the sortedNum for each RT element */
ret = _mvlu_set_rt_sort_num (typeName, rt_ctrl->rt_first, rt_ctrl->rt_num, ucaNamesOut);
if (ret)
return(ret); /* don't bother continuing */
/* Find the offset of the data for each RT within the type */
_mvlu_set_rt_offset (rt_ctrl->rt_first, rt_ctrl->rt_num);
/* Find the size of each RT within the type */
rt = rt_ctrl->rt_first;
for (i = 0; i < rt_ctrl->rt_num; ++i, ++rt)
_mvlu_set_rt_size (rt);
return (ret);
}
/************************************************************************/
/************************************************************************/
/* _mvlu_set_rt_size */
/************************************************************************/
/* This function would not be needed except that the UCA structure */
/* handling needs to know the size of each subelement too ... */
static ST_VOID _mvlu_set_rt_size (RUNTIME_TYPE *rt)
{
ST_INT numUcaRt;
ST_INT blockedLen;
if (rt->el_tag == RT_ARR_END || rt->el_tag == RT_STR_END)
{
return;
}
if (rt->el_tag == RT_STR_START)
numUcaRt = rt->u.str.num_rt_blks+2;
else if (rt->el_tag == RT_ARR_START)
numUcaRt = rt->u.arr.num_rt_blks+2;
else
numUcaRt = 1;
/* Now we can find the size of this element and it's associates */
blockedLen = ms_get_blocked_length (rt, numUcaRt);
rt->offset_to_last = blockedLen;
}
/************************************************************************/
/************************************************************************/
/* _mvlu_set_rt_offset */
/************************************************************************/
static ST_VOID _mvlu_set_rt_offset (RUNTIME_TYPE *rt, ST_INT numRt)
{
ST_INT data_offset;
SD_CONST RUNTIME_TYPE *rt_end;
ST_INT arr_loops[ASN1_MAX_LEVEL];
ST_BOOLEAN arr_el_set[ASN1_MAX_LEVEL];
ST_INT arr_loop_level;
arr_loop_level = 0;
rt_end = rt + numRt; /* end block */
data_offset = 0;
/* Traverse the RT type as though we were doing a ASN.1 to LOCAL */
while (rt < rt_end)
{
if (rt->el_tag == RT_ARR_END) /* treat case of array ending */
{
if (--arr_loops[arr_loop_level] > 0)/* if need to do next ar elmnt*/
{
rt -= rt->u.arr.num_rt_blks; /* mv rt to start of arr */
continue;
}
else
--arr_loop_level;
}
if (arr_loop_level == 0 || arr_el_set[arr_loop_level] == SD_FALSE)
{
rt->mvluTypeInfo.offSet = data_offset; /* Set the offset */
/* renxiaobao <20><><EFBFBD><EFBFBD>*/
/*arr_el_set[arr_loop_level] = SD_TRUE;*/
}
data_offset += rt->el_size; /* Offset for next */
if (rt->el_tag == RT_ARR_START) /* Set up array looping */
{
++arr_loop_level;
arr_loops[arr_loop_level] = rt->u.arr.num_elmnts;
arr_el_set[arr_loop_level] = SD_FALSE;
}
rt++; /* point to next runtime element */
}
}
/************************************************************************/
/************************************************************************/
/* _mvlu_set_rt_sort_num */
/************************************************************************/
static ST_RET _mvlu_set_rt_sort_num (ST_CHAR *typeName,
RUNTIME_TYPE *rt, ST_INT numRt,
MVLU_UCA_NAME_CTRL **ucaNamesOut)
{
MVLU_UCA_NAME_CTRL *ucaNames;
ST_INT i;
ucaNames = (MVLU_UCA_NAME_CTRL *) chk_calloc (numRt, sizeof (MVLU_UCA_NAME_CTRL));
nestLevel = 0;
/* Derive the UCA names within this type */
namePrefix[0] = (ST_CHAR *) chk_calloc (1, MAX_PREFIX_LEN);
if (typeName != NULL)
strcpy (namePrefix[0], typeName);
if (_mvlu_build_uca_name_tbl (rt, numRt, ucaNames))
{
chk_free(ucaNames);
chk_free(namePrefix[0]);
return (SD_FAILURE); /* don't bother continuing */
}
/* Now sort the UCA names within the type */
_mvlu_sort_uca_names (ucaNames, rt, numRt);
for (i = 0; i < MAX_NEST_LEVEL; ++i)
{
if (namePrefix[i] != NULL)
{
chk_free (namePrefix[i]);
namePrefix[i] = NULL;
}
}
if (ucaNamesOut == NULL)
chk_free (ucaNames);
else
*ucaNamesOut = ucaNames;
return (SD_SUCCESS);
}
/************************************************************************/
/* _mvlu_build_uca_name_tbl */
/* Start with retCode=SD_SUCCESS. If any call to _mvlu_save_rt_uca_name */
/* fails, set retCode=SD_FAILURE. Do not return immediately because we */
/* want to log as many problems as possible first. */
/************************************************************************/
static ST_RET _mvlu_build_uca_name_tbl (RUNTIME_TYPE *rt, ST_INT rt_num,
MVLU_UCA_NAME_CTRL *ucaNames)
{
ST_INT i;
ST_RET retCode=SD_SUCCESS;
nestLevel = 0;
for (i = 0; i < rt_num; ++i, ++rt)
{
ucaNames[i].rtIndex = i;
ucaNames[i].rt = rt;
switch (rt->el_tag)
{
case RT_STR_START :
if (ms_comp_name_pres(rt))
{
if (_mvlu_save_rt_uca_name (nestLevel, rt, &ucaNames[i]))
retCode = SD_FAILURE; /*continue but eventually return this*/
++nestLevel;
if (namePrefix[nestLevel] == NULL)
namePrefix[nestLevel] = (ST_CHAR *) chk_calloc (1, MAX_PREFIX_LEN);
strcpy (namePrefix[nestLevel], namePrefix[nestLevel-1]);
strcat (namePrefix[nestLevel], "$");
strcat (namePrefix[nestLevel], ms_comp_name_find(rt));
}
break;
case RT_STR_END :
--nestLevel;
break;
case RT_ARR_START :
if (_mvlu_save_rt_uca_name (nestLevel, rt, &ucaNames[i]))
retCode = SD_FAILURE; /*continue but eventually return this*/
/* We let the array element inherit our name so we will generate */
/* rd/wr ind handler functions and references for the contained */
/* primitive elements */
/* This causes duplicate names (name of array same as name of */
/* object IN array). That's OK because names of anything inside */
/* array are dropped when sorted (see _mvlu_sort_uca_names). */
/* The "sorted" array of names is used in GetNameList response. */
if (ms_is_rt_prim (rt+1) || (rt+1)->el_tag==RT_STR_START)
{
#if defined(USE_RT_TYPE_2)
(rt+1)->comp_name_ptr = rt->comp_name_ptr;
#elif defined(USE_RT_TYPE_3)
(rt+1)->name_index = rt->name_index;
#else
strcpy ((rt+1)->name, rt->name);
#endif
}
else
{
SLOGALWAYS1 ("Warning: Arrays of arrays not supported for UCA (%s)",
ucaNames[i].ucaName);
retCode = SD_FAILURE; /*continue but eventually return this*/
}
break;
case RT_ARR_END :
break;
default :
if (_mvlu_save_rt_uca_name (nestLevel, rt, &ucaNames[i]))
retCode = SD_FAILURE; /*continue but eventually return this*/
break;
}
}
return (retCode);
}
/************************************************************************/
/* _mvlu_save_rt_uca_name */
/* Start with retCode=SD_SUCCESS. If anything fails, set retCode=SD_FAILURE.*/
/************************************************************************/
static ST_RET _mvlu_save_rt_uca_name (ST_INT nestLevel,
RUNTIME_TYPE *rt,
MVLU_UCA_NAME_CTRL *nameDest)
{
ST_CHAR nameBuf[256];
ST_RET retCode = SD_SUCCESS;
nameDest->ucaName [0] = '\0'; /* start with empty string */
nameDest->rt = rt;
if (ms_comp_name_pres(rt))
{
sprintf (nameBuf, "%s$%s", namePrefix[nestLevel], ms_comp_name_find(rt));
/* Make sure there is room left for longest allowed Logical Node Name*/
/* (11 characters according to IEC 61850-7-2 but we allow 15). */
/* NOTE: this allows 5 or 6 more char than 61850-7-2 specifies, so */
/* it is more forgiving, but it prevents illegal MMS names. */
if (strlen (nameBuf) > (MAX_IDENT_LEN-15))
{
SLOGALWAYS2 ("Error: Flattened IEC 61850 variable name '%s' > %d characters. Illegal.",
nameBuf, (MAX_IDENT_LEN-15));
SLOGCALWAYS0 ("Must allow space for LNName up to 15 characters");
retCode = SD_FAILURE;
}
else
strcpy (nameDest->ucaName, nameBuf);
}
return (retCode);
}
/************************************************************************/
/************************************************************************/
/* SORTING UCA NAMES WITHIN A TYPE */
/************************************************************************/
/* elementCompare */
/************************************************************************/
/* This function is sorting the namelist table */
static ST_INT elementCompare (const MVLU_UCA_NAME_CTRL *a,
const MVLU_UCA_NAME_CTRL *b)
{
return (strcmp (a->ucaName, b->ucaName));
}
/************************************************************************/
/* _mvlu_sort_uca_names */
/************************************************************************/
static ST_VOID _mvlu_sort_uca_names (MVLU_UCA_NAME_CTRL *ucaNames,
RUNTIME_TYPE *rt, ST_INT numRt)
{
ST_INT i;
ST_INT numNames;
MVLU_UCA_NAME_CTRL *sortedNames; /* compressed/sorted array of names*/
sortedNames = (MVLU_UCA_NAME_CTRL *) M_MALLOC (MSMEM_GEN, numRt*sizeof(MVLU_UCA_NAME_CTRL));
/* Compress the name table */
numNames = 0;
for (i = 0; i < numRt; ++i, ++rt)
{
if (ucaNames[i].ucaName[0] != '\0')
{
sortedNames[numNames] = ucaNames[i];
++numNames;
/* CRITICAL:
* The "ucaNames" array contains names for objects inside arrays.
* They must be kept in the original array, because they are needed
* for generating leaf function names.
* However, they are NOT legal variable names, so they are NOT
* copied to the SORTED array (used for GetNameList response).
* This is done by skipping over the runtime type for the array.
*/
if (rt->el_tag==RT_ARR_START)
{
rt += (rt->u.arr.num_rt_blks + 1);
i += (rt->u.arr.num_rt_blks + 1);
}
}
}
/* OK, we now have a raw table of names, go ahead and sort them */
qsort (sortedNames, numNames, sizeof (MVLU_UCA_NAME_CTRL),
(int (*)(const void *,const void *)) elementCompare);
#if 0 /* DEBUG: enable this code to debug sorting algorithm */
if (numNames)
{
ST_INT j;
SLOGALWAYS0 ("Array of UCA variable names (Uncompressed/Unsorted)");
for (j = 0; j<numRt; j++)
SLOGCALWAYS1 ("%s", ucaNames[j].ucaName);
SLOGALWAYS0 ("Array of UCA variable names (Compressed/Sorted)");
for (j = 0; j<numNames; j++)
SLOGCALWAYS1 ("%s", sortedNames[j].ucaName);
}
#endif
/* Now assign sort numbers to the RT elements */
for (i = 0; i < numNames; ++i)
{
sortedNames[i].rt->mvluTypeInfo.sortedNum = i+1;
}
M_FREE (MSMEM_GEN, sortedNames);
}

352
mmslib/mvlu/mvlu_sbo.c Normal file
View File

@@ -0,0 +1,352 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998-2004, All Rights Reserved. */
/* */
/* PROPRIETARY AND CONFIDENTIAL */
/* */
/* MODULE NAME : mvlu_sbo.c */
/* PRODUCT(S) : MMSEASE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 05/06/08 JRB 15 Chg sbo_pool from static to global. */
/* 02/26/07 JRB 14 initSboCtrl: add use_ms_timer arg. */
/* 01/27/05 JRB 13 Log if createSboName fails. */
/* 12/03/04 JRB 12 Move 61850 code to new module mvl61850_ctl.c.*/
/* Make initSboCtrl funct global so 61850 */
/* module can use it too. */
/* Use strrchr to find last '$'. */
/* 09/20/04 JRB 11 Replace chk_sbo_select w/ mvlu_sbo_chk_state.*/
/* Chg chk_sbo_timeouts to mvlu_sbo_chk_timers. */
/* Do timeouts ONLY in mvlu_sbo_chk_timers. */
/* Do "Select" only if SBO is ONLY attribute */
/* being read (not part of higher level var). */
/* Add funct mvlu_sbo_ctrl_free. */
/* Del currTime global variable. */
/* Pass sboTimeout arg to initSboCtrl. */
/* 12/11/02 JRB 10 Use new mvl_uca.h */
/* 12/09/02 MDE 09 Changed SBO reference handling */
/* 10/25/00 JRB 08 Add #ifdef MVL_UCA. */
/* 07/13/00 JRB 07 Add #ifdef USE_RT_TYPE_2. */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 09/07/99 MDE 05 Changed MVL_VA_SCOPE to MVL_SCOPE */
/* 12/11/98 MDE 04 Removed scope references from VA */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 02 Minor lint cleanup */
/* 09/11/98 MDE 01 New */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mvl_uca.h"
#include "mvl_log.h"
#if defined(MVL_UCA) /* This entire module is only valid for UCA. */
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* Global variables */
/************************************************************************/
MVL_SBO_CTRL sbo_pool[MAX_NUM_SBO_PEND];
/************************************************************************/
/* Static functions */
static ST_VOID createSboName (MVL_VAR_ASSOC *va, MVL_SCOPE *va_scope,
ST_CHAR *dest,
ST_BOOLEAN select, ST_RTREF primRef);
/************************************************************************/
/************************************************************************/
/* mvlu_sbo_select_rd_ind */
/* Leaf function for reading UCA "SBO" attribute (i.e. performing */
/* Control Model 'Select' Service). */
/* NOTE: do NOT use this leaf function for IEC 61850 SBO. */
/************************************************************************/
ST_VOID mvlu_sbo_select_rd_ind (MVLU_RD_VA_CTRL *mvluRdVaCtrl)
{
ST_CHAR *dest;
MVL_VAR_ASSOC *va;
MVL_SCOPE *va_scope;
ST_CHAR sboName[MAX_SBO_NAME_SIZE+1];
MVL_SBO_CTRL *sboCtrl;
ST_CHAR *lastdollar; /* ptr to last '$' in var name */
/* First take care of timeout housekeeping */
mvlu_sbo_chk_timers ();
/* find the name of the attribute being selected */
va = mvluRdVaCtrl->rdVaCtrl->va;
/* Only perform "Select" if SBO is ONLY attribute being read. */
/* Check this by seeing if variable name ends with "$SBO". */
/* Point to where "$SBO" should be, then see if it's there. */
lastdollar = strrchr (va->name, '$'); /* find last '$' */
if (lastdollar != NULL && strcmp (lastdollar+1, "SBO") == 0)
{
va_scope = &mvluRdVaCtrl->rdVaCtrl->va_scope;
createSboName (va, va_scope, sboName, SD_TRUE, mvluRdVaCtrl->primRef);
/* Get a SBO control element */
sboCtrl = initSboCtrl (mvluRdVaCtrl->indCtrl->event->net_info,sboName,
SBO_SELECT_TIMEOUT, SD_FALSE); /* timeout in seconds*/
if (sboCtrl == NULL)
{
mvlu_rd_prim_done (mvluRdVaCtrl, SD_FAILURE);
return;
}
}
else
/* Higher level variable read. Allow read, but just return NULL (empty) string.*/
sboName[0]='\0';
dest = (ST_CHAR *) mvluRdVaCtrl->primData;
strcpy (dest, sboName);
mvlu_rd_prim_done (mvluRdVaCtrl, SD_SUCCESS);
}
/************************************************************************/
/* mvlu_sbo_operate_wr_ind */
/* NOTE: this leaf function should be used only for UCA (not for 61850).*/
/************************************************************************/
ST_VOID mvlu_sbo_operate_wr_ind (MVLU_WR_VA_CTRL *mvluWrVaCtrl)
{
MVL_SBO_CTRL *sboSelect;
MVL_SCOPE *va_scope;
ST_CHAR sboName[MAX_SBO_NAME_SIZE+1];
/* First take care of timeout housekeeping */
mvlu_sbo_chk_timers ();
va_scope = &mvluWrVaCtrl->wrVaCtrl->va_scope;
createSboName (mvluWrVaCtrl->wrVaCtrl->va, &mvluWrVaCtrl->wrVaCtrl->va_scope, sboName, SD_FALSE, (ST_RTREF) 0);
sboSelect = mvlu_sbo_chk_state (sboName,
mvluWrVaCtrl->indCtrl->event->net_info);
if (sboSelect != NULL)
{
u_mvl_sbo_operate (sboSelect, mvluWrVaCtrl);
sboSelect->in_use = SD_FALSE;
}
else /* The select was not in place, cannot operate ... */
{
mvlu_wr_prim_done (mvluWrVaCtrl, SD_FAILURE);
}
}
/************************************************************************/
/* mvlu_clr_pend_sbo */
/************************************************************************/
ST_VOID mvlu_clr_pend_sbo (MVL_NET_INFO *net_info)
{
ST_INT i;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i)
{
if (sbo_pool[i].net_info == net_info)
sbo_pool[i].in_use = SD_FALSE;
}
}
/************************************************************************/
/************************************************************************/
/************************************************************************/
/* mvlu_sbo_chk_timers */
/************************************************************************/
ST_VOID mvlu_sbo_chk_timers ()
{
ST_INT i;
MVL_SBO_CTRL *sboCtrl;
time_t currTime;
ST_DOUBLE currTimeMs; /* current time in milliseconds */
currTime = time (NULL); /* PORT ISSUE: time() */
currTimeMs = sGetMsTime ();
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_TRUE)
{
if (sboCtrl->use_ms_timer)
{
if (sboCtrl->expire_time_ms < currTimeMs)
sboCtrl->in_use = SD_FALSE; /* SBO timer expired */
}
else /* use timer in seconds */
{
if (sboCtrl->expire_time < currTime)
sboCtrl->in_use = SD_FALSE; /* SBO timer expired */
}
/* renxiaobao <20><><EFBFBD><EFBFBD> */
if (sboCtrl->in_use != SD_TRUE)
printf("sboCtrl TimeOut : %s currTime: %5.0f \n",sboCtrl->sbo_var,sGetMsTime());
}
}
}
/************************************************************************/
/* initSboCtrl */
/************************************************************************/
MVL_SBO_CTRL *initSboCtrl (MVL_NET_INFO *net_info,
ST_CHAR *sbo_name,
ST_UINT32 sboTimeout,
ST_BOOLEAN use_ms_timer)
{
ST_INT i;
MVL_SBO_CTRL *sboCtrl;
time_t currTime = time (NULL);
/* OK, now see if the element is already selected */
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_TRUE && !strcmp (sboCtrl->sbo_var, sbo_name))
{
/* OK, already selected, make sure it is us then reset the timeout */
if (sboCtrl->net_info != net_info)
return (NULL);
if (sboCtrl->use_ms_timer)
sboCtrl->expire_time_ms = sGetMsTime () + sboTimeout;
else
sboCtrl->expire_time = currTime + sboTimeout;
return (sboCtrl);
}
}
/* The protected element is not selected, find a unused SBO control */
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_FALSE)
break;
}
if (i >= MAX_NUM_SBO_PEND)
return (NULL);
/* OK, we have a newly selected SBO control, set the parameters */
sboCtrl->in_use = SD_TRUE;
sboCtrl->use_ms_timer = use_ms_timer;
if (sboCtrl->use_ms_timer)
sboCtrl->expire_time_ms = sGetMsTime () + sboTimeout;
else
sboCtrl->expire_time = currTime + sboTimeout;
sboCtrl->net_info = net_info;
strcpy (sboCtrl->sbo_var, sbo_name);
return (sboCtrl);
}
/************************************************************************/
/* mvlu_sbo_chk_state */
/* Find the MVL_SBO_CTRL struct for this "sboName". */
/* Call createSboName (for UCA), mvl61850_sbo_create_sboname (for 61850)*/
/* to generate the "sboName" string to pass to this function. */
/************************************************************************/
MVL_SBO_CTRL *mvlu_sbo_chk_state (ST_CHAR *sboName,
MVL_NET_INFO *net_info)
{
ST_INT i;
MVL_SBO_CTRL *sboCtrl;
/* See if we have selected the element */
sboCtrl = sbo_pool;
for (i = 0; i < MAX_NUM_SBO_PEND; ++i, ++sboCtrl)
{
if (sboCtrl->in_use == SD_TRUE &&
!strcmp (sboCtrl->sbo_var, sboName) &&
sboCtrl->net_info == net_info)
{
return (sboCtrl);
}
}
return (NULL);
}
/************************************************************************/
/************************************************************************/
/* createSboName */
/* Creates a name to return when an UCA SBO attribute is read. */
/* NOTE: this name may also be passed to "mvlu_sbo_chk_state" */
/* to find the correct MVL_SBO_CTRL struct. */
/************************************************************************/
static ST_VOID createSboName (MVL_VAR_ASSOC *va, MVL_SCOPE *va_scope,
ST_CHAR *dest, ST_BOOLEAN select, ST_RTREF primRef)
{
ST_INT len;
/* if primRef is NULL, then don't perform the string table lookup */
switch (va_scope->scope)
{
case VMD_SPEC:
strcpy (dest, "/");
break;
case DOM_SPEC:
strcpy (dest, va_scope->dom->name);
strcat (dest, "/");
break;
case AA_SPEC:
strcpy (dest,"@/");
break;
}
/* Scope in place, now append the name of variable */
strcat (dest, va->name);
/* Now, "SBO" is the end of the name, and the reference is the index */
/* to the string for the component that is being selected. So, if we */
/* want the name of the protected element we just replace the "SBO" */
/* with the element name. */
if (select == SD_TRUE)
{
len = strlen (dest) - 3;
if (primRef != 0)
/* primRef must be a pointer to a string; name of protected element */
strcpy (&dest[len], (ST_CHAR *) primRef);
else
MVL_LOG_ERR1 ("SBO name generated '%s' is invalid", dest);
/* DEBUG: should this function return SD_FAILURE in this case? */
}
}
/************************************************************************/
/* mvlu_sbo_ctrl_free */
/* Frees the MVL_SBO_CTRL struct by setting in_use=SD_FALSE. */
/* Client must "Select" (i.e. read SBO) again before next "Operate". */
/************************************************************************/
void logprint(char * fmt,...);
ST_VOID mvlu_sbo_ctrl_free (MVL_SBO_CTRL *sboCtrl)
{
/* When writing non-SBO variables, sboCtrl == NULL. */
if (sboCtrl)
{
sboCtrl->in_use = SD_FALSE;
/*renxiaobao <20><><EFBFBD><EFBFBD>*/
//logprint("ctrl sboCtrl free : %s currTime: %5.0f \n",sboCtrl->sbo_var,sGetMsTime());
}
return;
}
#endif /* defined(MVL_UCA) */

477
mmslib/mvlu/mvluleaf.c Normal file
View File

@@ -0,0 +1,477 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998-2001, All Rights Reserved. */
/* */
/* PROPRIETARY AND CONFIDENTIAL */
/* */
/* MODULE NAME : mvluleaf.c */
/* PRODUCT(S) : MMSEASE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 10/11/06 JRB 06 Add mvlu_set_leaf_param_name2. */
/* mvlu_load_xml_leaf_file: fix error return. */
/* 09/13/05 JRB 05 Add ERR log if mvlu_find_..._fun_index fails.*/
/* 07/08/04 JRB 04 Fix "Reference" log msg. */
/* 12/20/02 JRB 03 mvlu_set_leaf_param moved here. */
/* MVL_LEAF_FUN_LOOKUP_ENABLE MUST be defined */
/* for all except mvlu_set_leaf_param. */
/* 12/11/02 JRB 02 Use new mvl_uca.h */
/* 11/12/02 MDE 01 New */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_uca.h"
#include "mvl_log.h"
#if defined(MVL_UCA) /* This entire module is only valid for UCA. */
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/* Most of the code in this module requires this to be defined. */
#if defined(MVLU_LEAF_FUN_LOOKUP_ENABLE)
/************************************************************************/
#define MAX_LEAF_NAME 200
#define MAX_FUN_NAME 200
#define MAX_REF_NAME 200
static ST_VOID _getAttribVal (ST_CHAR *xmlBuf, ST_CHAR *attribName,
ST_CHAR *dest, ST_INT destSize);
/************************************************************************/
/************************************************************************/
/* mvlu_load_xml_leaf_file */
/* NOTE: continue after errors, but save the last error detected and */
/* return it. */
/************************************************************************/
ST_RET mvlu_load_xml_leaf_file (ST_CHAR *fileName)
{
FILE *fp;
ST_CHAR leafName[MAX_LEAF_NAME+1];
ST_CHAR rdIndFunName[MAX_FUN_NAME+1];
ST_CHAR wrIndFunName[MAX_FUN_NAME+1];
ST_CHAR refString[MAX_REF_NAME+1];
ST_CHAR buf[1000];
ST_CHAR *p;
ST_INT setFlags;
ST_RET ret;
ST_RET last_error = SD_SUCCESS; /* save last error detected */
fp = fopen (fileName, "rt");
if (fp == NULL)
{
MVL_LOG_NERR1 ("Could not open leaf map XML file '%s'", fileName);
return (SD_FAILURE);
}
/* Now read in the file and set the leaf parameters */
MVLU_LOG_FLOW1 ("Setting Leaf Parameters using file '%s'", fileName);
ret = SD_SUCCESS;
while (SD_TRUE)
{
leafName[0] = 0;
rdIndFunName[0] = 0;
wrIndFunName[0] = 0;
refString[0] = 0;
if (fgets (buf, sizeof(buf) - 1, fp) == NULL)
break;
if (strstr (buf, "<Leafmap>") != NULL)
continue;
if (strstr (buf, "</Leafmap>") != NULL)
break;
p = strstr (buf, "<Leaf ");
if (!p)
continue;
_getAttribVal (p, "Name", leafName, sizeof (leafName));
_getAttribVal (p, "RdIndFun", rdIndFunName, sizeof (rdIndFunName));
_getAttribVal (p, "WrIndFun", wrIndFunName, sizeof (wrIndFunName));
_getAttribVal (p, "Ref", refString, sizeof (refString));
if (leafName[0] == 0)
{
MVL_LOG_NERR1 ("'Name' attribute not present in '%s'", buf);
ret = SD_FAILURE;
break;
}
setFlags = 0;
if (rdIndFunName[0] != 0)
setFlags |= MVLU_SET_RD_FUN;
if (wrIndFunName[0] != 0)
setFlags |= MVLU_SET_WR_FUN;
if (refString[0] != 0)
setFlags |= MVLU_SET_REF;
ret = mvlu_set_leaf_param_name (setFlags, leafName,
rdIndFunName, wrIndFunName, refString);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Could not set leaf %s parameters", leafName);
last_error = ret; /* save last error detected */
}
}
fclose (fp);
return (last_error); /* return last error detected */
}
/************************************************************************/
/* _getAttribVal */
/************************************************************************/
static ST_VOID _getAttribVal (ST_CHAR *xmlBuf, ST_CHAR *attribName,
ST_CHAR *dest, ST_INT destSize)
{
ST_CHAR *p;
ST_CHAR look[50];
*dest = 0;
strcpy (look, attribName);
strcat (look, "=\"");
p = strstr (xmlBuf, look);
if (!p)
return;
p += strlen (look);
while (*p != 0 && *p != '"' && destSize > 0)
{
*(dest++) = *(p++);
--destSize;
}
*dest = 0;
}
/************************************************************************/
/* mvlu_set_leaf_param_name */
/************************************************************************/
ST_RET mvlu_set_leaf_param_name (ST_INT setFlags, ST_CHAR *leafName,
ST_CHAR *rdIndFunName, ST_CHAR *wrIndFunName,
ST_CHAR *refString)
{
ST_RTINT rdIndex;
ST_RTINT wrIndex;
ST_RTREF ref;
ST_RET ret;
if (setFlags & MVLU_SET_RD_FUN)
{
rdIndex = mvlu_find_rd_ind_fun_index (rdIndFunName);
if (rdIndex < 0)
{
/* Error already logged in "mvlu_find_rd.." function. */
return (SD_FAILURE);
}
}
if (setFlags & MVLU_SET_WR_FUN)
{
wrIndex = mvlu_find_wr_ind_fun_index (wrIndFunName);
if (wrIndex < 0)
{
/* Error already logged in "mvlu_find_wr.." function. */
return (SD_FAILURE);
}
}
ret = u_mvlu_resolve_leaf_ref (leafName, &setFlags, refString, &ref);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Could not resolve reference '%s'", refString);
return (SD_FAILURE);
}
MVLU_LOG_FLOW1 ("Setting Leaf Parameters for leaf '%s'", leafName);
if (setFlags & MVLU_SET_RD_FUN)
{
MVLU_LOG_CFLOW2 (" Read Indication: %s\t(%d)", rdIndFunName, (int) rdIndex);
}
if (setFlags & MVLU_SET_WR_FUN)
{
MVLU_LOG_CFLOW2 (" Write Indication: %s\t(%d)", wrIndFunName, (int) wrIndex);
}
if (setFlags & MVLU_SET_REF)
{
MVLU_LOG_CFLOW1 (" Reference: 0x%X", (long) ref);
}
ret = mvlu_set_leaf_param (setFlags, leafName, rdIndex, wrIndex, (ST_RTREF) ref);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Could not set leaf %s parameters", leafName);
}
return (ret);
}
/************************************************************************/
/* mvlu_find_rd_ind_fun_index */
/************************************************************************/
ST_RTINT mvlu_find_rd_ind_fun_index (ST_CHAR *funName)
{
ST_RTINT rdIndex;
for (rdIndex = 0; rdIndex < mvluNumRdFunEntries; ++rdIndex)
{
if (!strcmp (funName, mvluRdFunInfoTbl[rdIndex].fun_name))
break;
}
if (rdIndex >= mvluNumRdFunEntries)
{
MVL_LOG_ERR1 ("Could not find 'leaf read' function '%s'", funName);
return (-1);
}
return (rdIndex);
}
/************************************************************************/
/* mvlu_find_wr_ind_fun_index */
/************************************************************************/
ST_RTINT mvlu_find_wr_ind_fun_index (ST_CHAR *funName)
{
ST_RTINT wrIndex;
for (wrIndex = 0; wrIndex < mvluNumWrFunEntries; ++wrIndex)
{
if (!strcmp (funName, mvluWrFunInfoTbl[wrIndex].fun_name))
break;
}
if (wrIndex >= mvluNumWrFunEntries)
{
MVL_LOG_ERR1 ("Could not find 'leaf write' function '%s'", funName);
return (-1);
}
return (wrIndex);
}
/************************************************************************/
#endif /* defined(MVLU_LEAF_FUN_LOOKUP_ENABLE) */
/************************************************************************/
/************************************************************************/
/* mvlu_set_leaf_param */
/* DEBUG: could change this to call mvlu_set_leaf_param2 after type found.*/
/************************************************************************/
ST_RET mvlu_set_leaf_param (ST_INT setFlags, ST_CHAR *leafName,
ST_RTINT rdIndFunIndex, ST_RTINT wrIndFunIndex,
ST_RTREF ref)
{
RUNTIME_TYPE *rt;
ST_INT type_id;
ST_CHAR *leafNameBuf;
ST_CHAR *p;
/* Make a working copy */
leafNameBuf = chk_strdup (leafName);
rt = NULL; /* Flag that we failed */
/* The type name must be the first part of this string */
p = strstr (leafNameBuf, "$");
if (p)
{
*p = 0;
type_id = mvl_typename_to_typeid (leafNameBuf);
if (type_id >= 0)
{
++p;
rt = mvlu_find_rt_leaf (type_id, p);
}
else
{
MVL_LOG_NERR1 ("Could not find type '%s'", leafNameBuf);
}
}
else
{
MVL_LOG_NERR1 ("Could not find type '%s'", leafNameBuf);
}
chk_free (leafNameBuf);
if (!rt)
return (SD_FAILURE);
if (setFlags & MVLU_SET_RD_FUN)
{
if (u_mvlu_leaf_rd_ind_fun == NULL && rdIndFunIndex >= mvluNumRdFunEntries)
{
MVL_LOG_NERR0 ("Read ind function index out of range for use with default leaf read handler");
return (SD_FAILURE);
}
rt->mvluTypeInfo.rdIndFunIndex = rdIndFunIndex;
}
if (setFlags & MVLU_SET_WR_FUN)
{
if (u_mvlu_leaf_wr_ind_fun == NULL && wrIndFunIndex >= mvluNumWrFunEntries)
{
MVL_LOG_NERR0 ("Write ind function index out of range for use with default leaf write handler");
return (SD_FAILURE);
}
rt->mvluTypeInfo.wrIndFunIndex = wrIndFunIndex;
}
#if defined(MVLU_USE_REF)
if (setFlags & MVLU_SET_REF)
rt->mvluTypeInfo.ref = ref;
#endif /* MVLU_USE_REF */
return (SD_SUCCESS);
}
/************************************************************************/
/* mvlu_set_leaf_param2 */
/* Similar to mvlu_set_leaf_param but uses additional base_var_type_id arg.*/
/************************************************************************/
static ST_RET mvlu_set_leaf_param2 (ST_INT base_var_type_id,
ST_INT setFlags,
ST_CHAR *leafName,
ST_RTINT rdIndFunIndex,
ST_RTINT wrIndFunIndex,
ST_RTREF ref)
{
RUNTIME_TYPE *rt;
ST_CHAR *p;
/* The name to find starts after the first '$'. */
p = strstr (leafName, "$");
if (p)
{
++p; /* point after '$' */
rt = mvlu_find_rt_leaf (base_var_type_id, p);
if (!rt)
MVL_LOG_NERR1 ("Cannot find leaf '%s'", leafName);
}
else
{
MVL_LOG_NERR1 ("Cannot find leaf. No '$' in leaf name '%s'", leafName);
rt = NULL;
}
if (!rt)
return (SD_FAILURE);
if (setFlags & MVLU_SET_RD_FUN)
{
if (u_mvlu_leaf_rd_ind_fun == NULL && rdIndFunIndex >= mvluNumRdFunEntries)
{
MVL_LOG_NERR0 ("Read ind function index out of range for use with default leaf read handler");
return (SD_FAILURE);
}
rt->mvluTypeInfo.rdIndFunIndex = rdIndFunIndex;
}
if (setFlags & MVLU_SET_WR_FUN)
{
if (u_mvlu_leaf_wr_ind_fun == NULL && wrIndFunIndex >= mvluNumWrFunEntries)
{
MVL_LOG_NERR0 ("Write ind function index out of range for use with default leaf write handler");
return (SD_FAILURE);
}
rt->mvluTypeInfo.wrIndFunIndex = wrIndFunIndex;
}
#if defined(MVLU_USE_REF)
if (setFlags & MVLU_SET_REF)
rt->mvluTypeInfo.ref = ref;
#endif /* MVLU_USE_REF */
return (SD_SUCCESS);
}
/************************************************************************/
/* mvlu_set_leaf_param_name2 */
/* Similar to mvlu_set_leaf_param_name but uses additional base_var_type_id arg.*/
/************************************************************************/
ST_RET mvlu_set_leaf_param_name2 (ST_INT base_var_type_id,
ST_INT setFlags,
ST_CHAR *leafName,
ST_CHAR *rdIndFunName,
ST_CHAR *wrIndFunName,
ST_CHAR *refString)
{
ST_RTINT rdIndex;
ST_RTINT wrIndex;
ST_RTREF ref;
ST_RET ret;
if (setFlags & MVLU_SET_RD_FUN)
{
rdIndex = mvlu_find_rd_ind_fun_index (rdIndFunName);
if (rdIndex < 0)
{
/* Error already logged in "mvlu_find_rd.." function. */
return (SD_FAILURE);
}
}
if (setFlags & MVLU_SET_WR_FUN)
{
wrIndex = mvlu_find_wr_ind_fun_index (wrIndFunName);
if (wrIndex < 0)
{
/* Error already logged in "mvlu_find_wr.." function. */
return (SD_FAILURE);
}
}
ret = u_mvlu_resolve_leaf_ref (leafName, &setFlags, refString, &ref);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Could not resolve reference '%s'", refString);
return (SD_FAILURE);
}
MVLU_LOG_FLOW1 ("Setting Leaf Parameters for leaf '%s'", leafName);
if (setFlags & MVLU_SET_RD_FUN)
{
MVLU_LOG_CFLOW2 (" Read Indication: %s\t(%d)", rdIndFunName, (int) rdIndex);
}
if (setFlags & MVLU_SET_WR_FUN)
{
MVLU_LOG_CFLOW2 (" Write Indication: %s\t(%d)", wrIndFunName, (int) wrIndex);
}
if (setFlags & MVLU_SET_REF)
{
MVLU_LOG_CFLOW1 (" Reference: 0x%X", (long) ref);
}
ret = mvlu_set_leaf_param2 (base_var_type_id, setFlags, leafName, rdIndex, wrIndex, (ST_RTREF) ref);
if (ret != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Could not set leaf %s parameters", leafName);
}
return (ret);
}
/************************************************************************/
#endif /* defined(MVL_UCA) */
/************************************************************************/

53
mmslib/mvlu/s_cancel.c Normal file
View File

@@ -0,0 +1,53 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_cancel.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/11/04 GLB 09 Remove "thisFileName" */
/* 09/21/01 JRB 08 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 07 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 04/01/99 MDE 05 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 03 Minor lint cleanup */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_cancel_ind */
/* A MMS MMSOP_CANCEL request has been received. For now, just send error */
/************************************************************************/
ST_VOID _mvl_process_cancel_ind (MVL_COMM_EVENT *event)
{
ST_RET rc;
/* Build cancel error response message, */
/* class = Cancel, code = 'Cancel Not Possible' */
rc = mpl_cancel_err (event->u.mms.dec_rslt.id, 10, 2);
_mvl_send_resp (event, rc);
}

99
mmslib/mvlu/s_concl.c Normal file
View File

@@ -0,0 +1,99 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_concl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 05/14/08 JRB 07 Add mplas_concl_err. */
/* 05/01/02 MDE 06 Added MLOG logging */
/* 10/25/00 JRB 05 Pass ind up to user. User must call resp fct */
/* 09/13/99 MDE 04 Added SD_CONST modifiers */
/* 11/16/98 MDE 03 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mvl_defs.h"
#include "mvl_log.h"
#include "mloguser.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_process_concl_ind */
/* A Conclude indication has been received. Pass it up to user. */
/************************************************************************/
ST_VOID _mvl_process_concl_ind (MVL_COMM_EVENT *event)
{
/* Pass up to user for processing. User must call mplas_concl_resp */
/* to send Conclude response. */
u_mvl_concl_ind (event);
}
/************************************************************************/
/* _mvl_process_concl_ind */
/* Send Conclude response. */
/************************************************************************/
ST_VOID mplas_concl_resp (MVL_COMM_EVENT *event)
{
ST_RET rc;
/* We can log here if so desired */
if ((mms_debug_sel & MMS_LOG_RESP) && ml_log_resp_info_fun != NULL)
(*ml_log_resp_info_fun) (0, MMSOP_CONCLUDE, NULL);
/* Send a Conclude response */
rc = _mvl_send_msg ((ST_UCHAR *) "\x8C\x00",2,event->net_info);
if (rc != SD_SUCCESS)
MVL_LOG_NERR1 ("Conclude Indication : _mvl_send_msg failed, ret = %x", rc);
_mvl_free_comm_event (event); /* All done with this event */
}
/************************************************************************/
/* mplas_concl_err */
/* Send Conclude error response. */
/* NOTE: err_class should always be 9, and err_code should be 0 or 1. */
/************************************************************************/
ST_RET mplas_concl_err (MVL_COMM_EVENT *event, ST_INT16 err_class, ST_INT16 err_code)
{
ST_RET rc;
rc = mpl_conclude_err (err_class,err_code); /* encode Conclude-ErrorPDU*/
if (rc)
{ /* Should never happen. No good recovery. */
MVL_LOG_ERR1 ("Error encoding Conclude-ErrorPDU, rc = %x", rc);
}
else
{ /* send it */
rc = _mvl_send_msg (mmsl_msg_start,mmsl_msg_len,event->net_info);
if (rc != SD_SUCCESS)
MVL_LOG_ERR1 ("Error sending Conclude-ErrorPDU, rc = %x", rc);
}
return (rc);
}

137
mmslib/mvlu/s_defvl.c Normal file
View File

@@ -0,0 +1,137 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : s_defvl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_defvlist_ind */
/* mvlas_defvlist_resp */
/* mplas_defvlist_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 03/06/08 JRB 17 Send error resp if any variable not Named. */
/* 04/09/07 MDE 16 Enhanced filtered logging */
/* 02/21/07 JRB 15 Fix comment. */
/* 10/30/06 JRB 14 Use new mvl_vmd_* object handling functions. */
/* 01/30/06 GLB 13 Integrated porting changes for VMS */
/* 09/21/01 JRB 12 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 11 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 10 Added SD_CONST modifiers */
/* 01/20/99 JRB 09 Use new mvl_nvl_add (simpler, more efficient)*/
/* 01/14/99 JRB 08 BUG FIX: Increment variable_list in loop. */
/* 12/11/98 MDE 07 Removed scope references from VA */
/* 11/16/98 MDE 06 Allow use of manufactured variables */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 07/09/98 JRB 04 Set altAcc=NULL (no alternate access). */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 06/05/98 MDE 02 Moved 'mvl_insert_nvlist' elsewhere */
/* 04/14/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/* _mvl_process_defvlist_ind */
/* A "defvlist" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_defvlist_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.defvlist.req_info =
(DEFVLIST_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_defvlist_ind (indCtrl);
}
/************************************************************************/
/* mvlas_defvlist_resp */
/* Most of this code doesn't care whether the Named Variable List is */
/* VMD-specific, Dom-specific, etc. */
/************************************************************************/
ST_VOID mvlas_defvlist_resp (MVL_IND_PEND *indCtrl)
{
MVL_NVLIST_CTRL *nvlist_ctrl; /* alloc, fill in, & then copy to list */
ST_INT j;
VARIABLE_LIST *variable_list;
DEFVLIST_REQ_INFO *req_info = indCtrl->u.defvlist.req_info;
OBJECT_NAME *tmp_obj_array;
if (req_info->num_of_variables <= 0)
{
_mplas_err_resp (indCtrl,4,0); /* Service error , other */
return;
}
variable_list = (VARIABLE_LIST *) (req_info + 1);
/* Create temporary obj array from var list. */
tmp_obj_array = (OBJECT_NAME *) M_MALLOC (MSMEM_GEN, req_info->num_of_variables * sizeof (OBJECT_NAME));
for (j = 0; j < req_info->num_of_variables; j++, variable_list++)
{
if (variable_list->var_spec.var_spec_tag != VA_SPEC_NAMED)
{ /* Only "Named" variables supported */
_mplas_err_resp (indCtrl, MMS_ERRCLASS_DEFINITION, MMS_ERRCODE_TYPE_UNSUPPORTED);
M_FREE (MSMEM_GEN, tmp_obj_array); /* cleanup */
return; /* stop now */
}
memcpy (&tmp_obj_array [j], &variable_list->var_spec.vs.name, sizeof (OBJECT_NAME));
}
/* NOTE: Use "obj_name.vmd_spec" for an object of any scope, */
/* because "obj_name" is a union of identical type objects. */
nvlist_ctrl = mvl_vmd_nvl_add (&mvl_vmd, &req_info->vl_name, indCtrl->event->net_info,
req_info->num_of_variables, tmp_obj_array,
SD_TRUE); /* copy name because it is volatile */
M_FREE (MSMEM_GEN, tmp_obj_array); /* free temporary object array. */
if (nvlist_ctrl == NULL)
{ /* Failed. */
_mplas_err_resp (indCtrl,4,0); /* Service error, other */
return;
}
nvlist_ctrl->mms_deletable = SD_TRUE; /* MMS spec requires this*/
nvlist_ctrl->altAcc = NULL; /* Don't support alternate access*/
mplas_defvlist_resp (indCtrl);
}
/************************************************************************/
/* mplas_defvlist_resp */
/************************************************************************/
ST_VOID mplas_defvlist_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a "defvlist" response (no response info). */
rc = mpl_defvlist_resp (indCtrl->event->u.mms.dec_rslt.id);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, NULL);
_mvl_send_resp_i (indCtrl, rc);
}

190
mmslib/mvlu/s_delvl.c Normal file
View File

@@ -0,0 +1,190 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : s_delvl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_delvlist_ind */
/* mvlas_delvlist_resp */
/* mplas_delvlist_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 16 Enhanced filtered logging */
/* 10/30/06 JRB 15 Use new mvl_vmd_* object handling functions. */
/* 08/21/06 JRB 14 Check mms_deletable flag in DELVL_SPEC case. */
/* 09/21/01 JRB 13 Alloc global bufs only once at startup. */
/* 07/13/00 JRB 12 Init num_matched, num_deleted for DELVL_SPEC.*/
/* 01/21/00 MDE 11 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 10 Added SD_CONST modifiers */
/* 04/07/99 JRB 09 Add support for SPECIFIC scope. */
/* 04/07/99 MDE 08 Logging improvements */
/* 01/21/99 JRB 07 Add support for AA-specific scope. */
/* 01/14/99 JRB 06 Use new "bsearch" object model. */
/* 11/16/98 MDE 05 Now use '_mvl_destroy_nvl_entries' */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 06/22/98 MDE 03 More changes to allow compile under C++ */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 04/14/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
static ST_RET delete_nvlist (DELVLIST_RESP_INFO *resp_info,
ST_INT *num_nvlist,
MVL_NVLIST_CTRL **nvlist_tbl);
/************************************************************************/
/* _mvl_process_delvlist_ind */
/* A "delvlist" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_delvlist_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.delvlist.req_info =
(DELVLIST_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_delvlist_ind (indCtrl);
}
/************************************************************************/
/* mvlas_delvlist_resp */
/************************************************************************/
ST_VOID mvlas_delvlist_resp (MVL_IND_PEND *indCtrl)
{
DELVLIST_RESP_INFO resp_info;
DELVLIST_REQ_INFO *req_info = indCtrl->u.delvlist.req_info;
MVL_DOM_CTRL *mvl_dom;
MVL_AA_OBJ_CTRL *aa_objs;
ST_INT j;
OBJECT_NAME *obj_name;
MVL_NVLIST_CTRL *nvl;
if (req_info->scope == DELVL_VMD)
{
/* "delete_nvlist" deletes all deletable ("mvl_obj_delete" can't).*/
if (delete_nvlist (&resp_info, &mvl_vmd.num_nvlist, mvl_vmd.nvlist_tbl))
{
_mplas_err_resp (indCtrl,4,0); /* Service error , other */
return;
}
}
else if (req_info->scope == DELVL_DOM)
{
mvl_dom = mvl_vmd_find_dom (&mvl_vmd, req_info->dname);
if (mvl_dom == NULL)
{
MVL_LOG_NERR1 ("Delete NVL ind: Domain '%s' not found", req_info->dname);
_mplas_err_resp (indCtrl,2,1); /* Object undefined */
return;
}
/* "delete_nvlist" deletes all deletable ("mvl_obj_delete" can't).*/
if (delete_nvlist (&resp_info, &mvl_dom->num_nvlist, mvl_dom->nvlist_tbl))
{
_mplas_err_resp (indCtrl,4,0); /* Service error , other */
return;
}
}
else if (req_info->scope == DELVL_AA)
{
aa_objs = indCtrl->event->net_info->aa_objs;
/* "delete_nvlist" deletes all deletable ("mvl_obj_delete" can't).*/
if (delete_nvlist (&resp_info, &aa_objs->num_nvlist, aa_objs->nvlist_tbl))
{
_mplas_err_resp (indCtrl,4,0); /* Service error , other */
return;
}
}
else
{ /* Must be DELVL_SPEC (i.e. delete listed NVLs). */
/* Init "obj_name" to point to array of OBJECT_NAME structs which */
/* MMS decoder puts right after the "req_info" struct. */
resp_info.num_matched = 0;
resp_info.num_deleted = 0;
obj_name = (OBJECT_NAME *) (req_info + 1);
for (j = 0; j < req_info->num_of_vnames; j++, obj_name++)
{
if ((nvl = mvl_vmd_find_nvl (&mvl_vmd, obj_name, indCtrl->event->net_info)) != NULL)
{
resp_info.num_matched++;
if (nvl->mms_deletable &&
mvl_vmd_nvl_remove (&mvl_vmd, obj_name, indCtrl->event->net_info) == SD_SUCCESS)
resp_info.num_deleted++;
}
}
}
indCtrl->u.delvlist.resp_info = &resp_info;
mplas_delvlist_resp (indCtrl);
}
/************************************************************************/
/* mplas_delvlist_resp */
/************************************************************************/
ST_VOID mplas_delvlist_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a "delvlist" response */
rc = mpl_delvlist_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.delvlist.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.delvlist.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}
/************************************************************************/
/* delete_nvlist */
/* This function deletes all nvlists with "mms_deletable == TRUE". */
/* It is more efficient than multiple calls to "mvl_obj_delete" */
/* because it deletes multiple entries with one call. */
/* This function fills in "resp_info" and modifies "*num_mvlist" and */
/* the array pointed to by "nvlist_tbl". */
/************************************************************************/
static ST_RET delete_nvlist (DELVLIST_RESP_INFO *resp_info,
ST_INT *num_nvlist,
MVL_NVLIST_CTRL **nvlist_tbl)
{
ST_INT j, k;
resp_info->num_matched = (*num_nvlist);
resp_info->num_deleted = 0; /* Init count. */
for (j = 0, k = 0; j < (*num_nvlist); j++)
{
if (nvlist_tbl[j]->mms_deletable)
{
/* free up allocated resources for this nvlist */
mvl_nvl_destroy (nvlist_tbl[j]);
resp_info->num_deleted++; /* Increment count. */
}
else
{ /* move this entry up in array. */
nvlist_tbl[k] = nvlist_tbl[j];
k++; /* Increment count of entries left. */
}
}
(*num_nvlist) -= (ST_INT) resp_info->num_deleted;
return (SD_SUCCESS);
}

68
mmslib/mvlu/s_fclose.c Normal file
View File

@@ -0,0 +1,68 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_fclose.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_fclose_ind */
/* mplas_fclose_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_fclose_ind */
/* A file close indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_fclose_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.fclose.req_info =
(FCLOSE_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_fclose_ind (indCtrl);
}
/************************************************************************/
/* mplas_fclose_resp */
/************************************************************************/
ST_VOID mplas_fclose_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a File Close response */
rc = mpl_fclose_resp (indCtrl->event->u.mms.dec_rslt.id);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, NULL);
_mvl_send_resp_i (indCtrl, rc);
}

77
mmslib/mvlu/s_fdel.c Normal file
View File

@@ -0,0 +1,77 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : s_fdel.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_fdelete_ind */
/* mplas_fdelete_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 10 Enhanced filtered logging */
/* 03/11/04 GLB 09 Remove "thisFileName" */
/* 09/21/01 JRB 08 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 07 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 04/01/99 MDE 05 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 03 Minor lint cleanup */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 04/14/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* _mvl_process_fdelete_ind */
/* A "fdelete" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_fdelete_ind (MVL_IND_PEND *indCtrl)
{
FDELETE_REQ_INFO *req_info;
MVLAS_FDELETE_CTRL *fdelete;
fdelete = &indCtrl->u.fdelete;
req_info = (FDELETE_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
if (_mvl_concat_filename (fdelete->filename, req_info->num_of_fname,
(FILE_NAME *)(req_info + 1), sizeof (fdelete->filename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
u_mvl_fdelete_ind (indCtrl);
}
/************************************************************************/
/* mplas_fdelete_resp */
/************************************************************************/
ST_VOID mplas_fdelete_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a "fdelete" response */
rc = mpl_fdelete_resp (indCtrl->event->u.mms.dec_rslt.id);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, NULL);
_mvl_send_resp_i (indCtrl, rc);
}

769
mmslib/mvlu/s_fdir.c Normal file
View File

@@ -0,0 +1,769 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_fdir.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_fdir_ind */
/* mplas_fdir_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 13 Enhanced filtered logging */
/* 03/09/05 CRM 12 Added mvlas_fdir_resp, convertFileTime, and */
/* fileFdirEnt functions for WIN32 defined */
/* 09/21/01 JRB 11 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 10 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 09/13/00 JRB 09 Compute resp_info size (don't use const). */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/*-----------------------------------------*/
/* Global definitions used by all systems */
/*-----------------------------------------*/
/*
#define SERVICE_OVRHD 20
#define DIR_ENTRY_OVRHD 32
*/
#define SERVICE_OVRHD 256
#define DIR_ENTRY_OVRHD 64
/************************************************************************/
/************************************************************************/
/* _mvl_process_fdir_ind */
/* A fdir indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_fdir_ind (MVL_IND_PEND *indCtrl)
{
FDIR_REQ_INFO *req_info;
FILE_NAME *fs_fname; /* ptr to array of FILE_NAME for "fs" */
FILE_NAME *ca_fname; /* ptr to array of FILE_NAME for "ca" */
MVLAS_FDIR_CTRL *fdir;
fdir = &indCtrl->u.fdir;
req_info = (FDIR_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
/* fs_fname array is right after req_info */
fs_fname = (FILE_NAME *)(req_info + 1);
/* ca_fname array is right after fs_fname array */
ca_fname = fs_fname + req_info->num_of_fs_fname;
if (req_info->filespec_pres)
{
if (_mvl_concat_filename (fdir->fs_filename, req_info->num_of_fs_fname,
fs_fname, sizeof (fdir->fs_filename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
}
else
fdir->fs_filename[0] = 0;
if (req_info->cont_after_pres)
{
if (_mvl_concat_filename (fdir->ca_filename, req_info->num_of_ca_fname,
ca_fname, sizeof (fdir->ca_filename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
}
else
fdir->ca_filename[0] = 0;
u_mvl_fdir_ind (indCtrl);
}
/************************************************************************/
/* mplas_fdir_resp */
/************************************************************************/
ST_VOID mplas_fdir_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
FDIR_RESP_INFO *resp_info;
ST_UINT resp_size; /* size of "resp_info" */
FDIR_DIR_ENT *fdir_entry;
FILE_NAME *fname;
ST_INT j;
MVL_FDIR_RESP_INFO *mvl_resp_info;
mvl_resp_info = indCtrl->u.fdir.resp_info;
/* Compute size needed for "resp_info". */
/* NOTE: num_of_fname is always 1, so total_num_of_fname = num_dir_ent. */
resp_size = sizeof (FDIR_RESP_INFO)
+ (mvl_resp_info->num_dir_ent * sizeof (FDIR_DIR_ENT))
+ (mvl_resp_info->num_dir_ent * sizeof (FILE_NAME));
resp_info = (FDIR_RESP_INFO *) M_CALLOC (MSMEM_ENC_OS_INFO, 1, resp_size);
resp_info->num_dir_ent = mvl_resp_info->num_dir_ent;
resp_info->more_follows = mvl_resp_info->more_follows;
for (j = 0, fdir_entry = (FDIR_DIR_ENT *) (resp_info + 1);
j < resp_info->num_dir_ent; j++)
{
fdir_entry->fsize = mvl_resp_info->dir_ent[j].fsize;
fdir_entry->mtimpres = mvl_resp_info->dir_ent[j].mtimpres;
fdir_entry->mtime = mvl_resp_info->dir_ent[j].mtime;
fdir_entry->num_of_fname = 1; /* we always use 1 */
fname = (FILE_NAME *) (fdir_entry + 1);
fname->fn_len = strlen (mvl_resp_info->dir_ent[j].filename);
fname->fname = mvl_resp_info->dir_ent[j].filename;
/* always 1 fname, so point after it to get to next fdir_entry. */
fdir_entry = (FDIR_DIR_ENT *) (fname + 1);
}
/* Build a File Directory response */
rc = mpl_fdir_resp (indCtrl->event->u.mms.dec_rslt.id, resp_info);
_mvl_send_resp_i (indCtrl, rc);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.getvar.resp_info);
M_FREE (MSMEM_ENC_OS_INFO, resp_info);
}
/*renxiaobao <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>*/
#if defined(linux) || defined(__ECOS) || defined(VXWORKS)
#include <dirent.h>
int MMS_DIR_READ_MAX = 200;
ST_VOID fillFdirEnt (struct stat *pstFindData, FDIR_DIR_ENT *pstFdirEnt,
FILE_NAME *pstFileName, ST_CHAR *nameBuffer,ST_CHAR *FileName)
{
time_t theTime;
/* Fill in the FDIR_DIR_ENT struct. */
/*printf("%s st_size %d st_mtime %lu ...\n",FileName,pstFindData->st_size,pstFindData->st_mtime);*/
theTime = pstFindData->st_mtime;
pstFdirEnt->fsize = pstFindData->st_size ;
/* theTime = 1022036250;
if (theTime == -1) */
if (theTime < 0)
{
printf("fillFdirEnt theTime = %lx\n",theTime);
pstFdirEnt->mtimpres = SD_FALSE;
}
else
{
pstFdirEnt->mtimpres = SD_TRUE;
pstFdirEnt->mtime = (ST_INT32) theTime;
}
pstFdirEnt->num_of_fname = 1;
/* Fill in nameBuffer. */
strcpy (nameBuffer, FileName);
if(S_ISDIR (pstFindData->st_mode))
{
/*strcat (nameBuffer, "\\");*/
strcat (nameBuffer, "/");
pstFdirEnt->fsize = pstFindData->st_size ;
}
/* Fill in the FILE_NAME struct. */
pstFileName->fname = nameBuffer;
pstFileName->fn_len = strlen (nameBuffer);
}
short fdir_fullname_flag=1;
extern int mms_filename_conv(char *mms_name,char *sys_name);
extern int mms_open_root_dir();
extern char mms_root_dir_buf[16][32];
extern char sys_root_dir_buf[16][32];
int root_dir_num=0;
#if defined(__ECOS)
void UTF_8ToGB2312(char *pOut, char *pText, int pLen);
char *GB_UTF(unsigned char *p_desStr,unsigned char *p_srcStr);
#define file_utf_to_gb2312 UTF_8ToGB2312
#define file_gb2312_to_utf GB_UTF
#endif
#if defined(VXWORKS)
void gb2312_convert_uft8(char *p_desStr,char *p_srcStr);
void utf8_convert_gb2312(char *pOut, char *pText, int pLen);
#define file_utf_to_gb2312 utf8_convert_gb2312
#define file_gb2312_to_utf gb2312_convert_uft8
#endif
ST_VOID mvlas_fdir_resp (MVL_IND_PEND *indCtrl)
{
ST_INT status,ret;
ST_CHAR tmp_name [128];
ST_CHAR sys_name [128];
ST_CHAR fs_name [128];
ST_CHAR ca_name [128];
ST_CHAR filename [128];
FDIR_RESP_INFO *rsp_ptr;
FDIR_DIR_ENT *dir_ptr;
ST_INT rsp_size;
ST_CHAR *name_ptr;
ST_INT total_len, doMore;
FILE_NAME *fname_ptr;
ST_UCHAR found_ca = SD_FALSE;
ST_CHAR *data_buf;
MVLAS_FDIR_CTRL *fdir_ctrl;
ST_INT negotiatedPduSize;
ST_INT max_dir_ents;
ST_RET rc;
DIR *dir=0;
struct dirent *dirptr;
struct stat file_stat;
MVL_FDIR_RESP_INFO resp_info;
ST_CHAR *tmp_dir_ent_array;
short i;
char *str;
/* calculate the maximum message size and number of directory entries */
negotiatedPduSize = (ST_INT) indCtrl->event->net_info->max_pdu_size;
max_dir_ents = (negotiatedPduSize - SERVICE_OVRHD) / DIR_ENTRY_OVRHD;
/* set the number of directory entries and allocate memory for response info */
fdir_ctrl = &indCtrl->u.fdir;
/****************************/
/* <20><EFBFBD><E3B6AB><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> */
/****************************/
file_utf_to_gb2312(tmp_name,fdir_ctrl->fs_filename,strlen(fdir_ctrl->fs_filename));
strcpy(fdir_ctrl->fs_filename,tmp_name);
file_utf_to_gb2312(tmp_name,fdir_ctrl->ca_filename,strlen(fdir_ctrl->ca_filename));
strcpy(fdir_ctrl->ca_filename,tmp_name);
/****************************/
/* Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
/****************************/
if((strlen(fdir_ctrl->fs_filename)==0)||(strstr(fdir_ctrl->fs_filename,"*")))
strcpy (fs_name, "/");
else
strcpy (fs_name, fdir_ctrl->fs_filename);
/****************************/
/* Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD> */
/****************************/
strcpy (ca_name, fdir_ctrl->ca_filename);
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
if((strlen (ca_name))&&(strrchr(ca_name,'/')))
{
strcpy (fs_name,ca_name);
str = strrchr(fs_name,'/');
strcpy (ca_name,str+1);
*(str+1) = 0;
printf("Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%s fs_name:%s ca_name:%s...\n\r",fdir_ctrl->ca_filename,fs_name,ca_name);
}
if(strlen (ca_name)) found_ca = SD_FALSE;
else found_ca = SD_TRUE;
/****************************/
/* <09><>Ŀ¼<C4BF><C2BC>ȡ */
/****************************/
if(strcmp(fs_name, "/")==0)
{
root_dir_num = mms_open_root_dir();
if(root_dir_num==0) printf("<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>...\n\r");
/*<2A><>Ŀ¼icd<63>ļ<EFBFBD>*/
ret = stat ("/etc/device.icd", &file_stat);
if(ret==0) strcpy(mms_root_dir_buf[root_dir_num++],"/device.icd");
else printf("%s stat ʧ<><CAA7>...\n\r","/etc/device.icd");
resp_info.num_dir_ent = root_dir_num;
resp_info.more_follows = SD_FALSE;
tmp_dir_ent_array = (ST_CHAR *) chk_calloc (resp_info.num_dir_ent, sizeof(MVL_DIR_ENT));
resp_info.dir_ent = (MVL_DIR_ENT *) tmp_dir_ent_array;
for(i=0;i<root_dir_num;i++)
{
resp_info.dir_ent[i].fsize = 0;
resp_info.dir_ent[i].mtimpres = SD_TRUE;
resp_info.dir_ent[i].mtime = 0;
strcpy (resp_info.dir_ent[i].filename,mms_root_dir_buf[i]);
}
/*<2A><>Ŀ¼icd<63>ļ<EFBFBD>*/
if(ret==0)
{
resp_info.dir_ent[root_dir_num-1].mtime = file_stat.st_mtime;
resp_info.dir_ent[root_dir_num-1].fsize = file_stat.st_size ;
}
fdir_ctrl->resp_info = &resp_info;
mplas_fdir_resp (indCtrl);
chk_free (tmp_dir_ent_array);
return;
}
/*---------------------------------------------------------*/
/* Find maximum response buffer size, calloc space for it, */
/* and initialize the response structure variables. */
/*---------------------------------------------------------*/
rsp_size = sizeof (FDIR_RESP_INFO)+( max_dir_ents * sizeof (FDIR_DIR_ENT) )+( max_dir_ents * sizeof (FILE_NAME) );
rsp_ptr = (FDIR_RESP_INFO *) chk_calloc (1,rsp_size);
data_buf = chk_malloc (negotiatedPduSize);
rsp_ptr->num_dir_ent = 0;
rsp_ptr->more_follows = SD_FALSE;
/*---------------------------------*/
/* Initialize some other variables */
/*---------------------------------*/
name_ptr = data_buf;
total_len = 0;
status = SD_SUCCESS;
fname_ptr = ( FILE_NAME * )( fdir_ctrl + 1 );
/****************************/
/* Ŀ¼<C4BF><C2BC>Ϣ<EFBFBD><CFA2>ȡ */
/****************************/
if(fs_name[strlen (fs_name)-1]!='/') strcat(fs_name,"/");
ret = mms_filename_conv(fs_name,sys_name);
if(sys_name[strlen (sys_name)-1]!='/') strcat(sys_name,"/");
dir = opendir(sys_name);
if((!ret)||(!dir))
{
printf("Ŀ¼ %s - %s<><73>ȡʧ<C8A1><CAA7>...\n\r",fs_name,sys_name);
status = SD_FAILURE;
}
if(status == SD_SUCCESS )
{
if ((dirptr = readdir(dir)))
{
dir_ptr = (FDIR_DIR_ENT *)(rsp_ptr + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
doMore = SD_TRUE;
while(doMore )
{
/* Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD> */
if(! found_ca &&(!strcmp (dirptr->d_name, ca_name))) found_ca = SD_TRUE;
if(!(found_ca && (strcmp (dirptr->d_name, ca_name))))
{
if(!(dirptr = readdir(dir))) doMore = SD_FALSE;
continue;
}
/* Discard the . and .. entries */
if (!strcmp (dirptr->d_name, ".")|| !strcmp (dirptr->d_name, ".."))
{
if(!(dirptr = readdir(dir))) doMore = SD_FALSE;
continue;
}
/*ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF>޳<EFBFBD>*/
strcpy(filename,sys_name);
strcat(filename,dirptr->d_name);
strcat(filename,"/");
for(i=0;i<root_dir_num;i++)
{
if(strcmp(filename,sys_root_dir_buf[i])==0) break;
}
if(i!=root_dir_num)
{
if(!(dirptr = readdir(dir))) doMore = SD_FALSE;
continue;
}
total_len += ( strlen(dirptr->d_name) + DIR_ENTRY_OVRHD);
total_len += strlen(sys_name);
/* <20><><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
if((total_len >= (negotiatedPduSize - SERVICE_OVRHD)) ||
(rsp_ptr->num_dir_ent>=MMS_DIR_READ_MAX))
{
printf("total_len(%d) > %d num=%d ...\n",
total_len,negotiatedPduSize,rsp_ptr->num_dir_ent);
rsp_ptr->more_follows = SD_TRUE;
doMore = SD_FALSE;
continue;
}
/* Ŀ¼<C4BF>ļ<EFBFBD><C4BC><EFBFBD>Ϣ */
sprintf(filename,"%s%s",sys_name,dirptr->d_name);
ret = stat (filename, &file_stat);
if(ret!=0) printf("%s stat ʧ<><CAA7>...\n\r",filename);
rsp_ptr->num_dir_ent++;
fillFdirEnt(&file_stat, dir_ptr, fname_ptr, name_ptr,dirptr->d_name);
/*ȫ·<C8AB><C2B7>*/
if(fdir_fullname_flag)
{
strcpy(filename,fs_name);
strcat(filename,fname_ptr->fname);
strcpy(fname_ptr->fname,filename);
}
/*UTF8<46><38><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>*/
/*UTF_8ToGB2312(tmp_name,fname_ptr->fname,strlen(fname_ptr->fname));*/
file_gb2312_to_utf(tmp_name,fname_ptr->fname);
strcpy(fname_ptr->fname,tmp_name);
fname_ptr->fn_len = strlen (fname_ptr->fname);
name_ptr += fname_ptr->fn_len + 1; /* check for end of buffer */
dir_ptr = (FDIR_DIR_ENT *) ((FILE_NAME *) (dir_ptr + 1) + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
if(!(dirptr = readdir(dir))) doMore = SD_FALSE;
}
}
}
if (dir) closedir(dir);
/* if (status == SD_SUCCESS) directory was successful */
if(1)
{
/* Build a File Directory response */
rc = mpl_fdir_resp (indCtrl->event->u.mms.dec_rslt.id, rsp_ptr);
_mvl_send_resp_i (indCtrl, rc);
strcpy (fs_name, fdir_ctrl->fs_filename);
strcpy (ca_name, fdir_ctrl->ca_filename);
printf("filenum=%3d total_len=%5d fdir_name=%s %s %s\n\r",rsp_ptr->num_dir_ent,total_len,
fdir_ctrl->fs_filename,fdir_ctrl->ca_filename,sys_name);
}
/*------------------------*/
/* Free allocated storage */
/*------------------------*/
chk_free (rsp_ptr);
chk_free (data_buf);
}
ST_VOID mvlas_fattr_resp (MVL_IND_PEND *indCtrl)
{
ST_INT status;
ST_CHAR fs_name [MAX_FILE_NAME+1];
ST_CHAR ca_name [MAX_FILE_NAME+1];
ST_CHAR filename[MAX_FILE_NAME+1];
FDIR_RESP_INFO *rsp_ptr;
FDIR_DIR_ENT *dir_ptr;
ST_INT rsp_size;
ST_CHAR *name_ptr;
ST_INT total_len, doMore;
FILE_NAME *fname_ptr;
ST_CHAR *data_buf;
MVLAS_FDIR_CTRL *fdir_ctrl;
ST_INT negotiatedPduSize;
ST_INT max_dir_ents;
ST_RET rc;
struct stat file_stat;
/* calculate the maximum message size and number of directory entries */
negotiatedPduSize = (ST_INT) indCtrl->event->net_info->max_pdu_size;
max_dir_ents = (negotiatedPduSize - SERVICE_OVRHD) / DIR_ENTRY_OVRHD;
/* set the number of directory entries and allocate memory for response info */
fdir_ctrl = &indCtrl->u.fdir;
fs_name[0] = 0;
if(fdir_ctrl->fs_filename[0]!='/') strcpy (fs_name, "/");
strcat (fs_name, fdir_ctrl->fs_filename);
/*strcpy (fs_name, fdir_ctrl->fs_filename);*/
strcpy (ca_name, fdir_ctrl->ca_filename);
/*---------------------------------------------------------*/
/* Find maximum response buffer size, calloc space for it, */
/* and initialize the response structure variables. */
/*---------------------------------------------------------*/
rsp_size = sizeof (FDIR_RESP_INFO)
+ ( max_dir_ents * sizeof (FDIR_DIR_ENT) )
+ ( max_dir_ents * sizeof (FILE_NAME) );
rsp_ptr = (FDIR_RESP_INFO *) chk_calloc (1,rsp_size);
/* Allocate buffer to hold just names. Will NEVER use whole buffer */
/* because names plus overhead must be less than mms_max_msgsze. */
data_buf = chk_malloc (negotiatedPduSize);
rsp_ptr->num_dir_ent = 0;
rsp_ptr->more_follows = SD_FALSE; /* set default value */
/*---------------------------------*/
/* Initialize some other variables */
/*---------------------------------*/
name_ptr = data_buf;
total_len = 0;
status = SD_SUCCESS;
fname_ptr = ( FILE_NAME * )( fdir_ctrl + 1 );
dir_ptr = (FDIR_DIR_ENT *)(rsp_ptr + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
total_len += ( strlen(fs_name) + DIR_ENTRY_OVRHD );
memset(filename,0,MAX_FILE_NAME);
strcpy(filename,fs_name);
/*if(lstat(filename, &file_stat) != 0 )*/
if(stat (filename, &file_stat) != 0 )
{
printf("fdir(%s %s %s) read error ...\n", fdir_ctrl->fs_filename,fs_name,ca_name);
/*_mplas_err_resp (indCtrl,11,3);*/ /* File name syntax error */
_mplas_err_resp (indCtrl,11,0); /* File name syntax error */
chk_free (rsp_ptr);
chk_free (data_buf);
return;
}
rsp_ptr->num_dir_ent++;
fillFdirEnt (&file_stat, dir_ptr, fname_ptr, name_ptr,fs_name);
name_ptr += fname_ptr->fn_len + 1; /* check for end of buffer */
dir_ptr = (FDIR_DIR_ENT *) ((FILE_NAME *) (dir_ptr + 1) + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
doMore = SD_FALSE;
if (status == SD_SUCCESS) /* directory was successful */
{
/* Build a File Directory response */
rc = mpl_fdir_resp (indCtrl->event->u.mms.dec_rslt.id, rsp_ptr);
_mvl_send_resp_i (indCtrl, rc);
}
/*------------------------*/
/* Free allocated storage */
/*------------------------*/
chk_free (rsp_ptr);
chk_free (data_buf);
}
#endif
#if defined(_WIN32)
short fdir_fullname_flag=1;
/************************************************************************/
/* convertFileTime */
/* convert FILETIME to time_t */
/************************************************************************/
static time_t convertFileTime (FILETIME *pstFileTime)
{
WORD wFatDate, wFatTime;
struct tm stTm;
time_t retTime;
FILETIME stLocalTime;
FileTimeToLocalFileTime (pstFileTime, &stLocalTime);
if (FileTimeToDosDateTime (&stLocalTime, &wFatDate, &wFatTime))
{
stTm.tm_sec = (wFatTime & 0x001F) * 2; // bits 0-4
stTm.tm_min = (wFatTime & 0x07E0) >> 5; // bits 5-10
stTm.tm_hour = (wFatTime & 0xF800) >> 11; // bits 11-15
stTm.tm_mday = wFatDate & 0x001F; // bits 0-4
stTm.tm_mon = ((wFatDate & 0x01E0)>>5) - 1; // bits 5-8
stTm.tm_year = ((wFatDate & 0xFE00)>>9) + 80; // bits 9-15
stTm.tm_isdst = -1; // let someone else figure out DST
retTime = mktime (&stTm);
}
else
retTime = -1;
return retTime;
}
/************************************************************************/
/* fileFdirEnt */
/* fill up the FDIR_DIR_ENT struct, FILE_NAME struct, and nameBuffer */
/* from the WIN32_FIND_DATA struct. */
/************************************************************************/
static ST_VOID fillFdirEnt (WIN32_FIND_DATA *pstFindData, FDIR_DIR_ENT *pstFdirEnt,
FILE_NAME *pstFileName, ST_CHAR *nameBuffer)
{
time_t theTime;
/* Fill in the FDIR_DIR_ENT struct. */
pstFdirEnt->fsize = (pstFindData->nFileSizeHigh * MAXDWORD) + pstFindData->nFileSizeLow;
theTime = convertFileTime (&pstFindData->ftLastWriteTime);
if (theTime == -1)
pstFdirEnt->mtimpres = SD_FALSE;
else
{
pstFdirEnt->mtimpres = SD_TRUE;
pstFdirEnt->mtime = (ST_INT32) theTime;
}
pstFdirEnt->num_of_fname = 1;
/* Fill in nameBuffer. */
strcpy (nameBuffer, pstFindData->cFileName);
if (pstFindData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
strcat (nameBuffer, "\\");
/* Fill in the FILE_NAME struct. */
pstFileName->fname = nameBuffer;
pstFileName->fn_len = strlen (nameBuffer);
}
/************************************************************************/
/* mvlas_fdir_resp */
/************************************************************************/
#include "stdio.h"
ST_VOID mvlas_fdir_resp (MVL_IND_PEND *indCtrl)
{
ST_INT status;
ST_CHAR tmp_name [MAX_FILE_NAME+1],*pfind;
ST_CHAR fs_name [MAX_FILE_NAME+1];
ST_CHAR ca_name [MAX_FILE_NAME+1];
ST_INT ca_len;
FDIR_RESP_INFO *rsp_ptr;
FDIR_DIR_ENT *dir_ptr;
ST_INT rsp_size;
ST_CHAR *name_ptr;
ST_INT total_len, doMore;
FILE_NAME *fname_ptr;
ST_UCHAR found_ca = SD_FALSE;
ST_CHAR *data_buf;
WIN32_FIND_DATA stFindData;
HANDLE hFind;
MVLAS_FDIR_CTRL *fdir_ctrl;
ST_INT negotiatedPduSize;
ST_INT max_dir_ents;
ST_RET rc;
char path[MAX_PATH];
/* calculate the maximum message size and number of directory entries */
negotiatedPduSize = (ST_INT) indCtrl->event->net_info->max_pdu_size;
max_dir_ents = (negotiatedPduSize - SERVICE_OVRHD) / DIR_ENTRY_OVRHD;
/* set the number of directory entries and allocate memory for response info */
fdir_ctrl = &indCtrl->u.fdir;
strcpy (fs_name, fdir_ctrl->fs_filename);
strcpy (ca_name, fdir_ctrl->ca_filename);
path[0]=0;
if(!strstr(fs_name,":"))
{
GetCurrentDirectory (MAX_PATH,path);
GetCurrentDirectoryA(MAX_PATH,path);
}
//printf("GetCurrentDirectory1=%s fs_filename=%s\n",path,fs_name);
//renxiaobao <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
if(strlen(fs_name)==0) strcpy (fs_name, "\\");
/* check if ca_filename is present */
if ((ca_len = strlen (ca_name)) > 0)
{
/* strip off any '\' character at the end of file name */
if (ca_len && ca_name[ca_len-1] == '\\')
{
ca_len--;
ca_name[ca_len] = '\0';
}
}
else
found_ca = SD_TRUE;
/*---------------------------------------------------------*/
/* Find maximum response buffer size, calloc space for it, */
/* and initialize the response structure variables. */
/*---------------------------------------------------------*/
rsp_size = sizeof (FDIR_RESP_INFO)
+ ( max_dir_ents * sizeof (FDIR_DIR_ENT) )
+ ( max_dir_ents * sizeof (FILE_NAME) );
rsp_ptr = (FDIR_RESP_INFO *) chk_calloc (1,rsp_size);
/* Allocate buffer to hold just names. Will NEVER use whole buffer */
/* because names plus overhead must be less than mms_max_msgsze. */
data_buf = chk_malloc (negotiatedPduSize);
rsp_ptr->num_dir_ent = 0;
rsp_ptr->more_follows = SD_FALSE; /* set default value */
/*---------------------------------*/
/* Initialize some other variables */
/*---------------------------------*/
name_ptr = data_buf;
total_len = 0;
status = SD_SUCCESS;
fname_ptr = ( FILE_NAME * )( fdir_ctrl + 1 );
/* traverse the directory and stash output in the resp struct */
if ( status == SD_SUCCESS )
{
sprintf(tmp_name,"%s%s",path,fs_name);
strcpy(fs_name,tmp_name);
while(pfind=strstr(fs_name,"/")) *pfind = 92; // '/'<27><EFBFBD><E6BBBB>'\\'
strcat (fs_name, "*");
// printf("fs_name=%s\r\n",fs_name);
// hFind = FindFirstFile (fs_name, &stFindData);
hFind = FindFirstFileA (fs_name, &stFindData);
//printf("FindFirstFile fs_name=%s\r\n",fs_name);
if (hFind != INVALID_HANDLE_VALUE)
{
dir_ptr = (FDIR_DIR_ENT *)(rsp_ptr + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
doMore = SD_TRUE;
while ( doMore )
{
if (!found_ca && (!stricmp (stFindData.cFileName, ca_name)) )
found_ca = SD_TRUE;
if (found_ca && (stricmp (stFindData.cFileName, ca_name)) )
{
/* Discard the . and .. entries */
if (!strcmp (stFindData.cFileName, ".") ||
!strcmp (stFindData.cFileName, ".."))
{
//doMore = FindNextFile (hFind, &stFindData);
doMore = FindNextFileA (hFind, &stFindData);
continue;
}
/* see how big it would be and if it fits - keep it */
total_len += ( strlen(stFindData.cFileName) + DIR_ENTRY_OVRHD );
if (total_len < (negotiatedPduSize - SERVICE_OVRHD) )
{
rsp_ptr->num_dir_ent++;
fillFdirEnt (&stFindData, dir_ptr, fname_ptr, name_ptr);
name_ptr += fname_ptr->fn_len + 1; /* check for end of buffer */
dir_ptr = (FDIR_DIR_ENT *) ((FILE_NAME *) (dir_ptr + 1) + 1);
fname_ptr = (FILE_NAME *)(dir_ptr + 1);
//doMore = FindNextFile (hFind, &stFindData);
doMore = FindNextFileA (hFind, &stFindData);
}
else /* message size limit */
{
rsp_ptr->more_follows = SD_TRUE;
doMore = SD_FALSE;
}
//printf("total_len=%d %d\n",total_len,negotiatedPduSize);
}
else
//doMore = FindNextFile (hFind, &stFindData);
doMore = FindNextFileA (hFind, &stFindData);
}
FindClose (hFind);
}
}
if (status == SD_SUCCESS) /* directory was successful */
{
/* Build a File Directory response */
rc = mpl_fdir_resp (indCtrl->event->u.mms.dec_rslt.id, rsp_ptr);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, rsp_ptr);
_mvl_send_resp_i (indCtrl, rc);
}
/*------------------------*/
/* Free allocated storage */
/*------------------------*/
chk_free (rsp_ptr);
chk_free (data_buf);
}
#endif /* if defined(_WIN32) */

81
mmslib/mvlu/s_fopen.c Normal file
View File

@@ -0,0 +1,81 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_fopen.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_fopen_ind */
/* mplas_fopen_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_fopen_ind */
/* A file open indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_fopen_ind (MVL_IND_PEND *indCtrl)
{
FOPEN_REQ_INFO *req_info;
MVLAS_FOPEN_CTRL *fopenCtrl;
fopenCtrl = &indCtrl->u.fopen;
req_info = (FOPEN_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
if (_mvl_concat_filename (fopenCtrl->filename, req_info->num_of_fname,
(FILE_NAME *)(req_info + 1), sizeof (fopenCtrl->filename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
fopenCtrl->init_pos = req_info->init_pos;
u_mvl_fopen_ind (indCtrl);
}
/************************************************************************/
/* mplas_fopen_resp */
/************************************************************************/
ST_VOID mplas_fopen_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a "fopen" response. */
rc = mpl_fopen_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.fopen.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.fopen.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

75
mmslib/mvlu/s_fread.c Normal file
View File

@@ -0,0 +1,75 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_fread.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_fread_ind */
/* mplas_fread_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_fread_ind */
/* A file open indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_fread_ind (MVL_IND_PEND *indCtrl)
{
MVLAS_FREAD_CTRL *freadCtrl;
freadCtrl = &indCtrl->u.fread;
freadCtrl->req_info = (FREAD_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
/* (Max file block size) = (Max PDU size) - 100 to allow for MMS headers.*/
freadCtrl->max_size = indCtrl->event->net_info->max_pdu_size - 100;
u_mvl_fread_ind (indCtrl);
}
/************************************************************************/
/* mplas_fread_resp */
/************************************************************************/
ST_VOID mplas_fread_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a File Read response */
rc = mpl_fread_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.fread.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.fread.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

82
mmslib/mvlu/s_fren.c Normal file
View File

@@ -0,0 +1,82 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : s_fren.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_frename_ind */
/* mplas_frename_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 05 Enhanced filtered logging */
/* 03/11/04 GLB 04 Remove "thisFileName" */
/* 09/21/01 JRB 03 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 02 Now use MEM_SMEM for dynamic memory */
/* 10/15/99 GLB 01 Created to acommodate file Rename */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* _mvl_process_frename_ind */
/* A "frename" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_frename_ind (MVL_IND_PEND *indCtrl)
{
FRENAME_REQ_INFO *req_info;
MVLAS_FRENAME_CTRL *frename;
FILE_NAME *fname_idx;
frename = &indCtrl->u.frename;
req_info = (FRENAME_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
fname_idx = (FILE_NAME *)(req_info + 1);
if (_mvl_concat_filename (frename->curfilename, req_info->num_of_cur_fname,
fname_idx, sizeof (frename->curfilename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
if (_mvl_concat_filename (frename->newfilename, req_info->num_of_new_fname,
(FILE_NAME *)(fname_idx + req_info->num_of_cur_fname),
sizeof (frename->newfilename)))
{
_mplas_err_resp (indCtrl,11,3); /* File name syntax error */
return;
}
u_mvl_frename_ind (indCtrl);
}
/************************************************************************/
/* mplas_frename_resp */
/************************************************************************/
ST_VOID mplas_frename_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a "frename" response */
rc = mpl_frename_resp (indCtrl->event->u.mms.dec_rslt.id);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, NULL);
_mvl_send_resp_i (indCtrl, rc);
}

65
mmslib/mvlu/s_getcl.c Normal file
View File

@@ -0,0 +1,65 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 2000 - 2000, All Rights Reserved */
/* */
/* MODULE NAME : s_getcl.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_getcl_ind */
/* mplas_getcl_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 04 Enhanced filtered logging */
/* 03/11/04 GLB 03 Remove "thisFileName" */
/* 09/21/01 JRB 02 Alloc global bufs only once at startup. */
/* 10/25/00 JRB 01 Created. */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pdom.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/*----------------------------------------------------------------------*/
/* Functions to process GetProgramInvocationAttributes Indication */
/* and send GetProgramInvocationAttributes Response. */
/*----------------------------------------------------------------------*/
/************************************************************************/
/* _mvl_process_getcl_ind */
/* GetProgramInvocationAttributes Indication received. */
/* Process it and pass it up to user. */
/************************************************************************/
ST_VOID _mvl_process_getcl_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.getcl.req_info =
(GETCL_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_getcl_ind (indCtrl);
}
/************************************************************************/
/* mplas_getcl_resp */
/* Send GetProgramInvocationAttributes Response. */
/************************************************************************/
ST_VOID mplas_getcl_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
rc = mpl_getcl_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.getcl.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.getcl.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

108
mmslib/mvlu/s_getdom.c Normal file
View File

@@ -0,0 +1,108 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_getdom.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 09 Enhanced filtered logging */
/* 10/30/06 JRB 08 Use new mvl_vmd_* object handling functions. */
/* 09/21/01 JRB 07 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 06 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 05 Added SD_CONST modifiers */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mplas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pdom.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_process_getdom_ind */
/* A 'Get Domain Attributes' indication has been received, */
/* process it and respond */
/************************************************************************/
ST_VOID _mvl_process_getdom_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.getdom.req_info =
(GETDOM_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_getdom_ind (indCtrl);
}
/************************************************************************/
/* mvlas_getdom_resp */
/************************************************************************/
ST_VOID mvlas_getdom_resp (MVL_IND_PEND *indCtrl)
{
GETDOM_REQ_INFO *req_info;
GETDOM_RESP_INFO *resp_info;
GETDOM_RESP_INFO default_resp_info;
MVL_DOM_CTRL *dom;
req_info = indCtrl->u.getdom.req_info;
dom = mvl_vmd_find_dom (&mvl_vmd, req_info->dname);
if (dom == NULL)
{
MVL_LOG_NERR1 ("GetDomAttrib Ind : %s not found", req_info->dname);
_mplas_err_resp (indCtrl,2,1); /* definition, object undefined */
return;
}
resp_info = dom->get_dom_resp_info;
if (resp_info == NULL)
{
resp_info = &default_resp_info;
resp_info->num_of_capab = 0;
resp_info->mms_deletable = 0;
resp_info->sharable = 0;
resp_info->num_of_pinames = 0;
resp_info->state = 2; /* 2 : ready */
}
indCtrl->u.getdom.resp_info = resp_info;
mplas_getdom_resp (indCtrl);
}
/************************************************************************/
/* mplas_getdom_resp */
/************************************************************************/
ST_VOID mplas_getdom_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
rc = mpl_getdom_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.getdom.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.getdom.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

439
mmslib/mvlu/s_getnam.c Normal file
View File

@@ -0,0 +1,439 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2005, All Rights Reserved */
/* */
/* MODULE NAME : s_getnam.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 21 Enhanced filtered logging */
/* 10/30/06 JRB 20 Use new mvl_vmd_* object handling functions. */
/* u_gnl_ind_*: add net_info arg to */
/* elim use of global var "_mvl_curr_net_info". */
/* 01/19/05 JRB 19 u_gnl_ind_* return (-1) on error. */
/* mvlas_namelist_resp: send err resp on error */
/* (instead of empty name list). */
/* 08/20/04 JRB 18 Del uninformative "#pragma message". */
/* 03/04/02 JRB 17 Avoid uninitialized locals in u_gnl_ind_jous */
/* 01/23/02 EJV 16 Added journals to domain: */
/* u_gnl_ind_jous - added DOM_SPEC case. */
/* 09/21/01 JRB 15 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 14 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 10/25/00 JRB 13 Del GNL funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* Del NO_GLB_VAR_INIT code (no longer needed). */
/* 01/21/00 MDE 12 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 11 Added SD_CONST modifiers */
/* 04/07/99 MDE 10 Logging improvements */
/* 01/08/99 JRB 09 Use new "bsearch" object model. */
/* 11/16/98 MDE 08 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 07 Minor lint cleanup */
/* 07/02/98 MDE 06 Added Journal support */
/* 06/15/98 MDE 05 Changes to allow compile under C++ */
/* 05/14/98 JRB 04 Use MVL_IND_PEND. Add mplas resp function. */
/* 02/10/98 MDE 03 Added 'u_gnl_done' function pointer */
/* 09/18/97 MDE 02 Fixed 'continue after' handling */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* Approximate worst case PDU overhead */
#define MVL_GNL_RESP_OH 25
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
static ST_INT getLocalObjectNames (MVL_OBJ ** obj_tbl, ST_INT num_obj,
NAMELIST_REQ_INFO *req_info, ST_CHAR **ptr,
ST_BOOLEAN *moreFollowsOut, ST_INT maxNames);
/************************************************************************/
/************************************************************************/
/* _mvl_process_getnam_ind */
/* A get name indication has been received, process it and respond */
/************************************************************************/
#define GETNAM_RESP_BUF_SIZE (sizeof(NAMELIST_RESP_INFO)+ \
(MVL_MAX_GNL_NAMES * sizeof(ST_CHAR *)))
ST_VOID _mvl_process_getnam_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.namelist.req_info =
(NAMELIST_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_namelist_ind (indCtrl);
}
/************************************************************************/
/* mvlas_namelist_resp */
/* NOTE: u_gnl_ind_* functions return negative value on errors. */
/************************************************************************/
ST_VOID mvlas_namelist_resp (MVL_IND_PEND *indCtrl)
{
NAMELIST_REQ_INFO *req_info;
NAMELIST_RESP_INFO *resp_info;
ST_CHAR **ptr;
ST_INT num_obj;
ST_INT i;
ST_INT max_size;
ST_INT16 mms_class;
req_info = indCtrl->u.namelist.req_info;
mms_class = req_info->obj.mms_class;
/* Now create the response data structure */
resp_info = (NAMELIST_RESP_INFO *)
M_CALLOC (MSMEM_ENC_OS_INFO, 1, GETNAM_RESP_BUF_SIZE);
ptr = (ST_CHAR **)(resp_info + 1);
num_obj = 0;
switch (req_info->obj.mms_class)
{
case MMS_CLASS_VAR: /* NamedVariables */
num_obj = u_gnl_ind_vars(indCtrl->event->net_info, req_info, ptr, &resp_info->more_follows,
MVL_MAX_GNL_NAMES);
break;
case MMS_CLASS_VARLIST: /* NamedVariableLists */
num_obj = u_gnl_ind_nvls(indCtrl->event->net_info, req_info, ptr, &resp_info->more_follows,
MVL_MAX_GNL_NAMES);
break;
case MMS_CLASS_DOM: /* Domains */
num_obj = u_gnl_ind_doms(req_info, ptr, &resp_info->more_follows,
MVL_MAX_GNL_NAMES);
break;
case MMS_CLASS_JOU: /* Journals */
num_obj = u_gnl_ind_jous(indCtrl->event->net_info, req_info, ptr, &resp_info->more_follows,
MVL_MAX_GNL_NAMES);
break;
case MMS_CLASS_SCAT_ACC: /* Scattered Access */
case MMS_CLASS_TYPE: /* NamedTypes */
case MMS_CLASS_SEM: /* Semaphores */
case MMS_CLASS_EV_COND: /* Event Conditions */
case MMS_CLASS_EV_ACT: /* EventActions */
case MMS_CLASS_EV_ENROLL: /* EventEnrollments */
case MMS_CLASS_PI: /* Program Invocations */
case MMS_CLASS_OPER_STA: /* OperatorStations */
break;
default:
break;
}
if (num_obj < 0)
{ /* error. Send error response. */
_mplas_err_resp (indCtrl,7,2); /* access, non-existent */
}
else
{
/* Let's make sure they will all fit into the PDU */
max_size = indCtrl->event->net_info->max_pdu_size - MVL_GNL_RESP_OH;
resp_info->num_names = 0;
for (i = 0; i < num_obj; ++i, ++ptr)
{
max_size -= (2 + strlen (*ptr));
if (resp_info->num_names > MVL_MAX_GNL_NAMES || max_size <= 0)
{
resp_info->more_follows = SD_TRUE;
break;
}
++resp_info->num_names;
}
/* Build a Get Name List response */
indCtrl->u.namelist.resp_info = resp_info;
mplas_namelist_resp (indCtrl);
}
#if defined(MVL_UCA) /* extra cleanup for UCA */
u_gnl_done (mms_class, resp_info);
#endif /* defined(MVL_UCA) */
M_FREE (MSMEM_ENC_OS_INFO, resp_info);
}
/************************************************************************/
/* mplas_namelist_resp */
/************************************************************************/
ST_VOID mplas_namelist_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
rc = mpl_namelist_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.namelist.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.namelist.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}
/************************************************************************/
/************************************************************************/
#if defined(MVL_UCA)
/* This function not used. See customized 'u_gnl_ind_vars' in 'mvl_uca.c'.*/
#elif defined(USE_MANUFACTURED_OBJS)
#pragma message("USE_MANUFACTURED_OBJS defined. Must provide customized 'u_gnl_ind_vars'.")
#else /* default */
ST_INT u_gnl_ind_vars (MVL_NET_INFO *net_info, NAMELIST_REQ_INFO *req_info,
ST_CHAR **ptr, ST_BOOLEAN *moreFollowsOut,
ST_INT maxNames)
{
ST_INT num_obj;
MVL_VAR_ASSOC **va;
MVL_AA_OBJ_CTRL *aa;
MVL_DOM_CTRL *domCtrl;
/* First get the number of objects and pointer to the object table */
num_obj = 0;
if (req_info->objscope == VMD_SPEC)
{
num_obj = mvl_vmd.num_var_assoc;
va = mvl_vmd.var_assoc_tbl;
}
else if (req_info->objscope == DOM_SPEC)
{
domCtrl = mvl_vmd_find_dom (&mvl_vmd, req_info->dname);
if (domCtrl)
{
num_obj = domCtrl->num_var_assoc;
va = domCtrl->var_assoc_tbl;
}
else
{
MVL_LOG_NERR1 ("GetNameList variables: Domain '%s' not found", req_info->dname);
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
}
else /* AA_SPEC */
{
aa = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
if (aa)
{
num_obj = aa->num_var_assoc;
va = aa->var_assoc_tbl;
}
else
{
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
}
/* Get all the names. */
return (getLocalObjectNames ((MVL_OBJ **) va, num_obj,
req_info, ptr, moreFollowsOut, maxNames));
}
#endif /* default */
/************************************************************************/
/************************************************************************/
#if defined(MVL_UCA)
/* This function not used. See customized 'u_gnl_ind_nvls' in 'mvl_uca.c'.*/
#elif defined(USE_MANUFACTURED_OBJS)
#pragma message("USE_MANUFACTURED_OBJS defined. Must provide customized 'u_gnl_ind_nvls'.")
#else /* default */
ST_INT u_gnl_ind_nvls (MVL_NET_INFO *net_info, NAMELIST_REQ_INFO *req_info,
ST_CHAR **ptr, ST_BOOLEAN *moreFollowsOut,
ST_INT maxNames)
{
ST_INT num_obj;
MVL_AA_OBJ_CTRL *aa;
MVL_NVLIST_CTRL **vl;
MVL_DOM_CTRL *domCtrl;
/* First get the number of objects and pointer to the object table */
num_obj = 0;
if (req_info->objscope == VMD_SPEC)
{
num_obj = mvl_vmd.num_nvlist;
vl = mvl_vmd.nvlist_tbl;
}
else if (req_info->objscope == DOM_SPEC)
{
domCtrl = mvl_vmd_find_dom (&mvl_vmd, req_info->dname);
if (domCtrl)
{
num_obj = domCtrl->num_nvlist;
vl = domCtrl->nvlist_tbl;
}
else
{
MVL_LOG_NERR1 ("GetNameList NVL: Domain '%s' not found", req_info->dname);
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
}
else /* AA_SPEC */
{
aa = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
if (aa)
{
num_obj = aa->num_nvlist;
vl = aa->nvlist_tbl;
}
else
{
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
}
/* Get all the names. */
return (getLocalObjectNames ((MVL_OBJ **) vl, num_obj,
req_info, ptr, moreFollowsOut, maxNames));
}
#endif /* default */
/************************************************************************/
/************************************************************************/
#if defined(USE_MANUFACTURED_OBJS)
#pragma message("USE_MANUFACTURED_OBJS defined. Must provide customized 'u_gnl_ind_doms'.")
#else /* default */
ST_INT u_gnl_ind_doms (NAMELIST_REQ_INFO *req_info,
ST_CHAR **ptr, ST_BOOLEAN *moreFollowsOut,
ST_INT maxNames)
{
/* Get all the names. */
return (getLocalObjectNames ((MVL_OBJ **) mvl_vmd.dom_tbl, mvl_vmd.num_dom,
req_info, ptr, moreFollowsOut, maxNames));
}
#endif /* default */
/************************************************************************/
/************************************************************************/
ST_INT u_gnl_ind_jous (MVL_NET_INFO *net_info, NAMELIST_REQ_INFO *req_info,
ST_CHAR **ptr, ST_BOOLEAN *moreFollowsOut,
ST_INT maxNames)
{
ST_INT num_obj;
MVL_AA_OBJ_CTRL *aa;
MVL_DOM_CTRL *dom;
MVL_JOURNAL_CTRL **jou;
/* First get the number of objects and pointer to the object table */
num_obj = 0;
jou = NULL;
switch (req_info->objscope)
{
case VMD_SPEC:
num_obj = mvl_vmd.num_jou;
jou = mvl_vmd.jou_tbl;
break;
case AA_SPEC:
aa = (MVL_AA_OBJ_CTRL *) net_info->aa_objs;
if (aa)
{
num_obj = aa->num_jou;
jou = aa->jou_tbl;
}
break;
case DOM_SPEC:
dom = mvl_vmd_find_dom (&mvl_vmd, req_info->dname);
if (dom)
{
num_obj = dom->num_jou;
jou = dom->jou_tbl;
}
else
{
MVL_LOG_NERR1 ("GetNameList NVL Journal: Domain '%s' not found", req_info->dname);
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
break;
default:
*moreFollowsOut = SD_FALSE;
return (-1); /* error. This triggers error response */
}
/* Get all the names. */
if (num_obj)
return (getLocalObjectNames ((MVL_OBJ **) jou, num_obj,
req_info, ptr, moreFollowsOut, maxNames));
return (0);
}
/************************************************************************/
/* getLocalObjectNames */
/* Find index into array of pointers for name AFTER continue_after name.*/
/************************************************************************/
static ST_INT getLocalObjectNames (MVL_OBJ ** obj_tbl,
ST_INT num_obj,
NAMELIST_REQ_INFO *req_info,
ST_CHAR **ptr, /* array of ptrs to names*/
ST_BOOLEAN *moreFollowsOut,
ST_INT maxNames) /* max # of names */
{
ST_INT obj_index; /* index to array of objects */
ST_INT name_index; /* index to array of names */
MVL_OBJ **key;
if (req_info->cont_after_pres)
{
key = mvl_obj_find_key (obj_tbl, num_obj, req_info->continue_after);
if (key)
obj_index = key - obj_tbl + 1; /* index to next one (i.e. + 1).*/
else
{
MVL_LOG_ERR1 ("GetNameList Error: continue after name '%s' not found",
req_info->continue_after);
obj_index = num_obj; /* Treat as if there are no more objects.*/
}
}
else
obj_index = 0; /* No continue_after. Start with first entry. */
/* Now make the list for the response */
for (name_index = 0; name_index < maxNames && obj_index < num_obj;
++obj_index, ++name_index)
ptr[name_index] = obj_tbl[obj_index]->name;
if (obj_index < num_obj)
*moreFollowsOut = SD_TRUE;
return (name_index);
}

265
mmslib/mvlu/s_getvaa.c Normal file
View File

@@ -0,0 +1,265 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2002, All Rights Reserved */
/* */
/* MODULE NAME : s_getvaa.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 22 Enhanced filtered logging */
/* 11/03/06 RKR 21 Added code to generate a misencoded typespec */
/* 11/02/06 JRB 20 mplas_err_resp: fix class/code for IEC 61850.*/
/* 10/30/06 JRB 19 Add args on call to _mvl_objname_to_va. */
/* Del MVL_DYN_ASN1_TYPES option (was enabled */
/* by default). Always do default behavior. */
/* Elim use of global var "_mvl_curr_net_info". */
/* 01/30/06 GLB 18 Integrated porting changes for VMS */
/* 06/29/04 JRB 17 Improve NERR log msg. */
/* 03/13/03 JRB 16 Use mvl_type_ctrl_find. */
/* 02/25/02 MDE 15 Now get max PDU size from mvl_cfg_info */
/* 01/02/02 JRB 14 Converted to use ASN1R (re-entrant ASN1) */
/* 09/21/01 JRB 13 Alloc global bufs only once at startup. */
/* 10/25/00 JRB 12 Del u_mvl funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* 01/21/00 MDE 11 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 10 Added SD_CONST modifiers */
/* 04/07/99 MDE 09 Logging improvements */
/* 12/11/98 MDE 08 Removed scope references from VA */
/* 12/11/98 MDE 07 Now use 'va_to_free' as manufactured flag */
/* 11/16/98 MDE 06 Renamed internal functions (prefix '_') */
/* 08/06/98 JRB 05 Use mmsl_max_msg_size to encode type_spec. */
/* 06/15/98 MDE 04 Changes to allow compile under C++ */
/* 05/14/98 JRB 03 Use MVL_IND_PEND. Add mplas resp function. */
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES, use _mvl_call_get_va */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_acse.h"
#include "mvl_log.h"
#if defined(_S_TEST_PROBES)
#include "stestprb.h"
ST_CHAR *misencodedPDU = "\xA2\x82\x05\x20\xA1\x82\x05\x1C\x30\x82\x01\x93\x80\x02\x53\x54\
\xA1\x82\x01\x8B\xA2\x82\x01\x87\xA1\x82\x01\x83\x30\x2C\x80\x03\
\x4D\x6F\x64\xA1\x25\xA2\x23\xA1\x21\x30\x0C\x80\x05\x73\x74\x56\
\x61\x6C\xA1\x03\x85\x01\x08\x30\x08\x80\x01\x71\xA1\x03\x84\x01\
\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x2C\x80\x03\x42\x65\
\x68\xA1\x25\xA2\x23\xA1\x21\x30\x0C\x80\x05\x73\x74\x56\x61\x6C\
\xA1\x03\x85\x01\x08\x30\x08\x80\x01\x71\xA1\x03\x84\x01\xF3\x30\
\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x2F\x80\x06\x48\x65\x61\x6C\
\x74\x68\xA1\x25\xA2\x23\xA1\x21\x30\x0C\x80\x05\x73\x74\x56\x61\
\x6C\xA1\x03\x85\x01\x08\x30\x08\x80\x01\x71\xA1\x03\x84\x01\xF3\
\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x30\x80\x07\x4F\x70\x43\
\x6E\x74\x52\x73\xA1\x25\xA2\x23\xA1\x21\x30\x0C\x80\x05\x73\x74\
\x56\x61\x6C\xA1\x03\x85\x01\x20\x30\x08\x80\x01\x71\xA1\x03\x84\
\x01\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x31\x80\x08\x4E\
\x75\x6D\x43\x6E\x74\x52\x73\xA1\x25\xA2\x23\xA1\x21\x30\x0C\x80\
\x05\x73\x74\x56\x61\x6C\xA1\x03\x85\x01\x20\x30\x08\x80\x01\x71\
\xA1\x03\x84\x01\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x2F\
\x80\x06\x43\x68\x6B\x48\x64\x75\xA1\x25\xA2\x23\xA1\x21\x30\x0C\
\x80\x05\x73\x74\x56\x61\x6C\xA1\x03\x84\x01\xF8\x30\x08\x80\x01\
\x71\xA1\x03\x84\x01\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\
\x2D\x80\x05\x4D\x65\x6D\x4F\x76\xA1\x24\xA2\x22\xA1\x20\x30\x0B\
\x80\x05\x73\x74\x56\x61\x6C\xA1\x02\x83\x00\x30\x08\x80\x01\x71\
\xA1\x03\x84\x01\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\x2F\
\x80\x06\x4E\x75\x6D\x52\x63\x64\xA1\x25\xA2\x23\xA1\x21\x30\x0C\
\x80\x05\x73\x74\x56\x61\x6C\xA1\x03\x85\x01\x20\x30\x08\x80\x01\
\x71\xA1\x03\x84\x01\xF3\x30\x07\x80\x01\x74\xA1\x02\x91\x00\x30\
\x82\x01\xC0\x80\x02\x43\x4F\xA1\x82\x01\xB8\xA2\x82\x01\xB4\xA1\
\x82\x01\xB0\x30\x81\x8D\x80\x07\x4F\x70\x43\x6E\x74\x52\x73\xA1\
\x81\x81\xA2\x7F\xA1\x7D\x30\x7B\x80\x04\x4F\x70\x65\x72\xA1\x73\
\xA2\x71\xA1\x6F\x30\x0D\x80\x06\x63\x74\x6C\x56\x61\x6C\xA1\x03\
\x85\x01\x20\x30\x2C\x80\x06\x6F\x72\x69\x67\x69\x6E\xA1\x22\xA2\
\x20\xA1\x1E\x30\x0C\x80\x05\x6F\x72\x43\x61\x74\xA1\x03\x85\x01\
\x08\x30\x0E\x80\x07\x6F\x72\x49\x64\x65\x6E\x74\xA1\x03\x89\x01\
\xC0\x30\x0D\x80\x06\x63\x74\x6C\x4E\x75\x6D\xA1\x03\x86\x01\x08\
\x30\x07\x80\x01\x54\xA1\x02\x91\x00\x30\x0A\x80\x04\x54\x65\x73\
\x74\xA1\x02\x83\x00\x30\x0C\x80\x05\x43\x68\x65\x63\x6B\xA1\x03\
\x84\x01\xFE\x30\x81\x8E\x80\x08\x4E\x75\x6D\x43\x6E\x74\x52\x73\
\xA1\x81\x81\xA2\x7F\xA1\x7D\x30\x7B\x80\x04\x4F\x70\x65\x72\xA1\
\x73\xA2\x71\xA1\x6F\x30\x0D\x80\x06\x63\x74\x6C\x56\x61\x6C\xA1\
\x03\x85\x01\x20\x30\x2C\x80\x06\x6F\x72\x69\x67\x69\x6E\xA1\x22\
\xA2\x20\xA1\x1E\x30\x0C\x80\x05\x6F\x72\x43\x61\x74\xA1\x03\x85\
\x01\x08\x30\x0E\x80\x07\x6F\x72\x49\x64\x65\x6E\x74\xA1\x03\x89\
\x01\xC0\x30\x0D\x80\x06\x63\x74\x6C\x4E\x75\x6D\xA1\x03\x86\x01\
\x08\x30\x07\x80\x01\x54\xA1\x02\x91\x00\x30\x0A\x80\x04\x54\x65\
\x73\x74\xA1\x02\x83\x00\x30\x0C\x80\x05\x43\x68\x65\x63\x6B\xA1\
\x03\x84\x01\xFE\x30\x81\x8C\x80\x06\x43\x68\x6B\x48\x64\x75\xA1\
\x81\x81\xA2\x7F\xA1\x7D\x30\x7B\x80\x04\x4F\x70\x65\x72\xA1\x73\
\xA2\x71\xA1\x6F\x30\x0D\x80\x06\x63\x74\x6C\x56\x61\x6C\xA1\x03\
\x85\x01\xC0\x30\x2C\x80\x06\x6F\x72\x69\x67\x69\x6E\xA1\x22\xA2\
\x20\xA1\x1E\x30\x0C\x80\x05\x6F\x72\x43\x61\x74\xA1\x03\x85\x01\
\x08\x30\x0E\x80\x07\x6F\x72\x49\x64\x65\x6E\x74\xA1\x03\x89\x01\
\xC0\x30\x0D\x80\x06\x63\x74\x6C\x4E\x75\x6D\xA1\x03\x86\x01\x08\
\x30\x07\x80\x01\x54\xA1\x02\x91\x00\x30\x0A\x80\x04\x54\x65\x73\
\x74\xA1\x02\x83\x00\x30\x0C\x80\x05\x43\x68\x65\x63\x6B\xA1\x03\
\x84\x01\xFE\x30\x81\x91\x80\x02\x43\x46\xA1\x81\x8A\xA2\x81\x87\
\xA1\x81\x84\x30\x1C\x80\x03\x4D\x6F\x64\xA1\x15\xA2\x13\xA1\x11\
\x30\x0F\x80\x08\x63\x74\x6C\x4D\x6F\x64\x65\x6C\xA1\x03\x85\x01\
\x08\x30\x20\x80\x07\x4F\x70\x43\x6E\x74\x52\x73\xA1\x15\xA2\x13\
\xA1\x11\x30\x0F\x80\x08\x63\x74\x6C\x4D\x6F\x64\x65\x6C\xA1\x03\
\x85\x01\x08\x30\x21\x80\x08\x4E\x75\x6D\x43\x6E\x74\x52\x73\xA1\
\x15\xA2\x13\xA1\x11\x30\x0F\x80\x08\x63\x74\x6C\x4D\x6F\x64\x65\
\x6C\xA1\x03\x85\x01\x08\x30\x1F\x80\x06\x43\x68\x6B\x48\x64\x75\
\xA1\x15\xA2\x13\xA1\x11\x30\x0F\x80\x08\x63\x74\x6C\x4D\x6F\x64\
\x65\x6C\xA1\x03\x85\x01\x08\x30\x81\xFE\x80\x02\x44\x43\xA1\x81\
\xF7\xA2\x81\xF4\xA1\x81\xF1\x30\x19\x80\x06\x48\x65\x61\x6C\x74\
\x68\xA1\x0F\xA2\x0D\xA1\x0B\x30\x09\x80\x01\x64\xA1\x04\x8A\x02\
\xFF\x01\x30\x4B\x80\x06\x4E\x61\x6D\x50\x6C\x74\xA1\x41\xA2\x3F\
\xA1\x3D\x30\x0E\x80\x06\x76\x65\x6E\x64\x6F\x72\xA1\x04\x8A\x02\
\xFF\x01\x30\x0D\x80\x05\x73\x77\x52\x65\x76\xA1\x04\x8A\x02\xFF\
\x01\x30\x09\x80\x01\x64\xA1\x04\x8A\x02\xFF\x01\x30\x11\x80\x09\
\x63\x6F\x6E\x66\x69\x67\x52\x65\x76\xA1\x04\x8A\x02\xFF\x01\x30\
\x1A\x80\x07\x4F\x70\x43\x6E\x74\x52\x73\xA1\x0F\xA2\x0D\xA1\x0B\
\x30\x09\x80\x01\x64\xA1\x04\x8A\x02\xFF\x01\x30\x1B\x80\x08\x4E\
\x75\x6D\x43\x6E\x74\x52\x73\xA1\x0F\xA2\x0D\xA1\x0B\x30\x09\x80\
\x01\x64\xA1\x04\x8A\x02\xFF\x01\x30\x19\x80\x06\x43\x68\x6B\x48\
\x64\x75\xA1\x0F\xA2\x0D\xA1\x0B\x30\x09\x80\x01\x64\xA1\x04\x8A\
\x02\xFF\x01\x30\x18\x80\x05\x4D\x65\x6D\x4F\x76\xA1\x0F\xA2\x0D\
\xA1\x0B\x30\x09\x80\x01\x64\xA1\x04\x8A\x02\xFF\x01\x30\x19\x80\
\x06\x4E\x75\x6D\x52\x63\x64\xA1\x0F\xA2\x0D\xA1\x0B\x30\x09\x80\
\x01\x64\xA1\x04\x8A\x02\xFF\x01\x30\x2A\x80\x02\x45\x58\xA1\x24\
\xA2\x22\xA1\x20\x30\x1E\x80\x06\x43\x68\x6B\x48\x64\x75\xA1\x14\
\xA2\x12\xA1\x10\x30\x0E\x80\x06\x64\x61\x74\x61\x4E\x73\xA1\x04\
\x8A\x02\xFF\x01";
#endif
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_process_getvaa_ind */
/* A 'Get Variable Access Attributes' indication has been received, */
/* process it and respond */
/************************************************************************/
ST_VOID _mvl_process_getvaa_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.getvar.req_info =
(GETVAR_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_getvar_ind (indCtrl);
}
/************************************************************************/
/* mvlas_getvar_resp */
/************************************************************************/
ST_VOID mvlas_getvar_resp (MVL_IND_PEND *indCtrl)
{
GETVAR_REQ_INFO *req_info;
GETVAR_RESP_INFO resp_info;
MVL_VAR_ASSOC *va;
ST_RET rc;
ST_UCHAR *asn1_buf;
ST_INT asn1_len;
ST_UCHAR *asn1_start;
ASN1_ENC_CTXT localEncCtx; /* For readability, use "aCtx" to access this.*/
ASN1_ENC_CTXT *aCtx = &localEncCtx;
MVL_TYPE_CTRL *type_ctrl;
req_info = indCtrl->u.getvar.req_info;
asn1_buf = (ST_UCHAR *) M_MALLOC (MSMEM_ASN1_DATA_ENC, mvl_cfg_info->max_msg_size);
rc = SD_FAILURE;
if (req_info->req_tag == 0) /* Object Name */
{
va = _mvl_objname_to_va (&mvl_vmd, indCtrl->event->net_info, MMSOP_GET_VAR, &req_info->name,
NULL,
SD_FALSE,
NULL,
NULL);
if (va)
{
resp_info.mms_deletable = SD_FALSE;
resp_info.address_pres = SD_FALSE;
/* We will derive the ASN.1 directly from the runtime type. */
/* This takes a bit more code, but if we have Lot's of types we can */
/* save space. */
type_ctrl = mvl_type_ctrl_find (va->type_id); /* find type */
asn1r_strt_asn1_bld (aCtx, asn1_buf, mvl_cfg_info->max_msg_size);
rc = ms_runtime_to_asn1 (aCtx, type_ctrl->rt, type_ctrl->num_rt);
if (rc == SD_SUCCESS)
{
asn1_start = aCtx->asn1r_field_ptr+1;
asn1_len = (asn1_buf + mvl_cfg_info->max_msg_size) - asn1_start;
resp_info.type_spec.len = asn1_len;
resp_info.type_spec.data = asn1_start;
}
else
{
MVL_LOG_NERR1 ("GetVarAccAttrib : VarName='%s'. Could not create ASN.1 from RUNTIME. Probably MMS msgsize to small.",
req_info->name.obj_name.vmd_spec);
}
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
if (va->va_to_free)
u_mvl_free_va (MMSOP_GET_VAR, va, indCtrl->event->net_info);
#endif /* defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS) */
}
else
{
MVL_LOG_NERR1 ("GetVarAccAttrib : Variable Association '%s' not found",
req_info->name.obj_name.vmd_spec);
}
} /* End 'if object (variable name) */
if (rc != SD_SUCCESS)
_mplas_err_resp (indCtrl,MMS_ERRCLASS_ACCESS,MMS_ERRCODE_OBJ_NON_EXISTENT);
else
{
#if defined(_S_TEST_PROBES)
if (_sTestProbeEnabled(_MVL_TEST_RETURN_BAD_TYPE))
{
SLOGALWAYS0 ("TEST: Sending bad type for getVaa");
resp_info.type_spec.data = misencodedPDU;
resp_info.type_spec.len = 1316; /* 0x524 in Hex */
}
#endif
indCtrl->u.getvar.resp_info = &resp_info;
mplas_getvar_resp (indCtrl);
}
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
}
/************************************************************************/
/* mplas_getvar_resp */
/************************************************************************/
ST_VOID mplas_getvar_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
rc = mpl_getvar_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.getvar.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.getvar.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

167
mmslib/mvlu/s_getvla.c Normal file
View File

@@ -0,0 +1,167 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_getvla.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_getvla_ind */
/* mvlas_getvlist_resp */
/* mplas_getvlist_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 17 Enhanced filtered logging */
/* 11/02/06 JRB 16 mplas_err_resp: fix class/code for IEC 61850.*/
/* 10/30/06 JRB 15 Use new mvl_vmd_* object handling functions. */
/* Elim use of global var "_mvl_curr_net_info". */
/* 08/09/06 JRB 14 For MVL_UCA, call mvl_find_nvl */
/* (DO NOT call u_mvl_get_nvl, u_mvl_free_nvl). */
/* 09/21/01 JRB 13 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 12 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 10/25/00 JRB 11 Del u_mvl funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* 01/21/00 MDE 10 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 09 Added SD_CONST modifiers */
/* 09/07/99 MDE 08 Changed MVL_VA_SCOPE to MVL_SCOPE */
/* 01/15/99 JRB 07 IF (u_mvl_get_nvl_fun != NULL) call it, */
/* ELSE call "mvl_find_nvl". */
/* 12/11/98 MDE 06 Removed scope references from VA */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* Use new mms_deletable in MVL_NVLIST_CTRL. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* _mvl_process_getvla_ind */
/* A 'Get Variable List Attributes' indication has been received, */
/* process it and respond */
/************************************************************************/
ST_VOID _mvl_process_getvla_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.getvlist.req_info =
(GETVLIST_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_getvlist_ind (indCtrl);
}
/************************************************************************/
/* mvlas_getvlist_resp */
/************************************************************************/
ST_VOID mvlas_getvlist_resp (MVL_IND_PEND *indCtrl)
{
GETVLIST_REQ_INFO *req_info;
GETVLIST_RESP_INFO *resp_info;
MVL_NVLIST_CTRL *nvlist;
ST_INT num_var;
ST_INT i;
VARIABLE_LIST *vl;
MVL_VAR_ASSOC *va;
MVL_SCOPE *va_scope;
MVL_SCOPE vmdVaScope;
req_info = indCtrl->u.getvlist.req_info;
/* Now find the named variable list */
#if defined(USE_MANUFACTURED_OBJS)
nvlist = u_mvl_get_nvl (MMSOP_GET_VLIST, &req_info->vl_name,
indCtrl->event->net_info);
#else /* default */
nvlist = mvl_vmd_find_nvl (&mvl_vmd, &req_info->vl_name, indCtrl->event->net_info);
#endif /* default */
if (nvlist)
{
num_var = nvlist->num_of_entries;
resp_info = (GETVLIST_RESP_INFO *)
M_CALLOC (MSMEM_ENC_OS_INFO, 1, sizeof(GETVLIST_RESP_INFO) +
(num_var * sizeof(VARIABLE_LIST)));
resp_info->mms_deletable = nvlist->mms_deletable;
resp_info->num_of_variables = num_var;
vl = (VARIABLE_LIST *) (resp_info + 1);
for (i = 0; i < num_var; ++i, ++vl)
{
va = nvlist->entries[i];
/* For backwards compatibility only ... */
if (nvlist->va_scope != NULL)
va_scope = &nvlist->va_scope[i];
else
{
MVL_LOG_NERR0 ("Warning: Info Rpt nvl->va_scope is NULL, using VMD scope");
va_scope = &vmdVaScope;
va_scope->scope = VMD_SPEC;
}
vl->alt_access_pres = SD_FALSE;
vl->var_spec.var_spec_tag = VA_SPEC_NAMED;
/* We know this is a union so the following line is OK ... */
vl->var_spec.vs.name.obj_name.vmd_spec = va->name;
vl->var_spec.vs.name.object_tag = va_scope->scope;
if (va_scope->scope == DOM_SPEC)
vl->var_spec.vs.name.domain_id = va_scope->dom->name;
}
indCtrl->u.getvlist.resp_info = resp_info;
mplas_getvlist_resp (indCtrl);
#if defined(USE_MANUFACTURED_OBJS)
u_mvl_free_nvl (MMSOP_GET_VLIST, nvlist, indCtrl->event->net_info);
#endif
M_FREE (MSMEM_ENC_OS_INFO, resp_info);
}
else
{
MVL_LOG_NERR0 ("Get Var List Attributes Indication : could not find the list");
_mplas_err_resp (indCtrl,MMS_ERRCLASS_DEFINITION,MMS_ERRCODE_OBJ_UNDEFINED);
}
}
/************************************************************************/
/* mplas_getvlist_resp */
/************************************************************************/
ST_VOID mplas_getvlist_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
rc = mpl_getvlist_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.getvlist.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.getvlist.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

65
mmslib/mvlu/s_ident.c Normal file
View File

@@ -0,0 +1,65 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1996 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_ident.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mplas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_ident_ind */
/* A identify indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_ident_ind (MVL_IND_PEND *indCtrl)
{
/* There is no Request Info for this service. Just call user function.*/
u_mvl_ident_ind (indCtrl);
}
/************************************************************************/
/* mplas_ident_resp */
/************************************************************************/
ST_VOID mplas_ident_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build an identify response */
rc = mpl_ident_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.ident.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.ident.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

219
mmslib/mvlu/s_info.c Normal file
View File

@@ -0,0 +1,219 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_info.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 20 Enhanced filtered logging */
/* 01/30/06 GLB 19 Integrated porting changes for VMS */
/* 12/12/02 JRB 18 Add & use mvl_encode_info_rpt funct. */
/* Use new thread-safe mpl_info,_mvl_send_msg */
/* and skip S_LOCK.. */
/* Pass net_info to mvl_get_va_asn1_data so */
/* don't need mvl_curr_net_info global var. */
/* 07/10/02 JRB 17 Call mvl_ureq_bufs_avail. */
/* 02/25/02 MDE 16 Now get max PDU size from mvl_cfg_info */
/* 09/21/01 JRB 15 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 14 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 10/06/00 MDE 13 Added LOCK/UNLOCK */
/* 08/07/00 JRB 12 Set scope & domain name correctly for NVL. */
/* 05/15/00 MDE 11 Added MMS statistics */
/* 04/14/00 JRB 10 Lint cleanup. */
/* 01/21/00 MDE 09 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 08 Added SD_CONST modifiers */
/* 09/07/99 MDE 07 Changed MVL_VA_SCOPE to MVL_SCOPE */
/* 12/11/98 MDE 06 Removed scope references from VA */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 06/15/98 MDE 04 Changes to allow compile under C++ */
/* 02/10/98 MDE 03 Removed NEST_RT_TYPES, always support AA */
/* 09/18/97 MDE 02 Fixed problem when no nvl->altAcc */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_acse.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
ST_RET mvl_info_variables (MVL_NET_INFO *net_info, MVL_NVLIST_CTRL *nvl,
ST_BOOLEAN listOfVariables)
{
ST_RET rc;
ASN1_ENC_CTXT aCtx;
ST_UCHAR *my_enc_buf;
if (mvl_ureq_bufs_avail (net_info) <= 0)
{
MVL_LOG_ERR0 ("Not enough ACSE buffers available to send InformationReport");
return (MVL_ERR_REQ_PEND_COUNT);
}
my_enc_buf = (ST_UCHAR *) mvl_enc_buf_alloc (mmsl_enc_buf_size);
asn1r_strt_asn1_bld (&aCtx, my_enc_buf, mmsl_enc_buf_size);/*CRITICAL*/
rc = mvl_encode_info_rpt (net_info, nvl, listOfVariables, &aCtx);
if (rc == SD_SUCCESS)
{ /* Encode was successful, go ahead and send. */
rc = _mvl_send_msg (ASN1_ENC_PTR(&aCtx),ASN1_ENC_LEN(&aCtx),net_info);
if (rc == SD_SUCCESS) /* _mvl_send_msg logs on any error. */
++mvl_mms_statistics.serverInfoRpt;
}
mvl_enc_buf_free (my_enc_buf);
return(rc);
}
/************************************************************************/
/* mvl_encode_info_rpt */
/************************************************************************/
ST_RET mvl_encode_info_rpt (MVL_NET_INFO *net_info,
MVL_NVLIST_CTRL *nvl,
ST_BOOLEAN listOfVariables,
ASN1_ENC_CTXT *aCtx)
{
ST_RET rc;
INFO_REQ_INFO *info_info;
ACCESS_RESULT *ar;
ST_INT req_info_size;
MVL_VAR_ASSOC *va;
MVL_SCOPE *va_scope;
MVL_SCOPE vmdVaScope;
ST_UCHAR *asn1_buf;
ST_UCHAR *asn1_start;
ST_INT asn1_len;
ST_INT asn1_buf_left;
VARIABLE_LIST *vl;
ST_INT num_var;
ST_INT i;
ST_BOOLEAN alt_access_pres;
ALT_ACCESS *alt_acc;
va = *nvl->entries;
num_var = nvl->num_of_entries;
/* Calculate the required size for the info report information */
req_info_size = sizeof(INFO_REQ_INFO) +
(num_var * sizeof(ACCESS_RESULT));
/* May need to add some more to handle the variable specification */
if (listOfVariables == SD_TRUE)
req_info_size += (num_var * sizeof(VARIABLE_LIST));
info_info = (INFO_REQ_INFO *) M_CALLOC (MSMEM_ENC_OS_INFO, 1, req_info_size);
info_info->num_of_acc_result = num_var;
/* We need to create the variable specification - either a list of */
/* variables or a named variable list */
if (listOfVariables == SD_TRUE)
{
info_info->va_spec.var_acc_tag = VAR_ACC_VARLIST;
info_info->va_spec.num_of_variables = num_var;
vl = (VARIABLE_LIST *) (info_info + 1);
for (i = 0; i < nvl->num_of_entries; ++i, ++vl)
{
va = nvl->entries[i];
/* For backwards compatibility only ... */
if (nvl->va_scope != NULL)
va_scope = &nvl->va_scope[i];
else
{
MVL_LOG_NERR0 ("Warning: Info Rpt nvl->va_scope is NULL, using VMD scope");
va_scope = &vmdVaScope;
va_scope->scope = VMD_SPEC;
}
/* We know this is a union so the following line is OK ... */
vl->var_spec.vs.name.obj_name.vmd_spec = va->name;
vl->var_spec.vs.name.object_tag = va_scope->scope;
if (va_scope->scope == DOM_SPEC)
vl->var_spec.vs.name.domain_id = va_scope->dom->name;
}
info_info->acc_rslt_list = (ACCESS_RESULT *) (vl);
}
else /* Named Variable List */
{
info_info->va_spec.var_acc_tag = VAR_ACC_NAMEDLIST;
info_info->va_spec.vl_name.object_tag = nvl->nvl_scope.scope;
if (nvl->nvl_scope.scope == DOM_SPEC)
info_info->va_spec.vl_name.domain_id = nvl->nvl_scope.dom->name;
info_info->va_spec.vl_name.obj_name.vmd_spec = nvl->name;
info_info->acc_rslt_list = (ACCESS_RESULT *) (info_info + 1);
}
ar = info_info->acc_rslt_list;
asn1_buf = (ST_UCHAR *) M_MALLOC (MSMEM_ASN1_DATA_ENC, mvl_cfg_info->max_msg_size);
asn1_buf_left = mvl_cfg_info->max_msg_size;
/* Now encode the data, create the access result */
asn1_start = asn1_buf;
for (i = 0; i < nvl->num_of_entries; ++i, ++ar)
{
va = nvl->entries[i];
alt_access_pres = SD_FALSE;
if (nvl->altAcc)
{
alt_acc = nvl->altAcc[i];
if (alt_acc != NULL)
alt_access_pres = SD_TRUE;
}
else
alt_acc = NULL; /* Just so it's initialized. Eliminates warning.*/
rc = mvl_get_va_asn1_data (net_info, va, alt_access_pres, alt_acc, asn1_start,
asn1_buf_left, &asn1_len);
if (rc == SD_SUCCESS)
{
ar->acc_rslt_tag = ACC_RSLT_SUCCESS;
ar->va_data.len = asn1_len;
ar->va_data.data = asn1_start;
asn1_buf_left -= asn1_len; /* adjust buffer control variables */
asn1_start += asn1_len;
}
else
{
ar->acc_rslt_tag = ACC_RSLT_FAILURE;
ar->failure = ARE_TYPE_INCONSISTENT;
}
}
/* Build a info request */
rc = mpl_info (aCtx, info_info);
/* Log the PDU, if enabled */
mpl_unsol_req_log (net_info, MMSOP_INFO_RPT, info_info);
M_FREE (MSMEM_ENC_OS_INFO, info_info);
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
if (rc != SD_SUCCESS)
MVL_LOG_NERR1 ("mvl_encode_info_rpt error = %x", rc);
return (rc);
}

69
mmslib/mvlu/s_jinit.c Normal file
View File

@@ -0,0 +1,69 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1996 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_jinit.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_jinit_ind */
/* mplas_jinit_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mvlas resp function. */
/* 11/04/97 MDE 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_jinit_ind */
/* A Initialize Journal indication has been rcved, process and respond */
/************************************************************************/
ST_VOID _mvl_process_jinit_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.jinit.req_info =
(JINIT_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_jinit_ind (indCtrl);
}
/************************************************************************/
/* mplas_jinit_resp */
/************************************************************************/
ST_VOID mplas_jinit_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a jinit response */
rc = mpl_jinit_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.jinit.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.jinit.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

337
mmslib/mvlu/s_jread.c Normal file
View File

@@ -0,0 +1,337 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1996 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_jread.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_jread_ind */
/* mvlas_jread_resp */
/* mplas_jread_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 21 Enhanced filtered logging */
/* 10/30/06 JRB 20 Use new mvl_vmd_* object handling functions. */
/* 01/30/06 GLB 19 Integrated porting changes for VMS */
/* 03/28/05 JRB 18 Del suicacse header. */
/* 02/25/02 MDE 17 Now get max PDU size from mvl_cfg_info */
/* 09/21/01 JRB 16 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 15 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 01/21/00 MDE 14 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 13 Added SD_CONST modifiers */
/* 08/30/99 JRB 12 DON'T log after mplas_err_resp (causes GPF). */
/* 01/15/99 JRB 11 Call mvl_find_jou to find journal. */
/* 11/16/98 MDE 10 Renamed internal functions (prefix '_') */
/* 10/09/98 JRB 09 Use modified MVL_JOURNAL_ENTRY. */
/* 09/21/98 MDE 08 Minor lint cleanup */
/* 09/10/98 JRB 07 Make sure moreFollows set correctly. */
/* 07/16/98 MDE 06 More journal work */
/* 07/15/98 MDE 05 Changed Journal Read user functions */
/* 06/15/98 MDE 04 Changes to allow compile under C++ */
/* 05/14/98 JRB 03 Use MVL_IND_PEND. Add mvlas resp function. */
/* 05/14/98 JRB 02 Fixed uninitialized pointers, etc. */
/* 11/04/97 MDE 01 Created */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_acse.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
/* Local variables and functions */
static MVL_JREAD_BUF_CTRL _bufCtrl;
static ST_UCHAR *_asn1BufStart;
static ST_INT _asn1BufLeft;
static ST_RET mvlJe_to_je (JOURNAL_ENTRY *je, MVL_JOURNAL_ENTRY *mvlJe);
/************************************************************************/
/************************************************************************/
/* _mvl_process_jread_ind */
/* A Read Journal indication has been rcved, process and respond */
/************************************************************************/
ST_VOID _mvl_process_jread_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.jread.req_info =
(JREAD_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_jread_ind (indCtrl);
}
/************************************************************************/
/* mvlas_jread_resp */
/* This is the Virtual Machine response function for ReadJournal. */
/* It calls the following user functions to manage the Journal data: */
/* u_mvl_start_jread */
/* u_mvl_get_next_jread_entry */
/* u_mvl_free_jread_entry */
/* u_mvl_end_jread */
/************************************************************************/
ST_RET app_start_jread(MVL_JOURNAL_CTRL *jCtrl,JREAD_REQ_INFO *reqInfo,MVL_JREAD_BUF_CTRL *bufCtrl,
void **usrHandleOut);
ST_VOID mvlas_jread_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
JREAD_REQ_INFO *reqInfo;
JREAD_RESP_INFO *respInfo;
JOURNAL_ENTRY *je;
ST_BOOLEAN moreFollows = SD_FALSE; /* Would never get set if 0 entries*/
MVL_JOURNAL_CTRL *jCtrl;
MVL_JOURNAL_ENTRY mvlJe;
MVL_JOURNAL_ENTRY *mvlJep;
ST_VOID *usrHandle;
ST_UCHAR *asn1_buf;
ST_INT i;
reqInfo = indCtrl->u.jread.req_info;
/* First find our Journal Control element */
jCtrl = mvl_vmd_find_jou (&mvl_vmd, &reqInfo->jou_name, indCtrl->event->net_info);
if (jCtrl == NULL)
{
MVL_LOG_NERR1 ("ReadJournal - could not find journal '%s'",
reqInfo->jou_name.obj_name.vmd_spec);
printf("ReadJournal - could not find journal '%s'\n",
reqInfo->jou_name.obj_name.vmd_spec);
_mplas_err_resp (indCtrl, 2, 1); /* object undefined */
return;
}
/* Give the user the JREAD request information */
memset (&_bufCtrl, 0, sizeof (MVL_JREAD_BUF_CTRL));
/* renxiaobao <20><>־*/
/*rc = u_mvl_start_jread (jCtrl, reqInfo, &_bufCtrl, &usrHandle);*/
rc = app_start_jread(jCtrl, reqInfo, &_bufCtrl, &usrHandle);
if (rc != SD_SUCCESS)
{
_mplas_err_resp (indCtrl, 2, 1); /* object undefined */
return;
}
/* Limit the number we will return */
if (_bufCtrl.numUsrEntries > MAX_JREAD_RESP_ENTRIES)
_bufCtrl.numUsrEntries = MAX_JREAD_RESP_ENTRIES;
if (_bufCtrl.numVarInfo > MAX_JREAD_RESP_VARS)
_bufCtrl.numVarInfo = MAX_JREAD_RESP_VARS;
/* Allocate the response information data buffer */
respInfo =
(JREAD_RESP_INFO *) M_CALLOC (MSMEM_ENC_OS_INFO, 1, sizeof (JREAD_RESP_INFO) +
(_bufCtrl.numUsrEntries * sizeof (JOURNAL_ENTRY)) +
(_bufCtrl.numVarInfo * sizeof (VAR_INFO)) );
/*
//printf("respInfo size=%d \n ",sizeof (JREAD_RESP_INFO) +
// (_bufCtrl.numUsrEntries * sizeof (JOURNAL_ENTRY)) +
// (_bufCtrl.numVarInfo * sizeof (VAR_INFO)));
*/
/* Set the storage buffer start locations */
#if defined (MVL_JREAD_ENTRYID_DYNAMIC)
_bufCtrl.nextEntryId = _bufCtrl.entryIdBuf;
#endif
#if defined (MVL_JREAD_VARTAG_DYNAMIC)
_bufCtrl.nextVarTag = _bufCtrl.varTagBuf;
#endif
#if defined (MVL_JREAD_ANNOTATION_DYNAMIC)
_bufCtrl.nextAnnotation = _bufCtrl.annotationBuf;
#endif
/* Allocate the ASN.1 data encode buffer */
asn1_buf = (ST_UCHAR *) M_MALLOC (MSMEM_ASN1_DATA_ENC, mvl_cfg_info->max_msg_size);
_asn1BufStart = asn1_buf;
_asn1BufLeft = mvl_cfg_info->max_msg_size;
/* Now get the journals from the user, one at a time */
respInfo->num_of_jou_entry = 0;
je = (JOURNAL_ENTRY *) (respInfo + 1);
for (i = 0; i < _bufCtrl.numUsrEntries; ++i)
{
/* get the next from the user */
mvlJep = &mvlJe;
rc = u_mvl_get_next_jread_entry (jCtrl, usrHandle, &moreFollows, &mvlJep);
if (rc != SD_SUCCESS)
{
moreFollows = SD_FALSE; /* Didn't get entry, so can't be more. */
break;
}
/* Map it onto the MMS-EASE JOURNAL_ENTRY */
rc = mvlJe_to_je (je, mvlJep);
/* Let the user free resources */
u_mvl_free_jread_entry (jCtrl, usrHandle, mvlJep);
/* Verify that the mapping was OK */
if (rc != SD_SUCCESS)
{
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
M_FREE (MSMEM_ENC_OS_INFO, respInfo);
_mplas_err_resp (indCtrl, 1, 3); /* application reference invalid */
return;
}
++respInfo->num_of_jou_entry;
if (moreFollows == SD_FALSE)
break;
/* We need to adjust the MMS-EASE JE pointer to the next position */
/* Each JE is possibly followed by a array of VAR_INFO */
if (je->ent_content.entry_form_tag == 2 &&
je->ent_content.ef.data.list_of_var_pres)
{
je = (JOURNAL_ENTRY *) ((ST_CHAR *)je + sizeof (JOURNAL_ENTRY) +
je->ent_content.ef.data.num_of_var * sizeof (VAR_INFO));
}
else
++je; /* CRITICAL: don't try to access je after this */
}
respInfo->more_follows = moreFollows;
/* OK, the MMS-EASE data structure is ready to roll */
indCtrl->u.jread.resp_info = respInfo;
mplas_jread_resp (indCtrl);
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
M_FREE (MSMEM_ENC_OS_INFO, respInfo);
/* Tell the user we are done */
u_mvl_end_jread (jCtrl, usrHandle, &_bufCtrl, reqInfo);
}
/************************************************************************/
/* mplas_jread_resp */
/************************************************************************/
ST_VOID mplas_jread_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a jread response */
rc = mpl_jread_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.jread.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.jread.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}
/************************************************************************/
/* mvlJe_to_je */
/************************************************************************/
static ST_RET mvlJe_to_je (JOURNAL_ENTRY *je, MVL_JOURNAL_ENTRY *mvlJe)
{
ST_UCHAR *appRefAsn1Start;
ST_INT appRefAsn1Len;
ST_INT i;
ST_INT numVar;
ST_RET rc;
VAR_INFO *varInfo;
/* First take care of the entry ID */
#if defined (MVL_JREAD_ENTRYID_DYNAMIC)
je->entry_id_len = mvlJe->entry_id_len;
je->entry_id = _bufCtrl.nextEntryId;
memcpy (_bufCtrl.nextEntryId, mvlJe->entry_id, mvlJe->entry_id_len);
_bufCtrl.nextEntryId += mvlJe->entry_id_len;
#else
je->entry_id_len = mvlJe->entry_id_len;
je->entry_id = mvlJe->entry_id;
#endif
/* Now take care of the application reference ... */
rc = ms_appref_to_asn1 (&(mvlJe->orig_app), _asn1BufStart, _asn1BufLeft,
&appRefAsn1Start, &appRefAsn1Len);
if (rc == SD_SUCCESS)
{
je->orig_ae_len = appRefAsn1Len;
je->orig_ae = appRefAsn1Start;
/* Adjust ASN.1 buffer control - this was built from the back, so */
/* don't need to change the buffer start pointer. */
_asn1BufLeft -= appRefAsn1Len;
}
else
{
MVL_LOG_ERR0 ("Error: ReadJournal.Resp: orig_app encode failed");
return (rc);
}
/* Now set up the entry content */
/* Occurance Time */
memcpy (&(je->ent_content.occur_time), &(mvlJe->occur_time),
sizeof (MMS_BTOD));
/* No additional detail */
je->ent_content.addl_detail_pres = SD_FALSE;
je->ent_content.entry_form_tag = mvlJe->entry_form_tag;
if (mvlJe->entry_form_tag == 2) /* event/data */
{
je->ent_content.ef.data.event_pres = mvlJe->ef.data.event_pres;
memcpy (&(je->ent_content.ef.data.evcon_name),
&(mvlJe->ef.data.evcon_name), sizeof (OBJECT_NAME));
je->ent_content.ef.data.cur_state = mvlJe->ef.data.cur_state;
je->ent_content.ef.data.list_of_var_pres = mvlJe->ef.data.list_of_var_pres;
if (je->ent_content.ef.data.list_of_var_pres)
{
numVar = mvlJe->ef.data.num_of_var;
je->ent_content.ef.data.num_of_var = numVar;
varInfo = (VAR_INFO *) (je + 1);
for (i = 0; i < numVar; ++i, ++varInfo)
{
/* OK, now tell MMS-EASE where the ASN.1 data is */
varInfo->value_spec.data = mvlJe->ef.data.list_of_var[i].value_spec.data;
varInfo->value_spec.len = mvlJe->ef.data.list_of_var[i].value_spec.len;
/* Now store the var_tag in our buffer and set the MMS pointer */
#if defined (MVL_JREAD_VARTAG_DYNAMIC)
varInfo->var_tag = _bufCtrl.nextVarTag;
strcpy (_bufCtrl.nextVarTag, mvlJe->ef.data.list_of_var[i].var_tag);
_bufCtrl.nextVarTag += (strlen (_bufCtrl.nextVarTag) + 1);
#else
varInfo->var_tag = mvlJe->ef.data.list_of_var[i].var_tag;
#endif
} /* end "loop" */
} /* end "if list_of_var_pres" */
}
else /* entry form is annotation */
{
#if defined (MVL_JREAD_ANNOTATION_DYNAMIC)
je->ent_content.ef.annotation = _bufCtrl.nextAnnotation;
strcpy (_bufCtrl.nextAnnotation, mvlJe->ef.annotation);
_bufCtrl.nextAnnotation += (strlen (_bufCtrl.nextAnnotation) + 1);
#else
je->ent_content.ef.annotation = mvlJe->ef.annotation;
#endif
}
return (SD_SUCCESS);
}

67
mmslib/mvlu/s_jstat.c Normal file
View File

@@ -0,0 +1,67 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1998, All Rights Reserved */
/* */
/* MODULE NAME : s_jstat.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_jstat_ind */
/* mplas_jstat_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 10 Enhanced filtered logging */
/* 03/11/04 GLB 09 Remove "thisFileName" */
/* 09/21/01 JRB 08 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 07 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 06 Added SD_CONST modifiers */
/* 04/01/99 MDE 05 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 04 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 03 Minor lint cleanup */
/* 06/15/98 MDE 02 Changes to allow compile under C++ */
/* 04/14/98 JRB 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pfil.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* _mvl_process_jstat_ind */
/* A "jstat" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_jstat_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.jstat.req_info =
(JSTAT_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_jstat_ind (indCtrl);
}
/************************************************************************/
/* mplas_jstat_resp */
/************************************************************************/
ST_VOID mplas_jstat_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build a jstat response */
rc = mpl_jstat_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.jstat.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.jstat.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

466
mmslib/mvlu/s_obtfi.c Normal file
View File

@@ -0,0 +1,466 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1998 - 1999, All Rights Reserved */
/* */
/* MODULE NAME : s_obtfi.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* _mvl_process_obtfile_ind */
/* mplas_obtfile_resp */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 11/12/07 MDE 10 Use _mvl_getpath for temp file path */
/* 04/09/07 MDE 09 Enhanced filtered logging */
/* 10/17/06 MDE 08 Added mvlas_obtfile_resp_ex */
/* 01/30/06 GLB 07 Integrated porting changes for VMS */
/* 02/04/03 MDE 06 Now use _mvl_tmpnam */
/* 09/21/01 JRB 05 Alloc global bufs only once at startup. */
/* 04/14/00 EJV 04 Added check for more error conditions in */
/* u_fopen_done and u_fread_done */
/* 03/21/00 JRB 03 Send err resp if tmpnam or fopen fails. */
/* 01/21/00 MDE 02 Now use MEM_SMEM for dynamic memory */
/* 10/15/99 GLB 01 Created to add Obtain File function */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "glbsem.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
#include <stdio.h>
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
typedef struct filecopyinfo
{
ST_CHAR tempfilename[MVL_MAX_TMPNAM_LEN+1];
ST_CHAR destfilename[MAX_FILE_NAME+1];
MVL_IND_PEND *indCtrl;
FILE *fp;
ST_INT32 frsmid;
ST_UINT32 fsize;
ST_UINT32 fileSizeLimit;
} MVL_OBTFILE_STATE;
MVL_REQ_PEND *send_file_open (MVL_NET_INFO *NetInfo, ST_CHAR *src);
MVL_REQ_PEND *send_file_read (MVL_NET_INFO *NetInfo,
MVL_OBTFILE_STATE *u_file_info);
MVL_REQ_PEND *send_file_close (MVL_NET_INFO *NetInfo,
MVL_OBTFILE_STATE *u_file_info);
ST_VOID u_fopen_done (MVL_REQ_PEND *req);
ST_VOID u_fread_done( MVL_REQ_PEND *req);
ST_VOID u_fclose_done( MVL_REQ_PEND *req);
/************************************************************************/
/************************************************************************/
/* _mvl_process_obtfile_ind */
/* An Obtain File request has been sent and */
/* An Obtain File indication was received, so process it and respond */
/************************************************************************/
ST_VOID _mvl_process_obtfile_ind (MVL_IND_PEND *indCtrl)
{
OBTFILE_REQ_INFO *req_info;
MVLAS_OBTFILE_CTRL *obtfile;
FILE_NAME *fname_idx;
req_info = (OBTFILE_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
fname_idx = (FILE_NAME *)(req_info + 1);
obtfile = &indCtrl->u.obtfile;
if (_mvl_concat_filename (obtfile->srcfilename, req_info->num_of_src_fname,
fname_idx, sizeof (obtfile->srcfilename)))
{
MVL_LOG_ERR0 ("ObtFile error: _mvl_process_obtfile_ind failed (_mvl_concat_filename(srcfilename) failed)");
_mplas_err_resp (indCtrl,11,3); /* 3 = File name syntax error */
return;
}
if (_mvl_concat_filename (obtfile->destfilename, req_info->num_of_dest_fname,
(FILE_NAME *)(fname_idx + req_info->num_of_src_fname),
sizeof (obtfile->destfilename)))
{
MVL_LOG_ERR0 ("ObtFile error: _mvl_process_obtfile_ind failed (_mvl_concat_filename(destfilename) failed)");
_mplas_err_resp (indCtrl,11,3); /* 3 = File name syntax error */
return;
}
u_mvl_obtfile_ind (indCtrl);
}
/************************************************************************/
/* mvlas_obtfile_resp */
/* Open a temp file to copy into and save the destination file name */
/************************************************************************/
ST_VOID mvlas_obtfile_resp (MVL_IND_PEND *indCtrl)
{
mvlas_obtfile_resp_ex (indCtrl, 0);
}
extern int mms_filename_conv(char *mms_name,char *sys_name);
ST_VOID mvlas_obtfile_resp_ex (MVL_IND_PEND *indCtrl, ST_UINT32 fileSizeLimit)
{
MVL_OBTFILE_STATE *obtfile_state;
MVL_REQ_PEND *req;
MVLAS_OBTFILE_CTRL *obtfile;
int ret;
ST_CHAR tmpfile_path[MVL_MAX_TMPFILE_PATH];
ST_CHAR destfilename[MVL_MAX_TMPFILE_PATH];
obtfile = &indCtrl->u.obtfile;
obtfile_state = (MVL_OBTFILE_STATE *) M_CALLOC (MSMEM_GEN, 1, sizeof (MVL_OBTFILE_STATE));
/* save destination name for rename */
/*<2A>ļ<EFBFBD><C4BC><EFBFBD>ӳ<EFBFBD><D3B3>*/
ret = mms_filename_conv(obtfile->destfilename,destfilename);
if(!ret) printf("<EFBFBD>ļ<EFBFBD>%sӳ<73><D3B3>ʧ<EFBFBD><CAA7>...\n\r",obtfile->destfilename);
strcpy(obtfile->destfilename,destfilename);
/*renxiaobao <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
tmpfile_path[0] = 0;
if(obtfile->destfilename[0]!='/') strcpy (tmpfile_path, "/");
strcat (tmpfile_path, obtfile->destfilename);
strcpy(obtfile->destfilename,tmpfile_path);*/
strncpy (obtfile_state->destfilename, obtfile->destfilename, MAX_FILE_NAME+1);
obtfile_state->indCtrl = indCtrl;
/* Create a temporary file name to copy into. This prevents partially */
/* transferred files from hanging around and being accidently used */
/* Open the created temporary file. Send the file open request. */
_mvl_getpath (destfilename, tmpfile_path);
if (_mvl_tmpnam (obtfile_state->tempfilename, tmpfile_path) != SD_SUCCESS ||
(obtfile_state->fp = fopen(obtfile_state->tempfilename, "wb")) == NULL ||
(req = send_file_open (indCtrl->event->net_info,obtfile->srcfilename)) == NULL)
{
if ( obtfile_state->fp )
{
MVL_LOG_ERR0 ("ObtFile error: mvlas_obtfile_resp failed (fopen failed)");
fclose (obtfile_state->fp); /* close temporary file */
remove (obtfile_state->tempfilename); /* get rid of temporary file */
}
else
{
MVL_LOG_ERR1 ("ObtFile: mvlas_obtfile_resp failed (invalid tmpnam (%s) or send_file_open failed)",
obtfile_state->tempfilename);
}
_mplas_err_resp (indCtrl,11,0); /* 0 = other */
}
else
{
req->v = obtfile_state;
obtfile_state->fileSizeLimit = fileSizeLimit;
}
}
/************************************************************************/
/* send_file_open */
/* Send a file open request to open file on the other side */
/************************************************************************/
MVL_REQ_PEND *send_file_open (MVL_NET_INFO *NetInfo, ST_CHAR *src)
{
MVL_REQ_PEND *req= NULL;
if ((mvla_fopen(NetInfo, src, 0, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fopen_done;
}
return (req);
}
/************************************************************************/
/* u_fopen_done */
/* It was indicated that a file open request was made */
/* Confirm file open response that was received as a result of a request*/
/************************************************************************/
ST_VOID u_fopen_done( MVL_REQ_PEND *req)
{
ST_RET ret;
MVL_REQ_PEND *freadreq= NULL;
MVL_OBTFILE_STATE *obtfile_state;
FOPEN_RESP_INFO *resp_info;
#if 0
ERR_INFO *err_ptr;
REJECT_RESP_INFO *rej_ptr;
#endif
obtfile_state = (MVL_OBTFILE_STATE *) req->v;
ret = req->result;
if (ret == SD_SUCCESS)
{
resp_info = req->u.fopen.resp_info;
if (obtfile_state->fileSizeLimit > 0 &&
(resp_info->ent.fsize > obtfile_state->fileSizeLimit))
{
MVL_LOG_NERR2 ("ObtFile error: file size %ld exceeds limit %ld",
resp_info->ent.fsize, obtfile_state->fileSizeLimit);
ret = SD_FAILURE;
}
else
{
obtfile_state ->frsmid = resp_info->frsmid;
obtfile_state ->fsize = resp_info->ent.fsize;
if ((freadreq = send_file_read (req->net_info, obtfile_state)) != NULL)
{
freadreq->v = obtfile_state;
}
else
{
MVL_LOG_ERR0 ("ObtFile error: u_fopen_done failed (send_file_read failed)");
ret = SD_FAILURE;
}
}
}
else
{
MVL_LOG_ERR0 ("ObtFile error: u_fopen_done failed (mvla_fopen failed)");
}
if ( ret != SD_SUCCESS )
{ /* file open failed */
#if 0
if (req->result==MVL_ERR_CNF_REJ_ERR)
{
rej_ptr = (REJECT_RESP_INFO *) req->event->u.mms.dec_rslt.data_ptr;
printf ("\n MMS REJECT");
printf ("\n detected_here = %d",req->u.reject.resp_info->detected_here);
printf ("\n invoke_known = %d",req->u.reject.resp_info->invoke_known);
printf ("\n invoke = %d",req->u.reject.resp_info->invoke);
printf ("\n pdu_type = %d",req->u.reject.resp_info->pdu_type);
printf ("\n rej_class = %d",req->u.reject.resp_info->rej_class);
printf ("\n rej_code = %d",req->u.reject.resp_info->rej_code);
}
if (req->result==MVL_ERR_CNF_ERR_OK)
{
err_ptr = (ERR_INFO *) req->event->u.mms.dec_rslt.data_ptr;
printf ("\n MMS ERROR RESPONSE");
printf ("\n class = %d, code = %d", req->u.error.resp_info->eclass,
req->u.error.resp_info->code);
}
#endif
fclose (obtfile_state->fp); /* close temporary file */
remove (obtfile_state->tempfilename); /* get rid of temporary file */
if (req->net_info->conn_active == SD_TRUE)
_mplas_err_resp (obtfile_state->indCtrl,11,0); /* 0 = other */
M_FREE (MSMEM_GEN, obtfile_state);
}
mvl_free_req_ctrl (req);
}
/************************************************************************/
/* send_file_read */
/* Send a file read request to obtain a block of the file data */
/************************************************************************/
MVL_REQ_PEND *send_file_read (MVL_NET_INFO *NetInfo,
MVL_OBTFILE_STATE *obtfile_state)
{
MVL_REQ_PEND *req= NULL;
FREAD_REQ_INFO fread_req;
fread_req.frsmid = obtfile_state->frsmid;
if ((mvla_fread (NetInfo, &fread_req, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fread_done;
}
return (req);
}
/************************************************************************/
/* u_fread_done */
/* Confirm the file read response sent to indicate a read request */
/************************************************************************/
ST_VOID u_fread_done( MVL_REQ_PEND *req)
{
ST_RET ret;
MVL_REQ_PEND *freadreq= NULL;
MVL_REQ_PEND *fclosereq= NULL;
MVL_OBTFILE_STATE *obtfile_state;
FREAD_RESP_INFO *resp_info;
obtfile_state = (MVL_OBTFILE_STATE *) req->v;
ret = req->result;
if (ret == SD_SUCCESS)
{
resp_info = req->u.fread.resp_info;
if ( fwrite (resp_info->filedata, sizeof(ST_CHAR), resp_info->fd_len, obtfile_state->fp)
== (unsigned) resp_info->fd_len )
{
if ( resp_info->more_follows == SD_TRUE)
{
if ((freadreq = send_file_read (req->net_info, obtfile_state)) != NULL)
{
freadreq->v = obtfile_state; /* if more file data request to read another block */
}
else
{
MVL_LOG_ERR0 ("ObtFile error: u_fread_done failed (send_file_read failed)");
ret = SD_FAILURE;
}
}
else
{
if ((fclosereq = send_file_close (req->net_info, obtfile_state)) != NULL)
{
fclosereq->v = obtfile_state; /* no more file data so send a file close request */
}
else
{
MVL_LOG_ERR0 ("ObtFile error: u_fread_done failed (send_file_close failed)");
ret = SD_FAILURE;
}
}
}
else
{
/* write failed */
MVL_LOG_ERR0 ("ObtFile error: u_fread_done failed (fwrite failed)");
ret = SD_FAILURE;
}
}
else
{
MVL_LOG_ERR0 ("ObtFile error: u_fread_done failed (mvla_fread failed)");
}
if (ret != SD_SUCCESS )
{ /* read failed so close and remove temp file */
fclose (obtfile_state->fp);
remove (obtfile_state->tempfilename); /* may fail if file nonexistent */
if (req->net_info->conn_active == SD_TRUE)
_mplas_err_resp (obtfile_state->indCtrl,11,0); /* 0 = Other */
M_FREE (MSMEM_GEN, obtfile_state);
}
mvl_free_req_ctrl (req);
}
/************************************************************************/
/* send_file_close */
/* No more data to read from file so send a request to close the file */
/************************************************************************/
MVL_REQ_PEND *send_file_close (MVL_NET_INFO *NetInfo,
MVL_OBTFILE_STATE *obtfile_state)
{
MVL_REQ_PEND *req= NULL;
FCLOSE_REQ_INFO fclose_req;
fclose_req.frsmid = obtfile_state->frsmid;
if ((mvla_fclose (NetInfo, &fclose_req, &req)) == SD_SUCCESS)
{
req->u_req_done = u_fclose_done;
}
return (req);
}
/************************************************************************/
/* u_fclose_done */
/* Confirm file closed response */
/************************************************************************/
int obtfile_call_back(MVL_IND_PEND *indCtrl);
ST_VOID u_fclose_done( MVL_REQ_PEND *req)
{
int ret;
MVL_OBTFILE_STATE *obtfile_state;
obtfile_state = (MVL_OBTFILE_STATE *) req->v;
if (req->result == SD_SUCCESS) /* close succeeded */
{
/* always close transferred file, rename and remove temp file */
fclose (obtfile_state->fp); /* close temp file */
remove (obtfile_state->destfilename); /* may fail if file nonexistent */
/* rename the temporary file to become the requested destination file */
/* use the ANSI rename function if available on your OS */
/* otherwise use other function appropriate for your system */
if (rename (obtfile_state->tempfilename, obtfile_state->destfilename))
{
MVL_LOG_ERR0 ("ObtFile error: u_fclose_done failed (rename failed)");
printf("ObtFile error: %s-%s)",obtfile_state->tempfilename, obtfile_state->destfilename);
remove (obtfile_state->tempfilename); /* cleanup useless file */
_mplas_err_resp (obtfile_state->indCtrl, 11, 0); /* 0 = other file error */
}
else /* send an obtainfile response */
{
ret = obtfile_call_back (obtfile_state->indCtrl);
if(ret==0) mplas_obtfile_resp (obtfile_state->indCtrl);
else _mplas_err_resp (obtfile_state->indCtrl, 11, 0);
/* mplas_obtfile_resp (obtfile_state->indCtrl); */
}
}
else /* close failed */
{
MVL_LOG_ERR0 ("ObtFile error: u_fclose_done failed (mvla_fclose failed)");
/* always close transferred file, rename and remove temp file */
fclose (obtfile_state->fp); /* close temp file */
remove (obtfile_state->tempfilename); /* cleanup useless file */
/* but don't send an obtainfile response */
if (req->net_info->conn_active == SD_TRUE)
_mplas_err_resp (obtfile_state->indCtrl,11,0); /* 0 = other */
}
M_FREE (MSMEM_GEN, obtfile_state);
mvl_free_req_ctrl (req);
}
/************************************************************************/
/* mplas_obtfile_resp */
/* Send a response to confirm the obtain file request that prompted the */
/* reading of file data */
/************************************************************************/
ST_VOID mplas_obtfile_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build an Obtain File Response with Null to confirm */
rc = mpl_obtfile_resp (indCtrl->event->u.mms.dec_rslt.id);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, NULL);
_mvl_send_resp_i (indCtrl, rc);
}

449
mmslib/mvlu/s_read.c Normal file
View File

@@ -0,0 +1,449 @@
/*******************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 2005, All Rights Reserved */
/* */
/* MODULE NAME : s_read.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 01/23/09 JRB 30 Deal with non-named variables better */
/* 04/09/07 MDE 29 Enhanced filtered logging */
/* 10/30/06 JRB 28 Use new mvl_vmd_* object handling functions. */
/* Add args on call to _mvl_objname_to_va. */
/* Elim use of global "_mvl_curr_usr_ind_ctrl". */
/* 08/09/06 JRB 27 For MVL_UCA, call mvl_find_nvl */
/* (DO NOT call u_mvl_get_nvl, u_mvl_free_nvl). */
/* 01/30/06 GLB 26 Integrated porting changes for VMS */
/* 10/19/05 JRB 25 Fix spec_in_result handling (was ignored). */
/* 05/16/05 JRB 24 Send appropriate failure codes in read resp. */
/* 12/12/02 JRB 23 Add net_info arg to mvl_get_va_asn1_data & */
/* prep_.. functions to elim use of */
/* mvl_curr_net_info global var. */
/* 07/24/02 JRB 22 Use mvl_send_resp_i like ALL responses. */
/* 07/09/02 MDE 21 Add maxpend_ind support */
/* 02/25/02 MDE 20 Now get max PDU size from mvl_cfg_info */
/* 09/21/01 JRB 19 Alloc global bufs only once at startup. */
/* 03/30/01 MDE 18 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 10/25/00 JRB 17 Del u_mvl funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* 06/19/00 JRB 16 Free rdCtrl->vaCtrlTbl on error. */
/* 05/15/00 MDE 15 Added MMS statistics */
/* 03/10/00 JRB 14 Copy va_scope to appropriate structures. */
/* 01/21/00 MDE 13 Now use MEM_SMEM for dynamic memory */
/* 11/22/99 JRB 12 mvlas_read_resp: del indCtrl from link list */
/* 09/13/99 MDE 11 Added SD_CONST modifiers */
/* 04/07/99 MDE 10 Logging improvements */
/* 01/15/99 JRB 09 IF (u_mvl_get_nvl_fun != NULL) call it, */
/* ELSE call "mvl_find_nvl". */
/* 12/11/98 MDE 08 Removed scope references from VA */
/* 11/16/98 MDE 07 Renamed internal functions (prefix '_') */
/* 11/10/98 MDE 06 Moved 'mvl_get_va_asn1_data' to mvl_var.c */
/* 06/15/98 MDE 05 Changes to allow compile under C++ */
/* 05/15/98 JRB 04 Chg mvl_process.. arg to (MVL_IND_PEND *). */
/* 05/15/98 JRB 03 Call u_mvl_read_ind direct (no funct ptr). */
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES, always support AA, */
/* added 'u_mvl_rd_ind_start' and */
/* 'u_mvl_rd_resp_sent', other */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_acse.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
/************************************************************************/
ST_RET (*u_mvl_rd_ind_start) (MVL_IND_PEND *indCtrl);
ST_VOID (*u_mvl_rd_resp_sent) (MVL_IND_PEND *indCtrl);
/************************************************************************/
/************************************************************************/
/* Internal functions */
static ST_RET prep_lov_rd_ctrl (MVL_IND_PEND *indCtrl, READ_REQ_INFO *read_info,
MVLAS_READ_CTRL *rdCtrlOut);
static ST_RET prep_nvl_rd_ctrl (MVL_IND_PEND *indCtrl, MVL_NET_INFO *net_info, READ_REQ_INFO *read_info,
MVLAS_READ_CTRL *rdCtrlOut);
static ST_RET prep_read_resp (MVL_NET_INFO *net_info, MVLAS_READ_CTRL *rdCtrl,
READ_REQ_INFO *req_info,
READ_RESP_INFO **resp_info_out,
ST_UCHAR *asn1_buf, ST_INT asn1_buf_size);
/************************************************************************/
/************************************************************************/
/* _mvl_process_read_ind */
/************************************************************************/
ST_VOID _mvl_process_read_ind (MVL_IND_PEND *indCtrl)
{
READ_REQ_INFO *read_info;
MVLAS_READ_CTRL *rdCtrl;
ST_RET rc;
rdCtrl = &indCtrl->u.rd;
read_info = (READ_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
rdCtrl->var_acc_tag = read_info->va_spec.var_acc_tag;
rc = SD_SUCCESS;
if (u_mvl_rd_ind_start)
{
/* This might set optional user pointer "indCtrl->usr_ind_ctrl". */
rc = (*u_mvl_rd_ind_start) (indCtrl);
}
if (rc == SD_SUCCESS)
{
if (rdCtrl->var_acc_tag == VAR_ACC_NAMEDLIST)
rc = prep_nvl_rd_ctrl (indCtrl, indCtrl->event->net_info, read_info, rdCtrl);
else
rc = prep_lov_rd_ctrl (indCtrl, read_info, rdCtrl);
}
if (rc == SD_SUCCESS)
{
u_mvl_read_ind (indCtrl);
}
else
{
_mplas_err_resp (indCtrl,7,2);
}
}
/************************************************************************/
/* prep_lov_rd_ctrl */
/************************************************************************/
static ST_RET prep_lov_rd_ctrl (MVL_IND_PEND *indCtrl, READ_REQ_INFO *read_info,
MVLAS_READ_CTRL *rdCtrl)
{
MVLAS_RD_VA_CTRL *vaCtrl;
VARIABLE_LIST *vl;
ST_INT num_var;
ST_INT i;
ST_BOOLEAN alt_access_pres;
/* This is a list of variables */
/* Allocate the read control data structures */
num_var = read_info->va_spec.num_of_variables;
rdCtrl->vaCtrlTbl = (MVLAS_RD_VA_CTRL *) M_CALLOC (MSMEM_GEN, num_var,
sizeof(MVLAS_RD_VA_CTRL));
vaCtrl = rdCtrl->vaCtrlTbl;
rdCtrl->numVar = num_var;
/* Prepare to process each variable in the list */
vl = (VARIABLE_LIST *) (read_info + 1);
for (i = 0; i < num_var; ++i, ++vl, ++vaCtrl)
{
ST_BOOLEAN alt_access_done = SD_FALSE; /* chg if AA processed */
/* These are done by the 'chk_calloc' call */
/* vaCtrl->va = NULL; */
/* vaCtrl->alt_access_pres = SD_FALSE; */
vaCtrl->acc_rslt_tag = ACC_RSLT_SUCCESS;
alt_access_pres = vl->alt_access_pres;
if (alt_access_pres) /* no alternate access support now */
{
#if !defined(MVL_AA_SUPP)
MVL_LOG_NERR0 ("Read Indication : Alternate Access not supported");
continue;
#else
/* now create the AA, given the ASN.1 spec */
if (ms_asn1_to_aa (vl->alt_access.data, vl->alt_access.len,
&vaCtrl->alt_acc))
{
MVL_LOG_NERR0 ("Read Indication : ASN.1 -> AA failure");
continue;
}
vaCtrl->alt_access_pres = SD_TRUE;
#endif
}
switch (vl->var_spec.var_spec_tag)
{
case VA_SPEC_NAMED :
vaCtrl->va = _mvl_objname_to_va (&mvl_vmd, indCtrl->event->net_info, MMSOP_READ, &vl->var_spec.vs.name,
&vaCtrl->va_scope,
alt_access_pres,
&vaCtrl->alt_acc,
&alt_access_done);
if (!vaCtrl->va)
{
MVL_LOG_NERR1 ("Read ind : Variable Association '%s' not found",
vl->var_spec.vs.name.obj_name.vmd_spec);
}
break;
case VA_SPEC_ADDRESSED:
case VA_SPEC_DESCRIBED:
case VA_SPEC_SCATTERED:
case VA_SPEC_INVALIDATED:
default :
MVL_LOG_NERR1 ("Read: Unsupported MMS VariableSpecification Tag %d", vl->var_spec.var_spec_tag);
/* NOTE: "vaCtrl->va = NULL" already. That's GOOD. */
break;
}
if (vaCtrl->va)
vaCtrl->va->usr_ind_ctrl = indCtrl->usr_ind_ctrl; /* save optional user pointer in va*/
/* If alt_acc allocated, free it now if done with it, or if va not found.*/
if (alt_access_pres && (alt_access_done || vaCtrl->va==NULL))
{
M_FREE (MSMEM_GEN, vaCtrl->alt_acc.aa);
vaCtrl->alt_access_pres = SD_FALSE;
}
}
return (SD_SUCCESS);
}
/************************************************************************/
/* prep_nvl_rd_ctrl */
/************************************************************************/
static ST_RET prep_nvl_rd_ctrl (MVL_IND_PEND *indCtrl, MVL_NET_INFO *net_info, READ_REQ_INFO *read_info,
MVLAS_READ_CTRL *rdCtrl)
{
MVL_NVLIST_CTRL *nvList;
MVLAS_RD_VA_CTRL *vaCtrl;
ST_INT i;
ST_INT num_var;
/* search for the NVL */
#if defined(USE_MANUFACTURED_OBJS)
nvList = u_mvl_get_nvl (MMSOP_READ, &read_info->va_spec.vl_name,
net_info);
#else /* default */
nvList = mvl_vmd_find_nvl (&mvl_vmd, &read_info->va_spec.vl_name, indCtrl->event->net_info);
#endif /* default */
if (!nvList)
{
MVL_LOG_NERR0 ("Read NVL : NamedVariableList not found");
return (MVL_ERR_NVL_NOT_FOUND);
}
rdCtrl->nvList = nvList;
/* Found the named variable list, create the response */
num_var = nvList->num_of_entries;
rdCtrl->vaCtrlTbl = (MVLAS_RD_VA_CTRL *) M_CALLOC (MSMEM_GEN, num_var,
sizeof(MVLAS_RD_VA_CTRL));
vaCtrl = rdCtrl->vaCtrlTbl;
rdCtrl->numVar = num_var;
for (i = 0; i < num_var; ++i, ++vaCtrl)
{
/* These are done by the 'chk_calloc' call */
/* vaCtrl->va = NULL; */
/* vaCtrl->alt_access_pres = NULL; */
vaCtrl->va = nvList->entries[i];
memcpy (&vaCtrl->va_scope, &nvList->va_scope[i], sizeof(MVL_SCOPE));
vaCtrl->acc_rslt_tag = ACC_RSLT_SUCCESS;
vaCtrl->va->usr_ind_ctrl = indCtrl->usr_ind_ctrl; /* save optional user pointer in va*/
}
return (SD_SUCCESS);
}
/************************************************************************/
/************************************************************************/
/* mvlas_read_resp */
/************************************************************************/
ST_RET mvlas_read_resp (MVL_IND_PEND *indCtrl)
{
MVLAS_READ_CTRL *rdCtrl;
MVL_COMM_EVENT *event;
MVL_NET_INFO *net_info;
READ_RESP_INFO *resp_info;
ST_UCHAR *asn1_buf;
ST_RET rc;
READ_REQ_INFO *req_info = (READ_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
event = indCtrl->event;
net_info = indCtrl->event->net_info;
rdCtrl = &indCtrl->u.rd;
asn1_buf = (ST_UCHAR *) M_MALLOC (MSMEM_ASN1_DATA_ENC, mvl_cfg_info->max_msg_size);
rc = prep_read_resp (net_info, rdCtrl, req_info, &resp_info, asn1_buf, mvl_cfg_info->max_msg_size);
if (rc == SD_SUCCESS)
{
/* Build the read response */
rc = mpl_read_resp (event->u.mms.dec_rslt.id, resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, resp_info);
/* The process functions allocate the response buffer */
M_FREE (MSMEM_ENC_OS_INFO, resp_info);
}
#if defined(USE_MANUFACTURED_OBJS)
if (rdCtrl->nvList) /* For NVL, this was allocated by prep_nvl_... */
u_mvl_free_nvl (MMSOP_READ, rdCtrl->nvList, event->net_info);
#endif
if (u_mvl_rd_resp_sent)
(*u_mvl_rd_resp_sent) (indCtrl);
M_FREE (MSMEM_ASN1_DATA_ENC, asn1_buf);
M_FREE (MSMEM_GEN, rdCtrl->vaCtrlTbl);
/* NOTE: This funct frees indCtrl. DO NOT use after this. */
/* NOTE: if rc != SD_SUCCESS, this funct sends error resp. */
_mvl_send_resp_i (indCtrl, rc);
return (SD_SUCCESS);
}
/************************************************************************/
/* prep_read_resp */
/************************************************************************/
static ST_RET prep_read_resp (MVL_NET_INFO *net_info, MVLAS_READ_CTRL *rdCtrl,
READ_REQ_INFO *req_info,
READ_RESP_INFO **resp_info_out,
ST_UCHAR *asn1_buf, ST_INT asn1_buf_size)
{
MVLAS_RD_VA_CTRL *vaCtrl;
MVL_VAR_ASSOC *va;
READ_RESP_INFO *resp_info;
ACCESS_RESULT *ar_ptr;
ST_UCHAR *asn1_start;
ST_INT asn1_len;
ST_INT asn1_buf_left;
ST_INT num_var;
ST_INT i;
num_var = rdCtrl->numVar;
/* Allocate READ_RESP_INFO struct plus space for variableAccessSpec */
/* (only used if spec_in_result=TRUE) and accessResults. */
resp_info =
(READ_RESP_INFO *) M_CALLOC (MSMEM_ENC_OS_INFO, 1, sizeof (READ_RESP_INFO) +
(num_var * sizeof (VARIABLE_LIST)) + /* for variableAccessSpec*/
(num_var * sizeof (ACCESS_RESULT)));
*resp_info_out = resp_info;
if (req_info->spec_in_result)
{ /* Send variableAccessSpec in response */
resp_info->va_spec_pres = SD_TRUE;
resp_info->va_spec.var_acc_tag = req_info->va_spec.var_acc_tag;
if (resp_info->va_spec.var_acc_tag == VAR_ACC_VARLIST)
{ /* list of variables */
/* Copy variableAccessSpec (array of VARIABLE_LIST) from req to resp.*/
resp_info->va_spec.num_of_variables = num_var;
memcpy ((resp_info + 1), (req_info + 1), num_var * sizeof (VARIABLE_LIST));
}
else
{ /* variable list name : copy name from req to resp. */
memcpy (&resp_info->va_spec.vl_name, &req_info->va_spec.vl_name, sizeof (OBJECT_NAME));
}
}
else
{ /* Do NOT send variableAccessSpec in response. */
resp_info->va_spec_pres = SD_FALSE;
}
resp_info->num_of_acc_result = num_var;
/* Calculate pointer to start of accessResults (after variableAccessSpec)*/
resp_info->acc_rslt_list = (ACCESS_RESULT *)
((((VARIABLE_LIST *)(resp_info+1)) + num_var));
ar_ptr = resp_info->acc_rslt_list;
asn1_start = asn1_buf;
asn1_buf_left = asn1_buf_size;
vaCtrl = rdCtrl->vaCtrlTbl;
for (i = 0; i < num_var; ++i, ++ar_ptr, ++vaCtrl)
{
va = vaCtrl->va;
if (va == NULL)
{
ar_ptr->acc_rslt_tag = ACC_RSLT_FAILURE;
ar_ptr->failure = ARE_OBJ_NONEXISTENT;
}
else
{
/* Copy values from vaCtrl, but may change due to other errors. */
ar_ptr->acc_rslt_tag = vaCtrl->acc_rslt_tag;
ar_ptr->failure = vaCtrl->failure;
if (ar_ptr->acc_rslt_tag == ACC_RSLT_SUCCESS)
{ /* may still fail other checks */
/* Sanity check, because foundry can generate configured variables w/o */
/* the data pointer initialized. */
if (va->data == NULL)
{ /* Error. Override values set before */
MVL_LOG_NERR1 ("Read Indication : va '%s' data is NULL", va->name);
ar_ptr->acc_rslt_tag = ACC_RSLT_FAILURE;
ar_ptr->failure = ARE_OBJ_INVALIDATED;
}
else if (mvl_get_va_asn1_data (net_info,
va, vaCtrl->alt_access_pres, &vaCtrl->alt_acc,
asn1_start, asn1_buf_left, &asn1_len) != SD_SUCCESS)
{ /* Error. Override values set before */
ar_ptr->acc_rslt_tag = ACC_RSLT_FAILURE;
ar_ptr->failure = ARE_OBJ_ACC_UNSUPPORTED;
}
else
{ /* this is the only path to success */
ar_ptr->va_data.len = asn1_len;
ar_ptr->va_data.data = asn1_start;
asn1_buf_left -= asn1_len; /* adjust buffer control variables */
asn1_start += asn1_len;
}
}
}
/* IMPORTANT: Use ar_ptr->acc_rslt_tag here (not vaCtrl->acc_rslt_tag).*/
if (ar_ptr->acc_rslt_tag == ACC_RSLT_SUCCESS)
++mvl_mms_statistics.serverVarRdOk;
else
++mvl_mms_statistics.serverVarRdErr;
/* The user needs to free a manufactured NVL and the associated VA's */
/* in the 'u_mvl_free_va_fun'; here just free manufactured variables */
/* associated with a list of variables. */
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
if (rdCtrl->var_acc_tag == VAR_ACC_VARLIST)
{
if (va && va->va_to_free != NULL)
u_mvl_free_va (MMSOP_READ, va, net_info);
}
#endif /* defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS) */
#if defined(MVL_AA_SUPP)
if (vaCtrl->alt_access_pres) /* if we calloc'd this AA, free it */
M_FREE (MSMEM_GEN, vaCtrl->alt_acc.aa);
#endif
} /* end loop */
return (SD_SUCCESS);
}

67
mmslib/mvlu/s_status.c Normal file
View File

@@ -0,0 +1,67 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_status.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 04/09/07 MDE 11 Enhanced filtered logging */
/* 03/11/04 GLB 10 Remove "thisFileName" */
/* 09/21/01 JRB 09 Alloc global bufs only once at startup. */
/* 01/21/00 MDE 08 Now use MEM_SMEM for dynamic memory */
/* 09/13/99 MDE 07 Added SD_CONST modifiers */
/* 04/01/99 MDE 06 Changes to decode buffer allocation scheme */
/* 11/16/98 MDE 05 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 04 Minor lint cleanup */
/* 06/15/98 MDE 03 Changes to allow compile under C++ */
/* 05/14/98 JRB 02 Use MVL_IND_PEND. Add mplas resp function. */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvmd.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/************************************************************************/
/* _mvl_process_status_ind */
/* A "status" indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_status_ind (MVL_IND_PEND *indCtrl)
{
indCtrl->u.status.req_info =
(STATUS_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
u_mvl_status_ind (indCtrl);
}
/************************************************************************/
/* mplas_status_resp */
/************************************************************************/
ST_VOID mplas_status_resp (MVL_IND_PEND *indCtrl)
{
ST_RET rc;
/* Build an status response */
rc = mpl_status_resp (indCtrl->event->u.mms.dec_rslt.id,
indCtrl->u.status.resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, indCtrl->u.status.resp_info);
_mvl_send_resp_i (indCtrl, rc);
}

438
mmslib/mvlu/s_write.c Normal file
View File

@@ -0,0 +1,438 @@
/************************************************************************/
/* SISCO SOFTWARE MODULE HEADER *****************************************/
/************************************************************************/
/* (c) Copyright Systems Integration Specialists Company, Inc., */
/* 1994 - 1996, All Rights Reserved */
/* */
/* MODULE NAME : s_write.c */
/* PRODUCT(S) : MMSEASE-LITE */
/* */
/* MODULE DESCRIPTION : */
/* */
/* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : */
/* NONE */
/* */
/* MODIFICATION LOG : */
/* Date Who Rev Comments */
/* -------- --- ------ ------------------------------------------- */
/* 02/02/09 JRB 32 Chk va_to_free before ...free_va. */
/* 01/23/09 MDE 31 Use 0x%X for hex values in log msgs. */
/* 01/13/09 MDE 30 Free VA (and temp type) in case of errors */
/* 05/01/08 JRB 29 Chk ms_asn1_to_local return & set */
/* WRITE_RESULT "failure" appropriately. */
/* 04/09/07 MDE 28 Enhanced filtered logging */
/* 10/30/06 JRB 27 Use new mvl_vmd_* object handling functions. */
/* Add args on call to _mvl_objname_to_va. */
/* Elim use of global "_mvl_curr_net_info". */
/* Elim use of global "_mvl_curr_usr_ind_ctrl". */
/* 08/09/06 JRB 26 ALWAYS set resp_tag & failure in wr_rslt */
/* same as in vaCtrl. In put_asn1_data, set */
/* vaCtrl->failure to appropriate value. */
/* 01/30/06 GLB 25 Integrated porting changes for VMS */
/* 05/16/05 JRB 24 Send appropriate failure codes in write resp.*/
/* Move statistics code so it is always executed*/
/* 03/13/03 JRB 23 Use mvl_type_ctrl_find. */
/* 07/24/02 JRB 22 Use mvl_send_resp_i like ALL responses. */
/* 07/09/02 MDE 21 Add maxpend_ind support */
/* 09/21/01 JRB 20 Alloc global bufs only once at startup. */
/* 05/25/01 MDE 19 Moved where the old data is saved */
/* 03/30/01 MDE 18 Changed MSMEM_ENC_INFO to MSMEM_ENC_OS_INFO */
/* 10/25/00 JRB 17 Del u_mvl funct ptrs. Call functs directly. */
/* Control with #ifdefs. */
/* 10/06/00 MDE 16 Now restore old data for write failure */
/* 05/15/00 MDE 15 Added MMS statistics */
/* 01/21/00 MDE 14 Now use MEM_SMEM for dynamic memory */
/* 11/22/99 JRB 13 mvlas_write_resp: del indCtrl from link list */
/* 09/13/99 MDE 12 Added SD_CONST modifiers */
/* 04/07/99 MDE 11 Logging improvements */
/* 12/11/98 MDE 10 Removed scope references from VA */
/* 12/08/98 MDE 09 Fixed write handling for alternate access */
/* 11/16/98 MDE 08 Renamed internal functions (prefix '_') */
/* 09/21/98 MDE 07 Minor lint cleanup */
/* 06/15/98 MDE 06 Changes to allow compile under C++ */
/* 05/15/98 JRB 05 Chg mvl_process.. arg to (MVL_IND_PEND *). */
/* 05/15/98 JRB 04 Call u_mvl_write_ind direct (no funct ptr). */
/* 02/20/98 MDE 03 Fixed usrVa set problem */
/* 02/10/98 MDE 02 Removed NEST_RT_TYPES, always support AA, */
/* added 'u_mvl_wr_ind_start' and */
/* 'u_mvl_wr_resp_sent', other */
/* 09/10/97 MDE 01 MMS-LITE V4.0 Release */
/************************************************************************/
#include "glbtypes.h"
#include "sysincs.h"
#include "mmsdefs.h"
#include "mms_pvar.h"
#include "mms_vvar.h"
#include "mvl_defs.h"
#include "mvl_log.h"
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
/************************************************************************/
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
#endif
/************************************************************************/
ST_RET (*u_mvl_wr_ind_start) (MVL_IND_PEND *indCtrl);
ST_VOID (*u_mvl_wr_resp_sent) (MVL_IND_PEND *indCtrl);
/************************************************************************/
/* Internal functions */
static ST_VOID put_asn1_data (MVL_IND_PEND *indCtrl, VARIABLE_LIST *vl,
ST_UCHAR *asn1_buffer, ST_INT asn1_len,
MVLAS_WR_VA_CTRL *vaCtrl);
/************************************************************************/
/************************************************************************/
/* _mvl_process_write_ind */
/* A write indication has been received, process it and respond */
/************************************************************************/
ST_VOID _mvl_process_write_ind (MVL_IND_PEND *indCtrl)
{
MVLAS_WRITE_CTRL *wrCtrl;
MVLAS_WR_VA_CTRL *vaCtrl;
WRITE_REQ_INFO *write_info;
ST_INT num_var;
VARIABLE_LIST *vl_ptr;
VAR_ACC_DATA *va_ptr;
ST_INT i;
ST_RET rc;
write_info = (WRITE_REQ_INFO *) indCtrl->event->u.mms.dec_rslt.data_ptr;
num_var = write_info->va_spec.num_of_variables;
/* verify that this is a list of variables */
if (write_info->va_spec.var_acc_tag != VAR_ACC_VARLIST)
{
_mplas_err_resp (indCtrl,7,2); /* access, non-existent */
return;
}
if (u_mvl_wr_ind_start)
{
/* This might set optional user pointer "indCtrl->usr_ind_ctrl". */
rc = (*u_mvl_wr_ind_start) (indCtrl);
if (rc != SD_SUCCESS)
{
_mplas_err_resp (indCtrl,7,2); /* access, non-existent */
return;
}
}
wrCtrl = &indCtrl->u.wr;
wrCtrl->vaCtrlTbl = (MVLAS_WR_VA_CTRL *) M_CALLOC (MSMEM_GEN, num_var,
sizeof(MVLAS_WR_VA_CTRL));
vaCtrl = wrCtrl->vaCtrlTbl;
wrCtrl->numVar = num_var;
/* Looks OK, prepare to process each variable in the list */
vl_ptr = (VARIABLE_LIST *) (write_info+1);
va_ptr = write_info->va_data;
for (i = 0; i < num_var; ++i, ++vl_ptr, ++va_ptr, ++vaCtrl)
put_asn1_data (indCtrl, vl_ptr, va_ptr->data, va_ptr->len, vaCtrl);
u_mvl_write_ind (indCtrl);
}
/************************************************************************/
/* mvlas_write_resp */
/************************************************************************/
ST_VOID mvlas_write_resp (MVL_IND_PEND *indCtrl)
{
MVLAS_WRITE_CTRL *wrCtrl;
MVLAS_WR_VA_CTRL *vaCtrl;
MVL_COMM_EVENT *event;
MVL_NET_INFO *net_info;
ST_RET rc;
ST_CHAR *resp_buf;
ST_INT num_var;
ST_INT va_data_size;
WRITE_RESP_INFO *resp_info;
WRITE_RESULT *wr_rslt;
ST_INT i;
MVL_TYPE_CTRL *type_ctrl;
net_info = indCtrl->event->net_info;
event = indCtrl->event;
wrCtrl = &indCtrl->u.wr;
vaCtrl = wrCtrl->vaCtrlTbl;
num_var = wrCtrl->numVar;
resp_buf = (ST_CHAR *) M_CALLOC (MSMEM_ENC_OS_INFO, 1, sizeof(WRITE_RESP_INFO) +
(num_var * sizeof (WRITE_RESULT)));
/* Create a write response info struct */
resp_info = (WRITE_RESP_INFO *) resp_buf;
resp_info->num_of_result = num_var;
wr_rslt = (WRITE_RESULT *) (resp_info +1);
for (i = 0; i < num_var; ++i, ++wr_rslt, ++vaCtrl)
{
wr_rslt->resp_tag = vaCtrl->resp_tag;
wr_rslt->failure = vaCtrl->failure;
if (vaCtrl->va != NULL)
{
if (wr_rslt->resp_tag == WR_RSLT_FAILURE)
{ /* On a failure, restore the previous data */
type_ctrl = mvl_type_ctrl_find (vaCtrl->va->type_id);
va_data_size = type_ctrl->data_size;
memcpy (vaCtrl->va->data, vaCtrl->oldData, va_data_size);
}
M_FREE (MSMEM_GEN, vaCtrl->oldData);
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
if (vaCtrl->va->va_to_free != NULL)
u_mvl_free_va (MMSOP_WRITE, vaCtrl->va, event->net_info);
#endif /* defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS) */
}
if (wr_rslt->resp_tag == WR_RSLT_SUCCESS)
++mvl_mms_statistics.serverVarWrOk;
else
++mvl_mms_statistics.serverVarWrErr;
} /* end loop */
/* Build a write response */
rc = mpl_write_resp (event->u.mms.dec_rslt.id, resp_info);
if (rc == SD_SUCCESS)
mpl_resp_log (indCtrl, resp_info);
if (u_mvl_wr_resp_sent)
(*u_mvl_wr_resp_sent) (indCtrl);
M_FREE (MSMEM_ENC_OS_INFO, resp_buf);
M_FREE (MSMEM_GEN, wrCtrl->vaCtrlTbl);
/* NOTE: This funct frees indCtrl. DO NOT use after this. */
/* NOTE: if rc != SD_SUCCESS, this funct sends error resp. */
_mvl_send_resp_i (indCtrl, rc);
}
/************************************************************************/
/* put_asn1_data */
/* This function is to provide ASN.1 encoded data, given the variable */
/* list element. */
/************************************************************************/
static ST_VOID put_asn1_data (MVL_IND_PEND *indCtrl, VARIABLE_LIST *vl,
ST_UCHAR *asn1_buffer, ST_INT asn1_len,
MVLAS_WR_VA_CTRL *vaCtrl)
{
MVL_VAR_ASSOC *va;
RUNTIME_TYPE *rt;
ST_INT num_rt;
ST_RET rc;
ST_CHAR *temp_data_buf;
ST_CHAR *va_data;
ST_INT va_data_size;
ST_INT aa_mode;
ALT_ACCESS alt_acc; /* Alternate Access specification */
ST_BOOLEAN alt_access_pres;
ST_BOOLEAN alt_access_done;
MVL_TYPE_CTRL *type_ctrl;
/* There are more ways to fail than to succeed! */
/* Assume failure=ARE_TYPE_INCONSISTENT, but may be changed in some cases.*/
vaCtrl->resp_tag = WR_RSLT_FAILURE;
vaCtrl->failure = ARE_TYPE_INCONSISTENT;
alt_access_pres = vl->alt_access_pres;
if (alt_access_pres) /* no alternate access support now */
{
#if !defined(MVL_AA_SUPP)
MVL_LOG_NERR0 ("Put ASN1 Data : Alternate Access not supported");
return;
#else
/* now create the AA, given the ASN.1 spec */
if (ms_asn1_to_aa (vl->alt_access.data, vl->alt_access.len,
&alt_acc))
{
MVL_LOG_NERR0 ("Write Indication : ASN.1 -> AA failure");
return;
}
#endif
}
switch (vl->var_spec.var_spec_tag)
{
case VA_SPEC_NAMED :
va = _mvl_objname_to_va (&mvl_vmd, indCtrl->event->net_info, MMSOP_WRITE, &vl->var_spec.vs.name,
&vaCtrl->va_scope,
alt_access_pres,
&alt_acc,
&alt_access_done);
if (alt_access_pres && alt_access_done)
{
M_FREE (MSMEM_GEN, alt_acc.aa);
alt_access_pres = SD_FALSE;
}
if (!va) /* could not find variable association */
{
MVL_LOG_NERR1 ("Write ind : Variable Association '%s' not found",
vl->var_spec.vs.name.obj_name.vmd_spec);
vaCtrl->failure = ARE_OBJ_NONEXISTENT;
return;
}
vaCtrl->va = va;
va->usr_ind_ctrl = indCtrl->usr_ind_ctrl; /* save optional user pointer in va*/
/* Save the current data in case the user rejects the write */
type_ctrl = mvl_type_ctrl_find (va->type_id); /* find type */
va_data_size = type_ctrl->data_size;
vaCtrl->oldData = (ST_UCHAR *) M_MALLOC (MSMEM_GEN, va_data_size);
memcpy (vaCtrl->oldData, va->data, va_data_size);
/* We have obtained a variable association */
/* Now do the alternate access preprocess function if appropriate */
#if defined(MVL_AA_SUPP)
aa_mode = MVL_USE_UNPACKED_AA;
if (alt_access_pres && va->proc && va->proc->proc_write_aa)
{
rc = (*va->proc->proc_write_aa)(&va, &alt_acc,
indCtrl->event->net_info, &aa_mode);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Write : proc_write_aa returned %d", rc);
return;
}
}
#endif
/* Now take care of the data conversion (asn1 to local) */
rc = mvl_get_runtime (va->type_id, &rt, &num_rt);
if (rc != SD_SUCCESS)
{
M_FREE (MSMEM_GEN, vaCtrl->oldData);
MVL_LOG_NERR1 ("Could not get type_id %d", va->type_id);
vaCtrl->va = NULL;
return;
}
/* Sanity check, because foundry can generate configured vars w/o */
/* the data pointer initialized. */
if (va->data == NULL)
{
M_FREE (MSMEM_GEN, vaCtrl->oldData);
MVL_LOG_NERR1 ("Write Indication : va '%s' data is NULL", va->name);
vaCtrl->va = NULL;
return;
}
va_data = (ST_CHAR *) va->data;
/* "va_data_size" already set above */
break;
case VA_SPEC_DESCRIBED :
default :
MVL_LOG_NERR0 ("Put ASN1 Data : Invalid Variable Specification Tag");
vaCtrl->failure = ARE_OBJ_ACC_UNSUPPORTED;
return;
break;
}
/* If we got here, we have a valid runtime and have resolved local */
/* data pointer and size. Go ahead and convert the ASN.1 data element to*/
/* local data format */
temp_data_buf = (ST_CHAR *) M_MALLOC (MSMEM_WR_DATA_DEC_BUF, va_data_size);
#if defined(MVL_AA_SUPP)
if (alt_access_pres == SD_FALSE || aa_mode == MVL_USE_NO_AA)
rc = ms_asn1_to_local (rt, num_rt, asn1_buffer, asn1_len, temp_data_buf);
else
{
/* This is an alternate access write, we must first copy the data */
/* contents to to the temp buffer, then only the selected elements */
/* will be written by the data conversion. */
memcpy (temp_data_buf, va_data, va_data_size);
if (aa_mode == MVL_USE_PACKED_AA)
m_alt_acc_packed = SD_TRUE;
else
m_alt_acc_packed = SD_FALSE;
rc = ms_asn1_to_local_aa (rt, num_rt, &alt_acc,
asn1_buffer, asn1_len, temp_data_buf);
}
#else
rc = ms_asn1_to_local (rt, num_rt, asn1_buffer, asn1_len, temp_data_buf);
#endif
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Put ASN1 Data : ms_asn1_to_local failed, rc = 0x%X", rc);
M_FREE (MSMEM_GEN, vaCtrl->oldData);
M_FREE (MSMEM_WR_DATA_DEC_BUF, temp_data_buf);
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
/* Need to free VA (caller will not if vaCtrl->va == NULL) */
if (vaCtrl->va->va_to_free != NULL)
u_mvl_free_va (MMSOP_WRITE, vaCtrl->va, NULL);
#endif
vaCtrl->va = NULL;
if (rc == ASN1E_UNEXPECTED_TAG)
/* Tag mismatch in this context indicates MMS type mismatch. */
vaCtrl->failure = ARE_TYPE_INCONSISTENT;
else
vaCtrl->failure = ARE_OBJ_VALUE_INVALID;
return;
}
/* Call the preprocessing function for this variable, if it exists */
if (va->proc && va->proc->pre_write_aa)
{
rc = (*va->proc->pre_write_aa)(va, alt_access_pres, &alt_acc,
indCtrl->event->net_info,
temp_data_buf, va_data_size);
if (rc != SD_SUCCESS)
{
MVL_LOG_NERR1 ("Put ASN1 Data : call to Write pre-processor failed, rc = 0x%X", rc);
M_FREE (MSMEM_GEN, vaCtrl->oldData);
#if defined(MVL_UCA) || defined(USE_MANUFACTURED_OBJS)
/* Need to free VA (caller will not if vaCtrl->va == NULL) */
if (vaCtrl->va->va_to_free != NULL)
u_mvl_free_va (MMSOP_WRITE, vaCtrl->va, NULL);
#endif
vaCtrl->va = NULL;
}
}
/* OK, almost done. The data has been converted OK and the user has had */
/* a chance to look at it. If rc == SD_SUCCESS, we are OK. */
if (rc == SD_SUCCESS)
{
vaCtrl->resp_tag = WR_RSLT_SUCCESS;
memcpy (va_data, temp_data_buf, va_data_size);
/* Call the postprocessing function for this variable, if it exists */
if (va->proc && va->proc->post_write_aa)
(*va->proc->post_write_aa)(va, alt_access_pres, &alt_acc, indCtrl->event->net_info);
}
#if defined(MVL_AA_SUPP)
if (alt_access_pres) /* if we calloc'd this AA, free it */
M_FREE (MSMEM_GEN, alt_acc.aa);
#endif
M_FREE (MSMEM_WR_DATA_DEC_BUF, temp_data_buf);
}

3286
mmslib/mvlu/sclproc.c Normal file

File diff suppressed because it is too large Load Diff