|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* DisMan Event MIB:
|
|
Packit |
fcad23 |
* Implementation of the event table configure handling
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-config.h>
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-features.h>
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-includes.h>
|
|
Packit |
fcad23 |
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
Packit |
fcad23 |
#include <net-snmp/agent/agent_callbacks.h>
|
|
Packit |
fcad23 |
#include "disman/event/mteObjects.h"
|
|
Packit |
fcad23 |
#include "disman/event/mteEvent.h"
|
|
Packit |
fcad23 |
#include "disman/event/mteEventConf.h"
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
netsnmp_feature_require(iquery)
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/** Initializes the mteEventsConf module */
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
init_mteEventConf(void)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
init_event_table_data();
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Register config handlers for user-level (fixed) events....
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
snmpd_register_config_handler("notificationEvent",
|
|
Packit |
fcad23 |
parse_notificationEvent, NULL,
|
|
Packit |
fcad23 |
"eventname notifyOID [-m] [-i OID|-o OID]*");
|
|
Packit |
fcad23 |
snmpd_register_config_handler("setEvent",
|
|
Packit |
fcad23 |
parse_setEvent, NULL,
|
|
Packit |
fcad23 |
"eventname [-I] OID = value");
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
netsnmp_ds_register_config(ASN_BOOLEAN,
|
|
Packit |
fcad23 |
netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
|
|
Packit |
fcad23 |
NETSNMP_DS_LIB_APPTYPE),
|
|
Packit |
fcad23 |
"strictDisman", NETSNMP_DS_APPLICATION_ID,
|
|
Packit |
fcad23 |
NETSNMP_DS_AGENT_STRICT_DISMAN);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* ... and for persistent storage of dynamic event table entries.
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* (The previous implementation didn't store these entries,
|
|
Packit |
fcad23 |
* so we don't need to worry about backwards compatability)
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
snmpd_register_config_handler("_mteETable",
|
|
Packit |
fcad23 |
parse_mteETable, NULL, NULL);
|
|
Packit |
fcad23 |
snmpd_register_config_handler("_mteENotTable",
|
|
Packit |
fcad23 |
parse_mteENotTable, NULL, NULL);
|
|
Packit |
fcad23 |
snmpd_register_config_handler("_mteESetTable",
|
|
Packit |
fcad23 |
parse_mteESetTable, NULL, NULL);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Register to save (non-fixed) entries when the agent shuts down
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
|
|
Packit |
fcad23 |
store_mteETable, NULL);
|
|
Packit |
fcad23 |
snmp_register_callback(SNMP_CALLBACK_APPLICATION,
|
|
Packit |
fcad23 |
SNMPD_CALLBACK_PRE_UPDATE_CONFIG,
|
|
Packit |
fcad23 |
clear_mteETable, NULL);
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* ==============================
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* utility routines
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* ============================== */
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Find or create the specified event entry
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
static struct mteEvent *
|
|
Packit |
fcad23 |
_find_mteEvent_entry( const char *owner, const char *ename )
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
netsnmp_variable_list owner_var, ename_var;
|
|
Packit |
fcad23 |
netsnmp_tdata_row *row;
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* If there's already an existing entry,
|
|
Packit |
fcad23 |
* then use that...
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset(&owner_var, 0, sizeof(netsnmp_variable_list));
|
|
Packit |
fcad23 |
memset(&ename_var, 0, sizeof(netsnmp_variable_list));
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(&owner_var, ASN_OCTET_STR, owner, strlen(owner));
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(&ename_var, ASN_PRIV_IMPLIED_OCTET_STR,
|
|
Packit |
fcad23 |
ename, strlen(ename));
|
|
Packit |
fcad23 |
owner_var.next_variable = &ename_var;
|
|
Packit |
fcad23 |
row = netsnmp_tdata_row_get_byidx( event_table_data, &owner_var );
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* ... otherwise, create a new one
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
if (!row)
|
|
Packit |
fcad23 |
row = mteEvent_createEntry( owner, ename, 0 );
|
|
Packit |
fcad23 |
if (!row)
|
|
Packit |
fcad23 |
return NULL;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* return (struct mteEvent *)netsnmp_tdata_row_entry( row ); */
|
|
Packit |
fcad23 |
return (struct mteEvent *)row->data;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
static struct mteEvent *
|
|
Packit |
fcad23 |
_find_typed_mteEvent_entry( const char *owner, const char *ename, int type )
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
struct mteEvent *entry = _find_mteEvent_entry( owner, ename );
|
|
Packit |
fcad23 |
if (!entry)
|
|
Packit |
fcad23 |
return NULL;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* If this is an existing (i.e. valid) entry of the
|
|
Packit |
fcad23 |
* same type, then throw an error and discard it.
|
|
Packit |
fcad23 |
* But allow combined Set/Notification events.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
if ( entry &&
|
|
Packit |
fcad23 |
(entry->flags & MTE_EVENT_FLAG_VALID) &&
|
|
Packit |
fcad23 |
(entry->mteEventActions & type )) {
|
|
Packit |
fcad23 |
config_perror("error: duplicate event name");
|
|
Packit |
fcad23 |
return NULL;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
return entry;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* ==============================
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* User-configured (static) events
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* ============================== */
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
parse_notificationEvent( const char *token, char *line )
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char ename[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
char buf[SPRINT_MAX_LEN];
|
|
Packit |
fcad23 |
oid name_buf[MAX_OID_LEN];
|
|
Packit |
fcad23 |
size_t name_buf_len;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
struct mteObject *object;
|
|
Packit |
fcad23 |
int wild = 1;
|
|
Packit |
fcad23 |
int idx = 0;
|
|
Packit |
fcad23 |
char *cp;
|
|
Packit |
fcad23 |
#ifndef NETSNMP_DISABLE_MIB_LOADING
|
|
Packit |
fcad23 |
struct tree *tp;
|
|
Packit |
fcad23 |
#endif
|
|
Packit |
fcad23 |
struct varbind_list *var;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Parsing notificationEvent config\n"));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* The event name could be used directly to index the mteObjectsTable.
|
|
Packit |
fcad23 |
* But it's quite possible that the same name could also be used to
|
|
Packit |
fcad23 |
* set up a mteTriggerTable entry (with trigger-specific objects).
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* To avoid such a clash, we'll add a prefix ("_E").
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset(ename, 0, sizeof(ename));
|
|
Packit |
fcad23 |
ename[0] = '_';
|
|
Packit |
fcad23 |
ename[1] = 'E';
|
|
Packit |
fcad23 |
cp = copy_nword(line, ename+2, MTE_STR1_LEN-2);
|
|
Packit |
fcad23 |
if (!cp || ename[2] == '\0') {
|
|
Packit |
fcad23 |
config_perror("syntax error: no event name");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Parse the notification OID field ...
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN);
|
|
Packit |
fcad23 |
if ( buf[0] == '\0' ) {
|
|
Packit |
fcad23 |
config_perror("syntax error: no notification OID");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
name_buf_len = MAX_OID_LEN;
|
|
Packit |
fcad23 |
if (!snmp_parse_oid(buf, name_buf, &name_buf_len)) {
|
|
Packit |
fcad23 |
snmp_log(LOG_ERR, "notificationEvent OID: %s\n", buf);
|
|
Packit |
fcad23 |
config_perror("unknown notification OID");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* ... and the relevant object/instances.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
if ( cp && *cp=='-' && *(cp+1)=='m' ) {
|
|
Packit |
fcad23 |
#ifdef NETSNMP_DISABLE_MIB_LOADING
|
|
Packit |
fcad23 |
config_perror("Can't use -m if MIB loading is disabled");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
#else
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Use the MIB definition to add the standard
|
|
Packit |
fcad23 |
* notification payload to the mteObjectsTable.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
cp = skip_token( cp );
|
|
Packit |
fcad23 |
tp = get_tree( name_buf, name_buf_len, get_tree_head());
|
|
Packit |
fcad23 |
if (!tp) {
|
|
Packit |
fcad23 |
config_perror("Can't locate notification payload info");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
for (var = tp->varbinds; var; var=var->next) {
|
|
Packit |
fcad23 |
idx++;
|
|
Packit |
fcad23 |
object = mteObjects_addOID( "snmpd.conf", ename, idx,
|
|
Packit |
fcad23 |
var->vblabel, wild );
|
|
Packit |
fcad23 |
idx = object->mteOIndex;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
#endif
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
while (cp) {
|
|
Packit |
fcad23 |
if ( *cp == '-' ) {
|
|
Packit |
fcad23 |
switch (*(cp+1)) {
|
|
Packit |
fcad23 |
case 'm':
|
|
Packit |
fcad23 |
config_perror("-m option must come first");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
case 'i': /* exact instance */
|
|
Packit |
fcad23 |
case 'w': /* "not-wild" (backward compatability) */
|
|
Packit |
fcad23 |
wild = 0;
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case 'o': /* wildcarded object */
|
|
Packit |
fcad23 |
wild = 1;
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
default:
|
|
Packit |
fcad23 |
config_perror("unrecognised option");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
cp = skip_token( cp );
|
|
Packit |
fcad23 |
if (!cp) {
|
|
Packit |
fcad23 |
config_perror("missing parameter");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
idx++;
|
|
Packit |
fcad23 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN);
|
|
Packit |
fcad23 |
object = mteObjects_addOID( "snmpd.conf", ename, idx, buf, wild );
|
|
Packit |
fcad23 |
idx = object->mteOIndex;
|
|
Packit |
fcad23 |
wild = 1; /* default to wildcarded objects */
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* If the entry has parsed successfully, then create,
|
|
Packit |
fcad23 |
* populate and activate the new event entry.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
entry = _find_typed_mteEvent_entry("snmpd.conf", ename+2,
|
|
Packit |
fcad23 |
MTE_EVENT_NOTIFICATION);
|
|
Packit |
fcad23 |
if (!entry) {
|
|
Packit |
fcad23 |
mteObjects_removeEntries( "snmpd.conf", ename );
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
entry->mteNotification_len = name_buf_len;
|
|
Packit |
fcad23 |
memcpy( entry->mteNotification, name_buf, name_buf_len*sizeof(oid));
|
|
Packit |
fcad23 |
memcpy( entry->mteNotifyOwner, "snmpd.conf", 10 );
|
|
Packit |
fcad23 |
memcpy( entry->mteNotifyObjects, ename, MTE_STR1_LEN );
|
|
Packit |
fcad23 |
entry->mteEventActions |= MTE_EVENT_NOTIFICATION;
|
|
Packit |
fcad23 |
entry->flags |= MTE_EVENT_FLAG_ENABLED |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_ACTIVE |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_FIXED |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_VALID;
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
parse_setEvent( const char *token, char *line )
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char ename[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
char buf[SPRINT_MAX_LEN];
|
|
Packit |
fcad23 |
oid name_buf[MAX_OID_LEN];
|
|
Packit |
fcad23 |
size_t name_buf_len;
|
|
Packit |
fcad23 |
long value;
|
|
Packit |
fcad23 |
int wild = 1;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
char *cp;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Parsing setEvent config... "));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
memset( ename, 0, sizeof(ename));
|
|
Packit |
fcad23 |
cp = copy_nword(line, ename, MTE_STR1_LEN);
|
|
Packit |
fcad23 |
if (!cp || ename[0] == '\0') {
|
|
Packit |
fcad23 |
config_perror("syntax error: no event name");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
if (cp && *cp=='-' && *(cp+1)=='I') {
|
|
Packit |
fcad23 |
wild = 0; /* an instance assignment */
|
|
Packit |
fcad23 |
cp = skip_token( cp );
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Parse the SET assignment in the form "OID = value"
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN);
|
|
Packit |
fcad23 |
if ( buf[0] == '\0' ) {
|
|
Packit |
fcad23 |
config_perror("syntax error: no set OID");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
name_buf_len = MAX_OID_LEN;
|
|
Packit |
fcad23 |
if (!snmp_parse_oid(buf, name_buf, &name_buf_len)) {
|
|
Packit |
fcad23 |
snmp_log(LOG_ERR, "setEvent OID: %s\n", buf);
|
|
Packit |
fcad23 |
config_perror("unknown set OID");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
if (cp && *cp == '=') {
|
|
Packit |
fcad23 |
cp = skip_token( cp ); /* skip the '=' assignment character */
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
if (!cp) {
|
|
Packit |
fcad23 |
config_perror("syntax error: missing set value");
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
value = strtol( cp, NULL, 0);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* If the entry has parsed successfully, then create,
|
|
Packit |
fcad23 |
* populate and activate the new event entry.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
entry = _find_typed_mteEvent_entry("snmpd.conf", ename, MTE_EVENT_SET);
|
|
Packit |
fcad23 |
if (!entry) {
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
memcpy( entry->mteSetOID, name_buf, name_buf_len*sizeof(oid));
|
|
Packit |
fcad23 |
entry->mteSetOID_len = name_buf_len;
|
|
Packit |
fcad23 |
entry->mteSetValue = value;
|
|
Packit |
fcad23 |
if (wild)
|
|
Packit |
fcad23 |
entry->flags |= MTE_SET_FLAG_OBJWILD;
|
|
Packit |
fcad23 |
entry->mteEventActions |= MTE_EVENT_SET;
|
|
Packit |
fcad23 |
entry->flags |= MTE_EVENT_FLAG_ENABLED |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_ACTIVE |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_FIXED |
|
|
Packit |
fcad23 |
MTE_EVENT_FLAG_VALID;
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* ==============================
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* Persistent (dynamic) configuration
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* ============================== */
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
parse_mteETable(const char *token, char *line )
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char owner[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
char ename[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
void *vp;
|
|
Packit |
fcad23 |
size_t tmp;
|
|
Packit |
fcad23 |
size_t len;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteEventTable config... "));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the index information for this entry
|
|
Packit |
fcad23 |
* and create a (non-fixed) data structure for it.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset( owner, 0, sizeof(owner));
|
|
Packit |
fcad23 |
memset( ename, 0, sizeof(ename));
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = owner;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = ename;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
entry = _find_mteEvent_entry( owner, ename );
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the accessible (event-independent) column values.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
len = MTE_STR2_LEN; vp = entry->mteEventComment;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Skip the mteEventAction field, and note that the
|
|
Packit |
fcad23 |
* boolean values are combined into a single field.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_UNSIGNED, line, &tmp, NULL);
|
|
Packit |
fcad23 |
entry->flags |= (tmp &
|
|
Packit |
fcad23 |
(MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE));
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* XXX - Will need to read in the 'iquery' access information
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
entry->flags |= MTE_EVENT_FLAG_VALID;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "\n"));
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
parse_mteENotTable(const char *token, char *line)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char owner[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
char ename[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
void *vp;
|
|
Packit |
fcad23 |
size_t len;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteENotifyTable config... "));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the index information for this entry
|
|
Packit |
fcad23 |
* and create a (non-fixed) data structure for it.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset( owner, 0, sizeof(owner));
|
|
Packit |
fcad23 |
memset( ename, 0, sizeof(ename));
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = owner;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = ename;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
entry = _find_mteEvent_entry( owner, ename );
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the accessible column values.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
vp = entry->mteNotification;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OBJECT_ID, line, &vp,
|
|
Packit |
fcad23 |
&entry->mteNotification_len);
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = entry->mteNotifyOwner;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = entry->mteNotifyObjects;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry->mteEventActions |= MTE_EVENT_NOTIFICATION;
|
|
Packit |
fcad23 |
entry->flags |= MTE_EVENT_FLAG_VALID;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "\n"));
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
parse_mteESetTable(const char *token, char *line)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char owner[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
char ename[MTE_STR1_LEN+1];
|
|
Packit |
fcad23 |
void *vp;
|
|
Packit |
fcad23 |
size_t len;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteESetTable config... "));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the index information for this entry
|
|
Packit |
fcad23 |
* and create a (non-fixed) data structure for it.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset( owner, 0, sizeof(owner));
|
|
Packit |
fcad23 |
memset( ename, 0, sizeof(ename));
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = owner;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR1_LEN; vp = ename;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
entry = _find_mteEvent_entry( owner, ename );
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read in the accessible column values.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
vp = entry->mteSetOID;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OBJECT_ID, line, &vp,
|
|
Packit |
fcad23 |
&entry->mteSetOID_len);
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_UNSIGNED, line,
|
|
Packit |
fcad23 |
&entry->mteSetValue, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR2_LEN; vp = entry->mteSetTarget;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
len = MTE_STR2_LEN; vp = entry->mteSetContext;
|
|
Packit |
fcad23 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len;;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry->mteEventActions |= MTE_EVENT_SET;
|
|
Packit |
fcad23 |
entry->flags |= MTE_EVENT_FLAG_VALID;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSG(("disman:event:conf", "\n"));
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
int
|
|
Packit |
fcad23 |
store_mteETable(int majorID, int minorID, void *serverarg, void *clientarg)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
char line[SNMP_MAXBUF];
|
|
Packit |
fcad23 |
char *cptr, *cp;
|
|
Packit |
fcad23 |
void *vp;
|
|
Packit |
fcad23 |
size_t tint;
|
|
Packit |
fcad23 |
netsnmp_tdata_row *row;
|
|
Packit |
fcad23 |
struct mteEvent *entry;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", "Storing mteEventTable config:\n"));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
for (row = netsnmp_tdata_row_first( event_table_data );
|
|
Packit |
fcad23 |
row;
|
|
Packit |
fcad23 |
row = netsnmp_tdata_row_next( event_table_data, row )) {
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Skip entries that were set up via static config directives
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
entry = (struct mteEvent *)netsnmp_tdata_row_entry( row );
|
|
Packit |
fcad23 |
if ( entry->flags & MTE_EVENT_FLAG_FIXED )
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", " Storing (%s %s)\n",
|
|
Packit |
fcad23 |
entry->mteOwner, entry->mteEName));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Save the basic mteEventTable entry...
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset(line, 0, sizeof(line));
|
|
Packit |
fcad23 |
strcat(line, "_mteETable ");
|
|
Packit |
fcad23 |
cptr = line + strlen(line);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
cp = entry->mteOwner; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteEName; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteEventComment; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
/* ... (but skip the mteEventAction field)... */
|
|
Packit |
fcad23 |
tint = entry->flags & (MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE);
|
|
Packit |
fcad23 |
cptr = read_config_store_data( ASN_UNSIGNED, cptr, &tint, NULL );
|
|
Packit |
fcad23 |
/* XXX - Need to store the 'iquery' access information */
|
|
Packit |
fcad23 |
snmpd_store_config(line);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* ... then save Notify and/or Set entries separately
|
|
Packit |
fcad23 |
* (The mteEventAction bits will be set when these are read in).
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
if ( entry->mteEventActions & MTE_EVENT_NOTIFICATION ) {
|
|
Packit |
fcad23 |
memset(line, 0, sizeof(line));
|
|
Packit |
fcad23 |
strcat(line, "_mteENotTable ");
|
|
Packit |
fcad23 |
cptr = line + strlen(line);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
cp = entry->mteOwner; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteEName; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
vp = entry->mteNotification;
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp,
|
|
Packit |
fcad23 |
&entry->mteNotification_len);
|
|
Packit |
fcad23 |
cp = entry->mteNotifyOwner; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteNotifyObjects; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
snmpd_store_config(line);
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
if ( entry->mteEventActions & MTE_EVENT_SET ) {
|
|
Packit |
fcad23 |
memset(line, 0, sizeof(line));
|
|
Packit |
fcad23 |
strcat(line, "_mteESetTable ");
|
|
Packit |
fcad23 |
cptr = line + strlen(line);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
cp = entry->mteOwner; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteEName; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
vp = entry->mteSetOID;
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp,
|
|
Packit |
fcad23 |
&entry->mteSetOID_len);
|
|
Packit |
fcad23 |
tint = entry->mteSetValue;
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_INTEGER, cptr, &tint, NULL);
|
|
Packit |
fcad23 |
cp = entry->mteSetTarget; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
cp = entry->mteSetContext; tint = strlen( cp );
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint );
|
|
Packit |
fcad23 |
tint = entry->flags & (MTE_SET_FLAG_OBJWILD|MTE_SET_FLAG_CTXWILD);
|
|
Packit |
fcad23 |
cptr = read_config_store_data(ASN_UNSIGNED, cptr, &tint, NULL);
|
|
Packit |
fcad23 |
snmpd_store_config(line);
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:conf", " done.\n"));
|
|
Packit |
fcad23 |
return SNMPERR_SUCCESS;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
int
|
|
Packit |
fcad23 |
clear_mteETable(int majorID, int minorID, void *serverarg, void *clientarg)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
netsnmp_tdata_row *row;
|
|
Packit |
fcad23 |
netsnmp_variable_list owner_var;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* We're only interested in entries set up via the config files
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
memset( &owner_var, 0, sizeof(netsnmp_variable_list));
|
|
Packit |
fcad23 |
snmp_set_var_typed_value( &owner_var, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
"snmpd.conf", strlen("snmpd.conf"));
|
|
Packit |
fcad23 |
while (( row = netsnmp_tdata_row_next_byidx( event_table_data,
|
|
Packit |
fcad23 |
&owner_var ))) {
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* XXX - check for owner of "snmpd.conf"
|
|
Packit |
fcad23 |
* and break at the end of these
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
netsnmp_tdata_remove_and_delete_row( event_table_data, row );
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
return SNMPERR_SUCCESS;
|
|
Packit |
fcad23 |
}
|