* Updates the flow to the provided file */
| 70 | * Updates the flow to the provided file |
| 71 | */ |
| 72 | int updateFlow(std::unique_ptr<minifi::io::Socket> socket, std::ostream &out, std::string file) { |
| 73 | socket->initialize(); |
| 74 | std::vector<uint8_t> data; |
| 75 | uint8_t op = minifi::c2::Operation::UPDATE; |
| 76 | minifi::io::BufferStream stream; |
| 77 | stream.write(&op, 1); |
| 78 | stream.write("flow"); |
| 79 | stream.write(file); |
| 80 | if (socket->write(const_cast<uint8_t*>(stream.getBuffer()), gsl::narrow<int>(stream.size())) < 0) { |
| 81 | return -1; |
| 82 | } |
| 83 | // read the response |
| 84 | uint8_t resp = 0; |
| 85 | socket->read(&resp, 1); |
| 86 | if (resp == minifi::c2::Operation::DESCRIBE) { |
| 87 | uint16_t connections = 0; |
| 88 | socket->read(connections); |
| 89 | out << connections << " are full" << std::endl; |
| 90 | for (int i = 0; i < connections; i++) { |
| 91 | std::string fullcomponent; |
| 92 | socket->read(fullcomponent); |
| 93 | out << fullcomponent << " is full" << std::endl; |
| 94 | } |
| 95 | } |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Lists connections which are full |
no test coverage detected