Changeset 9b3f53c in nscp for modules/NRPEClient/NRPEClient.cpp
- Timestamp:
- 12/06/09 22:23:10 (3 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 79e734f
- Parents:
- dcd90b2
- File:
-
- 1 edited
-
modules/NRPEClient/NRPEClient.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modules/NRPEClient/NRPEClient.cpp
rdcd90b2 r9b3f53c 69 69 } 70 70 71 void NRPEClient::add_options(po::options_description &desc, nrpe_connection_data command_data) {71 void NRPEClient::add_options(po::options_description &desc, nrpe_connection_data &command_data) { 72 72 desc.add_options() 73 73 ("help,h", "Show this help message.") … … 102 102 tokenizer_t tok(args, sep); 103 103 for(tokenizer_t::iterator beg=tok.begin(); beg!=tok.end();++beg){ 104 std::wcout << *beg << std::endl;105 104 list.push_back(*beg); 106 105 } … … 192 191 NRPEClient::nrpe_result_data NRPEClient::execute_nrpe_command(nrpe_connection_data con, std::wstring arguments) { 193 192 try { 194 NRPEPacket packet;193 nrpe::packet packet; 195 194 if (!con.no_ssl) { 196 195 #ifdef USE_SSL 197 packet = send_ssl(con.host, con.port, con.timeout, NRPEPacket::make_request(con.get_cli(arguments), con.buffer_length));196 packet = send_ssl(con.host, con.port, con.timeout, nrpe::packet::make_request(con.get_cli(arguments), con.buffer_length)); 198 197 #else 199 198 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("SSL support not available (compiled without USE_SSL)!")); 200 199 #endif 201 200 } else 202 packet = send_nossl(con.host, con.port, con.timeout, NRPEPacket::make_request(con.get_cli(arguments), con.buffer_length));201 packet = send_nossl(con.host, con.port, con.timeout, nrpe::packet::make_request(con.get_cli(arguments), con.buffer_length)); 203 202 return nrpe_result_data(packet.getResult(), packet.getPayload()); 204 } catch ( NRPEPacket::NRPEPacketException &e) {203 } catch (nrpe::nrpe_packet_exception &e) { 205 204 return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.getMessage()); 206 205 } catch (std::runtime_error &e) { … … 323 322 } 324 323 325 void send(NRPEPacket &packet, boost::posix_time::seconds timeout) { 326 std::vector<char> buf(packet.getBufferLength()); 327 write_with_timeout(socket_, socket_, boost::asio::buffer(packet.getBuffer(), packet.getBufferLength()), timeout); 328 } 329 NRPEPacket recv(const NRPEPacket &packet, boost::posix_time::seconds timeout) { 330 std::vector<char> buf(packet.getBufferLength()); 324 void send(nrpe::packet &packet, boost::posix_time::seconds timeout) { 325 std::vector<char> buf(packet.get_packet_length()); 326 write_with_timeout(socket_, socket_, boost::asio::buffer(packet.create_buffer(), packet.get_packet_length()), timeout); 327 } 328 nrpe::packet recv(const nrpe::packet &packet, boost::posix_time::seconds timeout) { 329 std::vector<char> buf(packet.get_packet_length()); 330 std::cout << "About to read: " << buf.size() << std::endl; 331 331 read_with_timeout(socket_, socket_, boost::asio::buffer(buf), timeout); 332 return NRPEPacket(&buf[0], buf.size(), packet.getInternalBufferLength()); 332 std::cout << "Read data: " << buf.size() << std::endl; 333 return nrpe::packet(&buf[0], buf.size(), packet.get_payload_length()); 333 334 } 334 335 }; … … 370 371 } 371 372 372 void send( NRPEPacket &packet, boost::posix_time::seconds timeout) {373 void send(nrpe::packet &packet, boost::posix_time::seconds timeout) { 373 374 NSC_LOG_CRITICAL(_T("Writing...")); 374 std::vector<char> buf(packet.get BufferLength());375 write_with_timeout(socket_, socket_.lowest_layer(), boost::asio::buffer(packet. getBuffer(), packet.getBufferLength()), timeout);375 std::vector<char> buf(packet.get_packet_length()); 376 write_with_timeout(socket_, socket_.lowest_layer(), boost::asio::buffer(packet.create_buffer(), packet.get_packet_length()), timeout); 376 377 NSC_LOG_CRITICAL(_T("Written...")); 377 378 } 378 NRPEPacket recv(const NRPEPacket &packet, boost::posix_time::seconds timeout) {379 nrpe::packet recv(const nrpe::packet &packet, boost::posix_time::seconds timeout) { 379 380 NSC_LOG_CRITICAL(_T("Reading...")); 380 std::vector<char> buf(packet.get BufferLength());381 std::vector<char> buf(packet.get_packet_length()); 381 382 read_with_timeout(socket_, socket_.lowest_layer(), boost::asio::buffer(buf), timeout); 382 return NRPEPacket(&buf[0], buf.size(), packet.getInternalBufferLength());383 return nrpe::packet(&buf[0], buf.size(), packet.get_payload_length()); 383 384 NSC_LOG_CRITICAL(_T("Read...")); 384 385 } 385 386 }; 386 NRPEPacket NRPEClient::send_ssl(std::wstring host, int port, int timeout, NRPEPacket packet)387 nrpe::packet NRPEClient::send_ssl(std::wstring host, int port, int timeout, nrpe::packet packet) 387 388 { 388 389 boost::asio::io_service io_service; … … 397 398 #endif 398 399 399 NRPEPacket NRPEClient::send_nossl(std::wstring host, int port, int timeout, NRPEPacket packet)400 nrpe::packet NRPEClient::send_nossl(std::wstring host, int port, int timeout, nrpe::packet packet) 400 401 { 401 402 boost::asio::io_service io_service;
Note: See TracChangeset
for help on using the changeset viewer.








