Re: How to get instance from a Request in Table_handler()

Simon Chamlian <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAJTs9Vn7owMv8qeEXQDeXZDNL7xdDwZmWufos40hZReVySgTTQ@mail.gmail.com>
Thanks.

Before seeing you answer, I was doing:

                // Get index
                instance = -1;
                if(table_entry!=NULL) instance = table_entry->xxxx_Index;

                // Validate instance
                if(instance >= SNMP_CFG_NOTIFIED_NMS_MAX || instance < 0)
                {
                    continue;
                }



The problem is to avoid crashing the agent upon a set on wrong instance
(row).

In the  case MODE_SET_ACTION: and case MODE_SET_RESERVE1: what should I do
when the instance is wrong?

                if(instance >= SNMP_CFG_NOTIFIED_NMS_MAX || instance < 0)
                {
                    continue;
                }

OR

                if(instance >= SNMP_CFG_NOTIFIED_NMS_MAX || instance < 0)
                {
                    netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHOBJECT);
                    return SNMP_ERR_NOERROR;
                }


Thanks,
S





On Tue, Mar 20, 2012 at 5:43 AM, Dave Shield <[email protected]>wrote:

> On 16 March 2012 19:39, Simon Chamlian <[email protected]> wrote:
> > In the request handler function:
>
> > How can we get the instance of the request
> > (i.e., the row number of the table) ?
>
> The clean way:
>
>    for (request=requests; request; request=request->next) {
>         table_info = netsnmp_extract_table_info(request);
>        /** table_info->colnum contains the column number requested */
>        /** table_info->indexes contains a linked list of snmp variable
>           bindings for the indexes of the table.  Values in the list
>           have been set corresponding to the indexes of the request */
>        :
>    }
>
>
> The dirty way (relies on the OID being valid and complete,
> and the table being indexed by a single integer)
>
>    for (request=requests; request; request=request->next) {
>         vb = request->requestvb;
>        idx = vb->name[ vb->name_length -1 ];
>        :
>    }
>
>
> Dave
>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________
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.