net-snmp 5.7
snmp_client.h
00001 /*
00002  * snmp_client.h
00003  */
00004 /***********************************************************
00005         Copyright 1988, 1989 by Carnegie Mellon University
00006 
00007                       All Rights Reserved
00008 
00009 Permission to use, copy, modify, and distribute this software and its 
00010 documentation for any purpose and without fee is hereby granted, 
00011 provided that the above copyright notice appear in all copies and that
00012 both that copyright notice and this permission notice appear in 
00013 supporting documentation, and that the name of CMU not be
00014 used in advertising or publicity pertaining to distribution of the
00015 software without specific, written prior permission.  
00016 
00017 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00018 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00019 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00020 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00021 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00022 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00023 SOFTWARE.
00024 ******************************************************************/
00025 
00026 #ifndef SNMP_CLIENT_H
00027 #define SNMP_CLIENT_H
00028 
00029 #include <net-snmp/types.h>
00030 #include <net-snmp/varbind_api.h>
00031 #include <net-snmp/pdu_api.h>
00032 #include <net-snmp/output_api.h>
00033 #include <net-snmp/session_api.h>
00034 
00035 #ifdef __cplusplus
00036 extern          "C" {
00037 #endif
00038 
00039 
00040     struct snmp_pdu;
00041     struct snmp_session;
00042     struct variable_list;
00043 
00044     struct synch_state {
00045         int             waiting;
00046         int             status;
00047         /*
00048          * status codes 
00049          */
00050 #define STAT_SUCCESS    0
00051 #define STAT_ERROR      1
00052 #define STAT_TIMEOUT 2
00053         int             reqid;
00054         netsnmp_pdu    *pdu;
00055     };
00056 
00057     NETSNMP_IMPORT
00058     void            snmp_replace_var_types(netsnmp_variable_list * vbl,
00059                                            u_char old_type,
00060                                            u_char new_type);
00061     NETSNMP_IMPORT
00062     void            snmp_reset_var_buffers(netsnmp_variable_list * var);
00063     void            snmp_reset_var_types(netsnmp_variable_list * vbl,
00064                                          u_char new_type);
00065     NETSNMP_IMPORT
00066     int             count_varbinds(netsnmp_variable_list * var_ptr);
00067     NETSNMP_IMPORT
00068     int             count_varbinds_of_type(netsnmp_variable_list * var_ptr,
00069                                            u_char type);
00070     netsnmp_variable_list *find_varbind_of_type(netsnmp_variable_list *
00071                                                 var_ptr, u_char type);
00072     NETSNMP_IMPORT
00073     netsnmp_variable_list *find_varbind_in_list(netsnmp_variable_list *vblist,
00074                                                 const oid *name, size_t len);
00075 
00076     netsnmp_pdu    *snmp_split_pdu(netsnmp_pdu *, int skipCount,
00077                                    int copyCount);
00078 
00079     unsigned long   snmp_varbind_len(netsnmp_pdu *pdu);
00080     NETSNMP_IMPORT
00081     int             snmp_clone_var(netsnmp_variable_list *,
00082                                    netsnmp_variable_list *);
00083     NETSNMP_IMPORT
00084     int             snmp_synch_response_cb(netsnmp_session *,
00085                                            netsnmp_pdu *, netsnmp_pdu **,
00086                                            snmp_callback);
00087     NETSNMP_IMPORT
00088     int             snmp_clone_mem(void **, const void *, unsigned);
00089 
00090 
00091 NETSNMP_IMPORT
00092 void              netsnmp_query_set_default_session(netsnmp_session *);
00093 NETSNMP_IMPORT
00094 netsnmp_session * netsnmp_query_get_default_session_unchecked( void );
00095 NETSNMP_IMPORT
00096 netsnmp_session * netsnmp_query_get_default_session( void );
00097 NETSNMP_IMPORT
00098 int netsnmp_query_get(     netsnmp_variable_list *, netsnmp_session *);
00099 NETSNMP_IMPORT
00100 int netsnmp_query_getnext( netsnmp_variable_list *, netsnmp_session *);
00101 NETSNMP_IMPORT
00102 int netsnmp_query_walk(    netsnmp_variable_list *, netsnmp_session *);
00103 #ifndef NETSNMP_NO_WRITE_SUPPORT
00104 NETSNMP_IMPORT
00105 int netsnmp_query_set(     netsnmp_variable_list *, netsnmp_session *);
00106 #endif /* !NETSNMP_NO_WRITE_SUPPORT */
00107 
00114     struct netsnmp_state_machine_step_s;
00115     struct netsnmp_state_machine_input_s;
00116 
00118     typedef int (netsnmp_state_machine_func)(struct netsnmp_state_machine_input_s *input,
00119                                              struct netsnmp_state_machine_step_s *step);
00120 
00121     typedef struct netsnmp_state_machine_step_s {
00122 
00123         const char   *name; /* primarily for logging/debugging */
00124         u_int         sm_flags;
00125         
00126         netsnmp_state_machine_func *run;
00127         int                         result; /* return code for this step */
00128         
00129         
00130         struct netsnmp_state_machine_step_s *on_success;
00131         struct netsnmp_state_machine_step_s *on_error;
00132         
00133         /*
00134          * user fields (not touched by state machine functions)
00135          */
00136         u_int         flags;
00137         void         *step_context;
00138         
00139     } netsnmp_state_machine_step;
00140 
00141     typedef struct netsnmp_state_machine_input_s {
00142         const char                  *name;
00143         int                          steps_so_far;
00144         netsnmp_state_machine_step  *steps;
00145         netsnmp_state_machine_step  *cleanup;
00146         netsnmp_state_machine_step  *last_run;
00147 
00148         /*
00149          * user fields (not touched by state machine functions)
00150          */
00151         void         *input_context;
00152 
00153     } netsnmp_state_machine_input;
00154 
00155 
00156     NETSNMP_IMPORT int
00157     netsnmp_state_machine_run( netsnmp_state_machine_input *input );
00158 
00159     NETSNMP_IMPORT int
00160     netsnmp_row_create(netsnmp_session *sess, netsnmp_variable_list *vars,
00161                        int row_status_index);
00162 
00163 
00164 #ifdef __cplusplus
00165 }
00166 #endif
00167 #endif                          /* SNMP_CLIENT_H */