diff options
author | iphydf <iphydf@users.noreply.github.com> | 2019-01-12 21:28:21 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2020-03-05 22:56:26 +0000 |
commit | e35d70af1822095b7b273f1cec16878645b90078 (patch) | |
tree | 143241b035976125cfb7fee241e3fde9ad02195b /toxcore/onion_client.c | |
parent | cbc26d9b165277e3c450806e1da1e6904a9dcedb (diff) |
Use net_pack/unpack instead of host_to_net.
The latter is doing pretty much the same thing but in a confusing way (it
doesn't change the type of the variable, but does change the semantics).
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r-- | toxcore/onion_client.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index d11a91e8..6dd945b0 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -971,8 +971,7 @@ static int handle_dhtpk_announce(void *object, const uint8_t *source_pubkey, con | |||
971 | } | 971 | } |
972 | 972 | ||
973 | uint64_t no_replay; | 973 | uint64_t no_replay; |
974 | memcpy(&no_replay, data + 1, sizeof(uint64_t)); | 974 | net_unpack_u64(data + 1, &no_replay); |
975 | net_to_host((uint8_t *) &no_replay, sizeof(no_replay)); | ||
976 | 975 | ||
977 | if (no_replay <= onion_c->friends_list[friend_num].last_noreplay) { | 976 | if (no_replay <= onion_c->friends_list[friend_num].last_noreplay) { |
978 | return 1; | 977 | return 1; |
@@ -1207,9 +1206,8 @@ static int send_dhtpk_announce(Onion_Client *onion_c, uint16_t friend_num, uint8 | |||
1207 | 1206 | ||
1208 | uint8_t data[DHTPK_DATA_MAX_LENGTH]; | 1207 | uint8_t data[DHTPK_DATA_MAX_LENGTH]; |
1209 | data[0] = ONION_DATA_DHTPK; | 1208 | data[0] = ONION_DATA_DHTPK; |
1210 | uint64_t no_replay = mono_time_get(onion_c->mono_time); | 1209 | const uint64_t no_replay = mono_time_get(onion_c->mono_time); |
1211 | host_to_net((uint8_t *)&no_replay, sizeof(no_replay)); | 1210 | net_pack_u64(data + 1, no_replay); |
1212 | memcpy(data + 1, &no_replay, sizeof(no_replay)); | ||
1213 | memcpy(data + 1 + sizeof(uint64_t), dht_get_self_public_key(onion_c->dht), CRYPTO_PUBLIC_KEY_SIZE); | 1211 | memcpy(data + 1 + sizeof(uint64_t), dht_get_self_public_key(onion_c->dht), CRYPTO_PUBLIC_KEY_SIZE); |
1214 | Node_format nodes[MAX_SENT_NODES]; | 1212 | Node_format nodes[MAX_SENT_NODES]; |
1215 | uint16_t num_relays = copy_connected_tcp_relays(onion_c->c, nodes, (MAX_SENT_NODES / 2)); | 1213 | uint16_t num_relays = copy_connected_tcp_relays(onion_c->c, nodes, (MAX_SENT_NODES / 2)); |