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

📄 vsutillib.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* vsUtilLib.c - Entity MIB utility Library *//* *  Copyright 2002-2005 Wind River Systems, Inc. *  All rights reserved.  Provided under license only. *  Distribution or other use of this software is only *  permitted pursuant to the terms of a license agreement *  from Wind River Systems (and is otherwise prohibited). *  Refer to that license agreement for terms of use. */#include "copyright_wrs.h"/*modification history-------------------01g,19apr05,job  update copyright notices01f,01dec03,job  update copyright information01e,26aug03,job  patch to previous fix01d,22aug03,job  remove dependencies on SNMPv301c,15aug03,job  virtual stack further modifications01b,26mar03,ant  changes after code review, changed component name, buffer 		 overflow checking, OIDs definitions used, new functions		 vsContextNameRegister() and vsContextNameRegister()01a,17dec02,ant  written*//*  * This library provides facilities for SNMP Agent that is supposed to * retrieve MIB information from various VS instances. SNMP Agent * receives all SNMP requests by the Management stack. These requests * contain information (community string, resp. context name) that * indicates what VS instance they are intended for. This library  * (together with namingScopes.c) supplies SNMP Agent with the * facilities to proccess such SNMP requests.  *//* includes */#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/entlogic.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/vxcmpnts.h>#include <wrn/wm/common/dyncfg.h>/* The whole file is intended to be included only when * SNMP_VXWORKS_VIRTUAL_STACK functionality is required. */#if INSTALL_SNMP_VXWORKS_VIRTUAL_STACK#include <netinet/in.h>#include <netinet/vsLib.h>#include <sockLib.h>#include <inetLib.h>#include <wrn/wm/snmp/engine/wkobj.h>/* print out debuging messages if defined to 1 */#ifndef SNMP_VS_UTIL_DEBUG#define SNMP_VS_UTIL_DEBUG 0#endif#include <wrn/wm/snmp/vxagent/namingScopes.h>#if (INSTALL_ENVOY_SNMP_VERSION_3) #include <wrn/wm/snmp/engine/v3_eng.h>#endif /* #if (INSTALL_ENVOY_SNMP_VERSION_3) */#include <wrn/wm/snmp/vxagent/vxprotos.h>#include <wrn/wm/common/glue.h>#include <wrn/wm/common/dyncfg.h>DYNCFG_VBL_DECLARE_EXTERN(snmpv3_component)/* globals */char 	 	vsNamingScopePrefix [MAXSIZE_entLogicalCommunity];/* imports */extern SEM_ID snmpdConfigMutex;extern unsigned int snmpdInstalledComponentsValue;IMPORT int     snmpSocket;    /* socket descriptor for snmp */#if INSTALL_ENVOY_SNMP_VERSION_3DYNCFG_FUNCPTR1 (_nvhard_vs_add, int, int)DYNCFG_FUNCPTR1 (_nvhard_vs_remove, int, int)DYNCFG_FUNCPTR1 (_vs_v3engine_set, void, ENT_LOGICAL_T *)#endif#if INSTALL_SNMP_VXWORKS_VS_ENTITY/* statics */LOCAL unsigned int * vsToEntLogical = NULL;LOCAL struct sockaddr_in  snmp_srvr;/****************************************************************************** * * vsSnmpUtilEntLogicalInit - Initialise Logical Entity MIB utility  * * This function initialises Logical Entity MIB utility. It allocates memory for * the table which maps vsNum to entLogicalIndex. * * RETURNS: OK or ERROR * */static STATUS vsSnmpUtilEntLogicalInit ()    {    int size = VSID_MAX;        if ((vsToEntLogical = (unsigned int *)         SNMP_memory_alloc (size * sizeof (int))) == 0)        {        return (ERROR);        }    MEMSET (vsToEntLogical, 0, size * sizeof (int));          return (OK);    }/****************************************************************************** * * vsSnmpUtilEntLogicalAdd - Add a mapping between vsNum and entLogicalIndex * * This function sets the mapping between vsNum and entLogicalIndex. * * RETURNS: OK or ERROR * */static STATUS vsSnmpUtilEntLogicalAdd    (    unsigned int vsNum,    unsigned int entLogicalIndex    )    {    if (vsToEntLogical[vsNum] != 0)        {        return (ERROR);        }    vsToEntLogical[vsNum] = entLogicalIndex;    #if SNMP_VS_UTIL_DEBUG    printf ("vsSnmpUtilEntLogicalAdd: entLogicalIndex %d mapped to vsNum %d\n",    		entLogicalIndex, vsNum);#endif /* SNMP_VS_UTIL_DEBUG */    return (OK);    }/****************************************************************************** * * vsSnmpUtilEntLogicalRemove - remove a mapping between vsNum and entLogicalIndex * *  This function removes the mapping between vsNum and entLogicalIndex. *  * RETURNS: N/A * */static void vsSnmpUtilEntLogicalRemove    (    unsigned int vsNum    )    {    vsToEntLogical[vsNum] = 0;    #if SNMP_VS_UTIL_DEBUG    printf ("vsSnmpUtilEntLogicalRemove: removed mapping for vsNum %d\n", vsNum);#endif /* SNMP_VS_UTIL_DEBUG */    }/****************************************************************************** * * vsSnmpUtilEntLogicalGet - get a mapping between vsNum and entLogicalIndex * * This function retrieves entLogicalIndex that's mapped to vsNum. * * RETURNS: entLogicalIndex or ERROR * */static unsigned int vsSnmpUtilEntLogicalGet    (    unsigned int vsNum    )    {    return (vsToEntLogical[vsNum]);    }#if SNMP_VS_UTIL_DEBUG/****************************************************************************** * * vsSnmpUtilEntLogicalShow - Show a mapping between vsNum and entLogicalIndex * * This function prints out the mapping table vsToEntLogical. * * RETURNS: N/A * */static void vsSUELShow (void)    {    int size = VSID_MAX;    int i;        for (i = 0; i < size; i++)        if (vsToEntLogical[i] != 0)            printf ("vsnum = %d - entLogicalIndex %d\n", i, vsToEntLogical[i]);    }#endif /* SNMP_VS_UTIL_DEBUG */#endif 	/* INSTALL_SNMP_VXWORKS_VS_ENTITY *//****************************************************************************** * * vsSnmpUtilInit - VS Snmp Util Library initialization * * This function must be called before any of vsSnmpUtilVSAdd or  * vsSnmpUtilVSRemove are called.  * * RETURNS: OK or ERROR * */   static STATUS vsSnmpUtilInit     (    char * namingScopePrefix    )     {    char buf[MAXSIZE_entLogicalCommunity];        /* There is going to be added VS number to the Prefix. */         sprintf (buf, "%d", VSID_MAX);      if ((strlen (namingScopePrefix) + strlen (buf) + 1) >     					MAXSIZE_entLogicalCommunity)        return (ERROR);	    strcpy(vsNamingScopePrefix, namingScopePrefix);    /* Initialise Logical Entity MIB utility  */#if INSTALL_SNMP_VXWORKS_VS_ENTITY    if (vsSnmpUtilEntLogicalInit () != OK)       return (ERROR);#endif 	/* INSTALL_SNMP_VXWORKS_VS_ENTITY */    /* Initialisation function for community string functions, v1 and v2 */    communityStringInit (VS_MGMT_STACK);        /* Initialisation function for context name functions, v3 */    #if INSTALL_ENVOY_SNMP_VERSION_3    if (snmpdInstalledComponentsValue & SNMPD_VERSION_3_COMPONENT)        contextNameInit (VS_MGMT_STACK);#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */        return (OK);        }/****************************************************************************** * * vsCommunityStringsRegister - register new community string * * This function is an example of the function that can be called to register * new community string for a VS instance when the instance is created. * In envoy.h there is a #define for VS_COMMUNITY_REGISTER that, by default * gets defined to this function. If the user needs to register the community * string with different parameters then VS_COMMUNITY_REGISTER must be defined * to a user function. * * Parameters: * * <vsnum> - the vsnum of VS instance that is being created * * RETURNS: N/A * */void vsCommunityStringsRegister    (    int vsnum    )    {    char buf[MAXSIZE_entLogicalCommunity];    int buf_len;        sprintf (buf, "%s%d", vsNamingScopePrefix, vsnum);    buf_len = strlen (buf);     communityStringRegister ((bits8_t *) buf, buf_len, VIEW_TYPE_GET,                             (bits8_t *) "two", 3, vsnum);    }#if INSTALL_ENVOY_SNMP_VERSION_3 /****************************************************************************** * * vsContextNameRegister - register new context name * * This function is an example of the function that can be called to register * new context name for a VS instance when the instance is created. * In envoy.h there is a #define for VS_CONTEXT_REGISTER that, by default * gets defined to this function. If the user needs to register the context * name with different parameters then VS_CONTEXT_REGISTER must be defined * to a user function. * * Parameters: * * <vsnum> - the vsnum of VS instance that is being created * * RETURNS: N/A * */void vsContextNameRegister    (

⌨️ 快捷键说明

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