agent_registry.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #ifndef AGENT_REGISTRY_H
  2. #define AGENT_REGISTRY_H
  3. /***********************************************************************/
  4. /*
  5. * new version2 agent handler API structures
  6. */
  7. /***********************************************************************/
  8. #include <net-snmp/agent/snmp_agent.h>
  9. #include <net-snmp/library/fd_event_manager.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /***********************************************************************/
  14. /*
  15. * requests api definitions
  16. */
  17. /***********************************************************************/
  18. /*
  19. * the structure of parameters passed to registered ACM modules
  20. */
  21. struct view_parameters {
  22. netsnmp_pdu *pdu;
  23. oid *name;
  24. size_t namelen;
  25. int test;
  26. int errorcode; /* Do not change unless you're
  27. specifying an error, as it starts
  28. in a success state. */
  29. int check_subtree;
  30. };
  31. struct register_parameters {
  32. oid *name;
  33. size_t namelen;
  34. int priority;
  35. int range_subid;
  36. oid range_ubound;
  37. int timeout;
  38. u_char flags;
  39. const char *contextName;
  40. netsnmp_session *session;
  41. netsnmp_handler_registration *reginfo;
  42. };
  43. typedef struct subtree_context_cache_s {
  44. const char *context_name;
  45. struct netsnmp_subtree_s *first_subtree;
  46. struct subtree_context_cache_s *next;
  47. } subtree_context_cache;
  48. void setup_tree (void);
  49. void shutdown_tree (void);
  50. void dump_registry(void);
  51. netsnmp_subtree *netsnmp_subtree_find (const oid *, size_t,
  52. netsnmp_subtree *,
  53. const char *context_name);
  54. netsnmp_subtree *netsnmp_subtree_find_next(const oid *, size_t,
  55. netsnmp_subtree *,
  56. const char *context_name);
  57. netsnmp_subtree *netsnmp_subtree_find_prev(const oid *, size_t,
  58. netsnmp_subtree *,
  59. const char *context_name);
  60. netsnmp_subtree *netsnmp_subtree_find_first(const char *context_name);
  61. netsnmp_session *get_session_for_oid (const oid *, size_t,
  62. const char *context_name);
  63. subtree_context_cache *get_top_context_cache(void);
  64. void netsnmp_set_lookup_cache_size(int newsize);
  65. int netsnmp_get_lookup_cache_size(void);
  66. #define MIB_REGISTERED_OK 0
  67. #define MIB_DUPLICATE_REGISTRATION -1
  68. #define MIB_REGISTRATION_FAILED -2
  69. #define MIB_UNREGISTERED_OK 0
  70. #define MIB_NO_SUCH_REGISTRATION -1
  71. #define MIB_UNREGISTRATION_FAILED -2
  72. #define DEFAULT_MIB_PRIORITY 127
  73. int register_mib (const char *,
  74. const struct variable *,
  75. size_t, size_t, const oid *,
  76. size_t);
  77. int register_mib_priority (const char *,
  78. const struct variable *,
  79. size_t, size_t, const oid *, size_t,
  80. int);
  81. int register_mib_range (const char *,
  82. const struct variable *,
  83. size_t, size_t, const oid *,
  84. size_t, int, int, oid,
  85. netsnmp_session *);
  86. int register_mib_context (const char *,
  87. const struct variable *,
  88. size_t, size_t, const oid *, size_t,
  89. int, int, oid, netsnmp_session *,
  90. const char *, int, int);
  91. int netsnmp_register_mib_table_row (const char *,
  92. const struct variable *,
  93. size_t, size_t, oid *,
  94. size_t, int, int, netsnmp_session *,
  95. const char *, int, int);
  96. int unregister_mib (oid *, size_t);
  97. int unregister_mib_priority (oid *, size_t, int);
  98. int unregister_mib_range (oid *, size_t, int, int, oid);
  99. int unregister_mib_context (oid *, size_t, int, int, oid,
  100. const char *);
  101. void clear_context (void);
  102. void unregister_mibs_by_session (netsnmp_session *);
  103. int netsnmp_unregister_mib_table_row (oid *mibloc, size_t mibloclen,
  104. int priority, int var_subid,
  105. oid range_ubound,
  106. const char *context);
  107. int compare_tree (const oid *, size_t,
  108. const oid *, size_t);
  109. int in_a_view (oid *, size_t *,
  110. netsnmp_pdu *, int);
  111. int check_access (netsnmp_pdu *pdu);
  112. int netsnmp_acm_check_subtree (netsnmp_pdu *, oid *, size_t);
  113. void register_mib_reattach (void);
  114. void register_mib_detach (void);
  115. /*
  116. * REGISTER_MIB(): This macro simply loads register_mib with less pain:
  117. *
  118. * descr: A short description of the mib group being loaded.
  119. * var: The variable structure to load.
  120. * vartype: The variable structure used to define it (variable[2, 4, ...])
  121. * theoid: An *initialized* *exact length* oid pointer.
  122. * (sizeof(theoid) *must* return the number of elements!)
  123. */
  124. #define REGISTER_MIB(descr, var, vartype, theoid) \
  125. if (register_mib(descr, (const struct variable *) var, \
  126. sizeof(struct vartype), \
  127. sizeof(var)/sizeof(struct vartype), \
  128. theoid, sizeof(theoid)/sizeof(oid)) != \
  129. MIB_REGISTERED_OK) \
  130. DEBUGMSGTL(("register_mib", "%s registration failed\n", descr));
  131. #define NUM_EXTERNAL_SIGS 32
  132. #define SIG_REGISTERED_OK 0
  133. #define SIG_REGISTRATION_FAILED -2
  134. #define SIG_UNREGISTERED_OK 0
  135. extern int external_signal_scheduled[NUM_EXTERNAL_SIGS];
  136. extern void (*external_signal_handler[NUM_EXTERNAL_SIGS])(int);
  137. int register_signal(int, void (*func)(int));
  138. int unregister_signal(int);
  139. /*
  140. * internal API. Don't use this. Use netsnmp_register_handler instead
  141. */
  142. struct netsnmp_handler_registration_s;
  143. int netsnmp_register_mib(const char *, struct variable *,
  144. size_t, size_t, oid *, size_t,
  145. int, int, oid, netsnmp_session *,
  146. const char *, int, int,
  147. struct netsnmp_handler_registration_s *,
  148. int);
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif /* AGENT_REGISTRY_H */