aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-08-09 11:40:28 -0700
committerNick Mathewson <nickm@torproject.org>2010-09-27 12:31:13 -0400
commitddcb59bb70457e203247931aaad3a3ff8b923f97 (patch)
tree803eac2d836936d44043b7793f4e6706208504cd /src/or/buffers.c
parent5279036148ca158f7c60f793f401604060b1c1ba (diff)
downloadtor-ddcb59bb70457e203247931aaad3a3ff8b923f97.tar.gz
tor-ddcb59bb70457e203247931aaad3a3ff8b923f97.zip
Fix more remaining users of inbuf/outbuf to handle bufferevents instead.
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 374c37c860..9fde8972b1 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1988,6 +1988,27 @@ peek_buf_has_control0_command(buf_t *buf)
return 0;
}
+#ifdef USE_BUFFEREVENTS
+int
+peek_evbuffer_has_control0_command(struct evbuffer *buf)
+{
+ int result = 0;
+ if (evbuffer_get_length(buf) >= 4) {
+ int free_out = 0;
+ char *data = NULL;
+ size_t n = inspect_evbuffer(buf, &data, 4, &free_out);
+ uint16_t cmd;
+ tor_assert(n >= 4);
+ cmd = ntohs(get_uint16(data+2));
+ if (cmd <= 0x14)
+ result = 1;
+ if (free_out)
+ tor_free(data);
+ }
+ return result;
+}
+#endif
+
/** Return the index within <b>buf</b> at which <b>ch</b> first appears,
* or -1 if <b>ch</b> does not appear on buf. */
static off_t