diff options
author | Andrea Shepard <andrea@torproject.org> | 2012-09-27 11:38:27 -0700 |
---|---|---|
committer | Andrea Shepard <andrea@torproject.org> | 2012-10-10 00:44:45 -0700 |
commit | 851734d3245dfd56be02f6f4a78a3b776f4ebedc (patch) | |
tree | db581fc8a6c520bd32b9ab14029301a5b777f1e7 /src/or/circuitmux.h | |
parent | 35f5259df4feacbb77b14c6da30ec137a21763bb (diff) | |
download | tor-851734d3245dfd56be02f6f4a78a3b776f4ebedc.tar.gz tor-851734d3245dfd56be02f6f4a78a3b776f4ebedc.zip |
Implement circuitmux policy basic notifications mechanism
Diffstat (limited to 'src/or/circuitmux.h')
-rw-r--r-- | src/or/circuitmux.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/or/circuitmux.h b/src/or/circuitmux.h index ade544f3b2..e344b6ed91 100644 --- a/src/or/circuitmux.h +++ b/src/or/circuitmux.h @@ -11,6 +11,57 @@ #include "or.h" +typedef struct circuitmux_policy_s circuitmux_policy_t; +typedef struct circuitmux_policy_data_s circuitmux_policy_data_t; +typedef struct circuitmux_policy_circ_data_s circuitmux_policy_circ_data_t; + +struct circuitmux_policy_s { + /* Allocate cmux-wide policy-specific data */ + circuitmux_policy_data_t * (*alloc_cmux_data)(circuitmux_t *cmux); + /* Free cmux-wide policy-specific data */ + void (*free_cmux_data)(circuitmux_t *cmux, + circuitmux_policy_data_t *pol_data); + /* Allocate circuit policy-specific data for a newly attached circuit */ + circuitmux_policy_circ_data_t * + (*alloc_circ_data)(circuitmux_t *cmux, + circuitmux_policy_data_t *pol_data, + circuit_t *circ, + cell_direction_t direction, + unsigned int cell_count); + /* Free circuit policy-specific data */ + void (*free_circ_data)(circuitmux_t *cmux, + circuitmux_policy_data_t *pol_data, + circuit_t *circ, + circuitmux_policy_circ_data_t *pol_circ_data); + /* Notify that a circuit has become active/inactive */ + void (*notify_circ_active)(circuitmux_t *cmux, + circuitmux_policy_data_t *pol_data, + circuit_t *circ, + circuitmux_policy_circ_data_t *pol_circ_data); + void (*notify_circ_inactive)(circuitmux_t *cmux, + circuitmux_policy_data_t *pol_data, + circuit_t *circ, + circuitmux_policy_circ_data_t *pol_circ_data); +}; + +/* + * Circuitmux policy implementations can subclass this to store circuitmux- + * wide data; it just has the magic number in the base struct. + */ + +struct circuitmux_policy_data_s { + uint32_t magic; +}; + +/* + * Circuitmux policy implementations can subclass this to store circuit- + * specific data; it just has the magic number in the base struct. + */ + +struct circuitmux_policy_circ_data_s { + uint32_t magic; +}; + /* Consistency check */ void circuitmux_assert_okay(circuitmux_t *cmux); @@ -19,6 +70,12 @@ circuitmux_t * circuitmux_alloc(void); void circuitmux_detach_all_circuits(circuitmux_t *cmux); void circuitmux_free(circuitmux_t *cmux); +/* Policy control */ +void circuitmux_clear_policy(circuitmux_t *cmux); +const circuitmux_policy_t * circuitmux_get_policy(circuitmux_t *cmux); +void circuitmux_set_policy(circuitmux_t *cmux, + const circuitmux_policy_t *pol); + /* Status inquiries */ cell_direction_t circuitmux_attached_circuit_direction( circuitmux_t *cmux, |