diff options
Diffstat (limited to 'src/or/connection.h')
-rw-r--r-- | src/or/connection.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/or/connection.h b/src/or/connection.h index f38927e788..563b48cd86 100644 --- a/src/or/connection.h +++ b/src/or/connection.h @@ -12,6 +12,11 @@ #ifndef _TOR_CONNECTION_H #define _TOR_CONNECTION_H +#ifndef USE_BUFFEREVENTS +/* XXXX For buf_datalen in inline function */ +#include "buffers.h" +#endif + const char *conn_type_to_string(int type); const char *conn_state_to_string(int type, int state); @@ -73,6 +78,29 @@ connection_write_to_buf_zlib(const char *string, size_t len, _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1); } +static size_t connection_get_inbuf_len(connection_t *conn); +static size_t connection_get_outbuf_len(connection_t *conn); + +static INLINE size_t +connection_get_inbuf_len(connection_t *conn) +{ + IF_HAS_BUFFEREVENT(conn, { + return evbuffer_get_length(bufferevent_get_input(conn->bufev)); + }) ELSE_IF_NO_BUFFEREVENT { + return buf_datalen(conn->inbuf); + } +} + +static INLINE size_t +connection_get_outbuf_len(connection_t *conn) +{ + IF_HAS_BUFFEREVENT(conn, { + return evbuffer_get_length(bufferevent_get_output(conn->bufev)); + }) ELSE_IF_NO_BUFFEREVENT { + return buf_datalen(conn->outbuf); + } +} + connection_t *connection_get_by_global_id(uint64_t id); connection_t *connection_get_by_type(int type); |