snmp_client.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * snmp_client.h
  3. */
  4. /***********************************************************
  5. Copyright 1988, 1989 by Carnegie Mellon University
  6. All Rights Reserved
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that the name of CMU not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.
  14. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16. CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20. SOFTWARE.
  21. ******************************************************************/
  22. #ifndef SNMP_CLIENT_H
  23. #define SNMP_CLIENT_H
  24. #include <net-snmp/types.h>
  25. #include <net-snmp/varbind_api.h>
  26. #include <net-snmp/pdu_api.h>
  27. #include <net-snmp/output_api.h>
  28. #include <net-snmp/session_api.h>
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. struct snmp_pdu;
  33. struct snmp_session;
  34. struct variable_list;
  35. struct synch_state {
  36. int waiting;
  37. int status;
  38. /*
  39. * status codes
  40. */
  41. #define STAT_SUCCESS 0
  42. #define STAT_ERROR 1
  43. #define STAT_TIMEOUT 2
  44. int reqid;
  45. netsnmp_pdu *pdu;
  46. };
  47. NETSNMP_IMPORT
  48. void snmp_replace_var_types(netsnmp_variable_list * vbl,
  49. u_char old_type,
  50. u_char new_type);
  51. NETSNMP_IMPORT
  52. void snmp_reset_var_buffers(netsnmp_variable_list * var);
  53. void snmp_reset_var_types(netsnmp_variable_list * vbl,
  54. u_char new_type);
  55. NETSNMP_IMPORT
  56. int count_varbinds(netsnmp_variable_list * var_ptr);
  57. NETSNMP_IMPORT
  58. int count_varbinds_of_type(netsnmp_variable_list * var_ptr,
  59. u_char type);
  60. netsnmp_variable_list *find_varbind_of_type(netsnmp_variable_list *
  61. var_ptr, u_char type);
  62. NETSNMP_IMPORT
  63. netsnmp_variable_list *find_varbind_in_list(netsnmp_variable_list *vblist,
  64. const oid *name, size_t len);
  65. netsnmp_pdu *snmp_split_pdu(netsnmp_pdu *, int skipCount,
  66. int copyCount);
  67. unsigned long snmp_varbind_len(netsnmp_pdu *pdu);
  68. NETSNMP_IMPORT
  69. int snmp_clone_var(netsnmp_variable_list *,
  70. netsnmp_variable_list *);
  71. NETSNMP_IMPORT
  72. int snmp_synch_response_cb(netsnmp_session *,
  73. netsnmp_pdu *, netsnmp_pdu **,
  74. snmp_callback);
  75. NETSNMP_IMPORT
  76. int snmp_clone_mem(void **, const void *, unsigned);
  77. NETSNMP_IMPORT
  78. void netsnmp_query_set_default_session(netsnmp_session *);
  79. NETSNMP_IMPORT
  80. netsnmp_session * netsnmp_query_get_default_session_unchecked( void );
  81. NETSNMP_IMPORT
  82. netsnmp_session * netsnmp_query_get_default_session( void );
  83. NETSNMP_IMPORT
  84. int netsnmp_query_get( netsnmp_variable_list *, netsnmp_session *);
  85. NETSNMP_IMPORT
  86. int netsnmp_query_getnext( netsnmp_variable_list *, netsnmp_session *);
  87. NETSNMP_IMPORT
  88. int netsnmp_query_walk( netsnmp_variable_list *, netsnmp_session *);
  89. #ifndef NETSNMP_NO_WRITE_SUPPORT
  90. NETSNMP_IMPORT
  91. int netsnmp_query_set( netsnmp_variable_list *, netsnmp_session *);
  92. #endif /* !NETSNMP_NO_WRITE_SUPPORT */
  93. /** **************************************************************************
  94. *
  95. * state machine
  96. *
  97. */
  98. /** forward declare */
  99. struct netsnmp_state_machine_step_s;
  100. struct netsnmp_state_machine_input_s;
  101. /** state machine process */
  102. typedef int (netsnmp_state_machine_func)(struct netsnmp_state_machine_input_s *input,
  103. struct netsnmp_state_machine_step_s *step);
  104. typedef struct netsnmp_state_machine_step_s {
  105. const char *name; /* primarily for logging/debugging */
  106. u_int sm_flags;
  107. netsnmp_state_machine_func *run;
  108. int result; /* return code for this step */
  109. struct netsnmp_state_machine_step_s *on_success;
  110. struct netsnmp_state_machine_step_s *on_error;
  111. /*
  112. * user fields (not touched by state machine functions)
  113. */
  114. u_int flags;
  115. void *step_context;
  116. } netsnmp_state_machine_step;
  117. typedef struct netsnmp_state_machine_input_s {
  118. const char *name;
  119. int steps_so_far;
  120. netsnmp_state_machine_step *steps;
  121. netsnmp_state_machine_step *cleanup;
  122. netsnmp_state_machine_step *last_run;
  123. /*
  124. * user fields (not touched by state machine functions)
  125. */
  126. void *input_context;
  127. } netsnmp_state_machine_input;
  128. NETSNMP_IMPORT int
  129. netsnmp_state_machine_run( netsnmp_state_machine_input *input );
  130. NETSNMP_IMPORT int
  131. netsnmp_row_create(netsnmp_session *sess, netsnmp_variable_list *vars,
  132. int row_status_index);
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* SNMP_CLIENT_H */