19 #include <boost/bind.hpp>
20 #include <boost/cstdint.hpp>
33 using namespace agentxcpp;
34 using namespace boost;
42 master_proxy::master_proxy(boost::asio::io_service* _io_service,
43 std::string _description,
44 uint8_t _default_timeout,
46 std::string _filename) :
47 io_service(_io_service),
48 io_service_by_user(true),
49 socket_file(_filename.c_str()),
50 description(_description),
51 default_timeout(_default_timeout),
79 uint8_t _default_timeout,
81 std::string _filename) :
82 io_service(new boost::asio::io_service()),
83 io_service_by_user(false),
84 socket_file(_filename.c_str()),
85 description(_description),
86 default_timeout(_default_timeout),
133 catch(boost::system::system_error)
138 boost::shared_ptr<ResponsePDU> response;
171 this->
sessionID = response->get_sessionID();
190 boost::shared_ptr<ResponsePDU> response;
196 std::list< boost::shared_ptr<RegisterPDU> >::const_iterator r;
262 boost::shared_ptr<ResponsePDU> response;
266 switch(response->get_error())
321 boost::shared_ptr<RegisterPDU> pdu(
new RegisterPDU);
322 pdu->set_subtree(subtree);
323 pdu->set_priority(priority);
324 pdu->set_timeout(timeout);
355 boost::shared_ptr<UnregisterPDU> pdu;
358 std::list< boost::shared_ptr<RegisterPDU> >::iterator r;
362 if( (*r)->get_priority() == priority
363 && (*r)->get_subtree() == subtree
364 && (*r)->get_range_subid() == 0
365 && (*r)->get_upper_bound() == 0 )
416 boost::shared_ptr<ResponsePDU> response;
420 switch(response->get_error())
466 boost::shared_ptr<RegisterPDU> pdu)
468 boost::shared_ptr<UnregisterPDU> new_pdu(
new UnregisterPDU());
469 new_pdu->set_subtree( pdu->get_subtree() );
470 new_pdu->set_range_subid( pdu->get_range_subid() );
471 new_pdu->set_upper_bound( pdu->get_upper_bound() );
472 new_pdu->set_priority( pdu->get_priority() );
524 if(pdu->get_sessionID() != this->
sessionID)
547 shared_ptr<GetPDU> get_pdu;
548 if( (get_pdu = dynamic_pointer_cast<GetPDU>(pdu)) != 0 )
554 vector<oid> sr = get_pdu->get_sr();
557 vector<oid>::const_iterator i;
560 for(i = sr.begin(); i != sr.end(); i++)
563 const oid& name = *i;
566 map< oid, shared_ptr<variable> >::const_iterator var;
575 var->second->update();
594 oid name_copy(name, 0);
638 bool is_registered =
false;
639 std::list< boost::shared_ptr<RegisterPDU> >::const_iterator r;
642 if((*r)->get_instance_registration() ==
false &&
643 (*r)->get_range_subid() == 0)
646 if( (*r)->get_subtree().contains(
id) )
649 is_registered =
true;
656 if( ! is_registered )
669 map<oid, shared_ptr<variable> >::iterator i =
variables.find(
id);