net-snmp 5.7
|
00001 /************************************************************************** 00002 * object_monitor.h 00003 * 00004 * Contributed by: Robert Story <rstory@freesnmp.com> 00005 * 00006 * $Id$ 00007 * 00008 * functions and data structures for cooperating code to monitor objects. 00009 * 00010 * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! 00011 * WARNING! WARNING! 00012 * WARNING! WARNING! 00013 * WARNING! This code is under active development WARNING! 00014 * WARNING! and is subject to change at any time. WARNING! 00015 * WARNING! WARNING! 00016 * WARNING! WARNING! 00017 * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! 00018 */ 00019 #ifndef OBJECT_MONITOR_H 00020 #define OBJECT_MONITOR_H 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 /* 00027 * notification types 00028 */ 00029 enum { 00030 /* 00031 * cooperative notification from the object being watched 00032 */ 00033 NOTIFICATION_COOPERATIVE = 1, 00034 /* 00035 * notification that an object has been set vi SNMP-SET 00036 */ 00037 NOTIFICATION_SET_REQUEST, 00038 /* 00039 * end of current notification types 00040 */ 00041 NOTIFICATION_END 00042 }; 00043 00044 /* 00045 * COOPERATIVE event types 00046 */ 00047 enum { 00048 EVENT_ROW_ADD = 1, 00049 EVENT_ROW_MOD, 00050 EVENT_ROW_DEL, 00051 EVENT_COL_MOD, 00052 EVENT_OBJ_MOD, 00053 EVENT_END 00054 }; 00055 00056 /* 00057 * data structures 00058 */ 00059 00060 00064 typedef struct netsnmp_monitor_callback_header_s { 00065 00067 unsigned int event; 00068 00070 netsnmp_index monitored_object; 00071 00073 int priority; 00074 00076 void *watcher_data; 00077 00079 void *object_info; 00080 00082 struct netsnmp_monitor_callback_header_s *private; 00083 int refs; 00084 00085 00086 } netsnmp_monitor_callback_header; 00087 00088 /* 00089 * 00090 */ 00091 typedef struct netsnmp_monitor_callback_set_request_s { 00092 00094 netsnmp_monitor_callback_header hdr; 00095 00097 netsnmp_mib_handler *handler; 00098 00100 netsnmp_pdu *pdu; 00101 00103 netsnmp_request_info *request; 00104 00105 } netsnmp_monitor_set_request_data; 00106 00107 /* 00108 * 00109 */ 00110 typedef struct netsnmp_monitor_callback_cooperative_s { 00111 00113 netsnmp_monitor_callback_header hdr; 00114 00115 } netsnmp_monitor_callback_cooperative; 00116 00117 00118 00119 typedef void 00120 (netsnmp_object_monitor_callback) (netsnmp_monitor_callback_header 00121 *); 00122 00123 00124 00125 00126 /********************************************************************** 00127 * Registration function prototypes 00128 */ 00129 00130 /* 00131 * Register a callback for the specified object. 00132 */ 00133 int netsnmp_monitor_register(oid * object, size_t oid_len, 00134 int priority, 00135 unsigned int events, 00136 void *watcher_data, 00137 netsnmp_object_monitor_callback 00138 * cb); 00139 00140 /* 00141 * Unregister a callback for the specified object. 00142 */ 00143 int netsnmp_monitor_unregister(oid * object, 00144 size_t oid_len, 00145 int priority, 00146 void *watcher_data, 00147 netsnmp_object_monitor_callback 00148 * cb); 00149 00150 /* 00151 * check to see if a registration exists for an object/event combination 00152 */ 00153 int netsnmp_monitor_check_registered(int event, oid * oid, 00154 int oid_len); 00155 00156 00157 /********************************************************************** 00158 * function prototypes 00159 */ 00160 00161 /* 00162 * Notifies the object monitor of an event. 00163 */ 00164 void netsnmp_notify_monitor(netsnmp_monitor_callback_header 00165 * cbh); 00166 00167 00168 00169 00170 /********************************************************************** 00171 * function prototypes 00172 */ 00173 00174 /* 00175 * Notifies the object monitor of a cooperative event. 00176 */ 00177 void netsnmp_notify_cooperative(int event, oid * object, 00178 size_t len, char oid_steal, 00179 void *object_info); 00180 00181 00182 00183 #ifdef __cplusplus 00184 } 00185 #endif 00186 #endif