Expose some channel cell queue stuff to the test suite

This commit is contained in:
Andrea Shepard 2014-01-21 20:51:21 -08:00
parent 5992a69dee
commit bbb06b73cd
2 changed files with 33 additions and 27 deletions

View File

@ -13,6 +13,9 @@
#define TOR_CHANNEL_INTERNAL_
/* This one's for stuff only channel.c and the test suite should see */
#define CHANNEL_PRIVATE_
#include "or.h"
#include "channel.h"
#include "channeltls.h"
@ -31,29 +34,6 @@
#include "routerlist.h"
#include "scheduler.h"
/* Cell queue structure */
typedef struct cell_queue_entry_s cell_queue_entry_t;
struct cell_queue_entry_s {
TOR_SIMPLEQ_ENTRY(cell_queue_entry_s) next;
enum {
CELL_QUEUE_FIXED,
CELL_QUEUE_VAR,
CELL_QUEUE_PACKED
} type;
union {
struct {
cell_t *cell;
} fixed;
struct {
var_cell_t *var_cell;
} var;
struct {
packed_cell_t *packed_cell;
} packed;
} u;
};
/* Global lists of channels */
/* All channel_t instances */
@ -175,7 +155,6 @@ static cell_queue_entry_t *
cell_queue_entry_new_fixed(cell_t *cell);
static cell_queue_entry_t *
cell_queue_entry_new_var(var_cell_t *var_cell);
static int chan_cell_queue_len(const chan_cell_queue_t *queue);
static int is_destroy_cell(channel_t *chan,
const cell_queue_entry_t *q, circid_t *circid_out);
@ -1751,9 +1730,8 @@ channel_get_cell_queue_entry_size(channel_t *chan, cell_queue_entry_t *q)
rv = get_cell_network_size(chan->wide_circ_ids);
break;
case CELL_QUEUE_VAR:
tor_assert(q->u.var.var_cell);
rv = get_var_cell_header_size(chan->wide_circ_ids) +
q->u.var.var_cell->payload_len;
(q->u.var.var_cell ? q->u.var.var_cell->payload_len : 0);
break;
case CELL_QUEUE_PACKED:
rv = get_cell_network_size(chan->wide_circ_ids);
@ -3455,7 +3433,7 @@ channel_listener_describe_transport(channel_listener_t *chan_l)
/**
* Return the number of entries in <b>queue</b>
*/
static int
STATIC int
chan_cell_queue_len(const chan_cell_queue_t *queue)
{
int r = 0;

View File

@ -354,6 +354,34 @@ void channel_set_cmux_policy_everywhere(circuitmux_policy_t *pol);
#ifdef TOR_CHANNEL_INTERNAL_
#ifdef CHANNEL_PRIVATE_
/* Cell queue structure (here rather than channel.c for test suite use) */
typedef struct cell_queue_entry_s cell_queue_entry_t;
struct cell_queue_entry_s {
TOR_SIMPLEQ_ENTRY(cell_queue_entry_s) next;
enum {
CELL_QUEUE_FIXED,
CELL_QUEUE_VAR,
CELL_QUEUE_PACKED
} type;
union {
struct {
cell_t *cell;
} fixed;
struct {
var_cell_t *var_cell;
} var;
struct {
packed_cell_t *packed_cell;
} packed;
} u;
};
/* Cell queue functions for benefit of test suite */
STATIC int chan_cell_queue_len(const chan_cell_queue_t *queue);
#endif
/* Channel operations for subclasses and internal use only */
/* Initialize a newly allocated channel - do this first in subclass