Trap一般是网络设备发出的,由网管程序(Manager)接收。
没听说要对设备发送Trap。这有什么用吗?接收Trap的程序我倒是有。

解决方案 »

  1.   

    SnmpExtensionClose
    SnmpExtensionInit
    SnmpExtensionInitEx
    SnmpExtensionMonitor
    SnmpExtensionQuery
    SnmpExtensionQueryEx
    SnmpExtensionTrap SnmpMgrClose
    SnmpMgrGetTrap
    SnmpMgrGetTrapEx
    SnmpMgrOidToStr
    SnmpMgrOpen
    SnmpMgrRequest
    SnmpMgrStrToOid
    SnmpMgrTrapListen SnmpSvcGetUptime
    SnmpSvcSetLogLevel
    SnmpSvcSetLogType
    SnmpUtilAsnAnyCpy
    SnmpUtilAsnAnyFree
    SnmpUtilDbgPrintSnmpUtilIdsToA 
    SnmpUtilMemAlloc
    SnmpUtilMemFree
    SnmpUtilMemReAlloc
    SnmpUtilOctetsCmp
    SnmpUtilOctetsCpy
    SnmpUtilOctetsFree
    SnmpUtilOctetsNCmp
    SnmpUtilOidAppend
    SnmpUtilOidCmp
    SnmpUtilOidCpy
    SnmpUtilOidFree
    SnmpUtilOidNCmpSnmpUtilOidToA 
    SnmpUtilPrintAsnAny
    SnmpUtilPrintOid 
    SnmpUtilVarBindCpy
    SnmpUtilVarBindListCpy
    SnmpUtilVarBindFree
    SnmpUtilVarBindListFree 这些API中,能具体介绍几个与Trap相关的也行。就介绍介绍基本用法和基本原理。
      

  2.   

    SnmpExtensionClose
    SnmpExtensionInit
    SnmpExtensionInitEx
    SnmpExtensionMonitor
    SnmpExtensionQuery
    SnmpExtensionQueryEx
    SnmpExtensionTrap SnmpMgrClose
    SnmpMgrGetTrap
    SnmpMgrGetTrapEx
    SnmpMgrOidToStr
    SnmpMgrOpen
    SnmpMgrRequest
    SnmpMgrStrToOid
    SnmpMgrTrapListen SnmpSvcGetUptime
    SnmpSvcSetLogLevel
    SnmpSvcSetLogType
    SnmpUtilAsnAnyCpy
    SnmpUtilAsnAnyFree
    SnmpUtilDbgPrintSnmpUtilIdsToA 
    SnmpUtilMemAlloc
    SnmpUtilMemFree
    SnmpUtilMemReAlloc
    SnmpUtilOctetsCmp
    SnmpUtilOctetsCpy
    SnmpUtilOctetsFree
    SnmpUtilOctetsNCmp
    SnmpUtilOidAppend
    SnmpUtilOidCmp
    SnmpUtilOidCpy
    SnmpUtilOidFree
    SnmpUtilOidNCmpSnmpUtilOidToA 
    SnmpUtilPrintAsnAny
    SnmpUtilPrintOid 
    SnmpUtilVarBindCpy
    SnmpUtilVarBindListCpy
    SnmpUtilVarBindFree
    SnmpUtilVarBindListFree 这些API中,能具体介绍几个与Trap相关的也行。就介绍介绍基本用法和基本原理。
      

  3.   

    SnmpExtensionClose
    SnmpExtensionInit
    SnmpExtensionInitEx
    SnmpExtensionMonitor
    SnmpExtensionQuery
    SnmpExtensionQueryEx
    SnmpExtensionTrap SnmpMgrClose
    SnmpMgrGetTrap
    SnmpMgrGetTrapEx
    SnmpMgrOidToStr
    SnmpMgrOpen
    SnmpMgrRequest
    SnmpMgrStrToOid
    SnmpMgrTrapListen SnmpSvcGetUptime
    SnmpSvcSetLogLevel
    SnmpSvcSetLogType
    SnmpUtilAsnAnyCpy
    SnmpUtilAsnAnyFree
    SnmpUtilDbgPrintSnmpUtilIdsToA 
    SnmpUtilMemAlloc
    SnmpUtilMemFree
    SnmpUtilMemReAlloc
    SnmpUtilOctetsCmp
    SnmpUtilOctetsCpy
    SnmpUtilOctetsFree
    SnmpUtilOctetsNCmp
    SnmpUtilOidAppend
    SnmpUtilOidCmp
    SnmpUtilOidCpy
    SnmpUtilOidFree
    SnmpUtilOidNCmpSnmpUtilOidToA 
    SnmpUtilPrintAsnAny
    SnmpUtilPrintOid 
    SnmpUtilVarBindCpy
    SnmpUtilVarBindListCpy
    SnmpUtilVarBindFree
    SnmpUtilVarBindListFree 这些API中,能具体介绍几个与Trap相关的也行。就介绍介绍基本用法和基本原理。
      

  4.   

    SnmpRegister()The SnmpRegister function registers the application's desire to receive or discontinue trap and inform notifications from the specified entity of interest (dstEntity), which will act in an agent role.
     
    Syntax:
    SNMPAPI_STATUS SnmpRegister (
    IN HSNMP_SESSION session,
    IN HSNMP_ENTITY srcEntity,
    IN HSNMP_ENTITY dstEntity,
    IN HSNMP_CONTEXT context,
    IN smiLPCOID  notification,
    IN smiUINT32 status);Parameter Description
    session Identifies the session which is interested in registering.
    srcEntity Identifies the management entity (manager role) of interest--this will be the trap recipient.  (This is the “source” of the notification request.)
    dstEntity Identifies the management entity (agent role) of interest--this will be the trap sender.  (This is the “target” of the notification request.)
    context Identifies the context of interest. 
    notification Identifies the trap/notification OID matching sequence to be registered or un-registered.
    status Indicates whether to register (SNMPAPI_ON) or un-register (SNMPAPI_OFF) for the subject notification..
     
    Returns:If the function is successful, the return value is SNMPAPI_SUCCESS.
     
    If the function fails, the return value is SNMPAPI_FAILURE.  Use the SnmpGetLastError function to obtain extended error information.
     SnmpGetLastError() Description
    "Common Error Codes" See Section 2.10.1 Common Error Codes..
    SNMPAPI_SESSION_INVALID Indicates that the session parameter is invalid.
    SNMPAPI_ENTITY_INVALID Indicates that the entity parameter is invalid.
    SNMPAPI_CONTEXT_INVALID Indicates that the context parameter is invalid.
    SNMPAPI_OID_INVALID Indicates that the notification parameter is invalid.
    SNMPAPI_TL_NOT_INITIALIZED Transport layer not initialized
    SNMPAPI_TL_IN_USE Trap port not available
    SNMPAPI_TL_NOT_AVAILABLE Network subsystem has failed
     
     
    Comments:In WinSNMP all traps are delivered to the applications are SNMPv2  traps.  If an implementation receives an SNMPv1 trap from an SNMPv1 agent, it must convert it to an SNMPv2 trap in accordance with RFC 1452 (the “Coexistence” document).See Appendix A. Mapping Traps Between SNMPv1 and SNMPv2.Notifications, traps or informs, are defined using OBJECT IDENTIFIERs, as specified in SNMPv2. Hence, an application interested in receiving coldStart traps should construct an OBJECT IDENTIFIER corresponding to this trap based upon the SNMPv2 MIB (RFC 1450) and use this as the notification parameter.The value of the notification parameter is used for pattern matching against the OIDs of received traps and notifications.  That is, if the first ‘n’ sub-ids of a received SnmpTrapOID match all the sub-ids (‘n’) of a notification value passed to SnmpRegister, than that SnmpTrapOID is a match.  Accordingly, a  received SnmpTrapOID with fewer sub-ids than a given notification parameters must fail the matching process with respect to that particular notification parameter.An application may pass NULL for any or all of the srcEntity, dstEntity, context, and notification parameters.  The significance of NULL in any of these parameters is, effectively, to tell the implementation to not filter out any received traps or notifications on the basis of this parameter.If the notification parameter is NULL, then the application is indicating that it is interested in registering or unregistering for any and all notifications from the dstEntity, as indicated by the status parameter.If the status parameter contains any value other than SNMPAPI_OFF or SNMPAPI_ON, it will be treated as though it were SNMPAPI_ON.
     
    Upon receipt of a trap/notification, the hWnd parameter specified in the SnmpOpen call for the registered session is sent the wMsg specified. The application should call SnmpRecvMsg with this session to retrieve the appropriate results.Note that it is the responsibility of a Level 3 implementation to acknowledge the receipt of an InformRequest-PDU.  This tells the issuing management entity that the inform made it to the implementation "platform", but not necessarily to any particular application(s).In the case where a NULL dstEntity parameter to SnmpRegister results in the implementation creating an entity object for the srcEntity parameter on a future SnmpRecvMsg call, the entity will "belong" to the application as though it had caused its creation with SnmpStrToEntity.  Put differently, the behavior
    in this respect will be the same as for SnmpDecodeMsg.  This is equally true--although perhaps less likely to occur--with respect to the srcEntity and context parameters as well.Note that this functionality relates to [not] filtering traps/notifications received by the implementation.  It does not address the issue of how such traps/notifications get directed to the implementation in the first place.  This is assumed to occur "out-of-band" from the perspective of application making use of NULL filtering parameters as described above.
     
      

  5.   

    全英文啊?看是我完全看得懂的话,也就看MSDN就够了,有时候网友的几句点眼之语比长篇大论效果要好得多。谢谢回复。