object_monitor.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**************************************************************************
  2. * object_monitor.h
  3. *
  4. * Contributed by: Robert Story <rstory@freesnmp.com>
  5. *
  6. * $Id$
  7. *
  8. * functions and data structures for cooperating code to monitor objects.
  9. *
  10. * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
  11. * WARNING! WARNING!
  12. * WARNING! WARNING!
  13. * WARNING! This code is under active development WARNING!
  14. * WARNING! and is subject to change at any time. WARNING!
  15. * WARNING! WARNING!
  16. * WARNING! WARNING!
  17. * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
  18. */
  19. #ifndef OBJECT_MONITOR_H
  20. #define OBJECT_MONITOR_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /*
  25. * notification types
  26. */
  27. enum {
  28. /*
  29. * cooperative notification from the object being watched
  30. */
  31. NOTIFICATION_COOPERATIVE = 1,
  32. /*
  33. * notification that an object has been set vi SNMP-SET
  34. */
  35. NOTIFICATION_SET_REQUEST,
  36. /*
  37. * end of current notification types
  38. */
  39. NOTIFICATION_END
  40. };
  41. /*
  42. * COOPERATIVE event types
  43. */
  44. enum {
  45. EVENT_ROW_ADD = 1,
  46. EVENT_ROW_MOD,
  47. EVENT_ROW_DEL,
  48. EVENT_COL_MOD,
  49. EVENT_OBJ_MOD,
  50. EVENT_END
  51. };
  52. /*
  53. * data structures
  54. */
  55. /**
  56. * callback header
  57. */
  58. typedef struct netsnmp_monitor_callback_header_s {
  59. /** callback type */
  60. unsigned int event;
  61. /** registered oid */
  62. netsnmp_index monitored_object;
  63. /** priority */
  64. int priority;
  65. /** pointer given by watcher at registration */
  66. void *watcher_data;
  67. /** pointer passed from the monitored object */
  68. void *object_info;
  69. /** DO NOT USE, INTERNAL USE ONLY */
  70. struct netsnmp_monitor_callback_header_s *private;
  71. int refs;
  72. } netsnmp_monitor_callback_header;
  73. /*
  74. *
  75. */
  76. typedef struct netsnmp_monitor_callback_set_request_s {
  77. /** header */
  78. netsnmp_monitor_callback_header hdr;
  79. /** handler that registered to handle this object */
  80. netsnmp_mib_handler *handler;
  81. /** pdu containing the set request */
  82. netsnmp_pdu *pdu;
  83. /** the set request */
  84. netsnmp_request_info *request;
  85. } netsnmp_monitor_set_request_data;
  86. /*
  87. *
  88. */
  89. typedef struct netsnmp_monitor_callback_cooperative_s {
  90. /** header */
  91. netsnmp_monitor_callback_header hdr;
  92. } netsnmp_monitor_callback_cooperative;
  93. typedef void
  94. (netsnmp_object_monitor_callback) (netsnmp_monitor_callback_header
  95. *);
  96. /**********************************************************************
  97. * Registration function prototypes
  98. */
  99. /*
  100. * Register a callback for the specified object.
  101. */
  102. int netsnmp_monitor_register(oid * object, size_t oid_len,
  103. int priority,
  104. unsigned int events,
  105. void *watcher_data,
  106. netsnmp_object_monitor_callback
  107. * cb);
  108. /*
  109. * Unregister a callback for the specified object.
  110. */
  111. int netsnmp_monitor_unregister(oid * object,
  112. size_t oid_len,
  113. int priority,
  114. void *watcher_data,
  115. netsnmp_object_monitor_callback
  116. * cb);
  117. /*
  118. * check to see if a registration exists for an object/event combination
  119. */
  120. int netsnmp_monitor_check_registered(int event, oid * oid,
  121. int oid_len);
  122. /**********************************************************************
  123. * function prototypes
  124. */
  125. /*
  126. * Notifies the object monitor of an event.
  127. */
  128. void netsnmp_notify_monitor(netsnmp_monitor_callback_header
  129. * cbh);
  130. /**********************************************************************
  131. * function prototypes
  132. */
  133. /*
  134. * Notifies the object monitor of a cooperative event.
  135. */
  136. void netsnmp_notify_cooperative(int event, oid * object,
  137. size_t len, char oid_steal,
  138. void *object_info);
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif /** OBJECT_MONITOR_H */