Re: Can we extract (agent)IP address for which get/set request is generated in table handler

parveen yadav <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Fulko Hew wrote:
>
> On Tue, May 12, 2009 at 2:23 AM, parveen yadav 
> <[email protected] <mailto:[email protected]>> wrote:
>
>     Fulko Hew wrote:
>>     On Sat, May 9, 2009 at 5:18 AM, parveen yadav
>>     <[email protected] <mailto:[email protected]>>
>>     wrote:
>>
>>         Wes Hardaker wrote:
>>>>>>>>         On Tue, 05 May 2009 14:27:53 +0530, parveen yadav <[email protected]> <mailto:[email protected]> said:
>>>>>>>>                     
>>>         py> I am trying to extract agent IP address for which get/set request is 
>>>         py> generated by snmpget in get_first_data_point,get_next_data_point and 
>>>         py> table handler. I am table iterator for my table.
>>>
>>>         No, you can't.  Though technically possible some of the time it's
>>>         generally not something that you should be doing.  SNMP wasn't designed
>>>         to work that way, and although it's possible it breaks under some
>>>         conditions.  EG, if you ever want to run your code as an AgentX subagent
>>>         that information isn't available at all.
>>>           
>>         But i think we can extract request ip in case net-snmp is
>>         working as main agent and we do not need to handle AgentX.
>>         But it is hard to find the storage location. I have tried
>>         request structure.
>>         Do i need to look some where else also??
>>
>>      
>>     If I understand correctly, then this was something I needed and I
>>     recently
>>     added to the Perl interface for agents, its available in the upcoming
>>     release, but only for IPv4 based requests, and I don't think
>>     it'll work
>>     for AgentX based agents either.
>     thanks for reply
>
>     I have traced packet from snmp_read. But there is still confusion
>     about Ipaddress of request. Can somebody clear the doubt.
>
>
> Can you be more specific?  What are you confused about?
> What  language are you using?
>
> If you are using Perl, your agent code would look something like this:
>
> if (!$agent) {
>     print "The mandatory Perl agent is not defined in this Net-SNMP 
> installation\n";
>     return;
> }
> $agent->register('myprog', '1.2.3.4', \&my_snmp_handler);
>
> sub my_snmp_handler {
>     my ($handler, $registration_info, $request_info, $requests) = @_;
>
>     my $targetIp = inet_ntoa($request_info->getTargetIp());
>     for (my $request = $requests; $request; $request = $request->next()) {
>         handle_oid($targetIp, $request_info, $request);
>     }
> }
>
>
I am using C language agent. There is netsnmp_request_info structure in 
agent. In table handler , through requests list handler finds the 
request to process.
But there is no method like getTargetIp(). It must be perl specific and 
there must be some alternate.
I will try to explore this . This must be looking in request info for Ip.

thanks

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com

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