当前位置: 首页>>代码示例>>C++>>正文


C++ Pdu类代码示例

本文整理汇总了C++中Pdu的典型用法代码示例。如果您正苦于以下问题:C++ Pdu类的具体用法?C++ Pdu怎么用?C++ Pdu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Pdu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitUTarget

/////////////////////////////////////////////////////////////////////////////
// 函数:SetRequest                                                        //
// 说明:设置简单变量的结果                                                //
// 参数:无                                                                //
// 返回值:                                                                //
//      成功返回0,否则返回一个非0 值                                      //
/////////////////////////////////////////////////////////////////////////////
int BasicSNMP::SetRequest()
{
	int nResult = 0;
	Pdu pdu;                               // construct a Pdu object
	Vb vb;                                 // construct a Vb object
	vb.set_oid(oid);                      // set the Oid portion of the Vb
	vb.set_value(m_nOIDValue);                      // set the Oid portion of the Vb
	pdu += vb;   

	SnmpTarget *target;// = &ctarget;
	if(version ==version3)
	{//If SNMP Version Is 3
		nResult = InitUTarget();//Init UTarget
		pdu.set_security_level( m_nSecurityLevel);//Set the Security Level portion of Pdu
		pdu.set_context_name (contextName);//Set the Context Name portion of Pdu
		pdu.set_context_engine_id(contextEngineID);//Set the Context Engine ID portion of Pdu
		target = &utarget; //Set SNMP Target
	}
	else
	{
		target = &ctarget; //Set SNMP Target
	}

	nResult = pSnmp->set(pdu,*target);//Get Reques

	return nResult;
}
开发者ID:chengxingyu123,项目名称:ecc814,代码行数:34,代码来源:SNMP_lib.cpp

示例2: load_vbs

int wpdu::load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu)
{
  int status = 0;

   // load up the payload
   // for all Vbs in list, add them to the pdu
   int vb_count;
   Vb tempvb;
   Oid tempoid;
   SmiLPOID smioid;
   SmiVALUE smival;

   vb_count = pdu.get_vb_count();

   for (int z = 0; z < vb_count; z++) {
      pdu.get_vb( tempvb, z);
      tempvb.get_oid( tempoid);
      smioid = tempoid.oidval();
      // what are we trying to convert here (vb oid part or value part)
      status = convert_vb_to_smival( tempvb, &smival );
      if ( status != SNMP_CLASS_SUCCESS)
         return status;

      // add the var to the raw pdu
      cmu_snmp::add_var(raw_pdu, smioid->ptr, (int) smioid->len, &smival);
      free_smival_descriptor( &smival);
    }

  return status;
}
开发者ID:helixum,项目名称:wow-cata,代码行数:30,代码来源:wpdu.cpp

示例3: handle_get

