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

📄 nvhard.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* *  Copyright 2000-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. *//* *  Copyright 1995-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: nvhard.c,v $ * Revision 1.8  2003/01/15 14:05:12  josh * directory structure shifting * * Revision 1.7  2002/08/26 20:31:07  josh * modifications to the code to eliminate warnings from Diab compiler * * Revision 1.6  2001/11/15 21:53:49  josh * populate the proxy table a little * * Revision 1.5  2001/11/12 22:53:17  meister * Changed some DYNCFG_EXTERN_FUNCPTRS's to DYNCFG_FUNCPTR's * * Revision 1.4  2001/11/07 22:15:54  meister * rework pathnames again * * 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:39  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:49  tneale * Tornado shuffle * * Revision 1.1.8.5  2001/09/27 13:08:27  meister * dynamic configuration rototill * * Revision 1.1.8.4  2001/09/25 17:11:07  josh * general cleanup and improvement of some default behavior * * Revision 1.1.8.3  2001/09/24 16:44:10  josh * update hardcoded entries in the community table * * Revision 1.1.8.2  2001/09/18 19:43:05  josh * patch base-level support to something workable * * Revision 1.1.8.1  2001/09/18 19:07:56  josh * base-level support for proxy and coexistence nvram routines * * Revision 1.1  2000/03/08 20:09:51  josh * fake nonvolatile memory access for 2275 Views and SNMPv3 * * Revision 1.5  2000/02/15 21:47:22  josh * API changes to various Install() calls * * Revision 1.4  1999/11/24 19:52:42  josh * adding keys for a second engine id -- makes sending informs * work (for that id, anyway...) * * Revision 1.3  1999/11/10 20:05:17  josh * updating code to work with SNMPv3 Notifies * * Revision 1.2  1999/11/01 19:44:19  josh * adding basic support for the Notify code * * Revision 1.1  1999/09/24 19:08:14  sar * Create a file similiar to nvutils.c but for use on demos that don't * include a disk (or other nv storage).  So we just hardwire the values * and don't try to save anything to nv. * *//* [clearcase]modification history-------------------01c,19apr05,job  update copyright notices01b,13apr05,AJS  Diffie-Hellman work01a,24nov03,job  update copyright information*//* This is a hardwired version of nvutils.c.  It is supplied for demo and * test purposes as well as providing the stubs required for the snmpv3 * nv macros. */#include <wrn/wm/common/install.h>#include <wrn/wm/common/config.h>#include <snmptalk.h>#include <stdio.h>#include <ctype.h>#include <wrn/wm/snmp/engine/asn1conf.h>#include <wrn/wm/snmp/engine/asn1.h>#include <wrn/wm/snmp/engine/buffer.h>#include <wrn/wm/snmp/engine/objectid.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/view.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include <wrn/wm/snmp/engine/smi.h>#include <wrn/wm/demo/nvutils.h>#if (INSTALL_ENVOY_SNMP_VERSION_3) #include <wrn/wm/snmp/engine/v3_eng.h>#include <wrn/wm/snmp/engine/v3_user.h>#include <wrn/wm/snmp/engine/v3_auth.h>#include <wrn/wm/snmp/engine/v3_priv.h>#include <wrn/wm/snmp/engine/v3_acc.h>#include <wrn/wm/snmp/engine/v3_con.h>#if (INSTALL_ENVOY_SNMP_V3_TARGET)#include <wrn/wm/snmp/engine/v3_trgt.h>#if (INSTALL_ENVOY_SNMP_V3_NOTIFY)#include <wrn/wm/snmp/engine/v3_ntfy.h>#endif /* #if (INSTALL_ENVOY_SNMP_V3_NOTIFY) */#if (INSTALL_ENVOY_SNMP_V3_PROXY)#include <wrn/wm/snmp/engine/v3_proxy.h>#endif /* #if (INSTALL_ENVOY_SNMP_V3_PROXY) */#if (INSTALL_ENVOY_SNMP_COEXISTENCE)#include <wrn/wm/snmp/engine/v3_comm.h>#endif /* #if (INSTALL_ENVOY_SNMP_COEXISTENCE */#endif /* #if (INSTALL_ENVOY_SNMP_V3_TARGET */#endif /* #if (INSTALL_ENVOY_SNMP_VERSION_3) */#include <wrn/wm/common/glue.h>#include <wrn/wm/common/dyncfg.h>DYNCFG_VBL_DECLARE_EXTERN(envoy_use_v2_types)DYNCFG_VBL_DECLARE_EXTERN(envoy_use_v2_protos)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_FUNCPTR1(_nvhard_read_v3myid,int,char *)DYNCFG_FUNCPTR0(_nvhard_read_v3users,int)DYNCFG_FUNCPTR0(_nvhard_read_usmDHparams,int)DYNCFG_FUNCPTR0(_nvhard_read_v3groups,int)DYNCFG_FUNCPTR0(_nvhard_read_v3access,int)DYNCFG_FUNCPTR0(_nvhard_read_v3contexts,int)DYNCFG_FUNCPTR0(_nvhard_read_v3taddr,int)DYNCFG_FUNCPTR0(_nvhard_read_v3tparam,int)DYNCFG_FUNCPTR0(_nvhard_read_v3notify,int)DYNCFG_FUNCPTR0(_nvhard_read_v3nprof,int)DYNCFG_FUNCPTR0(_nvhard_read_v3nfilt,int)DYNCFG_FUNCPTR0(_nvhard_read_v3proxy,int)DYNCFG_FUNCPTR0(_nvhard_read_community,int)/****************************************************************************Space for the non-volatile configuration file names****************************************************************************/char  NV_Config_Static[MAX_NVF]      = "snmp_nv.txt";char *NV_Config_File                 = NV_Config_Static;char  NV_Old_Config_Static[MAX_NVF]  = "snmp_nv.old";char *NV_Old_Config_File             = NV_Old_Config_Static;char  NV_Temp_Config_Static[MAX_NVF] = "snmp_nv.tmp";char *NV_Temp_Config_File            = NV_Temp_Config_Static;#if INSTALL_ENVOY_SNMP_V3_NOTIFYSNMPV3_TRAP_T *trap_root = 0;#endif/* Flags to tell us what to do.   Read only: only read the file (1), the default is writeable (0)   Get views: from config file (1) or the precompiled versin (0) */int NV_Read_Only         = 0;int NV_Views_From_Config = 1;static intread_views(){VIEWLEAF_T *view;OIDC_T onea_obj[]  = {1, 3, 6, 1, 6, 3};OIDC_T oneb_obj[]  = {1, 3, 6, 1, 2, 1, 1};OIDC_T two_obj[]   = {1, 3};OIDC_T three_obj[] = {1, 3, 6, 1, 2, 1, 5};view = SNMP_View_Create(onea_obj, 6);if (view == 0)    return(1);SNMP_View_Set_Status(view, 1);SNMP_View_Set_Type(view, 1);if (SNMP_View_2275_Install(view, (bits8_t *) "one", 3))    return(1);view = SNMP_View_Create(oneb_obj, 7);if (view == 0)    return(1);SNMP_View_Set_Status(view, 1);SNMP_View_Set_Type(view, 1);if (SNMP_View_2275_Install(view, (bits8_t *) "one", 3))    return(1);view = SNMP_View_Create(two_obj, 2);if (view == 0)    return(1);SNMP_View_Set_Status(view, 1);SNMP_View_Set_Type(view, 1);if (SNMP_View_2275_Install(view, (bits8_t *) "two", 3))    return(1);view = SNMP_View_Create(three_obj, 7);if (view == 0)    return(1);SNMP_View_Set_Status(view, 1);SNMP_View_Set_Type(view, 1);if (SNMP_View_2275_Install(view, (bits8_t *) "three", 5))    return(1);return(0);}/****************************************************************************NAME: SNMP_NV_ConfigPURPOSE: Populate the databasePARAMETERS:        RETURNS: int    0 = success                other = failure, any comments have already been printed****************************************************************************/int  SNMP_NV_Config(char *eng_id){/* The view section */if (read_views() != 0) {    return(1);    }#if (INSTALL_ENVOY_SNMP_VERSION_3)DYNCFG_IFCFGVBL_BEGIN(snmpv3_component)/* the information about the local engine */if (DYNCFG_FUNCALL(_nvhard_read_v3myid)(eng_id) != 0) {    return(1);    }/* the users known */if (DYNCFG_FUNCALL(_nvhard_read_v3users)() != 0) {    return(1);    }#if INSTALL_SNMP_V3_DIFFIE_HELLMAN/* the Diffie-Hellman parameters*/if (DYNCFG_FUNCALL(_nvhard_read_usmDHparams)() != 0) {    return(1);    }#endif /* INSTALL_SNMP_V3_DIFFIE_HELLMAN */    /* the user to group table */if (DYNCFG_FUNCALL(_nvhard_read_v3groups)() != 0) {    return(1);    }/* the access table, (group to view) */if (DYNCFG_FUNCALL(_nvhard_read_v3access)() != 0) {    return(1);    }/* the context table, (list of contexts) */if (DYNCFG_FUNCALL(_nvhard_read_v3contexts)() != 0) {    return(1);    }#if INSTALL_ENVOY_SNMP_V3_TARGETDYNCFG_IFCFGVBL_BEGIN(envoy_snmp_target)/* the target addr table, (list of targets) */if (DYNCFG_FUNCALL(_nvhard_read_v3taddr)() != 0) {    return(1);    }/* the target params table, (list of params for targets) */if (DYNCFG_FUNCALL(_nvhard_read_v3tparam)() != 0) {    return(1);    }#if INSTALL_ENVOY_SNMP_V3_NOTIFYDYNCFG_IFCFGVBL_BEGIN(envoy_snmp_notify)/* the notify table */if (DYNCFG_FUNCALL(_nvhard_read_v3notify)() != 0) {    return(1);    }/* the notify filter profile table */if (DYNCFG_FUNCALL(_nvhard_read_v3nprof)() != 0) {    return(1);    }/* the notify filter table */if (DYNCFG_FUNCALL(_nvhard_read_v3nfilt)() != 0) {    return(1);    }DYNCFG_IFCFGVBL_END(envoy_snmp_notify)#endif /* INSTALL_ENVOY_SNMP_V3_NOTIFY */#if INSTALL_ENVOY_SNMP_COEXISTENCEDYNCFG_IFCFGVBL_BEGIN(envoy_snmp_coexistence)/* the community table */if (DYNCFG_FUNCALL(_nvhard_read_community)() != 0) {    return(1);    }DYNCFG_IFCFGVBL_END(envoy_snmp_coexistence)#endif /* INSTALL_ENVOY_SNMP_COEXISTENCE */#if INSTALL_ENVOY_SNMP_V3_PROXYDYNCFG_IFCFGVBL_BEGIN(envoy_snmp_proxy)/* the proxy table */if (DYNCFG_FUNCALL(_nvhard_read_v3proxy)() != 0) {    return(1);    }DYNCFG_IFCFGVBL_END(envoy_snmp_proxy)#endif /* INSTALL_ENVOY_SNMP_V3_PROXY */    DYNCFG_IFCFGVBL_END(envoy_snmp_target)#endif /* INSTALL_ENVOY_SNMP_V3_TARGET */DYNCFG_IFCFGVBL_END(snmpv3_component)#endif /* INSTALL_ENVOY_SNMP_VERSION_3 */return(0);}/**********************************************************************The following user-exits are used to connect various method routineswith any non-volatile storage that may be required, and any policydecisions.  This particular set of routines connects up to therfc 2275 view table and the access, group and user tables from SNMPv3.Each table has a set of 5 routines that follows the same organization.The *_test routines will be called while the tesproc method routine isbeing processed.  It should determine that the requested change isallowed and reserve any resources that may be required.  A returnof NO_ERROR indicates that the set is acceptable and processingshould continue.  Any other return is a failure and is used asthe error argument to testproc_error().If the set fails after a *_test routine has been called, butbefore the corresponding *_set routine is called, then one ofthe *_backout routines will be called to allow you to releaseany reserved resources.  The *_set routines will be called from the setproc method routines.When it is called the corresponding *_test routine will have beencalled and should have reserved any resources and the rest of theset request will have been validated.  These routines may be thoughtof as "pushing the button" to commit the set.If the set fails after a *_set routine has been called the thecorresponding *_undo routine will be called to allow you toudno any actions you have taken.  A return of 0 indicates success,-1 indicates failure.Finally if the set completes successfully, the corresponding*_finsihed routines are called when the packet is being releasedallowing you to release any saved resources.Parameters:	pkt - the packet that is requesting the set operation	vbp - the var bind that caused the method routine to run	current - is the information that is currently installed		  in the table.  In the *_test, *_backout and *_set		  routines this is the information before the set request.		  In the *_undo routines it is the information after		  the set request.	new     - is the what the set is requesting be installed in the table	save    - is what was in the table before the set requestIf current isn't 0 it includes the indexing information for the entryotherwise the entry can be found in the new or save entry.  For the test, backout and set routines the following table showswhich entries will be in use.		destroy		create		updatecurrent 	in use		0		in usenew		0		in use		in useFor the  undo routines the following table showswhich entries will be in use.		destroy		create		updatecurrent 	0		in use		in usesave		in use		0		in use**********************************************************************//* * Note well: These are stub routines that don't actually do anything * they should be replaced with routines that either connect to non-volatile * storage or disallow changes that should be but won't be saved across * reboots */sbits32_t  snmp_view_2275_test(SNMP_PKT_T *pkt,		      VB_T       *vbp,		      VIEWLEAF_T *current,		      VIEWLEAF_T *new ){return(NO_ERROR);}void  snmp_view_2275_set(SNMP_PKT_T *pkt,		     VB_T       *vbp,		     VIEWLEAF_T *current,		     VIEWLEAF_T *new ){}void  snmp_view_2275_backout(VIEWLEAF_T *current,			 VIEWLEAF_T *new ){}int  snmp_view_2275_undo(SNMP_PKT_T *pkt,		      VB_T       *vbp,		      VIEWLEAF_T *current,		      VIEWLEAF_T *save ){return(0);}void  snmp_view_2275_finished(void){}

⌨️ 快捷键说明

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