📄 if_mib.cpp
字号:
/*_############################################################################ _## _## if_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 _## _##########################################################################*/#include <if_mib.h>/** * generated by AgentGen 1.5.2 for AGENT++v3.4 * Wed Feb 28 01:09:22 GMT+01:00 2001. *///--AgentGen BEGIN=_INCLUDE#include <agent_pp/system_group.h>#include <snmp_pp/log.h>#ifdef linux#include <unistd.h>#include <stdlib.h>#include <ctype.h>#include <sys/socket.h>#include <sys/ioctl.h>#include <sys/sysctl.h>#include <net/if.h>#include <netinet/ip.h>#ifdef AGENTPP_NAMESPACEnamespace Agentpp {#endif//--AgentGen END/** * ifNumber * */ifNumber* ifNumber::instance = 0;ifNumber::ifNumber(): MibLeaf(oidIfNumber, READONLY, new SnmpInt32()){ // This leaf object is a singleton. In order to access it use // the static pointer ifNumber::instance. instance = this; //--AgentGen BEGIN=ifNumber::ifNumber //--AgentGen END}ifNumber::~ifNumber(){ //--AgentGen BEGIN=ifNumber::~ifNumber //--AgentGen END}void ifNumber::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifNumber::get_request if (ifEntry::instance) { ifEntry::instance->update(req); set_state(ifEntry::instance->size()); } //--AgentGen END MibLeaf::get_request(req, ind);}long ifNumber::get_state(){ return (long)*((SnmpInt32*)value);}void ifNumber::set_state(long l){ //--AgentGen BEGIN=ifNumber::set_state //--AgentGen END *((SnmpInt32*)value) = l;}//--AgentGen BEGIN=ifNumber//--AgentGen END/** * ifAdminStatus * */ifAdminStatus::ifAdminStatus(const Oidx& id): MibLeaf(id, READWRITE, new SnmpInt32()){ //--AgentGen BEGIN=ifAdminStatus::ifAdminStatus set_access(READONLY); //--AgentGen END}ifAdminStatus::~ifAdminStatus(){ //--AgentGen BEGIN=ifAdminStatus::~ifAdminStatus //--AgentGen END}MibEntryPtr ifAdminStatus::clone(){ MibEntryPtr other = new ifAdminStatus(oid); ((ifAdminStatus*)other)->replace_value(value->clone()); ((ifAdminStatus*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifAdminStatus::clone //--AgentGen END return other;}void ifAdminStatus::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifAdminStatus::get_request //--AgentGen END MibLeaf::get_request(req, ind);}long ifAdminStatus::get_state(){ return (long)*((SnmpInt32*)value);}void ifAdminStatus::set_state(long l){ //--AgentGen BEGIN=ifAdminStatus::set_state //--AgentGen END *((SnmpInt32*)value) = l;}int ifAdminStatus::set(const Vbx& vb){ //--AgentGen BEGIN=ifAdminStatus::set long l = 0; vb.get_value(l); // *((SnmpInt32*)value) = l; Vbx vbs[3]; Oidx index(my_row->get_index()); Oidx ind("1.3.6.1.2.1.2.2.1.1"); ind += index; vbs[0].set_oid(ind); Oidx adminStatus(oidIfAdminStatus); adminStatus += index; Oidx operStatus(oidIfOperStatus); operStatus += index; vbs[0].set_oid(ind); vbs[0].set_value(SnmpUInt32(index[0])); vbs[1].set_oid(adminStatus); int state = 0; my_row->get_nth(7)->get_value(state); vbs[1].set_value(SnmpInt32(state)); vbs[2].set_oid(operStatus); vbs[2].set_value(SnmpInt32(get_state())); switch(l) { case 1: { linkUp no(((AgentXSharedTable*)my_table)->get_subagent_mib()); no.generate(vbs, 3, ""); break; } default: { linkDown no(((AgentXSharedTable*)my_table)->get_subagent_mib()); no.generate(vbs, 3, ""); break; } } my_row->get_nth(7)->replace_value(new SnmpInt32(l)); //--AgentGen END return MibLeaf::set(vb);}boolean ifAdminStatus::value_ok(const Vbx& vb){ long v; vb.get_value(v); if ((v != 1) && (v != 2) && (v != 3) ) return FALSE; //--AgentGen BEGIN=ifAdminStatus::value_ok //--AgentGen END return TRUE;}int ifAdminStatus::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=ifAdminStatus::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=ifAdminStatus//--AgentGen END/** * ifLinkUpDownTrapEnable * */ifLinkUpDownTrapEnable::ifLinkUpDownTrapEnable(const Oidx& id): MibLeaf(id, READWRITE, new SnmpInt32()){ //--AgentGen BEGIN=ifLinkUpDownTrapEnable::ifLinkUpDownTrapEnable //--AgentGen END}ifLinkUpDownTrapEnable::~ifLinkUpDownTrapEnable(){ //--AgentGen BEGIN=ifLinkUpDownTrapEnable::~ifLinkUpDownTrapEnable //--AgentGen END}MibEntryPtr ifLinkUpDownTrapEnable::clone(){ MibEntryPtr other = new ifLinkUpDownTrapEnable(oid); ((ifLinkUpDownTrapEnable*)other)->replace_value(value->clone()); ((ifLinkUpDownTrapEnable*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifLinkUpDownTrapEnable::clone //--AgentGen END return other;}void ifLinkUpDownTrapEnable::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifLinkUpDownTrapEnable::get_request //--AgentGen END MibLeaf::get_request(req, ind);}long ifLinkUpDownTrapEnable::get_state(){ return (long)*((SnmpInt32*)value);}void ifLinkUpDownTrapEnable::set_state(long l){ //--AgentGen BEGIN=ifLinkUpDownTrapEnable::set_state //--AgentGen END *((SnmpInt32*)value) = l;}int ifLinkUpDownTrapEnable::set(const Vbx& vb){ //--AgentGen BEGIN=ifLinkUpDownTrapEnable::set //--AgentGen END return MibLeaf::set(vb);}boolean ifLinkUpDownTrapEnable::value_ok(const Vbx& vb){ long v; vb.get_value(v); if ((v != 1) && (v != 2)) return FALSE; //--AgentGen BEGIN=ifLinkUpDownTrapEnable::value_ok //--AgentGen END return TRUE;}int ifLinkUpDownTrapEnable::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=ifLinkUpDownTrapEnable::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=ifLinkUpDownTrapEnable//--AgentGen END/** * ifPromiscuousMode * */ifPromiscuousMode::ifPromiscuousMode(const Oidx& id): MibLeaf(id, READWRITE, new SnmpInt32()){ //--AgentGen BEGIN=ifPromiscuousMode::ifPromiscuousMode //--AgentGen END}ifPromiscuousMode::~ifPromiscuousMode(){ //--AgentGen BEGIN=ifPromiscuousMode::~ifPromiscuousMode //--AgentGen END}MibEntryPtr ifPromiscuousMode::clone(){ MibEntryPtr other = new ifPromiscuousMode(oid); ((ifPromiscuousMode*)other)->replace_value(value->clone()); ((ifPromiscuousMode*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifPromiscuousMode::clone //--AgentGen END return other;}void ifPromiscuousMode::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifPromiscuousMode::get_request //--AgentGen END MibLeaf::get_request(req, ind);}long ifPromiscuousMode::get_state(){ return (long)*((SnmpInt32*)value);}void ifPromiscuousMode::set_state(long l){ //--AgentGen BEGIN=ifPromiscuousMode::set_state //--AgentGen END *((SnmpInt32*)value) = l;}int ifPromiscuousMode::set(const Vbx& vb){ //--AgentGen BEGIN=ifPromiscuousMode::set //--AgentGen END return MibLeaf::set(vb);}boolean ifPromiscuousMode::value_ok(const Vbx& vb){ long v; vb.get_value(v); if ((v != 1) && (v != 2)) return FALSE; //--AgentGen BEGIN=ifPromiscuousMode::value_ok //--AgentGen END return TRUE;}int ifPromiscuousMode::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=ifPromiscuousMode::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=ifPromiscuousMode//--AgentGen END/** * ifAlias * */ifAlias::ifAlias(const Oidx& id): SnmpDisplayString(id, READWRITE, new OctetStr()){ //--AgentGen BEGIN=ifAlias::ifAlias //--AgentGen END}ifAlias::~ifAlias(){ //--AgentGen BEGIN=ifAlias::~ifAlias //--AgentGen END}MibEntryPtr ifAlias::clone(){ MibEntryPtr other = new ifAlias(oid); ((ifAlias*)other)->replace_value(value->clone()); ((ifAlias*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifAlias::clone //--AgentGen END return other;}void ifAlias::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifAlias::get_request //--AgentGen END MibLeaf::get_request(req, ind);}int ifAlias::set(const Vbx& vb){ //--AgentGen BEGIN=ifAlias::set //--AgentGen END return MibLeaf::set(vb);}boolean ifAlias::value_ok(const Vbx& vb){ //--AgentGen BEGIN=ifAlias::value_ok //--AgentGen END return TRUE;}int ifAlias::prepare_set_request(Request* req, int& ind){ int status; if ((status = SnmpDisplayString::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; Vb vb(req->get_value(ind)); OctetStr v; vb.get_value(v); if (!(((v.len() >= 0) && (v.len() <= 255)))) return SNMP_ERROR_WRONG_LENGTH; //--AgentGen BEGIN=ifAlias::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=ifAlias//--AgentGen END/** * ifStackStatus * */ifStackStatus::ifStackStatus(const Oidx& id): snmpRowStatus(id, READCREATE){ //--AgentGen BEGIN=ifStackStatus::ifStackStatus //--AgentGen END}ifStackStatus::~ifStackStatus(){ //--AgentGen BEGIN=ifStackStatus::~ifStackStatus //--AgentGen END}MibEntryPtr ifStackStatus::clone(){ MibEntryPtr other = new ifStackStatus(oid); ((ifStackStatus*)other)->replace_value(value->clone()); ((ifStackStatus*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifStackStatus::clone //--AgentGen END return other;}long ifStackStatus::get_state(){ return (long)*((SnmpInt32*)value);}void ifStackStatus::set_state(long l){ //--AgentGen BEGIN=ifStackStatus::set_state //--AgentGen END *((SnmpInt32*)value) = l;}int ifStackStatus::set(const Vbx& vb){ //--AgentGen BEGIN=ifStackStatus::set //--AgentGen END return snmpRowStatus::set(vb);}int ifStackStatus::prepare_set_request(Request* req, int& ind){ int status; if ((status = snmpRowStatus::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=ifStackStatus::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}//--AgentGen BEGIN=ifStackStatus//--AgentGen END/** * ifTestId * */ifTestId::ifTestId(const Oidx& id): MibLeaf(id, READWRITE, new SnmpInt32()){ //--AgentGen BEGIN=ifTestId::ifTestId //--AgentGen END}ifTestId::~ifTestId(){ //--AgentGen BEGIN=ifTestId::~ifTestId //--AgentGen END}MibEntryPtr ifTestId::clone(){ MibEntryPtr other = new ifTestId(oid); ((ifTestId*)other)->replace_value(value->clone()); ((ifTestId*)other)->set_reference_to_table(my_table); //--AgentGen BEGIN=ifTestId::clone //--AgentGen END return other;}void ifTestId::get_request(Request* req, int ind){ //--AgentGen BEGIN=ifTestId::get_request //--AgentGen END MibLeaf::get_request(req, ind);}long ifTestId::get_state(){ return (long)*((SnmpInt32*)value);}void ifTestId::set_state(long l){ //--AgentGen BEGIN=ifTestId::set_state //--AgentGen END *((SnmpInt32*)value) = l;}int ifTestId::set(const Vbx& vb){ //--AgentGen BEGIN=ifTestId::set //--AgentGen END return MibLeaf::set(vb);}boolean ifTestId::value_ok(const Vbx& vb){ long v; vb.get_value(v); if (!(((v >= 0) && (v <= 2147483647)))) return FALSE; //--AgentGen BEGIN=ifTestId::value_ok //--AgentGen END return TRUE;}int ifTestId::prepare_set_request(Request* req, int& ind){ int status; if ((status = MibLeaf::prepare_set_request(req, ind)) != SNMP_ERROR_SUCCESS) return status; //--AgentGen BEGIN=ifTestId::prepare_set_request //--AgentGen END return SNMP_ERROR_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -