RE: Table GetNext for next column

"Madan Mohan Goud" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Dave,
	Thanks for your inputs. I changed my handler functions in the
way you explained.

My new 'get_{first,next}_data_point' routines will save a reference to
the per-row data structure in the 'data_context' parameter.  In handler
function I am using the API call 'netsnmp_extract_iterator_context() in
order to retrieve the current entry.


The strange behavior I am seeing is as follows: 
(1) First column it retrieves properly. 
(2) From second column, it jumps to the last index instead of retrieving
values from the list of indices. In the same way it yields value of all
columns indexed for final index. 

Please let me know if something strikes your mind with this kind of
error.

Thanks n advance,
Madan


[root@brcm-india ~]# snmpwalk -c public -v 1 10.240.10.169 ifTable.1
IF-MIB::ifIndex.3 = INTEGER: 6
IF-MIB::ifIndex.6 = INTEGER: 16
IF-MIB::ifIndex.16 = INTEGER: 24
IF-MIB::ifIndex.24 = INTEGER: 27
IF-MIB::ifIndex.27 = INTEGER: 37
IF-MIB::ifIndex.37 = INTEGER: 43
IF-MIB::ifIndex.43 = INTEGER: 50
IF-MIB::ifIndex.50 = INTEGER: 51
IF-MIB::ifIndex.51 = INTEGER: 59
IF-MIB::ifIndex.59 = INTEGER: 67
IF-MIB::ifIndex.67 = INTEGER: 68
IF-MIB::ifIndex.68 = INTEGER: 73
IF-MIB::ifIndex.73 = INTEGER: 83
IF-MIB::ifIndex.83 = INTEGER: 85
IF-MIB::ifIndex.85 = INTEGER: 90
IF-MIB::ifIndex.90 = INTEGER: 96
IF-MIB::ifIndex.96 = INTEGER: 105
IF-MIB::ifIndex.105 = INTEGER: 112
IF-MIB::ifIndex.112 = INTEGER: 115
IF-MIB::ifIndex.115 = INTEGER: 119
IF-MIB::ifIndex.119 = INTEGER: 129
IF-MIB::ifIndex.129 = INTEGER: 132
IF-MIB::ifIndex.132 = INTEGER: 139
IF-MIB::ifIndex.139 = INTEGER: 139
IF-MIB::ifDescr.139 = STRING: value117
IF-MIB::ifType.139 = INTEGER: if-gsn(145)
IF-MIB::ifMtu.139 = INTEGER: 151
IF-MIB::ifSpeed.139 = Gauge32: 109
IF-MIB::ifPhysAddress.139 = STRING: 76:61:6c:75:65:31:33:38
IF-MIB::ifAdminStatus.139 = INTEGER: 109
IF-MIB::ifOperStatus.139 = INTEGER: 137
IF-MIB::ifLastChange.139 = Timeticks: (127) 0:00:01.27
IF-MIB::ifInOctets.139 = Counter32: 125
IF-MIB::ifInUcastPkts.139 = Counter32: 118
IF-MIB::ifInNUcastPkts.139 = Counter32: 122
IF-MIB::ifInDiscards.139 = Counter32: 117
IF-MIB::ifInErrors.139 = Counter32: 150
IF-MIB::ifInUnknownProtos.139 = Counter32: 123
IF-MIB::ifOutOctets.139 = Counter32: 124
IF-MIB::ifOutUcastPkts.139 = Counter32: 119
IF-MIB::ifOutNUcastPkts.139 = Counter32: 119
IF-MIB::ifOutDiscards.139 = Counter32: 127
IF-MIB::ifOutErrors.139 = Counter32: 114
IF-MIB::ifOutQLen.139 = Gauge32: 131

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dave Shield
Sent: Tuesday, July 10, 2007 9:19 PM
To: Madan Mohan Goud
Cc: [email protected]
Subject: Re: Table GetNext for next column

On 10/07/07, Madan Mohan Goud <[email protected]> wrote:
> 1. I am following iterator approach

OK.

So you indicate the end of the column by returning NULL from the
'Get_next_data_point' routine.


> My handler function will take the indexes from the request and
retrieve
> the value corresponding to this instance from application.

The expectation is that your 'get_{first,next}_data_point' routines will
save a reference to the per-row data structure in the 'data_context'
parameter.  The handler function can then retrieve this via the API
call 'netsnmp_extract_iterator_context()'.
   It shouldn't be necessary to interpret the index values again.



> 2. What is the simplest way of sending back the agent that no more
> instances of this object exists?

Return NULL from the 'get_next_data_point' routine.
The handler will only be called if there is another row to report.
Moving on to the next column will be handled internally by the
iterator helper.

>                           I am doing it by setting the type of
> varbind in request to (request->requestvb->type) SNMP_NOSUCHOBJECT.

No - that's wrong.
(And will probably confuse the iterator helper).

It's not even the right exception - the agent would return
'noSuchInstance'
for a GET request of a non-existent row.  'noSuchObject' implies the
column
does not exist at all.

But this is not the way to handle things using the iterator helper.
The handler will be called with things already set up for the
appropriate
row.  Just return the relevant column value, and leave the helper to
handle everything else.

Dave



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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.