Loading src/or/buffers.c +7 −1 Original line number Diff line number Diff line Loading @@ -17,11 +17,17 @@ * and drained from functions in connection.c, trigged by events that are * monitored in main.c. **/ #define BUFFERS_PRIVATE #include "or.h" #include "orconfig.h" #include <stddef.h> #include "buffers.h" #include "compat.h" #include "compress.h" #include "util.h" #include "torint.h" #include "torlog.h" #include "tortls.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif Loading src/or/buffers.h +13 −5 Original line number Diff line number Diff line Loading @@ -12,8 +12,17 @@ #ifndef TOR_BUFFERS_H #define TOR_BUFFERS_H #include "compat.h" #include "compat.h" #include "torint.h" #include "testsupport.h" typedef struct buf_t buf_t; struct tor_tls_t; struct tor_compress_state_t; struct ext_or_cmd_t; buf_t *buf_new(void); buf_t *buf_new_with_capacity(size_t size); size_t buf_get_default_chunk_size(const buf_t *buf); Loading @@ -30,13 +39,14 @@ size_t buf_get_total_allocation(void); int read_to_buf(tor_socket_t s, size_t at_most, buf_t *buf, int *reached_eof, int *socket_error); int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf); int read_to_buf_tls(struct tor_tls_t *tls, size_t at_most, buf_t *buf); int flush_buf(tor_socket_t s, buf_t *buf, size_t sz, size_t *buf_flushlen); int flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen); int flush_buf_tls(struct tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen); int write_to_buf(const char *string, size_t string_len, buf_t *buf); int write_to_buf_compress(buf_t *buf, tor_compress_state_t *state, int write_to_buf_compress(buf_t *buf, struct tor_compress_state_t *state, const char *data, size_t data_len, int done); int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen); void peek_from_buf(char *string, size_t string_len, const buf_t *buf); Loading @@ -47,8 +57,6 @@ int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len); #define PEEK_BUF_STARTSWITH_MAX 16 int peek_buf_startswith(const buf_t *buf, const char *cmd); int fetch_ext_or_command_from_buf(buf_t *buf, ext_or_cmd_t **out); int buf_set_to_copy(buf_t **output, const buf_t *input); Loading src/or/ext_orport.c +2 −1 Original line number Diff line number Diff line Loading @@ -23,8 +23,9 @@ #include "ext_orport.h" #include "control.h" #include "config.h" #include "util.h" #include "main.h" #include "proto_ext_or.h" #include "util.h" /** Allocate and return a structure capable of holding an Extended * ORPort message of body length <b>len</b>. */ Loading src/or/include.am +2 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ LIBTOR_A_SOURCES = \ src/or/protover.c \ src/or/proto_cell.c \ src/or/proto_control0.c \ src/or/proto_ext_or.c \ src/or/proto_http.c \ src/or/proto_socks.c \ src/or/policies.c \ Loading Loading @@ -221,6 +222,7 @@ ORHEADERS = \ src/or/protover.h \ src/or/proto_cell.h \ src/or/proto_control0.h \ src/or/proto_ext_or.h \ src/or/proto_http.h \ src/or/proto_socks.h \ src/or/reasons.h \ Loading src/or/or.h +7 −7 Original line number Diff line number Diff line Loading @@ -1179,11 +1179,8 @@ typedef struct { uint16_t length; /**< How long is the payload body? */ } relay_header_t; typedef struct buf_t buf_t; typedef struct socks_request_t socks_request_t; #define buf_t buf_t typedef struct entry_port_cfg_t { /* Client port types (socks, dns, trans, natd) only: */ uint8_t isolation_flags; /**< Zero or more isolation flags */ Loading Loading @@ -1243,6 +1240,8 @@ typedef struct server_port_cfg_t { #define CONTROL_CONNECTION_MAGIC 0x8abc765du #define LISTENER_CONNECTION_MAGIC 0x1a1ac741u struct buf_t; /** Description of a connection to another host or process, and associated * data. * Loading Loading @@ -1314,8 +1313,9 @@ typedef struct connection_t { struct event *read_event; /**< Libevent event structure. */ struct event *write_event; /**< Libevent event structure. */ buf_t *inbuf; /**< Buffer holding data read over this connection. */ buf_t *outbuf; /**< Buffer holding data to write over this connection. */ struct buf_t *inbuf; /**< Buffer holding data read over this connection. */ struct buf_t *outbuf; /**< Buffer holding data to write over this * connection. */ size_t outbuf_flushlen; /**< How much data should we try to flush from the * outbuf? */ time_t timestamp_lastread; /**< When was the last time libevent said we could Loading Loading @@ -1722,11 +1722,11 @@ typedef struct entry_connection_t { /** For AP connections only: buffer for data that we have sent * optimistically, which we might need to re-send if we have to * retry this connection. */ buf_t *pending_optimistic_data; struct buf_t *pending_optimistic_data; /* For AP connections only: buffer for data that we previously sent * optimistically which we are currently re-sending as we retry this * connection. */ buf_t *sending_optimistic_data; struct buf_t *sending_optimistic_data; /** If this is a DNSPort connection, this field holds the pending DNS * request that we're going to try to answer. */ Loading Loading
src/or/buffers.c +7 −1 Original line number Diff line number Diff line Loading @@ -17,11 +17,17 @@ * and drained from functions in connection.c, trigged by events that are * monitored in main.c. **/ #define BUFFERS_PRIVATE #include "or.h" #include "orconfig.h" #include <stddef.h> #include "buffers.h" #include "compat.h" #include "compress.h" #include "util.h" #include "torint.h" #include "torlog.h" #include "tortls.h" #ifdef HAVE_UNISTD_H #include <unistd.h> #endif Loading
src/or/buffers.h +13 −5 Original line number Diff line number Diff line Loading @@ -12,8 +12,17 @@ #ifndef TOR_BUFFERS_H #define TOR_BUFFERS_H #include "compat.h" #include "compat.h" #include "torint.h" #include "testsupport.h" typedef struct buf_t buf_t; struct tor_tls_t; struct tor_compress_state_t; struct ext_or_cmd_t; buf_t *buf_new(void); buf_t *buf_new_with_capacity(size_t size); size_t buf_get_default_chunk_size(const buf_t *buf); Loading @@ -30,13 +39,14 @@ size_t buf_get_total_allocation(void); int read_to_buf(tor_socket_t s, size_t at_most, buf_t *buf, int *reached_eof, int *socket_error); int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf); int read_to_buf_tls(struct tor_tls_t *tls, size_t at_most, buf_t *buf); int flush_buf(tor_socket_t s, buf_t *buf, size_t sz, size_t *buf_flushlen); int flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen); int flush_buf_tls(struct tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen); int write_to_buf(const char *string, size_t string_len, buf_t *buf); int write_to_buf_compress(buf_t *buf, tor_compress_state_t *state, int write_to_buf_compress(buf_t *buf, struct tor_compress_state_t *state, const char *data, size_t data_len, int done); int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen); void peek_from_buf(char *string, size_t string_len, const buf_t *buf); Loading @@ -47,8 +57,6 @@ int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len); #define PEEK_BUF_STARTSWITH_MAX 16 int peek_buf_startswith(const buf_t *buf, const char *cmd); int fetch_ext_or_command_from_buf(buf_t *buf, ext_or_cmd_t **out); int buf_set_to_copy(buf_t **output, const buf_t *input); Loading
src/or/ext_orport.c +2 −1 Original line number Diff line number Diff line Loading @@ -23,8 +23,9 @@ #include "ext_orport.h" #include "control.h" #include "config.h" #include "util.h" #include "main.h" #include "proto_ext_or.h" #include "util.h" /** Allocate and return a structure capable of holding an Extended * ORPort message of body length <b>len</b>. */ Loading
src/or/include.am +2 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ LIBTOR_A_SOURCES = \ src/or/protover.c \ src/or/proto_cell.c \ src/or/proto_control0.c \ src/or/proto_ext_or.c \ src/or/proto_http.c \ src/or/proto_socks.c \ src/or/policies.c \ Loading Loading @@ -221,6 +222,7 @@ ORHEADERS = \ src/or/protover.h \ src/or/proto_cell.h \ src/or/proto_control0.h \ src/or/proto_ext_or.h \ src/or/proto_http.h \ src/or/proto_socks.h \ src/or/reasons.h \ Loading
src/or/or.h +7 −7 Original line number Diff line number Diff line Loading @@ -1179,11 +1179,8 @@ typedef struct { uint16_t length; /**< How long is the payload body? */ } relay_header_t; typedef struct buf_t buf_t; typedef struct socks_request_t socks_request_t; #define buf_t buf_t typedef struct entry_port_cfg_t { /* Client port types (socks, dns, trans, natd) only: */ uint8_t isolation_flags; /**< Zero or more isolation flags */ Loading Loading @@ -1243,6 +1240,8 @@ typedef struct server_port_cfg_t { #define CONTROL_CONNECTION_MAGIC 0x8abc765du #define LISTENER_CONNECTION_MAGIC 0x1a1ac741u struct buf_t; /** Description of a connection to another host or process, and associated * data. * Loading Loading @@ -1314,8 +1313,9 @@ typedef struct connection_t { struct event *read_event; /**< Libevent event structure. */ struct event *write_event; /**< Libevent event structure. */ buf_t *inbuf; /**< Buffer holding data read over this connection. */ buf_t *outbuf; /**< Buffer holding data to write over this connection. */ struct buf_t *inbuf; /**< Buffer holding data read over this connection. */ struct buf_t *outbuf; /**< Buffer holding data to write over this * connection. */ size_t outbuf_flushlen; /**< How much data should we try to flush from the * outbuf? */ time_t timestamp_lastread; /**< When was the last time libevent said we could Loading Loading @@ -1722,11 +1722,11 @@ typedef struct entry_connection_t { /** For AP connections only: buffer for data that we have sent * optimistically, which we might need to re-send if we have to * retry this connection. */ buf_t *pending_optimistic_data; struct buf_t *pending_optimistic_data; /* For AP connections only: buffer for data that we previously sent * optimistically which we are currently re-sending as we retry this * connection. */ buf_t *sending_optimistic_data; struct buf_t *sending_optimistic_data; /** If this is a DNSPort connection, this field holds the pending DNS * request that we're going to try to answer. */ Loading