Hi MF,
Thanks for your help.
That's shame I don't really understand how to use your example.
I guess your main point is taht I can get index values in handle_table().
static int
handle_table(netsnmp_mib_handler* handler,
netsnmp_handler_registration* reginfo,
netsnmp_agent_request_info* reqinfo,
netsnmp_request_info* requests)
{
netsnmp_request_info* r;
netsnmp_table_request_info* tri;
netsnmp_variable_list* vl;
for (r = requests; r; r = r->next) {
tri = netsnmp_extract_table_info(r);
if (!tri)
continue;
/* Here *vl contains the ip address and
* *vl->next_variable contains the port
* Note that this only extracts the indices, it is up to you
* to handle getnext requests properly!
*/
}
}
return SNMP_ERR_NOERROR;
}
But before I can get index values, I still need to get all external data for
XXXTable_get_first(next)_data_point to search.
Maybe I misunderstood your suggestion, could you explain more clearly?
Sorry that I am still very new to net-snmp.
Thanks in advance.
BR,
永鈦鑫 iTAS Corporation
新竹市水源街75號
NO. 75,Shuiyuan St., Hsinchu City, Taiwan, R.O.C.
Tel:03-5716099 Ext.1208
E-mail:[email protected]
----- Original Message -----
From: "Magnus Fromreide" <[email protected]>
To: "Tewen Hsieh" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, June 10, 2009 4:51 AM
Subject: Re: Could anyone give me some suggestions?
> On Mon, 2009-06-08 at 19:10 +0800, Tewen Hsieh wrote:
>>
>> Hi,
>>
>> Thanks for your help.
>>
>> But I can't understand your suggestion. Could you explain more
>> clearly? Thanks.
>>
>> I want to get the the index *values*, not to know the indices a table
>> used.
>> For example, in XXX table there are two indices including ip address
>> and port number.
>> When I send a request 1.3.6.1.4.192.168.100.100.33 to agent, how can I
>> get index values (ip address = 192.168.100.100, port num = 33) in the
>> template code generated from mib2c.iterate_access.conf?
>>
>> Do you have any idea about this?
>
> As Dave says there is no helper for this.
>
> This code is part of a test program I have (the module is named indexes,
> you may wish to do a search and replace to change the name to something
> better, also you might have to remove some const's as I tend to add them
> generously and the old code might fail to handle all the ones that I
> use).
>
> static int
> handle_table(netsnmp_mib_handler* handler,
> netsnmp_handler_registration* reginfo,
> netsnmp_agent_request_info* reqinfo,
> netsnmp_request_info* requests)
> {
> netsnmp_request_info* r;
> netsnmp_table_request_info* tri;
> netsnmp_variable_list* vl;
>
> for (r = requests; r; r = r->next) {
> tri = netsnmp_extract_table_info(r);
> if (!tri)
> continue;
> /* Here *vl contains the ip address and
> * *vl->next_variable contains the port
> * Note that this only extracts the indices, it is up to you
> * to handle getnext requests properly!
> */
> }
> }
> return SNMP_ERR_NOERROR;
> }
>
> static const oid indexes_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 9999, 9999,
> 4711 };
>
> void
> init_indexes(void)
> {
> netsnmp_handler_registration *reg =
> netsnmp_create_handler_registration(
> "indexes", handle_table,
> indexes_oid, OID_LENGTH(indexes_oid),
> HANDLER_CAN_RONLY);
> netsnmp_table_registration_info *table_info =
> SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
> netsnmp_table_helper_add_indexes(
> table_info,
> ASN_IPADDRESS, ASN_INTEGER,
> 0);
> table_info->min_column = 2; /* adopt this to your situation */
> table_info->max_column = 2;
> netsnmp_register_table(reg, table_info);
> }
>
> void
> shutdown_indexes(void)
> {
> unregister_mib(indexes_oid, OID_LENGTH(indexes_oid));
> }
>
> /* since you are using an old version of the agent you might wish to
> * add this function
> */
> void deinit_indexes(void) { shutdown_indexes(); }
>
>
>>
>>
>> 永鈦鑫 iTAS Corporation
>> 新竹市水源街75號
>> NO. 75,Shuiyuan St., Hsinchu City, Taiwan, R.O.C.
>> Tel:03-5716099 Ext.1208
>> E-mail:[email protected]
>> ----- Original Message -----
>> From: Amol Anil Malokar
>> To: Tewen Hsieh
>> Sent: Monday, June 08, 2009 6:41 PM
>> Subject: RE: Could anyone give me some suggestions?
>>
>>
>> hi ,
>>
>> check with data structure ;
>>
>> "netsnmp_table_registration_info"
>>
>>
>>
>>
>> ______________________________________________________________
>> From: Tewen Hsieh [mailto:[email protected]]
>> Sent: Mon 6/8/2009 3:55 PM
>> To: [email protected]
>> Subject: Could anyone give me some suggestions?
>>
>>
>> Hi all,
>>
>> I used "mib2c.iterate_access.conf" to generate my template
>> code for XXX table.
>> In XXXTable_get_first_data_point(), I use
>> XXXTable_createStructure() to get external data and store them
>> in a local structure when this table is accessed at the first
>> time. (The external data are all PHY register values.)
>> So the agent can response very fast after the first request.
>> But the external data I must get at the first time is very
>> huge, the agent always timeouts when it still works in
>> XXXTable_createStructure() to get external data.
>> Could anyone give me some suggestions about resolving this
>> condition?
>>
>> I also tried to not get all external data, but I don't know
>> how to get the index value of the incoming request in
>> XXXTable_get_first_data_point().
>> Could anyone help me to know where can get the index valuse of
>> the incoming request in template code that are generated from
>> "mib2c.iterate_acc.conf".
>>
>>
>> Thanks in advance.
>>
>>
>>
>> BR,
>>
>>
>>
>>
>>
>>
>>
>> 永鈦鑫 iTAS Corporation
>> 新竹市水源街75號
>> NO. 75,Shuiyuan St., Hsinchu City, Taiwan, R.O.C.
>> Tel:03-5716099 Ext.1208
>> E-mail:[email protected]
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive
>> use of the addressee(s) and may contain proprietary, confidential
>> or privileged information. If you are not the intended
>> recipient, you should not disseminate, distribute or copy this
>> e-mail. Please notify the sender immediately and destroy
>> all copies of this message and any attachments contained in it.
>>
>> ------------------------------------------------------------------------------
>> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
>> looking to deploy the next generation of Solaris that includes the latest
>> innovations from Sun and the OpenSource community. Download a copy and
>> enjoy capabilities such as Networking, Storage and Virtualization.
>> Go to: http://p.sf.net/sfu/opensolaris-get
>> _______________________________________________ Net-snmp-coders mailing
>> list [email protected]
>> https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
>
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders