From a5d98a24451f610e348b4512879995b924c3d6ed Mon Sep 17 00:00:00 2001 From: job Date: Thu, 17 Jun 2021 15:59:23 +0000 Subject: [PATCH] Add simple BGP Enhanced Route Refresh Message decoding seems OK claudio@ --- usr.sbin/tcpdump/print-bgp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c index 8a0f1699ba1..2b09c940fac 100644 --- a/usr.sbin/tcpdump/print-bgp.c +++ b/usr.sbin/tcpdump/print-bgp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-bgp.c,v 1.29 2019/07/03 03:24:03 deraadt Exp $ */ +/* $OpenBSD: print-bgp.c,v 1.30 2021/06/17 15:59:23 job Exp $ */ /* * Copyright (C) 1999 WIDE Project. @@ -97,7 +97,7 @@ struct bgp_route_refresh { u_int16_t len; u_int8_t type; u_int8_t afi[2]; /* unaligned; should be u_int16_t */ - u_int8_t res; + u_int8_t subtype; u_int8_t safi; }; #define BGP_ROUTE_REFRESH_SIZE 23 @@ -189,6 +189,7 @@ static const char *bgp_capcode[] = { /* 67: [Chen] */ "DYNAMIC_CAPABILITY", /* 68: [Appanna] */ "MULTISESSION", /* 69: [draft-ietf-idr-add-paths] */ "ADD-PATH", + /* 70: RFC7313 */ "ENHANCED_ROUTE_REFRESH" }; #define bgp_capcode(x) \ @@ -199,7 +200,7 @@ static const char *bgpnotify_major[] = { NULL, "Message Header Error", "OPEN Message Error", "UPDATE Message Error", "Hold Timer Expired", "Finite State Machine Error", - "Cease", "Capability Message Error", + "Cease", "ROUTE_REFRESH Message Error", }; #define bgp_notify_major(x) \ num_or_str(bgpnotify_major, \ @@ -323,6 +324,11 @@ static const char *afnumber[] = AFNUM_NAME_STR; num_or_str(afnumber, \ sizeof(afnumber)/sizeof(afnumber[0]), (x))) +static const char *refreshtype[] = { + "Request", "BoRR", "EoRR" +}; +#define refresh_subtype(x) \ + num_or_str(refreshtype, sizeof(refreshtype)/sizeof(refreshtype[0]), (x)) static const char * num_or_str(const char **table, size_t siz, int value) @@ -1069,7 +1075,8 @@ bgp_route_refresh_print(const u_char *dat, int length) bgp_route_refresh_header = (const struct bgp_route_refresh *)dat; - printf(" (%s %s)", + printf(" %s (%s %s)", + refresh_subtype(bgp_route_refresh_header->subtype), af_name(EXTRACT_16BITS(&bgp_route_refresh_header->afi)), bgp_attr_nlri_safi(bgp_route_refresh_header->safi)); -- 2.20.1