A generic callback mechanism(3)

NAME
A generic callback mechanism -

  Functions
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)
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.
void clear_callback (void)
snmp_gen_callback * snmp_callback_list (int major, int minor)

Function Documentation

  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:
    major is the SNMP callback major type used
    minor is the SNMP callback minor type used
    caller_arg is 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 182 of file callback.c.

References snmp_log().

Referenced by netsnmp_acm_check_subtree(), netsnmp_register_mib_table_row(), snmp_shutdown(), and unregister_mib_context().

  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:
    major is the SNMP callback major type used

    •   SNMP_CALLBACK_LIBRARY

    •   SNMP_CALLBACK_APPLICATION

    minor is 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_callback is the callback function that is registered.
    arg when not NULL is a void pointer used whenever new_callback function is exercised.

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 115 of file callback.c.

Referenced by netsnmp_register_save_list().

  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:
    major is the SNMP callback major type used
    minor is the SNMP callback minor type used
    target is the callback function that will be unregistered.
    arg is a void pointer used for comparison against the registered callback's sc_client_arg variable.
    matchargs is 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 295 of file callback.c.

References SNMP_FREE, and snmp_log().