snmp_alarm.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef SNMP_ALARM_H
  2. #define SNMP_ALARM_H
  3. /*
  4. * For 'timeval'
  5. */
  6. #ifdef TIME_WITH_SYS_TIME
  7. # include <sys/time.h>
  8. # include <time.h>
  9. #else
  10. # ifdef HAVE_SYS_TIME_H
  11. # include <sys/time.h>
  12. # else
  13. # include <time.h>
  14. # endif
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. typedef void (SNMPAlarmCallback) (unsigned int clientreg,
  20. void *clientarg);
  21. /*
  22. * alarm flags
  23. */
  24. #define SA_REPEAT 0x01 /* keep repeating every X seconds */
  25. #define SA_FIRED 0x10 /* Being processed in run_alarms */
  26. struct snmp_alarm {
  27. /** Alarm interval. Zero if single-shot. */
  28. struct timeval t;
  29. unsigned int flags;
  30. unsigned int clientreg;
  31. /** Last time the alarm fired [monotonic clock]. */
  32. struct timeval t_lastM;
  33. /** Next time the alarm will fire [monotonic clock]. */
  34. struct timeval t_nextM;
  35. void *clientarg;
  36. SNMPAlarmCallback *thecallback;
  37. struct snmp_alarm *next;
  38. };
  39. /*
  40. * the ones you should need
  41. */
  42. NETSNMP_IMPORT
  43. void snmp_alarm_unregister(unsigned int clientreg);
  44. void snmp_alarm_unregister_all(void);
  45. NETSNMP_IMPORT
  46. unsigned int snmp_alarm_register(unsigned int when,
  47. unsigned int flags,
  48. SNMPAlarmCallback * thecallback,
  49. void *clientarg);
  50. unsigned int snmp_alarm_register_hr(struct timeval t,
  51. unsigned int flags,
  52. SNMPAlarmCallback * cb,
  53. void *cd);
  54. NETSNMP_IMPORT
  55. int snmp_alarm_reset(unsigned int clientreg);
  56. /*
  57. * the ones you shouldn't
  58. */
  59. NETSNMP_IMPORT void init_snmp_alarm(void);
  60. int init_alarm_post_config(int majorid, int minorid,
  61. void *serverarg,
  62. void *clientarg);
  63. void sa_update_entry(struct snmp_alarm *alrm);
  64. struct snmp_alarm *sa_find_next(void);
  65. NETSNMP_IMPORT void run_alarms(void);
  66. RETSIGTYPE alarm_handler(int a);
  67. void set_an_alarm(void);
  68. int netsnmp_get_next_alarm_time(struct timeval *alarm_tm,
  69. const struct timeval *now);
  70. int get_next_alarm_delay_time(struct timeval *delta);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* SNMP_ALARM_H */