Re: MAC Address As Index

Bill Fenner <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <CAF4SogZV4LNA3J6sYZ6WFVOQZQFwM2a5j0EjHKYGqvzZkXo1Hw@mail.gmail.com>
On Tue, Sep 17, 2019 at 4:27 AM Krishna Chaitanya <[email protected]>
wrote:

> On Tue, Sep 17, 2019 at 5:18 AM Bill Fenner <[email protected]> wrote:
> >
> > You can do this if you use snmp_varlist_add_variable() to create the
> index info (you can't use netsnmp_table_helper_add_indexes).  The code
> would be something like
> >
> >     table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
> >     snmp_varlist_add_variable(&table_info->indexes,
> >                                   NULL,
> >                                   0,
> >                                   ASN_TYPE_OF_IFACE_NAME,
> >                                   NULL,
> >                                   0);
> >     snmp_varlist_add_variable(&table_info->indexes,
> >                                   NULL,
> >                                   0,
> >                                   ASN_IMPLIED_OCTET_STR,
> >                                   "XXXXXX",
> >                                   6);
> >     snmp_varlist_add_variable(&table_info->indexes,
> >                                   NULL,
> >                                   0,
> >                                   ASN_TYPE_OF_HIST_CLASS,
> >                                   NULL,
> >                                   0);
> >     snmp_varlist_add_variable(&table_info->indexes,
> >                                   NULL,
> >                                   0,
> >                                   ASN_TYPE_OF_HISTBIN_INDEX,
> >                                   NULL,
> >                                   0);
> >
> Thanks, Bill. I was using  "netsnmp_table_set_add_indexes" for the
> initial addition (don't have access to index_data but only type),
>

You should be able to replace "table_info" above by "tset->table" and add
the 4 calls to snmp_varlist_add_variable in place of the call to
"netsnmp_table_set_add_indexes".

and then when the data is available I either use
> "netsnmp_table_dataset_replace_row/netsnmp_table_dataset_add_row"
> using the API "netsnmp_table_row_add_index" for index.
>

This will continue to work.  The real difference is setting vp->val_len in
the indexes that you supply when you're registering the table.  For most
types this is not relevant but for the ASN_PRIV_IMPLIED types if you do not
set the length, as you saw it will consume the whole rest of the data and
not parse the indexes from the OID after that.

  Bill

_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
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.