aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection_ap.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-04-17 17:10:41 +0000
committerNick Mathewson <nickm@torproject.org>2003-04-17 17:10:41 +0000
commit32a3e704b48ac277456fd89c6bd8cd96ccb3d0c8 (patch)
tree27b2fd77b157b7663af55c3a3483e5cbaf39cb81 /src/or/connection_ap.c
parentfdf4d4aa85c1b996f36944cea19c13e49e52b972 (diff)
downloadtor-32a3e704b48ac277456fd89c6bd8cd96ccb3d0c8.tar
tor-32a3e704b48ac277456fd89c6bd8cd96ccb3d0c8.tar.gz
Choose correct abstraction for topic_foo. Abstract random-integer code
svn:r249
Diffstat (limited to 'src/or/connection_ap.c')
-rw-r--r--src/or/connection_ap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/or/connection_ap.c b/src/or/connection_ap.c
index 444dfc00a..7dfa1ccc5 100644
--- a/src/or/connection_ap.c
+++ b/src/or/connection_ap.c
@@ -119,15 +119,18 @@ int ap_handshake_process_socks(connection_t *conn) {
int ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) {
cell_t cell;
+ uint16_t topic_id;
memset(&cell, 0, sizeof(cell_t));
/* deliver the dest_addr in a data cell */
cell.command = CELL_DATA;
cell.aci = circ->n_aci;
- cell.topic_command = TOPIC_COMMAND_BEGIN;
- crypto_pseudo_rand(2, (char*)&cell.topic_id);
+ SET_CELL_TOPIC_COMMAND(cell, TOPIC_COMMAND_BEGIN);
+ if (CRYPTO_PSEUDO_RAND_INT(topic_id))
+ return -1;
+ SET_CELL_TOPIC_ID(cell, topic_id);
/* FIXME check for collisions */
- ap_conn->topic_id = cell.topic_id;
+ ap_conn->topic_id = topic_id;
snprintf(cell.payload+4, CELL_PAYLOAD_SIZE-4, "%s:%d", ap_conn->dest_addr, ap_conn->dest_port);
cell.length = strlen(cell.payload+TOPIC_HEADER_SIZE)+1+TOPIC_HEADER_SIZE;