diff options
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/buffer.c | 66 | ||||
-rw-r--r-- | usr.sbin/relayd/check_tcp.c | 22 | ||||
-rw-r--r-- | usr.sbin/relayd/imsg.c | 22 | ||||
-rw-r--r-- | usr.sbin/relayd/imsg.h | 42 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 10 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_udp.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/ssl.c | 10 |
8 files changed, 91 insertions, 91 deletions
diff --git a/usr.sbin/relayd/buffer.c b/usr.sbin/relayd/buffer.c index 512afa59022..1e6d9d43b7f 100644 --- a/usr.sbin/relayd/buffer.c +++ b/usr.sbin/relayd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.22 2009/09/15 10:54:59 jacekm Exp $ */ +/* $OpenBSD: buffer.c,v 1.23 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -28,16 +28,16 @@ #include "imsg.h" -int buf_realloc(struct buf *, size_t); -void buf_enqueue(struct msgbuf *, struct buf *); -void buf_dequeue(struct msgbuf *, struct buf *); +int ibuf_realloc(struct ibuf *, size_t); +void ibuf_enqueue(struct msgbuf *, struct ibuf *); +void ibuf_dequeue(struct msgbuf *, struct ibuf *); -struct buf * -buf_open(size_t len) +struct ibuf * +ibuf_open(size_t len) { - struct buf *buf; + struct ibuf *buf; - if ((buf = calloc(1, sizeof(struct buf))) == NULL) + if ((buf = calloc(1, sizeof(struct ibuf))) == NULL) return (NULL); if ((buf->buf = malloc(len)) == NULL) { free(buf); @@ -49,15 +49,15 @@ buf_open(size_t len) return (buf); } -struct buf * -buf_dynamic(size_t len, size_t max) +struct ibuf * +ibuf_dynamic(size_t len, size_t max) { - struct buf *buf; + struct ibuf *buf; if (max < len) return (NULL); - if ((buf = buf_open(len)) == NULL) + if ((buf = ibuf_open(len)) == NULL) return (NULL); if (max > 0) @@ -67,7 +67,7 @@ buf_dynamic(size_t len, size_t max) } int -buf_realloc(struct buf *buf, size_t len) +ibuf_realloc(struct ibuf *buf, size_t len) { u_char *b; @@ -87,10 +87,10 @@ buf_realloc(struct buf *buf, size_t len) } int -buf_add(struct buf *buf, const void *data, size_t len) +ibuf_add(struct ibuf *buf, const void *data, size_t len) { if (buf->wpos + len > buf->size) - if (buf_realloc(buf, len) == -1) + if (ibuf_realloc(buf, len) == -1) return (-1); memcpy(buf->buf + buf->wpos, data, len); @@ -99,12 +99,12 @@ buf_add(struct buf *buf, const void *data, size_t len) } void * -buf_reserve(struct buf *buf, size_t len) +ibuf_reserve(struct ibuf *buf, size_t len) { void *b; if (buf->wpos + len > buf->size) - if (buf_realloc(buf, len) == -1) + if (ibuf_realloc(buf, len) == -1) return (NULL); b = buf->buf + buf->wpos; @@ -113,7 +113,7 @@ buf_reserve(struct buf *buf, size_t len) } void * -buf_seek(struct buf *buf, size_t pos, size_t len) +ibuf_seek(struct ibuf *buf, size_t pos, size_t len) { /* only allowed to seek in already written parts */ if (pos + len > buf->wpos) @@ -123,28 +123,28 @@ buf_seek(struct buf *buf, size_t pos, size_t len) } size_t -buf_size(struct buf *buf) +ibuf_size(struct ibuf *buf) { return (buf->wpos); } size_t -buf_left(struct buf *buf) +ibuf_left(struct ibuf *buf) { return (buf->max - buf->wpos); } void -buf_close(struct msgbuf *msgbuf, struct buf *buf) +ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf) { - buf_enqueue(msgbuf, buf); + ibuf_enqueue(msgbuf, buf); } int -buf_write(struct msgbuf *msgbuf) +ibuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; - struct buf *buf; + struct ibuf *buf; unsigned int i = 0; ssize_t n; @@ -176,7 +176,7 @@ buf_write(struct msgbuf *msgbuf) } void -buf_free(struct buf *buf) +ibuf_free(struct ibuf *buf) { free(buf->buf); free(buf); @@ -193,14 +193,14 @@ msgbuf_init(struct msgbuf *msgbuf) void msgbuf_drain(struct msgbuf *msgbuf, size_t n) { - struct buf *buf, *next; + struct ibuf *buf, *next; for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0; buf = next) { next = TAILQ_NEXT(buf, entry); if (buf->rpos + n >= buf->wpos) { n -= buf->wpos - buf->rpos; - buf_dequeue(msgbuf, buf); + ibuf_dequeue(msgbuf, buf); } else { buf->rpos += n; n = 0; @@ -211,17 +211,17 @@ msgbuf_drain(struct msgbuf *msgbuf, size_t n) void msgbuf_clear(struct msgbuf *msgbuf) { - struct buf *buf; + struct ibuf *buf; while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL) - buf_dequeue(msgbuf, buf); + ibuf_dequeue(msgbuf, buf); } int msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; - struct buf *buf; + struct ibuf *buf; unsigned int i = 0; ssize_t n; struct msghdr msg; @@ -284,14 +284,14 @@ msgbuf_write(struct msgbuf *msgbuf) } void -buf_enqueue(struct msgbuf *msgbuf, struct buf *buf) +ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf) { TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry); msgbuf->queued++; } void -buf_dequeue(struct msgbuf *msgbuf, struct buf *buf) +ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf) { TAILQ_REMOVE(&msgbuf->bufs, buf, entry); @@ -299,5 +299,5 @@ buf_dequeue(struct msgbuf *msgbuf, struct buf *buf) close(buf->fd); msgbuf->queued--; - buf_free(buf); + ibuf_free(buf); } diff --git a/usr.sbin/relayd/check_tcp.c b/usr.sbin/relayd/check_tcp.c index f88fa8b295b..65c3734b913 100644 --- a/usr.sbin/relayd/check_tcp.c +++ b/usr.sbin/relayd/check_tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_tcp.c,v 1.36 2010/02/18 14:02:16 jsg Exp $ */ +/* $OpenBSD: check_tcp.c,v 1.37 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -176,7 +176,7 @@ tcp_host_up(int s, struct ctl_tcp_event *cte) return; } - if ((cte->buf = buf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) + if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) fatalx("tcp_host_up: cannot create dynamic buffer"); event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->conf.timeout, cte); @@ -211,7 +211,7 @@ tcp_send_req(int s, short event, void *arg) len -= bs; } while (len > 0); - if ((cte->buf = buf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) + if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) fatalx("tcp_send_req: cannot create dynamic buffer"); event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, tcp_read_buf, &cte->tv_start, &cte->table->conf.timeout, cte); @@ -231,7 +231,7 @@ tcp_read_buf(int s, short event, void *arg) if (event == EV_TIMEOUT) { cte->host->up = HOST_DOWN; - buf_free(cte->buf); + ibuf_free(cte->buf); close(s); hce_notify_done(cte->host, HCE_TCP_READ_TIMEOUT); return; @@ -244,7 +244,7 @@ tcp_read_buf(int s, short event, void *arg) if (errno == EAGAIN || errno == EINTR) goto retry; cte->host->up = HOST_DOWN; - buf_free(cte->buf); + ibuf_free(cte->buf); close(cte->s); hce_notify_done(cte->host, HCE_TCP_READ_FAIL); return; @@ -252,18 +252,18 @@ tcp_read_buf(int s, short event, void *arg) cte->host->up = HOST_DOWN; (void)cte->validate_close(cte); close(cte->s); - buf_free(cte->buf); + ibuf_free(cte->buf); hce_notify_done(cte->host, cte->host->he); return; default: - if (buf_add(cte->buf, rbuf, br) == -1) + if (ibuf_add(cte->buf, rbuf, br) == -1) fatal("tcp_read_buf: buf_add error"); if (cte->validate_read != NULL) { if (cte->validate_read(cte) != 0) goto retry; close(cte->s); - buf_free(cte->buf); + ibuf_free(cte->buf); hce_notify_done(cte->host, cte->host->he); return; } @@ -282,7 +282,7 @@ check_send_expect(struct ctl_tcp_event *cte) /* * ensure string is nul-terminated. */ - b = buf_reserve(cte->buf, 1); + b = ibuf_reserve(cte->buf, 1); if (b == NULL) fatal("out of memory"); *b = '\0'; @@ -314,7 +314,7 @@ check_http_code(struct ctl_tcp_event *cte) /* * ensure string is nul-terminated. */ - b = buf_reserve(cte->buf, 1); + b = ibuf_reserve(cte->buf, 1); if (b == NULL) fatal("out of memory"); *b = '\0'; @@ -366,7 +366,7 @@ check_http_digest(struct ctl_tcp_event *cte) /* * ensure string is nul-terminated. */ - b = buf_reserve(cte->buf, 1); + b = ibuf_reserve(cte->buf, 1); if (b == NULL) fatal("out of memory"); *b = '\0'; diff --git a/usr.sbin/relayd/imsg.c b/usr.sbin/relayd/imsg.c index 4110ffde012..780efebc145 100644 --- a/usr.sbin/relayd/imsg.c +++ b/usr.sbin/relayd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.30 2010/04/07 18:09:39 nicm Exp $ */ +/* $OpenBSD: imsg.c,v 1.31 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -135,7 +135,7 @@ int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, pid_t pid, int fd, void *data, u_int16_t datalen) { - struct buf *wbuf; + struct ibuf *wbuf; if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL) return (-1); @@ -154,7 +154,7 @@ int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, pid_t pid, int fd, const struct iovec *iov, int iovcnt) { - struct buf *wbuf; + struct ibuf *wbuf; int i, datalen = 0; for (i = 0; i < iovcnt; i++) @@ -175,11 +175,11 @@ imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, } /* ARGSUSED */ -struct buf * +struct ibuf * imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, pid_t pid, u_int16_t datalen) { - struct buf *wbuf; + struct ibuf *wbuf; struct imsg_hdr hdr; datalen += IMSG_HEADER_SIZE; @@ -193,7 +193,7 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, hdr.peerid = peerid; if ((hdr.pid = pid) == 0) hdr.pid = ibuf->pid; - if ((wbuf = buf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) { + if ((wbuf = ibuf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) { return (NULL); } if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1) @@ -203,18 +203,18 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid, } int -imsg_add(struct buf *msg, void *data, u_int16_t datalen) +imsg_add(struct ibuf *msg, void *data, u_int16_t datalen) { if (datalen) - if (buf_add(msg, data, datalen) == -1) { - buf_free(msg); + if (ibuf_add(msg, data, datalen) == -1) { + ibuf_free(msg); return (-1); } return (datalen); } void -imsg_close(struct imsgbuf *ibuf, struct buf *msg) +imsg_close(struct imsgbuf *ibuf, struct ibuf *msg) { struct imsg_hdr *hdr; @@ -226,7 +226,7 @@ imsg_close(struct imsgbuf *ibuf, struct buf *msg) hdr->len = (u_int16_t)msg->wpos; - buf_close(&ibuf->w, msg); + ibuf_close(&ibuf->w, msg); } void diff --git a/usr.sbin/relayd/imsg.h b/usr.sbin/relayd/imsg.h index 983d9205d93..ba4c6863078 100644 --- a/usr.sbin/relayd/imsg.h +++ b/usr.sbin/relayd/imsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.h,v 1.14 2010/04/27 21:04:04 nicm Exp $ */ +/* $OpenBSD: imsg.h,v 1.15 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -18,12 +18,12 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define READ_BUF_SIZE 65535 +#define IBUF_READ_SIZE 65535 #define IMSG_HEADER_SIZE sizeof(struct imsg_hdr) #define MAX_IMSGSIZE 16384 -struct buf { - TAILQ_ENTRY(buf) entry; +struct ibuf { + TAILQ_ENTRY(ibuf) entry; u_char *buf; size_t size; size_t max; @@ -33,13 +33,13 @@ struct buf { }; struct msgbuf { - TAILQ_HEAD(, buf) bufs; + TAILQ_HEAD(, ibuf) bufs; u_int32_t queued; int fd; }; -struct buf_read { - u_char buf[READ_BUF_SIZE]; +struct ibuf_read { + u_char buf[IBUF_READ_SIZE]; u_char *rptr; size_t wpos; }; @@ -51,7 +51,7 @@ struct imsg_fd { struct imsgbuf { TAILQ_HEAD(, imsg_fd) fds; - struct buf_read r; + struct ibuf_read r; struct msgbuf w; int fd; pid_t pid; @@ -75,16 +75,16 @@ struct imsg { /* buffer.c */ -struct buf *buf_open(size_t); -struct buf *buf_dynamic(size_t, size_t); -int buf_add(struct buf *, const void *, size_t); -void *buf_reserve(struct buf *, size_t); -void *buf_seek(struct buf *, size_t, size_t); -size_t buf_size(struct buf *); -size_t buf_left(struct buf *); -void buf_close(struct msgbuf *, struct buf *); -int buf_write(struct msgbuf *); -void buf_free(struct buf *); +struct ibuf *ibuf_open(size_t); +struct ibuf *ibuf_dynamic(size_t, size_t); +int ibuf_add(struct ibuf *, const void *, size_t); +void *ibuf_reserve(struct ibuf *, size_t); +void *ibuf_seek(struct ibuf *, size_t, size_t); +size_t ibuf_size(struct ibuf *); +size_t ibuf_left(struct ibuf *); +void ibuf_close(struct msgbuf *, struct ibuf *); +int ibuf_write(struct msgbuf *); +void ibuf_free(struct ibuf *); void msgbuf_init(struct msgbuf *); void msgbuf_clear(struct msgbuf *); int msgbuf_write(struct msgbuf *); @@ -98,10 +98,10 @@ int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, void *, u_int16_t); int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int, const struct iovec *, int); -struct buf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, +struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, u_int16_t); -int imsg_add(struct buf *, void *, u_int16_t); -void imsg_close(struct imsgbuf *, struct buf *); +int imsg_add(struct ibuf *, void *, u_int16_t); +void imsg_close(struct imsgbuf *, struct ibuf *); void imsg_free(struct imsg *); int imsg_flush(struct imsgbuf *); void imsg_clear(struct imsgbuf *); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 751c35d81e5..a0562187c16 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.120 2010/05/14 11:13:36 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.121 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -928,7 +928,7 @@ relay_resolve(struct ctl_relay_event *cre, struct protonode *proot, struct protonode *pn) { struct rsession *con = (struct rsession *)cre->con; - char buf[READ_BUF_SIZE], *ptr; + char buf[IBUF_READ_SIZE], *ptr; int id; if (pn->mark && (pn->mark != con->se_mark)) @@ -1072,7 +1072,7 @@ relay_handle_http(struct ctl_relay_event *cre, struct protonode *proot, struct protonode *pn, struct protonode *pk, int header) { struct rsession *con = (struct rsession *)cre->con; - char buf[READ_BUF_SIZE], *ptr; + char buf[IBUF_READ_SIZE], *ptr; int ret = PN_DROP, mark = 0; struct protonode *next; @@ -2878,8 +2878,8 @@ relay_ssl_readcb(int fd, short event, void *arg) int ret = 0, ssl_err = 0; short what = EVBUFFER_READ; size_t len; - char rbuf[READ_BUF_SIZE]; - int howmuch = READ_BUF_SIZE; + char rbuf[IBUF_READ_SIZE]; + int howmuch = IBUF_READ_SIZE; if (event == EV_TIMEOUT) { what |= EVBUFFER_TIMEOUT; diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c index 9f75de248f9..45af8476daf 100644 --- a/usr.sbin/relayd/relay_udp.c +++ b/usr.sbin/relayd/relay_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_udp.c,v 1.21 2009/08/07 11:21:53 reyk Exp $ */ +/* $OpenBSD: relay_udp.c,v 1.22 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -178,7 +178,7 @@ relay_udp_response(int fd, short sig, void *arg) struct protocol *proto = rlay->rl_proto; void *priv = NULL; struct sockaddr_storage ss; - u_int8_t buf[READ_BUF_SIZE]; + u_int8_t buf[IBUF_READ_SIZE]; ssize_t len; socklen_t slen; @@ -216,7 +216,7 @@ relay_udp_server(int fd, short sig, void *arg) socklen_t slen; struct timeval tv; struct sockaddr_storage ss; - u_int8_t buf[READ_BUF_SIZE]; + u_int8_t buf[IBUF_READ_SIZE]; void *priv = NULL; ssize_t len; diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 24c86bf865b..21e3833cf05 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.135 2010/05/14 11:13:36 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.136 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -116,7 +116,7 @@ struct ctl_icmp_event { struct ctl_tcp_event { int s; char *req; - struct buf *buf; + struct ibuf *buf; struct host *host; struct table *table; struct timeval tv_start; diff --git a/usr.sbin/relayd/ssl.c b/usr.sbin/relayd/ssl.c index 9f4081d551a..6688b2fdec8 100644 --- a/usr.sbin/relayd/ssl.c +++ b/usr.sbin/relayd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.15 2009/06/04 13:46:07 reyk Exp $ */ +/* $OpenBSD: ssl.c,v 1.16 2010/05/26 13:56:08 nicm Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -91,7 +91,7 @@ ssl_read(int s, short event, void *arg) } return; } - if (buf_add(cte->buf, rbuf, ret) == -1) + if (ibuf_add(cte->buf, rbuf, ret) == -1) fatal("ssl_read: buf_add error"); if (cte->validate_read != NULL) { if (cte->validate_read(cte) != 0) @@ -145,7 +145,7 @@ ssl_write(int s, short event, void *arg) return; } } - if ((cte->buf = buf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) + if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) fatalx("ssl_write: cannot create dynamic buffer"); event_again(&cte->ev, s, EV_TIMEOUT|EV_READ, ssl_read, @@ -204,7 +204,7 @@ ssl_connect(int s, short event, void *arg) return; } - if ((cte->buf = buf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) + if ((cte->buf = ibuf_dynamic(SMALL_READ_BUF_SIZE, UINT_MAX)) == NULL) fatalx("ssl_connect: cannot create dynamic buffer"); event_again(&cte->ev, cte->s, EV_TIMEOUT|EV_READ, ssl_read, &cte->tv_start, &cte->table->conf.timeout, cte); @@ -224,7 +224,7 @@ ssl_cleanup(struct ctl_tcp_event *cte) SSL_clear(cte->ssl); } if (cte->buf != NULL) - buf_free(cte->buf); + ibuf_free(cte->buf); } void |