diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-10-30 21:46:02 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-10-30 21:46:02 +0000 |
commit | 7e80640b97bbd97e8bcf5e95366f535a8bd16bfc (patch) | |
tree | f46817f2cd202427069438dda5340d61de2ac6e7 /src/or/command.c | |
parent | 57f7c852f809b9332fc7a52058a24713b1385c14 (diff) | |
download | tor-7e80640b97bbd97e8bcf5e95366f535a8bd16bfc.tar.gz tor-7e80640b97bbd97e8bcf5e95366f535a8bd16bfc.zip |
r16285@catbus: nickm | 2007-10-30 17:43:25 -0400
Implement (but do not enable) link connection version negotiation
svn:r12286
Diffstat (limited to 'src/or/command.c')
-rw-r--r-- | src/or/command.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/or/command.c b/src/or/command.c index 4fa098d9a7..c449e6c0a0 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -395,7 +395,8 @@ command_process_versions_cell(cell_t *cell, or_connection_t *conn) uint16_t versionslen; int highest_supported_version = 0; const char *cp, *end; - if (conn->link_proto != 0) { + if (conn->link_proto != 0 || + conn->_base.state != OR_CONN_STATE_WAITING_FOR_VERSIONS) { log_fn(LOG_PROTOCOL_WARN, LD_OR, "Received a VERSIONS cell on a connection with its version " "already set to %d; dropping", (int) conn->link_proto); @@ -412,13 +413,18 @@ command_process_versions_cell(cell_t *cell, or_connection_t *conn) highest_supported_version = v; } } - if (!versionslen) { + if (!highest_supported_version) { log_fn(LOG_PROTOCOL_WARN, LD_OR, "Couldn't find a version in common; defaulting to v1."); /*XXXX020 or just break the connection?*/ conn->link_proto = 1; return; } + conn->link_proto = highest_supported_version; + conn->_base.state = OR_CONN_STATE_OPEN; + + if (highest_supported_version >= 2) + connection_or_send_netinfo(conn); } /** Process a 'netinfo' cell. DOCDOC say more. */ @@ -433,9 +439,9 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn) uint8_t n_other_addrs; time_t now = time(NULL); - /*XXXX020 reject duplicat netinfos. */ + /*XXXX020 reject duplicate netinfos. */ - if (conn->link_proto < 2) { + if (conn->link_proto < 2 || conn->_base.state != OR_CONN_STATE_OPEN) { log_fn(LOG_PROTOCOL_WARN, LD_OR, "Received a NETINFO cell on %s connection; dropping.", conn->link_proto == 0 ? "non-versioned" : "a v1"); |