2 * Note: this file originally auto-generated by mib2c using
3 * : mib2c.create-dataset.conf,v 5.2 2002/07/17 14:41:53 dts12 Exp $
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8 #include <net-snmp/agent/net-snmp-agent-includes.h>
9 #include "mteTriggerTable.h"
10 #include "mteEventTable.h"
11 #include "mteEventNotificationTable.h"
12 #include "mteObjectsTable.h"
14 netsnmp_table_data_set *table_set = NULL;
16 /** Initialize the mteEventTable table by defining its contents and how it's structured */
18 initialize_table_mteEventTable(void)
20 static oid mteEventTable_oid[] =
21 { 1, 3, 6, 1, 2, 1, 88, 1, 4, 2 };
22 size_t mteEventTable_oid_len = OID_LENGTH(mteEventTable_oid);
25 * create the table structure itself
27 table_set = netsnmp_create_table_data_set("mteEventTable");
30 * comment this out or delete if you don't support creation of new rows
32 table_set->allow_creation = 1;
33 /* mark the row status column */
34 table_set->rowstatus_column = COLUMN_MTEEVENTENTRYSTATUS;
36 /***************************************************
39 DEBUGMSGTL(("initialize_table_mteEventTable",
40 "adding indexes to table mteEventTable\n"));
41 netsnmp_table_set_add_indexes(table_set,
42 ASN_OCTET_STR, /* index: mteOwner */
43 ASN_PRIV_IMPLIED_OCTET_STR, /* index: mteEventName */
46 DEBUGMSGTL(("initialize_table_mteEventTable",
47 "adding column types to table mteEventTable\n"));
48 netsnmp_table_set_multi_add_default_row(table_set,
50 ASN_OCTET_STR, 0, NULL, 0,
51 COLUMN_MTEEVENTCOMMENT,
52 ASN_OCTET_STR, 1, NULL, 0,
53 COLUMN_MTEEVENTACTIONS,
54 ASN_OCTET_STR, 1, NULL, 0,
55 COLUMN_MTEEVENTENABLED,
56 ASN_INTEGER, 1, NULL, 0,
57 COLUMN_MTEEVENTENTRYSTATUS,
58 ASN_INTEGER, 1, NULL, 0, 0);
60 /* keep index values around for comparisons later */
61 table_set->table->store_indexes = 1;
63 * registering the table with the master agent
66 * note: if you don't need a subhandler to deal with any aspects
67 * of the request, change mteEventTable_handler to "NULL"
69 netsnmp_register_table_data_set(netsnmp_create_handler_registration
71 mteEventTable_handler,
73 mteEventTable_oid_len,
74 HANDLER_CAN_RWRITE), table_set, NULL);
77 /** Initializes the mteEventTable module */
79 init_mteEventTable(void)
83 * here we initialize all the tables we're planning on supporting
85 initialize_table_mteEventTable();
88 /** handles requests for the mteEventTable table, if anything else needs to be done */
90 mteEventTable_handler(netsnmp_mib_handler *handler,
91 netsnmp_handler_registration *reginfo,
92 netsnmp_agent_request_info *reqinfo,
93 netsnmp_request_info *requests)
96 * perform anything here that you need to do. The requests have
97 * already been processed by the master table_dataset handler, but
98 * this gives you chance to act on the request in some other way
102 /* XXX: on rowstatus = destroy, remove the corresponding rows from the
103 other tables: snmpEventNotificationTable and the set table */
104 return SNMP_ERR_NOERROR;
111 run_mte_events(struct mteTriggerTable_data *item,
112 oid * name_oid, size_t name_oid_len,
113 const char *eventobjowner, const char *eventobjname)
115 static oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; /* snmpTrapIOD.0 */
117 netsnmp_variable_list *var_list = NULL;
119 netsnmp_table_row *row, *notif_row;
120 netsnmp_table_data_set_storage *col1, *tc, *no, *noo;
122 for(row = table_set->table->first_row; row; row = row->next) {
123 if (strcmp(row->indexes->val.string, eventobjowner) == 0 &&
124 strcmp(row->indexes->next_variable->val.string,
125 eventobjname) == 0) {
127 col1 = (netsnmp_table_data_set_storage *) row->data;
129 tc = netsnmp_table_data_set_find_column(col1,
130 COLUMN_MTEEVENTACTIONS);
131 if (!tc->data.bitstring[0] & 0x80) {
132 /* not a notification. next! (XXX: do sets) */
136 tc = netsnmp_table_data_set_find_column(col1,
137 COLUMN_MTEEVENTENABLED);
138 if (*(tc->data.integer) != 1) {
139 /* not enabled. next! */
143 if (!mteEventNotif_table_set) {
144 /* no notification info */
148 /* send the notification */
151 /* XXX: get notif information */
152 for(notif_row = mteEventNotif_table_set->table->first_row;
153 notif_row; notif_row = notif_row->next) {
154 if (strcmp(notif_row->indexes->val.string,
155 eventobjowner) == 0 &&
156 strcmp(notif_row->indexes->next_variable->val.string,
157 eventobjname) == 0) {
160 col1 = (netsnmp_table_data_set_storage *) notif_row->data;
162 tc = netsnmp_table_data_set_find_column(col1, COLUMN_MTEEVENTNOTIFICATION);
163 no = netsnmp_table_data_set_find_column(col1, COLUMN_MTEEVENTNOTIFICATIONOBJECTS);
164 noo = netsnmp_table_data_set_find_column(col1, COLUMN_MTEEVENTNOTIFICATIONOBJECTSOWNER);
166 continue; /* no notification to be had. XXX: return? */
171 snmp_varlist_add_variable(&var_list, objid_snmptrap,
172 sizeof(objid_snmptrap) /
175 (u_char *) tc->data.objid,
178 /* XXX: add objects from the mteObjectsTable */
179 if (no && no->data.string &&
180 noo && noo->data.string && name_oid) {
181 mte_add_objects(var_list, item,
184 name_oid + item->mteTriggerValueIDLen,
185 name_oid_len - item->mteTriggerValueIDLen);
188 DEBUGMSGTL(("mteEventTable:send_events", "sending an event "));
189 DEBUGMSGOID(("mteEventTable:send_events", tc->data.objid, tc->data_len / sizeof(oid)));
190 DEBUGMSG(("mteEventTable:send_events", "\n"));
192 send_v2trap(var_list);
193 snmp_free_varbind(var_list);