Problem with table - SNMP

This is a discussion on Problem with table - SNMP ; Hi All, I am trying to implement a table following the dataset.c in example. Below is the code void init_DryContactTable(void) { netsnmp_table_data_set *table_set; netsnmp_table_row *row; /* * the OID we want to register our integer at. This should be the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Problem with table

  1. Problem with table

    Hi All,

    I am trying to implement a table following the dataset.c in example.

    Below is the code



    void
    init_DryContactTable(void)
    {
    netsnmp_table_data_set *table_set;
    netsnmp_table_row *row;

    /*
    * the OID we want to register our integer at. This should be the
    * * OID node for the entire table. In our case this is the
    * * netSnmpIETFWGTable oid definition
    */

    init_values();
    oid my_registration_oid[] =
    { 1, 3, 6, 1, 4, 1,4321,7};

    DEBUGMSGTL(("DryContactTable",
    "Initalizing example dryContact table\n"));


    table_set = netsnmp_create_table_data_set("DryContactTable");

    /*
    * allow the creation of new rows via SNMP SETs
    */
    table_set->allow_creation = 1;

    /*
    * set up what a row "should" look like, starting with the index
    */
    netsnmp_table_dataset_add_index(table_set, ASN_INTEGER);

    /*
    * define what the columns should look like. both are octet strings here
    */
    netsnmp_table_set_multi_add_default_row(table_set,
    //DryContact PortID
    2, ASN_INTEGER, 1, NULL, 0,
    // DryContactPortType
    3, ASN_INTEGER, 1, NULL, 0,
    //DryContactDisplay String
    4,ASN_OCTET_STR,1,NULL,0,
    // DryContactPortValue
    5,ASN_INTEGER,1,NULL,0,

    0 /* done */ );

    /*
    * register the table
    */
    /*
    * if we wanted to handle specific data in a specific way, or note
    * * when requests came in we could change the NULL below to a valid
    * * handler method in which we could over ride the default
    * * behaviour of the table_dataset helper
    */

    int ret;
    ret=netsnmp_register_table_data_set(netsnmp_create _handler_registration
    ("DryContactTable", NULL,
    my_registration_oid,
    OID_LENGTH(my_registration_oid),
    HANDLER_CAN_RWRITE), table_set, NULL);

    if(ret==0)
    {
    DEBUGMSGTL(("DryContactTable",
    "REGISTRATION SUCCESSS!!!!~####### \n"));
    }
    else
    DEBUGMSGTL(("DryContactTable",
    "REGISTRATION FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));

    DEBUGMSGTL(("DryContactTable",
    "Table registered with the OID which comes under interfaces \n"));

    int i=1;


    for(i=1;i<=10;i++)
    {
    /*
    * 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,
    (char*)&DryContacts_Details[i].dryContact_PortID,
    sizeof(DryContacts_Details[i].dryContact_PortID));
    /*
    * set column 2 to be the WG chair name "Russ Mundy"
    */


    ret= netsnmp_set_row_column(row, 2, ASN_INTEGER, (char*)
    &DryContacts_Details[i].dryContact_PortType,
    sizeof(DryContacts_Details[i].dryContact_PortType));
    netsnmp_mark_row_column_writable(row, 2, 1); /* make writable
    via SETs */
    if(ret==0)
    {
    DEBUGMSGTL(("DryContactTable",
    "Added a element !!!!~####### \n"));
    }
    else
    DEBUGMSGTL(("DryContactTable",
    "Addition FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));
    ret=netsnmp_set_row_column(row, 3, ASN_OCTET_STR,
    &DryContacts_Details[i].drycontact_DisplayString,
    strlen(DryContacts_Details[i].drycontact_DisplayString));
    if(ret==0)
    {
    DEBUGMSGTL(("DryContactTable",
    "Added a element !!!!~####### \n"));
    }
    else
    DEBUGMSGTL(("DryContactTable",
    "Addition FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));
    netsnmp_set_row_column(row, 4, ASN_INTEGER, (char*)
    &DryContacts_Details[i].dryContact_PortValue,
    sizeof(DryContacts_Details[i].dryContact_PortValue));

    }
    //netsnmp_register_auto_data_table(table_set, NULL);

    DEBUGMSGTL(("example_data_set", "Done initializing.\n"));

    /*
    * 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"
    */

    }


    The code is getting compiled and the debug messages are also printed
    saying that the table is registered.But I am getting no such object
    for snmpget and snmpwalk.

    I have used the OID 1.3.6.1.4.43211.7 for tables..

    Please help me solve this basic issue ,
    I have implemented the table directly from datasets .
    Regards,
    Deepak

    -------------------------------------------------------------------------
    This SF.net email is sponsored by: Microsoft
    Defy all challenges. Microsoft(R) Visual Studio 2005.
    http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
    _______________________________________________
    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/...net-snmp-users

  2. Re: Problem with table

    On Nov 16, 9:21 pm, peerlessdeep...@gmail.com ("Deepak Pandian")
    wrote:
    > Hi All,
    >
    > I am trying to implement a table following the dataset.c in example.
    >
    > Below is the code
    >
    > void
    > init_DryContactTable(void)
    > {
    > netsnmp_table_data_set *table_set;
    > netsnmp_table_row *row;
    >
    > /*
    > * the OID we want to register our integer at. This should be the
    > * * OID node for the entire table. In our case this is the
    > * * netSnmpIETFWGTable oid definition
    > */
    >
    > init_values();
    > oid my_registration_oid[] =
    > { 1, 3, 6, 1, 4, 1,4321,7};
    >
    > DEBUGMSGTL(("DryContactTable",
    > "Initalizing example dryContact table\n"));
    >
    > table_set = netsnmp_create_table_data_set("DryContactTable");
    >
    > /*
    > * allow the creation of new rows via SNMP SETs
    > */
    > table_set->allow_creation = 1;
    >
    > /*
    > * set up what a row "should" look like, starting with the index
    > */
    > netsnmp_table_dataset_add_index(table_set, ASN_INTEGER);
    >
    > /*
    > * define what the columns should look like. both are octet strings here
    > */
    > netsnmp_table_set_multi_add_default_row(table_set,
    > //DryContact PortID
    > 2, ASN_INTEGER, 1, NULL, 0,
    > // DryContactPortType
    > 3, ASN_INTEGER, 1, NULL, 0,
    > //DryContactDisplay String
    > 4,ASN_OCTET_STR,1,NULL,0,
    > // DryContactPortValue
    > 5,ASN_INTEGER,1,NULL,0,
    >
    > 0 /* done */ );
    >
    > /*
    > * register the table
    > */
    > /*
    > * if we wanted to handle specific data in a specific way, or note
    > * * when requests came in we could change the NULL below to a valid
    > * * handler method in which we could over ride the default
    > * * behaviour of the table_dataset helper
    > */
    >
    > int ret;
    > ret=netsnmp_register_table_data_set(netsnmp_create _handler_registration
    > ("DryContactTable", NULL,
    > my_registration_oid,
    > OID_LENGTH(my_registration_oid),
    > HANDLER_CAN_RWRITE), table_set, NULL);
    >
    > if(ret==0)
    > {
    > DEBUGMSGTL(("DryContactTable",
    > "REGISTRATION SUCCESSS!!!!~####### \n"));
    > }
    > else
    > DEBUGMSGTL(("DryContactTable",
    > "REGISTRATION FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));
    >
    > DEBUGMSGTL(("DryContactTable",
    > "Table registered with the OID which comes under interfaces \n"));
    >
    > int i=1;
    >
    > for(i=1;i<=10;i++)
    > {
    > /*
    > * 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,
    > (char*)&DryContacts_Details[i].dryContact_PortID,
    > sizeof(DryContacts_Details[i].dryContact_PortID));
    > /*
    > * set column 2 to be the WG chair name "Russ Mundy"
    > */
    >
    > ret= netsnmp_set_row_column(row, 2, ASN_INTEGER, (char*)
    > &DryContacts_Details[i].dryContact_PortType,
    > sizeof(DryContacts_Details[i].dryContact_PortType));
    > netsnmp_mark_row_column_writable(row, 2, 1); /* make writable
    > via SETs */
    > if(ret==0)
    > {
    > DEBUGMSGTL(("DryContactTable",
    > "Added a element !!!!~####### \n"));
    > }
    > else
    > DEBUGMSGTL(("DryContactTable",
    > "Addition FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));
    > ret=netsnmp_set_row_column(row, 3, ASN_OCTET_STR,
    > &DryContacts_Details[i].drycontact_DisplayString,
    > strlen(DryContacts_Details[i].drycontact_DisplayString));
    > if(ret==0)
    > {
    > DEBUGMSGTL(("DryContactTable",
    > "Added a element !!!!~####### \n"));
    > }
    > else
    > DEBUGMSGTL(("DryContactTable",
    > "Addition FAILED @@@@@@@@@@@@@@@@@@@@@@@ \n"));
    > netsnmp_set_row_column(row, 4, ASN_INTEGER, (char*)
    > &DryContacts_Details[i].dryContact_PortValue,
    > sizeof(DryContacts_Details[i].dryContact_PortValue));
    >
    > }
    > //netsnmp_register_auto_data_table(table_set, NULL);
    >
    > DEBUGMSGTL(("example_data_set", "Done initializing.\n"));
    >
    > /*
    > * 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"
    > */
    >
    > }
    >
    > The code is getting compiled and the debug messages are also printed
    > saying that the table is registered.But I am getting no such object
    > for snmpget and snmpwalk.
    >
    > I have used the OID 1.3.6.1.4.43211.7 for tables..
    >
    > Please help me solve this basic issue ,
    > I have implemented the table directly from datasets .
    > Regards,
    > Deepak
    >
    > -------------------------------------------------------------------------
    > This SF.net email is sponsored by: Microsoft
    > Defy all challenges. Microsoft(R) Visual Studio 2005.http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
    > _______________________________________________
    > Net-snmp-users mailing list
    > Net-snmp-us...@lists.sourceforge.net
    > Please see the following page to unsubscribe or change other options:https://lists.sourceforge.net/lists/...net-snmp-users


    Sorry guys! I troubled myself and the group with a silly miss !!!
    (take)

    The bug with the above code is that I missed to add the row to the
    table.
    "
    netsnmp_table_dataset_add_row(table_set, row);
    must be used to do that.

    Thanks for the support

+ Reply to Thread