mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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. svn:r16155
This commit is contained in:
@@ -69,12 +69,12 @@ static time_t start_of_month(time_t when);
|
||||
*
|
||||
* 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 @@ circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type,
|
||||
const char *payload)
|
||||
{
|
||||
cell_t cell;
|
||||
uint16_t id;
|
||||
circid_t id;
|
||||
|
||||
tor_assert(circ);
|
||||
tor_assert(circ->n_conn);
|
||||
|
||||
+10
-10
@@ -34,7 +34,7 @@ static void circuit_free_cpath_node(crypt_path_t *victim);
|
||||
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 @@ _orconn_circid_entries_eq(orconn_circid_circuit_map_t *a,
|
||||
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 @@ orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL;
|
||||
* 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 @@ circuit_set_circid_orconn_helper(circuit_t *circ, int direction,
|
||||
* 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 @@ circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
|
||||
* 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 @@ origin_circuit_new(void)
|
||||
/** 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 @@ circuit_get_by_global_id(uint32_t id)
|
||||
* 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 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, or_connection_t *conn)
|
||||
* 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 @@ circuit_get_by_circid_orconn(uint16_t circ_id, or_connection_t *conn)
|
||||
/** 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;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
|
||||
* 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 @@ connection_ap_process_natd(edge_connection_t *conn)
|
||||
/** 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:
|
||||
|
||||
@@ -1016,7 +1016,7 @@ connection_or_process_cells_from_inbuf(or_connection_t *conn)
|
||||
* 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;
|
||||
|
||||
|
||||
+3
-3
@@ -63,7 +63,7 @@ connection_cpu_finished_flushing(connection_t *conn)
|
||||
/** 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 @@ tag_pack(char *tag, uint32_t addr, uint16_t port, uint16_t circ_id)
|
||||
/** 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 @@ connection_cpu_process_inbuf(connection_t *conn)
|
||||
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;
|
||||
|
||||
|
||||
+21
-18
@@ -717,10 +717,15 @@ typedef enum {
|
||||
/** 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 @@ typedef struct cell_t {
|
||||
/** 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 cell_queue_t {
|
||||
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 @@ typedef struct or_connection_t {
|
||||
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 @@ typedef struct edge_connection_t {
|
||||
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 @@ typedef struct {
|
||||
#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 @@ typedef struct circuit_t {
|
||||
/** 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 @@ typedef struct origin_circuit_t {
|
||||
|
||||
/** 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 @@ void entry_guards_free_all(void);
|
||||
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 @@ void _connection_mark_unattached_ap(edge_connection_t *conn, int endreason,
|
||||
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 @@ void connection_or_write_cell_to_buf(const cell_t *cell,
|
||||
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 @@ int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user