net-snmp 5.7
agent_registry.h
00001 #ifndef AGENT_REGISTRY_H
00002 #define AGENT_REGISTRY_H
00003 
00004 /***********************************************************************/
00005 /*
00006  * new version2 agent handler API structures 
00007  */
00008 /***********************************************************************/
00009 
00010 #include <net-snmp/agent/snmp_agent.h>
00011 #include <net-snmp/library/fd_event_manager.h>
00012 
00013 #ifdef __cplusplus
00014 extern          "C" {
00015 #endif
00016 
00017 /***********************************************************************/
00018     /*
00019      * requests api definitions 
00020      */
00021 /***********************************************************************/
00022 
00023     /*
00024      * the structure of parameters passed to registered ACM modules 
00025      */
00026 struct view_parameters {
00027     netsnmp_pdu    *pdu;
00028     oid            *name;
00029     size_t          namelen;
00030     int             test;
00031     int             errorcode;          /*  Do not change unless you're
00032                                             specifying an error, as it starts
00033                                             in a success state.  */
00034     int             check_subtree;
00035 };
00036 
00037 struct register_parameters {
00038     oid                          *name;
00039     size_t                        namelen;
00040     int                           priority;
00041     int                           range_subid;
00042     oid                           range_ubound;
00043     int                           timeout;
00044     u_char                        flags;
00045     const char                   *contextName;
00046     netsnmp_session              *session;
00047     netsnmp_handler_registration *reginfo;
00048 };
00049 
00050 typedef struct subtree_context_cache_s {
00051     const char                          *context_name;
00052     struct netsnmp_subtree_s            *first_subtree;
00053     struct subtree_context_cache_s      *next;
00054 } subtree_context_cache;
00055 
00056 
00057 
00058 void             setup_tree               (void);
00059 void             shutdown_tree    (void);
00060 
00061 
00062 netsnmp_subtree *netsnmp_subtree_find     (const oid *, size_t,
00063                                            netsnmp_subtree *,
00064                                            const char *context_name);
00065 
00066 netsnmp_subtree *netsnmp_subtree_find_next(const oid *, size_t,
00067                                            netsnmp_subtree *,
00068                                            const char *context_name);
00069 
00070 netsnmp_subtree *netsnmp_subtree_find_prev(const oid *, size_t,
00071                                            netsnmp_subtree *,
00072                                            const char *context_name);
00073 
00074 netsnmp_subtree *netsnmp_subtree_find_first(const char *context_name);
00075 
00076 netsnmp_session *get_session_for_oid       (const oid *, size_t, 
00077                                             const char *context_name);
00078 
00079 subtree_context_cache *get_top_context_cache(void);
00080 
00081 void netsnmp_set_lookup_cache_size(int newsize);
00082 int netsnmp_get_lookup_cache_size(void);
00083 
00084 #define MIB_REGISTERED_OK                0
00085 #define MIB_DUPLICATE_REGISTRATION      -1
00086 #define MIB_REGISTRATION_FAILED         -2
00087 #define MIB_UNREGISTERED_OK              0
00088 #define MIB_NO_SUCH_REGISTRATION        -1
00089 #define MIB_UNREGISTRATION_FAILED       -2
00090 #define DEFAULT_MIB_PRIORITY            127
00091 
00092 int             register_mib               (const char *, struct variable *,
00093                                             size_t, size_t, const oid *,
00094                                             size_t);
00095 
00096 int             register_mib_priority      (const char *, struct variable *,
00097                                             size_t, size_t, const oid *, size_t,
00098                                             int);
00099 
00100 int             register_mib_range         (const char *, struct variable *,
00101                                             size_t, size_t, const oid *,
00102                                             size_t, int, int, oid,
00103                                             netsnmp_session *);
00104 
00105 int             register_mib_context       (const char *, struct variable *,
00106                                             size_t, size_t, const oid *, size_t,
00107                                             int, int, oid, netsnmp_session *,
00108                                             const char *, int, int);
00109 
00110 int     netsnmp_register_mib_table_row     (const char *, struct variable *,
00111                                             size_t, size_t, oid *,
00112                                             size_t, int, int, netsnmp_session *,
00113                                             const char *, int, int);
00114 
00115 int             unregister_mib             (oid *, size_t);
00116 
00117 int             unregister_mib_priority    (oid *, size_t, int);
00118 int             unregister_mib_range       (oid *, size_t, int, int, oid);
00119 int             unregister_mib_context     (oid *, size_t, int, int, oid,
00120                                             const char *);
00121 void            clear_context              (void);
00122 void            unregister_mibs_by_session (netsnmp_session *);
00123 int     netsnmp_unregister_mib_table_row   (oid *mibloc, size_t mibloclen,
00124                                             int priority, int var_subid,
00125                                             oid range_ubound,
00126                                             const char *context);
00127 
00128 int             compare_tree               (const oid *, size_t, 
00129                                             const oid *, size_t);
00130 int             in_a_view                  (oid *, size_t *, 
00131                                             netsnmp_pdu *, int);
00132 int             check_access               (netsnmp_pdu *pdu);
00133 int             netsnmp_acm_check_subtree  (netsnmp_pdu *, oid *, size_t);
00134 void            register_mib_reattach      (void);
00135 void            register_mib_detach        (void);
00136 
00137 /*
00138  * REGISTER_MIB(): This macro simply loads register_mib with less pain:
00139  * 
00140  * descr:   A short description of the mib group being loaded.
00141  * var:     The variable structure to load.
00142  * vartype: The variable structure used to define it (variable[2, 4, ...])
00143  * theoid:  An *initialized* *exact length* oid pointer.
00144  *          (sizeof(theoid) *must* return the number of elements!) 
00145  */
00146 
00147 #define REGISTER_MIB(descr, var, vartype, theoid)                      \
00148   if (register_mib(descr, (struct variable *) var, sizeof(struct vartype), \
00149                sizeof(var)/sizeof(struct vartype),                     \
00150                theoid, sizeof(theoid)/sizeof(oid)) != MIB_REGISTERED_OK ) \
00151         DEBUGMSGTL(("register_mib", "%s registration failed\n", descr));
00152 
00153 
00154 #define NUM_EXTERNAL_SIGS 32
00155 #define SIG_REGISTERED_OK                0
00156 #define SIG_REGISTRATION_FAILED         -2
00157 #define SIG_UNREGISTERED_OK              0
00158 
00159 extern int      external_signal_scheduled[NUM_EXTERNAL_SIGS];
00160 extern void     (*external_signal_handler[NUM_EXTERNAL_SIGS])(int);
00161 
00162 int             register_signal(int, void (*func)(int));
00163 int             unregister_signal(int);
00164 
00165 
00166 
00167 /*
00168  * internal API.  Don't use this.  Use netsnmp_register_handler instead 
00169  */
00170 
00171 struct netsnmp_handler_registration_s;
00172 
00173 int             netsnmp_register_mib(const char *, struct variable *,
00174                                      size_t, size_t, oid *, size_t,
00175                                      int, int, oid, netsnmp_session *,
00176                                      const char *, int, int,
00177                                      struct netsnmp_handler_registration_s *,
00178                                      int);
00179 
00180 #ifdef __cplusplus
00181 }
00182 #endif
00183 
00184 #endif                          /* AGENT_REGISTRY_H */