callback.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * callback.c: A generic callback mechanism
  3. */
  4. #ifndef CALLBACK_H
  5. #define CALLBACK_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define MAX_CALLBACK_IDS 2
  10. #define MAX_CALLBACK_SUBIDS 17
  11. /*
  12. * Callback Major Types
  13. */
  14. #define SNMP_CALLBACK_LIBRARY 0
  15. #define SNMP_CALLBACK_APPLICATION 1
  16. /*
  17. * SNMP_CALLBACK_LIBRARY minor types
  18. */
  19. #define SNMP_CALLBACK_POST_READ_CONFIG 0
  20. #define SNMP_CALLBACK_STORE_DATA 1
  21. #define SNMP_CALLBACK_SHUTDOWN 2
  22. #define SNMP_CALLBACK_POST_PREMIB_READ_CONFIG 3
  23. #define SNMP_CALLBACK_LOGGING 4
  24. #define SNMP_CALLBACK_SESSION_INIT 5
  25. #define SNMP_CALLBACK_PRE_READ_CONFIG 7
  26. #define SNMP_CALLBACK_PRE_PREMIB_READ_CONFIG 8
  27. /*
  28. * Callback priority (lower priority numbers called first(
  29. */
  30. #define NETSNMP_CALLBACK_HIGHEST_PRIORITY -1024
  31. #define NETSNMP_CALLBACK_DEFAULT_PRIORITY 0
  32. #define NETSNMP_CALLBACK_LOWEST_PRIORITY 1024
  33. typedef int (SNMPCallback) (int majorID, int minorID,
  34. void *serverarg, void *clientarg);
  35. struct snmp_gen_callback {
  36. SNMPCallback *sc_callback;
  37. void *sc_client_arg;
  38. int priority;
  39. struct snmp_gen_callback *next;
  40. };
  41. /*
  42. * function prototypes
  43. */
  44. NETSNMP_IMPORT
  45. void init_callbacks(void);
  46. NETSNMP_IMPORT
  47. int netsnmp_register_callback(int major, int minor,
  48. SNMPCallback * new_callback,
  49. void *arg, int priority);
  50. NETSNMP_IMPORT
  51. int snmp_register_callback(int major, int minor,
  52. SNMPCallback * new_callback,
  53. void *arg);
  54. NETSNMP_IMPORT
  55. int snmp_call_callbacks(int major, int minor,
  56. void *caller_arg);
  57. NETSNMP_IMPORT
  58. int snmp_callback_available(int major, int minor); /* is >1 available */
  59. NETSNMP_IMPORT
  60. int snmp_count_callbacks(int major, int minor); /* ret the number registered */
  61. NETSNMP_IMPORT
  62. int snmp_unregister_callback(int major, int minor,
  63. SNMPCallback * new_callback,
  64. void *arg, int matchargs);
  65. NETSNMP_IMPORT
  66. void clear_callback (void);
  67. int netsnmp_callback_clear_client_arg(void *, int i, int j);
  68. struct snmp_gen_callback *snmp_callback_list(int major, int minor);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /* CALLBACK_H */