[or-cvs] Get the rest of intro-ack/nak handling in ... except for th...

Nick Mathewson nickm at seul.org
Tue Apr 13 01:41:41 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv10351/src/or

Modified Files:
	circuit.c or.h rendclient.c 
Log Message:
Get the rest of intro-ack/nak handling in ... except for the tricky "pick a new intro and re-extend and re-try" part.

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- circuit.c	12 Apr 2004 22:47:11 -0000	1.203
+++ circuit.c	13 Apr 2004 01:41:39 -0000	1.204
@@ -276,6 +276,10 @@
        circ->purpose != CIRCUIT_PURPOSE_C_REND_READY &&
        circ->purpose != CIRCUIT_PURPOSE_C_REND_JOINED)
       return 0;
+  } else if (purpose == CIRCUIT_PURPOSE_C_INTRODUCING) {
+    if (circ->purpose != CIRCUIT_PURPOSE_C_INTRODUCING &&
+        circ->purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT)
+      return 0;
   } else {
     if(purpose != circ->purpose)
       return 0;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.314
retrieving revision 1.315
diff -u -d -r1.314 -r1.315
--- or.h	13 Apr 2004 00:38:16 -0000	1.314
+++ or.h	13 Apr 2004 01:41:39 -0000	1.315
@@ -216,16 +216,18 @@
  */
 #define CIRCUIT_PURPOSE_C_GENERAL 5 /* normal circuit, with cpath */
 #define CIRCUIT_PURPOSE_C_INTRODUCING 6 /* at Alice, connecting to intro point */
-#define CIRCUIT_PURPOSE_C_ESTABLISH_REND 7 /* at Alice, waiting for ack */
-#define CIRCUIT_PURPOSE_C_REND_READY 8 /* at Alice, waiting for Bob */
-#define CIRCUIT_PURPOSE_C_REND_JOINED 9 /* at Alice, rendezvous established */
+#define CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT 7 /* at alice, sent INTRODUCE1 to intro point, waiting for ACK/NAK */
 
-#define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 10 /* at Bob, waiting for introductions */
-#define CIRCUIT_PURPOSE_S_INTRO 11 /* at Bob, successfully established intro */
-#define CIRCUIT_PURPOSE_S_CONNECT_REND 12 /* at Bob, connecting to rend point */
+#define CIRCUIT_PURPOSE_C_ESTABLISH_REND 8 /* at Alice, waiting for ack */
+#define CIRCUIT_PURPOSE_C_REND_READY 9 /* at Alice, waiting for Bob */
+#define CIRCUIT_PURPOSE_C_REND_JOINED 10 /* at Alice, rendezvous established */
 
-#define CIRCUIT_PURPOSE_S_REND_JOINED 13 /* at Bob, rendezvous established.*/
-#define _CIRCUIT_PURPOSE_MAX 13
+#define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 11 /* at Bob, waiting for introductions */
+#define CIRCUIT_PURPOSE_S_INTRO 12 /* at Bob, successfully established intro */
+#define CIRCUIT_PURPOSE_S_CONNECT_REND 13 /* at Bob, connecting to rend point */
+
+#define CIRCUIT_PURPOSE_S_REND_JOINED 14 /* at Bob, rendezvous established.*/
+#define _CIRCUIT_PURPOSE_MAX 14
 
 #define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>_CIRCUIT_PURPOSE_OR_MAX)
 #define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))

Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- rendclient.c	12 Apr 2004 23:33:47 -0000	1.30
+++ rendclient.c	13 Apr 2004 01:41:39 -0000	1.31
@@ -110,8 +110,8 @@
     return -1;
   }
 
-  /* we don't need it anymore, plus it's been used. send the destroy. */
-  circuit_mark_for_close(introcirc);
+  /* Now, we wait for an ACK or NAK on this circuit. */
+  introcirc->purpose = CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT;
 
   return 0;
 err:
@@ -140,15 +140,32 @@
 /* Called when get an ACK or a NAK for a REND_INTRODUCE1 cell.
  */
 int
-rend_client_introduction_acked(circuit_t *introcirc,
+rend_client_introduction_acked(circuit_t *circ,
                                const char *request, int request_len)
 {
+  if (circ->purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
+    log_fn(LOG_WARN, "Recieved REND_INTRODUCE_ACK on unexpected circuit %d",
+           circ->n_circ_id);
+    circuit_mark_for_close(circ);
+    return -1;
+  }
+
   if (request_len == 0) {
     /* It's an ACK; the introduction point relayed our introduction request. */
-    /* XXXX writeme */
+    /* So close the circuit; we won't need it any more. */
+    circuit_mark_for_close(circ);
   } else {
     /* It's a NAK; the introduction point didn't relay our request. */
-    /* XXXX writeme */
+    circ->purpose = CIRCUIT_PURPOSE_C_INTRODUCING;
+    /* XXXX
+     * Now become non-open, extend to another one of Bob's
+     * introduction points, and try again.  Maybe mark the service as
+     * non-functional at the first intro point somehow?
+     *
+     * Or re-fetch the service descriptor? Hm....
+     *
+     * XXXX writeme
+     */
   }
   return 0;
 }



More information about the tor-commits mailing list