From: Timo Teräs Date: Sat, 23 May 2015 08:08:39 +0000 (+0300) Subject: lib: make prefix2str simpler to use, and use it in zclient X-Git-Tag: frr-2.0-rc1~550^2~16 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=855110bb0b6f762ebaffa0be64a1422d8d007510;p=matthieu%2Ffrr.git lib: make prefix2str simpler to use, and use it in zclient Returning the buffer allows using it in the logging functions in easier way. This also makes the API consistent with sockunion. Add also PREFIX_STRLEN to be the generic buffer length required for any prefix string representation. Signed-off-by: Timo Teräs Signed-off-by: David Lamparter (cherry picked from commit 41eb9a4305fbcb206c900a18af7df7115d857d60) --- diff --git a/lib/prefix.h b/lib/prefix.h index 6be20de691..39c2b62019 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -129,6 +129,9 @@ union prefix46constptr #define INET6_BUFSIZ 51 #endif /* INET6_BUFSIZ */ +/* Maximum prefix string length (IPv6) */ +#define PREFIX_STRLEN 51 + /* Max bit/byte length of IPv4 address. */ #define IPV4_MAX_BYTELEN 4 #define IPV4_MAX_BITLEN 32 diff --git a/lib/zclient.c b/lib/zclient.c index ea663329ca..b6d3aa9fed 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1181,11 +1181,11 @@ zebra_interface_address_read (int type, struct stream *s, vrf_id_t vrf_id) else if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) { /* carp interfaces on OpenBSD with 0.0.0.0/0 as "peer" */ - char buf[PREFIX2STR_BUFFER]; - prefix2str (ifc->address, buf, sizeof(buf)); + char buf[PREFIX_STRLEN]; zlog_warn("warning: interface %s address %s " "with peer flag set, but no peer address!", - ifp->name, buf); + ifp->name, + prefix2str (ifc->address, buf, sizeof buf)); UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); } }