aboutsummaryrefslogtreecommitdiff
path: root/src/or/proto_control0.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-08-08 11:51:36 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-05 13:57:51 -0400
commit234c5015f1536bc51fe5f87c5b7c1072d3f9dbd2 (patch)
treec42f7496f55bf59ab8e0103239d2eec766b95aae /src/or/proto_control0.c
parentbabe31fc7c52700ae1d04f9b95eca75459d1a8c2 (diff)
downloadtor-234c5015f1536bc51fe5f87c5b7c1072d3f9dbd2.tar.gz
tor-234c5015f1536bc51fe5f87c5b7c1072d3f9dbd2.zip
Move protocol-specific functions out of buffers.c
This commit does not change the implementation of any function: it only moves code and adds new includes as necessary. Part of #23149.
Diffstat (limited to 'src/or/proto_control0.c')
-rw-r--r--src/or/proto_control0.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/or/proto_control0.c b/src/or/proto_control0.c
new file mode 100644
index 0000000000..4c505fa6f9
--- /dev/null
+++ b/src/or/proto_control0.c
@@ -0,0 +1,27 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#define BUFFERS_PRIVATE // XXXX remove.
+#include "or.h"
+#include "buffers.h"
+#include "proto_control0.h"
+
+/** Return 1 iff buf looks more like it has an (obsolete) v0 controller
+ * command on it than any valid v1 controller command. */
+int
+peek_buf_has_control0_command(buf_t *buf)
+{
+ if (buf->datalen >= 4) {
+ char header[4];
+ uint16_t cmd;
+ peek_from_buf(header, sizeof(header), buf);
+ cmd = ntohs(get_uint16(header+2));
+ if (cmd <= 0x14)
+ return 1; /* This is definitely not a v1 control command. */
+ }
+ return 0;
+}
+