📄 v3mt_pxy.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. *//* v3mt_pxy.c - method routines for the snmpProxyTable *//*modification history--------------------01b,18apr05,job update copyright notices01a,24nov03,job update copyright information$Log: v3mt_pxy.c,v $Revision 1.4 2002/05/22 18:21:40 joshfix a commentRevision 1.3 2001/12/21 22:50:41 joshshould be returning WRONG_LENGTH instead of WRONG_VALUE incertain casesRevision 1.2 2001/11/06 21:20:33 joshrevised new path hackingRevision 1.1.1.1 2001/11/05 17:47:40 tnealeTornado shuffleRevision 9.3.2.3 2001/09/28 20:49:06 joshmethod routines will now allow rows to be created as permanent orread-only rows. It will also prevent the deletion of such rows.Revision 9.3.2.2 2001/08/24 14:09:55 joshdon't allow snmpProxyContextEngineID to be set to our ownengine IDRevision 9.3.2.1 2001/06/28 18:22:55 joshSeeding the Cormorant branch with the code from the oldcormorant branchRevision 9.2.2.1 2001/04/11 19:35:40 joshmoving cormorant-specific files onto the specialcormorant branch so they don't get in kingfisher's wayRevision 9.2 2001/01/19 22:22:00 paulUpdate copyright.Revision 9.1 2000/07/12 18:25:45 joshupdate to method routine to use more standard definitionsRevision 9.0 2000/06/09 13:59:47 joshupdating version stampRevision 1.1 2000/06/09 13:48:59 joshfirst (and possibly only) round of method routines for proxy code*//*DESCRIPTIONThis module contains the method routines for managing thesnmpProxyTable via SNMP.INCLUDE FILES: asn1conf.h, asn1.h, buffer.h, mib.h, localio.h, snmpdefs.h, snmp.h, auxfuncs.h, objectid.h, v3_proxy.h, v3_eng.h*//* includes */#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/objectid.h>#include <wrn/wm/snmp/engine/v3_proxy.h>#include <wrn/wm/snmp/engine/v3_eng.h>/* defines *//* default values for the macros to map the method routines to the proxy's non volatile storage */#if !defined(SNMP_V3_PROXY_DESTROY_BACKOUT)#define SNMP_V3_PROXY_DESTROY_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_PROXY_CREATE_BACKOUT)#define SNMP_V3_PROXY_CREATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_PROXY_UPDATE_BACKOUT)#define SNMP_V3_PROXY_UPDATE_BACKOUT(CUR, NEW)#endif#if !defined(SNMP_V3_PROXY_FINISHED)#define SNMP_V3_PROXY_FINISHED()#endif#if !defined(SNMP_V3_PROXY_DESTROY_TEST)#define SNMP_V3_PROXY_DESTROY_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_PROXY_CREATE_TEST)#define SNMP_V3_PROXY_CREATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_PROXY_UPDATE_TEST)#define SNMP_V3_PROXY_UPDATE_TEST(PKT, VBP, CUR, NEW) NO_ERROR#endif#if !defined(SNMP_V3_PROXY_DESTROY_SET)#define SNMP_V3_PROXY_DESTROY_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_PROXY_CREATE_SET)#define SNMP_V3_PROXY_CREATE_SET(PKT, VBP, CUR, NEW)#endif#if !defined(SNMP_V3_PROXY_UPDATE_SET)#define SNMP_V3_PROXY_UPDATE_SET(PKT, VBP, CUR, NEW)#endif/* these aren't defined by default *//*#define SNMP_V3_PROXY_DESTROY_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_PROXY_CREATE_UNDO(PKT, VBP, CUR, SAV)#define SNMP_V3_PROXY_UPDATE_UNDO(PKT, VBP, CUR, SAV)*//* * Method routines for the snmpProxyTable: * * snmpProxyName -- not-accessible * The locally arbitrary, but unique identifier associated * with this snmpProxyEntry. * * snmpProxyType -- read-create * The type of message that may be forwarded using * the translation parameters defined by this entry. * * snmpProxyContextEngineID -- read-create * The contextEngineID contained in messages that * may be forwarded using the translation parameters * defined by this entry. * * snmpProxyContextName -- read-create * The contextName contained in messages that may be * forwarded using the translation parameters defined * by this entry. * * This object is optional, and if not supported, the * contextName contained in a message is ignored when * selecting an entry in the snmpProxyTable. * * snmpProxyTargetParamsIn -- read-create * This object selects an entry in the snmpTargetParamsTable. * The selected entry is used to determine which row of the * snmpProxyTable to use for forwarding received messages. * * snmpProxySingleTargetOut -- read-create * This object selects a management target defined in the * snmpTargetAddrTable (in the SNMP-TARGET-MIB). The * selected target is defined by an entry in the * snmpTargetAddrTable whose index value (snmpTargetAddrName) * is equal to this object. * * This object is only used when selection of a single * target is required (i.e. when forwarding an incoming * read or write request). * * snmpProxyMultipleTargetOut -- read-create * This object selects a set of management targets defined * in the snmpTargetAddrTable (in the SNMP-TARGET-MIB). * * This object is only used when selection of multiple * targets is required (i.e. when forwarding an incoming * notification). * * snmpProxyStorageType -- read-create * The storage type of this conceptual row. * * snmpProxyRowStatus -- 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). * * The following objects may not be modified while the * value of this object is active(1): * - snmpProxyType * - snmpProxyContextEngineID * - snmpProxyContextName * - snmpProxyTargetParamsIn * - snmpProxySingleTargetOut * - snmpProxyMultipleTargetOut *//**************************************************************************** snmpProxyEntryGetValue -- retrieve the values and put them into varbinds** An internal routine to retrieve the values of the variables, used* by the method routines snmpProxyEntry_get and snmpProxyEntry_next.* You need to replace the type STRUCT_snmpProxyEntry with something* appropriate to your system.** RETURNS: GEN_ERR if an error occurred* NO_ERR if all worked properly*/static int snmpProxyEntryGetValue ( OIDC_T lastmatch, SNMP_PKT_T * pktp, VB_T * vbp, SNMP_PROXY_T * proxy ) { switch (lastmatch) { case LEAF_snmpProxyType: /* Values: * read(1) = PROXY_TYPE_READ * write(2) = PROXY_TYPE_WRITE * trap(3) = PROXY_TYPE_TRAP * inform(4) = PROXY_TYPE_INFORM */ getproc_got_int32 (pktp, vbp, SNMP_Proxy_Get_Proxy_Type (proxy)); break; case LEAF_snmpProxyContextEngineID: getproc_got_string (pktp, vbp, SNMP_Proxy_Get_Context_Engine_ID_Len (proxy), SNMP_Proxy_Get_Context_Engine_ID (proxy), 0, VT_STRING); break; case LEAF_snmpProxyContextName: getproc_got_string (pktp, vbp, SNMP_Proxy_Get_Context_Name_Len (proxy), SNMP_Proxy_Get_Context_Name (proxy), 0, VT_STRING); break; case LEAF_snmpProxyTargetParamsIn: getproc_got_string (pktp, vbp, SNMP_Proxy_Get_Target_Params_In_Len (proxy), SNMP_Proxy_Get_Target_Params_In (proxy), 0, VT_STRING); break; case LEAF_snmpProxySingleTargetOut: getproc_got_string (pktp, vbp, SNMP_Proxy_Get_Single_Target_Out_Len (proxy), SNMP_Proxy_Get_Single_Target_Out (proxy), 0, VT_STRING); break; case LEAF_snmpProxyMultipleTargetOut: getproc_got_string (pktp, vbp, SNMP_Proxy_Get_Multiple_Target_Out_Len (proxy), SNMP_Proxy_Get_Multiple_Target_Out (proxy), 0, VT_STRING); break; case LEAF_snmpProxyStorageType: /* Values: * other(1) = VAL_snmpProxyStorageType_other * volatile(2) = VAL_snmpProxyStorageType_volatile * nonVolatile(3) = VAL_snmpProxyStorageType_nonVolatile * permanent(4) = VAL_snmpProxyStorageType_permanent * readOnly(5) = VAL_snmpProxyStorageType_readOnly */ getproc_got_int32 (pktp, vbp, SNMP_Proxy_Get_Storage (proxy)); break; case LEAF_snmpProxyRowStatus: /* Values: * active(1) = VAL_snmpProxyRowStatus_active * notInService(2) = VAL_snmpProxyRowStatus_notInService * notReady(3) = VAL_snmpProxyRowStatus_notReady * createAndGo(4) = VAL_snmpProxyRowStatus_createAndGo * createAndWait(5) = VAL_snmpProxyRowStatus_createAndWait * destroy(6) = VAL_snmpProxyRowStatus_destroy */ getproc_got_int32 (pktp, vbp, SNMP_Proxy_Get_Status (proxy)); break; default: return GEN_ERR; } return NO_ERROR; }/**************************************************************************** snmpProxyEntry_get - the getproc for the snmpProxyTable** This function handles get requests. It is never called directly, only* by the Envoy engine.** Returns: N/A*/void snmpProxyEntry_get ( OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp ) { SNMP_PROXY_T * pProxy = 0; bits8_t name [ETC_PROXY_NAME_MAX]; ALENGTH_T nameLen = ETC_PROXY_NAME_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, &nameLen, name, 1) == 0) && (nameLen != 0)) pProxy = SNMP_Proxy_Lookup(name, nameLen); if (pProxy == 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 = snmpProxyEntryGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, pProxy)) != NO_ERROR) getproc_error (pktp, vbp, error); } } }/**************************************************************************** snmpProxyEntry_next - the nextproc for the snmpProxyTable** This function handles next requests. It is never called directly, only* by the Envoy engine.** Returns: N/A*/void snmpProxyEntry_next ( OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp ) { SNMP_PROXY_T * pProxy; OIDC_T bestInst [ETC_PROXY_NAME_MAX]; int error; /* find all the varbinds that share the same getproc and instance */ group_by_getproc_and_instance (pktp, vbp, tcount, tlist); pProxy = SNMP_Proxy_Next (tcount, tlist); if ((pProxy != 0) && ((error = string_to_oid (SNMP_Proxy_Get_Proxy_Name_Len (pProxy), SNMP_Proxy_Get_Proxy_Name (pProxy), ETC_PROXY_NAME_MAX, bestInst, 1)) == 0)) { for ( ; vbp ; vbp = vbp->vb_link) { if ((error = snmpProxyEntryGetValue (vbp->vb_ml.ml_last_match, pktp, vbp, pProxy)) == NO_ERROR) nextproc_next_instance (pktp, vbp, SNMP_Proxy_Get_Proxy_Name_Len (pProxy), bestInst); 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); }/***************************************************************************** proxyTableDestroyCleanup - cleanup after a successful test (destroy)** Cleanup after a proxy 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_T.** RETURNS: N/A*/static void proxyTableDestroyCleanup ( ptr_t proxyPtr ) { SNMP_V3_PROXY_DESTROY_BACKOUT (((VB_T *)proxyPtr)->vb_priv, 0); }/***************************************************************************** proxyTableCreateCleanup - cleanup after a successful test (create)** Cleanup after a proxy create test succeeded but some other test failed. As* this is a create the state pointer points to a structure that is installed,* we need to deinstall it, call the backout routine, and cleanup the state.** Expects the pointer to point to a VB_T** RETURNS: N/A*/static void proxyTableCreateCleanup ( ptr_t proxyPtr ) { SNMP_PROXY_T * pProxy; pProxy = (SNMP_PROXY_T *) (((VB_T *)proxyPtr)->vb_priv); SNMP_V3_PROXY_CREATE_BACKOUT (0, pProxy); SNMP_Proxy_Deinstall (pProxy); SNMP_Proxy_Destroy (pProxy); }/***************************************************************************** proxyTableUpdateCleanup - cleanup after a successful test (update)* * Cleanup after a proxy update test succeeded but some other test failed. As* this is an update the state pointer points to a structure that isn't* installed. The next pointer of that structure points to the installed copy.* We call the backout routine and cleanup the state.** RETURNS: N/A*/static void proxyTableUpdateCleanup ( ptr_t proxyPtr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -