diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-05-08 18:21:56 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-05-08 18:21:56 +0000 |
commit | ba7241969d9dea34da5fa860599a6ed7c6522771 (patch) | |
tree | 9581d5006a1db2ac838462f29afd9ebe9e65b08d /usr.sbin/bgpd/log.c | |
parent | b593062d63e67181a24bd26fcad1712f2154772d (diff) |
provide log_sockaddr, which uses getnameinfo(), and use it in
log_conn_attempt
Diffstat (limited to 'usr.sbin/bgpd/log.c')
-rw-r--r-- | usr.sbin/bgpd/log.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c index 576d5e34092..096868191e9 100644 --- a/usr.sbin/bgpd/log.c +++ b/usr.sbin/bgpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.34 2004/04/25 22:02:55 henning Exp $ */ +/* $OpenBSD: log.c,v 1.35 2004/05/08 18:21:55 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -375,13 +375,12 @@ log_notification(const struct peer *peer, u_int8_t errcode, u_int8_t subcode, void log_conn_attempt(const struct peer *peer, struct sockaddr *sa) { - char *p, buf[NI_MAXHOST]; + char *p; + const char *b; if (peer == NULL) { /* connection from non-peer, drop */ - if (getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, - NI_NUMERICHOST)) - strlcpy(buf, "(unknown)", sizeof(buf)); - logit(LOG_INFO, "connection from non-peer %s refused", buf); + b = log_sockaddr(sa); + logit(LOG_INFO, "connection from non-peer %s refused", b); } else { p = log_fmt_peer(&peer->conf); logit(LOG_INFO, "Connection attempt from %s while session is " @@ -400,3 +399,14 @@ log_addr(const struct bgpd_addr *addr) else return (buf); } + +const char * +log_sockaddr(struct sockaddr *sa) +{ + static char buf[NI_MAXHOST]; + + if (getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST)) + return ("(unknown)"); + else + return (buf); +} |