| 31 | } |
| 32 | |
| 33 | void handle_ping_done(struct subd *connectd, const u8 *msg) |
| 34 | { |
| 35 | u16 totlen; |
| 36 | bool sent; |
| 37 | u64 reqid; |
| 38 | struct ping_command *ping_command; |
| 39 | |
| 40 | if (!fromwire_connectd_ping_done(msg, &reqid, &sent, &totlen)) { |
| 41 | log_broken(connectd->log, "Malformed ping reply %s", |
| 42 | tal_hex(tmpctx, msg)); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | ping_command = find_ping_command(connectd->ld, reqid); |
| 47 | if (!ping_command) { |
| 48 | log_broken(connectd->log, "ping reply for unknown reqid %"PRIu64, reqid); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | log_debug(connectd->log, "Got ping reply!"); |
| 53 | if (!sent) |
| 54 | was_pending(command_fail(ping_command->cmd, LIGHTNINGD, |
| 55 | "Ping already pending")); |
| 56 | else { |
| 57 | struct json_stream *response = json_stream_success(ping_command->cmd); |
| 58 | |
| 59 | json_add_num(response, "totlen", totlen); |
| 60 | was_pending(command_success(ping_command->cmd, response)); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static struct command_result *json_ping(struct command *cmd, |
| 65 | const char *buffer, |
no test coverage detected