3
* Implementation of the mteTriggerDeltaTable 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/mteTriggerDeltaTable.h"
16
/** Initializes the mteTriggerDeltaTable module */
18
init_mteTriggerDeltaTable(void)
20
static oid mteTDeltaTable_oid[] = { 1, 3, 6, 1, 2, 1, 88, 1, 2, 3 };
21
size_t mteTDeltaTable_oid_len = OID_LENGTH(mteTDeltaTable_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 mteTriggerDeltaTable slice
33
reg = netsnmp_create_handler_registration("mteTriggerDeltaTable",
34
mteTriggerDeltaTable_handler,
36
mteTDeltaTable_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_MTETRIGGERDELTADISCONTINUITYID;
47
table_info->max_column = COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE;
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 Delta Table\n"));
55
/** handles requests for the mteTriggerDeltaTable table */
57
mteTriggerDeltaTable_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", "Delta 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 mteTriggerBooleanTable should only contains entries for
82
* rows where the mteTriggerSampleType is 'deltaValue(2)'
83
* So skip entries where this isn't the case.
85
if (!entry || !(entry->flags & MTE_TRIGGER_FLAG_DELTA ))
88
switch (tinfo->colnum) {
89
case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
90
snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
91
(u_char *) entry->mteDeltaDiscontID,
92
entry->mteDeltaDiscontID_len*sizeof(oid));
94
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
95
ret = (entry->flags & MTE_TRIGGER_FLAG_DWILD ) ?
97
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
99
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
100
snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
101
entry->mteDeltaDiscontIDType);
110
case MODE_SET_RESERVE1:
111
for (request = requests; request; request = request->next) {
112
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
113
tinfo = netsnmp_extract_table_info(request);
116
* Since the mteTriggerDeltaTable only contains entries for
117
* rows where mteTriggerSampleType is 'deltaValue(2)',
118
* strictly speaking we should reject assignments where
119
* this isn't the case.
120
* But SET requests that include an assignment of
121
* 'deltaValue(2)' at the same time are valid, so would
122
* need to be accepted. Unfortunately, this assignment
123
* is only applied in the COMMIT pass, so it's difficult
124
* to detect whether this holds or not.
126
* Let's fudge things for now, by processing
127
* assignments even if this value isn't set.
129
switch (tinfo->colnum) {
130
case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
131
ret = netsnmp_check_vb_oid(request->requestvb);
132
if (ret != SNMP_ERR_NOERROR) {
133
netsnmp_set_request_error(reqinfo, request, ret);
134
return SNMP_ERR_NOERROR;
137
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
138
ret = netsnmp_check_vb_truthvalue(request->requestvb);
139
if (ret != SNMP_ERR_NOERROR) {
140
netsnmp_set_request_error(reqinfo, request, ret);
141
return SNMP_ERR_NOERROR;
144
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
145
ret = netsnmp_check_vb_int_range(request->requestvb,
147
MTE_DELTAD_DATETIME);
148
if (ret != SNMP_ERR_NOERROR) {
149
netsnmp_set_request_error(reqinfo, request, ret);
150
return SNMP_ERR_NOERROR;
154
netsnmp_set_request_error(reqinfo, request,
155
SNMP_ERR_NOTWRITABLE);
156
return SNMP_ERR_NOERROR;
160
* The Event MIB is somewhat ambiguous as to whether the
161
* various trigger table entries can be modified once the
162
* main mteTriggerTable entry has been marked 'active'.
163
* But it's clear from discussion on the DisMan mailing
164
* list is that the intention is not.
166
* So check for whether this row is already active,
167
* and reject *all* SET requests if it is.
169
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
171
entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
172
netsnmp_set_request_error(reqinfo, request,
173
SNMP_ERR_INCONSISTENTVALUE);
174
return SNMP_ERR_NOERROR;
179
case MODE_SET_RESERVE2:
184
case MODE_SET_ACTION:
185
for (request = requests; request; request = request->next) {
186
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
189
* New rows must be created via the RowStatus column
190
* (in the main mteTriggerTable)
192
netsnmp_set_request_error(reqinfo, request,
193
SNMP_ERR_NOCREATION);
194
/* or inconsistentName? */
195
return SNMP_ERR_NOERROR;
200
case MODE_SET_COMMIT:
202
* All these assignments are "unfailable", so it's
203
* (reasonably) safe to apply them in the Commit phase
205
for (request = requests; request; request = request->next) {
206
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
207
tinfo = netsnmp_extract_table_info(request);
209
switch (tinfo->colnum) {
210
case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
211
if ( snmp_oid_compare(
212
request->requestvb->val.objid,
213
request->requestvb->val_len/sizeof(oid),
214
_sysUpTime_instance, _sysUpTime_inst_len) != 0 ) {
215
memset(entry->mteDeltaDiscontID, 0,
216
sizeof(entry->mteDeltaDiscontID));
217
memcpy(entry->mteDeltaDiscontID,
218
request->requestvb->val.string,
219
request->requestvb->val_len);
220
entry->mteDeltaDiscontID_len =
221
request->requestvb->val_len/sizeof(oid);
222
entry->flags &= ~MTE_TRIGGER_FLAG_SYSUPT;
225
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
226
if (*request->requestvb->val.integer == TV_TRUE)
227
entry->flags |= MTE_TRIGGER_FLAG_DWILD;
229
entry->flags &= ~MTE_TRIGGER_FLAG_DWILD;
231
case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
232
entry->mteDeltaDiscontIDType = *request->requestvb->val.integer;
238
return SNMP_ERR_NOERROR;