[or-cvs] cell.c is now obsolete

Roger Dingledine arma at seul.org
Thu Oct 3 02:17:44 UTC 2002


Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or

Modified Files:
	Makefile.am command.c config.c 
Removed Files:
	cell.c 
Log Message:
cell.c is now obsolete


Index: Makefile.am
===================================================================
RCS file: /home/or/cvsroot/src/or/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile.am	26 Sep 2002 12:09:09 -0000	1.8
+++ Makefile.am	3 Oct 2002 02:17:41 -0000	1.9
@@ -7,7 +7,7 @@
 
 or_LDADD = -L../common -lor
 
-or_SOURCES = buffers.c cell.c circuit.c command.c connection.c \
+or_SOURCES = buffers.c circuit.c command.c connection.c \
              connection_exit.c connection_ap.c connection_op.c connection_or.c config.c \
              main.c onion.c routers.c directory.c
 

Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- command.c	17 Sep 2002 08:14:36 -0000	1.11
+++ command.c	3 Oct 2002 02:17:41 -0000	1.12
@@ -31,13 +31,50 @@
   }
 }
 
+/* helper function for command_process_create_cell */
+static int deliver_onion_to_conn(aci_t aci, unsigned char *onion, uint32_t onionlen, connection_t *conn) {
+  char *buf;
+  int buflen, dataleft;
+  cell_t cell;
+ 
+  assert(aci && onion && onionlen);
+ 
+  buflen = onionlen+4;
+  buf = malloc(buflen);
+  if(!buf)
+    return -1;
+ 
+  log(LOG_DEBUG,"deliver_onion_to_conn(): Setting onion length to %u.",onionlen);
+  *(uint32_t*)buf = htonl(onionlen);
+  memcpy((void *)(buf+4),(void *)onion,onionlen);
+ 
+  dataleft = buflen;
+  while(dataleft > 0) {
+    memset(&cell,0,sizeof(cell_t));
+    cell.command = CELL_CREATE;
+    cell.aci = aci;
+    if(dataleft >= CELL_PAYLOAD_SIZE)
+      cell.length = CELL_PAYLOAD_SIZE;
+    else
+      cell.length = dataleft;
+    memcpy(cell.payload, buf+buflen-dataleft, cell.length);
+    dataleft -= cell.length;
+ 
+    log(LOG_DEBUG,"deliver_onion_to_conn(): Delivering create cell, payload %d bytes.",cell.length);
+    if(connection_write_cell_to_buf(&cell, conn) < 0) {
+      log(LOG_DEBUG,"deliver_onion_to_conn(): Could not buffer new create cells. Closing.");
+      free(buf);
+      return -1;
+    }
+  }
+  free(buf);
+  return 0;
+}
+
 void command_process_create_cell(cell_t *cell, connection_t *conn) {
   circuit_t *circ;
   connection_t *n_conn;
-  unsigned char *cellbuf; /* array of cells */
-  int cellbuflen; /* size of cellbuf in bytes */
-  cell_t *tmpcell; /* pointer to an arbitrary cell */
-  int retval, i;
+  int retval;
 
   circ = circuit_get_by_aci_conn(cell->aci, conn);
 
@@ -122,30 +159,14 @@
     pad_onion(circ->onion,circ->onionlen, sizeof(onion_layer_t));
     log(LOG_DEBUG,"command_process_create_cell(): Padded the onion with random data.");
 
-    retval = pack_create(circ->n_aci, circ->onion, circ->onionlen, &cellbuf, &cellbuflen);
+    retval = deliver_onion_to_conn(circ->n_aci, circ->onion, circ->onionlen, n_conn); 
+//    retval = pack_create(circ->n_aci, circ->onion, circ->onionlen, &cellbuf, &cellbuflen);
     free((void *)circ->onion);
     circ->onion = NULL;
-    if (retval == -1) /* pack_create() error */
-    {
-      log(LOG_DEBUG,"command_process_create_cell(): Could not pack the onion into CREATE cells. Closing the connection.");
+    if (retval == -1) {
+      log(LOG_DEBUG,"command_process_create_cell(): Could not deliver the onion to next conn. Closing.");
       circuit_close(circ);
-      return;
     }
-    log(LOG_DEBUG,"command_process_create_cell(): Onion packed into CREATE cells. Buffering the cells.");
-    /* queue the create cells for transmission to the next hop */
-    tmpcell = (cell_t *)cellbuf;
-    for (i=0;i<cellbuflen/sizeof(cell_t);i++)
-    {
-      retval = connection_write_cell_to_buf(tmpcell, n_conn);
-      if (retval == -1) /* buffering failed, drop the connection */
-      {
-        log(LOG_DEBUG,"command_process_create_cell(): Could not buffer new create cells. Closing.");
-        circuit_close(circ);
-        return;
-      }
-      tmpcell++;
-    }
-    free((void *)cellbuf);
     return;
 
   } else { /* this is destined for an exit */

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- config.c	1 Oct 2002 23:37:31 -0000	1.19
+++ config.c	3 Oct 2002 02:17:41 -0000	1.20
@@ -10,7 +10,10 @@
  */
 
 #include "or.h"
-#include <string.h>
+
+#ifndef POPT_TABLEEND /* handle popt 1.6 before 1.6.2 */
+#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
+#endif
 
 const char * 
 basename(const char *filename)

--- cell.c DELETED ---



More information about the tor-commits mailing list