[or-cvs] Make ACI anti-collision logic work; make sure that cells ar...
Nick Mathewson
nickm at seul.org
Tue Mar 11 21:38:40 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv2779
Modified Files:
circuit.c connection.c connection_ap.c main.c
Log Message:
Make ACI anti-collision logic work; make sure that cells are filled with 0s.
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- circuit.c 10 Mar 2003 22:30:05 -0000 1.26
+++ circuit.c 11 Mar 2003 21:38:38 -0000 1.27
@@ -113,10 +113,10 @@
crypto_pseudo_rand(2, (unsigned char *)&test_aci);
- if(aci_type == ACI_TYPE_LOWER && test_aci >= (2<<15))
- test_aci -= (2<<15);
- if(aci_type == ACI_TYPE_HIGHER && test_aci < (2<<15))
- test_aci += (2<<15);
+ if(aci_type == ACI_TYPE_LOWER && test_aci >= (1<<15))
+ test_aci -= (1<<15);
+ if(aci_type == ACI_TYPE_HIGHER && test_aci < (1<<15))
+ test_aci += (1<<15);
/* if aci_type == ACI_BOTH, don't filter any of it */
if(test_aci == 0)
@@ -489,6 +489,7 @@
assert(circ);
+ memset(&sendme, 0, sizeof(cell_t));
sendme.command = CELL_SENDME;
sendme.length = CIRCWINDOW_INCREMENT;
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- connection.c 11 Mar 2003 01:51:41 -0000 1.39
+++ connection.c 11 Mar 2003 21:38:38 -0000 1.40
@@ -479,6 +479,8 @@
connection_write_cell_to_buf(&cell, conn);
}
+ /* ???? If we might not have added a cell above, why are we
+ * ???? increasing outbuf_flushlen? -NM */
conn->outbuf_flushlen += sizeof(cell_t); /* instruct it to send a cell */
connection_start_writing(conn);
@@ -512,6 +514,7 @@
return 0;
}
+ memset(&cell, 0, sizeof(cell_t));
cell.aci = aci;
cell.command = CELL_DESTROY;
log(LOG_INFO,"connection_send_destroy(): Sending destroy (aci %d).",aci);
@@ -606,6 +609,9 @@
if(!amount_to_process)
return 0;
+ /* Initialize the cell with 0's */
+ memset(&cell, 0, sizeof(cell_t));
+
if(amount_to_process > CELL_PAYLOAD_SIZE - TOPIC_HEADER_SIZE) {
cell.length = CELL_PAYLOAD_SIZE - TOPIC_HEADER_SIZE;
} else {
@@ -679,6 +685,7 @@
return 0;
}
+ memset(&cell, 0, sizeof(cell_t));
*(uint16_t *)(cell.payload+2) = htons(conn->topic_id);
*cell.payload = TOPIC_COMMAND_SENDME;
cell.length += TOPIC_HEADER_SIZE;
Index: connection_ap.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_ap.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- connection_ap.c 18 Feb 2003 01:35:55 -0000 1.25
+++ connection_ap.c 11 Mar 2003 21:38:38 -0000 1.26
@@ -314,6 +314,8 @@
} else { /* last cell */
cell.length = dataleft;
memcpy(cell.payload, tmpbuf + tmpbuflen - dataleft, dataleft);
+ /* fill extra space with 0 bytes */
+ memset(cell.payload + dataleft, 0, CELL_PAYLOAD_SIZE - dataleft);
connection_write_cell_to_buf(&cell, n_conn);
dataleft = 0;
}
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- main.c 11 Mar 2003 01:51:41 -0000 1.42
+++ main.c 11 Mar 2003 21:38:38 -0000 1.43
@@ -342,7 +342,7 @@
/* either a full router, or we've got a circuit. send a padding cell. */
// log(LOG_DEBUG,"prepare_for_poll(): Sending keepalive to (%s:%d)",
// tmpconn->address, tmpconn->port);
-// memset(&cell,0,sizeof(cell_t));
+ memset(&cell,0,sizeof(cell_t));
cell.command = CELL_PADDING;
if(connection_write_cell_to_buf(&cell, tmpconn) < 0)
tmpconn->marked_for_close = 1;
More information about the tor-commits
mailing list