// callback : have received a Pdu from the target host with given read comm str
// this is really simplistic, but gives the general idea
int agent_impl::handle_get( Pdu &pdu, UdpTarget &target)
{
  ACE_TRACE("agent_impl::handle_get");
  OctetStr mgr_rd_str, agent_rd_str;
  target.get_read_community(mgr_rd_str); // requster's read community string
  tgt_.get_read_community(agent_rd_str); // this agent's read community string

  //  1. verify we have a valid read string else drop pdu (no response to caller)
  if (mgr_rd_str != agent_rd_str) {
     ACE_DEBUG((LM_DEBUG, "agent_impl::handle_get: invalid read community recvd\n"));
     return 0;
  }

  // 2. iterate over each varbind in the pdu, filling providing responses
  int fdone = 0;
  for (int i = 0; (i < pdu.get_vb_count()) && !fdone; i++) {
    Vb vb;
    pdu.get_vb(vb, i);
    if (get_response(vb)) { // set a value for the oid if we can else
      set_error_status(&pdu, SNMP_ERROR_NO_SUCH_NAME); // these ought to be member
      set_error_index(&pdu, i); // functions but are not yet...
      fdone++; // trigger flag to exit loop early
    }
    else // failed, return noSuch error
      pdu.set_vb(vb, i);
  }

  // 3. lastly, return the pkt to the caller
  return respond(pdu, target);
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:32,代码来源:agent_impl.cpp

示例4: lock

std::shared_ptr<Data> FlowManager::get_sdu_for_above(const PortId id)
{
    Pdu tmp;
    if (above_buffers_.find(id) == above_buffers_.end()) {
        std::unique_lock<std::mutex> lock(mutex_);
        above_buffers_[id].reset(new Buffer<Pdu>);
    }

    // we know id exists, so we can safely access it
    above_buffers_.at(id)->popFront(tmp);
    return tmp.get_payload();
}
开发者ID:andrepuschmann,项目名称:libgdtp,代码行数:12,代码来源:flow_manager.cpp

示例5: KeyChange

void KeyChange(Snmp* snmp, Pdu& myPdu, 
	       const OctetStr& user, const OctetStr& newpass, 
	       SnmpTarget& target, int type)
{
  struct UsmKeyUpdate *uku = NULL;
  int stat;
  int status;

  uku = usm->key_update_prepare(user, target, newpass,
				myPdu, type, stat);
  if (uku == NULL)
    cout << "Key update preparation failed *************" << endl
         << "with " << snmp->error_msg(stat) << endl <<endl;

  if (( status = snmp->set( myPdu,target)) == SNMP_CLASS_SUCCESS) {
    Vb vb3;
    Oid oid3;
    myPdu.get_vb( vb3,0);
    vb3.get_oid(oid3);
    Vb vb4;
    Oid oid4;
    myPdu.get_vb( vb4,1);
    vb4.get_oid(oid4);
    if (myPdu.get_type() == REPORT_MSG) {
      cout << "Received a reportPDU! with Oid " 
           << oid3.get_printable() << endl
           << snmp->error_msg(oid3) << endl;
      usm->key_update_abort(uku);
    } 
    else {
      cout << flush << endl
           << "Oid = " << vb3.get_printable_oid() << endl
           << "Value = " << vb3.get_printable_value() << endl;
      cout << flush << endl 
           << "Oid = " << vb4.get_printable_oid() << endl
           << "Value = " << vb4.get_printable_value() << endl;
      int resul = usm->key_update_commit(uku, USM_PasswordAllKeyUpdate);
      cout << endl  << "result of local key update: " 
           << resul << endl;

    }
  }
  else {
    cout << "SNMP++ KeyChange Error, " << snmp->error_msg( status)
	 << " (" << status <<")"<< endl;
    usm->key_update_abort(uku);
  }
  
  cout << "******************************** END" 
       << endl << endl << flush;
}
开发者ID:cunfate,项目名称:SnmpWithGUI,代码行数:51,代码来源:snmpPasswd.cpp

示例6: handle_pdu_from_below

int FlowManager::handle_pdu_from_below(const PortId id, Pdu &pdu)
{
    LOG_DEBUG("handle_frame_from_below()");
    // check if destination address matches
    if (destinations_.find(pdu.get_dest_addr()) == destinations_.end()) {
        // frame is not for us
        LOG_DEBUG("Ignoring frame for " << pdu.get_dest_addr());
        return 0;
    }

    // get corresponding connection handle
    FlowBase* flow = find_flow(pdu, id);
    flow->handle_frame_from_below(pdu);
    return 1;
}
开发者ID:andrepuschmann,项目名称:libgdtp,代码行数:15,代码来源:flow_manager.cpp

示例7: address

const string & SnmpDG::GetMibObject(const snmp_version  version, const SnmpPara& spr,  const string oid) const
{
	if(!m_inited_success)
	{
		return m_empty_object;
	}
	Snmp::socket_startup();

	UdpAddress address(spr.ip.c_str());
	//string myoid = oid;

	Pdu pdu;
	Vb vb;
	vb.set_oid(oid.c_str());//(myoid.c_str());
	pdu += vb;

	CTarget ctarget(address); 
	ctarget.set_version( version );
	ctarget.set_retry(spr.retry);           
	ctarget.set_timeout(spr.timeout); 
	ctarget.set_readcommunity(spr.community.c_str());
	SnmpTarget *target;
	target = &ctarget;

	int status;
	Snmp snmp(status, 0, false);
	if (status == SNMP_CLASS_SUCCESS)
	{
		if ((status = snmp.get( pdu, *target)) == SNMP_CLASS_SUCCESS)
		{
			pdu.get_vb( vb,0);
			//string oid_tmp = vb.get_printable_oid();
			m_mib_object = vb.get_printable_value();
		}
		else
		{
			m_mib_object = string("");
			SetLastError(status);
		}
	}
	else
	{
		m_mib_object = string("");
		SetLastError(status);
	}
	Snmp::socket_cleanup();  // Shut down socket subsystem
	return m_mib_object;
}
开发者ID:SiteView,项目名称:NNMQT,代码行数:48,代码来源:SnmpDG.cpp

示例8: get_pdu

// return a pdu from a buffer
int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
{
  if (iovec_.iov_len == 0)
    return -1; // NO DATA

  snmp_pdu *raw_pdu;
  raw_pdu = cmu_snmp::pdu_create(0);
  if (!raw_pdu) {
    return SNMP_CLASS_RESOURCE_UNAVAIL;
  }

  // max value a client can send us - TODO: replace this with an
  // api to get actual string length
  int status = cmu_snmp::parse( raw_pdu, (unsigned char *)iovec_.iov_base,
                     community_name, comm_len,
                     version, iovec_.iov_len);
  if (status != 0)
    return SNMP_CLASS_INTERNAL_ERROR;

  community_name[comm_len] = 0; // set null based on returned length
  set_request_id( &pdu, raw_pdu->reqid);
  set_error_status( &pdu, (int) raw_pdu->errstat);
  set_error_index( &pdu, (int) raw_pdu->errindex);
  pdu.set_type( raw_pdu->command);

  if (restore_vbs(pdu, raw_pdu)) {
    cmu_snmp::free_pdu(raw_pdu);
    return SNMP_CLASS_INTERNAL_ERROR;
  }

  cmu_snmp::free_pdu(raw_pdu);
  return 0;
}
开发者ID:helixum,项目名称:wow-cata,代码行数:34,代码来源:wpdu.cpp

示例9: respond

int sagent::respond(Pdu& pdu,UdpTarget& tgt)
{
  pdu.set_type(sNMP_PDU_RESPONSE);
  transaction tr(pdu, tgt, iv_snmp_session_);
  tr.send();
  return 0;
}
开发者ID:asir6,项目名称:Colt,代码行数:7,代码来源:sagent.cpp

示例10: Callback

int CNotifyEvent::Callback(SnmpTarget &target, Pdu &pdu, SnmpSocket fd, int status)
{
  Oid trapid;
  pdu.get_notify_id(trapid);
  (void)fd;

  // Make the callback if the trap passed the filters
  if ((m_snmp) && (notify_filter(trapid, target)))
  {
    int reason;

    if (SNMP_CLASS_TL_FAILED == status)
      reason = SNMP_CLASS_TL_FAILED;
    else
      reason = SNMP_CLASS_NOTIFICATION;

    //------[ call into the callback function ]-------------------------
    if (m_snmp->get_notify_callback())
      (m_snmp->get_notify_callback())(
          reason,
          m_snmp,                        // snmp++ session who owns the req
          pdu,                        // trap pdu
          target,                        // target
          m_snmp->get_notify_callback_data()); // callback data
  }
  return SNMP_CLASS_SUCCESS;
}
开发者ID:AT-GROUP,项目名称:SatellitePackage,代码行数:27,代码来源:notifyqueue.cpp

示例11: run_transaction

int Snmp::run_transaction(Pdu& pdu, UdpTarget& target)
{
  int rc, done = 0;

  // 1. set unique id to match this packet on return
  size_t hold_req_id = req_id_++;
  set_request_id(&pdu, hold_req_id);

  // 2. write request to agent
  transaction trans(pdu, target, iv_snmp_session_);

  // this call blocks while it attempts to retrieve agent response
  while (!done) {
    if ((rc = trans.run()) < 0) {
       last_transaction_status_ = rc;
       return rc;
    }
    else {
      trans.result(pdu);
      // verify this is the pdu we are after
      if (pdu.get_request_id() == hold_req_id)
        done = 1 ;
    }
  }
  return 0;
}
开发者ID:asir6,项目名称:Colt,代码行数:26,代码来源:snmp.cpp

示例12: snmp

Status SnmpManager::handleOperationGetNext(Request *request)
{
    Snmp::socket_startup();
    int status;
    Snmp snmp(status, 0, false);
    if (status != SNMP_CLASS_SUCCESS) {
        /*Setup SNMP FAILED*/
        Helper::log(0, "RequestGetNext Failed");
        Helper::log(1, snmp.error_msg(status));
        Helper::pop("Error", snmp.error_msg(status));
        Snmp::socket_cleanup();
        return Status_FAILED;
    }
    Pdu pdu;
    pdu += request->data;
    CTarget ctarget(request->address);
    ctarget.set_retry(request->retry);
    ctarget.set_timeout(request->timeout);
    ctarget.set_version(request->version);
    ctarget.set_readcommunity(request->community.c_str());
    SnmpTarget *target = &ctarget;
    status = snmp.get_next(pdu, *target);
    if (status == SNMP_CLASS_SUCCESS) {
        /*GetNextRequest SUCCESS*/
        Helper::log(1, "RequestGetNext SUCCESS");
        pdu.get_vb(request->data, 0);
        QString replayOid = request->data.get_printable_oid();
        QString replayValue = request->data.get_printable_value();
    }
    else {
        /*GetNextRequest FAILED*/
        Helper::log(0, "RequestGetNext Failed");
        Helper::log(1, snmp.error_msg(status));
        Helper::pop("Error", snmp.error_msg(status));
        Snmp::socket_cleanup();
        return Status_FAILED;
    }
    Snmp::socket_cleanup();
    qDebug() << "########################################################";
    qDebug() << "Handle RequestGetNext Successfully";
    qDebug() << "Oid:       " << request->data.get_printable_oid();
    qDebug() << "Value:     " << request->data.get_printable_value();
    qDebug() << "########################################################";
    return Status_SUCCESS;
}
开发者ID:luoyetx,项目名称:QMIBBrowser,代码行数:45,代码来源:snmpmanager.cpp

示例13: validate_args

int Snmp::validate_args(const Pdu& pdu, const UdpTarget& target) const
{
  // 0. check object status
  if (construct_status_ != SNMP_CLASS_SUCCESS)
     return construct_status_;

  // 1. check args passed
  if ( !pdu.valid() || !target.valid() )
     return SNMP_INVALID_ARGS;
  return 0;
}
开发者ID:asir6,项目名称:Colt,代码行数:11,代码来源:snmp.cpp

示例14: set

int Snmp::set( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
{
  ACE_TRACE("Snmp::set");
  int rc;
  if ((rc = validate_args(pdu, target)) != 0)
     return rc;

   pdu.set_type( sNMP_PDU_SET);
   check_default_port(target);
   return run_transaction(pdu, target, cb);
}
开发者ID:asir6,项目名称:Colt,代码行数:11,代码来源:snmp.cpp

示例15:

MibIter::MibIter(Snmp* snmp, Pdu& pdu, UdpTarget *target):
  snmp_(snmp), target_(target), pdu_(pdu), first_(0),
 valid_(0)
{
  // verify we have a valid oid to begin iterating with
  Oid oid;
  Vb vb;
  pdu.get_vb(vb, 0);
  vb.get_oid(oid);
  if (oid.valid())
    valid_ = 1;
}
开发者ID:asir6,项目名称:Colt,代码行数:12,代码来源:walk.cpp


注:本文中的Pdu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。