static void recv_output_len(void *arg) { struct scan_peer *peer = arg; deferred_read(peer->fd, peer->tmp_buf, 4, peer, recv_output, kill_peer); }
static void recv_command(struct build_peer *peer) { LIST_INSERT_HEAD(&inactive_peers, peer, peer_link); deferred_read(peer->fd, peer->tmp_buf, 1, peer, assign_job, kill_peer); }
static void recv_status(void *arg) { struct build_peer *peer = arg; deferred_read(peer->fd, peer->tmp_buf, 1, peer, finish_job, kill_peer); }
static void recv_output(void *arg) { struct scan_peer *peer = arg; uint32_t output_len; (void)memcpy(&output_len, peer->tmp_buf, 4); output_len = ntohl(output_len); if (output_len == 0) { LIST_REMOVE(peer, peer_link); process_job(peer->job, JOB_DONE); assign_job(peer); return; } if (output_len == 0xffffff) { warnx("Invalid output len received from peer"); kill_peer(peer); return; } peer->job->scan_output = xmalloc(output_len + 1); peer->job->scan_output[output_len] = '\0'; peer->output_len = output_len; deferred_read(peer->fd, peer->job->scan_output, output_len, peer, finish_job, kill_peer); }