Robert Story wrote:

On Thu, 14 Apr 2005 14:17:39 +0200 Christian wrote:
CJ> I am brand new at this (snmp, net-snmp, etc) and I am writing an agent CJ> using the mib2c.mfd.conf generated code-framework (container-cached) CJ> from net-snmp 5.2.1,


Great! Stop by the IRC channel if you want more interactive help. You might
also want to try the latest CVS version. I've been busy improving it. (In that
case, you would also probably want to switch to using mib2c-update, to help
automate merging in changes as I make them.)

CJ> 1) I'm trying to figure out a way to get ahold of the IP-address on CJ> which the snmp-request was received inside my *_cache_load() function CJ> (in *_data_access.c), is this at all possible without altering the snmplib?

Trying to figure out where a packet came from is strongly discouraged. Once a
PDU has been authenticated and accepted, it shouldn't matter where it came
from. If you need different data from different hosts, SNMP contexts is the
right way to do it.

That said, if you really really want to do it, you could probably poke about in
the structures passed to the cache_load wrapper in *_interface.c, and pass the
info to the cache_load routine.


I know it's not really something that one usually wants, but I really need to get ahold of the (local) IP-adress/interface on which the snmp-request was received, where it came from (who requested) is not at all important. The important thing is which of my local interfaces (which IP-address) originally received the request.

I've been looking around in *_interface.c and especially in the _cache_load(netsnmp_cache * cache, void *vmagic) procedure.
But from what I can understand, no such information is available in the netsmp_cache struct. Btw, what is the netsnmp_cache.hint used for?


CJ> 2) I'm also trying to get ahold of the user-context (*_registration_ptr) CJ> from my *_cache_load() function (again in *_data_access.c), can this be CJ> done?
CJ> CJ> If anyone could shine some light on these issues I'd be very greatful! :)


Sure. Just add these simple functions in *_interface.c (they are auto-generated
for you in the CVS versions):

xxxTable_registration *
xxxTable_registration_get(void)
{
   return xxxTable_if_ctx.user_ctx;
}

xxxTable_registration *
xxxTable_registration_set(auditConfigTable_registration * new)
{
   xxxTable_registration *old = xxxTable_if_ctx.user_ctx;
   xxxConfigTable_if_ctx.user_ctx = new;
   return old;
}







------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to