Loading src/or/circuit.c +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ void circuit_about_to_close_connection(connection_t *conn) { memset(&cell, 0, sizeof(cell_t)); cell.command = CELL_DATA; cell.length = TOPIC_HEADER_SIZE; *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_END; if(conn == circ->p_conn) { Loading src/or/connection.c +2 −2 Original line number Diff line number Diff line Loading @@ -617,7 +617,7 @@ repeat_connection_package_raw_inbuf: log(LOG_DEBUG,"connection_package_raw_inbuf(): Packaging %d bytes (%d waiting).",cell.length, amount_to_process); *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_DATA; cell.length += TOPIC_HEADER_SIZE; cell.command = CELL_DATA; Loading Loading @@ -673,7 +673,7 @@ int connection_consider_sending_sendme(connection_t *conn, int edge_type) { return 0; } *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_SENDME; cell.length += TOPIC_HEADER_SIZE; cell.command = CELL_DATA; Loading src/or/connection_ap.c +3 −5 Original line number Diff line number Diff line Loading @@ -336,10 +336,9 @@ int ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) { /* deliver the dest_addr in a data cell */ cell.command = CELL_DATA; cell.aci = circ->n_aci; crypto_pseudo_rand(3, cell.payload+1); /* byte 0 is blank, bytes 1-3 are random */ crypto_pseudo_rand(2, cell.payload+2); /* bytes 0-1 is blank, bytes 2-3 are random */ /* FIXME check for collisions */ cell.payload[0] = 0; ap_conn->topic_id = *(uint32_t *)cell.payload; ap_conn->topic_id = ntohs(*(uint16_t *)(cell.payload+2)); cell.payload[0] = TOPIC_COMMAND_BEGIN; 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; Loading Loading @@ -381,8 +380,7 @@ int connection_ap_process_data_cell(cell_t *cell, circuit_t *circ) { assert(cell && circ); topic_command = *cell->payload; *cell->payload = 0; topic_id = *(uint32_t *)cell->payload; topic_id = ntohs(*(uint16_t *)(cell->payload+2)); log(LOG_DEBUG,"connection_ap_process_data_cell(): command %d topic %d", topic_command, topic_id); num_seen++; log(LOG_DEBUG,"connection_exit_process_data_cell(): Now seen %d data cells here.", num_seen); Loading src/or/connection_exit.c +4 −5 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ int connection_exit_send_connected(connection_t *conn) { memset(&cell, 0, sizeof(cell_t)); cell.aci = circ->p_aci; cell.command = CELL_DATA; *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_CONNECTED; cell.length = TOPIC_HEADER_SIZE; log(LOG_INFO,"connection_exit_send_connected(): passing back cell (aci %d).",circ->p_aci); Loading Loading @@ -129,7 +129,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { } cell->payload[0] = 0; n_conn->topic_id = *(uint32_t *)(cell->payload); n_conn->topic_id = ntohs(*(uint16_t *)(cell->payload+2)); n_conn->address = strdup(cell->payload + TOPIC_HEADER_SIZE); n_conn->port = atoi(comma+1); Loading @@ -150,7 +150,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { circ->n_conn = n_conn; /* send it off to the gethostbyname farm */ if(dns_tor_to_master(n_conn->address) < 0) { if(dns_tor_to_master(n_conn) < 0) { log(LOG_DEBUG,"connection_exit_begin_conn(): Couldn't queue resolve request."); connection_remove(n_conn); connection_free(n_conn); Loading @@ -171,8 +171,7 @@ int connection_exit_process_data_cell(cell_t *cell, circuit_t *circ) { assert(cell && circ); topic_command = *cell->payload; *cell->payload = 0; topic_id = *(uint32_t *)cell->payload; topic_id = ntohs(*(uint16_t *)(cell->payload+2)); log(LOG_DEBUG,"connection_exit_process_data_cell(): command %d topic %d", topic_command, topic_id); num_seen++; log(LOG_DEBUG,"connection_exit_process_data_cell(): Now seen %d data cells here.", num_seen); Loading src/or/dns.c +23 −3 Original line number Diff line number Diff line Loading @@ -339,10 +339,30 @@ static int dns_master_to_tor(int from, int to) { return 0; } int dns_tor_to_master(char *address) { int dns_tor_to_master(connection_t *exitconn) { connection_t *conn; unsigned char len; #ifdef DO_DNS_DIRECTLY /* new version which does it all right here */ struct hostent *rent; rent = gethostbyname(exitconn->address); if (!rent) { return -1; } memcpy((char *)&exitconn->addr, rent->h_addr, rent->h_length); exitconn->addr = ntohl(exitconn->addr); /* get it back to host order */ if(connection_exit_connect(exitconn) < 0) { exitconn->marked_for_close = 1; } return 0; #endif /* old version which actually uses the dns farm */ conn = connection_get_by_type(CONN_TYPE_DNSMASTER); if(!conn) { log(LOG_ERR,"dns_tor_to_master(): dns master nowhere to be found!"); Loading @@ -350,13 +370,13 @@ int dns_tor_to_master(char *address) { return -1; } len = strlen(address); len = strlen(exitconn->address); if(connection_write_to_buf(&len, 1, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write length."); return -1; } if(connection_write_to_buf(address, len, conn) < 0) { if(connection_write_to_buf(exitconn->address, len, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write address."); return -1; } Loading Loading
src/or/circuit.c +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ void circuit_about_to_close_connection(connection_t *conn) { memset(&cell, 0, sizeof(cell_t)); cell.command = CELL_DATA; cell.length = TOPIC_HEADER_SIZE; *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_END; if(conn == circ->p_conn) { Loading
src/or/connection.c +2 −2 Original line number Diff line number Diff line Loading @@ -617,7 +617,7 @@ repeat_connection_package_raw_inbuf: log(LOG_DEBUG,"connection_package_raw_inbuf(): Packaging %d bytes (%d waiting).",cell.length, amount_to_process); *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_DATA; cell.length += TOPIC_HEADER_SIZE; cell.command = CELL_DATA; Loading Loading @@ -673,7 +673,7 @@ int connection_consider_sending_sendme(connection_t *conn, int edge_type) { return 0; } *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_SENDME; cell.length += TOPIC_HEADER_SIZE; cell.command = CELL_DATA; Loading
src/or/connection_ap.c +3 −5 Original line number Diff line number Diff line Loading @@ -336,10 +336,9 @@ int ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ) { /* deliver the dest_addr in a data cell */ cell.command = CELL_DATA; cell.aci = circ->n_aci; crypto_pseudo_rand(3, cell.payload+1); /* byte 0 is blank, bytes 1-3 are random */ crypto_pseudo_rand(2, cell.payload+2); /* bytes 0-1 is blank, bytes 2-3 are random */ /* FIXME check for collisions */ cell.payload[0] = 0; ap_conn->topic_id = *(uint32_t *)cell.payload; ap_conn->topic_id = ntohs(*(uint16_t *)(cell.payload+2)); cell.payload[0] = TOPIC_COMMAND_BEGIN; 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; Loading Loading @@ -381,8 +380,7 @@ int connection_ap_process_data_cell(cell_t *cell, circuit_t *circ) { assert(cell && circ); topic_command = *cell->payload; *cell->payload = 0; topic_id = *(uint32_t *)cell->payload; topic_id = ntohs(*(uint16_t *)(cell->payload+2)); log(LOG_DEBUG,"connection_ap_process_data_cell(): command %d topic %d", topic_command, topic_id); num_seen++; log(LOG_DEBUG,"connection_exit_process_data_cell(): Now seen %d data cells here.", num_seen); Loading
src/or/connection_exit.c +4 −5 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ int connection_exit_send_connected(connection_t *conn) { memset(&cell, 0, sizeof(cell_t)); cell.aci = circ->p_aci; cell.command = CELL_DATA; *(uint32_t *)cell.payload = conn->topic_id; *(uint16_t *)(cell.payload+2) = htons(conn->topic_id); *cell.payload = TOPIC_COMMAND_CONNECTED; cell.length = TOPIC_HEADER_SIZE; log(LOG_INFO,"connection_exit_send_connected(): passing back cell (aci %d).",circ->p_aci); Loading Loading @@ -129,7 +129,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { } cell->payload[0] = 0; n_conn->topic_id = *(uint32_t *)(cell->payload); n_conn->topic_id = ntohs(*(uint16_t *)(cell->payload+2)); n_conn->address = strdup(cell->payload + TOPIC_HEADER_SIZE); n_conn->port = atoi(comma+1); Loading @@ -150,7 +150,7 @@ int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) { circ->n_conn = n_conn; /* send it off to the gethostbyname farm */ if(dns_tor_to_master(n_conn->address) < 0) { if(dns_tor_to_master(n_conn) < 0) { log(LOG_DEBUG,"connection_exit_begin_conn(): Couldn't queue resolve request."); connection_remove(n_conn); connection_free(n_conn); Loading @@ -171,8 +171,7 @@ int connection_exit_process_data_cell(cell_t *cell, circuit_t *circ) { assert(cell && circ); topic_command = *cell->payload; *cell->payload = 0; topic_id = *(uint32_t *)cell->payload; topic_id = ntohs(*(uint16_t *)(cell->payload+2)); log(LOG_DEBUG,"connection_exit_process_data_cell(): command %d topic %d", topic_command, topic_id); num_seen++; log(LOG_DEBUG,"connection_exit_process_data_cell(): Now seen %d data cells here.", num_seen); Loading
src/or/dns.c +23 −3 Original line number Diff line number Diff line Loading @@ -339,10 +339,30 @@ static int dns_master_to_tor(int from, int to) { return 0; } int dns_tor_to_master(char *address) { int dns_tor_to_master(connection_t *exitconn) { connection_t *conn; unsigned char len; #ifdef DO_DNS_DIRECTLY /* new version which does it all right here */ struct hostent *rent; rent = gethostbyname(exitconn->address); if (!rent) { return -1; } memcpy((char *)&exitconn->addr, rent->h_addr, rent->h_length); exitconn->addr = ntohl(exitconn->addr); /* get it back to host order */ if(connection_exit_connect(exitconn) < 0) { exitconn->marked_for_close = 1; } return 0; #endif /* old version which actually uses the dns farm */ conn = connection_get_by_type(CONN_TYPE_DNSMASTER); if(!conn) { log(LOG_ERR,"dns_tor_to_master(): dns master nowhere to be found!"); Loading @@ -350,13 +370,13 @@ int dns_tor_to_master(char *address) { return -1; } len = strlen(address); len = strlen(exitconn->address); if(connection_write_to_buf(&len, 1, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write length."); return -1; } if(connection_write_to_buf(address, len, conn) < 0) { if(connection_write_to_buf(exitconn->address, len, conn) < 0) { log(LOG_DEBUG,"dns_tor_to_master(): Couldn't write address."); return -1; } Loading