diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-12-21 14:48:53 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-12-21 14:48:53 -0500 |
commit | 1c05dfd0b6ae9303d1f815a4d610655f32c0cc50 (patch) | |
tree | 62f8f15a06f49024c46eb4defff27c7286f82495 /src/or/channel.h | |
parent | 647a90b9b3bcec5d6cac766e6b3756d6ff1302ce (diff) | |
parent | af1469b9a3298382de39dca87b02410e829399a2 (diff) | |
download | tor-1c05dfd0b6ae9303d1f815a4d610655f32c0cc50.tar.gz tor-1c05dfd0b6ae9303d1f815a4d610655f32c0cc50.zip |
Merge branch 'ticket7356_squashed'
Diffstat (limited to 'src/or/channel.h')
-rw-r--r-- | src/or/channel.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/or/channel.h b/src/or/channel.h index 5c2a1a35e2..ec7a15f5f1 100644 --- a/src/or/channel.h +++ b/src/or/channel.h @@ -503,6 +503,39 @@ channel_t * channel_find_by_remote_digest(const char *identity_digest); channel_t * channel_next_with_digest(channel_t *chan); /* + * Helper macros to lookup state of given channel. + */ + +#define CHANNEL_IS_CLOSED(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_CLOSED)) +#define CHANNEL_IS_OPENING(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_OPENING)) +#define CHANNEL_IS_OPEN(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_OPEN)) +#define CHANNEL_IS_MAINT(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_MAINT)) +#define CHANNEL_IS_CLOSING(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_CLOSING)) +#define CHANNEL_IS_ERROR(chan) (channel_is_in_state((chan), \ + CHANNEL_STATE_ERROR)) + +#define CHANNEL_FINISHED(chan) (CHANNEL_IS_CLOSED(chan) || \ + CHANNEL_IS_ERROR(chan)) + +#define CHANNEL_CONDEMNED(chan) (CHANNEL_IS_CLOSING(chan) || \ + CHANNEL_FINISHED(chan)) + +#define CHANNEL_CAN_HANDLE_CELLS(chan) (CHANNEL_IS_OPENING(chan) || \ + CHANNEL_IS_OPEN(chan) || \ + CHANNEL_IS_MAINT(chan)) + +static INLINE int +channel_is_in_state(channel_t *chan, channel_state_t state) +{ + return chan->state == state; +} + +/* * Metadata queries/updates */ |