Not getting specific trap

yogesh m <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I am trying to learn SNMP
This is my first snmp agent code... 
In this i am trying to generate my Trap for first system status of first row.
can any one tell me that why my agent is unable to generate the trap.
and how can i put values of ip. 

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "telecrbt.h"

static const oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0};
fill_teleSysResourceTable(void);
send_mySysDown_trap();
/** Initializes the telecrbt module */
void init_telecrbt(void)
{
        initialize_table_teleSysResourceTable();
        send_mySysDown_trap();
}
long status=0;
fill_teleSysResourceTable(void);
 void initialize_table_teleSysResourceTable(void)
{
        const oid       teleSysResourceTable_oid[] =
        { 1, 3, 6, 1, 4, 1, xxxx, 1, 1, 1 };
        const size_t    teleSysResourceTable_oid_len =
                OID_LENGTH(teleSysResourceTable_oid);
        netsnmp_handler_registration *reg;
        netsnmp_iterator_info *iinfo;
        netsnmp_table_registration_info *table_info;
        netsnmp_agent_request_info *reqinfo;
        //printf("i m in table1\n");
        iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
        DEBUGMSGTL(("telecrbt:init",
                                "initializing table teleSysResourceTable\n"));
        reg =
                netsnmp_create_handler_registration("teleSysResourceTable",
                                teleSysResourceTable_handler,
                                teleSysResourceTable_oid,
                                teleSysResourceTable_oid_len,
                                HANDLER_CAN_RONLY);

        table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
                                                                                                                                    
 
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,0);   /* index: 
teleSysIndex */
        table_info->min_column = COLUMN_TELESYSINDEX;
        table_info->max_column = COLUMN_TELESYSCPUUSAGE;

        iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
        iinfo->get_first_data_point =
                teleSysResourceTable_get_first_data_point;

        iinfo->get_next_data_point = teleSysResourceTable_get_next_data_point;
        iinfo->table_reginfo = table_info;
        
        netsnmp_register_table_iterator(reg,iinfo);
        
 fill_teleSysResourceTable();
}

/*
 * Typical data structure for a row entry 
 */
struct teleSysResourceTable_entry {
        
        long            teleSysIndex;

        /*
         * Column values 
         */
        
        long            teleSysStatus;
        char            teleSysHostname[333];
        size_t          teleSysHostname_len;
        in_addr_t       teleSysIP;
        long            teleSysHDDUsage;
        long            teleSysMemUsage;
        long            teleSysCPUusage;



struct teleSysResourceTable_entry *next;
};

struct teleSysResourceTable_entry *teleSysResourceTable_head;

/*
 * create a new row in the (unsorted) table 
 */
 struct teleSysResourceTable_entry *
teleSysResourceTable_createEntry(teleSysIndex)
{
        struct teleSysResourceTable_entry *entry;
        entry = SNMP_MALLOC_TYPEDEF(struct teleSysResourceTable_entry);
        if (!entry)
                return NULL;

        entry->teleSysIndex = teleSysIndex;
        entry->next = teleSysResourceTable_head;
        teleSysResourceTable_head = entry;  
        return entry;
}
fill_teleSysResourceTable(void)
{
        struct teleSysResourceTable_entry *entry;
         long         teleSysIndex=NULL;
        long         teleSysStatus=NULL;
        char            teleSysHostname[333]="\0";
        size_t          teleSysHostname_len=strlen(NULL);
        in_addr_t       teleSysIP=NULL;
        long            teleSysHDDUsage=NULL;
        long            teleSysMemUsage=NULL;
        long            teleSysCPUusage=NULL;
       
        entry = SNMP_MALLOC_TYPEDEF(struct teleSysResourceTable_entry);
entry=teleSysResourceTable_createEntry(1);
        entry->teleSysStatus=0;
         entry->teleSysHostname[333]="yogesh";
        entry->teleSysIP="192.168.1.2";
        entry->teleSysHDDUsage=6;
        entry->teleSysMemUsage=5;
        entry->teleSysCPUusage=4;

entry=teleSysResourceTable_createEntry(2);
        entry->teleSysStatus=1;
        entry->teleSysHostname[333]="manrao";
        entry->teleSysIP="192.168.1.3";
        entry->teleSysHDDUsage=111;
        entry->teleSysMemUsage=222;
        entry->teleSysCPUusage=333;

int
send_mySysDown_trap(void)
{
    netsnmp_variable_list *var_list = NULL;
    const oid       mySysDown_oid[] = { 1, 3, 6, 1, 4, 1, xxxx, 1, 2, 1 };
    const oid       teleSysStatus_oid[] =
        { 1, 3, 6, 1, 4, 1, xxxx, 1, 1, 1, 1, 2, 1 /* insert index here */
        };
    /*
     * Set the snmpTrapOid.0 value
     */
int *teleSysStatus = 1;
 snmp_varlist_add_variable(&var_list,
                              snmptrap_oid, OID_LENGTH(snmptrap_oid),
                              ASN_OBJECT_ID,
                              mySysDown_oid, sizeof(mySysDown_oid));
/*
     * Add any objects from the trap definition
     */
    snmp_varlist_add_variable(&var_list,
                              teleSysStatus_oid,
                              OID_LENGTH(teleSysStatus_oid), ASN_INTEGER,
                              /*
                               * Set an appropriate value for teleSysStatus 
                               */
                              &teleSysStatus,sizeof(teleSysStatus));

    /*
     * 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;
}

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.