Add clarity/typesafety wrappers for control_event_circuit_status_minor

This commit is contained in:
Nick Mathewson 2012-01-11 10:28:20 -05:00
parent 0e911abf27
commit c5b58df775
3 changed files with 39 additions and 9 deletions

View File

@ -1228,8 +1228,7 @@ circuit_launch_by_extend_info(uint8_t purpose,
* began. */ * began. */
tor_gettimeofday(&circ->_base.timestamp_created); tor_gettimeofday(&circ->_base.timestamp_created);
control_event_circuit_status_minor(circ, CIRC_MINOR_EVENT_CANNIBALIZED, control_event_circuit_cannibalized(circ, old_purpose,
(int)old_purpose,
&old_timestamp_created); &old_timestamp_created);
switch (purpose) { switch (purpose) {
@ -1965,9 +1964,8 @@ circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
circ->purpose = new_purpose; circ->purpose = new_purpose;
if (CIRCUIT_IS_ORIGIN(circ)) { if (CIRCUIT_IS_ORIGIN(circ)) {
control_event_circuit_status_minor(TO_ORIGIN_CIRCUIT(circ), control_event_circuit_purpose_changed(TO_ORIGIN_CIRCUIT(circ),
CIRC_MINOR_EVENT_PURPOSE_CHANGED, old_purpose);
(int)old_purpose, NULL);
} }
} }

View File

@ -3376,7 +3376,7 @@ control_event_circuit_status(origin_circuit_t *circ, circuit_status_event_t tp,
/** Something minor has happened to circuit <b>circ</b>: tell any /** Something minor has happened to circuit <b>circ</b>: tell any
* interested control connections. */ * interested control connections. */
int static int
control_event_circuit_status_minor(origin_circuit_t *circ, control_event_circuit_status_minor(origin_circuit_t *circ,
circuit_status_minor_event_t e, circuit_status_minor_event_t e,
int purpose, const struct timeval *tv) int purpose, const struct timeval *tv)
@ -3444,6 +3444,36 @@ control_event_circuit_status_minor(origin_circuit_t *circ,
return 0; return 0;
} }
/**
* <b>circ</b> has changed its purpose from <b>old_purpose</b>: 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);
}
/**
* <b>circ</b> has changed its purpose from <b>old_purpose</b>, and its
* created-time from <b>old_tv_created</b>: 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 <b>conn</b> and a <b>len</b>-character buffer /** Given an AP connection <b>conn</b> and a <b>len</b>-character buffer
* <b>buf</b>, determine the address:port combination requested on * <b>buf</b>, determine the address:port combination requested on
* <b>conn</b>, and write it to <b>buf</b>. Return 0 on success, -1 on * <b>conn</b>, and write it to <b>buf</b>. Return 0 on success, -1 on

View File

@ -37,9 +37,11 @@ int control_event_is_interesting(int event);
int control_event_circuit_status(origin_circuit_t *circ, int control_event_circuit_status(origin_circuit_t *circ,
circuit_status_event_t e, int reason); circuit_status_event_t e, int reason);
int control_event_circuit_status_minor(origin_circuit_t *circ, int control_event_circuit_purpose_changed(origin_circuit_t *circ,
circuit_status_minor_event_t e, int old_purpose);
int purpose, const struct timeval *tv); 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, int control_event_stream_status(entry_connection_t *conn,
stream_status_event_t e, stream_status_event_t e,
int reason); int reason);