SNMP_ALARM

NAME
SYNOPSIS
DESCRIPTION
USAGE
INITIALIZATION
NOTES
SEE ALSO

NAME

snmp_alarm_register, snmp_alarm_unregister, init_snmp_alarm, int init_alarm_post_config - alarm functions

SYNOPSIS

#include <snmp_alarm.h>

unsigned int
snmp_alarm_register(unsigned int seconds,
unsigned int flags,
SNMPAlarmCallback *thecallback,
void *clientarg)

void
snmp_alarm_unregister(unsigned int registrationNumber)

void
init_snmp_alarm(void)

void
init_alarm_post_config(0,0,NULL,NULL);

DESCRIPTION

These functions implement support for a generic timer handling mechanism for multiple parts of an application to register function callbacks to happen at a particular time in the future.

USAGE

The usage is fairly simple and straight-forward: Simply create a function you want called back at some point in the future. The function definition should be similar to:

void my_callback_func(unsigned int registrationNumber, void *clientarg);

Then, call snmp_alarm_register() to register your callback to be called seconds from now. The flags field should either be SA_REPEAT or NULL. If flags is set with SA_REPEAT, then the registered callback function will be called every seconds. If the SA_REPEAT flag is not set, then the function will only be called once and removed from the alarm system registration.

The clientarg parameter in the registration function is used only be th client function and is stored and passed back directly to them on every call to the system.

The snmp_alarm_register() function returns a unique unsigned int (which is also passed to the callback function on each call), which can then be used to remove the callback from the queue at a later point in the future using the snmp_alarm_unregister() function. If the snmp_alarm_register() call fails it returns zero.

INITIALIZATION

The init_snmp_alarm() function initializes the routines, but a call to init_alarm_post_config() should be called even later and sets up the first timer to initialize the callback function. These two functions should not be used directly by applications, but are instead used by the init_snmp() function which you should call instead.

NOTES

Internally, the snmp_alarm system uses the SIGALRM signal and therefore no other part of the application should be using the regular system based alarm() function.

SEE ALSO

snmp_api(3)