mib2c --生成notification

notification也就是trap相关的代码比较简单 也就是前面我们最后一步的时候输入y

最终生成的代码

/*
 * Note: this file originally auto-generated by mib2c
 * using mib2c.notify.conf
 */

#include 
#include 
#include 
#include "testModule.h"

extern const oid snmptrap_oid[];
extern const size_t snmptrap_oid_len;

int
send_objTrap_trap( void )
{
    netsnmp_variable_list  *var_list = NULL;
    const oid objTrap_oid[] = { 1,3,6,1,4,1,2,1,5 };
    const oid objtype1_oid[] = { 1,3,6,1,4,1,2,1,1, 0 };

    /*
     * Set the snmpTrapOid.0 value
     */
    snmp_varlist_add_variable(&var_list,
        snmptrap_oid, snmptrap_oid_len,
        ASN_OBJECT_ID,
        objTrap_oid, sizeof(objTrap_oid));
    
    /*
     * Add any objects from the trap definition
     */
    snmp_varlist_add_variable(&var_list,
        objtype1_oid, OID_LENGTH(objtype1_oid),
        ASN_INTEGER,
        /* Set an appropriate value for objtype1 */
        NULL, 0);

    /*
     * Add any extra (optional) objects here
     */

    /*
     * Send the trap to the list of configured destinations
     *  and clean up
     */
    send_v2trap( var_list );
    snmp_free_varbind( var_list );

    return SNMP_ERR_NOERROR;
}

你可能感兴趣的:(mib2c --生成notification)