From c5b58df77588fd1307d248e75d360eb27023033c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 11 Jan 2012 10:28:20 -0500 Subject: [PATCH] Add clarity/typesafety wrappers for control_event_circuit_status_minor --- src/or/circuituse.c | 8 +++----- src/or/control.c | 32 +++++++++++++++++++++++++++++++- src/or/control.h | 8 +++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 55ec88a33f..442798dbb5 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1228,8 +1228,7 @@ circuit_launch_by_extend_info(uint8_t purpose, * began. */ tor_gettimeofday(&circ->_base.timestamp_created); - control_event_circuit_status_minor(circ, CIRC_MINOR_EVENT_CANNIBALIZED, - (int)old_purpose, + control_event_circuit_cannibalized(circ, old_purpose, &old_timestamp_created); switch (purpose) { @@ -1965,9 +1964,8 @@ circuit_change_purpose(circuit_t *circ, uint8_t new_purpose) circ->purpose = new_purpose; if (CIRCUIT_IS_ORIGIN(circ)) { - control_event_circuit_status_minor(TO_ORIGIN_CIRCUIT(circ), - CIRC_MINOR_EVENT_PURPOSE_CHANGED, - (int)old_purpose, NULL); + control_event_circuit_purpose_changed(TO_ORIGIN_CIRCUIT(circ), + old_purpose); } } diff --git a/src/or/control.c b/src/or/control.c index 9cbb8cd04d..e15adbd8e8 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3376,7 +3376,7 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp, /** Something minor has happened to circuit circ: tell any * interested control connections. */ -int +static int control_event_circuit_status_minor(origin_circuit_t *circ, circuit_status_minor_event_t e, int purpose, const struct timeval *tv) @@ -3444,6 +3444,36 @@ control_event_circuit_status_minor(origin_circuit_t *circ, return 0; } +/** + * circ has changed its purpose from old_purpose: tell any + * interested controllers. + */ +int +control_event_circuit_purpose_changed(origin_circuit_t *circ, + int old_purpose) +{ + return control_event_circuit_status_minor(circ, + CIRC_MINOR_EVENT_PURPOSE_CHANGED, + old_purpose, + NULL); +} + +/** + * circ has changed its purpose from old_purpose, and its + * created-time from old_tv_created: tell any interested controllers. + */ +int +control_event_circuit_cannibalized(origin_circuit_t *circ, + int old_purpose, + const struct timeval *old_tv_created) +{ + return control_event_circuit_status_minor(circ, + CIRC_MINOR_EVENT_CANNIBALIZED, + old_purpose, + old_tv_created); +} + + /** Given an AP connection conn and a len-character buffer * buf, determine the address:port combination requested on * conn, and write it to buf. Return 0 on success, -1 on diff --git a/src/or/control.h b/src/or/control.h index d7127f4ac0..7af4449d49 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -37,9 +37,11 @@ int control_event_is_interesting(int event); int control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t e, int reason); -int control_event_circuit_status_minor(origin_circuit_t *circ, - circuit_status_minor_event_t e, - int purpose, const struct timeval *tv); +int control_event_circuit_purpose_changed(origin_circuit_t *circ, + int old_purpose); +int control_event_circuit_cannibalized(origin_circuit_t *circ, + int old_purpose, + const struct timeval *old_tv_created); int control_event_stream_status(entry_connection_t *conn, stream_status_event_t e, int reason);