summaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-22 19:36:38 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-22 19:36:38 +0000
commit7a0072cc1a70b42dd38c58ac20fe873c48beeace (patch)
treec3a79af68b99022e1045f62de02e0d76cfce8a82 /src/or/relay.c
parentec81f870181940909507fd5356fa5ecc11c7440e (diff)
downloadtor-7a0072cc1a70b42dd38c58ac20fe873c48beeace.tar.gz
tor-7a0072cc1a70b42dd38c58ac20fe873c48beeace.zip
Specify and implement close-stream and close-circuit control messages
svn:r3814
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index 5fd5be9097..5651fd35e1 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -476,16 +476,13 @@ connection_edge_end_reason_str(char *payload, uint16_t length) {
}
}
-/** Translate the <b>payload</b> of length <b>length</b>, which
- * came from a relay 'end' cell, into an appropriate SOCKS5 reply code.
+/** Translate <b>reason</b> (as from a relay 'end' cell) into an
+ * appropriate SOCKS5 reply code.
*/
-static socks5_reply_status_t
-connection_edge_end_reason_socks5_response(char *payload, uint16_t length) {
- if (length < 1) {
- log_fn(LOG_WARN,"End cell arrived with length 0. Should be at least 1.");
- return SOCKS5_GENERAL_ERROR;
- }
- switch (*payload) {
+socks5_reply_status_t
+connection_edge_end_reason_socks5_response(int reason)
+{
+ switch (reason) {
case END_STREAM_REASON_MISC:
return SOCKS5_GENERAL_ERROR;
case END_STREAM_REASON_RESOLVEFAILED:
@@ -511,7 +508,7 @@ connection_edge_end_reason_socks5_response(char *payload, uint16_t length) {
case END_STREAM_REASON_TORPROTOCOL:
return SOCKS5_GENERAL_ERROR;
default:
- log_fn(LOG_WARN,"Reason for ending (%d) not recognized.",*payload);
+ log_fn(LOG_WARN,"Reason for ending (%d) not recognized.",reason);
return SOCKS5_GENERAL_ERROR;
}
}
@@ -817,9 +814,14 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
rh.length),
conn->stream_id, (int)conn->stream_size);
if (conn->socks_request && !conn->socks_request->has_finished) {
- socks5_reply_status_t status =
- connection_edge_end_reason_socks5_response(
- cell->payload+RELAY_HEADER_SIZE, rh.length);
+ socks5_reply_status_t status;
+ if (rh.length < 1) {
+ log_fn(LOG_WARN,"End cell arrived with length 0. Should be at least 1.");
+ status = SOCKS5_GENERAL_ERROR;
+ } else {
+ status = connection_edge_end_reason_socks5_response(
+ *(uint8_t*)cell->payload+RELAY_HEADER_SIZE);
+ }
connection_ap_handshake_socks_reply(conn, NULL, 0, status);
}
#ifdef HALF_OPEN