summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/log.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-25 07:16:25 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-25 07:16:25 +0000
commit37c92f570b0006ae5ef608e55d28d1b71232c851 (patch)
treef74f02c9ddeef9c1db5ab08ae2446b5214bca6e5 /usr.sbin/bgpd/log.c
parent02e4ba579e5d3a5e96773d05e9ea6941ea48bf83 (diff)
add "neighbor cloning", allowing you to specify a prefix and prefixlength
instead of the neighbor's IP address. WHen a connection comes in matching that mask we clone the neighbor spec. IPv6 match code by itojun, rde feeding by claudio, ok claudio
Diffstat (limited to 'usr.sbin/bgpd/log.c')
-rw-r--r--usr.sbin/bgpd/log.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c
index 3575d886fd3..ad0daf325a8 100644
--- a/usr.sbin/bgpd/log.c
+++ b/usr.sbin/bgpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.32 2004/04/25 01:52:11 henning Exp $ */
+/* $OpenBSD: log.c,v 1.33 2004/04/25 07:16:24 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -110,17 +110,27 @@ char *
log_fmt_peer(const struct peer_config *peer)
{
const char *ip;
- char *pfmt;
+ char *pfmt, *p;
ip = log_addr(&peer->remote_addr);
+ if ((peer->remote_addr.af == AF_INET && peer->remote_masklen != 32) ||
+ (peer->remote_addr.af == AF_INET6 && peer->remote_masklen != 128)) {
+ if (asprintf(&p, "%s/%u", ip, peer->remote_masklen) == -1)
+ fatal(NULL);
+ } else {
+ if((p = strdup(ip)) == NULL)
+ fatal(NULL);
+ }
+
if (peer->descr[0]) {
- if (asprintf(&pfmt, "neighbor %s (%s)", ip, peer->descr) ==
+ if (asprintf(&pfmt, "neighbor %s (%s)", p, peer->descr) ==
-1)
fatal(NULL);
} else {
- if (asprintf(&pfmt, "neighbor %s", ip) == -1)
+ if (asprintf(&pfmt, "neighbor %s", p) == -1)
fatal(NULL);
}
+ free(p);
return (pfmt);
}
@@ -365,8 +375,7 @@ 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[48];
-
+ char *p, buf[NI_MAXHOST];
if (peer == NULL) { /* connection from non-peer, drop */
if (getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0,