📄 entitymt.c
字号:
/* * 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. *//* entitymt.c - method routines for the Entity MIB *//*modification history--------------------01b,18apr05,job update copyright notices01a,24nov03,job update copyright information$Log: entitymt.c,v $Revision 1.1 2002/05/23 18:47:32 joshsupport for the entLogicalTable from RFC 2737*//*DESCRIPTIONThis module contains the method routines for managing theEntity MIB via SNMP. Currently, only the entLogicalTableand the entityGeneral object entLastChangeTime are supported.INCLUDE FILES: asn1conf.h, asn1.h, buffer.h, mib.h, localio.h, snmpdefs.h, snmp.h, auxfuncs.h, objectid.h, entlogic.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/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/entlogic.h>/* * Method routines for the entLogicalTable: * * entLogicalIndex -- not-accessible * The value of this object uniquely identifies the logical * entity. The value should be a small positive integer; index * values for different logical entities are are not * necessarily contiguous. * * entLogicalDescr -- read-only * A textual description of the logical entity. This object * should contain a string which identifies the manufacturer's * name for the logical entity, and should be set to a distinct * value for each version of the logical entity. * * entLogicalType -- read-only * An indication of the type of logical entity. This will * typically be the OBJECT IDENTIFIER name of the node in the * SMI's naming hierarchy which represents the major MIB * module, or the majority of the MIB modules, supported by the * logical entity. For example: * a logical entity of a regular host/router -> mib-2 * a logical entity of a 802.1d bridge -> dot1dBridge * a logical entity of a 802.3 repeater -> snmpDot3RptrMgmt * If an appropriate node in the SMI's naming hierarchy cannot * be identified, the value 'mib-2' should be used. * * entLogicalCommunity -- read-only * An SNMPv1 or SNMPv2C community-string which can be used to * access detailed management information for this logical * entity. The agent should allow read access with this * community string (to an appropriate subset of all managed * objects) and may also return a community string based on the * privileges of the request used to read this object. Note * that an agent may return a community string with read-only * privileges, even if this object is accessed with a read- * write community string. However, the agent must take care * not to return a community string which allows more * privileges than the community string used to access this * object. * * A compliant SNMP agent may wish to conserve naming scopes by * representing multiple logical entities in a single 'default' * naming scope. This is possible when the logical entities * represented by the same value of entLogicalCommunity have no * object instances in common. For example, 'bridge1' and * 'repeater1' may be part of the main naming scope, but at * least one additional community string is needed to represent * 'bridge2' and 'repeater2'. * * Logical entities 'bridge1' and 'repeater1' would be * represented by sysOREntries associated with the 'default' * naming scope. * * For agents not accessible via SNMPv1 or SNMPv2C, the value * of this object is the empty string. This object may also * contain an empty string if a community string has not yet * been assigned by the agent, or no community string with * suitable access rights can be returned for a particular SNMP * request. * * Note that this object is deprecated. Agents which implement * SNMPv3 access should use the entLogicalContextEngineID and * entLogicalContextName objects to identify the context * associated with each logical entity. SNMPv3 agents may * return a zero-length string for this object, or may continue * to return a community string (e.g., tri-lingual agent * support). * * entLogicalTAddress -- read-only * The transport service address by which the logical entity * receives network management traffic, formatted according to * the corresponding value of entLogicalTDomain. * * For snmpUDPDomain, a TAddress is 6 octets long, the initial * 4 octets containing the IP-address in network-byte order and * the last 2 containing the UDP port in network-byte order. * Consult 'Transport Mappings for Version 2 of the Simple * Network Management Protocol' (RFC 1906 [RFC1906]) for * further information on snmpUDPDomain. * * entLogicalTDomain -- read-only * Indicates the kind of transport service by which the * logical entity receives network management traffic. * Possible values for this object are presently found in the * Transport Mappings for SNMPv2 document (RFC 1906 * [RFC1906]). * * entLogicalContextEngineID -- read-only * The authoritative contextEngineID that can be used to send * an SNMP message concerning information held by this logical * entity, to the address specified by the associated * 'entLogicalTAddress/entLogicalTDomain' pair. * * This object, together with the associated * entLogicalContextName object, defines the context associated * with a particular logical entity, and allows access to SNMP * engines identified by a contextEngineId and contextName * pair. * * If no value has been configured by the agent, a zero-length * string is returned, or the agent may choose not to * instantiate this object at all. * * entLogicalContextName -- read-only * The contextName that can be used to send an SNMP message * concerning information held by this logical entity, to the * address specified by the associated * 'entLogicalTAddress/entLogicalTDomain' pair. * * This object, together with the associated * entLogicalContextEngineID object, defines the context * associated with a particular logical entity, and allows * access to SNMP engines identified by a contextEngineId and * contextName pair. * * If no value has been configured by the agent, a zero-length * string is returned, or the agent may choose not to * instantiate this object at all. */static int entLogicalEntry_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, ENT_LOGICAL_T *entLogical) {switch(lastmatch) { case LEAF_entLogicalDescr: getproc_got_string(pktp, vbp, Ent_Logical_Get_Descr_Len(entLogical), Ent_Logical_Get_Descr(entLogical), 0, VT_STRING); break; case LEAF_entLogicalType: getproc_got_object_id(pktp, vbp, Ent_Logical_Get_Type(entLogical)->num_components, Ent_Logical_Get_Type(entLogical)->component_list, 0); break; case LEAF_entLogicalCommunity: getproc_got_string(pktp, vbp, Ent_Logical_Get_Community_Len(entLogical), Ent_Logical_Get_Community(entLogical), 0, VT_STRING); break; case LEAF_entLogicalTAddress: getproc_got_string(pktp, vbp, Ent_Logical_Get_TAddress_Len(entLogical), Ent_Logical_Get_TAddress(entLogical), 0, VT_STRING); break; case LEAF_entLogicalTDomain: getproc_got_object_id(pktp, vbp, Ent_Logical_Get_TDomain(entLogical)->num_components, Ent_Logical_Get_TDomain(entLogical)->component_list, 0); break; case LEAF_entLogicalContextEngineID: getproc_got_string(pktp, vbp, Ent_Logical_Get_Context_Engine_ID_Len(entLogical), Ent_Logical_Get_Context_Engine_ID(entLogical), 0, VT_STRING); break; case LEAF_entLogicalContextName: getproc_got_string(pktp, vbp, Ent_Logical_Get_Context_Name_Len(entLogical), Ent_Logical_Get_Context_Name(entLogical), 0, VT_STRING); break; default: return GEN_ERR; }return NO_ERROR;}void entLogicalEntry_get(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ENT_LOGICAL_T *entLogical;int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);if ((tcount != 1) || ((entLogical = Ent_Logical_Lookup(*tlist)) == 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 = entLogicalEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, entLogical)) != NO_ERROR) getproc_error(pktp, vbp, error); } }} void entLogicalEntry_next(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){ENT_LOGICAL_T *entLogical; OIDC_T entIndex[1];int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);entLogical = Ent_Logical_Next(tcount, tlist);if (entLogical) { entIndex[0] = Ent_Logical_Get_Index(entLogical); for ( ; vbp ; vbp = vbp->vb_link ) { if ((error = entLogicalEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, entLogical)) == NO_ERROR) nextproc_next_instance(pktp, vbp, 1, entIndex); 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);} /* * Method routines for the entityGeneral variables: * * entLastChangeTime -- read-only * The value of sysUpTime at the time a conceptual row is * created, modified, or deleted in any of these tables: * - entPhysicalTable * - entLogicalTable * - entLPMappingTable * - entAliasMappingTable * - entPhysicalContainsTable */static int entityGeneral_get_value(OIDC_T lastmatch, SNMP_PKT_T *pktp, VB_T *vbp, ENT_GENERAL_T *entGeneral){switch(lastmatch) { case LEAF_entLastChangeTime: getproc_got_uint32(pktp, vbp, Ent_General_Get_Last_Change_Time(entGeneral), VT_TIMETICKS); break; default: return GEN_ERR; }return NO_ERROR;}void entityGeneral_get(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){int error;/* find all the varbinds that share the same getproc and instance */group_by_getproc_and_instance(pktp, vbp, tcount, tlist);/* check that the instance is exactly .0 */if (!((tcount == 1) && (*tlist == 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 = entityGeneral_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, Ent_General_Group_Lookup())) != NO_ERROR) getproc_error(pktp, vbp, error); } }}void entityGeneral_next(OIDC_T lastmatch, int tcount, OIDC_T *tlist, SNMP_PKT_T *pktp, VB_T *vbp){OIDC_T instance = 0;/* the only time there's a next for a scalar is if we're given * no instance at all. */if (tcount != 0) nextproc_no_next(pktp, vbp);else { /* find all the varbinds in this group and retrieve their * values from the same data structure */ for (group_by_getproc_and_instance(pktp, vbp, tcount, tlist); vbp; vbp = vbp->vb_link) { nextproc_next_instance(pktp, vbp, 1, &instance); entityGeneral_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, Ent_General_Group_Lookup()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -