This is a massive rename. We'll then split channel and buffer.
This change needs a lot of cleanups. At many locations, the parameter
or variable is still called "buf" which will become ambiguous. Also,
the "struct channel" is still defined in buffers.h.
int srv_redispatch_connect(struct session *t);
const char *backend_lb_algo_str(int algo);
int backend_parse_balance(const char **args, char **err, struct proxy *curproxy);
-int tcp_persist_rdp_cookie(struct session *s, struct buffer *req, int an_bit);
+int tcp_persist_rdp_cookie(struct session *s, struct channel *req, int an_bit);
int be_downtime(struct proxy *px);
void recount_servers(struct proxy *px);
int init_buffer();
/* SI-to-buffer functions : buffer_{get,put}_{char,block,string,chunk} */
-int bo_inject(struct buffer *buf, const char *msg, int len);
-int bi_putblk(struct buffer *buf, const char *str, int len);
-int bi_putchr(struct buffer *buf, char c);
-int bo_getline(struct buffer *buf, char *str, int len);
-int bo_getblk(struct buffer *buf, char *blk, int len, int offset);
-int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len);
-int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
-void buffer_dump(FILE *o, struct buffer *b, int from, int to);
-void buffer_slow_realign(struct buffer *buf);
-void buffer_bounce_realign(struct buffer *buf);
-unsigned long long buffer_forward(struct buffer *buf, unsigned long long bytes);
+int bo_inject(struct channel *buf, const char *msg, int len);
+int bi_putblk(struct channel *buf, const char *str, int len);
+int bi_putchr(struct channel *buf, char c);
+int bo_getline(struct channel *buf, char *str, int len);
+int bo_getblk(struct channel *buf, char *blk, int len, int offset);
+int buffer_replace2(struct channel *b, char *pos, char *end, const char *str, int len);
+int buffer_insert_line2(struct channel *b, char *pos, const char *str, int len);
+void buffer_dump(FILE *o, struct channel *b, int from, int to);
+void buffer_slow_realign(struct channel *buf);
+void buffer_bounce_realign(struct channel *buf);
+unsigned long long buffer_forward(struct channel *buf, unsigned long long bytes);
/* Initialize all fields in the buffer. The BF_OUT_EMPTY flags is set. */
-static inline void buffer_init(struct buffer *buf)
+static inline void buffer_init(struct channel *buf)
{
buf->o = 0;
buf->i = 0;
})
/* Returns the start of the input data in a buffer */
-static inline char *bi_ptr(const struct buffer *b)
+static inline char *bi_ptr(const struct channel *b)
{
return b->p;
}
/* Returns the end of the input data in a buffer (pointer to next
* insertion point).
*/
-static inline char *bi_end(const struct buffer *b)
+static inline char *bi_end(const struct channel *b)
{
char *ret = b->p + b->i;
}
/* Returns the amount of input data that can contiguously be read at once */
-static inline int bi_contig_data(const struct buffer *b)
+static inline int bi_contig_data(const struct channel *b)
{
int data = b->data + b->size - b->p;
}
/* Returns the start of the output data in a buffer */
-static inline char *bo_ptr(const struct buffer *b)
+static inline char *bo_ptr(const struct channel *b)
{
char *ret = b->p - b->o;
}
/* Returns the end of the output data in a buffer */
-static inline char *bo_end(const struct buffer *b)
+static inline char *bo_end(const struct channel *b)
{
return b->p;
}
/* Returns the amount of output data that can contiguously be read at once */
-static inline int bo_contig_data(const struct buffer *b)
+static inline int bo_contig_data(const struct channel *b)
{
char *beg = b->p - b->o;
}
/* Return the buffer's length in bytes by summing the input and the output */
-static inline int buffer_len(const struct buffer *buf)
+static inline int buffer_len(const struct channel *buf)
{
return buf->i + buf->o;
}
/* Return non-zero only if the buffer is not empty */
-static inline int buffer_not_empty(const struct buffer *buf)
+static inline int buffer_not_empty(const struct channel *buf)
{
return buf->i | buf->o;
}
/* Return non-zero only if the buffer is empty */
-static inline int buffer_empty(const struct buffer *buf)
+static inline int buffer_empty(const struct channel *buf)
{
return !buffer_not_empty(buf);
}
/* Normalizes a pointer after a subtract */
-static inline char *buffer_wrap_sub(const struct buffer *buf, char *ptr)
+static inline char *buffer_wrap_sub(const struct channel *buf, char *ptr)
{
if (ptr < buf->data)
ptr += buf->size;
}
/* Normalizes a pointer after an addition */
-static inline char *buffer_wrap_add(const struct buffer *buf, char *ptr)
+static inline char *buffer_wrap_add(const struct channel *buf, char *ptr)
{
if (ptr - buf->size >= buf->data)
ptr -= buf->size;
* bytes free. The result is between 0 and global.maxrewrite, which is itself
* smaller than any buf->size.
*/
-static inline int buffer_reserved(const struct buffer *buf)
+static inline int buffer_reserved(const struct channel *buf)
{
int ret = global.tune.maxrewrite - buf->to_forward - buf->o;
* pending bytes are forwarded, the buffer still has global.tune.maxrewrite
* bytes free. The result sits between buf->size - maxrewrite and buf->size.
*/
-static inline int buffer_max_len(const struct buffer *buf)
+static inline int buffer_max_len(const struct channel *buf)
{
return buf->size - buffer_reserved(buf);
}
* close to happen. The test is optimized to avoid as many operations as
* possible for the fast case and to be used as an "if" condition.
*/
-static inline int bi_full(const struct buffer *b)
+static inline int bi_full(const struct channel *b)
{
int rem = b->size;
* is close to happen. The test is optimized to avoid as many operations as
* possible for the fast case.
*/
-static inline int bi_avail(const struct buffer *b)
+static inline int bi_avail(const struct channel *b)
{
int rem = b->size;
int rem2;
/* Return the maximum amount of bytes that can be written into the buffer,
* including reserved space which may be overwritten.
*/
-static inline int buffer_total_space(const struct buffer *buf)
+static inline int buffer_total_space(const struct channel *buf)
{
return buf->size - buffer_len(buf);
}
* and enforces a limit on buf->data + buf->size. <start> must be within the
* buffer.
*/
-static inline int buffer_contig_area(const struct buffer *buf, const char *start, int count)
+static inline int buffer_contig_area(const struct channel *buf, const char *start, int count)
{
if (count > buf->data - start + buf->size)
count = buf->data - start + buf->size;
/* Return the amount of bytes that can be written into the buffer at once,
* including reserved space which may be overwritten.
*/
-static inline int buffer_contig_space(const struct buffer *buf)
+static inline int buffer_contig_space(const struct channel *buf)
{
const char *left, *right;
* to out. The caller is responsible for ensuring that adv is always
* smaller than or equal to b->i. The BF_OUT_EMPTY flag is updated.
*/
-static inline void b_adv(struct buffer *b, unsigned int adv)
+static inline void b_adv(struct channel *b, unsigned int adv)
{
b->i -= adv;
b->o += adv;
* backwards, and that as many bytes from out are moved to in. The caller is
* responsible for ensuring that adv is always smaller than or equal to b->o.
*/
-static inline void b_rew(struct buffer *b, unsigned int adv)
+static inline void b_rew(struct channel *b, unsigned int adv)
{
b->i += adv;
b->o -= adv;
* excluding the amount of reserved space passed in <res>, which is
* preserved.
*/
-static inline int buffer_contig_space_with_res(const struct buffer *buf, int res)
+static inline int buffer_contig_space_with_res(const struct channel *buf, int res)
{
/* Proceed differently if the buffer is full, partially used or empty.
* The hard situation is when it's partially used and either data or
/* Return the amount of bytes that can be written into the buffer at once,
* excluding reserved space, which is preserved.
*/
-static inline int buffer_contig_space_res(const struct buffer *buf)
+static inline int buffer_contig_space_res(const struct channel *buf)
{
return buffer_contig_space_with_res(buf, buffer_reserved(buf));
}
* once, so the original pointer must be between ->data-size and ->data+2*size-1,
* otherwise an invalid pointer might be returned.
*/
-static inline const char *buffer_pointer(const struct buffer *buf, const char *ptr)
+static inline const char *buffer_pointer(const struct channel *buf, const char *ptr)
{
if (ptr < buf->data)
ptr += buf->size;
/* Returns the distance between two pointers, taking into account the ability
* to wrap around the buffer's end.
*/
-static inline int buffer_count(const struct buffer *buf, const char *from, const char *to)
+static inline int buffer_count(const struct channel *buf, const char *from, const char *to)
{
int count = to - from;
if (count < 0)
/* returns the amount of pending bytes in the buffer. It is the amount of bytes
* that is not scheduled to be sent.
*/
-static inline int buffer_pending(const struct buffer *buf)
+static inline int buffer_pending(const struct channel *buf)
{
return buf->i;
}
* <end>. It always starts at buf->p. The work area includes the
* reserved area.
*/
-static inline int buffer_work_area(const struct buffer *buf, const char *end)
+static inline int buffer_work_area(const struct channel *buf, const char *end)
{
end = buffer_pointer(buf, end);
if (end == buffer_wrap_add(buf, buf->p + buf->i))
}
/* Return 1 if the buffer has less than 1/4 of its capacity free, otherwise 0 */
-static inline int buffer_almost_full(const struct buffer *buf)
+static inline int buffer_almost_full(const struct channel *buf)
{
if (buffer_total_space(buf) < buf->size / 4)
return 1;
}
/* Returns true if the buffer's input is already closed */
-static inline int buffer_input_closed(struct buffer *buf)
+static inline int buffer_input_closed(struct channel *buf)
{
return ((buf->flags & BF_SHUTR) != 0);
}
/* Returns true if the buffer's output is already closed */
-static inline int buffer_output_closed(struct buffer *buf)
+static inline int buffer_output_closed(struct channel *buf)
{
return ((buf->flags & BF_SHUTW) != 0);
}
* That way, we don't have to update the timeout on every I/O. Note that the
* analyser timeout is always checked.
*/
-static inline void buffer_check_timeouts(struct buffer *b)
+static inline void buffer_check_timeouts(struct channel *b)
{
if (likely(!(b->flags & (BF_SHUTR|BF_READ_TIMEOUT|BF_READ_ACTIVITY|BF_READ_NOEXP))) &&
unlikely(tick_is_expired(b->rex, now_ms)))
* already covers those data. That permits doing a flush even after a forward,
* although not recommended.
*/
-static inline void buffer_flush(struct buffer *buf)
+static inline void buffer_flush(struct channel *buf)
{
buf->p = buffer_wrap_add(buf, buf->p + buf->i);
buf->o += buf->i;
* that any spliced data is not affected since we may not have any access to
* it.
*/
-static inline void buffer_erase(struct buffer *buf)
+static inline void buffer_erase(struct channel *buf)
{
buf->o = 0;
buf->i = 0;
* stopped. This is mainly to be used to send error messages after existing
* data.
*/
-static inline void bi_erase(struct buffer *buf)
+static inline void bi_erase(struct channel *buf)
{
if (!buf->o)
return buffer_erase(buf);
* This is mainly used to remove empty lines at the beginning of a request
* or a response.
*/
-static inline void bi_fast_delete(struct buffer *buf, int n)
+static inline void bi_fast_delete(struct channel *buf, int n)
{
buf->i -= n;
buf->p += n;
}
/* marks the buffer as "shutdown" ASAP for reads */
-static inline void buffer_shutr_now(struct buffer *buf)
+static inline void buffer_shutr_now(struct channel *buf)
{
buf->flags |= BF_SHUTR_NOW;
}
/* marks the buffer as "shutdown" ASAP for writes */
-static inline void buffer_shutw_now(struct buffer *buf)
+static inline void buffer_shutw_now(struct channel *buf)
{
buf->flags |= BF_SHUTW_NOW;
}
/* marks the buffer as "shutdown" ASAP in both directions */
-static inline void buffer_abort(struct buffer *buf)
+static inline void buffer_abort(struct channel *buf)
{
buf->flags |= BF_SHUTR_NOW | BF_SHUTW_NOW;
buf->flags &= ~BF_AUTO_CONNECT;
* during this first call.
*/
static inline void buffer_install_hijacker(struct session *s,
- struct buffer *b,
- void (*func)(struct session *, struct buffer *))
+ struct channel *b,
+ void (*func)(struct session *, struct channel *))
{
b->hijacker = func;
b->flags |= BF_HIJACK;
}
/* Releases the buffer from hijacking mode. Often used by the hijack function */
-static inline void buffer_stop_hijack(struct buffer *buf)
+static inline void buffer_stop_hijack(struct channel *buf)
{
buf->flags &= ~BF_HIJACK;
}
/* allow the consumer to try to establish a new connection. */
-static inline void buffer_auto_connect(struct buffer *buf)
+static inline void buffer_auto_connect(struct channel *buf)
{
buf->flags |= BF_AUTO_CONNECT;
}
/* prevent the consumer from trying to establish a new connection, and also
* disable auto shutdown forwarding.
*/
-static inline void buffer_dont_connect(struct buffer *buf)
+static inline void buffer_dont_connect(struct channel *buf)
{
buf->flags &= ~(BF_AUTO_CONNECT|BF_AUTO_CLOSE);
}
/* allow the producer to forward shutdown requests */
-static inline void buffer_auto_close(struct buffer *buf)
+static inline void buffer_auto_close(struct channel *buf)
{
buf->flags |= BF_AUTO_CLOSE;
}
/* prevent the producer from forwarding shutdown requests */
-static inline void buffer_dont_close(struct buffer *buf)
+static inline void buffer_dont_close(struct channel *buf)
{
buf->flags &= ~BF_AUTO_CLOSE;
}
/* allow the producer to read / poll the input */
-static inline void buffer_auto_read(struct buffer *buf)
+static inline void buffer_auto_read(struct channel *buf)
{
buf->flags &= ~BF_DONT_READ;
}
/* prevent the producer from read / poll the input */
-static inline void buffer_dont_read(struct buffer *buf)
+static inline void buffer_dont_read(struct channel *buf)
{
buf->flags |= BF_DONT_READ;
}
* Tries to realign the given buffer, and returns how many bytes can be written
* there at once without overwriting anything.
*/
-static inline int buffer_realign(struct buffer *buf)
+static inline int buffer_realign(struct channel *buf)
{
if (!(buf->i | buf->o)) {
/* let's realign the buffer to optimize I/O */
* with <len> causing a wrapping at the end of the buffer. It's the caller's
* responsibility to ensure that <len> is never larger than buf->o.
*/
-static inline void bo_skip(struct buffer *buf, int len)
+static inline void bo_skip(struct channel *buf, int len)
{
buf->o -= len;
if (!buf->o && !buf->pipe)
* Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
* transferred. The chunk's length is updated with the number of bytes sent.
*/
-static inline int bi_putchk(struct buffer *buf, struct chunk *chunk)
+static inline int bi_putchk(struct channel *buf, struct chunk *chunk)
{
int ret;
* Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
* transferred.
*/
-static inline int bi_putstr(struct buffer *buf, const char *str)
+static inline int bi_putstr(struct channel *buf, const char *str)
{
return bi_putblk(buf, str, strlen(str));
}
* it's up to the caller to call bo_skip(buf, 1) when it has consumed the char.
* Also note that this function respects the ->o limit.
*/
-static inline int bo_getchr(struct buffer *buf)
+static inline int bo_getchr(struct channel *buf)
{
/* closed or empty + imminent close = -2; empty = -1 */
if (unlikely(buf->flags & (BF_OUT_EMPTY|BF_SHUTW))) {
* not done. The function does not adjust ->o nor BF_OUT_EMPTY because
* it does not make sense to use it on data scheduled to be sent.
*/
-static inline int buffer_replace(struct buffer *b, char *pos, char *end, const char *str)
+static inline int buffer_replace(struct channel *b, char *pos, char *end, const char *str)
{
return buffer_replace2(b, pos, end, str, strlen(str));
}
#include <types/session.h>
int frontend_accept(struct session *s);
-int frontend_decode_proxy_request(struct session *s, struct buffer *req, int an_bit);
+int frontend_decode_proxy_request(struct session *s, struct channel *req, int an_bit);
int make_proxy_line(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst);
int process_cli(struct session *t);
int process_srv_data(struct session *t);
int process_srv_conn(struct session *t);
-int http_wait_for_request(struct session *s, struct buffer *req, int an_bit);
-int http_process_req_common(struct session *s, struct buffer *req, int an_bit, struct proxy *px);
-int http_process_request(struct session *t, struct buffer *req, int an_bit);
-int http_process_tarpit(struct session *s, struct buffer *req, int an_bit);
-int http_process_request_body(struct session *s, struct buffer *req, int an_bit);
+int http_wait_for_request(struct session *s, struct channel *req, int an_bit);
+int http_process_req_common(struct session *s, struct channel *req, int an_bit, struct proxy *px);
+int http_process_request(struct session *t, struct channel *req, int an_bit);
+int http_process_tarpit(struct session *s, struct channel *req, int an_bit);
+int http_process_request_body(struct session *s, struct channel *req, int an_bit);
int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* svr_name);
-int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit);
-int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, struct proxy *px);
-int http_request_forward_body(struct session *s, struct buffer *req, int an_bit);
-int http_response_forward_body(struct session *s, struct buffer *res, int an_bit);
+int http_wait_for_response(struct session *s, struct channel *rep, int an_bit);
+int http_process_res_common(struct session *t, struct channel *rep, int an_bit, struct proxy *px);
+int http_request_forward_body(struct session *s, struct channel *req, int an_bit);
+int http_response_forward_body(struct session *s, struct channel *res, int an_bit);
void debug_hdr(const char *dir, struct session *t, const char *start, const char *end);
void get_srv_from_appsession(struct session *t, const char *begin, int len);
-int apply_filter_to_req_headers(struct session *t, struct buffer *req, struct hdr_exp *exp);
-int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_exp *exp);
-int apply_filters_to_request(struct session *s, struct buffer *req, struct proxy *px);
-int apply_filters_to_response(struct session *t, struct buffer *rtr, struct proxy *px);
+int apply_filter_to_req_headers(struct session *t, struct channel *req, struct hdr_exp *exp);
+int apply_filter_to_req_line(struct session *t, struct channel *req, struct hdr_exp *exp);
+int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px);
+int apply_filters_to_response(struct session *t, struct channel *rtr, struct proxy *px);
void manage_client_side_appsession(struct session *t, const char *buf, int len);
-void manage_client_side_cookies(struct session *t, struct buffer *req);
-void manage_server_side_cookies(struct session *t, struct buffer *rtr);
-void check_response_for_cacheability(struct session *t, struct buffer *rtr);
+void manage_client_side_cookies(struct session *t, struct channel *req);
+void manage_server_side_cookies(struct session *t, struct channel *rtr);
+void check_response_for_cacheability(struct session *t, struct channel *rtr);
int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
void init_proto_http();
int http_find_header2(const char *name, int len,
int tcp_connect_probe(struct connection *conn);
int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
-int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit);
-int tcp_inspect_response(struct session *s, struct buffer *rep, int an_bit);
+int tcp_inspect_request(struct session *s, struct channel *req, int an_bit);
+int tcp_inspect_response(struct session *s, struct channel *rep, int an_bit);
int tcp_exec_req_rules(struct session *s);
int smp_fetch_rdp_cookie(struct proxy *px, struct session *l4, void *l7, unsigned int opt, const struct arg *args, struct sample *smp);
#include <types/stream_interface.h>
/* The BF_* macros designate Buffer Flags, which may be ORed in the bit field
- * member 'flags' in struct buffer. Here we have several types of flags :
+ * member 'flags' in struct channel. Here we have several types of flags :
*
* - pure status flags, reported by the lower layer, which must be cleared
* before doing further I/O :
/* needed for a declaration below */
struct session;
-struct buffer {
+struct channel {
unsigned int flags; /* BF_* */
int rex; /* expiration date for a read, in ticks */
int wex; /* expiration date for a write or connect, in ticks */
unsigned int to_forward; /* number of bytes to forward after out without a wake-up */
unsigned int analysers; /* bit field indicating what to do on the buffer */
int analyse_exp; /* expiration date for current analysers (if set) */
- void (*hijacker)(struct session *, struct buffer *); /* alternative content producer */
+ void (*hijacker)(struct session *, struct channel *); /* alternative content producer */
unsigned char xfer_large; /* number of consecutive large xfers */
unsigned char xfer_small; /* number of consecutive small xfers */
unsigned long long total; /* total data read */
struct http_msg {
unsigned int msg_state; /* where we are in the current message parsing */
unsigned int flags; /* flags describing the message (HTTP version, ...) */
- struct buffer *buf; /* pointer to the buffer which holds the message */
+ struct channel *buf; /* pointer to the buffer which holds the message */
unsigned int next; /* pointer to next byte to parse, relative to buf->p */
unsigned int sov; /* current header: start of value */
unsigned int eoh; /* End Of Headers, relative to buffer */
struct proxy *be; /* the proxy this session depends on for the server side */
int flags; /* some flags describing the session */
unsigned term_trace; /* term trace: 4*8 bits indicating which part of the code closed */
- struct buffer *req; /* request buffer */
- struct buffer *rep; /* response buffer */
+ struct channel *req; /* request buffer */
+ struct channel *rep; /* response buffer */
struct stream_interface si[2]; /* client and server stream interfaces */
struct server *srv_conn; /* session already has a slot on a server and is not in queue */
struct target target; /* target to use for this session */
unsigned int state; /* SI_ST* */
unsigned int prev_state;/* SI_ST*, copy of previous state */
unsigned int flags; /* SI_FL_* */
- struct buffer *ib, *ob; /* input and output buffers */
+ struct channel *ib, *ob; /* input and output buffers */
unsigned int exp; /* wake up time for connect, queue, turn-around, ... */
void *owner; /* generally a (struct task*) */
unsigned int err_type; /* first error detected, one of SI_ET_* */
{
int hs_len;
int hs_type, bleft;
- struct buffer *b;
+ struct channel *b;
const unsigned char *data;
if (!l4)
const struct arg *args, struct sample *smp)
{
int hs_len, ext_len, bleft;
- struct buffer *b;
+ struct channel *b;
unsigned char *data;
if (!l4)
{
unsigned long hash = 0;
struct http_txn *txn = &s->txn;
- struct buffer *req = s->req;
+ struct channel *req = s->req;
struct http_msg *msg = &txn->req;
struct proxy *px = s->be;
unsigned int plen = px->url_param_len;
* session. This always returns 1, and the analyser removes itself from the
* list. Nothing is performed if a server was already assigned.
*/
-int tcp_persist_rdp_cookie(struct session *s, struct buffer *req, int an_bit)
+int tcp_persist_rdp_cookie(struct session *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
int ret;
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
int init_buffer()
{
- pool2_buffer = create_pool("buffer", sizeof(struct buffer) + global.tune.bufsize, MEM_F_SHARED);
+ pool2_buffer = create_pool("buffer", sizeof(struct channel) + global.tune.bufsize, MEM_F_SHARED);
return pool2_buffer != NULL;
}
* Directly touching ->to_forward will cause lockups when ->o goes down to
* zero if nobody is ready to push the remaining data.
*/
-unsigned long long buffer_forward(struct buffer *buf, unsigned long long bytes)
+unsigned long long buffer_forward(struct channel *buf, unsigned long long bytes)
{
unsigned int new_forward;
unsigned int forwarded;
* Note: this function appends data to the buffer's output and possibly overwrites
* any pending input data which are assumed not to exist.
*/
-int bo_inject(struct buffer *buf, const char *msg, int len)
+int bo_inject(struct channel *buf, const char *msg, int len)
{
int max;
* flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
* transferred.
*/
-int bi_putchr(struct buffer *buf, char c)
+int bi_putchr(struct channel *buf, char c)
{
if (unlikely(buffer_input_closed(buf)))
return -2;
* Buffer flags FULL, EMPTY and READ_PARTIAL are updated if some data can be
* transferred.
*/
-int bi_putblk(struct buffer *buf, const char *blk, int len)
+int bi_putblk(struct channel *buf, const char *blk, int len)
{
int max;
* output are full. If either of them is full, the string may be returned
* as is, without the '\n'.
*/
-int bo_getline(struct buffer *buf, char *str, int len)
+int bo_getline(struct channel *buf, char *str, int len)
{
int ret, max;
char *p;
* The buffer status is not changed. The caller must call bo_skip() to
* update it.
*/
-int bo_getblk(struct buffer *buf, char *blk, int len, int offset)
+int bo_getblk(struct channel *buf, char *blk, int len, int offset)
{
int firstblock;
* <orig> is not updated. The string length is taken from parameter <len>. If
* <len> is null, the <str> pointer is allowed to be null.
*/
-int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len)
+int buffer_replace2(struct channel *b, char *pos, char *end, const char *str, int len)
{
int delta;
*
* The number of bytes added is returned on success. 0 is returned on failure.
*/
-int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
+int buffer_insert_line2(struct channel *b, char *pos, const char *str, int len)
{
int delta;
* becomes contiguous and starts at the beginning of the buffer area. The
* function may only be used when the buffer's output is empty.
*/
-void buffer_slow_realign(struct buffer *buf)
+void buffer_slow_realign(struct channel *buf)
{
/* two possible cases :
* - the buffer is in one contiguous block, we move it in-place
* so it's desirable to use it only on non-contiguous buffers. No pointers are
* changed, the caller is responsible for that.
*/
-void buffer_bounce_realign(struct buffer *buf)
+void buffer_bounce_realign(struct channel *buf)
{
int advance, to_move;
char *from, *to;
/*
* Dumps part or all of a buffer.
*/
-void buffer_dump(FILE *o, struct buffer *b, int from, int to)
+void buffer_dump(FILE *o, struct channel *b, int from, int to)
{
fprintf(o, "Dumping buffer %p\n", b);
fprintf(o, " data=%p o=%d i=%d p=%p\n",
*/
static void cli_io_handler(struct stream_interface *si)
{
- struct buffer *req = si->ob;
- struct buffer *res = si->ib;
+ struct channel *req = si->ob;
+ struct channel *res = si->ib;
int reql;
int len;
static void http_stats_io_handler(struct stream_interface *si)
{
struct session *s = si->conn.data_ctx;
- struct buffer *req = si->ob;
- struct buffer *res = si->ib;
+ struct channel *req = si->ob;
+ struct channel *res = si->ib;
if (unlikely(si->state == SI_ST_DIS || si->state == SI_ST_CLO))
goto out;
static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
{
struct session *s = si->conn.data_ctx;
- struct buffer *rep = si->ib;
+ struct channel *rep = si->ib;
struct proxy *px;
struct chunk msg;
unsigned int up;
static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struct uri_auth *uri)
{
struct session *s = si->conn.data_ctx;
- struct buffer *rep = si->ib;
+ struct channel *rep = si->ib;
struct server *sv, *svs; /* server and server-state, server-state=server or server->track */
struct listener *l;
struct chunk msg;
* are removed from the buffer. The function returns zero if it needs to wait
* for more data (max: timeout_client), or 1 if it has finished and removed itself.
*/
-int frontend_decode_proxy_request(struct session *s, struct buffer *req, int an_bit)
+int frontend_decode_proxy_request(struct session *s, struct channel *req, int an_bit)
{
char *line = req->data;
char *end = req->data + req->i;
{
unsigned int state; /* updated only when leaving the FSM */
register char *ptr, *end; /* request pointers, to avoid dereferences */
- struct buffer *buf = msg->buf;
+ struct channel *buf = msg->buf;
state = msg->msg_state;
ptr = buf->p + msg->next;
*/
int http_parse_chunk_size(struct http_msg *msg)
{
- const struct buffer *buf = msg->buf;
+ const struct channel *buf = msg->buf;
const char *ptr = b_ptr(buf, msg->next);
const char *ptr_old = ptr;
const char *end = buf->data + buf->size;
*/
int http_forward_trailers(struct http_msg *msg)
{
- const struct buffer *buf = msg->buf;
+ const struct channel *buf = msg->buf;
/* we have msg->next which points to next line. Look for CRLF. */
while (1) {
*/
int http_skip_chunk_crlf(struct http_msg *msg)
{
- const struct buffer *buf = msg->buf;
+ const struct channel *buf = msg->buf;
const char *ptr;
int bytes;
* when it has nothing left to do, and may remove any analyser when it wants to
* abort.
*/
-int http_wait_for_request(struct session *s, struct buffer *req, int an_bit)
+int http_wait_for_request(struct session *s, struct channel *req, int an_bit)
{
/*
* We will parse the partial (or complete) lines.
* Parse the posted data and enable/disable servers if necessary.
* Returns 1 if request was parsed or zero if it needs more data.
*/
-int http_process_req_stat_post(struct stream_interface *si, struct http_txn *txn, struct buffer *req)
+int http_process_req_stat_post(struct stream_interface *si, struct http_txn *txn, struct channel *req)
{
struct proxy *px = NULL;
struct server *sv = NULL;
* either needs more data or wants to immediately abort the request (eg: deny,
* error, ...).
*/
-int http_process_req_common(struct session *s, struct buffer *req, int an_bit, struct proxy *px)
+int http_process_req_common(struct session *s, struct channel *req, int an_bit, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->req;
* needs more data, encounters an error, or wants to immediately abort the
* request. It relies on buffers flags, and updates s->req->analysers.
*/
-int http_process_request(struct session *s, struct buffer *req, int an_bit)
+int http_process_request(struct session *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->req;
* returns zero, at the beginning because it prevents any other processing
* from occurring, and at the end because it terminates the request.
*/
-int http_process_tarpit(struct session *s, struct buffer *req, int an_bit)
+int http_process_tarpit(struct session *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
* because it expects the request to be parsed. It returns zero if it needs to
* read more data, or 1 once it has completed its analysis.
*/
-int http_process_request_body(struct session *s, struct buffer *req, int an_bit)
+int http_process_request_body(struct session *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.req;
char *hdr_name = be->server_id_hdr_name;
int hdr_name_len = be->server_id_hdr_len;
- struct buffer *req = txn->req.buf;
+ struct channel *req = txn->req.buf;
char *hdr_val;
unsigned int old_o, old_i;
*/
int http_sync_req_state(struct session *s)
{
- struct buffer *buf = s->req;
+ struct channel *buf = s->req;
struct http_txn *txn = &s->txn;
unsigned int old_flags = buf->flags;
unsigned int old_state = txn->req.msg_state;
*/
int http_sync_res_state(struct session *s)
{
- struct buffer *buf = s->rep;
+ struct channel *buf = s->rep;
struct http_txn *txn = &s->txn;
unsigned int old_flags = buf->flags;
unsigned int old_state = txn->rsp.msg_state;
* bytes of pending data + the headers if not already done (between sol and sov).
* It eventually adjusts sol to match sov after the data in between have been sent.
*/
-int http_request_forward_body(struct session *s, struct buffer *req, int an_bit)
+int http_request_forward_body(struct session *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.req;
* when it has nothing left to do, and may remove any analyser when it wants to
* abort.
*/
-int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit)
+int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->rsp;
* and updates t->rep->analysers. It might make sense to explode it into several
* other functions. It works like process_request (see indications above).
*/
-int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, struct proxy *px)
+int http_process_res_common(struct session *t, struct channel *rep, int an_bit, struct proxy *px)
{
struct http_txn *txn = &t->txn;
struct http_msg *msg = &txn->rsp;
* bytes of pending data + the headers if not already done (between sol and sov).
* It eventually adjusts sol to match sov after the data in between have been sent.
*/
-int http_response_forward_body(struct session *s, struct buffer *res, int an_bit)
+int http_response_forward_body(struct session *s, struct channel *res, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.rsp;
* Since it can manage the switch to another backend, it updates the per-proxy
* DENY stats.
*/
-int apply_filter_to_req_headers(struct session *t, struct buffer *req, struct hdr_exp *exp)
+int apply_filter_to_req_headers(struct session *t, struct channel *req, struct hdr_exp *exp)
{
char term;
char *cur_ptr, *cur_end, *cur_next;
* Since it can manage the switch to another backend, it updates the per-proxy
* DENY stats.
*/
-int apply_filter_to_req_line(struct session *t, struct buffer *req, struct hdr_exp *exp)
+int apply_filter_to_req_line(struct session *t, struct channel *req, struct hdr_exp *exp)
{
char term;
char *cur_ptr, *cur_end;
* unparsable request. Since it can manage the switch to another backend, it
* updates the per-proxy DENY stats.
*/
-int apply_filters_to_request(struct session *s, struct buffer *req, struct proxy *px)
+int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct hdr_exp *exp;
* - there are non-space chars before <from> ;
* - there is a CR/LF at or after <next>.
*/
-int del_hdr_value(struct buffer *buf, char **from, char *next)
+int del_hdr_value(struct channel *buf, char **from, char *next)
{
char *prev = *from;
* of the multiple very crappy and ambiguous syntaxes we have to support. it
* highly recommended not to touch this part without a good reason !
*/
-void manage_client_side_cookies(struct session *t, struct buffer *req)
+void manage_client_side_cookies(struct session *t, struct channel *req)
{
struct http_txn *txn = &t->txn;
int preserve_hdr;
/* Iterate the same filter through all response headers contained in <rtr>.
* Returns 1 if this filter can be stopped upon return, otherwise 0.
*/
-int apply_filter_to_resp_headers(struct session *t, struct buffer *rtr, struct hdr_exp *exp)
+int apply_filter_to_resp_headers(struct session *t, struct channel *rtr, struct hdr_exp *exp)
{
char term;
char *cur_ptr, *cur_end, *cur_next;
* Returns 0 if nothing has been done, 1 if the filter has been applied,
* or -1 if a replacement resulted in an invalid status line.
*/
-int apply_filter_to_sts_line(struct session *t, struct buffer *rtr, struct hdr_exp *exp)
+int apply_filter_to_sts_line(struct session *t, struct channel *rtr, struct hdr_exp *exp)
{
char term;
char *cur_ptr, *cur_end;
* Returns 0 if everything is alright, or -1 in case a replacement lead to an
* unparsable response.
*/
-int apply_filters_to_response(struct session *s, struct buffer *rtr, struct proxy *px)
+int apply_filters_to_response(struct session *s, struct channel *rtr, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct hdr_exp *exp;
* desirable to call it only when needed. This function is also used when we
* just need to know if there is a cookie (eg: for check-cache).
*/
-void manage_server_side_cookies(struct session *t, struct buffer *res)
+void manage_server_side_cookies(struct session *t, struct channel *res)
{
struct http_txn *txn = &t->txn;
struct server *srv;
/*
* Check if response is cacheable or not. Updates t->flags.
*/
-void check_response_for_cacheability(struct session *t, struct buffer *rtr)
+void check_response_for_cacheability(struct session *t, struct channel *rtr)
{
struct http_txn *txn = &t->txn;
char *p1, *p2;
struct http_msg *msg,
int state, struct proxy *other_end)
{
- struct buffer *buf = msg->buf;
+ struct channel *buf = msg->buf;
int len1, len2;
es->len = MIN(buf->i, sizeof(es->buf));
* function may be called for frontend rules and backend rules. It only relies
* on the backend pointer so this works for both cases.
*/
-int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit)
+int tcp_inspect_request(struct session *s, struct channel *req, int an_bit)
{
struct tcp_rule *rule;
struct stksess *ts;
* response. It relies on buffers flags, and updates s->rep->analysers. The
* function may be called for backend rules.
*/
-int tcp_inspect_response(struct session *s, struct buffer *rep, int an_bit)
+int tcp_inspect_response(struct session *s, struct channel *rep, int an_bit)
{
struct tcp_rule *rule;
int partial;
unsigned int len_size = arg_p[1].data.uint;
unsigned int buf_offset;
unsigned int buf_size = 0;
- struct buffer *b;
+ struct channel *b;
int i;
/* Format is (len offset, len size, buf offset) or (len offset, len size) */
{
unsigned int buf_offset = arg_p[0].data.uint;
unsigned int buf_size = arg_p[1].data.uint;
- struct buffer *b;
+ struct channel *b;
if (!l4)
return 0;
*/
static int sess_update_st_con_tcp(struct session *s, struct stream_interface *si)
{
- struct buffer *req = si->ob;
- struct buffer *rep = si->ib;
+ struct channel *req = si->ob;
+ struct channel *rep = si->ib;
/* If we got an error, or if nothing happened and the connection timed
* out, we must give up. The CER state handler will take care of retry
*/
static void sess_establish(struct session *s, struct stream_interface *si)
{
- struct buffer *req = si->ob;
- struct buffer *rep = si->ib;
+ struct channel *req = si->ob;
+ struct channel *rep = si->ib;
if (target_srv(&s->target))
health_adjust(target_srv(&s->target), HANA_STATUS_L4_OK);
* It returns 1 if the processing can continue on next analysers, or zero if it
* either needs more data or wants to immediately abort the request.
*/
-static int process_switching_rules(struct session *s, struct buffer *req, int an_bit)
+static int process_switching_rules(struct session *s, struct channel *req, int an_bit)
{
struct persist_rule *prst_rule;
* it then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_server_rules(struct session *s, struct buffer *req, int an_bit)
+static int process_server_rules(struct session *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
struct server_rule *rule;
* it then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_sticking_rules(struct session *s, struct buffer *req, int an_bit)
+static int process_sticking_rules(struct session *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
struct sticking_rule *rule;
* then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_store_rules(struct session *s, struct buffer *rep, int an_bit)
+static int process_store_rules(struct session *s, struct channel *rep, int an_bit)
{
struct proxy *px = s->be;
struct sticking_rule *rule;
* This function automatically allocates a pipe from the pipe pool. It also
* carefully ensures to clear b->pipe whenever it leaves the pipe empty.
*/
-static int sock_raw_splice_in(struct buffer *b, struct stream_interface *si)
+static int sock_raw_splice_in(struct channel *b, struct stream_interface *si)
{
static int splice_detects_close;
int fd = si_fd(si);
{
int fd = conn->t.sock.fd;
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
- struct buffer *b = si->ib;
+ struct channel *b = si->ib;
int ret, max, cur_read;
int read_poll = MAX_READ_POLL_LOOPS;
static int sock_raw_write_loop(struct connection *conn)
{
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
- struct buffer *b = si->ob;
+ struct channel *b = si->ob;
int write_poll = MAX_WRITE_POLL_LOOPS;
int ret, max;
/* default chk_rcv function for scheduled tasks */
static void stream_int_chk_rcv(struct stream_interface *si)
{
- struct buffer *ib = si->ib;
+ struct channel *ib = si->ib;
DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n",
__FUNCTION__,
/* default chk_snd function for scheduled tasks */
static void stream_int_chk_snd(struct stream_interface *si)
{
- struct buffer *ob = si->ob;
+ struct channel *ob = si->ob;
DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n",
__FUNCTION__,
{
int fd = conn->t.sock.fd;
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
- struct buffer *b = si->ob;
+ struct channel *b = si->ob;
/* we might have been called just after an asynchronous shutw */
if (b->flags & BF_SHUTW)
*/
void stream_int_update_conn(struct stream_interface *si)
{
- struct buffer *ib = si->ib;
- struct buffer *ob = si->ob;
+ struct channel *ib = si->ib;
+ struct channel *ob = si->ob;
if (si->conn.flags & CO_FL_HANDSHAKE) {
/* a handshake is in progress */
*/
void stream_int_chk_rcv_conn(struct stream_interface *si)
{
- struct buffer *ib = si->ib;
+ struct channel *ib = si->ib;
if (unlikely(si->state != SI_ST_EST || (ib->flags & BF_SHUTR)))
return;
*/
void stream_int_chk_snd_conn(struct stream_interface *si)
{
- struct buffer *ob = si->ob;
+ struct channel *ob = si->ob;
if (unlikely(si->state != SI_ST_EST || (ob->flags & BF_SHUTW)))
return;
void si_conn_send_cb(struct connection *conn)
{
struct stream_interface *si = container_of(conn, struct stream_interface, conn);
- struct buffer *b = si->ob;
+ struct channel *b = si->ob;
if (conn->flags & CO_FL_ERROR)
goto out_error;