---
name: "init_snmp_alarm"
section: "3snmp"
platform: "linux"
package: "libsnmp4.2-dev"
version: "4.2.5-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://carta.tech/man/snmp_alarm/3snmp"
---

# init\_snmp\_alarm(3snmp)

alarm functions

Part of [snmp\_alarm(3snmp)](/man/snmp_alarm/3snmp.md).

## NAME

snmp\_alarm\_register, snmp\_alarm\_unregister, init\_snmp\_alarm, 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)](/man/snmp_api/3.md)
