I have a problem controlling notificaton/traps generation. I used
net-snmp example 

notification.c  and I am getting this odd behavior. I use
snmp_alarm_register() 

to execute my function check_send_trap() every 5sec. check_send_trap()
monitors variable trapFlag 

to decide whether to generate a trap. trapFlag is set by an api function
when I want to 

send a trap.  When I change the value of TrapFlag from the api,
check_send_trap() 

apparently does not see the value of TrapFlag change ??? If I set
TrapFlag initially 

the trap is sent every 5s continually. If I clear TrapFlag initially no
traps get sent.

I can see TrapFlag  change when I call my api function, but
check_send_trap() never 

sees the value of TrapFlag change, and this is the same variable!!!

I tried referencing TrapFlag directly in check_send_trap(),also tried
using 

the callback data in the snmp_alarm_register() call to save a pointer to
TrapFlag. Neither

approach works, its like check_send_trap() is looking at a different
variable???. 

Can you help me as I have spent 2 days trying to figure out what I am
doing wrong? 

I have everything else (get, set,etc.) working and I thought traps would
easy!!

I am running Net-snmp v5.1.1 on montavista linux. 

This is my code in case you can spot anything I am doing wrong:

 

1. INIT notification function called by net-snmp:-

void init_notification(void)

{

    DEBUGMSGTL(("example_notification",

                "initializing (setting callback alarm)\n"));

            init_snmp_alarmtraps();

}

 

2. SETUP ALARM TO SEND TRAP EVERY 5s:

void init_snmp_alarmtraps(void)

{

// run check_send_trap() every 5 seconds

    snmp_alarm_register(5,     /* seconds */

                        SA_REPEAT,         /* repeat (every 5 seconds).
*/

                                    check_send_trap,

                        &trapFlag /*  callback data needed */

//                      NULL    /* no callback data needed */

        );

}

 

3. CALLBACK FUNCTION check_send_trap:-

void check_send_trap(unsigned int clientreg, void *clientarg)

{

            //decide to send a trap based on value of TrapFlag

            int sendTrap;

            //Get TrapFlag value from clientarg - also tried referencing
TrapFlag directly

            sendTrap=*(int*)clientarg;

 

    printf("\ncheck_send_trap, sendTrap=%d\n",sendTrap);fflush(stdout);

            if (sendTrap)

            {

                        send_alarmTrap_trap(clientreg,clientarg);

            }

}

 

Note: send_alarmTrap_trap() code from notification.c net-snmp example,
works OK

 

Thanks in advance,

 

Clive 

[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 

 

 

 

------------------------------------------------------------------------------------------------
This message is for the designated recipient only and may
contain privileged, proprietary, or otherwise private information.  
If you have received it in error, please notify the sender
immediately and delete the original.  Any unauthorized use of
this email is prohibited.
------------------------------------------------------------------------------------------------
[mf2]
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
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