⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 master.cpp

📁 JdonFramework need above jdk 1.4.0This version has passed under Tomcat 4.x/5.x JBoss 3.x/JBoss 4.0.0
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*_############################################################################  _##   _##  master.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 <stdlib.h>#include <signal.h>#include <agent_pp/agent++.h>#include <agent_pp/snmp_group.h>#include <agent_pp/system_group.h>#include <agent_pp/snmp_target_mib.h>#include <agent_pp/snmp_notification_mib.h>#include <agent_pp/notification_originator.h>#include <agent_pp/notification_log_mib.h>#include <agent_pp/snmp_community_mib.h>#include <agent_pp/agentpp_config_mib.h>#include <agent_pp/v3_mib.h>#include <snmp_pp/oid_def.h>#include <snmp_pp/mp_v3.h>#include <snmp_pp/log.h>#include <agentx_pp/agentx_master.h>#include <agentx_pp/agentpp_agentx_mib.h>#ifdef AGENTPP_NAMESPACEusing namespace Agentpp;#endif// globals:u_short port;MasterAgentXMib* mib = 0;RequestList* reqList = 0;AgentXMaster* agentx = 0;boolean run = TRUE;extern "C" {static void sig(int signo){	if ((signo == SIGTERM) || (signo == SIGINT) ||	    (signo == SIGSEGV)) {		printf ("\n");      		switch (signo) {		case SIGSEGV: {			printf ("Segmentation fault, aborting.\n");			exit(1);		}		case SIGTERM: 		case SIGINT: {					if (run) printf ("User abort\n");		        run = FALSE;		}		}	}}}void init_signals(){	signal (SIGTERM, sig);	signal (SIGINT, sig);	signal (SIGSEGV, sig);	// catch SIGPIPE and ignore it	// this can occur when the subagent dies when we are trying	// to send a request#ifndef WIN32	signal (SIGPIPE, sig);#endif}	/** * The RegDump class can be used for debugging purposes to dump the * registration of the AgentX master agent. It is not used by default.  */class RegDump: public MibLeaf{public:  RegDump(Mib* m): MibLeaf("1.3.6.1.4.1.4976.100.0", READWRITE, new OctetStr(""))  {     myMib = m;  }    virtual int set(const Vbx& vb)  {	OctetStr context;	vb.get_value(context);	MibContext* c = myMib->get_context(context);	if (!c) return SNMP_ERROR_COMITFAIL;	OidListCursor<MibEntry> cr(c->get_content());	LOG_BEGIN(DEBUG_LOG | 1);	LOG("RegDump: BEGIN");	LOG_END;	for (; cr.get(); cr.next()) {		LOG_BEGIN(DEBUG_LOG | 1);		LOG(cr.get()->key()->get_printable());		LOG(cr.get()->max_key()->get_printable());		LOG_END;	}	LOG_BEGIN(DEBUG_LOG | 1);	LOG("RegDump: END");	LOG_END;		return MibLeaf::set(vb);  }protected:  Mib* myMib;};#ifdef _SNMPv3void allow_agentx_tcp_from_localhost(){	// init AgentX source address validation	if (snmpTargetAddrEntry::instance && 		snmpTargetAddrExtEntry::instance) { 		snmpTargetAddrEntry::instance->		    add_entry("AgentXLocalhost", "1.3.6.1.2.1.100.1.5",			      OctetStr::from_hex_string("7F 00 00 01 00 00"),					  "agentX", "null");		MibTableRow* r =		    snmpTargetAddrExtEntry::instance->		    add_row(Oidx::from_string("AgentXLocalhost", FALSE));		snmpTargetAddrExtEntry::instance->		    set_row(r, OctetStr::from_hex_string("FF FF FF FF 00 00"),			    1500);		r = agentppAgentXExtSrcAddrEntry::instance->		    add_row(Oidx::from_string("localhost"));		r->get_nth(0)->replace_value(new OctetStr("agentX"));		r->get_nth(1)->replace_value(new SnmpInt32(rowActive));	}}#endifvoid init(Mib& mib){	OctetStr sysDescr("AgentX++ v");	sysDescr += AGENTXPP_VERSION_STRING;	sysDescr += " example agent";        mib.add(new sysGroup(sysDescr.get_printable(), 			     "1.3.6.1.4.1.4976", 10));  	mib.add(new snmpGroup());	mib.add(new TestAndIncr(oidSnmpSetSerialNo));	mib.add(new snmp_target_mib());		// Add the following if you want to be able to	// dump the agent's current AgentX registration to stdout	//	mib.add(new RegDump(&mib));#ifdef _SNMPv3	mib.add(new snmp_community_mib());	mib.add(new agentpp_agentx_mib());#endif	mib.add(new snmp_notification_mib());#ifdef _SNMPv3	mib.add(new notification_log_mib());	UsmUserTable *uut = new UsmUserTable();	uut->addNewRow("unsecureUser",		       SNMPv3_usmNoAuthProtocol,		       SNMPv3_usmNoPrivProtocol, "", "");		uut->addNewRow("MD5",		       SNMPv3_usmHMACMD5AuthProtocol,		       SNMPv3_usmNoPrivProtocol,		       "MD5UserAuthPassword", "");		uut->addNewRow("SHA",		       SNMPv3_usmHMACSHAAuthProtocol,		       SNMPv3_usmNoPrivProtocol,		       "SHAUserAuthPassword", "");		uut->addNewRow("MD5DES",		       SNMPv3_usmHMACMD5AuthProtocol,		       SNMPv3_usmDESPrivProtocol,		       "MD5DESUserAuthPassword",		       "MD5DESUserPrivPassword");	uut->addNewRow("SHADES",		       SNMPv3_usmHMACSHAAuthProtocol,		       SNMPv3_usmDESPrivProtocol,		       "SHADESUserAuthPassword",		       "SHADESUserPrivPassword");		uut->addNewRow("MD5IDEA",		       SNMPv3_usmHMACMD5AuthProtocol,		       SNMPv3_usmIDEAPrivProtocol,		       "MD5IDEAUserAuthPassword",		       "MD5IDEAUserPrivPassword");		uut->addNewRow("SHAIDEA",		       SNMPv3_usmHMACSHAAuthProtocol,		       SNMPv3_usmIDEAPrivProtocol,		       "SHAIDEAUserAuthPassword",		       "SHAIDEAUserPrivPassword");	// add non persistent USM statistics	mib.add(new UsmStats());	// add the USM MIB - usm_mib MibGroup is used to	// make user added entries persistent	mib.add(new usm_mib(uut));	// add non persistent SNMPv3 engine object	mib.add(new V3SnmpEngine());	mib.add(new MPDGroup());	mib.add(new agentpp_config_mib(&mib));#endif	/* No longer needed if auto context creation is activated! See below.	// add an empty context, so a subagent can register	// its objects within this context (and of course the default 	// context.	mib.add_context("subagent");	mib.add_context("subagent2");	*/}	int main (int argc, char* argv[]){	int agentxPort = AGENTX_SVC_PORT;	if (argc>1) {	    port = atoi(argv[1]);	    if (argc > 2) {		agentxPort = atoi(argv[2]);	    }	}	else {	    port = 4700;	}#ifndef _NO_LOGGING	DefaultLog::log()->set_filter(ERROR_LOG, 5);	DefaultLog::log()->set_filter(WARNING_LOG, 5);	DefaultLog::log()->set_filter(EVENT_LOG, 5);	DefaultLog::log()->set_filter(INFO_LOG, 5);	DefaultLog::log()->set_filter(DEBUG_LOG, 5);#endif	int status;	Snmp::socket_startup();  // Initialize socket subsystem	Snmpx snmp(status, port);	if (status == SNMP_CLASS_SUCCESS) {		LOG_BEGIN(EVENT_LOG | 1);		LOG("main: SNMP listen port");		LOG(port);		LOG_END;	}	else {		LOG_BEGIN(ERROR_LOG | 0);		LOG("main: SNMP port init failed");		LOG(status);		LOG_END;		exit(1);	}#ifdef _SNMPv3        unsigned int snmpEngineBoots = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -