OK, sorry, I should have provided the whole stuff, so here it is.

void init_GenServerTable()
{
    ...

netsnmp_table_data_set *genServerTable = 
netsnmp_create_table_data_set("genServerTable");

genServerTable->allow_creation = 1;

// Add index
netsnmp_table_dataset_add_index(genServerTable, ASN_UINTEGER);

// Add other rows
netsnmp_table_set_multi_add_default_row(genServerTable,
                                            2,
                                            ASN_OCTET_STR, 0, NULL, 0,
                                            3,
                                            ASN_OCTET_STR, 0, NULL, 0,
                                            4,
                                            ASN_OCTET_STR, 0, NULL, 0,
                                            5,
                                            ASN_UINTEGER, 0, NULL, 0,           
                          
           0);

netsnmp_register_table_data_set(netsnmp_create_handler_registration
                                    ("genServerTable",
                                     NULL,
                                     genServerTableOid,
                                     genServerTableOidLen,
                                     HANDLER_CAN_RWRITE), genServerTable, 
NULL);

// Add a Row
netsnmp_table_row *row  = netsnmp_create_table_data_row();

u_long ind = 1;
netsnmp_table_row_add_index(row, ASN_UINTEGER, &ind, sizeof(ind));

netsnmp_set_row_column(row, 2, ASN_OCTET_STR,
                         "Test1", strlen("Test1"));

netsnmp_set_row_column(row, 3, ASN_OCTET_STR, "Test2",
                           strlen("Test2"));

netsnmp_set_row_column(row, 4, ASN_OCTET_STR,
                           "Test3", strlen("Test3"));

netsnmp_table_dataset_add_row(genServerTable, row);
}

If index is managed by net-snmp, why do I have to use 
netsnmp_table_row_add_index with the value ind manually managed in my 
sample?

>From: "Dave Shield" <[EMAIL PROTECTED]>
>To: "Arnaud BODENAN" <[EMAIL PROTECTED]>
>CC: net-snmp-users@lists.sourceforge.net
>Subject: Re: FW: Re: How can I extend a MIB with a subagentX
>Date: Thu, 31 Aug 2006 17:01:51 +0100
>
>On 31/08/06, Arnaud BODENAN <[EMAIL PROTECTED]> wrote:
>>I've added in my registration of my table the creation of the rows:
>
>>int initGenServerTable
>>{
>    [omitted]
>>// Add a Row
>>netsnmp_table_row *row  = netsnmp_create_table_data_row();
>    [snip]
>>netsnmp_table_dataset_add_row(genServerTable, row);
>>}
>>
>>When I execute my sub agent, I now have the following error:
>>illegal data attempted to be added to table (no index)genServerTable
>>although I set the index (variable ind) in the row of the table...
>
>But have you *declared* the structure of the table, and how it is indexed?
>This would normally occur in the block of code that you omitted,
>before starting to populate the table (netsnmp_create_table_data_row()
>through netsnmp_table_dataset_add_row()).
>
>See 'mibgroup.examples/data_set.c' for the necessary code.
>
>
>
>>I hoped that management of the index of a table was managed by the 
>>net-snmp API.
>
>Yes - it is.
>
>>Must I manage it myself?
>
>No - you don't have to manage this yourself.
>But you do need to tell the agent what form this indexing takes.
>It's not clear from the code you've provided whether or not you are
>actually doing this.
>
>See the example referred to above.
>
>Dave

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to