summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/relay.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/relayd/relay.c')
-rw-r--r--usr.sbin/relayd/relay.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index b56d90728a4..cc821a35587 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.160 2012/12/18 15:58:25 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.161 2013/01/17 20:34:18 bluhm Exp $ */
/*
* Copyright (c) 2006 - 2012 Reyk Floeter <reyk@openbsd.org>
@@ -607,8 +607,8 @@ relay_socket_listen(struct sockaddr_storage *ss, in_port_t port,
void
relay_connected(int fd, short sig, void *arg)
{
- struct rsession *con = (struct rsession *)arg;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct rsession *con = arg;
+ struct relay *rlay = con->se_relay;
struct protocol *proto = rlay->rl_proto;
evbuffercb outrd = relay_read;
evbuffercb outwr = relay_write;
@@ -689,7 +689,7 @@ relay_connected(int fd, short sig, void *arg)
void
relay_input(struct rsession *con)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct protocol *proto = rlay->rl_proto;
evbuffercb inrd = relay_read;
evbuffercb inwr = relay_write;
@@ -739,7 +739,7 @@ relay_input(struct rsession *con)
void
relay_write(struct bufferevent *bev, void *arg)
{
- struct ctl_relay_event *cre = (struct ctl_relay_event *)arg;
+ struct ctl_relay_event *cre = arg;
struct rsession *con = cre->con;
if (gettimeofday(&con->se_tv_last, NULL) == -1)
con->se_done = 1;
@@ -768,7 +768,7 @@ relay_dump(struct ctl_relay_event *cre, const void *buf, size_t len)
void
relay_read(struct bufferevent *bev, void *arg)
{
- struct ctl_relay_event *cre = (struct ctl_relay_event *)arg;
+ struct ctl_relay_event *cre = arg;
struct rsession *con = cre->con;
struct evbuffer *src = EVBUFFER_INPUT(bev);
@@ -814,7 +814,7 @@ int
relay_splice(struct ctl_relay_event *cre)
{
struct rsession *con = cre->con;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct protocol *proto = rlay->rl_proto;
struct splice sp;
@@ -862,7 +862,7 @@ relay_splicelen(struct ctl_relay_event *cre)
void
relay_error(struct bufferevent *bev, short error, void *arg)
{
- struct ctl_relay_event *cre = (struct ctl_relay_event *)arg;
+ struct ctl_relay_event *cre = arg;
struct rsession *con = cre->con;
struct evbuffer *dst;
@@ -925,7 +925,7 @@ relay_error(struct bufferevent *bev, short error, void *arg)
void
relay_accept(int fd, short event, void *arg)
{
- struct relay *rlay = (struct relay *)arg;
+ struct relay *rlay = arg;
struct protocol *proto = rlay->rl_proto;
struct rsession *con = NULL;
struct ctl_natlook *cnl = NULL;
@@ -1033,8 +1033,7 @@ relay_accept(int fd, short event, void *arg)
con->se_out.port == rlay->rl_conf.port)
con->se_out.ss.ss_family = AF_UNSPEC;
} else if (rlay->rl_conf.flags & F_NATLOOK) {
- if ((cnl = (struct ctl_natlook *)
- calloc(1, sizeof(struct ctl_natlook))) == NULL) {
+ if ((cnl = calloc(1, sizeof(*cnl))) == NULL) {
relay_close(con, "failed to allocate nat lookup");
return;
}
@@ -1103,7 +1102,7 @@ relay_hash_addr(struct sockaddr_storage *ss, u_int32_t p)
int
relay_from_table(struct rsession *con)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct host *host;
struct relay_table *rlt = NULL;
struct table *table = NULL;
@@ -1200,8 +1199,8 @@ relay_from_table(struct rsession *con)
void
relay_natlook(int fd, short event, void *arg)
{
- struct rsession *con = (struct rsession *)arg;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct rsession *con = arg;
+ struct relay *rlay = con->se_relay;
struct ctl_natlook *cnl = con->se_cnl;
if (cnl == NULL)
@@ -1226,7 +1225,7 @@ relay_natlook(int fd, short event, void *arg)
void
relay_session(struct rsession *con)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct ctl_relay_event *in = &con->se_in, *out = &con->se_out;
if (bcmp(&rlay->rl_conf.ss, &out->ss, sizeof(out->ss)) == 0 &&
@@ -1267,7 +1266,7 @@ relay_session(struct rsession *con)
void
relay_bindanyreq(struct rsession *con, in_port_t port, int proto)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct ctl_bindany bnd;
struct timeval tv;
@@ -1289,7 +1288,7 @@ relay_bindanyreq(struct rsession *con, in_port_t port, int proto)
void
relay_bindany(int fd, short event, void *arg)
{
- struct rsession *con = (struct rsession *)arg;
+ struct rsession *con = arg;
if (con->se_bnds == -1) {
relay_close(con, "bindany failed, invalid socket");
@@ -1303,8 +1302,8 @@ void
relay_connect_retry(int fd, short sig, void *arg)
{
struct timeval evtpause = { 1, 0 };
- struct rsession *con = (struct rsession *)arg;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct rsession *con = arg;
+ struct relay *rlay = con->se_relay;
int bnds = -1;
if (relay_inflight < 1)
@@ -1383,7 +1382,7 @@ relay_connect_retry(int fd, short sig, void *arg)
int
relay_connect(struct rsession *con)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
struct timeval evtpause = { 1, 0 };
int bnds = -1, ret;
@@ -1472,7 +1471,7 @@ void
relay_close(struct rsession *con, const char *msg)
{
char ibuf[128], obuf[128], *ptr = NULL;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
SPLAY_REMOVE(session_tree, &rlay->rl_sessions, con);
@@ -1826,7 +1825,7 @@ relay_ssl_ctx_create(struct relay *rlay)
void
relay_ssl_transaction(struct rsession *con, struct ctl_relay_event *cre)
{
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
SSL *ssl;
const SSL_METHOD *method;
void (*cb)(int, short, void *);
@@ -1874,8 +1873,8 @@ relay_ssl_transaction(struct rsession *con, struct ctl_relay_event *cre)
void
relay_ssl_accept(int fd, short event, void *arg)
{
- struct rsession *con = (struct rsession *)arg;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct rsession *con = arg;
+ struct relay *rlay = con->se_relay;
int retry_flag = 0;
int ssl_err = 0;
int ret;
@@ -1932,8 +1931,8 @@ retry:
void
relay_ssl_connect(int fd, short event, void *arg)
{
- struct rsession *con = (struct rsession *)arg;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct rsession *con = arg;
+ struct relay *rlay = con->se_relay;
int retry_flag = 0;
int ssl_err = 0;
int ret;
@@ -2004,9 +2003,9 @@ relay_ssl_readcb(int fd, short event, void *arg)
{
char rbuf[IBUF_READ_SIZE];
struct bufferevent *bufev = arg;
- struct ctl_relay_event *cre = (struct ctl_relay_event *)bufev->cbarg;
+ struct ctl_relay_event *cre = bufev->cbarg;
struct rsession *con = cre->con;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
int ret = 0, ssl_err = 0;
short what = EVBUFFER_READ;
int howmuch = IBUF_READ_SIZE;
@@ -2078,9 +2077,9 @@ void
relay_ssl_writecb(int fd, short event, void *arg)
{
struct bufferevent *bufev = arg;
- struct ctl_relay_event *cre = (struct ctl_relay_event *)bufev->cbarg;
+ struct ctl_relay_event *cre = bufev->cbarg;
struct rsession *con = cre->con;
- struct relay *rlay = (struct relay *)con->se_relay;
+ struct relay *rlay = con->se_relay;
int ret = 0, ssl_err;
short what = EVBUFFER_WRITE;
@@ -2272,7 +2271,7 @@ relay_load_file(const char *name, off_t *len)
if (fstat(fd, &st) != 0)
goto fail;
size = st.st_size;
- if ((buf = (char *)calloc(1, size + 1)) == NULL)
+ if ((buf = calloc(1, size + 1)) == NULL)
goto fail;
if (read(fd, buf, size) != size)
goto fail;
@@ -2355,7 +2354,7 @@ relay_proto_cmp(struct protonode *a, struct protonode *b)
int
relay_session_cmp(struct rsession *a, struct rsession *b)
{
- struct relay *rlay = (struct relay *)b->se_relay;
+ struct relay *rlay = b->se_relay;
struct protocol *proto = rlay->rl_proto;
if (proto != NULL && proto->cmp != NULL)