watcher.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * watcher.h
  3. */
  4. #ifndef NETSNMP_WATCHER_H
  5. #define NETSNMP_WATCHER_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /** @ingroup watcher
  10. * @{
  11. */
  12. /*
  13. * if handler flag has this bit set, the timestamp will be
  14. * treated as a pointer to the timestamp. If this bit is
  15. * not set (the default), the timestamp is a struct timeval
  16. * that must be compared to the agent starttime.
  17. */
  18. #define NETSNMP_WATCHER_DIRECT MIB_HANDLER_CUSTOM1
  19. /** The size of the watched object is constant.
  20. * @hideinitializer
  21. */
  22. #define WATCHER_FIXED_SIZE 0x01
  23. /** The maximum size of the watched object is stored in max_size.
  24. * If WATCHER_SIZE_STRLEN is set then it is supposed that max_size + 1
  25. * bytes could be stored in the buffer.
  26. * @hideinitializer
  27. */
  28. #define WATCHER_MAX_SIZE 0x02
  29. /** If set then the variable data_size_p points to is supposed to hold the
  30. * current size of the watched object and will be updated on writes.
  31. * @hideinitializer
  32. * @since Net-SNMP 5.5
  33. */
  34. #define WATCHER_SIZE_IS_PTR 0x04
  35. /** If set then data is suppposed to be a zero-terminated character array
  36. * and both data_size and data_size_p are ignored. Additionally \\0 is a
  37. * forbidden character in the data set.
  38. * @hideinitializer
  39. * @since Net-SNMP 5.5
  40. */
  41. #define WATCHER_SIZE_STRLEN 0x08
  42. /** If set then size is in units of object identifiers.
  43. * This is useful if you have an OID and tracks the OID_LENGTH of it as
  44. * opposed to it's size.
  45. * @hideinitializer
  46. * @since Net-SNMP 5.5.1
  47. */
  48. #define WATCHER_SIZE_UNIT_OIDS 0x10
  49. typedef struct netsnmp_watcher_info_s {
  50. void *data;
  51. size_t data_size;
  52. size_t max_size;
  53. u_char type;
  54. int flags;
  55. size_t *data_size_p;
  56. } netsnmp_watcher_info;
  57. /** @} */
  58. int netsnmp_register_watched_instance( netsnmp_handler_registration *reginfo,
  59. netsnmp_watcher_info *winfo);
  60. int netsnmp_register_watched_instance2(netsnmp_handler_registration *reginfo,
  61. netsnmp_watcher_info *winfo);
  62. int netsnmp_register_watched_scalar( netsnmp_handler_registration *reginfo,
  63. netsnmp_watcher_info *winfo);
  64. int netsnmp_register_watched_scalar2( netsnmp_handler_registration *reginfo,
  65. netsnmp_watcher_info *winfo);
  66. int netsnmp_register_watched_timestamp(netsnmp_handler_registration *reginfo,
  67. marker_t timestamp);
  68. int netsnmp_watched_timestamp_register(netsnmp_mib_handler *whandler,
  69. netsnmp_handler_registration *reginfo,
  70. marker_t timestamp);
  71. int netsnmp_register_watched_spinlock(netsnmp_handler_registration *reginfo,
  72. int *spinlock);
  73. /*
  74. * Convenience registration calls
  75. */
  76. int netsnmp_register_ulong_scalar(const char *name,
  77. const oid * reg_oid, size_t reg_oid_len,
  78. u_long * it,
  79. Netsnmp_Node_Handler * subhandler);
  80. int netsnmp_register_read_only_ulong_scalar(const char *name,
  81. const oid * reg_oid, size_t reg_oid_len,
  82. u_long * it,
  83. Netsnmp_Node_Handler * subhandler);
  84. int netsnmp_register_long_scalar(const char *name,
  85. const oid * reg_oid, size_t reg_oid_len,
  86. long * it,
  87. Netsnmp_Node_Handler * subhandler);
  88. int netsnmp_register_read_only_long_scalar(const char *name,
  89. const oid * reg_oid, size_t reg_oid_len,
  90. long * it,
  91. Netsnmp_Node_Handler * subhandler);
  92. int netsnmp_register_int_scalar(const char *name,
  93. const oid * reg_oid, size_t reg_oid_len,
  94. int * it,
  95. Netsnmp_Node_Handler * subhandler);
  96. int netsnmp_register_read_only_int_scalar(const char *name,
  97. const oid * reg_oid, size_t reg_oid_len,
  98. int * it,
  99. Netsnmp_Node_Handler * subhandler);
  100. int netsnmp_register_read_only_counter32_scalar(const char *name,
  101. const oid * reg_oid, size_t reg_oid_len,
  102. u_long * it,
  103. Netsnmp_Node_Handler * subhandler);
  104. #define WATCHER_HANDLER_NAME "watcher"
  105. netsnmp_mib_handler *netsnmp_get_watcher_handler(void);
  106. netsnmp_watcher_info *
  107. netsnmp_init_watcher_info(netsnmp_watcher_info *, void *, size_t, u_char, int);
  108. netsnmp_watcher_info *
  109. netsnmp_init_watcher_info6(netsnmp_watcher_info *,
  110. void *, size_t, u_char, int, size_t, size_t*);
  111. netsnmp_watcher_info *
  112. netsnmp_create_watcher_info(void *, size_t, u_char, int);
  113. netsnmp_watcher_info *
  114. netsnmp_create_watcher_info6(void *, size_t, u_char, int, size_t, size_t*);
  115. netsnmp_watcher_info *
  116. netsnmp_clone_watcher_info(netsnmp_watcher_info *winfo);
  117. void
  118. netsnmp_owns_watcher_info(netsnmp_mib_handler *handler);
  119. Netsnmp_Node_Handler netsnmp_watcher_helper_handler;
  120. netsnmp_mib_handler *netsnmp_get_watched_timestamp_handler(void);
  121. Netsnmp_Node_Handler netsnmp_watched_timestamp_handler;
  122. netsnmp_mib_handler *netsnmp_get_watched_spinlock_handler(void);
  123. Netsnmp_Node_Handler netsnmp_watched_spinlock_handler;
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif /** NETSNMP_WATCHER_H */