[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r16155: Make circid_t and streamid_t get used instead of uint16_t; i (in tor/trunk: . src/or)
Author: nickm
Date: 2008-07-23 11:58:30 -0400 (Wed, 23 Jul 2008)
New Revision: 16155
Modified:
tor/trunk/
tor/trunk/src/or/circuitbuild.c
tor/trunk/src/or/circuitlist.c
tor/trunk/src/or/connection_edge.c
tor/trunk/src/or/connection_or.c
tor/trunk/src/or/cpuworker.c
tor/trunk/src/or/or.h
Log:
r17322@aud-055: nickm | 2008-07-23 16:50:50 +0200
Make circid_t and streamid_t get used instead of uint16_t; it is possible we will soon want to make circid_t change to uint32_t.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r17322] on 49666b30-7950-49c5-bedf-9dc8f3168102
Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/circuitbuild.c 2008-07-23 15:58:30 UTC (rev 16155)
@@ -69,12 +69,12 @@
*
* Return it, or 0 if can't get a unique circ_id.
*/
-static uint16_t
+static circid_t
get_unique_circ_id_by_conn(or_connection_t *conn)
{
- uint16_t test_circ_id;
- uint16_t attempts=0;
- uint16_t high_bit;
+ circid_t test_circ_id;
+ circid_t attempts=0;
+ circid_t high_bit;
tor_assert(conn);
if (conn->circ_id_type == CIRC_ID_TYPE_NEITHER) {
@@ -488,7 +488,7 @@
const char *payload)
{
cell_t cell;
- uint16_t id;
+ circid_t id;
tor_assert(circ);
tor_assert(circ->n_conn);
Modified: tor/trunk/src/or/circuitlist.c
===================================================================
--- tor/trunk/src/or/circuitlist.c 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/circuitlist.c 2008-07-23 15:58:30 UTC (rev 16155)
@@ -34,7 +34,7 @@
typedef struct orconn_circid_circuit_map_t {
HT_ENTRY(orconn_circid_circuit_map_t) node;
or_connection_t *or_conn;
- uint16_t circ_id;
+ circid_t circ_id;
circuit_t *circuit;
} orconn_circid_circuit_map_t;
@@ -53,7 +53,7 @@
static INLINE unsigned int
_orconn_circid_entry_hash(orconn_circid_circuit_map_t *a)
{
- return (((unsigned)a->circ_id)<<16) ^ (unsigned)(uintptr_t)(a->or_conn);
+ return (((unsigned)a->circ_id)<<8) ^ (unsigned)(uintptr_t)(a->or_conn);
}
/** Map from [orconn,circid] to circuit. */
@@ -80,13 +80,13 @@
* XXX "active" isn't an arg anymore */
static void
circuit_set_circid_orconn_helper(circuit_t *circ, int direction,
- uint16_t id,
+ circid_t id,
or_connection_t *conn)
{
orconn_circid_circuit_map_t search;
orconn_circid_circuit_map_t *found;
or_connection_t *old_conn, **conn_ptr;
- uint16_t old_id, *circid_ptr;
+ circid_t old_id, *circid_ptr;
int was_active, make_active;
if (direction == CELL_DIRECTION_OUT) {
@@ -159,7 +159,7 @@
* with the corresponding circuit ID, and add the circuit as appropriate
* to the (orconn,id)-\>circuit map. */
void
-circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
+circuit_set_p_circid_orconn(or_circuit_t *circ, circid_t id,
or_connection_t *conn)
{
circuit_set_circid_orconn_helper(TO_CIRCUIT(circ), CELL_DIRECTION_IN,
@@ -173,7 +173,7 @@
* with the corresponding circuit ID, and add the circuit as appropriate
* to the (orconn,id)-\>circuit map. */
void
-circuit_set_n_circid_orconn(circuit_t *circ, uint16_t id,
+circuit_set_n_circid_orconn(circuit_t *circ, circid_t id,
or_connection_t *conn)
{
circuit_set_circid_orconn_helper(circ, CELL_DIRECTION_OUT, id, conn);
@@ -356,7 +356,7 @@
/** Allocate a new or_circuit_t, connected to <b>p_conn</b> as
* <b>p_circ_id</b>. If <b>p_conn</b> is NULL, the circuit is unattached. */
or_circuit_t *
-or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn)
+or_circuit_new(circid_t p_circ_id, or_connection_t *p_conn)
{
/* CircIDs */
or_circuit_t *circ;
@@ -603,7 +603,7 @@
* Return NULL if no such circuit exists.
*/
static INLINE circuit_t *
-circuit_get_by_circid_orconn_impl(uint16_t circ_id, or_connection_t *conn)
+circuit_get_by_circid_orconn_impl(circid_t circ_id, or_connection_t *conn)
{
orconn_circid_circuit_map_t search;
orconn_circid_circuit_map_t *found;
@@ -652,7 +652,7 @@
* Return NULL if no such circuit exists.
*/
circuit_t *
-circuit_get_by_circid_orconn(uint16_t circ_id, or_connection_t *conn)
+circuit_get_by_circid_orconn(circid_t circ_id, or_connection_t *conn)
{
circuit_t *circ = circuit_get_by_circid_orconn_impl(circ_id, conn);
if (!circ || circ->marked_for_close)
@@ -664,7 +664,7 @@
/** Return true iff the circuit ID <b>circ_id</b> is currently used by a
* circuit, marked or not, on <b>conn</b>. */
int
-circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn)
+circuit_id_in_use_on_orconn(circid_t circ_id, or_connection_t *conn)
{
return circuit_get_by_circid_orconn_impl(circ_id, conn) != NULL;
}
Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/connection_edge.c 2008-07-23 15:58:30 UTC (rev 16155)
@@ -153,7 +153,7 @@
* Mark it for close and return 0.
*/
int
-connection_edge_destroy(uint16_t circ_id, edge_connection_t *conn)
+connection_edge_destroy(circid_t circ_id, edge_connection_t *conn)
{
if (!conn->_base.marked_for_close) {
log_info(LD_EDGE,
@@ -1944,11 +1944,11 @@
/** Iterate over the two bytes of stream_id until we get one that is not
* already in use; return it. Return 0 if can't get a unique stream_id.
*/
-static uint16_t
+static streamid_t
get_unique_stream_id_by_circ(origin_circuit_t *circ)
{
edge_connection_t *tmpconn;
- uint16_t test_stream_id;
+ streamid_t test_stream_id;
uint32_t attempts=0;
again:
Modified: tor/trunk/src/or/connection_or.c
===================================================================
--- tor/trunk/src/or/connection_or.c 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/connection_or.c 2008-07-23 15:58:30 UTC (rev 16155)
@@ -1016,7 +1016,7 @@
* Return 0.
*/
int
-connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn, int reason)
+connection_or_send_destroy(circid_t circ_id, or_connection_t *conn, int reason)
{
cell_t cell;
Modified: tor/trunk/src/or/cpuworker.c
===================================================================
--- tor/trunk/src/or/cpuworker.c 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/cpuworker.c 2008-07-23 15:58:30 UTC (rev 16155)
@@ -63,7 +63,7 @@
/** Pack addr,port,and circ_id; set *tag to the result. (See note on
* cpuworker_main for wire format.) */
static void
-tag_pack(char *tag, uint32_t addr, uint16_t port, uint16_t circ_id)
+tag_pack(char *tag, uint32_t addr, uint16_t port, circid_t circ_id)
{
*(uint32_t *)tag = addr;
*(uint16_t *)(tag+4) = port;
@@ -73,7 +73,7 @@
/** Unpack <b>tag</b> into addr, port, and circ_id.
*/
static void
-tag_unpack(const char *tag, uint32_t *addr, uint16_t *port, uint16_t *circ_id)
+tag_unpack(const char *tag, uint32_t *addr, uint16_t *port, circid_t *circ_id)
{
struct in_addr in;
char addrbuf[INET_NTOA_BUF_LEN];
@@ -137,7 +137,7 @@
char buf[LEN_ONION_RESPONSE];
uint32_t addr;
uint16_t port;
- uint16_t circ_id;
+ circid_t circ_id;
or_connection_t *p_conn;
circuit_t *circ;
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2008-07-23 15:00:19 UTC (rev 16154)
+++ tor/trunk/src/or/or.h 2008-07-23 15:58:30 UTC (rev 16155)
@@ -717,10 +717,15 @@
/** Largest number of bytes that can fit in a relay cell payload. */
#define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
+/** Identifies a circuit on an or_connection */
+typedef uint16_t circid_t;
+/** Identifies a stream on a circuit */
+typedef uint16_t streamid_t;
+
/** Parsed onion routing cell. All communication between nodes
* is via cells. */
typedef struct cell_t {
- uint16_t circ_id; /**< Circuit which received the cell. */
+ circid_t circ_id; /**< Circuit which received the cell. */
uint8_t command; /**< Type of the cell: one of CELL_PADDING, CELL_CREATE,
* CELL_DESTROY, etc */
char payload[CELL_PAYLOAD_SIZE]; /**< Cell body. */
@@ -729,7 +734,7 @@
/** Parsed variable-length onion routing cell. */
typedef struct var_cell_t {
uint8_t command;
- uint16_t circ_id;
+ circid_t circ_id;
uint16_t payload_len;
char payload[1];
} var_cell_t;
@@ -752,7 +757,7 @@
typedef struct {
uint8_t command; /**< The end-to-end relay command. */
uint16_t recognized; /**< Used to tell whether cell is for us. */
- uint16_t stream_id; /**< Which stream is this cell associated with? */
+ streamid_t stream_id; /**< Which stream is this cell associated with? */
char integrity[4]; /**< Used to tell whether cell is corrupted. */
uint16_t length; /**< How long is the payload body? */
} relay_header_t;
@@ -932,7 +937,7 @@
unsigned int is_canonical:1;
uint8_t link_proto; /**< What protocol version are we using? 0 for
* "none negotiated yet." */
- uint16_t next_circ_id; /**< Which circ_id do we try to use next on
+ circid_t next_circ_id; /**< Which circ_id do we try to use next on
* this connection? This is always in the
* range 0..1<<15-1. */
@@ -983,8 +988,8 @@
uint32_t address_ttl; /**< TTL for address-to-addr mapping on exit
* connection. Exit connections only. */
- uint16_t stream_id; /**< The stream ID used for this edge connection on its
- * circuit */
+ streamid_t stream_id; /**< The stream ID used for this edge connection on its
+ * circuit */
/** The reason why this connection is closing; passed to the controller. */
uint16_t end_reason;
@@ -1737,8 +1742,6 @@
#define ORIGIN_CIRCUIT_MAGIC 0x35315243u
#define OR_CIRCUIT_MAGIC 0x98ABC04Fu
-typedef uint16_t circid_t;
-
/**
* A circuit is a path over the onion routing
* network. Applications can connect to one end of the circuit, and can
@@ -1773,7 +1776,7 @@
/** The identity hash of n_conn. */
char n_conn_id_digest[DIGEST_LEN];
/** The circuit_id used in the next (forward) hop of this circuit. */
- uint16_t n_circ_id;
+ circid_t n_circ_id;
/** The port for the OR that is next in this circuit. */
uint16_t n_port;
/** The IPv4 address of the OR that is next in this circuit. */
@@ -1874,7 +1877,7 @@
/** The next stream_id that will be tried when we're attempting to
* construct a new AP stream originating at this circuit. */
- uint16_t next_stream_id;
+ streamid_t next_stream_id;
/** Quasi-global identifier for this circuit; used for control.c */
/* XXXX NM This can get re-used after 2**32 circuits. */
@@ -2608,17 +2611,17 @@
circuit_t * _circuit_get_global_list(void);
const char *circuit_state_to_string(int state);
void circuit_dump_by_conn(connection_t *conn, int severity);
-void circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
+void circuit_set_p_circid_orconn(or_circuit_t *circ, circid_t id,
or_connection_t *conn);
-void circuit_set_n_circid_orconn(circuit_t *circ, uint16_t id,
+void circuit_set_n_circid_orconn(circuit_t *circ, circid_t id,
or_connection_t *conn);
void circuit_set_state(circuit_t *circ, uint8_t state);
void circuit_close_all_marked(void);
origin_circuit_t *origin_circuit_new(void);
-or_circuit_t *or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn);
-circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id,
+or_circuit_t *or_circuit_new(circid_t p_circ_id, or_connection_t *p_conn);
+circuit_t *circuit_get_by_circid_orconn(circid_t circ_id,
or_connection_t *conn);
-int circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn);
+int circuit_id_in_use_on_orconn(circid_t circ_id, or_connection_t *conn);
circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
void circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason);
origin_circuit_t *circuit_get_by_global_id(uint32_t id);
@@ -2845,7 +2848,7 @@
int connection_edge_reached_eof(edge_connection_t *conn);
int connection_edge_process_inbuf(edge_connection_t *conn,
int package_partial);
-int connection_edge_destroy(uint16_t circ_id, edge_connection_t *conn);
+int connection_edge_destroy(circid_t circ_id, edge_connection_t *conn);
int connection_edge_end(edge_connection_t *conn, char reason);
int connection_edge_end_errno(edge_connection_t *conn);
int connection_edge_finished_flushing(edge_connection_t *conn);
@@ -2941,7 +2944,7 @@
or_connection_t *conn);
void connection_or_write_var_cell_to_buf(const var_cell_t *cell,
or_connection_t *conn);
-int connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn,
+int connection_or_send_destroy(circid_t circ_id, or_connection_t *conn,
int reason);
int connection_or_send_netinfo(or_connection_t *conn);
int connection_or_send_cert(or_connection_t *conn);
@@ -3640,7 +3643,7 @@
void relay_header_pack(char *dest, const relay_header_t *src);
void relay_header_unpack(relay_header_t *dest, const char *src);
-int relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
+int relay_send_command_from_edge(streamid_t stream_id, circuit_t *circ,
uint8_t relay_command, const char *payload,
size_t payload_len, crypt_path_t *cpath_layer);
int connection_edge_send_command(edge_connection_t *fromconn,