summaryrefslogtreecommitdiff
path: root/include/net-snmp/agent/object_monitor.h
blob: 8ac3ecaf6c2f05142b823f55a94819c4de7d32aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**************************************************************************
 * object_monitor.h
 *
 * Contributed by: Robert Story <rstory@freesnmp.com>
 *
 * $Id$
 *
 * functions and data structures for cooperating code to monitor objects.
 *
 * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
 * WARNING!                                                       WARNING!
 * WARNING!                                                       WARNING!
 * WARNING!         This code is under active development         WARNING!
 * WARNING!         and is subject to change at any time.         WARNING!
 * WARNING!                                                       WARNING!
 * WARNING!                                                       WARNING!
 * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
 */
#ifndef OBJECT_MONITOR_H
#define OBJECT_MONITOR_H

#ifdef __cplusplus
extern          "C" {
#endif

    /*
     * notification types
     */
    enum {
        /*
         * cooperative notification from the object being watched
         */
        NOTIFICATION_COOPERATIVE = 1,
        /*
         * notification that an object has been set vi SNMP-SET
         */
        NOTIFICATION_SET_REQUEST,
        /*
         * end of current notification types
         */
        NOTIFICATION_END
    };

    /*
     * COOPERATIVE event types
     */
    enum {
        EVENT_ROW_ADD = 1,
        EVENT_ROW_MOD,
        EVENT_ROW_DEL,
        EVENT_COL_MOD,
        EVENT_OBJ_MOD,
        EVENT_END
    };

    /*
     * data structures
     */


    /**
     * callback header
     */
    typedef struct netsnmp_monitor_callback_header_s {

   /** callback type */
        unsigned int    event;

   /** registered oid */
        netsnmp_index   monitored_object;

   /** priority */
        int             priority;

   /** pointer given by watcher at registration */
        void           *watcher_data;

   /** pointer passed from the monitored object */
        void           *object_info;

   /** DO NOT USE, INTERNAL USE ONLY */
        struct netsnmp_monitor_callback_header_s *private;
        int             refs;


    } netsnmp_monitor_callback_header;

    /*
     *
     */
    typedef struct netsnmp_monitor_callback_set_request_s {

    /** header */
        netsnmp_monitor_callback_header hdr;

    /** handler that registered to handle this object */
        netsnmp_mib_handler *handler;

    /** pdu containing the set request */
        netsnmp_pdu    *pdu;

    /** the set request */
        netsnmp_request_info *request;

    } netsnmp_monitor_set_request_data;

    /*
     *
     */
    typedef struct netsnmp_monitor_callback_cooperative_s {

   /** header */
        netsnmp_monitor_callback_header hdr;

    } netsnmp_monitor_callback_cooperative;



    typedef void   
        (netsnmp_object_monitor_callback) (netsnmp_monitor_callback_header
                                           *);




    /**********************************************************************
     * Registration function prototypes
     */

    /*
     * Register a callback for the specified object.
     */
    int             netsnmp_monitor_register(oid * object, size_t oid_len,
                                             int priority,
                                             unsigned int events,
                                             void *watcher_data,
                                             netsnmp_object_monitor_callback
                                             * cb);

    /*
     * Unregister a callback for the specified object.
     */
    int             netsnmp_monitor_unregister(oid * object,
                                               size_t oid_len,
                                               int priority,
                                               void *watcher_data,
                                               netsnmp_object_monitor_callback
                                               * cb);

    /*
     * check to see if a registration exists for an object/event combination
     */
    int             netsnmp_monitor_check_registered(int event, oid * oid,
                                                     int oid_len);


    /**********************************************************************
     * function prototypes
     */

    /*
     * Notifies the object monitor of an event.
     */
    void            netsnmp_notify_monitor(netsnmp_monitor_callback_header
                                           * cbh);




    /**********************************************************************
     * function prototypes
     */

    /*
     * Notifies the object monitor of a cooperative event.
     */
    void            netsnmp_notify_cooperative(int event, oid * object,
                                               size_t len, char oid_steal,
                                               void *object_info);



#ifdef __cplusplus
}
#endif
#endif /** OBJECT_MONITOR_H */