summaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-09-13 10:03:09 -0400
committerNick Mathewson <nickm@torproject.org>2011-10-10 23:14:09 -0400
commit1b0645acba905c37759194c222aacbbe40771223 (patch)
tree86cbb2bd41f0391f7cfe2757f45d56ee6da5183a /src/or/command.c
parentfdbb9cdf746bbf0c39c34188baa8872471183ff7 (diff)
downloadtor-1b0645acba905c37759194c222aacbbe40771223.tar.gz
tor-1b0645acba905c37759194c222aacbbe40771223.zip
Cell types and states for new OR handshake
Also, define all commands > 128 as variable-length when using v3 or later link protocol. Running into a var cell with an unrecognized type is no longer a bug.
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/or/command.c b/src/or/command.c
index d24373eec8..72d8cd7cf6 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -93,7 +93,7 @@ command_time_process_cell(cell_t *cell, or_connection_t *conn, int *time,
void
command_process_cell(cell_t *cell, or_connection_t *conn)
{
- int handshaking = (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING);
+ int handshaking = (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V2);
#ifdef KEEP_TIMING_STATS
/* how many of each cell have we seen so far this second? needs better
* name. */
@@ -207,7 +207,7 @@ command_process_var_cell(var_cell_t *cell, or_connection_t *conn)
#endif
/* reject all when not handshaking. */
- if (conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING)
+ if (conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V2)
return;
switch (cell->command) {
@@ -216,10 +216,9 @@ command_process_var_cell(var_cell_t *cell, or_connection_t *conn)
PROCESS_CELL(versions, cell, conn);
break;
default:
- log_warn(LD_BUG,
+ log_fn(LOG_INFO, LD_PROTOCOL,
"Variable-length cell of unknown type (%d) received.",
cell->command);
- tor_fragile_assert();
break;
}
}
@@ -506,7 +505,7 @@ command_process_versions_cell(var_cell_t *cell, or_connection_t *conn)
int highest_supported_version = 0;
const uint8_t *cp, *end;
if (conn->link_proto != 0 ||
- conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING ||
+ conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V2 ||
(conn->handshake_state && conn->handshake_state->received_versions)) {
log_fn(LOG_PROTOCOL_WARN, LD_OR,
"Received a VERSIONS cell on a connection with its version "
@@ -572,7 +571,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
conn->link_proto == 0 ? "non-versioned" : "a v1");
return;
}
- if (conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING) {
+ if (conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V2) {
log_fn(LOG_PROTOCOL_WARN, LD_OR,
"Received a NETINFO cell on non-handshaking connection; dropping.");
return;