[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] sendme: Better function names
commit 0d8b9b56c5332b8f0205f460d0b23bb7f5620eff
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Mon Apr 29 11:38:11 2019 -0400
sendme: Better function names
From nickm's review, improve the names of some functions.
Part of #26288
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/core/crypto/relay_crypto.c | 8 ++++----
src/core/or/relay.c | 2 +-
src/core/or/sendme.c | 10 +++++-----
src/core/or/sendme.h | 8 ++++----
src/test/test_sendme.c | 18 +++++++++---------
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/core/crypto/relay_crypto.c b/src/core/crypto/relay_crypto.c
index 3a6dad4b1..5be45d6c7 100644
--- a/src/core/crypto/relay_crypto.c
+++ b/src/core/crypto/relay_crypto.c
@@ -154,8 +154,8 @@ relay_decrypt_cell(circuit_t *circ, cell_t *cell,
*layer_hint = thishop;
/* This cell is for us. Keep a record of this cell because we will
* use it in the next SENDME cell. */
- if (sendme_circuit_is_next_cell(thishop->deliver_window)) {
- sendme_circuit_note_inbound_cell(thishop);
+ if (sendme_circuit_cell_is_next(thishop->deliver_window)) {
+ sendme_circuit_record_inbound_cell(thishop);
}
return 0;
}
@@ -230,8 +230,8 @@ relay_encrypt_cell_inbound(cell_t *cell,
/* We are about to send this cell outbound on the circuit. Keep a record of
* this cell if we are expecting that the next cell is a SENDME. */
- if (sendme_circuit_is_next_cell(TO_CIRCUIT(or_circ)->package_window)) {
- sendme_circuit_note_outbound_cell(or_circ);
+ if (sendme_circuit_cell_is_next(TO_CIRCUIT(or_circ)->package_window)) {
+ sendme_circuit_record_outbound_cell(or_circ);
}
/* encrypt one layer */
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
index d273facd5..1b2aafb86 100644
--- a/src/core/or/relay.c
+++ b/src/core/or/relay.c
@@ -701,7 +701,7 @@ relay_send_command_from_edge_,(streamid_t stream_id, circuit_t *circ,
* we need to. This call needs to be after the circuit_package_relay_cell()
* because the cell digest is set within that function. */
if (relay_command == RELAY_COMMAND_DATA) {
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
}
return 0;
diff --git a/src/core/or/sendme.c b/src/core/or/sendme.c
index b65f30ba9..ff58c1489 100644
--- a/src/core/or/sendme.c
+++ b/src/core/or/sendme.c
@@ -294,7 +294,7 @@ send_circuit_level_sendme(circuit_t *circ, crypt_path_t *layer_hint,
/** Keep the current inbound cell digest for the next SENDME digest. This part
* is only done by the client as the circuit came back from the Exit. */
void
-sendme_circuit_note_outbound_cell(or_circuit_t *or_circ)
+sendme_circuit_record_outbound_cell(or_circuit_t *or_circ)
{
tor_assert(or_circ);
relay_crypto_record_sendme_digest(&or_circ->crypto);
@@ -303,7 +303,7 @@ sendme_circuit_note_outbound_cell(or_circuit_t *or_circ)
/** Keep the current inbound cell digest for the next SENDME digest. This part
* is only done by the client as the circuit came back from the Exit. */
void
-sendme_circuit_note_inbound_cell(crypt_path_t *cpath)
+sendme_circuit_record_inbound_cell(crypt_path_t *cpath)
{
tor_assert(cpath);
relay_crypto_record_sendme_digest(&cpath->crypto);
@@ -316,7 +316,7 @@ sendme_circuit_note_inbound_cell(crypt_path_t *cpath)
* one cell (the possible SENDME cell) should be a multiple of the increment
* window value. */
bool
-sendme_circuit_is_next_cell(int window)
+sendme_circuit_cell_is_next(int window)
{
/* Is this the last cell before a SENDME? The idea is that if the package or
* deliver window reaches a multiple of the increment, after this cell, we
@@ -578,7 +578,7 @@ sendme_note_stream_data_packaged(edge_connection_t *conn)
/* Note the cell digest in the circuit sendme last digests FIFO if applicable.
* It is safe to pass a circuit that isn't meant to track those digests. */
void
-sendme_note_cell_digest(circuit_t *circ)
+sendme_record_cell_digest(circuit_t *circ)
{
const uint8_t *digest;
@@ -592,7 +592,7 @@ sendme_note_cell_digest(circuit_t *circ)
/* Is this the last cell before a SENDME? The idea is that if the
* package_window reaches a multiple of the increment, after this cell, we
* should expect a SENDME. */
- if (!sendme_circuit_is_next_cell(circ->package_window)) {
+ if (!sendme_circuit_cell_is_next(circ->package_window)) {
return;
}
diff --git a/src/core/or/sendme.h b/src/core/or/sendme.h
index 5889b41e9..78273eb9a 100644
--- a/src/core/or/sendme.h
+++ b/src/core/or/sendme.h
@@ -35,12 +35,12 @@ int sendme_note_circuit_data_packaged(circuit_t *circ,
int sendme_note_stream_data_packaged(edge_connection_t *conn);
/* Track cell digest. */
-void sendme_note_cell_digest(circuit_t *circ);
-void sendme_circuit_note_inbound_cell(crypt_path_t *cpath);
-void sendme_circuit_note_outbound_cell(or_circuit_t *or_circ);
+void sendme_record_cell_digest(circuit_t *circ);
+void sendme_circuit_record_inbound_cell(crypt_path_t *cpath);
+void sendme_circuit_record_outbound_cell(or_circuit_t *or_circ);
/* Circuit level information. */
-bool sendme_circuit_is_next_cell(int window);
+bool sendme_circuit_cell_is_next(int window);
/* Private section starts. */
#ifdef SENDME_PRIVATE
diff --git a/src/test/test_sendme.c b/src/test/test_sendme.c
index 50943e5f4..d40fbaf86 100644
--- a/src/test/test_sendme.c
+++ b/src/test/test_sendme.c
@@ -43,7 +43,7 @@ free_mock_consensus(void)
}
static void
-test_v1_note_digest(void *arg)
+test_v1_record_digest(void *arg)
{
or_circuit_t *or_circ = NULL;
origin_circuit_t *orig_circ = NULL;
@@ -61,7 +61,7 @@ test_v1_note_digest(void *arg)
circ->purpose = CIRCUIT_PURPOSE_S_REND_JOINED;
/* We should never note SENDME digest on origin circuit. */
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_assert(!circ->sendme_last_digests);
/* We do not need the origin circuit for now. */
orig_circ = NULL;
@@ -73,23 +73,23 @@ test_v1_note_digest(void *arg)
* in order to catched the CIRCWINDOW_INCREMENT-nth cell. Try something that
* shouldn't be noted. */
circ->package_window = CIRCWINDOW_INCREMENT;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_assert(!circ->sendme_last_digests);
/* This should work now. Package window at CIRCWINDOW_INCREMENT + 1. */
circ->package_window++;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_assert(circ->sendme_last_digests);
tt_int_op(smartlist_len(circ->sendme_last_digests), OP_EQ, 1);
/* Next cell in the package window shouldn't do anything. */
circ->package_window++;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_int_op(smartlist_len(circ->sendme_last_digests), OP_EQ, 1);
/* The next CIRCWINDOW_INCREMENT should add one more digest. */
circ->package_window = (CIRCWINDOW_INCREMENT * 2) + 1;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_int_op(smartlist_len(circ->sendme_last_digests), OP_EQ, 2);
done:
@@ -188,7 +188,7 @@ test_v1_build_cell(void *arg)
/* Note the wrong digest in the circuit, cell should fail validation. */
circ->package_window = CIRCWINDOW_INCREMENT + 1;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_int_op(smartlist_len(circ->sendme_last_digests), OP_EQ, 1);
setup_full_capture_of_logs(LOG_INFO);
tt_int_op(sendme_is_valid(circ, payload, sizeof(payload)), OP_EQ, false);
@@ -200,7 +200,7 @@ test_v1_build_cell(void *arg)
/* Record the cell digest into the circuit, cell should validate. */
memcpy(or_circ->crypto.sendme_digest, digest, sizeof(digest));
circ->package_window = CIRCWINDOW_INCREMENT + 1;
- sendme_note_cell_digest(circ);
+ sendme_record_cell_digest(circ);
tt_int_op(smartlist_len(circ->sendme_last_digests), OP_EQ, 1);
tt_int_op(sendme_is_valid(circ, payload, sizeof(payload)), OP_EQ, true);
/* After a validation, the last digests is always popped out. */
@@ -254,7 +254,7 @@ test_cell_payload_pad(void *arg)
}
struct testcase_t sendme_tests[] = {
- { "v1_note_digest", test_v1_note_digest, TT_FORK,
+ { "v1_record_digest", test_v1_record_digest, TT_FORK,
NULL, NULL },
{ "v1_consensus_params", test_v1_consensus_params, TT_FORK,
NULL, NULL },
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits