[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Use CIRCUIT_IS_ORIGIN in favor of boolean circ->cpath
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv25282/src/or
Modified Files:
circuit.c command.c connection_edge.c or.h rendclient.c
rendservice.c
Log Message:
Use CIRCUIT_IS_ORIGIN in favor of boolean circ->cpath
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- circuit.c 8 Apr 2004 02:22:26 -0000 1.197
+++ circuit.c 8 Apr 2004 02:24:06 -0000 1.198
@@ -260,7 +260,7 @@
{
routerinfo_t *exitrouter;
- if (!circ->cpath)
+ if (!CIRCUIT_IS_ORIGIN(circ))
return 0; /* this circ doesn't start at us */
if (must_be_open && (circ->state != CIRCUIT_STATE_OPEN || !circ->n_conn))
return 0; /* ignore non-open circs */
@@ -442,7 +442,7 @@
while(circ) {
victim = circ;
circ = circ->next;
- if(!victim->cpath)
+ if(!CIRCUIT_IS_ORIGIN(victim))
continue; /* didn't originate here */
if(victim->marked_for_close)
continue; /* don't mess with marked circs */
@@ -473,7 +473,7 @@
int num=0;
for(circ=global_circuitlist;circ;circ = circ->next) {
- if(circ->cpath
+ if(CIRCUIT_IS_ORIGIN(circ)
&& circ->state != CIRCUIT_STATE_OPEN
&& !circ->marked_for_close)
num++;
@@ -493,7 +493,7 @@
time_t now = time(NULL);
for(circ=global_circuitlist;circ;circ = circ->next) {
- if(circ->cpath && circ->state != CIRCUIT_STATE_OPEN &&
+ if(CIRCUIT_IS_ORIGIN(circ) && circ->state != CIRCUIT_STATE_OPEN &&
!circ->marked_for_close && circ->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
(!circ->timestamp_dirty ||
circ->timestamp_dirty + options.NewCircuitPeriod < now)) {
@@ -661,8 +661,9 @@
assert(cell_direction == CELL_DIRECTION_IN || cell_direction == CELL_DIRECTION_OUT);
if(cell_direction == CELL_DIRECTION_IN) {
- if(circ->cpath) { /* we're at the beginning of the circuit.
- We'll want to do layered crypts. */
+ if(CIRCUIT_IS_ORIGIN(circ)) { /* we're at the beginning of the circuit.
+ We'll want to do layered crypts. */
+ assert(circ->cpath);
thishop = circ->cpath;
if(thishop->state != CPATH_STATE_OPEN) {
log_fn(LOG_WARN,"Relay cell before first created cell? Closing.");
@@ -973,7 +974,7 @@
struct crypt_path_t *hop;
char *states[] = {"closed", "waiting for keys", "open"};
routerinfo_t *router;
- assert(circ->cpath);
+ assert(CIRCUIT_IS_ORIGIN(circ) && circ->cpath);
snprintf(s, sizeof(buf)-1, "circ (length %d, exit %s): ",
circ->build_state->desired_path_len, circ->build_state->chosen_exit);
@@ -1045,7 +1046,7 @@
log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d",
poll_index, type, this_circid, other_circid, circ->state,
circuit_state_to_string[circ->state], (int)circ->timestamp_created);
- if(circ->cpath) { /* circ starts at this node */
+ if(CIRCUIT_IS_ORIGIN(circ)) { /* circ starts at this node */
if(circ->state == CIRCUIT_STATE_BUILDING)
log(severity,"Building: desired len %d, planned exit node %s.",
circ->build_state->desired_path_len, circ->build_state->chosen_exit);
@@ -1105,7 +1106,7 @@
!circ->p_streams) {
log_fn(LOG_DEBUG,"Closing n_circ_id %d",circ->n_circ_id);
circuit_mark_for_close(circ);
- } else if (!circ->timestamp_dirty && circ->cpath &&
+ } else if (!circ->timestamp_dirty && CIRCUIT_IS_ORIGIN(circ) &&
circ->state == CIRCUIT_STATE_OPEN) {
/* Also, gather a list of open unused circuits that we created.
* Because we add elements to the front of global_circuitlist,
@@ -1253,7 +1254,7 @@
}
onion_extend_cpath(&circ->cpath, circ->build_state, &firsthop);
- if(!circ->cpath) {
+ if(!CIRCUIT_IS_ORIGIN(circ)) {
log_fn(LOG_INFO,"Generating first cpath hop failed.");
circuit_mark_for_close(circ);
return NULL;
@@ -1308,7 +1309,7 @@
for(circ=global_circuitlist;circ;circ = circ->next) {
if (circ->marked_for_close)
continue;
- if(circ->cpath && circ->n_addr == or_conn->addr && circ->n_port == or_conn->port) {
+ if(CIRCUIT_IS_ORIGIN(circ) && circ->n_addr == or_conn->addr && circ->n_port == or_conn->port) {
assert(circ->state == CIRCUIT_STATE_OR_WAIT);
log_fn(LOG_DEBUG,"Found circ %d, sending onion skin.", circ->n_circ_id);
circ->n_conn = or_conn;
@@ -1332,7 +1333,7 @@
int circ_id_type;
char payload[2+4+ONIONSKIN_CHALLENGE_LEN];
- assert(circ && circ->cpath);
+ assert(circ && CIRCUIT_IS_ORIGIN(circ));
if(circ->cpath->state == CPATH_STATE_CLOSED) {
assert(circ->n_conn && circ->n_conn->type == CONN_TYPE_OR);
@@ -1518,7 +1519,7 @@
unsigned char keys[CPATH_KEY_MATERIAL_LEN];
crypt_path_t *hop;
- assert(circ->cpath);
+ assert(CIRCUIT_IS_ORIGIN(circ));
if(circ->cpath->state == CPATH_STATE_AWAITING_KEYS)
hop = circ->cpath;
else {
@@ -1557,7 +1558,7 @@
crypt_path_t *victim;
connection_t *stream;
- assert(circ);
+ assert(circ && CIRCUIT_IS_ORIGIN(circ));
assert(layer);
/* XXX Since we don't ask for truncates currently, getting a truncated
@@ -1654,11 +1655,13 @@
assert(c->package_window >= 0);
if (c->state == CIRCUIT_STATE_OPEN) {
if (c->cpath) {
+ assert(CIRCUIT_IS_ORIGIN(c));
assert(!c->n_crypto);
assert(!c->p_crypto);
assert(!c->n_digest);
assert(!c->p_digest);
} else {
+ assert(!CIRCUIT_IS_ORIGIN(c));
assert(c->n_crypto);
assert(c->p_crypto);
assert(c->n_digest);
Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- command.c 5 Apr 2004 22:01:35 -0000 1.57
+++ command.c 8 Apr 2004 02:24:06 -0000 1.58
@@ -132,7 +132,7 @@
return;
}
- if(circ->cpath) { /* we're the OP. Handshake this. */
+ if(CIRCUIT_IS_ORIGIN(circ)) { /* we're the OP. Handshake this. */
log_fn(LOG_DEBUG,"at OP. Finishing handshake.");
if(circuit_finish_handshake(circ, cell->payload) < 0) {
log_fn(LOG_WARN,"circuit_finish_handshake failed.");
@@ -198,7 +198,7 @@
onion_pending_remove(circ);
}
- if(cell->circ_id == circ->p_circ_id || circ->cpath) {
+ if(cell->circ_id == circ->p_circ_id || CIRCUIT_IS_ORIGIN(circ)) {
/* either the destroy came from behind, or we're the AP */
circ->p_conn = NULL;
circuit_mark_for_close(circ);
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- connection_edge.c 8 Apr 2004 02:10:43 -0000 1.151
+++ connection_edge.c 8 Apr 2004 02:24:06 -0000 1.152
@@ -833,7 +833,7 @@
/* assert_connection_ok(conn, time(NULL)); */
circ->p_streams = apconn;
- assert(circ->cpath && circ->cpath->prev);
+ assert(CIRCUIT_IS_ORIGIN(circ) && circ->cpath && circ->cpath->prev);
assert(circ->cpath->prev->state == CPATH_STATE_OPEN);
apconn->cpath_layer = circ->cpath->prev;
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.307
retrieving revision 1.308
diff -u -d -r1.307 -r1.308
--- or.h 7 Apr 2004 22:41:00 -0000 1.307
+++ or.h 8 Apr 2004 02:24:06 -0000 1.308
@@ -190,10 +190,12 @@
#define _CIRCUIT_PURPOSE_MIN 1
/* these circuits were initiated elsewhere */
+#define _CIRCUIT_PURPOSE_OR_MIN 1
#define CIRCUIT_PURPOSE_OR 1 /* normal circuit, at OR. */
#define CIRCUIT_PURPOSE_INTRO_POINT 2 /* At OR, from Bob, waiting for intro from Alices */
#define CIRCUIT_PURPOSE_REND_POINT_WAITING 3 /* At OR, from Alice, waiting for Bob */
#define CIRCUIT_PURPOSE_REND_ESTABLISHED 4 /* At OR, both circuits have this purpose */
+#define _CIRCUIT_PURPOSE_OR_MAX 4
/* these circuits originate at this node */
@@ -225,6 +227,9 @@
#define CIRCUIT_PURPOSE_S_REND_JOINED 13 /* at Bob, rendezvous established.*/
#define _CIRCUIT_PURPOSE_MAX 13
+#define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>_CIRCUIT_PURPOSE_OR_MAX)
+#define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))
+
#define RELAY_COMMAND_BEGIN 1
#define RELAY_COMMAND_DATA 2
#define RELAY_COMMAND_END 3
@@ -561,7 +566,7 @@
/*
* rend_query holds y portion of y.onion (nul-terminated) if purpose
* is C_INTRODUCING or C_ESTABLISH_REND, or is a C_GENERAL for a
- * hidden service.
+ * hidden service, or is S_*.
*/
char rend_query[REND_SERVICE_ID_LEN+1];
Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- rendclient.c 8 Apr 2004 02:11:49 -0000 1.27
+++ rendclient.c 8 Apr 2004 02:24:06 -0000 1.28
@@ -9,7 +9,7 @@
rend_client_introcirc_is_open(circuit_t *circ)
{
assert(circ->purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
- assert(circ->cpath);
+ assert(CIRCUIT_IS_ORIGIN(circ) && circ->cpath);
log_fn(LOG_INFO,"introcirc is open");
connection_ap_attach_pending();
@@ -125,7 +125,7 @@
rend_client_rendcirc_is_open(circuit_t *circ)
{
assert(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
- assert(circ->cpath);
+ assert(CIRCUIT_IS_ORIGIN(circ));
log_fn(LOG_INFO,"rendcirc is open");
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- rendservice.c 8 Apr 2004 02:10:43 -0000 1.41
+++ rendservice.c 8 Apr 2004 02:24:06 -0000 1.42
@@ -481,7 +481,7 @@
char hexid[9];
assert(circuit->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
- assert(circuit->cpath);
+ assert(CIRCUIT_IS_ORIGIN(circuit) && circuit->cpath);
hex_encode(circuit->rend_pk_digest, 4, hexid);
service = rend_service_get_by_pk_digest(circuit->rend_pk_digest);