FW: table dataset iteration not working

"Watsh Rajneesh" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <9BC384FCC8432F43A02C252EA3C290C104578B7C@HQ-EXCH-5.corp.brocade.com>
Hi All,

 

The dot3StatsTable does not have all columns in sequence (meaning, we have column 1 - index, column 2 - 11, 13, 16-21 so columns at 12, 14 and 15 index are missing). In my code (given in below mail) I am handling those invalid columns by not calling netsnmp_set_row_column() for them. But in the snmpwalk result the get-next is terminating at 11th column since it cannot find the column at 12th index (oid = 1.3.6.1.2.1.10.7.2.1.12). Do I need to call netsnmp_set_row_column() for even the invalid column indices? 

 

Thanks,
Watsh

 

________________________________

From: Watsh Rajneesh 
Sent: Thursday, November 13, 2008 3:36 PM
To: 'Suresh Bikmal'
Subject: RE: table dataset iteration not working

 

Hi Suresh,

 

There is another issue. The dot3StatsTable does not have all columns in sequence (meaning, we have column 1 - index, column 2 - 11, 13, 16-21 so columns at 12, 14 and 15 index are missing). In my code (given in below mail) I am handling those invalid columns by not calling netsnmp_set_row_column() for them. But in the snmpwalk result the get-next is terminating at 11th column since it cannot find the column at 12th index (oid = 1.3.6.1.2.1.10.7.2.1.12). Do I need to call netsnmp_set_row_column() for even the invalid column indices?

 

Thanks,
Watsh

 

________________________________

From: Watsh Rajneesh 
Sent: Thursday, November 13, 2008 3:28 PM
To: 'Suresh Bikmal'
Subject: RE: table dataset iteration not working

 

Thanks Suresh. It worked :-). I just had to comment out the index column from the netsmp_table_set_multi_add_default_row () method as you rightly pointed out.

 

Regards,

Watsh

________________________________

From: Suresh Bikmal [mailto:[email protected]] 
Sent: Thursday, November 13, 2008 2:28 PM
To: Watsh Rajneesh
Subject: Re: table dataset iteration not working

 

Rajneesh,

what version of net-snmp are you using?

try this: 
when you call the api, netsnmp_table_set_multi_add_default_row in the initialize_table_dot3StatsTable method,
do not pass the first index column. just give the details of the non-index columns.

let me know how it goes.

Have a nice time,
-Suresh

 

 

________________________________

From: Watsh Rajneesh <[email protected]>
To: [email protected]
Sent: Tuesday, November 11, 2008 6:01:24 PM
Subject: table dataset iteration not working

Hi All,

 

I generated my table code using the mib2c.create_dataset.conf configuration. The get on a column works but the get-next/snmpwalk does not work. I compared my code with the agent/mibgroup/data_set.c source and it seems to be no different. Can someone please shed some light on what’s missing in my code below for the table iteration to work?

 

 

void

initialize_table_dot3StatsTable(void)

{

    static oid dot3StatsTable_oid[] = {1,3,6,1,2,1,10,7,2};

    size_t dot3StatsTable_oid_len = OID_LENGTH(dot3StatsTable_oid);

    netsnmp_table_data_set *table_set;

      netsnmp_table_row *row;

      // variables declared - wrajnees

      static int _max_cols = 21; // there are 18 columns in this table.

      int column = 0;

      int index = 1;

      int val = 20;

      static oid      objid_etherchipset[] = { 0 };     /* snmpTrapIOD.0 */

 

      // end variables declared.

 

    /* create the table structure itself */

    table_set = netsnmp_create_table_data_set("dot3StatsTable");

 

    /* comment this out or delete if you don't support creation of new rows */

      

    table_set->allow_creation = 1;

 

    /***************************************************

     * Adding indexes

     */

    DEBUGMSGTL(("initialize_table_dot3StatsTable",

                "adding indexes to table dot3StatsTable\n"));

 

    netsnmp_table_set_add_indexes(table_set,

                           ASN_INTEGER,  /* index: dot3StatsIndex */

                           0);

 

      

    DEBUGMSGTL(("initialize_table_dot3StatsTable",

                "adding column types to table dot3StatsTable\n"));            

    netsnmp_table_set_multi_add_default_row(table_set,

                                            COLUMN_DOT3STATSINDEX, ASN_INTEGER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSALIGNMENTERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSFCSERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSSINGLECOLLISIONFRAMES, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSMULTIPLECOLLISIONFRAMES, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSSQETESTERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSDEFERREDTRANSMISSIONS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSLATECOLLISIONS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSEXCESSIVECOLLISIONS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSINTERNALMACTRANSMITERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSCARRIERSENSEERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSFRAMETOOLONGS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSINTERNALMACRECEIVEERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSETHERCHIPSET, ASN_OBJECT_ID, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSSYMBOLERRORS, ASN_COUNTER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSDUPLEXSTATUS, ASN_INTEGER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSRATECONTROLABILITY, ASN_INTEGER, 0,

                                            NULL, 0,

                                            COLUMN_DOT3STATSRATECONTROLSTATUS, ASN_INTEGER, 0,

                                            NULL, 0,

                              0);

 

 

    

    /* registering the table with the master agent */

    /* note: if you don't need a subhandler to deal with any aspects

       of the request, change dot3StatsTable_handler to "NULL" */

    netsnmp_register_table_data_set(netsnmp_create_handler_registration("dot3StatsTable", NULL,

                                                        dot3StatsTable_oid,

                                                        dot3StatsTable_oid_len,

                                                        HANDLER_CAN_RONLY),

                            table_set, NULL);

      // Add code - wrajnees

 

      /*

     * create the a row for the table, and add the data 

     */

    row = netsnmp_create_table_data_row();

      /*

     * set the index to the IETF WG name "snmpv3" 

     */

    netsnmp_table_row_add_index(row, ASN_INTEGER, (u_char*)&index, sizeof(index));

      /*

     * set the column 2 and above

     */

      for (column = 2; column <= _max_cols; column++) {

            // Following columns are not valid.

            switch(column) {

                  case 12: // INVALIDs

                  case 14:

                  case 15:

                        break;

                  case 17: // OID

                        netsnmp_set_row_column(row, column, ASN_OBJECT_ID,

                                             (u_char*)objid_etherchipset, 1*sizeof(oid));

                        break;

                  case 19: // INTEGER

                  case 21:

                        netsnmp_set_row_column(row, column, ASN_INTEGER,

                                             (u_char*)&val, sizeof(val));     

                        break;

                  case 20: // TRUTH_VALUE

                        netsnmp_set_row_column(row, column, ASN_INTEGER,

                                             (u_char*)&val, sizeof(val));     

                        break;

                  default: // COUNTER

                        netsnmp_set_row_column(row, column, ASN_COUNTER,

                                             (u_char*)&val, sizeof(val));     

                        break;

            }

 

 

      }

      /*

       * add the row to the table 

       */

      netsnmp_table_dataset_add_row(table_set, row);

 

      /*

     * Finally, this actually allows the "add_row" token it the

     * * snmpd.conf file to add rows to this table.

     * * Example snmpd.conf line:

     * *   add_row netSnmpIETFWGTable eos "Glenn Waters" "Dale Francisco"

     */

    netsnmp_register_auto_data_table(table_set, NULL);

 

      // End add code - wrajnees

}

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
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.