Re: Problem with table

"Deepak Pandian" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Dear all,

I figured out some bugs in my code .. so please ignore the earlier
mail and consider this 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,4325,2,1};
	   //1.3.6.1.2.1.2.3
		   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,
&DryContacts_Details[i].dryContact_PortID,
									   sizeof(DryContacts_Details[i].dryContact_PortID));
		   netsnmp_mark_row_column_writable(row, 2, 1);

		
		   ret= netsnmp_set_row_column(row, 3, ASN_INTEGER, (char*)
&DryContacts_Details[i].dryContact_PortType,
sizeof(DryContacts_Details[i].dryContact_PortType));
		   netsnmp_mark_row_column_writable(row,3, 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,4, 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, 5, 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"
			*/
		
	   }
	
	



This is the initializations piece of code ; But still I am not able to
access this table elements through snmpget. Can anyone shed light on
the mistake I am making .

Thanks in advance.
Deepak



On Nov 16, 2007 9:51 PM, Deepak Pandian <[email protected]> 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
[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.