From 855110bb0b6f762ebaffa0be64a1422d8d007510 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timo=20Ter=C3=A4s?= Date: Sat, 23 May 2015 11:08:39 +0300 Subject: [PATCH] lib: make prefix2str simpler to use, and use it in zclient MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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) --- lib/prefix.h | 3 +++ lib/zclient.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) 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); } } -- 2.39.5