bgpd: encap: extend extcommunity handling
Add code to print ENCAP communities.
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index c76f01e..5d69b42 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -643,15 +643,34 @@
/* 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)