This lets us remove BUFFERS_PRIVATE from two of the modules.
* 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_cell.h"
const int circ_id_len = get_circ_id_size(wide_circ_ids);
const unsigned header_len = get_var_cell_header_size(wide_circ_ids);
*out = NULL;
- if (buf->datalen < header_len)
+ if (buf_datalen(buf) < header_len)
return 0;
peek_from_buf(hdr, header_len, buf);
return 0;
length = ntohs(get_uint16(hdr + circ_id_len + 1));
- if (buf->datalen < (size_t)(header_len+length))
+ if (buf_datalen(buf) < (size_t)(header_len+length))
return 1;
result = var_cell_new(length);
result->command = command;
* 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"
int
peek_buf_has_control0_command(buf_t *buf)
{
- if (buf->datalen >= 4) {
+ if (buf_datalen(buf) >= 4) {
char header[4];
uint16_t cmd;
peek_from_buf(header, sizeof(header), buf);
crlf_offset = buf_find_string_offset(buf, "\r\n\r\n", 4);
if (crlf_offset > (int)max_headerlen ||
- (crlf_offset < 0 && buf->datalen > max_headerlen)) {
+ (crlf_offset < 0 && buf_datalen(buf) > max_headerlen)) {
log_debug(LD_HTTP,"headers too long.");
return -1;
} else if (crlf_offset < 0) {
headerlen = crlf_offset + 4;
headers = buf->head->data;
- bodylen = buf->datalen - headerlen;
+ bodylen = buf_datalen(buf) - headerlen;
log_debug(LD_HTTP,"headerlen %d, bodylen %d.", (int)headerlen, (int)bodylen);
if (max_headerlen <= headerlen) {
ssize_t n_drain;
size_t want_length = 128;
- if (buf->datalen < 2) /* version and another byte */
+ if (buf_datalen(buf) < 2) /* version and another byte */
return 0;
do {
else if (n_drain > 0)
buf_remove_from_front(buf, n_drain);
- } while (res == 0 && buf->head && want_length < buf->datalen &&
- buf->datalen >= 2);
+ } while (res == 0 && buf->head && want_length < buf_datalen(buf) &&
+ buf_datalen(buf) >= 2);
return res;
}
char hdr[EXT_OR_CMD_HEADER_SIZE];
uint16_t len;
- if (buf->datalen < EXT_OR_CMD_HEADER_SIZE)
+ if (buf_datalen(buf) < EXT_OR_CMD_HEADER_SIZE)
return 0;
peek_from_buf(hdr, sizeof(hdr), buf);
len = ntohs(get_uint16(hdr+2));
- if (buf->datalen < (unsigned)len + EXT_OR_CMD_HEADER_SIZE)
+ if (buf_datalen(buf) < (unsigned)len + EXT_OR_CMD_HEADER_SIZE)
return 0;
*out = ext_or_cmd_new(len);
(*out)->cmd = ntohs(get_uint16(hdr));
log_warn(LD_APP,"socks4: Destaddr too long. Rejecting.");
return -1;
}
- // tor_assert(next < buf->cur+buf->datalen);
+ // tor_assert(next < buf->cur+buf_datalen(buf));
if (log_sockstype)
log_notice(LD_APP,
{
ssize_t drain = 0;
int r;
- if (buf->datalen < 2)
+ if (buf_datalen(buf) < 2)
return 0;
buf_pullup(buf, MAX_SOCKS_MESSAGE_LEN);