| 9219 | |
| 9220 | |
| 9221 | static void receive_packet_with_callback(rem_port* port, PACKET* packet) |
| 9222 | { |
| 9223 | /************************************** |
| 9224 | * |
| 9225 | * r e c e i v e _ p a c k e t _ w i t h _ c a l l b a c k |
| 9226 | * |
| 9227 | ************************************** |
| 9228 | * |
| 9229 | * Functional description |
| 9230 | * If received packet is request from callback info from user, |
| 9231 | * send requested info (or no data if callback is not set) and |
| 9232 | * wait for next packet. |
| 9233 | * |
| 9234 | **************************************/ |
| 9235 | |
| 9236 | UCharBuffer buf; |
| 9237 | for (;;) |
| 9238 | { |
| 9239 | if (!port->receive(packet)) |
| 9240 | { |
| 9241 | Arg::Gds(isc_net_read_err).raise(); |
| 9242 | } |
| 9243 | |
| 9244 | switch (packet->p_operation) |
| 9245 | { |
| 9246 | case op_crypt_key_callback: |
| 9247 | { |
| 9248 | P_CRYPT_CALLBACK* cc = &packet->p_cc; |
| 9249 | Cleanup ccData([&cc]() { |
| 9250 | cc->p_cc_data.cstr_length = 0; |
| 9251 | cc->p_cc_data.cstr_address = nullptr; |
| 9252 | }); |
| 9253 | |
| 9254 | if (port->port_client_crypt_callback) |
| 9255 | { |
| 9256 | if (cc->p_cc_reply <= 0) |
| 9257 | { |
| 9258 | cc->p_cc_reply = 1; |
| 9259 | } |
| 9260 | UCHAR* reply = buf.getBuffer(cc->p_cc_reply); |
| 9261 | unsigned l = port->port_client_crypt_callback->callback(cc->p_cc_data.cstr_length, |
| 9262 | cc->p_cc_data.cstr_address, cc->p_cc_reply, reply); |
| 9263 | |
| 9264 | REMOTE_free_packet(port, packet, true); |
| 9265 | cc->p_cc_data.cstr_length = l; |
| 9266 | cc->p_cc_data.cstr_address = reply; |
| 9267 | } |
| 9268 | else |
| 9269 | { |
| 9270 | REMOTE_free_packet(port, packet, true); |
| 9271 | cc->p_cc_data.cstr_length = 0; |
| 9272 | } |
| 9273 | |
| 9274 | packet->p_operation = op_crypt_key_callback; |
| 9275 | cc->p_cc_reply = 0; |
| 9276 | port->send(packet); |
| 9277 | } |
| 9278 | break; |
no test coverage detected