[or-cvs] r17646: {tor} Change CELL_DIRECTION_* to an enum. (tor/trunk/src/or)

nickm at seul.org nickm at seul.org
Wed Dec 17 17:20:19 UTC 2008


Author: nickm
Date: 2008-12-17 12:20:19 -0500 (Wed, 17 Dec 2008)
New Revision: 17646

Modified:
   tor/trunk/src/or/or.h
   tor/trunk/src/or/relay.c
Log:
Change CELL_DIRECTION_* to an enum.

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-12-17 16:45:36 UTC (rev 17645)
+++ tor/trunk/src/or/or.h	2008-12-17 17:20:19 UTC (rev 17646)
@@ -745,8 +745,11 @@
  * future are dropped immediately. */
 #define REND_REPLAY_TIME_INTERVAL (60 * 60)
 
-#define CELL_DIRECTION_IN 1
-#define CELL_DIRECTION_OUT 2
+/** Used to indicate which way a cell is going on a circuit. */
+typedef enum {
+  CELL_DIRECTION_IN=1, /**< The cell is moving towards the origin. */
+  CELL_DIRECTION_OUT=2, /**< The cell is moving away from the origin. */
+} cell_direction_t;
 
 /** Initial value for both sides of a circuit transmission window when the
  * circuit is initialized.  Measured in cells. */
@@ -3823,7 +3826,7 @@
 extern uint64_t stats_n_relay_cells_delivered;
 
 int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
-                               int cell_direction);
+                               cell_direction_t cell_direction);
 
 void relay_header_pack(char *dest, const relay_header_t *src);
 void relay_header_unpack(relay_header_t *dest, const char *src);
@@ -3852,7 +3855,7 @@
 void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell);
 
 void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
-                                  cell_t *cell, int direction);
+                                  cell_t *cell, cell_direction_t direction);
 void connection_or_unlink_all_active_circs(or_connection_t *conn);
 int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
                                                   int max, time_t now);

Modified: tor/trunk/src/or/relay.c
===================================================================
--- tor/trunk/src/or/relay.c	2008-12-17 16:45:36 UTC (rev 17645)
+++ tor/trunk/src/or/relay.c	2008-12-17 17:20:19 UTC (rev 17646)
@@ -16,10 +16,10 @@
 #include "or.h"
 #include "mempool.h"
 
-static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
+static int relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
                 crypt_path_t **layer_hint, char *recognized);
 static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell,
-                                            int cell_direction,
+                                            cell_direction_t cell_direction,
                                             crypt_path_t *layer_hint);
 
 static int
@@ -141,7 +141,8 @@
  * Return -<b>reason</b> on failure.
  */
 int
-circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, int cell_direction)
+circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
+                           cell_direction_t cell_direction)
 {
   or_connection_t *or_conn=NULL;
   crypt_path_t *layer_hint=NULL;
@@ -252,7 +253,7 @@
  * else return 0.
  */
 static int
-relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
+relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
             crypt_path_t **layer_hint, char *recognized)
 {
   relay_header_t rh;
@@ -326,7 +327,7 @@
  */
 static int
 circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
-                           int cell_direction,
+                           cell_direction_t cell_direction,
                            crypt_path_t *layer_hint)
 {
   or_connection_t *conn; /* where to send the cell */
@@ -379,7 +380,7 @@
  * attached to circ, return that conn, else return NULL.
  */
 static edge_connection_t *
-relay_lookup_conn(circuit_t *circ, cell_t *cell, int cell_direction,
+relay_lookup_conn(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction,
                   crypt_path_t *layer_hint)
 {
   edge_connection_t *tmpconn;
@@ -472,7 +473,7 @@
 {
   cell_t cell;
   relay_header_t rh;
-  int cell_direction;
+  cell_direction_t cell_direction;
   /* XXXX NM Split this function into a separate versions per circuit type? */
 
   tor_assert(circ);
@@ -1801,7 +1802,7 @@
  * transmitting in <b>direction</b>. */
 void
 append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
-                             cell_t *cell, int direction)
+                             cell_t *cell, cell_direction_t direction)
 {
   cell_queue_t *queue;
   int streams_blocked;



More information about the tor-commits mailing list