"Commands:\n"
" -S Sign file\n"
" -V Verify file\n"
- " -P Get pulic signing key from secret key\n"
- " -H Get pulic host key from secret key\n"
+ " -P Get public signing key from secret key\n"
+ " -H Get public host key from secret key\n"
" -G Generate new private key\n"
" -D <host>[:<port>] Download network data from unetd\n"
" -U <host>[:<port>] Upload network data to unetd\n"
pex_msg_update_response_init(&ctx, empty_key, pubkey,
peerpubkey, true, data, net_data, net_data_len);
while (!done) {
- __pex_msg_send(-1, NULL);
+ __pex_msg_send(-1, NULL, NULL, 0);
done = !pex_msg_update_response_continue(&ctx);
}
sync_done = true;
uloop_end();
}
-static void pex_recv(struct pex_hdr *hdr, struct sockaddr_in6 *addr)
+static void pex_recv(void *msg, size_t msg_len, struct sockaddr_in6 *addr)
{
- struct pex_ext_hdr *ehdr = (void *)(hdr + 1);
- void *data = (void *)(ehdr + 1);
- uint32_t len = be32_to_cpu(hdr->len);
- uint64_t *msg_req_id = data;
+ struct pex_hdr *hdr;
+ struct pex_ext_hdr *ehdr;
+ uint64_t *msg_req_id;
+ void *data;
+
+ hdr = pex_rx_accept(msg, msg_len, true);
+ if (!hdr)
+ return;
+
+ ehdr = (void *)(hdr + 1);
+ data = (void *)(ehdr + 1);
+ msg_req_id = data;
if (hdr->version != 0)
return;
if (cmd != CMD_UPLOAD)
break;
- pex_handle_update_request(addr, hdr->id, data, len);
+ pex_handle_update_request(addr, hdr->id, data, hdr->len);
break;
case PEX_MSG_UPDATE_RESPONSE:
case PEX_MSG_UPDATE_RESPONSE_DATA:
case PEX_MSG_UPDATE_RESPONSE_NO_DATA:
- if (len < sizeof(*msg_req_id) || *msg_req_id != req_id)
+ if (hdr->len < sizeof(*msg_req_id) || *msg_req_id != req_id)
break;
if (cmd == CMD_DOWNLOAD &&
return 1;
req_id = req->req_id;
- if (__pex_msg_send(-1, NULL) < 0) {
+ if (__pex_msg_send(-1, NULL, NULL, 0) < 0) {
if (!quiet)
perror("send");
return 1;