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

📄 v3mt_nfy.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *  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 1999 Integrated Systems, Inc. *  All rights reserved. *//* * $Log: v3mt_nfy.c,v $ * Revision 1.2  2001/11/06 21:20:33  josh * revised new path hacking * * Revision 1.1.1.1  2001/11/05 17:47:40  tneale * Tornado shuffle * * Revision 9.8.4.1  2001/09/28 20:49:06  josh * method routines will now allow rows to be created as permanent or * read-only rows.  It will also prevent the deletion of such rows. * * Revision 9.8  2001/04/17 19:12:19  josh * make sure method routines return proper error codes and fully * check format of set tags * * Revision 9.7  2001/01/19 22:22:00  paul * Update copyright. * * Revision 9.6  2000/03/17 00:17:49  meister * Update copyright message * * Revision 9.5  2000/03/10 15:02:39  josh * fixes to the setproc/cleanup/undoprocs regarding row creation, * so we can back out gracefully but still not shoot ourselves in * foot while doing regular cleanups. * * Revision 9.4  2000/02/16 19:59:29  josh * more WRONG_LENGTH/WRONG_VALUE changes * * Revision 9.3  2000/02/16 18:45:52  josh * returning WRONG_LENGTH instead of WRONG_VALUE, where appropriate * * Revision 9.2  2000/02/04 21:56:12  josh * functions which are clearly static have been declared as such. * this makes the vxWorks compiler happy. * * Revision 9.1  2000/01/02 22:55:54  josh * patching up a memory leak here, a broken compare there...per * sar's comments * * Revision 9.0  1999/10/21 20:44:42  josh * updating version stamps * * Revision 1.3  1999/10/21 19:07:20  josh * fixing method routine bugs discovered in testing * * Revision 1.2  1999/10/18 22:49:46  josh * patches to method routines and related code * * Revision 1.1  1999/10/15 13:04:48  josh * method routines for Notify MIB from RFC 2573 * *//* [clearcase]modification history-------------------01b,18apr05,job  update copyright notices01a,24nov03,job  update copyright information*/#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/mib.h>#include <wrn/wm/snmp/engine/localio.h>#include <wrn/wm/snmp/engine/snmpdefs.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include <wrn/wm/snmp/engine/v3_trgt.h>#include <wrn/wm/snmp/engine/v3_ntfy.h>#include <wrn/wm/snmp/engine/ntfy_chk.h>/* default values for the macros to map the method routines   to the notifys non volatile storage */#if !defined(SNMP_V3_NOTIFY_DESTROY_BACKOUT)#define SNMP_V3_NOTIFY_DESTROY_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NOTIFY_CREATE_BACKOUT)#define SNMP_V3_NOTIFY_CREATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NOTIFY_UPDATE_BACKOUT)#define SNMP_V3_NOTIFY_UPDATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NOTIFY_FINISHED)#define SNMP_V3_NOTIFY_FINISHED()#endif#if !defined(SNMP_V3_NOTIFY_DESTROY_TEST)#define SNMP_V3_NOTIFY_DESTROY_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NOTIFY_CREATE_TEST)#define SNMP_V3_NOTIFY_CREATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NOTIFY_UPDATE_TEST)#define SNMP_V3_NOTIFY_UPDATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NOTIFY_DESTROY_SET)#define SNMP_V3_NOTIFY_DESTROY_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NOTIFY_CREATE_SET)#define SNMP_V3_NOTIFY_CREATE_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NOTIFY_UPDATE_SET)#define SNMP_V3_NOTIFY_UPDATE_SET(PKT, VBP, CUR, NEW)#endif/* these aren't defined by default *//*#define SNMP_V3_NOTIFY_DESTROY_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NOTIFY_CREATE_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NOTIFY_UPDATE_UNDO(PKT, VBP, CUR, SAV)*//* default values for the macros to map the method routines   to the notify_filter_profiles non volatile storage */#if !defined(SNMP_V3_NPROF_DESTROY_BACKOUT)#define SNMP_V3_NPROF_DESTROY_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NPROF_CREATE_BACKOUT)#define SNMP_V3_NPROF_CREATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NPROF_UPDATE_BACKOUT)#define SNMP_V3_NPROF_UPDATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NPROF_FINISHED)#define SNMP_V3_NPROF_FINISHED()#endif#if !defined(SNMP_V3_NPROF_DESTROY_TEST)#define SNMP_V3_NPROF_DESTROY_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NPROF_CREATE_TEST)#define SNMP_V3_NPROF_CREATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NPROF_UPDATE_TEST)#define SNMP_V3_NPROF_UPDATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NPROF_DESTROY_SET)#define SNMP_V3_NPROF_DESTROY_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NPROF_CREATE_SET)#define SNMP_V3_NPROF_CREATE_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NPROF_UPDATE_SET)#define SNMP_V3_NPROF_UPDATE_SET(PKT, VBP, CUR, NEW)#endif/* these aren't defined by default *//*#define SNMP_V3_NPROF_DESTROY_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NPROF_CREATE_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NPROF_UPDATE_UNDO(PKT, VBP, CUR, SAV)*//* default values for the macros to map the method routines   to the notify_filters non volatile storage */#if !defined(SNMP_V3_NFILT_DESTROY_BACKOUT)#define SNMP_V3_NFILT_DESTROY_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NFILT_CREATE_BACKOUT)#define SNMP_V3_NFILT_CREATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NFILT_UPDATE_BACKOUT)#define SNMP_V3_NFILT_UPDATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_NFILT_FINISHED)#define SNMP_V3_NFILT_FINISHED()#endif#if !defined(SNMP_V3_NFILT_DESTROY_TEST)#define SNMP_V3_NFILT_DESTROY_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NFILT_CREATE_TEST)#define SNMP_V3_NFILT_CREATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NFILT_UPDATE_TEST)#define SNMP_V3_NFILT_UPDATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_NFILT_DESTROY_SET)#define SNMP_V3_NFILT_DESTROY_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NFILT_CREATE_SET)#define SNMP_V3_NFILT_CREATE_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_NFILT_UPDATE_SET)#define SNMP_V3_NFILT_UPDATE_SET(PKT, VBP, CUR, NEW)#endif/* these aren't defined by default *//*#define SNMP_V3_NFILT_DESTROY_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NFILT_CREATE_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_NFILT_UPDATE_UNDO(PKT, VBP, CUR, SAV)*//* * Method routines for the snmpNotifyTable: * *   snmpNotifyName -- not-accessible * The locally arbitrary, but unique identifier associated * with this snmpNotifyEntry. * *   snmpNotifyTag -- read-create * This object contains a single tag value which is used * to select entries in the snmpTargetAddrTable.  Any entry * in the snmpTargetAddrTable which contains a tag value * which is equal to the value of an instance of this * object is selected.  If this object contains a value * of zero length, no entries are selected. * *   snmpNotifyType -- read-create * This object determines the type of notification to * be generated for entries in the snmpTargetAddrTable * selected by the corresponding instance of * snmpNotifyTag.  This value is only used when * generating notifications, and is ignored when * using the snmpTargetAddrTable for other purposes. *  * If the value of this object is trap(1), then any * messages generated for selected rows will contain * Unconfirmed-Class PDUs. *  * If the value of this object is inform(2), then any * messages generated for selected rows will contain * Confirmed-Class PDUs. *  * Note that if an SNMP entity only supports * generation of Unconfirmed-Class PDUs (and not * Confirmed-Class PDUs), then this object may be * read-only. * *   snmpNotifyStorageType -- read-create * The storage type for this conceptual row. * *   snmpNotifyRowStatus -- read-create * The status of this conceptual row. *  * To create a row in this table, a manager must * set this object to either createAndGo(4) or * createAndWait(5). *//* An internal routine to retrieve the values of the variables, used * by the method routines snmpNotifyEntry_get and snmpNotifyEntry_next. */static int  snmpNotifyEntry_get_value(OIDC_T         lastmatch,                            SNMP_PKT_T    *pktp,                            VB_T          *vbp,                            SNMP_NOTIFY_T *notify){switch(lastmatch) {    case LEAF_snmpNotifyTag:        getproc_got_string(pktp, vbp, SNMP_Notify_Get_Tag_Len(notify),			   SNMP_Notify_Get_Tag(notify), 0, VT_STRING);	break;    case LEAF_snmpNotifyType:        /* Values:	 *  trap(1)   = VAL_snmpNotifyType_trap	 *  inform(2) = VAL_snmpNotifyType_inform	 */        getproc_got_int32(pktp, vbp, SNMP_Notify_Get_Type(notify));	break;    case LEAF_snmpNotifyStorageType:        /* Values:	 *  other(1)       = VAL_snmpNotifyStorageType_other	 *  volatile(2)    = VAL_snmpNotifyStorageType_volatile	 *  nonVolatile(3) = VAL_snmpNotifyStorageType_nonVolatile	 *  permanent(4)   = VAL_snmpNotifyStorageType_permanent	 *  readOnly(5)    = VAL_snmpNotifyStorageType_readOnly	 */        getproc_got_int32(pktp, vbp, SNMP_Notify_Get_Storage(notify)); 	break;    case LEAF_snmpNotifyRowStatus:        /* Values:	 *  active(1)        = VAL_snmpNotifyRowStatus_active	 *  notInService(2)  = VAL_snmpNotifyRowStatus_notInService	 *  notReady(3)      = VAL_snmpNotifyRowStatus_notReady	 *  createAndGo(4)   = VAL_snmpNotifyRowStatus_createAndGo	 *  createAndWait(5) = VAL_snmpNotifyRowStatus_createAndWait	 *  destroy(6)       = VAL_snmpNotifyRowStatus_destroy	 */        getproc_got_int32(pktp, vbp, SNMP_Notify_Get_Status(notify));	break;    default:        return GEN_ERR;    }return NO_ERROR;}void  snmpNotifyEntry_get(OIDC_T      lastmatch,                      int         tcount,                      OIDC_T     *tlist,                      SNMP_PKT_T *pktp,                      VB_T       *vbp){SNMP_NOTIFY_T *notify = 0;bits8_t name[ETC_NOTIFY_MAX];ALENGTH_T name_len = ETC_NOTIFY_MAX;int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* use the instance (tcount and tlist) to look up the entry in the * table.  */if ((oid_to_string(tcount, tlist, &name_len, name, 1) == 0) &&    (name_len != 0))    notify = SNMP_Notify_Lookup(name, name_len);if (notify == 0) {    for ( ; vbp ; vbp = vbp->vb_link)        getproc_nosuchins(pktp, vbp);    }else {    /* retrieve all the values from the same data structure */    for ( ; vbp ; vbp = vbp->vb_link ) {        if ((error = snmpNotifyEntry_get_value(vbp->vb_ml.ml_last_match,					       pktp, vbp, notify)) != NO_ERROR)            getproc_error(pktp, vbp, error);        }    }}void  snmpNotifyEntry_next(OIDC_T      lastmatch,                       int         tcount,                       OIDC_T     *tlist,                       SNMP_PKT_T *pktp,                       VB_T       *vbp){SNMP_NOTIFY_T *notify;OIDC_T best_inst[ETC_NOTIFY_MAX];int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);notify = SNMP_Notify_Next(tcount, tlist);if ((notify) && (error = string_to_oid(SNMP_Notify_Get_Name_Len(notify),				       SNMP_Notify_Get_Name(notify),				       ETC_NOTIFY_MAX,				       best_inst, 1) == 0)) {    for ( ; vbp ; vbp = vbp->vb_link ) {        if ((error = snmpNotifyEntry_get_value(vbp->vb_ml.ml_last_match,					       pktp, vbp, notify)) == NO_ERROR)	    nextproc_next_instance(pktp, vbp, 				   SNMP_Notify_Get_Name_Len(notify),				   best_inst);	else	    nextproc_error(pktp, vbp, error);        }    }else /* there's no more in this table */    for ( ; vbp ; vbp = vbp->vb_link )        nextproc_no_next(pktp, vbp);}/****************************************************************************NAME: notifytable_destroy_cleanupPURPOSE: Cleanup after a notify test (delete) succeeded but some         other test failed.  We merely call the DESTROY_BACKOUT macro         to allow the customer to restore any changed state.  Expects         the pointer to point to a VB_TPARAMETERS: 	ptr_t   A pointer to the vb that points to the notify		that we were going to delete, cast as a ptr_tRETURNS: Nothing****************************************************************************/static void   notifytable_destroy_cleanup(ptr_t notifyptr){SNMP_V3_NOTIFY_DESTROY_BACKOUT(((VB_T *)notifyptr)->vb_priv, 0);}/****************************************************************************

⌨️ 快捷键说明

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