Many thanks, For pointing me in the right direction.
It took me some time with the debugger to find out where I can get this mysterious (x) - well I did know that it was the reqinfo->mode pointer you explained, but I didn't know how to get it -. Converting my .so to executable, so that I can use the debugger, I discovered amidst a few function pointers, that custom handlers are actually called with 4 arguments. This I discovered no more or less by comparing function addresses to my own handler address: __inline__ static int handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *areqinfo, netsnmp_request_info *reqinfo) Uptill now I thought that it was just an empty variable list (Remember an older mail of mine asking about calling conventions for handlers?). So the required variable is areqinfo->mode. I think it deserves both a FAQ and a wiki spot. I have to leave on a business trip, but when I come back (end of January) I intend to document my experiences with custom handlers. Maybe you can tell me then how best to go about it. BR, Nikos ----- Original Message ----- From: "Wes Hardaker" <[email protected]> To: "Nikos Balkanas" <[email protected]> Cc: <[email protected]> Sent: Monday, January 05, 2009 6:19 PM Subject: Re: netsnmp_create_handler_registration >>>>>> On Sat, 3 Jan 2009 15:33:51 +0200, "Nikos Balkanas" >>>>>> <[email protected]> said: > > NB> During a SET operation the custom handler will be called 4 times, 2 > NB> with old values and 2 with new ones (Reserve1, Reserve2, Action, > NB> Commit). > > The values in the varbinds are always the new ones (IE, the ones from > the SET packet). > > NB> If the same handler is used also for GET operations > NB> (HANDLER_CAN_RWRITE) will be called once only (let's call it > NB> Reserve1). > > It's called GET actually :-) > > NB> How can one distinguish between GET and SET calls? > > The reqinfo->mode variable will be set to one of (snmp_agent.h): > > #define MODE_GET SNMP_MSG_GET > #define MODE_GETNEXT SNMP_MSG_GETNEXT > #define MODE_GETBULK SNMP_MSG_GETBULK > #define MODE_GET_STASH SNMP_MSG_INTERNAL_GET_STASH > > #define MODE_SET_BEGIN SNMP_MSG_INTERNAL_SET_BEGIN > #define MODE_SET_RESERVE1 SNMP_MSG_INTERNAL_SET_RESERVE1 > #define MODE_SET_RESERVE2 SNMP_MSG_INTERNAL_SET_RESERVE2 > #define MODE_SET_ACTION SNMP_MSG_INTERNAL_SET_ACTION > #define MODE_SET_COMMIT SNMP_MSG_INTERNAL_SET_COMMIT > #define MODE_SET_FREE SNMP_MSG_INTERNAL_SET_FREE > #define MODE_SET_UNDO SNMP_MSG_INTERNAL_SET_UNDO > > There is even a MODE_IS_GET(x) macro that tells you if the incoming mode > is a GET type vs a SET type operation. > > > -- > Wes Hardaker > Sparta, Inc. ------------------------------------------------------------------------------ _______________________________________________ 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
