From b04f434f693e49c65197c2c1bcee2d5fd66f12d2 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 29 Sep 2019 21:54:04 +0200 Subject: TunnelEncaps: Improve format function --- proto/bgp/attrs.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'proto') diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index c6317892..f8153dd0 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -21,6 +21,7 @@ #include "lib/resource.h" #include "lib/string.h" #include "lib/unaligned.h" +#include "lib/tunnel_encaps.h" #include "bgp.h" @@ -919,23 +920,9 @@ bgp_format_tunnel_encap(const eattr *a, byte *buf, uint size) { char *pos = buf; - if (a->u.ptr->length == 0) - { - bsprintf(pos, ""); - return; - } - - for (uint i = 0; i < a->u.ptr->length; i++) - { - if (size < 4) - { - bsprintf(pos, "..."); - return; - } - - uint l = bsprintf(pos, "%02x ", a->u.ptr->data[i]); + int l = format_tunnel_encap(a, pos, size); + if (l > 0) ADVANCE(pos, size, l); - } } static void -- cgit v1.2.3