diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 10:31:29 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-05 23:09:28 +0000 |
commit | 8739f7fccb7cafc54ca0f5fa074c9a740f7048ba (patch) | |
tree | 88e9f53fa6e734cd8095487d1896c56f844c782c /toxcore/ping.c | |
parent | 64d0297acc7d6a1697683052e15cc76383312c38 (diff) |
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.
This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.
[1] struct/union/enum
Diffstat (limited to 'toxcore/ping.c')
-rw-r--r-- | toxcore/ping.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/ping.c b/toxcore/ping.c index 3daeff86..3767805d 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c | |||
@@ -72,7 +72,7 @@ int32_t ping_send_request(Ping *ping, IP_Port ipp, const uint8_t *public_key) | |||
72 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; | 72 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; |
73 | 73 | ||
74 | // generate key to encrypt ping_id with recipient privkey | 74 | // generate key to encrypt ping_id with recipient privkey |
75 | DHT_get_shared_key_sent(ping->dht, shared_key, public_key); | 75 | dht_get_shared_key_sent(ping->dht, shared_key, public_key); |
76 | // Generate random ping_id. | 76 | // Generate random ping_id. |
77 | uint8_t data[PING_DATA_SIZE]; | 77 | uint8_t data[PING_DATA_SIZE]; |
78 | id_copy(data, public_key); | 78 | id_copy(data, public_key); |
@@ -154,7 +154,7 @@ static int handle_ping_request(void *object, IP_Port source, const uint8_t *pack | |||
154 | 154 | ||
155 | uint8_t ping_plain[PING_PLAIN_SIZE]; | 155 | uint8_t ping_plain[PING_PLAIN_SIZE]; |
156 | // Decrypt ping_id | 156 | // Decrypt ping_id |
157 | DHT_get_shared_key_recv(dht, shared_key, packet + 1); | 157 | dht_get_shared_key_recv(dht, shared_key, packet + 1); |
158 | rc = decrypt_data_symmetric(shared_key, | 158 | rc = decrypt_data_symmetric(shared_key, |
159 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, | 159 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE, |
160 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE, | 160 | packet + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE, |
@@ -196,7 +196,7 @@ static int handle_ping_response(void *object, IP_Port source, const uint8_t *pac | |||
196 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; | 196 | uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE]; |
197 | 197 | ||
198 | // generate key to encrypt ping_id with recipient privkey | 198 | // generate key to encrypt ping_id with recipient privkey |
199 | DHT_get_shared_key_sent(ping->dht, shared_key, packet + 1); | 199 | dht_get_shared_key_sent(ping->dht, shared_key, packet + 1); |
200 | 200 | ||
201 | uint8_t ping_plain[PING_PLAIN_SIZE]; | 201 | uint8_t ping_plain[PING_PLAIN_SIZE]; |
202 | // Decrypt ping_id | 202 | // Decrypt ping_id |
@@ -291,7 +291,7 @@ int32_t ping_add(Ping *ping, const uint8_t *public_key, IP_Port ip_port) | |||
291 | 291 | ||
292 | IP_Port temp; | 292 | IP_Port temp; |
293 | 293 | ||
294 | if (DHT_getfriendip(ping->dht, public_key, &temp) == 0) { | 294 | if (dht_getfriendip(ping->dht, public_key, &temp) == 0) { |
295 | ping_send_request(ping, ip_port, public_key); | 295 | ping_send_request(ping, ip_port, public_key); |
296 | return -1; | 296 | return -1; |
297 | } | 297 | } |