3
* Implementation of the mteTriggerThresholdTable MIB interface
4
* See 'mteTrigger.c' for active behaviour of this table.
6
* (based on mib2c.table_data.conf output)
9
#include <net-snmp/net-snmp-config.h>
10
#include <net-snmp/net-snmp-includes.h>
11
#include <net-snmp/agent/net-snmp-agent-includes.h>
12
#include "disman/event/mteTrigger.h"
13
#include "disman/event/mteTriggerThresholdTable.h"
16
/** Initializes the mteTriggerThresholdTable module */
18
init_mteTriggerThresholdTable(void)
20
static oid mteTThreshTable_oid[] = { 1, 3, 6, 1, 2, 1, 88, 1, 2, 6 };
21
size_t mteTThreshTable_oid_len = OID_LENGTH(mteTThreshTable_oid);
22
netsnmp_handler_registration *reg;
23
netsnmp_table_registration_info *table_info;
26
* Ensure the (combined) table container is available...
28
init_trigger_table_data();
31
* ... then set up the MIB interface to the mteTriggerThresholdTable slice
33
reg = netsnmp_create_handler_registration("mteTriggerThresholdTable",
34
mteTriggerThresholdTable_handler,
36
mteTThreshTable_oid_len,
39
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
40
netsnmp_table_helper_add_indexes(table_info,
41
ASN_OCTET_STR, /* index: mteOwner */
42
/* index: mteTriggerName */
43
ASN_PRIV_IMPLIED_OCTET_STR,
46
table_info->min_column = COLUMN_MTETRIGGERTHRESHOLDSTARTUP;
47
table_info->max_column = COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT;
49
/* Register this using the (common) trigger_table_data container */
50
netsnmp_tdata_register(reg, trigger_table_data, table_info);
51
DEBUGMSGTL(("disman:event:init", "Trigger Threshold Table\n"));
55
/** handles requests for the mteTriggerThresholdTable table */
57
mteTriggerThresholdTable_handler(netsnmp_mib_handler *handler,
58
netsnmp_handler_registration *reginfo,
59
netsnmp_agent_request_info *reqinfo,
60
netsnmp_request_info *requests)
63
netsnmp_request_info *request;
64
netsnmp_table_request_info *tinfo;
65
struct mteTrigger *entry;
68
DEBUGMSGTL(("disman:event:mib", "Threshold Table handler (%d)\n",
71
switch (reqinfo->mode) {
73
* Read-support (also covers GetNext requests)
76
for (request = requests; request; request = request->next) {
77
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
78
tinfo = netsnmp_extract_table_info(request);
81
* The mteTriggerThresholdTable should only contains entries for
82
* rows where the mteTriggerTest 'threshold(2)' bit is set.
83
* So skip entries where this isn't the case.
85
if (!entry || !(entry->mteTriggerTest & MTE_TRIGGER_THRESHOLD ))
88
switch (tinfo->colnum) {
89
case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
90
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
91
entry->mteTThStartup);
93
case COLUMN_MTETRIGGERTHRESHOLDRISING:
94
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
95
entry->mteTThRiseValue);
97
case COLUMN_MTETRIGGERTHRESHOLDFALLING:
98
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
99
entry->mteTThFallValue);
101
case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
102
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
103
entry->mteTThDRiseValue);
105
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
106
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
107
entry->mteTThDFallValue);
109
case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
110
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
111
(u_char *) entry->mteTThObjOwner,
112
strlen(entry->mteTThObjOwner));
114
case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
115
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
116
(u_char *) entry->mteTThObjects,
117
strlen(entry->mteTThObjects));
119
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
120
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
121
(u_char *) entry->mteTThRiseOwner,
122
strlen(entry->mteTThRiseOwner));
124
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
125
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
126
(u_char *) entry->mteTThRiseEvent,
127
strlen(entry->mteTThRiseEvent));
129
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
130
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
131
(u_char *) entry->mteTThFallOwner,
132
strlen(entry->mteTThFallOwner));
134
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
135
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
136
(u_char *) entry->mteTThFallEvent,
137
strlen(entry->mteTThFallEvent));
139
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
140
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
141
(u_char *) entry->mteTThDRiseOwner,
142
strlen(entry->mteTThDRiseOwner));
144
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
145
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
146
(u_char *) entry->mteTThDRiseEvent,
147
strlen(entry->mteTThDRiseEvent));
149
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
150
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
151
(u_char *) entry->mteTThDFallOwner,
152
strlen(entry->mteTThDFallOwner));
154
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
155
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
156
(u_char *) entry->mteTThDFallEvent,
157
strlen(entry->mteTThDFallEvent));
166
case MODE_SET_RESERVE1:
167
for (request = requests; request; request = request->next) {
168
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
169
tinfo = netsnmp_extract_table_info(request);
172
* Since the mteTriggerThresholdTable only contains entries for
173
* rows where the mteTriggerTest 'threshold(2)' bit is set,
174
* strictly speaking we should reject assignments where
175
* this isn't the case.
176
* But SET requests that include an assignment of the
177
* 'threshold(2)' bit at the same time are valid, so would
178
* need to be accepted. Unfortunately, this assignment
179
* is only applied in the COMMIT pass, so it's difficult
180
* to detect whether this holds or not.
182
* Let's fudge things for now, by processing assignments
183
* even if the 'threshold(2)' bit isn't set.
185
switch (tinfo->colnum) {
186
case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
187
ret = netsnmp_check_vb_int_range(request->requestvb,
188
MTE_THRESH_START_RISE,
189
MTE_THRESH_START_RISEFALL );
190
if (ret != SNMP_ERR_NOERROR) {
191
netsnmp_set_request_error(reqinfo, request, ret);
192
return SNMP_ERR_NOERROR;
195
case COLUMN_MTETRIGGERTHRESHOLDRISING:
196
case COLUMN_MTETRIGGERTHRESHOLDFALLING:
197
case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
198
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
199
ret = netsnmp_check_vb_int(request->requestvb);
200
if (ret != SNMP_ERR_NOERROR) {
201
netsnmp_set_request_error(reqinfo, request, ret);
202
return SNMP_ERR_NOERROR;
205
case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
206
case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
207
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
208
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
209
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
210
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
211
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
212
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
213
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
214
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
215
ret = netsnmp_check_vb_type_and_max_size(
216
request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);
217
if (ret != SNMP_ERR_NOERROR) {
218
netsnmp_set_request_error(reqinfo, request, ret);
219
return SNMP_ERR_NOERROR;
223
netsnmp_set_request_error(reqinfo, request,
224
SNMP_ERR_NOTWRITABLE);
225
return SNMP_ERR_NOERROR;
229
* The Event MIB is somewhat ambiguous as to whether the
230
* various trigger table entries can be modified once the
231
* main mteTriggerTable entry has been marked 'active'.
232
* But it's clear from discussion on the DisMan mailing
233
* list is that the intention is not.
235
* So check for whether this row is already active,
236
* and reject *all* SET requests if it is.
238
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
240
entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
241
netsnmp_set_request_error(reqinfo, request,
242
SNMP_ERR_INCONSISTENTVALUE);
243
return SNMP_ERR_NOERROR;
248
case MODE_SET_RESERVE2:
253
case MODE_SET_ACTION:
254
for (request = requests; request; request = request->next) {
255
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
258
* New rows must be created via the RowStatus column
259
* (in the main mteTriggerTable)
261
netsnmp_set_request_error(reqinfo, request,
262
SNMP_ERR_NOCREATION);
263
/* or inconsistentName? */
264
return SNMP_ERR_NOERROR;
269
case MODE_SET_COMMIT:
271
* All these assignments are "unfailable", so it's
272
* (reasonably) safe to apply them in the Commit phase
274
for (request = requests; request; request = request->next) {
275
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
276
tinfo = netsnmp_extract_table_info(request);
278
switch (tinfo->colnum) {
279
case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
280
entry->mteTThStartup = *request->requestvb->val.integer;
282
case COLUMN_MTETRIGGERTHRESHOLDRISING:
283
entry->mteTThRiseValue = *request->requestvb->val.integer;
285
case COLUMN_MTETRIGGERTHRESHOLDFALLING:
286
entry->mteTThFallValue = *request->requestvb->val.integer;
288
case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
289
entry->mteTThDRiseValue = *request->requestvb->val.integer;
291
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
292
entry->mteTThDFallValue = *request->requestvb->val.integer;
294
case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
295
memset(entry->mteTThObjOwner, 0, sizeof(entry->mteTThObjOwner));
296
memcpy(entry->mteTThObjOwner, request->requestvb->val.string,
297
request->requestvb->val_len);
299
case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
300
memset(entry->mteTThObjects, 0, sizeof(entry->mteTThObjects));
301
memcpy(entry->mteTThObjects, request->requestvb->val.string,
302
request->requestvb->val_len);
304
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
305
memset(entry->mteTThRiseOwner, 0, sizeof(entry->mteTThRiseOwner));
306
memcpy(entry->mteTThRiseOwner, request->requestvb->val.string,
307
request->requestvb->val_len);
309
case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
310
memset(entry->mteTThRiseEvent, 0, sizeof(entry->mteTThRiseEvent));
311
memcpy(entry->mteTThRiseEvent, request->requestvb->val.string,
312
request->requestvb->val_len);
314
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
315
memset(entry->mteTThFallOwner, 0, sizeof(entry->mteTThFallOwner));
316
memcpy(entry->mteTThFallOwner, request->requestvb->val.string,
317
request->requestvb->val_len);
319
case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
320
memset(entry->mteTThFallEvent, 0, sizeof(entry->mteTThFallEvent));
321
memcpy(entry->mteTThFallEvent, request->requestvb->val.string,
322
request->requestvb->val_len);
324
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
325
memset(entry->mteTThDRiseOwner, 0, sizeof(entry->mteTThDRiseOwner));
326
memcpy(entry->mteTThDRiseOwner, request->requestvb->val.string,
327
request->requestvb->val_len);
329
case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
330
memset(entry->mteTThDRiseEvent, 0, sizeof(entry->mteTThDRiseEvent));
331
memcpy(entry->mteTThDRiseEvent, request->requestvb->val.string,
332
request->requestvb->val_len);
334
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
335
memset(entry->mteTThDFallOwner, 0, sizeof(entry->mteTThDFallOwner));
336
memcpy(entry->mteTThDFallOwner, request->requestvb->val.string,
337
request->requestvb->val_len);
339
case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
340
memset(entry->mteTThDFallEvent, 0, sizeof(entry->mteTThDFallEvent));
341
memcpy(entry->mteTThDFallEvent, request->requestvb->val.string,
342
request->requestvb->val_len);
348
return SNMP_ERR_NOERROR;