summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-11-02 16:50:24 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-11-02 16:50:24 +0000
commit974a47072ad3b635cf9049ffe6184ef1b6cf1e4c (patch)
treee5420bc816936b27ca3cc8bacf0a66ba09a95212 /usr.sbin
parent3838ab8b046e5dfa95768d75170eb9f730754f10 (diff)
pass struct sockaddr_storage instead of ss_to_text() in reporting
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka.c11
-rw-r--r--usr.sbin/smtpd/lka_report.c14
-rw-r--r--usr.sbin/smtpd/smtp_report.c9
-rw-r--r--usr.sbin/smtpd/smtp_session.c6
-rw-r--r--usr.sbin/smtpd/smtpd.h6
5 files changed, 28 insertions, 18 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index f9f41670001..9ad4080fdaf 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.209 2018/11/01 14:48:49 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.210 2018/11/02 16:50:23 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -84,7 +84,8 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
int v;
time_t tm;
const char *command, *response;
- const char *src_addr, *dest_addr, *ciphers;
+ const char *ciphers;
+ struct sockaddr_storage ss_src, ss_dest;
if (imsg == NULL)
lka_shutdown();
@@ -406,11 +407,11 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_msg(&m, imsg);
m_get_time(&m, &tm);
m_get_id(&m, &reqid);
- m_get_string(&m, &src_addr);
- m_get_string(&m, &dest_addr);
+ m_get_sockaddr(&m, (struct sockaddr *)&ss_src);
+ m_get_sockaddr(&m, (struct sockaddr *)&ss_dest);
m_end(&m);
- lka_report_smtp_link_connect(tm, reqid, src_addr, dest_addr);
+ lka_report_smtp_link_connect(tm, reqid, &ss_src, &ss_dest);
return;
case IMSG_SMTP_REPORT_LINK_DISCONNECT:
diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c
index 18f855806c0..c8406eb2ba2 100644
--- a/usr.sbin/smtpd/lka_report.c
+++ b/usr.sbin/smtpd/lka_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_report.c,v 1.2 2018/11/02 15:56:47 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.3 2018/11/02 16:50:23 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -51,11 +51,19 @@ report_smtp_broadcast(const char *format, ...)
}
void
-lka_report_smtp_link_connect(time_t tm, uint64_t reqid, const char *src_addr, const char *dest_addr)
+lka_report_smtp_link_connect(time_t tm, uint64_t reqid,
+ const struct sockaddr_storage *ss_src,
+ const struct sockaddr_storage *ss_dest)
{
+ char src[NI_MAXHOST + 5];
+ char dest[NI_MAXHOST + 5];
+
+ (void)strlcpy(src, ss_to_text(ss_src), sizeof src);
+ (void)strlcpy(dest, ss_to_text(ss_dest), sizeof dest);
+
report_smtp_broadcast("report|smtp-in|link-connect|"
"%zd|%016"PRIx64"|%s|%s\n",
- tm, reqid, src_addr, dest_addr);
+ tm, reqid, src, dest);
}
void
diff --git a/usr.sbin/smtpd/smtp_report.c b/usr.sbin/smtpd/smtp_report.c
index 21aa671065f..60e1f011c61 100644
--- a/usr.sbin/smtpd/smtp_report.c
+++ b/usr.sbin/smtpd/smtp_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_report.c,v 1.1 2018/11/01 14:48:49 gilles Exp $ */
+/* $OpenBSD: smtp_report.c,v 1.2 2018/11/02 16:50:23 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -44,13 +44,14 @@
#include "rfc5322.h"
void
-smtp_report_link_connect(uint64_t qid, const char *src, const char *dest)
+smtp_report_link_connect(uint64_t qid, const struct sockaddr_storage *ss_src,
+ const struct sockaddr_storage *ss_dest)
{
m_create(p_lka, IMSG_SMTP_REPORT_LINK_CONNECT, 0, 0, -1);
m_add_time(p_lka, time(NULL));
m_add_id(p_lka, qid);
- m_add_string(p_lka, src);
- m_add_string(p_lka, dest);
+ m_add_sockaddr(p_lka, (const struct sockaddr *)ss_src);
+ m_add_sockaddr(p_lka, (const struct sockaddr *)ss_dest);
m_close(p_lka);
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 9f433caf4aa..fd09cd45a46 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.342 2018/11/02 16:09:57 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.343 2018/11/02 16:50:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -553,8 +553,8 @@ smtp_session(struct listener *listener, int sock,
"[hostname=%s, port=%d, tag=%s]", s, listener,
listener->hostname, ntohs(listener->port), listener->tag);
- smtp_report_link_connect(s->id, ss_to_text(&s->ss),
- ss_to_text(&s->listener->ss));
+ smtp_report_link_connect(s->id, &s->ss,
+ &s->listener->ss);
/* For local enqueueing, the hostname is already set */
if (hostname) {
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 7c97f9ce87a..82477ef3fd1 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.566 2018/11/01 14:48:49 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.567 2018/11/02 16:50:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1249,7 +1249,7 @@ struct io *lka_proc_get_io(const char *);
/* lka_report.c */
-void lka_report_smtp_link_connect(time_t, uint64_t, const char *, const char *);
+void lka_report_smtp_link_connect(time_t, uint64_t, const struct sockaddr_storage *, const struct sockaddr_storage *);
void lka_report_smtp_link_disconnect(time_t, uint64_t);
void lka_report_smtp_link_tls(time_t, uint64_t, const char *);
void lka_report_smtp_tx_begin(time_t, uint64_t);
@@ -1427,7 +1427,7 @@ void smtp_collect(void);
/* smtp_report.c */
-void smtp_report_link_connect(uint64_t, const char *, const char *);
+void smtp_report_link_connect(uint64_t, const struct sockaddr_storage *, const struct sockaddr_storage *);
void smtp_report_link_disconnect(uint64_t);
void smtp_report_link_tls(uint64_t, const char *);
void smtp_report_tx_begin(uint64_t);