tor  0.4.1.0-alpha-dev
proto_control0.c
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 #include "core/or/or.h"
8 #include "lib/buf/buffers.h"
9 #include "core/proto/proto_control0.h"
10 
13 int
14 peek_buf_has_control0_command(buf_t *buf)
15 {
16  if (buf_datalen(buf) >= 4) {
17  char header[4];
18  uint16_t cmd;
19  buf_peek(buf, header, sizeof(header));
20  cmd = ntohs(get_uint16(header+2));
21  if (cmd <= 0x14)
22  return 1; /* This is definitely not a v1 control command. */
23  }
24  return 0;
25 }
26 
void buf_peek(const buf_t *buf, char *string, size_t string_len)
Definition: buffers.c:607
Master header file for Tor-specific functionality.
static uint16_t get_uint16(const void *cp)
Definition: bytes.h:37
Header file for buffers.c.