| 1 |
/* |
| 2 |
* DisMan Event MIB: |
| 3 |
* Implementation of the event table configure handling |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <net-snmp/net-snmp-config.h> |
| 7 |
#include <net-snmp/net-snmp-features.h> |
| 8 |
#include <net-snmp/net-snmp-includes.h> |
| 9 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 10 |
#include <net-snmp/agent/agent_callbacks.h> |
| 11 |
#include "disman/event/mteObjects.h" |
| 12 |
#include "disman/event/mteEvent.h" |
| 13 |
#include "disman/event/mteEventConf.h" |
| 14 |
|
| 15 |
netsnmp_feature_require(iquery); |
| 16 |
|
| 17 |
/** Initializes the mteEventsConf module */ |
| 18 |
void |
| 19 |
init_mteEventConf(void) |
| 20 |
{ |
| 21 |
init_event_table_data(); |
| 22 |
|
| 23 |
/* |
| 24 |
* Register config handlers for user-level (fixed) events.... |
| 25 |
*/ |
| 26 |
snmpd_register_config_handler("notificationEvent", |
| 27 |
parse_notificationEvent, NULL, |
| 28 |
"eventname notifyOID [-m] [-i OID|-o OID]*"); |
| 29 |
snmpd_register_config_handler("setEvent", |
| 30 |
parse_setEvent, NULL, |
| 31 |
"eventname [-I] OID = value"); |
| 32 |
|
| 33 |
netsnmp_ds_register_config(ASN_BOOLEAN, |
| 34 |
netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, |
| 35 |
NETSNMP_DS_LIB_APPTYPE), |
| 36 |
"strictDisman", NETSNMP_DS_APPLICATION_ID, |
| 37 |
NETSNMP_DS_AGENT_STRICT_DISMAN); |
| 38 |
|
| 39 |
/* |
| 40 |
* ... and for persistent storage of dynamic event table entries. |
| 41 |
* |
| 42 |
* (The previous implementation didn't store these entries, |
| 43 |
* so we don't need to worry about backwards compatability) |
| 44 |
*/ |
| 45 |
snmpd_register_config_handler("_mteETable", |
| 46 |
parse_mteETable, NULL, NULL); |
| 47 |
snmpd_register_config_handler("_mteENotTable", |
| 48 |
parse_mteENotTable, NULL, NULL); |
| 49 |
snmpd_register_config_handler("_mteESetTable", |
| 50 |
parse_mteESetTable, NULL, NULL); |
| 51 |
|
| 52 |
/* |
| 53 |
* Register to save (non-fixed) entries when the agent shuts down |
| 54 |
*/ |
| 55 |
snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, |
| 56 |
store_mteETable, NULL); |
| 57 |
snmp_register_callback(SNMP_CALLBACK_APPLICATION, |
| 58 |
SNMPD_CALLBACK_PRE_UPDATE_CONFIG, |
| 59 |
clear_mteETable, NULL); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
/* ============================== |
| 64 |
* |
| 65 |
* utility routines |
| 66 |
* |
| 67 |
* ============================== */ |
| 68 |
|
| 69 |
/* |
| 70 |
* Find or create the specified event entry |
| 71 |
*/ |
| 72 |
static struct mteEvent * |
| 73 |
_find_mteEvent_entry( const char *owner, const char *ename ) |
| 74 |
{ |
| 75 |
netsnmp_variable_list owner_var, ename_var; |
| 76 |
netsnmp_tdata_row *row; |
| 77 |
/* |
| 78 |
* If there's already an existing entry, |
| 79 |
* then use that... |
| 80 |
*/ |
| 81 |
memset(&owner_var, 0, sizeof(netsnmp_variable_list)); |
| 82 |
memset(&ename_var, 0, sizeof(netsnmp_variable_list)); |
| 83 |
snmp_set_var_typed_value(&owner_var, ASN_OCTET_STR, owner, strlen(owner)); |
| 84 |
snmp_set_var_typed_value(&ename_var, ASN_PRIV_IMPLIED_OCTET_STR, |
| 85 |
ename, strlen(ename)); |
| 86 |
owner_var.next_variable = &ename_var; |
| 87 |
row = netsnmp_tdata_row_get_byidx( event_table_data, &owner_var ); |
| 88 |
/* |
| 89 |
* ... otherwise, create a new one |
| 90 |
*/ |
| 91 |
if (!row) |
| 92 |
row = mteEvent_createEntry( owner, ename, 0 ); |
| 93 |
if (!row) |
| 94 |
return NULL; |
| 95 |
|
| 96 |
/* return (struct mteEvent *)netsnmp_tdata_row_entry( row ); */ |
| 97 |
return (struct mteEvent *)row->data; |
| 98 |
} |
| 99 |
|
| 100 |
static struct mteEvent * |
| 101 |
_find_typed_mteEvent_entry( const char *owner, const char *ename, int type ) |
| 102 |
{ |
| 103 |
struct mteEvent *entry = _find_mteEvent_entry( owner, ename ); |
| 104 |
if (!entry) |
| 105 |
return NULL; |
| 106 |
|
| 107 |
/* |
| 108 |
* If this is an existing (i.e. valid) entry of the |
| 109 |
* same type, then throw an error and discard it. |
| 110 |
* But allow combined Set/Notification events. |
| 111 |
*/ |
| 112 |
if ( entry && |
| 113 |
(entry->flags & MTE_EVENT_FLAG_VALID) && |
| 114 |
(entry->mteEventActions & type )) { |
| 115 |
config_perror("error: duplicate event name"); |
| 116 |
return NULL; |
| 117 |
} |
| 118 |
return entry; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
/* ============================== |
| 123 |
* |
| 124 |
* User-configured (static) events |
| 125 |
* |
| 126 |
* ============================== */ |
| 127 |
|
| 128 |
void |
| 129 |
parse_notificationEvent( const char *token, char *line ) |
| 130 |
{ |
| 131 |
char ename[MTE_STR1_LEN+1]; |
| 132 |
char buf[SPRINT_MAX_LEN]; |
| 133 |
oid name_buf[MAX_OID_LEN]; |
| 134 |
size_t name_buf_len; |
| 135 |
struct mteEvent *entry; |
| 136 |
struct mteObject *object; |
| 137 |
int wild = 1; |
| 138 |
int idx = 0; |
| 139 |
char *cp; |
| 140 |
#ifndef NETSNMP_DISABLE_MIB_LOADING |
| 141 |
struct tree *tp; |
| 142 |
#endif |
| 143 |
struct varbind_list *var; |
| 144 |
|
| 145 |
DEBUGMSGTL(("disman:event:conf", "Parsing notificationEvent config\n")); |
| 146 |
|
| 147 |
/* |
| 148 |
* The event name could be used directly to index the mteObjectsTable. |
| 149 |
* But it's quite possible that the same name could also be used to |
| 150 |
* set up a mteTriggerTable entry (with trigger-specific objects). |
| 151 |
* |
| 152 |
* To avoid such a clash, we'll add a prefix ("_E"). |
| 153 |
*/ |
| 154 |
memset(ename, 0, sizeof(ename)); |
| 155 |
ename[0] = '_'; |
| 156 |
ename[1] = 'E'; |
| 157 |
cp = copy_nword(line, ename+2, MTE_STR1_LEN-2); |
| 158 |
if (!cp || ename[2] == '\0') { |
| 159 |
config_perror("syntax error: no event name"); |
| 160 |
return; |
| 161 |
} |
| 162 |
|
| 163 |
/* |
| 164 |
* Parse the notification OID field ... |
| 165 |
*/ |
| 166 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN); |
| 167 |
if ( buf[0] == '\0' ) { |
| 168 |
config_perror("syntax error: no notification OID"); |
| 169 |
return; |
| 170 |
} |
| 171 |
name_buf_len = MAX_OID_LEN; |
| 172 |
if (!snmp_parse_oid(buf, name_buf, &name_buf_len)) { |
| 173 |
snmp_log(LOG_ERR, "notificationEvent OID: %s\n", buf); |
| 174 |
config_perror("unknown notification OID"); |
| 175 |
return; |
| 176 |
} |
| 177 |
|
| 178 |
/* |
| 179 |
* ... and the relevant object/instances. |
| 180 |
*/ |
| 181 |
if ( cp && *cp=='-' && *(cp+1)=='m' ) { |
| 182 |
#ifdef NETSNMP_DISABLE_MIB_LOADING |
| 183 |
config_perror("Can't use -m if MIB loading is disabled"); |
| 184 |
return; |
| 185 |
#else |
| 186 |
/* |
| 187 |
* Use the MIB definition to add the standard |
| 188 |
* notification payload to the mteObjectsTable. |
| 189 |
*/ |
| 190 |
cp = skip_token( cp ); |
| 191 |
tp = get_tree( name_buf, name_buf_len, get_tree_head()); |
| 192 |
if (!tp) { |
| 193 |
config_perror("Can't locate notification payload info"); |
| 194 |
return; |
| 195 |
} |
| 196 |
for (var = tp->varbinds; var; var=var->next) { |
| 197 |
idx++; |
| 198 |
object = mteObjects_addOID( "snmpd.conf", ename, idx, |
| 199 |
var->vblabel, wild ); |
| 200 |
idx = object->mteOIndex; |
| 201 |
} |
| 202 |
#endif |
| 203 |
} |
| 204 |
while (cp) { |
| 205 |
if ( *cp == '-' ) { |
| 206 |
switch (*(cp+1)) { |
| 207 |
case 'm': |
| 208 |
config_perror("-m option must come first"); |
| 209 |
return; |
| 210 |
case 'i': /* exact instance */ |
| 211 |
case 'w': /* "not-wild" (backward compatability) */ |
| 212 |
wild = 0; |
| 213 |
break; |
| 214 |
case 'o': /* wildcarded object */ |
| 215 |
wild = 1; |
| 216 |
break; |
| 217 |
default: |
| 218 |
config_perror("unrecognised option"); |
| 219 |
return; |
| 220 |
} |
| 221 |
cp = skip_token( cp ); |
| 222 |
if (!cp) { |
| 223 |
config_perror("missing parameter"); |
| 224 |
return; |
| 225 |
} |
| 226 |
} |
| 227 |
idx++; |
| 228 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN); |
| 229 |
object = mteObjects_addOID( "snmpd.conf", ename, idx, buf, wild ); |
| 230 |
idx = object->mteOIndex; |
| 231 |
wild = 1; /* default to wildcarded objects */ |
| 232 |
} |
| 233 |
|
| 234 |
/* |
| 235 |
* If the entry has parsed successfully, then create, |
| 236 |
* populate and activate the new event entry. |
| 237 |
*/ |
| 238 |
entry = _find_typed_mteEvent_entry("snmpd.conf", ename+2, |
| 239 |
MTE_EVENT_NOTIFICATION); |
| 240 |
if (!entry) { |
| 241 |
mteObjects_removeEntries( "snmpd.conf", ename ); |
| 242 |
return; |
| 243 |
} |
| 244 |
entry->mteNotification_len = name_buf_len; |
| 245 |
memcpy( entry->mteNotification, name_buf, name_buf_len*sizeof(oid)); |
| 246 |
memcpy( entry->mteNotifyOwner, "snmpd.conf", 10 ); |
| 247 |
memcpy( entry->mteNotifyObjects, ename, MTE_STR1_LEN ); |
| 248 |
entry->mteEventActions |= MTE_EVENT_NOTIFICATION; |
| 249 |
entry->flags |= MTE_EVENT_FLAG_ENABLED | |
| 250 |
MTE_EVENT_FLAG_ACTIVE | |
| 251 |
MTE_EVENT_FLAG_FIXED | |
| 252 |
MTE_EVENT_FLAG_VALID; |
| 253 |
return; |
| 254 |
} |
| 255 |
|
| 256 |
void |
| 257 |
parse_setEvent( const char *token, char *line ) |
| 258 |
{ |
| 259 |
char ename[MTE_STR1_LEN+1]; |
| 260 |
char buf[SPRINT_MAX_LEN]; |
| 261 |
oid name_buf[MAX_OID_LEN]; |
| 262 |
size_t name_buf_len; |
| 263 |
long value; |
| 264 |
int wild = 1; |
| 265 |
struct mteEvent *entry; |
| 266 |
char *cp; |
| 267 |
|
| 268 |
DEBUGMSGTL(("disman:event:conf", "Parsing setEvent config... ")); |
| 269 |
|
| 270 |
memset( ename, 0, sizeof(ename)); |
| 271 |
cp = copy_nword(line, ename, MTE_STR1_LEN); |
| 272 |
if (!cp || ename[0] == '\0') { |
| 273 |
config_perror("syntax error: no event name"); |
| 274 |
return; |
| 275 |
} |
| 276 |
|
| 277 |
if (cp && *cp=='-' && *(cp+1)=='I') { |
| 278 |
wild = 0; /* an instance assignment */ |
| 279 |
cp = skip_token( cp ); |
| 280 |
} |
| 281 |
|
| 282 |
/* |
| 283 |
* Parse the SET assignment in the form "OID = value" |
| 284 |
*/ |
| 285 |
cp = copy_nword(cp, buf, SPRINT_MAX_LEN); |
| 286 |
if ( buf[0] == '\0' ) { |
| 287 |
config_perror("syntax error: no set OID"); |
| 288 |
return; |
| 289 |
} |
| 290 |
name_buf_len = MAX_OID_LEN; |
| 291 |
if (!snmp_parse_oid(buf, name_buf, &name_buf_len)) { |
| 292 |
snmp_log(LOG_ERR, "setEvent OID: %s\n", buf); |
| 293 |
config_perror("unknown set OID"); |
| 294 |
return; |
| 295 |
} |
| 296 |
if (cp && *cp == '=') { |
| 297 |
cp = skip_token( cp ); /* skip the '=' assignment character */ |
| 298 |
} |
| 299 |
if (!cp) { |
| 300 |
config_perror("syntax error: missing set value"); |
| 301 |
return; |
| 302 |
} |
| 303 |
|
| 304 |
value = strtol( cp, NULL, 0); |
| 305 |
|
| 306 |
/* |
| 307 |
* If the entry has parsed successfully, then create, |
| 308 |
* populate and activate the new event entry. |
| 309 |
*/ |
| 310 |
entry = _find_typed_mteEvent_entry("snmpd.conf", ename, MTE_EVENT_SET); |
| 311 |
if (!entry) { |
| 312 |
return; |
| 313 |
} |
| 314 |
memcpy( entry->mteSetOID, name_buf, name_buf_len*sizeof(oid)); |
| 315 |
entry->mteSetOID_len = name_buf_len; |
| 316 |
entry->mteSetValue = value; |
| 317 |
if (wild) |
| 318 |
entry->flags |= MTE_SET_FLAG_OBJWILD; |
| 319 |
entry->mteEventActions |= MTE_EVENT_SET; |
| 320 |
entry->flags |= MTE_EVENT_FLAG_ENABLED | |
| 321 |
MTE_EVENT_FLAG_ACTIVE | |
| 322 |
MTE_EVENT_FLAG_FIXED | |
| 323 |
MTE_EVENT_FLAG_VALID; |
| 324 |
return; |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
/* ============================== |
| 329 |
* |
| 330 |
* Persistent (dynamic) configuration |
| 331 |
* |
| 332 |
* ============================== */ |
| 333 |
|
| 334 |
void |
| 335 |
parse_mteETable(const char *token, char *line ) |
| 336 |
{ |
| 337 |
char owner[MTE_STR1_LEN+1]; |
| 338 |
char ename[MTE_STR1_LEN+1]; |
| 339 |
void *vp; |
| 340 |
size_t tmp; |
| 341 |
size_t len; |
| 342 |
struct mteEvent *entry; |
| 343 |
|
| 344 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteEventTable config... ")); |
| 345 |
|
| 346 |
/* |
| 347 |
* Read in the index information for this entry |
| 348 |
* and create a (non-fixed) data structure for it. |
| 349 |
*/ |
| 350 |
memset( owner, 0, sizeof(owner)); |
| 351 |
memset( ename, 0, sizeof(ename)); |
| 352 |
len = MTE_STR1_LEN; vp = owner; |
| 353 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 354 |
len = MTE_STR1_LEN; vp = ename; |
| 355 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 356 |
entry = _find_mteEvent_entry( owner, ename ); |
| 357 |
|
| 358 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename)); |
| 359 |
|
| 360 |
/* |
| 361 |
* Read in the accessible (event-independent) column values. |
| 362 |
*/ |
| 363 |
len = MTE_STR2_LEN; vp = entry->mteEventComment; |
| 364 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 365 |
/* |
| 366 |
* Skip the mteEventAction field, and note that the |
| 367 |
* boolean values are combined into a single field. |
| 368 |
*/ |
| 369 |
line = read_config_read_data(ASN_UNSIGNED, line, &tmp, NULL); |
| 370 |
entry->flags |= (tmp & |
| 371 |
(MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE)); |
| 372 |
/* |
| 373 |
* XXX - Will need to read in the 'iquery' access information |
| 374 |
*/ |
| 375 |
entry->flags |= MTE_EVENT_FLAG_VALID; |
| 376 |
|
| 377 |
DEBUGMSG(("disman:event:conf", "\n")); |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
void |
| 382 |
parse_mteENotTable(const char *token, char *line) |
| 383 |
{ |
| 384 |
char owner[MTE_STR1_LEN+1]; |
| 385 |
char ename[MTE_STR1_LEN+1]; |
| 386 |
void *vp; |
| 387 |
size_t len; |
| 388 |
struct mteEvent *entry; |
| 389 |
|
| 390 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteENotifyTable config... ")); |
| 391 |
|
| 392 |
/* |
| 393 |
* Read in the index information for this entry |
| 394 |
* and create a (non-fixed) data structure for it. |
| 395 |
*/ |
| 396 |
memset( owner, 0, sizeof(owner)); |
| 397 |
memset( ename, 0, sizeof(ename)); |
| 398 |
len = MTE_STR1_LEN; vp = owner; |
| 399 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 400 |
len = MTE_STR1_LEN; vp = ename; |
| 401 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 402 |
entry = _find_mteEvent_entry( owner, ename ); |
| 403 |
|
| 404 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename)); |
| 405 |
|
| 406 |
/* |
| 407 |
* Read in the accessible column values. |
| 408 |
*/ |
| 409 |
vp = entry->mteNotification; |
| 410 |
line = read_config_read_data(ASN_OBJECT_ID, line, &vp, |
| 411 |
&entry->mteNotification_len); |
| 412 |
len = MTE_STR1_LEN; vp = entry->mteNotifyOwner; |
| 413 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 414 |
len = MTE_STR1_LEN; vp = entry->mteNotifyObjects; |
| 415 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 416 |
|
| 417 |
entry->mteEventActions |= MTE_EVENT_NOTIFICATION; |
| 418 |
entry->flags |= MTE_EVENT_FLAG_VALID; |
| 419 |
|
| 420 |
DEBUGMSG(("disman:event:conf", "\n")); |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
void |
| 425 |
parse_mteESetTable(const char *token, char *line) |
| 426 |
{ |
| 427 |
char owner[MTE_STR1_LEN+1]; |
| 428 |
char ename[MTE_STR1_LEN+1]; |
| 429 |
void *vp; |
| 430 |
size_t len; |
| 431 |
struct mteEvent *entry; |
| 432 |
|
| 433 |
DEBUGMSGTL(("disman:event:conf", "Parsing mteESetTable config... ")); |
| 434 |
|
| 435 |
/* |
| 436 |
* Read in the index information for this entry |
| 437 |
* and create a (non-fixed) data structure for it. |
| 438 |
*/ |
| 439 |
memset( owner, 0, sizeof(owner)); |
| 440 |
memset( ename, 0, sizeof(ename)); |
| 441 |
len = MTE_STR1_LEN; vp = owner; |
| 442 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 443 |
len = MTE_STR1_LEN; vp = ename; |
| 444 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 445 |
entry = _find_mteEvent_entry( owner, ename ); |
| 446 |
|
| 447 |
DEBUGMSG(("disman:event:conf", "(%s, %s) ", owner, ename)); |
| 448 |
|
| 449 |
/* |
| 450 |
* Read in the accessible column values. |
| 451 |
*/ |
| 452 |
vp = entry->mteSetOID; |
| 453 |
line = read_config_read_data(ASN_OBJECT_ID, line, &vp, |
| 454 |
&entry->mteSetOID_len); |
| 455 |
line = read_config_read_data(ASN_UNSIGNED, line, |
| 456 |
&entry->mteSetValue, &len); |
| 457 |
len = MTE_STR2_LEN; vp = entry->mteSetTarget; |
| 458 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 459 |
len = MTE_STR2_LEN; vp = entry->mteSetContext; |
| 460 |
line = read_config_read_data(ASN_OCTET_STR, line, &vp, &len); |
| 461 |
|
| 462 |
entry->mteEventActions |= MTE_EVENT_SET; |
| 463 |
entry->flags |= MTE_EVENT_FLAG_VALID; |
| 464 |
|
| 465 |
DEBUGMSG(("disman:event:conf", "\n")); |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
int |
| 471 |
store_mteETable(int majorID, int minorID, void *serverarg, void *clientarg) |
| 472 |
{ |
| 473 |
char line[SNMP_MAXBUF]; |
| 474 |
char *cptr, *cp; |
| 475 |
void *vp; |
| 476 |
size_t tint; |
| 477 |
netsnmp_tdata_row *row; |
| 478 |
struct mteEvent *entry; |
| 479 |
|
| 480 |
|
| 481 |
DEBUGMSGTL(("disman:event:conf", "Storing mteEventTable config:\n")); |
| 482 |
|
| 483 |
for (row = netsnmp_tdata_row_first( event_table_data ); |
| 484 |
row; |
| 485 |
row = netsnmp_tdata_row_next( event_table_data, row )) { |
| 486 |
|
| 487 |
/* |
| 488 |
* Skip entries that were set up via static config directives |
| 489 |
*/ |
| 490 |
entry = (struct mteEvent *)netsnmp_tdata_row_entry( row ); |
| 491 |
if ( entry->flags & MTE_EVENT_FLAG_FIXED ) |
| 492 |
continue; |
| 493 |
|
| 494 |
DEBUGMSGTL(("disman:event:conf", " Storing (%s %s)\n", |
| 495 |
entry->mteOwner, entry->mteEName)); |
| 496 |
|
| 497 |
/* |
| 498 |
* Save the basic mteEventTable entry... |
| 499 |
*/ |
| 500 |
memset(line, 0, sizeof(line)); |
| 501 |
strcat(line, "_mteETable "); |
| 502 |
cptr = line + strlen(line); |
| 503 |
|
| 504 |
cp = entry->mteOwner; tint = strlen( cp ); |
| 505 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint ); |
| 506 |
cp = entry->mteEName; tint = strlen( cp ); |
| 507 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint ); |
| 508 |
cp = entry->mteEventComment; tint = strlen( cp ); |
| 509 |
cptr = read_config_store_data( ASN_OCTET_STR, cptr, &cp, &tint ); |
| 510 |
/* ... (but skip the mteEventAction field)... */ |
| 511 |
tint = entry->flags & (MTE_EVENT_FLAG_ENABLED|MTE_EVENT_FLAG_ACTIVE); |
| 512 |
cptr = read_config_store_data( ASN_UNSIGNED, cptr, &tint, NULL ); |
| 513 |
/* XXX - Need to store the 'iquery' access information */ |
| 514 |
snmpd_store_config(line); |
| 515 |
|
| 516 |
/* |
| 517 |
* ... then save Notify and/or Set entries separately |
| 518 |
* (The mteEventAction bits will be set when these are read in). |
| 519 |
*/ |
| 520 |
if ( entry->mteEventActions & MTE_EVENT_NOTIFICATION ) { |
| 521 |
memset(line, 0, sizeof(line)); |
| 522 |
strcat(line, "_mteENotTable "); |
| 523 |
cptr = line + strlen(line); |
| 524 |
|
| 525 |
cp = entry->mteOwner; tint = strlen( cp ); |
| 526 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 527 |
cp = entry->mteEName; tint = strlen( cp ); |
| 528 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 529 |
vp = entry->mteNotification; |
| 530 |
cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp, |
| 531 |
&entry->mteNotification_len); |
| 532 |
cp = entry->mteNotifyOwner; tint = strlen( cp ); |
| 533 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 534 |
cp = entry->mteNotifyObjects; tint = strlen( cp ); |
| 535 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 536 |
snmpd_store_config(line); |
| 537 |
} |
| 538 |
|
| 539 |
if ( entry->mteEventActions & MTE_EVENT_SET ) { |
| 540 |
memset(line, 0, sizeof(line)); |
| 541 |
strcat(line, "_mteESetTable "); |
| 542 |
cptr = line + strlen(line); |
| 543 |
|
| 544 |
cp = entry->mteOwner; tint = strlen( cp ); |
| 545 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 546 |
cp = entry->mteEName; tint = strlen( cp ); |
| 547 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 548 |
vp = entry->mteSetOID; |
| 549 |
cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &vp, |
| 550 |
&entry->mteSetOID_len); |
| 551 |
tint = entry->mteSetValue; |
| 552 |
cptr = read_config_store_data(ASN_INTEGER, cptr, &tint, NULL); |
| 553 |
cp = entry->mteSetTarget; tint = strlen( cp ); |
| 554 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 555 |
cp = entry->mteSetContext; tint = strlen( cp ); |
| 556 |
cptr = read_config_store_data(ASN_OCTET_STR, cptr, &cp, &tint ); |
| 557 |
tint = entry->flags & (MTE_SET_FLAG_OBJWILD|MTE_SET_FLAG_CTXWILD); |
| 558 |
cptr = read_config_store_data(ASN_UNSIGNED, cptr, &tint, NULL); |
| 559 |
snmpd_store_config(line); |
| 560 |
} |
| 561 |
} |
| 562 |
|
| 563 |
DEBUGMSGTL(("disman:event:conf", " done.\n")); |
| 564 |
return SNMPERR_SUCCESS; |
| 565 |
} |
| 566 |
|
| 567 |
int |
| 568 |
clear_mteETable(int majorID, int minorID, void *serverarg, void *clientarg) |
| 569 |
{ |
| 570 |
netsnmp_tdata_row *row; |
| 571 |
netsnmp_variable_list owner_var; |
| 572 |
|
| 573 |
/* |
| 574 |
* We're only interested in entries set up via the config files |
| 575 |
*/ |
| 576 |
memset( &owner_var, 0, sizeof(netsnmp_variable_list)); |
| 577 |
snmp_set_var_typed_value( &owner_var, ASN_OCTET_STR, |
| 578 |
"snmpd.conf", strlen("snmpd.conf")); |
| 579 |
while (( row = netsnmp_tdata_row_next_byidx( event_table_data, |
| 580 |
&owner_var ))) { |
| 581 |
/* |
| 582 |
* XXX - check for owner of "snmpd.conf" |
| 583 |
* and break at the end of these |
| 584 |
*/ |
| 585 |
netsnmp_tdata_remove_and_delete_row( event_table_data, row ); |
| 586 |
} |
| 587 |
return SNMPERR_SUCCESS; |
| 588 |
} |