Dave Shield wrote:
2009/7/14 parveen yadav <parveenya...@coraltele.com>:
As we know we can find first and next index in first and next data_point 
function.

Not quite - the {first,next}_data_point routines are use to step through
each of the rows in the table, providing the index values for each row
in turn.
   They provide information about the actual table.

What you are talking about here is extracting information from the
OID supplied by the client.   This is completely separate from real
table, and may not correspond at all.
   The job of the table helpers (and you haven't bothered to say which
one you are using), is to match these two things together - what the
client is asking for, and what actually exists.

 a listeach of the rows in the table.


I tried to extract this index from OID in table handler.

int get_table_index(netsnmp_table_request_info *table_info.....)

        /**# \b IF Check table info carries valid OID or not */
        if(table_info->indexes->name)

It's been a while since I've looked at the handling of table indexes,
but I'm pretty sure that you should not be using the "name" field here.
The index values are extracted into the *value* field of the "indexes" list.

So
            *index =
   table_info->indexes->name[table_info->indexes->name_length - id];

should probably be something like

               *index = *(table_info->indexes->val.integer);

(assuming this table has a single integer index).
The table helper has already extracted the index value for you.
It's a complete waste of time to repeat this once again.


THIS function works fine for GET request.

Hmmm... that may be a fluke.


But when i tried the same for all cases in set request,
table_info->indexes->name_length always comes out to be 0.
I want to know, does this information is not passed in case of set request
to table handler or i am missing something.

You are missing the point of what the basic table helper does.

Dave

thanks for your quick reply.

{first,next}_data_point are used to find first and next valid index(or data for 
the same).

Table helper is working in background to find handler according to request and call it with valid parameters.

Now i know what i was missing.
i thought this field[netsnmp_vardata val] is for holding actual value to be set.
I have made some changes in get_table_index() to make it work properly.
------>>>>
static int get_table_index(netsnmp_table_request_info *table_info,int MAX_IDX,int *idx_buf)
{
   netsnmp_variable_list *next_idx;
   unsigned char count = 0;
   if(!table_info)
   {
       return -1;
   }

   if(table_info->indexes)
   {
       next_idx = table_info->indexes;
       while(next_idx)
       {
           idx_buf[count] = *(next_idx->val.integer);
           next_idx = next_idx->next_variable;
if(++count >= MAX_IDX) /** this is for special case in my table */
               break;
       }
       if(count)
           return 0;
   }
   return -1;
}

Now its working fine for both set and get requests.

thanks again
PArveen YAdav
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
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