diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2016-11-24 20:52:14 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2016-11-24 20:52:14 +0000 |
commit | 286f6f7995a516bb50a3a69c4817ae24be1f0d59 (patch) | |
tree | d1b92ba350613457624a7f01b3063674ea4a961a | |
parent | 7cc247f2eff7d7ef55b01163e2b84d8961de9917 (diff) |
add an io_fileno() accessor
ok gilles@
-rw-r--r-- | usr.sbin/smtpd/ioev.c | 8 | ||||
-rw-r--r-- | usr.sbin/smtpd/ioev.h | 3 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta_session.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 6 |
4 files changed, 15 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c index 0ff8218e896..503796c6cd5 100644 --- a/usr.sbin/smtpd/ioev.c +++ b/usr.sbin/smtpd/ioev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ioev.c,v 1.34 2016/11/24 20:44:04 eric Exp $ */ +/* $OpenBSD: ioev.c,v 1.35 2016/11/24 20:52:13 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -375,6 +375,12 @@ io_ssl(struct io *io) return io->ssl; } +int +io_fileno(struct io *io) +{ + return io->sock; +} + /* * Buffered output functions */ diff --git a/usr.sbin/smtpd/ioev.h b/usr.sbin/smtpd/ioev.h index 21f3e7b3f17..b12a9ed853d 100644 --- a/usr.sbin/smtpd/ioev.h +++ b/usr.sbin/smtpd/ioev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ioev.h,v 1.12 2016/11/24 20:44:04 eric Exp $ */ +/* $OpenBSD: ioev.h,v 1.13 2016/11/24 20:52:13 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -71,6 +71,7 @@ const char* io_strio(struct io *); const char* io_strevent(int); const char* io_error(struct io *); void* io_ssl(struct io *); +int io_fileno(struct io *); /* Buffered output functions */ int io_write(struct io *, const void *, size_t); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index fd060884839..291b1f6c583 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.92 2016/11/24 20:44:04 eric Exp $ */ +/* $OpenBSD: mta_session.c,v 1.93 2016/11/24 20:52:13 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -1032,7 +1032,7 @@ mta_response(struct mta_session *s, char *line) */ sa_len = sizeof(ss); sa = (struct sockaddr *)&ss; - if (getsockname(s->io.sock, sa, &sa_len) < 0) + if (getsockname(io_fileno(&s->io), sa, &sa_len) < 0) mta_delivery_log(e, NULL, buf, delivery, line); else mta_delivery_log(e, sa_to_text(sa), @@ -1432,7 +1432,7 @@ mta_flush_task(struct mta_session *s, int delivery, const char *error, size_t co */ sa = (struct sockaddr *)&ss; sa_len = sizeof(ss); - if (getsockname(s->io.sock, sa, &sa_len) < 0) + if (getsockname(io_fileno(&s->io), sa, &sa_len) < 0) mta_delivery_log(e, NULL, relay, delivery, error); else mta_delivery_log(e, sa_to_text(sa), diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 4377ef4760a..27097495d36 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.298 2016/11/24 20:44:04 eric Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.299 2016/11/24 20:52:13 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -2075,7 +2075,7 @@ smtp_lookup_servername(struct smtp_session *s) if (s->listener->hostnametable[0]) { sa_len = sizeof(ss); sa = (struct sockaddr *)&ss; - if (getsockname(s->io.sock, sa, &sa_len) == -1) { + if (getsockname(io_fileno(&s->io), sa, &sa_len) == -1) { log_warn("warn: getsockname()"); } else { @@ -2103,7 +2103,7 @@ smtp_connected(struct smtp_session *s) s->id, ss_to_text(&s->ss), s->hostname); sl = sizeof(ss); - if (getsockname(s->io.sock, (struct sockaddr*)&ss, &sl) == -1) { + if (getsockname(io_fileno(&s->io), (struct sockaddr*)&ss, &sl) == -1) { smtp_free(s, strerror(errno)); return; } |