traceRouteCtlTable.c
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:215k
源码类别:
SNMP编程
开发平台:
Unix_Linux
- /*
- *Copyright(c)2004,Cisco URP imburses and Network Information Center in Beijing University of Posts and Telecommunications researches.
- *
- *All right reserved
- *
- *File Name:traceRouteCtlTable.c
- *File Description:Rows of traceRouteCtlTable MIB add delete ans read.
- * Rows of traceRouteResultsTable MIB add and delete.
- * Rows of traceRouteProbeHistoryTable MIB add and delete.
- * Rows of traceRouteHopsTable MIB add and delete.
- * The main function is also here.
- *
- *Current Version:1.0
- *Author:ChenJing
- *Date:2004.8.20
- */
- #include <net-snmp/net-snmp-config.h>
- #include <net-snmp/net-snmp-includes.h>
- #include <net-snmp/agent/net-snmp-agent-includes.h>
- #include <pthread.h>
- #include "traceRouteCtlTable.h"
- #include "traceRouteResultsTable.h"
- #include "traceRouteProbeHistoryTable.h"
- #include "traceRouteHopsTable.h"
- #include "header_complex.h"
- oid traceRouteCtlTable_variables_oid[] =
- { 1, 3, 6, 1, 2, 1, 81, 1, 2 };
- /* trap */
- oid traceRoutePathChange[] = { 1, 3, 6, 1, 2, 1, 81, 0, 1 };
- oid traceRouteTestFailed[] = { 1, 3, 6, 1, 2, 1, 81, 0, 2 };
- oid traceRouteTestCompleted[] = { 1, 3, 6, 1, 2, 1, 81, 0, 3 };
- struct variable2 traceRouteCtlTable_variables[] = {
- /*
- * magic number , variable type , ro/rw , callback fn , L, oidsuffix
- */
- {COLUMN_TRACEROUTECTLTARGETADDRESSTYPE, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 3}},
- {COLUMN_TRACEROUTECTLTARGETADDRESS, ASN_OCTET_STR, RWRITE, var_traceRouteCtlTable, 2, {1, 4}},
- {COLUMN_TRACEROUTECTLBYPASSROUTETABLE, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 5}},
- {COLUMN_TRACEROUTECTLDATASIZE, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 6}},
- {COLUMN_TRACEROUTECTLTIMEOUT, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 7}},
- {COLUMN_TRACEROUTECTLPROBESPERHOP, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 8}},
- {COLUMN_TRACEROUTECTLPORT, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 9}},
- {COLUMN_TRACEROUTECTLMAXTTL, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 10}},
- {COLUMN_TRACEROUTECTLDSFIELD, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 11}},
- {COLUMN_TRACEROUTECTLSOURCEADDRESSTYPE, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 12}},
- {COLUMN_TRACEROUTECTLSOURCEADDRESS, ASN_OCTET_STR, RWRITE, var_traceRouteCtlTable, 2, {1, 13}},
- {COLUMN_TRACEROUTECTLIFINDEX, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 14}},
- {COLUMN_TRACEROUTECTLMISCOPTIONS, ASN_OCTET_STR, RWRITE, var_traceRouteCtlTable, 2, {1, 15}},
- {COLUMN_TRACEROUTECTLMAXFAILURES, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 16}},
- {COLUMN_TRACEROUTECTLDONTFRAGMENT, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 17}},
- {COLUMN_TRACEROUTECTLINITIALTTL, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 18}},
- {COLUMN_TRACEROUTECTLFREQUENCY, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 19}},
- {COLUMN_TRACEROUTECTLSTORAGETYPE, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 20}},
- {COLUMN_TRACEROUTECTLADMINSTATUS, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 21}},
- {COLUMN_TRACEROUTECTLDESCR, ASN_OCTET_STR, RWRITE, var_traceRouteCtlTable, 2, {1, 22}},
- {COLUMN_TRACEROUTECTLMAXROWS, ASN_UNSIGNED, RWRITE, var_traceRouteCtlTable, 2, {1, 23}},
- {COLUMN_TRACEROUTECTLTRAPGENERATION, ASN_OCTET_STR, RWRITE, var_traceRouteCtlTable, 2, {1, 24}},
- {COLUMN_TRACEROUTECTLCREATEHOPSENTRIES, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 25}},
- {COLUMN_TRACEROUTECTLTYPE, ASN_OBJECT_ID, RWRITE, var_traceRouteCtlTable, 2, {1, 26}},
- {COLUMN_TRACEROUTECTLROWSTATUS, ASN_INTEGER, RWRITE, var_traceRouteCtlTable, 2, {1, 27}}
- };
- /*
- * global storage of our data, saved in and configured by header_complex()
- */
- struct header_complex_index *traceRouteCtlTableStorage = NULL;
- struct header_complex_index *traceRouteResultsTableStorage = NULL;
- struct header_complex_index *traceRouteProbeHistoryTableStorage = NULL;
- struct header_complex_index *traceRouteHopsTableStorage = NULL;
- void
- init_traceRouteCtlTable(void)
- {
- DEBUGMSGTL(("traceRouteCtlTable", "initializing... "));
- /*
- * register ourselves with the agent to handle our mib tree
- */
- REGISTER_MIB("traceRouteCtlTable", traceRouteCtlTable_variables,
- variable2, traceRouteCtlTable_variables_oid);
- /*
- * register our config handler(s) to deal with registrations
- */
- snmpd_register_config_handler("traceRouteCtlTable",
- parse_traceRouteCtlTable, NULL, NULL);
- /*
- * we need to be called back later to store our data
- */
- snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
- store_traceRouteCtlTable, NULL);
- DEBUGMSGTL(("traceRouteCtlTable", "done.n"));
- }
- void
- init_trResultsTable(struct traceRouteCtlTable_data *item)
- {
- struct traceRouteResultsTable_data *StorageTmp = NULL;
- netsnmp_variable_list *vars = NULL;
- char *host = NULL;
- host =
- (char *) malloc(sizeof(char) *
- (item->traceRouteCtlTargetAddressLen + 1));
- if (host == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable", "host calloc %sn",
- strerror(errno)));
- exit(1);
- }
- bzero(host, sizeof(char) * (item->traceRouteCtlTargetAddressLen + 1));
- strcpy(host, item->traceRouteCtlTargetAddress);
- host[item->traceRouteCtlTargetAddressLen] = ' ';
- StorageTmp = SNMP_MALLOC_STRUCT(traceRouteResultsTable_data);
- if (StorageTmp == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable", "StorageTmp malloc %sn",
- strerror(errno)));
- exit(1);
- }
- StorageTmp->traceRouteCtlOwnerIndex =
- (char *) malloc(sizeof(char) *
- (item->traceRouteCtlOwnerIndexLen + 1));
- if (StorageTmp->traceRouteCtlOwnerIndex == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceRouteCtlOwnerIndex malloc %sn",
- strerror(errno)));
- exit(1);
- }
- memcpy(StorageTmp->traceRouteCtlOwnerIndex,
- item->traceRouteCtlOwnerIndex,
- item->traceRouteCtlOwnerIndexLen + 1);
- StorageTmp->traceRouteCtlOwnerIndex[item->traceRouteCtlOwnerIndexLen] =
- ' ';
- StorageTmp->traceRouteCtlOwnerIndexLen =
- item->traceRouteCtlOwnerIndexLen;
- StorageTmp->traceRouteCtlTestName =
- (char *) malloc(sizeof(char) *
- (item->traceRouteCtlTestNameLen + 1));
- if (StorageTmp->traceRouteCtlTestName == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceRouteCtlTestName malloc %sn", strerror(errno)));
- exit(1);
- }
- memcpy(StorageTmp->traceRouteCtlTestName, item->traceRouteCtlTestName,
- item->traceRouteCtlTestNameLen + 1);
- StorageTmp->traceRouteCtlTestName[item->traceRouteCtlTestNameLen] =
- ' ';
- StorageTmp->traceRouteCtlTestNameLen = item->traceRouteCtlTestNameLen;
- StorageTmp->traceRouteResultsOperStatus = 1;
- if (item->traceRouteCtlTargetAddressType == 1
- || item->traceRouteCtlTargetAddressType == 16) {
- struct sockaddr whereto; /* Who to try to reach */
- register struct sockaddr_in *to = (struct sockaddr_in *) &whereto;
- register struct hostinfo *hi = NULL;
- hi = gethostinfo(host);
- if (hi == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable", "hi calloc %sn",
- strerror(errno)));
- exit(1);
- }
- setsin(to, hi->addrs[0]);
- if (inet_ntoa(to->sin_addr) == NULL) {
- StorageTmp->traceRouteResultsIpTgtAddrType = 0;
- StorageTmp->traceRouteResultsIpTgtAddr = strdup("");
- StorageTmp->traceRouteResultsIpTgtAddrLen = 0;
- } else {
- StorageTmp->traceRouteResultsIpTgtAddrType = 1;
- StorageTmp->traceRouteResultsIpTgtAddr =
- (char *) malloc(sizeof(char) *
- (strlen(inet_ntoa(to->sin_addr)) + 1));
- if (StorageTmp->traceRouteResultsIpTgtAddr == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceRouteResultsIpTgtAddr malloc %sn",
- strerror(errno)));
- exit(1);
- }
- memcpy(StorageTmp->traceRouteResultsIpTgtAddr,
- inet_ntoa(to->sin_addr),
- strlen(inet_ntoa(to->sin_addr)) + 1);
- StorageTmp->
- traceRouteResultsIpTgtAddr[strlen(inet_ntoa(to->sin_addr))]
- = ' ';
- StorageTmp->traceRouteResultsIpTgtAddrLen =
- strlen(inet_ntoa(to->sin_addr));
- }
- }
- if (item->traceRouteCtlTargetAddressType == 2) {
- struct sockaddr_in6 whereto; /* Who to try to reach */
- register struct sockaddr_in6 *to =
- (struct sockaddr_in6 *) &whereto;
- struct hostent *hp = NULL;
- /* struct hostenv hp; */
- char pa[64];
- bzero(pa, 64);
- to->sin6_family = AF_INET6;
- to->sin6_port = htons(33434);
- if (inet_pton(AF_INET6, host, &to->sin6_addr) > 0) {
- StorageTmp->traceRouteResultsIpTgtAddrType = 2;
- StorageTmp->traceRouteResultsIpTgtAddr =
- (char *) malloc(sizeof(char) * (strlen(host) + 1));
- if (StorageTmp->traceRouteResultsIpTgtAddr == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceRouteResultsIpTgtAddr malloc %sn",
- strerror(errno)));
- exit(1);
- }
- bzero(StorageTmp->traceRouteResultsIpTgtAddr,
- sizeof(char) * (strlen(host) + 1));
- memcpy(StorageTmp->traceRouteResultsIpTgtAddr, host,
- strlen(host) + 1);
- StorageTmp->traceRouteResultsIpTgtAddr[strlen(host)] = ' ';
- StorageTmp->traceRouteResultsIpTgtAddrLen = strlen(host);
- } else {
- hp = gethostbyname2(host, AF_INET6);
- if (hp != NULL) {
- const char *hostname;
- memmove((caddr_t) & to->sin6_addr, hp->h_addr, 16);
- hostname = inet_ntop(AF_INET6, &to->sin6_addr, pa, 64);
- StorageTmp->traceRouteResultsIpTgtAddrType = 2;
- StorageTmp->traceRouteResultsIpTgtAddr =
- (char *) malloc(sizeof(char) * (strlen(hostname) + 1));
- if (StorageTmp->traceRouteResultsIpTgtAddr == NULL) {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceRouteResultsIpTgtAddr malloc %sn",
- strerror(errno)));
- exit(1);
- }
- bzero(StorageTmp->traceRouteResultsIpTgtAddr,
- sizeof(char) * (strlen(host) + 1));
- memcpy(StorageTmp->traceRouteResultsIpTgtAddr, hostname,
- strlen(hostname) + 1);
- StorageTmp->traceRouteResultsIpTgtAddr[strlen(hostname)] =
- ' ';
- StorageTmp->traceRouteResultsIpTgtAddrLen =
- strlen(hostname);
- } else {
- DEBUGMSGTL(("traceRouteCtlTable",
- "traceroute: unknown host %sn", host));
- StorageTmp->traceRouteResultsIpTgtAddrType = 0;
- StorageTmp->traceRouteResultsIpTgtAddr = strdup("");
- StorageTmp->traceRouteResultsIpTgtAddrLen = 0;
- }
- }
- }
- StorageTmp->traceRouteResultsCurHopCount = 0;
- StorageTmp->traceRouteResultsCurProbeCount = 0;
- StorageTmp->traceRouteResultsTestAttempts = 0;
- StorageTmp->traceRouteResultsTestSuccesses = 0;
- StorageTmp->traceRouteResultsLastGoodPath = strdup("");
- StorageTmp->traceRouteResultsLastGoodPathLen = 0;
- item->traceRouteResults = StorageTmp;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) item->traceRouteCtlOwnerIndex, item->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) item->traceRouteCtlTestName, item->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- if ((header_complex_get(traceRouteResultsTableStorage, vars)) != NULL) {
- traceRouteResultsTable_del(item);
- }
- snmp_free_varbind(vars);
- vars = NULL;
- if (item->traceRouteResults != NULL) {
- if (traceRouteResultsTable_add(item) != SNMPERR_SUCCESS) {
- DEBUGMSGTL(("traceRouteResultsTable",
- "init an entry errorn"));
- }
- }
- }
- int
- modify_trResultsOper(struct traceRouteCtlTable_data *thedata, long val)
- {
- netsnmp_variable_list *vars = NULL;
- struct traceRouteResultsTable_data *StorageTmp = NULL;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- if ((StorageTmp =
- header_complex_get(traceRouteResultsTableStorage,
- vars)) == NULL) {
- snmp_free_varbind(vars);
- vars = NULL;
- return SNMP_ERR_NOSUCHNAME;
- } else {
- StorageTmp->traceRouteResultsOperStatus = val;
- DEBUGMSGTL(("traceRouteResultsOperStatus", "done.n"));
- snmp_free_varbind(vars);
- vars = NULL;
- return SNMPERR_SUCCESS;
- }
- }
- struct traceRouteCtlTable_data *
- create_traceRouteCtlTable_data(void)
- {
- struct traceRouteCtlTable_data *StorageNew = NULL;
- StorageNew = SNMP_MALLOC_STRUCT(traceRouteCtlTable_data);
- if (StorageNew == NULL) {
- exit(1);
- }
- StorageNew->traceRouteCtlTargetAddressType = 1;
- StorageNew->traceRouteCtlTargetAddress = strdup("");
- StorageNew->traceRouteCtlTargetAddressLen = 0;
- StorageNew->traceRouteCtlByPassRouteTable = 2;
- StorageNew->traceRouteCtlDataSize = 0;
- StorageNew->traceRouteCtlTimeOut = 3;
- StorageNew->traceRouteCtlProbesPerHop = 3;
- StorageNew->traceRouteCtlPort = 33434;
- StorageNew->traceRouteCtlMaxTtl = 30;
- StorageNew->traceRouteCtlDSField = 0;
- StorageNew->traceRouteCtlSourceAddressType = 0;
- StorageNew->traceRouteCtlSourceAddress = strdup("");
- StorageNew->traceRouteCtlSourceAddressLen = 0;
- StorageNew->traceRouteCtlIfIndex = 0;
- StorageNew->traceRouteCtlMiscOptions = strdup("");
- StorageNew->traceRouteCtlMiscOptionsLen = 0;
- StorageNew->traceRouteCtlMaxFailures = 5;
- StorageNew->traceRouteCtlDontFragment = 2;
- StorageNew->traceRouteCtlInitialTtl = 1;
- StorageNew->traceRouteCtlFrequency = 0;
- StorageNew->traceRouteCtlStorageType = ST_NONVOLATILE;
- StorageNew->traceRouteCtlAdminStatus = 2;
- StorageNew->traceRouteCtlDescr = (char *) malloc(strlen("00") + 1);
- if (StorageNew->traceRouteCtlDescr == NULL) {
- exit(1);
- }
- memcpy(StorageNew->traceRouteCtlDescr, "00", strlen("00") + 1);
- StorageNew->traceRouteCtlDescr[strlen("00")] = ' ';
- StorageNew->traceRouteCtlDescrLen =
- strlen(StorageNew->traceRouteCtlDescr);
- StorageNew->traceRouteCtlMaxRows = 50;
- StorageNew->traceRouteCtlTrapGeneration = strdup("");
- StorageNew->traceRouteCtlTrapGenerationLen = 0;
- StorageNew->traceRouteCtlCreateHopsEntries = 2;
- StorageNew->traceRouteCtlType = calloc(1, sizeof(oid) * sizeof(2)); /* 0.0 */
- StorageNew->traceRouteCtlTypeLen = 2;
- StorageNew->traceRouteResults = NULL;
- StorageNew->traceRouteProbeHis = NULL;
- StorageNew->traceRouteHops = NULL;
- StorageNew->storageType = ST_NONVOLATILE;
- /* StorageNew->traceRouteProbeHistoryMaxIndex=0; */
- return StorageNew;
- }
- /*
- * traceRouteCtlTable_add(): adds a structure node to our data set
- */
- int
- traceRouteCtlTable_add(struct traceRouteCtlTable_data *thedata)
- {
- netsnmp_variable_list *vars = NULL;
- DEBUGMSGTL(("traceRouteCtlTable", "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->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlOperationName */
- if (header_complex_add_data(&traceRouteCtlTableStorage, vars, thedata)
- == NULL) {
- vars = NULL;
- return SNMPERR_GENERR;
- } else {
- DEBUGMSGTL(("traceRouteCtlTable", "registered an entryn"));
- DEBUGMSGTL(("traceRouteCtlTable", "done.n"));
- vars = NULL;
- return SNMPERR_SUCCESS;
- }
- }
- int
- traceRouteResultsTable_add(struct traceRouteCtlTable_data *thedata)
- {
- netsnmp_variable_list *vp = NULL;
- netsnmp_variable_list *vars_list = NULL;
- struct traceRouteResultsTable_data *p = NULL;
- p = thedata->traceRouteResults;
- if (thedata->traceRouteResults != NULL) {
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlOwnerIndex, p->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlTestName, p->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- DEBUGMSGTL(("traceRouteResultsTable", "adding data... "));
- /*
- * add the index variables to the varbind list, which is
- * used by header_complex to index the data
- */
- header_complex_add_data(&traceRouteResultsTableStorage, vars_list,
- p);
- DEBUGMSGTL(("traceRouteResultsTable", "out finishedn"));
- vars_list = NULL;
- DEBUGMSGTL(("traceRouteResultsTable", "done.n"));
- return SNMPERR_SUCCESS;
- } else {
- vars_list = NULL;
- DEBUGMSGTL(("traceRouteResultsTable", "error.n"));
- return SNMP_ERR_INCONSISTENTNAME;
- }
- }
- int
- traceRouteProbeHistoryTable_add(struct traceRouteProbeHistoryTable_data
- *thedata)
- {
- netsnmp_variable_list *vars_list = NULL;
- if (thedata != NULL) {
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &thedata->traceRouteProbeHistoryIndex, sizeof(thedata->traceRouteProbeHistoryIndex)); /* traceRouteProbeHistoryIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &thedata->traceRouteProbeHistoryHopIndex, sizeof(thedata->traceRouteProbeHistoryHopIndex)); /* traceRouteProbeHistoryHopIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &thedata->traceRouteProbeHistoryProbeIndex, sizeof(thedata->traceRouteProbeHistoryProbeIndex)); /* traceRouteProbeHistoryProbeIndex */
- DEBUGMSGTL(("traceRouteProbeHistoryTable", "adding data... "));
- /*
- * add the index variables to the varbind list, which is
- * used by header_complex to index the data
- */
- if (header_complex_add_data
- (&traceRouteProbeHistoryTableStorage, vars_list,
- thedata) == NULL) {
- vars_list = NULL;
- return SNMP_ERR_INCONSISTENTNAME;
- } else {
- DEBUGMSGTL(("traceRouteProbeHistoryTable", "out finishedn"));
- vars_list = NULL;
- DEBUGMSGTL(("traceRouteProbeHistoryTable", "done.n"));
- return SNMPERR_SUCCESS;
- }
- } else {
- return SNMP_ERR_INCONSISTENTNAME;
- }
- }
- int
- traceRouteProbeHistoryTable_addall(struct traceRouteCtlTable_data *thedata)
- {
- netsnmp_variable_list *vars_list = NULL;
- struct traceRouteProbeHistoryTable_data *p = NULL;
- p = thedata->traceRouteProbeHis;
- if (thedata->traceRouteProbeHis != NULL)
- do {
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlOwnerIndex, p->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlTestName, p->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &p->traceRouteProbeHistoryIndex, sizeof(p->traceRouteProbeHistoryIndex)); /* traceRouteProbeHistoryIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &p->traceRouteProbeHistoryHopIndex, sizeof(p->traceRouteProbeHistoryHopIndex)); /* traceRouteProbeHistoryHopIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &p->traceRouteProbeHistoryProbeIndex, sizeof(p->traceRouteProbeHistoryProbeIndex)); /* traceRouteProbeHistoryProbeIndex */
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "adding data... "));
- /*
- * add the index variables to the varbind list, which is
- * used by header_complex to index the data
- */
- if (header_complex_add_data
- (&traceRouteProbeHistoryTableStorage, vars_list,
- p) == NULL) {
- vars_list = NULL;
- return SNMP_ERR_INCONSISTENTNAME;
- } else {
- struct header_complex_index *temp = NULL;
- temp = traceRouteProbeHistoryTableStorage;
- if (traceRouteProbeHistoryTableStorage != NULL)
- do {
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "adding data,vars_oid=%un ",
- temp->name));
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "adding data,vars_oid=%dn ",
- temp->namelen));
- temp = temp->next;
- } while (temp != NULL);
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "out finishedn"));
- DEBUGMSGTL(("traceRouteProbeHistoryTable", "done.n"));
- vars_list = NULL;
- return SNMPERR_SUCCESS;
- }
- p = p->next;
- } while (p != NULL);
- else {
- return SNMP_ERR_INCONSISTENTNAME;
- }
- }
- int
- traceRouteHopsTable_add(struct traceRouteHopsTable_data *thedata)
- {
- netsnmp_variable_list *vars_list = NULL;
- if (thedata != NULL) {
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &thedata->traceRouteHopsHopIndex, sizeof(thedata->traceRouteHopsHopIndex)); /* traceRouteHopsHopIndex */
- DEBUGMSGTL(("traceRouteHopsTable", "adding data... "));
- /*
- * add the index variables to the varbind list, which is
- * used by header_complex to index the data
- */
- if (header_complex_add_data
- (&traceRouteHopsTableStorage, vars_list, thedata) == NULL) {
- vars_list = NULL;
- return SNMP_ERR_INCONSISTENTNAME;
- } else {
- DEBUGMSGTL(("traceRouteHopsTable", "out finishedn"));
- DEBUGMSGTL(("traceRouteHopsTable", "done.n"));
- vars_list = NULL;
- return SNMPERR_SUCCESS;
- }
- }
- }
- int
- traceRouteHopsTable_addall(struct traceRouteCtlTable_data *thedata)
- {
- netsnmp_variable_list *vars_list = NULL;
- struct traceRouteHopsTable_data *p = NULL;
- vars_list = NULL;
- p = thedata->traceRouteHops;
- if (thedata->traceRouteHops != NULL) {
- do {
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlOwnerIndex, p->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_OCTET_STR, (char *) p->traceRouteCtlTestName, p->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- snmp_varlist_add_variable(&vars_list, NULL, 0, ASN_UNSIGNED, (char *) &p->traceRouteHopsHopIndex, sizeof(p->traceRouteHopsHopIndex)); /* traceRouteHopsHopIndex */
- DEBUGMSGTL(("traceRouteHopsTable", "adding data... "));
- /*
- * add the index variables to the varbind list, which is
- * used by header_complex to index the data
- */
- if (header_complex_add_data
- (&traceRouteHopsTableStorage, vars_list, p) == NULL) {
- vars_list = NULL;
- return SNMP_ERR_INCONSISTENTNAME;
- } else {
- struct header_complex_index *temp = NULL;
- temp = traceRouteHopsTableStorage;
- if (traceRouteHopsTableStorage != NULL)
- do {
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "adding data,vars_oid=%un ",
- temp->name));
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "adding data,vars_oid=%dn ",
- temp->namelen));
- temp = temp->next;
- } while (temp != NULL);
- DEBUGMSGTL(("traceRouteHopsTable", "out finishedn"));
- vars_list = NULL;
- }
- p = p->next;
- } while (p != NULL);
- DEBUGMSGTL(("traceRouteHopsTable", "done.n"));
- return SNMPERR_SUCCESS;
- } else {
- return SNMP_ERR_INCONSISTENTNAME;
- }
- }
- unsigned long
- traceRouteProbeHistoryTable_count(struct traceRouteCtlTable_data *thedata)
- {
- struct header_complex_index *hciptr2 = NULL;
- netsnmp_variable_list *vars = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len;
- unsigned long count = 0;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- vars = NULL;
- for (hciptr2 = traceRouteProbeHistoryTableStorage; hciptr2 != NULL;
- hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- count = count + 1;
- }
- }
- return count;
- }
- unsigned long
- traceRouteHopsTable_count(struct traceRouteCtlTable_data *thedata)
- {
- struct header_complex_index *hciptr2 = NULL;
- netsnmp_variable_list *vars = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len;
- unsigned long count = 0;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlOperationName */
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- vars = NULL;
- for (hciptr2 = traceRouteHopsTableStorage; hciptr2 != NULL;
- hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- count = count + 1;
- }
- }
- return count;
- }
- int
- traceRouteProbeHistoryTable_delLast(struct traceRouteCtlTable_data
- *thedata)
- {
- struct traceRouteProbeHistoryTable_data *p = NULL;
- struct header_complex_index *hciptr1 = NULL;
- struct header_complex_index *hciptr2 = NULL;
- struct header_complex_index *hcilast = NULL;
- struct traceRouteProbeHistoryTable_data *StorageDel = NULL;
- struct traceRouteProbeHistoryTable_data *StorageTmp = NULL;
- netsnmp_variable_list *vars = NULL;
- netsnmp_variable_list *vars_temp = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len = 0;
- time_t last_time = 2147483647;
- struct tm *tp = NULL;
- tp = (struct tm *) malloc(sizeof(struct tm));
- if (tp == NULL) {
- exit(1);
- }
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlOperationName */
- bzero(newoid, sizeof(oid) * MAX_OID_LEN);
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- for (hcilast = hciptr2 = traceRouteProbeHistoryTableStorage;
- hciptr2 != NULL; hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- StorageTmp =
- header_complex_get_from_oid
- (traceRouteProbeHistoryTableStorage, hciptr2->name,
- hciptr2->namelen);
- strptime(StorageTmp->traceRouteProbeHistoryTime, "%c", tp);
- if (last_time > timegm(tp)) {
- last_time = timegm(tp);
- hcilast = hciptr2;
- }
- }
- }
- StorageDel =
- header_complex_extract_entry(&traceRouteProbeHistoryTableStorage,
- hcilast);
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "delete the last one success!n"));
- vars = NULL;
- free(tp);
- tp = NULL;
- }
- void
- traceRouteCtlTable_cleaner(struct header_complex_index *thestuff)
- {
- struct header_complex_index *hciptr = NULL;
- struct traceRouteCtlTable_data *StorageDel = NULL;
- DEBUGMSGTL(("traceRouteCtlTable", "cleanerout "));
- for (hciptr = thestuff; hciptr != NULL; hciptr = hciptr->next) {
- StorageDel =
- header_complex_extract_entry(&traceRouteCtlTableStorage,
- hciptr);
- if (StorageDel != NULL) {
- free(StorageDel->traceRouteCtlOwnerIndex);
- StorageDel->traceRouteCtlOwnerIndex = NULL;
- free(StorageDel->traceRouteCtlTestName);
- StorageDel->traceRouteCtlTestName = NULL;
- free(StorageDel->traceRouteCtlTargetAddress);
- StorageDel->traceRouteCtlTargetAddress = NULL;
- free(StorageDel->traceRouteCtlSourceAddress);
- StorageDel->traceRouteCtlSourceAddress = NULL;
- free(StorageDel->traceRouteCtlMiscOptions);
- StorageDel->traceRouteCtlMiscOptions = NULL;
- free(StorageDel->traceRouteCtlDescr);
- StorageDel->traceRouteCtlDescr = NULL;
- free(StorageDel->traceRouteCtlTrapGeneration);
- StorageDel->traceRouteCtlTrapGeneration = NULL;
- free(StorageDel->traceRouteCtlType);
- StorageDel->traceRouteCtlType = NULL;
- free(StorageDel);
- StorageDel = NULL;
- }
- DEBUGMSGTL(("traceRouteCtlTable", "cleaner "));
- }
- }
- /*
- * parse_mteObjectsTable():
- * parses .conf file entries needed to configure the mib.
- */
- void
- parse_traceRouteCtlTable(const char *token, char *line)
- {
- size_t tmpint;
- struct traceRouteCtlTable_data *StorageTmp =
- SNMP_MALLOC_STRUCT(traceRouteCtlTable_data);
- DEBUGMSGTL(("traceRouteCtlTable", "parsing config... "));
- if (StorageTmp == NULL) {
- config_perror("malloc failure");
- return;
- }
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlOwnerIndex,
- &StorageTmp->traceRouteCtlOwnerIndexLen);
- if (StorageTmp->traceRouteCtlOwnerIndex == NULL) {
- config_perror("invalid specification for traceRouteCtlOwnerIndex");
- return;
- }
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlTestName,
- &StorageTmp->traceRouteCtlTestNameLen);
- if (StorageTmp->traceRouteCtlTestName == NULL) {
- config_perror("invalid specification for traceRouteCtlTestName");
- return;
- }
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlTargetAddressType,
- &tmpint);
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlTargetAddress,
- &StorageTmp->traceRouteCtlTargetAddressLen);
- if (StorageTmp->traceRouteCtlTargetAddress == NULL) {
- config_perror
- ("invalid specification for traceRouteCtlTargetAddress");
- return;
- }
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlByPassRouteTable,
- &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlDataSize, &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlTimeOut, &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlProbesPerHop,
- &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlPort, &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlMaxTtl, &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlDSField, &tmpint);
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlSourceAddressType,
- &tmpint);
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlSourceAddress,
- &StorageTmp->traceRouteCtlSourceAddressLen);
- if (StorageTmp->traceRouteCtlSourceAddress == NULL) {
- config_perror
- ("invalid specification for traceRouteCtlSourceAddress");
- return;
- }
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlIfIndex, &tmpint);
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlMiscOptions,
- &StorageTmp->traceRouteCtlMiscOptionsLen);
- if (StorageTmp->traceRouteCtlMiscOptions == NULL) {
- config_perror
- ("invalid specification for traceRouteCtlMiscOptions");
- return;
- }
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlMaxFailures,
- &tmpint);
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlDontFragment,
- &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlInitialTtl,
- &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlFrequency,
- &tmpint);
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlStorageType,
- &tmpint);
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlAdminStatus,
- &tmpint);
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlDescr,
- &StorageTmp->traceRouteCtlDescrLen);
- if (StorageTmp->traceRouteCtlDescr == NULL) {
- config_perror("invalid specification for traceRouteCtlTrapDescr");
- return;
- }
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteCtlMaxRows, &tmpint);
- line =
- read_config_read_data(ASN_OCTET_STR, line,
- &StorageTmp->traceRouteCtlTrapGeneration,
- &StorageTmp->traceRouteCtlTrapGenerationLen);
- if (StorageTmp->traceRouteCtlTrapGeneration == NULL) {
- config_perror
- ("invalid specification for traceRouteCtlTrapGeneration");
- return;
- }
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlCreateHopsEntries,
- &tmpint);
- line =
- read_config_read_data(ASN_OBJECT_ID, line,
- &StorageTmp->traceRouteCtlType,
- &StorageTmp->traceRouteCtlTypeLen);
- if (StorageTmp->traceRouteCtlType == NULL) {
- config_perror("invalid specification for traceRouteCtlType");
- return;
- }
- line =
- read_config_read_data(ASN_INTEGER, line,
- &StorageTmp->traceRouteCtlRowStatus,
- &tmpint);
- line =
- read_config_read_data(ASN_UNSIGNED, line,
- &StorageTmp->traceRouteProbeHistoryMaxIndex,
- &tmpint);
- StorageTmp->storageType = ST_NONVOLATILE;
- traceRouteCtlTable_add(StorageTmp);
- /* traceRouteCtlTable_cleaner(traceRouteCtlTableStorage); */
- DEBUGMSGTL(("traceRouteCtlTable", "done.n"));
- }
- /*
- * store_traceRouteCtlTable():
- * stores .conf file entries needed to configure the mib.
- */
- int
- store_traceRouteCtlTable(int majorID, int minorID, void *serverarg,
- void *clientarg)
- {
- char line[SNMP_MAXBUF];
- char *cptr = NULL;
- size_t tmpint;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- struct header_complex_index *hcindex = NULL;
- DEBUGMSGTL(("traceRouteCtlTable", "storing data... "));
- for (hcindex = traceRouteCtlTableStorage; hcindex != NULL;
- hcindex = hcindex->next) {
- StorageTmp = (struct traceRouteCtlTable_data *) hcindex->data;
- if (StorageTmp->storageType != ST_READONLY) {
- memset(line, 0, sizeof(line));
- strcat(line, "traceRouteCtlTable ");
- cptr = line + strlen(line);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->
- traceRouteCtlOwnerIndex,
- &StorageTmp->
- traceRouteCtlOwnerIndexLen);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->traceRouteCtlTestName,
- &StorageTmp->
- traceRouteCtlTestNameLen);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlTargetAddressType,
- &tmpint);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->
- traceRouteCtlTargetAddress,
- &StorageTmp->
- traceRouteCtlTargetAddressLen);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlByPassRouteTable,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlDataSize,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlTimeOut,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->
- traceRouteCtlProbesPerHop, &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlPort,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlMaxTtl,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlDSField,
- &tmpint);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlSourceAddressType,
- &tmpint);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->
- traceRouteCtlSourceAddress,
- &StorageTmp->
- traceRouteCtlSourceAddressLen);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->traceRouteCtlIfIndex,
- &tmpint);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->
- traceRouteCtlMiscOptions,
- &StorageTmp->
- traceRouteCtlMiscOptionsLen);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->
- traceRouteCtlMaxFailures, &tmpint);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlDontFragment, &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->
- traceRouteCtlInitialTtl, &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlFrequency,
- &tmpint);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlStorageType, &tmpint);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlAdminStatus, &tmpint);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->traceRouteCtlDescr,
- &StorageTmp->traceRouteCtlDescrLen);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->traceRouteCtlMaxRows,
- &tmpint);
- cptr =
- read_config_store_data(ASN_OCTET_STR, cptr,
- &StorageTmp->
- traceRouteCtlTrapGeneration,
- &StorageTmp->
- traceRouteCtlTrapGenerationLen);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->
- traceRouteCtlCreateHopsEntries,
- &tmpint);
- cptr =
- read_config_store_data(ASN_OBJECT_ID, cptr,
- &StorageTmp->traceRouteCtlType,
- &StorageTmp->traceRouteCtlTypeLen);
- cptr =
- read_config_store_data(ASN_INTEGER, cptr,
- &StorageTmp->traceRouteCtlRowStatus,
- &tmpint);
- cptr =
- read_config_store_data(ASN_UNSIGNED, cptr,
- &StorageTmp->
- traceRouteProbeHistoryMaxIndex,
- &tmpint);
- snmpd_store_config(line);
- }
- }
- DEBUGMSGTL(("traceRouteCtlTable", "done.n"));
- return SNMPERR_SUCCESS;
- }
- /*
- * var_traceRouteCtlTable():
- * Handle this table separately from the scalar value case.
- * The workings of this are basically the same as for var_mteObjectsTable above.
- */
- unsigned char *
- var_traceRouteCtlTable(struct variable *vp,
- oid * name,
- size_t *length,
- int exact,
- size_t *var_len, WriteMethod ** write_method)
- {
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- /*
- * this assumes you have registered all your data properly
- */
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, vp, name, length, exact,
- var_len, write_method)) == NULL) {
- if (vp->magic == COLUMN_TRACEROUTECTLROWSTATUS)
- *write_method = write_traceRouteCtlRowStatus;
- return NULL;
- }
- /*
- * this is where we do the value assignments for the mib results.
- */
- switch (vp->magic) {
- case COLUMN_TRACEROUTECTLTARGETADDRESSTYPE:
- *write_method = write_traceRouteCtlTargetAddressType;
- *var_len = sizeof(StorageTmp->traceRouteCtlTargetAddressType);
- return (u_char *) & StorageTmp->traceRouteCtlTargetAddressType;
- case COLUMN_TRACEROUTECTLTARGETADDRESS:
- *write_method = write_traceRouteCtlTargetAddress;
- *var_len = (StorageTmp->traceRouteCtlTargetAddressLen);
- return (u_char *) StorageTmp->traceRouteCtlTargetAddress;
- case COLUMN_TRACEROUTECTLBYPASSROUTETABLE:
- *write_method = write_traceRouteCtlByPassRouteTable;
- *var_len = sizeof(StorageTmp->traceRouteCtlByPassRouteTable);
- return (u_char *) & StorageTmp->traceRouteCtlByPassRouteTable;
- case COLUMN_TRACEROUTECTLDATASIZE:
- *write_method = write_traceRouteCtlDataSize;
- *var_len = sizeof(StorageTmp->traceRouteCtlDataSize);
- return (u_char *) & StorageTmp->traceRouteCtlDataSize;
- case COLUMN_TRACEROUTECTLTIMEOUT:
- *write_method = write_traceRouteCtlTimeOut;
- *var_len = sizeof(StorageTmp->traceRouteCtlTimeOut);
- return (u_char *) & StorageTmp->traceRouteCtlTimeOut;
- case COLUMN_TRACEROUTECTLPROBESPERHOP:
- *write_method = write_traceRouteCtlProbesPerHop;
- *var_len = sizeof(StorageTmp->traceRouteCtlProbesPerHop);
- return (u_char *) & StorageTmp->traceRouteCtlProbesPerHop;
- case COLUMN_TRACEROUTECTLPORT:
- *write_method = write_traceRouteCtlPort;
- *var_len = sizeof(StorageTmp->traceRouteCtlPort);
- return (u_char *) & StorageTmp->traceRouteCtlPort;
- case COLUMN_TRACEROUTECTLMAXTTL:
- *write_method = write_traceRouteCtlMaxTtl;
- *var_len = sizeof(StorageTmp->traceRouteCtlMaxTtl);
- return (u_char *) & StorageTmp->traceRouteCtlMaxTtl;
- case COLUMN_TRACEROUTECTLDSFIELD:
- *write_method = write_traceRouteCtlDSField;
- *var_len = sizeof(StorageTmp->traceRouteCtlDSField);
- return (u_char *) & StorageTmp->traceRouteCtlDSField;
- case COLUMN_TRACEROUTECTLSOURCEADDRESSTYPE:
- *write_method = write_traceRouteCtlSourceAddressType;
- *var_len = sizeof(StorageTmp->traceRouteCtlSourceAddressType);
- return (u_char *) & StorageTmp->traceRouteCtlSourceAddressType;
- case COLUMN_TRACEROUTECTLSOURCEADDRESS:
- *write_method = write_traceRouteCtlSourceAddress;
- *var_len = (StorageTmp->traceRouteCtlSourceAddressLen);
- return (u_char *) StorageTmp->traceRouteCtlSourceAddress;
- case COLUMN_TRACEROUTECTLIFINDEX:
- *write_method = write_traceRouteCtlIfIndex;
- *var_len = sizeof(StorageTmp->traceRouteCtlIfIndex);
- return (u_char *) & StorageTmp->traceRouteCtlIfIndex;
- case COLUMN_TRACEROUTECTLMISCOPTIONS:
- *write_method = write_traceRouteCtlMiscOptions;
- *var_len = (StorageTmp->traceRouteCtlMiscOptionsLen);
- return (u_char *) StorageTmp->traceRouteCtlMiscOptions;
- case COLUMN_TRACEROUTECTLMAXFAILURES:
- *write_method = write_traceRouteCtlMaxFailures;
- *var_len = sizeof(StorageTmp->traceRouteCtlMaxFailures);
- return (u_char *) & StorageTmp->traceRouteCtlMaxFailures;
- case COLUMN_TRACEROUTECTLDONTFRAGMENT:
- *write_method = write_traceRouteCtlDontFragment;
- *var_len = sizeof(StorageTmp->traceRouteCtlDontFragment);
- return (u_char *) & StorageTmp->traceRouteCtlDontFragment;
- case COLUMN_TRACEROUTECTLINITIALTTL:
- *write_method = write_traceRouteCtlInitialTtl;
- *var_len = sizeof(StorageTmp->traceRouteCtlInitialTtl);
- return (u_char *) & StorageTmp->traceRouteCtlInitialTtl;
- case COLUMN_TRACEROUTECTLFREQUENCY:
- *write_method = write_traceRouteCtlFrequency;
- *var_len = sizeof(StorageTmp->traceRouteCtlFrequency);
- return (u_char *) & StorageTmp->traceRouteCtlFrequency;
- case COLUMN_TRACEROUTECTLSTORAGETYPE:
- *write_method = write_traceRouteCtlStorageType;
- *var_len = sizeof(StorageTmp->traceRouteCtlStorageType);
- return (u_char *) & StorageTmp->traceRouteCtlStorageType;
- case COLUMN_TRACEROUTECTLADMINSTATUS:
- *write_method = write_traceRouteCtlAdminStatus;
- *var_len = sizeof(StorageTmp->traceRouteCtlAdminStatus);
- return (u_char *) & StorageTmp->traceRouteCtlAdminStatus;
- case COLUMN_TRACEROUTECTLDESCR:
- *write_method = write_traceRouteCtlDescr;
- *var_len = (StorageTmp->traceRouteCtlDescrLen);
- return (u_char *) StorageTmp->traceRouteCtlDescr;
- case COLUMN_TRACEROUTECTLMAXROWS:
- *write_method = write_traceRouteCtlMaxRows;
- *var_len = sizeof(StorageTmp->traceRouteCtlMaxRows);
- return (u_char *) & StorageTmp->traceRouteCtlMaxRows;
- case COLUMN_TRACEROUTECTLTRAPGENERATION:
- *write_method = write_traceRouteCtlTrapGeneration;
- *var_len = (StorageTmp->traceRouteCtlTrapGenerationLen);
- return (u_char *) StorageTmp->traceRouteCtlTrapGeneration;
- case COLUMN_TRACEROUTECTLCREATEHOPSENTRIES:
- *write_method = write_traceRouteCtlCreateHopsEntries;
- *var_len = sizeof(StorageTmp->traceRouteCtlCreateHopsEntries);
- return (u_char *) & StorageTmp->traceRouteCtlCreateHopsEntries;
- case COLUMN_TRACEROUTECTLTYPE:
- *write_method = write_traceRouteCtlType;
- *var_len = (StorageTmp->traceRouteCtlTypeLen) * sizeof(oid);
- return (u_char *) StorageTmp->traceRouteCtlType;
- case COLUMN_TRACEROUTECTLROWSTATUS:
- *write_method = write_traceRouteCtlRowStatus;
- *var_len = sizeof(StorageTmp->traceRouteCtlRowStatus);
- return (u_char *) & StorageTmp->traceRouteCtlRowStatus;
- default:
- ERROR_MSG("");
- }
- return NULL;
- }
- int
- traceRouteResultsTable_del(struct traceRouteCtlTable_data *thedata)
- {
- struct header_complex_index *hciptr2 = NULL;
- struct traceRouteResultsTable_data *StorageDel = NULL;
- netsnmp_variable_list *vars = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len = 0;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- bzero(newoid, sizeof(oid) * MAX_OID_LEN);
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- for (hciptr2 = traceRouteResultsTableStorage; hciptr2 != NULL;
- hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- StorageDel =
- header_complex_extract_entry
- (&traceRouteResultsTableStorage, hciptr2);
- DEBUGMSGTL(("traceRouteResultsTable", "delete success!n"));
- }
- }
- vars = NULL;
- return SNMPERR_SUCCESS;
- }
- int
- traceRouteProbeHistoryTable_del(struct traceRouteCtlTable_data *thedata)
- {
- struct header_complex_index *hciptr2 = NULL;
- struct traceRouteProbeHistoryTable_data *StorageDel = NULL;
- netsnmp_variable_list *vars = NULL;
- netsnmp_variable_list *vars_temp = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len = 0;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlOperationName */
- bzero(newoid, sizeof(oid) * MAX_OID_LEN);
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- for (hciptr2 = traceRouteProbeHistoryTableStorage; hciptr2 != NULL;
- hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- StorageDel =
- header_complex_extract_entry
- (&traceRouteProbeHistoryTableStorage, hciptr2);
- DEBUGMSGTL(("traceRouteProbeHistoryTable",
- "delete success!n"));
- }
- }
- vars = NULL;
- return SNMPERR_SUCCESS;
- }
- int
- traceRouteHopsTable_del(struct traceRouteCtlTable_data *thedata)
- {
- struct header_complex_index *hciptr2 = NULL;
- struct traceRouteHopsTable_data *StorageDel = NULL;
- netsnmp_variable_list *vars = NULL;
- netsnmp_variable_list *vars_temp = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len = 0;
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlOwnerIndex, thedata->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) thedata->traceRouteCtlTestName, thedata->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- bzero(newoid, sizeof(oid) * MAX_OID_LEN);
- header_complex_generate_oid(newoid, &newoid_len, NULL, 0, vars);
- for (hciptr2 = traceRouteHopsTableStorage; hciptr2 != NULL;
- hciptr2 = hciptr2->next) {
- if (snmp_oid_compare(newoid, newoid_len, hciptr2->name, newoid_len)
- == 0) {
- StorageDel =
- header_complex_extract_entry(&traceRouteHopsTableStorage,
- hciptr2);
- DEBUGMSGTL(("traceRouteHopsTable", "delete success!n"));
- }
- }
- vars = NULL;
- return SNMPERR_SUCCESS;
- }
- /*
- * send trap
- */
- int
- send_traceRoute_trap(struct traceRouteCtlTable_data *item,
- oid * trap_oid, size_t trap_oid_len)
- {
- static oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; /* snmpTrapIOD.0 */
- struct traceRouteResultsTable_data *StorageTmp = NULL;
- struct traceRouteHopsTable_data *StorageHops = NULL;
- netsnmp_variable_list *var_list = NULL;
- netsnmp_variable_list *vars = NULL;
- netsnmp_variable_list *var_hops = NULL;
- oid newoid[MAX_OID_LEN];
- size_t newoid_len = 0;
- oid indexoid[MAX_OID_LEN];
- size_t indexoid_len = 0;
- struct header_complex_index *hciptr;
- oid tempoid[MAX_OID_LEN];
- size_t tempoid_len = 0;
- oid traceRouteCtlTargetAddress[] =
- { 1, 3, 6, 1, 2, 1, 81, 1, 2, 1, 4 };
- oid traceRouteHopsIpTgAddress[] =
- { 1, 3, 6, 1, 2, 1, 81, 1, 5, 1, 3 };
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) item->traceRouteCtlOwnerIndex, item->traceRouteCtlOwnerIndexLen); /* traceRouteCtlOwnerIndex */
- snmp_varlist_add_variable(&vars, NULL, 0, ASN_OCTET_STR, (char *) item->traceRouteCtlTestName, item->traceRouteCtlTestNameLen); /* traceRouteCtlTestName */
- /*
- * snmpTrap oid
- */
- snmp_varlist_add_variable(&var_list, objid_snmptrap,
- sizeof(objid_snmptrap) / sizeof(oid),
- ASN_OBJECT_ID, (u_char *) trap_oid,
- trap_oid_len * sizeof(oid));
- /*
- * traceRouteCtlTargetAddress
- */
- bzero(newoid, MAX_OID_LEN * sizeof(oid));
- header_complex_generate_oid(newoid, &newoid_len,
- traceRouteCtlTargetAddress,
- sizeof(traceRouteCtlTargetAddress) /
- sizeof(oid), vars);
- snmp_varlist_add_variable(&var_list, newoid,
- newoid_len,
- ASN_OCTET_STR,
- (u_char *) item->traceRouteCtlTargetAddress,
- item->traceRouteCtlTargetAddressLen);
- for (hciptr = traceRouteHopsTableStorage; hciptr != NULL;
- hciptr = hciptr->next) {
- bzero(indexoid, MAX_OID_LEN * sizeof(oid));
- header_complex_generate_oid(indexoid, &indexoid_len, NULL, 0,
- vars);
- if (snmp_oid_compare
- (indexoid, indexoid_len, hciptr->name, indexoid_len) == 0) {
- StorageHops =
- (struct traceRouteHopsTable_data *)
- header_complex_get_from_oid(traceRouteHopsTableStorage,
- hciptr->name, hciptr->namelen);
- bzero(tempoid, MAX_OID_LEN * sizeof(oid));
- header_complex_generate_oid(tempoid, &tempoid_len,
- traceRouteHopsIpTgAddress,
- sizeof(traceRouteHopsIpTgAddress) /
- sizeof(oid), vars);
- snmp_varlist_add_variable(&var_hops, NULL, 0, ASN_UNSIGNED, (char *) &StorageHops->traceRouteHopsHopIndex, sizeof(StorageHops->traceRouteHopsHopIndex)); /* traceRouteCtlTestName */
- bzero(newoid, MAX_OID_LEN * sizeof(oid));
- header_complex_generate_oid(newoid, &newoid_len, tempoid,
- tempoid_len, var_hops);
- snmp_varlist_add_variable(&var_list, newoid, newoid_len,
- ASN_OCTET_STR,
- (u_char *) StorageHops->
- traceRouteHopsIpTgtAddress,
- StorageHops->
- traceRouteHopsIpTgtAddressLen);
- var_hops = NULL;
- }
- }
- /*
- * XXX: stuff based on event table
- */
- DEBUGMSG(("pingTest:send_ping_trap", "success!n"));
- send_v2trap(var_list);
- snmp_free_varbind(vars);
- vars = NULL;
- snmp_free_varbind(var_list);
- var_list = NULL;
- }
- int
- write_traceRouteCtlTargetAddressType(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddressType not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlTargetAddressType;
- StorageTmp->traceRouteCtlTargetAddressType = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlTargetAddressType = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlTargetAddress(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static char *tmpvar;
- static size_t tmplen;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_OCTET_STR) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddress not ASN_OCTET_STRn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in long_ret for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlTargetAddress;
- tmplen = StorageTmp->traceRouteCtlTargetAddressLen;
- StorageTmp->traceRouteCtlTargetAddress =
- (char *) malloc(var_val_len + 1);
- if (StorageTmp->traceRouteCtlTargetAddress == NULL) {
- exit(1);
- }
- memcpy(StorageTmp->traceRouteCtlTargetAddress, var_val,
- var_val_len);
- StorageTmp->traceRouteCtlTargetAddress[var_val_len] = ' ';
- StorageTmp->traceRouteCtlTargetAddressLen = var_val_len;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- SNMP_FREE(StorageTmp->traceRouteCtlTargetAddress);
- StorageTmp->traceRouteCtlTargetAddress = NULL;
- StorageTmp->traceRouteCtlTargetAddress = tmpvar;
- StorageTmp->traceRouteCtlTargetAddressLen = tmplen;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- SNMP_FREE(tmpvar);
- tmpvar = NULL;
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlByPassRouteTable(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddressType not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlByPassRouteTable;
- StorageTmp->traceRouteCtlByPassRouteTable = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlByPassRouteTable = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlDataSize(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlDataSize not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlDataSize;
- if ((*((long *) var_val)) >= 0 && (*((long *) var_val)) <= 65507)
- StorageTmp->traceRouteCtlDataSize = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlDataSize = 56;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlDataSize = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlTimeOut(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlDataSize not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlTimeOut;
- if ((*((long *) var_val)) >= 1 && (*((long *) var_val)) <= 60)
- StorageTmp->traceRouteCtlTimeOut = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlTimeOut = 3;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlTimeOut = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlProbesPerHop(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlDataSize not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlProbesPerHop;
- if ((*((long *) var_val)) >= 1 && (*((long *) var_val)) <= 10)
- StorageTmp->traceRouteCtlProbesPerHop = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlProbesPerHop = 3;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlProbesPerHop = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlPort(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddressType not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlPort;
- StorageTmp->traceRouteCtlPort = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlPort = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlMaxTtl(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlDataSize not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlMaxTtl;
- if ((*((long *) var_val)) >= 1 && (*((long *) var_val)) <= 255)
- StorageTmp->traceRouteCtlMaxTtl = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlMaxTtl = 30;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlMaxTtl = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlDSField(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlDataSize not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlDSField;
- StorageTmp->traceRouteCtlDSField = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlDSField = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlSourceAddressType(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlMaxRows not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlSourceAddressType;
- StorageTmp->traceRouteCtlSourceAddressType = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlSourceAddressType = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlSourceAddress(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static char *tmpvar;
- static size_t tmplen;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_OCTET_STR) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddress not ASN_OCTET_STRn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in long_ret for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlSourceAddress;
- tmplen = StorageTmp->traceRouteCtlSourceAddressLen;
- StorageTmp->traceRouteCtlSourceAddress =
- (char *) malloc(var_val_len + 1);
- if (StorageTmp->traceRouteCtlSourceAddress == NULL) {
- exit(1);
- }
- memcpy(StorageTmp->traceRouteCtlSourceAddress, var_val,
- var_val_len + 1);
- StorageTmp->traceRouteCtlSourceAddress[var_val_len] = ' ';
- StorageTmp->traceRouteCtlSourceAddressLen = var_val_len;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- SNMP_FREE(StorageTmp->traceRouteCtlSourceAddress);
- StorageTmp->traceRouteCtlSourceAddress = NULL;
- StorageTmp->traceRouteCtlSourceAddress = tmpvar;
- StorageTmp->traceRouteCtlSourceAddressLen = tmplen;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- SNMP_FREE(tmpvar);
- tmpvar = NULL;
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlIfIndex(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlMaxRows not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlIfIndex;
- StorageTmp->traceRouteCtlIfIndex = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlIfIndex = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlMiscOptions(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static char *tmpvar;
- static size_t tmplen;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_OCTET_STR) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTargetAddress not ASN_OCTET_STRn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in long_ret for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlMiscOptions;
- tmplen = StorageTmp->traceRouteCtlMiscOptionsLen;
- StorageTmp->traceRouteCtlMiscOptions =
- (char *) malloc(var_val_len + 1);
- if (StorageTmp->traceRouteCtlMiscOptions == NULL) {
- exit(1);
- }
- memcpy(StorageTmp->traceRouteCtlMiscOptions, var_val,
- var_val_len + 1);
- StorageTmp->traceRouteCtlMiscOptions[var_val_len] = ' ';
- StorageTmp->traceRouteCtlMiscOptionsLen = var_val_len;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- SNMP_FREE(StorageTmp->traceRouteCtlMiscOptions);
- StorageTmp->traceRouteCtlMiscOptions = NULL;
- StorageTmp->traceRouteCtlMiscOptions = tmpvar;
- StorageTmp->traceRouteCtlMiscOptionsLen = tmplen;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- SNMP_FREE(tmpvar);
- tmpvar = NULL;
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlMaxFailures(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTrapTestFailureFilter not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlMaxFailures;
- if ((*((long *) var_val)) >= 0 && (*((long *) var_val)) <= 15)
- StorageTmp->traceRouteCtlMaxFailures = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlMaxFailures = 1;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlMaxFailures = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlDontFragment(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name,
- size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlMaxRows not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlDontFragment;
- StorageTmp->traceRouteCtlDontFragment = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlDontFragment = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlInitialTtl(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlTrapTestFailureFilter not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlInitialTtl;
- if ((*((long *) var_val)) >= 0 && (*((long *) var_val)) <= 255)
- StorageTmp->traceRouteCtlInitialTtl = *((long *) var_val);
- else
- StorageTmp->traceRouteCtlInitialTtl = 1;
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlInitialTtl = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlFrequency(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_UNSIGNED) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlSourceAddressType not ASN_UNSIGNEDn");
- return SNMP_ERR_WRONGTYPE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlFrequency;
- StorageTmp->traceRouteCtlFrequency = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlFrequency = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlStorageType(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- int set_value;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- if (StorageTmp && StorageTmp->traceRouteCtlRowStatus == RS_ACTIVE) {
- return SNMP_ERR_NOTWRITABLE;
- }
- set_value = *((long *) var_val);
- switch (action) {
- case RESERVE1:
- if (var_val_type != ASN_INTEGER) {
- snmp_log(LOG_ERR,
- "write to traceRouteCtlMaxRows not ASN_INTEGERn");
- return SNMP_ERR_WRONGTYPE;
- }
- if ((StorageTmp->traceRouteCtlStorageType == 2
- || StorageTmp->traceRouteCtlStorageType == 3)
- && (set_value == 4 || set_value == 5)) {
- return SNMP_ERR_WRONGVALUE;
- }
- break;
- case RESERVE2:
- /*
- * memory reseveration, final preparation...
- */
- break;
- case FREE:
- /*
- * Release any resources that have been allocated
- */
- break;
- case ACTION:
- /*
- * The variable has been stored in objid for
- * you to use, and you have just been asked to do something with
- * it. Note that anything done here must be reversable in the UNDO case
- */
- tmpvar = StorageTmp->traceRouteCtlStorageType;
- StorageTmp->traceRouteCtlStorageType = *((long *) var_val);
- break;
- case UNDO:
- /*
- * Back out any changes made in the ACTION case
- */
- StorageTmp->traceRouteCtlStorageType = tmpvar;
- break;
- case COMMIT:
- /*
- * Things are working well, so it's now safe to make the change
- * permanently. Make sure that anything done here can't fail!
- */
- break;
- }
- return SNMP_ERR_NOERROR;
- }
- int
- write_traceRouteCtlAdminStatus(int action,
- u_char * var_val,
- u_char var_val_type,
- size_t var_val_len,
- u_char * statP, oid * name, size_t name_len)
- {
- static size_t tmpvar;
- struct traceRouteCtlTable_data *StorageTmp = NULL;
- netsnmp_variable_list *vars = NULL;
- struct traceRouteResultsTable_data *StorageNew = NULL;
- static size_t tmplen;
- size_t newlen =
- name_len -
- (sizeof(traceRouteCtlTable_variables_oid) / sizeof(oid) + 3 - 1);
- if ((StorageTmp =
- header_complex(traceRouteCtlTableStorage, NULL,
- &name[sizeof(traceRouteCtlTable_variables_oid) /
- sizeof(oid) + 3 - 1], &newlen, 1, NULL,
- NULL)) == NULL)
- return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */
- if (StorageTmp && StorageTmp->storageType == ST_READONLY) {
- return SNMP_ERR_NOTWRITABLE;
- }
- switch (action) {
- case RESERVE1: