From ff2310ce3662eefa6a565ec5f53e8ca42baf7e60 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Fri, 22 Mar 2024 07:19:29 +0000 Subject: Rework parse_notification() to use the ibuf API for everything. While there fix the RFC5492 handling of ERR_OPEN_CAPA (the current code has the logic inversed). ERR_OPEN_CAPA is there to signal that a needed capability is missing in our OPEN message. Just add the handling of ERR_OPEN_CAPA to log_notification(). Also rework the handling of the shutdown reason and move the printing into log_notification(). OK tb@ --- usr.sbin/bgpd/util.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'usr.sbin/bgpd/util.c') diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c index db4f5e75765..cdbcc576d2b 100644 --- a/usr.sbin/bgpd/util.c +++ b/usr.sbin/bgpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.83 2024/03/20 09:35:46 claudio Exp $ */ +/* $OpenBSD: util.c,v 1.84 2024/03/22 07:19:28 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -309,6 +309,32 @@ log_policy(enum role role) } } +const char * +log_capability(uint8_t capa) +{ + static char buf[20]; + + switch (capa) { + case CAPA_MP: + return "Multiprotocol Extensions"; + case CAPA_REFRESH: + return "Route Refresh"; + case CAPA_ROLE: + return "BGP Role"; + case CAPA_RESTART: + return "Graceful Restart"; + case CAPA_AS4BYTE: + return "4-octet AS number"; + case CAPA_ADD_PATH: + return "ADD-PATH"; + case CAPA_ENHANCED_RR: + return "Enhanced Route Refresh"; + default: + snprintf(buf, sizeof(buf), "unknown %u", capa); + return buf; + } +} + static const char * aspath_delim(uint8_t seg_type, int closing) { -- cgit v1.2.3