net-snmp 5.7
Defines | Functions
A generic callback mechanism
The Net-SNMP library

Defines

#define LOCK_PER_CALLBACK_SUBID   1
#define CALLBACK_LOCK(maj, min)   ++_locks[maj][min]
#define CALLBACK_UNLOCK(maj, min)   --_locks[maj][min]
#define CALLBACK_LOCK_COUNT(maj, min)   _locks[maj][min]

Functions

 netsnmp_feature_child_of (callbacks_all, libnetsnmp)
NETSNMP_STATIC_INLINE int _callback_lock (int major, int minor, const char *warn, int do_assert)
NETSNMP_STATIC_INLINE void _callback_unlock (int major, int minor)
void init_callbacks (void)
int snmp_register_callback (int major, int minor, SNMPCallback *new_callback, void *arg)
 This function registers a generic callback function.
int netsnmp_register_callback (int major, int minor, SNMPCallback *new_callback, void *arg, int priority)
 Register a callback function.
int snmp_call_callbacks (int major, int minor, void *caller_arg)
 This function calls the callback function for each registered callback of type major and minor.
int snmp_count_callbacks (int major, int minor)
int snmp_callback_available (int major, int minor)
int snmp_unregister_callback (int major, int minor, SNMPCallback *target, void *arg, int matchargs)
 This function unregisters a specified callback function given a major and minor type.
int netsnmp_callback_clear_client_arg (void *ptr, int i, int j)
 find and clear client args that match ptr
void clear_callback (void)
struct snmp_gen_callbacksnmp_callback_list (int major, int minor)

Function Documentation

int netsnmp_callback_clear_client_arg ( void *  ptr,
int  i,
int  j 
)

find and clear client args that match ptr

Parameters:
ptrpointer to search for
icallback id to start at
jcallback subid to start at

Definition at line 498 of file callback.c.

int netsnmp_register_callback ( int  major,
int  minor,
SNMPCallback *  new_callback,
void *  arg,
int  priority 
)

Register a callback function.

Parameters:
majorMajor callback event type.
minorMinor callback event type.
new_callbackCallback function being registered.
argArgument that will be passed to the callback function. Handler invocation priority. When multiple handlers have been registered for the same (major, minor) callback event type, handlers with the numerically lowest priority will be invoked first. Handlers with identical priority are invoked in the order they have been registered.
See also:
snmp_register_callback

Definition at line 260 of file callback.c.

int snmp_call_callbacks ( int  major,
int  minor,
void *  caller_arg 
)

This function calls the callback function for each registered callback of type major and minor.

Parameters:
majoris the SNMP callback major type used
minoris the SNMP callback minor type used
caller_argis a void pointer which is sent in as the callback's serverarg parameter, if needed.
Returns:
Returns SNMPERR_GENERR if major is >= MAX_CALLBACK_IDS or minor is >= MAX_CALLBACK_SUBIDS, otherwise SNMPERR_SUCCESS is returned.
See also:
snmp_register_callback
snmp_unregister_callback

Definition at line 320 of file callback.c.

int snmp_register_callback ( int  major,
int  minor,
SNMPCallback *  new_callback,
void *  arg 
)

This function registers a generic callback function.

The major and minor values are used to set the new_callback function into a global static multi-dimensional array of type struct snmp_gen_callback. The function makes sure to append this callback function at the end of the link list, snmp_gen_callback->next.

Parameters:
majoris the SNMP callback major type used
  • SNMP_CALLBACK_LIBRARY
  • SNMP_CALLBACK_APPLICATION
Parameters:
minoris the SNMP callback minor type used
  • SNMP_CALLBACK_POST_READ_CONFIG
  • SNMP_CALLBACK_STORE_DATA
  • SNMP_CALLBACK_SHUTDOWN
  • SNMP_CALLBACK_POST_PREMIB_READ_CONFIG
  • SNMP_CALLBACK_LOGGING
  • SNMP_CALLBACK_SESSION_INIT
new_callbackis the callback function that is registered.
argwhen not NULL is a void pointer used whenever new_callback function is exercised. Ownership is transferred to the twodimensional thecallbacks[][] array. The function clear_callback() will deallocate the memory pointed at by calling free().
Returns:
Returns SNMPERR_GENERR if major is >= MAX_CALLBACK_IDS or minor is >= MAX_CALLBACK_SUBIDS or a snmp_gen_callback pointer could not be allocated, otherwise SNMPERR_SUCCESS is returned.
  • #define MAX_CALLBACK_IDS 2
  • #define MAX_CALLBACK_SUBIDS 16
See also:
snmp_call_callbacks
snmp_unregister_callback

Definition at line 238 of file callback.c.

int snmp_unregister_callback ( int  major,
int  minor,
SNMPCallback *  target,
void *  arg,
int  matchargs 
)

This function unregisters a specified callback function given a major and minor type.

Note: no bound checking on major and minor.

Parameters:
majoris the SNMP callback major type used
minoris the SNMP callback minor type used
targetis the callback function that will be unregistered.
argis a void pointer used for comparison against the registered callback's sc_client_arg variable.
matchargsis an integer used to bypass the comparison of arg and the callback's sc_client_arg variable only when matchargs is set to 0.
Returns:
Returns the number of callbacks that were unregistered.
See also:
snmp_register_callback
snmp_call_callbacks

set cleanup flag?

Definition at line 442 of file callback.c.