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 };
00047 
00048 typedef struct subtree_context_cache_s {
00049     char                                *context_name;
00050     struct netsnmp_subtree_s            *first_subtree;
00051     struct subtree_context_cache_s      *next;
00052 } subtree_context_cache;
00053 
00054 
00055 
00056 void             setup_tree               (void);
00057 void             shutdown_tree    (void);
00058 
00059 
00060 netsnmp_subtree *netsnmp_subtree_find     (oid *, size_t, netsnmp_subtree *,
00061                                            const char *context_name);
00062 
00063 netsnmp_subtree *netsnmp_subtree_find_next(oid *, size_t, netsnmp_subtree *,
00064                                            const char *context_name);
00065 
00066 netsnmp_subtree *netsnmp_subtree_find_prev(oid *, size_t,netsnmp_subtree *,
00067                                            const char *context_name);
00068 
00069 netsnmp_subtree *netsnmp_subtree_find_first(const char *context_name);
00070 
00071 netsnmp_session *get_session_for_oid       (oid *, size_t, 
00072                                             const char *context_name);
00073 
00074 subtree_context_cache *get_top_context_cache(void);
00075 
00076 void netsnmp_set_lookup_cache_size(int newsize);
00077 int netsnmp_get_lookup_cache_size(void);
00078 
00079 #define MIB_REGISTERED_OK                0
00080 #define MIB_DUPLICATE_REGISTRATION      -1
00081 #define MIB_REGISTRATION_FAILED         -2
00082 #define MIB_UNREGISTERED_OK              0
00083 #define MIB_NO_SUCH_REGISTRATION        -1
00084 #define MIB_UNREGISTRATION_FAILED       -2
00085 #define DEFAULT_MIB_PRIORITY            127
00086 
00087 int             register_mib               (const char *, struct variable *,
00088                                             size_t, size_t, oid *, size_t);
00089 
00090 int             register_mib_priority      (const char *, struct variable *,
00091                                             size_t, size_t, oid *, size_t,
00092                                             int);
00093 
00094 int             register_mib_range         (const char *, struct variable *,
00095                                             size_t, size_t, oid *, size_t, 
00096                                             int, int, oid, netsnmp_session *);
00097 
00098 int             register_mib_context       (const char *, struct variable *,
00099                                             size_t, size_t, oid *, size_t,
00100                                             int, int, oid, netsnmp_session *,
00101                                             const char *, int, int);
00102 
00103 int     netsnmp_register_mib_table_row     (const char *, struct variable *,
00104                                             size_t, size_t, oid *, size_t, 
00105                                             int, int, netsnmp_session *,
00106                                             const char *, int, int);
00107 
00108 int             unregister_mib             (oid *, size_t);
00109 
00110 int             unregister_mib_priority    (oid *, size_t, int);
00111 int             unregister_mib_range       (oid *, size_t, int, int, oid);
00112 int             unregister_mib_context     (oid *, size_t, int, int, oid,
00113                                             const char *);
00114 void            clear_context              (void);
00115 void            unregister_mibs_by_session (netsnmp_session *);
00116 int     netsnmp_unregister_mib_table_row   (oid *mibloc, size_t mibloclen,
00117                                             int priority, int var_subid,
00118                                             oid range_ubound,
00119                                             const char *context);
00120 
00121 int             compare_tree               (const oid *, size_t, 
00122                                             const oid *, size_t);
00123 int             in_a_view                  (oid *, size_t *, 
00124                                             netsnmp_pdu *, int);
00125 int             check_access               (netsnmp_pdu *pdu);
00126 int             netsnmp_acm_check_subtree  (netsnmp_pdu *, oid *, size_t);
00127 void            register_mib_reattach      (void);
00128 void            register_mib_detach        (void);
00129 
00130 /*
00131  * REGISTER_MIB(): This macro simply loads register_mib with less pain:
00132  * 
00133  * descr:   A short description of the mib group being loaded.
00134  * var:     The variable structure to load.
00135  * vartype: The variable structure used to define it (variable[2, 4, ...])
00136  * theoid:  An *initialized* *exact length* oid pointer.
00137  *          (sizeof(theoid) *must* return the number of elements!) 
00138  */
00139 
00140 #define REGISTER_MIB(descr, var, vartype, theoid)                      \
00141   if (register_mib(descr, (struct variable *) var, sizeof(struct vartype), \
00142                sizeof(var)/sizeof(struct vartype),                     \
00143                theoid, sizeof(theoid)/sizeof(oid)) != MIB_REGISTERED_OK ) \
00144         DEBUGMSGTL(("register_mib", "%s registration failed\n", descr));
00145 
00146 
00147 #define NUM_EXTERNAL_SIGS 32
00148 #define SIG_REGISTERED_OK                0
00149 #define SIG_REGISTRATION_FAILED         -2
00150 #define SIG_UNREGISTERED_OK              0
00151 
00152 extern int      external_signal_scheduled[NUM_EXTERNAL_SIGS];
00153 extern void     (*external_signal_handler[NUM_EXTERNAL_SIGS])(int);
00154 
00155 int             register_signal(int, void (*func)(int));
00156 int             unregister_signal(int);
00157 
00158 
00159 
00160 /*
00161  * internal API.  Don't use this.  Use netsnmp_register_handler instead 
00162  */
00163 
00164 struct netsnmp_handler_registration_s;
00165 
00166 int             netsnmp_register_mib(const char *, struct variable *,
00167                                      size_t, size_t, oid *, size_t,
00168                                      int, int, oid, netsnmp_session *,
00169                                      const char *, int, int,
00170                                      struct netsnmp_handler_registration_s *,
00171                                      int);
00172 
00173 #ifdef __cplusplus
00174 }
00175 #endif
00176 
00177 #endif                          /* AGENT_REGISTRY_H */

net-snmpに対してSat Sep 5 13:14:20 2009に生成されました。  doxygen 1.4.7