本文整理汇总了C++中Pdu::agent_error_reason方法的典型用法代码示例。如果您正苦于以下问题:C++ Pdu::agent_error_reason方法的具体用法?C++ Pdu::agent_error_reason怎么用?C++ Pdu::agent_error_reason使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pdu
的用法示例。
在下文中一共展示了Pdu::agent_error_reason方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
void getapp::result(Snmp *, int rc)
{
Vb vb;
if (rc < 0)
{
const char *ptr = snmp_.error_string();
cout << "ASNMP:ERROR: get command failed reason: " << ptr << endl;
}
else
{
// check to see if there are any errors
if (pdu_.get_error_status())
{
cout << "ERROR: agent replied as follows\n";
cout << pdu_.agent_error_reason() << endl;
}
else
{
VbIter iter(pdu_);
while (iter.next(vb))
{
cout << "\tOid = " << vb.to_string_oid() << "\n";
cout << "\tValue = " << vb.to_string_value() << "\n";
}
}
}
cout << "\nASNMP:INFO: command completed normally.\n"<< endl;
ACE_Reactor::instance()->end_reactor_event_loop();
}
示例2: run
int getapp::run()
{
//----------[ create a ASNMP session ]-----------------------------------
if ( snmp_.valid() != SNMP_CLASS_SUCCESS) {
cout << "\nASNMP:ERROR:Create session failed: "<<
snmp_.error_string()<< "\n";
return 1;
}
//--------[ build up ASNMP object needed ]-------------------------------
if (address_.get_port() == 0)
address_.set_port(DEF_AGENT_PORT);
target_.set_address( address_); // make a target using the address
//-------[ issue the request, blocked mode ]-----------------------------
cout << "\nASNMP:INFO:SNMP Version " << (target_.get_version()+ 1) << \
" GET SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n";
target_.get_address(address_); // target updates port used
int rc;
const char *name = address_.resolve_hostname(rc);
cout << "Device: " << address_ << " ";
//FUZZ: disable check_for_lack_ACE_OS
cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n";
//FUZZ: enable check_for_lack_ACE_OS
cout << "[ Retries=" << target_.get_retry() << " \
Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \
community_.to_string() << " ]"<< endl;
if (snmp_.get( pdu_, target_) == SNMP_CLASS_SUCCESS) {
Vb vb;
// check to see if there are any errors
if (pdu_.get_error_status()) {
cout << "ERROR: agent replied as follows\n";
cout << pdu_.agent_error_reason() << endl;
}
else {
VbIter iter(pdu_);
while (iter.next(vb)) {
cout << "\tOid = " << vb.to_string_oid() << "\n";
cout << "\tValue = " << vb.to_string_value() << "\n";
}
}
}
else {
const char *ptr = snmp_.error_string();
cout << "ASNMP:ERROR: get command failed reason: " << ptr << endl;
}
cout << "\nASNMP:INFO: command completed normally.\n"<< endl;
return 0;
}
示例3: next
// return vb of next oid in agent tree, return 1 else return 0, reason set
int MibIter::next(Vb& vb, char *& reason)
{
int rc;
if (valid_ == 0) // not valid object
return -1;
// 1. poll for value
if (first_ == 0) {
rc = snmp_->get( pdu_, *target_);
first_++;
}
else {
rc = snmp_->get_next( pdu_, *target_);
}
if (rc != SNMP_CLASS_SUCCESS) {
reason = const_cast <char*> (snmp_->error_string());
return 0;
}
// 2. check for problems
if (pdu_.get_error_status()) {
reason = const_cast <char*> (pdu_.agent_error_reason());
return 0;
}
// 3. return vb to caller
pdu_.get_vb(vb, 0);
Oid nextoid;
vb.get_oid(nextoid); // and setup next oid to get
Vb nextvb(nextoid);
pdu_.delete_all_vbs();
pdu_ += nextvb; // can't do set_vb as there are no entries to replace
return 1; // ok
}