📄 expexpressiontable.c
字号:
/* *Copyright(c)2004,Cisco URP imburses and Network Information Center in Beijing University of Posts and Telecommunications researches. * *All right reserved * *File Name: expExpressionTable.c *File Description: expExpressionTable MIB operation. * *Current Version:1.0 *Author:JianShun Tong *Date:2004.8.20 *//* * This file was generated by mib2c and is intended for use as * a mib module for the ucd-snmp snmpd agent. *//* * This should always be included first before anything else */#include <net-snmp/net-snmp-config.h>#if HAVE_STDLIB_H#include <stdlib.h>#endif#if HAVE_STRING_H#include <string.h>#else#include <strings.h>#endif#ifdef HAVE_LIMITS_H#include <limits.h>#endif/* * minimal include directives */#include <net-snmp/net-snmp-includes.h>#include <net-snmp/agent/net-snmp-agent-includes.h>#include "header_complex.h"#include "expErrorTable.h"#include "expExpressionTable.h"#include "expObjectTable.h"#include "expValueTable.h"/* * expExpressionTable_variables_oid: * this is the top level oid that we want to register under. This * is essentially a prefix, with the suffix appearing in the * variable below. */oid expExpressionTable_variables_oid[] = { 1, 3, 6, 1, 2, 1, 90, 1, 2, 1 };/* * variable2 expExpressionTable_variables: */struct variable2 expExpressionTable_variables[] = { /* * magic number , variable type , ro/rw , callback fn , L, oidsuffix */#define EXPEXPRESSION 3 {EXPEXPRESSION, ASN_OCTET_STR, RWRITE, var_expExpressionTable, 2, {1, 3}},#define EXPEXPRESSIONVALUETYPE 4 {EXPEXPRESSIONVALUETYPE, ASN_INTEGER, RWRITE, var_expExpressionTable, 2, {1, 4}},#define EXPEXPRESSIONCOMMENT 5 {EXPEXPRESSIONCOMMENT, ASN_OCTET_STR, RWRITE, var_expExpressionTable, 2, {1, 5}},#define EXPEXPRESSIONDELTALNTERVAL 6 {EXPEXPRESSIONDELTALNTERVAL, ASN_INTEGER, RWRITE, var_expExpressionTable, 2, {1, 6}},#define EXPEXPRESSIONPREFIX 7 {EXPEXPRESSIONPREFIX, ASN_OBJECT_ID, RONLY, var_expExpressionTable, 2, {1, 7}},#define EXPEXPRESSIONERRORS 8 {EXPEXPRESSIONERRORS, ASN_UNSIGNED, RONLY, var_expExpressionTable, 2, {1, 8}},#define EXPEXPRESSIONENTRYSTATUS 9 {EXPEXPRESSIONENTRYSTATUS, ASN_INTEGER, RWRITE, var_expExpressionTable, 2, {1, 9}}};/* * global storage of our data, saved in and configured by header_complex() */struct header_complex_index *expExpressionTableStorage = NULL;extern struct header_complex_index *expObjectTableStorage;extern struct header_complex_index *expValueTableStorage;oid mmTimeInstance[] = { 1, 3, 6, 1, 2, 1, 1, 3, 0 };/* * init_expExpressionTable(): * Initialization routine. This is called when the agent starts up. * At a minimum, registration of your variables should take place here. */voidinit_expExpressionTable(void){ /* * register ourselves with the agent to handle our mib tree */ REGISTER_MIB("expExpressionTable", expExpressionTable_variables, variable2, expExpressionTable_variables_oid); /* * register our config handler(s) to deal with registrations */ snmpd_register_config_handler("expExpressionTable", parse_expExpressionTable, NULL, NULL); snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, store_expExpressionTable, NULL); DEBUGMSGTL(("expExpressionTable", "done.\n"));}struct expExpressionTable_data *create_expExpressionTable_data(void){ struct expExpressionTable_data *StorageNew; StorageNew = SNMP_MALLOC_STRUCT(expExpressionTable_data); /* * fill in default row values here into StorageNew */ /* * fill in values for all tables (even if not * appropriate), since its easier to do here than anywhere * else */ StorageNew->expExpression = strdup(""); StorageNew->expExpressionValueType = EXPEXPRESSION_COUNTER32; StorageNew->expExpressionComment = strdup(""); StorageNew->expExpressionDeltaInterval = 0; StorageNew->expExpressionPrefix = calloc(1, sizeof(oid) * 2); /* 0.0 */ StorageNew->expExpressionPrefixLen = 2; StorageNew->hc_ObjectTableStorage = NULL; StorageNew->hc_ValueTableStorage = NULL; StorageNew->storageType = ST_NONVOLATILE; return StorageNew;}intexpExpressionTable_add(struct expExpressionTable_data *thedata){ netsnmp_variable_list *vars = NULL; DEBUGMSGTL(("expExpressionTable", "adding data... ")); /* * add the index variables to the varbind list, which is * used by header_complex to index the data */ snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->expExpressionOwner, thedata->expExpressionOwnerLen); /* expExpressionOwner */ snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->expExpressionName, thedata->expExpressionNameLen); /* expExpressionName */ header_complex_add_data(&expExpressionTableStorage, vars, thedata); DEBUGMSGTL(("expExpressionTable", "registered an entry\n")); DEBUGMSGTL(("expExpressionTable", "done.\n")); return SNMPERR_SUCCESS;}/* * parse_mteTriggerTable(): * parses .conf file entries needed to configure the mib. */voidparse_expExpressionTable(const char *token, char *line){ size_t tmpint; oid *tmpoid = NULL; struct expExpressionTable_data *StorageTmp = SNMP_MALLOC_STRUCT(expExpressionTable_data); DEBUGMSGTL(("expExpressionTable", "parsing config... ")); if (StorageTmp == NULL) { config_perror("malloc failure"); return; } line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->expExpressionOwner, &StorageTmp->expExpressionOwnerLen); if (StorageTmp->expExpressionOwner == NULL) { config_perror("invalid specification for expExpressionOwner"); return; } line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->expExpressionName, &StorageTmp->expExpressionNameLen); if (StorageTmp->expExpressionName == NULL) { config_perror("invalid specification for expExpressionName"); return; } line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->expExpression, &StorageTmp->expExpressionLen); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->expExpressionValueType, &tmpint); line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->expExpressionComment, &StorageTmp->expExpressionCommentLen); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->expExpressionDeltaInterval, &tmpint); line = read_config_read_data(ASN_OBJECT_ID, line, &StorageTmp->expExpressionPrefix, &StorageTmp->expExpressionPrefixLen); line = read_config_read_data(ASN_UNSIGNED, line, &StorageTmp->expExpressionErrors, &tmpint); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->expExpressionEntryStatus, &tmpint); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->have_copied_auth_info, &tmpint); if (StorageTmp->have_copied_auth_info) { line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->pdu_version, &tmpint); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->pdu_securityModel, &tmpint); line = read_config_read_data(ASN_INTEGER, line, &StorageTmp->pdu_securityLevel, &tmpint); line = read_config_read_data(ASN_OBJECT_ID, line, &tmpoid, &tmpint); if (!netsnmp_tdomain_support (tmpoid, tmpint, &StorageTmp->pdu_tDomain, &StorageTmp->pdu_tDomainLen)) { config_perror ("unsupported transport domain for mteTriggerEntry"); return; } if (tmpoid != NULL) { free(tmpoid); } /* * can be NULL? Yes. */ line = read_config_read_data(ASN_OCTET_STR, line, &(StorageTmp->pdu_transport), &StorageTmp->pdu_transportLen); line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->pdu_community, &StorageTmp->pdu_community_len); if (StorageTmp->pdu_community == NULL) { config_perror("invalid specification for pdu_community"); return; } line = read_config_read_data(ASN_OCTET_STR, line, &StorageTmp->pdu_securityName, &StorageTmp->pdu_securityNameLen); if (StorageTmp->pdu_securityName == NULL) { config_perror("invalid specification for pdu_securityName"); return; } } StorageTmp->storageType = ST_NONVOLATILE; expExpressionTable_add(StorageTmp); DEBUGMSGTL(("expExpressionTable", "done.\n"));}/* * store_expExpressionTable(): * stores .conf file entries needed to configure the mib. */intstore_expExpressionTable(int majorID, int minorID, void *serverarg, void *clientarg){ char line[SNMP_MAXBUF]; char *cptr; size_t tmpint; struct expExpressionTable_data *StorageTmp; struct expObjectTable_data *ObjectStorageTmp; struct expValueTable_data *ValueStorageTmp; struct header_complex_index *hcindex, *hc_object, *hc_value; DEBUGMSGTL(("expExpressionTable", "storing data... ")); for (hcindex = expExpressionTableStorage; hcindex != NULL; hcindex = hcindex->next) { StorageTmp = (struct expExpressionTable_data *) hcindex->data; if (StorageTmp->storageType == ST_NONVOLATILE) { memset(line, 0, sizeof(line)); strcat(line, "expExpressionTable "); cptr = line + strlen(line); /* * expExpressionTable */ cptr = read_config_store_data(ASN_OCTET_STR, cptr, &StorageTmp->expExpressionOwner, &StorageTmp->expExpressionOwnerLen); cptr = read_config_store_data(ASN_OCTET_STR, cptr, &StorageTmp->expExpressionName, &StorageTmp->expExpressionNameLen); cptr = read_config_store_data(ASN_OCTET_STR, cptr, &StorageTmp->expExpression, &StorageTmp->expExpressionLen); cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp->expExpressionValueType, &tmpint); cptr = read_config_store_data(ASN_OCTET_STR, cptr, &StorageTmp->expExpressionComment, &StorageTmp-> expExpressionCommentLen); cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp-> expExpressionDeltaInterval, &tmpint); cptr = read_config_store_data(ASN_OBJECT_ID, cptr, &StorageTmp->expExpressionPrefix, &StorageTmp-> expExpressionPrefixLen); cptr = read_config_store_data(ASN_UNSIGNED, cptr, &StorageTmp->expExpressionErrors, &tmpint); cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp-> expExpressionEntryStatus, &tmpint); cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp->have_copied_auth_info, &tmpint); if (StorageTmp->have_copied_auth_info) { cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp->pdu_version, &tmpint); cptr = read_config_store_data(ASN_INTEGER, cptr, &StorageTmp->pdu_securityModel, &tmpint); cptr = read_config_store_data(ASN_INTEGER, cptr,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -