From: Lou Berger Date: Tue, 12 Jan 2016 18:42:00 +0000 (-0500) Subject: bgpd: encap: extend extcommunity handling X-Git-Tag: frr-2.0-rc1~689 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0014c3011f59c0bb6fce4880ce6c243e9b11c069;p=matthieu%2Ffrr.git bgpd: encap: extend extcommunity handling Add code to print ENCAP communities. Signed-off-by: Lou Berger Signed-off-by: David Lamparter (cherry picked from commit 5a81fc9ae610ff343902ebabc12237d6e40d91cb) --- diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index f9f11866c8..b60cbd0854 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -649,15 +649,34 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format) /* High-order octet of type. */ encode = *pnt++; - if (encode != ECOMMUNITY_ENCODE_AS && encode != ECOMMUNITY_ENCODE_IP - && encode != ECOMMUNITY_ENCODE_AS4) - { - len = sprintf (str_buf + str_pnt, "?"); - str_pnt += len; - first = 0; - continue; - } - + + switch (encode) + { + case ECOMMUNITY_ENCODE_AS: + case ECOMMUNITY_ENCODE_IP: + case ECOMMUNITY_ENCODE_AS4: + break; + + case ECOMMUNITY_ENCODE_OPAQUE: + if (*pnt == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP) + { + uint16_t tunneltype; + memcpy (&tunneltype, pnt + 5, 2); + tunneltype = ntohs(tunneltype); + len = sprintf (str_buf + str_pnt, "ET:%d", tunneltype); + str_pnt += len; + first = 0; + continue; + } + /* fall through */ + + default: + len = sprintf (str_buf + str_pnt, "?"); + str_pnt += len; + first = 0; + continue; + } + /* Low-order octet of type. */ type = *pnt++; if (type != ECOMMUNITY_ROUTE_TARGET && type != ECOMMUNITY_SITE_ORIGIN) diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 92affccca4..993fd5acfd 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -25,11 +25,15 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define ECOMMUNITY_ENCODE_AS 0x00 #define ECOMMUNITY_ENCODE_IP 0x01 #define ECOMMUNITY_ENCODE_AS4 0x02 +#define ECOMMUNITY_ENCODE_OPAQUE 0x03 -/* Low-order octet of the Extended Communityes type field. */ +/* Low-order octet of the Extended Communities type field. */ #define ECOMMUNITY_ROUTE_TARGET 0x02 #define ECOMMUNITY_SITE_ORIGIN 0x03 +/* Low-order octet of the Extended Communities type field for OPAQUE types */ +#define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c + /* Extended communities attribute string format. */ #define ECOMMUNITY_FORMAT_ROUTE_MAP 0 #define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1