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

📄 snmpdlib.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* snmpdLib.c  - entry points to the SNMP v1/v2c agent *//* *  Copyright 1984-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 -------------------------01x,19apr05,job  update copyright notices01w,07sep04,job  fix shutdown bugs01v,04may04,job  add a lookup table to pull in needed symbols01u,02dec03,msa  Fix SPR90953, CentiSecs rollover.01t,01dec03,job  update copyright information01s,13aug03,job  a new round of virtual stack modification01r,18jul03,job  virtual stack fixes01q,02may03,job  shutdown code01p,28apr03,job  fix init order issue01o,14mar03,job  fix a few shutdown memory leaks01n,07mar03,job  fix centiseconds counter wrapping01m,05dec00,ten  added initialization code for TAE01l,14mar99,jdi  doc: removed refs to config.h and/or configAll.h (SPR 25663).01k,09feb99,wsl  Added comments to document ERRNO codes01j,19apr98,ann Removed creation of SNMP_CoarseLock and added a call to                envoy_init() which initializes SNMP_CoarseLock.                Added call to clean up master-agent resources.01j,06oct98,jmp  moved doc to snmpdLibDoc.c.01i,12sep96,rjc  Added warning messages in snmpMibsInit () SPR 7193;01h,09sep96,rjc  changed param comment in snmpdTrapSend ()(for ppDestAddrTbl01g,12aug96,rjc  memory allocation funcs moved to snmpIoLib.c01f,19jun96,rjc  Fix for SPR 6708 (coding conventions)                 Modified snmpdLog to prepend "tSnmpd" before mesgs.01e,14jun96,jmo  4th update man pages01d,12jun96,jmo  3rd update man pages (whew!)01c,11jun96,jmo  2nd update man pages01b,23may96,jmo  doc changes01a,10mar96,rjc  written*//* * $Log: snmpdlib.c,v $ * Revision 1.20  2003/01/15 14:05:12  josh * directory structure shifting * * Revision 1.19  2002/08/26 20:31:07  josh * modifications to the code to eliminate warnings from Diab compiler * * Revision 1.18  2002/07/09 19:14:27  josh * remove a namespace collision by renaming SNMP_community_lookup() * to SNMP_community_coexistence_lookup() * * Revision 1.17  2002/05/01 19:09:17  josh * adding a new call snmpdShutdown() * * Revision 1.16  2002/03/26 16:58:45  tneale * Fixed typo * * Revision 1.15  2002/03/20 16:36:58  tneale * Make task options a variable * * Revision 1.14  2002/03/19 19:34:07  josh * add dynamic call to ax_add_ax_mibs() for AgentX MIB * fix snmpTraceInput() so it doesn't use a fixed buffer anymore * (safer for long community strings) * * Revision 1.13  2002/01/08 18:25:02  tneale * Return type of snmpdTaskDelete bow depends on Tornado version, to satisfy taskDeleteHookAdd * * Revision 1.12  2002/01/07 21:02:09  tneale * Changed snmpdTaskDelete to return int, as required for taskDeleteHookAdd() * * Revision 1.11  2001/12/17 22:18:52  josh * don't call the mib2 init routines directly -- they may not be necessary * * Revision 1.10  2001/12/04 22:56:41  meister * turn off snmpd tracing * * Revision 1.9  2001/11/30 23:13:38  meister * fix typo: CYNAMIC -> DYNAMIC * * Revision 1.8  2001/11/28 22:20:28  meister * initStartSnmpd() should only be compiled if COMMON_DYNAMIC_COMP_CONFIG * is installed * * Revision 1.7  2001/11/12 22:53:18  meister * Changed some DYNCFG_EXTERN_FUNCPTRS's to DYNCFG_FUNCPTR's * * Revision 1.6  2001/11/09 17:30:24  tneale * Another adjustment for generated header files * * Revision 1.5  2001/11/09 14:54:07  tneale * Fixed paths for generated files mibhand.h and mibleaf.h * * Revision 1.4  2001/11/08 22:18:34  meister * rework pathnames * * Revision 1.3  2001/11/06 21:50:53  josh * second (and hopefully final) pass of new path hacking * * Revision 1.2  2001/11/06 21:20:40  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:49  tneale * Tornado shuffle * * Revision 1.8.4.4  2001/11/02 17:18:23  meister * split out user ans core dynamic config * * Revision 1.8.4.3  2001/10/29 18:36:17  josh * support for the multi-instance TCP/IP stack via the new option * ENVOY_VXWORKS_MULTI_INSTANCE * * Revision 1.8.4.2  2001/10/19 21:13:00  meister * usrSnmpInit should be compiled n if we are on T2 and using dynamic * component configuration * * Revision 1.8.4.1  2001/10/16 18:30:08  meister * component file shuffling, use snmpdLog instead of raw printfs * * Revision 1.8  2001/04/24 17:44:10  josh * updating vxWorks agent with modifications carried over * from Windnet/SNMP agent * * Revision 1.7  2001/04/16 19:38:43  josh * merging the kingfisher branch onto the trunk * * Revision 1.6.2.5  2001/03/12 22:11:33  tneale * Updated copyright * * Revision 1.6.2.4  2000/12/05 22:05:34  tneale * Cleaned up the TAE support code * * Revision 1.6.2.3  2000/10/18 20:05:42  josh * added a definition for ENVOY_SNMP_FREE_LOCK_TAG() and removed * responsibility for cleaning continue lock from * snmpHookPrivRelease() * * Revision 1.6.2.2  2000/10/17 21:26:57  josh * added new option: ENVOY_VXWORKS_TAE will prevent code specific to * T:AE from being built in T2 * * Revision 1.6.2.1  2000/10/06 22:34:31  tneale * Modified to make an agent that starts at boot, without being integrated * with the Tornado IDE. * * Revision 1.6  2000/03/13 17:17:02  josh * cleanup to remove some warnings * * Revision 1.5  2000/03/09 13:53:52  josh * patch the timer task so it reads messages into a clean buffer * * Revision 1.4  2000/03/08 20:09:17  josh * Adding V3 support to vxWorks port * * Revision 1.3  2000/03/07 21:17:26  josh * fixing log comments * * Revision 1.2  2000/03/07 20:58:35  josh * putting CVS headers and logs into files that were lacking * *//*DESCRIPTIONThis module implements the WindNet SNMPv1/v2c agent for VxWorks. Thisagent provides for the management of objects defined by the MIB-IIstandard.  The agent management information base can be extended toinclude additional user-defined MIBs.  The agent also provides supportfor asynchronous method routines and dynamic loading of MIBs.INCLUDE FILES: snmpdLib.hSEE ALSO:The SNMP version 1 framework is defined by the following Request ForComments (RFCs): 1155, 1157, 1212. MIB-II is defined by RFC 1213.For more information about SNMP, refer to these documents.For more information about the VxWorks SNMP agent, see the.I "WindNet SNMP VxWorks Component Release Supplement."*//* includes */#include <wrn/wm/snmp/engine/auxfuncs.h>#include <wrn/wm/snmp/vxagent/snmpdInit.h>#include <wrn/wm/snmp/vxagent/snmpdLib.h>#include <taskLib.h>#include <taskHookLib.h>#include <sysLib.h>#include <m2Lib.h>#include <wdLib.h>#include <msgQLib.h>#include <wrn/wm/snmp/engine/etimer.h>#include <wrn/wm/snmp/engine/vxcmpnts.h>#include <wrn/wm/snmp/vxagent/snmpIoLib.h>#include <wrn/wm/snmp/engine/snmpstat.h>#include <tickLib.h>#include <wrn/wm/snmp/vxagent/mibleaf.h>#include <wrn/wm/snmp/engine/view.h>#include <stdlib.h>#include <ctype.h>#include <stdio.h>#include <semLib.h>#include <wrn/wm/snmp/engine/buildpkt.h>#include <wrn/wm/snmp/engine/objectid.h>#if INSTALL_SNMP_VXWORKS_VIRTUAL_STACK#include <netinet/vsLib.h>#endif /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK */#if INSTALL_COMMON_DYNAMIC_COMP_CONFIG#include <wrn/wm/common/dyncfg.h>SEM_ID snmpdInitFinishedSem;BOOL snmpInitDone = 0;           /* has init completed? */extern SEM_ID snmpdConfigMutex;extern unsigned int snmpdInstalledComponentsValue;DYNCFG_VBL_DECLARE_EXTERN(envoy_snmp_coexistence)DYNCFG_VBL_DECLARE_EXTERN(envoy_snmp_proxy)DYNCFG_VBL_DECLARE_EXTERN(envoy_snmp_target)DYNCFG_VBL_DECLARE_EXTERN(envoy_snmp_notify)DYNCFG_VBL_DECLARE_EXTERN(snmpv3_component)DYNCFG_VBL_DECLARE_EXTERN(agentx_master_component)DYNCFG_VBL_DECLARE_EXTERN(agentx_subagent_component)DYNCFG_FUNCPTR3(SNMP_community_coexistence_lookup,int,SNMP_PKT_T *,                SNMPADDR_T *, SNMPADDR_T *)DYNCFG_FUNCPTR3(lookup_SNMP_community,int,SNMP_PKT_T *,SNMPADDR_T *,                SNMPADDR_T *)DYNCFG_FUNCPTR0(v3_add_v3_mibs,void)DYNCFG_FUNCPTR0(ax_add_ax_mibs,void)DYNCFG_FUNCPTR0(snmpCleanUserTable,void)DYNCFG_FUNCPTR0(snmpCleanSecurityToGroupTable,void)DYNCFG_FUNCPTR0(snmpCleanAccessTable,void)DYNCFG_FUNCPTR0(snmpCleanContextTable,void)DYNCFG_FUNCPTR0(snmpCleanV3Tree,void)DYNCFG_FUNCPTR0(snmpCleanTargetTables,void)DYNCFG_FUNCPTR0(snmpCleanNotifyTables,void)DYNCFG_FUNCPTR0(snmpCleanCommunityTable,void)DYNCFG_FUNCPTR0(snmpCleanProxyTable,void)DYNCFG_FUNCPTR0(snmpCleanAgentXMaster,void)    DYNCFG_FUNCPTR0(snmpCleanAgentXSubagent,void)        #endif/* Add a lookup table so that SNMP_Create_Internal_Request() will always * be in the image */void * snmpSymbolLookupTable[] = { (void *) SNMP_Create_Internal_Request };#if INSTALL_SNMP_VXWORKS_VIRTUAL_STACKint snmpdStackNum;#endif /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK *//* defines */#define SNMPD_PRIO_DEFAULT      150#define SNMPD_STACK_DEFAULT     0x7000#define SNMPD_OPT_DEFAULT       0/* locals  */LOCAL MIB_MODULE *       pSnmpModules;               /* Mibs for this agent */LOCAL int                snmpdTaskId;                /* snmp agent task id */LOCAL int                snmpdTmrTaskId;             /* snmp timer task id */LOCAL STATUS             mibsInitialized = FALSE;    /* mibs initalized flag   */LOCAL ulong_t            snmpStartCentiSecs;         /*  start time */LOCAL VOIDFUNCPTR   snmpHkPrivRlseRtn;     /* user hook private release rtn */LOCAL FUNCPTR       snmpHkSetPduVldtRtn;   /* user hook set pdu validate rtn */LOCAL FUNCPTR       snmpHkPreSetRtn;       /* user hook pre set rtn */LOCAL FUNCPTR       snmpHkPostSetRtn;      /* user hook post set rtn */LOCAL FUNCPTR       snmpHkSetFailedRtn;    /* user hook set failed rtn */LOCAL void     snmpReady (int);#if (INSTALL_ENVOY_VXWORKS_TAE || INSTALL_COMMON_DYNAMIC_COMP_CONFIG)/**************************************************************************** Locals associated with initialization.  These may move once * do some further integration with the Tornado IDE.  ** In T2 the functions usrMib2Init and usrMib2CleanUp and their* prototypes are in target/config/comps/net/usrSnmpCfg.c.  The MIB2 * definitions are in target/config/comps/src/configAll.h.  The function* usrSnmpInit is new to T3; it is the initialization function named in * the component project's component definition file.*/#define MIB2_SYS_DESCR		"VxWorks SNMPv1/v2c Agent"#define MIB2_SYS_CONTACT	"Wind River Systems"#define MIB2_SYS_LOCATION	"Planet Earth"#define MIB2_SYS_OBJID_LEN	2#define MIB2_SYS_OBJID		{ 0, 0 }STATUS usrMib2Init (void);STATUS usrMib2CleanUp (void);LOCAL MIB_MODULE snmpMibModules [] ={    { NULL, NULL },};#if INSTALL_COMMON_DYNAMIC_COMP_CONFIG/* Forward declaration of initialization routine */STATUS usrSnmpInit (void);void initStartSnmpd (void){    int task_mode;#if INSTALL_ENVOY_VXWORKS_TAE    task_mode = VX_USER_MODE;#else    task_mode = 0x0000;#endif         snmpdInitFinishedSem = semBCreate(SEM_Q_PRIORITY, SEM_FULL);     snmpInitDone = 0;     semTake (snmpdConfigMutex,WAIT_FOREVER);     snmpdLog (SNMP_INFO, " initialize AgentX listener\n");     taskSpawn ("tStartSnmpd", ENVOY_VXWORKS_SNMPD_PRIORITY, task_mode,                 8182, (FUNCPTR) usrSnmpInit,                0,0,0,0,0,0,0,0,0,0);     semGive (snmpdConfigMutex);     snmpReady (WAIT_FOREVER);}#endif /* #if INSTALL_COMMON_DYNAMIC_COMP_CONFIG */#endif /* #if (INSTALL_ENVOY_VXWORKS_TAE) */struct Timer_Block timerBlock;MSG_Q_ID           tmrQID;WDOG_ID            tmrWDID;#define TIMER_PRI 200#define TIMER_STK 4096/* globals */int                    snmpTraceLevel;         /* Trace level for agent logs *//* Functions to link in. Just need to refer to these funcs somewhere. * Should be local but that causes compiler to crib unused variable.  */FUNCPTR            snmpFuncsToLink [] =      {    SNMP_Bind_Null,    (FUNCPTR) SNMP_Bind_64_Unsigned_Integer,    (FUNCPTR) SNMP_Bind_String,    SNMP_Bind_Object_ID,    SNMP_Bind_IP_Address,    SNMP_Bind_Integer,    (FUNCPTR) SNMP_Bind_Unsigned_Integer    };/* forward declarations */LOCAL void     snmpAgentOutputRtn (SNMPADDR_T  *, SNMPADDR_T *, PTR_T,                                    ALENGTH_T, PTR_T);LOCAL void     snmpAgentErrorRtn (SNMPADDR_T *, SNMPADDR_T *, int, PTR_T);#if INSTALL_SNMP_VXWORKS_VIRTUAL_STACKLOCAL int      snmpdMain (int, int);#else /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK */LOCAL int      snmpdMain (int);#endif /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK */LOCAL STATUS   snmpGlobalsInit (void);LOCAL void     snmpdCleanup (void);LOCAL ulong_t  snmpCentiSecsGet (void);LOCAL void     snmpdViewTblRemove (void);#if INSTALL_ENVOY_VXWORKS_TAE    LOCAL void     snmpdTaskDelete (WIND_TCB *);#else    LOCAL int      snmpdTaskDelete (WIND_TCB *);#endif/************************************************************************  * snmpReady: Called to ensure that SNMP has completed executing.       * *            Blocks until SNMP enters main IO loop.                    * * RETURNS: nothing                                                     *  ************************************************************************/LOCAL void snmpReady (int timeout)    {    if (snmpInitDone != 0)        return;    semTake (snmpdInitFinishedSem, timeout);    /*     * As soon as we take it, we release it to let everyone else through.     */    semGive (snmpdInitFinishedSem);    }/************************************************************************  * snmpTimer: function called by a watchdog timer.  All it can safely   * *            do is send a message to a preestablished message queue.   * * RETURNS: nothing                                                     *  ************************************************************************/static void snmpTimer(void){bits8_t end_timeout[] = "4";msgQSend(tmrQID, (char *) end_timeout, 1, NO_WAIT, MSG_PRI_NORMAL);}/************************************************************************  * timerTask:   a looping task that handles timer issues in a non-ISR   *  *              context.                                                *  * RETURNS: nothing                                                     *  ************************************************************************/#if INSTALL_SNMP_VXWORKS_VIRTUAL_STACKstatic void timerTask(int vsNum)#else /* INSTALL_SNMP_VXWORKS_VIRTUAL_STACK */

⌨️ 快捷键说明

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