On 30 December 2011 04:54, Mandar Joshi <[email protected]> wrote:
>> But what is the exact code that you are using to register the OID?
>>
>
> This is the code I'm using http://pastebin.com/fRvv0CFX
> The only change I've made from the sample is add a handler which prints out
> the last part of the OID using DEBUGMSGTL

OK - three comments about your handler:

Firstly, it only deals with requests that contain a single varbind.
If the agent receives a request with two or more OIDs, both within
your table, then the second one won't be handled correctly.

You need to wrap the processing block within a loop such as follows:

    switch (reqinfo->mode) {
    case MODE_GET:
    case MODE_GETNEXT:
        for (request=requests; request; request=request->next) {
            row = netsnmp_extract_table_row(request);   // Note change
of variable!

        }


Secondly, if you want to know the index value(s) from the incoming request,
this information is available automatically:

    netsnmp_table_request_info *table_info =
netsnmp_extract_table_info(request);
    DEBUGMSGTL(("DATA_SET_MIB_MODULE","%s\n", table_info->indexes->val.string));


Thirdly, I'm not entirely sure that the GETNEXT case will ever be triggered.
Many of the table helpers know which rows are valid, and will convert
a GETNEXT request into the equivalent GET request, and pass it through
to the MIB-specific handler as such.
   I can't recall whether the data_set helper works this way, but I
wouldn't be at all surprised.

Try it - issue a "snmpgetnext" request for an OID within this table,
and see what index value gets passed into your handler routine.


Dave

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to