📄 agentpp_test_mib.cpp
字号:
/*_############################################################################ _## _## agentpp_test_mib.cpp _## _## _## AgentX++ v1.4.15 _## --------------------------------------------------------- _## Copyright (C) 2000-2006, Frank Fock, All rights reserved. _## _## Use of this software is subject to the license agreement you received _## with this software and which can be downloaded from _## http://www.agentpp.com _## _## This is licensed software and may not be used in a commercial _## environment, except for evaluation purposes, unless a valid _## license has been purchased. _## _## Last updated: Fri Jun 16 20:00:36 CEST 2006 _## _##########################################################################*/ //--AgentGen BEGIN=_BEGIN//--AgentGen END#ifndef _agentpp_test_mib_cpp#define _agentpp_test_mib_cpp#include <agentpp_test_mib.h>//--AgentGen BEGIN=_INCLUDE//--AgentGen END#ifdef AGENTPP_NAMESPACEnamespace Agentpp {#endif// Scalar Objects/** * agentppTestTimeout * * "Setting this object will be delayed by the given * amount of milliseconds. That is, by setting this * object to 1000 the corresponding response to * that SET request will be delayed by one second." */ agentppTestTimeout* agentppTestTimeout::instance = 0;agentppTestTimeout::agentppTestTimeout(): MibLeaf(oidAgentppTestTimeout, READWRITE, new Gauge32()){ // This leaf object is a singleton. In order to access it use // the static pointer agentppTestTimeout::instance. instance = this; //--AgentGen BEGIN=agentppTestTimeout::agentppTestTimeout //--AgentGen END}agentppTestTimeout::~agentppTestTimeout(){ //--AgentGen BEGIN=agentppTestTimeout::~agentppTestTimeout //--AgentGen END}void agentppTestTimeout::get_request(Request* req, int ind){ //--AgentGen BEGIN=agentppTestTimeout::get_request //--AgentGen END MibLeaf::get_request(req, ind);}unsigned long agentppTestTimeout::get_state(){ //--AgentGen BEGIN=agentppTestTimeout::get_state //--AgentGen END return (unsigned long)*((Gauge32*)value);}void agentppTestTimeout::set_state(unsigned long l){ //--AgentGen BEGIN=agentppTestTimeout::set_state //--AgentGen END *((Gauge32*)value) = l;}int agentppTestTimeout::set(const Vbx& vb){ //--AgentGen BEGIN=agentppTestTimeout::set unsigned long timeout; vb.get_value(timeout);#ifndef WIN32 struct timeval tvptr; tvptr.tv_sec = timeout/1000; // wait up to sec seconds tvptr.tv_usec = (timeout%1000)*1000; select(0, NULL, NULL, NULL, &tvptr);#else Sleep(timeout);#endif //--AgentGen END return MibLeaf::set(vb);}int agentppTestTimeout::commit_set_request(Request* req, int ind){ //--AgentGen BEGIN=agentppTestTimeout::commit_set_request //--AgentGen END return MibLeaf::commit_set_request(req, ind);}void agentppTestTimeout::cleanup_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestTimeout::cleanup_set_request //--AgentGen END MibLeaf::cleanup_set_request(req, ind);}int agentppTestTimeout::undo_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestTimeout::undo_set_request //--AgentGen END return MibLeaf::undo_set_request(req, ind);}boolean agentppTestTimeout::value_ok(const Vbx& vb){ unsigned long v; vb.get_value(v); if (!(((v >= 0ul) && (v <= 1000000ul)))) return FALSE; //--AgentGen BEGIN=agentppTestTimeout::value_ok //--AgentGen END return TRUE;}int agentppTestTimeout::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=agentppTestTimeout::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=agentppTestTimeout//--AgentGen END// Columnar Objects/** * agentppTestSharedTableDelay * * "The number of 1/100 seconds that a request to this * row will be delayed before it is processed." */ agentppTestSharedTableDelay::agentppTestSharedTableDelay(const Oidx& id): MibLeaf(id, READCREATE, new SnmpInt32(0), VMODE_DEFAULT){ //--AgentGen BEGIN=agentppTestSharedTableDelay::agentppTestSharedTableDelay //--AgentGen END}agentppTestSharedTableDelay::~agentppTestSharedTableDelay(){ //--AgentGen BEGIN=agentppTestSharedTableDelay::~agentppTestSharedTableDelay //--AgentGen END}MibEntryPtr agentppTestSharedTableDelay::clone(){ MibEntryPtr other = new agentppTestSharedTableDelay(oid); ((agentppTestSharedTableDelay*)other)->replace_value(value->clone()); ((agentppTestSharedTableDelay*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=agentppTestSharedTableDelay::clone //--AgentGen END return other;}void agentppTestSharedTableDelay::get_request(Request* req, int ind){ //--AgentGen BEGIN=agentppTestSharedTableDelay::get_request delay_execution(); //--AgentGen END MibLeaf::get_request(req, ind);}long agentppTestSharedTableDelay::get_state(){ //--AgentGen BEGIN=agentppTestSharedTableDelay::get_state //--AgentGen END return (long)*((SnmpInt32*)value);} void agentppTestSharedTableDelay::set_state(long l){ //--AgentGen BEGIN=agentppTestSharedTableDelay::set_state //--AgentGen END *((SnmpInt32*)value) = l;} int agentppTestSharedTableDelay::set(const Vbx& vb){ //--AgentGen BEGIN=agentppTestSharedTableDelay::set //--AgentGen END return MibLeaf::set(vb);}int agentppTestSharedTableDelay::commit_set_request(Request* req, int ind){ //--AgentGen BEGIN=agentppTestSharedTableDelay::commit_set_request delay_execution(); //--AgentGen END return MibLeaf::commit_set_request(req, ind);}void agentppTestSharedTableDelay::cleanup_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestSharedTableDelay::cleanup_set_request //--AgentGen END MibLeaf::cleanup_set_request(req, ind);}int agentppTestSharedTableDelay::undo_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestSharedTableDelay::undo_set_request //--AgentGen END return MibLeaf::undo_set_request(req, ind);}boolean agentppTestSharedTableDelay::value_ok(const Vbx& vb){ long v; vb.get_value(v); if (!(((v >= 0) && (v <= 6000)))) return FALSE; //--AgentGen BEGIN=agentppTestSharedTableDelay::value_ok //--AgentGen END return TRUE;}int agentppTestSharedTableDelay::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=agentppTestSharedTableDelay::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=agentppTestSharedTableDelayvoid agentppTestSharedTableDelay::delay_execution() { unsigned long timeout = get_state()*10; if (timeout == 0) return;#ifndef WIN32 struct timeval tvptr; tvptr.tv_sec = timeout/1000; // wait up to sec seconds tvptr.tv_usec = (timeout%1000)*1000; select(0, NULL, NULL, NULL, &tvptr);#else Sleep(timeout);#endif }//--AgentGen END/** * agentppTestSharedTableRowStatus * * "The row status of the row." */ agentppTestSharedTableRowStatus::agentppTestSharedTableRowStatus(const Oidx& id): snmpRowStatus(id, READCREATE){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::agentppTestSharedTableRowStatus set_state(rowActive); //--AgentGen END}agentppTestSharedTableRowStatus::~agentppTestSharedTableRowStatus(){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::~agentppTestSharedTableRowStatus //--AgentGen END}MibEntryPtr agentppTestSharedTableRowStatus::clone(){ MibEntryPtr other = new agentppTestSharedTableRowStatus(oid); ((agentppTestSharedTableRowStatus*)other)->replace_value(value->clone()); ((agentppTestSharedTableRowStatus*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=agentppTestSharedTableRowStatus::clone //--AgentGen END return other;}long agentppTestSharedTableRowStatus::get_state(){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::get_state //--AgentGen END return (long)*((SnmpInt32*)value);} void agentppTestSharedTableRowStatus::set_state(long l){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::set_state //--AgentGen END *((SnmpInt32*)value) = l;} int agentppTestSharedTableRowStatus::set(const Vbx& vb){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::set //--AgentGen END return snmpRowStatus::set(vb);}int agentppTestSharedTableRowStatus::commit_set_request(Request* req, int ind){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::commit_set_request //--AgentGen END return snmpRowStatus::commit_set_request(req, ind);}void agentppTestSharedTableRowStatus::cleanup_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::cleanup_set_request //--AgentGen END snmpRowStatus::cleanup_set_request(req, ind);}int agentppTestSharedTableRowStatus::undo_set_request(Request* req, int& ind){ //--AgentGen BEGIN=agentppTestSharedTableRowStatus::undo_set_request //--AgentGen END return snmpRowStatus::undo_set_request(req, ind);}int agentppTestSharedTableRowStatus::prepare_set_request(Request* req, int& ind){ int status; if ((status = snmpRowStatus::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=agentppTestSharedTableRowStatus::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=agentppTestSharedTableRowStatus//--AgentGen END/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -